diff options
Diffstat (limited to 'WebCore/plugins')
-rw-r--r-- | WebCore/plugins/PluginData.h | 4 | ||||
-rw-r--r-- | WebCore/plugins/PluginDatabase.cpp | 4 | ||||
-rw-r--r-- | WebCore/plugins/PluginDatabase.h | 2 | ||||
-rw-r--r-- | WebCore/plugins/PluginInfoStore.cpp | 12 | ||||
-rw-r--r-- | WebCore/plugins/PluginMainThreadScheduler.h | 2 | ||||
-rw-r--r-- | WebCore/plugins/PluginStream.cpp | 4 | ||||
-rw-r--r-- | WebCore/plugins/PluginView.cpp | 19 | ||||
-rw-r--r-- | WebCore/plugins/PluginView.h | 31 | ||||
-rw-r--r-- | WebCore/plugins/chromium/PluginDataChromium.cpp | 2 | ||||
-rw-r--r-- | WebCore/plugins/chromium/PluginDataChromium.h | 39 | ||||
-rw-r--r-- | WebCore/plugins/gtk/PluginViewGtk.cpp | 4 | ||||
-rw-r--r-- | WebCore/plugins/mac/PluginPackageMac.cpp | 2 | ||||
-rw-r--r-- | WebCore/plugins/mac/PluginViewMac.cpp | 175 | ||||
-rw-r--r-- | WebCore/plugins/qt/PluginDataQt.cpp | 4 | ||||
-rw-r--r-- | WebCore/plugins/qt/PluginViewQt.cpp | 20 | ||||
-rw-r--r-- | WebCore/plugins/win/PluginViewWin.cpp | 23 | ||||
-rw-r--r-- | WebCore/plugins/wx/PluginDataWx.cpp | 78 |
17 files changed, 340 insertions, 85 deletions
diff --git a/WebCore/plugins/PluginData.h b/WebCore/plugins/PluginData.h index b2866bf..6960a25 100644 --- a/WebCore/plugins/PluginData.h +++ b/WebCore/plugins/PluginData.h @@ -29,14 +29,14 @@ namespace WebCore { class Page; struct PluginInfo; - struct MimeClassInfo { + struct MimeClassInfo : Noncopyable { String type; String desc; String suffixes; PluginInfo* plugin; }; - struct PluginInfo { + struct PluginInfo : Noncopyable { String name; String file; String desc; diff --git a/WebCore/plugins/PluginDatabase.cpp b/WebCore/plugins/PluginDatabase.cpp index 25e6000..dcd7208 100644 --- a/WebCore/plugins/PluginDatabase.cpp +++ b/WebCore/plugins/PluginDatabase.cpp @@ -325,7 +325,7 @@ void PluginDatabase::clear() m_preferredPlugins.clear(); } -#if (!PLATFORM(SYMBIAN)) && (!PLATFORM(WIN_OS) || PLATFORM(WX) || !ENABLE(NETSCAPE_PLUGIN_API)) +#if (!PLATFORM(WINCE)) && (!PLATFORM(SYMBIAN)) && (!PLATFORM(WIN_OS) || !ENABLE(NETSCAPE_PLUGIN_API)) // 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? @@ -385,7 +385,7 @@ Vector<String> PluginDatabase::defaultPluginDirectories() // Add paths specific to each port #if PLATFORM(QT) Vector<String> qtPaths; - String qtPath(getenv("QTWEBKIT_PLUGIN_PATH")); + String qtPath(qgetenv("QTWEBKIT_PLUGIN_PATH").constData()); qtPath.split(UChar(':'), /* allowEmptyEntries */ false, qtPaths); paths.append(qtPaths); #endif diff --git a/WebCore/plugins/PluginDatabase.h b/WebCore/plugins/PluginDatabase.h index fe74682..90214ca 100644 --- a/WebCore/plugins/PluginDatabase.h +++ b/WebCore/plugins/PluginDatabase.h @@ -51,7 +51,7 @@ namespace WebCore { typedef HashSet<RefPtr<PluginPackage>, PluginPackageHash> PluginSet; - class PluginDatabase { + class PluginDatabase : public Noncopyable { public: PluginDatabase(); diff --git a/WebCore/plugins/PluginInfoStore.cpp b/WebCore/plugins/PluginInfoStore.cpp index bd2f2d0..9a441f3 100644 --- a/WebCore/plugins/PluginInfoStore.cpp +++ b/WebCore/plugins/PluginInfoStore.cpp @@ -27,9 +27,15 @@ #include "PluginInfoStore.h" #include "KURL.h" +<<<<<<< HEAD:WebCore/plugins/PluginInfoStore.cpp #if PLATFORM(ANDROID) +======= +>>>>>>> webkit.org at r51976:WebCore/plugins/PluginInfoStore.cpp #include "Page.h" +<<<<<<< HEAD:WebCore/plugins/PluginInfoStore.cpp #endif +======= +>>>>>>> webkit.org at r51976:WebCore/plugins/PluginInfoStore.cpp #include "PluginData.h" #include "PluginDatabase.h" #include "PluginPackage.h" @@ -96,8 +102,12 @@ bool PluginInfoStore::supportsMIMEType(const WebCore::String& mimeType) void refreshPlugins(bool reloadOpenPages) { +<<<<<<< HEAD:WebCore/plugins/PluginInfoStore.cpp #if PLATFORM(ANDROID) +======= +>>>>>>> webkit.org at r51976:WebCore/plugins/PluginInfoStore.cpp Page::refreshPlugins(reloadOpenPages); +<<<<<<< HEAD:WebCore/plugins/PluginInfoStore.cpp #else PluginDatabase::installedPlugins()->refresh(); @@ -105,6 +115,8 @@ void refreshPlugins(bool reloadOpenPages) // FIXME: reload open pages } #endif +======= +>>>>>>> webkit.org at r51976:WebCore/plugins/PluginInfoStore.cpp } } diff --git a/WebCore/plugins/PluginMainThreadScheduler.h b/WebCore/plugins/PluginMainThreadScheduler.h index 8872d56..610e89c 100644 --- a/WebCore/plugins/PluginMainThreadScheduler.h +++ b/WebCore/plugins/PluginMainThreadScheduler.h @@ -36,7 +36,7 @@ typedef NPP_t* NPP; namespace WebCore { -class PluginMainThreadScheduler { +class PluginMainThreadScheduler : public Noncopyable { public: typedef void MainThreadFunction(void*); diff --git a/WebCore/plugins/PluginStream.cpp b/WebCore/plugins/PluginStream.cpp index cd9f83d..4be3d13 100644 --- a/WebCore/plugins/PluginStream.cpp +++ b/WebCore/plugins/PluginStream.cpp @@ -120,6 +120,8 @@ void PluginStream::stop() m_loader->cancel(); m_loader = 0; } + + m_client = 0; } void PluginStream::startStream() @@ -305,7 +307,7 @@ void PluginStream::destroyStream() m_streamState = StreamStopped; - if (!m_loadManually) + if (!m_loadManually && m_client) m_client->streamDidFinishLoading(this); if (!m_path.isNull()) { diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp index 0b2f6ec..3f40000 100644 --- a/WebCore/plugins/PluginView.cpp +++ b/WebCore/plugins/PluginView.cpp @@ -45,7 +45,7 @@ #include "Page.h" #include "FocusController.h" #include "PlatformMouseEvent.h" -#if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API) +#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API) #include "PluginMessageThrottlerWin.h" #endif #include "PluginPackage.h" @@ -141,7 +141,7 @@ void PluginView::setFrameRect(const IntRect& rect) #if PLATFORM(WIN_OS) || PLATFORM(SYMBIAN) // On Windows and Symbian, always call plugin to change geometry. setNPWindowRect(rect); -#elif XP_UNIX +#elif defined(XP_UNIX) // On Unix, multiple calls to setNPWindow() in windowed mode causes Flash to crash if (m_mode == NP_FULL || !m_isWindowed) setNPWindowRect(rect); @@ -337,7 +337,6 @@ void PluginView::stop() #endif #if ENABLE(NETSCAPE_PLUGIN_API) -#if !PLATFORM(WX) // FIXME: Revisit this when implementing plugins for wx #ifdef XP_WIN // Unsubclass the window if (m_isWindowed) { @@ -354,7 +353,6 @@ void PluginView::stop() #endif } #endif // XP_WIN -#endif // !PLATFORM(WX) #endif // ENABLE(NETSCAPE_PLUGIN_API) #if !defined(XP_MACOSX) @@ -877,7 +875,7 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p #if defined(XP_UNIX) || defined(Q_WS_X11) , m_needsXEmbed(false) #endif -#if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API) +#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API) , m_pluginWndProc(0) , m_lastMessage(0) , m_isCallingPluginWndProc(false) @@ -890,9 +888,11 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p #if defined(XP_MACOSX) , m_drawingModel(NPDrawingModel(-1)) , m_eventModel(NPEventModel(-1)) + , m_contextRef(0) + , m_fakeWindow(0) #endif #if defined(Q_WS_X11) && ENABLE(NETSCAPE_PLUGIN_API) - , m_hasPendingGeometryChange(false) + , m_hasPendingGeometryChange(true) , m_drawable(0) , m_visual(0) , m_colormap(0) @@ -1288,7 +1288,7 @@ void PluginView::paintMissingPluginIcon(GraphicsContext* context, const IntRect& context->save(); context->clip(windowClipRect()); - context->drawImage(nullPluginImage.get(), imageRect.location()); + context->drawImage(nullPluginImage.get(), DeviceColorSpace, imageRect.location()); context->restore(); } @@ -1333,4 +1333,9 @@ Node* PluginView::node() const return m_element; } +String PluginView::pluginName() const +{ + return m_plugin->name(); +} + } // namespace WebCore diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h index 8a5706f..dd2458e 100644 --- a/WebCore/plugins/PluginView.h +++ b/WebCore/plugins/PluginView.h @@ -2,6 +2,7 @@ /* * Copyright (C) 2006, 2007, 2008 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 @@ -46,17 +47,24 @@ #include <wtf/RefPtr.h> #include <wtf/Vector.h> +<<<<<<< HEAD:WebCore/plugins/PluginView.h #ifdef PLUGIN_SCHEDULE_TIMER #include "PluginTimer.h" #endif #if PLATFORM(WIN_OS) && PLATFORM(QT) +======= +#if PLATFORM(WIN_OS) && (PLATFORM(QT) || PLATFORM(WX)) +>>>>>>> webkit.org at r51976:WebCore/plugins/PluginView.h typedef struct HWND__* HWND; typedef HWND PlatformPluginWidget; #elif defined(ANDROID_PLUGINS) typedef struct PluginWidgetAndroid* PlatformPluginWidget; #else typedef PlatformWidget PlatformPluginWidget; +#if defined(XP_MACOSX) && PLATFORM(QT) +#include <QPixmap> +#endif #endif #if USE(JSC) @@ -79,7 +87,7 @@ namespace WebCore { class TouchEvent; #endif class KURL; -#if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API) +#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API) class PluginMessageThrottlerWin; #endif class PluginPackage; @@ -94,7 +102,7 @@ namespace WebCore { PluginStatusLoadedSuccessfully }; - class PluginRequest { + class PluginRequest : public Noncopyable { public: PluginRequest(const FrameLoadRequest& frameLoadRequest, bool sendNotification, void* notifyData, bool shouldAllowPopups) : m_frameLoadRequest(frameLoadRequest) @@ -206,7 +214,7 @@ namespace WebCore { const String& mimeType() const { return m_mimeType; } const KURL& url() const { return m_url; } -#if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API) +#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API) static LRESULT CALLBACK PluginViewWndProc(HWND, UINT, WPARAM, LPARAM); LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); WNDPROC pluginWndProc() const { return m_pluginWndProc; } @@ -222,6 +230,8 @@ namespace WebCore { virtual void halt(); virtual void restart(); virtual Node* node() const; + virtual bool isWindowed() const { return m_isWindowed; } + virtual String pluginName() const; bool isHalted() const { return m_isHalted; } bool hasBeenHalted() const { return m_hasBeenHalted; } @@ -254,7 +264,7 @@ namespace WebCore { void invalidateWindowlessPluginRect(const IntRect&); -#if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API) +#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API) void paintWindowedPluginIntoContext(GraphicsContext*, const IntRect&); static HDC WINAPI hookedBeginPaint(HWND, PAINTSTRUCT*); static BOOL WINAPI hookedEndPaint(HWND, const PAINTSTRUCT*); @@ -335,7 +345,7 @@ namespace WebCore { bool m_needsXEmbed; #endif -#if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API) +#if PLATFORM(WIN_OS) && ENABLE(NETSCAPE_PLUGIN_API) OwnPtr<PluginMessageThrottlerWin> m_messageThrottler; WNDPROC m_pluginWndProc; unsigned m_lastMessage; @@ -344,11 +354,15 @@ namespace WebCore { bool m_haveUpdatedPluginWidget; #endif +<<<<<<< HEAD:WebCore/plugins/PluginView.h #ifdef PLUGIN_SCHEDULE_TIMER PluginTimerList m_timerList; #endif #if (PLATFORM(QT) && PLATFORM(WIN_OS)) || defined(XP_MACOSX) +======= +#if ((PLATFORM(QT) || PLATFORM(WX)) && PLATFORM(WIN_OS)) || defined(XP_MACOSX) +>>>>>>> webkit.org at r51976:WebCore/plugins/PluginView.h // On Mac OSX and Qt/Windows the plugin does not have its own native widget, // but is using the containing window as its reference for positioning/painting. PlatformPluginWidget m_window; @@ -371,12 +385,15 @@ private: void setNPWindowIfNeeded(); #elif defined(XP_MACOSX) NP_CGContext m_npCgContext; - OwnPtr<Timer<PluginView> > m_nullEventTimer; NPDrawingModel m_drawingModel; NPEventModel m_eventModel; + CGContextRef m_contextRef; + WindowRef m_fakeWindow; +#if PLATFORM(QT) + QPixmap m_pixmap; +#endif void setNPWindowIfNeeded(); - void nullEventTimerFired(Timer<PluginView>*); Point globalMousePosForPlugin() const; #endif diff --git a/WebCore/plugins/chromium/PluginDataChromium.cpp b/WebCore/plugins/chromium/PluginDataChromium.cpp index 3df81af..5c28643 100644 --- a/WebCore/plugins/chromium/PluginDataChromium.cpp +++ b/WebCore/plugins/chromium/PluginDataChromium.cpp @@ -29,7 +29,7 @@ */ #include "config.h" -#include "PluginData.h" +#include "PluginDataChromium.h" #include "ChromiumBridge.h" diff --git a/WebCore/plugins/chromium/PluginDataChromium.h b/WebCore/plugins/chromium/PluginDataChromium.h new file mode 100644 index 0000000..78701b4 --- /dev/null +++ b/WebCore/plugins/chromium/PluginDataChromium.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2009 Google, Inc. 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 COMPUTER, 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 COMPUTER, 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. + */ + +#ifndef PluginDataChromium_h +#define PluginDataChromium_h + +#include "PluginData.h" + +namespace WebCore { + +// Checks if any of the plugins handle this extension, and if so returns the +// plugin's mime type for this extension. Otherwise returns an empty string. +String getPluginMimeTypeFromExtension(const String& extension); + +} // namespace WebCore + +#endif // PluginDataChromium_h diff --git a/WebCore/plugins/gtk/PluginViewGtk.cpp b/WebCore/plugins/gtk/PluginViewGtk.cpp index bc3a622..6ea9417 100644 --- a/WebCore/plugins/gtk/PluginViewGtk.cpp +++ b/WebCore/plugins/gtk/PluginViewGtk.cpp @@ -227,7 +227,7 @@ void PluginView::setNPWindowIfNeeded() GtkAllocation allocation = { m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height() }; gtk_widget_size_allocate(platformPluginWidget(), &allocation); -#if PLATFORM(XP_UNIX) +#if defined(XP_UNIX) if (!m_needsXEmbed) { gtk_xtbin_set_position(GTK_XTBIN(platformPluginWidget()), m_windowRect.x(), m_windowRect.y()); gtk_xtbin_resize(platformPluginWidget(), m_windowRect.width(), m_windowRect.height()); @@ -332,7 +332,7 @@ NPError PluginView::getValue(NPNVariable variable, void* value) return NPERR_GENERIC_ERROR; #endif -#if PLATFORM(XP_UNIX) +#if defined(XP_UNIX) case NPNVxtAppContext: if (!m_needsXEmbed) { *(void **)value = XtDisplayToApplicationContext (GTK_XTBIN(platformPluginWidget())->xtclient.xtdisplay); diff --git a/WebCore/plugins/mac/PluginPackageMac.cpp b/WebCore/plugins/mac/PluginPackageMac.cpp index 325bc4d..4aef3a0 100644 --- a/WebCore/plugins/mac/PluginPackageMac.cpp +++ b/WebCore/plugins/mac/PluginPackageMac.cpp @@ -177,7 +177,7 @@ bool PluginPackage::fetchInfo() WTF::RetainPtr<CFDictionaryRef> extensionsDict = (CFDictionaryRef)values[i]; - WTF:RetainPtr<CFNumberRef> enabled = (CFNumberRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginTypeEnabled")); + WTF::RetainPtr<CFNumberRef> enabled = (CFNumberRef)CFDictionaryGetValue(extensionsDict.get(), CFSTR("WebPluginTypeEnabled")); if (enabled) { int enabledValue = 0; if (CFNumberGetValue(enabled.get(), kCFNumberIntType, &enabledValue) && enabledValue == 0) diff --git a/WebCore/plugins/mac/PluginViewMac.cpp b/WebCore/plugins/mac/PluginViewMac.cpp index 6521c84..44a0262 100644 --- a/WebCore/plugins/mac/PluginViewMac.cpp +++ b/WebCore/plugins/mac/PluginViewMac.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. * Copyright (C) 2008 Collabora Ltd. All rights reserved. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + * 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 @@ -75,6 +76,7 @@ using JSC::UString; #if PLATFORM(QT) #include <QWidget> #include <QKeyEvent> +#include <QPainter> #include "QWebPageClient.h" QT_BEGIN_NAMESPACE #if QT_VERSION < 0x040500 @@ -85,6 +87,11 @@ extern Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget* w); QT_END_NAMESPACE #endif +#if PLATFORM(WX) +#include <wx/defs.h> +#include <wx/wx.h> +#endif + using std::min; using namespace WTF; @@ -101,6 +108,10 @@ static inline WindowRef nativeWindowFor(PlatformWidget widget) if (widget) return static_cast<WindowRef>(qt_mac_window_for(widget)); #endif +#if PLATFORM(WX) + if (widget) + return (WindowRef)widget->MacGetTopLevelWindowRef(); +#endif return 0; } @@ -110,6 +121,10 @@ static inline CGContextRef cgHandleFor(PlatformWidget widget) if (widget) return (CGContextRef)widget->macCGHandle(); #endif +#if PLATFORM(WX) + if (widget) + return (CGContextRef)widget->MacGetCGContextRef(); +#endif return 0; } @@ -121,6 +136,12 @@ static inline IntPoint topLevelOffsetFor(PlatformWidget widget) return widget->mapTo(topLevel, QPoint(0, 0)) + topLevel->geometry().topLeft() - topLevel->pos(); } #endif +#if PLATFORM(WX) + if (widget) { + PlatformWidget toplevel = wxGetTopLevelParent(widget); + return toplevel->ScreenToClient(widget->GetScreenPosition()); + } +#endif return IntPoint(); } @@ -173,18 +194,29 @@ bool PluginView::platformStart() } #if PLATFORM(QT) + // Set the platformPluginWidget only in the case of QWebView so that the context menu appears in the right place. + // In all other cases, we use off-screen rendering if (QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient()) { - if (QWidget* widget = client->ownerWidget()) { + if (QWidget* widget = qobject_cast<QWidget*>(client->pluginParent())) setPlatformPluginWidget(widget); - } } #endif +#if PLATFORM(WX) + if (wxWindow* widget = m_parentFrame->view()->hostWindow()->platformPageClient()) + setPlatformPluginWidget(widget); +#endif - show(); + // Create a fake window relative to which all events will be sent when using offscreen rendering + if (!platformPluginWidget()) { + // Make the default size really big. It is unclear why this is required but with a smaller size, mouse move + // events don't get processed. Resizing the fake window to flash's size doesn't help. + ::Rect windowBounds = { 0, 0, 1000, 1000 }; + CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes, &windowBounds, &m_fakeWindow); + // Flash requires the window to be hilited to process mouse move events. + HiliteWindow(m_fakeWindow, true); + } - // TODO: Implement null timer throttling depending on plugin activation - m_nullEventTimer.set(new Timer<PluginView>(this, &PluginView::nullEventTimerFired)); - m_nullEventTimer->startRepeating(0.02); + show(); return true; } @@ -193,6 +225,11 @@ void PluginView::platformDestroy() { if (platformPluginWidget()) setPlatformPluginWidget(0); + else { + CGContextRelease(m_contextRef); + if (m_fakeWindow) + DisposeWindow(m_fakeWindow); + } } // Used before the plugin view has been initialized properly, and as a @@ -322,7 +359,11 @@ void PluginView::setFocus() LOG(Plugins, "PluginView::setFocus()"); if (platformPluginWidget()) +#if PLATFORM(QT) platformPluginWidget()->setFocus(Qt::OtherFocusReason); +#else + platformPluginWidget()->SetFocus(); +#endif else Widget::setFocus(); @@ -357,15 +398,21 @@ void PluginView::setNPWindowIfNeeded() if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow) return; - CGContextRef newContextRef = cgHandleFor(platformPluginWidget()); - if (!newContextRef) - return; + CGContextRef newContextRef = 0; + WindowRef newWindowRef = 0; + if (platformPluginWidget()) { + newContextRef = cgHandleFor(platformPluginWidget()); + newWindowRef = nativeWindowFor(platformPluginWidget()); + m_npWindow.type = NPWindowTypeWindow; + } else { + newContextRef = m_contextRef; + newWindowRef = m_fakeWindow; + m_npWindow.type = NPWindowTypeDrawable; + } - WindowRef newWindowRef = nativeWindowFor(platformPluginWidget()); - if (!newWindowRef) + if (!newContextRef || !newWindowRef) return; - m_npWindow.type = NPWindowTypeWindow; m_npWindow.window = (void*)&m_npCgContext; m_npCgContext.window = newWindowRef; m_npCgContext.context = newContextRef; @@ -382,7 +429,7 @@ void PluginView::setNPWindowIfNeeded() m_npWindow.clipRect.bottom = m_windowRect.y() + m_windowRect.height(); LOG(Plugins, "PluginView::setNPWindowIfNeeded(): window=%p, context=%p," - " window.x:%d window.y:%d window.width:%d window.height:%d window.clipRect size:%dx%d", + " window.x:%ld window.y:%ld window.width:%d window.height:%d window.clipRect size:%dx%d", newWindowRef, newContextRef, m_npWindow.x, m_npWindow.y, m_npWindow.width, m_npWindow.height, m_npWindow.clipRect.right - m_npWindow.clipRect.left, m_npWindow.clipRect.bottom - m_npWindow.clipRect.top); @@ -409,6 +456,17 @@ void PluginView::updatePluginWidget() IntPoint offset = topLevelOffsetFor(platformPluginWidget()); m_windowRect.move(offset.x(), offset.y()); + if (!platformPluginWidget()) { + if (m_windowRect.size() != oldWindowRect.size()) { + CGContextRelease(m_contextRef); +#if PLATFORM(QT) + m_pixmap = QPixmap(m_windowRect.size()); + m_pixmap.fill(Qt::transparent); + m_contextRef = qt_mac_cg_context(&m_pixmap); +#endif + } + } + m_clipRect = windowClipRect(); m_clipRect.move(-m_windowRect.x(), -m_windowRect.y()); @@ -433,8 +491,29 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) return; CGContextSaveGState(cgContext); - IntPoint offset = frameRect().location(); - CGContextTranslateCTM(cgContext, offset.x(), offset.y()); + if (platformPluginWidget()) { + IntPoint offset = frameRect().location(); + CGContextTranslateCTM(cgContext, offset.x(), offset.y()); + } + + IntRect targetRect(frameRect()); + targetRect.intersects(rect); + + // clip the context so that plugin only updates the interested area. + CGRect r; + r.origin.x = targetRect.x() - frameRect().x(); + r.origin.y = targetRect.y() - frameRect().y(); + r.size.width = targetRect.width(); + r.size.height = targetRect.height(); + CGContextClipToRect(cgContext, r); + + if (!platformPluginWidget() && m_isTransparent) { // clean the pixmap in transparent mode +#if PLATFORM(QT) + QPainter painter(&m_pixmap); + painter.setCompositionMode(QPainter::CompositionMode_Clear); + painter.fillRect(QRectF(r.origin.x, r.origin.y, r.size.width, r.size.height), Qt::transparent); +#endif + } EventRecord event; event.what = updateEvt; @@ -448,18 +527,32 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) LOG(Events, "PluginView::paint(): Paint event not accepted"); CGContextRestoreGState(cgContext); + + if (!platformPluginWidget()) { +#if PLATFORM(QT) + QPainter* painter = context->platformContext(); + painter->drawPixmap(targetRect.x(), targetRect.y(), m_pixmap, + targetRect.x() - frameRect().x(), targetRect.y() - frameRect().y(), targetRect.width(), targetRect.height()); +#endif + } } void PluginView::invalidateRect(const IntRect& rect) { if (platformPluginWidget()) +#if PLATFORM(QT) platformPluginWidget()->update(convertToContainingWindow(rect)); +#else + platformPluginWidget()->RefreshRect(convertToContainingWindow(rect)); +#endif + else + invalidateWindowlessPluginRect(rect); } void PluginView::invalidateRect(NPRect* rect) { - // TODO: optimize - invalidate(); + IntRect r(rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top); + invalidateRect(r); } void PluginView::invalidateRegion(NPRegion region) @@ -484,8 +577,7 @@ void PluginView::handleMouseEvent(MouseEvent* event) EventRecord record; if (event->type() == eventNames().mousemoveEvent) { - // Mouse movement is handled by null timer events - return; + record.what = nullEvent; } else if (event->type() == eventNames().mouseoverEvent) { record.what = adjustCursorEvent; } else if (event->type() == eventNames().mouseoutEvent) { @@ -502,7 +594,20 @@ void PluginView::handleMouseEvent(MouseEvent* event) return; } - record.where = globalMousePosForPlugin(); + if (platformPluginWidget()) { + record.where = globalMousePosForPlugin(); + } else { + if (event->button() == 2) { + // always pass the global position for right-click since Flash uses it to position the context menu + record.where = globalMousePosForPlugin(); + } else { + IntPoint postZoomPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(event->absoluteLocation())); + record.where.h = postZoomPos.x() + m_windowRect.x(); + // The number 22 is the height of the title bar. As to why it figures in the calculation below + // is left as an exercise to the reader :-) + record.where.v = postZoomPos.y() + m_windowRect.y() - 22; + } + } record.modifiers = modifiersForEvent(event); if (!event->buttonDown()) @@ -583,8 +688,10 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event) LOG(Plugins, "PV::hKE(): record.modifiers: %d", record.modifiers); +#if PLATFORM(QT) LOG(Plugins, "PV::hKE(): PKE.qtEvent()->nativeVirtualKey: 0x%02X, charCode: %d", keyCode, int(uchar(charCodes[0]))); +#endif if (!dispatchNPEvent(record)) LOG(Events, "PluginView::handleKeyboardEvent(): Keyboard event type %d not accepted", record.what); @@ -592,22 +699,6 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event) event->setDefaultHandled(); } -void PluginView::nullEventTimerFired(Timer<PluginView>*) -{ - EventRecord record; - - record.what = nullEvent; - record.message = 0; - record.when = TickCount(); - record.where = globalMousePosForPlugin(); - record.modifiers = GetCurrentKeyModifiers(); - if (!Button()) - record.modifiers |= btnState; - - if (!dispatchNPEvent(record)) - LOG(Events, "PluginView::nullEventTimerFired(): Null event not accepted"); -} - static int modifiersForEvent(UIEventWithKeyState* event) { int modifiers = 0; @@ -649,6 +740,18 @@ Point PluginView::globalMousePosForPlugin() const pos.h = short(pos.h * scaleFactor); pos.v = short(pos.v * scaleFactor); +#if PLATFORM(WX) + // make sure the titlebar/toolbar size is included + WindowRef windowRef = nativeWindowFor(platformPluginWidget()); + ::Rect content, structure; + + GetWindowBounds(windowRef, kWindowStructureRgn, &structure); + GetWindowBounds(windowRef, kWindowContentRgn, &content); + + int top = content.top - structure.top; + pos.v -= top; +#endif + return pos; } diff --git a/WebCore/plugins/qt/PluginDataQt.cpp b/WebCore/plugins/qt/PluginDataQt.cpp index 5478d38..a836937 100644 --- a/WebCore/plugins/qt/PluginDataQt.cpp +++ b/WebCore/plugins/qt/PluginDataQt.cpp @@ -24,18 +24,15 @@ #include "PluginDatabase.h" #include "PluginPackage.h" -#if QT_VERSION >= 0x040400 #include "ChromeClientQt.h" #include "Page.h" #include <qwebpage.h> #include <qwebpluginfactory.h> -#endif namespace WebCore { void PluginData::initPlugins() { -#if QT_VERSION >= 0x040400 QWebPage* webPage = static_cast<ChromeClientQt*>(m_page->chrome()->client())->m_webPage; QWebPluginFactory* factory = webPage->pluginFactory(); if (factory) { @@ -62,7 +59,6 @@ void PluginData::initPlugins() m_plugins.append(info); } } -#endif PluginDatabase *db = PluginDatabase::installedPlugins(); const Vector<PluginPackage*> &plugins = db->plugins(); diff --git a/WebCore/plugins/qt/PluginViewQt.cpp b/WebCore/plugins/qt/PluginViewQt.cpp index e61736b..063a7e5 100644 --- a/WebCore/plugins/qt/PluginViewQt.cpp +++ b/WebCore/plugins/qt/PluginViewQt.cpp @@ -138,26 +138,14 @@ void PluginView::setFocus() void PluginView::show() { - setSelfVisible(true); - - if (isParentVisible() && platformPluginWidget()) - platformPluginWidget()->setVisible(true); - - // do not call parent impl. here as it will set the platformWidget - // (same as platformPluginWidget in the Qt port) to visible, even - // when parent isn't visible. + Q_ASSERT(platformPluginWidget() == platformWidget()); + Widget::show(); } void PluginView::hide() { - setSelfVisible(false); - - if (isParentVisible() && platformPluginWidget()) - platformPluginWidget()->setVisible(false); - - // do not call parent impl. here as it will set the platformWidget - // (same as platformPluginWidget in the Qt port) to invisible, even - // when parent isn't visible. + Q_ASSERT(platformPluginWidget() == platformWidget()); + Widget::hide(); } void PluginView::paint(GraphicsContext* context, const IntRect& rect) diff --git a/WebCore/plugins/win/PluginViewWin.cpp b/WebCore/plugins/win/PluginViewWin.cpp index 5ccce0e..89eecc6 100644 --- a/WebCore/plugins/win/PluginViewWin.cpp +++ b/WebCore/plugins/win/PluginViewWin.cpp @@ -30,7 +30,9 @@ #include "PluginView.h" #include "BitmapImage.h" +#if !PLATFORM(WX) #include "BitmapInfo.h" +#endif #include "Document.h" #include "DocumentLoader.h" #include "Element.h" @@ -81,12 +83,21 @@ #include <QWidget> #endif +#if PLATFORM(WX) +#include <wx/defs.h> +#include <wx/window.h> +#endif + static inline HWND windowHandleForPageClient(PlatformPageClient client) { #if PLATFORM(QT) if (!client) return 0; return client->ownerWidget()->winId(); +#elif PLATFORM(WX) + if (!client) + return 0; + return (HWND)client->GetHandle(); #else return client; #endif @@ -145,7 +156,7 @@ HDC WINAPI PluginView::hookedBeginPaint(HWND hWnd, PAINTSTRUCT* lpPaint) "push %3\n" "call *%4\n" : "=a" (result) - : "a" (beginPaintSysCall), "g" (lpPaint), "g" (hWnd), "m" (*beginPaint) + : "a" (beginPaintSysCall), "g" (lpPaint), "g" (hWnd), "m" (beginPaint) : "memory" ); return result; @@ -175,7 +186,7 @@ BOOL WINAPI PluginView::hookedEndPaint(HWND hWnd, const PAINTSTRUCT* lpPaint) "push %3\n" "call *%4\n" : "=a" (result) - : "a" (endPaintSysCall), "g" (lpPaint), "g" (hWnd), "m" (*endPaint) + : "a" (endPaintSysCall), "g" (lpPaint), "g" (hWnd), "m" (endPaint) ); return result; #elif defined (_M_IX86) @@ -702,7 +713,7 @@ void PluginView::handleMouseEvent(MouseEvent* event) if (!dispatchNPEvent(npEvent)) event->setDefaultHandled(); -#if !PLATFORM(QT) && !PLATFORM(WINCE) +#if !PLATFORM(QT) && !PLATFORM(WX) && !PLATFORM(WINCE) // 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; @@ -987,7 +998,7 @@ bool PluginView::platformStart() HWND window = ::CreateWindowEx(0, kWebPluginViewdowClassName, 0, flags, 0, 0, 0, 0, parentWindowHandle, 0, Page::instanceHandle(), 0); -#if PLATFORM(WIN_OS) && PLATFORM(QT) +#if PLATFORM(WIN_OS) && (PLATFORM(QT) || PLATFORM(WX)) m_window = window; #else setPlatformWidget(window); @@ -1030,6 +1041,7 @@ void PluginView::platformDestroy() PassRefPtr<Image> PluginView::snapshot() { +#if !PLATFORM(WX) OwnPtr<HDC> hdc(CreateCompatibleDC(0)); if (!m_isWindowed) { @@ -1059,6 +1071,9 @@ PassRefPtr<Image> PluginView::snapshot() SelectObject(hdc.get(), hbmpOld); return BitmapImage::create(hbmp.get()); +#else + return 0; +#endif } void PluginView::halt() diff --git a/WebCore/plugins/wx/PluginDataWx.cpp b/WebCore/plugins/wx/PluginDataWx.cpp new file mode 100644 index 0000000..58ee315 --- /dev/null +++ b/WebCore/plugins/wx/PluginDataWx.cpp @@ -0,0 +1,78 @@ +/* + * 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" +#include "PluginDatabase.h" +#include "PluginPackage.h" + +namespace WebCore { + +void PluginData::initPlugins() +{ + PluginDatabase* db = PluginDatabase::installedPlugins(); + const Vector<PluginPackage*> &plugins = db->plugins(); + + for (unsigned int i = 0; i < plugins.size(); ++i) { + PluginInfo* info = new PluginInfo; + PluginPackage* package = plugins[i]; + + info->name = package->name(); + info->file = package->fileName(); + info->desc = package->description(); + + const MIMEToDescriptionsMap& mimeToDescriptions = package->mimeToDescriptions(); + MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end(); + for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) { + MimeClassInfo* mime = new MimeClassInfo; + info->mimes.append(mime); + + mime->type = it->first; + mime->desc = it->second; + mime->plugin = info; + + Vector<String> extensions = package->mimeToExtensions().get(mime->type); + + for (unsigned i = 0; i < extensions.size(); i++) { + if (i > 0) + mime->suffixes += ","; + + mime->suffixes += extensions[i]; + } + } + + m_plugins.append(info); + } +} + +void PluginData::refresh() +{ + notImplemented(); +} + +}; |