From 82ed95f41007391adc1676c745b0642d32870b95 Mon Sep 17 00:00:00 2001 From: George Mount Date: Tue, 15 Nov 2011 11:27:47 -0800 Subject: [PATCH] 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 --- core/java/android/webkit/WebView.java | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index ec2f55bc48198..7c7f2b19aae9d 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -361,6 +361,7 @@ public class WebView extends AbsoluteLayout private final Rect mGLRectViewport = new Rect(); private final Rect mViewRectViewport = new Rect(); + private final RectF mVisibleContentRect = new RectF(); private boolean mGLViewportEmpty = false; /** @@ -4586,11 +4587,14 @@ public class WebView extends AbsoluteLayout + " extras=" + extras); } + calcOurContentVisibleRectF(mVisibleContentRect); if (canvas.isHardwareAccelerated()) { - int functor = nativeGetDrawGLFunction(mNativeClass, - mGLViewportEmpty ? null : mGLRectViewport, mGLViewportEmpty ? null : mViewRectViewport, getScale(), extras); - ((HardwareCanvas) canvas).callDrawGLFunction(functor); + Rect glRectViewport = mGLViewportEmpty ? null : mGLRectViewport; + Rect viewRectViewport = mGLViewportEmpty ? null : mViewRectViewport; + int functor = nativeGetDrawGLFunction(mNativeClass, glRectViewport, + viewRectViewport, mVisibleContentRect, getScale(), extras); + ((HardwareCanvas) canvas).callDrawGLFunction(functor); if (mHardwareAccelSkia != getSettings().getHardwareAccelSkiaEnabled()) { mHardwareAccelSkia = getSettings().getHardwareAccelSkiaEnabled(); nativeUseHardwareAccelSkia(mHardwareAccelSkia); @@ -4606,7 +4610,8 @@ public class WebView extends AbsoluteLayout canvas.setDrawFilter(df); // XXX: Revisit splitting content. Right now it causes a // synchronization problem with layers. - int content = nativeDraw(canvas, color, extras, false); + int content = nativeDraw(canvas, mVisibleContentRect, color, + extras, false); canvas.setDrawFilter(null); if (!mBlockWebkitViewMessages && content != 0) { mWebViewCore.sendMessage(EventHub.SPLIT_PICTURE_SET, content, 0); @@ -5776,8 +5781,9 @@ public class WebView extends AbsoluteLayout } else { mGLViewportEmpty = true; } + calcOurContentVisibleRectF(mVisibleContentRect); nativeUpdateDrawGLFunction(mGLViewportEmpty ? null : mGLRectViewport, - mGLViewportEmpty ? null : mViewRectViewport); + mGLViewportEmpty ? null : mViewRectViewport, mVisibleContentRect); } /** @@ -8774,7 +8780,6 @@ public class WebView extends AbsoluteLayout mSendScrollEvent = false; recordNewContentSize(draw.mContentSize.x, draw.mContentSize.y, updateLayout); - if (isPictureAfterFirstLayout) { // Reset the last sent data here since dealing with new page. mLastWidthSent = 0; @@ -9345,7 +9350,8 @@ public class WebView extends AbsoluteLayout * @hide only needs to be accessible to Browser and testing */ public void drawPage(Canvas canvas) { - nativeDraw(canvas, 0, 0, false); + calcOurContentVisibleRectF(mVisibleContentRect); + nativeDraw(canvas, mVisibleContentRect, 0, 0, false); } /** @@ -9476,13 +9482,14 @@ public class WebView extends AbsoluteLayout * MUST be passed to WebViewCore with SPLIT_PICTURE_SET message so that the * native allocation can be freed. */ - private native int nativeDraw(Canvas canvas, int color, int extra, - boolean splitIfNeeded); + private native int nativeDraw(Canvas canvas, RectF visibleRect, + int color, int extra, boolean splitIfNeeded); private native void nativeDumpDisplayTree(String urlOrNull); private native boolean nativeEvaluateLayersAnimations(int nativeInstance); private native int nativeGetDrawGLFunction(int nativeInstance, Rect rect, - Rect viewRect, float scale, int extras); - private native void nativeUpdateDrawGLFunction(Rect rect, Rect viewRect); + Rect viewRect, RectF visibleRect, float scale, int extras); + private native void nativeUpdateDrawGLFunction(Rect rect, Rect viewRect, + RectF visibleRect); private native void nativeExtendSelection(int x, int y); private native int nativeFindAll(String findLower, String findUpper, boolean sameAsLastSearch);