Changeset 255827 in webkit


Ignore:
Timestamp:
Feb 5, 2020 10:22:02 AM (4 years ago)
Author:
Wenson Hsieh
Message:

[macCatalyst] IBeam cursor doesn't show up when hovering over text form controls prior to editing
https://bugs.webkit.org/show_bug.cgi?id=207268
<rdar://problem/59188152>

Reviewed by Tim Horton.

On macCatalyst, when hovering over textareas and input fields that have not been edited yet, the cursor fails to
change to an IBeam and instead falls back to the default style. Even though EventHandler::selectCursor()
returns IBeam, we end up not actually using an IBeam because the position information's lineCaretExtent is
an empty rect, which means the caret height is 0 and, more importantly, the line rect will not contain the
request point.

The line rect is empty in text fields that have not been edited yet because the form control's inner plaintext
contenteditable div (embedded in the shadow root) does not contain any child renderers with a non-zero height.
Even if it did, however, the element may still be much taller than the combined height of the inner div's
children, so the line rect may still not contain the position information request point (this is most easily
noticeable when focusing a textarea, typing a few letters, and then moving the cursor to near the bottom of the
textarea element).

To fix this, add a fallback path for the scenario where we want to show an IBeam, but fail to find line rects
that contain the request point. Instead, we still show an IBeam, but simply fake the lineCaretExtent to be an
element-wide rect that is the height of the caret, and is also vertically centered about 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

    r255819 r255827  
     12020-02-05  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macCatalyst] IBeam cursor doesn't show up when hovering over text form controls prior to editing
     4        https://bugs.webkit.org/show_bug.cgi?id=207268
     5        <rdar://problem/59188152>
     6
     7        Reviewed by Tim Horton.
     8
     9        On macCatalyst, when hovering over textareas and input fields that have not been edited yet, the cursor fails to
     10        change to an IBeam and instead falls back to the default style. Even though `EventHandler::selectCursor()`
     11        returns `IBeam`, we end up not actually using an IBeam because the position information's `lineCaretExtent` is
     12        an empty rect, which means the caret height is 0 and, more importantly, the line rect will not contain the
     13        request point.
     14
     15        The line rect is empty in text fields that have not been edited yet because the form control's inner plaintext
     16        contenteditable div (embedded in the shadow root) does not contain any child renderers with a non-zero height.
     17        Even if it did, however, the element may still be much taller than the combined height of the inner div's
     18        children, so the line rect may still not contain the position information request point (this is most easily
     19        noticeable when focusing a textarea, typing a few letters, and then moving the cursor to near the bottom of the
     20        textarea element).
     21
     22        To fix this, add a fallback path for the scenario where we want to show an IBeam, but fail to find line rects
     23        that contain the request point. Instead, we still show an IBeam, but simply fake the lineCaretExtent to be an
     24        element-wide rect that is the height of the caret, and is also vertically centered about the request point.
     25
     26        * WebProcess/WebPage/ios/WebPageIOS.mm:
     27        (WebKit::populateCaretContext):
     28
    1292020-02-05  Commit Queue  <commit-queue@webkit.org>
    230
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r255786 r255827  
    28182818    info.caretHeight = info.lineCaretExtent.height();
    28192819
     2820    bool lineContainsRequestPoint = info.lineCaretExtent.contains(request.point);
    28202821    // Force an I-beam cursor if the page didn't request a hand, and we're inside the bounds of the line.
    2821     if (info.lineCaretExtent.contains(request.point) && info.cursor->type() != Cursor::Hand && canForceCaretForPosition(position))
     2822    if (lineContainsRequestPoint && info.cursor->type() != Cursor::Hand && canForceCaretForPosition(position))
    28222823        info.cursor = Cursor::fromType(Cursor::IBeam);
     2824
     2825    if (!lineContainsRequestPoint && info.cursor->type() == Cursor::IBeam) {
     2826        auto approximateLineRectInContentCoordinates = renderer->absoluteBoundingBoxRect();
     2827        approximateLineRectInContentCoordinates.setHeight(position.absoluteCaretBounds().height());
     2828        info.lineCaretExtent = view->contentsToRootView(approximateLineRectInContentCoordinates);
     2829        info.lineCaretExtent.setY(request.point.y() - info.lineCaretExtent.height() / 2);
     2830        info.caretHeight = info.lineCaretExtent.height();
     2831    }
    28232832}
    28242833
Note: See TracChangeset for help on using the changeset viewer.