Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (135314 => 135315)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-11-20 22:39:38 UTC (rev 135314)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-11-20 22:41:29 UTC (rev 135315)
@@ -1,3 +1,52 @@
+2012-11-20 Istiaque Ahmed <lazy...@chromium.org>
+
+ Provide page/window coordinates to plugin's local coordinates translation in WebPluginContainer.
+ https://bugs.webkit.org/show_bug.cgi?id=102339
+
+ Reviewed by Adam Barth.
+
+ This change will allow converting a page's window coordinates to plugins's local coordinates,
+ taking CSS transformations into account. Embedder page of the plugin can use this information
+ for targetting elements inside the plugin (e.g. devtools can inspect a specific element at the
+ local coordinate position inside plugin).
+
+ * WebKit.gyp:
+ * WebKit.gypi:
+ * public/WebNode.h:
+ (WebKit):
+ * public/WebPluginContainer.h:
+ (WebKit):
+ (WebPluginContainer):
+ * src/WebFrameImpl.cpp:
+ (WebKit::WebFrameImpl::executeCommand):
+ (WebKit::WebFrameImpl::printBegin):
+ (WebKit::WebFrameImpl::isPrintScalingDisabledForPlugin):
+ * src/WebNode.cpp:
+ (WebKit::WebNode::pluginContainer):
+ (WebKit):
+ * src/WebPluginContainerImpl.cpp:
+ (WebKit::WebPluginContainerImpl::windowToLocalPoint):
+ (WebKit):
+ * src/WebPluginContainerImpl.h:
+ (WebPluginContainerImpl):
+ * tests/FakeWebPlugin.cpp: Added.
+ (WebKit):
+ (WebKit::FakeWebPlugin::FakeWebPlugin):
+ (WebKit::FakeWebPlugin::~FakeWebPlugin):
+ (WebKit::FakeWebPlugin::initialize):
+ (WebKit::FakeWebPlugin::destroy):
+ * tests/FakeWebPlugin.h: Added.
+ (WebKit):
+ (FakeWebPlugin):
+ * tests/WebPluginContainerTest.cpp: Added.
+ (WebKit):
+ (WebPluginContainerTest):
+ (WebKit::WebPluginContainerTest::WebPluginContainerTest):
+ (WebKit::WebPluginContainerTest::TearDown):
+ (WebKit::getWebPluginContainer):
+ (WebKit::TEST_F):
+ * tests/data/plugin_container.html: Added.
+
2012-11-20 Alpha Lam <hc...@chromium.org>
[chromium] Make lazy image decoding thread-safe
Modified: trunk/Source/WebKit/chromium/WebKit.gyp (135314 => 135315)
--- trunk/Source/WebKit/chromium/WebKit.gyp 2012-11-20 22:39:38 UTC (rev 135314)
+++ trunk/Source/WebKit/chromium/WebKit.gyp 2012-11-20 22:41:29 UTC (rev 135315)
@@ -717,6 +717,7 @@
# functions defined only in !WEBKIT_IMPLEMENTATION.
'tests/AssociatedURLLoaderTest.cpp',
'tests/EventListenerTest.cpp',
+ 'tests/FakeWebPlugin.cpp',
'tests/FrameTestHelpers.cpp',
'tests/IDBBindingUtilitiesTest.cpp',
'tests/LevelDBTest.cpp',
@@ -731,6 +732,7 @@
'tests/WebImageTest.cpp',
'tests/WebPageNewSerializerTest.cpp',
'tests/WebPageSerializerTest.cpp',
+ 'tests/WebPluginContainerTest.cpp',
'tests/WebViewTest.cpp',
],
'conditions': [
Modified: trunk/Source/WebKit/chromium/WebKit.gypi (135314 => 135315)
--- trunk/Source/WebKit/chromium/WebKit.gypi 2012-11-20 22:39:38 UTC (rev 135314)
+++ trunk/Source/WebKit/chromium/WebKit.gypi 2012-11-20 22:41:29 UTC (rev 135315)
@@ -64,6 +64,8 @@
'tests/DeferredImageDecoderTest.cpp',
'tests/DragImageTest.cpp',
'tests/EventListenerTest.cpp',
+ 'tests/FakeWebPlugin.cpp',
+ 'tests/FakeWebPlugin.h',
'tests/FakeWebCompositorOutputSurface.h',
'tests/FakeWebGraphicsContext3D.h',
'tests/FilterOperationsTest.cpp',
@@ -113,6 +115,7 @@
'tests/WebMediaPlayerClientImplTest.cpp',
'tests/WebPageNewSerializerTest.cpp',
'tests/WebPageSerializerTest.cpp',
+ 'tests/WebPluginContainerTest.cpp',
'tests/WebSocketDeflaterTest.cpp',
'tests/WebSocketExtensionDispatcherTest.cpp',
'tests/WebURLRequestTest.cpp',
Modified: trunk/Source/WebKit/chromium/public/WebNode.h (135314 => 135315)
--- trunk/Source/WebKit/chromium/public/WebNode.h 2012-11-20 22:39:38 UTC (rev 135314)
+++ trunk/Source/WebKit/chromium/public/WebNode.h 2012-11-20 22:41:29 UTC (rev 135315)
@@ -45,6 +45,7 @@
class WebElement;
class WebFrame;
class WebNodeList;
+class WebPluginContainer;
// Provides access to some properties of a DOM node.
class WebNode {
@@ -119,6 +120,7 @@
// This does not 100% guarantee the user can see it, but is pretty close.
// Note: This method only works properly after layout has occurred.
WEBKIT_EXPORT bool hasNonEmptyBoundingBox() const;
+ WEBKIT_EXPORT WebPluginContainer* pluginContainer() const;
template<typename T> T to()
{
Modified: trunk/Source/WebKit/chromium/public/WebPluginContainer.h (135314 => 135315)
--- trunk/Source/WebKit/chromium/public/WebPluginContainer.h 2012-11-20 22:39:38 UTC (rev 135314)
+++ trunk/Source/WebKit/chromium/public/WebPluginContainer.h 2012-11-20 22:41:29 UTC (rev 135315)
@@ -31,6 +31,8 @@
#ifndef WebPluginContainer_h
#define WebPluginContainer_h
+#include "platform/WebCommon.h"
+
struct NPObject;
namespace WebKit {
@@ -40,6 +42,7 @@
class WebString;
class WebURL;
class WebURLRequest;
+struct WebPoint;
struct WebRect;
class WebPluginContainer {
@@ -117,6 +120,9 @@
// is in use but a scroll bar is not in use).
virtual void setWantsWheelEvents(bool) = 0;
+ // Converts view's window coordinates to plugin's local coordinates.
+ virtual WebPoint windowToLocalPoint(const WebPoint&) = 0;
+
virtual WebPlugin* plugin() = 0;
virtual void setPlugin(WebPlugin*) = 0;
Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (135314 => 135315)
--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp 2012-11-20 22:39:38 UTC (rev 135314)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp 2012-11-20 22:41:29 UTC (rev 135315)
@@ -130,7 +130,6 @@
#include "RenderObject.h"
#include "RenderTreeAsText.h"
#include "RenderView.h"
-#include "RenderWidget.h"
#include "ResourceHandle.h"
#include "ResourceRequest.h"
#include "SchemeRegistry.h"
@@ -304,23 +303,6 @@
return ++next;
}
-static WebPluginContainerImpl* pluginContainerFromNode(const WebNode& node)
-{
- if (node.isNull())
- return 0;
-
- const Node* coreNode = node.constUnwrap<Node>();
- if (coreNode->hasTagName(HTMLNames::objectTag) || coreNode->hasTagName(HTMLNames::embedTag)) {
- RenderObject* object = coreNode->renderer();
- if (object && object->isWidget()) {
- Widget* widget = toRenderWidget(object)->widget();
- if (widget && widget->isPluginContainer())
- return static_cast<WebPluginContainerImpl*>(widget);
- }
- }
- return 0;
-}
-
WebPluginContainerImpl* WebFrameImpl::pluginContainerFromFrame(Frame* frame)
{
if (!frame)
@@ -1232,7 +1214,7 @@
if (command == "Copy") {
WebPluginContainerImpl* pluginContainer = pluginContainerFromFrame(frame());
if (!pluginContainer)
- pluginContainer = pluginContainerFromNode(node);
+ pluginContainer = static_cast<WebPluginContainerImpl*>(node.pluginContainer());
if (pluginContainer) {
pluginContainer->copy();
return true;
@@ -1428,7 +1410,7 @@
pluginContainer = pluginContainerFromFrame(frame());
} else {
// We only support printing plugin nodes for now.
- pluginContainer = pluginContainerFromNode(constrainToNode);
+ pluginContainer = static_cast<WebPluginContainerImpl*>(constrainToNode.pluginContainer());
}
if (pluginContainer && pluginContainer->supportsPaginatedPrint())
@@ -1477,7 +1459,7 @@
bool WebFrameImpl::isPrintScalingDisabledForPlugin(const WebNode& node)
{
- WebPluginContainerImpl* pluginContainer = node.isNull() ? pluginContainerFromFrame(frame()) : pluginContainerFromNode(node);
+ WebPluginContainerImpl* pluginContainer = node.isNull() ? pluginContainerFromFrame(frame()) : static_cast<WebPluginContainerImpl*>(node.pluginContainer());
if (!pluginContainer || !pluginContainer->supportsPaginatedPrint())
return false;
Modified: trunk/Source/WebKit/chromium/src/WebNode.cpp (135314 => 135315)
--- trunk/Source/WebKit/chromium/src/WebNode.cpp 2012-11-20 22:39:38 UTC (rev 135314)
+++ trunk/Source/WebKit/chromium/src/WebNode.cpp 2012-11-20 22:41:29 UTC (rev 135315)
@@ -38,12 +38,17 @@
#include "Node.h"
#include "NodeList.h"
#include "EventListenerWrapper.h"
+#include "RenderObject.h"
+#include "RenderWidget.h"
#include "WebDOMEvent.h"
#include "WebDOMEventListener.h"
#include "WebDocument.h"
#include "WebElement.h"
#include "WebFrameImpl.h"
#include "WebNodeList.h"
+#include "WebPluginContainer.h"
+#include "WebPluginContainerImpl.h"
+#include "Widget.h"
#include "markup.h"
#include <public/WebString.h>
#include <public/WebVector.h>
@@ -235,6 +240,22 @@
return m_private->hasNonEmptyBoundingBox();
}
+WebPluginContainer* WebNode::pluginContainer() const
+{
+ if (isNull())
+ return 0;
+ const Node* coreNode = constUnwrap<Node>();
+ if (coreNode->hasTagName(HTMLNames::objectTag) || coreNode->hasTagName(HTMLNames::embedTag)) {
+ RenderObject* object = coreNode->renderer();
+ if (object && object->isWidget()) {
+ Widget* widget = WebCore::toRenderWidget(object)->widget();
+ if (widget && widget->isPluginContainer())
+ return static_cast<WebPluginContainerImpl*>(widget);
+ }
+ }
+ return 0;
+}
+
WebNode::WebNode(const PassRefPtr<Node>& node)
: m_private(node)
{
Modified: trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp (135314 => 135315)
--- trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp 2012-11-20 22:39:38 UTC (rev 135314)
+++ trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp 2012-11-20 22:41:29 UTC (rev 135315)
@@ -545,6 +545,15 @@
}
}
+WebPoint WebPluginContainerImpl::windowToLocalPoint(const WebPoint& point)
+{
+ ScrollView* view = parent();
+ if (!view)
+ return point;
+ WebPoint windowPoint = view->windowToContents(point);
+ return roundedIntPoint(m_element->renderer()->absoluteToLocal(LayoutPoint(windowPoint), UseTransforms | SnapOffsetForTransforms));
+}
+
void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response)
{
// Make sure that the plugin receives window geometry before data, or else
Modified: trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h (135314 => 135315)
--- trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h 2012-11-20 22:39:38 UTC (rev 135314)
+++ trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.h 2012-11-20 22:41:29 UTC (rev 135315)
@@ -115,6 +115,7 @@
virtual bool isRectTopmost(const WebRect&);
virtual void setIsAcceptingTouchEvents(bool);
virtual void setWantsWheelEvents(bool);
+ virtual WebPoint windowToLocalPoint(const WebPoint&);
// This cannot be null.
WebPlugin* plugin() { return m_webPlugin; }
Added: trunk/Source/WebKit/chromium/tests/FakeWebPlugin.cpp (0 => 135315)
--- trunk/Source/WebKit/chromium/tests/FakeWebPlugin.cpp (rev 0)
+++ trunk/Source/WebKit/chromium/tests/FakeWebPlugin.cpp 2012-11-20 22:41:29 UTC (rev 135315)
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "FakeWebPlugin.h"
+
+#include "WebPluginParams.h"
+#include <wtf/StdLibExtras.h>
+
+namespace WebKit {
+
+FakeWebPlugin::FakeWebPlugin(WebFrame* frame, const WebPluginParams& params)
+ : m_frame(frame)
+{
+}
+
+FakeWebPlugin::~FakeWebPlugin()
+{
+}
+
+bool FakeWebPlugin::initialize(WebPluginContainer* container)
+{
+ m_container = container;
+ return true;
+}
+
+void FakeWebPlugin::destroy()
+{
+ m_container = 0;
+ m_frame = 0;
+}
+
+} // namespace WebKit
Added: trunk/Source/WebKit/chromium/tests/FakeWebPlugin.h (0 => 135315)
--- trunk/Source/WebKit/chromium/tests/FakeWebPlugin.h (rev 0)
+++ trunk/Source/WebKit/chromium/tests/FakeWebPlugin.h 2012-11-20 22:41:29 UTC (rev 135315)
@@ -0,0 +1,78 @@
+/*
+ * 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 FakeWebPlugin_h
+#define FakeWebPlugin_h
+
+#include "WebPlugin.h"
+
+namespace WebKit {
+
+class WebDragData;
+class WebFrame;
+class WebInputEvent;
+class WebPluginContainer;
+class WebURL;
+class WebURLRequest;
+class WebURLResponse;
+
+class FakeWebPlugin : public WebPlugin {
+public:
+ FakeWebPlugin(WebKit::WebFrame*, const WebKit::WebPluginParams&);
+ virtual ~FakeWebPlugin();
+
+ // WebPlugin methods:
+ virtual bool initialize(WebKit::WebPluginContainer*) OVERRIDE;
+ virtual void destroy() OVERRIDE;
+ virtual NPObject* scriptableObject() OVERRIDE { return 0; }
+ virtual bool canProcessDrag() const OVERRIDE { return false; }
+ virtual void paint(WebKit::WebCanvas*, const WebKit::WebRect&) OVERRIDE { }
+ virtual void updateGeometry(const WebKit::WebRect& frameRect, const WebKit::WebRect& clipRect, const WebKit::WebVector<WebKit::WebRect>& cutOutsRects, bool isVisible) OVERRIDE { }
+ virtual void updateFocus(bool) OVERRIDE { }
+ virtual void updateVisibility(bool) OVERRIDE { }
+ virtual bool acceptsInputEvents() OVERRIDE { return true; }
+ virtual bool handleInputEvent(const WebKit::WebInputEvent&, WebKit::WebCursorInfo&) OVERRIDE { return false; }
+ virtual bool handleDragStatusUpdate(WebKit::WebDragStatus, const WebKit::WebDragData&, WebKit::WebDragOperationsMask, const WebKit::WebPoint& position, const WebKit::WebPoint& screenPosition) OVERRIDE { return false; }
+ virtual void didReceiveResponse(const WebKit::WebURLResponse&) OVERRIDE { }
+ virtual void didReceiveData(const char* data, int dataLength) OVERRIDE { }
+ virtual void didFinishLoading() OVERRIDE { }
+ virtual void didFailLoading(const WebKit::WebURLError&) OVERRIDE { }
+ virtual void didFinishLoadingFrameRequest(const WebKit::WebURL&, void* notifyData) OVERRIDE { }
+ virtual void didFailLoadingFrameRequest(const WebKit::WebURL&, void* notifyData, const WebKit::WebURLError&) OVERRIDE { }
+ virtual bool isPlaceholder() OVERRIDE { return false; }
+
+private:
+ WebFrame* m_frame;
+ WebPluginContainer* m_container;
+};
+
+} // namespace WebKit
+
+#endif // FakeWebPlugin_h
Added: trunk/Source/WebKit/chromium/tests/WebPluginContainerTest.cpp (0 => 135315)
--- trunk/Source/WebKit/chromium/tests/WebPluginContainerTest.cpp (rev 0)
+++ trunk/Source/WebKit/chromium/tests/WebPluginContainerTest.cpp 2012-11-20 22:41:29 UTC (rev 135315)
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WebPluginContainer.h"
+
+#include "Element.h"
+#include "FakeWebPlugin.h"
+#include "FrameTestHelpers.h"
+#include "URLTestHelpers.h"
+#include "WebDocument.h"
+#include "WebElement.h"
+#include "WebFrame.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebPluginContainerImpl.h"
+#include "WebPluginParams.h"
+#include "WebSettings.h"
+#include "WebView.h"
+#include "WebViewImpl.h"
+#include <gtest/gtest.h>
+#include <webkit/support/webkit_support.h>
+
+using namespace WebKit;
+
+namespace {
+
+class WebPluginContainerTest : public testing::Test {
+public:
+ WebPluginContainerTest()
+ : m_baseURL("http://www.test.com/")
+ {
+ }
+
+ virtual void TearDown()
+ {
+ webkit_support::UnregisterAllMockedURLs();
+ }
+
+protected:
+ std::string m_baseURL;
+};
+
+class TestPluginWebFrameClient : public WebFrameClient {
+ virtual WebPlugin* createPlugin(WebFrame* frame, const WebPluginParams& params) OVERRIDE
+ {
+ if (params.mimeType == WebString::fromUTF8("application/x-webkit-test-webplugin"))
+ return new FakeWebPlugin(frame, params);
+ return WebFrameClient::createPlugin(frame, params);
+ }
+};
+
+WebPluginContainer* getWebPluginContainer(WebView* webView, const WebString& id)
+{
+ WebElement element = webView->mainFrame()->document().getElementById(id);
+ return element.pluginContainer();
+}
+
+TEST_F(WebPluginContainerTest, WindowToLocalPointTest)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html"));
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "plugin_container.html", true, new TestPluginWebFrameClient());
+ ASSERT(webView);
+ webView->settings()->setPluginsEnabled(true);
+ webView->resize(WebSize(300, 300));
+ webView->layout();
+ webkit_support::RunAllPendingMessages();
+
+ WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebString::fromUTF8("translated-plugin"));
+ ASSERT(pluginContainerOne);
+ WebPoint point1 = pluginContainerOne->windowToLocalPoint(WebPoint(10, 10));
+ ASSERT_EQ(0, point1.x);
+ ASSERT_EQ(0, point1.y);
+ WebPoint point2 = pluginContainerOne->windowToLocalPoint(WebPoint(100, 100));
+ ASSERT_EQ(90, point2.x);
+ ASSERT_EQ(90, point2.y);
+
+ WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebString::fromUTF8("rotated-plugin"));
+ ASSERT(pluginContainerTwo);
+ WebPoint point3 = pluginContainerTwo->windowToLocalPoint(WebPoint(0, 10));
+ ASSERT_EQ(10, point3.x);
+ ASSERT_EQ(0, point3.y);
+ WebPoint point4 = pluginContainerTwo->windowToLocalPoint(WebPoint(-10, 10));
+ ASSERT_EQ(10, point4.x);
+ ASSERT_EQ(10, point4.y);
+
+ webView->close();
+}
+
+}
Added: trunk/Source/WebKit/chromium/tests/data/plugin_container.html (0 => 135315)
--- trunk/Source/WebKit/chromium/tests/data/plugin_container.html (rev 0)
+++ trunk/Source/WebKit/chromium/tests/data/plugin_container.html 2012-11-20 22:41:29 UTC (rev 135315)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <style type="text/css">
+ body { margin: 0; padding: 0; }
+ </style>
+</head>
+<body>
+ <object id="rotated-plugin"
+ style="-webkit-transform: rotate(90deg); position: absolute; top: 0; left: 0; -webkit-transform-origin: 0 0;"
+ type="application/x-webkit-test-webplugin"
+ border=0
+ width="40"
+ height="40">
+ </object>
+ <object id="translated-plugin"
+ border=0
+ style="-webkit-transform: translate(10px, 10px); position: absolute; top: 0; left: 0;"
+ type="application/x-webkit-test-webplugin"
+ width="40"
+ height="40">
+ </object>
+</body>
+</html>