summaryrefslogtreecommitdiffstats
path: root/WebCore/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/plugins')
-rw-r--r--WebCore/plugins/PluginView.cpp4
-rw-r--r--WebCore/plugins/PluginView.h30
-rw-r--r--WebCore/plugins/PluginViewNone.cpp8
-rw-r--r--WebCore/plugins/gtk/gtk2xtbin.c11
-rw-r--r--WebCore/plugins/qt/PluginPackageQt.cpp63
-rw-r--r--WebCore/plugins/qt/PluginViewQt.cpp57
6 files changed, 123 insertions, 50 deletions
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp
index 5a33b78..d410948 100644
--- a/WebCore/plugins/PluginView.cpp
+++ b/WebCore/plugins/PluginView.cpp
@@ -85,6 +85,8 @@ using JSC::JSValue;
using JSC::UString;
#endif
+#if ENABLE(NETSCAPE_PLUGIN_API)
+
using std::min;
using namespace WTF;
@@ -1486,3 +1488,5 @@ void PluginView::privateBrowsingStateChanged(bool privateBrowsingEnabled)
}
} // namespace WebCore
+
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index 2b272ec..01797e5 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -32,11 +32,9 @@
#include "HaltablePlugin.h"
#include "IntRect.h"
#include "MediaCanStartListener.h"
-#include "PluginStream.h"
#include "ResourceRequest.h"
#include "Timer.h"
#include "Widget.h"
-#include "npruntime_internal.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
@@ -45,10 +43,16 @@
#include <wtf/Vector.h>
#include <wtf/text/CString.h>
+<<<<<<< HEAD
// ANDROID
// TODO: Upstream to webkit.org
#ifdef PLUGIN_SCHEDULE_TIMER
#include "PluginTimer.h"
+=======
+#if ENABLE(NETSCAPE_PLUGIN_API)
+#include "PluginStream.h"
+#include "npruntime_internal.h"
+>>>>>>> webkit.org at r66079
#endif
#if OS(WINDOWS) && (PLATFORM(QT) || PLATFORM(WX))
@@ -130,13 +134,21 @@ namespace WebCore {
virtual void didFail(const ResourceError&) = 0;
};
- class PluginView : public Widget, private PluginStreamClient, public PluginManualLoader, private HaltablePlugin, private MediaCanStartListener {
+ class PluginView : public Widget
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ , private PluginStreamClient
+#endif
+ , public PluginManualLoader
+ , private HaltablePlugin
+ , private MediaCanStartListener {
public:
static PassRefPtr<PluginView> create(Frame* parentFrame, const IntSize&, Element*, const KURL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually);
virtual ~PluginView();
PluginPackage* plugin() const { return m_plugin.get(); }
+#if ENABLE(NETSCAPE_PLUGIN_API)
NPP instance() const { return m_instance; }
+#endif
void setNPWindowRect(const IntRect&);
static PluginView* currentPluginView();
@@ -147,6 +159,7 @@ namespace WebCore {
PluginStatus status() const { return m_status; }
+#if ENABLE(NETSCAPE_PLUGIN_API)
// NPN functions
NPError getURLNotify(const char* url, const char* target, void* notifyData);
NPError getURL(const char* url, const char* target);
@@ -155,6 +168,7 @@ namespace WebCore {
NPError newStream(NPMIMEType type, const char* target, NPStream** stream);
int32_t write(NPStream* stream, int32_t len, void* buffer);
NPError destroyStream(NPStream* stream, NPReason reason);
+#endif
const char* userAgent();
#if ENABLE(NETSCAPE_PLUGIN_API)
static const char* userAgentStatic();
@@ -164,10 +178,10 @@ namespace WebCore {
#if ENABLE(NETSCAPE_PLUGIN_API)
NPError getValue(NPNVariable variable, void* value);
static NPError getValueStatic(NPNVariable variable, void* value);
-#endif
NPError setValue(NPPVariable variable, void* value);
void invalidateRect(NPRect*);
void invalidateRegion(NPRegion);
+#endif
void forceRedraw();
void pushPopupsEnabledState(bool state);
void popPopupsEnabledState();
@@ -263,9 +277,11 @@ namespace WebCore {
void stop();
void platformDestroy();
static void setCurrentPluginView(PluginView*);
+#if ENABLE(NETSCAPE_PLUGIN_API)
NPError load(const FrameLoadRequest&, bool sendNotification, void* notifyData);
NPError handlePost(const char* url, const char* target, uint32_t len, const char* buf, bool file, void* notifyData, bool sendNotification, bool allowHeaders);
NPError handlePostReadFile(Vector<char>& buffer, uint32_t len, const char* buf);
+#endif
static void freeStringArray(char** stringArray, int length);
void setCallingPlugin(bool) const;
@@ -279,8 +295,10 @@ namespace WebCore {
static BOOL WINAPI hookedEndPaint(HWND, const PAINTSTRUCT*);
#endif
+#if ENABLE(NETSCAPE_PLUGIN_API)
static bool platformGetValueStatic(NPNVariable variable, void* value, NPError* result);
bool platformGetValue(NPNVariable variable, void* value, NPError* result);
+#endif
RefPtr<Frame> m_parentFrame;
RefPtr<PluginPackage> m_plugin;
@@ -305,7 +323,9 @@ namespace WebCore {
Timer<PluginView> m_lifeSupportTimer;
#ifndef NP_NO_CARBON
+#if ENABLE(NETSCAPE_PLUGIN_API)
bool dispatchNPEvent(NPEvent&);
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
#endif
void updatePluginWidget();
void paintMissingPluginIcon(GraphicsContext*, const IntRect&);
@@ -342,9 +362,11 @@ namespace WebCore {
String m_mimeType;
WTF::CString m_userAgent;
+#if ENABLE(NETSCAPE_PLUGIN_API)
NPP m_instance;
NPP_t m_instanceStruct;
NPWindow m_npWindow;
+#endif
Vector<bool, 4> m_popupStateStack;
diff --git a/WebCore/plugins/PluginViewNone.cpp b/WebCore/plugins/PluginViewNone.cpp
index eb32cd1..ab8f620 100644
--- a/WebCore/plugins/PluginViewNone.cpp
+++ b/WebCore/plugins/PluginViewNone.cpp
@@ -66,12 +66,12 @@ void PluginView::setNPWindowRect(const IntRect&)
{
}
+#if ENABLE(NETSCAPE_PLUGIN_API)
NPError PluginView::handlePostReadFile(Vector<char>&, uint32_t, const char*)
{
return 0;
}
-#if ENABLE(NETSCAPE_PLUGIN_API)
bool PluginView::platformGetValue(NPNVariable, void*, NPError*)
{
return false;
@@ -81,19 +81,21 @@ bool PluginView::platformGetValueStatic(NPNVariable, void*, NPError*)
{
return false;
}
-#endif
void PluginView::invalidateRect(NPRect*)
{
}
+#endif
void PluginView::invalidateRect(const IntRect&)
{
}
+#if ENABLE(NETSCAPE_PLUGIN_API)
void PluginView::invalidateRegion(NPRegion)
{
}
+#endif
void PluginView::forceRedraw()
{
@@ -139,7 +141,7 @@ void PluginView::handleFocusOutEvent()
// ports using PluginView, but until then, if new functions like this are
// added, please make sure they have the proper platform #ifs so that changes
// do not break ports who compile both this file and PluginView.cpp.
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM) || PLATFORM(EFL) || OS(WINCE) && !PLATFORM(QT)
+#if PLATFORM(MAC) || PLATFORM(CHROMIUM) || PLATFORM(EFL) || (OS(WINCE) && !PLATFORM(QT)) || (PLATFORM(QT) && !OS(WINCE))
#if ENABLE(NETSCAPE_PLUGIN_API)
void PluginView::keepAlive(NPP)
{
diff --git a/WebCore/plugins/gtk/gtk2xtbin.c b/WebCore/plugins/gtk/gtk2xtbin.c
index b7fd3f0..a0808d9 100644
--- a/WebCore/plugins/gtk/gtk2xtbin.c
+++ b/WebCore/plugins/gtk/gtk2xtbin.c
@@ -326,6 +326,8 @@ gtk_xtbin_new (GdkWindow *parent_window, String * f)
{
GtkXtBin *xtbin;
gpointer user_data;
+ GdkVisual* visual;
+ GdkColormap* colormap;
assert(parent_window != NULL);
xtbin = g_object_new (GTK_TYPE_XTBIN, NULL);
@@ -339,10 +341,13 @@ gtk_xtbin_new (GdkWindow *parent_window, String * f)
/* Initialize the Xt toolkit */
xtbin->parent_window = parent_window;
+ visual = gtk_widget_get_default_visual();
+ colormap = gtk_widget_get_default_colormap();
+
xt_client_init(&(xtbin->xtclient),
- GDK_VISUAL_XVISUAL(gdk_rgb_get_visual()),
- GDK_COLORMAP_XCOLORMAP(gdk_rgb_get_colormap()),
- gdk_visual_get_depth(gdk_rgb_get_visual()));
+ GDK_VISUAL_XVISUAL(visual),
+ GDK_COLORMAP_XCOLORMAP(colormap),
+ gdk_visual_get_depth(visual));
if (!xtbin->xtclient.xtdisplay) {
/* If XtOpenDisplay failed, we can't go any further.
diff --git a/WebCore/plugins/qt/PluginPackageQt.cpp b/WebCore/plugins/qt/PluginPackageQt.cpp
index 07149f3..d92fffe 100644
--- a/WebCore/plugins/qt/PluginPackageQt.cpp
+++ b/WebCore/plugins/qt/PluginPackageQt.cpp
@@ -35,8 +35,6 @@
namespace WebCore {
-typedef void gtkInitFunc(int *argc, char ***argv);
-
bool PluginPackage::fetchInfo()
{
if (!load())
@@ -92,6 +90,39 @@ static NPError staticPluginQuirkRequiresGtkToolKit_NPN_GetValue(NPP instance, NP
return NPN_GetValue(instance, variable, value);
}
+static void initializeGtk(QLibrary* module = 0)
+{
+ // Ensures missing Gtk initialization in some versions of Adobe's flash player
+ // plugin do not cause crashes. See BR# 40567, 44324, and 44405 for details.
+ if (module) {
+ typedef void *(*gtk_init_ptr)(int*, char***);
+ gtk_init_ptr gtkInit = (gtk_init_ptr)module->resolve("gtk_init");
+ if (gtkInit) {
+ // Prevent gtk_init() from replacing the X error handlers, since the Gtk
+ // handlers abort when they receive an X error, thus killing the viewer.
+#ifdef Q_WS_X11
+ int (*old_error_handler)(Display*, XErrorEvent*) = XSetErrorHandler(0);
+ int (*old_io_error_handler)(Display*) = XSetIOErrorHandler(0);
+#endif
+ gtkInit(0, 0);
+#ifdef Q_WS_X11
+ XSetErrorHandler(old_error_handler);
+ XSetIOErrorHandler(old_io_error_handler);
+#endif
+ return;
+ }
+ }
+
+ QLibrary library("libgtk-x11-2.0.so.0");
+ if (library.load()) {
+ typedef void *(*gtk_init_check_ptr)(int*, char***);
+ gtk_init_check_ptr gtkInitCheck = (gtk_init_check_ptr)library.resolve("gtk_init_check");
+ // NOTE: We're using gtk_init_check() since gtk_init() calls exit() on failure.
+ if (gtkInitCheck)
+ (void) gtkInitCheck(0, 0);
+ }
+}
+
bool PluginPackage::load()
{
if (m_isLoaded) {
@@ -111,7 +142,6 @@ bool PluginPackage::load()
NP_InitializeFuncPtr NP_Initialize;
NPError npErr;
- gtkInitFunc* gtkInit;
NP_Initialize = (NP_InitializeFuncPtr)m_module->resolve("NP_Initialize");
m_NPP_Shutdown = (NPP_ShutdownProcPtr)m_module->resolve("NP_Shutdown");
@@ -128,26 +158,13 @@ bool PluginPackage::load()
// nspluginwrapper relies on the toolkit value to know if glib is available
// It does so in NP_Initialize with a null instance, therefore it is done this way:
m_browserFuncs.getvalue = staticPluginQuirkRequiresGtkToolKit_NPN_GetValue;
- }
-
- // WORKAROUND: Prevent gtk based plugin crashes such as BR# 40567 by
- // explicitly forcing the initializing of Gtk, i.e. calling gtk_init,
- // whenver the symbol is present in the plugin library loaded above.
- // Note that this workaround is based on code from the NSPluginClass ctor
- // in KDE's kdebase/apps/nsplugins/viewer/nsplugin.cpp file.
- gtkInit = (gtkInitFunc*)m_module->resolve("gtk_init");
- if (gtkInit) {
- // Prevent gtk_init() from replacing the X error handlers, since the Gtk
- // handlers abort when they receive an X error, thus killing the viewer.
-#ifdef Q_WS_X11
- int (*old_error_handler)(Display*, XErrorEvent*) = XSetErrorHandler(0);
- int (*old_io_error_handler)(Display*) = XSetIOErrorHandler(0);
-#endif
- gtkInit(0, 0);
-#ifdef Q_WS_X11
- XSetErrorHandler(old_error_handler);
- XSetIOErrorHandler(old_io_error_handler);
-#endif
+ // Workaround Adobe's failure to properly initialize Gtk in some versions
+ // of their flash player plugin.
+ initializeGtk();
+ } else if (m_path.contains("flashplayer")) {
+ // Workaround Adobe's failure to properly initialize Gtk in some versions
+ // of their flash player plugin.
+ initializeGtk(m_module);
}
#if defined(XP_UNIX)
diff --git a/WebCore/plugins/qt/PluginViewQt.cpp b/WebCore/plugins/qt/PluginViewQt.cpp
index 3b41072..5c681b8 100644
--- a/WebCore/plugins/qt/PluginViewQt.cpp
+++ b/WebCore/plugins/qt/PluginViewQt.cpp
@@ -171,27 +171,49 @@ void PluginView::hide()
#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
void PluginView::paintUsingImageSurfaceExtension(QPainter* painter, const IntRect& exposedRect)
{
- if (m_isTransparent) {
- // On Maemo5, Flash expects the buffer to contain the contents that are below it.
- // We don't support transparency, so clean the image before giving to Flash.
- QPainter imagePainter(&m_image);
- imagePainter.fillRect(exposedRect, Qt::white);
- }
-
NPImageExpose imageExpose;
- imageExpose.data = reinterpret_cast<char*>(m_image.bits());
- imageExpose.stride = m_image.bytesPerLine();
- imageExpose.depth = m_image.depth();
+ QPoint offset;
+ QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
+ const bool surfaceHasUntransformedContents = client && qobject_cast<QWidget*>(client->pluginParent());
+
+ QPaintDevice* surface = QPainter::redirected(painter->device(), &offset);
+
+ // If the surface is a QImage, we can render directly into it
+ if (surfaceHasUntransformedContents && surface && surface->devType() == QInternal::Image) {
+ QImage* image = static_cast<QImage*>(surface);
+ offset = -offset; // negating the offset gives us the offset of the view within the surface
+ imageExpose.data = reinterpret_cast<char*>(image->bits());
+ imageExpose.dataSize.width = image->width();
+ imageExpose.dataSize.height = image->height();
+ imageExpose.stride = image->bytesPerLine();
+ imageExpose.depth = image->depth(); // this is guaranteed to be 16 on Maemo5
+ imageExpose.translateX = offset.x() + m_windowRect.x();
+ imageExpose.translateY = offset.y() + m_windowRect.y();
+ imageExpose.scaleX = 1;
+ imageExpose.scaleY = 1;
+ } else {
+ if (m_isTransparent) {
+ // On Maemo5, Flash expects the buffer to contain the contents that are below it.
+ // We don't support transparency for non-raster graphicssystem, so clean the image
+ // before giving to Flash.
+ QPainter imagePainter(&m_image);
+ imagePainter.fillRect(exposedRect, Qt::white);
+ }
+
+ imageExpose.data = reinterpret_cast<char*>(m_image.bits());
+ imageExpose.dataSize.width = m_image.width();
+ imageExpose.dataSize.height = m_image.height();
+ imageExpose.stride = m_image.bytesPerLine();
+ imageExpose.depth = m_image.depth();
+ imageExpose.translateX = 0;
+ imageExpose.translateY = 0;
+ imageExpose.scaleX = 1;
+ imageExpose.scaleY = 1;
+ }
imageExpose.x = exposedRect.x();
imageExpose.y = exposedRect.y();
imageExpose.width = exposedRect.width();
imageExpose.height = exposedRect.height();
- imageExpose.dataSize.width = m_image.width();
- imageExpose.dataSize.height = m_image.height();
- imageExpose.translateX = 0;
- imageExpose.translateY = 0;
- imageExpose.scaleX = 1;
- imageExpose.scaleY = 1;
XEvent xevent;
memset(&xevent, 0, sizeof(XEvent));
@@ -206,7 +228,8 @@ void PluginView::paintUsingImageSurfaceExtension(QPainter* painter, const IntRec
dispatchNPEvent(xevent);
- painter->drawImage(QPoint(frameRect().x() + exposedRect.x(), frameRect().y() + exposedRect.y()), m_image, exposedRect);
+ if (!surfaceHasUntransformedContents || !surface || surface->devType() != QInternal::Image)
+ painter->drawImage(QPoint(frameRect().x() + exposedRect.x(), frameRect().y() + exposedRect.y()), m_image, exposedRect);
}
#endif