Plugin in iframe may not display
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2013 22:05:07 +0000 (22:05 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2013 22:05:07 +0000 (22:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109879

Patch by John Bauman <jbauman@chromium.org> on 2013-02-27
Reviewed by Simon Fraser.

Source/WebCore:

Changing the cliprect on a layer containing an iframe may change the
cliprect of plugins inside the iframe, so recursively tell all plugins
in iframes that their cliprect has changed after doing layout on the
outer frame.

Test: plugins/plugin-clip-subframe.html

* platform/ScrollView.cpp:
(WebCore::ScrollView::clipRectChanged):
* platform/ScrollView.h:
* platform/Widget.h:
(WebCore::Widget::clipRectChanged):
* plugins/PluginView.cpp:
(WebCore::PluginView::clipRectChanged):
* plugins/PluginView.h:
* rendering/RenderWidget.cpp:
(WebCore::RenderWidget::setWidgetGeometry):

Source/WebKit/chromium:

Use clipRectChanged to update the geometry.

* src/WebPluginContainerImpl.cpp:
(WebKit::WebPluginContainerImpl::clipRectChanged):
* src/WebPluginContainerImpl.h:

Source/WebKit/mac:

Ensure NetscapePluginWidget informs the plugin view of the cliprect change directly.

* Plugins/WebBaseNetscapePluginView.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(NetscapePluginWidget::clipRectChanged):

Source/WebKit2:

Update geometry when cliprect changes.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::clipRectChanged):
* WebProcess/Plugins/PluginView.h:

Tools:

LogNPPSetWindow will be used with other ports as well.

* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt:

LayoutTests:

Use log-npp-set-window to ensure plugin clip changes correctly.

* platform/mac-wk2/plugins/plugin-clip-subframe-expected.txt: Added.
* platform/mac/plugins/plugin-clip-subframe-expected.txt: Added.
* plugins/plugin-clip-subframe-expected.txt: Added.
* plugins/plugin-clip-subframe.html: Added.
* plugins/resources/plugin-clip-subframe-iframe.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144236 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk2/plugins/plugin-clip-subframe-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/plugins/plugin-clip-subframe-expected.txt [new file with mode: 0644]
LayoutTests/plugins/plugin-clip-subframe-expected.txt [new file with mode: 0644]
LayoutTests/plugins/plugin-clip-subframe.html [new file with mode: 0644]
LayoutTests/plugins/resources/plugin-clip-subframe-iframe.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollView.cpp
Source/WebCore/platform/ScrollView.h
Source/WebCore/platform/Widget.h
Source/WebCore/plugins/PluginView.cpp
Source/WebCore/plugins/PluginView.h
Source/WebCore/rendering/RenderWidget.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebPluginContainerImpl.cpp
Source/WebKit/chromium/src/WebPluginContainerImpl.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.h
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.h
Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.gypi
Tools/DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt

index a4454cd..33e5538 100644 (file)
@@ -1,3 +1,18 @@
+2013-02-27  John Bauman  <jbauman@chromium.org>
+
+        Plugin in iframe may not display
+        https://bugs.webkit.org/show_bug.cgi?id=109879
+
+        Reviewed by Simon Fraser.
+
+        Use log-npp-set-window to ensure plugin clip changes correctly.
+
+        * platform/mac-wk2/plugins/plugin-clip-subframe-expected.txt: Added.
+        * platform/mac/plugins/plugin-clip-subframe-expected.txt: Added.
+        * plugins/plugin-clip-subframe-expected.txt: Added.
+        * plugins/plugin-clip-subframe.html: Added.
+        * plugins/resources/plugin-clip-subframe-iframe.html: Added.
+
 2013-02-27  Chris Rogers  <crogers@google.com>
 
         Implement channel up-mixing and down-mixing rules
diff --git a/LayoutTests/platform/mac-wk2/plugins/plugin-clip-subframe-expected.txt b/LayoutTests/platform/mac-wk2/plugins/plugin-clip-subframe-expected.txt
new file mode 100644 (file)
index 0000000..b4ea0e5
--- /dev/null
@@ -0,0 +1,4 @@
+CONSOLE MESSAGE: line 3: NPP_SetWindow: NULL window, Rect {0, 0, 300, 150}, Clip Rect {0, 0, 0, 0}, Type 2
+CONSOLE MESSAGE: line 3: NPP_SetWindow: NULL window, Rect {0, 0, 300, 150}, Clip Rect {0, 0, 0, 0}, Type 2
+CONSOLE MESSAGE: line 3: NPP_SetWindow: NULL window, Rect {0, 0, 300, 150}, Clip Rect {0, 0, 300, 150}, Type 2
+
diff --git a/LayoutTests/platform/mac/plugins/plugin-clip-subframe-expected.txt b/LayoutTests/platform/mac/plugins/plugin-clip-subframe-expected.txt
new file mode 100644 (file)
index 0000000..f79500c
--- /dev/null
@@ -0,0 +1,3 @@
+CONSOLE MESSAGE: line 3: NPP_SetWindow: NULL window, Rect {18, 218, 300, 150}, Clip Rect {0, 600, 0, 600}, Type 0
+CONSOLE MESSAGE: line 3: NPP_SetWindow: NULL window, Rect {18, 218, 300, 150}, Clip Rect {18, 218, 108, 368}, Type 0
+
diff --git a/LayoutTests/plugins/plugin-clip-subframe-expected.txt b/LayoutTests/plugins/plugin-clip-subframe-expected.txt
new file mode 100644 (file)
index 0000000..3ba695e
--- /dev/null
@@ -0,0 +1,3 @@
+CONSOLE MESSAGE: line 3: NPP_SetWindow: non-NULL window, Rect {18, 218, 300, 150}, Clip Rect {65518, 65318, 65518, 65318}, Type 1
+CONSOLE MESSAGE: line 3: NPP_SetWindow: non-NULL window, Rect {18, 218, 300, 150}, Clip Rect {0, 0, 90, 150}, Type 1
+
diff --git a/LayoutTests/plugins/plugin-clip-subframe.html b/LayoutTests/plugins/plugin-clip-subframe.html
new file mode 100644 (file)
index 0000000..65ad49b
--- /dev/null
@@ -0,0 +1,29 @@
+<!doctype html>
+<html>
+<script>
+function test() {
+    // Increase the size of the container so the iframe becomes visible.
+    document.getElementById("container").style.height = "400px";
+    setTimeout(done, 10);
+}
+
+function done() {
+    if (testRunner) {
+        testRunner.dumpAsText();
+        testRunner.notifyDone();
+    }
+}
+
+function runTest() {
+    if (testRunner)
+        testRunner.waitUntilDone();
+    setTimeout(test, 10);
+}
+</script>
+<body onload="runTest()">
+
+<div id = "container" style="overflow: hidden; width:100px; height:100px">
+<iframe id='subframe' src='resources/plugin-clip-subframe-iframe.html' width=500 height=500 style="margin-top:200px"></iframe>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/plugins/resources/plugin-clip-subframe-iframe.html b/LayoutTests/plugins/resources/plugin-clip-subframe-iframe.html
new file mode 100644 (file)
index 0000000..92bcb91
--- /dev/null
@@ -0,0 +1,7 @@
+<script>
+function windowWasSet(msg) {
+    console.log(msg);
+}
+</script>
+
+<embed id="testCPlugin" type="application/x-webkit-test-netscape" test="log-npp-set-window"></embed>
index 7b8f293..68edfac 100644 (file)
@@ -1,3 +1,28 @@
+2013-02-27  John Bauman  <jbauman@chromium.org>
+
+        Plugin in iframe may not display
+        https://bugs.webkit.org/show_bug.cgi?id=109879
+
+        Reviewed by Simon Fraser.
+
+        Changing the cliprect on a layer containing an iframe may change the
+        cliprect of plugins inside the iframe, so recursively tell all plugins
+        in iframes that their cliprect has changed after doing layout on the
+        outer frame.
+
+        Test: plugins/plugin-clip-subframe.html
+
+        * platform/ScrollView.cpp:
+        (WebCore::ScrollView::clipRectChanged):
+        * platform/ScrollView.h:
+        * platform/Widget.h:
+        (WebCore::Widget::clipRectChanged):
+        * plugins/PluginView.cpp:
+        (WebCore::PluginView::clipRectChanged):
+        * plugins/PluginView.h:
+        * rendering/RenderWidget.cpp:
+        (WebCore::RenderWidget::setWidgetGeometry):
+
 2013-02-27  Chris Rogers  <crogers@google.com>
 
         Implement channel up-mixing and down-mixing rules
index 27038d3..3c97a85 100644 (file)
@@ -887,6 +887,13 @@ void ScrollView::frameRectsChanged()
         (*current)->frameRectsChanged();
 }
 
+void ScrollView::clipRectChanged()
+{
+    HashSet<RefPtr<Widget> >::const_iterator end = m_children.end();
+    for (HashSet<RefPtr<Widget> >::const_iterator current = m_children.begin(); current != end; ++current)
+        (*current)->clipRectChanged();
+}
+
 #if USE(ACCELERATED_COMPOSITING)
 static void positionScrollbarLayer(GraphicsLayer* graphicsLayer, Scrollbar* scrollbar)
 {
index a31645d..d04c3e8 100644 (file)
@@ -243,6 +243,9 @@ public:
     // Widget override to update our scrollbars and notify our contents of the resize.
     virtual void setFrameRect(const IntRect&);
 
+    // Widget override to notify our contents of a cliprect change.
+    virtual void clipRectChanged() OVERRIDE;
+
     // For platforms that need to hit test scrollbars from within the engine's event handlers (like Win32).
     Scrollbar* scrollbarAtPoint(const IntPoint& windowPoint);
 
index c2c7c6d..515421e 100644 (file)
@@ -210,6 +210,9 @@ public:
     // Notifies this widget that other widgets on the page have been repositioned.
     virtual void widgetPositionsUpdated() {}
 
+    // Notifies this widget that its clip rect changed.
+    virtual void clipRectChanged() { }
+
     // Whether transforms affect the frame rect. FIXME: We get rid of this and have
     // the frame rects be the same no matter what transforms are applied.
     virtual bool transformsAffectFrameRect() { return true; }
index 7d92bec..af0576f 100644 (file)
@@ -158,6 +158,11 @@ void PluginView::frameRectsChanged()
     updatePluginWidget();
 }
 
+void PluginView::clipRectChanged()
+{
+    updatePluginWidget();
+}
+
 void PluginView::handleEvent(Event* event)
 {
     if (!m_plugin || m_isWindowed)
index 84e62d8..b333480 100644 (file)
@@ -210,6 +210,7 @@ namespace WebCore {
         virtual void show();
         virtual void hide();
         virtual void paint(GraphicsContext*, const IntRect&);
+        virtual void clipRectChanged() OVERRIDE;
 
         // This method is used by plugins on all platforms to obtain a clip rect that includes clips set by WebCore,
         // e.g., in overflow:auto sections.  The clip rects coordinates are in the containing window's coordinate space.
index c07681f..c8dc5da 100644 (file)
@@ -155,6 +155,9 @@ bool RenderWidget::setWidgetGeometry(const LayoutRect& frame)
     RenderWidgetProtector protector(this);
     RefPtr<Node> protectedNode(node());
     m_widget->setFrameRect(newFrame);
+
+    if (clipChanged && !boundsChanged)
+        m_widget->clipRectChanged();
     
 #if USE(ACCELERATED_COMPOSITING)
     if (hasLayer() && layer()->isComposited())
index 6aba331..3a23679 100644 (file)
@@ -1,3 +1,16 @@
+2013-02-27  John Bauman  <jbauman@chromium.org>
+
+        Plugin in iframe may not display
+        https://bugs.webkit.org/show_bug.cgi?id=109879
+
+        Reviewed by Simon Fraser.
+
+        Use clipRectChanged to update the geometry.
+
+        * src/WebPluginContainerImpl.cpp:
+        (WebKit::WebPluginContainerImpl::clipRectChanged):
+        * src/WebPluginContainerImpl.h:
+
 2013-02-27  Stephen Chenney  <schenney@chromium.org>
 
         RenderTableCellDeathTest unit test fails on mac
index 180002e..6e4dde6 100644 (file)
@@ -222,6 +222,11 @@ void WebPluginContainerImpl::widgetPositionsUpdated()
     reportGeometry();
 }
 
+void WebPluginContainerImpl::clipRectChanged()
+{
+    reportGeometry();
+}
+
 void WebPluginContainerImpl::setParentVisible(bool parentVisible)
 {
     // We override this function to make sure that geometry updates are sent
index bb2f4ea..19d397d 100644 (file)
@@ -92,6 +92,7 @@ public:
     virtual void setParentVisible(bool);
     virtual void setParent(WebCore::ScrollView*);
     virtual void widgetPositionsUpdated();
+    virtual void clipRectChanged() OVERRIDE;
     virtual bool isPluginContainer() const { return true; }
 
     // WebPluginContainer methods
index a51e6ae..02764bf 100644 (file)
@@ -1,3 +1,16 @@
+2013-02-27  John Bauman  <jbauman@chromium.org>
+
+        Plugin in iframe may not display
+        https://bugs.webkit.org/show_bug.cgi?id=109879
+
+        Reviewed by Simon Fraser.
+
+        Ensure NetscapePluginWidget informs the plugin view of the cliprect change directly.
+
+        * Plugins/WebBaseNetscapePluginView.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (NetscapePluginWidget::clipRectChanged):
+
 2013-02-26  Alexey Proskuryakov  <ap@apple.com>
 
         Don't add a body to platform request until necessary
index 4b4d6dc..9b933f4 100644 (file)
@@ -99,6 +99,7 @@ namespace WebCore {
 - (void)handleMouseExited:(NSEvent *)event;
 - (void)setAttributeKeys:(NSArray *)keys andValues:(NSArray *)values;
 - (void)focusChanged;
+- (void)updateAndSetWindow;
 
 - (WebFrame *)webFrame;
 - (WebDataSource *)dataSource;
index a6d2cbc..2f7b587 100644 (file)
@@ -1585,6 +1585,12 @@ public:
             event->setDefaultHandled(); // We don't know if the plug-in has handled mousedown event by displaying a context menu, so we never want WebKit to show a default one.
     }
 
+    virtual void clipRectChanged()
+    {
+        // Changing the clip rect doesn't affect the view hierarchy, so the plugin must be told about the change directly.
+        [(WebBaseNetscapePluginView *)platformWidget() updateAndSetWindow];
+    }
+
 private:
     virtual void notifyWidget(WidgetNotification notification)
     {
index 7b62aa1..bcb47f7 100644 (file)
@@ -1,3 +1,16 @@
+2013-02-27  John Bauman  <jbauman@chromium.org>
+
+        Plugin in iframe may not display
+        https://bugs.webkit.org/show_bug.cgi?id=109879
+
+        Reviewed by Simon Fraser.
+
+        Update geometry when cliprect changes.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::clipRectChanged):
+        * WebProcess/Plugins/PluginView.h:
+
 2013-02-27  Jer Noble  <jer.noble@apple.com>
 
         REGRESSION (48533): Full-frame plugins stopped working (download instead of loading the plugin)
index 8df14cb..d9c2005 100644 (file)
@@ -738,6 +738,11 @@ void PluginView::frameRectsChanged()
     viewGeometryDidChange();
 }
 
+void PluginView::clipRectChanged()
+{
+    viewGeometryDidChange();
+}
+
 void PluginView::setParent(ScrollView* scrollView)
 {
     Widget::setParent(scrollView);
index eec236a..386da86 100644 (file)
@@ -160,6 +160,7 @@ private:
     virtual void show();
     virtual void hide();
     virtual bool transformsAffectFrameRect();
+    virtual void clipRectChanged() OVERRIDE;
 
     // WebCore::MediaCanStartListener
     virtual void mediaCanStart();
index 2d5e334..85e379a 100644 (file)
@@ -1,3 +1,15 @@
+2013-02-27  John Bauman  <jbauman@chromium.org>
+
+        Plugin in iframe may not display
+        https://bugs.webkit.org/show_bug.cgi?id=109879
+
+        Reviewed by Simon Fraser.
+
+        LogNPPSetWindow will be used with other ports as well.
+
+        * DumpRenderTree/DumpRenderTree.gypi:
+        * DumpRenderTree/TestNetscapePlugIn/CMakeLists.txt:
+
 2013-02-27  Jochen Eisinger  <jochen@chromium.org>
 
         plugins/netscape-plugin-setwindow-size*.html and plugins/pass-different-npp-struct.html should be async
index d753939..cd4755a 100644 (file)
             'TestNetscapePlugIn/Tests/GetURLWithJavaScriptURL.cpp',
             'TestNetscapePlugIn/Tests/GetURLWithJavaScriptURLDestroyingPlugin.cpp',
             'TestNetscapePlugIn/Tests/GetUserAgentWithNullNPPFromNPPNew.cpp',
+            'TestNetscapePlugIn/Tests/LogNPPSetWindow.cpp',
             'TestNetscapePlugIn/Tests/NPPNewFails.cpp',
             'TestNetscapePlugIn/Tests/NPRuntimeCallsWithNullNPP.cpp',
             'TestNetscapePlugIn/Tests/NPRuntimeObjectFromDestroyedPlugin.cpp',
index e339ab1..c180e09 100644 (file)
@@ -13,6 +13,7 @@ set(WebKitTestNetscapePlugin_SOURCES
     ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/GetURLWithJavaScriptURL.cpp
     ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/GetURLWithJavaScriptURLDestroyingPlugin.cpp
     ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/GetUserAgentWithNullNPPFromNPPNew.cpp
+    ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/LogNPPSetWindow.cpp
     ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/NPDeallocateCalledBeforeNPShutdown.cpp
     ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/NPPNewFails.cpp
     ${WEBKIT_TESTNETSCAPEPLUGIN_DIR}/Tests/NPPSetWindowCalledDuringDestruction.cpp