Title: [135916] trunk/Source
- Revision
- 135916
- Author
- [email protected]
- Date
- 2012-11-27 13:56:44 -0800 (Tue, 27 Nov 2012)
Log Message
PDFPlugin: Scroll bars do not grow on hover
https://bugs.webkit.org/show_bug.cgi?id=103382
<rdar://problem/12555262>
Reviewed by Beth Dakin.
PDFPlugin needs to forward relevant mouse events to the scrollbars.
In addition, it needs to implement currentMousePosition so ScrollableArea and friends
can find the mouse position at arbitrary times.
I also took this opportunity to factor some coordinate space conversion functions out.
* WebProcess/Plugins/PDF/PDFPlugin.h:
(WebKit::PDFPlugin::currentMousePosition): Added. Return the last mouse position in our coordinate space.
(WebKit::PDFPlugin::convertFromRootViewToPlugin): Added.
(WebKit::PDFPlugin::convertFromPluginToPDFView): Added.
(PDFPlugin):
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::convertFromRootViewToPlugin): Convert a point from content space to plugin space, via the transform we get in geometryDidChange.
(WebKit::PDFPlugin::convertFromPluginToPDFView): Convert a point from plugin space to PDFLayerController's flipped coordinate space.
(WebKit::PDFPlugin::geometryDidChange): Use convertFromPluginToPDFView.
(WebKit::PDFPlugin::nsEventForWebMouseEvent): Cache the mouse position in plugin space instead of PDFLayerController space. Use our new conversion functions.
(WebKit::PDFPlugin::handleMouseEvent): Forward relevant mouse events to scrollbars:
Determine which scrollbar the mouse is over now, and which it was previously over, and use that to:
If the mouse is moved over a scrollbar, send mouseEntered to the scrollbar.
If the mouse is moved out of a scrollbar, send mouseExited to the scrollbar.
If the mouse is currently over a scrollbar, send mouseMoved/Up/Down to the scrollbar instead of PDFLayerController.
If the mouse is currently over the scroll corner, bail, because nobody should get those events.
Export a few WebCore::Scrollbar methods to WebKit(2).
* WebCore.exp.in:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (135915 => 135916)
--- trunk/Source/WebCore/ChangeLog 2012-11-27 21:52:47 UTC (rev 135915)
+++ trunk/Source/WebCore/ChangeLog 2012-11-27 21:56:44 UTC (rev 135916)
@@ -1,3 +1,15 @@
+2012-11-27 Tim Horton <[email protected]>
+
+ PDFPlugin: Scroll bars do not grow on hover
+ https://bugs.webkit.org/show_bug.cgi?id=103382
+ <rdar://problem/12555262>
+
+ Reviewed by Beth Dakin.
+
+ Export a few WebCore::Scrollbar methods to WebKit(2).
+
+ * WebCore.exp.in:
+
2012-11-27 Tom Sepez <[email protected]>
Regression(r129406): Fix the scope of the WidgetHierarchyUpdateSuspensionScope in Element::Attach().
Modified: trunk/Source/WebCore/WebCore.exp.in (135915 => 135916)
--- trunk/Source/WebCore/WebCore.exp.in 2012-11-27 21:52:47 UTC (rev 135915)
+++ trunk/Source/WebCore/WebCore.exp.in 2012-11-27 21:56:44 UTC (rev 135916)
@@ -1077,6 +1077,9 @@
__ZN7WebCore9PageGroup29removeUserStyleSheetFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE
__ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldEPNS_15DOMWrapperWorldE
__ZN7WebCore9PageGroup9pageGroupERKN3WTF6StringE
+__ZN7WebCore9Scrollbar10mouseMovedERKNS_18PlatformMouseEventE
+__ZN7WebCore9Scrollbar11mouseExitedEv
+__ZN7WebCore9Scrollbar12mouseEnteredEv
__ZN7WebCore9Scrollbar13setProportionEii
__ZN7WebCore9Scrollbar21createNativeScrollbarEPNS_14ScrollableAreaENS_20ScrollbarOrientationENS_20ScrollbarControlSizeE
__ZN7WebCore9Scrollbar22maxOverlapBetweenPagesEv
Modified: trunk/Source/WebKit2/ChangeLog (135915 => 135916)
--- trunk/Source/WebKit2/ChangeLog 2012-11-27 21:52:47 UTC (rev 135915)
+++ trunk/Source/WebKit2/ChangeLog 2012-11-27 21:56:44 UTC (rev 135916)
@@ -1,3 +1,34 @@
+2012-11-27 Tim Horton <[email protected]>
+
+ PDFPlugin: Scroll bars do not grow on hover
+ https://bugs.webkit.org/show_bug.cgi?id=103382
+ <rdar://problem/12555262>
+
+ Reviewed by Beth Dakin.
+
+ PDFPlugin needs to forward relevant mouse events to the scrollbars.
+ In addition, it needs to implement currentMousePosition so ScrollableArea and friends
+ can find the mouse position at arbitrary times.
+
+ I also took this opportunity to factor some coordinate space conversion functions out.
+
+ * WebProcess/Plugins/PDF/PDFPlugin.h:
+ (WebKit::PDFPlugin::currentMousePosition): Added. Return the last mouse position in our coordinate space.
+ (WebKit::PDFPlugin::convertFromRootViewToPlugin): Added.
+ (WebKit::PDFPlugin::convertFromPluginToPDFView): Added.
+ (PDFPlugin):
+ * WebProcess/Plugins/PDF/PDFPlugin.mm:
+ (WebKit::PDFPlugin::convertFromRootViewToPlugin): Convert a point from content space to plugin space, via the transform we get in geometryDidChange.
+ (WebKit::PDFPlugin::convertFromPluginToPDFView): Convert a point from plugin space to PDFLayerController's flipped coordinate space.
+ (WebKit::PDFPlugin::geometryDidChange): Use convertFromPluginToPDFView.
+ (WebKit::PDFPlugin::nsEventForWebMouseEvent): Cache the mouse position in plugin space instead of PDFLayerController space. Use our new conversion functions.
+ (WebKit::PDFPlugin::handleMouseEvent): Forward relevant mouse events to scrollbars:
+ Determine which scrollbar the mouse is over now, and which it was previously over, and use that to:
+ If the mouse is moved over a scrollbar, send mouseEntered to the scrollbar.
+ If the mouse is moved out of a scrollbar, send mouseExited to the scrollbar.
+ If the mouse is currently over a scrollbar, send mouseMoved/Up/Down to the scrollbar instead of PDFLayerController.
+ If the mouse is currently over the scroll corner, bail, because nobody should get those events.
+
2012-11-27 Dan Bernstein <[email protected]>
Entering Tab View after a bunch of YouTube pages were opened in background tabs makes all of them start playing simultaneously
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h (135915 => 135916)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h 2012-11-27 21:52:47 UTC (rev 135915)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h 2012-11-27 21:56:44 UTC (rev 135916)
@@ -94,8 +94,11 @@
virtual void setScrollOffset(const WebCore::IntPoint&) OVERRIDE;
virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&) OVERRIDE;
virtual void invalidateScrollCornerRect(const WebCore::IntRect&) OVERRIDE;
+ virtual WebCore::IntPoint currentMousePosition() const { return m_lastMousePositionInPluginCoordinates; }
NSEvent *nsEventForWebMouseEvent(const WebMouseEvent&);
+ WebCore::IntPoint convertFromPluginToPDFView(const WebCore::IntPoint&) const;
+ WebCore::IntPoint convertFromRootViewToPlugin(const WebCore::IntPoint&) const;
bool supportsForms();
@@ -110,8 +113,8 @@
RefPtr<WebCore::Element> m_annotationContainer;
WebCore::AffineTransform m_rootViewToPluginTransform;
- WebCore::IntPoint m_lastMousePoint;
WebMouseEvent m_lastMouseEvent;
+ WebCore::IntPoint m_lastMousePositionInPluginCoordinates;
RetainPtr<WKPDFLayerControllerDelegate> m_pdfLayerControllerDelegate;
};
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (135915 => 135916)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2012-11-27 21:52:47 UTC (rev 135915)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2012-11-27 21:56:44 UTC (rev 135916)
@@ -405,6 +405,16 @@
return m_containerLayer.get();
}
+IntPoint PDFPlugin::convertFromRootViewToPlugin(const IntPoint& point) const
+{
+ return m_rootViewToPluginTransform.mapPoint(point);
+}
+
+IntPoint PDFPlugin::convertFromPluginToPDFView(const IntPoint& point) const
+{
+ return IntPoint(point.x(), size().height() - point.y());
+}
+
void PDFPlugin::geometryDidChange(const IntSize& pluginSize, const IntRect&, const AffineTransform& pluginToRootViewTransform)
{
if (size() == pluginSize && pluginView()->pageScaleFactor() == [m_pdfLayerController.get() contentScaleFactor])
@@ -422,9 +432,9 @@
if (handlesPageScaleFactor()) {
CGFloat magnification = pluginView()->pageScaleFactor() - [m_pdfLayerController.get() contentScaleFactor];
- // FIXME: Instead of m_lastMousePoint, we should use the zoom origin from PluginView::setPageScaleFactor.
+ // FIXME: Instead of m_lastMousePositionInPluginCoordinates, we should use the zoom origin from PluginView::setPageScaleFactor.
if (magnification)
- [m_pdfLayerController.get() magnifyWithMagnification:magnification atPoint:m_lastMousePoint immediately:NO];
+ [m_pdfLayerController.get() magnifyWithMagnification:magnification atPoint:convertFromPluginToPDFView(m_lastMousePositionInPluginCoordinates) immediately:NO];
}
calculateSizes();
@@ -493,14 +503,10 @@
NSEvent *PDFPlugin::nsEventForWebMouseEvent(const WebMouseEvent& event)
{
- IntPoint mousePosition = event.position();
+ m_lastMousePositionInPluginCoordinates = convertFromRootViewToPlugin(event.position());
- IntPoint positionInPDFView(mousePosition);
- positionInPDFView = m_rootViewToPluginTransform.mapPoint(positionInPDFView);
- positionInPDFView.setY(size().height() - positionInPDFView.y());
+ IntPoint positionInPDFViewCoordinates(convertFromPluginToPDFView(m_lastMousePositionInPluginCoordinates));
- m_lastMousePoint = positionInPDFView;
-
NSEventType eventType = eventTypeFromWebEvent(event);
if (!eventType)
@@ -508,19 +514,36 @@
NSUInteger modifierFlags = modifierFlagsFromWebEvent(event);
- return [NSEvent mouseEventWithType:eventType location:positionInPDFView modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:event.clickCount() pressure:0];
+ return [NSEvent mouseEventWithType:eventType location:positionInPDFViewCoordinates modifierFlags:modifierFlags timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:event.clickCount() pressure:0];
}
bool PDFPlugin::handleMouseEvent(const WebMouseEvent& event)
{
+ PlatformMouseEvent platformEvent = platform(event);
+ IntPoint mousePosition = convertFromRootViewToPlugin(event.position());
+
m_lastMouseEvent = event;
- IntPoint mousePosition = event.position();
+ RefPtr<Scrollbar> targetScrollbar;
+ RefPtr<Scrollbar> targetScrollbarForLastMousePosition;
- // FIXME: Forward mouse events to the appropriate scrollbar.
- if (IntRect(m_verticalScrollbarLayer.get().frame).contains(mousePosition)
- || IntRect(m_horizontalScrollbarLayer.get().frame).contains(mousePosition)
- || IntRect(m_scrollCornerLayer.get().frame).contains(mousePosition))
+ if (m_verticalScrollbarLayer) {
+ IntRect verticalScrollbarFrame(m_verticalScrollbarLayer.get().frame);
+ if (verticalScrollbarFrame.contains(mousePosition))
+ targetScrollbar = verticalScrollbar();
+ if (verticalScrollbarFrame.contains(m_lastMousePositionInPluginCoordinates))
+ targetScrollbarForLastMousePosition = verticalScrollbar();
+ }
+
+ if (m_horizontalScrollbarLayer) {
+ IntRect horizontalScrollbarFrame(m_horizontalScrollbarLayer.get().frame);
+ if (horizontalScrollbarFrame.contains(mousePosition))
+ targetScrollbar = horizontalScrollbar();
+ if (horizontalScrollbarFrame.contains(m_lastMousePositionInPluginCoordinates))
+ targetScrollbarForLastMousePosition = horizontalScrollbar();
+ }
+
+ if (m_scrollCornerLayer && IntRect(m_scrollCornerLayer.get().frame).contains(mousePosition))
return false;
// Right-clicks and Control-clicks always call handleContextMenuEvent as well.
@@ -533,6 +556,17 @@
case WebEvent::MouseMove:
mouseMovedInContentArea();
+ if (targetScrollbar) {
+ if (!targetScrollbarForLastMousePosition) {
+ targetScrollbar->mouseEntered();
+ return true;
+ }
+ return targetScrollbar->mouseMoved(platformEvent);
+ }
+
+ if (!targetScrollbar && targetScrollbarForLastMousePosition)
+ targetScrollbarForLastMousePosition->mouseExited();
+
switch (event.button()) {
case WebMouseEvent::LeftButton:
[m_pdfLayerController.get() mouseDragged:nsEvent];
@@ -547,6 +581,9 @@
case WebEvent::MouseDown:
switch (event.button()) {
case WebMouseEvent::LeftButton:
+ if (targetScrollbar)
+ return targetScrollbar->mouseDown(platformEvent);
+
[m_pdfLayerController.get() mouseDown:nsEvent];
return true;
case WebMouseEvent::RightButton:
@@ -559,6 +596,9 @@
case WebEvent::MouseUp:
switch (event.button()) {
case WebMouseEvent::LeftButton:
+ if (targetScrollbar)
+ return targetScrollbar->mouseUp(platformEvent);
+
[m_pdfLayerController.get() mouseUp:nsEvent];
return true;
case WebMouseEvent::RightButton:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes