summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/android/plugins
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2011-09-06 16:03:58 -0400
committerDerek Sollenberger <djsollen@google.com>2011-09-06 16:03:58 -0400
commitb69c70c87600c96d612b5b4df6fb77e9829e772b (patch)
tree5e51ba53ea2f3677654d78aaee066c3b80fb1b6b /Source/WebKit/android/plugins
parent8ad3ab0e47f0d5039e89c1873c178f538ec1b0df (diff)
downloadexternal_webkit-b69c70c87600c96d612b5b4df6fb77e9829e772b.zip
external_webkit-b69c70c87600c96d612b5b4df6fb77e9829e772b.tar.gz
external_webkit-b69c70c87600c96d612b5b4df6fb77e9829e772b.tar.bz2
Fix for plugin being "centered" to the left corner instead of center
bug: 5149930 Change-Id: I23aa7f8292806897cbc99f7a36e6aec428daf859
Diffstat (limited to 'Source/WebKit/android/plugins')
-rw-r--r--Source/WebKit/android/plugins/PluginWidgetAndroid.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp b/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp
index c4c31e5..761e948 100644
--- a/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp
+++ b/Source/WebKit/android/plugins/PluginWidgetAndroid.cpp
@@ -49,6 +49,8 @@
#define DEBUG_EVENTS 0 // logs event contents, return value, and processing time
#define DEBUG_VISIBLE_RECTS 0 // temporary debug printfs and fixes
+#define MAX( a, b ) ( ((a) > (b)) ? (a) : (b) )
+
// this include statement must follow the declaration of PLUGIN_DEBUG_LOCAL
#include "PluginDebugAndroid.h"
@@ -571,20 +573,17 @@ void PluginWidgetAndroid::scrollToVisiblePluginRect() {
int rectCenterX = m_requestedVisibleRect.fLeft + m_requestedVisibleRect.width()/2;
int rectCenterY = m_requestedVisibleRect.fTop + m_requestedVisibleRect.height()/2;
- // find document coordinates for center of the visible screen
- int visibleDocCenterX = m_visibleDocRect.fLeft + m_visibleDocRect.width()/2;
- int visibleDocCenterY = m_visibleDocRect.fTop + m_visibleDocRect.height()/2;
-
- //compute the delta of the two points and scale to screen coordinates
- int deltaX = rectCenterX - visibleDocCenterX;
- int deltaY = rectCenterY - visibleDocCenterY;
+ // position the corner of the visible doc to center the requested rect
+ int scrollDocX = MAX(0, rectCenterX - (m_visibleDocRect.width()/2));
+ int scrollDocY = MAX(0, rectCenterY - (m_visibleDocRect.height()/2));
ScrollView* scrollView = m_pluginView->parent();
android::WebViewCore* core = android::WebViewCore::getWebViewCore(scrollView);
#if DEBUG_VISIBLE_RECTS
- PLUGIN_LOG("%s call scrollBy (%d,%d)", __FUNCTION__, deltaX, deltaY);
+ PLUGIN_LOG("%s call scrollTo (%d,%d) to center (%d,%d)", __FUNCTION__,
+ scrollDocX, scrollDocX, rectCenterX, rectCenterY);
#endif
- core->scrollTo(rectCenterX, rectCenterY, true);
+ core->scrollTo(scrollDocX, scrollDocX, true);
}
void PluginWidgetAndroid::requestFullScreen() {