Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (104633 => 104634)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-01-10 22:50:51 UTC (rev 104633)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-01-10 23:01:52 UTC (rev 104634)
@@ -1,3 +1,26 @@
+2012-01-10 Bill Budge <[email protected]>
+
+ Allow plugins to add rotate items to browser's context menu. Adds a new
+ WebPluginAction struct, with rotate types.
+ https://bugs.webkit.org/show_bug.cgi?id=75645
+
+ Reviewed by Darin Fisher.
+
+ * WebKit.gyp:
+ * public/WebContextMenuData.h:
+ * public/WebPlugin.h:
+ (WebKit::WebPlugin::canRotateView):
+ (WebKit::WebPlugin::rotateView):
+ * public/WebPluginAction.h: Added.
+ (WebKit::WebPluginAction::WebPluginAction):
+ * public/WebView.h:
+ * src/ContextMenuClientImpl.cpp:
+ (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::performMediaPlayerAction):
+ (WebKit::WebViewImpl::performPluginAction):
+ * src/WebViewImpl.h:
+
2012-01-10 Dana Jansens <[email protected]>
[chromium] Create iterators for the RenderSurface-Layer tree
Modified: trunk/Source/WebKit/chromium/WebKit.gyp (104633 => 104634)
--- trunk/Source/WebKit/chromium/WebKit.gyp 2012-01-10 22:50:51 UTC (rev 104633)
+++ trunk/Source/WebKit/chromium/WebKit.gyp 2012-01-10 23:01:52 UTC (rev 104634)
@@ -216,6 +216,7 @@
'public/WebPerformance.h',
'public/WebPermissionClient.h',
'public/WebPlugin.h',
+ 'public/WebPluginAction.h',
'public/WebPluginContainer.h',
'public/WebPluginDocument.h',
'public/WebPluginListBuilder.h',
Modified: trunk/Source/WebKit/chromium/public/WebContextMenuData.h (104633 => 104634)
--- trunk/Source/WebKit/chromium/public/WebContextMenuData.h 2012-01-10 22:50:51 UTC (rev 104633)
+++ trunk/Source/WebKit/chromium/public/WebContextMenuData.h 2012-01-10 23:01:52 UTC (rev 104634)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -102,6 +102,7 @@
MediaHasVideo = 0x40,
MediaControlRootElement = 0x80,
MediaCanPrint = 0x100,
+ MediaCanRotate = 0x200,
};
// Extra attributes describing media elements.
Modified: trunk/Source/WebKit/chromium/public/WebPlugin.h (104633 => 104634)
--- trunk/Source/WebKit/chromium/public/WebPlugin.h 2012-01-10 22:50:51 UTC (rev 104633)
+++ trunk/Source/WebKit/chromium/public/WebPlugin.h 2012-01-10 23:01:52 UTC (rev 104634)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -125,6 +125,16 @@
// Tells the plugin that the user has stopped the find operation.
virtual void stopFind() { }
+ // View rotation types.
+ enum RotationType {
+ RotationType90Clockwise,
+ RotationType90Counterclockwise
+ };
+ // Whether the plugin can rotate the view of its content.
+ virtual bool canRotateView() { return false; }
+ // Rotates the plugin's view of its content.
+ virtual void rotateView(RotationType type) { }
+
protected:
~WebPlugin() { }
};
Added: trunk/Source/WebKit/chromium/public/WebPluginAction.h (0 => 104634)
--- trunk/Source/WebKit/chromium/public/WebPluginAction.h (rev 0)
+++ trunk/Source/WebKit/chromium/public/WebPluginAction.h 2012-01-10 23:01:52 UTC (rev 104634)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPluginAction_h
+#define WebPluginAction_h
+
+namespace WebKit {
+
+struct WebPluginAction {
+ enum Type {
+ Unknown,
+ Rotate90Clockwise,
+ Rotate90Counterclockwise
+ };
+
+ Type type;
+ bool enable;
+
+ WebPluginAction()
+ : type(Unknown), enable(false) { }
+ WebPluginAction(Type type, bool enable)
+ : type(type), enable(enable) { }
+};
+
+} // namespace WebKit
+
+#endif
Modified: trunk/Source/WebKit/chromium/public/WebView.h (104633 => 104634)
--- trunk/Source/WebKit/chromium/public/WebView.h 2012-01-10 22:50:51 UTC (rev 104633)
+++ trunk/Source/WebKit/chromium/public/WebView.h 2012-01-10 23:01:52 UTC (rev 104634)
@@ -55,6 +55,7 @@
class WebString;
class WebViewClient;
struct WebMediaPlayerAction;
+struct WebPluginAction;
struct WebPoint;
class WebView : public WebWidget {
@@ -273,11 +274,15 @@
// Media ---------------------------------------------------------------
- // Performs the specified action on the node at the given location.
+ // Performs the specified media player action on the node at the given location.
virtual void performMediaPlayerAction(
const WebMediaPlayerAction&, const WebPoint& location) = 0;
+ // Performs the specified plugin action on the node at the given location.
+ virtual void performPluginAction(
+ const WebPluginAction&, const WebPoint& location) = 0;
+
// Data exchange -------------------------------------------------------
// Copy to the clipboard the image located at a particular point in the
Modified: trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp (104633 => 104634)
--- trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp 2012-01-10 22:50:51 UTC (rev 104633)
+++ trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp 2012-01-10 23:01:52 UTC (rev 104634)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -234,6 +234,10 @@
HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(r.innerNonSharedNode());
data.srcURL = pluginElement->document()->completeURL(pluginElement->url());
data.mediaFlags |= WebContextMenuData::MediaCanSave;
+
+ // Add context menu commands that are supported by the plugin.
+ if (plugin->plugin()->canRotateView())
+ data.mediaFlags |= WebContextMenuData::MediaCanRotate;
}
}
}
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.cpp (104633 => 104634)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-01-10 22:50:51 UTC (rev 104633)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.cpp 2012-01-10 23:01:52 UTC (rev 104634)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -95,6 +95,7 @@
#include "ProgressTracker.h"
#include "RenderLayerCompositor.h"
#include "RenderView.h"
+#include "RenderWidget.h"
#include "ResourceHandle.h"
#include "SchemeRegistry.h"
#include "ScrollAnimator.h"
@@ -125,6 +126,7 @@
#include "WebMediaPlayerAction.h"
#include "WebNode.h"
#include "WebPlugin.h"
+#include "WebPluginAction.h"
#include "WebPluginContainerImpl.h"
#include "platform/WebPoint.h"
#include "WebPopupMenuImpl.h"
@@ -2183,7 +2185,7 @@
HitTestResult result = hitTestResultForWindowPos(location);
RefPtr<Node> node = result.innerNonSharedNode();
if (!node->hasTagName(HTMLNames::videoTag) && !node->hasTagName(HTMLNames::audioTag))
- return;
+ return;
RefPtr<HTMLMediaElement> mediaElement =
static_pointer_cast<HTMLMediaElement>(node);
@@ -2208,6 +2210,33 @@
}
}
+void WebViewImpl::performPluginAction(const WebPluginAction& action,
+ const WebPoint& location)
+{
+ HitTestResult result = hitTestResultForWindowPos(location);
+ RefPtr<Node> node = result.innerNonSharedNode();
+ if (!node->hasTagName(HTMLNames::objectTag) && !node->hasTagName(HTMLNames::embedTag))
+ return;
+
+ RenderObject* object = node->renderer();
+ if (object && object->isWidget()) {
+ Widget* widget = toRenderWidget(object)->widget();
+ if (widget && widget->isPluginContainer()) {
+ WebPluginContainerImpl* plugin = static_cast<WebPluginContainerImpl*>(widget);
+ switch (action.type) {
+ case WebPluginAction::Rotate90Clockwise:
+ plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise);
+ break;
+ case WebPluginAction::Rotate90Counterclockwise:
+ plugin->plugin()->rotateView(WebPlugin::RotationType90Counterclockwise);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
+ }
+}
+
void WebViewImpl::copyImageAt(const WebPoint& point)
{
if (!m_page)
Modified: trunk/Source/WebKit/chromium/src/WebViewImpl.h (104633 => 104634)
--- trunk/Source/WebKit/chromium/src/WebViewImpl.h 2012-01-10 22:50:51 UTC (rev 104633)
+++ trunk/Source/WebKit/chromium/src/WebViewImpl.h 2012-01-10 23:01:52 UTC (rev 104634)
@@ -186,6 +186,9 @@
virtual void performMediaPlayerAction(
const WebMediaPlayerAction& action,
const WebPoint& location);
+ virtual void performPluginAction(
+ const WebPluginAction&,
+ const WebPoint&);
virtual void copyImageAt(const WebPoint& point);
virtual void dragSourceEndedAt(
const WebPoint& clientPoint,