Title: [138361] trunk/Source
Revision
138361
Author
[email protected]
Date
2012-12-21 02:31:34 -0800 (Fri, 21 Dec 2012)

Log Message

PDFPlugin: Cannot drop files/URLs on PDFPlugin
https://bugs.webkit.org/show_bug.cgi?id=105516
<rdar://problem/12729443>

Reviewed by Alexey Proskuryakov.

Add shouldAllowNavigationFromDrags to Plugin/PluginView/etc., which WebCore will
consult when dragging over a PluginDocument to decide whether or not a drag may result in navigation.

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::shouldAllowNavigationFromDrags): Added, always returning false to keep existing behavior.
* WebProcess/Plugins/Netscape/NetscapePlugin.h:
(NetscapePlugin): Added.
* WebProcess/Plugins/PDF/SimplePDFPlugin.h:
(WebKit::SimplePDFPlugin::shouldAllowNavigationFromDrags): Added, always returning true. (Simple)PDFPlugin should
navigate when dropped onto, just like an image or HTML document would.
* WebProcess/Plugins/Plugin.h:
(Plugin): Add shouldAllowNavigationFromDrags.
* WebProcess/Plugins/PluginProxy.h: Add shouldAllowNavigationFromDrags.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::shouldAllowNavigationFromDrags): Forward shouldAllowNavigationFromDrags to the plugin.
* WebProcess/Plugins/PluginView.h: Add shouldAllowNavigationFromDrags.

* page/DragController.cpp:
(WebCore::DragController::operationForLoad): If we drag over a PluginDocument, check if its PluginView
claims to support navigation resulting from a drag (only PDFPlugin will for now). If it does, allow the drag.
* plugins/PluginViewBase.h:
(WebCore::PluginViewBase::shouldAllowNavigationFromDrags): Add shouldAllowNavigationFromDrags.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (138360 => 138361)


--- trunk/Source/WebCore/ChangeLog	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebCore/ChangeLog	2012-12-21 10:31:34 UTC (rev 138361)
@@ -1,3 +1,17 @@
+2012-12-21  Tim Horton  <[email protected]>
+
+        PDFPlugin: Cannot drop files/URLs on PDFPlugin
+        https://bugs.webkit.org/show_bug.cgi?id=105516
+        <rdar://problem/12729443>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * page/DragController.cpp:
+        (WebCore::DragController::operationForLoad): If we drag over a PluginDocument, check if its PluginView
+        claims to support navigation resulting from a drag (only PDFPlugin will for now). If it does, allow the drag.
+        * plugins/PluginViewBase.h:
+        (WebCore::PluginViewBase::shouldAllowNavigationFromDrags): Add shouldAllowNavigationFromDrags.
+
 2012-12-21  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r138338.

Modified: trunk/Source/WebCore/page/DragController.cpp (138360 => 138361)


--- trunk/Source/WebCore/page/DragController.cpp	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebCore/page/DragController.cpp	2012-12-21 10:31:34 UTC (rev 138361)
@@ -58,6 +58,8 @@
 #include "Node.h"
 #include "Page.h"
 #include "PlatformKeyboardEvent.h"
+#include "PluginDocument.h"
+#include "PluginViewBase.h"
 #include "RenderFileUploadControl.h"
 #include "RenderImage.h"
 #include "RenderView.h"
@@ -405,7 +407,18 @@
 {
     ASSERT(dragData);
     Document* doc = m_page->mainFrame()->documentAtPoint(dragData->clientPosition());
-    if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->rendererIsEditable()))
+
+    bool pluginDocumentAcceptsDrags = false;
+
+    if (doc && doc->isPluginDocument()) {
+        const Widget* widget = static_cast<PluginDocument*>(doc)->pluginWidget();
+        const PluginViewBase* pluginView = (widget && widget->isPluginViewBase()) ? static_cast<const PluginViewBase*>(widget) : 0;
+
+        if (pluginView)
+            pluginDocumentAcceptsDrags = pluginView->shouldAllowNavigationFromDrags();
+    }
+
+    if (doc && (m_didInitiateDrag || (doc->isPluginDocument() && !pluginDocumentAcceptsDrags) || doc->rendererIsEditable()))
         return DragOperationNone;
     return dragOperation(dragData);
 }

Modified: trunk/Source/WebCore/plugins/PluginViewBase.h (138360 => 138361)


--- trunk/Source/WebCore/plugins/PluginViewBase.h	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebCore/plugins/PluginViewBase.h	2012-12-21 10:31:34 UTC (rev 138361)
@@ -75,6 +75,8 @@
 
     virtual bool shouldAlwaysAutoStart() const { return false; }
 
+    virtual bool shouldAllowNavigationFromDrags() const { return false; }
+
 protected:
     explicit PluginViewBase(PlatformWidget widget = 0) : Widget(widget) { }
     

Modified: trunk/Source/WebKit2/ChangeLog (138360 => 138361)


--- trunk/Source/WebKit2/ChangeLog	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-21 10:31:34 UTC (rev 138361)
@@ -1,3 +1,28 @@
+2012-12-21  Tim Horton  <[email protected]>
+
+        PDFPlugin: Cannot drop files/URLs on PDFPlugin
+        https://bugs.webkit.org/show_bug.cgi?id=105516
+        <rdar://problem/12729443>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Add shouldAllowNavigationFromDrags to Plugin/PluginView/etc., which WebCore will
+        consult when dragging over a PluginDocument to decide whether or not a drag may result in navigation.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::shouldAllowNavigationFromDrags): Added, always returning false to keep existing behavior.
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        (NetscapePlugin): Added.
+        * WebProcess/Plugins/PDF/SimplePDFPlugin.h:
+        (WebKit::SimplePDFPlugin::shouldAllowNavigationFromDrags): Added, always returning true. (Simple)PDFPlugin should
+        navigate when dropped onto, just like an image or HTML document would.
+        * WebProcess/Plugins/Plugin.h:
+        (Plugin): Add shouldAllowNavigationFromDrags.
+        * WebProcess/Plugins/PluginProxy.h: Add shouldAllowNavigationFromDrags.
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::shouldAllowNavigationFromDrags): Forward shouldAllowNavigationFromDrags to the plugin.
+        * WebProcess/Plugins/PluginView.h: Add shouldAllowNavigationFromDrags.
+
 2012-12-21  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r138357.

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


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2012-12-21 10:31:34 UTC (rev 138361)
@@ -926,6 +926,11 @@
     return true;
 }
 
+bool NetscapePlugin::shouldAllowNavigationFromDrags()
+{
+    return false;
+}
+
 bool NetscapePlugin::handlesPageScaleFactor()
 {
     return false;

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


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2012-12-21 10:31:34 UTC (rev 138361)
@@ -208,6 +208,7 @@
     virtual bool isEditingCommandEnabled(const String&) OVERRIDE;
 
     virtual bool shouldAllowScripting() OVERRIDE;
+    virtual bool shouldAllowNavigationFromDrags() OVERRIDE;
     
     virtual bool handlesPageScaleFactor() OVERRIDE;
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h (138360 => 138361)


--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h	2012-12-21 10:31:34 UTC (rev 138361)
@@ -172,6 +172,7 @@
     virtual bool handlesPageScaleFactor() OVERRIDE;
 
     virtual bool shouldAllowScripting() OVERRIDE { return false; }
+    virtual bool shouldAllowNavigationFromDrags() { return true; }
 
     WebCore::IntSize m_scrollOffset;
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h (138360 => 138361)


--- trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h	2012-12-21 10:31:34 UTC (rev 138361)
@@ -197,6 +197,9 @@
 
     // Ask the plug-in whether it should be allowed to execute _javascript_ or navigate to _javascript_ URLs.
     virtual bool shouldAllowScripting() = 0;
+
+    // Ask the plug-in whether it wants URLs and files dragged onto it to cause navigation.
+    virtual bool shouldAllowNavigationFromDrags() = 0;
     
     // Ask the plug-in whether it wants to override full-page zoom.
     virtual bool handlesPageScaleFactor() = 0;

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h (138360 => 138361)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2012-12-21 10:31:34 UTC (rev 138361)
@@ -105,6 +105,7 @@
     virtual bool handleEditingCommand(const String& commandName, const String& argument) OVERRIDE;
     virtual bool isEditingCommandEnabled(const String& commandName) OVERRIDE;
     virtual bool shouldAllowScripting() OVERRIDE { return true; }
+    virtual bool shouldAllowNavigationFromDrags() OVERRIDE { return false; }
     
     virtual bool handlesPageScaleFactor();
     

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (138360 => 138361)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2012-12-21 10:31:34 UTC (rev 138361)
@@ -856,6 +856,14 @@
     return m_plugin->shouldAllowScripting();
 }
 
+bool PluginView::shouldAllowNavigationFromDrags() const
+{
+    if (!m_isInitialized || !m_plugin)
+        return false;
+
+    return m_plugin->shouldAllowNavigationFromDrags();
+}
+
 void PluginView::notifyWidget(WidgetNotification notification)
 {
     switch (notification) {

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h (138360 => 138361)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h	2012-12-21 10:19:05 UTC (rev 138360)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h	2012-12-21 10:31:34 UTC (rev 138361)
@@ -138,6 +138,7 @@
     virtual WebCore::Scrollbar* verticalScrollbar();
     virtual bool wantsWheelEvents();
     virtual bool shouldAlwaysAutoStart() const OVERRIDE;
+    virtual bool shouldAllowNavigationFromDrags() const OVERRIDE;
 
     // WebCore::Widget
     virtual void setFrameRect(const WebCore::IntRect&);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to