Commit cd44c762 authored by chaopeng's avatar chaopeng Committed by Commit Bot

Disable overscroll history navigation on Windows Touchpad

Disable overscroll history navigation on Windows Touchpad with
feature flag. This CL also wraps all changes in crrev/c/98210
and crrev/c/1003214 behind this flag.

This CL also disable overscroll history navigation on Linux
Touchpad since we will set has_precise_delta for Linux soon.

Bug: 647140
Change-Id: Id08654bf20b3ada7b5e75f2308a915efeed0e934
Reviewed-on: https://chromium-review.googlesource.com/1002866
Commit-Queue: Jianpeng Chao <chaopeng@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarMohsen Izadi <mohsen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550508}
parent 5824f158
......@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
namespace {
......@@ -25,6 +26,9 @@ const float kThresholdCompleteTouchscreen = 0.25f;
const float kThresholdStartTouchpad = 60.f;
const float kThresholdStartTouchscreen = 50.f;
bool g_is_touchpad_overscroll_history_navigation_enabled_initialized = false;
bool g_touchpad_overscroll_history_navigation_enabled = false;
float GetStartThresholdMultiplier() {
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
if (!cmd->HasSwitch(switches::kOverscrollStartThreshold))
......@@ -127,4 +131,21 @@ void OverscrollConfig::ResetPullToRefreshMode() {
g_ptr_mode = OverscrollConfig::PullToRefreshMode::kDisabled;
}
// static
bool OverscrollConfig::TouchpadOverscrollHistoryNavigationEnabled() {
if (!g_is_touchpad_overscroll_history_navigation_enabled_initialized) {
g_is_touchpad_overscroll_history_navigation_enabled_initialized = true;
g_touchpad_overscroll_history_navigation_enabled =
base::FeatureList::IsEnabled(
features::kTouchpadOverscrollHistoryNavigation);
}
return g_touchpad_overscroll_history_navigation_enabled;
}
// static
void OverscrollConfig::ResetTouchpadOverscrollHistoryNavigationEnabled() {
g_is_touchpad_overscroll_history_navigation_enabled_initialized = false;
}
} // namespace content
......@@ -458,6 +458,14 @@ bool OverscrollController::ProcessOverscroll(float delta_x,
fabs(overscroll_delta_y_) > fabs(overscroll_delta_x_) * kMinRatio)
new_mode = overscroll_delta_y_ > 0.f ? OVERSCROLL_SOUTH : OVERSCROLL_NORTH;
// The horizontal overscroll is used for history navigation. Enable it for
// touchpad only if TouchpadOverscrollHistoryNavigation is enabled.
if ((new_mode == OVERSCROLL_EAST || new_mode == OVERSCROLL_WEST) &&
is_touchpad &&
!OverscrollConfig::TouchpadOverscrollHistoryNavigationEnabled()) {
new_mode = OVERSCROLL_NONE;
}
// The vertical overscroll is used for pull-to-refresh. Enable it only if
// pull-to-refresh is enabled.
if (new_mode == OVERSCROLL_SOUTH || new_mode == OVERSCROLL_NORTH) {
......
......@@ -7,8 +7,11 @@
#include <memory>
#include "base/containers/queue.h"
#include "base/test/scoped_feature_list.h"
#include "content/browser/renderer_host/overscroll_controller_delegate.h"
#include "content/common/input/synthetic_web_input_event_builders.h"
#include "content/public/browser/overscroll_configuration.h"
#include "content/public/common/content_features.h"
#include "content/public/test/scoped_overscroll_modes.h"
#include "content/test/test_overscroll_delegate.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -22,6 +25,9 @@ class OverscrollControllerTest : public ::testing::Test {
~OverscrollControllerTest() override {}
void SetUp() override {
OverscrollConfig::ResetTouchpadOverscrollHistoryNavigationEnabled();
scoped_feature_list_.InitAndEnableFeature(
features::kTouchpadOverscrollHistoryNavigation);
delegate_ = std::make_unique<TestOverscrollDelegate>(gfx::Size(400, 300));
controller_ = std::make_unique<OverscrollController>();
controller_->set_delegate(delegate_.get());
......@@ -107,6 +113,8 @@ class OverscrollControllerTest : public ::testing::Test {
// the last event is ACKed.
std::unique_ptr<blink::WebInputEvent> current_event_;
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(OverscrollControllerTest);
};
......@@ -324,4 +332,21 @@ TEST_F(OverscrollControllerTest, PullToRefreshEnabledTouchscreen) {
EXPECT_EQ(OVERSCROLL_NONE, delegate()->completed_mode());
}
// Ensure disabling kTouchpadOverscrollHistoryNavigation will prevent overscroll
// from touchpad.
TEST_F(OverscrollControllerTest, DisableTouchpadOverscrollHistoryNavigation) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(
features::kTouchpadOverscrollHistoryNavigation);
ASSERT_FALSE(OverscrollConfig::TouchpadOverscrollHistoryNavigationEnabled());
EXPECT_FALSE(SimulateGestureScrollUpdate(
200, 0, blink::kWebGestureDeviceTouchpad, false));
SimulateAck(false);
EXPECT_EQ(OVERSCROLL_NONE, controller_mode());
EXPECT_EQ(OverscrollSource::NONE, controller_source());
EXPECT_EQ(OVERSCROLL_NONE, delegate()->current_mode());
EXPECT_EQ(OVERSCROLL_NONE, delegate()->completed_mode());
}
} // namespace content
......@@ -900,6 +900,9 @@ class RenderWidgetHostViewAuraOverscrollTest
void SetUpOverscrollEnvironmentImpl(int debounce_interval_in_ms) {
SetFeatureList();
scoped_feature_list_.InitAndEnableFeature(
features::kTouchpadOverscrollHistoryNavigation);
ui::GestureConfiguration::GetInstance()->set_scroll_debounce_interval_in_ms(
debounce_interval_in_ms);
......@@ -1237,6 +1240,8 @@ class RenderWidgetHostViewAuraOverscrollTest
bool wheel_scroll_latching_enabled_;
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAuraOverscrollTest);
};
......
......@@ -60,9 +60,12 @@ class CONTENT_EXPORT OverscrollConfig {
static float GetThreshold(Threshold threshold);
static bool TouchpadOverscrollHistoryNavigationEnabled();
private:
friend class ScopedHistoryNavigationMode;
friend class ScopedPullToRefreshMode;
friend class OverscrollControllerTest;
// Helper functions used by |ScopedHistoryNavigationMode| to set and reset
// mode in tests.
......@@ -74,6 +77,10 @@ class CONTENT_EXPORT OverscrollConfig {
static void SetPullToRefreshMode(PullToRefreshMode mode);
static void ResetPullToRefreshMode();
// Helper functions to reset TouchpadOverscrollHistoryNavigationEnabled in
// tests.
static void ResetTouchpadOverscrollHistoryNavigationEnabled();
DISALLOW_IMPLICIT_CONSTRUCTORS(OverscrollConfig);
};
......
......@@ -36,6 +36,16 @@ const base::Feature kAsmJsToWebAssembly{"AsmJsToWebAssembly",
const base::Feature kAsyncWheelEvents{"AsyncWheelEvents",
base::FEATURE_ENABLED_BY_DEFAULT};
// Allows swipe left/right from touchpad change browser navigation.
const base::Feature kTouchpadOverscrollHistoryNavigation {
"TouchpadOverscrollHistoryNavigation",
#if defined(OS_WIN) || defined(OS_LINUX)
base::FEATURE_DISABLED_BY_DEFAULT
#else
base::FEATURE_ENABLED_BY_DEFAULT
#endif
};
// Block subresource requests whose URLs contain embedded credentials (e.g.
// `https://user:pass@example.com/resource`).
const base::Feature kBlockCredentialedSubresources{
......
......@@ -96,6 +96,7 @@ CONTENT_EXPORT extern const base::Feature kStopNonTimersInBackground;
CONTENT_EXPORT extern const base::Feature kTimerThrottlingForHiddenFrames;
CONTENT_EXPORT extern const base::Feature kTopDocumentIsolation;
CONTENT_EXPORT extern const base::Feature kTouchpadAndWheelScrollLatching;
CONTENT_EXPORT extern const base::Feature kTouchpadOverscrollHistoryNavigation;
CONTENT_EXPORT extern const base::Feature
kTurnOff2DAndOpacityCompositorAnimations;
CONTENT_EXPORT extern const base::Feature kUnifiedTouchAdjustment;
......
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