diff options
author | Grace Kloba <klobag@google.com> | 2010-01-19 19:00:16 -0800 |
---|---|---|
committer | Grace Kloba <klobag@google.com> | 2010-01-20 08:44:59 -0800 |
commit | 1f15f3a9f6dc2a169bbd160e2e1abb161f9927d9 (patch) | |
tree | 3f05712e2467690c62b0a7e92e800cdc8fb6d011 /WebCore/plugins | |
parent | 032a9065415ac4791c8d73bceba10cfa9fc77bf7 (diff) | |
download | external_webkit-1f15f3a9f6dc2a169bbd160e2e1abb161f9927d9.zip external_webkit-1f15f3a9f6dc2a169bbd160e2e1abb161f9927d9.tar.gz external_webkit-1f15f3a9f6dc2a169bbd160e2e1abb161f9927d9.tar.bz2 |
Changing plugin setwindow() to use page coordinate
instead of frame as it is what Flash expects. For
other port like Mac, it passes the window coordinate
to the plugin. In Android, plugin always sees the
full page and we use the visible screen rect to
indicate whether it is visible.
Change to use page coordinate across PluginView and
PluginWidget for consistency. This should fix the
problem Ben saw with plugin inside iframe (which is
caused by a race condition) and the cnnn ad problem
Adobe has.
Diffstat (limited to 'WebCore/plugins')
-rw-r--r-- | WebCore/plugins/PluginView.cpp | 7 | ||||
-rw-r--r-- | WebCore/plugins/PluginView.h | 2 | ||||
-rw-r--r-- | WebCore/plugins/android/PluginViewAndroid.cpp | 69 |
3 files changed, 45 insertions, 33 deletions
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp index 129a21c..89713b5 100644 --- a/WebCore/plugins/PluginView.cpp +++ b/WebCore/plugins/PluginView.cpp @@ -131,15 +131,8 @@ void PluginView::setFrameRect(const IntRect& rect) if (m_element->document()->printing()) return; -#if defined(ANDROID_PLUGINS) - if (m_isStarted && (rect != frameRect())) { - Widget::setFrameRect(rect); - setNPWindowRect(rect); // only call when it changes - } -#else if (rect != frameRect()) Widget::setFrameRect(rect); -#endif updatePluginWidget(); diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h index a5618f7..0ce9c7c 100644 --- a/WebCore/plugins/PluginView.h +++ b/WebCore/plugins/PluginView.h @@ -373,7 +373,7 @@ public: private: -#if defined(XP_UNIX) || defined(Q_WS_X11) || PLATFORM(SYMBIAN) +#if defined(XP_UNIX) || defined(Q_WS_X11) || PLATFORM(SYMBIAN) || defined(ANDROID_PLUGINS) void setNPWindowIfNeeded(); #elif defined(XP_MACOSX) NP_CGContext m_npCgContext; diff --git a/WebCore/plugins/android/PluginViewAndroid.cpp b/WebCore/plugins/android/PluginViewAndroid.cpp index e10641d..c4bccdb 100644 --- a/WebCore/plugins/android/PluginViewAndroid.cpp +++ b/WebCore/plugins/android/PluginViewAndroid.cpp @@ -206,11 +206,11 @@ void PluginView::handleTouchEvent(TouchEvent* event) evt.data.touch.modifiers = 0; // todo - // convert to coordinates that are relative to the plugin. The pageX / pageY - // values are the only values in the event that are consistently in frame - // coordinates despite their misleading name. - evt.data.touch.x = event->pageX() - m_npWindow.x; - evt.data.touch.y = event->pageY() - m_npWindow.y; + // convert to coordinates that are relative to the plugin. + IntPoint localPos = roundedIntPoint(m_element->renderer()->absoluteToLocal( + IntPoint(event->pageX(), event->pageY()))); + evt.data.touch.x = localPos.x(); + evt.data.touch.y = localPos.y(); int16 ret = m_plugin->pluginFuncs()->event(m_instance, &evt); if (ignoreRet) @@ -243,11 +243,11 @@ void PluginView::handleMouseEvent(MouseEvent* event) SkANP::InitEvent(&evt, kMouse_ANPEventType); evt.data.mouse.action = isUp ? kUp_ANPMouseAction : kDown_ANPMouseAction; - // convert to coordinates that are relative to the plugin. The pageX / pageY - // values are the only values in the event that are consistently in frame - // coordinates despite their misleading name. - evt.data.mouse.x = event->pageX() - m_npWindow.x; - evt.data.mouse.y = event->pageY() - m_npWindow.y; + // convert to coordinates that are relative to the plugin. + IntPoint localPos = roundedIntPoint(m_element->renderer()->absoluteToLocal( + IntPoint(event->pageX(), event->pageY()))); + evt.data.mouse.x = localPos.x(); + evt.data.mouse.y = localPos.y(); if (isDown) { // The plugin needs focus to receive keyboard events if (Page* page = m_parentFrame->page()) @@ -394,21 +394,34 @@ void PluginView::setParent(ScrollView* parent) } } -void PluginView::setNPWindowRect(const IntRect& rect) +void PluginView::setNPWindowRect(const IntRect&) { - if (!m_isStarted) - return; + setNPWindowIfNeeded(); +} - // the rect is relative to the frameview's (0,0) - m_npWindow.x = rect.x(); - m_npWindow.y = rect.y(); - m_npWindow.width = rect.width(); - m_npWindow.height = rect.height(); +void PluginView::setNPWindowIfNeeded() +{ + if (!m_isStarted || !parent()) + return; - m_npWindow.clipRect.left = 0; - m_npWindow.clipRect.top = 0; - m_npWindow.clipRect.right = rect.width(); - m_npWindow.clipRect.bottom = rect.height(); + // in Android, plugin always get the setwindow() in the page coordinate. + IntRect pageRect = m_windowRect; + ScrollView* top = parent(); + while (top->parent()) + top = top->parent(); + // only the top ScrollView can have the offset + pageRect.move(top->scrollOffset()); + + // the m_npWindow is relative to the page + m_npWindow.x = pageRect.x(); + m_npWindow.y = pageRect.y(); + m_npWindow.width = pageRect.width(); + m_npWindow.height = pageRect.height(); + + m_npWindow.clipRect.left = pageRect.x(); + m_npWindow.clipRect.top = pageRect.y(); + m_npWindow.clipRect.right = pageRect.x() + pageRect.width(); + m_npWindow.clipRect.bottom = pageRect.y() + pageRect.height(); if (m_plugin->pluginFuncs()->setwindow) { #if USE(JSC) @@ -587,16 +600,22 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect) } m_window->inval(rect, false); + context->save(); + context->translate(frame.x(), frame.y()); m_window->draw(android_gc2canvas(context)); + context->restore(); } -// new as of SVN 38068, Nov 5 2008 void PluginView::updatePluginWidget() { - // I bet/hope we can move all of setNPWindowRect() into here FrameView* frameView = static_cast<FrameView*>(parent()); if (frameView) { - m_windowRect = IntRect(frameView->contentsToWindow(frameRect().location()), frameRect().size()); + IntRect oldWindowRect = m_windowRect; + + m_windowRect = frameView->contentsToWindow(frameRect()); + + if (m_windowRect != oldWindowRect) + setNPWindowIfNeeded(); } } |