2009-03-03 Onne Gorter <onne.gorter@avinity.net>
authorkov@webkit.org <kov@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Mar 2009 17:26:57 +0000 (17:26 +0000)
committerkov@webkit.org <kov@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Mar 2009 17:26:57 +0000 (17:26 +0000)
        Reviewed by Anders Carlsson.

        https://bugs.webkit.org/show_bug.cgi?id=27385
        resizing plugins does not work, because the plugin never gets informed

        Make gtk plugins resize correctly, by sending them the setwindow event
        correctly. Also ensure that all plugin eventing is done with correct
        locking/calling. Mostly copied from mac implementation.

        manual test: manual-tests/gtk/plugin-resize-scroll.html

        * plugins/PluginView.h:
        * plugins/gtk/PluginViewGtk.cpp:
        (WebCore::PluginView::dispatchNPEvent):
        ensure locking/calling for NPEvents
        (WebCore::PluginView::updatePluginWidget):
        if something changed, let setNPWindowIfNeeded handle it
        (WebCore::PluginView::paint):
        (WebCore::PluginView::handleKeyboardEvent):
        (WebCore::PluginView::handleMouseEvent):
        ensure calling conventions
        (WebCore::PluginView::setNPWindowRect):
        just pass control to setNPWindowIfNeeded
        (WebCore::PluginView::setNPWindowIfNeeded):
        event the plugin correctly of new window
        (WebCore::PluginView::init):
        init through the new setup

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

WebCore/ChangeLog
WebCore/manual-tests/gtk/plugin-resize-scroll.html [new file with mode: 0644]
WebCore/plugins/PluginView.h
WebCore/plugins/gtk/PluginViewGtk.cpp

index 338fc58500bcf278af5a4f6e755145c8ba0dae8b..d4a60fe16d09e73a2a88dbd7855c11590056d5e7 100644 (file)
@@ -1,3 +1,33 @@
+2009-03-03  Onne Gorter  <onne.gorter@avinity.net>
+
+        Reviewed by Anders Carlsson.
+
+        https://bugs.webkit.org/show_bug.cgi?id=27385
+        resizing plugins does not work, because the plugin never gets informed
+
+        Make gtk plugins resize correctly, by sending them the setwindow event
+        correctly. Also ensure that all plugin eventing is done with correct
+        locking/calling. Mostly copied from mac implementation.
+
+        manual test: manual-tests/gtk/plugin-resize-scroll.html
+
+        * plugins/PluginView.h:
+        * plugins/gtk/PluginViewGtk.cpp:
+        (WebCore::PluginView::dispatchNPEvent):
+        ensure locking/calling for NPEvents
+        (WebCore::PluginView::updatePluginWidget):
+        if something changed, let setNPWindowIfNeeded handle it
+        (WebCore::PluginView::paint):
+        (WebCore::PluginView::handleKeyboardEvent):
+        (WebCore::PluginView::handleMouseEvent):
+        ensure calling conventions
+        (WebCore::PluginView::setNPWindowRect):
+        just pass control to setNPWindowIfNeeded
+        (WebCore::PluginView::setNPWindowIfNeeded):
+        event the plugin correctly of new window
+        (WebCore::PluginView::init):
+        init through the new setup
+
 2009-03-03  Mike Belshe  <mike@belshe.com>
 
         Reviewed by Darin Fisher.
 2009-03-03  Mike Belshe  <mike@belshe.com>
 
         Reviewed by Darin Fisher.
diff --git a/WebCore/manual-tests/gtk/plugin-resize-scroll.html b/WebCore/manual-tests/gtk/plugin-resize-scroll.html
new file mode 100644 (file)
index 0000000..d452b95
--- /dev/null
@@ -0,0 +1,28 @@
+<html>
+    <head>
+        <style>
+            html, body {
+                background-color: blue;
+                color: white;
+            }
+            #spacer {
+                width: 100%;
+                height: 1000px;
+                background-color: yellow;
+            }
+        </style>
+        </script>
+    </head>
+    <body>
+        <p>
+            Resize the browser, ensure that the plugin resizes and does not produce a greyish border.
+            Scroll the view, ensure that plugin scrolls out of view.
+        </p>
+
+        <embed id="embed" height="100" style="width: 100%" pbgcolor="green"
+              src="http://www.tizag.com/pics/example.swf" type="application/x-shockwave-flash"/>
+
+        <div id="spacer"><p>content</p></div>
+    </body>
+</html>
+
index f9fb2857f8581efa0a026759b5f35bee509dfb50..d5579830f0b968e3521da5d639d618f7f9ee95b9 100644 (file)
@@ -301,6 +301,9 @@ private:
         void nullEventTimerFired(Timer<PluginView>*);
         Point globalMousePosForPlugin() const;
 #endif
         void nullEventTimerFired(Timer<PluginView>*);
         Point globalMousePosForPlugin() const;
 #endif
+#if PLATFORM(GTK) || defined(Q_WS_X11)
+        void setNPWindowIfNeeded();
+#endif
 
         IntRect m_clipRect; // The clip rect to apply to a windowed plug-in
         IntRect m_windowRect; // Our window rect.
 
         IntRect m_clipRect; // The clip rect to apply to a windowed plug-in
         IntRect m_windowRect; // Our window rect.
index 5ec515b8d1d307c75cc10effcc57d0d41ab99e22..30be6b01b575e71dfb1a4cc32f04c4564686eb78 100644 (file)
@@ -82,6 +82,23 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
 
 using namespace HTMLNames;
 
+bool PluginView::dispatchNPEvent(NPEvent& event)
+{
+    // sanity check
+    if (!m_plugin->pluginFuncs()->event)
+        return false;
+
+    PluginView::setCurrentPluginView(this);
+    JSC::JSLock::DropAllLocks dropAllLocks(false);
+    setCallingPlugin(true);
+
+    bool accepted = m_plugin->pluginFuncs()->event(m_instance, &event);
+
+    setCallingPlugin(false);
+    PluginView::setCurrentPluginView(0);
+    return accepted;
+}
+
 void PluginView::updatePluginWidget()
 {
     if (!parent() || !m_isWindowed)
 void PluginView::updatePluginWidget()
 {
     if (!parent() || !m_isWindowed)
@@ -97,16 +114,8 @@ void PluginView::updatePluginWidget()
     m_clipRect = windowClipRect();
     m_clipRect.move(-m_windowRect.x(), -m_windowRect.y());
 
     m_clipRect = windowClipRect();
     m_clipRect.move(-m_windowRect.x(), -m_windowRect.y());
 
-    GtkAllocation allocation = { m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height() };
-    if (platformPluginWidget()) {
-        gtk_widget_size_allocate(platformPluginWidget(), &allocation);
-#if PLATFORM(X11)
-        if (!m_needsXEmbed) {
-            gtk_xtbin_set_position(GTK_XTBIN(platformPluginWidget()), m_windowRect.x(), m_windowRect.y());
-            gtk_xtbin_resize(platformPluginWidget(), m_windowRect.width(), m_windowRect.height());
-        }
-#endif
-    }
+    if (platformPluginWidget() && (m_windowRect != oldWindowRect || m_clipRect != oldClipRect))
+        setNPWindowIfNeeded();
 }
 
 void PluginView::setFocus()
 }
 
 void PluginView::setFocus()
@@ -144,7 +153,12 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
         return;
     }
 
         return;
     }
 
-    if (m_isWindowed || context->paintingDisabled())
+    if (context->paintingDisabled())
+        return;
+
+    setNPWindowIfNeeded();
+
+    if (m_isWindowed)
         return;
 
     NPEvent npEvent;
         return;
 
     NPEvent npEvent;
@@ -154,12 +168,8 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
 
     ASSERT(parent()->isFrameView());
 
 
     ASSERT(parent()->isFrameView());
 
-    if (m_plugin->pluginFuncs()->event) {
-        JSC::JSLock::DropAllLocks dropAllLocks(false);
-        m_plugin->pluginFuncs()->event(m_instance, &npEvent);
-    }
-
-    setNPWindowRect(frameRect());
+    if (!dispatchNPEvent(npEvent))
+        LOG(Events, "PluginView::paint(): Paint event not accepted");
 }
 
 void PluginView::handleKeyboardEvent(KeyboardEvent* event)
 }
 
 void PluginView::handleKeyboardEvent(KeyboardEvent* event)
@@ -169,7 +179,7 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event)
     /* FIXME: Synthesize an XEvent to pass through */
 
     JSC::JSLock::DropAllLocks dropAllLocks(false);
     /* FIXME: Synthesize an XEvent to pass through */
 
     JSC::JSLock::DropAllLocks dropAllLocks(false);
-    if (!m_plugin->pluginFuncs()->event(m_instance, &npEvent))
+    if (!dispatchNPEvent(npEvent))
         event->setDefaultHandled();
 }
 
         event->setDefaultHandled();
 }
 
@@ -184,7 +194,7 @@ void PluginView::handleMouseEvent(MouseEvent* event)
     IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(IntPoint(event->pageX(), event->pageY()));
 
     JSC::JSLock::DropAllLocks dropAllLocks(false);
     IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(IntPoint(event->pageX(), event->pageY()));
 
     JSC::JSLock::DropAllLocks dropAllLocks(false);
-    if (!m_plugin->pluginFuncs()->event(m_instance, &npEvent))
+    if (!dispatchNPEvent(npEvent))
         event->setDefaultHandled();
 }
 
         event->setDefaultHandled();
 }
 
@@ -200,40 +210,41 @@ void PluginView::setParent(ScrollView* parent)
     }
 }
 
     }
 }
 
-void PluginView::setNPWindowRect(const IntRect& rect)
+void PluginView::setNPWindowRect(const IntRect&)
 {
 {
-    if (!m_isStarted || !parent())
-        return;
-
-    IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(rect.location());
-    m_npWindow.x = p.x();
-    m_npWindow.y = p.y();
-
-    m_npWindow.width = rect.width();
-    m_npWindow.height = rect.height();
-
-    m_npWindow.clipRect.left = 0;
-    m_npWindow.clipRect.top = 0;
-    m_npWindow.clipRect.right = rect.width();
-    m_npWindow.clipRect.bottom = rect.height();
+    setNPWindowIfNeeded();
+}
 
 
-    if (m_npWindow.x < 0 || m_npWindow.y < 0 ||
-        m_npWindow.width <= 0 || m_npWindow.height <= 0)
+void PluginView::setNPWindowIfNeeded()
+{
+    if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow)
         return;
 
         return;
 
-    if (m_plugin->pluginFuncs()->setwindow) {
-        PluginView::setCurrentPluginView(this);
-        JSC::JSLock::DropAllLocks dropAllLocks(false);
-        setCallingPlugin(true);
-        m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
-        setCallingPlugin(false);
-        PluginView::setCurrentPluginView(0);
+    m_npWindow.x = m_windowRect.x();
+    m_npWindow.y = m_windowRect.y();
+    m_npWindow.width = m_windowRect.width();
+    m_npWindow.height = m_windowRect.height();
 
 
-        if (!m_isWindowed)
-            return;
+    m_npWindow.clipRect.left = m_clipRect.x();
+    m_npWindow.clipRect.top = m_clipRect.y();
+    m_npWindow.clipRect.right = m_clipRect.width();
+    m_npWindow.clipRect.bottom = m_clipRect.height();
 
 
-        ASSERT(platformPluginWidget());
+    GtkAllocation allocation = { m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height() };
+    gtk_widget_size_allocate(platformPluginWidget(), &allocation);
+#if PLATFORM(X11)
+    if (!m_needsXEmbed) {
+        gtk_xtbin_set_position(GTK_XTBIN(platformPluginWidget()), m_windowRect.x(), m_windowRect.y());
+        gtk_xtbin_resize(platformPluginWidget(), m_windowRect.width(), m_windowRect.height());
     }
     }
+#endif
+
+    PluginView::setCurrentPluginView(this);
+    JSC::JSLock::DropAllLocks dropAllLocks(false);
+    setCallingPlugin(true);
+    m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
+    setCallingPlugin(false);
+    PluginView::setCurrentPluginView(0);
 }
 
 void PluginView::setParentVisible(bool visible)
 }
 
 void PluginView::setParentVisible(bool visible)
@@ -576,10 +587,12 @@ void PluginView::init()
         m_npWindow.window = 0;
     }
 
         m_npWindow.window = 0;
     }
 
+    // TODO remove in favor of null events, like mac port?
     if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall)))
     if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall)))
-        setNPWindowRect(frameRect());
+        updatePluginWidget(); // was: setNPWindowIfNeeded(), but this doesn't produce 0x0 rects at first go
 
     m_status = PluginStatusLoadedSuccessfully;
 }
 
 } // namespace WebCore
 
     m_status = PluginStatusLoadedSuccessfully;
 }
 
 } // namespace WebCore
+