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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138361 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f5661e0e
2012-12-21 Tim Horton <timothy_horton@apple.com>
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 <webkit.review.bot@gmail.com>
Unreviewed, rolling out r138338.
......@@ -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 @@ DragOperation DragController::operationForLoad(DragData* dragData)
{
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);
}
......
......@@ -75,6 +75,8 @@ public:
virtual bool shouldAlwaysAutoStart() const { return false; }
virtual bool shouldAllowNavigationFromDrags() const { return false; }
protected:
explicit PluginViewBase(PlatformWidget widget = 0) : Widget(widget) { }
......
2012-12-21 Tim Horton <timothy_horton@apple.com>
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 <webkit.review.bot@gmail.com>
Unreviewed, rolling out r138357.
......@@ -926,6 +926,11 @@ bool NetscapePlugin::shouldAllowScripting()
return true;
}
bool NetscapePlugin::shouldAllowNavigationFromDrags()
{
return false;
}
bool NetscapePlugin::handlesPageScaleFactor()
{
return false;
......
......@@ -208,6 +208,7 @@ private:
virtual bool isEditingCommandEnabled(const String&) OVERRIDE;
virtual bool shouldAllowScripting() OVERRIDE;
virtual bool shouldAllowNavigationFromDrags() OVERRIDE;
virtual bool handlesPageScaleFactor() OVERRIDE;
......
......@@ -172,6 +172,7 @@ protected:
virtual bool handlesPageScaleFactor() OVERRIDE;
virtual bool shouldAllowScripting() OVERRIDE { return false; }
virtual bool shouldAllowNavigationFromDrags() { return true; }
WebCore::IntSize m_scrollOffset;
......
......@@ -197,6 +197,9 @@ public:
// 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;
......
......@@ -105,6 +105,7 @@ private:
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();
......
......@@ -856,6 +856,14 @@ bool PluginView::shouldAllowScripting()
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) {
......
......@@ -138,6 +138,7 @@ private:
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&);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment