diff options
author | Steve Block <steveblock@google.com> | 2011-05-06 11:45:16 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-12 13:44:10 +0100 |
commit | cad810f21b803229eb11403f9209855525a25d57 (patch) | |
tree | 29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /Source/WebCore/plugins/symbian | |
parent | 121b0cf4517156d0ac5111caf9830c51b69bae8f (diff) | |
download | external_webkit-cad810f21b803229eb11403f9209855525a25d57.zip external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2 |
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'Source/WebCore/plugins/symbian')
6 files changed, 869 insertions, 0 deletions
diff --git a/Source/WebCore/plugins/symbian/PluginContainerSymbian.cpp b/Source/WebCore/plugins/symbian/PluginContainerSymbian.cpp new file mode 100644 index 0000000..b839870 --- /dev/null +++ b/Source/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, QGraphicsProxyWidget* proxy) + : QWidget(parent) + , m_pluginView(view) + , m_proxy(proxy) + , m_hasPendingGeometryChange(false) +{ +} + +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*) +{ + 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/Source/WebCore/plugins/symbian/PluginContainerSymbian.h b/Source/WebCore/plugins/symbian/PluginContainerSymbian.h new file mode 100644 index 0000000..fead872 --- /dev/null +++ b/Source/WebCore/plugins/symbian/PluginContainerSymbian.h @@ -0,0 +1,53 @@ +/* + 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> + +class QGraphicsProxyWidget; + +namespace WebCore { + + class PluginView; + + class PluginContainerSymbian : public QWidget { + Q_OBJECT + public: + 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; + QGraphicsProxyWidget* m_proxy; + QRect m_windowRect; + QRegion m_clipRegion; + bool m_hasPendingGeometryChange; + }; +} + +#endif // PluginContainerSymbian_h diff --git a/Source/WebCore/plugins/symbian/PluginDatabaseSymbian.cpp b/Source/WebCore/plugins/symbian/PluginDatabaseSymbian.cpp new file mode 100644 index 0000000..2e09296 --- /dev/null +++ b/Source/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/Source/WebCore/plugins/symbian/PluginPackageSymbian.cpp b/Source/WebCore/plugins/symbian/PluginPackageSymbian.cpp new file mode 100644 index 0000000..7fca625 --- /dev/null +++ b/Source/WebCore/plugins/symbian/PluginPackageSymbian.cpp @@ -0,0 +1,182 @@ +/* + 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 "MIMETypeRegistry.h" +#include "npinterface.h" +#include "npruntime_impl.h" +#include "PluginDatabase.h" +#include "PluginDebug.h" +#include <QPluginLoader> +#include <wtf/text/CString.h> + +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; +} + +uint16_t PluginPackage::NPVersion() const +{ + return NP_VERSION_MINOR; +} +} + diff --git a/Source/WebCore/plugins/symbian/PluginViewSymbian.cpp b/Source/WebCore/plugins/symbian/PluginViewSymbian.cpp new file mode 100644 index 0000000..b8a72b1 --- /dev/null +++ b/Source/WebCore/plugins/symbian/PluginViewSymbian.cpp @@ -0,0 +1,441 @@ +/* + Copyright (C) 2009, 2010 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 "Bridge.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 "HostWindow.h" +#include "Image.h" +#include "JSDOMBinding.h" +#include "KeyboardEvent.h" +#include "MouseEvent.h" +#include "NotImplemented.h" +#include "Page.h" +#include "PlatformKeyboardEvent.h" +#include "PlatformMouseEvent.h" +#include "PluginContainerSymbian.h" +#include "PluginDebug.h" +#include "PluginMainThreadScheduler.h" +#include "PluginPackage.h" +#include "QWebPageClient.h" +#include "RenderLayer.h" +#include "ScriptController.h" +#include "Settings.h" +#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> +#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(bool focused) +{ + if (platformPluginWidget()) { + if (focused) + platformPluginWidget()->setFocus(Qt::OtherFocusReason); + } else { + Widget::setFocus(focused); + } +} + +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; + + ASSERT(event->keyEvent()->qtEvent()); + 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(); + if (m_status == PluginStatusLoadedSuccessfully) + updatePluginWidget(); + } +} + +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 = max(0, m_clipRect.x()); + m_npWindow.clipRect.top = max(0, m_clipRect.y()); + m_npWindow.clipRect.right = m_clipRect.x() + m_clipRect.width(); + m_npWindow.clipRect.bottom = m_clipRect.y() + 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(); + + 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_t len, const char* buf) +{ + notImplemented(); + return NPERR_NO_ERROR; +} + +bool PluginView::platformGetValueStatic(NPNVariable variable, void* value, NPError* result) +{ + switch (variable) { + case NPNVjavascriptEnabledBool: + *static_cast<NPBool*>(value) = true; + *result = NPERR_NO_ERROR; + return true; + + case NPNVSupportsWindowless: + *static_cast<NPBool*>(value) = true; + *result = NPERR_NO_ERROR; + return true; + + default: + return false; + } +} + +bool PluginView::platformGetValue(NPNVariable, void*, NPError*) +{ + return false; +} + +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(); + 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(); + + } else { + setPlatformWidget(0); + m_npWindow.type = NPWindowTypeDrawable; + m_npWindow.window = 0; // Not used? + } + updatePluginWidget(); + setNPWindowIfNeeded(); + + return true; +} + +void PluginView::platformDestroy() +{ + if (platformPluginWidget()) { + PluginContainerSymbian* container = static_cast<PluginContainerSymbian*>(platformPluginWidget()); + if (container && container->proxy()) + delete container->proxy(); + else + delete container; + } +} + +void PluginView::halt() +{ +} + +void PluginView::restart() +{ +} + +} // namespace WebCore diff --git a/Source/WebCore/plugins/symbian/npinterface.h b/Source/WebCore/plugins/symbian/npinterface.h new file mode 100644 index 0000000..e296127 --- /dev/null +++ b/Source/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 |