diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 05:43:03 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-21 05:43:03 +0000 |
commit | 9df94ae9a38f1959f7cec1a0666bbc9d9e6f42cb (patch) | |
tree | ea9b3c18ec88f5ada9940aa6f94d0b41ac275a02 /android_webview | |
parent | 2686040bc4b822b94cc5a08571a5210486428fa1 (diff) | |
download | chromium_src-9df94ae9a38f1959f7cec1a0666bbc9d9e6f42cb.zip chromium_src-9df94ae9a38f1959f7cec1a0666bbc9d9e6f42cb.tar.gz chromium_src-9df94ae9a38f1959f7cec1a0666bbc9d9e6f42cb.tar.bz2 |
Clean up AwContents calls to change visibility
Visibility is stored in AwContents and native BrowserViewRenderer. It
seems to be windowVisible && viewVisible && !mIsPaused. So clean all
this up, make sure we don't make unnecessary calls into ContentViewCore.
Precursor work to pass visibility from BrowserViewRenderer directly to
cc.
BUG=250594
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/17291010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207720 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r-- | android_webview/browser/browser_view_renderer.h | 2 | ||||
-rw-r--r-- | android_webview/browser/in_process_view_renderer.cc | 19 | ||||
-rw-r--r-- | android_webview/browser/in_process_view_renderer.h | 5 | ||||
-rw-r--r-- | android_webview/java/src/org/chromium/android_webview/AwContents.java | 38 | ||||
-rw-r--r-- | android_webview/native/aw_contents.cc | 6 | ||||
-rw-r--r-- | android_webview/native/aw_contents.h | 4 |
6 files changed, 39 insertions, 35 deletions
diff --git a/android_webview/browser/browser_view_renderer.h b/android_webview/browser/browser_view_renderer.h index dad70ed..608d038 100644 --- a/android_webview/browser/browser_view_renderer.h +++ b/android_webview/browser/browser_view_renderer.h @@ -99,7 +99,7 @@ class BrowserViewRenderer { virtual void EnableOnNewPicture(bool enabled) = 0; // View update notifications. - virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0; + virtual void OnVisibilityChanged(bool visible) = 0; virtual void OnSizeChanged(int width, int height) = 0; virtual void OnAttachedToWindow(int width, int height) = 0; virtual void OnDetachedFromWindow() = 0; diff --git a/android_webview/browser/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc index acb6db8..ce55d1f 100644 --- a/android_webview/browser/in_process_view_renderer.cc +++ b/android_webview/browser/in_process_view_renderer.cc @@ -306,7 +306,7 @@ InProcessViewRenderer::InProcessViewRenderer( java_helper_(java_helper), web_contents_(web_contents), compositor_(NULL), - view_visible_(false), + visible_(false), dip_scale_(0.0), continuous_invalidate_(false), block_invalidates_(false), @@ -364,7 +364,7 @@ void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { return; TRACE_EVENT0("android_webview", "InProcessViewRenderer::DrawGL"); - DCHECK(view_visible_); + DCHECK(visible_); // We need to watch if the current Android context has changed and enforce // a clean-up in the compositor. @@ -553,16 +553,13 @@ InProcessViewRenderer::CapturePicture() { void InProcessViewRenderer::EnableOnNewPicture(bool enabled) { } -void InProcessViewRenderer::OnVisibilityChanged(bool view_visible, - bool window_visible) { - TRACE_EVENT_INSTANT2("android_webview", +void InProcessViewRenderer::OnVisibilityChanged(bool visible) { + TRACE_EVENT_INSTANT1("android_webview", "InProcessViewRenderer::OnVisibilityChanged", TRACE_EVENT_SCOPE_THREAD, - "view_visible", - view_visible, - "window_visible", - window_visible); - view_visible_ = window_visible && view_visible; + "visible", + visible); + visible_ = visible; } void InProcessViewRenderer::OnSizeChanged(int width, int height) { @@ -603,7 +600,7 @@ bool InProcessViewRenderer::IsAttachedToWindow() { } bool InProcessViewRenderer::IsViewVisible() { - return view_visible_; + return visible_; } gfx::Rect InProcessViewRenderer::GetScreenRect() { diff --git a/android_webview/browser/in_process_view_renderer.h b/android_webview/browser/in_process_view_renderer.h index db85926..673b6f3 100644 --- a/android_webview/browser/in_process_view_renderer.h +++ b/android_webview/browser/in_process_view_renderer.h @@ -42,8 +42,7 @@ class InProcessViewRenderer : public BrowserViewRenderer, virtual void DrawGL(AwDrawGLInfo* draw_info) OVERRIDE; virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() OVERRIDE; virtual void EnableOnNewPicture(bool enabled) OVERRIDE; - virtual void OnVisibilityChanged( - bool view_visible, bool window_visible) OVERRIDE; + virtual void OnVisibilityChanged(bool visible) OVERRIDE; virtual void OnSizeChanged(int width, int height) OVERRIDE; virtual void ScrollTo(gfx::Vector2d new_value) OVERRIDE; virtual void OnAttachedToWindow(int width, int height) OVERRIDE; @@ -77,7 +76,7 @@ class InProcessViewRenderer : public BrowserViewRenderer, content::WebContents* web_contents_; content::SynchronousCompositor* compositor_; - bool view_visible_; + bool visible_; float dip_scale_; // When true, we should continuously invalidate and keep drawing, for example 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 4f8b72b..d7f3727 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); diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 89c1cf9..f281e88 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -590,10 +590,8 @@ void AwContents::OnSizeChanged(JNIEnv* env, jobject obj, browser_view_renderer_->OnSizeChanged(w, h); } -void AwContents::SetWindowViewVisibility(JNIEnv* env, jobject obj, - bool window_visible, - bool view_visible) { - browser_view_renderer_->OnVisibilityChanged(window_visible, view_visible); +void AwContents::SetVisibility(JNIEnv* env, jobject obj, bool visible) { + browser_view_renderer_->OnVisibilityChanged(visible); } void AwContents::OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h) { diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h index 15761b98..f5a6742 100644 --- a/android_webview/native/aw_contents.h +++ b/android_webview/native/aw_contents.h @@ -92,9 +92,7 @@ class AwContents : public FindHelper::Listener, void RequestNewHitTestDataAt(JNIEnv* env, jobject obj, jint x, jint y); void UpdateLastHitTestData(JNIEnv* env, jobject obj); void OnSizeChanged(JNIEnv* env, jobject obj, int w, int h, int ow, int oh); - void SetWindowViewVisibility(JNIEnv* env, jobject obj, - bool window_visible, - bool view_visible); + void SetVisibility(JNIEnv* env, jobject obj, bool visible); void OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h); void OnDetachedFromWindow(JNIEnv* env, jobject obj); base::android::ScopedJavaLocalRef<jbyteArray> GetOpaqueState( |