[GTK] Fix NPAPI plugins on Windows

https://bugs.webkit.org/show_bug.cgi?id=54531

Patch by Kalev Lember <kalevlember@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/WTF:

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
parent 75612ee9
2012-06-21 Kalev Lember <kalevlember@gmail.com>
[GTK] Fix NPAPI plugins on Windows
https://bugs.webkit.org/show_bug.cgi?id=54531
Reviewed by Martin Robinson.
Define XP_WIN on Windows for plugin support.
* GNUmakefile.am:
2012-06-21 Ryuan Choi <ryuan.choi@gmail.com>
[EFL][WK2] Make WebKit2/Efl headers and resources installable.
......
......@@ -161,7 +161,10 @@ global_cppflags += \
endif
# 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
......
2012-06-21 Kalev Lember <kalevlember@gmail.com>
[GTK] Fix NPAPI plugins on Windows
https://bugs.webkit.org/show_bug.cgi?id=54531
Reviewed by Martin Robinson.
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:
2012-06-21 Balazs Kelemen <kbalazs@webkit.org>
Compile error: 'bool std::isinf(float)' is not 'constexpr' with GCC 4.6 in C++11 mode
......
......@@ -15,6 +15,11 @@ libWTF_la_LIBADD = \
$(WINMM_LIBS) \
-lpthread
if TARGET_WIN32
# OwnPtrWin.cpp needs the symbols from gdi32 dll
libWTF_la_LIBADD += -lgdi32
endif
libWTF_la_CXXFLAGS = \
$(global_cxxflags) \
$(libWTF_la_CFLAGS)
......
......@@ -227,7 +227,8 @@ wtf_sources += \
Source/WTF/wtf/OSAllocatorWin.cpp \
Source/WTF/wtf/ThreadFunctionInvocation.h \
Source/WTF/wtf/ThreadingWin.cpp \
Source/WTF/wtf/ThreadSpecificWin.cpp
Source/WTF/wtf/ThreadSpecificWin.cpp \
Source/WTF/wtf/win/OwnPtrWin.cpp
else
wtf_sources += \
Source/WTF/wtf/OSAllocatorPosix.cpp
......
......@@ -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
......
2012-06-21 Kalev Lember <kalevlember@gmail.com>
[GTK] Fix NPAPI plugins on Windows
https://bugs.webkit.org/show_bug.cgi?id=54531
Reviewed by Martin Robinson.
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):
2012-06-21 Brady Eidson <beidson@apple.com>
<rdar://problem/11718988> and https://bugs.webkit.org/show_bug.cgi?id=89673
......@@ -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
libWebCoreModules_la_SOURCES = \
$(webcore_modules_sources)
......
......@@ -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
# ----
......
......@@ -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;
......
......@@ -488,7 +488,7 @@ namespace WebCore {
void drawWindowsBitmap(WindowsBitmap*, const IntPoint&);
#endif
#if (PLATFORM(QT) && OS(WINDOWS)) || (PLATFORM(WX) && OS(WINDOWS))
#if (PLATFORM(GTK) && OS(WINDOWS)) || (PLATFORM(QT) && OS(WINDOWS)) || (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; }
......
......@@ -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
......
......@@ -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
......
......@@ -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
}
......@@ -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
}
......@@ -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
}
}
......@@ -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;
......
......@@ -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"
#if HAVE(QT5)
......@@ -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 HAVE(QT5)
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment