LeOSium_old/patches/0003-LeOS/1-19/8 - Disable-text-fragments-...

168 lines
7.8 KiB
Diff
Raw Permalink Normal View History

2023-11-18 11:23:04 +01:00
From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Sat, 22 Aug 2020 12:46:20 +0200
Subject: Disable text fragments by default
Revert "[Text Fragment] Unflag fragment directive removal."
Original License: BSD-3-Clause - https://spdx.org/licenses/BSD-3-Clause.html
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
Change-Id: I145be3cf3de31f7c92fc97c74fede22addf8621a
---
chrome/browser/about_flags.cc | 5 +++++
chrome/browser/flag-metadata.json | 5 +++++
chrome/browser/flag_descriptions.cc | 4 ++++
chrome/browser/flag_descriptions.h | 3 +++
chrome/browser/ui/prefs/prefs_tab_helper.cc | 2 +-
content/child/runtime_features.cc | 2 ++
third_party/blink/common/features.cc | 5 +++++
third_party/blink/public/common/features.h | 1 +
third_party/blink/renderer/core/dom/document.cc | 5 +++++
.../blink/renderer/platform/runtime_enabled_features.json5 | 5 ++---
10 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -6328,6 +6328,11 @@ const FeatureEntry kFeatureEntries[] = {
"")},
#endif
+ {"enable-text-fragment-anchor",
+ flag_descriptions::kEnableTextFragmentAnchorName,
+ flag_descriptions::kEnableTextFragmentAnchorDescription, kOsAll,
+ FEATURE_VALUE_TYPE(blink::features::kTextFragmentAnchor)},
+
#if BUILDFLAG(IS_CHROMEOS_ASH)
{"enable-web-authentication-chromeos-authenticator",
flag_descriptions::kEnableWebAuthenticationChromeOSAuthenticatorName,
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -2827,6 +2827,11 @@
"owners": [ "robsc", "napper", "alanlxl" ],
"expiry_milestone": 130
},
+ {
+ "name": "enable-text-fragment-anchor",
+ "owners": [ "bokan", "input-dev" ],
+ "expiry_milestone": -1
+ },
{
"name": "enable-neural-stylus-palm-rejection",
"owners": [ "robsc", "napper", "adlr" ],
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -1327,6 +1327,10 @@ extern const char kDropInputEventsBeforeFirstPaintDescription[] =
"intentionally interact with elements on that page. By dropping the events "
"we prevent accidental interaction with a page the user has not seen yet.";
+const char kEnableTextFragmentAnchorName[] = "Enable Text Fragment Anchor.";
+const char kEnableTextFragmentAnchorDescription[] =
+ "Enables scrolling to text specified in URL's fragment.";
+
const char kEnableCssSelectorFragmentAnchorName[] =
"Enables CSS selector fragment anchors";
const char kEnableCssSelectorFragmentAnchorDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -739,6 +739,9 @@ extern const char kReduceHorizontalFlingVelocityDescription[];
extern const char kRetailCouponsName[];
extern const char kRetailCouponsDescription[];
+extern const char kEnableTextFragmentAnchorName[];
+extern const char kEnableTextFragmentAnchorDescription[];
+
extern const char kDropInputEventsBeforeFirstPaintName[];
extern const char kDropInputEventsBeforeFirstPaintDescription[];
diff --git a/chrome/browser/ui/prefs/prefs_tab_helper.cc b/chrome/browser/ui/prefs/prefs_tab_helper.cc
--- a/chrome/browser/ui/prefs/prefs_tab_helper.cc
+++ b/chrome/browser/ui/prefs/prefs_tab_helper.cc
@@ -361,7 +361,7 @@ void PrefsTabHelper::RegisterProfilePrefs(
prefs::kEnableReferrers,
!base::FeatureList::IsEnabled(features::kNoReferrers));
registry->RegisterBooleanPref(prefs::kEnableEncryptedMedia, true);
- registry->RegisterBooleanPref(prefs::kScrollToTextFragmentEnabled, true);
+ registry->RegisterBooleanPref(prefs::kScrollToTextFragmentEnabled, false);
#if BUILDFLAG(IS_ANDROID)
registry->RegisterDoublePref(browser_ui::prefs::kWebKitFontScaleFactor, 1.0);
registry->RegisterBooleanPref(browser_ui::prefs::kWebKitForceEnableZoom,
diff --git a/content/child/runtime_features.cc b/content/child/runtime_features.cc
--- a/content/child/runtime_features.cc
+++ b/content/child/runtime_features.cc
@@ -290,6 +290,8 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
raw_ref(autofill::features::kAutofillSharedAutofill)},
{wf::EnableTouchDragAndContextMenu,
raw_ref(features::kTouchDragAndContextMenu)},
+ {wf::EnableTextFragmentIdentifiers,
+ raw_ref(blink::features::kTextFragmentAnchor)},
{wf::EnableUserActivationSameOriginVisibility,
raw_ref(features::kUserActivationSameOriginVisibility)},
{wf::EnableVideoPlaybackQuality, raw_ref(features::kVideoPlaybackQuality)},
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
--- a/third_party/blink/common/features.cc
+++ b/third_party/blink/common/features.cc
@@ -520,6 +520,11 @@ BASE_FEATURE(kDroppedTouchSequenceIncludesTouchEnd,
"DroppedTouchSequenceIncludesTouchEnd",
base::FEATURE_DISABLED_BY_DEFAULT);
+// Enable text snippets in URL fragments. https://crbug.com/919204.
+BASE_FEATURE(kTextFragmentAnchor,
+ "TextFragmentAnchor",
+ base::FEATURE_DISABLED_BY_DEFAULT);
+
// File handling icons. https://crbug.com/1218213
BASE_FEATURE(kFileHandlingIcons,
"FileHandlingIcons",
diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h
--- a/third_party/blink/public/common/features.h
+++ b/third_party/blink/public/common/features.h
@@ -247,6 +247,7 @@ BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kDecodeJpeg420ImagesToYUV);
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kDecodeLossyWebPImagesToYUV);
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebFontsCacheAwareTimeoutAdaption);
+BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kTextFragmentAnchor);
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kAudioWorkletThreadRealtimePriority);
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAudioSinkSelection);
diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc
--- a/third_party/blink/renderer/core/dom/document.cc
+++ b/third_party/blink/renderer/core/dom/document.cc
@@ -4300,9 +4300,14 @@ void Document::SetURL(const KURL& url) {
TRACE_EVENT1("navigation", "Document::SetURL", "url",
new_url.GetString().Utf8());
+ // If text fragment identifiers are enabled, we strip the fragment directive
+ // from the URL fragment.
+ // E.g. "#id:~:text=a" --> "#id"
+ if (RuntimeEnabledFeatures::TextFragmentIdentifiersEnabled(domWindow())) {
// Strip the fragment directive from the URL fragment. E.g. "#id:~:text=a"
// --> "#id". See https://github.com/WICG/scroll-to-text-fragment.
new_url = fragment_directive_->ConsumeFragmentDirective(new_url);
+ }
url_ = new_url;
UpdateBaseURL();
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5
--- a/third_party/blink/renderer/platform/runtime_enabled_features.json5
+++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
@@ -3320,10 +3320,9 @@
},
{
name: "TextFragmentIdentifiers",
- origin_trial_feature_name: "TextFragmentIdentifiers",
public: true,
- status: "stable",
- base_feature: "TextFragmentAnchor",
+ status: "test",
+ origin_trial_feature_name: "TextFragmentIdentifiers"
},
{
name: "TextFragmentTapOpensContextMenu",
--
2.40.1