Title: [96823] trunk/Source
Revision
96823
Author
a...@apple.com
Date
2011-10-06 10:04:49 -0700 (Thu, 06 Oct 2011)

Log Message

        https://bugs.webkit.org/show_bug.cgi?id=69492
        [Mac] Should be able to scroll embedded PDFs from keyboard

        Reviewed by Darin Adler.

        * WebProcess/Plugins/Plugin.h:
        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
        (WebKit::NetscapePlugin::handleScroll):
        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
        * WebProcess/Plugins/PluginProxy.cpp:
        (WebKit::PluginProxy::handleScroll):
        * WebProcess/Plugins/PluginProxy.h:
        Added a handleScroll method. A plug-in gets it if it doesn't handle a keyboard event, and
        WebCore decides that this is an event for scrolling. A plug-in can decide whether it scrolls
        main content, or some scrollable subview of its own.

        * WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
        (WebKit::BuiltInPDFView::handleMouseEvent): Added a comment explaining returned value.
        (WebKit::BuiltInPDFView::handleScroll): Just call ScrollableArea, it will do everything.

        * WebProcess/Plugins/PDF/BuiltInPDFView.h: Added a handleScroll override.

        * WebProcess/Plugins/PluginView.cpp:
        (WebKit::PluginView::scroll): Pass a PluginViewBase scroll to plug-in to handle.
        (WebKit::PluginView::handleEvent): Added a FIXME.
        * WebProcess/Plugins/PluginView.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (96822 => 96823)


--- trunk/Source/WebCore/ChangeLog	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebCore/ChangeLog	2011-10-06 17:04:49 UTC (rev 96823)
@@ -1,3 +1,26 @@
+2011-10-05  Alexey Proskuryakov  <a...@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=69492
+        [Mac] Should be able to scroll embedded PDFs from keyboard
+
+        Reviewed by Darin Adler.
+
+        * WebCore.exp.in: Export ScrollableArea::scroll.
+
+        * html/HTMLPlugInElement.cpp: (WebCore::HTMLPlugInElement::defaultEventHandler): Call base
+        class default event handler, so that events on focused plug-in elements would fall through
+        to EventHandler::defaultKeyboardEventHandler.
+
+        * plugins/PluginViewBase.h: (WebCore::PluginViewBase::scroll): Added a method that's called
+        on a plug-in when WebCore asks it to scroll. Plug-in cannot really know what key events
+        result in scroll actions.
+
+        * rendering/RenderEmbeddedObject.cpp:
+        (WebCore::RenderEmbeddedObject::scroll):
+        (WebCore::RenderEmbeddedObject::logicalScroll):
+        * rendering/RenderEmbeddedObject.h:
+        Ask plug-in to scroll when EventHandler::scrollOverflow() is called.
+
 2011-10-06  Konstantin Scheglov  <scheg...@google.com>
 
         REGRESSION (r95852?): Disappearing Border on bugs.webkit.org attachments <table>

Modified: trunk/Source/WebCore/WebCore.exp.in (96822 => 96823)


--- trunk/Source/WebCore/WebCore.exp.in	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-10-06 17:04:49 UTC (rev 96823)
@@ -377,6 +377,7 @@
 __ZN7WebCore14ScrollableArea27willRemoveVerticalScrollbarEPNS_9ScrollbarE
 __ZN7WebCore14ScrollableArea28setScrollOffsetFromInternalsERKNS_8IntPointE
 __ZN7WebCore14ScrollableArea29willRemoveHorizontalScrollbarEPNS_9ScrollbarE
+__ZN7WebCore14ScrollableArea6scrollENS_15ScrollDirectionENS_17ScrollGranularityEf
 __ZN7WebCore14ScrollableAreaC2Ev
 __ZN7WebCore14ScrollableAreaD2Ev
 __ZN7WebCore14ScrollbarTheme11nativeThemeEv

Modified: trunk/Source/WebCore/html/HTMLPlugInElement.cpp (96822 => 96823)


--- trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebCore/html/HTMLPlugInElement.cpp	2011-10-06 17:04:49 UTC (rev 96823)
@@ -181,6 +181,9 @@
     if (!widget)
         return;
     widget->handleEvent(event);
+    if (event->defaultHandled())
+        return;
+    HTMLFrameOwnerElement::defaultEventHandler(event);
 }
 
 #if ENABLE(NETSCAPE_PLUGIN_API)

Modified: trunk/Source/WebCore/plugins/PluginViewBase.h (96822 => 96823)


--- trunk/Source/WebCore/plugins/PluginViewBase.h	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebCore/plugins/PluginViewBase.h	2011-10-06 17:04:49 UTC (rev 96823)
@@ -27,6 +27,7 @@
 
 #include "Widget.h"
 #include "GraphicsLayer.h"
+#include "ScrollTypes.h"
 #include <wtf/text/WTFString.h>
 
 namespace JSC {
@@ -48,6 +49,7 @@
     virtual JSC::JSObject* scriptObject(JSC::JSGlobalObject*) { return 0; }
     virtual void privateBrowsingStateChanged(bool) { }
     virtual bool getFormValue(String&) { return false; }
+    virtual bool scroll(ScrollDirection, ScrollGranularity) { return false; }
 
 protected:
     PluginViewBase(PlatformWidget widget = 0) : Widget(widget) { }

Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp (96822 => 96823)


--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp	2011-10-06 17:04:49 UTC (rev 96823)
@@ -249,7 +249,22 @@
             view->setMarginHeight(marginHeight);
     }
 }
- 
+
+bool RenderEmbeddedObject::scroll(ScrollDirection direction, ScrollGranularity granularity, float, Node**)
+{
+    if (!widget() || !widget()->isPluginViewBase())
+        return false;
+
+    return static_cast<PluginViewBase*>(widget())->scroll(direction, granularity);
+}
+
+bool RenderEmbeddedObject::logicalScroll(ScrollLogicalDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)
+{
+    // Plugins don't expose a writing direction, so assuming horizontal LTR.
+    return scroll(logicalToPhysical(direction, true, false), granularity, multiplier, stopNode);
+}
+
+
 bool RenderEmbeddedObject::isInMissingPluginIndicator(const LayoutPoint& point) const
 {
     FloatRect contentRect;

Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.h (96822 => 96823)


--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.h	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.h	2011-10-06 17:04:49 UTC (rev 96823)
@@ -66,7 +66,10 @@
 
     virtual void layout();
     virtual void viewCleared();
-    
+
+    virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier, Node** stopNode);
+    virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier, Node** stopNode);
+
     void setMissingPluginIndicatorIsPressed(bool);
     bool isInMissingPluginIndicator(MouseEvent*) const;
     bool isInMissingPluginIndicator(const LayoutPoint&) const;

Modified: trunk/Source/WebKit2/ChangeLog (96822 => 96823)


--- trunk/Source/WebKit2/ChangeLog	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebKit2/ChangeLog	2011-10-06 17:04:49 UTC (rev 96823)
@@ -1,3 +1,32 @@
+2011-10-05  Alexey Proskuryakov  <a...@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=69492
+        [Mac] Should be able to scroll embedded PDFs from keyboard
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/Plugins/Plugin.h:
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::handleScroll):
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        * WebProcess/Plugins/PluginProxy.cpp:
+        (WebKit::PluginProxy::handleScroll):
+        * WebProcess/Plugins/PluginProxy.h:
+        Added a handleScroll method. A plug-in gets it if it doesn't handle a keyboard event, and
+        WebCore decides that this is an event for scrolling. A plug-in can decide whether it scrolls
+        main content, or some scrollable subview of its own.
+
+        * WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
+        (WebKit::BuiltInPDFView::handleMouseEvent): Added a comment explaining returned value.
+        (WebKit::BuiltInPDFView::handleScroll): Just call ScrollableArea, it will do everything.
+
+        * WebProcess/Plugins/PDF/BuiltInPDFView.h: Added a handleScroll override.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::scroll): Pass a PluginViewBase scroll to plug-in to handle.
+        (WebKit::PluginView::handleEvent): Added a FIXME.
+        * WebProcess/Plugins/PluginView.h:
+
 2011-10-06  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] Do not use C API in GTK+ API public headers

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (96822 => 96823)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-10-06 17:04:49 UTC (rev 96823)
@@ -880,6 +880,11 @@
     return true;
 }
 
+bool NetscapePlugin::handleScroll(ScrollDirection, ScrollGranularity)
+{
+    return false;
+}
+
 bool NetscapePlugin::supportsSnapshotting() const
 {
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (96822 => 96823)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-10-06 17:04:49 UTC (rev 96823)
@@ -205,6 +205,7 @@
 
     virtual void privateBrowsingStateChanged(bool);
     virtual bool getFormValue(String& formValue);
+    virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
 
     bool supportsSnapshotting() const;
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp (96822 => 96823)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp	2011-10-06 17:04:49 UTC (rev 96823)
@@ -385,6 +385,8 @@
             m_horizontalScrollbar->mouseDown(mouseDownEvent);
         if (m_verticalScrollbar)
             m_verticalScrollbar->mouseDown(mouseDownEvent);
+        // Returning false as that will make EventHandler unfocus the plug-in, which is appropriate when clicking scrollbars.
+        // When support for PDF forms is added, we'll need to actually focus the plug-in.
         break;
     }
     case WebEvent::MouseUp:
@@ -466,6 +468,11 @@
     return false;
 }
 
+bool BuiltInPDFView::handleScroll(ScrollDirection direction, ScrollGranularity granularity)
+{
+    return scroll(direction, granularity);
+}
+
 IntRect BuiltInPDFView::scrollCornerRect() const
 {
     if (!m_horizontalScrollbar || !m_verticalScrollbar)

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h (96822 => 96823)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.h	2011-10-06 17:04:49 UTC (rev 96823)
@@ -102,6 +102,7 @@
 
     virtual void privateBrowsingStateChanged(bool);
     virtual bool getFormValue(String& formValue);
+    virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
 
     // ScrollableArea methods.
     virtual WebCore::IntRect scrollCornerRect() const;

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h (96822 => 96823)


--- trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h	2011-10-06 17:04:49 UTC (rev 96823)
@@ -28,6 +28,7 @@
 
 #include <WebCore/GraphicsLayer.h>
 #include <WebCore/KURL.h>
+#include <WebCore/ScrollTypes.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 
@@ -199,6 +200,9 @@
     // Gets the form value representation for the plug-in, letting plug-ins participate in form submission.
     virtual bool getFormValue(String& formValue) = 0;
 
+    // Tells the plug-in that it should scroll. The plug-in should return true if it did scroll.
+    virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) = 0;
+
 protected:
     Plugin();
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp (96822 => 96823)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp	2011-10-06 17:04:49 UTC (rev 96823)
@@ -382,6 +382,11 @@
     return returnValue;
 }
 
+bool PluginProxy::handleScroll(ScrollDirection, ScrollGranularity)
+{
+    return false;
+}
+
 void PluginProxy::loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups)
 {
     controller()->loadURL(requestID, method, urlString, target, headerFields, httpBody, allowPopups);

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h (96822 => 96823)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2011-10-06 17:04:49 UTC (rev 96823)
@@ -102,6 +102,7 @@
 
     virtual void privateBrowsingStateChanged(bool);
     virtual bool getFormValue(String& formValue);
+    virtual bool handleScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
 
     bool needsBackingStore() const;
     uint64_t windowNPObjectID();

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (96822 => 96823)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-10-06 17:04:49 UTC (rev 96823)
@@ -519,6 +519,15 @@
     return m_plugin->getFormValue(formValue);
 }
 
+bool PluginView::scroll(ScrollDirection direction, ScrollGranularity granularity)
+{
+    // The plug-in can be null here if it failed to initialize.
+    if (!m_isInitialized || !m_plugin)
+        return false;
+
+    return m_plugin->handleScroll(direction, granularity);
+}
+
 void PluginView::setFrameRect(const WebCore::IntRect& rect)
 {
     Widget::setFrameRect(rect);
@@ -582,6 +591,8 @@
         || (event->type() == eventNames().mousedownEvent && currentEvent->type() == WebEvent::MouseDown)
         || (event->type() == eventNames().mouseupEvent && currentEvent->type() == WebEvent::MouseUp)) {
         // We have a mouse event.
+
+        // FIXME: Clicking in a scroll bar should not change focus.
         if (currentEvent->type() == WebEvent::MouseDown)
             focusPluginElement();
         

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h (96822 => 96823)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h	2011-10-06 16:58:22 UTC (rev 96822)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h	2011-10-06 17:04:49 UTC (rev 96823)
@@ -103,6 +103,7 @@
     virtual JSC::JSObject* scriptObject(JSC::JSGlobalObject*);
     virtual void privateBrowsingStateChanged(bool);
     virtual bool getFormValue(String&);
+    virtual bool scroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
 
     // WebCore::Widget
     virtual void setFrameRect(const WebCore::IntRect&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to