Changeset 255879 in webkit


Ignore:
Timestamp:
Feb 5, 2020 4:52:00 PM (4 years ago)
Author:
Wenson Hsieh
Message:

[macCatalyst] Incorrect IBeam cursor when selecting text on Wikipedia
https://bugs.webkit.org/show_bug.cgi?id=207299
<rdar://problem/59200545>

Reviewed by Tim Horton.

After r255827, if EventHandler selects an IBeam cursor at the position information request location, we will
always attempt to show a caret at that location, whose height is the height of the editing caret for that
visible position. However, this means that:

  • It's possible for the caret to be incorrectly sized if the caret is before a large replaced element, such as

a table. Since the request location is also outside of any line rect, it doesn't make sense to use the caret
height for the height of the cursor. Instead, fall back to computed line height. This fixes an issue on
en.wikipedia.org where the line rect would sometimes update to an enormous size when selecting text, since
the caret would temporarily hover over an editing position that is before a large table.

  • This fallback path completely negates certain cursor behaviors; partially restore this behavior by making it

so that in the case where the cursor is in editable content and the line caret first line from the top of
the hit-tested node already contains the request point, don't bother trying to recenter the line rect to be
right over the request point.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::populateCaretContext):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r255875 r255879  
     12020-02-05  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macCatalyst] Incorrect IBeam cursor when selecting text on Wikipedia
     4        https://bugs.webkit.org/show_bug.cgi?id=207299
     5        <rdar://problem/59200545>
     6
     7        Reviewed by Tim Horton.
     8
     9        After r255827, if EventHandler selects an IBeam cursor at the position information request location, we will
     10        always attempt to show a caret at that location, whose height is the height of the editing caret for that
     11        visible position. However, this means that:
     12
     13        -   It's possible for the caret to be incorrectly sized if the caret is before a large replaced element, such as
     14            a table. Since the request location is also outside of any line rect, it doesn't make sense to use the caret
     15            height for the height of the cursor. Instead, fall back to computed line height. This fixes an issue on
     16            en.wikipedia.org where the line rect would sometimes update to an enormous size when selecting text, since
     17            the caret would temporarily hover over an editing position that is before a large table.
     18
     19        -   This fallback path completely negates certain cursor behaviors; partially restore this behavior by making it
     20            so that in the case where the cursor is in editable content and the line caret first line from the top of
     21            the hit-tested node already contains the request point, don't bother trying to recenter the line rect to be
     22            right over the request point.
     23
     24        * WebProcess/WebPage/ios/WebPageIOS.mm:
     25        (WebKit::populateCaretContext):
     26
    1272020-02-05  Chris Dumez  <cdumez@apple.com>
    228
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r255827 r255879  
    27982798        return;
    27992799
    2800     auto* renderer = hitTestResult.innerNode()->renderer();
     2800    auto node = hitTestResult.innerNode();
     2801    if (!node)
     2802        return;
     2803
     2804    auto* renderer = node->renderer();
    28012805    if (!renderer)
    28022806        return;
     
    28252829    if (!lineContainsRequestPoint && info.cursor->type() == Cursor::IBeam) {
    28262830        auto approximateLineRectInContentCoordinates = renderer->absoluteBoundingBoxRect();
    2827         approximateLineRectInContentCoordinates.setHeight(position.absoluteCaretBounds().height());
     2831        approximateLineRectInContentCoordinates.setHeight(renderer->style().computedLineHeight());
    28282832        info.lineCaretExtent = view->contentsToRootView(approximateLineRectInContentCoordinates);
    2829         info.lineCaretExtent.setY(request.point.y() - info.lineCaretExtent.height() / 2);
     2833        if (!info.lineCaretExtent.contains(request.point) || !node->hasEditableStyle())
     2834            info.lineCaretExtent.setY(request.point.y() - info.lineCaretExtent.height() / 2);
    28302835        info.caretHeight = info.lineCaretExtent.height();
    28312836    }
Note: See TracChangeset for help on using the changeset viewer.