Commit 92c5ab40 authored by Mohsen Izadi's avatar Mohsen Izadi Committed by Commit Bot

Honor overscroll-behavior CSS property in new gesture-nav UI

When overscroll-behavior-x for the root element of a page is set to
anything other than 'auto', gesture-nav should not start on the page.

Similarly, when overscroll-behavior-y for the root element of a page is
set to anything other than 'auto', pull-to-refresh should not start on
the page.

BUG=800074,742510
TEST=GestureNavSimpleTest.* in content_unittests

Change-Id: I86cf2f50c5ceb6613dc293c1fd32ca2cfff4daa2
Reviewed-on: https://chromium-review.googlesource.com/981127Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Mohsen Izadi <mohsen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546736}
parent 7555a545
......@@ -555,6 +555,12 @@ bool GestureNavSimple::OnOverscrollUpdate(float delta_x, float delta_y) {
}
void GestureNavSimple::OnOverscrollComplete(OverscrollMode overscroll_mode) {
if (mode_ == OverscrollMode::OVERSCROLL_NONE) {
// Previous mode change has been ignored because of overscroll-behavior
// value; so, ignore this, too.
return;
}
DCHECK_EQ(mode_, overscroll_mode);
mode_ = OVERSCROLL_NONE;
......@@ -599,6 +605,29 @@ void GestureNavSimple::OnOverscrollModeChange(OverscrollMode old_mode,
OverscrollMode new_mode,
OverscrollSource source,
cc::OverscrollBehavior behavior) {
DCHECK(old_mode == OverscrollMode::OVERSCROLL_NONE ||
new_mode == OverscrollMode::OVERSCROLL_NONE);
// Do not start a new gesture-nav if overscroll-behavior-x is not auto.
if ((new_mode == OverscrollMode::OVERSCROLL_EAST ||
new_mode == OverscrollMode::OVERSCROLL_WEST) &&
behavior.x != cc::OverscrollBehavior::kOverscrollBehaviorTypeAuto) {
return;
}
// Do not start a new pull-to-refresh if overscroll-behavior-y is not auto.
if (new_mode == OverscrollMode::OVERSCROLL_SOUTH &&
behavior.y != cc::OverscrollBehavior::kOverscrollBehaviorTypeAuto) {
return;
}
if (old_mode != OverscrollMode::OVERSCROLL_NONE &&
mode_ == OverscrollMode::OVERSCROLL_NONE) {
// Previous mode change has been ignored because of overscroll-behavior
// value; so, ignore this one, too.
return;
}
DCHECK_EQ(mode_, old_mode);
if (mode_ == new_mode)
return;
......
......@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "content/browser/renderer_host/overscroll_controller_delegate.h"
#include "content/common/content_export.h"
namespace content {
......@@ -17,7 +18,7 @@ class WebContentsImpl;
// A simple delegate for the overscroll controller that paints an arrow on top
// of the web-contents as a hint for pending navigations from overscroll.
class GestureNavSimple : public OverscrollControllerDelegate {
class CONTENT_EXPORT GestureNavSimple : public OverscrollControllerDelegate {
public:
explicit GestureNavSimple(WebContentsImpl* web_contents);
~GestureNavSimple() override;
......@@ -27,6 +28,8 @@ class GestureNavSimple : public OverscrollControllerDelegate {
void OnAffordanceAnimationEnded();
private:
friend class GestureNavSimpleTest;
// OverscrollControllerDelegate:
gfx::Size GetDisplaySize() const override;
bool OnOverscrollUpdate(float delta_x, float delta_y) override;
......
......@@ -1497,6 +1497,7 @@ test("content_unittests") {
"../browser/tracing/background_memory_tracing_observer_unittest.cc",
"../browser/tracing/background_tracing_config_unittest.cc",
"../browser/tracing/tracing_ui_unittest.cc",
"../browser/web_contents/aura/gesture_nav_simple_unittest.cc",
"../browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc",
"../browser/web_contents/aura/overscroll_window_animation_unittest.cc",
"../browser/web_contents/aura/overscroll_window_delegate_unittest.cc",
......@@ -2025,6 +2026,7 @@ test("content_unittests") {
} else {
sources -= [
"../browser/renderer_host/render_widget_host_view_aura_unittest.cc",
"../browser/web_contents/aura/gesture_nav_simple_unittest.cc",
"../browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc",
"../browser/web_contents/aura/overscroll_window_animation_unittest.cc",
"../browser/web_contents/aura/overscroll_window_delegate_unittest.cc",
......
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