diff options
-rw-r--r-- | cc/input/top_controls_manager.cc | 33 | ||||
-rw-r--r-- | cc/input/top_controls_manager.h | 12 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 11 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.h | 4 | ||||
-rw-r--r-- | content/browser/android/content_view_core_impl.cc | 12 | ||||
-rw-r--r-- | content/browser/android/content_view_core_impl.h | 6 | ||||
-rw-r--r-- | content/common/view_messages.h | 9 | ||||
-rw-r--r-- | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java | 13 | ||||
-rw-r--r-- | content/renderer/gpu/render_widget_compositor.cc | 8 | ||||
-rw-r--r-- | content/renderer/gpu/render_widget_compositor.h | 4 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 4 | ||||
-rw-r--r-- | content/renderer/render_view_impl.h | 4 | ||||
-rw-r--r-- | content/renderer/render_view_impl_android.cc | 6 |
13 files changed, 92 insertions, 34 deletions
diff --git a/cc/input/top_controls_manager.cc b/cc/input/top_controls_manager.cc index e1698f1..343dd3c 100644 --- a/cc/input/top_controls_manager.cc +++ b/cc/input/top_controls_manager.cc @@ -40,7 +40,7 @@ TopControlsManager::TopControlsManager(TopControlsManagerClient* client, float top_controls_hide_threshold) : client_(client), animation_direction_(NO_ANIMATION), - enable_hiding_(true), + visibility_restriction_(NONE), controls_top_offset_(0.f), top_controls_height_(top_controls_height), current_scroll_delta_(0.f), @@ -55,15 +55,30 @@ TopControlsManager::TopControlsManager(TopControlsManagerClient* client, TopControlsManager::~TopControlsManager() { } -void TopControlsManager::EnableHidingTopControls(bool enable) { - enable_hiding_ = enable; +void TopControlsManager::UpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate) { + float final_controls_position = 0.f; + + if (enable_hiding && enable_showing) { + visibility_restriction_ = NONE; + } else if (enable_showing || !enable_hiding) { + visibility_restriction_ = ALWAYS_SHOWN; + } else { + visibility_restriction_ = ALWAYS_HIDDEN; + final_controls_position = -top_controls_height_; + } - if (!enable) { + if (visibility_restriction_ != NONE && + final_controls_position != controls_top_offset_) { ResetAnimations(); - if (controls_top_offset_ != 0) { - SetupAnimation(SHOWING_CONTROLS); - client_->setNeedsRedraw(); + if (animate) { + SetupAnimation(visibility_restriction_ == ALWAYS_SHOWN ? + SHOWING_CONTROLS : HIDING_CONTROLS); + } else { + controls_top_offset_ = final_controls_position; } + client_->setNeedsRedraw(); } } @@ -75,7 +90,9 @@ void TopControlsManager::ScrollBegin() { gfx::Vector2dF TopControlsManager::ScrollBy( const gfx::Vector2dF pending_delta) { - if (!enable_hiding_ && pending_delta.y() > 0) + if (visibility_restriction_ == ALWAYS_SHOWN && pending_delta.y() > 0) + return pending_delta; + else if (visibility_restriction_ == ALWAYS_HIDDEN && pending_delta.y() < 0) return pending_delta; current_scroll_delta_ += pending_delta.y(); diff --git a/cc/input/top_controls_manager.h b/cc/input/top_controls_manager.h index 59289f6..78ccf80 100644 --- a/cc/input/top_controls_manager.h +++ b/cc/input/top_controls_manager.h @@ -31,6 +31,12 @@ class CC_EXPORT TopControlsManager HIDING_CONTROLS }; + enum VisibilityRestriction { + ALWAYS_SHOWN, + ALWAYS_HIDDEN, + NONE + }; + static scoped_ptr<TopControlsManager> Create( TopControlsManagerClient* client, float top_controls_height, @@ -47,7 +53,9 @@ class CC_EXPORT TopControlsManager } AnimationDirection animation_direction() { return animation_direction_; } - void EnableHidingTopControls(bool enable); + void UpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate); void ScrollBegin(); gfx::Vector2dF ScrollBy(const gfx::Vector2dF pending_delta); @@ -73,7 +81,7 @@ class CC_EXPORT TopControlsManager scoped_ptr<KeyframedFloatAnimationCurve> top_controls_animation_; AnimationDirection animation_direction_; - bool enable_hiding_; + VisibilityRestriction visibility_restriction_; float controls_top_offset_; float top_controls_height_; diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 75b6118..c98c81b 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -983,13 +983,18 @@ void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { SetNeedsCommit(); } -void LayerTreeHost::EnableHidingTopControls(bool enable) { +void LayerTreeHost::UpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate) { if (!settings_.calculate_top_controls_position) return; proxy_->ImplThread()->PostTask( - base::Bind(&TopControlsManager::EnableHidingTopControls, - top_controls_manager_weak_ptr_, enable)); + base::Bind(&TopControlsManager::UpdateTopControlsState, + top_controls_manager_weak_ptr_, + enable_hiding, + enable_showing, + animate)); } bool LayerTreeHost::BlocksPendingCommit() const { diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 220cbb5..b412dab 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -224,7 +224,9 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) { void SetDeviceScaleFactor(float device_scale_factor); float device_scale_factor() const { return device_scale_factor_; } - void EnableHidingTopControls(bool enable); + void UpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate); HeadsUpDisplayLayer* hud_layer() const { return hud_layer_.get(); } diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index bb67051..ccdc2e0 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -1253,10 +1253,16 @@ void ContentViewCoreImpl::ExitFullscreen(JNIEnv* env, jobject obj) { host->ExitFullscreen(); } -void ContentViewCoreImpl::EnableHidingTopControls(JNIEnv* env, jobject obj, - bool enable) { +void ContentViewCoreImpl::UpdateTopControlsState(JNIEnv* env, + jobject obj, + bool enable_hiding, + bool enable_showing, + bool animate) { RenderViewHost* host = web_contents_->GetRenderViewHost(); - host->Send(new ViewMsg_EnableHidingTopControls(host->GetRoutingID(), enable)); + host->Send(new ViewMsg_UpdateTopControlsState(host->GetRoutingID(), + enable_hiding, + enable_showing, + animate)); } void ContentViewCoreImpl::ShowImeIfNeeded(JNIEnv* env, jobject obj) { diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h index 6bab21b..72a7256 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core_impl.h @@ -200,7 +200,11 @@ class ContentViewCoreImpl : public ContentViewCore, void WasResized(JNIEnv* env, jobject obj); jboolean IsRenderWidgetHostViewReady(JNIEnv* env, jobject obj); void ExitFullscreen(JNIEnv* env, jobject obj); - void EnableHidingTopControls(JNIEnv* env, jobject obj, bool enable); + void UpdateTopControlsState(JNIEnv* env, + jobject obj, + bool enable_hiding, + bool enable_showing, + bool animate); void ShowImeIfNeeded(JNIEnv* env, jobject obj); void ShowInterstitialPage(JNIEnv* env, diff --git a/content/common/view_messages.h b/content/common/view_messages.h index c87ff49..0e84bef 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -1352,9 +1352,12 @@ IPC_MESSAGE_ROUTED0(ViewMsg_UndoScrollFocusedEditableNodeIntoView) IPC_MESSAGE_ROUTED1(ViewMsg_ImeBatchStateChanged, bool /* is_begin */) -// Notifies the renderer whether hiding the top controls is enabled. -IPC_MESSAGE_ROUTED1(ViewMsg_EnableHidingTopControls, - bool /* enable */) +// Notifies the renderer whether hiding/showing the top controls is enabled +// and whether or not to animate to the proper state. +IPC_MESSAGE_ROUTED3(ViewMsg_UpdateTopControlsState, + bool /* enable_hiding */, + bool /* enable_showing */, + bool /* animate */) IPC_MESSAGE_ROUTED0(ViewMsg_ShowImeIfNeeded) diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java index 9d157ae..565a849 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java @@ -2531,10 +2531,13 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { /** * Changes whether hiding the top controls is enabled. * - * @param enable Whether hiding the top controls should be enabled. + * @param enableHiding Whether hiding the top controls should be enabled or not. + * @param enableShowing Whether showing the top controls should be enabled or not. + * @param animate Whether the transition should be animated or not. */ - public void enableHidingTopControls(boolean enable) { - nativeEnableHidingTopControls(mNativeContentViewCore, enable); + public void updateTopControlsState(boolean enableHiding, boolean enableShowing, + boolean animate) { + nativeUpdateTopControlsState(mNativeContentViewCore, enableHiding, enableShowing, animate); } /** @@ -2801,8 +2804,8 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { private native boolean nativeIsRenderWidgetHostViewReady(int nativeContentViewCoreImpl); private native void nativeExitFullscreen(int nativeContentViewCoreImpl); - private native void nativeEnableHidingTopControls( - int nativeContentViewCoreImpl, boolean enable); + private native void nativeUpdateTopControlsState(int nativeContentViewCoreImpl, + boolean enableHiding, boolean enableShowing, boolean animate); private native void nativeShowImeIfNeeded(int nativeContentViewCoreImpl); diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc index 5187800..4284b4b 100644 --- a/content/renderer/gpu/render_widget_compositor.cc +++ b/content/renderer/gpu/render_widget_compositor.cc @@ -309,8 +309,12 @@ skia::RefPtr<SkPicture> RenderWidgetCompositor::CapturePicture() { return layer_tree_host_->CapturePicture(); } -void RenderWidgetCompositor::EnableHidingTopControls(bool enable) { - layer_tree_host_->EnableHidingTopControls(enable); +void RenderWidgetCompositor::UpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate) { + layer_tree_host_->UpdateTopControlsState(enable_hiding, + enable_showing, + animate); } void RenderWidgetCompositor::SetOverdrawBottomHeight( diff --git a/content/renderer/gpu/render_widget_compositor.h b/content/renderer/gpu/render_widget_compositor.h index de68d4a..38a3e84 100644 --- a/content/renderer/gpu/render_widget_compositor.h +++ b/content/renderer/gpu/render_widget_compositor.h @@ -35,7 +35,9 @@ class RenderWidgetCompositor : public WebKit::WebLayerTreeView, void Composite(base::TimeTicks frame_begin_time); void GetRenderingStats(cc::RenderingStats* stats); skia::RefPtr<SkPicture> CapturePicture(); - void EnableHidingTopControls(bool enable); + void UpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate); void SetOverdrawBottomHeight(float overdraw_bottom_height); // WebLayerTreeView implementation. diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 6ec60c4..dd55cf5 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -1091,8 +1091,8 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) IPC_MESSAGE_HANDLER(ViewMsg_UndoScrollFocusedEditableNodeIntoView, OnUndoScrollFocusedEditableNodeIntoRect) - IPC_MESSAGE_HANDLER(ViewMsg_EnableHidingTopControls, - OnEnableHidingTopControls) + IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, + OnUpdateTopControlsState) #elif defined(OS_MACOSX) IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index a778fb4..28a6f1a 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -1041,7 +1041,9 @@ class CONTENT_EXPORT RenderViewImpl void OnSelectPopupMenuItems(bool canceled, const std::vector<int>& selected_indices); void OnUndoScrollFocusedEditableNodeIntoRect(); - void OnEnableHidingTopControls(bool enable); + void OnUpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate); #elif defined(OS_MACOSX) void OnCopyToFindPboard(); void OnPluginImeCompositionCompleted(const string16& text, int plugin_id); diff --git a/content/renderer/render_view_impl_android.cc b/content/renderer/render_view_impl_android.cc index bc061f2..31b273f 100644 --- a/content/renderer/render_view_impl_android.cc +++ b/content/renderer/render_view_impl_android.cc @@ -11,10 +11,12 @@ namespace content { -void RenderViewImpl::OnEnableHidingTopControls(bool enable) { +void RenderViewImpl::OnUpdateTopControlsState(bool enable_hiding, + bool enable_showing, + bool animate) { DCHECK(compositor_); if (compositor_) { - compositor_->EnableHidingTopControls(enable); + compositor_->UpdateTopControlsState(enable_hiding, enable_showing, animate); } } |