diff options
| author | Grace Kloba <klobag@google.com> | 2010-03-12 19:19:48 -0800 |
|---|---|---|
| committer | Grace Kloba <klobag@google.com> | 2010-03-16 14:21:21 -0700 |
| commit | 1e65d9e561bfc72f6f5297613be76883a37f83f0 (patch) | |
| tree | fef11d5e7a39dcae1a89c369f9e90ab39818b3d5 /core/java/android/webkit/WebView.java | |
| parent | 43bde92913d1471ae90acf057c4b2324ac6e1905 (diff) | |
Use float instead of cast to int when calculating
the new zoom center. This should avoid the rounding
difference which caused the video in nytimes.com
not fully fit in the current view.
Fix http://b/issue?id=2512510
Diffstat (limited to 'core/java/android/webkit/WebView.java')
| -rw-r--r-- | core/java/android/webkit/WebView.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 52bc8be10e4f..83cd528a347b 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -5761,11 +5761,11 @@ public class WebView extends AbsoluteLayout contentToViewY(docY + docHeight / 2) - viewHeight / 2, true, 0); } else { - int oldScreenX = contentToViewX(docX) - mScrollX; - int rectViewX = (int) (docX * scale); - int rectViewWidth = (int) (docWidth * scale); - int newMaxWidth = (int) (mContentWidth * scale); - int newScreenX = (viewWidth - rectViewWidth) / 2; + float oldScreenX = docX * mActualScale - mScrollX; + float rectViewX = docX * scale; + float rectViewWidth = docWidth * scale; + float newMaxWidth = mContentWidth * scale; + float newScreenX = (viewWidth - rectViewWidth) / 2; // pin the newX to the WebView if (newScreenX > rectViewX) { newScreenX = rectViewX; @@ -5774,12 +5774,12 @@ public class WebView extends AbsoluteLayout } mZoomCenterX = (oldScreenX * scale - newScreenX * mActualScale) / (scale - mActualScale); - int oldScreenY = contentToViewY(docY) - mScrollY; - int rectViewY = (int) (docY * scale) + getTitleHeight(); - int rectViewHeight = (int) (docHeight * scale); - int newMaxHeight = (int) (mContentHeight * scale) - + getTitleHeight(); - int newScreenY = (viewHeight - rectViewHeight) / 2; + float oldScreenY = docY * mActualScale + getTitleHeight() + - mScrollY; + float rectViewY = docY * scale + getTitleHeight(); + float rectViewHeight = docHeight * scale; + float newMaxHeight = mContentHeight * scale + getTitleHeight(); + float newScreenY = (viewHeight - rectViewHeight) / 2; // pin the newY to the WebView if (newScreenY > rectViewY) { newScreenY = rectViewY; |
