Changeset 251683 in webkit


Ignore:
Timestamp:
Oct 28, 2019 4:29:25 PM (4 years ago)
Author:
Chris Dumez
Message:

editing/firstPositionInNode-crash.html in crashing in Debug
https://bugs.webkit.org/show_bug.cgi?id=203520

Reviewed by Ryosuke Niwa.

If positionInParentBeforeNode / positionInParentAfterNode on a node and editingIgnoresContent()
returns true for this node's parent, keep traversing ancestors until we find one for which
editingIgnoresContent() returns false.

No new tests, covered by editing/firstPositionInNode-crash.html.

  • dom/Position.cpp:

(WebCore::positionInParentBeforeNode):
(WebCore::positionInParentAfterNode):

  • dom/Position.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r251680 r251683  
     12019-10-28  Chris Dumez  <cdumez@apple.com>
     2
     3        editing/firstPositionInNode-crash.html in crashing in Debug
     4        https://bugs.webkit.org/show_bug.cgi?id=203520
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        If positionInParentBeforeNode / positionInParentAfterNode on a node and editingIgnoresContent()
     9        returns true for this node's parent, keep traversing ancestors until we find one for which
     10        editingIgnoresContent() returns false.
     11
     12        No new tests, covered by editing/firstPositionInNode-crash.html.
     13
     14        * dom/Position.cpp:
     15        (WebCore::positionInParentBeforeNode):
     16        (WebCore::positionInParentAfterNode):
     17        * dom/Position.h:
     18
    1192019-10-28  Zalan Bujtas  <zalan@apple.com>
    220
  • trunk/Source/WebCore/dom/Position.cpp

    r251041 r251683  
    15701570}
    15711571
     1572Position positionInParentBeforeNode(Node* node)
     1573{
     1574    auto* ancestor = node->parentNode();
     1575    while (ancestor && editingIgnoresContent(*ancestor)) {
     1576        node = ancestor;
     1577        ancestor = ancestor->parentNode();
     1578    }
     1579    ASSERT(ancestor);
     1580    return Position(ancestor, node->computeNodeIndex(), Position::PositionIsOffsetInAnchor);
     1581}
     1582
     1583Position positionInParentAfterNode(Node* node)
     1584{
     1585    auto* ancestor = node->parentNode();
     1586    while (ancestor && editingIgnoresContent(*ancestor)) {
     1587        node = ancestor;
     1588        ancestor = ancestor->parentNode();
     1589    }
     1590    ASSERT(ancestor);
     1591    return Position(ancestor, node->computeNodeIndex() + 1, Position::PositionIsOffsetInAnchor);
     1592}
     1593
    15721594} // namespace WebCore
    15731595
  • trunk/Source/WebCore/dom/Position.h

    r239190 r251683  
    264264}
    265265
    266 inline Position positionInParentBeforeNode(const Node* node)
    267 {
    268     ASSERT(node->parentNode());
    269     return Position(node->parentNode(), node->computeNodeIndex(), Position::PositionIsOffsetInAnchor);
    270 }
    271 
    272 inline Position positionInParentAfterNode(const Node* node)
    273 {
    274     ASSERT(node->parentNode());
    275     return Position(node->parentNode(), node->computeNodeIndex() + 1, Position::PositionIsOffsetInAnchor);
    276 }
     266Position positionInParentBeforeNode(Node*);
     267Position positionInParentAfterNode(Node*);
    277268
    278269// positionBeforeNode and positionAfterNode return neighbor-anchored positions, construction is O(1)
Note: See TracChangeset for help on using the changeset viewer.