Changeset 85374 in webkit
- Timestamp:
- Apr 29, 2011 5:23:01 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r85373 r85374 1 2011-04-29 Emil Eklund <eae@chromium.org> 2 3 Reviewed by Tony Chang. 4 5 Setting outerHTML should merge text nodes 6 https://bugs.webkit.org/show_bug.cgi?id=52686 7 8 Add test for setting Element.outerHTML. 9 10 * fast/dom/set-outer-html-expected.txt: Added. 11 * fast/dom/set-outer-html.html: Added. 12 1 13 2011-04-29 Emil A Eklund <eae@chromium.org> 2 14 -
trunk/Source/WebCore/ChangeLog
r85373 r85374 1 2011-04-29 Emil Eklund <eae@chromium.org> 2 3 Reviewed by Tony Chang. 4 5 Setting outerHTML should merge text nodes 6 https://bugs.webkit.org/show_bug.cgi?id=52686 7 8 When setting outerHTML adjacent text nodes should be merged. This matches 9 the behavior of outerText and the IE implementation of outerHTML. 10 11 Test: fast/dom/set-outer-html.html 12 13 * html/HTMLElement.cpp: 14 (WebCore::mergeWithNextTextNode): Move function to before setOuterHTML. 15 (WebCore::HTMLElement::setOuterHTML): Merge adjacent text nodes after replacing the element. 16 1 17 2011-04-29 Emil A Eklund <eae@chromium.org> 2 18 -
trunk/Source/WebCore/html/HTMLElement.cpp
r85267 r85374 361 361 } 362 362 363 static void mergeWithNextTextNode(PassRefPtr<Node> node, ExceptionCode& ec) 364 { 365 ASSERT(node && node->isTextNode()); 366 Node* next = node->nextSibling(); 367 if (!next || !next->isTextNode()) 368 return; 369 370 RefPtr<Text> textNode = static_cast<Text*>(node.get()); 371 RefPtr<Text> textNext = static_cast<Text*>(next); 372 textNode->appendData(textNext->data(), ec); 373 if (ec) 374 return; 375 if (textNext->parentNode()) // Might have been removed by mutation event. 376 textNext->remove(ec); 377 } 378 363 379 void HTMLElement::setOuterHTML(const String& html, ExceptionCode& ec) 364 380 { … … 368 384 return; 369 385 } 370 HTMLElement* parent = toHTMLElement(p); 371 372 RefPtr<DocumentFragment> fragment = createFragmentFromSource(html, parent, ec); 373 if (fragment) { 374 // FIXME: Why doesn't this have code to merge neighboring text nodes the way setOuterText does? 375 parent->replaceChild(fragment.release(), this, ec); 376 } 386 RefPtr<HTMLElement> parent = static_cast<HTMLElement*>(p); 387 RefPtr<Node> prev = previousSibling(); 388 RefPtr<Node> next = nextSibling(); 389 390 RefPtr<DocumentFragment> fragment = createFragmentFromSource(html, parent.get(), ec); 391 if (ec) 392 return; 393 394 parent->replaceChild(fragment.release(), this, ec); 395 RefPtr<Node> node = next ? next->previousSibling() : 0; 396 if (!ec && node && node->isTextNode()) 397 mergeWithNextTextNode(node.release(), ec); 398 399 if (!ec && prev && prev->isTextNode()) 400 mergeWithNextTextNode(prev.release(), ec); 377 401 } 378 402 … … 456 480 if (!ec) 457 481 replaceChildrenWithFragment(this, fragment.release(), ec); 458 }459 460 static void mergeWithNextTextNode(PassRefPtr<Node> node, ExceptionCode& ec)461 {462 ASSERT(node && node->isTextNode());463 Node* next = node->nextSibling();464 if (!next || !next->isTextNode())465 return;466 467 RefPtr<Text> textNode = static_cast<Text*>(node.get());468 RefPtr<Text> textNext = static_cast<Text*>(next);469 textNode->appendData(textNext->data(), ec);470 if (ec)471 return;472 if (textNext->parentNode()) // Might have been removed by mutation event.473 textNext->remove(ec);474 482 } 475 483
Note: See TracChangeset
for help on using the changeset viewer.