From 5655832af95b56bf25c0183a2d5d2cd909d6c8f4 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Mon, 3 Aug 2009 15:45:38 -0400 Subject: Fixing mouse and touch coordinates inside iframes. --- WebKit/android/plugins/PluginWidgetAndroid.cpp | 26 ++++++++++++++++++++++---- WebKit/android/plugins/PluginWidgetAndroid.h | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'WebKit') diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index 30a55cb..96aa74b 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -71,7 +71,8 @@ void PluginWidgetAndroid::setWindow(NPWindow* window, bool isTransparent) { if (m_drawingModel == kSurface_ANPDrawingModel) { if (m_surface) { - m_surface->attach(window->x, window->y, window->width, window->height); + IntPoint docPoint = getDocumentCoordinates(window->x, window->y); + m_surface->attach(docPoint.x(), docPoint.y(), window->width, window->height); } } else { m_flipPixelRef->safeUnref(); @@ -292,9 +293,7 @@ void PluginWidgetAndroid::scrollToVisibleFrameRect() { // this requires converting the m_requestedFrameRect from frame to doc coordinates // find the center of the visibleRect in document coordinates - ScrollView* scrollView = m_pluginView->parent(); - IntPoint pluginFramePoint = IntPoint(m_requestedFrameRect.fLeft, m_requestedFrameRect.fTop); - IntPoint pluginDocPoint = scrollView->convertToContainingWindow(pluginFramePoint); + IntPoint pluginDocPoint = getDocumentCoordinates(m_requestedFrameRect.fLeft, m_requestedFrameRect.fTop); int rectCenterX = pluginDocPoint.x() + m_requestedFrameRect.width()/2; int rectCenterY = pluginDocPoint.y() + m_requestedFrameRect.height()/2; @@ -306,6 +305,25 @@ void PluginWidgetAndroid::scrollToVisibleFrameRect() { int deltaX = rectCenterX - screenCenterX; int deltaY = rectCenterY - screenCenterY; + ScrollView* scrollView = m_pluginView->parent(); android::WebViewCore* core = android::WebViewCore::getWebViewCore(scrollView); core->scrollBy(deltaX, deltaY, true); } + +IntPoint PluginWidgetAndroid::getDocumentCoordinates(int frameX, int frameY) { + IntPoint docPoint = IntPoint(frameX, frameY); + + const ScrollView* currentScrollView = m_pluginView->parent(); + if (currentScrollView) { + const ScrollView* parentScrollView = currentScrollView->parent(); + while (parentScrollView) { + + docPoint.move(currentScrollView->x(), currentScrollView->y()); + + currentScrollView = parentScrollView; + parentScrollView = parentScrollView->parent(); + } + } + + return docPoint; +} diff --git a/WebKit/android/plugins/PluginWidgetAndroid.h b/WebKit/android/plugins/PluginWidgetAndroid.h index 1da618f..cc2d206 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.h +++ b/WebKit/android/plugins/PluginWidgetAndroid.h @@ -27,6 +27,7 @@ #define PluginWidgetAndroid_H #include "android_npapi.h" +#include "IntPoint.h" #include "SkRect.h" #include @@ -132,6 +133,7 @@ struct PluginWidgetAndroid { void setVisibleRects(const ANPRectI rects[], int32_t count); private: + WebCore::IntPoint getDocumentCoordinates(int frameX, int frameY); void computeVisibleFrameRect(); void scrollToVisibleFrameRect(); -- cgit v1.1