Changeset 80696 in webkit


Ignore:
Timestamp:
Mar 10, 2011 12:33:11 AM (13 years ago)
Author:
ojan@chromium.org
Message:

2011-03-10 Ojan Vafai <ojan@chromium.org>

Reviewed by Darin Adler.

Able to move nodes across documents
https://bugs.webkit.org/show_bug.cgi?id=19524

Makes cross-document appendChild, insertBefore, Range.insertNode and Range.surroundContents work.
This matches Gecko and the new Dom Core spec. There are a number of Range methods where we don't
match Gecko or the spec that will need to be updated in a following patch.

  • dom/html/level1/core/hc_elementwrongdocumenterr-expected.txt:
  • dom/html/level1/core/hc_namednodemapwrongdocumenterr-expected.txt:
  • dom/xhtml/level1/core/hc_elementwrongdocumenterr-expected.txt:
  • dom/xhtml/level1/core/hc_namednodemapwrongdocumenterr-expected.txt:
  • fast/dom/move-nodes-across-documents-expected.txt: Added.
  • fast/dom/move-nodes-across-documents.html: Added.

2011-03-10 Ojan Vafai <ojan@chromium.org>

Reviewed by Darin Adler.

Able to move nodes across documents
https://bugs.webkit.org/show_bug.cgi?id=19524

Makes cross-document appendChild, insertBefore, Range.insertNode and Range.surroundContents work.
This matches Gecko and the new Dom Core spec. There are a number of Range methods where we don't
match Gecko or the spec that will need to be updated in a following patch.

Test: fast/dom/move-nodes-across-documents.html

  • dom/Element.cpp: (WebCore::Element::removeAttributeNode):
  • dom/NamedNodeMap.cpp: (WebCore::NamedNodeMap::setNamedItem):
  • dom/Node.cpp: (WebCore::Node::setDocumentRecursively): (WebCore::checkAcceptChild): (WebCore::Node::checkReplaceChild):
  • dom/Range.cpp: (WebCore::Range::insertNode): (WebCore::Range::surroundContents):
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r80692 r80696  
     12011-03-10  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Able to move nodes across documents
     6        https://bugs.webkit.org/show_bug.cgi?id=19524
     7
     8        Makes cross-document appendChild, insertBefore, Range.insertNode and Range.surroundContents work.
     9        This matches Gecko and the new Dom Core spec. There are a number of Range methods where we don't
     10        match Gecko or the spec that will need to be updated in a following patch.
     11
     12        * dom/html/level1/core/hc_elementwrongdocumenterr-expected.txt:
     13        * dom/html/level1/core/hc_namednodemapwrongdocumenterr-expected.txt:
     14        * dom/xhtml/level1/core/hc_elementwrongdocumenterr-expected.txt:
     15        * dom/xhtml/level1/core/hc_namednodemapwrongdocumenterr-expected.txt:
     16        * fast/dom/move-nodes-across-documents-expected.txt: Added.
     17        * fast/dom/move-nodes-across-documents.html: Added.
     18
    1192011-03-09  Roland Steiner  <rolandsteiner@chromium.org>
    220
  • trunk/LayoutTests/dom/html/level1/core/hc_elementwrongdocumenterr-expected.txt

    r11962 r80696  
    1 Test:   http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementwrongdocumenterr
    2 Status: Success
     1Test:   http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementwrongdocumenterr   
     2Status: failure
     3Detail: throw_WRONG_DOCUMENT_ERR: assertTrue failed
  • trunk/LayoutTests/dom/html/level1/core/hc_namednodemapwrongdocumenterr-expected.txt

    r11962 r80696  
    1 Test:   http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapwrongdocumenterr
    2 Status: Success
     1Test:   http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapwrongdocumenterr       
     2Status: failure
     3Detail: throw_WRONG_DOCUMENT_ERR: assertTrue failed
  • trunk/LayoutTests/dom/xhtml/level1/core/hc_elementwrongdocumenterr-expected.txt

    r11962 r80696  
    11Test    http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_elementwrongdocumenterr
    2 Status  Success
     2Status  failure
     3Message throw_WRONG_DOCUMENT_ERR: assertTrue failed
  • trunk/LayoutTests/dom/xhtml/level1/core/hc_namednodemapwrongdocumenterr-expected.txt

    r11962 r80696  
    11Test    http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapwrongdocumenterr
    2 Status  Success
     2Status  failure
     3Message throw_WRONG_DOCUMENT_ERR: assertTrue failed
  • trunk/Source/WebCore/ChangeLog

    r80695 r80696  
     12011-03-10  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Able to move nodes across documents
     6        https://bugs.webkit.org/show_bug.cgi?id=19524
     7
     8        Makes cross-document appendChild, insertBefore, Range.insertNode and Range.surroundContents work.
     9        This matches Gecko and the new Dom Core spec. There are a number of Range methods where we don't
     10        match Gecko or the spec that will need to be updated in a following patch.
     11
     12        Test: fast/dom/move-nodes-across-documents.html
     13
     14        * dom/Element.cpp:
     15        (WebCore::Element::removeAttributeNode):
     16        * dom/NamedNodeMap.cpp:
     17        (WebCore::NamedNodeMap::setNamedItem):
     18        * dom/Node.cpp:
     19        (WebCore::Node::setDocumentRecursively):
     20        (WebCore::checkAcceptChild):
     21        (WebCore::Node::checkReplaceChild):
     22        * dom/Range.cpp:
     23        (WebCore::Range::insertNode):
     24        (WebCore::Range::surroundContents):
     25
    1262011-03-09  Antti Koivisto  <antti@apple.com>
    227
  • trunk/Source/WebCore/dom/Element.cpp

    r80412 r80696  
    13981398        return 0;
    13991399    }
    1400     if (document() != attr->document()) {
    1401         ec = WRONG_DOCUMENT_ERR;
    1402         return 0;
    1403     }
     1400
     1401    ASSERT(document() == attr->document());
    14041402
    14051403    NamedNodeMap* attrs = attributes(true);
  • trunk/Source/WebCore/dom/NamedNodeMap.cpp

    r77019 r80696  
    101101    }
    102102
    103     // WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map.
    104     if (arg->document() != m_element->document()) {
    105         ec = WRONG_DOCUMENT_ERR;
    106         return 0;
    107     }
    108 
    109103    // Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes in a non-attribute node
    110104    if (!arg->isAttributeNode()) {
  • trunk/Source/WebCore/dom/Node.cpp

    r80487 r80696  
    760760void Node::setDocumentRecursively(Document* document)
    761761{
    762     // FIXME: To match Gecko, we should do this for nodes that are already in the document as well.
    763     if (this->document() == document || this->inDocument())
     762    if (this->document() == document)
    764763        return;
    765764
     
    11431142static void checkAcceptChild(Node* newParent, Node* newChild, ExceptionCode& ec)
    11441143{
    1145     // Perform error checking as required by spec for adding a new child. Used by replaceChild().
    1146    
    11471144    // Not mentioned in spec: throw NOT_FOUND_ERR if newChild is null
    11481145    if (!newChild) {
     
    11511148    }
    11521149   
    1153     // NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly
    11541150    if (newParent->isReadOnlyNode()) {
    11551151        ec = NO_MODIFICATION_ALLOWED_ERR;
    11561152        return;
    11571153    }
    1158    
    1159     // WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that
    1160     // created this node.
    1161     // We assume that if newChild is a DocumentFragment, all children are created from the same document
    1162     // as the fragment itself (otherwise they could not have been added as children)
    1163     if (newChild->document() != newParent->document() && newChild->inDocument()) {
    1164         // but if the child is not in a document yet then loosen the
    1165         // restriction, so that e.g. creating an element with the Option()
    1166         // constructor and then adding it to a different document works,
    1167         // as it does in Mozilla and Mac IE.
    1168         ec = WRONG_DOCUMENT_ERR;
    1169         return;
    1170     }
    1171    
     1154
     1155    if (newChild->inDocument() && newChild->nodeType() == Node::DOCUMENT_TYPE_NODE) {
     1156        ec = HIERARCHY_REQUEST_ERR;
     1157        return;
     1158    }
     1159
    11721160    // HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the
    11731161    // newChild node, or if the node to append is one of this node's ancestors.
    11741162
    1175     // check for ancestor/same node
    11761163    if (newChild == newParent || newParent->isDescendantOf(newChild)) {
    11771164        ec = HIERARCHY_REQUEST_ERR;
     
    11821169void Node::checkReplaceChild(Node* newChild, Node* oldChild, ExceptionCode& ec)
    11831170{
     1171    if (!oldChild) {
     1172        ec = NOT_FOUND_ERR;
     1173        return;
     1174    }
     1175
    11841176    checkAcceptChild(this, newChild, ec);
    11851177    if (ec)
  • trunk/Source/WebCore/dom/Range.cpp

    r80408 r80696  
    930930    if (containedByReadOnly()) {
    931931        ec = NO_MODIFICATION_ALLOWED_ERR;
    932         return;
    933     }
    934 
    935     // WRONG_DOCUMENT_ERR: Raised if newParent and the container of the start of the Range were
    936     // not created from the same document.
    937     if (newNode->document() != m_start.container()->document()) {
    938         ec = WRONG_DOCUMENT_ERR;
    939932        return;
    940933    }
     
    14241417    }
    14251418
    1426     // WRONG_DOCUMENT_ERR: Raised if newParent and the container of the start of the Range were
    1427     // not created from the same document.
    1428     if (newParent->document() != m_start.container()->document()) {
    1429         ec = WRONG_DOCUMENT_ERR;
    1430         return;
    1431     }
    1432 
    14331419    // Raise a HIERARCHY_REQUEST_ERR if m_start.container() doesn't accept children like newParent.
    14341420    Node* parentOfNewParent = m_start.container();
Note: See TracChangeset for help on using the changeset viewer.