 Chromium Code Reviews
 Chromium Code Reviews Issue 19045003:
  Element's insertAdjacent API should lazy attach  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 19045003:
  Element's insertAdjacent API should lazy attach  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| Index: Source/core/html/HTMLElement.cpp | 
| diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp | 
| index 5e03b35fc70f48acfdc487e6e5c3113fc929aef3..4089ef6bb2594e7813b54fc88d8c02c99a6d7992 100644 | 
| --- a/Source/core/html/HTMLElement.cpp | 
| +++ b/Source/core/html/HTMLElement.cpp | 
| @@ -494,9 +494,8 @@ Node* HTMLElement::insertAdjacent(const String& where, Node* newChild, Exception | 
| // Opera also appears to disallow such usage. | 
| if (equalIgnoringCase(where, "beforeBegin")) { | 
| - ContainerNode* parent = this->parentNode(); | 
| - if (parent) { | 
| - parent->insertBefore(newChild, this, ec); | 
| + if (ContainerNode* parent = this->parentNode()) { | 
| + parent->insertBefore(newChild, this, ec, AttachLazily); | 
| if (!ec) | 
| return newChild; | 
| } | 
| @@ -504,19 +503,18 @@ Node* HTMLElement::insertAdjacent(const String& where, Node* newChild, Exception | 
| } | 
| if (equalIgnoringCase(where, "afterBegin")) { | 
| - insertBefore(newChild, firstChild(), ec); | 
| + insertBefore(newChild, firstChild(), ec, AttachLazily); | 
| return ec ? 0 : newChild; | 
| } | 
| if (equalIgnoringCase(where, "beforeEnd")) { | 
| - appendChild(newChild, ec); | 
| + appendChild(newChild, ec, AttachLazily); | 
| return ec ? 0 : newChild; | 
| } | 
| if (equalIgnoringCase(where, "afterEnd")) { | 
| - ContainerNode* parent = this->parentNode(); | 
| - if (parent) { | 
| - parent->insertBefore(newChild, nextSibling(), ec); | 
| + if (ContainerNode* parent = this->parentNode()) { | 
| + parent->insertBefore(newChild, nextSibling(), ec, AttachLazily); | 
| if (!ec) | 
| return newChild; | 
| } | 
| @@ -537,7 +535,6 @@ Element* HTMLElement::insertAdjacentElement(const String& where, Element* newChi | 
| } | 
| Node* returnValue = insertAdjacent(where, newChild, ec); | 
| - ASSERT_WITH_SECURITY_IMPLICATION(!returnValue || returnValue->isElementNode()); | 
| 
ojan
2013/07/12 05:12:44
What's wrong with these asserts?
 | 
| return toElement(returnValue); | 
| } | 
| @@ -550,7 +547,6 @@ static Element* contextElementForInsertion(const String& where, Element* element | 
| ec = NoModificationAllowedError; | 
| return 0; | 
| } | 
| - ASSERT_WITH_SECURITY_IMPLICATION(!parent || parent->isElementNode()); | 
| return toElement(parent); | 
| } | 
| if (equalIgnoringCase(where, "afterBegin") || equalIgnoringCase(where, "beforeEnd")) |