summaryrefslogtreecommitdiffstats
path: root/WebCore/plugins/symbian
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-11-05 09:23:40 +0000
committerSteve Block <steveblock@google.com>2009-11-10 22:41:12 +0000
commitcac0f67c402d107cdb10971b95719e2ff9c7c76b (patch)
treed182c7f87211c6f201a5f038e332336493ebdbe7 /WebCore/plugins/symbian
parent4b2ef0f288e7c6c4602f621b7a0e9feed304b70e (diff)
downloadexternal_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.zip
external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.tar.gz
external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.tar.bz2
Merge webkit.org at r50258 : Initial merge by git.
Change-Id: I1a9e1dc4ed654b69174ad52a4f031a07240f37b0
Diffstat (limited to 'WebCore/plugins/symbian')
-rw-r--r--WebCore/plugins/symbian/PluginContainerSymbian.cpp77
-rw-r--r--WebCore/plugins/symbian/PluginContainerSymbian.h50
-rw-r--r--WebCore/plugins/symbian/PluginDatabaseSymbian.cpp79
-rw-r--r--WebCore/plugins/symbian/PluginPackageSymbian.cpp177
-rw-r--r--WebCore/plugins/symbian/PluginViewSymbian.cpp462
-rw-r--r--WebCore/plugins/symbian/npinterface.h37
6 files changed, 882 insertions, 0 deletions
diff --git a/WebCore/plugins/symbian/PluginContainerSymbian.cpp b/WebCore/plugins/symbian/PluginContainerSymbian.cpp
new file mode 100644
index 0000000..aece0e4
--- /dev/null
+++ b/WebCore/plugins/symbian/PluginContainerSymbian.cpp
@@ -0,0 +1,77 @@
+/*
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "PluginContainerSymbian.h"
+
+#include "FocusController.h"
+#include "Frame.h"
+#include "FrameView.h"
+#include "Page.h"
+#include "PlatformKeyboardEvent.h"
+#include "PluginView.h"
+
+#include <QApplication>
+#include <QWidget>
+
+using namespace WebCore;
+
+PluginContainerSymbian::PluginContainerSymbian(PluginView* view, QWidget* parent)
+ : m_parent(parent)
+ , m_pluginView(view)
+ , m_hasPendingGeometryChange(false)
+{
+ setParent(m_parent);
+}
+
+PluginContainerSymbian::~PluginContainerSymbian()
+{
+}
+
+void PluginContainerSymbian::requestGeometry(const QRect& rect, const QRegion& clip)
+{
+ if (m_windowRect != rect || m_clipRegion != clip) {
+ m_windowRect = rect;
+ m_clipRegion = clip;
+ m_hasPendingGeometryChange = true;
+ }
+}
+
+void PluginContainerSymbian::adjustGeometry()
+{
+ if (m_hasPendingGeometryChange) {
+ setGeometry(m_windowRect);
+ setMask(m_clipRegion);
+ m_hasPendingGeometryChange = false;
+ }
+}
+
+void PluginContainerSymbian::focusInEvent(QFocusEvent* event)
+{
+ if (Page* page = m_pluginView->parentFrame()->page())
+ page->focusController()->setActive(true);
+
+ m_pluginView->focusPluginElement();
+}
+
+void PluginContainerSymbian::focusOutEvent(QFocusEvent*)
+{
+ if (Page* page = m_pluginView->parentFrame()->page())
+ page->focusController()->setActive(false);
+}
diff --git a/WebCore/plugins/symbian/PluginContainerSymbian.h b/WebCore/plugins/symbian/PluginContainerSymbian.h
new file mode 100644
index 0000000..fce4a71
--- /dev/null
+++ b/WebCore/plugins/symbian/PluginContainerSymbian.h
@@ -0,0 +1,50 @@
+/*
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef PluginContainerSymbian_h
+#define PluginContainerSymbian_h
+
+#include <QWidget>
+
+namespace WebCore {
+
+ class PluginView;
+
+ class PluginContainerSymbian : public QWidget {
+ Q_OBJECT
+ public:
+ PluginContainerSymbian(PluginView*, QWidget* parent);
+ ~PluginContainerSymbian();
+
+ void requestGeometry(const QRect&, const QRegion& clip = QRegion());
+ void adjustGeometry();
+
+ protected:
+ virtual void focusInEvent(QFocusEvent*);
+ virtual void focusOutEvent(QFocusEvent*);
+ private:
+ PluginView* m_pluginView;
+ QWidget* m_parent;
+ QRect m_windowRect;
+ QRegion m_clipRegion;
+ bool m_hasPendingGeometryChange;
+ };
+}
+
+#endif // PluginContainerSymbian_h
diff --git a/WebCore/plugins/symbian/PluginDatabaseSymbian.cpp b/WebCore/plugins/symbian/PluginDatabaseSymbian.cpp
new file mode 100644
index 0000000..2e09296
--- /dev/null
+++ b/WebCore/plugins/symbian/PluginDatabaseSymbian.cpp
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#include "config.h"
+#include "PluginDatabase.h"
+
+#include <QFileInfo>
+#include <f32file.h>
+
+static const char QTPLUGIN_FILTER[] = "*.qtplugin";
+static const char QT_PLUGIN_FOLDER[] = ":\\resource\\qt\\plugins\\npqtplugins\\";
+
+namespace WebCore {
+
+Vector<String> PluginDatabase::defaultPluginDirectories()
+{
+ Vector<String> directories;
+ //find the installation drive
+ TDriveList drivelist;
+ TChar driveLetter;
+ RFs fsSession;
+
+ if (fsSession.Connect() == KErrNone && fsSession.DriveList(drivelist) == KErrNone) {
+ for (TInt driveNumber = EDriveA; driveNumber <= EDriveZ; driveNumber++) {
+ if (drivelist[driveNumber] && fsSession.DriveToChar(driveNumber, driveLetter) == KErrNone) {
+ QString driveStringValue(QChar((uint)driveLetter.GetUpperCase()));
+ QString stubDirPath;
+ stubDirPath.append(driveStringValue);
+ stubDirPath.append(QT_PLUGIN_FOLDER);
+ if (QFileInfo(stubDirPath).exists())
+ directories.append(stubDirPath);
+ }
+ }
+ }
+
+ fsSession.Close();
+ return directories;
+}
+
+bool PluginDatabase::isPreferredPluginDirectory(const String& path)
+{
+ return true;
+}
+
+void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
+{
+ // FIXME: This should be a case insensitive set.
+ HashSet<String> uniqueFilenames;
+
+ String fileNameFilter(QTPLUGIN_FILTER);
+
+ Vector<String>::const_iterator dirsEnd = m_pluginDirectories.end();
+ for (Vector<String>::const_iterator dIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) {
+ Vector<String> pluginPaths = listDirectory(*dIt, fileNameFilter);
+ Vector<String>::const_iterator pluginsEnd = pluginPaths.end();
+ for (Vector<String>::const_iterator pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) {
+ if (!fileExists(*pIt))
+ continue;
+ paths.add(*pIt);
+ }
+ }
+}
+
+}
diff --git a/WebCore/plugins/symbian/PluginPackageSymbian.cpp b/WebCore/plugins/symbian/PluginPackageSymbian.cpp
new file mode 100644
index 0000000..d5c7533
--- /dev/null
+++ b/WebCore/plugins/symbian/PluginPackageSymbian.cpp
@@ -0,0 +1,177 @@
+/*
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#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>
+
+namespace WebCore {
+
+bool PluginPackage::fetchInfo()
+{
+ if (!load())
+ return false;
+
+ char* buf = 0;
+ NPError err = m_pluginFuncs.getvalue(0, NPPVpluginNameString, (void *)&buf);
+ m_name = buf;
+ err = m_pluginFuncs.getvalue(0, NPPVpluginDescriptionString, (void *)&buf);
+ m_description = buf;
+
+ determineModuleVersionFromDescription();
+
+ String s = m_npInterface->NP_GetMIMEDescription();
+ Vector<String> types;
+ s.split(UChar('|'), false, types); // <MIME1>;<ext1,ext2,ext3,...>;<Description>|<MIME2>|<MIME3>|...
+
+ for (int i = 0; i < types.size(); ++i) {
+ Vector<String> mime;
+ types[i].split(UChar(';'), true, mime); // <MIME1>;<ext1,ext2,ext3,...>;<Description>
+ if (mime.size() > 0) {
+ Vector<String> exts;
+ if (mime.size() > 1)
+ mime[1].split(UChar(','), false, exts); // <ext1,ext2,ext3,...>
+
+ m_mimeToExtensions.add(mime[0], exts); // <MIME>,<ext1,ext2,ext3>
+ if (mime.size() > 2)
+ m_mimeToDescriptions.add(mime[0], mime[2]); // <MIME>,<Description>
+ }
+ }
+ unload();
+ return true;
+}
+
+bool PluginPackage::load()
+{
+ if (m_isLoaded) {
+ m_loadCount++;
+ return true;
+ }
+
+ m_pluginLoader = new QPluginLoader(m_path);
+ if (!m_pluginLoader->load()) {
+ delete m_pluginLoader;
+ m_pluginLoader = 0;
+ return false;
+ }
+
+ QObject* plugin = m_pluginLoader->instance();
+ if (!plugin) {
+ m_pluginLoader->unload();
+ delete m_pluginLoader;
+ m_pluginLoader = 0;
+ return false;
+ }
+
+ // Plugin instance created
+ // Cast plugin to NPInterface,
+ m_npInterface = qobject_cast<NPInterface*>(plugin);
+ if (!m_npInterface) {
+ m_pluginLoader->unload();
+ delete m_pluginLoader;
+ m_pluginLoader = 0;
+ return false;
+ }
+
+ m_isLoaded = true;
+
+ NPError npErr;
+ memset(&m_pluginFuncs, 0, sizeof(m_pluginFuncs));
+ m_pluginFuncs.size = sizeof(m_pluginFuncs);
+ m_browserFuncs.size = sizeof(m_browserFuncs);
+ m_browserFuncs.version = NP_VERSION_MINOR;
+ m_browserFuncs.geturl = NPN_GetURL;
+ m_browserFuncs.posturl = NPN_PostURL;
+ m_browserFuncs.requestread = NPN_RequestRead;
+ m_browserFuncs.newstream = NPN_NewStream;
+ m_browserFuncs.write = NPN_Write;
+ m_browserFuncs.destroystream = NPN_DestroyStream;
+ m_browserFuncs.status = NPN_Status;
+ m_browserFuncs.uagent = NPN_UserAgent;
+ m_browserFuncs.memalloc = NPN_MemAlloc;
+ m_browserFuncs.memfree = NPN_MemFree;
+ m_browserFuncs.memflush = NPN_MemFlush;
+ m_browserFuncs.reloadplugins = NPN_ReloadPlugins;
+ m_browserFuncs.geturlnotify = NPN_GetURLNotify;
+ m_browserFuncs.posturlnotify = NPN_PostURLNotify;
+ m_browserFuncs.getvalue = NPN_GetValue;
+ m_browserFuncs.setvalue = NPN_SetValue;
+ m_browserFuncs.invalidaterect = NPN_InvalidateRect;
+ m_browserFuncs.invalidateregion = NPN_InvalidateRegion;
+ m_browserFuncs.forceredraw = NPN_ForceRedraw;
+ m_browserFuncs.getJavaEnv = NPN_GetJavaEnv;
+ m_browserFuncs.getJavaPeer = NPN_GetJavaPeer;
+ m_browserFuncs.pushpopupsenabledstate = NPN_PushPopupsEnabledState;
+ m_browserFuncs.poppopupsenabledstate = NPN_PopPopupsEnabledState;
+ m_browserFuncs.releasevariantvalue = _NPN_ReleaseVariantValue;
+ m_browserFuncs.getstringidentifier = _NPN_GetStringIdentifier;
+ m_browserFuncs.getstringidentifiers = _NPN_GetStringIdentifiers;
+ m_browserFuncs.getintidentifier = _NPN_GetIntIdentifier;
+ m_browserFuncs.identifierisstring = _NPN_IdentifierIsString;
+ m_browserFuncs.utf8fromidentifier = _NPN_UTF8FromIdentifier;
+ m_browserFuncs.createobject = _NPN_CreateObject;
+ m_browserFuncs.retainobject = _NPN_RetainObject;
+ m_browserFuncs.releaseobject = _NPN_ReleaseObject;
+ m_browserFuncs.invoke = _NPN_Invoke;
+ m_browserFuncs.invokeDefault = _NPN_InvokeDefault;
+ m_browserFuncs.evaluate = _NPN_Evaluate;
+ m_browserFuncs.getproperty = _NPN_GetProperty;
+ m_browserFuncs.setproperty = _NPN_SetProperty;
+ m_browserFuncs.removeproperty = _NPN_RemoveProperty;
+ m_browserFuncs.hasproperty = _NPN_HasMethod;
+ m_browserFuncs.hasmethod = _NPN_HasProperty;
+ m_browserFuncs.setexception = _NPN_SetException;
+ m_browserFuncs.enumerate = _NPN_Enumerate;
+ m_browserFuncs.construct = _NPN_Construct;
+
+ npErr = m_npInterface->NP_Initialize(&m_browserFuncs, &m_pluginFuncs);
+ if (npErr != NPERR_NO_ERROR) {
+ m_pluginLoader->unload();
+ delete m_pluginLoader;
+ m_pluginLoader = 0;
+ return false;
+ }
+
+ m_loadCount++;
+ return true;
+}
+
+void PluginPackage::unload()
+{
+ if (!m_isLoaded)
+ return;
+
+ if (--m_loadCount > 0)
+ return;
+
+ m_isLoaded = false;
+ m_npInterface->NP_Shutdown();
+
+ m_pluginLoader->unload();
+ delete m_pluginLoader;
+ m_pluginLoader = 0;
+}
+}
+
diff --git a/WebCore/plugins/symbian/PluginViewSymbian.cpp b/WebCore/plugins/symbian/PluginViewSymbian.cpp
new file mode 100644
index 0000000..14e25b1
--- /dev/null
+++ b/WebCore/plugins/symbian/PluginViewSymbian.cpp
@@ -0,0 +1,462 @@
+/*
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#include "config.h"
+#include "PluginView.h"
+
+#include "Document.h"
+#include "DocumentLoader.h"
+#include "Element.h"
+#include "FocusController.h"
+#include "Frame.h"
+#include "FrameLoadRequest.h"
+#include "FrameLoader.h"
+#include "FrameTree.h"
+#include "FrameView.h"
+#include "GraphicsContext.h"
+#include "HTMLNames.h"
+#include "HTMLPlugInElement.h"
+#include "Image.h"
+#include "JSDOMBinding.h"
+#include "KeyboardEvent.h"
+#include "MouseEvent.h"
+#include "NotImplemented.h"
+#include "npfunctions.h"
+#include "npinterface.h"
+#include "Page.h"
+#include "PlatformKeyboardEvent.h"
+#include "PlatformMouseEvent.h"
+#include "PluginContainerSymbian.h"
+#include "PluginDebug.h"
+#include "PluginMainThreadScheduler.h"
+#include "PluginPackage.h"
+#include "RenderLayer.h"
+#include "ScriptController.h"
+#include "Settings.h"
+#include "npruntime_impl.h"
+#include "runtime.h"
+#include "runtime_root.h"
+#include "QWebPageClient.h"
+#include <QKeyEvent>
+#include <QPixmap.h>
+#include <QRegion>
+#include <QVector>
+#include <QWidget>
+#include <runtime/JSLock.h>
+#include <runtime/JSValue.h>
+
+using JSC::ExecState;
+using JSC::Interpreter;
+using JSC::JSLock;
+using JSC::JSObject;
+using JSC::UString;
+
+using namespace std;
+
+using namespace WTF;
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+void PluginView::updatePluginWidget()
+{
+ if (!parent())
+ return;
+ ASSERT(parent()->isFrameView());
+ FrameView* frameView = static_cast<FrameView*>(parent());
+ IntRect oldWindowRect = m_windowRect;
+ 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)
+ return;
+
+ // in order to move/resize the plugin window at the same time as the rest of frame
+ // during e.g. scrolling, we set the mask and 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();
+}
+
+void PluginView::setFocus()
+{
+ if (platformPluginWidget())
+ platformPluginWidget()->setFocus(Qt::OtherFocusReason);
+ else
+ Widget::setFocus();
+}
+
+void PluginView::show()
+{
+ setSelfVisible(true);
+
+ if (isParentVisible() && platformPluginWidget())
+ platformPluginWidget()->setVisible(true);
+}
+
+void PluginView::hide()
+{
+ setSelfVisible(false);
+
+ if (isParentVisible() && platformPluginWidget())
+ platformPluginWidget()->setVisible(false);
+}
+
+void PluginView::paint(GraphicsContext* context, const IntRect& rect)
+{
+ if (!m_isStarted) {
+ paintMissingPluginIcon(context, rect);
+ return;
+ }
+
+ if (context->paintingDisabled())
+ return;
+ m_npWindow.ws_info = (void*)(context->platformContext());
+ setNPWindowIfNeeded();
+
+ if (m_isWindowed && platformPluginWidget())
+ static_cast<PluginContainerSymbian*>(platformPluginWidget())->adjustGeometry();
+
+ if (m_isWindowed)
+ return;
+
+ context->save();
+ IntRect clipRect(rect);
+ clipRect.intersect(frameRect());
+ context->clip(clipRect);
+ context->translate(frameRect().location().x(), frameRect().location().y());
+
+ QPaintEvent ev(rect);
+ QEvent& npEvent = ev;
+ dispatchNPEvent(npEvent);
+
+ context->restore();
+}
+
+// TODO: Unify across ports.
+bool PluginView::dispatchNPEvent(NPEvent& event)
+{
+ if (!m_plugin->pluginFuncs()->event)
+ return false;
+
+ PluginView::setCurrentPluginView(this);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
+
+ setCallingPlugin(true);
+ bool accepted = m_plugin->pluginFuncs()->event(m_instance, &event);
+ setCallingPlugin(false);
+ PluginView::setCurrentPluginView(0);
+
+ return accepted;
+}
+
+void PluginView::handleKeyboardEvent(KeyboardEvent* event)
+{
+ if (m_isWindowed)
+ return;
+
+ QEvent& npEvent = *(event->keyEvent()->qtEvent());
+ if (!dispatchNPEvent(npEvent))
+ event->setDefaultHandled();
+}
+
+void PluginView::handleMouseEvent(MouseEvent* event)
+{
+ if (m_isWindowed)
+ return;
+
+ if (event->type() == eventNames().mousedownEvent) {
+ // Give focus to the plugin on click
+ if (Page* page = m_parentFrame->page())
+ page->focusController()->setActive(true);
+
+ focusPluginElement();
+ }
+
+ QEvent::Type type;
+ if (event->type() == eventNames().mousedownEvent)
+ type = QEvent::MouseButtonPress;
+ else if (event->type() == eventNames().mousemoveEvent)
+ type = QEvent::MouseMove;
+ else if (event->type() == eventNames().mouseupEvent)
+ type = QEvent::MouseButtonRelease;
+ else
+ return;
+
+ QPoint position(event->offsetX(), event->offsetY());
+ Qt::MouseButton button;
+ switch (event->which()) {
+ case 1:
+ button = Qt::LeftButton;
+ break;
+ case 2:
+ button = Qt::MidButton;
+ break;
+ case 3:
+ button = Qt::RightButton;
+ break;
+ default:
+ button = Qt::NoButton;
+ }
+ Qt::KeyboardModifiers modifiers = 0;
+ if (event->ctrlKey())
+ modifiers |= Qt::ControlModifier;
+ if (event->altKey())
+ modifiers |= Qt::AltModifier;
+ if (event->shiftKey())
+ modifiers |= Qt::ShiftModifier;
+ if (event->metaKey())
+ modifiers |= Qt::MetaModifier;
+ QMouseEvent mouseEvent(type, position, button, button, modifiers);
+ QEvent& npEvent = mouseEvent;
+ if (!dispatchNPEvent(npEvent))
+ event->setDefaultHandled();
+}
+
+void PluginView::setParent(ScrollView* parent)
+{
+ Widget::setParent(parent);
+
+ if (parent)
+ init();
+}
+
+void PluginView::setNPWindowRect(const IntRect&)
+{
+ if (!m_isWindowed)
+ setNPWindowIfNeeded();
+}
+
+void PluginView::setNPWindowIfNeeded()
+{
+ if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow)
+ return;
+ if (m_isWindowed) {
+ ASSERT(platformPluginWidget());
+ platformPluginWidget()->setGeometry(m_windowRect);
+ // if setMask is set with an empty QRegion, no clipping will
+ // be performed, so in that case we hide the plugin view
+ platformPluginWidget()->setVisible(!m_clipRect.isEmpty());
+ platformPluginWidget()->setMask(QRegion(m_clipRect));
+
+ m_npWindow.x = m_windowRect.x();
+ m_npWindow.y = m_windowRect.y();
+
+ m_npWindow.clipRect.left = m_clipRect.x();
+ m_npWindow.clipRect.top = m_clipRect.y();
+ m_npWindow.clipRect.right = m_clipRect.width();
+ m_npWindow.clipRect.bottom = m_clipRect.height();
+
+ } else {
+ // always call this method before painting.
+ m_npWindow.x = 0;
+ m_npWindow.y = 0;
+
+ m_npWindow.clipRect.left = 0;
+ m_npWindow.clipRect.top = 0;
+ m_npWindow.clipRect.right = m_windowRect.width();
+ m_npWindow.clipRect.bottom = m_windowRect.height();
+ m_npWindow.window = 0;
+ }
+
+ m_npWindow.width = m_windowRect.width();
+ m_npWindow.height = m_windowRect.height();
+ if (m_npWindow.x < 0 || m_npWindow.y < 0 || m_npWindow.width <= 0 || m_npWindow.height <= 0)
+ return;
+
+ PluginView::setCurrentPluginView(this);
+ JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly);
+ setCallingPlugin(true);
+ m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
+ setCallingPlugin(false);
+ PluginView::setCurrentPluginView(0);
+}
+
+void PluginView::setParentVisible(bool visible)
+{
+ if (isParentVisible() == visible)
+ return;
+
+ Widget::setParentVisible(visible);
+
+ if (isSelfVisible() && platformPluginWidget())
+ platformPluginWidget()->setVisible(visible);
+}
+
+NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const char* buf)
+{
+ notImplemented();
+ return NPERR_NO_ERROR;
+}
+
+NPError PluginView::getValueStatic(NPNVariable variable, void* value)
+{
+ LOG(Plugins, "PluginView::getValueStatic(%s)", prettyNameForNPNVariable(variable).data());
+
+ switch (variable) {
+ case NPNVjavascriptEnabledBool:
+ *static_cast<NPBool*>(value) = true;
+ return NPERR_NO_ERROR;
+
+ case NPNVSupportsWindowless:
+ *static_cast<NPBool*>(value) = true;
+ return NPERR_NO_ERROR;
+
+ default:
+ return NPERR_GENERIC_ERROR;
+ }
+}
+
+NPError PluginView::getValue(NPNVariable variable, void* value)
+{
+ 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);
+ }
+}
+
+void PluginView::invalidateRect(const IntRect& rect)
+{
+ if (m_isWindowed) {
+ platformWidget()->update(rect);
+ return;
+ }
+
+ invalidateWindowlessPluginRect(rect);
+}
+
+void PluginView::invalidateRect(NPRect* rect)
+{
+ if (m_isWindowed)
+ return;
+ if (!rect) {
+ invalidate();
+ return;
+ }
+ IntRect r(rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top);
+ m_invalidRects.append(r);
+ if (!m_invalidateTimer.isActive())
+ m_invalidateTimer.startOneShot(0.001);
+}
+
+void PluginView::invalidateRegion(NPRegion region)
+{
+ if (m_isWindowed)
+ return;
+
+ if (!region)
+ return;
+
+ QVector<QRect> rects = region->rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect& qRect = rects.at(i);
+ m_invalidRects.append(qRect);
+ if (!m_invalidateTimer.isActive())
+ m_invalidateTimer.startOneShot(0.001);
+ }
+}
+
+void PluginView::forceRedraw()
+{
+ if (m_isWindowed)
+ return;
+ invalidate();
+}
+
+bool PluginView::platformStart()
+{
+ ASSERT(m_isStarted);
+ ASSERT(m_status == PluginStatusLoadedSuccessfully);
+
+ show();
+
+ 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())));
+ m_npWindow.type = NPWindowTypeWindow;
+ m_npWindow.window = (void*)platformPluginWidget();
+
+ } else {
+ setPlatformWidget(0);
+ m_npWindow.type = NPWindowTypeDrawable;
+ m_npWindow.window = 0; // Not used?
+ }
+ setNPWindowIfNeeded();
+
+ return true;
+}
+
+void PluginView::platformDestroy()
+{
+ delete platformPluginWidget();
+}
+
+void PluginView::halt()
+{
+}
+
+void PluginView::restart()
+{
+}
+
+} // namespace WebCore
diff --git a/WebCore/plugins/symbian/npinterface.h b/WebCore/plugins/symbian/npinterface.h
new file mode 100644
index 0000000..0f0b6ca
--- /dev/null
+++ b/WebCore/plugins/symbian/npinterface.h
@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef npinterface_H
+#define npinterface_H
+
+#include "npfunctions.h"
+#include <QtPlugin>
+
+class NPInterface {
+public:
+ virtual NPError NP_Initialize(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs) = 0;
+ virtual void NP_Shutdown() = 0;
+ virtual char* NP_GetMIMEDescription() = 0;
+};
+
+
+QT_BEGIN_NAMESPACE
+Q_DECLARE_INTERFACE(NPInterface, "com.nokia.qts60.webplugin/1.0");
+QT_END_NAMESPACE
+
+#endif // npinterface_H