Changeset 189914 in webkit


Ignore:
Timestamp:
Sep 17, 2015, 8:51:08 AM (10 years ago)
Author:
Chris Dumez
Message:

Range.deleteContents cannot delete DocType
https://bugs.webkit.org/show_bug.cgi?id=148773
<rdar://problem/22571280>

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline W3C DOM test now that more checks are passing.

  • web-platform-tests/dom/ranges/Range-deleteContents-expected.txt:

Source/WebCore:

Range.deleteContents() was not able to delete a DocumentType Node, and
was throwing a HIERARCHY_REQUEST_ERR. The DOM specification does not
say we should throw in such case:
https://dom.spec.whatwg.org/#dom-range-deletecontents

However, Range.extractContents() should still throw an exception
if any of the contained children in a DocumentType Node:
https://dom.spec.whatwg.org/#concept-range-extract (Step 12)

No new tests, already covered by existing test.

  • dom/Range.cpp:

(WebCore::Range::deleteContents):
(WebCore::Range::extractContents):
(WebCore::Range::checkDeleteExtract):

  • dom/Range.h:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r189893 r189914  
     12015-09-17  Chris Dumez  <cdumez@apple.com>
     2
     3        Range.deleteContents cannot delete DocType
     4        https://bugs.webkit.org/show_bug.cgi?id=148773
     5        <rdar://problem/22571280>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Rebaseline W3C DOM test now that more checks are passing.
     10
     11        * web-platform-tests/dom/ranges/Range-deleteContents-expected.txt:
     12
    1132015-09-16  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-deleteContents-expected.txt

    r189471 r189914  
    4949PASS Resulting DOM for range 22 [testDiv, 2, paras[4], 1]
    5050PASS Resulting cursor position for range 22 [testDiv, 2, paras[4], 1]
    51 FAIL Resulting DOM for range 23 [document, 0, document, 1] HierarchyRequestError: DOM Exception 3
    52 FAIL Resulting cursor position for range 23 [document, 0, document, 1] undefined is not an object (evaluating 'actualRoots')
    53 FAIL Resulting DOM for range 24 [document, 0, document, 2] HierarchyRequestError: DOM Exception 3
    54 FAIL Resulting cursor position for range 24 [document, 0, document, 2] undefined is not an object (evaluating 'actualRoots')
     51PASS Resulting DOM for range 23 [document, 0, document, 1]
     52PASS Resulting cursor position for range 23 [document, 0, document, 1]
     53PASS Resulting DOM for range 24 [document, 0, document, 2]
     54PASS Resulting cursor position for range 24 [document, 0, document, 2]
    5555PASS Resulting DOM for range 25 [comment, 2, comment, 3]
    5656PASS Resulting cursor position for range 25 [comment, 2, comment, 3]
  • trunk/Source/WebCore/ChangeLog

    r189913 r189914  
     12015-09-17  Chris Dumez  <cdumez@apple.com>
     2
     3        Range.deleteContents cannot delete DocType
     4        https://bugs.webkit.org/show_bug.cgi?id=148773
     5        <rdar://problem/22571280>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Range.deleteContents() was not able to delete a DocumentType Node, and
     10        was throwing a HIERARCHY_REQUEST_ERR. The DOM specification does not
     11        say we should throw in such case:
     12        https://dom.spec.whatwg.org/#dom-range-deletecontents
     13
     14        However, Range.extractContents() should still throw an exception
     15        if any of the contained children in a DocumentType Node:
     16        https://dom.spec.whatwg.org/#concept-range-extract (Step 12)
     17
     18        No new tests, already covered by existing test.
     19
     20        * dom/Range.cpp:
     21        (WebCore::Range::deleteContents):
     22        (WebCore::Range::extractContents):
     23        (WebCore::Range::checkDeleteExtract):
     24        * dom/Range.h:
     25
    1262015-09-17  Eric Carlson  <eric.carlson@apple.com>
    227
  • trunk/Source/WebCore/dom/Range.cpp

    r189576 r189914  
    490490void Range::deleteContents(ExceptionCode& ec)
    491491{
    492     checkDeleteExtract(ec);
     492    checkDeleteExtract(Delete, ec);
    493493    if (ec)
    494494        return;
     
    837837RefPtr<DocumentFragment> Range::extractContents(ExceptionCode& ec)
    838838{
    839     checkDeleteExtract(ec);
     839    checkDeleteExtract(Extract, ec);
    840840    if (ec)
    841841        return nullptr;
     
    13351335}
    13361336
    1337 void Range::checkDeleteExtract(ExceptionCode& ec)
     1337void Range::checkDeleteExtract(ActionType action, ExceptionCode& ec)
    13381338{
    13391339    ec = 0;
     
    13471347            return;
    13481348        }
    1349         if (n->nodeType() == Node::DOCUMENT_TYPE_NODE) {
     1349
     1350        if (action == Extract && n->nodeType() == Node::DOCUMENT_TYPE_NODE) {
    13501351            ec = HIERARCHY_REQUEST_ERR;
    13511352            return;
  • trunk/Source/WebCore/dom/Range.h

    r189182 r189914  
    162162    Node* checkNodeWOffset(Node*, int offset, ExceptionCode&) const;
    163163    void checkNodeBA(Node*, ExceptionCode&) const;
    164     void checkDeleteExtract(ExceptionCode&);
    165164    bool containedByReadOnly() const;
    166165
    167166    enum ActionType { Delete, Extract, Clone };
     167    void checkDeleteExtract(ActionType, ExceptionCode&);
    168168    RefPtr<DocumentFragment> processContents(ActionType, ExceptionCode&);
    169169    static RefPtr<Node> processContentsBetweenOffsets(ActionType, PassRefPtr<DocumentFragment>, Node*, unsigned startOffset, unsigned endOffset, ExceptionCode&);
Note: See TracChangeset for help on using the changeset viewer.