diff options
Diffstat (limited to 'WebCore/plugins/android/PluginViewAndroid.cpp')
-rw-r--r-- | WebCore/plugins/android/PluginViewAndroid.cpp | 99 |
1 files changed, 55 insertions, 44 deletions
diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index 09117ae..f10ac45 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -50,19 +50,20 @@ #include "PlatformKeyboardEvent.h" #include "PluginMainThreadScheduler.h" #include "PluginPackage.h" -// #include "kjs_binding.h" -// #include "kjs_proxy.h" #include "android_graphics.h" #include "SkCanvas.h" #include "npruntime_impl.h" -#include "runtime_root.h" +// #include "runtime_root.h" #include "utils/SystemClock.h" #include "ScriptController.h" #include "Settings.h" + +#if USE(JSC) #include <runtime/JSLock.h> -// #include <kjs/value.h> +#endif + #include <wtf/ASCIICType.h> -#include "runtime.h" +// #include "runtime.h" #include "WebViewCore.h" #include "PluginDebug.h" @@ -77,11 +78,13 @@ /////////////////////////////////////////////////////////////////////////////// extern void ANPAudioTrackInterfaceV0_Init(ANPInterface* value); +extern void ANPBitmapInterfaceV0_Init(ANPInterface* value); extern void ANPCanvasInterfaceV0_Init(ANPInterface* value); extern void ANPLogInterfaceV0_Init(ANPInterface* value); extern void ANPMatrixInterfaceV0_Init(ANPInterface* value); extern void ANPOffscreenInterfaceV0_Init(ANPInterface* value); extern void ANPPaintInterfaceV0_Init(ANPInterface* value); +extern void ANPPathInterfaceV0_Init(ANPInterface* value); extern void ANPTypefaceInterfaceV0_Init(ANPInterface* value); extern void ANPWindowInterfaceV0_Init(ANPInterface* value); @@ -96,10 +99,12 @@ struct VarProcPair { static const VarProcPair gVarProcs[] = { { VARPROCLINE(AudioTrackInterfaceV0) }, - { VARPROCLINE(LogInterfaceV0) }, + { VARPROCLINE(BitmapInterfaceV0) }, { VARPROCLINE(CanvasInterfaceV0) }, + { VARPROCLINE(LogInterfaceV0) }, { VARPROCLINE(MatrixInterfaceV0) }, { VARPROCLINE(PaintInterfaceV0) }, + { VARPROCLINE(PathInterfaceV0) }, { VARPROCLINE(TypefaceInterfaceV0) }, { VARPROCLINE(WindowInterfaceV0) }, }; @@ -131,12 +136,6 @@ static bool anp_getInterface(NPNVariable var, void* value, NPError* error) { /////////////////////////////////////////////////////////////////////////////// -using JSC::ExecState; -using JSC::Interpreter; -using JSC::JSLock; -using JSC::JSObject; -using JSC::UString; - using std::min; using namespace WTF; @@ -152,22 +151,22 @@ void PluginView::platformInit() m_isWindowed = false; // we don't support windowed yet m_window = new PluginWidgetAndroid(this); - + m_npWindow.type = NPWindowTypeDrawable; m_npWindow.window = 0; } - + PluginView::~PluginView() { stop(); - + deleteAllValues(m_requests); - + freeStringArray(m_paramNames, m_paramCount); freeStringArray(m_paramValues, m_paramCount); - + m_parentFrame->script()->cleanupScriptObjectsForPlugin(this); - + // Since we have no legacy plugins to check, we ignore the quirks check // if (m_plugin && !m_plugin->quirks().contains(PluginQuirkDontUnloadPlugin)) if (m_plugin) { @@ -189,38 +188,47 @@ void PluginView::init() ASSERT(m_status == PluginStatusCanNotFindPlugin); return; } - + if (!m_plugin->load()) { m_plugin = 0; m_status = PluginStatusCanNotLoadPlugin; return; } - + if (!start()) { m_status = PluginStatusCanNotLoadPlugin; return; } - + m_status = PluginStatusLoadedSuccessfully; } - + void PluginView::handleMouseEvent(MouseEvent* event) { const AtomicString& type = event->type(); bool isDown = (eventNames().mousedownEvent == type); bool isUp = (eventNames().mouseupEvent == type); - if (!isDown && !isUp) { - return; - } - + bool isOver = (eventNames().mouseoverEvent == type); + bool isOut = (eventNames().mouseoutEvent == type); + ANPEvent evt; - SkANP::InitEvent(&evt, kTouch_ANPEventType); - evt.data.touch.action = isDown ? kDown_ANPTouchAction : kUp_ANPTouchAction; - evt.data.touch.modifiers = 0; // todo - // these are relative to plugin - evt.data.touch.x = event->pageX() - m_npWindow.x; - evt.data.touch.y = event->pageY() - m_npWindow.y; + if (isDown || isUp) { + SkANP::InitEvent(&evt, kTouch_ANPEventType); + evt.data.touch.action = isDown ? kDown_ANPTouchAction : kUp_ANPTouchAction; + evt.data.touch.modifiers = 0; // todo + // these are relative to plugin + evt.data.touch.x = event->pageX() - m_npWindow.x; + evt.data.touch.y = event->pageY() - m_npWindow.y; + } + else if (isOver || isOut) { + SkANP::InitEvent(&evt, kLifecycle_ANPEventType); + evt.data.lifecycle.action = isOver ? kGainFocus_ANPLifecycleAction : kLooseFocus_ANPLifecycleAction; + } + else { + return; + } + if (m_plugin->pluginFuncs()->event(m_instance, &evt)) { event->setDefaultHandled(); } @@ -275,7 +283,7 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event) evt.data.key.repeatCount = pke->repeatCount(); evt.data.key.modifiers = make_modifiers(pke->shiftKey(), pke->altKey()); evt.data.key.unichar = pke->unichar(); - + if (m_plugin->pluginFuncs()->event(m_instance, &evt)) { event->setDefaultHandled(); } @@ -312,7 +320,7 @@ void PluginView::setNPWindowRect(const IntRect& rect) { if (!m_isStarted) return; - + const int width = rect.width(); const int height = rect.height(); @@ -320,22 +328,24 @@ void PluginView::setNPWindowRect(const IntRect& rect) IntPoint p = parent()->convertToContainingWindow(rect.location()); m_npWindow.x = p.x(); m_npWindow.y = p.y(); - + m_npWindow.width = width; m_npWindow.height = height; - + m_npWindow.clipRect.left = 0; m_npWindow.clipRect.top = 0; m_npWindow.clipRect.right = width; m_npWindow.clipRect.bottom = height; if (m_plugin->pluginFuncs()->setwindow) { +#if USE(JSC) JSC::JSLock::DropAllLocks dropAllLocks(false); +#endif setCallingPlugin(true); m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow); setCallingPlugin(false); } - + m_window->setWindow(m_npWindow.x, m_npWindow.y, width, height, m_isTransparent); } @@ -355,8 +365,9 @@ void PluginView::stop() ASSERT(m_streams.isEmpty()); m_isStarted = false; - +#if USE(JSC) JSC::JSLock::DropAllLocks dropAllLocks(false); +#endif PluginMainThreadScheduler::scheduler().unregisterPlugin(m_instance); @@ -446,13 +457,13 @@ NPError PluginView::getValue(NPNVariable variable, void* value) *retValue = !networkStateNotifier().onLine(); return NPERR_NO_ERROR; } - + case kSupportedDrawingModel_ANPGetValue: { uint32_t* bits = reinterpret_cast<uint32_t*>(value); *bits = (1 << kBitmap_ANPDrawingModel); return NPERR_NO_ERROR; } - + default: { NPError error = NPERR_GENERIC_ERROR; (void)anp_getInterface(variable, value, &error); @@ -538,12 +549,12 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) paintMissingPluginIcon(context, rect); return; } - + IntRect frame = frameRect(); if (!frame.width() || !frame.height()) { return; } - + m_window->inval(rect, false); m_window->draw(android_gc2canvas(context)); } @@ -559,8 +570,8 @@ void PluginView::updatePluginWidget() } // new as of SVN 38068, Nov 5 2008 -void PluginView::setParentVisible(bool) { - notImplemented(); +void PluginView::setParentVisible(bool) { + notImplemented(); } } // namespace WebCore |