[mingw-webkitgtk] Backport NPAPI plugin support from trunk

Kalev Lember kalev at fedoraproject.org
Mon Aug 6 19:09:13 UTC 2012


commit e342c15c7ef0da73de4744a71632d755f82edf0b
Author: Kalev Lember <kalevlember at gmail.com>
Date:   Mon Aug 6 19:48:05 2012 +0300

    Backport NPAPI plugin support from trunk

 .gitignore                                         |    1 +
 0001-GTK-Fix-NPAPI-plugins-on-Windows.patch        |  491 ++++++++++++++++++++
 ...Fix-plugin-drawing-to-an-offscreen-buffer.patch |   59 +++
 mingw-webkitgtk.spec                               |   11 +
 sources                                            |    1 +
 5 files changed, 563 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 5fe9b3f..6939e42 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@
 /webkit-1.8.0.tar.xz
 /webkit-1.8.1.tar.xz
 /webkit-1.8.2.tar.xz
+/webkit-1.8.2-win32-extra.tar.xz
diff --git a/0001-GTK-Fix-NPAPI-plugins-on-Windows.patch b/0001-GTK-Fix-NPAPI-plugins-on-Windows.patch
new file mode 100644
index 0000000..847344a
--- /dev/null
+++ b/0001-GTK-Fix-NPAPI-plugins-on-Windows.patch
@@ -0,0 +1,491 @@
+From 618672dd7b30d030c8fbecd165c385293b9d1cff Mon Sep 17 00:00:00 2001
+From: "commit-queue at webkit.org"
+ <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
+Date: Thu, 21 Jun 2012 19:20:00 +0000
+Subject: [PATCH] [GTK] Fix NPAPI plugins on Windows
+ https://bugs.webkit.org/show_bug.cgi?id=54531
+
+Patch by Kalev Lember <kalevlember at gmail.com> on 2012-06-21
+Reviewed by Martin Robinson.
+
+.:
+
+Define XP_WIN on Windows for plugin support.
+
+* GNUmakefile.am:
+
+Source/WebCore:
+
+Switch to using PluginPackageWin.cpp and PluginViewWin.cpp on Windows
+platform, and leave plugins/gtk/ only for XP_UNIX platforms. With this
+we can share a lot of code with other ports and don't have to
+reimplement all the Windows-specific code in plugins/gtk/.
+
+* GNUmakefile.am:
+* GNUmakefile.list.am:
+* platform/FileSystem.h:
+(WebCore):
+* platform/graphics/GraphicsContext.h:
+(GraphicsContext):
+* platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h:
+(WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
+(GraphicsContextPlatformPrivate):
+* platform/graphics/transforms/TransformationMatrix.h:
+(TransformationMatrix):
+* platform/graphics/win/GraphicsContextCairoWin.cpp:
+(WebCore):
+* platform/graphics/win/GraphicsContextWin.cpp:
+(WebCore):
+* platform/gtk/FileSystemGtk.cpp:
+(WebCore::unloadModule):
+* plugins/PluginView.h:
+(PluginView):
+* plugins/win/PluginViewWin.cpp:
+(windowHandleForPageClient):
+(WebCore::registerPluginView):
+(WebCore::PluginView::paint):
+(WebCore::PluginView::handleMouseEvent):
+(WebCore::PluginView::platformStart):
+(WebCore::PluginView::snapshot):
+
+Source/JavaScriptCore:
+
+Define ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH for the GTK+ port, and
+include OwnPtrWin.cpp in the list of files built on Windows.
+
+* GNUmakefile.am:
+* GNUmakefile.list.am:
+* wtf/Platform.h:
+
+git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+---
+ GNUmakefile.am                                     |  5 ++-
+ Source/JavaScriptCore/GNUmakefile.am                          |  5 +++
+ Source/JavaScriptCore/GNUmakefile.list.am                     |  3 +-
+ Source/JavaScriptCore/wtf/Platform.h                          |  2 +-
+ Source/WebCore/GNUmakefile.am                      | 13 ++++++++
+ Source/WebCore/GNUmakefile.list.am                 | 23 ++++++++++---
+ Source/WebCore/platform/FileSystem.h               |  6 ++--
+ Source/WebCore/platform/graphics/GraphicsContext.h |  2 +-
+ .../cairo/GraphicsContextPlatformPrivateCairo.h    |  6 ++--
+ .../graphics/transforms/TransformationMatrix.h     |  4 +--
+ .../graphics/win/GraphicsContextCairoWin.cpp       |  5 +++
+ .../platform/graphics/win/GraphicsContextWin.cpp   |  4 +++
+ Source/WebCore/platform/gtk/FileSystemGtk.cpp      |  4 +++
+ Source/WebCore/plugins/PluginView.h                |  4 +--
+ Source/WebCore/plugins/win/PluginViewWin.cpp       | 29 +++++++++++-----
+ 18 files changed, 152 insertions(+), 27 deletions(-)
+
+diff --git a/GNUmakefile.am b/GNUmakefile.am
+index f963842..6a4e977 100644
+--- a/GNUmakefile.am
++++ b/GNUmakefile.am
+@@ -161,7 +161,10 @@ global_cppflags += \
+ 	-DWTF_CHANGES
+ 
+ # For the Gtk port we want to use XP_UNIX both in X11 and Mac
+-if !TARGET_WIN32
++if TARGET_WIN32
++global_cppflags += \
++	-DXP_WIN
++else
+ global_cppflags += \
+ 	-DXP_UNIX
+ endif
+diff --git a/Source/JavaScriptCore/GNUmakefile.am b/Source/JavaScriptCore/GNUmakefile.am
+index 2633bbb..7eab5c6 100644
+--- a/Source/JavaScriptCore/GNUmakefile.am
++++ b/Source/JavaScriptCore/GNUmakefile.am
+@@ -15,6 +15,11 @@ libjavascriptcoregtk_ at WEBKITGTK_API_MAJOR_VERSION@_ at WEBKITGTK_API_MINOR_VERSION@_la_LIBADD = \
+ 	$(GLIB_LIBS) \
+ 	$(WINMM_LIBS)
+ 
++if TARGET_WIN32
++# OwnPtrWin.cpp needs the symbols from gdi32 dll
++libjavascriptcoregtk_ at WEBKITGTK_API_MAJOR_VERSION@_ at WEBKITGTK_API_MINOR_VERSION@_la_LIBADD += -lgdi32
++endif
++
+ libjavascriptcoregtk_ at WEBKITGTK_API_MAJOR_VERSION@_ at WEBKITGTK_API_MINOR_VERSION@_la_CXXFLAGS = \
+ 	$(global_cxxflags) \
+ 	$(libjavascriptcoregtk_ at WEBKITGTK_API_MAJOR_VERSION@_ at WEBKITGTK_API_MINOR_VERSION@_la_CFLAGS)
+diff --git a/Source/JavaScriptCore/GNUmakefile.list.am b/Source/JavaScriptCore/GNUmakefile.list.am
+index 3dfc1db..c5f48a6 100644
+--- a/Source/JavaScriptCore/GNUmakefile.list.am
++++ b/Source/JavaScriptCore/GNUmakefile.list.am
+@@ -227,7 +227,8 @@ javascriptcore_sources += \
+ 	Source/JavaScriptCore/wtf/OSAllocatorWin.cpp \
+ 	Source/JavaScriptCore/wtf/ThreadFunctionInvocation.h \
+ 	Source/JavaScriptCore/wtf/ThreadingWin.cpp \
+-	Source/JavaScriptCore/wtf/ThreadSpecificWin.cpp
++	Source/JavaScriptCore/wtf/ThreadSpecificWin.cpp \
++	Source/JavaScriptCore/wtf/win/OwnPtrWin.cpp
+ else
+ javascriptcore_sources += \
+ 	Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp \
+diff --git a/Source/JavaScriptCore/wtf/Platform.h b/Source/JavaScriptCore/wtf/Platform.h
+index 3da0cd7..a5c2eae 100644
+--- a/Source/JavaScriptCore/wtf/Platform.h
++++ b/Source/JavaScriptCore/wtf/Platform.h
+@@ -1026,7 +1026,7 @@
+ #define WTF_USE_PROTECTION_SPACE_AUTH_CALLBACK 1
+ #endif
+ 
+-#if !ENABLE(NETSCAPE_PLUGIN_API) || (ENABLE(NETSCAPE_PLUGIN_API) && ((OS(UNIX) && (PLATFORM(QT) || PLATFORM(WX))) || PLATFORM(GTK) || PLATFORM(EFL)))
++#if !ENABLE(NETSCAPE_PLUGIN_API) || (ENABLE(NETSCAPE_PLUGIN_API) && ((OS(UNIX) && (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(WX))) || PLATFORM(EFL)))
+ #define ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH 1
+ #endif
+ 
+diff --git a/Source/WebCore/GNUmakefile.am b/Source/WebCore/GNUmakefile.am
+index 1319180..1649872 100644
+--- a/Source/WebCore/GNUmakefile.am
++++ b/Source/WebCore/GNUmakefile.am
+@@ -155,6 +155,14 @@ webcoregtk_cppflags += \
+ 	-I$(srcdir)/Source/WebCore/platform/graphics/pango
+ endif # END USE_PANGO
+ 
++# ---
++# Windows plugin support
++# ---
++if TARGET_WIN32
++webcoregtk_cppflags += \
++	-I$(srcdir)/Source/WebCore/platform/graphics/win
++endif # END TARGET_WIN32
++
+ # ----
+ # HTML Details Element
+ # ----
+@@ -965,6 +973,11 @@ libWebCore_la_CPPFLAGS = \
+ 	$(XRENDER_CFLAGS) \
+ 	$(XT_CFLAGS)
+ 
++if TARGET_WIN32
++# PluginPackageWin.cpp needs the symbols from version dll
++libWebCore_la_LIBADD = -lversion
++endif
++
+ # We have a different library with only the files that require GTK+. It allows us
+ # to build a common WebCore lib and two different gtk WebCore libs depending on
+ # the gtk version. In WeKit2 gtk2 is not supported, but the plugin process needs to
+diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am
+index 7c670d3..e55d972 100644
+--- a/Source/WebCore/GNUmakefile.list.am
++++ b/Source/WebCore/GNUmakefile.list.am
+@@ -4818,9 +4818,7 @@ webcoregtk_sources += \
+ 	Source/WebCore/platform/gtk/SoundGtk.cpp \
+ 	Source/WebCore/platform/gtk/WidgetGtk.cpp \
+ 	Source/WebCore/platform/gtk/WidgetRenderingContext.cpp \
+-	Source/WebCore/platform/gtk/WidgetRenderingContext.h \
+-	Source/WebCore/plugins/gtk/PluginPackageGtk.cpp \
+-	Source/WebCore/plugins/gtk/PluginViewGtk.cpp
++	Source/WebCore/platform/gtk/WidgetRenderingContext.h
+ 
+ if TARGET_X11
+ webcoregtk_sources += \
+@@ -4836,13 +4834,28 @@ endif
+ 
+ if TARGET_WIN32
+ webcore_sources += \
++	Source/WebCore/platform/graphics/win/DIBPixelData.cpp \
++	Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp \
++	Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp \
++	Source/WebCore/platform/graphics/win/LocalWindowsContext.h \
++	Source/WebCore/platform/graphics/win/TransformationMatrixWin.cpp \
++	Source/WebCore/platform/win/BitmapInfo.cpp \
++	Source/WebCore/platform/win/BitmapInfo.h \
+ 	Source/WebCore/platform/win/SystemInfo.cpp \
+ 	Source/WebCore/platform/win/SystemInfo.h \
++	Source/WebCore/platform/win/WebCoreInstanceHandle.cpp \
++	Source/WebCore/platform/win/WebCoreInstanceHandle.h \
+ 	Source/WebCore/plugins/win/PluginDatabaseWin.cpp \
+ 	Source/WebCore/plugins/win/PluginMessageThrottlerWin.cpp \
+-	Source/WebCore/plugins/win/PluginMessageThrottlerWin.h
++	Source/WebCore/plugins/win/PluginMessageThrottlerWin.h \
++	Source/WebCore/plugins/win/PluginPackageWin.cpp
++webcoregtk_sources += \
++	Source/WebCore/platform/cairo/WidgetBackingStoreCairo.cpp \
++	Source/WebCore/plugins/win/PluginViewWin.cpp
++else
+ webcoregtk_sources += \
+-	Source/WebCore/platform/cairo/WidgetBackingStoreCairo.cpp
++	Source/WebCore/plugins/gtk/PluginPackageGtk.cpp \
++	Source/WebCore/plugins/gtk/PluginViewGtk.cpp
+ endif
+ 
+ # ----
+diff --git a/Source/WebCore/platform/FileSystem.h b/Source/WebCore/platform/FileSystem.h
+index 6d7e05e..b3c259a 100644
+--- a/Source/WebCore/platform/FileSystem.h
++++ b/Source/WebCore/platform/FileSystem.h
+@@ -74,10 +74,10 @@ typedef struct _GModule GModule;
+ namespace WebCore {
+ 
+ // PlatformModule
+-#if PLATFORM(GTK)
+-typedef GModule* PlatformModule;
+-#elif OS(WINDOWS)
++#if OS(WINDOWS)
+ typedef HMODULE PlatformModule;
++#elif PLATFORM(GTK)
++typedef GModule* PlatformModule;
+ #elif PLATFORM(QT)
+ #if defined(Q_WS_MAC)
+ typedef CFBundleRef PlatformModule;
+diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h
+index af252a7..f27bec7 100644
+--- a/Source/WebCore/platform/graphics/GraphicsContext.h
++++ b/Source/WebCore/platform/graphics/GraphicsContext.h
+@@ -488,7 +488,7 @@ namespace WebCore {
+         void drawWindowsBitmap(WindowsBitmap*, const IntPoint&);
+ #endif
+ 
+-#if (PLATFORM(QT) && defined(Q_WS_WIN)) || (PLATFORM(WX) && OS(WINDOWS))
++#if (PLATFORM(GTK) && OS(WINDOWS)) || (PLATFORM(QT) && defined(Q_WS_WIN)) || (PLATFORM(WX) && OS(WINDOWS))
+         HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);
+         void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);
+         bool shouldIncludeChildWindows() const { return false; }
+diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h b/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
+index d5577a3..4cc8c80 100644
+--- a/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
++++ b/Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
+@@ -52,7 +52,8 @@ public:
+         : platformContext(newPlatformContext)
+ #if PLATFORM(GTK)
+         , expose(0)
+-#elif PLATFORM(WIN)
++#endif
++#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS))
+         // NOTE:  These may note be needed: review and remove once Cairo implementation is complete
+         , m_hdc(0)
+         , m_shouldIncludeChildWindows(false)
+@@ -97,7 +98,8 @@ public:
+ 
+ #if PLATFORM(GTK)
+     GdkEventExpose* expose;
+-#elif PLATFORM(WIN)
++#endif
++#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS))
+     HDC m_hdc;
+     bool m_shouldIncludeChildWindows;
+ #endif
+diff --git a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
+index 7ce30c4..b164d79 100644
+--- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
++++ b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h
+@@ -50,7 +50,7 @@ typedef struct CGAffineTransform CGAffineTransform;
+ #include <wx/graphics.h>
+ #endif
+ 
+-#if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS)) || (PLATFORM(WX) && OS(WINDOWS))
++#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS)) || (PLATFORM(QT) && OS(WINDOWS)) || (PLATFORM(WX) && OS(WINDOWS))
+ #if COMPILER(MINGW) && !COMPILER(MINGW64)
+ typedef struct _XFORM XFORM;
+ #else
+@@ -341,7 +341,7 @@ public:
+     operator wxGraphicsMatrix() const;
+ #endif
+ 
+-#if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS)) || (PLATFORM(WX) && OS(WINDOWS))
++#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS)) || (PLATFORM(QT) && OS(WINDOWS)) || (PLATFORM(WX) && OS(WINDOWS))
+     operator XFORM() const;
+ #endif
+ 
+diff --git a/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp b/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
+index e2deff7..9fbfd69 100644
+--- a/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
++++ b/Source/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
+@@ -27,6 +27,7 @@
+ #include "GraphicsContext.h"
+ 
+ #include "AffineTransform.h"
++#include "DIBPixelData.h"
+ #include "Path.h"
+ 
+ #include <cairo-win32.h>
+@@ -36,6 +37,7 @@ using namespace std;
+ 
+ namespace WebCore {
+ 
++#if PLATFORM(WIN)
+ static cairo_t* createCairoContextWithHDC(HDC hdc, bool hasAlpha)
+ {
+     // Put the HDC In advanced mode so it will honor affine transforms.
+@@ -87,6 +89,7 @@ void GraphicsContext::platformInit(HDC dc, bool hasAlpha)
+         setPlatformStrokeColor(strokeColor(), strokeColorSpace());
+     }
+ }
++#endif
+ 
+ static void setRGBABitmapAlpha(unsigned char* bytes, size_t length, unsigned char level)
+ {
+@@ -149,6 +152,7 @@ void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, boo
+     ::DeleteDC(hdc);
+ }
+ 
++#if PLATFORM(WIN)
+ void GraphicsContext::drawWindowsBitmap(WindowsBitmap* bitmap, const IntPoint& point)
+ {
+     drawBitmapToContext(m_data, platformContext()->cr(), bitmap->windowsDIB(), IntSize(point.x(), bitmap->size().height() + point.y()));
+@@ -171,5 +175,6 @@ void GraphicsContextPlatformPrivate::flush()
+     cairo_surface_flush(surface);
+     cairo_surface_destroy(surface);
+ }
++#endif
+ 
+ }
+diff --git a/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp b/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp
+index e319bc4..9514a49 100644
+--- a/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp
++++ b/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp
+@@ -51,6 +51,7 @@ static void fillWithClearColor(HBITMAP bitmap)
+     memset(bmpInfo.bmBits, 0, bufferSize);
+ }
+ 
++#if PLATFORM(WIN)
+ void GraphicsContext::setShouldIncludeChildWindows(bool include)
+ {
+     m_data->m_shouldIncludeChildWindows = include;
+@@ -94,6 +95,7 @@ PassOwnPtr<GraphicsContext::WindowsBitmap> GraphicsContext::createWindowsBitmap(
+ {
+     return adoptPtr(new WindowsBitmap(m_data->m_hdc, size));
+ }
++#endif
+ 
+ HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
+ {
+@@ -133,6 +135,7 @@ HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlpha
+     return m_data->m_hdc;
+ }
+ 
++#if PLATFORM(WIN)
+ void GraphicsContextPlatformPrivate::save()
+ {
+     if (!m_hdc)
+@@ -202,5 +205,6 @@ void GraphicsContextPlatformPrivate::setCTM(const AffineTransform& transform)
+     XFORM xform = transform.toTransformationMatrix();
+     SetWorldTransform(m_hdc, &xform);
+ }
++#endif
+ 
+ }
+diff --git a/Source/WebCore/platform/gtk/FileSystemGtk.cpp b/Source/WebCore/platform/gtk/FileSystemGtk.cpp
+index 39c4d65..45cd53e 100644
+--- a/Source/WebCore/platform/gtk/FileSystemGtk.cpp
++++ b/Source/WebCore/platform/gtk/FileSystemGtk.cpp
+@@ -356,6 +356,10 @@ int readFromFile(PlatformFileHandle handle, char* data, int length)
+ 
+ bool unloadModule(PlatformModule module)
+ {
++#if OS(WINDOWS)
++    return ::FreeLibrary(module);
++#else
+     return g_module_close(module);
++#endif
+ }
+ }
+diff --git a/Source/WebCore/plugins/PluginView.h b/Source/WebCore/plugins/PluginView.h
+index aaf87c1..63ac151 100644
+--- a/Source/WebCore/plugins/PluginView.h
++++ b/Source/WebCore/plugins/PluginView.h
+@@ -47,7 +47,7 @@
+ #include "npruntime_internal.h"
+ #endif
+ 
+-#if OS(WINDOWS) && (PLATFORM(QT) || PLATFORM(WX))
++#if OS(WINDOWS) && (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(WX))
+ typedef struct HWND__* HWND;
+ typedef HWND PlatformPluginWidget;
+ #else
+@@ -376,7 +376,7 @@ namespace WebCore {
+         bool m_haveUpdatedPluginWidget;
+ #endif
+ 
+-#if ((PLATFORM(QT) || PLATFORM(WX)) && OS(WINDOWS)) || defined(XP_MACOSX) || PLATFORM(EFL)
++#if ((PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(WX)) && OS(WINDOWS)) || defined(XP_MACOSX) || PLATFORM(EFL)
+         // On Mac OSX and Qt/Windows the plugin does not have its own native widget,
+         // but is using the containing window as its reference for positioning/painting.
+         PlatformPluginWidget m_window;
+diff --git a/Source/WebCore/plugins/win/PluginViewWin.cpp b/Source/WebCore/plugins/win/PluginViewWin.cpp
+index c857a40..d4dc9b9 100644
+--- a/Source/WebCore/plugins/win/PluginViewWin.cpp
++++ b/Source/WebCore/plugins/win/PluginViewWin.cpp
+@@ -86,6 +86,11 @@
+ #include <cairo-win32.h>
+ #endif
+ 
++#if PLATFORM(GTK)
++#include <gdk/gdkwin32.h>
++#include <gtk/gtk.h>
++#endif
++
+ #if PLATFORM(QT)
+ #include "QWebPageClient.h"
+ #include <QWidget>
+@@ -102,7 +107,13 @@
+ 
+ static inline HWND windowHandleForPageClient(PlatformPageClient client)
+ {
+-#if PLATFORM(QT)
++#if PLATFORM(GTK)
++    if (!client)
++        return 0;
++    if (GdkWindow* window = gtk_widget_get_window(client))
++        return static_cast<HWND>(GDK_WINDOW_HWND(window));
++    return 0;
++#elif PLATFORM(QT)
+     if (!client)
+         return 0;
+     if (QWidget* pluginParent = qobject_cast<QWidget*>(client->pluginParent()))
+@@ -300,8 +311,8 @@ static bool registerPluginView()
+ 
+     haveRegisteredWindowClass = true;
+ 
+-#if PLATFORM(QT)
+-    WebCore::setInstanceHandle((HINSTANCE)(qWinAppInst()));
++#if PLATFORM(GTK) || PLATFORM(QT)
++    WebCore::setInstanceHandle((HINSTANCE)(GetModuleHandle(0)));
+ #endif
+ 
+     ASSERT(WebCore::instanceHandle());
+@@ -642,9 +653,9 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
+ 
+     // On Safari/Windows without transparency layers the GraphicsContext returns the HDC
+     // of the window and the plugin expects that the passed in DC has window coordinates.
+-    // In the Qt port we always draw in an offscreen buffer and therefore need to preserve
+-    // the translation set in getWindowsContext.
+-#if !PLATFORM(QT) && !OS(WINCE)
++    // In the GTK and Qt ports we always draw in an offscreen buffer and therefore need
++    // to preserve the translation set in getWindowsContext.
++#if !PLATFORM(GTK) && !PLATFORM(QT) && !OS(WINCE)
+     if (!context->isInTransparencyLayer()) {
+         XFORM transform;
+         GetWorldTransform(windowsContext.hdc(), &transform);
+@@ -752,7 +763,7 @@ void PluginView::handleMouseEvent(MouseEvent* event)
+     if (dispatchNPEvent(npEvent))
+         event->setDefaultHandled();
+ 
+-#if !PLATFORM(QT) && !PLATFORM(WX) && !OS(WINCE)
++#if !PLATFORM(GTK) && !PLATFORM(QT) && !PLATFORM(WX) && !OS(WINCE)
+     // Currently, Widget::setCursor is always called after this function in EventHandler.cpp
+     // and since we don't want that we set ignoreNextSetCursor to true here to prevent that.
+     ignoreNextSetCursor = true;
+@@ -997,7 +1008,7 @@ bool PluginView::platformStart()
+         HWND window = ::CreateWindowEx(0, kWebPluginViewdowClassName, 0, flags,
+                                        0, 0, 0, 0, parentWindowHandle, 0, WebCore::instanceHandle(), 0);
+ 
+-#if OS(WINDOWS) && (PLATFORM(QT) || PLATFORM(WX))
++#if OS(WINDOWS) && (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(WX))
+         m_window = window;
+ #else
+         setPlatformWidget(window);
+@@ -1040,7 +1051,7 @@ void PluginView::platformDestroy()
+ 
+ PassRefPtr<Image> PluginView::snapshot()
+ {
+-#if !PLATFORM(WX) && !OS(WINCE)
++#if !PLATFORM(GTK) && !PLATFORM(WX) && !OS(WINCE)
+     OwnPtr<HDC> hdc = adoptPtr(CreateCompatibleDC(0));
+ 
+     if (!m_isWindowed) {
+-- 
+1.7.11.2
+
diff --git a/0002-GTK-Win-Fix-plugin-drawing-to-an-offscreen-buffer.patch b/0002-GTK-Win-Fix-plugin-drawing-to-an-offscreen-buffer.patch
new file mode 100644
index 0000000..ef32edd
--- /dev/null
+++ b/0002-GTK-Win-Fix-plugin-drawing-to-an-offscreen-buffer.patch
@@ -0,0 +1,59 @@
+From f2f3c0e183154b0726c723ff81b236fe50661c70 Mon Sep 17 00:00:00 2001
+From: "commit-queue at webkit.org"
+ <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
+Date: Thu, 28 Jun 2012 18:00:42 +0000
+Subject: [PATCH] [GTK][Win]: Fix plugin drawing to an offscreen buffer
+ https://bugs.webkit.org/show_bug.cgi?id=89499
+
+Patch by Kalev Lember <kalevlember at gmail.com> on 2012-06-28
+Reviewed by Brent Fulgham.
+
+Take into account that the GTK+ port draws to a backing store and adjust
+the target rectangle calculation accordingly.
+
+* plugins/win/PluginViewWin.cpp:
+(WebCore::PluginView::paint):
+(WebCore::PluginView::setNPWindowRect):
+
+git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121441 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+---
+ Source/WebCore/plugins/win/PluginViewWin.cpp | 14 ++++++++++++++
+ 2 files changed, 28 insertions(+)
+
+diff --git a/Source/WebCore/plugins/win/PluginViewWin.cpp b/Source/WebCore/plugins/win/PluginViewWin.cpp
+index 05cc102..adfd2d3 100644
+--- a/Source/WebCore/plugins/win/PluginViewWin.cpp
++++ b/Source/WebCore/plugins/win/PluginViewWin.cpp
+@@ -648,7 +648,15 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
+     }
+ 
+     ASSERT(parent()->isFrameView());
++
++    // In the GTK port we draw in an offscreen buffer and don't want to use the window
++    // coordinates.
++#if PLATFORM(GTK)
++    IntRect rectInWindow(rect);
++    rectInWindow.intersect(frameRect());
++#else
+     IntRect rectInWindow = static_cast<FrameView*>(parent())->contentsToWindow(frameRect());
++#endif
+     LocalWindowsContext windowsContext(context, rectInWindow, m_isTransparent);
+ 
+     // On Safari/Windows without transparency layers the GraphicsContext returns the HDC
+@@ -832,7 +840,13 @@ void PluginView::setNPWindowRect(const IntRect& rect)
+     m_npWindow.clipRect.right = r.width();
+     m_npWindow.clipRect.bottom = r.height();
+ #else
++    // In the GTK port we draw in an offscreen buffer and don't want to use the window
++    // coordinates.
++# if PLATFORM(GTK)
++    IntPoint p = rect.location();
++# else
+     IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(rect.location());
++# endif
+     m_npWindow.x = p.x();
+     m_npWindow.y = p.y();
+ 
+-- 
+1.7.11.2
+
diff --git a/mingw-webkitgtk.spec b/mingw-webkitgtk.spec
index e5a45a1..82eab53 100644
--- a/mingw-webkitgtk.spec
+++ b/mingw-webkitgtk.spec
@@ -39,6 +39,11 @@ URL:		http://webkit.org/
 
 Source0:	http://webkitgtk.org/releases/webkit-%{version}.tar.xz
 
+# NPAPI plugin support, backported from trunk
+Source1:	webkit-1.8.2-win32-extra.tar.xz
+Patch0:		0001-GTK-Fix-NPAPI-plugins-on-Windows.patch
+Patch1:		0002-GTK-Win-Fix-plugin-drawing-to-an-offscreen-buffer.patch
+
 # The DumpRenderTree tool fails to compile for version 1.3.13
 # as it depends on internal symbols which aren't exported in
 # the .dll so it's safe to skip building this tool
@@ -147,6 +152,11 @@ Static version of the MinGW Windows WebKitGTK+ library.
 %prep
 %setup -qn "webkit-%{version}"
 
+# NPAPI plugin support, backported from trunk
+%setup -qn "webkit-%{version}" -T -D -b 1
+%patch0 -p1 -b .npapi_plugins
+%patch1 -p1 -b .npapi_offscreen_drawing
+
 %patch2 -p0 -b .dumprendertree
 
 autoreconf --verbose --install -I Source/autotools
@@ -253,6 +263,7 @@ find $RPM_BUILD_ROOT -name "*.la" -delete
 %changelog
 * Mon Aug 06 2012 Kalev Lember <kalevlember at gmail.com> - 1.8.2-1
 - Update to 1.8.2
+- Backport NPAPI plugin support from trunk
 
 * Fri Jul 20 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.8.1-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
diff --git a/sources b/sources
index 7f7a06d..c51958b 100644
--- a/sources
+++ b/sources
@@ -1 +1,2 @@
 f7bd0bd4f323039f15e19c82a9a8313c  webkit-1.8.2.tar.xz
+bfa99f10709a9b948107e082946d6c77  webkit-1.8.2-win32-extra.tar.xz


More information about the scm-commits mailing list