Commit 8d794cef authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Fix the omnibox stops at the middle while we stop at middle

When we scroll the page and stops at the middle of the omnibox, the
page should either go up or down to either show the whole omnibox or
not show the omnibox at all. When I moved the ScrollEnd function
(https://chromium-review.googlesource.com/c/chromium/src/+/1688884) in
InputHandlerProxy::HandleGestureScrollEnd to be called for only
impl thread scroll only, so the scroll snap does not happen for main
thread scroll. We should call ScrollEnd for both impl and main threads
scroll.

Bug: 1026033
Change-Id: Id15379d70e4ccaab28b578e0798735141caac627
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1972460
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736057}
parent b5539085
...@@ -1284,7 +1284,7 @@ void WebViewImpl::UpdateBrowserControlsConstraint( ...@@ -1284,7 +1284,7 @@ void WebViewImpl::UpdateBrowserControlsConstraint(
GetBrowserControls().PermittedState(); GetBrowserControls().PermittedState();
GetBrowserControls().UpdateConstraintsAndState( GetBrowserControls().UpdateConstraintsAndState(
constraint, cc::BrowserControlsState::kBoth, false); constraint, cc::BrowserControlsState::kBoth);
// If the controls are going from a locked hidden to unlocked state, or vice // If the controls are going from a locked hidden to unlocked state, or vice
// versa, the ICB size needs to change but we can't rely on getting a // versa, the ICB size needs to change but we can't rely on getting a
......
...@@ -96,6 +96,32 @@ FloatSize BrowserControls::ScrollBy(FloatSize pending_delta) { ...@@ -96,6 +96,32 @@ FloatSize BrowserControls::ScrollBy(FloatSize pending_delta) {
return pending_delta - applied_delta; return pending_delta - applied_delta;
} }
void BrowserControls::ScrollEnd() {
if ((top_shown_ratio_ == TopMinShownRatio() || top_shown_ratio_ == 1) &&
(bottom_shown_ratio_ == BottomMinShownRatio() ||
bottom_shown_ratio_ == 1)) {
return;
}
// Both threshold values are copied from LayerTreeSettings, which are used in
// BrowserControlsOffsetManager::ScrollEnd.
constexpr float kTopControlsShowThreshold = 0.5f;
constexpr float kTopControlsHideThreshold = 0.5f;
float normalized_top_ratio =
(top_shown_ratio_ - TopMinShownRatio()) / (1.f - TopMinShownRatio());
if (normalized_top_ratio >= 1.f - kTopControlsHideThreshold) {
// If we're showing so much that the hide threshold won't trigger, show.
UpdateConstraintsAndState(permitted_state_,
cc::BrowserControlsState::kShown);
} else if (normalized_top_ratio < kTopControlsShowThreshold) {
// If we're showing so little that the show threshold won't trigger, hide.
UpdateConstraintsAndState(permitted_state_,
cc::BrowserControlsState::kHidden);
} else {
NOTREACHED();
}
}
void BrowserControls::ResetBaseline() { void BrowserControls::ResetBaseline() {
accumulated_scroll_delta_ = 0; accumulated_scroll_delta_ = 0;
baseline_top_content_offset_ = ContentOffset(); baseline_top_content_offset_ = ContentOffset();
...@@ -133,14 +159,22 @@ void BrowserControls::SetShownRatio(float top_ratio, float bottom_ratio) { ...@@ -133,14 +159,22 @@ void BrowserControls::SetShownRatio(float top_ratio, float bottom_ratio) {
void BrowserControls::UpdateConstraintsAndState( void BrowserControls::UpdateConstraintsAndState(
cc::BrowserControlsState constraints, cc::BrowserControlsState constraints,
cc::BrowserControlsState current, cc::BrowserControlsState current) {
bool animate) {
permitted_state_ = constraints; permitted_state_ = constraints;
DCHECK(!(constraints == cc::BrowserControlsState::kShown && DCHECK(!(constraints == cc::BrowserControlsState::kShown &&
current == cc::BrowserControlsState::kHidden)); current == cc::BrowserControlsState::kHidden));
DCHECK(!(constraints == cc::BrowserControlsState::kHidden && DCHECK(!(constraints == cc::BrowserControlsState::kHidden &&
current == cc::BrowserControlsState::kShown)); current == cc::BrowserControlsState::kShown));
if (current == cc::BrowserControlsState::kShown) {
top_shown_ratio_ = 1;
bottom_shown_ratio_ = 1;
} else if (current == cc::BrowserControlsState::kHidden) {
top_shown_ratio_ = TopMinShownRatio();
bottom_shown_ratio_ = BottomMinShownRatio();
}
page_->GetChromeClient().DidUpdateBrowserControls();
} }
void BrowserControls::SetParams(cc::BrowserControlsParams params) { void BrowserControls::SetParams(cc::BrowserControlsParams params) {
......
...@@ -55,8 +55,7 @@ class CORE_EXPORT BrowserControls final ...@@ -55,8 +55,7 @@ class CORE_EXPORT BrowserControls final
void SetShownRatio(float top_ratio, float bottom_ratio); void SetShownRatio(float top_ratio, float bottom_ratio);
void UpdateConstraintsAndState(cc::BrowserControlsState constraints, void UpdateConstraintsAndState(cc::BrowserControlsState constraints,
cc::BrowserControlsState current, cc::BrowserControlsState current);
bool animate);
void ScrollBegin(); void ScrollBegin();
...@@ -64,6 +63,8 @@ class CORE_EXPORT BrowserControls final ...@@ -64,6 +63,8 @@ class CORE_EXPORT BrowserControls final
// scroll amount. // scroll amount.
FloatSize ScrollBy(FloatSize scroll_delta); FloatSize ScrollBy(FloatSize scroll_delta);
void ScrollEnd();
cc::BrowserControlsState PermittedState() const { return permitted_state_; } cc::BrowserControlsState PermittedState() const { return permitted_state_; }
private: private:
......
...@@ -659,6 +659,8 @@ void ScrollManager::HandleDeferredGestureScrollEnd( ...@@ -659,6 +659,8 @@ void ScrollManager::HandleDeferredGestureScrollEnd(
WebInputEventResult ScrollManager::HandleGestureScrollEnd( WebInputEventResult ScrollManager::HandleGestureScrollEnd(
const WebGestureEvent& gesture_event) { const WebGestureEvent& gesture_event) {
TRACE_EVENT0("input", "ScrollManager::handleGestureScrollEnd"); TRACE_EVENT0("input", "ScrollManager::handleGestureScrollEnd");
GetPage()->GetBrowserControls().ScrollEnd();
Node* node = scroll_gesture_handling_node_; Node* node = scroll_gesture_handling_node_;
if (node && node->GetLayoutObject()) { if (node && node->GetLayoutObject()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment