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

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

Issue 17291010: Clean up AwContents calls to change visibility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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
« no previous file with comments | « android_webview/browser/in_process_view_renderer.cc ('k') | android_webview/native/aw_contents.h » ('j') | 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 4f8b72b83ede51355c616da2fb7589c36d673fe3..d7f3727c3ab972137be8428edc8ab529f63b34eb 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -133,6 +133,7 @@ public class AwContents {
private final AwSettings mSettings;
private boolean mIsPaused;
+ private boolean mIsVisible; // Equivalent to windowVisible && viewVisible && !mIsPaused.
private Bitmap mFavicon;
private boolean mHasRequestedVisitedHistoryFromClient;
// TODO(boliu): This should be in a global context, not per webview.
@@ -486,7 +487,7 @@ public class AwContents {
mLastGlobalVisibleWidth = 0;
mLastGlobalVisibleHeight = 0;
onSizeChanged(mContainerView.getWidth(), mContainerView.getHeight(), 0, 0);
- updateVisiblityState();
+ updateVisibilityStateForced();
onWindowFocusChanged(mWindowFocused);
}
@@ -853,15 +854,15 @@ public class AwContents {
*/
public void onPause() {
mIsPaused = true;
- mContentViewCore.onHide();
+ updateVisibilityState();
}
/**
* @see android.webkit.WebView#onResume()
*/
public void onResume() {
- mContentViewCore.onShow();
mIsPaused = false;
+ updateVisibilityState();
}
/**
@@ -1201,27 +1202,39 @@ public class AwContents {
* @see android.view.View#onVisibilityChanged()
*/
public void onVisibilityChanged(View changedView, int visibility) {
- updateVisiblityState();
+ updateVisibilityState();
}
/**
* @see android.view.View#onWindowVisibilityChanged()
*/
public void onWindowVisibilityChanged(int visibility) {
- updateVisiblityState();
+ updateVisibilityState();
}
- private void updateVisiblityState() {
- if (mNativeAwContents == 0 || mIsPaused) return;
+ private void updateVisibilityState() {
+ doUpdateVisibilityState(false);
+ }
+
+ private void updateVisibilityStateForced() {
+ doUpdateVisibilityState(true);
+ }
+
+ private void doUpdateVisibilityState(boolean forced) {
+ if (mNativeAwContents == 0) return;
boolean windowVisible = mContainerView.getWindowVisibility() == View.VISIBLE;
boolean viewVisible = mContainerView.getVisibility() == View.VISIBLE;
- nativeSetWindowViewVisibility(mNativeAwContents, windowVisible, viewVisible);
- if (viewVisible) {
- mContentViewCore.onShow();
+ boolean visible = windowVisible && viewVisible && !mIsPaused;
+ if (mIsVisible == visible && !forced) return;
+
+ mIsVisible = visible;
+ if (mIsVisible) {
+ mContentViewCore.onShow();
} else {
- mContentViewCore.onHide();
+ mContentViewCore.onHide();
}
+ nativeSetVisibility(mNativeAwContents, mIsVisible);
}
@@ -1533,8 +1546,7 @@ public class AwContents {
private native void nativeOnSizeChanged(int nativeAwContents, int w, int h, int ow, int oh);
private native void nativeScrollTo(int nativeAwContents, int x, int y);
- private native void nativeSetWindowViewVisibility(int nativeAwContents, boolean windowVisible,
- boolean viewVisible);
+ private native void nativeSetVisibility(int nativeAwContents, boolean visible);
private native void nativeOnAttachedToWindow(int nativeAwContents, int w, int h);
private native void nativeOnDetachedFromWindow(int nativeAwContents);
private native void nativeSetDipScale(int nativeAwContents, float dipScale);
« no previous file with comments | « android_webview/browser/in_process_view_renderer.cc ('k') | android_webview/native/aw_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698