Commit 5ad034ec authored by mfomitchev's avatar mfomitchev Committed by Commit bot

Switching Clank to use direction-based selection granularity strategy and adding a chrome flag.

This will also be enabled on Aura when Aura and Android touch selection flows
finally unified. I also plan to have at least one more experimental strategy
implmenented.

Prerequisite CL: https://codereview.chromium.org/988023005/

BUG=451255

Review URL: https://codereview.chromium.org/1096773002

Cr-Commit-Position: refs/heads/master@{#326896}
parent ec9abae8
......@@ -5876,6 +5876,18 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_ENABLE_TOUCH_EDITING_DESCRIPTION" desc="Description of the flag to enable touch based text editing.">
Touch editing can be initiated by tapping on a textfield or a selected text.
</message>
<message name="IDS_FLAGS_TOUCH_SELECTION_STRATEGY_NAME" desc="Name of the flag that controls touch based text selection strategy.">
Touch text selection strategy
</message>
<message name="IDS_FLAGS_TOUCH_SELECTION_STRATEGY_DESCRIPTION" desc="Description of the flag that controls touch based text selection strategy.">
Controls how text selection granularity changes when touch text selection handles are dragged. Non-default behavior is experimental.
</message>
<message name="IDS_TOUCH_SELECTION_STRATEGY_CHARACTER" desc="Description for the touch text selection strategy which always uses character granularity.">
Character
</message>
<message name="IDS_TOUCH_SELECTION_STRATEGY_DIRECTION" desc="Description for the touch text selection strategy which is based on the direction in which the handle is dragged.">
Direction
</message>
<message name="IDS_FLAGS_WALLET_SERVICE_USE_SANDBOX_NAME" desc="Title for the flag to use the Online Wallet sandbox servers (instead of production).">
Use Wallet sandbox servers
</message>
......
......@@ -180,6 +180,16 @@ const Experiment::Choice kOverscrollHistoryNavigationChoices[] = {
};
#endif
const Experiment::Choice kTouchTextSelectionStrategyChoices[] = {
{ IDS_GENERIC_EXPERIMENT_CHOICE_DEFAULT, "", "" },
{ IDS_TOUCH_SELECTION_STRATEGY_CHARACTER,
switches::kTouchTextSelectionStrategy,
"character" },
{ IDS_TOUCH_SELECTION_STRATEGY_DIRECTION,
switches::kTouchTextSelectionStrategy,
"direction" }
};
#if !defined(DISABLE_NACL)
const Experiment::Choice kNaClDebugMaskChoices[] = {
// Secure shell can be used on ChromeOS for forwarding the TCP port opened by
......@@ -1218,6 +1228,13 @@ const Experiment kExperiments[] = {
ENABLE_DISABLE_VALUE_TYPE(switches::kEnableTouchEditing,
switches::kDisableTouchEditing)
},
{
"touch-selection-strategy",
IDS_FLAGS_TOUCH_SELECTION_STRATEGY_NAME,
IDS_FLAGS_TOUCH_SELECTION_STRATEGY_DESCRIPTION,
kOsAndroid, // TODO(mfomitchev): Add CrOS/Win/Linux support soon.
MULTI_VALUE_TYPE(kTouchTextSelectionStrategyChoices)
},
{
"enable-stale-while-revalidate",
IDS_FLAGS_ENABLE_STALE_WHILE_REVALIDATE_NAME,
......
......@@ -1325,6 +1325,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kStatsCollectionController,
switches::kTestType,
switches::kTouchEvents,
switches::kTouchTextSelectionStrategy,
switches::kTraceToConsole,
// This flag needs to be propagated to the renderer process for
// --in-process-webgl.
......
......@@ -785,6 +785,11 @@ const char kTestingFixedHttpsPort[] = "testing-fixed-https-port";
// Type of the current test harness ("browser" or "ui").
const char kTestType[] = "test-type";
// Controls how text selection granularity changes when touch text selection
// handles are dragged. Should be "character" or "direction". If not specified,
// the platform default is used.
const char kTouchTextSelectionStrategy[] = "touch-selection-strategy";
// Causes TRACE_EVENT flags to be recorded beginning with shutdown. Optionally,
// can specify the specific trace categories to include (e.g.
// --trace-shutdown=base,net) otherwise, all events are recorded.
......
......@@ -217,6 +217,7 @@ CONTENT_EXPORT extern const char kTabCaptureUpscaleQuality[];
CONTENT_EXPORT extern const char kTestingFixedHttpPort[];
CONTENT_EXPORT extern const char kTestingFixedHttpsPort[];
CONTENT_EXPORT extern const char kTestType[];
CONTENT_EXPORT extern const char kTouchTextSelectionStrategy[];
CONTENT_EXPORT extern const char kTraceShutdown[];
extern const char kTraceShutdownFile[];
extern const char kTraceStartup[];
......
......@@ -762,6 +762,25 @@ void RenderViewImpl::Initialize(const ViewMsg_New_Params& params,
if (switches::IsTouchEditingEnabled())
webview()->settings()->setTouchEditingEnabled(true);
#if defined(OS_ANDROID)
WebSettings::SelectionStrategyType selection_strategy_default =
WebSettings::SelectionStrategyType::Direction;
#else
WebSettings::SelectionStrategyType selection_strategy_default =
WebSettings::SelectionStrategyType::Character;
#endif
WebSettings::SelectionStrategyType selection_strategy =
selection_strategy_default;
const std::string selection_strategy_str =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kTouchTextSelectionStrategy);
if (selection_strategy_str == "character")
selection_strategy = WebSettings::SelectionStrategyType::Character;
else if (selection_strategy_str == "direction")
selection_strategy = WebSettings::SelectionStrategyType::Direction;
webview()->settings()->setSelectionStrategy(selection_strategy);
if (!params.frame_name.empty())
webview()->mainFrame()->setName(params.frame_name);
......
......@@ -55340,6 +55340,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="593707592" label="disable-network-portal-notification"/>
<int value="598827460" label="enable-roboto-font-ui"/>
<int value="606288133" label="enable-print-preview-register-promos"/>
<int value="609112512" label="touch-selection-strategy"/>
<int value="610545308" label="enable-potentially-annoying-security-features"/>
<int value="625273056" label="disable-boot-animation"/>
<int value="630947363" label="touch-events"/>
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