Add setting to invert tap and long tap
This commit is contained in:
@@ -0,0 +1,481 @@
|
||||
From: uazo <uazo@users.noreply.github.com>
|
||||
Date: Wed, 12 Apr 2023 08:22:00 +0000
|
||||
Subject: Add setting to invert tap and long tap
|
||||
|
||||
Reverses single tap to long tap in android for accessibility reasons.
|
||||
The feature can be activated from the accessibility settings.
|
||||
---
|
||||
chrome/android/java/res/values/ids.xml | 1 +
|
||||
.../ChromeAccessibilitySettingsDelegate.java | 18 +++++++++++
|
||||
.../contextmenu/ChromeContextMenuItem.java | 5 ++-
|
||||
.../ChromeContextMenuPopulator.java | 5 +++
|
||||
.../tab/TabContextMenuItemDelegate.java | 8 +++++
|
||||
chrome/browser/about_flags.cc | 5 +++
|
||||
.../contextmenu/ContextMenuItemDelegate.java | 2 ++
|
||||
chrome/browser/flag_descriptions.cc | 4 +++
|
||||
chrome/browser/flag_descriptions.h | 3 ++
|
||||
.../browser/flags/ChromeFeatureList.java | 4 +++
|
||||
.../strings/android_chrome_strings.grd | 9 ++++++
|
||||
.../res/xml/accessibility_preferences.xml | 5 +++
|
||||
.../accessibility/AccessibilitySettings.java | 11 +++++++
|
||||
.../AccessibilitySettingsDelegate.java | 2 ++
|
||||
third_party/blink/common/features.cc | 4 +++
|
||||
third_party/blink/public/common/features.h | 2 ++
|
||||
.../renderer/core/html/html_anchor_element.cc | 12 ++++++-
|
||||
.../renderer/core/html/html_anchor_element.h | 2 +-
|
||||
.../core/page/context_menu_controller.cc | 32 +++++++++++++------
|
||||
.../core/page/context_menu_controller.h | 5 +--
|
||||
20 files changed, 125 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/chrome/android/java/res/values/ids.xml b/chrome/android/java/res/values/ids.xml
|
||||
--- a/chrome/android/java/res/values/ids.xml
|
||||
+++ b/chrome/android/java/res/values/ids.xml
|
||||
@@ -91,6 +91,7 @@ found in the LICENSE file.
|
||||
|
||||
<!-- Menu item IDs for FullscreenActivities -->
|
||||
<item type="id" name="contextmenu_open_in_chrome" />
|
||||
+ <item type="id" name="contextmenu_open_in_tab" />
|
||||
|
||||
<!-- Tags -->
|
||||
<item type="id" name="highlight_color" />
|
||||
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/accessibility/settings/ChromeAccessibilitySettingsDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/accessibility/settings/ChromeAccessibilitySettingsDelegate.java
|
||||
--- a/chrome/android/java/src/org/chromium/chrome/browser/accessibility/settings/ChromeAccessibilitySettingsDelegate.java
|
||||
+++ b/chrome/android/java/src/org/chromium/chrome/browser/accessibility/settings/ChromeAccessibilitySettingsDelegate.java
|
||||
@@ -139,6 +139,24 @@ public class ChromeAccessibilitySettingsDelegate implements AccessibilitySetting
|
||||
mSnackbarManager.showSnackbar(mSnackbar);
|
||||
}
|
||||
|
||||
+ private static class ShowAlwaysContextMenuOnLinksDelegate implements BooleanPreferenceDelegate {
|
||||
+ @Override
|
||||
+ public boolean isEnabled() {
|
||||
+ return ChromeFeatureList.sShowAlwaysContextMenuOnLinks.isEnabled();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setEnabled(boolean value) {
|
||||
+ CachedFeatureFlags.setFlagEnabled(ChromeFeatureList.SHOW_ALWAYS_CONTEXT_MENU_ON_LINKS,
|
||||
+ "show-always-context-menu-on-links", value);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BooleanPreferenceDelegate getShowAlwaysContextMenuOnLinksDelegate() {
|
||||
+ return new ShowAlwaysContextMenuOnLinksDelegate();
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public void addExtraPreferences(PreferenceFragmentCompat fragment) {
|
||||
if (ImageDescriptionsController.getInstance().shouldShowImageDescriptionsMenuItem()) {
|
||||
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuItem.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuItem.java
|
||||
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuItem.java
|
||||
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuItem.java
|
||||
@@ -88,8 +88,9 @@ class ChromeContextMenuItem {
|
||||
int SHARE_HIGHLIGHT = 32;
|
||||
int REMOVE_HIGHLIGHT = 33;
|
||||
int LEARN_MORE = 34;
|
||||
+ int FOLLOW_LINK = 35;
|
||||
// ALWAYS UPDATE!
|
||||
- int NUM_ENTRIES = 35;
|
||||
+ int NUM_ENTRIES = 36;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,6 +132,7 @@ class ChromeContextMenuItem {
|
||||
R.id.contextmenu_share_highlight, // Item.SHARE_HIGHLIGHT
|
||||
R.id.contextmenu_remove_highlight, // Item.REMOVE_HIGHLIGHT
|
||||
R.id.contextmenu_learn_more, // Item.LEARN_MORE
|
||||
+ R.id.contextmenu_open_in_tab, // Item.OPEN_IN_NEW_CHROME_TAB
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -172,6 +174,7 @@ class ChromeContextMenuItem {
|
||||
R.string.contextmenu_share_highlight, // Item.SHARE_HIGHLIGHT
|
||||
R.string.contextmenu_remove_highlight, // Item.REMOVE_HIGHLIGHT
|
||||
R.string.contextmenu_learn_more, // Item.LEARN_MORE
|
||||
+ R.string.contextmenu_open_in_tab, // Item.OPEN_IN_NEW_CHROME_TAB:
|
||||
};
|
||||
|
||||
/**
|
||||
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
|
||||
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
|
||||
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ChromeContextMenuPopulator.java
|
||||
@@ -362,6 +362,9 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
||||
|
||||
if (mParams.isAnchor()) {
|
||||
ModelList linkGroup = new ModelList();
|
||||
+ if (ChromeFeatureList.sShowAlwaysContextMenuOnLinks.isEnabled()) {
|
||||
+ linkGroup.add(createListItem(Item.FOLLOW_LINK));
|
||||
+ }
|
||||
if (FirstRunStatus.getFirstRunFlowComplete() && !isEmptyUrl(mParams.getUrl())
|
||||
&& UrlUtilities.isAcceptedScheme(mParams.getUrl())) {
|
||||
if (mMode == ContextMenuMode.NORMAL) {
|
||||
@@ -728,6 +731,8 @@ public class ChromeContextMenuPopulator implements ContextMenuPopulator {
|
||||
ShareHelper.shareImage(getWindow(), getProfile(),
|
||||
ShareHelper.getLastShareComponentName(), uri, null);
|
||||
});
|
||||
+ } else if (itemId == R.id.contextmenu_open_in_tab) {
|
||||
+ mItemDelegate.onOpenUrl(mParams.getUrl(), mParams.getReferrer());
|
||||
} else if (itemId == R.id.contextmenu_open_in_chrome) {
|
||||
recordContextMenuSelection(ContextMenuUma.Action.OPEN_IN_CHROME);
|
||||
mItemDelegate.onOpenInChrome(mParams.getUrl(), mParams.getPageUrl());
|
||||
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java
|
||||
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java
|
||||
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabContextMenuItemDelegate.java
|
||||
@@ -245,6 +245,14 @@ public class TabContextMenuItemDelegate implements ContextMenuItemDelegate {
|
||||
mTab.loadUrl(loadUrlParams);
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public void onOpenUrl(GURL url, Referrer referrer) {
|
||||
+ LoadUrlParams loadUrlParams = new LoadUrlParams(url.getSpec());
|
||||
+ loadUrlParams.setTransitionType(PageTransition.LINK);
|
||||
+ loadUrlParams.setReferrer(referrer);
|
||||
+ mTab.loadUrl(loadUrlParams);
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public void onOpenImageInNewTab(GURL url, Referrer referrer) {
|
||||
LoadUrlParams loadUrlParams = new LoadUrlParams(url.getSpec());
|
||||
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
|
||||
@@ -7100,6 +7100,11 @@ const FeatureEntry kFeatureEntries[] = {
|
||||
flag_descriptions::kMoveTopToolbarToBottomDescription, kOsAndroid,
|
||||
FEATURE_VALUE_TYPE(features::kMoveTopToolbarToBottom)},
|
||||
|
||||
+ {"show-always-context-menu-on-links",
|
||||
+ flag_descriptions::kShowAlwaysContextMenuOnLinksName,
|
||||
+ flag_descriptions::kShowAlwaysContextMenuOnLinksDescription, kOsAndroid,
|
||||
+ FEATURE_VALUE_TYPE(blink::features::kShowAlwaysContextMenuOnLinks)},
|
||||
+
|
||||
{"scroll-unification", flag_descriptions::kScrollUnificationName,
|
||||
flag_descriptions::kScrollUnificationDescription, kOsAll,
|
||||
FEATURE_VALUE_TYPE(features::kScrollUnification)},
|
||||
diff --git a/chrome/browser/contextmenu/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuItemDelegate.java b/chrome/browser/contextmenu/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuItemDelegate.java
|
||||
--- a/chrome/browser/contextmenu/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuItemDelegate.java
|
||||
+++ b/chrome/browser/contextmenu/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuItemDelegate.java
|
||||
@@ -105,6 +105,8 @@ public interface ContextMenuItemDelegate {
|
||||
*/
|
||||
void onOpenImageUrl(GURL url, Referrer referrer);
|
||||
|
||||
+ void onOpenUrl(GURL url, Referrer referrer);
|
||||
+
|
||||
/**
|
||||
* Called when the {@code url} is of an image and should be opened in a new tab.
|
||||
* @param url The image URL to open.
|
||||
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
|
||||
@@ -1830,6 +1830,10 @@ const char kMoveTopToolbarToBottomName[] = "Move top toolbar to bottom";
|
||||
const char kMoveTopToolbarToBottomDescription[] =
|
||||
"Move the top toolbar to the bottom.";
|
||||
|
||||
+const char kShowAlwaysContextMenuOnLinksName[] = "Always show contextmenu on links";
|
||||
+const char kShowAlwaysContextMenuOnLinksDescription[] =
|
||||
+ "Use accessibility settings to set it.";
|
||||
+
|
||||
const char kIncognitoDownloadsWarningName[] =
|
||||
"Enable Incognito downloads warning";
|
||||
const char kIncognitoDownloadsWarningDescription[] =
|
||||
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
|
||||
@@ -1025,6 +1025,9 @@ extern const char kCompositorThreadedScrollbarScrollingDescription[];
|
||||
extern const char kMoveTopToolbarToBottomName[];
|
||||
extern const char kMoveTopToolbarToBottomDescription[];
|
||||
|
||||
+extern const char kShowAlwaysContextMenuOnLinksName[];
|
||||
+extern const char kShowAlwaysContextMenuOnLinksDescription[];
|
||||
+
|
||||
extern const char kIncognitoReauthenticationForAndroidName[];
|
||||
extern const char kIncognitoReauthenticationForAndroidDescription[];
|
||||
|
||||
diff --git a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java
|
||||
--- a/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java
|
||||
+++ b/chrome/browser/flags/android/java/src/org/chromium/chrome/browser/flags/ChromeFeatureList.java
|
||||
@@ -377,6 +377,8 @@ public abstract class ChromeFeatureList {
|
||||
public static final String MODAL_PERMISSION_DIALOG_VIEW = "ModalPermissionDialogView";
|
||||
public static final String MOVE_TOP_TOOLBAR_TO_BOTTOM =
|
||||
"MoveTopToolbarToBottom";
|
||||
+ public static final String SHOW_ALWAYS_CONTEXT_MENU_ON_LINKS =
|
||||
+ "ShowAlwaysContextMenuOnLinks";
|
||||
public static final String NOTIFICATION_PERMISSION_VARIANT = "NotificationPermissionVariant";
|
||||
public static final String NOTIFICATION_PERMISSION_BOTTOM_SHEET =
|
||||
"NotificationPermissionBottomSheet";
|
||||
@@ -637,6 +639,8 @@ public abstract class ChromeFeatureList {
|
||||
new CachedFlag(LENS_CAMERA_ASSISTED_SEARCH, true);
|
||||
public static final CachedFlag sMoveTopToolbarToBottom =
|
||||
new CachedFlag(MOVE_TOP_TOOLBAR_TO_BOTTOM, false);
|
||||
+ public static final CachedFlag sShowAlwaysContextMenuOnLinks =
|
||||
+ new CachedFlag(SHOW_ALWAYS_CONTEXT_MENU_ON_LINKS, false);
|
||||
public static final CachedFlag sOSKResizesVisualViewportByDefault =
|
||||
new CachedFlag(OSK_RESIZES_VISUAL_VIEWPORT, false);
|
||||
public static final CachedFlag sOmahaMinSdkVersionAndroid =
|
||||
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd
|
||||
--- a/chrome/browser/ui/android/strings/android_chrome_strings.grd
|
||||
+++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
|
||||
@@ -1656,6 +1656,12 @@ Your Google account may have other forms of browsing history like searches and a
|
||||
<message name="IDS_MOVE_TOOLBAR_BOTTOM_SUMMARY" desc="Summary of the preference that allows the user to move toolbar on bottom.">
|
||||
Move toolbar to bottom
|
||||
</message>
|
||||
+ <message name="IDS_ALWAYS_SHOW_CONTEXTMENU_ON_LINKS_TITLE" desc="Title of the preference that open the context menu in links.">
|
||||
+ Always open the context menu in the links
|
||||
+ </message>
|
||||
+ <message name="IDS_ALWAYS_SHOW_CONTEXTMENU_ON_LINKS_SUMMARY" desc="Summary of the preference that open the context menu in links.">
|
||||
+ Allows the context menu to be opened with a tap and follow the link with long press
|
||||
+ </message>
|
||||
|
||||
<!-- Safety check -->
|
||||
<message name="IDS_PREFS_SAFETY_CHECK" desc="Title of the Safety check element in settings, allowing the user to check multiple areas of browser safety. [CHAR_LIMIT=32]">
|
||||
@@ -2687,6 +2693,9 @@ To change this setting, <ph name="BEGIN_LINK"><resetlink></ph>reset sync<p
|
||||
<message name="IDS_CONTEXTMENU_OPEN_IN_NEW_CHROME_TAB" desc="Context sensitive menu item to open the selected link in a new Chrome tab from Chrome Custom Tab. [CHAR_LIMIT=30]">
|
||||
Open in new Chrome tab
|
||||
</message>
|
||||
+ <message name="IDS_CONTEXTMENU_OPEN_IN_TAB" desc="Context sensitive menu item to open the selected link in tab. [CHAR_LIMIT=30]">
|
||||
+ Open in current tab
|
||||
+ </message>
|
||||
<message name="IDS_CONTEXTMENU_OPEN_IN_CHROME_INCOGNITO_TAB" desc="Context sensitive menu item to open the selected link in a Chrome Incognito tab from Chrome Custom Tab. [CHAR_LIMIT=30]">
|
||||
Open in Incognito tab
|
||||
</message>
|
||||
diff --git a/components/browser_ui/accessibility/android/java/res/xml/accessibility_preferences.xml b/components/browser_ui/accessibility/android/java/res/xml/accessibility_preferences.xml
|
||||
--- a/components/browser_ui/accessibility/android/java/res/xml/accessibility_preferences.xml
|
||||
+++ b/components/browser_ui/accessibility/android/java/res/xml/accessibility_preferences.xml
|
||||
@@ -26,6 +26,11 @@ found in the LICENSE file.
|
||||
android:summary="@string/page_zoom_always_show_preference_summary"
|
||||
android:title="@string/page_zoom_always_show_preference_title" />
|
||||
|
||||
+ <org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
+ android:key="always_show_contextmenu_on_links"
|
||||
+ android:summary="@string/always_show_contextmenu_on_links_summary"
|
||||
+ android:title="@string/always_show_contextmenu_on_links_title" />
|
||||
+
|
||||
<org.chromium.components.browser_ui.settings.ChromeSwitchPreference
|
||||
android:key="force_enable_zoom"
|
||||
android:summary="@string/force_enable_zoom_summary"
|
||||
diff --git a/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettings.java b/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettings.java
|
||||
--- a/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettings.java
|
||||
+++ b/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettings.java
|
||||
@@ -37,6 +37,7 @@ public class AccessibilitySettings extends PreferenceFragmentCompat
|
||||
private BooleanPreferenceDelegate mForceTabletUIDelegate;
|
||||
static final String PREF_FORCE_TABLET_UI = "force_tablet_ui";
|
||||
static final String PREF_MOVE_TOOLBAR_TO_BOTTOM = "move_toolbar_bottom";
|
||||
+ static final String PREF_ALWAYS_SHOW_CONTEXTMENU_ON_LINKS = "always_show_contextmenu_on_links";
|
||||
private TextScalePreference mTextScalePref;
|
||||
private PageZoomPreference mPageZoomDefaultZoomPref;
|
||||
private ChromeSwitchPreference mPageZoomAlwaysShowPref;
|
||||
@@ -47,6 +48,7 @@ public class AccessibilitySettings extends PreferenceFragmentCompat
|
||||
private BooleanPreferenceDelegate mAccessibilityTabSwitcherDelegate;
|
||||
private double mPageZoomLatestDefaultZoomPrefValue;
|
||||
private BooleanPreferenceDelegate mMoveTopToolbarToBottomDelegate;
|
||||
+ private BooleanPreferenceDelegate mShowAlwaysContextMenuOnLinksDelegate;
|
||||
|
||||
private FontSizePrefs mFontSizePrefs;
|
||||
private FontSizePrefsObserver mFontSizePrefsObserver = new FontSizePrefsObserver() {
|
||||
@@ -143,6 +145,12 @@ public class AccessibilitySettings extends PreferenceFragmentCompat
|
||||
mMoveToolbarToBottomPref.setChecked(mMoveTopToolbarToBottomDelegate.isEnabled());
|
||||
mMoveToolbarToBottomPref.setOnPreferenceChangeListener(this);
|
||||
|
||||
+ ChromeSwitchPreference mShowAlwaysContextMenuOnLinksPref =
|
||||
+ (ChromeSwitchPreference) findPreference(PREF_ALWAYS_SHOW_CONTEXTMENU_ON_LINKS);
|
||||
+ mShowAlwaysContextMenuOnLinksDelegate = mDelegate.getShowAlwaysContextMenuOnLinksDelegate();
|
||||
+ mShowAlwaysContextMenuOnLinksPref.setChecked(mShowAlwaysContextMenuOnLinksDelegate.isEnabled());
|
||||
+ mShowAlwaysContextMenuOnLinksPref.setOnPreferenceChangeListener(this);
|
||||
+
|
||||
Preference captions = findPreference(PREF_CAPTIONS);
|
||||
captions.setOnPreferenceClickListener(preference -> {
|
||||
Intent intent = new Intent(Settings.ACTION_CAPTIONING_SETTINGS);
|
||||
@@ -205,6 +213,9 @@ public class AccessibilitySettings extends PreferenceFragmentCompat
|
||||
} else if (PREF_MOVE_TOOLBAR_TO_BOTTOM.equals(preference.getKey())) {
|
||||
mMoveTopToolbarToBottomDelegate.setEnabled((Boolean) newValue);
|
||||
mDelegate.requestRestart(getActivity());
|
||||
+ } else if (PREF_ALWAYS_SHOW_CONTEXTMENU_ON_LINKS.equals(preference.getKey())) {
|
||||
+ mShowAlwaysContextMenuOnLinksDelegate.setEnabled((Boolean) newValue);
|
||||
+ mDelegate.requestRestart(getActivity());
|
||||
}
|
||||
|
||||
return true;
|
||||
diff --git a/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettingsDelegate.java b/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettingsDelegate.java
|
||||
--- a/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettingsDelegate.java
|
||||
+++ b/components/browser_ui/accessibility/android/java/src/org/chromium/components/browser_ui/accessibility/AccessibilitySettingsDelegate.java
|
||||
@@ -33,6 +33,8 @@ public interface AccessibilitySettingsDelegate {
|
||||
|
||||
BooleanPreferenceDelegate getMoveTopToolbarToBottomDelegate();
|
||||
|
||||
+ BooleanPreferenceDelegate getShowAlwaysContextMenuOnLinksDelegate();
|
||||
+
|
||||
/**
|
||||
* @return The BrowserContextHandle that should be used to read and update settings.
|
||||
*/
|
||||
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
|
||||
@@ -964,6 +964,10 @@ BASE_FEATURE(kEnablePenetratingImageSelection,
|
||||
"EnablePenetratingImageSelection",
|
||||
base::FEATURE_ENABLED_BY_DEFAULT);
|
||||
|
||||
+BASE_FEATURE(kShowAlwaysContextMenuOnLinks,
|
||||
+ "ShowAlwaysContextMenuOnLinks",
|
||||
+ base::FEATURE_DISABLED_BY_DEFAULT);
|
||||
+
|
||||
// Used to configure a per-origin allowlist of performance.mark events that are
|
||||
// permitted to be included in slow reports traces. See crbug.com/1181774.
|
||||
BASE_FEATURE(kBackgroundTracingPerformanceMark,
|
||||
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
|
||||
@@ -403,6 +403,8 @@ BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kScopeMemoryCachePerContext);
|
||||
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kEnablePenetratingImageSelection);
|
||||
|
||||
+BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kShowAlwaysContextMenuOnLinks);
|
||||
+
|
||||
// Used to configure a per-origin allowlist of performance.mark events that are
|
||||
// permitted to be included in slow reports traces. See crbug.com/1181774.
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kBackgroundTracingPerformanceMark);
|
||||
diff --git a/third_party/blink/renderer/core/html/html_anchor_element.cc b/third_party/blink/renderer/core/html/html_anchor_element.cc
|
||||
--- a/third_party/blink/renderer/core/html/html_anchor_element.cc
|
||||
+++ b/third_party/blink/renderer/core/html/html_anchor_element.cc
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "third_party/blink/renderer/core/loader/ping_loader.h"
|
||||
#include "third_party/blink/renderer/core/navigation_api/navigation_api.h"
|
||||
#include "third_party/blink/renderer/core/page/chrome_client.h"
|
||||
+#include "third_party/blink/renderer/core/page/context_menu_controller.h"
|
||||
#include "third_party/blink/renderer/core/page/page.h"
|
||||
#include "third_party/blink/renderer/core/speculation_rules/document_speculation_rules.h"
|
||||
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
|
||||
@@ -418,7 +419,7 @@ void HTMLAnchorElement::SendPings(const KURL& destination_url) const {
|
||||
}
|
||||
}
|
||||
|
||||
-void HTMLAnchorElement::HandleClick(Event& event) {
|
||||
+void HTMLAnchorElement::HandleClick(Event& event, bool do_not_show_context_menu) {
|
||||
event.SetDefaultHandled();
|
||||
|
||||
LocalDOMWindow* window = GetDocument().domWindow();
|
||||
@@ -572,6 +573,15 @@ void HTMLAnchorElement::HandleClick(Event& event) {
|
||||
}
|
||||
}
|
||||
|
||||
+ if (!do_not_show_context_menu &&
|
||||
+ base::FeatureList::IsEnabled(features::kShowAlwaysContextMenuOnLinks)) {
|
||||
+ if (Page* page = GetDocument().GetPage()) {
|
||||
+ page->GetContextMenuController().HandleContextMenuEvent(
|
||||
+ To<MouseEvent>(&event), /*do_not_show_context_menu*/true);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
Frame* target_frame =
|
||||
frame->Tree().FindOrCreateFrameForNavigation(frame_request, target).frame;
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/html/html_anchor_element.h b/third_party/blink/renderer/core/html/html_anchor_element.h
|
||||
--- a/third_party/blink/renderer/core/html/html_anchor_element.h
|
||||
+++ b/third_party/blink/renderer/core/html/html_anchor_element.h
|
||||
@@ -98,6 +98,7 @@ class CORE_EXPORT HTMLAnchorElement : public HTMLElement, public DOMURLUtils {
|
||||
void SendPings(const KURL& destination_url) const;
|
||||
|
||||
void Trace(Visitor*) const override;
|
||||
+ void HandleClick(Event&, bool do_not_show_context_menu = false);
|
||||
|
||||
protected:
|
||||
void ParseAttribute(const AttributeModificationParams&) override;
|
||||
@@ -119,7 +120,6 @@ class CORE_EXPORT HTMLAnchorElement : public HTMLElement, public DOMURLUtils {
|
||||
bool IsInteractiveContent() const final;
|
||||
InsertionNotificationRequest InsertedInto(ContainerNode&) override;
|
||||
void RemovedFrom(ContainerNode&) override;
|
||||
- void HandleClick(Event&);
|
||||
|
||||
unsigned link_relations_ : 31;
|
||||
mutable LinkHash cached_visited_link_hash_;
|
||||
diff --git a/third_party/blink/renderer/core/page/context_menu_controller.cc b/third_party/blink/renderer/core/page/context_menu_controller.cc
|
||||
--- a/third_party/blink/renderer/core/page/context_menu_controller.cc
|
||||
+++ b/third_party/blink/renderer/core/page/context_menu_controller.cc
|
||||
@@ -186,14 +186,16 @@ void ContextMenuController::DocumentDetached(Document* document) {
|
||||
}
|
||||
}
|
||||
|
||||
-void ContextMenuController::HandleContextMenuEvent(MouseEvent* mouse_event) {
|
||||
- DCHECK(mouse_event->type() == event_type_names::kContextmenu);
|
||||
+void ContextMenuController::HandleContextMenuEvent(MouseEvent* mouse_event, bool do_not_show_context_menu) {
|
||||
+ if (!base::FeatureList::IsEnabled(features::kShowAlwaysContextMenuOnLinks)) {
|
||||
+ DCHECK(mouse_event->type() == event_type_names::kContextmenu);
|
||||
+ }
|
||||
LocalFrame* frame = mouse_event->target()->ToNode()->GetDocument().GetFrame();
|
||||
PhysicalOffset location =
|
||||
PhysicalOffset::FromPointFRound(mouse_event->AbsoluteLocation());
|
||||
|
||||
if (ShowContextMenu(frame, location, mouse_event->GetMenuSourceType(),
|
||||
- mouse_event))
|
||||
+ mouse_event, do_not_show_context_menu))
|
||||
mouse_event->SetDefaultHandled();
|
||||
}
|
||||
|
||||
@@ -439,7 +441,8 @@ bool ContextMenuController::ShouldShowContextMenuFromTouch(
|
||||
bool ContextMenuController::ShowContextMenu(LocalFrame* frame,
|
||||
const PhysicalOffset& point,
|
||||
WebMenuSourceType source_type,
|
||||
- const MouseEvent* mouse_event) {
|
||||
+ const MouseEvent* mouse_event,
|
||||
+ bool do_not_show_context_menu) {
|
||||
// Displaying the context menu in this function is a big hack as we don't
|
||||
// have context, i.e. whether this is being invoked via a script or in
|
||||
// response to user input (Mouse event WM_RBUTTONDOWN,
|
||||
@@ -465,6 +468,15 @@ bool ContextMenuController::ShowContextMenu(LocalFrame* frame,
|
||||
if (!result.InnerNodeOrImageMapImage())
|
||||
return false;
|
||||
|
||||
+ if (!do_not_show_context_menu &&
|
||||
+ base::FeatureList::IsEnabled(features::kShowAlwaysContextMenuOnLinks)) {
|
||||
+ if (auto* anchor_element = DynamicTo<HTMLAnchorElement>(result.URLElement())) {
|
||||
+ Event event;
|
||||
+ anchor_element->HandleClick(event, /*do_not_show_context_menu*/true);
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
// Clear any previously set cached results if we are resetting the hit test
|
||||
// result.
|
||||
image_selection_cached_result_ = nullptr;
|
||||
@@ -808,11 +820,13 @@ bool ContextMenuController::ShowContextMenu(LocalFrame* frame,
|
||||
data.form_renderer_id = GetFormRendererId(result);
|
||||
data.field_renderer_id = GetFieldRendererId(result);
|
||||
|
||||
- const bool from_touch = source_type == kMenuSourceTouch ||
|
||||
- source_type == kMenuSourceLongPress ||
|
||||
- source_type == kMenuSourceLongTap;
|
||||
- if (from_touch && !ShouldShowContextMenuFromTouch(data))
|
||||
- return false;
|
||||
+ if (!base::FeatureList::IsEnabled(features::kShowAlwaysContextMenuOnLinks)) {
|
||||
+ const bool from_touch = source_type == kMenuSourceTouch ||
|
||||
+ source_type == kMenuSourceLongPress ||
|
||||
+ source_type == kMenuSourceLongTap;
|
||||
+ if (from_touch && !ShouldShowContextMenuFromTouch(data))
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
WebLocalFrameImpl* selected_web_frame =
|
||||
WebLocalFrameImpl::FromFrame(selected_frame);
|
||||
diff --git a/third_party/blink/renderer/core/page/context_menu_controller.h b/third_party/blink/renderer/core/page/context_menu_controller.h
|
||||
--- a/third_party/blink/renderer/core/page/context_menu_controller.h
|
||||
+++ b/third_party/blink/renderer/core/page/context_menu_controller.h
|
||||
@@ -57,7 +57,7 @@ class CORE_EXPORT ContextMenuController final
|
||||
|
||||
void DocumentDetached(Document*);
|
||||
|
||||
- void HandleContextMenuEvent(MouseEvent*);
|
||||
+ void HandleContextMenuEvent(MouseEvent*, bool do_not_show_context_menu = false);
|
||||
void ShowContextMenuAtPoint(LocalFrame*,
|
||||
float x,
|
||||
float y,
|
||||
@@ -123,7 +123,8 @@ class CORE_EXPORT ContextMenuController final
|
||||
bool ShowContextMenu(LocalFrame*,
|
||||
const PhysicalOffset&,
|
||||
WebMenuSourceType,
|
||||
- const MouseEvent* mouse_event = nullptr);
|
||||
+ const MouseEvent* mouse_event = nullptr,
|
||||
+ bool do_not_show_context_menu = false);
|
||||
|
||||
bool ShouldShowContextMenuFromTouch(const ContextMenuData&);
|
||||
|
||||
--
|
||||
2.25.1
|
||||
Reference in New Issue
Block a user