Skip to content

Commit

Permalink
[Android WebView] make spellcheck off by default and opt-in using spe…
Browse files Browse the repository at this point in the history
…llcheck="true" attribute.

In WebView no spellchecking will be provided on html elements
unless explicitly enabled via the spellcheck="true" attribute.
The main motivation is to have consistent backward behavior in
apps that use WebView. Also this will benefit performance and
battery life on mobile devices (see crbug.com/652314).

Related blink-side patch:
https://codereview.chromium.org/2316303006/

BUG=652314, 583616, 629609

Review-Url: https://codereview.chromium.org/2391613002
Cr-Commit-Position: refs/heads/master@{#423147}
  • Loading branch information
timvolodine authored and Commit bot committed Oct 5, 2016
1 parent ac80c9a commit db19519
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions android_webview/native/aw_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ void AwSettings::PopulateWebPreferencesLocked(JNIEnv* env,

// We use system scrollbars, so make Blink's scrollbars invisible.
web_prefs->hide_scrollbars = true;

// Keep spellcheck disabled on html elements unless the spellcheck="true"
// attribute is explicitly specified. This "opt-in" behavior is for backward
// consistency in apps that use WebView (see crbug.com/652314).
web_prefs->spellcheck_enabled_by_default = false;
}

static jlong Init(JNIEnv* env,
Expand Down
1 change: 1 addition & 0 deletions content/public/common/common_param_traits_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebPreferences)
IPC_STRUCT_TRAITS_MEMBER(resue_global_for_unowned_main_frame)
IPC_STRUCT_TRAITS_MEMBER(autoplay_muted_videos_enabled)
IPC_STRUCT_TRAITS_MEMBER(progress_bar_completion)
IPC_STRUCT_TRAITS_MEMBER(spellcheck_enabled_by_default)
#endif
IPC_STRUCT_TRAITS_MEMBER(autoplay_experiment_mode)
IPC_STRUCT_TRAITS_MEMBER(default_minimum_page_scale_factor)
Expand Down
1 change: 1 addition & 0 deletions content/public/common/web_preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ WebPreferences::WebPreferences()
resue_global_for_unowned_main_frame(false),
autoplay_muted_videos_enabled(false),
progress_bar_completion(ProgressBarCompletion::LOAD_EVENT),
spellcheck_enabled_by_default(true),
#endif
#if defined(OS_ANDROID)
default_minimum_page_scale_factor(0.25f),
Expand Down
3 changes: 3 additions & 0 deletions content/public/common/web_preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ struct CONTENT_EXPORT WebPreferences {
bool resue_global_for_unowned_main_frame;
bool autoplay_muted_videos_enabled;
ProgressBarCompletion progress_bar_completion;
// Specifies default setting for spellcheck when the spellcheck attribute is
// not explicitly specified.
bool spellcheck_enabled_by_default;
#endif

// String that describes how media element autoplay behavior should be
Expand Down
1 change: 1 addition & 0 deletions content/renderer/render_view_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,7 @@ void RenderView::ApplyWebPreferences(const WebPreferences& prefs,
settings->setForcePreloadNoneForMediaElements(is_low_end_device);
WebRuntimeFeatures::enableAutoplayMutedVideos(
prefs.autoplay_muted_videos_enabled && !is_low_end_device);
settings->setSpellCheckEnabledByDefault(prefs.spellcheck_enabled_by_default);
#endif

settings->setAutoplayExperimentMode(
Expand Down

0 comments on commit db19519

Please sign in to comment.