Title: [233296] trunk/Source/WebKit
Revision
233296
Author
[email protected]
Date
2018-06-27 18:29:44 -0700 (Wed, 27 Jun 2018)

Log Message

Fix IBeam issues with iPad apps on Mac
https://bugs.webkit.org/show_bug.cgi?id=186900

Reviewed by Wenson Hsieh.

* Shared/ios/InteractionInformationAtPosition.h:
* Shared/ios/InteractionInformationAtPosition.mm:
(WebKit::InteractionInformationAtPosition::encode const):
(WebKit::InteractionInformationAtPosition::decode):

Add functionality to determine what a caret rect should be, but as it is
expensive, it should only be done for this platform.

* Shared/ios/InteractionInformationRequest.cpp:
(WebKit::InteractionInformationRequest::isApproximateForRequest):
* Shared/ios/InteractionInformationRequest.h:

As there is no way to premptively request information on hover, we need to use
the last cached information, but only if it is close to the point we are about
to request information for. So having a way to determine if a point is very close
to a previous point is a good idea.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _currentPositionInformationIsApproximateForRequest:]):
(-[WKContentView closestPositionToPoint:]):

UIKit is using this function to determine if we should show an Ibeam or not.
So we need to implement it, at least for this platform.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getPositionInformation):

Pass up the calculated caret rect, but only for iPad apps on Mac.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (233295 => 233296)


--- trunk/Source/WebKit/ChangeLog	2018-06-28 01:10:37 UTC (rev 233295)
+++ trunk/Source/WebKit/ChangeLog	2018-06-28 01:29:44 UTC (rev 233296)
@@ -1,3 +1,39 @@
+2018-06-27  Megan Gardner  <[email protected]>
+
+        Fix IBeam issues with iPad apps on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=186900
+
+        Reviewed by Wenson Hsieh.
+
+        * Shared/ios/InteractionInformationAtPosition.h:
+        * Shared/ios/InteractionInformationAtPosition.mm:
+        (WebKit::InteractionInformationAtPosition::encode const):
+        (WebKit::InteractionInformationAtPosition::decode):
+
+        Add functionality to determine what a caret rect should be, but as it is
+        expensive, it should only be done for this platform.
+        
+        * Shared/ios/InteractionInformationRequest.cpp:
+        (WebKit::InteractionInformationRequest::isApproximateForRequest):
+        * Shared/ios/InteractionInformationRequest.h:
+
+        As there is no way to premptively request information on hover, we need to use 
+        the last cached information, but only if it is close to the point we are about
+        to request information for. So having a way to determine if a point is very close
+        to a previous point is a good idea.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _currentPositionInformationIsApproximateForRequest:]):
+        (-[WKContentView closestPositionToPoint:]):
+
+        UIKit is using this function to determine if we should show an Ibeam or not.
+        So we need to implement it, at least for this platform. 
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getPositionInformation):
+
+        Pass up the calculated caret rect, but only for iPad apps on Mac.
+
 2018-06-27  Yusuke Suzuki  <[email protected]>
 
         [GTK][WPE] Use LazyNeverDestroyed<XErrorTrapper> to remove static initializers

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h (233295 => 233296)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h	2018-06-28 01:10:37 UTC (rev 233295)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h	2018-06-28 01:29:44 UTC (rev 233296)
@@ -62,6 +62,9 @@
     String title;
     String idAttribute;
     WebCore::IntRect bounds;
+#if ENABLE(MINIMAL_SIMULATOR)
+    WebCore::IntRect caretRect;
+#endif
     RefPtr<ShareableBitmap> image;
     String textBefore;
     String textAfter;

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm (233295 => 233296)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm	2018-06-28 01:10:37 UTC (rev 233295)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm	2018-06-28 01:29:44 UTC (rev 233296)
@@ -61,6 +61,9 @@
     encoder << title;
     encoder << idAttribute;
     encoder << bounds;
+#if ENABLE(MINIMAL_SIMULATOR)
+    encoder << caretRect;
+#endif
     encoder << textBefore;
     encoder << textAfter;
     encoder << linkIndicator;
@@ -135,6 +138,11 @@
     
     if (!decoder.decode(result.bounds))
         return false;
+    
+#if ENABLE(MINIMAL_SIMULATOR)
+    if (!decoder.decode(result.caretRect))
+        return false;
+#endif
 
     if (!decoder.decode(result.textBefore))
         return false;

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp (233295 => 233296)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp	2018-06-28 01:10:37 UTC (rev 233295)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp	2018-06-28 01:29:44 UTC (rev 233296)
@@ -67,6 +67,17 @@
 
     return true;
 }
+    
+bool InteractionInformationRequest::isApproximatelyValidForRequest(const InteractionInformationRequest& other)
+{
+    if (other.includeSnapshot && !includeSnapshot)
+        return false;
+    
+    if (other.includeLinkIndicator && !includeLinkIndicator)
+        return false;
+    
+    return (other.point - point).diagonalLengthSquared() <= 4;
+}
 
 #endif // PLATFORM(IOS)
 

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h (233295 => 233296)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h	2018-06-28 01:10:37 UTC (rev 233295)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h	2018-06-28 01:29:44 UTC (rev 233296)
@@ -49,6 +49,7 @@
     }
 
     bool isValidForRequest(const InteractionInformationRequest&);
+    bool isApproximatelyValidForRequest(const InteractionInformationRequest& other);
 
     void encode(IPC::Encoder&) const;
     static bool decode(IPC::Decoder&, InteractionInformationRequest&);

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (233295 => 233296)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-06-28 01:10:37 UTC (rev 233295)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-06-28 01:29:44 UTC (rev 233296)
@@ -1500,6 +1500,11 @@
     return _outstandingPositionInformationRequest && _outstandingPositionInformationRequest->isValidForRequest(request);
 }
 
+- (BOOL)_currentPositionInformationIsApproximatelyValidForRequest:(const InteractionInformationRequest&)request
+{
+    return _hasValidPositionInformation && _positionInformation.request.isApproximatelyValidForRequest(request);
+}
+
 - (void)_invokeAndRemovePendingHandlersValidForCurrentPositionInformation
 {
     ASSERT(_hasValidPositionInformation);
@@ -3320,6 +3325,12 @@
 /* Hit testing. */
 - (UITextPosition *)closestPositionToPoint:(CGPoint)point
 {
+#if ENABLE(MINIMAL_SIMULATOR)
+    InteractionInformationRequest request(roundedIntPoint(point));
+    [self requestAsynchronousPositionInformationUpdate:request];
+    if ([self _currentPositionInformationIsApproximatelyValidForRequest:request] && _positionInformation.isSelectable)
+        return [WKTextPosition textPositionWithRect:_positionInformation.caretRect];
+#endif
     return nil;
 }
 

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


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-06-28 01:10:37 UTC (rev 233295)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2018-06-28 01:29:44 UTC (rev 233296)
@@ -2175,6 +2175,11 @@
                 if (info.isSelectable && !hitNode->isTextNode())
                     info.isSelectable = !isAssistableElement(*downcast<Element>(hitNode)) && !rectIsTooBigForSelection(info.bounds, *result.innerNodeFrame());
             }
+#if ENABLE(MINIMAL_SIMULATOR)
+            bool isInsideFixedPosition;
+            VisiblePosition caretPosition(renderer->positionForPoint(request.point, nullptr));
+            info.caretRect = caretPosition.absoluteCaretBounds(&isInsideFixedPosition);
+#endif
         }
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to