Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2589)

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 19693016: Hooking up setBackgroundColor from AwContents to render process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ity. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 40075d7d38576eb4ce7bbfd5f10ed0c72e95f220..c94c1abf3b59cc12b9eb18b1cdfdc0b3969d9805 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -156,12 +156,15 @@ public class AwContents {
// TODO(boliu): This should be in a global context, not per webview.
private final double mDIPScale;
+ // The base background color, i.e. not accounting for any CSS body from the current page.
+ private int mBaseBackgroundColor = Color.WHITE;
+
// Must call nativeUpdateLastHitTestData first to update this before use.
private final HitTestData mPossiblyStaleHitTestData = new HitTestData();
private DefaultVideoPosterRequestHandler mDefaultVideoPosterRequestHandler;
- // Bound method for suppling Picture instances to the AwContentClient. Will be null if the
+ // Bound method for suppling Picture instances to the AwContentsClient. Will be null if the
// picture listener API has not yet been enabled, or if it is using invalidation-only mode.
private Callable<Picture> mPictureListenerContentProvider;
@@ -641,7 +644,10 @@ public class AwContents {
private final Rect mClipBoundsTemporary = new Rect();
public void onDraw(Canvas canvas) {
- if (mNativeAwContents == 0) return;
+ if (mNativeAwContents == 0) {
+ canvas.drawColor(getEffectiveBackgroundColor());
+ return;
+ }
mScrollOffsetManager.syncScrollOffsetFromOnDraw();
@@ -651,8 +657,7 @@ public class AwContents {
mClipBoundsTemporary.left, mClipBoundsTemporary.top,
mClipBoundsTemporary.right, mClipBoundsTemporary.bottom )) {
Log.w(TAG, "nativeOnDraw failed; clearing to background color.");
- int c = mContentViewCore.getBackgroundColor();
- canvas.drawRGB(Color.red(c), Color.green(c), Color.blue(c));
+ canvas.drawColor(getEffectiveBackgroundColor());
}
}
@@ -818,6 +823,21 @@ public class AwContents {
}
}
+ public void setBackgroundColor(int color) {
+ mBaseBackgroundColor = color;
+ if (mNativeAwContents != 0) nativeSetBackgroundColor(mNativeAwContents, color);
+ }
+
+ private int getEffectiveBackgroundColor() {
+ // Do not ask the ContentViewCore for the background color, as it will always
+ // report white prior to initial navigation or post destruction, whereas we want
+ // to use the client supplied base value in those cases.
+ if (mNativeAwContents == 0 || !mContentsClient.isCachedRendererBackgroundColorValid()) {
+ return mBaseBackgroundColor;
+ }
+ return mContentsClient.getCachedRendererBackgroundColor();
+ }
+
public boolean isMultiTouchZoomSupported() {
return mSettings.supportsMultiTouchZoom();
}
@@ -1718,6 +1738,7 @@ public class AwContents {
private native int nativeReleasePopupAwContents(int nativeAwContents);
private native void nativeFocusFirstNode(int nativeAwContents);
+ private native void nativeSetBackgroundColor(int nativeAwContents, int color);
private native int nativeGetAwDrawGLViewContext(int nativeAwContents);
private native Picture nativeCapturePicture(int nativeAwContents);

Powered by Google App Engine
This is Rietveld 408576698