⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243621 in webkit


Ignore:
Timestamp:
Mar 28, 2019, 2:23:49 PM (7 years ago)
Author:
rniwa@webkit.org
Message:

Debug assert in DOMSelection::containsNode when node belongs to a different tree
https://bugs.webkit.org/show_bug.cgi?id=196342

Reviewed by Antti Koivisto.

Source/WebCore:

The assertion was wrong. It's possible for Range::compareBoundaryPoints to return WRONG_DOCUMENT_ERR
when the node and the start container belong to two different trees.

Return false in such a case for now since it's unclear (unspecified) what these methods on Selection
should do with respect to shadow trees, preserving the current behavior of release builds.

Test: editing/selection/containsNode-with-no-common-ancestor.html

  • page/DOMSelection.cpp:

(WebCore::DOMSelection::containsNode const):

LayoutTests:

Added a regression test to catch the debug assertion failure. The test always passed in release builds.

  • editing/selection/containsNode-with-no-common-ancestor-expected.txt: Added.
  • editing/selection/containsNode-with-no-common-ancestor.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r243613 r243621  
     12019-03-28  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Debug assert in DOMSelection::containsNode when node belongs to a different tree
     4        https://bugs.webkit.org/show_bug.cgi?id=196342
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added a regression test to catch the debug assertion failure. The test always passed in release builds.
     9
     10        * editing/selection/containsNode-with-no-common-ancestor-expected.txt: Added.
     11        * editing/selection/containsNode-with-no-common-ancestor.html: Added.
     12
    1132019-03-28  Shawn Roberts  <sroberts@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r243616 r243621  
     12019-03-28  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Debug assert in DOMSelection::containsNode when node belongs to a different tree
     4        https://bugs.webkit.org/show_bug.cgi?id=196342
     5
     6        Reviewed by Antti Koivisto.
     7
     8        The assertion was wrong. It's possible for Range::compareBoundaryPoints to return WRONG_DOCUMENT_ERR
     9        when the node and the start container belong to two different trees.
     10
     11        Return false in such a case for now since it's unclear (unspecified) what these methods on Selection
     12        should do with respect to shadow trees, preserving the current behavior of release builds.
     13
     14        Test: editing/selection/containsNode-with-no-common-ancestor.html
     15
     16        * page/DOMSelection.cpp:
     17        (WebCore::DOMSelection::containsNode const):
     18
    1192019-03-28  Tim Horton  <timothy_horton@apple.com>
    220
  • trunk/Source/WebCore/page/DOMSelection.cpp

    r236917 r243621  
    416416
    417417    auto startsResult = Range::compareBoundaryPoints(parentNode, nodeIndex, &selectedRange->startContainer(), selectedRange->startOffset());
    418     ASSERT(!startsResult.hasException());
     418    if (startsResult.hasException())
     419        return false;
     420
    419421    auto endsResult = Range::compareBoundaryPoints(parentNode, nodeIndex + 1, &selectedRange->endContainer(), selectedRange->endOffset());
    420422    ASSERT(!endsResult.hasException());
Note: See TracChangeset for help on using the changeset viewer.