Skip to content

Commit 82ed95f

Browse files
author
George Mount
committed
Content and viewport rects set in one step.
Bug 5342918 The content rect of the WebView was being retrieved during the draw while the viewport rect was being set when the draw functor was setup. During animations, the content rect was changing between the time the draw functor was retrieved and it was executed. The content rect is now being set with the viewport rect. Wekbkit Change: I05d68dcc Change-Id: I1b0978eeb27d9f1deddfeba3ede869f735f74394
1 parent de8c5ec commit 82ed95f

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

core/java/android/webkit/WebView.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ public void onScrollChanged() {
361361

362362
private final Rect mGLRectViewport = new Rect();
363363
private final Rect mViewRectViewport = new Rect();
364+
private final RectF mVisibleContentRect = new RectF();
364365
private boolean mGLViewportEmpty = false;
365366

366367
/**
@@ -4586,11 +4587,14 @@ private void drawCoreAndCursorRing(Canvas canvas, int color,
45864587
+ " extras=" + extras);
45874588
}
45884589

4590+
calcOurContentVisibleRectF(mVisibleContentRect);
45894591
if (canvas.isHardwareAccelerated()) {
4590-
int functor = nativeGetDrawGLFunction(mNativeClass,
4591-
mGLViewportEmpty ? null : mGLRectViewport, mGLViewportEmpty ? null : mViewRectViewport, getScale(), extras);
4592-
((HardwareCanvas) canvas).callDrawGLFunction(functor);
4592+
Rect glRectViewport = mGLViewportEmpty ? null : mGLRectViewport;
4593+
Rect viewRectViewport = mGLViewportEmpty ? null : mViewRectViewport;
45934594

4595+
int functor = nativeGetDrawGLFunction(mNativeClass, glRectViewport,
4596+
viewRectViewport, mVisibleContentRect, getScale(), extras);
4597+
((HardwareCanvas) canvas).callDrawGLFunction(functor);
45944598
if (mHardwareAccelSkia != getSettings().getHardwareAccelSkiaEnabled()) {
45954599
mHardwareAccelSkia = getSettings().getHardwareAccelSkiaEnabled();
45964600
nativeUseHardwareAccelSkia(mHardwareAccelSkia);
@@ -4606,7 +4610,8 @@ private void drawCoreAndCursorRing(Canvas canvas, int color,
46064610
canvas.setDrawFilter(df);
46074611
// XXX: Revisit splitting content. Right now it causes a
46084612
// synchronization problem with layers.
4609-
int content = nativeDraw(canvas, color, extras, false);
4613+
int content = nativeDraw(canvas, mVisibleContentRect, color,
4614+
extras, false);
46104615
canvas.setDrawFilter(null);
46114616
if (!mBlockWebkitViewMessages && content != 0) {
46124617
mWebViewCore.sendMessage(EventHub.SPLIT_PICTURE_SET, content, 0);
@@ -5776,8 +5781,9 @@ void setGLRectViewport() {
57765781
} else {
57775782
mGLViewportEmpty = true;
57785783
}
5784+
calcOurContentVisibleRectF(mVisibleContentRect);
57795785
nativeUpdateDrawGLFunction(mGLViewportEmpty ? null : mGLRectViewport,
5780-
mGLViewportEmpty ? null : mViewRectViewport);
5786+
mGLViewportEmpty ? null : mViewRectViewport, mVisibleContentRect);
57815787
}
57825788

57835789
/**
@@ -8774,7 +8780,6 @@ void setNewPicture(final WebViewCore.DrawData draw, boolean updateBaseLayer) {
87748780
mSendScrollEvent = false;
87758781
recordNewContentSize(draw.mContentSize.x,
87768782
draw.mContentSize.y, updateLayout);
8777-
87788783
if (isPictureAfterFirstLayout) {
87798784
// Reset the last sent data here since dealing with new page.
87808785
mLastWidthSent = 0;
@@ -9345,7 +9350,8 @@ public void debugDump() {
93459350
* @hide only needs to be accessible to Browser and testing
93469351
*/
93479352
public void drawPage(Canvas canvas) {
9348-
nativeDraw(canvas, 0, 0, false);
9353+
calcOurContentVisibleRectF(mVisibleContentRect);
9354+
nativeDraw(canvas, mVisibleContentRect, 0, 0, false);
93499355
}
93509356

93519357
/**
@@ -9476,13 +9482,14 @@ public float tileProfilingGetFloat(int frame, int tile, String key) {
94769482
* MUST be passed to WebViewCore with SPLIT_PICTURE_SET message so that the
94779483
* native allocation can be freed.
94789484
*/
9479-
private native int nativeDraw(Canvas canvas, int color, int extra,
9480-
boolean splitIfNeeded);
9485+
private native int nativeDraw(Canvas canvas, RectF visibleRect,
9486+
int color, int extra, boolean splitIfNeeded);
94819487
private native void nativeDumpDisplayTree(String urlOrNull);
94829488
private native boolean nativeEvaluateLayersAnimations(int nativeInstance);
94839489
private native int nativeGetDrawGLFunction(int nativeInstance, Rect rect,
9484-
Rect viewRect, float scale, int extras);
9485-
private native void nativeUpdateDrawGLFunction(Rect rect, Rect viewRect);
9490+
Rect viewRect, RectF visibleRect, float scale, int extras);
9491+
private native void nativeUpdateDrawGLFunction(Rect rect, Rect viewRect,
9492+
RectF visibleRect);
94869493
private native void nativeExtendSelection(int x, int y);
94879494
private native int nativeFindAll(String findLower, String findUpper,
94889495
boolean sameAsLastSearch);

0 commit comments

Comments
 (0)