Title: [255827] trunk/Source/WebKit
Revision
255827
Author
[email protected]
Date
2020-02-05 10:22:02 -0800 (Wed, 05 Feb 2020)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (255826 => 255827)


--- trunk/Source/WebKit/ChangeLog	2020-02-05 18:08:54 UTC (rev 255826)
+++ trunk/Source/WebKit/ChangeLog	2020-02-05 18:22:02 UTC (rev 255827)
@@ -1,3 +1,31 @@
+2020-02-05  Wenson Hsieh  <[email protected]>
+
+        [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):
+
 2020-02-05  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r255818.

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (255826 => 255827)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-02-05 18:08:54 UTC (rev 255826)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-02-05 18:22:02 UTC (rev 255827)
@@ -2817,9 +2817,18 @@
     info.lineCaretExtent = view->contentsToRootView(lineRect);
     info.caretHeight = info.lineCaretExtent.height();
 
+    bool lineContainsRequestPoint = info.lineCaretExtent.contains(request.point);
     // Force an I-beam cursor if the page didn't request a hand, and we're inside the bounds of the line.
-    if (info.lineCaretExtent.contains(request.point) && info.cursor->type() != Cursor::Hand && canForceCaretForPosition(position))
+    if (lineContainsRequestPoint && info.cursor->type() != Cursor::Hand && canForceCaretForPosition(position))
         info.cursor = Cursor::fromType(Cursor::IBeam);
+
+    if (!lineContainsRequestPoint && info.cursor->type() == Cursor::IBeam) {
+        auto approximateLineRectInContentCoordinates = renderer->absoluteBoundingBoxRect();
+        approximateLineRectInContentCoordinates.setHeight(position.absoluteCaretBounds().height());
+        info.lineCaretExtent = view->contentsToRootView(approximateLineRectInContentCoordinates);
+        info.lineCaretExtent.setY(request.point.y() - info.lineCaretExtent.height() / 2);
+        info.caretHeight = info.lineCaretExtent.height();
+    }
 }
 
 InteractionInformationAtPosition WebPage::positionInformation(const InteractionInformationRequest& request)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to