summaryrefslogtreecommitdiffstats
path: root/WebCore/plugins/mac/PluginViewMac.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/plugins/mac/PluginViewMac.cpp')
-rw-r--r--WebCore/plugins/mac/PluginViewMac.cpp84
1 files changed, 31 insertions, 53 deletions
diff --git a/WebCore/plugins/mac/PluginViewMac.cpp b/WebCore/plugins/mac/PluginViewMac.cpp
index 26f9eba..0ab91d1 100644
--- a/WebCore/plugins/mac/PluginViewMac.cpp
+++ b/WebCore/plugins/mac/PluginViewMac.cpp
@@ -75,6 +75,7 @@ using JSC::UString;
#if PLATFORM(QT)
#include <QWidget>
#include <QKeyEvent>
+#include "QWebPageClient.h"
QT_BEGIN_NAMESPACE
#if QT_VERSION < 0x040500
extern Q_GUI_EXPORT WindowPtr qt_mac_window_for(const QWidget* w);
@@ -125,30 +126,10 @@ static inline IntPoint topLevelOffsetFor(PlatformWidget widget)
// --------------- Lifetime management -----------------
-void PluginView::init()
+bool PluginView::platformStart()
{
- LOG(Plugins, "PluginView::init(): Initializing plug-in '%s'", m_plugin->name().utf8().data());
-
- if (m_haveInitialized)
- return;
- m_haveInitialized = true;
-
- if (!m_plugin) {
- ASSERT(m_status == PluginStatusCanNotFindPlugin);
- return;
- }
-
- if (!m_plugin->load()) {
- m_plugin = 0;
- m_status = PluginStatusCanNotLoadPlugin;
- return;
- }
-
- if (!start()) {
- m_status = PluginStatusCanNotLoadPlugin;
- stop(); // Make sure we unregister the plugin
- return;
- }
+ ASSERT(m_isStarted);
+ ASSERT(m_status == PluginStatusLoadedSuccessfully);
if (m_drawingModel == NPDrawingModel(-1)) {
// We default to QuickDraw, even though we don't support it,
@@ -180,8 +161,7 @@ void PluginView::init()
m_status = PluginStatusCanNotLoadPlugin;
LOG(Plugins, "Plug-in '%s' uses unsupported event model %s",
m_plugin->name().utf8().data(), prettyNameForEventModel(m_eventModel));
- stop();
- return;
+ return false;
}
if (getValueStatic(NPNVariable(NPNVsupportsQuickDrawBool + m_drawingModel), &drawingModelSupported) != NPERR_NO_ERROR
@@ -189,38 +169,30 @@ void PluginView::init()
m_status = PluginStatusCanNotLoadPlugin;
LOG(Plugins, "Plug-in '%s' uses unsupported drawing model %s",
m_plugin->name().utf8().data(), prettyNameForDrawingModel(m_drawingModel));
- stop();
- return;
+ return false;
}
- setPlatformPluginWidget(m_parentFrame->view()->hostWindow()->platformWindow());
+#if PLATFORM(QT)
+ if (QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient()) {
+ if (QWidget* window = QWidget::find(client->winId())) {
+ setPlatformPluginWidget(window);
+ }
+ }
+#endif
show();
- m_status = PluginStatusLoadedSuccessfully;
-
// TODO: Implement null timer throttling depending on plugin activation
m_nullEventTimer.set(new Timer<PluginView>(this, &PluginView::nullEventTimerFired));
m_nullEventTimer->startRepeating(0.02);
+
+ return true;
}
-PluginView::~PluginView()
+void PluginView::platformDestroy()
{
- LOG(Plugins, "PluginView::~PluginView()");
-
- stop();
-
- deleteAllValues(m_requests);
-
- freeStringArray(m_paramNames, m_paramCount);
- freeStringArray(m_paramValues, m_paramCount);
-
- m_parentFrame->script()->cleanupScriptObjectsForPlugin(this);
-
- if (m_plugin && !(m_plugin->quirks().contains(PluginQuirkDontUnloadPlugin)))
- m_plugin->unload();
-
- m_window = 0;
+ if (platformPluginWidget())
+ setPlatformPluginWidget(0);
}
// Used before the plugin view has been initialized properly, and as a
@@ -456,6 +428,14 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
setNPWindowIfNeeded();
+ CGContextRef cgContext = m_npCgContext.context;
+ if (!cgContext)
+ return;
+
+ CGContextSaveGState(cgContext);
+ IntPoint offset = frameRect().location();
+ CGContextTranslateCTM(cgContext, offset.x(), offset.y());
+
EventRecord event;
event.what = updateEvt;
event.message = (long unsigned int)m_npCgContext.window;
@@ -464,15 +444,10 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
event.where.v = 0;
event.modifiers = GetCurrentKeyModifiers();
- CGContextRef cg = m_npCgContext.context;
- CGContextSaveGState(cg);
- IntPoint offset = frameRect().location();
- CGContextTranslateCTM(cg, offset.x(), offset.y());
-
if (!dispatchNPEvent(event))
LOG(Events, "PluginView::paint(): Paint event not accepted");
- CGContextRestoreGState(cg);
+ CGContextRestoreGState(cgContext);
}
void PluginView::invalidateRect(const IntRect& rect)
@@ -717,10 +692,13 @@ NPError PluginView::handlePostReadFile(Vector<char>& buffer, uint32 len, const c
return NPERR_NO_ERROR;
}
-void PluginView::platformStart()
+void PluginView::halt()
{
}
+void PluginView::restart()
+{
+}
} // namespace WebCore