Changeset 251761 in webkit


Ignore:
Timestamp:
Oct 29, 2019 7:48:45 PM (4 years ago)
Author:
Wenson Hsieh
Message:

Source/WebCore:
REGRESSION (r251693): [iOS] Unable to change selection after focusing an element with keyboard attached
https://bugs.webkit.org/show_bug.cgi?id=203582

Reviewed by Tim Horton.

Introduces a new helper method to check whether two ElementContexts refer to the same element. Importantly, this
ignores any information on ElementContext that is not either the element, document, or page identifier (for now,
this only includes the element's bounding rect, which may change over time).

Test: editing/selection/ios/set-selection-by-tapping-after-changing-focused-element-bounds.html

  • dom/ElementContext.h:

(WebCore::ElementContext::isSameElement const):
(WebCore::operator==):

Source/WebKit:
REGRESSION (r251693): [iOS] Unable to change selection in a focused element if the element's bounds change
https://bugs.webkit.org/show_bug.cgi?id=203582

Reviewed by Tim Horton.

The refactoring in r251693 broke the ability to change selection in an editable area by tapping in iOS Safari,
in the case where the editable element's bounds change after focus. This is because the aforementioned change
now compares position informations' element context against the focused element information's element context to
check whether or not the position information request was inside the focused element. However, if the bounds of
the focused element change in between the position information request and when the element is initially
focused, the operator== comparison will fail, causing us to prevent text selection.

To fix this, only check whether or not the two element contexts refer to the same element in the DOM by
comparing page, document and element identifiers, but not the element's bounding rect.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:nodeHasBuiltInClickHandling:]):
(-[WKContentView gestureRecognizerShouldBegin:]):
(-[WKContentView textInteractionGesture:shouldBeginAtPoint:]):

LayoutTests:
REGRESSION (r251693): [iOS] Unable to change selection after focusing an element with keyboard attached
https://bugs.webkit.org/show_bug.cgi?id=203582

Reviewed by Tim Horton.

Add a new layout test to cover this scenario.

  • editing/selection/ios/set-selection-by-tapping-after-changing-focused-element-bounds-expected.txt: Added.
  • editing/selection/ios/set-selection-by-tapping-after-changing-focused-element-bounds.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r251750 r251761  
     12019-10-29  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        REGRESSION (r251693): [iOS] Unable to change selection after focusing an element with keyboard attached
     4        https://bugs.webkit.org/show_bug.cgi?id=203582
     5
     6        Reviewed by Tim Horton.
     7
     8        Add a new layout test to cover this scenario.
     9
     10        * editing/selection/ios/set-selection-by-tapping-after-changing-focused-element-bounds-expected.txt: Added.
     11        * editing/selection/ios/set-selection-by-tapping-after-changing-focused-element-bounds.html: Added.
     12
    1132019-10-29  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r251750 r251761  
     12019-10-29  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        REGRESSION (r251693): [iOS] Unable to change selection after focusing an element with keyboard attached
     4        https://bugs.webkit.org/show_bug.cgi?id=203582
     5
     6        Reviewed by Tim Horton.
     7
     8        Introduces a new helper method to check whether two ElementContexts refer to the same element. Importantly, this
     9        ignores any information on ElementContext that is not either the element, document, or page identifier (for now,
     10        this only includes the element's bounding rect, which may change over time).
     11
     12        Test: editing/selection/ios/set-selection-by-tapping-after-changing-focused-element-bounds.html
     13
     14        * dom/ElementContext.h:
     15        (WebCore::ElementContext::isSameElement const):
     16        (WebCore::operator==):
     17
    1182019-10-29  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebCore/dom/ElementContext.h

    r251388 r251761  
    4242    ~ElementContext() = default;
    4343
     44    bool isSameElement(const ElementContext& other) const
     45    {
     46        return webPageIdentifier == other.webPageIdentifier && documentIdentifier == other.documentIdentifier && elementIdentifier == other.elementIdentifier;
     47    }
     48
    4449    template<class Encoder> void encode(Encoder&) const;
    4550    template<class Decoder> static Optional<ElementContext> decode(Decoder&);
     
    4853inline bool operator==(const ElementContext& a, const ElementContext& b)
    4954{
    50     return a.boundingRect == b.boundingRect
    51         && a.webPageIdentifier == b.webPageIdentifier
    52         && a.documentIdentifier == b.documentIdentifier
    53         && a.elementIdentifier == b.elementIdentifier;
     55    return a.boundingRect == b.boundingRect && a.isSameElement(b);
    5456}
    5557
  • trunk/Source/WebKit/ChangeLog

    r251737 r251761  
     12019-10-29  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        REGRESSION (r251693): [iOS] Unable to change selection in a focused element if the element's bounds change
     4        https://bugs.webkit.org/show_bug.cgi?id=203582
     5
     6        Reviewed by Tim Horton.
     7
     8        The refactoring in r251693 broke the ability to change selection in an editable area by tapping in iOS Safari,
     9        in the case where the editable element's bounds change after focus. This is because the aforementioned change
     10        now compares position informations' element context against the focused element information's element context to
     11        check whether or not the position information request was inside the focused element. However, if the bounds of
     12        the focused element change in between the position information request and when the element is initially
     13        focused, the `operator==` comparison will fail, causing us to prevent text selection.
     14
     15        To fix this, only check whether or not the two element contexts refer to the same element in the DOM by
     16        comparing page, document and element identifiers, but not the element's bounding rect.
     17
     18        * UIProcess/ios/WKContentViewInteraction.mm:
     19        (-[WKContentView _didGetTapHighlightForRequest:color:quads:topLeftRadius:topRightRadius:bottomLeftRadius:bottomRightRadius:nodeHasBuiltInClickHandling:]):
     20        (-[WKContentView gestureRecognizerShouldBegin:]):
     21        (-[WKContentView textInteractionGesture:shouldBeginAtPoint:]):
     22
    1232019-10-07  Jer Noble  <jer.noble@apple.com>
    224
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r251720 r251761  
    16971697        return;
    16981698
    1699     if (hasFocusedElement(_focusedElementInformation) && _positionInformation.elementContext == _focusedElementInformation.elementContext)
     1699    if (hasFocusedElement(_focusedElementInformation) && _positionInformation.elementContext && _positionInformation.elementContext->isSameElement(_focusedElementInformation.elementContext))
    17001700        return;
    17011701
     
    22692269            if (![self ensurePositionInformationIsUpToDate:WebKit::InteractionInformationRequest(WebCore::roundedIntPoint(point))])
    22702270                return NO;
    2271             if (_positionInformation.elementContext == _focusedElementInformation.elementContext)
     2271            if (_positionInformation.elementContext && _positionInformation.elementContext->isSameElement(_focusedElementInformation.elementContext))
    22722272                return NO;
    22732273        }
     
    23152315        if (hasFocusedElement(_focusedElementInformation)) {
    23162316            // Prevent the gesture if it is the same node.
    2317             if (_positionInformation.elementContext == _focusedElementInformation.elementContext)
     2317            if (_positionInformation.elementContext && _positionInformation.elementContext->isSameElement(_focusedElementInformation.elementContext))
    23182318                return NO;
    23192319        } else {
     
    24502450    // If we're currently focusing an editable element, only allow the selection to move within that focused element.
    24512451    if (self.isFocusingElement)
    2452         return _positionInformation.elementContext == _focusedElementInformation.elementContext;
     2452        return _positionInformation.elementContext && _positionInformation.elementContext->isSameElement(_focusedElementInformation.elementContext);
    24532453
    24542454    // If we're selecting something, don't activate highlight.
Note: See TracChangeset for help on using the changeset viewer.