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 8ad3b4597e88892494eeef7fda2bebd8cf853ecb..70ebbd001fbc20bb6791c32560cf0f3ed8fc7f3b 100644 |
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java |
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
@@ -972,7 +972,7 @@ public class AwContents implements SmartClipProvider, |
installWebContentsObserver(); |
mSettings.setWebContents(webContents); |
nativeSetDipScale(mNativeAwContents, (float) mDIPScale); |
- updateContentViewCoreVisibility(); |
+ postUpdateContentViewCoreVisibility(); |
// The native side object has been bound to this java instance, so now is the time to |
// bind all the native->java relationships. |
@@ -1798,7 +1798,7 @@ public class AwContents implements SmartClipProvider, |
if (mIsPaused || isDestroyed(NO_WARN)) return; |
mIsPaused = true; |
nativeSetIsPaused(mNativeAwContents, mIsPaused); |
- updateContentViewCoreVisibility(); |
+ postUpdateContentViewCoreVisibility(); |
} |
/** |
@@ -1809,7 +1809,7 @@ public class AwContents implements SmartClipProvider, |
if (!mIsPaused || isDestroyed(NO_WARN)) return; |
mIsPaused = false; |
nativeSetIsPaused(mNativeAwContents, mIsPaused); |
- updateContentViewCoreVisibility(); |
+ postUpdateContentViewCoreVisibility(); |
} |
/** |
@@ -2348,7 +2348,7 @@ public class AwContents implements SmartClipProvider, |
private void setViewVisibilityInternal(boolean visible) { |
mIsViewVisible = visible; |
if (!isDestroyed(NO_WARN)) nativeSetViewVisibility(mNativeAwContents, mIsViewVisible); |
- updateContentViewCoreVisibility(); |
+ postUpdateContentViewCoreVisibility(); |
} |
private void setWindowVisibilityInternal(boolean visible) { |
@@ -2356,7 +2356,22 @@ public class AwContents implements SmartClipProvider, |
&& visible && !mIsWindowVisible; |
mIsWindowVisible = visible; |
if (!isDestroyed(NO_WARN)) nativeSetWindowVisibility(mNativeAwContents, mIsWindowVisible); |
- updateContentViewCoreVisibility(); |
+ postUpdateContentViewCoreVisibility(); |
+ } |
+ |
+ private void postUpdateContentViewCoreVisibility() { |
+ // When WebView is attached to a visible window, WebView will be |
+ // attached to a window whose visibility is initially invisible, then |
+ // the window visibility will be updated to true. This means CVC |
+ // visibility will be set to false then true immediately, in the same |
+ // function call of View#dispatchAttachedToWindow. To prevent this flip |
+ // of CVC visibility, post the task to update CVC visibility. |
+ mHandler.post(new Runnable() { |
boliu
2015/11/03 22:05:46
Can you not post more than you need to?
Also don'
|
+ @Override |
+ public void run() { |
+ updateContentViewCoreVisibility(); |
+ } |
+ }); |
} |
private void updateContentViewCoreVisibility() { |
@@ -3005,6 +3020,7 @@ public class AwContents implements SmartClipProvider, |
nativeOnAttachedToWindow(mNativeAwContents, mContainerView.getWidth(), |
mContainerView.getHeight()); |
updateHardwareAcceleratedFeaturesToggle(); |
+ postUpdateContentViewCoreVisibility(); |
setLocale(LocaleUtils.getDefaultLocale()); |
@@ -3026,6 +3042,7 @@ public class AwContents implements SmartClipProvider, |
mContentViewCore.onDetachedFromWindow(); |
updateHardwareAcceleratedFeaturesToggle(); |
+ postUpdateContentViewCoreVisibility(); |
if (mComponentCallbacks != null) { |
mContext.unregisterComponentCallbacks(mComponentCallbacks); |