Replace all uses of web_pref::EditingBehaviorType with mojom::EditingBehavior
This CL replaces all uses of EditingBehaviorType with mojom::EditingBehavior to reduce unnecessary type conversion. Bug: 1097943 Change-Id: I013e40a725d7b12f1f9d88a37f068e4163d1d399 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450130 Reviewed-by: Kentaro Hara <haraken@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com> Cr-Commit-Position: refs/heads/master@{#814131}
This commit is contained in:
content/web_test
third_party/blink
common
web_preferences
public
common
mojom
webpreferences
web
renderer
@ -264,9 +264,10 @@ void ApplyWebTestDefaultPreferences(blink::web_pref::WebPreferences* prefs) {
|
||||
prefs->translate_service_available = true;
|
||||
|
||||
#if defined(OS_MAC)
|
||||
prefs->editing_behavior = blink::web_pref::kEditingMacBehavior;
|
||||
prefs->editing_behavior = blink::mojom::EditingBehavior::kEditingMacBehavior;
|
||||
#else
|
||||
prefs->editing_behavior = blink::web_pref::kEditingWindowsBehavior;
|
||||
prefs->editing_behavior =
|
||||
blink::mojom::EditingBehavior::kEditingWindowsBehavior;
|
||||
#endif
|
||||
|
||||
#if defined(OS_MAC)
|
||||
|
@ -30,10 +30,9 @@ void TestPreferences::Reset() {
|
||||
allow_universal_access_from_file_urls = false;
|
||||
|
||||
#if defined(OS_MAC)
|
||||
editing_behavior = blink::web_pref::EditingBehaviorType::kEditingMacBehavior;
|
||||
editing_behavior = blink::mojom::EditingBehavior::kEditingMacBehavior;
|
||||
#else
|
||||
editing_behavior =
|
||||
blink::web_pref::EditingBehaviorType::kEditingWindowsBehavior;
|
||||
editing_behavior = blink::mojom::EditingBehavior::kEditingWindowsBehavior;
|
||||
#endif
|
||||
|
||||
tabs_to_links = false;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef CONTENT_WEB_TEST_RENDERER_TEST_PREFERENCES_H_
|
||||
#define CONTENT_WEB_TEST_RENDERER_TEST_PREFERENCES_H_
|
||||
|
||||
#include "third_party/blink/public/common/web_preferences/editing_behavior_types.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom.h"
|
||||
#include "third_party/blink/public/platform/web_string.h"
|
||||
#include "third_party/blink/public/platform/web_url.h"
|
||||
|
||||
@ -24,7 +24,7 @@ struct TestPreferences {
|
||||
bool loads_images_automatically;
|
||||
bool plugins_enabled;
|
||||
bool allow_universal_access_from_file_urls;
|
||||
blink::web_pref::EditingBehaviorType editing_behavior;
|
||||
blink::mojom::EditingBehavior editing_behavior;
|
||||
bool tabs_to_links;
|
||||
bool hyperlink_auditing_enabled;
|
||||
bool caret_browsing_enabled;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "build/build_config.h"
|
||||
#include "third_party/blink/public/common/features.h"
|
||||
#include "third_party/blink/public/mojom/v8_cache_options.mojom.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom.h"
|
||||
#include "ui/base/ui_base_switches_util.h"
|
||||
|
||||
namespace {
|
||||
@ -100,20 +101,20 @@ WebPreferences::WebPreferences()
|
||||
sync_xhr_in_documents_enabled(true),
|
||||
number_of_cpu_cores(1),
|
||||
#if defined(OS_MAC)
|
||||
editing_behavior(web_pref::kEditingMacBehavior),
|
||||
editing_behavior(mojom::EditingBehavior::kEditingMacBehavior),
|
||||
#elif defined(OS_WIN)
|
||||
editing_behavior(web_pref::kEditingWindowsBehavior),
|
||||
editing_behavior(mojom::EditingBehavior::kEditingWindowsBehavior),
|
||||
#elif defined(OS_ANDROID)
|
||||
editing_behavior(web_pref::kEditingAndroidBehavior),
|
||||
editing_behavior(mojom::EditingBehavior::kEditingAndroidBehavior),
|
||||
#elif defined(OS_CHROMEOS)
|
||||
editing_behavior(
|
||||
base::FeatureList::IsEnabled(blink::features::kCrOSAutoSelect)
|
||||
? web_pref::kEditingChromeOSBehavior
|
||||
: web_pref::kEditingUnixBehavior),
|
||||
? mojom::EditingBehavior::kEditingChromeOSBehavior
|
||||
: mojom::EditingBehavior::kEditingUnixBehavior),
|
||||
#elif defined(OS_POSIX)
|
||||
editing_behavior(web_pref::kEditingUnixBehavior),
|
||||
editing_behavior(mojom::EditingBehavior::kEditingUnixBehavior),
|
||||
#else
|
||||
editing_behavior(web_pref::kEditingMacBehavior),
|
||||
editing_behavior(mojom::EditingBehavior::kEditingMacBehavior),
|
||||
#endif
|
||||
supports_multiple_windows(true),
|
||||
viewport_enabled(false),
|
||||
|
@ -76,52 +76,6 @@ bool EnumTraits<blink::mojom::HoverType, ui::HoverType>::FromMojom(
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
blink::mojom::EditingBehavior EnumTraits<blink::mojom::EditingBehavior,
|
||||
blink::web_pref::EditingBehaviorType>::
|
||||
ToMojom(blink::web_pref::EditingBehaviorType behavior) {
|
||||
switch (behavior) {
|
||||
case blink::web_pref::EditingBehaviorType::kEditingMacBehavior:
|
||||
return blink::mojom::EditingBehavior::kEditingMacBehavior;
|
||||
case blink::web_pref::EditingBehaviorType::kEditingWindowsBehavior:
|
||||
return blink::mojom::EditingBehavior::kEditingWindowsBehavior;
|
||||
case blink::web_pref::EditingBehaviorType::kEditingUnixBehavior:
|
||||
return blink::mojom::EditingBehavior::kEditingUnixBehavior;
|
||||
case blink::web_pref::EditingBehaviorType::kEditingAndroidBehavior:
|
||||
return blink::mojom::EditingBehavior::kEditingAndroidBehavior;
|
||||
case blink::web_pref::EditingBehaviorType::kEditingChromeOSBehavior:
|
||||
return blink::mojom::EditingBehavior::kEditingChromeOSBehavior;
|
||||
}
|
||||
NOTREACHED();
|
||||
return blink::mojom::EditingBehavior::kMaxValue;
|
||||
}
|
||||
|
||||
// static
|
||||
bool EnumTraits<blink::mojom::EditingBehavior,
|
||||
blink::web_pref::EditingBehaviorType>::
|
||||
FromMojom(blink::mojom::EditingBehavior input,
|
||||
blink::web_pref::EditingBehaviorType* out) {
|
||||
switch (input) {
|
||||
case blink::mojom::EditingBehavior::kEditingMacBehavior:
|
||||
*out = blink::web_pref::EditingBehaviorType::kEditingMacBehavior;
|
||||
return true;
|
||||
case blink::mojom::EditingBehavior::kEditingWindowsBehavior:
|
||||
*out = blink::web_pref::EditingBehaviorType::kEditingWindowsBehavior;
|
||||
return true;
|
||||
case blink::mojom::EditingBehavior::kEditingUnixBehavior:
|
||||
*out = blink::web_pref::EditingBehaviorType::kEditingUnixBehavior;
|
||||
return true;
|
||||
case blink::mojom::EditingBehavior::kEditingAndroidBehavior:
|
||||
*out = blink::web_pref::EditingBehaviorType::kEditingAndroidBehavior;
|
||||
return true;
|
||||
case blink::mojom::EditingBehavior::kEditingChromeOSBehavior:
|
||||
*out = blink::web_pref::EditingBehaviorType::kEditingChromeOSBehavior;
|
||||
return true;
|
||||
}
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
blink::mojom::ImageAnimationPolicy
|
||||
EnumTraits<blink::mojom::ImageAnimationPolicy,
|
||||
@ -353,7 +307,6 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
|
||||
!data.ReadTextTrackWindowRadius(&out->text_track_window_radius) ||
|
||||
!data.ReadPrimaryPointerType(&out->primary_pointer_type) ||
|
||||
!data.ReadPrimaryHoverType(&out->primary_hover_type) ||
|
||||
!data.ReadEditingBehavior(&out->editing_behavior) ||
|
||||
!data.ReadViewportStyle(&out->viewport_style) ||
|
||||
!data.ReadAnimationPolicy(&out->animation_policy) ||
|
||||
!data.ReadAutoplayPolicy(&out->autoplay_policy) ||
|
||||
@ -445,6 +398,7 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
|
||||
out->barrel_button_for_drag_enabled = data.barrel_button_for_drag_enabled();
|
||||
out->sync_xhr_in_documents_enabled = data.sync_xhr_in_documents_enabled();
|
||||
out->number_of_cpu_cores = data.number_of_cpu_cores();
|
||||
out->editing_behavior = data.editing_behavior();
|
||||
out->supports_multiple_windows = data.supports_multiple_windows();
|
||||
out->viewport_enabled = data.viewport_enabled();
|
||||
out->viewport_meta_enabled = data.viewport_meta_enabled();
|
||||
|
1
third_party/blink/public/common/BUILD.gn
vendored
1
third_party/blink/public/common/BUILD.gn
vendored
@ -188,7 +188,6 @@ source_set("headers") {
|
||||
"web_package/signed_exchange_consts.h",
|
||||
"web_package/web_package_request_matcher.h",
|
||||
"web_preferences/autoplay_policy.h",
|
||||
"web_preferences/editing_behavior_types.h",
|
||||
"web_preferences/image_animation_policy.h",
|
||||
"web_preferences/viewport_style.h",
|
||||
"web_preferences/web_preferences.h",
|
||||
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
|
||||
* Copyright (C) 2010 Apple Inc. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public License
|
||||
* along with this library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_EDITING_BEHAVIOR_TYPES_H_
|
||||
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_EDITING_BEHAVIOR_TYPES_H_
|
||||
|
||||
namespace blink {
|
||||
namespace web_pref {
|
||||
|
||||
// There are multiple editing details that are different on Windows than
|
||||
// Macintosh. We use a single switch for all of them. Some examples:
|
||||
//
|
||||
// 1) Clicking below the last line of an editable area puts the caret at the
|
||||
// end of the last line on Mac, but in the middle of the last line on
|
||||
// Windows.
|
||||
// 2) Pushing the down arrow key on the last line puts the caret at the end
|
||||
// of the last line on Mac, but does nothing on Windows. A similar case
|
||||
// exists on the top line.
|
||||
//
|
||||
// This setting is intended to control these sorts of behaviors. There are some
|
||||
// other behaviors with individual function calls on EditorClient (smart copy
|
||||
// and paste and selecting the space after a double click) that could be
|
||||
// combined with this if if possible in the future.
|
||||
enum EditingBehaviorType {
|
||||
kEditingMacBehavior,
|
||||
kEditingWindowsBehavior,
|
||||
kEditingUnixBehavior,
|
||||
kEditingAndroidBehavior,
|
||||
kEditingChromeOSBehavior
|
||||
};
|
||||
|
||||
} // namespace web_pref
|
||||
} // namespace blink
|
||||
|
||||
#endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_WEB_PREFERENCES_EDITING_BEHAVIOR_TYPES_H_
|
@ -16,10 +16,10 @@
|
||||
#include "third_party/blink/public/common/common_export.h"
|
||||
#include "third_party/blink/public/common/css/preferred_color_scheme.h"
|
||||
#include "third_party/blink/public/common/web_preferences/autoplay_policy.h"
|
||||
#include "third_party/blink/public/common/web_preferences/editing_behavior_types.h"
|
||||
#include "third_party/blink/public/common/web_preferences/image_animation_policy.h"
|
||||
#include "third_party/blink/public/common/web_preferences/viewport_style.h"
|
||||
#include "third_party/blink/public/mojom/v8_cache_options.mojom-forward.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-forward.h"
|
||||
#include "ui/base/pointer/pointer_device.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
@ -136,7 +136,7 @@ struct BLINK_COMMON_EXPORT WebPreferences {
|
||||
bool barrel_button_for_drag_enabled = false;
|
||||
bool sync_xhr_in_documents_enabled;
|
||||
int number_of_cpu_cores;
|
||||
EditingBehaviorType editing_behavior;
|
||||
blink::mojom::EditingBehavior editing_behavior;
|
||||
bool supports_multiple_windows;
|
||||
bool viewport_enabled;
|
||||
bool viewport_meta_enabled;
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "net/nqe/effective_connection_type.h"
|
||||
#include "third_party/blink/public/common/common_export.h"
|
||||
#include "third_party/blink/public/common/css/preferred_color_scheme.h"
|
||||
#include "third_party/blink/public/common/web_preferences/autoplay_policy.h"
|
||||
#include "third_party/blink/public/common/web_preferences/image_animation_policy.h"
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom.h"
|
||||
#include "ui/base/pointer/pointer_device.h"
|
||||
@ -41,16 +43,6 @@ struct BLINK_COMMON_EXPORT EnumTraits<blink::mojom::PreferredColorScheme,
|
||||
blink::PreferredColorScheme* out);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct BLINK_COMMON_EXPORT EnumTraits<blink::mojom::EditingBehavior,
|
||||
blink::web_pref::EditingBehaviorType> {
|
||||
static blink::mojom::EditingBehavior ToMojom(
|
||||
blink::web_pref::EditingBehaviorType behavior);
|
||||
|
||||
static bool FromMojom(blink::mojom::EditingBehavior input,
|
||||
blink::web_pref::EditingBehaviorType* out);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct BLINK_COMMON_EXPORT EnumTraits<blink::mojom::ImageAnimationPolicy,
|
||||
blink::web_pref::ImageAnimationPolicy> {
|
||||
@ -437,7 +429,7 @@ struct BLINK_COMMON_EXPORT StructTraits<blink::mojom::WebPreferencesDataView,
|
||||
return r.number_of_cpu_cores;
|
||||
}
|
||||
|
||||
static blink::web_pref::EditingBehaviorType editing_behavior(
|
||||
static blink::mojom::EditingBehavior editing_behavior(
|
||||
const blink::web_pref::WebPreferences& r) {
|
||||
return r.editing_behavior;
|
||||
}
|
||||
|
@ -24,8 +24,20 @@ enum PreferredColorScheme {
|
||||
kLight,
|
||||
};
|
||||
|
||||
// TODO(gyuyoung): This Mojo enum will replace all uses of
|
||||
// web_pref::EditingBehaviorType in a follow-up CL.
|
||||
// There are multiple editing details that are different on Windows than
|
||||
// Macintosh. We use a single switch for all of them. Some examples:
|
||||
//
|
||||
// 1) Clicking below the last line of an editable area puts the caret at the
|
||||
// end of the last line on Mac, but in the middle of the last line on
|
||||
// Windows.
|
||||
// 2) Pushing the down arrow key on the last line puts the caret at the end
|
||||
// of the last line on Mac, but does nothing on Windows. A similar case
|
||||
// exists on the top line.
|
||||
//
|
||||
// This setting is intended to control these sorts of behaviors. There are some
|
||||
// other behaviors with individual function calls on EditorClient (smart copy
|
||||
// and paste and selecting the space after a double click) that could be
|
||||
// combined with this if if possible in the future.
|
||||
enum EditingBehavior {
|
||||
kEditingMacBehavior,
|
||||
kEditingWindowsBehavior,
|
||||
|
3
third_party/blink/public/web/web_settings.h
vendored
3
third_party/blink/public/web/web_settings.h
vendored
@ -38,6 +38,7 @@
|
||||
#include "third_party/blink/public/common/web_preferences/viewport_style.h"
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
#include "third_party/blink/public/mojom/v8_cache_options.mojom-forward.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-forward.h"
|
||||
#include "third_party/blink/public/platform/web_common.h"
|
||||
#include "third_party/blink/public/platform/web_effective_connection_type.h"
|
||||
#include "third_party/blink/public/platform/web_size.h"
|
||||
@ -134,7 +135,7 @@ class WebSettings {
|
||||
virtual void SetDontSendKeyEventsToJavascript(bool) = 0;
|
||||
virtual void SetDoubleTapToZoomEnabled(bool) = 0;
|
||||
virtual void SetDownloadableBinaryFontsEnabled(bool) = 0;
|
||||
virtual void SetEditingBehavior(web_pref::EditingBehaviorType) = 0;
|
||||
virtual void SetEditingBehavior(mojom::EditingBehavior) = 0;
|
||||
virtual void SetEnableScrollAnimator(bool) = 0;
|
||||
virtual void SetPrefersReducedMotion(bool) = 0;
|
||||
virtual void SetSmoothScrollForFindEnabled(bool) = 0;
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_EDITING_BEHAVIOR_H_
|
||||
#define THIRD_PARTY_BLINK_RENDERER_CORE_EDITING_EDITING_BEHAVIOR_H_
|
||||
|
||||
#include "third_party/blink/public/common/web_preferences/editing_behavior_types.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h"
|
||||
#include "third_party/blink/renderer/core/core_export.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
|
||||
|
||||
@ -32,7 +32,7 @@ class CORE_EXPORT EditingBehavior {
|
||||
STACK_ALLOCATED();
|
||||
|
||||
public:
|
||||
explicit EditingBehavior(web_pref::EditingBehaviorType type) : type_(type) {}
|
||||
explicit EditingBehavior(mojom::blink::EditingBehavior type) : type_(type) {}
|
||||
|
||||
// Individual functions for each case where we have more than one style of
|
||||
// editing behavior. Create a new function for any platform difference so we
|
||||
@ -42,46 +42,46 @@ class CORE_EXPORT EditingBehavior {
|
||||
// area, maintain the horizontal position on Windows and Android but extend it
|
||||
// to the boundary of the editable content on Mac and Linux.
|
||||
bool ShouldMoveCaretToHorizontalBoundaryWhenPastTopOrBottom() const {
|
||||
return type_ != web_pref::kEditingWindowsBehavior &&
|
||||
type_ != web_pref::kEditingAndroidBehavior;
|
||||
return type_ != mojom::blink::EditingBehavior::kEditingWindowsBehavior &&
|
||||
type_ != mojom::blink::EditingBehavior::kEditingAndroidBehavior;
|
||||
}
|
||||
|
||||
bool ShouldSelectReplacement() const {
|
||||
return type_ == web_pref::kEditingAndroidBehavior;
|
||||
return type_ == mojom::blink::EditingBehavior::kEditingAndroidBehavior;
|
||||
}
|
||||
|
||||
// On Windows, selections should always be considered as directional,
|
||||
// regardless if it is mouse-based or keyboard-based.
|
||||
bool ShouldConsiderSelectionAsDirectional() const {
|
||||
return type_ != web_pref::kEditingMacBehavior;
|
||||
return type_ != mojom::blink::EditingBehavior::kEditingMacBehavior;
|
||||
}
|
||||
|
||||
// On Mac, when revealing a selection (for example as a result of a Find
|
||||
// operation on the Browser), content should be scrolled such that the
|
||||
// selection gets certer aligned.
|
||||
bool ShouldCenterAlignWhenSelectionIsRevealed() const {
|
||||
return type_ == web_pref::kEditingMacBehavior;
|
||||
return type_ == mojom::blink::EditingBehavior::kEditingMacBehavior;
|
||||
}
|
||||
|
||||
// On Mac, style is considered present when present at the beginning of
|
||||
// selection. On other platforms, style has to be present throughout the
|
||||
// selection.
|
||||
bool ShouldToggleStyleBasedOnStartOfSelection() const {
|
||||
return type_ == web_pref::kEditingMacBehavior;
|
||||
return type_ == mojom::blink::EditingBehavior::kEditingMacBehavior;
|
||||
}
|
||||
|
||||
// Standard Mac behavior when extending to a boundary is grow the selection
|
||||
// rather than leaving the base in place and moving the extent. Matches
|
||||
// NSTextView.
|
||||
bool ShouldAlwaysGrowSelectionWhenExtendingToBoundary() const {
|
||||
return type_ == web_pref::kEditingMacBehavior;
|
||||
return type_ == mojom::blink::EditingBehavior::kEditingMacBehavior;
|
||||
}
|
||||
|
||||
// On Mac, when processing a contextual click, the object being clicked upon
|
||||
// should be selected.
|
||||
bool ShouldSelectOnContextualMenuClick() const {
|
||||
return type_ == web_pref::kEditingMacBehavior ||
|
||||
type_ == web_pref::kEditingChromeOSBehavior;
|
||||
return type_ == mojom::blink::EditingBehavior::kEditingMacBehavior ||
|
||||
type_ == mojom::blink::EditingBehavior::kEditingChromeOSBehavior;
|
||||
}
|
||||
|
||||
// On Mac, selecting backwards by word/line from the middle of a word/line,
|
||||
@ -89,7 +89,7 @@ class CORE_EXPORT EditingBehavior {
|
||||
// selection, instead of directly selecting to the other end of the line/word
|
||||
// (Unix/Windows behavior).
|
||||
bool ShouldExtendSelectionByWordOrLineAcrossCaret() const {
|
||||
return type_ != web_pref::kEditingMacBehavior;
|
||||
return type_ != mojom::blink::EditingBehavior::kEditingMacBehavior;
|
||||
}
|
||||
|
||||
// Based on native behavior, when using ctrl(alt)+arrow to move caret by word,
|
||||
@ -99,14 +99,14 @@ class CORE_EXPORT EditingBehavior {
|
||||
// But ctrl+right arrow moves caret to "abc |def |hij |opq" on Windows and
|
||||
// "abc| def| hij| opq|" on Mac and Linux.
|
||||
bool ShouldSkipSpaceWhenMovingRight() const {
|
||||
return type_ == web_pref::kEditingWindowsBehavior;
|
||||
return type_ == mojom::blink::EditingBehavior::kEditingWindowsBehavior;
|
||||
}
|
||||
|
||||
// On Mac, undo of delete/forward-delete of text should select the deleted
|
||||
// text. On other platforms deleted text should not be selected and the cursor
|
||||
// should be placed where the deletion started.
|
||||
bool ShouldUndoOfDeleteSelectText() const {
|
||||
return type_ == web_pref::kEditingMacBehavior;
|
||||
return type_ == mojom::blink::EditingBehavior::kEditingMacBehavior;
|
||||
}
|
||||
|
||||
// On Mac, backspacing at the start of a blocks merges with the
|
||||
@ -114,14 +114,14 @@ class CORE_EXPORT EditingBehavior {
|
||||
// platforms backspace event does nothing if the block above is a
|
||||
// table, but allows mergin otherwise.
|
||||
bool ShouldMergeContentWithTablesOnBackspace() const {
|
||||
return type_ == web_pref::kEditingMacBehavior;
|
||||
return type_ == mojom::blink::EditingBehavior::kEditingMacBehavior;
|
||||
}
|
||||
|
||||
// Support for global selections, used on platforms like the X Window
|
||||
// System that treat selection as a type of clipboard.
|
||||
bool SupportsGlobalSelection() const {
|
||||
return type_ != web_pref::kEditingWindowsBehavior &&
|
||||
type_ != web_pref::kEditingMacBehavior;
|
||||
return type_ != mojom::blink::EditingBehavior::kEditingWindowsBehavior &&
|
||||
type_ != mojom::blink::EditingBehavior::kEditingMacBehavior;
|
||||
}
|
||||
|
||||
// Convert a KeyboardEvent to a command name like "Copy", "Undo" and so on.
|
||||
@ -131,7 +131,7 @@ class CORE_EXPORT EditingBehavior {
|
||||
bool ShouldInsertCharacter(const KeyboardEvent&) const;
|
||||
|
||||
private:
|
||||
web_pref::EditingBehaviorType type_;
|
||||
mojom::blink::EditingBehavior type_;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
@ -132,7 +132,7 @@ SelectionInDOMTree Editor::SelectionForCommand(Event* event) {
|
||||
// not available.
|
||||
EditingBehavior Editor::Behavior() const {
|
||||
if (!GetFrame().GetSettings())
|
||||
return EditingBehavior(web_pref::kEditingMacBehavior);
|
||||
return EditingBehavior(mojom::blink::EditingBehavior::kEditingMacBehavior);
|
||||
|
||||
return EditingBehavior(GetFrame().GetSettings()->GetEditingBehaviorType());
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "mojo/public/mojom/base/text_direction.mojom-blink-forward.h"
|
||||
#include "third_party/blink/public/common/web_preferences/editing_behavior_types.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h"
|
||||
#include "third_party/blink/renderer/core/core_export.h"
|
||||
#include "third_party/blink/renderer/core/editing/editing_style.h"
|
||||
#include "third_party/blink/renderer/core/editing/finder/find_options.h"
|
||||
|
@ -271,8 +271,8 @@ VisibleSelection SelectionModifier::PrepareToModifySelection(
|
||||
VisiblePosition SelectionModifier::PositionForPlatform(
|
||||
bool is_get_start) const {
|
||||
Settings* settings = GetFrame().GetSettings();
|
||||
if (settings &&
|
||||
settings->GetEditingBehaviorType() == web_pref::kEditingMacBehavior)
|
||||
if (settings && settings->GetEditingBehaviorType() ==
|
||||
mojom::blink::EditingBehavior::kEditingMacBehavior)
|
||||
return is_get_start ? selection_.VisibleStart() : selection_.VisibleEnd();
|
||||
// Linux and Windows always extend selections from the extent endpoint.
|
||||
// FIXME: VisibleSelection should be fixed to ensure as an invariant that
|
||||
|
@ -59,7 +59,6 @@
|
||||
#include "third_party/blink/public/common/loader/referrer_utils.h"
|
||||
#include "third_party/blink/public/common/messaging/transferable_message.h"
|
||||
#include "third_party/blink/public/common/page/launching_process_state.h"
|
||||
#include "third_party/blink/public/common/web_preferences/editing_behavior_types.h"
|
||||
#include "third_party/blink/public/common/widget/device_emulation_params.h"
|
||||
#include "third_party/blink/public/mojom/blob/blob.mojom-blink.h"
|
||||
#include "third_party/blink/public/mojom/blob/data_element.mojom-blink.h"
|
||||
@ -68,6 +67,7 @@
|
||||
#include "third_party/blink/public/mojom/frame/frame_owner_element_type.mojom-blink.h"
|
||||
#include "third_party/blink/public/mojom/page_state/page_state.mojom-blink.h"
|
||||
#include "third_party/blink/public/mojom/scroll/scrollbar_mode.mojom-blink.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h"
|
||||
#include "third_party/blink/public/platform/web_cache.h"
|
||||
#include "third_party/blink/public/platform/web_security_origin.h"
|
||||
#include "third_party/blink/public/platform/web_url.h"
|
||||
@ -6439,7 +6439,7 @@ TEST_F(WebFrameTest, ReplaceMisspelledRange) {
|
||||
Element* element = document->getElementById("data");
|
||||
|
||||
web_view_helper.GetWebView()->GetSettings()->SetEditingBehavior(
|
||||
web_pref::EditingBehaviorType::kEditingWindowsBehavior);
|
||||
mojom::EditingBehavior::kEditingWindowsBehavior);
|
||||
|
||||
element->focus();
|
||||
NonThrowableExceptionState exception_state;
|
||||
@ -6485,7 +6485,7 @@ TEST_F(WebFrameTest, RemoveSpellingMarkers) {
|
||||
Element* element = document->getElementById("data");
|
||||
|
||||
web_view_helper.GetWebView()->GetSettings()->SetEditingBehavior(
|
||||
web_pref::EditingBehaviorType::kEditingWindowsBehavior);
|
||||
mojom::EditingBehavior::kEditingWindowsBehavior);
|
||||
|
||||
element->focus();
|
||||
NonThrowableExceptionState exception_state;
|
||||
@ -6536,7 +6536,7 @@ TEST_F(WebFrameTest, RemoveSpellingMarkersUnderWords) {
|
||||
Element* element = document->getElementById("data");
|
||||
|
||||
web_view_helper.GetWebView()->GetSettings()->SetEditingBehavior(
|
||||
web_pref::EditingBehaviorType::kEditingWindowsBehavior);
|
||||
mojom::EditingBehavior::kEditingWindowsBehavior);
|
||||
|
||||
element->focus();
|
||||
NonThrowableExceptionState exception_state;
|
||||
@ -6610,7 +6610,7 @@ TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition) {
|
||||
Element* element = document->getElementById("data");
|
||||
|
||||
web_view_helper.GetWebView()->GetSettings()->SetEditingBehavior(
|
||||
web_pref::EditingBehaviorType::kEditingWindowsBehavior);
|
||||
mojom::EditingBehavior::kEditingWindowsBehavior);
|
||||
|
||||
element->focus();
|
||||
NonThrowableExceptionState exception_state;
|
||||
@ -6644,7 +6644,7 @@ TEST_F(WebFrameTest, SpellcheckResultErasesMarkers) {
|
||||
Element* element = document->getElementById("data");
|
||||
|
||||
web_view_helper.GetWebView()->GetSettings()->SetEditingBehavior(
|
||||
web_pref::EditingBehaviorType::kEditingWindowsBehavior);
|
||||
mojom::EditingBehavior::kEditingWindowsBehavior);
|
||||
|
||||
element->focus();
|
||||
NonThrowableExceptionState exception_state;
|
||||
@ -6680,7 +6680,7 @@ TEST_F(WebFrameTest, SpellcheckResultsSavedInDocument) {
|
||||
Element* element = document->getElementById("data");
|
||||
|
||||
web_view_helper.GetWebView()->GetSettings()->SetEditingBehavior(
|
||||
web_pref::EditingBehaviorType::kEditingWindowsBehavior);
|
||||
mojom::EditingBehavior::kEditingWindowsBehavior);
|
||||
|
||||
element->focus();
|
||||
NonThrowableExceptionState exception_state;
|
||||
|
@ -465,7 +465,7 @@ void WebSettingsImpl::SetShowContextMenuOnMouseUp(bool enabled) {
|
||||
}
|
||||
|
||||
void WebSettingsImpl::SetEditingBehavior(
|
||||
web_pref::EditingBehaviorType behavior) {
|
||||
mojom::blink::EditingBehavior behavior) {
|
||||
settings_->SetEditingBehaviorType(behavior);
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@
|
||||
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_EXPORTED_WEB_SETTINGS_IMPL_H_
|
||||
#define THIRD_PARTY_BLINK_RENDERER_CORE_EXPORTED_WEB_SETTINGS_IMPL_H_
|
||||
|
||||
#include "third_party/blink/public/common/web_preferences/editing_behavior_types.h"
|
||||
#include "third_party/blink/public/mojom/v8_cache_options.mojom-blink.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h"
|
||||
#include "third_party/blink/public/web/web_settings.h"
|
||||
#include "third_party/blink/renderer/core/core_export.h"
|
||||
#include "third_party/blink/renderer/platform/heap/persistent.h"
|
||||
@ -83,7 +83,7 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings {
|
||||
void SetDontSendKeyEventsToJavascript(bool) override;
|
||||
void SetDoubleTapToZoomEnabled(bool) override;
|
||||
void SetDownloadableBinaryFontsEnabled(bool) override;
|
||||
void SetEditingBehavior(web_pref::EditingBehaviorType) override;
|
||||
void SetEditingBehavior(mojom::blink::EditingBehavior) override;
|
||||
void SetEnableScrollAnimator(bool) override;
|
||||
void SetPrefersReducedMotion(bool) override;
|
||||
void SetWebGL1Enabled(bool) override;
|
||||
|
@ -42,20 +42,20 @@ namespace blink {
|
||||
// Darwin/MacOS/Android (and then abusing the terminology);
|
||||
// 4) EditingAndroidBehavior comprises Android builds.
|
||||
// 99) MacEditingBehavior is used a fallback.
|
||||
static web_pref::EditingBehaviorType EditingBehaviorTypeForPlatform() {
|
||||
static mojom::blink::EditingBehavior EditingBehaviorTypeForPlatform() {
|
||||
return
|
||||
#if defined(OS_MAC)
|
||||
web_pref::kEditingMacBehavior
|
||||
mojom::blink::EditingBehavior::kEditingMacBehavior
|
||||
#elif defined(OS_WIN)
|
||||
web_pref::kEditingWindowsBehavior
|
||||
mojom::blink::EditingBehavior::kEditingWindowsBehavior
|
||||
#elif defined(OS_ANDROID)
|
||||
web_pref::kEditingAndroidBehavior
|
||||
mojom::blink::EditingBehavior::kEditingAndroidBehavior
|
||||
#elif defined(OS_CHROMEOS)
|
||||
base::FeatureList::IsEnabled(features::kCrOSAutoSelect)
|
||||
? web_pref::kEditingChromeOSBehavior
|
||||
: web_pref::kEditingUnixBehavior
|
||||
? mojom::blink::EditingBehavior::kEditingChromeOSBehavior
|
||||
: mojom::blink::EditingBehavior::kEditingUnixBehavior
|
||||
#else // Rest of the UNIX-like systems
|
||||
web_pref::kEditingUnixBehavior
|
||||
mojom::blink::EditingBehavior::kEditingUnixBehavior
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
@ -33,11 +33,11 @@
|
||||
#include "base/macros.h"
|
||||
#include "third_party/blink/public/common/css/navigation_controls.h"
|
||||
#include "third_party/blink/public/common/css/preferred_color_scheme.h"
|
||||
#include "third_party/blink/public/common/web_preferences/editing_behavior_types.h"
|
||||
#include "third_party/blink/public/common/web_preferences/image_animation_policy.h"
|
||||
#include "third_party/blink/public/common/web_preferences/viewport_style.h"
|
||||
#include "third_party/blink/public/mojom/manifest/display_mode.mojom-shared.h"
|
||||
#include "third_party/blink/public/mojom/v8_cache_options.mojom-blink.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h"
|
||||
#include "third_party/blink/public/platform/web_effective_connection_type.h"
|
||||
#include "third_party/blink/renderer/core/core_export.h"
|
||||
#include "third_party/blink/renderer/core/dom/events/add_event_listener_options_defaults.h"
|
||||
|
@ -98,7 +98,7 @@
|
||||
{
|
||||
name: "editingBehaviorType",
|
||||
initial: "EditingBehaviorTypeForPlatform()",
|
||||
type: "web_pref::EditingBehaviorType",
|
||||
type: "mojom::EditingBehavior",
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "third_party/blink/renderer/core/layout/layout_view.h"
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "third_party/blink/public/common/web_preferences/editing_behavior_types.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h"
|
||||
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
|
||||
#include "third_party/blink/renderer/core/editing/text_affinity.h"
|
||||
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
|
||||
@ -122,7 +122,7 @@ TEST_F(LayoutViewTest, NamedPages) {
|
||||
|
||||
struct HitTestConfig {
|
||||
bool layout_ng;
|
||||
web_pref::EditingBehaviorType editing_behavior;
|
||||
mojom::EditingBehavior editing_behavior;
|
||||
};
|
||||
|
||||
class LayoutViewHitTestTest : public testing::WithParamInterface<HitTestConfig>,
|
||||
@ -136,8 +136,10 @@ class LayoutViewHitTestTest : public testing::WithParamInterface<HitTestConfig>,
|
||||
protected:
|
||||
bool LayoutNG() { return RuntimeEnabledFeatures::LayoutNGEnabled(); }
|
||||
bool IsAndroidOrWindowsEditingBehavior() {
|
||||
return GetParam().editing_behavior == web_pref::kEditingAndroidBehavior ||
|
||||
GetParam().editing_behavior == web_pref::kEditingWindowsBehavior;
|
||||
return GetParam().editing_behavior ==
|
||||
mojom::EditingBehavior::kEditingAndroidBehavior ||
|
||||
GetParam().editing_behavior ==
|
||||
mojom::EditingBehavior::kEditingWindowsBehavior;
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
@ -152,17 +154,17 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
LayoutViewHitTestTest,
|
||||
::testing::Values(
|
||||
// Legacy
|
||||
HitTestConfig{false, web_pref::kEditingMacBehavior},
|
||||
HitTestConfig{false, web_pref::kEditingWindowsBehavior},
|
||||
HitTestConfig{false, web_pref::kEditingUnixBehavior},
|
||||
HitTestConfig{false, web_pref::kEditingAndroidBehavior},
|
||||
HitTestConfig{false, web_pref::kEditingChromeOSBehavior},
|
||||
HitTestConfig{false, mojom::EditingBehavior::kEditingMacBehavior},
|
||||
HitTestConfig{false, mojom::EditingBehavior::kEditingWindowsBehavior},
|
||||
HitTestConfig{false, mojom::EditingBehavior::kEditingUnixBehavior},
|
||||
HitTestConfig{false, mojom::EditingBehavior::kEditingAndroidBehavior},
|
||||
HitTestConfig{false, mojom::EditingBehavior::kEditingChromeOSBehavior},
|
||||
// LayoutNG
|
||||
HitTestConfig{true, web_pref::kEditingMacBehavior},
|
||||
HitTestConfig{true, web_pref::kEditingWindowsBehavior},
|
||||
HitTestConfig{true, web_pref::kEditingUnixBehavior},
|
||||
HitTestConfig{true, web_pref::kEditingAndroidBehavior},
|
||||
HitTestConfig{true, web_pref::kEditingChromeOSBehavior}));
|
||||
HitTestConfig{true, mojom::EditingBehavior::kEditingMacBehavior},
|
||||
HitTestConfig{true, mojom::EditingBehavior::kEditingWindowsBehavior},
|
||||
HitTestConfig{true, mojom::EditingBehavior::kEditingUnixBehavior},
|
||||
HitTestConfig{true, mojom::EditingBehavior::kEditingAndroidBehavior},
|
||||
HitTestConfig{true, mojom::EditingBehavior::kEditingChromeOSBehavior}));
|
||||
|
||||
TEST_P(LayoutViewHitTestTest, HitTestHorizontal) {
|
||||
LoadAhem();
|
||||
|
@ -314,20 +314,26 @@ void InternalSettings::setAccessibilityFontScaleFactor(
|
||||
void InternalSettings::setEditingBehavior(const String& editing_behavior,
|
||||
ExceptionState& exception_state) {
|
||||
InternalSettingsGuardForSettings();
|
||||
if (EqualIgnoringASCIICase(editing_behavior, "win"))
|
||||
GetSettings()->SetEditingBehaviorType(web_pref::kEditingWindowsBehavior);
|
||||
else if (EqualIgnoringASCIICase(editing_behavior, "mac"))
|
||||
GetSettings()->SetEditingBehaviorType(web_pref::kEditingMacBehavior);
|
||||
else if (EqualIgnoringASCIICase(editing_behavior, "unix"))
|
||||
GetSettings()->SetEditingBehaviorType(web_pref::kEditingUnixBehavior);
|
||||
else if (EqualIgnoringASCIICase(editing_behavior, "android"))
|
||||
GetSettings()->SetEditingBehaviorType(web_pref::kEditingAndroidBehavior);
|
||||
else if (EqualIgnoringASCIICase(editing_behavior, "chromeos"))
|
||||
GetSettings()->SetEditingBehaviorType(web_pref::kEditingChromeOSBehavior);
|
||||
else
|
||||
if (EqualIgnoringASCIICase(editing_behavior, "win")) {
|
||||
GetSettings()->SetEditingBehaviorType(
|
||||
mojom::EditingBehavior::kEditingWindowsBehavior);
|
||||
} else if (EqualIgnoringASCIICase(editing_behavior, "mac")) {
|
||||
GetSettings()->SetEditingBehaviorType(
|
||||
mojom::EditingBehavior::kEditingMacBehavior);
|
||||
} else if (EqualIgnoringASCIICase(editing_behavior, "unix")) {
|
||||
GetSettings()->SetEditingBehaviorType(
|
||||
mojom::EditingBehavior::kEditingUnixBehavior);
|
||||
} else if (EqualIgnoringASCIICase(editing_behavior, "android")) {
|
||||
GetSettings()->SetEditingBehaviorType(
|
||||
mojom::EditingBehavior::kEditingAndroidBehavior);
|
||||
} else if (EqualIgnoringASCIICase(editing_behavior, "chromeos")) {
|
||||
GetSettings()->SetEditingBehaviorType(
|
||||
mojom::EditingBehavior::kEditingChromeOSBehavior);
|
||||
} else {
|
||||
exception_state.ThrowDOMException(DOMExceptionCode::kSyntaxError,
|
||||
"The editing behavior type provided ('" +
|
||||
editing_behavior + "') is invalid.");
|
||||
}
|
||||
}
|
||||
|
||||
void InternalSettings::setLangAttributeAwareFormControlUIEnabled(bool enabled) {
|
||||
|
@ -27,9 +27,9 @@
|
||||
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_INTERNAL_SETTINGS_H_
|
||||
#define THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_INTERNAL_SETTINGS_H_
|
||||
|
||||
#include "third_party/blink/public/common/web_preferences/editing_behavior_types.h"
|
||||
#include "third_party/blink/public/common/web_preferences/image_animation_policy.h"
|
||||
#include "third_party/blink/public/mojom/manifest/display_mode.mojom-shared.h"
|
||||
#include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom-blink.h"
|
||||
#include "third_party/blink/renderer/core/page/page.h"
|
||||
#include "third_party/blink/renderer/core/testing/internal_settings_generated.h"
|
||||
#include "third_party/blink/renderer/platform/geometry/int_size.h"
|
||||
@ -57,7 +57,7 @@ class InternalSettings final : public InternalSettingsGenerated,
|
||||
|
||||
bool original_csp_;
|
||||
bool original_overlay_scrollbars_enabled_;
|
||||
web_pref::EditingBehaviorType original_editing_behavior_;
|
||||
mojom::EditingBehavior original_editing_behavior_;
|
||||
bool original_text_autosizing_enabled_;
|
||||
IntSize original_text_autosizing_window_size_override_;
|
||||
float original_accessibility_font_scale_factor_;
|
||||
|
Reference in New Issue
Block a user