diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/plugins')
17 files changed, 869 insertions, 285 deletions
diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginDataNone.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginDataNone.cpp new file mode 100644 index 0000000000..28e39673e0 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/plugins/PluginDataNone.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com> All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#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/PluginPackage.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginPackage.cpp index 1c684b93df..8adba98363 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginPackage.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/PluginPackage.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. * Copyright (C) 2008 Collabora Ltd. All rights reserved. + * Copyright (C) 2009 Holger Hans Peter Freyther * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -91,7 +92,8 @@ int PluginPackage::compare(const PluginPackage& compareTo) const if (diff) return diff; - if (diff = compareFileVersion(compareTo.version())) + diff = compareFileVersion(compareTo.version()); + if (diff) return diff; return strcmp(parentDirectory().utf8().data(), compareTo.parentDirectory().utf8().data()); @@ -237,4 +239,86 @@ void PluginPackage::determineModuleVersionFromDescription() } #endif +#if ENABLE(NETSCAPE_PLUGIN_API) +void PluginPackage::initializeBrowserFuncs() +{ + memset(&m_browserFuncs, 0, sizeof(m_browserFuncs)); + 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.pluginthreadasynccall = NPN_PluginThreadAsyncCall; + + 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.intfromidentifier = _NPN_IntFromIdentifier; + 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_HasProperty; + m_browserFuncs.hasmethod = _NPN_HasMethod; + m_browserFuncs.setexception = _NPN_SetException; + m_browserFuncs.enumerate = _NPN_Enumerate; + m_browserFuncs.construct = _NPN_Construct; +} +#endif + +#if ENABLE(PLUGIN_PACKAGE_SIMPLE_HASH) +unsigned PluginPackage::hash() const +{ + unsigned hashCodes[] = { + m_path.impl()->hash(), + m_lastModified + }; + + return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar)); +} + +bool PluginPackage::equal(const PluginPackage& a, const PluginPackage& b) +{ + return a.m_description == b.m_description; +} + +int PluginPackage::compareFileVersion(const PlatformModuleVersion& compareVersion) const +{ + // return -1, 0, or 1 if plug-in version is less than, equal to, or greater than + // the passed version + if (m_moduleVersion != compareVersion) + return m_moduleVersion > compareVersion ? 1 : -1; + return 0; +} +#endif + } diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginPackage.h b/src/3rdparty/webkit/WebCore/plugins/PluginPackage.h index 707eb25dbf..02d0dfce54 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginPackage.h +++ b/src/3rdparty/webkit/WebCore/plugins/PluginPackage.h @@ -75,6 +75,7 @@ namespace WebCore { void determineQuirks(const String& mimeType); void determineModuleVersionFromDescription(); + void initializeBrowserFuncs(); bool m_isLoaded; int m_loadCount; diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginPackageNone.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginPackageNone.cpp new file mode 100644 index 0000000000..487450a35a --- /dev/null +++ b/src/3rdparty/webkit/WebCore/plugins/PluginPackageNone.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com> All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#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/PluginStream.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginStream.cpp index 2cf2accdd2..d2d5d3c0a7 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginStream.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/PluginStream.cpp @@ -130,20 +130,20 @@ void PluginStream::startStream() // Some plugins (Flash) expect that javascript URLs are passed back decoded as this is the // format used when requesting the URL. - if (responseURL.protocolIs("javascript")) + if (protocolIsJavaScript(responseURL)) m_stream.url = strdup(decodeURLEscapeSequences(responseURL.string()).utf8().data()); else m_stream.url = strdup(responseURL.string().utf8().data()); - + CString mimeTypeStr = m_resourceResponse.mimeType().utf8(); - + long long expectedContentLength = m_resourceResponse.expectedContentLength(); if (m_resourceResponse.isHTTP()) { Vector<UChar> stringBuilder; String separator(": "); - String statusLine = String::format("HTTP %lu OK\n", m_resourceResponse.httpStatusCode()); + String statusLine = String::format("HTTP %d OK\n", m_resourceResponse.httpStatusCode()); stringBuilder.append(statusLine.characters(), statusLine.length()); diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginView.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginView.cpp index 61d31577ff..2c5adc5e0b 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginView.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/PluginView.cpp @@ -57,6 +57,7 @@ #include "PluginDebug.h" #include "PluginMainThreadScheduler.h" #include "PluginPackage.h" +#include "RenderBox.h" #include "RenderObject.h" #include "c_instance.h" #include "npruntime_impl.h" @@ -71,7 +72,6 @@ using JSC::ExecState; using JSC::JSLock; using JSC::JSObject; using JSC::JSValue; -using JSC::JSValuePtr; using JSC::UString; using std::min; @@ -86,7 +86,7 @@ static int s_callingPlugin; static String scriptStringIfJavaScriptURL(const KURL& url) { - if (!url.protocolIs("javascript")) + if (!protocolIsJavaScript(url)) return String(); // This returns an unescaped string @@ -205,14 +205,14 @@ static char* createUTF8String(const String& str) return result; } -static bool getString(ScriptController* proxy, JSValuePtr result, String& string) +static bool getString(ScriptController* proxy, JSValue result, String& string) { - if (!proxy || !result || result->isUndefined()) + if (!proxy || !result || result.isUndefined()) return false; JSLock lock(false); ExecState* exec = proxy->globalObject()->globalExec(); - UString ustring = result->toString(exec); + UString ustring = result.toString(exec); exec->clearException(); string = ustring; @@ -239,7 +239,7 @@ void PluginView::performRequest(PluginRequest* request) m_streams.add(stream); stream->start(); } else { - m_parentFrame->loader()->load(request->frameLoadRequest().resourceRequest(), targetFrameName); + m_parentFrame->loader()->load(request->frameLoadRequest().resourceRequest(), targetFrameName, false); // FIXME: <rdar://problem/4807469> This should be sent when the document has finished loading if (request->sendNotification()) { @@ -260,7 +260,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; - JSValuePtr result = m_parentFrame->loader()->executeScript(jsString, request->shouldAllowPopups()).jsValue(); + JSValue result = m_parentFrame->loader()->executeScript(jsString, request->shouldAllowPopups()).jsValue(); if (targetFrameName.isNull()) { String resultString; @@ -397,12 +397,12 @@ int32 PluginView::write(NPStream* stream, int32 len, void* buffer) NPError PluginView::destroyStream(NPStream* stream, NPReason reason) { - PluginStream* browserStream = static_cast<PluginStream*>(stream->ndata); - if (!stream || PluginStream::ownerForStream(stream) != m_instance) return NPERR_INVALID_INSTANCE_ERROR; + PluginStream* browserStream = static_cast<PluginStream*>(stream->ndata); browserStream->cancelAndDestroyStream(reason); + return NPERR_NO_ERROR; } @@ -563,6 +563,7 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p , m_pluginWndProc(0) , m_lastMessage(0) , m_isCallingPluginWndProc(false) + , m_wmPrintHDC(0) #endif #if (PLATFORM(QT) && PLATFORM(WIN_OS)) || defined(XP_MACOSX) , m_window(0) @@ -593,6 +594,14 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p resize(size); } +void PluginView::focusPluginElement() +{ + // Focus the plugin + if (Page* page = m_parentFrame->page()) + page->focusController()->setFocusedFrame(m_parentFrame); + m_parentFrame->document()->setFocusedNode(m_element); +} + void PluginView::didReceiveResponse(const ResourceResponse& response) { if (m_status != PluginStatusLoadedSuccessfully) @@ -904,9 +913,9 @@ void PluginView::invalidateWindowlessPluginRect(const IntRect& rect) if (!isVisible()) return; - RenderObject* renderer = m_element->renderer(); - if (!renderer) + if (!m_element->renderer()) return; + RenderBox* renderer = toRenderBox(m_element->renderer()); IntRect dirtyRect = rect; dirtyRect.move(renderer->borderLeft() + renderer->paddingLeft(), renderer->borderTop() + renderer->paddingTop()); diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginView.h b/src/3rdparty/webkit/WebCore/plugins/PluginView.h index 44f2146c33..41d986be70 100644 --- a/src/3rdparty/webkit/WebCore/plugins/PluginView.h +++ b/src/3rdparty/webkit/WebCore/plugins/PluginView.h @@ -173,6 +173,10 @@ namespace WebCore { virtual bool isPluginView() const { return true; } + Frame* parentFrame() const { return m_parentFrame; } + + void focusPluginElement(); + #if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API) static LRESULT CALLBACK PluginViewWndProc(HWND, UINT, WPARAM, LPARAM); LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); @@ -202,7 +206,13 @@ namespace WebCore { void setCallingPlugin(bool) const; void invalidateWindowlessPluginRect(const IntRect&); - + +#if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API) + void paintWindowedPluginIntoContext(GraphicsContext*, const IntRect&) const; + static HDC WINAPI hookedBeginPaint(HWND, PAINTSTRUCT*); + static BOOL WINAPI hookedEndPaint(HWND, const PAINTSTRUCT*); +#endif + Frame* m_parentFrame; RefPtr<PluginPackage> m_plugin; Element* m_element; @@ -238,7 +248,7 @@ namespace WebCore { CString m_mimeType; CString m_userAgent; - + NPP m_instance; NPP_t m_instanceStruct; NPWindow m_npWindow; @@ -261,6 +271,7 @@ namespace WebCore { WNDPROC m_pluginWndProc; unsigned m_lastMessage; bool m_isCallingPluginWndProc; + HDC m_wmPrintHDC; #endif #if (PLATFORM(QT) && PLATFORM(WIN_OS)) || defined(XP_MACOSX) @@ -277,7 +288,9 @@ public: private: -#if defined(XP_MACOSX) +#if PLATFORM(GTK) || defined(Q_WS_X11) + void setNPWindowIfNeeded(); +#elif defined(XP_MACOSX) NP_CGContext m_npCgContext; OwnPtr<Timer<PluginView> > m_nullEventTimer; @@ -286,6 +299,10 @@ private: Point globalMousePosForPlugin() const; #endif +#if defined(Q_WS_X11) + bool m_hasPendingGeometryChange; +#endif + IntRect m_clipRect; // The clip rect to apply to a windowed plug-in IntRect m_windowRect; // Our window rect. @@ -299,4 +316,4 @@ private: } // namespace WebCore -#endif +#endif diff --git a/src/3rdparty/webkit/WebCore/plugins/PluginViewNone.cpp b/src/3rdparty/webkit/WebCore/plugins/PluginViewNone.cpp new file mode 100644 index 0000000000..a3b6a178b0 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/plugins/PluginViewNone.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com> All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#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(); +} + +void PluginView::stop() +{ + notImplemented(); +} + +const char* PluginView::userAgent() +{ + notImplemented(); + return 0; +} + +#if ENABLE(NETSCAPE_PLUGIN_API) +const char* PluginView::userAgentStatic() +{ + notImplemented(); + return 0; +} +#endif + +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(); +} + +PluginView::~PluginView() +{ + notImplemented(); +} + +void PluginView::init() +{ + notImplemented(); +} + +void PluginView::setParentVisible(bool) +{ + notImplemented(); +} + +void PluginView::updatePluginWidget() +{ + notImplemented(); +} + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/plugins/mac/PluginPackageMac.cpp b/src/3rdparty/webkit/WebCore/plugins/mac/PluginPackageMac.cpp index 0af94b03df..18be90e7d0 100644 --- a/src/3rdparty/webkit/WebCore/plugins/mac/PluginPackageMac.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/mac/PluginPackageMac.cpp @@ -33,7 +33,6 @@ #include <wtf/RetainPtr.h> #include "CString.h" #include "MIMETypeRegistry.h" -#include "NotImplemented.h" #include "npruntime_impl.h" #include "PluginDatabase.h" #include "PluginDebug.h" @@ -285,51 +284,7 @@ bool PluginPackage::load() 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; + initializeBrowserFuncs(); npErr = NP_Initialize(&m_browserFuncs); LOG_NPERROR(npErr); @@ -349,30 +304,10 @@ abort: return false; } -unsigned PluginPackage::hash() const -{ - unsigned hashCodes[2] = { - m_path.impl()->hash(), - m_lastModified - }; - - return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), 2 * sizeof(unsigned) / sizeof(UChar)); -} - -bool PluginPackage::equal(const PluginPackage& a, const PluginPackage& b) -{ - return a.m_description == b.m_description; -} +} // namespace WebCore -int PluginPackage::compareFileVersion(const PlatformModuleVersion& compareVersion) const -{ - // return -1, 0, or 1 if plug-in version is less than, equal to, or greater than - // the passed version - if (m_moduleVersion != compareVersion) - return m_moduleVersion > compareVersion ? 1 : -1; - return 0; -} +#else -} // namespace WebCore +#include "../PluginPackageNone.cpp" #endif // !__LP64__ diff --git a/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp b/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp index 3229922550..5691c9c0b0 100644 --- a/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/mac/PluginViewMac.cpp @@ -76,7 +76,11 @@ using JSC::UString; #include <QWidget> #include <QKeyEvent> QT_BEGIN_NAMESPACE -extern Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget *w); +#if QT_VERSION < 0x040500 +extern Q_GUI_EXPORT WindowPtr qt_mac_window_for(const QWidget* w); +#else +extern Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget* w); +#endif QT_END_NAMESPACE #endif @@ -692,4 +696,8 @@ NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const c } // namespace WebCore +#else + +#include "../PluginViewNone.cpp" + #endif // !__LP64__ diff --git a/src/3rdparty/webkit/WebCore/plugins/npfunctions.h b/src/3rdparty/webkit/WebCore/plugins/npfunctions.h index 509430f72f..e28bf5eec9 100644 --- a/src/3rdparty/webkit/WebCore/plugins/npfunctions.h +++ b/src/3rdparty/webkit/WebCore/plugins/npfunctions.h @@ -63,9 +63,14 @@ typedef void* (*NPN_GetJavaPeerProcPtr)(NPP instance); typedef void (*NPN_PushPopupsEnabledStateProcPtr)(NPP instance, NPBool enabled); typedef void (*NPN_PopPopupsEnabledStateProcPtr)(NPP instance); typedef void (*NPN_PluginThreadAsyncCallProcPtr)(NPP npp, void (*func)(void *), void *userData); +typedef NPError (*NPN_GetValueForURLProcPtr)(NPP npp, NPNURLVariable variable, const char* url, char** value, uint32* len); +typedef NPError (*NPN_SetValueForURLProcPtr)(NPP npp, NPNURLVariable variable, const char* url, const char* value, uint32 len); +typedef NPError (*NPN_GetAuthenticationInfoProcPtr)(NPP npp, const char* protocol, const char* host, int32 port, const char* scheme, const char *realm, char** username, uint32* ulen, char** password, uint32* plen); + typedef uint32 (*NPN_ScheduleTimerProcPtr)(NPP npp, uint32 interval, NPBool repeat, void (*timerFunc)(NPP npp, uint32 timerID)); typedef void (*NPN_UnscheduleTimerProcPtr)(NPP npp, uint32 timerID); typedef NPError (*NPN_PopUpContextMenuProcPtr)(NPP instance, NPMenu* menu); +typedef NPBool (*NPN_ConvertPointProcPtr)(NPP npp, double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace); typedef void (*NPN_ReleaseVariantValueProcPtr) (NPVariant *variant); @@ -158,9 +163,13 @@ typedef struct _NPNetscapeFuncs { NPN_EnumerateProcPtr enumerate; NPN_PluginThreadAsyncCallProcPtr pluginthreadasynccall; NPN_ConstructProcPtr construct; + NPN_GetValueForURLProcPtr getvalueforurl; + NPN_SetValueForURLProcPtr setvalueforurl; + NPN_GetAuthenticationInfoProcPtr getauthenticationinfo; NPN_ScheduleTimerProcPtr scheduletimer; NPN_UnscheduleTimerProcPtr unscheduletimer; NPN_PopUpContextMenuProcPtr popupcontextmenu; + NPN_ConvertPointProcPtr convertpoint; } NPNetscapeFuncs; typedef struct _NPPluginFuncs { diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginContainerQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginContainerQt.cpp new file mode 100644 index 0000000000..59ab5bc064 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginContainerQt.cpp @@ -0,0 +1,149 @@ +/* + 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 "PluginContainerQt.h" + +#include "FocusController.h" +#include "Frame.h" +#include "FrameView.h" +#include "Page.h" +#include "PlatformKeyboardEvent.h" +#include "PlatformWheelEvent.h" +#include "PluginView.h" +#include <QApplication> +#include <QX11Info> + +using namespace WebCore; + +PluginClientWrapper::PluginClientWrapper(QWidget* parent, WId client) + : QWidget(0, Qt::Popup) +{ + // create a QWidget that adopts the plugin window id, do not give it + // a parent so that we don't end up handling events supposed to be + // handled by the QX11EmbedContainer. + + // without the parent this will be considered a toplevel widget, + // and thus make Qt not quit the event loop after the last window + // has been closed. In order to work around this, we set the window + // type to Qt::Popup. + + create(client, false, true); + m_parent = parent; +} + +PluginClientWrapper::~PluginClientWrapper() +{ + destroy(false, false); +} + +bool PluginClientWrapper::x11Event(XEvent* event) +{ + // modify the event window id and insert it into the Qt event system. + event->xany.window = m_parent->parentWidget()->winId(); + static_cast<QApplication*>(QApplication::instance())->x11ProcessEvent(event); + return true; +} + +PluginContainerQt::PluginContainerQt(PluginView* view, QWidget* parent) + : QX11EmbedContainer(parent) + , m_pluginView(view) + , m_clientWrapper(0) +{ + connect(this, SIGNAL(clientClosed()), this, SLOT(on_clientClosed())); + connect(this, SIGNAL(clientIsEmbedded()), this, SLOT(on_clientIsEmbedded())); +} + +PluginContainerQt::~PluginContainerQt() +{ + delete m_clientWrapper; +} + +void PluginContainerQt::on_clientClosed() +{ + delete m_clientWrapper; + m_clientWrapper = 0; +} + +void PluginContainerQt::on_clientIsEmbedded() +{ + delete m_clientWrapper; + m_clientWrapper = 0; + + // Only create a QWidget wrapper for the plugin in the case it isn't in the + // Qt window mapper, and thus receiving events from the Qt event system. + // This way the PluginClientWrapper receives the scroll events and passes + // them to the parent. NOTICE: Native Qt based plugins running in process, + // will already be in the window mapper, and thus creating a wrapper, stops + // them from getting events from Qt, as they are redirected to the wrapper. + if (!QWidget::find(clientWinId())) + m_clientWrapper = new PluginClientWrapper(this, clientWinId()); +} + +void PluginContainerQt::redirectWheelEventsToParent(bool enable) +{ + // steal wheel events from the plugin as we want to handle it. When doing this + // all button 4, 5, 6, and 7, ButtonPress and ButtonRelease events are passed + // to the x11Event handler of the PluginClientWrapper, which then changes the + // window id of the event to the parent of PluginContainer and puts the event + // back into the Qt event loop, so that we will actually scroll the parent + // frame. + for (int buttonNo = 4; buttonNo < 8; buttonNo++) { + if (enable) + XGrabButton(x11Info().display(), buttonNo, AnyModifier, clientWinId(), + false, ButtonPressMask, GrabModeAsync, GrabModeAsync, 0L, 0L); + else + XUngrabButton(x11Info().display(), buttonNo, AnyModifier, clientWinId()); + } +} + +bool PluginContainerQt::x11Event(XEvent* event) +{ + switch (event->type) { + case EnterNotify: + // if the plugin window doesn't have focus we do not want to send wheel + // events to it, but to the parent frame, so let's redirect here. + redirectWheelEventsToParent(!hasFocus()); + break; + case LeaveNotify: + // it is always safe to ungrab wheel events when the mouse leaves the + // plugin window. + redirectWheelEventsToParent(false); + break; + } + + return QX11EmbedContainer::x11Event(event); +} + +void PluginContainerQt::focusInEvent(QFocusEvent* event) +{ + // we got focus, stop redirecting the wheel events + redirectWheelEventsToParent(false); + + if (Page* page = m_pluginView->parentFrame()->page()) + page->focusController()->setActive(true); + + m_pluginView->focusPluginElement(); +} + +void PluginContainerQt::focusOutEvent(QFocusEvent*) +{ + if (Page* page = m_pluginView->parentFrame()->page()) + page->focusController()->setActive(false); +} diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginContainerQt.h b/src/3rdparty/webkit/WebCore/plugins/qt/PluginContainerQt.h new file mode 100644 index 0000000000..624654c588 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginContainerQt.h @@ -0,0 +1,63 @@ +/* + 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 PluginContainerQt_H +#define PluginContainerQt_H + +#include <QX11EmbedContainer> + +namespace WebCore { + + class PluginView; + + class PluginContainerQt : public QX11EmbedContainer + { + Q_OBJECT + public: + PluginContainerQt(PluginView*, QWidget* parent); + ~PluginContainerQt(); + + void redirectWheelEventsToParent(bool enable = true); + + protected: + virtual bool x11Event(XEvent*); + virtual void focusInEvent(QFocusEvent*); + virtual void focusOutEvent(QFocusEvent*); + + public slots: + void on_clientClosed(); + void on_clientIsEmbedded(); + + private: + PluginView* m_pluginView; + QWidget* m_clientWrapper; + }; + + class PluginClientWrapper : public QWidget + { + public: + PluginClientWrapper(QWidget* parent, WId client); + ~PluginClientWrapper(); + bool x11Event(XEvent*); + + private: + QWidget* m_parent; + }; +} + +#endif // PluginContainerQt_H diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp index 13f53941dd..d9e3765055 100644 --- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp @@ -29,7 +29,6 @@ #include "CString.h" #include "MIMETypeRegistry.h" -#include "NotImplemented.h" #include "npruntime_impl.h" #include "PluginDatabase.h" #include "PluginDebug.h" @@ -110,52 +109,7 @@ bool PluginPackage::load() 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_HasProperty; - m_browserFuncs.hasmethod = _NPN_HasMethod; - m_browserFuncs.setexception = _NPN_SetException; - m_browserFuncs.enumerate = _NPN_Enumerate; - m_browserFuncs.construct = _NPN_Construct; + initializeBrowserFuncs(); #if defined(XP_UNIX) npErr = NP_Initialize(&m_browserFuncs, &m_pluginFuncs); @@ -173,28 +127,4 @@ abort: return false; } -unsigned PluginPackage::hash() const -{ - unsigned hashCodes[2] = { - m_path.impl()->hash(), - m_lastModified - }; - - return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), 2 * sizeof(unsigned) / sizeof(UChar)); -} - -bool PluginPackage::equal(const PluginPackage& a, const PluginPackage& b) -{ - return a.m_description == b.m_description; -} - -int PluginPackage::compareFileVersion(const PlatformModuleVersion& compareVersion) const -{ - // return -1, 0, or 1 if plug-in version is less than, equal to, or greater than - // the passed version - if (m_moduleVersion != compareVersion) - return m_moduleVersion > compareVersion ? 1 : -1; - return 0; -} - } diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp index e856f92d46..25d61f9891 100644 --- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp @@ -27,40 +27,38 @@ #include "config.h" #include "PluginView.h" -#include <QWidget> -#include <QX11EmbedContainer> -#include <QX11Info> - -#include "NotImplemented.h" -#include "PluginDebug.h" -#include "PluginPackage.h" -#include "npruntime_impl.h" -#include "runtime.h" -#include "runtime_root.h" -#include <runtime/JSLock.h> -#include <runtime/JSValue.h> -#include "JSDOMBinding.h" -#include "ScriptController.h" - #include "Document.h" #include "DocumentLoader.h" #include "Element.h" -#include "FrameLoader.h" +#include "Frame.h" #include "FrameLoadRequest.h" +#include "FrameLoader.h" #include "FrameTree.h" -#include "Frame.h" #include "FrameView.h" #include "GraphicsContext.h" -#include "Image.h" #include "HTMLNames.h" #include "HTMLPlugInElement.h" +#include "Image.h" +#include "JSDOMBinding.h" #include "KeyboardEvent.h" #include "MouseEvent.h" +#include "NotImplemented.h" #include "Page.h" #include "PlatformMouseEvent.h" +#include "PluginContainerQt.h" +#include "PluginDebug.h" +#include "PluginPackage.h" #include "PluginMainThreadScheduler.h" #include "RenderLayer.h" +#include "ScriptController.h" #include "Settings.h" +#include "npruntime_impl.h" +#include "runtime.h" +#include "runtime_root.h" +#include <QWidget> +#include <QX11Info> +#include <runtime/JSLock.h> +#include <runtime/JSValue.h> using JSC::ExecState; using JSC::Interpreter; @@ -78,7 +76,7 @@ using namespace HTMLNames; void PluginView::updatePluginWidget() { - if (!parent() || !m_isWindowed) + if (!parent() || !m_isWindowed || !platformPluginWidget()) return; ASSERT(parent()->isFrameView()); @@ -91,11 +89,19 @@ void PluginView::updatePluginWidget() m_clipRect = windowClipRect(); m_clipRect.move(-m_windowRect.x(), -m_windowRect.y()); - if (platformPluginWidget()) { - platformPluginWidget()->move(m_windowRect.x(), m_windowRect.y()); - platformPluginWidget()->resize(m_windowRect.width(), m_windowRect.height()); - platformPluginWidget()->setMask(QRegion(m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height())); - } + if (m_windowRect == oldWindowRect && m_clipRect == oldClipRect) + return; + + // do not call setNPWindowIfNeeded immediately, will be called on paint() + m_hasPendingGeometryChange = true; + + // in order to move/resize the plugin window at the same time as the + // rest of frame during e.g. scrolling, we set the window geometry + // in the paint() function, but as paint() isn't called when the + // plugin window is outside the frame which can be caused by a + // scroll, we need to move/resize immediately. + if (!m_windowRect.intersects(frameView->frameRect())) + setNPWindowIfNeeded(); } void PluginView::setFocus() @@ -137,10 +143,11 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) return; } - if (m_isWindowed || context->paintingDisabled()) + if (context->paintingDisabled()) return; - notImplemented(); + if (m_isWindowed && platformPluginWidget()) + setNPWindowIfNeeded(); } void PluginView::handleKeyboardEvent(KeyboardEvent* event) @@ -159,46 +166,54 @@ void PluginView::setParent(ScrollView* parent) if (parent) init(); - else { - if (!platformPluginWidget()) - return; - } } -void PluginView::setNPWindowRect(const IntRect& rect) +void PluginView::setNPWindowRect(const IntRect&) { - if (!m_isStarted || !parent()) - return; - - IntPoint p = static_cast<FrameView*>(parent())->contentsToWindow(rect.location()); - m_npWindow.x = p.x(); - m_npWindow.y = p.y(); + // Ignored as we don't want to move immediately. +} - m_npWindow.width = rect.width(); - m_npWindow.height = rect.height(); +void PluginView::setNPWindowIfNeeded() +{ + if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow) + return; - m_npWindow.clipRect.left = 0; - m_npWindow.clipRect.top = 0; - m_npWindow.clipRect.right = rect.width(); - m_npWindow.clipRect.bottom = rect.height(); + // On Unix, only call plugin if it's full-page or windowed + if (m_mode != NP_FULL && m_mode != NP_EMBED) + return; - if (m_npWindow.x < 0 || m_npWindow.y < 0 || - m_npWindow.width <= 0 || m_npWindow.height <= 0) + 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)); + + // FLASH WORKAROUND: Only set initially. Multiple calls to + // setNPWindow() cause the plugin to crash. + if (m_npWindow.width == -1 || m_npWindow.height == -1) { + m_npWindow.width = m_windowRect.width(); + m_npWindow.height = m_windowRect.height(); + } - if (m_plugin->pluginFuncs()->setwindow) { - PluginView::setCurrentPluginView(this); - JSC::JSLock::DropAllLocks dropAllLocks(false); - setCallingPlugin(true); - m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow); - setCallingPlugin(false); - PluginView::setCurrentPluginView(0); + m_npWindow.x = m_windowRect.x(); + m_npWindow.y = m_windowRect.y(); - if (!m_isWindowed) - return; + 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(); - ASSERT(platformPluginWidget()); - } + PluginView::setCurrentPluginView(this); + JSC::JSLock::DropAllLocks dropAllLocks(false); + setCallingPlugin(true); + m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow); + setCallingPlugin(false); + PluginView::setCurrentPluginView(0); } void PluginView::setParentVisible(bool visible) @@ -288,7 +303,7 @@ NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const c //FIXME - read the file data into buffer FILE* fileHandle = fopen((filename.utf8()).data(), "r"); - + if (fileHandle == 0) return NPERR_FILE_NOT_FOUND; @@ -332,7 +347,7 @@ NPError PluginView::getValue(NPNVariable variable, void* value) *(void **)value = platformPluginWidget()->x11Info().display(); else *(void **)value = m_parentFrame->view()->hostWindow()->platformWindow()->x11Info().display(); - return NPERR_NO_ERROR; + return NPERR_NO_ERROR; case NPNVxtAppContext: return NPERR_GENERIC_ERROR; @@ -350,7 +365,7 @@ NPError PluginView::getValue(NPNVariable variable, void* value) void** v = (void**)value; *v = windowScriptObject; - + return NPERR_NO_ERROR; } @@ -397,10 +412,10 @@ void PluginView::invalidateRect(const IntRect& rect) platformWidget()->update(rect); return; } - + invalidateWindowlessPluginRect(rect); } - + void PluginView::invalidateRect(NPRect* rect) { notImplemented(); @@ -439,6 +454,8 @@ void PluginView::init() return; m_haveInitialized = true; + m_hasPendingGeometryChange = false; + if (!m_plugin) { ASSERT(m_status == PluginStatusCanNotFindPlugin); return; @@ -465,7 +482,7 @@ void PluginView::init() } if (m_needsXEmbed) { - setPlatformWidget(new QX11EmbedContainer(m_parentFrame->view()->hostWindow()->platformWindow())); + setPlatformWidget(new PluginContainerQt(this, m_parentFrame->view()->hostWindow()->platformWindow())); } else { notImplemented(); m_status = PluginStatusCanNotLoadPlugin; @@ -485,9 +502,13 @@ void PluginView::init() m_npWindow.type = NPWindowTypeWindow; m_npWindow.window = (void*)platformPluginWidget()->winId(); + m_npWindow.width = -1; + m_npWindow.height = -1; - if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) - setNPWindowRect(frameRect()); + if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) { + updatePluginWidget(); + setNPWindowIfNeeded(); + } m_status = PluginStatusLoadedSuccessfully; } diff --git a/src/3rdparty/webkit/WebCore/plugins/win/PluginPackageWin.cpp b/src/3rdparty/webkit/WebCore/plugins/win/PluginPackageWin.cpp index fe9b544831..b52553ec9a 100644 --- a/src/3rdparty/webkit/WebCore/plugins/win/PluginPackageWin.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/win/PluginPackageWin.cpp @@ -68,6 +68,11 @@ int PluginPackage::compareFileVersion(const PlatformModuleVersion& compareVersio bool PluginPackage::isPluginBlacklisted() { + if (name() == "Citrix ICA Client") { + // The Citrix ICA Client plug-in requires a Mozilla-based browser; see <rdar://6418681>. + return true; + } + if (name() == "Silverlight Plug-In") { // workaround for <rdar://5557379> Crash in Silverlight when opening microsoft.com. // the latest 1.0 version of Silverlight does not reproduce this crash, so allow it @@ -114,7 +119,7 @@ void PluginPackage::determineQuirks(const String& mimeType) m_quirks.add(PluginQuirkHasModalMessageLoop); } - if (name() == "VLC Multimedia Plugin") { + if (name() == "VLC Multimedia Plugin" || name() == "VLC Multimedia Plug-in") { // VLC hangs on NPP_Destroy if we call NPP_SetWindow with a null window handle m_quirks.add(PluginQuirkDontSetNullWindowHandleOnDestroy); @@ -276,56 +281,7 @@ bool PluginPackage::load() if (npErr != NPERR_NO_ERROR) goto abort; - memset(&m_browserFuncs, 0, sizeof(m_browserFuncs)); - 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.pluginthreadasynccall = NPN_PluginThreadAsyncCall; - - 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.intfromidentifier = _NPN_IntFromIdentifier; - 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_HasProperty; - m_browserFuncs.hasmethod = _NPN_HasMethod; - m_browserFuncs.setexception = _NPN_SetException; - m_browserFuncs.enumerate = _NPN_Enumerate; - m_browserFuncs.construct = _NPN_Construct; + initializeBrowserFuncs(); npErr = NP_Initialize(&m_browserFuncs); LOG_NPERROR(npErr); diff --git a/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp b/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp index 722262bb0f..67c34ebd5a 100644 --- a/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp +++ b/src/3rdparty/webkit/WebCore/plugins/win/PluginViewWin.cpp @@ -45,7 +45,6 @@ #include "KeyboardEvent.h" #include "MIMETypeRegistry.h" #include "MouseEvent.h" -#include "NotImplemented.h" #include "Page.h" #include "FocusController.h" #include "PlatformMouseEvent.h" @@ -99,6 +98,92 @@ const LPCWSTR kWebPluginViewProperty = L"WebPluginViewProperty"; static const char* MozillaUserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0"; +// The code used to hook BeginPaint/EndPaint originally came from +// <http://www.fengyuan.com/article/wmprint.html>. +// Copyright (C) 2000 by Feng Yuan (www.fengyuan.com). + +static unsigned beginPaintSysCall; +static BYTE* beginPaint; + +static unsigned endPaintSysCall; +static BYTE* endPaint; + +HDC WINAPI PluginView::hookedBeginPaint(HWND hWnd, PAINTSTRUCT* lpPaint) +{ + PluginView* pluginView = reinterpret_cast<PluginView*>(GetProp(hWnd, kWebPluginViewProperty)); + if (pluginView && pluginView->m_wmPrintHDC) { + // We're secretly handling WM_PRINTCLIENT, so set up the PAINTSTRUCT so + // that the plugin will paint into the HDC we provide. + memset(lpPaint, 0, sizeof(PAINTSTRUCT)); + lpPaint->hdc = pluginView->m_wmPrintHDC; + GetClientRect(hWnd, &lpPaint->rcPaint); + return pluginView->m_wmPrintHDC; + } + + // Call through to the original BeginPaint. + __asm mov eax, beginPaintSysCall + __asm push lpPaint + __asm push hWnd + __asm call beginPaint +} + +BOOL WINAPI PluginView::hookedEndPaint(HWND hWnd, const PAINTSTRUCT* lpPaint) +{ + PluginView* pluginView = reinterpret_cast<PluginView*>(GetProp(hWnd, kWebPluginViewProperty)); + if (pluginView && pluginView->m_wmPrintHDC) { + // We're secretly handling WM_PRINTCLIENT, so we don't have to do any + // cleanup. + return TRUE; + } + + // Call through to the original EndPaint. + __asm mov eax, endPaintSysCall + __asm push lpPaint + __asm push hWnd + __asm call endPaint +} + +static void hook(const char* module, const char* proc, unsigned& sysCallID, BYTE*& pProc, const void* pNewProc) +{ + // See <http://www.fengyuan.com/article/wmprint.html> for an explanation of + // how this function works. + + HINSTANCE hMod = GetModuleHandleA(module); + + pProc = reinterpret_cast<BYTE*>(GetProcAddress(hMod, proc)); + + if (pProc[0] != 0xB8) + return; + + // FIXME: Should we be reading the bytes one-by-one instead of doing an + // unaligned read? + sysCallID = *reinterpret_cast<unsigned*>(pProc + 1); + + DWORD flOldProtect; + if (!VirtualProtect(pProc, 5, PAGE_EXECUTE_READWRITE, &flOldProtect)) + return; + + pProc[0] = 0xE9; + *reinterpret_cast<unsigned*>(pProc + 1) = reinterpret_cast<intptr_t>(pNewProc) - reinterpret_cast<intptr_t>(pProc + 5); + + pProc += 5; +} + +static void setUpOffscreenPaintingHooks(HDC (WINAPI*hookedBeginPaint)(HWND, PAINTSTRUCT*), BOOL (WINAPI*hookedEndPaint)(HWND, const PAINTSTRUCT*)) +{ + static bool haveHooked = false; + if (haveHooked) + return; + haveHooked = true; + + // Most (all?) windowed plugins don't seem to respond to WM_PRINTCLIENT, so + // we hook into BeginPaint/EndPaint to allow their normal WM_PAINT handling + // to draw into a given HDC. Note that this hooking affects the entire + // process. + hook("user32.dll", "BeginPaint", beginPaintSysCall, beginPaint, hookedBeginPaint); + hook("user32.dll", "EndPaint", endPaintSysCall, endPaint, hookedEndPaint); +} + static bool registerPluginView() { static bool haveRegisteredWindowClass = false; @@ -201,9 +286,19 @@ PluginView::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) m_popPopupsStateTimer.startOneShot(0); } + if (message == WM_PRINTCLIENT) { + // Most (all?) windowed plugins don't respond to WM_PRINTCLIENT, so we + // change the message to WM_PAINT and rely on our hooked versions of + // BeginPaint/EndPaint to make the plugin draw into the given HDC. + message = WM_PAINT; + m_wmPrintHDC = reinterpret_cast<HDC>(wParam); + } + // Call the plug-in's window proc. LRESULT result = ::CallWindowProc(m_pluginWndProc, hWnd, message, wParam, lParam); + m_wmPrintHDC = 0; + m_isCallingPluginWndProc = false; return result; @@ -305,6 +400,34 @@ bool PluginView::dispatchNPEvent(NPEvent& npEvent) return result; } +void PluginView::paintWindowedPluginIntoContext(GraphicsContext* context, const IntRect& rect) const +{ + ASSERT(m_isWindowed); + ASSERT(context->shouldIncludeChildWindows()); + + ASSERT(parent()->isFrameView()); + IntPoint locationInWindow = static_cast<FrameView*>(parent())->contentsToWindow(frameRect().location()); + + HDC hdc = context->getWindowsContext(frameRect(), false); + + XFORM originalTransform; + GetWorldTransform(hdc, &originalTransform); + + // The plugin expects the DC to be in client coordinates, so we translate + // the DC to make that so. + XFORM transform = originalTransform; + transform.eDx = locationInWindow.x(); + transform.eDy = locationInWindow.y(); + + SetWorldTransform(hdc, &transform); + + SendMessage(platformPluginWidget(), WM_PRINTCLIENT, reinterpret_cast<WPARAM>(hdc), PRF_CLIENT | PRF_CHILDREN | PRF_OWNED); + + SetWorldTransform(hdc, &originalTransform); + + context->releaseWindowsContext(hdc, frameRect(), false); +} + void PluginView::paint(GraphicsContext* context, const IntRect& rect) { if (!m_isStarted) { @@ -313,8 +436,14 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) return; } - if (m_isWindowed || context->paintingDisabled()) + if (context->paintingDisabled()) + return; + + if (m_isWindowed) { + if (context->shouldIncludeChildWindows()) + paintWindowedPluginIntoContext(context, rect); return; + } ASSERT(parent()->isFrameView()); IntRect rectInWindow = static_cast<FrameView*>(parent())->contentsToWindow(frameRect()); @@ -422,10 +551,7 @@ void PluginView::handleMouseEvent(MouseEvent* event) } } else if (event->type() == eventNames().mousedownEvent) { - // Focus the plugin - if (Page* page = m_parentFrame->page()) - page->focusController()->setFocusedFrame(m_parentFrame); - m_parentFrame->document()->setFocusedNode(m_element); + focusPluginElement(); switch (event->button()) { case 0: npEvent.event = WM_LBUTTONDOWN; @@ -452,8 +578,6 @@ void PluginView::handleMouseEvent(MouseEvent* event) } else return; - HCURSOR currentCursor = ::GetCursor(); - JSC::JSLock::DropAllLocks dropAllLocks(false); if (!dispatchNPEvent(npEvent)) event->setDefaultHandled(); @@ -461,7 +585,7 @@ void PluginView::handleMouseEvent(MouseEvent* event) #if !PLATFORM(QT) // Currently, Widget::setCursor is always called after this function in EventHandler.cpp // and since we don't want that we set ignoreNextSetCursor to true here to prevent that. - ignoreNextSetCursor = true; + ignoreNextSetCursor = true; lastSetCursor = ::GetCursor(); #endif } @@ -802,6 +926,7 @@ void PluginView::init() if (m_isWindowed) { registerPluginView(); + setUpOffscreenPaintingHooks(hookedBeginPaint, hookedEndPaint); DWORD flags = WS_CHILD; if (isSelfVisible()) |