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

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

Issue 1409693010: Update WebView visibility during attach/detach (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2526
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c07ef8c7305ca7d0e1e4e1bc77b38bb238e90984..243c5bff9d8107631f51089edb06a234d8a88844 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -239,6 +239,8 @@ public class AwContents implements SmartClipProvider,
private boolean mIsAttachedToWindow;
// Visiblity state of |mContentViewCore|.
private boolean mIsContentViewCoreVisible;
+ private boolean mIsUpdateVisibilityTaskPending;
+ private Runnable mUpdateVisibilityRunnable;
private Bitmap mFavicon;
private boolean mHasRequestedVisitedHistoryFromClient;
@@ -694,6 +696,12 @@ public class AwContents implements SmartClipProvider,
mBackgroundThreadClient = new BackgroundThreadClientImpl();
mIoThreadClient = new IoThreadClientImpl();
mInterceptNavigationDelegate = new InterceptNavigationDelegateImpl();
+ mUpdateVisibilityRunnable = new Runnable() {
+ @Override
+ public void run() {
+ updateContentViewCoreVisibility();
+ }
+ };
AwSettings.ZoomSupportChangeListener zoomListener =
new AwSettings.ZoomSupportChangeListener() {
@@ -2281,10 +2289,27 @@ public class AwContents implements SmartClipProvider,
&& visible && !mIsWindowVisible;
mIsWindowVisible = visible;
if (!isDestroyed()) nativeSetWindowVisibility(mNativeAwContents, mIsWindowVisible);
- updateContentViewCoreVisibility();
+ postUpdateContentViewCoreVisibility();
+ }
+
+ private void postUpdateContentViewCoreVisibility() {
+ if (mIsUpdateVisibilityTaskPending) return;
+ // 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. DetachedFromWindow
+ // is a similar case, where window visibility changes before AwContents
+ // is detached from window.
+ //
+ // To prevent this flip of CVC visibility, post the task to update CVC
+ // visibility during attach, detach and window visibility change.
+ mIsUpdateVisibilityTaskPending = true;
+ mHandler.post(mUpdateVisibilityRunnable);
}
private void updateContentViewCoreVisibility() {
+ mIsUpdateVisibilityTaskPending = false;
if (isDestroyed()) return;
boolean contentViewCoreVisible = nativeIsVisible(mNativeAwContents);
@@ -2930,6 +2955,7 @@ public class AwContents implements SmartClipProvider,
nativeOnAttachedToWindow(mNativeAwContents, mContainerView.getWidth(),
mContainerView.getHeight());
updateHardwareAcceleratedFeaturesToggle();
+ postUpdateContentViewCoreVisibility();
setLocale(LocaleUtils.getDefaultLocale());
@@ -2951,6 +2977,7 @@ public class AwContents implements SmartClipProvider,
mContentViewCore.onDetachedFromWindow();
updateHardwareAcceleratedFeaturesToggle();
+ postUpdateContentViewCoreVisibility();
if (mComponentCallbacks != null) {
mContext.unregisterComponentCallbacks(mComponentCallbacks);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698