summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorNicolas Roard <nicolas@android.com>2010-05-10 15:15:51 -0700
committerNicolas Roard <nicolas@android.com>2010-05-10 19:31:54 -0700
commitf78acacb0d7a8e4d9e85a1cd6eed0f6bb38d6776 (patch)
tree873c4de8303d71d6ab1303bd7151c847bf810453 /core
parent6d00151c519d5c131cc1480978fe4417cc7bcc79 (diff)
downloadframeworks_base-f78acacb0d7a8e4d9e85a1cd6eed0f6bb38d6776.zip
frameworks_base-f78acacb0d7a8e4d9e85a1cd6eed0f6bb38d6776.tar.gz
frameworks_base-f78acacb0d7a8e4d9e85a1cd6eed0f6bb38d6776.tar.bz2
Fix the 'wobbling fixed elements' bug.
Cherry-picked from master. This CL has a corresponding C++ counterpart (https://android-git.corp.google.com/g/#change,51149) Bug:2665696 Change-Id: I0a044661ff21ef601ba34782db8acdc9531f98e7
Diffstat (limited to 'core')
-rw-r--r--core/java/android/webkit/WebView.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 6b316ce..f921caa 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -30,10 +30,12 @@ import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Interpolator;
+import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Picture;
import android.graphics.Point;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
@@ -1994,6 +1996,23 @@ public class WebView extends AbsoluteLayout
}
/**
+ * Given a x coordinate in view space, convert it to content space.
+ * Returns the result as a float.
+ */
+ private float viewToContentXf(int x) {
+ return x * mInvActualScale;
+ }
+
+ /**
+ * Given a y coordinate in view space, convert it to content space.
+ * Takes into account the height of the title bar if there is one
+ * embedded into the WebView. Returns the result as a float.
+ */
+ private float viewToContentYf(int y) {
+ return (y - getTitleHeight()) * mInvActualScale;
+ }
+
+ /**
* Given a distance in content space, convert it to view space. Note: this
* does not reflect translation, just scaling, so this should not be called
* with coordinates, but should be called for dimensions like width or
@@ -2230,6 +2249,24 @@ public class WebView extends AbsoluteLayout
r.bottom = Math.min(viewToContentY(r.bottom), mContentHeight);
}
+ // Sets r to be our visible rectangle in content coordinates. We use this
+ // method on the native side to compute the position of the fixed layers.
+ // Uses floating coordinates (necessary to correctly place elements when
+ // the scale factor is not 1)
+ private void calcOurContentVisibleRectF(RectF r) {
+ Rect ri = new Rect(0,0,0,0);
+ calcOurVisibleRect(ri);
+ // pin the rect to the bounds of the content
+ r.left = Math.max(viewToContentXf(ri.left), 0.0f);
+ // viewToContentY will remove the total height of the title bar. Add
+ // the visible height back in to account for the fact that if the title
+ // bar is partially visible, the part of the visible rect which is
+ // displaying our content is displaced by that amount.
+ r.top = Math.max(viewToContentYf(ri.top + getVisibleTitleHeight()), 0.0f);
+ r.right = Math.min(viewToContentXf(ri.right), (float)mContentWidth);
+ r.bottom = Math.min(viewToContentYf(ri.bottom), (float)mContentHeight);
+ }
+
static class ViewSizeData {
int mWidth;
int mHeight;