Title: [213954] trunk/Source/WebKit2
Revision
213954
Author
[email protected]
Date
2017-03-14 16:18:55 -0700 (Tue, 14 Mar 2017)

Log Message

Let PDFLayerController drive cursor updates so that it's correct more often
https://bugs.webkit.org/show_bug.cgi?id=169626
<rdar://problem/30762943>

Reviewed by Simon Fraser.

* WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h:
* WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h:
* WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm:
(-[WKPDFLayerControllerDelegate setMouseCursor:]):
(WebKit::PDFPlugin::handleMouseEvent):
(WebKit::PDFPlugin::handleMouseEnterEvent):
(WebKit::pdfLayerControllerCursorTypeToCursor):
(WebKit::PDFPlugin::notifyCursorChanged):
Disable updateCursor and use the setMouseCursor delegate method when possible.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (213953 => 213954)


--- trunk/Source/WebKit2/ChangeLog	2017-03-14 23:17:55 UTC (rev 213953)
+++ trunk/Source/WebKit2/ChangeLog	2017-03-14 23:18:55 UTC (rev 213954)
@@ -1,3 +1,21 @@
+2017-03-14  Tim Horton  <[email protected]>
+
+        Let PDFLayerController drive cursor updates so that it's correct more often
+        https://bugs.webkit.org/show_bug.cgi?id=169626
+        <rdar://problem/30762943>
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h:
+        * WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h:
+        * WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm:
+        (-[WKPDFLayerControllerDelegate setMouseCursor:]):
+        (WebKit::PDFPlugin::handleMouseEvent):
+        (WebKit::PDFPlugin::handleMouseEnterEvent):
+        (WebKit::pdfLayerControllerCursorTypeToCursor):
+        (WebKit::PDFPlugin::notifyCursorChanged):
+        Disable updateCursor and use the setMouseCursor delegate method when possible.
+
 2017-03-14  Andrew Gold  <[email protected]>
 
         Extend WKPreferences to include preferences for testing MediaCapture.

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h (213953 => 213954)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h	2017-03-14 23:17:55 UTC (rev 213953)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFLayerControllerSPI.h	2017-03-14 23:18:55 UTC (rev 213954)
@@ -33,6 +33,12 @@
 @class CPReadingModel;
 @class PDFViewLayout;
 
+typedef NS_ENUM(NSInteger, PDFLayerControllerCursorType) {
+    kPDFLayerControllerCursorTypePointer = 0,
+    kPDFLayerControllerCursorTypeHand,
+    kPDFLayerControllerCursorTypeIBeam,
+};
+
 @protocol PDFLayerControllerDelegate <NSObject>
 
 - (void)updateScrollPosition:(CGPoint)newPosition;
@@ -49,6 +55,8 @@
 - (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeDisplayMode:(int)mode;
 - (void)pdfLayerController:(PDFLayerController *)pdfLayerController didChangeSelection:(PDFSelection *)selection;
 
+- (void)setMouseCursor:(PDFLayerControllerCursorType)cursorType;
+
 @end
 
 @interface PDFLayerController : NSObject

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h (213953 => 213954)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h	2017-03-14 23:17:55 UTC (rev 213953)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.h	2017-03-14 23:18:55 UTC (rev 213954)
@@ -87,6 +87,7 @@
     void notifyDisplayModeChanged(int);
 
     void notifySelectionChanged(PDFSelection *);
+    void notifyCursorChanged(uint64_t /* PDFLayerControllerCursorType */);
 
     void clickedLink(NSURL *);
     void saveToPDF();
@@ -249,6 +250,7 @@
 
     WebFrame* webFrame() const { return m_frame; }
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     enum UpdateCursorMode {
         UpdateIfNeeded,
         ForceUpdate
@@ -260,6 +262,7 @@
     };
 
     void updateCursor(const WebMouseEvent&, UpdateCursorMode = UpdateIfNeeded);
+#endif
 
     JSObjectRef makeJSPDFDoc(JSContextRef);
     static JSValueRef jsPDFDocPrint(JSContextRef, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
@@ -297,8 +300,10 @@
 
     String m_lastFoundString;
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     HitTestResult m_lastHitTestResult;
-    
+#endif
+
     RetainPtr<WKPDFLayerControllerDelegate> m_pdfLayerControllerDelegate;
 
     WebCore::IntSize m_size;

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm (213953 => 213954)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm	2017-03-14 23:17:55 UTC (rev 213953)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/DeprecatedPDFPlugin.mm	2017-03-14 23:18:55 UTC (rev 213954)
@@ -396,6 +396,11 @@
     _pdfPlugin->notifySelectionChanged(selection);
 }
 
+- (void)setMouseCursor:(PDFLayerControllerCursorType)cursorType
+{
+    _pdfPlugin->notifyCursorChanged(cursorType);
+}
+
 @end
 
 @interface PDFViewLayout
@@ -1353,6 +1358,7 @@
     return [NSEvent mouseEventWithType:eventType location:positionInPDFViewCoordinates modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:event.clickCount() pressure:0];
 }
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
 void PDFPlugin::updateCursor(const WebMouseEvent& event, UpdateCursorMode mode)
 {
     HitTestResult hitTestResult = None;
@@ -1367,6 +1373,7 @@
     webFrame()->page()->send(Messages::WebPageProxy::SetCursor(hitTestResult == Text ? iBeamCursor() : pointerCursor()));
     m_lastHitTestResult = hitTestResult;
 }
+#endif
 
 bool PDFPlugin::handleMouseEvent(const WebMouseEvent& event)
 {
@@ -1409,7 +1416,9 @@
     switch (event.type()) {
     case WebEvent::MouseMove:
         mouseMovedInContentArea();
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
         updateCursor(event);
+#endif
 
         if (targetScrollbar) {
             if (!targetScrollbarForLastMousePosition) {
@@ -1474,7 +1483,9 @@
 bool PDFPlugin::handleMouseEnterEvent(const WebMouseEvent& event)
 {
     mouseEnteredContentArea();
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     updateCursor(event, ForceUpdate);
+#endif
     return false;
 }
 
@@ -1861,6 +1872,24 @@
     webFrame()->page()->didChangeSelection();
 }
 
+static const Cursor& pdfLayerControllerCursorTypeToCursor(PDFLayerControllerCursorType type)
+{
+    switch (type) {
+    case kPDFLayerControllerCursorTypeHand:
+        return handCursor();
+    case kPDFLayerControllerCursorTypeIBeam:
+        return iBeamCursor();
+    case kPDFLayerControllerCursorTypePointer:
+    default:
+        return pointerCursor();
+    }
+}
+
+void PDFPlugin::notifyCursorChanged(uint64_t type)
+{
+    webFrame()->page()->send(Messages::WebPageProxy::SetCursor(pdfLayerControllerCursorTypeToCursor(static_cast<PDFLayerControllerCursorType>(type))));
+}
+
 String PDFPlugin::getSelectionString() const
 {
     return [[m_pdfLayerController currentSelection] string];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to