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
This commit is contained in:
@ -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;
|
||||
@ -1993,6 +1995,23 @@ public class WebView extends AbsoluteLayout
|
||||
return viewToContentDimension(y - getTitleHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -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;
|
||||
|
Reference in New Issue
Block a user