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

Changeset 276688 in webkit


Ignore:
Timestamp:
Apr 27, 2021, 7:54:40 PM (5 years ago)
Author:
Wenson Hsieh
Message:

[iOS] Web content process occasionally crashes under VisibleSelection::adjustPositionForEnd
​https://bugs.webkit.org/show_bug.cgi?id=225072
rdar://77159489

Reviewed by Darin Adler.

Source/WebCore:

Add a helper method to check whether or not the given Position is in a tree scope. See WebKit/ChangeLog for
more details.

Test: editing/selection/ios/clear-selection-while-moving-selection-handles.html

  • dom/Position.h:

(WebCore::Position::isInTreeScope const):

Source/WebKit:

Make rangeForPointInRootViewCoordinates robust in the case where the original selection may have become
orphaned or null, by checking that the targetNode and existing selectionStart or selectionEnd are in a
tree scope before accessing treeScope().

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::rangeForPointInRootViewCoordinates):

LayoutTests:

Add a layout test that programmatically clears the selection in the middle of changing it by moving selection
handles.

  • editing/selection/ios/clear-selection-while-moving-selection-handles-expected.txt: Added.
  • editing/selection/ios/clear-selection-while-moving-selection-handles.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r276687 r276688  
     12021-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] Web content process occasionally crashes under VisibleSelection::adjustPositionForEnd
     4        https://bugs.webkit.org/show_bug.cgi?id=225072
     5        rdar://77159489
     6
     7        Reviewed by Darin Adler.
     8
     9        Add a layout test that programmatically clears the selection in the middle of changing it by moving selection
     10        handles.
     11
     12        * editing/selection/ios/clear-selection-while-moving-selection-handles-expected.txt: Added.
     13        * editing/selection/ios/clear-selection-while-moving-selection-handles.html: Added.
     14
    1152021-04-27  Diego Pino Garcia  <dpino@igalia.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r276679 r276688  
     12021-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] Web content process occasionally crashes under VisibleSelection::adjustPositionForEnd
     4        https://bugs.webkit.org/show_bug.cgi?id=225072
     5        rdar://77159489
     6
     7        Reviewed by Darin Adler.
     8
     9        Add a helper method to check whether or not the given `Position` is in a tree scope. See WebKit/ChangeLog for
     10        more details.
     11
     12        Test: editing/selection/ios/clear-selection-while-moving-selection-handles.html
     13
     14        * dom/Position.h:
     15        (WebCore::Position::isInTreeScope const):
     16
    1172021-04-27  Cameron McCormack  <heycam@apple.com>
    218
  • trunk/Source/WebCore/dom/Position.h

    r276191 r276688  
    125125    }
    126126
     127    bool isInTreeScope() const { return m_anchorNode && m_anchorNode->isInTreeScope(); }
     128
    127129    // These should only be used for PositionIsOffsetInAnchor positions, unless
    128130    // the position is a legacy editing position.
  • trunk/Source/WebKit/ChangeLog

    r276678 r276688  
     12021-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] Web content process occasionally crashes under VisibleSelection::adjustPositionForEnd
     4        https://bugs.webkit.org/show_bug.cgi?id=225072
     5        rdar://77159489
     6
     7        Reviewed by Darin Adler.
     8
     9        Make `rangeForPointInRootViewCoordinates` robust in the case where the original selection may have become
     10        orphaned or null, by checking that the `targetNode` and existing `selectionStart` or `selectionEnd` are in a
     11        tree scope before accessing `treeScope()`.
     12
     13        * WebProcess/WebPage/ios/WebPageIOS.mm:
     14        (WebKit::rangeForPointInRootViewCoordinates):
     15
    1162021-04-27  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r276598 r276688  
    15251525        if (result <= selectionStart)
    15261526            result = selectionStart.next();
    1527         else if (targetNode && selectionStart.deepEquivalent().treeScope() != &targetNode->treeScope())
     1527        else if (targetNode && targetNode->isInTreeScope() && selectionStart.deepEquivalent().isInTreeScope() && selectionStart.deepEquivalent().treeScope() != &targetNode->treeScope())
    15281528            result = VisibleSelection::adjustPositionForEnd(result.deepEquivalent(), selectionStart.deepEquivalent().containerNode());
    15291529
    … …  
    15321532        if (selectionEnd <= result)
    15331533            result = selectionEnd.previous();
    1534         else if (targetNode && selectionEnd.deepEquivalent().treeScope() != &targetNode->treeScope())
     1534        else if (targetNode && targetNode->isInTreeScope() && selectionEnd.deepEquivalent().isInTreeScope() && selectionEnd.deepEquivalent().treeScope() != &targetNode->treeScope())
    15351535            result = VisibleSelection::adjustPositionForStart(result.deepEquivalent(), selectionEnd.deepEquivalent().containerNode());
    15361536
Note: See TracChangeset for help on using the changeset viewer.