summaryrefslogtreecommitdiffstats
path: root/WebCore/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/plugins')
-rw-r--r--WebCore/plugins/MimeType.cpp3
-rw-r--r--WebCore/plugins/PluginDatabase.cpp2
-rw-r--r--WebCore/plugins/PluginDebug.h2
-rw-r--r--WebCore/plugins/PluginPackage.cpp2
-rw-r--r--WebCore/plugins/PluginPackageNone.cpp7
-rw-r--r--WebCore/plugins/PluginStream.cpp2
-rw-r--r--WebCore/plugins/PluginStream.h8
-rw-r--r--WebCore/plugins/PluginView.cpp98
-rw-r--r--WebCore/plugins/PluginView.h15
-rw-r--r--WebCore/plugins/PluginViewNone.cpp28
-rw-r--r--WebCore/plugins/gtk/PluginPackageGtk.cpp13
-rw-r--r--WebCore/plugins/gtk/PluginViewGtk.cpp151
-rw-r--r--WebCore/plugins/gtk/gtk2xtbin.c5
-rw-r--r--WebCore/plugins/mac/PluginPackageMac.cpp10
-rw-r--r--WebCore/plugins/mac/PluginViewMac.cpp191
-rw-r--r--WebCore/plugins/qt/PluginPackageQt.cpp2
-rw-r--r--WebCore/plugins/qt/PluginViewQt.cpp76
-rw-r--r--WebCore/plugins/symbian/PluginContainerSymbian.cpp8
-rw-r--r--WebCore/plugins/symbian/PluginContainerSymbian.h7
-rw-r--r--WebCore/plugins/symbian/PluginPackageSymbian.cpp2
-rw-r--r--WebCore/plugins/symbian/PluginViewSymbian.cpp79
-rw-r--r--WebCore/plugins/win/PluginMessageThrottlerWin.cpp31
-rw-r--r--WebCore/plugins/win/PluginMessageThrottlerWin.h2
-rw-r--r--WebCore/plugins/win/PluginPackageWin.cpp2
-rw-r--r--WebCore/plugins/win/PluginViewWin.cpp101
25 files changed, 448 insertions, 399 deletions
diff --git a/WebCore/plugins/MimeType.cpp b/WebCore/plugins/MimeType.cpp
index c4b051c..954715a 100644
--- a/WebCore/plugins/MimeType.cpp
+++ b/WebCore/plugins/MimeType.cpp
@@ -20,6 +20,7 @@
#include "MimeType.h"
#include "Frame.h"
+#include "FrameLoaderClient.h"
#include "Page.h"
#include "Plugin.h"
#include "PluginData.h"
@@ -55,7 +56,7 @@ const String &MimeType::description() const
PassRefPtr<Plugin> MimeType::enabledPlugin() const
{
const Page* p = m_pluginData->page();
- if (!p || !p->settings()->arePluginsEnabled())
+ if (!p || !p->mainFrame()->loader()->allowPlugins(NotAboutToInstantiatePlugin))
return 0;
const PluginInfo *info = m_pluginData->mimes()[m_index]->plugin;
diff --git a/WebCore/plugins/PluginDatabase.cpp b/WebCore/plugins/PluginDatabase.cpp
index 703ac87..a1200fc 100644
--- a/WebCore/plugins/PluginDatabase.cpp
+++ b/WebCore/plugins/PluginDatabase.cpp
@@ -263,7 +263,7 @@ PluginPackage* PluginDatabase::findPlugin(const KURL& url, String& mimeType)
String extension = filename.substring(extensionPos + 1);
String mimeTypeForExtension = MIMETypeForExtension(extension);
- if (plugin = pluginForMIMEType(mimeTypeForExtension))
+ if ((plugin = pluginForMIMEType(mimeTypeForExtension)))
mimeType = mimeTypeForExtension;
}
}
diff --git a/WebCore/plugins/PluginDebug.h b/WebCore/plugins/PluginDebug.h
index 5b84393..254864f 100644
--- a/WebCore/plugins/PluginDebug.h
+++ b/WebCore/plugins/PluginDebug.h
@@ -28,7 +28,7 @@
#include "Logging.h"
#include "npruntime_internal.h"
-#include "CString.h"
+#include <wtf/text/CString.h>
#define LOG_NPERROR(err) if (err != NPERR_NO_ERROR) LOG_VERBOSE(Plugins, "%s\n", prettyNameForNPError(err))
#define LOG_PLUGIN_NET_ERROR() LOG_VERBOSE(Plugins, "Stream failed due to problems with network, disk I/O, lack of memory, or other problems.\n")
diff --git a/WebCore/plugins/PluginPackage.cpp b/WebCore/plugins/PluginPackage.cpp
index 5949546..278be30 100644
--- a/WebCore/plugins/PluginPackage.cpp
+++ b/WebCore/plugins/PluginPackage.cpp
@@ -28,7 +28,6 @@
#include "config.h"
#include "PluginPackage.h"
-#include "CString.h"
#include "MIMETypeRegistry.h"
#include "PluginDatabase.h"
#include "PluginDebug.h"
@@ -36,6 +35,7 @@
#include "npruntime_impl.h"
#include <string.h>
#include <wtf/OwnArrayPtr.h>
+#include <wtf/text/CString.h>
namespace WebCore {
diff --git a/WebCore/plugins/PluginPackageNone.cpp b/WebCore/plugins/PluginPackageNone.cpp
index b943d88..3610f4a 100644
--- a/WebCore/plugins/PluginPackageNone.cpp
+++ b/WebCore/plugins/PluginPackageNone.cpp
@@ -42,4 +42,11 @@ bool PluginPackage::load()
return false;
}
+#if ENABLE(NETSCAPE_PLUGIN_API)
+uint16 PluginPackage::NPVersion() const
+{
+ return 0;
+}
+#endif
+
}
diff --git a/WebCore/plugins/PluginStream.cpp b/WebCore/plugins/PluginStream.cpp
index 9341c15..9bd497a 100644
--- a/WebCore/plugins/PluginStream.cpp
+++ b/WebCore/plugins/PluginStream.cpp
@@ -27,7 +27,6 @@
#include "config.h"
#include "PluginStream.h"
-#include "CString.h"
#include "DocumentLoader.h"
#include "Frame.h"
#include "FrameLoader.h"
@@ -35,6 +34,7 @@
#include "SharedBuffer.h"
#include "SubresourceLoader.h"
#include <StringExtras.h>
+#include <wtf/text/CString.h>
// We use -2 here because some plugins like to return -1 to indicate error
// and this way we won't clash with them.
diff --git a/WebCore/plugins/PluginStream.h b/WebCore/plugins/PluginStream.h
index 29a2644..c0487e3 100644
--- a/WebCore/plugins/PluginStream.h
+++ b/WebCore/plugins/PluginStream.h
@@ -27,7 +27,6 @@
#ifndef PluginStream_H
#define PluginStream_H
-#include "CString.h"
#include "FileSystem.h"
#include "KURL.h"
#include "NetscapePlugInStreamLoader.h"
@@ -42,6 +41,7 @@
#include <wtf/OwnPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
+#include <wtf/text/CString.h>
namespace WebCore {
class Frame;
@@ -70,7 +70,7 @@ namespace WebCore {
void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
- void sendJavaScriptStream(const KURL& requestURL, const CString& resultString);
+ void sendJavaScriptStream(const KURL& requestURL, const WTF::CString& resultString);
void cancelAndDestroyStream(NPReason);
static NPP ownerForStream(NPStream*);
@@ -113,8 +113,8 @@ namespace WebCore {
NPP m_instance;
uint16 m_transferMode;
int32 m_offset;
- CString m_headers;
- CString m_path;
+ WTF::CString m_headers;
+ WTF::CString m_path;
NPReason m_reason;
NPStream m_stream;
PluginQuirkSet m_quirks;
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp
index ba8d231..0bc4b0e 100644
--- a/WebCore/plugins/PluginView.cpp
+++ b/WebCore/plugins/PluginView.cpp
@@ -456,7 +456,7 @@ static bool getString(ScriptController* proxy, JSValue result, String& string)
UString ustring = result.toString(exec);
exec->clearException();
- string = ustring;
+ string = ustringToString(ustring);
return true;
}
#endif
@@ -579,12 +579,10 @@ NPError PluginView::load(const FrameLoadRequest& frameLoadRequest, bool sendNoti
String jsString = scriptStringIfJavaScriptURL(url);
if (!jsString.isNull()) {
- Settings* settings = m_parentFrame->settings();
-
// Return NPERR_GENERIC_ERROR if JS is disabled. This is what Mozilla does.
- if (!settings || !settings->isJavaScriptEnabled())
+ if (!m_parentFrame->script()->canExecuteScripts(NotAboutToExecuteScript))
return NPERR_GENERIC_ERROR;
-
+
// For security reasons, only allow JS requests to be made on the frame that contains the plug-in.
if (!targetFrameName.isNull() && m_parentFrame->tree()->find(targetFrameName) != m_parentFrame)
return NPERR_INVALID_PARAM;
@@ -1402,6 +1400,7 @@ void PluginView::keepAlive()
m_lifeSupportTimer.startOneShot(0);
}
+#if ENABLE(NETSCAPE_PLUGIN_API)
void PluginView::keepAlive(NPP instance)
{
PluginView* view = instanceMap().get(instance);
@@ -1410,5 +1409,94 @@ void PluginView::keepAlive(NPP instance)
view->keepAlive();
}
+#endif
+
+NPError PluginView::getValueStatic(NPNVariable variable, void* value)
+{
+ LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
+
+ NPError result;
+ if (platformGetValueStatic(variable, value, &result))
+ return result;
+
+ return NPERR_GENERIC_ERROR;
+}
+
+NPError PluginView::getValue(NPNVariable variable, void* value)
+{
+ LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
+
+ NPError result;
+ if (platformGetValue(variable, value, &result))
+ return result;
+
+ if (platformGetValueStatic(variable, value, &result))
+ return result;
+
+ switch (variable) {
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ case NPNVWindowNPObject: {
+ if (m_isJavaScriptPaused)
+ return NPERR_GENERIC_ERROR;
+
+ NPObject* windowScriptObject = m_parentFrame->script()->windowScriptNPObject();
+
+ // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
+ if (windowScriptObject)
+ _NPN_RetainObject(windowScriptObject);
+
+ void** v = (void**)value;
+ *v = windowScriptObject;
+
+ return NPERR_NO_ERROR;
+ }
+
+ case NPNVPluginElementNPObject: {
+ if (m_isJavaScriptPaused)
+ return NPERR_GENERIC_ERROR;
+
+ NPObject* pluginScriptObject = 0;
+
+ if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
+ pluginScriptObject = static_cast<HTMLPlugInElement*>(m_element)->getNPObject();
+
+ // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
+ if (pluginScriptObject)
+ _NPN_RetainObject(pluginScriptObject);
+
+ void** v = (void**)value;
+ *v = pluginScriptObject;
+
+ return NPERR_NO_ERROR;
+ }
+#endif
+
+ case NPNVprivateModeBool: {
+ Page* page = m_parentFrame->page();
+ if (!page)
+ return NPERR_GENERIC_ERROR;
+ *((NPBool*)value) = !page->settings() || page->settings()->privateBrowsingEnabled();
+ return NPERR_NO_ERROR;
+ }
+
+ default:
+ return NPERR_GENERIC_ERROR;
+ }
+}
+
+void PluginView::privateBrowsingStateChanged(bool privateBrowsingEnabled)
+{
+ NPP_SetValueProcPtr setValue = m_plugin->pluginFuncs()->setvalue;
+ if (!setValue)
+ return;
+
+ PluginView::setCurrentPluginView(this);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
+ setCallingPlugin(true);
+ NPBool value = privateBrowsingEnabled;
+ setValue(m_instance, NPNVprivateModeBool, &value);
+ setCallingPlugin(false);
+ PluginView::setCurrentPluginView(0);
+}
} // namespace WebCore
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index 3f0b49d..d769581 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -29,7 +29,6 @@
#ifndef PluginView_h
#define PluginView_h
-#include "CString.h"
#include "FrameLoadRequest.h"
#include "HaltablePlugin.h"
#include "IntRect.h"
@@ -45,6 +44,7 @@
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
+#include <wtf/text/CString.h>
// ANDROID
// TODO: Upstream to webkit.org
@@ -181,6 +181,8 @@ namespace WebCore {
void setJavaScriptPaused(bool);
+ void privateBrowsingStateChanged(bool);
+
void disconnectStream(PluginStream*);
void streamDidFinishLoading(PluginStream* stream) { disconnectStream(stream); }
@@ -241,7 +243,9 @@ namespace WebCore {
bool start();
+#if ENABLE(NETSCAPE_PLUGIN_API)
static void keepAlive(NPP);
+#endif
void keepAlive();
private:
@@ -271,6 +275,9 @@ namespace WebCore {
static BOOL WINAPI hookedEndPaint(HWND, const PAINTSTRUCT*);
#endif
+ static bool platformGetValueStatic(NPNVariable variable, void* value, NPError* result);
+ bool platformGetValue(NPNVariable variable, void* value, NPError* result);
+
RefPtr<Frame> m_parentFrame;
RefPtr<PluginPackage> m_plugin;
Element* m_element;
@@ -329,7 +336,7 @@ namespace WebCore {
String m_pluginsPage;
String m_mimeType;
- CString m_userAgent;
+ WTF::CString m_userAgent;
NPP m_instance;
NPP_t m_instanceStruct;
@@ -387,6 +394,7 @@ private:
void setNPWindowIfNeeded();
#elif defined(XP_MACOSX)
NP_CGContext m_npCgContext;
+ OwnPtr<Timer<PluginView> > m_nullEventTimer;
NPDrawingModel m_drawingModel;
NPEventModel m_eventModel;
CGContextRef m_contextRef;
@@ -395,8 +403,11 @@ private:
QPixmap m_pixmap;
#endif
+ Point m_lastMousePos;
void setNPWindowIfNeeded();
+ void nullEventTimerFired(Timer<PluginView>*);
Point globalMousePosForPlugin() const;
+ Point mousePosForPlugin(MouseEvent* event = 0) const;
#endif
#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/WebCore/plugins/PluginViewNone.cpp b/WebCore/plugins/PluginViewNone.cpp
index 2821afc..bb27357 100644
--- a/WebCore/plugins/PluginViewNone.cpp
+++ b/WebCore/plugins/PluginViewNone.cpp
@@ -67,15 +67,15 @@ NPError PluginView::handlePostReadFile(Vector<char>&, uint32, const char*)
return 0;
}
-NPError PluginView::getValue(NPNVariable, void*)
+bool PluginView::platformGetValue(NPNVariable, void*, NPError*)
{
- return 0;
+ return false;
}
#if ENABLE(NETSCAPE_PLUGIN_API)
-NPError PluginView::getValueStatic(NPNVariable, void*)
+bool PluginView::platformGetValueStatic(NPNVariable, void*, NPError*)
{
- return 0;
+ return false;
}
#endif
@@ -120,8 +120,28 @@ void PluginView::restart()
{
}
+#if ENABLE(NETSCAPE_PLUGIN_API)
void PluginView::keepAlive(NPP)
{
}
+#endif
+
+void PluginView::privateBrowsingStateChanged(bool)
+{
+}
+
+void PluginView::setJavaScriptPaused(bool)
+{
+}
+
+#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
+void PluginView::handleFocusInEvent()
+{
+}
+
+void PluginView::handleFocusOutEvent()
+{
+}
+#endif
} // namespace WebCore
diff --git a/WebCore/plugins/gtk/PluginPackageGtk.cpp b/WebCore/plugins/gtk/PluginPackageGtk.cpp
index 271a4a8..d975666 100644
--- a/WebCore/plugins/gtk/PluginPackageGtk.cpp
+++ b/WebCore/plugins/gtk/PluginPackageGtk.cpp
@@ -32,12 +32,12 @@
#include <gio/gio.h>
#include <stdio.h>
-#include "CString.h"
#include "GOwnPtr.h"
#include "MIMETypeRegistry.h"
#include "NotImplemented.h"
#include "npruntime_impl.h"
#include "PluginDebug.h"
+#include <wtf/text/CString.h>
namespace WebCore {
@@ -69,6 +69,9 @@ bool PluginPackage::fetchInfo()
}
const gchar* types = NP_GetMIMEDescription();
+ if (!types)
+ return true;
+
gchar** mimeDescs = g_strsplit(types, ";", -1);
for (int i = 0; mimeDescs[i] && mimeDescs[i][0]; i++) {
gchar** mimeData = g_strsplit(mimeDescs[i], ":", 3);
@@ -116,6 +119,14 @@ bool PluginPackage::load()
finalPath.set(g_file_get_path(resolvedFile.get()));
}
+ // No joke. If there is a netscape component in the path, go back
+ // to the symlink, as flash breaks otherwise.
+ // See http://src.chromium.org/viewvc/chrome/trunk/src/webkit/glue/plugins/plugin_list_posix.cc
+ GOwnPtr<gchar> baseName(g_path_get_basename(finalPath.get()));
+ if (!g_strcmp0(baseName.get(), "libflashplayer.so")
+ && g_strstr_len(finalPath.get(), -1, "/netscape/"))
+ finalPath.set(g_strdup(m_path.utf8().data()));
+
m_module = g_module_open(finalPath.get(), G_MODULE_BIND_LOCAL);
if (!m_module) {
diff --git a/WebCore/plugins/gtk/PluginViewGtk.cpp b/WebCore/plugins/gtk/PluginViewGtk.cpp
index 222584c..8de63e0 100644
--- a/WebCore/plugins/gtk/PluginViewGtk.cpp
+++ b/WebCore/plugins/gtk/PluginViewGtk.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2008 Collabora Ltd. All rights reserved.
* Copyright (C) 2009, 2010 Kakai, Inc. <brian@kakai.com>
+ * Copyright (C) 2010 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -129,31 +130,22 @@ void PluginView::updatePluginWidget()
m_clipRect = windowClipRect();
m_clipRect.move(-m_windowRect.x(), -m_windowRect.y());
- if (platformPluginWidget() && (m_windowRect != oldWindowRect || m_clipRect != oldClipRect))
- setNPWindowIfNeeded();
+ if (m_windowRect == oldWindowRect && m_clipRect == oldClipRect)
+ return;
#if defined(XP_UNIX)
- if (!m_isWindowed && m_windowRect.size() != oldWindowRect.size()) {
+ if (!m_isWindowed) {
if (m_drawable)
XFreePixmap(GDK_DISPLAY(), m_drawable);
-
+
m_drawable = XCreatePixmap(GDK_DISPLAY(), getRootWindow(m_parentFrame.get()),
m_windowRect.width(), m_windowRect.height(),
((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth);
XSync(GDK_DISPLAY(), False); // make sure that the server knows about the Drawable
}
-
- // do not call setNPWindowIfNeeded() immediately, will be called on paint()
- m_hasPendingGeometryChange = true;
#endif
- // In order to move/resize the plugin window at the same time as the
- // rest of frame during e.g. scrolling, we set the window geometry
- // in the paint() function, but as paint() isn't called when the
- // plugin window is outside the frame which can be caused by a
- // scroll, we need to move/resize immediately.
- if (!m_windowRect.intersects(frameView->frameRect()))
- setNPWindowIfNeeded();
+ setNPWindowIfNeeded();
}
void PluginView::setFocus()
@@ -507,12 +499,6 @@ void PluginView::setNPWindowIfNeeded()
if (m_isWindowed && !platformPluginWidget())
return;
-#if defined(XP_UNIX)
- if (!m_hasPendingGeometryChange)
- return;
- m_hasPendingGeometryChange = false;
-#endif
-
if (m_isWindowed) {
m_npWindow.x = m_windowRect.x();
m_npWindow.y = m_windowRect.y();
@@ -601,10 +587,8 @@ NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const c
return NPERR_NO_ERROR;
}
-NPError PluginView::getValueStatic(NPNVariable variable, void* value)
+bool PluginView::platformGetValueStatic(NPNVariable variable, void* value, NPError* result)
{
- LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
-
switch (variable) {
case NPNVToolkit:
#if defined(XP_UNIX)
@@ -612,7 +596,8 @@ NPError PluginView::getValueStatic(NPNVariable variable, void* value)
#else
*static_cast<uint32*>(value) = 0;
#endif
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
case NPNVSupportsXEmbedBool:
#if defined(XP_UNIX)
@@ -620,11 +605,13 @@ NPError PluginView::getValueStatic(NPNVariable variable, void* value)
#else
*static_cast<NPBool*>(value) = false;
#endif
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
case NPNVjavascriptEnabledBool:
*static_cast<NPBool*>(value) = true;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
case NPNVSupportsWindowless:
#if defined(XP_UNIX)
@@ -632,17 +619,16 @@ NPError PluginView::getValueStatic(NPNVariable variable, void* value)
#else
*static_cast<NPBool*>(value) = false;
#endif
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
default:
- return NPERR_GENERIC_ERROR;
+ return false;
}
}
-NPError PluginView::getValue(NPNVariable variable, void* value)
+bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* result)
{
- LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
-
switch (variable) {
case NPNVxDisplay:
#if defined(XP_UNIX)
@@ -650,56 +636,21 @@ NPError PluginView::getValue(NPNVariable variable, void* value)
*(void **)value = (void *)GDK_DISPLAY();
else
*(void **)value = (void *)GTK_XTBIN(platformPluginWidget())->xtclient.xtdisplay;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
#else
- return NPERR_GENERIC_ERROR;
+ *result = NPERR_GENERIC_ERROR;
#endif
+ return true;
#if defined(XP_UNIX)
case NPNVxtAppContext:
if (!m_needsXEmbed) {
*(void **)value = XtDisplayToApplicationContext (GTK_XTBIN(platformPluginWidget())->xtclient.xtdisplay);
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
} else
- return NPERR_GENERIC_ERROR;
-#endif
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- case NPNVWindowNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* windowScriptObject = m_parentFrame->script()->windowScriptNPObject();
-
- // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (windowScriptObject)
- _NPN_RetainObject(windowScriptObject);
-
- void** v = (void**)value;
- *v = windowScriptObject;
-
- return NPERR_NO_ERROR;
- }
-
- case NPNVPluginElementNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* pluginScriptObject = 0;
-
- if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
- pluginScriptObject = static_cast<HTMLPlugInElement*>(m_element)->getNPObject();
-
- // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (pluginScriptObject)
- _NPN_RetainObject(pluginScriptObject);
-
- void** v = (void**)value;
- *v = pluginScriptObject;
-
- return NPERR_NO_ERROR;
- }
+ *result = NPERR_GENERIC_ERROR;
+ return true;
#endif
case NPNVnetscapeWindow: {
@@ -711,11 +662,12 @@ NPError PluginView::getValue(NPNVariable variable, void* value)
HGDIOBJ* w = reinterpret_cast<HGDIOBJ*>(value);
*w = GDK_WINDOW_HWND(m_parentFrame->view()->hostWindow()->platformPageClient()->window);
#endif
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
}
- default:
- return getValueStatic(variable, value);
+ default:
+ return false;
}
}
@@ -768,12 +720,6 @@ static Display* getPluginDisplay()
#endif
}
-static gboolean
-plug_removed_cb(GtkSocket* socket, gpointer)
-{
- return TRUE;
-}
-
#if defined(XP_UNIX)
static void getVisualAndColormap(int depth, Visual** visual, Colormap* colormap)
{
@@ -812,6 +758,27 @@ static void getVisualAndColormap(int depth, Visual** visual, Colormap* colormap)
}
#endif
+static gboolean plugRemovedCallback(GtkSocket* socket, gpointer)
+{
+ return TRUE;
+}
+
+static void plugAddedCallback(GtkSocket* socket, PluginView* view)
+{
+ if (!socket || !view)
+ return;
+
+ // FIXME: Java Plugins do not seem to draw themselves properly the
+ // first time unless we do a size-allocate after they have done
+ // the plug operation on their side, which in general does not
+ // happen since we do size-allocates before setting the
+ // NPWindow. Apply this workaround until we figure out a better
+ // solution, if any.
+ IntRect rect = view->frameRect();
+ GtkAllocation allocation = { rect.x(), rect.y(), rect.width(), rect.height() };
+ gtk_widget_size_allocate(GTK_WIDGET(socket), &allocation);
+}
+
bool PluginView::platformStart()
{
ASSERT(m_isStarted);
@@ -828,15 +795,25 @@ bool PluginView::platformStart()
if (m_isWindowed) {
#if defined(XP_UNIX)
+ GtkWidget* pageClient = m_parentFrame->view()->hostWindow()->platformPageClient();
+
if (m_needsXEmbed) {
+ // If our parent is not anchored the startup process will
+ // fail miserably for XEmbed plugins a bit later on when
+ // we try to get the ID of our window (since realize will
+ // fail), so let's just abort here.
+ if (!gtk_widget_get_parent(pageClient))
+ return false;
+
setPlatformWidget(gtk_socket_new());
- gtk_container_add(GTK_CONTAINER(m_parentFrame->view()->hostWindow()->platformPageClient()), platformPluginWidget());
- g_signal_connect(platformPluginWidget(), "plug_removed", G_CALLBACK(plug_removed_cb), NULL);
+ gtk_container_add(GTK_CONTAINER(pageClient), platformPluginWidget());
+ g_signal_connect(platformPluginWidget(), "plug-added", G_CALLBACK(plugAddedCallback), this);
+ g_signal_connect(platformPluginWidget(), "plug-removed", G_CALLBACK(plugRemovedCallback), NULL);
} else
- setPlatformWidget(gtk_xtbin_new(m_parentFrame->view()->hostWindow()->platformPageClient()->window, 0));
+ setPlatformWidget(gtk_xtbin_new(pageClient->window, 0));
#else
setPlatformWidget(gtk_socket_new());
- gtk_container_add(GTK_CONTAINER(m_parentFrame->view()->hostWindow()->platformPageClient()), platformPluginWidget());
+ gtk_container_add(GTK_CONTAINER(pageClient), platformPluginWidget());
#endif
} else {
setPlatformWidget(0);
@@ -909,10 +886,8 @@ bool PluginView::platformStart()
#endif
// TODO remove in favor of null events, like mac port?
- if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) {
+ if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall)))
updatePluginWidget(); // was: setNPWindowIfNeeded(), but this doesn't produce 0x0 rects at first go
- setNPWindowIfNeeded();
- }
return true;
}
diff --git a/WebCore/plugins/gtk/gtk2xtbin.c b/WebCore/plugins/gtk/gtk2xtbin.c
index 68c5373..fad66fe 100644
--- a/WebCore/plugins/gtk/gtk2xtbin.c
+++ b/WebCore/plugins/gtk/gtk2xtbin.c
@@ -42,6 +42,7 @@
* inside a GTK application.
*/
+#include "GtkVersioning.h"
#include "xembed.h"
#include "gtk2xtbin.h"
#include <gtk/gtk.h>
@@ -401,7 +402,7 @@ gtk_xtbin_set_position (GtkXtBin *xtbin,
xtbin->x = x;
xtbin->y = y;
- if (GTK_WIDGET_REALIZED (xtbin))
+ if (gtk_widget_get_realized (xtbin))
gdk_window_move (GTK_WIDGET (xtbin)->window, x, y);
}
@@ -456,7 +457,7 @@ gtk_xtbin_unrealize (GtkWidget *object)
widget = GTK_WIDGET(object);
GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
- if (GTK_WIDGET_REALIZED (widget)) {
+ if (gtk_widget_get_realized (widget)) {
xt_client_unrealize(&(xtbin->xtclient));
}
diff --git a/WebCore/plugins/mac/PluginPackageMac.cpp b/WebCore/plugins/mac/PluginPackageMac.cpp
index be69242..9a297de 100644
--- a/WebCore/plugins/mac/PluginPackageMac.cpp
+++ b/WebCore/plugins/mac/PluginPackageMac.cpp
@@ -25,18 +25,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __LP64__
-
#include "config.h"
#include "PluginPackage.h"
#include <wtf/RetainPtr.h>
-#include "CString.h"
#include "MIMETypeRegistry.h"
#include "npruntime_impl.h"
#include "PluginDatabase.h"
#include "PluginDebug.h"
#include "WebCoreNSStringExtras.h"
+#include <wtf/text/CString.h>
#include <CoreFoundation/CoreFoundation.h>
@@ -307,9 +305,3 @@ uint16 PluginPackage::NPVersion() const
return NP_VERSION_MINOR;
}
} // namespace WebCore
-
-#else
-
-#include "../PluginPackageNone.cpp"
-
-#endif // !__LP64__
diff --git a/WebCore/plugins/mac/PluginViewMac.cpp b/WebCore/plugins/mac/PluginViewMac.cpp
index d415d8f..1fd4676 100644
--- a/WebCore/plugins/mac/PluginViewMac.cpp
+++ b/WebCore/plugins/mac/PluginViewMac.cpp
@@ -26,8 +26,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __LP64__
-
#include "config.h"
#include "PluginView.h"
@@ -80,11 +78,7 @@ using JSC::UString;
#include <QPainter>
#include "QWebPageClient.h"
QT_BEGIN_NAMESPACE
-#if QT_VERSION < 0x040500
-extern Q_GUI_EXPORT WindowPtr qt_mac_window_for(const QWidget* w);
-#else
extern Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget* w);
-#endif
QT_END_NAMESPACE
#endif
@@ -101,7 +95,9 @@ namespace WebCore {
using namespace HTMLNames;
+#ifndef NP_NO_CARBON
static int modifiersForEvent(UIEventWithKeyState *event);
+#endif
static inline WindowRef nativeWindowFor(PlatformWidget widget)
{
@@ -177,22 +173,31 @@ bool PluginView::platformStart()
// Gracefully handle unsupported drawing or event models. We can do this
// now since the drawing and event model can only be set during NPP_New.
- NPBool eventModelSupported, drawingModelSupported;
+#ifndef NP_NO_CARBON
+ NPBool eventModelSupported;
if (getValueStatic(NPNVariable(NPNVsupportsCarbonBool + m_eventModel), &eventModelSupported) != NPERR_NO_ERROR
|| !eventModelSupported) {
+#endif
m_status = PluginStatusCanNotLoadPlugin;
LOG(Plugins, "Plug-in '%s' uses unsupported event model %s",
m_plugin->name().utf8().data(), prettyNameForEventModel(m_eventModel));
return false;
+#ifndef NP_NO_CARBON
}
+#endif
+#ifndef NP_NO_QUICKDRAW
+ NPBool drawingModelSupported;
if (getValueStatic(NPNVariable(NPNVsupportsQuickDrawBool + m_drawingModel), &drawingModelSupported) != NPERR_NO_ERROR
|| !drawingModelSupported) {
+#endif
m_status = PluginStatusCanNotLoadPlugin;
LOG(Plugins, "Plug-in '%s' uses unsupported drawing model %s",
m_plugin->name().utf8().data(), prettyNameForDrawingModel(m_drawingModel));
return false;
+#ifndef NP_NO_QUICKDRAW
}
+#endif
#if PLATFORM(QT)
// Set the platformPluginWidget only in the case of QWebView so that the context menu appears in the right place.
@@ -209,16 +214,24 @@ bool PluginView::platformStart()
// Create a fake window relative to which all events will be sent when using offscreen rendering
if (!platformPluginWidget()) {
+#ifndef NP_NO_CARBON
// Make the default size really big. It is unclear why this is required but with a smaller size, mouse move
// events don't get processed. Resizing the fake window to flash's size doesn't help.
::Rect windowBounds = { 0, 0, 1000, 1000 };
CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes, &windowBounds, &m_fakeWindow);
// Flash requires the window to be hilited to process mouse move events.
- HiliteWindow(m_fakeWindow, true);
+ HiliteWindow(m_fakeWindow, true);
+#endif
}
show();
+ // TODO: Implement null timer throttling depending on plugin activation
+ m_nullEventTimer.set(new Timer<PluginView>(this, &PluginView::nullEventTimerFired));
+ m_nullEventTimer->startRepeating(0.02);
+
+ m_lastMousePos.h = m_lastMousePos.v = 0;
+
return true;
}
@@ -228,40 +241,45 @@ void PluginView::platformDestroy()
setPlatformPluginWidget(0);
else {
CGContextRelease(m_contextRef);
+#ifndef NP_NO_CARBON
if (m_fakeWindow)
DisposeWindow(m_fakeWindow);
+#endif
}
}
// Used before the plugin view has been initialized properly, and as a
// fallback for variables that do not require a view to resolve.
-NPError PluginView::getValueStatic(NPNVariable variable, void* value)
+bool PluginView::platformGetValueStatic(NPNVariable variable, void* value, NPError* result)
{
- LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
-
switch (variable) {
case NPNVToolkit:
*static_cast<uint32*>(value) = 0;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
case NPNVjavascriptEnabledBool:
*static_cast<NPBool*>(value) = true;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
#ifndef NP_NO_CARBON
case NPNVsupportsCarbonBool:
*static_cast<NPBool*>(value) = true;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
#endif
case NPNVsupportsCocoaBool:
*static_cast<NPBool*>(value) = false;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
// CoreGraphics is the only drawing model we support
case NPNVsupportsCoreGraphicsBool:
*static_cast<NPBool*>(value) = true;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
#ifndef NP_NO_QUICKDRAW
// QuickDraw is deprecated in 10.5 and not supported on 64-bit
@@ -270,61 +288,20 @@ NPError PluginView::getValueStatic(NPNVariable variable, void* value)
case NPNVsupportsOpenGLBool:
case NPNVsupportsCoreAnimationBool:
*static_cast<NPBool*>(value) = false;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
default:
- return NPERR_GENERIC_ERROR;
+ return false;
}
}
// Used only for variables that need a view to resolve
-NPError PluginView::getValue(NPNVariable variable, void* value)
+bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* error)
{
- LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
-
- switch (variable) {
- case NPNVWindowNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* windowScriptObject = m_parentFrame->script()->windowScriptNPObject();
-
- // Return value is expected to be retained, as described in
- // <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (windowScriptObject)
- _NPN_RetainObject(windowScriptObject);
-
- void** v = (void**)value;
- *v = windowScriptObject;
-
- return NPERR_NO_ERROR;
- }
-
- case NPNVPluginElementNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* pluginScriptObject = 0;
-
- if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
- pluginScriptObject = static_cast<HTMLPlugInElement*>(m_element)->getNPObject();
-
- // Return value is expected to be retained, as described in
- // <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (pluginScriptObject)
- _NPN_RetainObject(pluginScriptObject);
-
- void** v = (void**)value;
- *v = pluginScriptObject;
-
- return NPERR_NO_ERROR;
- }
-
- default:
- return getValueStatic(variable, value);
- }
-
+ return false;
}
+
void PluginView::setParent(ScrollView* parent)
{
LOG(Plugins, "PluginView::setParent(%p)", parent);
@@ -370,6 +347,7 @@ void PluginView::setFocus()
// TODO: Also handle and pass on blur events (focus lost)
+#ifndef NP_NO_CARBON
EventRecord record;
record.what = getFocusEvent;
record.message = 0;
@@ -379,6 +357,7 @@ void PluginView::setFocus()
if (!dispatchNPEvent(record))
LOG(Events, "PluginView::setFocus(): Get-focus event not accepted");
+#endif
}
void PluginView::setParentVisible(bool visible)
@@ -415,7 +394,9 @@ void PluginView::setNPWindowIfNeeded()
return;
m_npWindow.window = (void*)&m_npCgContext;
+#ifndef NP_NO_CARBON
m_npCgContext.window = newWindowRef;
+#endif
m_npCgContext.context = newContextRef;
m_npWindow.x = m_windowRect.x();
@@ -430,7 +411,7 @@ void PluginView::setNPWindowIfNeeded()
m_npWindow.clipRect.bottom = m_windowRect.y() + m_windowRect.height();
LOG(Plugins, "PluginView::setNPWindowIfNeeded(): window=%p, context=%p,"
- " window.x:%ld window.y:%ld window.width:%d window.height:%d window.clipRect size:%dx%d",
+ " window.x:%d window.y:%d window.width:%d window.height:%d window.clipRect size:%dx%d",
newWindowRef, newContextRef, m_npWindow.x, m_npWindow.y, m_npWindow.width, m_npWindow.height,
m_npWindow.clipRect.right - m_npWindow.clipRect.left, m_npWindow.clipRect.bottom - m_npWindow.clipRect.top);
@@ -463,7 +444,7 @@ void PluginView::updatePluginWidget()
#if PLATFORM(QT)
m_pixmap = QPixmap(m_windowRect.size());
m_pixmap.fill(Qt::transparent);
- m_contextRef = qt_mac_cg_context(&m_pixmap);
+ m_contextRef = m_pixmap.isNull() ? 0 : qt_mac_cg_context(&m_pixmap);
#endif
}
}
@@ -516,6 +497,7 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
#endif
}
+#ifndef NP_NO_CARBON
EventRecord event;
event.what = updateEvt;
event.message = (long unsigned int)m_npCgContext.window;
@@ -526,6 +508,7 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
if (!dispatchNPEvent(event))
LOG(Events, "PluginView::paint(): Paint event not accepted");
+#endif
CGContextRestoreGState(cgContext);
@@ -575,10 +558,13 @@ void PluginView::handleMouseEvent(MouseEvent* event)
if (!m_isStarted)
return;
+#ifndef NP_NO_CARBON
EventRecord record;
if (event->type() == eventNames().mousemoveEvent) {
- record.what = nullEvent;
+ // Mouse movement is handled by null timer events
+ m_lastMousePos = mousePosForPlugin(event);
+ return;
} else if (event->type() == eventNames().mouseoverEvent) {
record.what = adjustCursorEvent;
} else if (event->type() == eventNames().mouseoutEvent) {
@@ -594,21 +580,7 @@ void PluginView::handleMouseEvent(MouseEvent* event)
} else {
return;
}
-
- if (platformPluginWidget()) {
- record.where = globalMousePosForPlugin();
- } else {
- if (event->button() == 2) {
- // always pass the global position for right-click since Flash uses it to position the context menu
- record.where = globalMousePosForPlugin();
- } else {
- IntPoint postZoomPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(event->absoluteLocation()));
- record.where.h = postZoomPos.x() + m_windowRect.x();
- // The number 22 is the height of the title bar. As to why it figures in the calculation below
- // is left as an exercise to the reader :-)
- record.where.v = postZoomPos.y() + m_windowRect.y() - 22;
- }
- }
+ record.where = mousePosForPlugin(event);
record.modifiers = modifiersForEvent(event);
if (!event->buttonDown())
@@ -626,6 +598,7 @@ void PluginView::handleMouseEvent(MouseEvent* event)
} else {
event->setDefaultHandled();
}
+#endif
}
void PluginView::handleKeyboardEvent(KeyboardEvent* event)
@@ -638,6 +611,7 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event)
LOG(Plugins, "PV::hKE(): KE.keyCode: 0x%02X, KE.charCode: %d",
event->keyCode(), event->charCode());
+#ifndef NP_NO_CARBON
EventRecord record;
if (event->type() == eventNames().keydownEvent) {
@@ -698,8 +672,28 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event)
LOG(Events, "PluginView::handleKeyboardEvent(): Keyboard event type %d not accepted", record.what);
else
event->setDefaultHandled();
+#endif
}
+#ifndef NP_NO_CARBON
+void PluginView::nullEventTimerFired(Timer<PluginView>*)
+{
+ EventRecord record;
+
+ record.what = nullEvent;
+ record.message = 0;
+ record.when = TickCount();
+ record.where = m_lastMousePos;
+ record.modifiers = GetCurrentKeyModifiers();
+ if (!Button())
+ record.modifiers |= btnState;
+
+ if (!dispatchNPEvent(record))
+ LOG(Events, "PluginView::nullEventTimerFired(): Null event not accepted");
+}
+#endif
+
+#ifndef NP_NO_CARBON
static int modifiersForEvent(UIEventWithKeyState* event)
{
int modifiers = 0;
@@ -718,7 +712,9 @@ static int modifiersForEvent(UIEventWithKeyState* event)
return modifiers;
}
+#endif
+#ifndef NP_NO_CARBON
static bool tigerOrBetter()
{
static SInt32 systemVersion = 0;
@@ -730,7 +726,9 @@ static bool tigerOrBetter()
return systemVersion >= 0x1040;
}
+#endif
+#ifndef NP_NO_CARBON
Point PluginView::globalMousePosForPlugin() const
{
Point pos;
@@ -755,7 +753,31 @@ Point PluginView::globalMousePosForPlugin() const
return pos;
}
+#endif
+
+#ifndef NP_NO_CARBON
+Point PluginView::mousePosForPlugin(MouseEvent* event) const
+{
+ ASSERT(event);
+ if (platformPluginWidget())
+ return globalMousePosForPlugin();
+
+ if (event->button() == 2) {
+ // always pass the global position for right-click since Flash uses it to position the context menu
+ return globalMousePosForPlugin();
+ }
+ Point pos;
+ IntPoint postZoomPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(event->absoluteLocation()));
+ pos.h = postZoomPos.x() + m_windowRect.x();
+ // The number 22 is the height of the title bar. As to why it figures in the calculation below
+ // is left as an exercise to the reader :-)
+ pos.v = postZoomPos.y() + m_windowRect.y() - 22;
+ return pos;
+}
+#endif
+
+#ifndef NP_NO_CARBON
bool PluginView::dispatchNPEvent(NPEvent& event)
{
PluginView::setCurrentPluginView(this);
@@ -768,6 +790,7 @@ bool PluginView::dispatchNPEvent(NPEvent& event)
PluginView::setCurrentPluginView(0);
return accepted;
}
+#endif
// ------------------- Miscellaneous ------------------
@@ -805,9 +828,3 @@ void PluginView::restart()
}
} // namespace WebCore
-
-#else
-
-#include "../PluginViewNone.cpp"
-
-#endif // !__LP64__
diff --git a/WebCore/plugins/qt/PluginPackageQt.cpp b/WebCore/plugins/qt/PluginPackageQt.cpp
index 74deaf6..018c64f 100644
--- a/WebCore/plugins/qt/PluginPackageQt.cpp
+++ b/WebCore/plugins/qt/PluginPackageQt.cpp
@@ -27,11 +27,11 @@
#include "config.h"
#include "PluginPackage.h"
-#include "CString.h"
#include "MIMETypeRegistry.h"
#include "npruntime_impl.h"
#include "PluginDatabase.h"
#include "PluginDebug.h"
+#include <wtf/text/CString.h>
namespace WebCore {
diff --git a/WebCore/plugins/qt/PluginViewQt.cpp b/WebCore/plugins/qt/PluginViewQt.cpp
index 49c0000..fb88b87 100644
--- a/WebCore/plugins/qt/PluginViewQt.cpp
+++ b/WebCore/plugins/qt/PluginViewQt.cpp
@@ -553,96 +553,64 @@ NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const c
return NPERR_NO_ERROR;
}
-NPError PluginView::getValueStatic(NPNVariable variable, void* value)
+bool PluginView::platformGetValueStatic(NPNVariable variable, void* value, NPError* result)
{
- LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
-
switch (variable) {
case NPNVToolkit:
*static_cast<uint32*>(value) = 0;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
case NPNVSupportsXEmbedBool:
*static_cast<NPBool*>(value) = true;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
case NPNVjavascriptEnabledBool:
*static_cast<NPBool*>(value) = true;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
case NPNVSupportsWindowless:
*static_cast<NPBool*>(value) = true;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
default:
- return NPERR_GENERIC_ERROR;
+ return false;
}
}
-NPError PluginView::getValue(NPNVariable variable, void* value)
+bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* result)
{
- LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
-
switch (variable) {
case NPNVxDisplay:
*(void **)value = QX11Info::display();
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
case NPNVxtAppContext:
- return NPERR_GENERIC_ERROR;
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
- case NPNVWindowNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* windowScriptObject = m_parentFrame->script()->windowScriptNPObject();
-
- // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (windowScriptObject)
- _NPN_RetainObject(windowScriptObject);
-
- void** v = (void**)value;
- *v = windowScriptObject;
-
- return NPERR_NO_ERROR;
- }
-
- case NPNVPluginElementNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* pluginScriptObject = 0;
-
- if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
- pluginScriptObject = static_cast<HTMLPlugInElement*>(m_element)->getNPObject();
-
- // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (pluginScriptObject)
- _NPN_RetainObject(pluginScriptObject);
-
- void** v = (void**)value;
- *v = pluginScriptObject;
-
- return NPERR_NO_ERROR;
- }
-#endif
+ *result = NPERR_GENERIC_ERROR;
+ return true;
case NPNVnetscapeWindow: {
void* w = reinterpret_cast<void*>(value);
QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
*((XID *)w) = client ? client->ownerWidget()->window()->winId() : 0;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
}
case NPNVToolkit:
if (m_plugin->quirks().contains(PluginQuirkRequiresGtkToolKit)) {
*((uint32 *)value) = 2;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
}
- // fall through
+ return false;
+
default:
- return getValueStatic(variable, value);
+ return false;
}
}
diff --git a/WebCore/plugins/symbian/PluginContainerSymbian.cpp b/WebCore/plugins/symbian/PluginContainerSymbian.cpp
index aece0e4..b839870 100644
--- a/WebCore/plugins/symbian/PluginContainerSymbian.cpp
+++ b/WebCore/plugins/symbian/PluginContainerSymbian.cpp
@@ -32,12 +32,12 @@
using namespace WebCore;
-PluginContainerSymbian::PluginContainerSymbian(PluginView* view, QWidget* parent)
- : m_parent(parent)
+PluginContainerSymbian::PluginContainerSymbian(PluginView* view, QWidget* parent, QGraphicsProxyWidget* proxy)
+ : QWidget(parent)
, m_pluginView(view)
+ , m_proxy(proxy)
, m_hasPendingGeometryChange(false)
{
- setParent(m_parent);
}
PluginContainerSymbian::~PluginContainerSymbian()
@@ -62,7 +62,7 @@ void PluginContainerSymbian::adjustGeometry()
}
}
-void PluginContainerSymbian::focusInEvent(QFocusEvent* event)
+void PluginContainerSymbian::focusInEvent(QFocusEvent*)
{
if (Page* page = m_pluginView->parentFrame()->page())
page->focusController()->setActive(true);
diff --git a/WebCore/plugins/symbian/PluginContainerSymbian.h b/WebCore/plugins/symbian/PluginContainerSymbian.h
index fce4a71..fead872 100644
--- a/WebCore/plugins/symbian/PluginContainerSymbian.h
+++ b/WebCore/plugins/symbian/PluginContainerSymbian.h
@@ -22,6 +22,8 @@
#include <QWidget>
+class QGraphicsProxyWidget;
+
namespace WebCore {
class PluginView;
@@ -29,18 +31,19 @@ namespace WebCore {
class PluginContainerSymbian : public QWidget {
Q_OBJECT
public:
- PluginContainerSymbian(PluginView*, QWidget* parent);
+ PluginContainerSymbian(PluginView*, QWidget* parent, QGraphicsProxyWidget* proxy = 0);
~PluginContainerSymbian();
void requestGeometry(const QRect&, const QRegion& clip = QRegion());
void adjustGeometry();
+ QGraphicsProxyWidget* proxy() { return m_proxy; }
protected:
virtual void focusInEvent(QFocusEvent*);
virtual void focusOutEvent(QFocusEvent*);
private:
PluginView* m_pluginView;
- QWidget* m_parent;
+ QGraphicsProxyWidget* m_proxy;
QRect m_windowRect;
QRegion m_clipRegion;
bool m_hasPendingGeometryChange;
diff --git a/WebCore/plugins/symbian/PluginPackageSymbian.cpp b/WebCore/plugins/symbian/PluginPackageSymbian.cpp
index 44f8152..d30f80e 100644
--- a/WebCore/plugins/symbian/PluginPackageSymbian.cpp
+++ b/WebCore/plugins/symbian/PluginPackageSymbian.cpp
@@ -19,13 +19,13 @@
#include "config.h"
#include "PluginPackage.h"
-#include "CString.h"
#include "MIMETypeRegistry.h"
#include "npinterface.h"
#include "npruntime_impl.h"
#include "PluginDatabase.h"
#include "PluginDebug.h"
#include <QPluginLoader>
+#include <wtf/text/CString.h>
namespace WebCore {
diff --git a/WebCore/plugins/symbian/PluginViewSymbian.cpp b/WebCore/plugins/symbian/PluginViewSymbian.cpp
index 3492868..bae3b7f 100644
--- a/WebCore/plugins/symbian/PluginViewSymbian.cpp
+++ b/WebCore/plugins/symbian/PluginViewSymbian.cpp
@@ -52,7 +52,9 @@
#include "npfunctions.h"
#include "npinterface.h"
#include "npruntime_impl.h"
+#include "qgraphicswebview.h"
#include "runtime_root.h"
+#include <QGraphicsProxyWidget>
#include <QKeyEvent>
#include <QPixmap>
#include <QRegion>
@@ -85,6 +87,7 @@ void PluginView::updatePluginWidget()
IntRect oldClipRect = m_clipRect;
m_windowRect = IntRect(frameView->contentsToWindow(frameRect().location()), frameRect().size());
+
m_clipRect = windowClipRect();
m_clipRect.move(-m_windowRect.x(), -m_windowRect.y());
if (m_windowRect == oldWindowRect && m_clipRect == oldClipRect)
@@ -307,66 +310,27 @@ NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const c
return NPERR_NO_ERROR;
}
-NPError PluginView::getValueStatic(NPNVariable variable, void* value)
+bool PluginView::platformGetValueStatic(NPNVariable variable, void* value, NPError* result)
{
- LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
-
switch (variable) {
case NPNVjavascriptEnabledBool:
*static_cast<NPBool*>(value) = true;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
case NPNVSupportsWindowless:
*static_cast<NPBool*>(value) = true;
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
default:
- return NPERR_GENERIC_ERROR;
+ return false;
}
}
-NPError PluginView::getValue(NPNVariable variable, void* value)
+bool PluginView::platformGetValue(NPNVariable, void*, NPError*)
{
- LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
-
- switch (variable) {
- case NPNVWindowNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* windowScriptObject = m_parentFrame->script()->windowScriptNPObject();
-
- // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (windowScriptObject)
- _NPN_RetainObject(windowScriptObject);
-
- void** v = (void**)value;
- *v = windowScriptObject;
-
- return NPERR_NO_ERROR;
- }
-
- case NPNVPluginElementNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* pluginScriptObject = 0;
-
- if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
- pluginScriptObject = static_cast<HTMLPlugInElement*>(m_element)->getNPObject();
-
- // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (pluginScriptObject)
- _NPN_RetainObject(pluginScriptObject);
-
- void** v = (void**)value;
- *v = pluginScriptObject;
-
- return NPERR_NO_ERROR;
- }
- default:
- return getValueStatic(variable, value);
- }
+ return false;
}
void PluginView::invalidateRect(const IntRect& rect)
@@ -426,12 +390,15 @@ bool PluginView::platformStart()
if (m_isWindowed) {
QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
- // FIXME this will not work for QGraphicsView.
- // But we cannot use winId because it will create a window and on S60,
- // QWidgets should not create a window.
- Q_ASSERT(qobject_cast<QWidget*>(client->pluginParent()));
- setPlatformWidget(new PluginContainerSymbian(this,
- qobject_cast<QWidget*>(client->pluginParent())));
+ QGraphicsProxyWidget* proxy = 0;
+ if (QGraphicsWebView *webView = qobject_cast<QGraphicsWebView*>(client->pluginParent()))
+ proxy = new QGraphicsProxyWidget(webView);
+
+ PluginContainerSymbian* container = new PluginContainerSymbian(this, proxy ? 0 : client->ownerWidget(), proxy);
+ setPlatformWidget(container);
+ if (proxy)
+ proxy->setWidget(container);
+
m_npWindow.type = NPWindowTypeWindow;
m_npWindow.window = (void*)platformPluginWidget();
@@ -447,7 +414,11 @@ bool PluginView::platformStart()
void PluginView::platformDestroy()
{
- delete platformPluginWidget();
+ QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
+ if (client && qobject_cast<QGraphicsWebView*>(client->pluginParent()))
+ delete static_cast<PluginContainerSymbian*>(platformPluginWidget())->proxy();
+ else
+ delete platformPluginWidget();
}
void PluginView::halt()
diff --git a/WebCore/plugins/win/PluginMessageThrottlerWin.cpp b/WebCore/plugins/win/PluginMessageThrottlerWin.cpp
index b79ca20..46fee62 100644
--- a/WebCore/plugins/win/PluginMessageThrottlerWin.cpp
+++ b/WebCore/plugins/win/PluginMessageThrottlerWin.cpp
@@ -29,16 +29,26 @@
#include "PluginView.h"
#include <wtf/ASCIICType.h>
+#include <wtf/CurrentTime.h>
using namespace WTF;
namespace WebCore {
-static const double MessageThrottleTimeInterval = 0.001;
+// Set a timer to make sure we process any queued messages at least every 16ms.
+// This value allows Flash 60 messages/second, which should be enough for video
+// playback, and also gets us over the limit for kicking into high-resolution
+// timer mode (see SharedTimerWin.cpp).
+static const double MessageThrottleTimeInterval = 0.016;
+
+// During a continuous stream of messages, process one every 5ms.
+static const double MessageDirectProcessingInterval = 0.005;
PluginMessageThrottlerWin::PluginMessageThrottlerWin(PluginView* pluginView)
- : m_back(0), m_front(0)
+ : m_back(0)
+ , m_front(0)
, m_pluginView(pluginView)
+ , m_lastMessageTime(0)
, m_messageThrottleTimer(this, &PluginMessageThrottlerWin::messageThrottleTimerFired)
{
// Initialize the free list with our inline messages
@@ -74,11 +84,21 @@ void PluginMessageThrottlerWin::appendMessage(HWND hWnd, UINT msg, WPARAM wParam
if (!m_front)
m_front = message;
+ // If it has been more than MessageDirectProcessingInterval between throttled messages,
+ // go ahead and process a message directly.
+ double currentTime = WTF::currentTime();
+ if (currentTime - m_lastMessageTime > MessageDirectProcessingInterval) {
+ processQueuedMessage();
+ m_lastMessageTime = currentTime;
+ if (!m_front)
+ return;
+ }
+
if (!m_messageThrottleTimer.isActive())
m_messageThrottleTimer.startOneShot(MessageThrottleTimeInterval);
}
-void PluginMessageThrottlerWin::messageThrottleTimerFired(Timer<PluginMessageThrottlerWin>*)
+void PluginMessageThrottlerWin::processQueuedMessage()
{
PluginMessage* message = m_front;
m_front = m_front->next;
@@ -91,6 +111,11 @@ void PluginMessageThrottlerWin::messageThrottleTimerFired(Timer<PluginMessageThr
::CallWindowProc(m_pluginView->pluginWndProc(), message->hWnd, message->msg, message->wParam, message->lParam);
freeMessage(message);
+}
+
+void PluginMessageThrottlerWin::messageThrottleTimerFired(Timer<PluginMessageThrottlerWin>*)
+{
+ processQueuedMessage();
if (m_front)
m_messageThrottleTimer.startOneShot(MessageThrottleTimeInterval);
diff --git a/WebCore/plugins/win/PluginMessageThrottlerWin.h b/WebCore/plugins/win/PluginMessageThrottlerWin.h
index c74beab..0a7be70 100644
--- a/WebCore/plugins/win/PluginMessageThrottlerWin.h
+++ b/WebCore/plugins/win/PluginMessageThrottlerWin.h
@@ -51,6 +51,7 @@ namespace WebCore {
void appendMessage(HWND, UINT msg, WPARAM, LPARAM);
private:
+ void processQueuedMessage();
void messageThrottleTimerFired(Timer<PluginMessageThrottlerWin>*);
PluginMessage* allocateMessage();
bool isInlineMessage(PluginMessage* message);
@@ -65,6 +66,7 @@ namespace WebCore {
PluginMessage* m_freeInlineMessages;
Timer<PluginMessageThrottlerWin> m_messageThrottleTimer;
+ double m_lastMessageTime;
};
} // namespace WebCore
diff --git a/WebCore/plugins/win/PluginPackageWin.cpp b/WebCore/plugins/win/PluginPackageWin.cpp
index 203fb60..e70c2c2 100644
--- a/WebCore/plugins/win/PluginPackageWin.cpp
+++ b/WebCore/plugins/win/PluginPackageWin.cpp
@@ -29,7 +29,6 @@
#include "config.h"
#include "PluginPackage.h"
-#include "CString.h"
#include "MIMETypeRegistry.h"
#include "PluginDatabase.h"
#include "PluginDebug.h"
@@ -37,6 +36,7 @@
#include "npruntime_impl.h"
#include <string.h>
#include <wtf/OwnArrayPtr.h>
+#include <wtf/text/CString.h>
#include <shlwapi.h>
namespace WebCore {
diff --git a/WebCore/plugins/win/PluginViewWin.cpp b/WebCore/plugins/win/PluginViewWin.cpp
index 04fda8e..01e425f 100644
--- a/WebCore/plugins/win/PluginViewWin.cpp
+++ b/WebCore/plugins/win/PluginViewWin.cpp
@@ -26,45 +26,41 @@
*/
#include "config.h"
-
#include "PluginView.h"
#include "BitmapImage.h"
-#if !PLATFORM(WX)
-#include "BitmapInfo.h"
-#endif
#include "Bridge.h"
#include "Document.h"
#include "DocumentLoader.h"
#include "Element.h"
#include "EventNames.h"
-#include "FrameLoader.h"
+#include "FocusController.h"
+#include "Frame.h"
#include "FrameLoadRequest.h"
+#include "FrameLoader.h"
#include "FrameTree.h"
-#include "Frame.h"
#include "FrameView.h"
#include "GraphicsContext.h"
-#include "HostWindow.h"
-#include "Image.h"
#include "HTMLNames.h"
#include "HTMLPlugInElement.h"
+#include "HostWindow.h"
+#include "Image.h"
+#include "JSDOMBinding.h"
#include "JSDOMWindow.h"
#include "KeyboardEvent.h"
#include "MIMETypeRegistry.h"
#include "MouseEvent.h"
#include "Page.h"
-#include "FocusController.h"
#include "PlatformMouseEvent.h"
+#include "PluginDatabase.h"
+#include "PluginDebug.h"
+#include "PluginMainThreadScheduler.h"
#include "PluginMessageThrottlerWin.h"
#include "PluginPackage.h"
-#include "PluginMainThreadScheduler.h"
#include "RenderWidget.h"
-#include "JSDOMBinding.h"
#include "ScriptController.h"
-#include "PluginDatabase.h"
-#include "PluginDebug.h"
-#include "PluginPackage.h"
#include "Settings.h"
+#include "WebCoreInstanceHandle.h"
#include "c_instance.h"
#include "npruntime_impl.h"
#include "runtime_root.h"
@@ -72,6 +68,10 @@
#include <runtime/JSValue.h>
#include <wtf/ASCIICType.h>
+#if !PLATFORM(WX)
+#include "BitmapInfo.h"
+#endif
+
#if OS(WINCE)
#undef LOG_NPERROR
#define LOG_NPERROR(x)
@@ -289,10 +289,10 @@ static bool registerPluginView()
haveRegisteredWindowClass = true;
#if PLATFORM(QT)
- Page::setInstanceHandle((HINSTANCE)(qWinAppInst()));
+ WebCore::setInstanceHandle((HINSTANCE)(qWinAppInst()));
#endif
- ASSERT(Page::instanceHandle());
+ ASSERT(WebCore::instanceHandle());
#if OS(WINCE)
WNDCLASS wcex = { 0 };
@@ -309,7 +309,7 @@ static bool registerPluginView()
wcex.lpfnWndProc = DefWindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
- wcex.hInstance = Page::instanceHandle();
+ wcex.hInstance = WebCore::instanceHandle();
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(0, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)COLOR_WINDOW;
@@ -867,73 +867,30 @@ NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const c
return NPERR_NO_ERROR;
}
-NPError PluginView::getValueStatic(NPNVariable variable, void* value)
+bool PluginView::platformGetValueStatic(NPNVariable, void*, NPError*)
{
- LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
-
- return NPERR_GENERIC_ERROR;
+ return false;
}
-NPError PluginView::getValue(NPNVariable variable, void* value)
+bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* result)
{
- LOG(Plugins, "PluginView::getValue(%s)", prettyNameForNPNVariable(variable).data());
-
switch (variable) {
-#if ENABLE(NETSCAPE_PLUGIN_API)
- case NPNVWindowNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* windowScriptObject = m_parentFrame->script()->windowScriptNPObject();
-
- // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (windowScriptObject)
- _NPN_RetainObject(windowScriptObject);
-
- void** v = (void**)value;
- *v = windowScriptObject;
-
- return NPERR_NO_ERROR;
- }
-
- case NPNVPluginElementNPObject: {
- if (m_isJavaScriptPaused)
- return NPERR_GENERIC_ERROR;
-
- NPObject* pluginScriptObject = 0;
-
- if (m_element->hasTagName(appletTag) || m_element->hasTagName(embedTag) || m_element->hasTagName(objectTag))
- pluginScriptObject = static_cast<HTMLPlugInElement*>(m_element)->getNPObject();
-
- // Return value is expected to be retained, as described here: <http://www.mozilla.org/projects/plugin/npruntime.html>
- if (pluginScriptObject)
- _NPN_RetainObject(pluginScriptObject);
-
- void** v = (void**)value;
- *v = pluginScriptObject;
-
- return NPERR_NO_ERROR;
- }
-#endif
-
case NPNVnetscapeWindow: {
HWND* w = reinterpret_cast<HWND*>(value);
-
*w = windowHandleForPageClient(parent() ? parent()->hostWindow()->platformPageClient() : 0);
-
- return NPERR_NO_ERROR;
+ *result = NPERR_NO_ERROR;
+ return true;
}
case NPNVSupportsWindowless: {
- NPBool *result = reinterpret_cast<NPBool*>(value);
-
- *result = TRUE;
-
- return NPERR_NO_ERROR;
+ NPBool* flag = reinterpret_cast<NPBool*>(value);
+ *flag = TRUE;
+ *result = NPERR_NO_ERROR;
+ return true;
}
- default:
- return NPERR_GENERIC_ERROR;
+ default:
+ return false;
}
}
@@ -1011,7 +968,7 @@ bool PluginView::platformStart()
HWND parentWindowHandle = windowHandleForPageClient(m_parentFrame->view()->hostWindow()->platformPageClient());
HWND window = ::CreateWindowEx(0, kWebPluginViewdowClassName, 0, flags,
- 0, 0, 0, 0, parentWindowHandle, 0, Page::instanceHandle(), 0);
+ 0, 0, 0, 0, parentWindowHandle, 0, WebCore::instanceHandle(), 0);
#if OS(WINDOWS) && (PLATFORM(QT) || PLATFORM(WX))
m_window = window;