[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

aroben at apple.com aroben at apple.com
Wed Dec 22 12:21:18 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2c233b841da4167e6121b613a1400fc3e0d0996a
Author: aroben at apple.com <aroben at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Aug 19 21:22:52 2010 +0000

    Add support for painting windowless plugins on Windows
    
    This gets the video on the front page of vimeo.com painting (though
    you can't make it play because we don't support mouse events yet).
    
    Fixes <http://webkit.org/b/44274> <rdar://problem/8330398> Windowless
    plugins don't paint in WebKit2 on Windows
    
    Reviewed by Sam Weinig.
    
    * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
    (WebKit::NPN_GetValue): Tell the plugin that we support windowless
    mode on Windows.
    (WebKit::NPN_SetValue): Implemented handling of NPPVpluginWindowBool
    by calling through to NetscapePlugin::setIsWindowed.
    
    * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
    (WebKit::NetscapePlugin::NetscapePlugin): Added initialization of
    m_isWindowed. It defaults to false on Mac and true on other platforms,
    matching WebCore's PluginView.
    
    * WebProcess/Plugins/Netscape/NetscapePlugin.h: Added m_isWindowed.
    (WebKit::NetscapePlugin::setIsWindowed): Added standard setter.
    
    * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
    (WebKit::NetscapePlugin::platformPaint): Moved Mac-specific context
    translation code here from PluginView::paint.
    
    * WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp:
    (WebKit::NetscapePlugin::platformPaint): Implemented. Code was ported
    from WebCore's PluginViewWin.cpp.
    
    * WebProcess/Plugins/Plugin.h: Updated the comment for Plugin::paint
    to explain the coordinate system of the context.
    
    * WebProcess/Plugins/PluginView.cpp:
    (WebKit::PluginView::paint): Changed to translate the context from
    document to window coordinates. We were previously trying to translate
    to plugin-local coordinates, but this only worked for documents whose
    origin was the same as the window's origin (i.e., the main frame). The
    plugin takes care of any further translations needed. (Mac translates
    the context into plugin-local coordinates, and Windows leaves it in
    window coordinates.)
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65705 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index c14f415..c61934f 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,5 +1,51 @@
 2010-08-19  Adam Roben  <aroben at apple.com>
 
+        Add support for painting windowless plugins on Windows
+
+        This gets the video on the front page of vimeo.com painting (though
+        you can't make it play because we don't support mouse events yet).
+
+        Fixes <http://webkit.org/b/44274> <rdar://problem/8330395> Windowless
+        plugins don't paint in WebKit2 on Windows
+
+        Reviewed by Sam Weinig.
+
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        (WebKit::NPN_GetValue): Tell the plugin that we support windowless
+        mode on Windows.
+        (WebKit::NPN_SetValue): Implemented handling of NPPVpluginWindowBool
+        by calling through to NetscapePlugin::setIsWindowed.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::NetscapePlugin): Added initialization of
+        m_isWindowed. It defaults to false on Mac and true on other platforms,
+        matching WebCore's PluginView.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h: Added m_isWindowed.
+        (WebKit::NetscapePlugin::setIsWindowed): Added standard setter.
+
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::platformPaint): Moved Mac-specific context
+        translation code here from PluginView::paint.
+
+        * WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp:
+        (WebKit::NetscapePlugin::platformPaint): Implemented. Code was ported
+        from WebCore's PluginViewWin.cpp.
+
+        * WebProcess/Plugins/Plugin.h: Updated the comment for Plugin::paint
+        to explain the coordinate system of the context.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::paint): Changed to translate the context from
+        document to window coordinates. We were previously trying to translate
+        to plugin-local coordinates, but this only worked for documents whose
+        origin was the same as the window's origin (i.e., the main frame). The
+        plugin takes care of any further translations needed. (Mac translates
+        the context into plugin-local coordinates, and Windows leaves it in
+        window coordinates.)
+
+2010-08-19  Adam Roben  <aroben at apple.com>
+
         Implement PluginInfoStore::pluginsDirectories
 
         This makes WebKit2 able to find and load Flash on Windows.
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
index 1aae066..d6c080f 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
@@ -440,6 +440,10 @@ static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value)
             *(NPBool*)value = false;
             break;
 #endif
+#elif PLATFORM(WIN)
+       case NPNVSupportsWindowless:
+           *(NPBool*)value = true;
+           break;
 #endif
         default:
             notImplemented();
@@ -468,7 +472,12 @@ static NPError NPN_SetValue(NPP npp, NPPVariable variable, void *value)
         }
 #endif
 
-        case NPPVpluginWindowBool:
+        case NPPVpluginWindowBool: {
+            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
+            plugin->setIsWindowed(value);
+            return NPERR_NO_ERROR;
+        }
+
         case NPPVpluginTransparentBool:
         default:
             notImplemented();
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index a89f936..8a9469b 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -46,6 +46,11 @@ NetscapePlugin::NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule)
     , m_pluginModule(pluginModule)
     , m_npWindow()
     , m_isStarted(false)
+#if PLATFORM(MAC)
+    , m_isWindowed(false)
+#else
+    , m_isWindowed(true)
+#endif
     , m_inNPPNew(false)
     , m_loadManually(false)
 #if PLATFORM(MAC)
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index 008d876..18f6cf5 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -62,6 +62,7 @@ public:
     void loadURL(const WTF::String& method, const WTF::String& urlString, const WTF::String& target, const WebCore::HTTPHeaderMap& headerFields,
                  const Vector<char>& httpBody, bool sendNotification, void* notificationData);
     NPError destroyStream(NPStream*, NPReason);
+    void setIsWindowed(bool windowed) { m_isWindowed = windowed; }
     void setStatusbarText(const WTF::String&);
     static void setException(const WTF::String&);
     bool evaluate(NPObject*, const WTF::String&scriptString, NPVariant* result);
@@ -156,6 +157,7 @@ private:
     CString m_userAgent;
 
     bool m_isStarted;
+    bool m_isWindowed;
     bool m_inNPPNew;
     bool m_loadManually;
     RefPtr<NetscapePluginStream> m_manualStream;
diff --git a/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
index 5acb8ed..3348adc 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
+++ b/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm
@@ -137,6 +137,9 @@ static inline NPCocoaEvent initializeEvent(NPCocoaEventType type)
 
 void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect)
 {
+    // Translate the context so that the origin is at the top left corner of the plug-in view.
+    context->translate(frameRect().x(), frameRect().y());
+
     switch (m_eventModel) {
         case NPEventModelCocoa: {
             // Don't send draw events when we're using the Core Animation drawing model.
diff --git a/WebKit2/WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp b/WebKit2/WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp
index db86db6..28423d5 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/win/NetscapePluginWin.cpp
@@ -26,6 +26,7 @@
 #include "NetscapePlugin.h"
 
 #include "NotImplemented.h"
+#include <WebCore/GraphicsContext.h>
 
 using namespace WebCore;
 
@@ -37,9 +38,47 @@ bool NetscapePlugin::platformPostInitialize()
     return true;
 }
 
-void NetscapePlugin::platformPaint(GraphicsContext*, const IntRect&)
+void NetscapePlugin::platformPaint(GraphicsContext* context, const IntRect& dirtyRect)
 {
-    notImplemented();
+    // FIXME: Call SetWindow here if we haven't called it yet (see r59904).
+
+    if (m_isWindowed) {
+        // FIXME: Paint windowed plugins into context if context->shouldIncludeChildWindows() is true.
+        return;
+    }
+
+    // FIXME: Support transparent plugins.
+    HDC hdc = context->getWindowsContext(dirtyRect, false);
+
+    m_npWindow.type = NPWindowTypeDrawable;
+    m_npWindow.window = hdc;
+
+    WINDOWPOS windowpos = { 0, 0, 0, 0, 0, 0, 0 };
+
+    windowpos.x = m_frameRect.x();
+    windowpos.y = m_frameRect.y();
+    windowpos.cx = m_frameRect.width();
+    windowpos.cy = m_frameRect.height();
+
+    NPEvent npEvent;
+    npEvent.event = WM_WINDOWPOSCHANGED;
+    npEvent.wParam = 0;
+    npEvent.lParam = reinterpret_cast<uintptr_t>(&windowpos);
+
+    NPP_HandleEvent(&npEvent);
+
+    callSetWindow();
+
+    RECT dirtyWinRect = dirtyRect;
+
+    npEvent.event = WM_PAINT;
+    npEvent.wParam = reinterpret_cast<uintptr_t>(hdc);
+    npEvent.lParam = reinterpret_cast<uintptr_t>(&dirtyWinRect);
+
+    NPP_HandleEvent(&npEvent);
+
+    // FIXME: Support transparent plugins.
+    context->releaseWindowsContext(hdc, dirtyRect, false);
 }
 
 bool NetscapePlugin::platformHandleMouseEvent(const WebMouseEvent&)
diff --git a/WebKit2/WebProcess/Plugins/Plugin.h b/WebKit2/WebProcess/Plugins/Plugin.h
index 47fee83..cd9a3d0 100644
--- a/WebKit2/WebProcess/Plugins/Plugin.h
+++ b/WebKit2/WebProcess/Plugins/Plugin.h
@@ -63,7 +63,8 @@ public:
     // Destroys the plug-in.
     virtual void destroy() = 0;
 
-    // Tells the plug-in to paint itself into the given graphics context. The passed in dirty rect is in window coordinates.
+    // Tells the plug-in to paint itself into the given graphics context. The passed-in context and
+    // dirty rect are in window coordinates. The context is saved/restored by the caller.
     virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect& dirtyRect) = 0;
 
 #if PLATFORM(MAC)
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index 73f5ae5..c618a8e 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -374,19 +374,20 @@ void PluginView::paint(GraphicsContext* context, const IntRect& dirtyRect)
 {
     if (context->paintingDisabled() || !m_plugin || !m_isInitialized)
         return;
-    
+
     IntRect dirtyRectInWindowCoordinates = parent()->contentsToWindow(dirtyRect);
     
     IntRect paintRectInWindowCoordinates = intersection(dirtyRectInWindowCoordinates, clipRectInWindowCoordinates());
     if (paintRectInWindowCoordinates.isEmpty())
         return;
 
+    // context is in document coordinates. Translate it to window coordinates.
+    IntPoint documentOriginInWindowCoordinates = parent()->contentsToWindow(IntPoint());
     context->save();
-
-    // Translate the context so that the origin is at the top left corner of the plug-in view.
-    context->translate(frameRect().x(), frameRect().y());
+    context->translate(-documentOriginInWindowCoordinates.x(), -documentOriginInWindowCoordinates.y());
 
     m_plugin->paint(context, paintRectInWindowCoordinates);
+
     context->restore();
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list