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