diff options
author | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2009-10-22 19:50:52 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2009-10-22 20:34:20 +0200 |
commit | 57f1983c164bc8553c6b6aa7ac320f00e5405548 (patch) | |
tree | 6cfbec33f6e385ceb5cbfa0168f4a9f27f0c8e57 /src/3rdparty/webkit/WebCore/plugins | |
parent | 5baebfc68dd67def412bcbaa7c61b43d05e6ee42 (diff) |
Updated WebKit from /home/jturcott/dev/webkit/ to qtwebkit-4.6-snapshot-22102009 ( 0639bb8e812c8923287cd5523248ca64fa5f7a50 )
Changes in WebKit/qt since the last update:
Jocelyn: fatal error from script, sha1 in src/3rdparty/webkit/VERSION is bad
Diffstat (limited to 'src/3rdparty/webkit/WebCore/plugins')
21 files changed, 1465 insertions, 155 deletions
diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginDataNone.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginDataNone.cpp index 28e39673e0..3b98383ccf 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginDataNone.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/PluginDataNone.cpp @@ -27,18 +27,14 @@ #include "config.h" #include "PluginData.h" -#include "NotImplemented.h" - namespace WebCore { void PluginData::initPlugins() { - notImplemented(); } void PluginData::refresh() { - notImplemented(); } }; diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginDatabase.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginDatabase.cpp index f40ed952b9..c7979d14ad 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginDatabase.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/PluginDatabase.cpp @@ -320,7 +320,7 @@ void PluginDatabase::clear() m_preferredPlugins.clear(); } -#if !PLATFORM(WIN_OS) || PLATFORM(WX) +#if (!PLATFORM(SYMBIAN)) && (!PLATFORM(WIN_OS) || PLATFORM(WX)) // For Safari/Win the following three methods are implemented // in PluginDatabaseWin.cpp, but if we can use WebCore constructs // for the logic we should perhaps move it here under XP_WIN? @@ -355,6 +355,8 @@ Vector<String> PluginDatabase::defaultPluginDirectories() paths.append("/usr/lib/netscape/plugins-libc6"); paths.append("/usr/lib64/netscape/plugins"); paths.append("/usr/lib64/mozilla/plugins"); + paths.append("/usr/lib/nsbrowser/plugins"); + paths.append("/usr/lib64/nsbrowser/plugins"); String mozHome(getenv("MOZILLA_HOME")); mozHome.append("/plugins"); @@ -426,6 +428,6 @@ void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const } } -#endif // !PLATFORM(WIN_OS) +#endif // !PLATFORM(SYMBIAN) && !PLATFORM(WIN_OS) } diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginPackage.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginPackage.cpp index 612a9d7e6f..19337f0d44 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginPackage.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/PluginPackage.cpp @@ -113,6 +113,7 @@ PluginPackage::PluginPackage(const String& path, const time_t& lastModified) m_parentDirectory = m_path.left(m_path.length() - m_fileName.length() - 1); } +#if !PLATFORM(SYMBIAN) void PluginPackage::unload() { if (!m_isLoaded) @@ -125,6 +126,7 @@ void PluginPackage::unload() unloadWithoutShutdown(); } +#endif //!PLATFORM(SYMBIAN) void PluginPackage::unloadWithoutShutdown() { @@ -183,6 +185,7 @@ void PluginPackage::determineQuirks(const String& mimeType) #if PLATFORM(QT) m_quirks.add(PluginQuirkRequiresGtkToolKit); #endif + m_quirks.add(PluginQuirkRequiresDefaultScreenDepth); } else { // Flash 9 and older requests windowless plugins if we return a mozilla user agent m_quirks.add(PluginQuirkWantsMozillaUserAgent); diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginPackage.h b/src/3rdparty/webkit/WebCore/plugins/PluginPackage.h index 3afc57f9dd..d409ab60b8 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginPackage.h +++ b/src/3rdparty/webkit/WebCore/plugins/PluginPackage.h @@ -36,6 +36,11 @@ #include <wtf/HashMap.h> #include <wtf/RefCounted.h> +#if PLATFORM(SYMBIAN) +class QPluginLoader; +class NPInterface; +#endif + namespace WebCore { typedef HashMap<String, String> MIMEToDescriptionsMap; typedef HashMap<String, Vector<String> > MIMEToExtensionsMap; @@ -70,9 +75,17 @@ namespace WebCore { int compare(const PluginPackage&) const; PluginQuirkSet quirks() const { return m_quirks; } const PlatformModuleVersion& version() const { return m_moduleVersion; } +#if PLATFORM(SYMBIAN) + NPInterface* npInterface() const { return m_npInterface; } +#endif // PLATFORM(SYMBIAN) private: PluginPackage(const String& path, const time_t& lastModified); + +#if PLATFORM(SYMBIAN) + NPInterface* m_npInterface; + QPluginLoader* m_pluginLoader; +#endif // PLATFORM(SYMBIAN) bool fetchInfo(); bool isPluginBlacklisted(); void determineQuirks(const String& mimeType); diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginPackageNone.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginPackageNone.cpp index 487450a35a..b943d88af9 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginPackageNone.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/PluginPackageNone.cpp @@ -26,52 +26,20 @@ #include "config.h" #include "PluginPackage.h" -#include "CString.h" -#include "MIMETypeRegistry.h" -#include "NotImplemented.h" -#include "npruntime_impl.h" -#include "PluginDatabase.h" -#include "PluginDebug.h" - namespace WebCore { void PluginPackage::determineQuirks(const String&) { - notImplemented(); } bool PluginPackage::fetchInfo() { - notImplemented(); return false; } bool PluginPackage::load() { - notImplemented(); - return false; -} - -#if !ENABLE(PLUGIN_PACKAGE_SIMPLE_HASH) -unsigned PluginPackage::hash() const -{ - notImplemented(); - - return 0; -} - -bool PluginPackage::equal(const PluginPackage&, const PluginPackage&) -{ - notImplemented(); return false; } -int PluginPackage::compareFileVersion(const PlatformModuleVersion&) const -{ - notImplemented(); - return 0; -} - -#endif - } diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginQuirkSet.h b/src/3rdparty/webkit/WebCore/plugins/PluginQuirkSet.h index b652c6e328..de29baf8a1 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginQuirkSet.h +++ b/src/3rdparty/webkit/WebCore/plugins/PluginQuirkSet.h @@ -46,6 +46,7 @@ namespace WebCore { PluginQuirkDontSetNullWindowHandleOnDestroy = 1 << 10, PluginQuirkDontAllowMultipleInstances = 1 << 11, PluginQuirkRequiresGtkToolKit = 1 << 12, + PluginQuirkRequiresDefaultScreenDepth = 1 << 13 }; class PluginQuirkSet { diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginView.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginView.cpp index 28572a45cf..8320bc4867 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginView.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/PluginView.cpp @@ -53,6 +53,7 @@ #include "JSDOMBinding.h" #include "ScriptController.h" #include "ScriptValue.h" +#include "SecurityOrigin.h" #include "PluginDatabase.h" #include "PluginDebug.h" #include "PluginMainThreadScheduler.h" @@ -123,12 +124,12 @@ void PluginView::setFrameRect(const IntRect& rect) updatePluginWidget(); -#if PLATFORM(WIN_OS) - // On Windows, always call plugin to change geometry. +#if PLATFORM(WIN_OS) || PLATFORM(SYMBIAN) + // On Windows and Symbian, always call plugin to change geometry. setNPWindowRect(rect); #elif XP_UNIX - // On Unix, only call plugin if it's full-page. - if (m_mode == NP_FULL) + // On Unix, multiple calls to setNPWindow() in windowed mode causes Flash to crash + if (m_mode == NP_FULL || !m_isWindowed) setNPWindowRect(rect); #endif } @@ -147,6 +148,12 @@ void PluginView::handleEvent(Event* event) handleMouseEvent(static_cast<MouseEvent*>(event)); else if (event->isKeyboardEvent()) handleKeyboardEvent(static_cast<KeyboardEvent*>(event)); +#if defined(Q_WS_X11) && ENABLE(NETSCAPE_PLUGIN_API) + else if (event->type() == eventNames().DOMFocusOutEvent) + handleFocusOutEvent(); + else if (event->type() == eventNames().DOMFocusInEvent) + handleFocusInEvent(); +#endif } void PluginView::init() @@ -234,7 +241,13 @@ bool PluginView::start() if (!platformStart()) m_status = PluginStatusCanNotLoadPlugin; - return (m_status == PluginStatusLoadedSuccessfully); + if (m_status != PluginStatusLoadedSuccessfully) + return false; + + if (parentFrame()->page()) + parentFrame()->page()->didStartPlugin(this); + + return true; } PluginView::~PluginView() @@ -274,6 +287,9 @@ void PluginView::stop() if (!m_isStarted) return; + if (parentFrame()->page()) + parentFrame()->page()->didStopPlugin(this); + LOG(Plugins, "PluginView::stop(): Stopping plug-in '%s'", m_plugin->name().utf8().data()); HashSet<RefPtr<PluginStream> > streams = m_streams; @@ -434,7 +450,7 @@ void PluginView::performRequest(PluginRequest* request) // Executing a script can cause the plugin view to be destroyed, so we keep a reference to the parent frame. RefPtr<Frame> parentFrame = m_parentFrame; - JSValue result = m_parentFrame->loader()->executeScript(jsString, request->shouldAllowPopups()).jsValue(); + JSValue result = m_parentFrame->script()->executeScript(jsString, request->shouldAllowPopups()).jsValue(); if (targetFrameName.isNull()) { String resultString; @@ -501,9 +517,8 @@ NPError PluginView::load(const FrameLoadRequest& frameLoadRequest, bool sendNoti // 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; - } else if (!FrameLoader::canLoad(url, String(), m_parentFrame->document())) { + } else if (!SecurityOrigin::canLoad(url, String(), m_parentFrame->document())) return NPERR_GENERIC_ERROR; - } PluginRequest* request = new PluginRequest(frameLoadRequest, sendNotification, notifyData, arePopupsAllowed()); scheduleRequest(request); @@ -803,12 +818,18 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p , m_drawingModel(NPDrawingModel(-1)) , m_eventModel(NPEventModel(-1)) #endif -#if defined(Q_WS_X11) +#if defined(Q_WS_X11) && ENABLE(NETSCAPE_PLUGIN_API) , m_hasPendingGeometryChange(false) + , m_drawable(0) + , m_visual(0) + , m_colormap(0) + , m_pluginDisplay(0) #endif , m_loadManually(loadManually) , m_manualStream(0) , m_isJavaScriptPaused(false) + , m_isHalted(false) + , m_hasBeenHalted(false) { if (!m_plugin) { m_status = PluginStatusCanNotFindPlugin; @@ -1214,4 +1235,10 @@ const char* PluginView::userAgentStatic() } #endif + +Node* PluginView::node() const +{ + return m_element; +} + } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginView.h b/src/3rdparty/webkit/WebCore/plugins/PluginView.h index 54c10652ad..1477561aa8 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginView.h +++ b/src/3rdparty/webkit/WebCore/plugins/PluginView.h @@ -29,6 +29,7 @@ #include "CString.h" #include "FrameLoadRequest.h" +#include "HaltablePlugin.h" #include "IntRect.h" #include "KURL.h" #include "PlatformString.h" @@ -106,7 +107,7 @@ namespace WebCore { virtual void didFail(const ResourceError&) = 0; }; - class PluginView : public Widget, private PluginStreamClient, public PluginManualLoader { + class PluginView : public Widget, private PluginStreamClient, public PluginManualLoader, private HaltablePlugin { public: static PassRefPtr<PluginView> create(Frame* parentFrame, const IntSize&, Element*, const KURL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually); virtual ~PluginView(); @@ -193,6 +194,14 @@ namespace WebCore { void didFinishLoading(); void didFail(const ResourceError&); + // HaltablePlugin + virtual void halt(); + virtual void restart(); + virtual Node* node() const; + + bool isHalted() const { return m_isHalted; } + bool hasBeenHalted() const { return m_hasBeenHalted; } + static bool isCallingPlugin(); bool start(); @@ -249,6 +258,10 @@ namespace WebCore { void handleKeyboardEvent(KeyboardEvent*); void handleMouseEvent(MouseEvent*); +#if defined(Q_WS_X11) && ENABLE(NETSCAPE_PLUGIN_API) + void handleFocusInEvent(); + void handleFocusOutEvent(); +#endif int m_mode; int m_paramCount; @@ -295,12 +308,13 @@ public: void setPlatformPluginWidget(PlatformPluginWidget widget) { m_window = widget; } #else public: + void setPlatformPluginWidget(PlatformPluginWidget widget) { setPlatformWidget(widget); } PlatformPluginWidget platformPluginWidget() const { return platformWidget(); } #endif private: -#if defined(XP_UNIX) || defined(Q_WS_X11) +#if defined(XP_UNIX) || defined(Q_WS_X11) || PLATFORM(SYMBIAN) void setNPWindowIfNeeded(); #elif defined(XP_MACOSX) NP_CGContext m_npCgContext; @@ -313,8 +327,14 @@ private: Point globalMousePosForPlugin() const; #endif -#if defined(Q_WS_X11) +#if defined(Q_WS_X11) && ENABLE(NETSCAPE_PLUGIN_API) bool m_hasPendingGeometryChange; + Pixmap m_drawable; + Visual* m_visual; + Colormap m_colormap; + Display* m_pluginDisplay; + + void initXEvent(XEvent* event); #endif IntRect m_clipRect; // The clip rect to apply to a windowed plug-in @@ -325,6 +345,9 @@ private: bool m_isJavaScriptPaused; + bool m_isHalted; + bool m_hasBeenHalted; + static PluginView* s_currentPluginView; }; diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginViewNone.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginViewNone.cpp index b694214975..725af82e55 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginViewNone.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/PluginViewNone.cpp @@ -26,114 +26,98 @@ #include "config.h" #include "PluginView.h" -#include "NotImplemented.h" -#include "PluginPackage.h" - using namespace WTF; namespace WebCore { void PluginView::setFocus() { - notImplemented(); } void PluginView::show() { - notImplemented(); } void PluginView::hide() { - notImplemented(); } void PluginView::paint(GraphicsContext*, const IntRect&) { - notImplemented(); } void PluginView::handleKeyboardEvent(KeyboardEvent*) { - notImplemented(); } void PluginView::handleMouseEvent(MouseEvent*) { - notImplemented(); } void PluginView::setParent(ScrollView*) { - notImplemented(); } void PluginView::setNPWindowRect(const IntRect&) { - notImplemented(); } NPError PluginView::handlePostReadFile(Vector<char>&, uint32, const char*) { - notImplemented(); - return 0; } NPError PluginView::getValue(NPNVariable, void*) { - notImplemented(); return 0; } #if ENABLE(NETSCAPE_PLUGIN_API) NPError PluginView::getValueStatic(NPNVariable variable, void* value) { - notImplemented(); return 0; } #endif void PluginView::invalidateRect(NPRect*) { - notImplemented(); } void PluginView::invalidateRect(const IntRect&) { - notImplemented(); } void PluginView::invalidateRegion(NPRegion) { - notImplemented(); } void PluginView::forceRedraw() { - notImplemented(); } bool PluginView::platformStart() { - notImplemented(); - return true; } void PluginView::platformDestroy() { - notImplemented(); } void PluginView::setParentVisible(bool) { - notImplemented(); } void PluginView::updatePluginWidget() { - notImplemented(); +} + +void PluginView::halt() +{ +} + +void PluginView::restart() +{ } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/plugins/mac/PluginPackageMac.cpp b/src/3rdparty/webkit/WebCore/plugins/mac/PluginPackageMac.cpp index d242fb8707..325bc4d6cd 100644 --- a/src/3rdparty/webkit/WebCore/plugins/mac/PluginPackageMac.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/mac/PluginPackageMac.cpp @@ -159,7 +159,8 @@ bool PluginPackage::fetchInfo() plist = readPListFile(path.get(), /*createFile*/ true, m_module); } - mimeDict = (CFDictionaryRef)CFDictionaryGetValue(plist.get(), CFSTR("WebPluginMIMETypes")); + if (plist) + mimeDict = (CFDictionaryRef)CFDictionaryGetValue(plist.get(), CFSTR("WebPluginMIMETypes")); } if (!mimeDict) diff --git a/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp b/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp index 226aab698f..6521c84efc 100644 --- a/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp @@ -174,8 +174,8 @@ bool PluginView::platformStart() #if PLATFORM(QT) if (QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient()) { - if (QWidget* window = QWidget::find(client->winId())) { - setPlatformPluginWidget(window); + if (QWidget* widget = client->ownerWidget()) { + setPlatformPluginWidget(widget); } } #endif @@ -692,6 +692,14 @@ NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const c return NPERR_NO_ERROR; } +void PluginView::halt() +{ +} + +void PluginView::restart() +{ +} + } // namespace WebCore #else diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginContainerQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginContainerQt.cpp index 59ab5bc064..cb894a7bf6 100644 --- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginContainerQt.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginContainerQt.cpp @@ -73,6 +73,7 @@ PluginContainerQt::PluginContainerQt(PluginView* view, QWidget* parent) PluginContainerQt::~PluginContainerQt() { delete m_clientWrapper; + m_pluginView->setPlatformPluginWidget(0); } void PluginContainerQt::on_clientClosed() diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp index 7f5a7b9506..811992444c 100644 --- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp @@ -80,6 +80,16 @@ bool PluginPackage::fetchInfo() return true; } +static NPError staticPluginQuirkRequiresGtkToolKit_NPN_GetValue(NPP instance, NPNVariable variable, void* value) +{ + if (variable == NPNVToolkit) { + *static_cast<uint32*>(value) = 2; + return NPERR_NO_ERROR; + } + + return NPN_GetValue(instance, variable, value); +} + bool PluginPackage::load() { if (m_isLoaded) { @@ -111,6 +121,12 @@ bool PluginPackage::load() initializeBrowserFuncs(); + if (m_path.contains("npwrapper.")) { + // nspluginwrapper relies on the toolkit value to know if glib is available + // It does so in NP_Initialize with a null instance, therefore it is done this way: + m_browserFuncs.getvalue = staticPluginQuirkRequiresGtkToolKit_NPN_GetValue; + } + #if defined(XP_UNIX) npErr = NP_Initialize(&m_browserFuncs, &m_pluginFuncs); #else diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp index 908e7074c1..28637a11af 100644 --- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * Copyright (C) 2008 Collabora Ltd. All rights reserved. + * Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,6 +31,8 @@ #include "Document.h" #include "DocumentLoader.h" #include "Element.h" +#include "FloatPoint.h" +#include "FocusController.h" #include "Frame.h" #include "FrameLoadRequest.h" #include "FrameLoader.h" @@ -57,12 +60,20 @@ #include "runtime.h" #include "runtime_root.h" #include "QWebPageClient.h" +#include <QApplication> +#include <QDesktopWidget> #include <QKeyEvent> +#include <QPainter> #include <QWidget> #include <QX11Info> #include <runtime/JSLock.h> #include <runtime/JSValue.h> #include <X11/X.h> +#ifndef QT_NO_XRENDER +#define Bool int +#define Status int +#include <X11/extensions/Xrender.h> +#endif using JSC::ExecState; using JSC::Interpreter; @@ -80,7 +91,7 @@ using namespace HTMLNames; void PluginView::updatePluginWidget() { - if (!parent() || !m_isWindowed || !platformPluginWidget()) + if (!parent()) return; ASSERT(parent()->isFrameView()); @@ -96,6 +107,15 @@ void PluginView::updatePluginWidget() if (m_windowRect == oldWindowRect && m_clipRect == oldClipRect) return; + if (!m_isWindowed && m_windowRect.size() != oldWindowRect.size()) { + if (m_drawable) + XFreePixmap(QX11Info::display(), m_drawable); + + m_drawable = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), m_windowRect.width(), m_windowRect.height(), + ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth); + QApplication::syncX(); // make sure that the server knows about the Drawable + } + // do not call setNPWindowIfNeeded immediately, will be called on paint() m_hasPendingGeometryChange = true; @@ -150,8 +170,67 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) if (context->paintingDisabled()) return; - if (m_isWindowed && platformPluginWidget()) - setNPWindowIfNeeded(); + setNPWindowIfNeeded(); + + if (m_isWindowed || !m_drawable) + return; + + const bool syncX = m_pluginDisplay && m_pluginDisplay != QX11Info::display(); + + QPainter* painter = context->platformContext(); + + QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared); + const int drawableDepth = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth; + ASSERT(drawableDepth == qtDrawable.depth()); + + if (m_isTransparent && drawableDepth != 32) { + // Attempt content propagation for drawable with no alpha by copying over from the backing store + QPoint offset; + QPaintDevice* backingStoreDevice = QPainter::redirected(painter->device(), &offset); + offset = -offset; // negating the offset gives us the offset of the view within the backing store pixmap + + const bool hasValidBackingStore = backingStoreDevice && backingStoreDevice->devType() == QInternal::Pixmap; + QPixmap* backingStorePixmap = static_cast<QPixmap*>(backingStoreDevice); + + // We cannot grab contents from the backing store when painting on QGraphicsView items + // (because backing store contents are already transformed). What we really mean to do + // here is to check if we are painting on QWebView, but let's be a little permissive :) + QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); + const bool backingStoreHasUntransformedContents = client && qobject_cast<QWidget*>(client->pluginParent()); + + if (hasValidBackingStore && backingStorePixmap->depth() == drawableDepth + && backingStoreHasUntransformedContents) { + GC gc = XDefaultGC(QX11Info::display(), QX11Info::appScreen()); + XCopyArea(QX11Info::display(), backingStorePixmap->handle(), m_drawable, gc, + offset.x() + m_windowRect.x() + m_clipRect.x(), offset.y() + m_windowRect.y() + m_clipRect.y(), + m_clipRect.width(), m_clipRect.height(), m_clipRect.x(), m_clipRect.y()); + } else { // no backing store, clean the pixmap because the plugin thinks its transparent + QPainter painter(&qtDrawable); + painter.fillRect(m_clipRect, Qt::white); + } + + if (syncX) + QApplication::syncX(); + } + + XEvent xevent; + memset(&xevent, 0, sizeof(XEvent)); + XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose; + exposeEvent.type = GraphicsExpose; + exposeEvent.display = QX11Info::display(); + exposeEvent.drawable = m_drawable; + exposeEvent.x = m_clipRect.x(); + exposeEvent.y = m_clipRect.y(); + exposeEvent.width = m_clipRect.x() + m_clipRect.width(); // flash bug? it thinks width is the right + exposeEvent.height = m_clipRect.y() + m_clipRect.height(); // flash bug? it thinks height is the bottom + + dispatchNPEvent(xevent); + + if (syncX) + XSync(m_pluginDisplay, False); // sync changes by plugin + + painter->drawPixmap(frameRect().x() + m_clipRect.x(), frameRect().y() + m_clipRect.y(), qtDrawable, + m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height()); } // TODO: Unify across ports. @@ -161,45 +240,55 @@ bool PluginView::dispatchNPEvent(NPEvent& event) return false; PluginView::setCurrentPluginView(this); - JSC::JSLock::DropAllLocks dropAllLocks(false); - + JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); setCallingPlugin(true); - bool accepted = m_plugin->pluginFuncs(); + bool accepted = m_plugin->pluginFuncs()->event(m_instance, &event); setCallingPlugin(false); + PluginView::setCurrentPluginView(0); return accepted; } -void setSharedXEventFields(XEvent& xEvent, QWidget* hostWindow) +void setSharedXEventFields(XEvent* xEvent, QWidget* ownerWidget) { - xEvent.xany.serial = 0; // we are unaware of the last request processed by X Server - xEvent.xany.send_event = false; - xEvent.xany.display = hostWindow->x11Info().display(); - // NOTE: event.xany.window doesn't always respond to the .window property of other XEvent's + xEvent->xany.serial = 0; // we are unaware of the last request processed by X Server + xEvent->xany.send_event = false; + xEvent->xany.display = QX11Info::display(); + // NOTE: event->xany.window doesn't always respond to the .window property of other XEvent's // but does in the case of KeyPress, KeyRelease, ButtonPress, ButtonRelease, and MotionNotify // events; thus, this is right: - xEvent.xany.window = hostWindow->window()->handle(); + xEvent->xany.window = ownerWidget ? ownerWidget->window()->handle() : 0; } -void setXKeyEventSpecificFields(XEvent& xEvent, KeyboardEvent* event) +void PluginView::initXEvent(XEvent* xEvent) +{ + memset(xEvent, 0, sizeof(XEvent)); + + QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); + QWidget* ownerWidget = client ? client->ownerWidget() : 0; + setSharedXEventFields(xEvent, ownerWidget); +} + +void setXKeyEventSpecificFields(XEvent* xEvent, KeyboardEvent* event) { QKeyEvent* qKeyEvent = event->keyEvent()->qtEvent(); - xEvent.xkey.root = QX11Info::appRootWindow(); - xEvent.xkey.subwindow = 0; // we have no child window - xEvent.xkey.time = event->timeStamp(); - xEvent.xkey.state = qKeyEvent->nativeModifiers(); - xEvent.xkey.keycode = qKeyEvent->nativeScanCode(); - xEvent.xkey.same_screen = true; + xEvent->type = (event->type() == eventNames().keydownEvent) ? 2 : 3; // ints as Qt unsets KeyPress and KeyRelease + xEvent->xkey.root = QX11Info::appRootWindow(); + xEvent->xkey.subwindow = 0; // we have no child window + xEvent->xkey.time = event->timeStamp(); + xEvent->xkey.state = qKeyEvent->nativeModifiers(); + xEvent->xkey.keycode = qKeyEvent->nativeScanCode(); + xEvent->xkey.same_screen = true; // NOTE: As the XEvents sent to the plug-in are synthesized and there is not a native window // corresponding to the plug-in rectangle, some of the members of the XEvent structures are not // set to their normal Xserver values. e.g. Key events don't have a position. // source: https://developer.mozilla.org/en/NPEvent - xEvent.xkey.x = 0; - xEvent.xkey.y = 0; - xEvent.xkey.x_root = 0; - xEvent.xkey.y_root = 0; + xEvent->xkey.x = 0; + xEvent->xkey.y = 0; + xEvent->xkey.x_root = 0; + xEvent->xkey.y_root = 0; } void PluginView::handleKeyboardEvent(KeyboardEvent* event) @@ -207,25 +296,147 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event) if (m_isWindowed) return; - if (event->type() != "keydown" && event->type() != "keyup") + if (event->type() != eventNames().keydownEvent && event->type() != eventNames().keyupEvent) return; - XEvent npEvent; // On UNIX NPEvent is a typedef for XEvent. - - npEvent.type = (event->type() == "keydown") ? 2 : 3; // ints as Qt unsets KeyPress and KeyRelease - QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); - QWidget* window = QWidget::find(client->winId()); - setSharedXEventFields(npEvent, window); - setXKeyEventSpecificFields(npEvent, event); + XEvent npEvent; + initXEvent(&npEvent); + setXKeyEventSpecificFields(&npEvent, event); if (!dispatchNPEvent(npEvent)) event->setDefaultHandled(); } +static unsigned int inputEventState(MouseEvent* event) +{ + unsigned int state = 0; + if (event->ctrlKey()) + state |= ControlMask; + if (event->shiftKey()) + state |= ShiftMask; + if (event->altKey()) + state |= Mod1Mask; + if (event->metaKey()) + state |= Mod4Mask; + return state; +} + +static void setXButtonEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos) +{ + XButtonEvent& xbutton = xEvent->xbutton; + xbutton.type = event->type() == eventNames().mousedownEvent ? ButtonPress : ButtonRelease; + xbutton.root = QX11Info::appRootWindow(); + xbutton.subwindow = 0; + xbutton.time = event->timeStamp(); + xbutton.x = postZoomPos.x(); + xbutton.y = postZoomPos.y(); + xbutton.x_root = event->screenX(); + xbutton.y_root = event->screenY(); + xbutton.state = inputEventState(event); + switch (event->button()) { + case MiddleButton: + xbutton.button = Button2; + break; + case RightButton: + xbutton.button = Button3; + break; + case LeftButton: + default: + xbutton.button = Button1; + break; + } + xbutton.same_screen = true; +} + +static void setXMotionEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos) +{ + XMotionEvent& xmotion = xEvent->xmotion; + xmotion.type = MotionNotify; + xmotion.root = QX11Info::appRootWindow(); + xmotion.subwindow = 0; + xmotion.time = event->timeStamp(); + xmotion.x = postZoomPos.x(); + xmotion.y = postZoomPos.y(); + xmotion.x_root = event->screenX(); + xmotion.y_root = event->screenY(); + xmotion.state = inputEventState(event); + xmotion.is_hint = NotifyNormal; + xmotion.same_screen = true; +} + +static void setXCrossingEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos) +{ + XCrossingEvent& xcrossing = xEvent->xcrossing; + xcrossing.type = event->type() == eventNames().mouseoverEvent ? EnterNotify : LeaveNotify; + xcrossing.root = QX11Info::appRootWindow(); + xcrossing.subwindow = 0; + xcrossing.time = event->timeStamp(); + xcrossing.x = postZoomPos.y(); + xcrossing.y = postZoomPos.x(); + xcrossing.x_root = event->screenX(); + xcrossing.y_root = event->screenY(); + xcrossing.state = inputEventState(event); + xcrossing.mode = NotifyNormal; + xcrossing.detail = NotifyDetailNone; + xcrossing.same_screen = true; + xcrossing.focus = false; +} + 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(); + } + + XEvent npEvent; + initXEvent(&npEvent); + + IntPoint postZoomPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(event->absoluteLocation())); + + if (event->type() == eventNames().mousedownEvent || event->type() == eventNames().mouseupEvent) + setXButtonEventSpecificFields(&npEvent, event, postZoomPos); + else if (event->type() == eventNames().mousemoveEvent) + setXMotionEventSpecificFields(&npEvent, event, postZoomPos); + else if (event->type() == eventNames().mouseoutEvent || event->type() == eventNames().mouseoverEvent) + setXCrossingEventSpecificFields(&npEvent, event, postZoomPos); + else + return; + + if (!dispatchNPEvent(npEvent)) + event->setDefaultHandled(); +} + +void PluginView::handleFocusInEvent() +{ + XEvent npEvent; + initXEvent(&npEvent); + + XFocusChangeEvent& event = npEvent.xfocus; + event.type = 9; /* int as Qt unsets FocusIn */ + event.mode = NotifyNormal; + event.detail = NotifyDetailNone; + + dispatchNPEvent(npEvent); +} + +void PluginView::handleFocusOutEvent() +{ + XEvent npEvent; + initXEvent(&npEvent); + + XFocusChangeEvent& event = npEvent.xfocus; + event.type = 10; /* int as Qt unsets FocusOut */ + event.mode = NotifyNormal; + event.detail = NotifyDetailNone; + + dispatchNPEvent(npEvent); } void PluginView::setParent(ScrollView* parent) @@ -238,7 +449,8 @@ void PluginView::setParent(ScrollView* parent) void PluginView::setNPWindowRect(const IntRect&) { - // Ignored as we don't want to move immediately. + if (!m_isWindowed) + setNPWindowIfNeeded(); } void PluginView::setNPWindowIfNeeded() @@ -246,36 +458,53 @@ void PluginView::setNPWindowIfNeeded() if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow) return; + // If the plugin didn't load sucessfully, no point in calling setwindow + if (m_status != PluginStatusLoadedSuccessfully) + return; + // On Unix, only call plugin if it's full-page or windowed if (m_mode != NP_FULL && m_mode != NP_EMBED) return; + // Check if the platformPluginWidget still exists + if (m_isWindowed && !platformPluginWidget()) + return; + if (!m_hasPendingGeometryChange) return; m_hasPendingGeometryChange = false; - 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)); + if (m_isWindowed) { + 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 { + m_npWindow.x = 0; + m_npWindow.y = 0; + + m_npWindow.clipRect.left = 0; + m_npWindow.clipRect.top = 0; + m_npWindow.clipRect.right = 0; + m_npWindow.clipRect.bottom = 0; + } // FLASH WORKAROUND: Only set initially. Multiple calls to - // setNPWindow() cause the plugin to crash. - if (m_npWindow.width == -1 || m_npWindow.height == -1) { + // setNPWindow() cause the plugin to crash in windowed mode. + if (!m_isWindowed || m_npWindow.width == -1 || m_npWindow.height == -1) { m_npWindow.width = m_windowRect.width(); m_npWindow.height = m_windowRect.height(); } - 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(); - PluginView::setCurrentPluginView(this); JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); setCallingPlugin(true); @@ -340,6 +569,10 @@ NPError PluginView::getValueStatic(NPNVariable variable, void* value) *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; } @@ -351,13 +584,7 @@ NPError PluginView::getValue(NPNVariable variable, void* value) switch (variable) { case NPNVxDisplay: - if (platformPluginWidget()) - *(void **)value = platformPluginWidget()->x11Info().display(); - else { - QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); - QWidget* window = QWidget::find(client->winId()); - *(void **)value = window->x11Info().display(); - } + *(void **)value = QX11Info::display(); return NPERR_NO_ERROR; case NPNVxtAppContext: @@ -402,7 +629,8 @@ NPError PluginView::getValue(NPNVariable variable, void* value) case NPNVnetscapeWindow: { void* w = reinterpret_cast<void*>(value); - *((XID *)w) = m_parentFrame->view()->hostWindow()->platformPageClient()->winId(); + QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); + *((XID *)w) = client ? client->ownerWidget()->winId() : 0; return NPERR_NO_ERROR; } @@ -419,7 +647,7 @@ NPError PluginView::getValue(NPNVariable variable, void* value) void PluginView::invalidateRect(const IntRect& rect) { - if (platformWidget()) { + if (m_isWindowed) { platformWidget()->update(rect); return; } @@ -429,17 +657,88 @@ void PluginView::invalidateRect(const IntRect& rect) void PluginView::invalidateRect(NPRect* rect) { - notImplemented(); + if (!rect) { + invalidate(); + return; + } + IntRect r(rect->left, rect->top, rect->right + rect->left, rect->bottom + rect->top); + invalidateWindowlessPluginRect(r); } void PluginView::invalidateRegion(NPRegion region) { - notImplemented(); + invalidate(); } void PluginView::forceRedraw() { - notImplemented(); + invalidate(); +} + +static Display *getPluginDisplay() +{ + // The plugin toolkit might run using a different X connection. At the moment, we only + // support gdk based plugins (like flash) that use a different X connection. + // The code below has the same effect as this one: + // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default()); + QLibrary library("libgdk-x11-2.0"); + if (!library.load()) + return 0; + + typedef void *(*gdk_display_get_default_ptr)(); + gdk_display_get_default_ptr gdk_display_get_default = (gdk_display_get_default_ptr)library.resolve("gdk_display_get_default"); + if (!gdk_display_get_default) + return 0; + + typedef void *(*gdk_x11_display_get_xdisplay_ptr)(void *); + gdk_x11_display_get_xdisplay_ptr gdk_x11_display_get_xdisplay = (gdk_x11_display_get_xdisplay_ptr)library.resolve("gdk_x11_display_get_xdisplay"); + if (!gdk_x11_display_get_xdisplay) + return 0; + + return (Display*)gdk_x11_display_get_xdisplay(gdk_display_get_default()); +} + +static void getVisualAndColormap(int depth, Visual **visual, Colormap *colormap) +{ + *visual = 0; + *colormap = 0; + +#ifndef QT_NO_XRENDER + static const bool useXRender = qgetenv("QT_X11_NO_XRENDER").isNull(); // Should also check for XRender >= 0.5 +#else + static const bool useXRender = false; +#endif + + if (!useXRender && depth == 32) + return; + + int nvi; + XVisualInfo templ; + templ.screen = QX11Info::appScreen(); + templ.depth = depth; + templ.c_class = TrueColor; + XVisualInfo* xvi = XGetVisualInfo(QX11Info::display(), VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi); + + if (!xvi) + return; + +#ifndef QT_NO_XRENDER + if (depth == 32) { + for (int idx = 0; idx < nvi; ++idx) { + XRenderPictFormat* format = XRenderFindVisualFormat(QX11Info::display(), xvi[idx].visual); + if (format->type == PictTypeDirect && format->direct.alphaMask) { + *visual = xvi[idx].visual; + break; + } + } + } else +#endif // QT_NO_XRENDER + *visual = xvi[0].visual; + + XFree(xvi); + + if (*visual) + *colormap = XCreateColormap(QX11Info::display(), QX11Info::appRootWindow(), *visual, AllocNone); } bool PluginView::platformStart() @@ -456,30 +755,65 @@ bool PluginView::platformStart() PluginView::setCurrentPluginView(0); } - if (m_needsXEmbed) { + if (m_isWindowed) { QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); - setPlatformWidget(new PluginContainerQt(this, QWidget::find(client->winId()))); + if (m_needsXEmbed && client) { + setPlatformWidget(new PluginContainerQt(this, client->ownerWidget())); + // sync our XEmbed container window creation before sending the xid to plugins. + QApplication::syncX(); + } else { + notImplemented(); + m_status = PluginStatusCanNotLoadPlugin; + return false; + } } else { - notImplemented(); - return false; + setPlatformWidget(0); + m_pluginDisplay = getPluginDisplay(); } show(); - NPSetWindowCallbackStruct *wsi = new NPSetWindowCallbackStruct(); - + NPSetWindowCallbackStruct* wsi = new NPSetWindowCallbackStruct(); wsi->type = 0; - wsi->display = platformPluginWidget()->x11Info().display(); - wsi->visual = (Visual*)platformPluginWidget()->x11Info().visual(); - wsi->depth = platformPluginWidget()->x11Info().depth(); - wsi->colormap = platformPluginWidget()->x11Info().colormap(); - m_npWindow.ws_info = wsi; + if (m_isWindowed) { + const QX11Info* x11Info = &platformPluginWidget()->x11Info(); + + wsi->display = x11Info->display(); + wsi->visual = (Visual*)x11Info->visual(); + wsi->depth = x11Info->depth(); + wsi->colormap = x11Info->colormap(); + + m_npWindow.type = NPWindowTypeWindow; + m_npWindow.window = (void*)platformPluginWidget()->winId(); + m_npWindow.width = -1; + m_npWindow.height = -1; + } else { + const QX11Info* x11Info = &QApplication::desktop()->x11Info(); + + if (x11Info->depth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth)) { + getVisualAndColormap(32, &m_visual, &m_colormap); + wsi->depth = 32; + } + + if (!m_visual) { + getVisualAndColormap(x11Info->depth(), &m_visual, &m_colormap); + wsi->depth = x11Info->depth(); + } + + wsi->display = x11Info->display(); + wsi->visual = m_visual; + wsi->colormap = m_colormap; - m_npWindow.type = NPWindowTypeWindow; - m_npWindow.window = (void*)platformPluginWidget()->winId(); - m_npWindow.width = -1; - m_npWindow.height = -1; + m_npWindow.type = NPWindowTypeDrawable; + m_npWindow.window = 0; // Not used? + m_npWindow.x = 0; + m_npWindow.y = 0; + m_npWindow.width = -1; + m_npWindow.height = -1; + } + + m_npWindow.ws_info = wsi; if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) { updatePluginWidget(); @@ -493,6 +827,20 @@ void PluginView::platformDestroy() { if (platformPluginWidget()) delete platformPluginWidget(); + + if (m_drawable) + XFreePixmap(QX11Info::display(), m_drawable); + + if (m_colormap) + XFreeColormap(QX11Info::display(), m_colormap); +} + +void PluginView::halt() +{ +} + +void PluginView::restart() +{ } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/plugins/symbian/PluginContainerSymbian.cpp b/src/3rdparty/webkit/WebCore/plugins/symbian/PluginContainerSymbian.cpp new file mode 100644 index 0000000000..aece0e48b4 --- /dev/null +++ b/src/3rdparty/webkit/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/src/3rdparty/webkit/WebCore/plugins/symbian/PluginContainerSymbian.h b/src/3rdparty/webkit/WebCore/plugins/symbian/PluginContainerSymbian.h new file mode 100644 index 0000000000..fce4a7160a --- /dev/null +++ b/src/3rdparty/webkit/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/src/3rdparty/webkit/WebCore/plugins/symbian/PluginDatabaseSymbian.cpp b/src/3rdparty/webkit/WebCore/plugins/symbian/PluginDatabaseSymbian.cpp new file mode 100644 index 0000000000..2e092966eb --- /dev/null +++ b/src/3rdparty/webkit/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/src/3rdparty/webkit/WebCore/plugins/symbian/PluginPackageSymbian.cpp b/src/3rdparty/webkit/WebCore/plugins/symbian/PluginPackageSymbian.cpp new file mode 100644 index 0000000000..d5c7533f63 --- /dev/null +++ b/src/3rdparty/webkit/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/src/3rdparty/webkit/WebCore/plugins/symbian/PluginViewSymbian.cpp b/src/3rdparty/webkit/WebCore/plugins/symbian/PluginViewSymbian.cpp new file mode 100644 index 0000000000..14e25b1d1c --- /dev/null +++ b/src/3rdparty/webkit/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/src/3rdparty/webkit/WebCore/plugins/symbian/npinterface.h b/src/3rdparty/webkit/WebCore/plugins/symbian/npinterface.h new file mode 100644 index 0000000000..0f0b6ca220 --- /dev/null +++ b/src/3rdparty/webkit/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 diff --git a/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp b/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp index 21ac2a4e61..e1bf8d62ab 100644 --- a/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp @@ -29,6 +29,7 @@ #include "PluginView.h" +#include "BitmapImage.h" #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -52,6 +53,7 @@ #include "PluginMessageThrottlerWin.h" #include "PluginPackage.h" #include "PluginMainThreadScheduler.h" +#include "RenderWidget.h" #include "JSDOMBinding.h" #include "ScriptController.h" #include "PluginDatabase.h" @@ -75,6 +77,7 @@ #if PLATFORM(QT) #include "QWebPageClient.h" +#include <QWidget> #endif static inline HWND windowHandleForPageClient(PlatformPageClient client) @@ -82,7 +85,7 @@ static inline HWND windowHandleForPageClient(PlatformPageClient client) #if PLATFORM(QT) if (!client) return 0; - return client->winId(); + return client->ownerWidget()->winId(); #else return client; #endif @@ -1008,8 +1011,42 @@ bool PluginView::platformStart() void PluginView::platformDestroy() { - if (platformPluginWidget()) - DestroyWindow(platformPluginWidget()); + if (!platformPluginWidget()) + return; + + DestroyWindow(platformPluginWidget()); + setPlatformPluginWidget(0); +} + +void PluginView::halt() +{ + ASSERT(!m_isHalted); + ASSERT(m_isStarted); + +#if !PLATFORM(QT) + // Show a screenshot of the plug-in. + OwnPtr<HBITMAP> nodeImage(m_parentFrame->nodeImage(m_element)); + toRenderWidget(m_element->renderer())->showSubstituteImage(BitmapImage::create(nodeImage.get())); +#endif + + m_isHalted = true; + m_hasBeenHalted = true; + + stop(); + platformDestroy(); +} + +void PluginView::restart() +{ + ASSERT(!m_isStarted); + ASSERT(m_isHalted); + + // Clear any substitute image. + toRenderWidget(m_element->renderer())->showSubstituteImage(0); + + m_isHalted = false; + m_haveUpdatedPluginWidget = false; + start(); } } // namespace WebCore |