Title: [279351] trunk/Source/WebKit
Revision
279351
Author
katherine_che...@apple.com
Date
2021-06-28 16:52:26 -0700 (Mon, 28 Jun 2021)

Log Message

I-beam pointer is vertical for vertical text
https://bugs.webkit.org/show_bug.cgi?id=227414
<rdar://problem/77564647>

Reviewed by Tim Horton.

Pass the orientation from the renderer to the WKContentView. Rename
caretHeight to caretLength now that we use it to calculate the I-beam
size for vertical text.

* Shared/ios/InteractionInformationAtPosition.h:
* Shared/ios/InteractionInformationAtPosition.mm:
(WebKit::InteractionInformationAtPosition::encode const):
(WebKit::InteractionInformationAtPosition::decode):
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView pointerInteraction:styleForRegion:]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::populateCaretContext):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (279350 => 279351)


--- trunk/Source/WebKit/ChangeLog	2021-06-28 23:06:27 UTC (rev 279350)
+++ trunk/Source/WebKit/ChangeLog	2021-06-28 23:52:26 UTC (rev 279351)
@@ -1,3 +1,24 @@
+2021-06-28  Kate Cheney  <katherine_che...@apple.com>
+
+        I-beam pointer is vertical for vertical text
+        https://bugs.webkit.org/show_bug.cgi?id=227414
+        <rdar://problem/77564647>
+
+        Reviewed by Tim Horton.
+
+        Pass the orientation from the renderer to the WKContentView. Rename
+        caretHeight to caretLength now that we use it to calculate the I-beam
+        size for vertical text.
+
+        * Shared/ios/InteractionInformationAtPosition.h:
+        * Shared/ios/InteractionInformationAtPosition.mm:
+        (WebKit::InteractionInformationAtPosition::encode const):
+        (WebKit::InteractionInformationAtPosition::decode):
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView pointerInteraction:styleForRegion:]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::populateCaretContext):
+
 2021-06-28  Per Arne  <pvol...@apple.com>
 
         Pass correct value of AX per app settings to the WebContent process

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h (279350 => 279351)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h	2021-06-28 23:06:27 UTC (rev 279350)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h	2021-06-28 23:52:26 UTC (rev 279351)
@@ -72,6 +72,7 @@
 #endif
     bool shouldNotUseIBeamInEditableContent { false };
     bool isImageOverlayText { false };
+    bool isHorizontalWritingMode { false };
     WebCore::FloatPoint adjustedPointForNodeRespondingToClickEvents;
     URL url;
     URL imageURL;
@@ -85,7 +86,7 @@
     String textBefore;
     String textAfter;
 
-    float caretHeight { 0 };
+    float caretLength { 0 };
     WebCore::FloatRect lineCaretExtent;
 
     std::optional<WebCore::Cursor> cursor;

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm (279350 => 279351)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm	2021-06-28 23:06:27 UTC (rev 279350)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm	2021-06-28 23:52:26 UTC (rev 279351)
@@ -62,7 +62,7 @@
 #endif
     encoder << textBefore;
     encoder << textAfter;
-    encoder << caretHeight;
+    encoder << caretLength;
     encoder << lineCaretExtent;
     encoder << cursor;
     encoder << linkIndicator;
@@ -82,6 +82,7 @@
 #endif
     encoder << shouldNotUseIBeamInEditableContent;
     encoder << isImageOverlayText;
+    encoder << isHorizontalWritingMode;
     encoder << elementContext;
     encoder << imageElementContext;
 }
@@ -159,7 +160,7 @@
     if (!decoder.decode(result.textAfter))
         return false;
 
-    if (!decoder.decode(result.caretHeight))
+    if (!decoder.decode(result.caretLength))
         return false;
 
     if (!decoder.decode(result.lineCaretExtent))
@@ -209,6 +210,9 @@
     if (!decoder.decode(result.isImageOverlayText))
         return false;
 
+    if (!decoder.decode(result.isHorizontalWritingMode))
+        return false;
+
     if (!decoder.decode(result.elementContext))
         return false;
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (279350 => 279351)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-06-28 23:06:27 UTC (rev 279350)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-06-28 23:52:26 UTC (rev 279351)
@@ -9625,8 +9625,9 @@
     double scaleFactor = self._contentZoomScale;
 
     UIPointerStyle *(^iBeamCursor)(void) = ^{
-        float beamLength = _positionInformation.caretHeight * scaleFactor;
-        UIAxis iBeamConstraintAxes = UIAxisVertical;
+        float beamLength = _positionInformation.caretLength * scaleFactor;
+        auto axisOrientation = _positionInformation.isHorizontalWritingMode ? UIAxisVertical : UIAxisHorizontal;
+        UIAxis iBeamConstraintAxes = _positionInformation.isHorizontalWritingMode ? UIAxisVertical : UIAxisHorizontal;
 
         // If the I-beam is so large that the magnetism is hard to fight, we should not apply any magnetism.
         if (beamLength > [UITextInteraction _maximumBeamSnappingLength])
@@ -9636,7 +9637,7 @@
         if ([region.identifier isEqual:editablePointerRegionIdentifier])
             iBeamConstraintAxes = UIAxisNeither;
 
-        return [UIPointerStyle styleWithShape:[UIPointerShape beamWithPreferredLength:beamLength axis:UIAxisVertical] constrainedAxes:iBeamConstraintAxes];
+        return [UIPointerStyle styleWithShape:[UIPointerShape beamWithPreferredLength:beamLength axis:axisOrientation] constrainedAxes:iBeamConstraintAxes];
     };
 
     if (self.webView._editable) {

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


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-06-28 23:06:27 UTC (rev 279350)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-06-28 23:52:26 UTC (rev 279351)
@@ -3036,8 +3036,9 @@
     if (isEditable)
         lineRect.setWidth(blockFlow.contentWidth());
 
+    info.isHorizontalWritingMode = renderer->isHorizontalWritingMode();
     info.lineCaretExtent = view->contentsToRootView(lineRect);
-    info.caretHeight = info.lineCaretExtent.height();
+    info.caretLength = info.isHorizontalWritingMode ? info.lineCaretExtent.height() : info.lineCaretExtent.width();
 
     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.
@@ -3050,7 +3051,7 @@
         info.lineCaretExtent = view->contentsToRootView(approximateLineRectInContentCoordinates);
         if (!info.lineCaretExtent.contains(request.point) || !isEditable)
             info.lineCaretExtent.setY(request.point.y() - info.lineCaretExtent.height() / 2);
-        info.caretHeight = info.lineCaretExtent.height();
+        info.caretLength = info.isHorizontalWritingMode ? info.lineCaretExtent.height() : info.lineCaretExtent.width();
     }
 
     auto nodeShouldNotUseIBeam = ^(Node* node) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to