Commit 7a4a6008 authored by Shimi Zhang's avatar Shimi Zhang Committed by Chromium LUCI CQ

Cursor Control: Make the feature only available on Android R and above

Since the Android platform has this feature on Android R and above,
we need to make it consistent with the platform.

Bug: 1126778
Change-Id: Ie1404bc963e01b5154b4751413423f2e58ef9289
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575729Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Shimi Zhang <ctzsm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834500}
parent 61371742
......@@ -104,7 +104,8 @@ public final class ProductionSupportedFlagList {
Flag.baseFeature(AwFeatures.WEBVIEW_MIXED_CONTENT_AUTOUPGRADES,
"Enables autoupgrades for audio/video/image mixed content when mixed content "
+ "mode is set to MIXED_CONTENT_COMPATIBILITY_MODE"),
Flag.baseFeature(
UiFeatures.SWIPE_TO_MOVE_CURSOR, "Enables swipe to move cursor feature."),
Flag.baseFeature(UiFeatures.SWIPE_TO_MOVE_CURSOR,
"Enables swipe to move cursor feature."
+ "This flag will only take effect on Android 11 and above."),
};
}
......@@ -3275,7 +3275,8 @@ const char kAndroidNightModeTabReparentingDescription[] =
const char kSwipeToMoveCursorName[] = "Swipe to move cursor";
const char kSwipeToMoveCursorDescription[] =
"Allows user to use touch gestures to move the text cursor around.";
"Allows user to use touch gestures to move the text cursor around. This "
"flag will only take effect on Android 11 and above.";
const char kTabbedAppOverflowMenuIconsName[] =
"Android tabbed app overflow menu icons";
......
......@@ -826,7 +826,6 @@ class TouchActionBrowserTestEnableCursorControl
public:
TouchActionBrowserTestEnableCursorControl() {
feature_list_.InitWithFeatures({::features::kSwipeToMoveCursor}, {});
DCHECK(base::FeatureList::IsEnabled(::features::kSwipeToMoveCursor));
}
private:
......@@ -838,6 +837,8 @@ class TouchActionBrowserTestEnableCursorControl
// scroll, and changes the selection.
IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
BasicCursorControl) {
if (!::features::IsSwipeToMoveCursorEnabled())
return;
base::HistogramTester histograms;
LoadURL(kContentEditableDataURL.c_str());
......@@ -869,6 +870,8 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
// changed and scroll should happen.
IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
NoCursorControlForHorizontalScrollable) {
if (!::features::IsSwipeToMoveCursorEnabled())
return;
base::HistogramTester histograms;
LoadURL(kContentEditableHorizontalScrollableDataURL.c_str());
......@@ -900,6 +903,8 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
// Ensure the swipe is not triggering cursor control.
IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
NoCursorControlForNonPassiveLisenter) {
if (!::features::IsSwipeToMoveCursorEnabled())
return;
LoadURL(kContentEditableNonPassiveHandlerDataURL.c_str());
EXPECT_EQ(32,
......@@ -925,6 +930,8 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
// scroll, and changes the selection.
IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
CursorControlOnInput) {
if (!::features::IsSwipeToMoveCursorEnabled())
return;
base::HistogramTester histograms;
// input size larger than the text size, not horizontally scrollable.
LoadURL(base::StringPrintf(kInputTagCursorControl.c_str(), 40).c_str());
......@@ -953,6 +960,8 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
// right to left. Ensure the swipe is doing scrolling other than cursor control.
IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
NoCursorControlOnHorizontalScrollableInput) {
if (!::features::IsSwipeToMoveCursorEnabled())
return;
base::HistogramTester histograms;
// Make the input size smaller than the text size, so it horizontally
// scrollable.
......
......@@ -599,7 +599,7 @@ static void AdjustEffectiveTouchAction(ComputedStyle& style,
TouchAction enforced_by_policy = TouchAction::kNone;
if (element->GetDocument().IsVerticalScrollEnforced())
enforced_by_policy = TouchAction::kPanY;
if (base::FeatureList::IsEnabled(::features::kSwipeToMoveCursor) &&
if (::features::IsSwipeToMoveCursorEnabled() &&
IsEditableElement(element, style)) {
element_touch_action &= ~TouchAction::kInternalPanXScrolls;
}
......
......@@ -178,7 +178,8 @@ TEST_F(StyleAdjusterTest, AdjustOverflow) {
TEST_F(StyleAdjusterTest, TouchActionContentEditableArea) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures({::features::kSwipeToMoveCursor}, {});
ASSERT_TRUE(base::FeatureList::IsEnabled(::features::kSwipeToMoveCursor));
if (!::features::IsSwipeToMoveCursorEnabled())
return;
GetDocument().SetBaseURLOverride(KURL("http://test.com"));
SetBodyInnerHTML(R"HTML(
......@@ -229,7 +230,8 @@ TEST_F(StyleAdjusterTest, TouchActionContentEditableArea) {
TEST_F(StyleAdjusterTest, TouchActionNoPanXScrollsWhenNoPanX) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures({::features::kSwipeToMoveCursor}, {});
ASSERT_TRUE(base::FeatureList::IsEnabled(::features::kSwipeToMoveCursor));
if (!::features::IsSwipeToMoveCursorEnabled())
return;
GetDocument().SetBaseURLOverride(KURL("http://test.com"));
SetBodyInnerHTML(R"HTML(
......
......@@ -668,7 +668,8 @@ TEST_P(ScrollingTest, nestedTouchActionChangesUnion) {
TEST_P(ScrollingTest, touchActionEditableElement) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures({::features::kSwipeToMoveCursor}, {});
ASSERT_TRUE(base::FeatureList::IsEnabled(::features::kSwipeToMoveCursor));
if (!::features::IsSwipeToMoveCursorEnabled())
return;
// Long text that will overflow in y-direction.
LoadHTML(R"HTML(
<style>
......
......@@ -10,6 +10,10 @@
#include "base/win/windows_version.h"
#endif
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
#endif
namespace features {
#if defined(OS_WIN)
......@@ -268,4 +272,16 @@ const char kFilterNameOneEuro[] = "one_euro_filter";
const base::Feature kSwipeToMoveCursor{"SwipeToMoveCursor",
base::FEATURE_DISABLED_BY_DEFAULT};
bool IsSwipeToMoveCursorEnabled() {
static const bool enabled =
base::FeatureList::IsEnabled(kSwipeToMoveCursor)
#if defined(OS_ANDROID)
&& base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_R;
#else
;
#endif
return enabled;
}
} // namespace features
......@@ -147,6 +147,8 @@ COMPONENT_EXPORT(UI_BASE_FEATURES) extern const char kFilterNameOneEuro[];
COMPONENT_EXPORT(UI_BASE_FEATURES)
extern const base::Feature kSwipeToMoveCursor;
COMPONENT_EXPORT(UI_BASE_FEATURES) bool IsSwipeToMoveCursorEnabled();
} // namespace features
#endif // UI_BASE_UI_BASE_FEATURES_H_
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