Changeset 31090

Show
Ignore:
Timestamp:
2008-03-16 20:50:33 (2 months ago)
Author:
mjs@apple.com
Message:

WebCore:

2008-03-16 Maciej Stachowiak <mjs@apple.com>

Reviewed by Darin.

  • dom/Range.cpp:
    (WebCore::Range::surroundContents): Check for
    HIERARCHY_REQUEST_ERR before BAD_BOUNDARYPOINTS_ERR, since Acid3
    expects exceptional conditions to be tested in the order that the
    spec lists them. Also, adjust the HIERARCHY_REQUEST_ERR check. If
    the start point of the range is in a comment node, the node that
    would be the parent of a partial replacement is actually the
    comment node's parent (since comment nodes have character
    indices), so we should do the HIERARCHY_REQUEST_ERR check based on
    the parent of the comment node, as for text nodes, even though it
    will fail later with a different exception because it is not
    allowed to surround a partially selected non-text node.

LayoutTests:

2008-03-16 Maciej Stachowiak <mjs@apple.com>

Reviewed by Darin.

  • test for "Acid3 expects different exceptions for surroundContents calls involving comment nodes (affects Acid3 test 11)"
    http://bugs.webkit.org/show_bug.cgi?id=17509

  • fast/dom/Range/acid3-surround-contents-expected.txt: Added.
  • fast/dom/Range/acid3-surround-contents.html: Added.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/LayoutTests/ChangeLog

    r31089 r31090  
     12008-03-16  Maciej Stachowiak  <mjs@apple.com> 
     2 
     3        Reviewed by Darin. 
     4 
     5        - test for "Acid3 expects different exceptions for surroundContents calls involving comment nodes (affects Acid3 test 11)" 
     6        http://bugs.webkit.org/show_bug.cgi?id=17509 
     7         
     8        * fast/dom/Range/acid3-surround-contents-expected.txt: Added. 
     9        * fast/dom/Range/acid3-surround-contents.html: Added. 
     10 
    1112008-03-16  Marvin Decker  <marv.decker@gmail.com> 
    212 
  • trunk/WebCore/ChangeLog

    r31089 r31090  
     12008-03-16  Maciej Stachowiak  <mjs@apple.com> 
     2 
     3        Reviewed by Darin. 
     4 
     5        - fixed "Acid3 expects different exceptions for surroundContents calls involving comment nodes (affects Acid3 test 11)" 
     6        http://bugs.webkit.org/show_bug.cgi?id=17509 
     7         
     8        This gets us to 92/100 
     9 
     10        * dom/Range.cpp: 
     11        (WebCore::Range::surroundContents): Check for 
     12        HIERARCHY_REQUEST_ERR before BAD_BOUNDARYPOINTS_ERR, since Acid3 
     13        expects exceptional conditions to be tested in the order that the 
     14        spec lists them. Also, adjust the HIERARCHY_REQUEST_ERR check. If 
     15        the start point of the range is in a comment node, the node that 
     16        would be the parent of a partial replacement is actually the 
     17        comment node's parent (since comment nodes have character 
     18        indices), so we should do the HIERARCHY_REQUEST_ERR check based on 
     19        the parent of the comment node, as for text nodes, even though it 
     20        will fail later with a different exception because it is not 
     21        allowed to surround a partially selected non-text node. 
     22 
    1232008-03-16  Marvin Decker  <marv.decker@gmail.com> 
    224 
  • trunk/WebCore/dom/Range.cpp

    r31075 r31090  
    14061406    } 
    14071407 
     1408    // Raise a HIERARCHY_REQUEST_ERR if m_start.container doesn't accept children like newParent. 
     1409    Node* parentOfNewParent = m_start.container.get(); 
     1410 
     1411    // If m_start.container is a character data node, it will be split and it will be its parent that will  
     1412    // need to accept newParent (or in the case of a comment, it logically "would" 
     1413    if (parentOfNewParent->isCharacterDataNode()) 
     1414        parentOfNewParent = parentOfNewParent->parentNode(); 
     1415    if (!parentOfNewParent->childTypeAllowed(newParent->nodeType())) { 
     1416        ec = HIERARCHY_REQUEST_ERR; 
     1417        return; 
     1418    } 
     1419     
     1420    if (m_start.container == newParent || m_start.container->isDescendantOf(newParent.get())) { 
     1421        ec = HIERARCHY_REQUEST_ERR; 
     1422        return; 
     1423    } 
     1424 
     1425    // FIXME: Do we need a check if the node would end up with a child node of a type not 
     1426    // allowed by the type of node? 
     1427 
    14081428    // BAD_BOUNDARYPOINTS_ERR: Raised if the Range partially selects a non-Text node. 
    14091429    if (m_start.container->nodeType() != Node::TEXT_NODE) { 
     
    14191439        } 
    14201440    }     
    1421  
    1422     // Raise a HIERARCHY_REQUEST_ERR if m_start.container doesn't accept children like newParent. 
    1423     Node* parentOfNewParent = m_start.container.get(); 
    1424     // If m_start.container is a textNode, it will be split and it will be its parent that will  
    1425     // need to accept newParent. 
    1426     if (parentOfNewParent->isTextNode()) 
    1427         parentOfNewParent = parentOfNewParent->parentNode(); 
    1428     if (!parentOfNewParent->childTypeAllowed(newParent->nodeType())) { 
    1429         ec = HIERARCHY_REQUEST_ERR; 
    1430         return; 
    1431     } 
    1432      
    1433     if (m_start.container == newParent || m_start.container->isDescendantOf(newParent.get())) { 
    1434         ec = HIERARCHY_REQUEST_ERR; 
    1435         return; 
    1436     } 
    1437  
    1438     // FIXME: Do we need a check if the node would end up with a child node of a type not 
    1439     // allowed by the type of node? 
    14401441 
    14411442    ec = 0;