Skip to content

Commit 374e7d8

Browse files
Merge branch 'live' into disable-global-shortcut
2 parents d382419 + e68b6fd commit 374e7d8

File tree

1 file changed

+69
-19
lines changed

1 file changed

+69
-19
lines changed

patches/add-feature-to-toggle-middlemouse-copypaste.patch

+69-19
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,57 @@
1-
diff --git a/ui/views/selection_controller.cc b/ui/views/selection_controller.cc
2-
index b1a4514e7bdc4..d6c4abcbd7ca0 100644
3-
--- a/ui/views/selection_controller.cc
4-
+++ b/ui/views/selection_controller.cc
1+
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
2+
index 3cc13da526ba7..a8738cf3eb88a 100644
3+
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
4+
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
55
@@ -2,6 +2,9 @@
66
// Use of this source code is governed by a BSD-style license that can be
77
// found in the LICENSE file.
8-
8+
99
+#include "ui/views/views_features.h"
1010
+#include "third_party/blink/public/common/features_generated.h"
1111
+
12-
#include "ui/views/selection_controller.h"
12+
#include "chrome/browser/ui/views/tabs/tab_strip.h"
13+
14+
#include <stddef.h>
15+
@@ -2108,7 +2111,11 @@ void TabStrip::NewTabButtonPressed(const ui::Event& event) {
16+
const ui::MouseEvent& mouse = static_cast<const ui::MouseEvent&>(event);
17+
if (mouse.IsOnlyMiddleMouseButton()) {
18+
if (ui::Clipboard::IsSupportedClipboardBuffer(
19+
- ui::ClipboardBuffer::kSelection)) {
20+
+ ui::ClipboardBuffer::kSelection) &&
21+
+ !base::FeatureList::IsEnabled(
22+
+ blink::features::kMiddleClickAutoscroll) &&
23+
+ base::FeatureList::IsEnabled(
24+
+ views::features::kMiddleClickCopyPaste)) {
25+
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
26+
CHECK(clipboard)
27+
<< "Clipboard instance is not available, cannot proceed with "
28+
diff --git a/ui/views/selection_controller.h b/ui/views/selection_controller.h
29+
index dcc4d40592932..f9a9b002bd956 100644
30+
--- a/ui/views/selection_controller.h
31+
+++ b/ui/views/selection_controller.h
32+
@@ -5,6 +5,10 @@
33+
#ifndef UI_VIEWS_SELECTION_CONTROLLER_H_
34+
#define UI_VIEWS_SELECTION_CONTROLLER_H_
1335

14-
#include <algorithm>
15-
@@ -87,7 +90,12 @@ bool SelectionController::OnMousePressed(
36+
+// Needed features for middle click controls
37+
+#include "ui/views/views_features.h"
38+
+#include "third_party/blink/public/common/features_generated.h"
39+
+
40+
#include "base/memory/raw_ptr.h"
41+
#include "base/time/time.h"
42+
#include "base/timer/timer.h"
43+
@@ -61,7 +65,10 @@ class VIEWS_EXPORT SelectionController {
44+
// Sets whether the SelectionController should update or paste the
45+
// selection clipboard on middle-click. Default is false.
46+
void set_handles_selection_clipboard(bool value) {
47+
- handles_selection_clipboard_ = value;
48+
+ handles_selection_clipboard_ = value &&
49+
+ !base::FeatureList::IsEnabled(
50+
+ blink::features::kMiddleClickAutoscroll) &&
51+
+ base::FeatureList::IsEnabled(features::kMiddleClickCopyPaste);
1652
}
1753

18-
if (handles_selection_clipboard_ && event.IsOnlyMiddleMouseButton() &&
19-
- !delegate_->IsReadOnly()) {
20-
+ !delegate_->IsReadOnly() &&
21-
+ // MiddleClickAutoscroll can still paste without this check, so
22-
+ // these features are mutually exclusive in favor of autoscroll
23-
+ !base::FeatureList::IsEnabled(
24-
+ blink::features::kMiddleClickAutoscroll) &&
25-
+ base::FeatureList::IsEnabled(features::kMiddleClickCopyPaste)) {
26-
delegate_->OnBeforePointerAction();
27-
const bool selection_changed =
28-
render_text->MoveCursorToPoint(event.location(), false);
54+
// Offsets the double-clicked word's range. This is only used in the unusual
2955
diff --git a/ui/views/views_features.cc b/ui/views/views_features.cc
3056
index b6352269a2a8b..50365c274e3a3 100644
3157
--- a/ui/views/views_features.cc
@@ -55,3 +81,27 @@ index 0a86cbad6f271..24c504b18119a 100644
5581
} // namespace views::features
5682

5783
#endif // UI_VIEWS_VIEWS_FEATURES_H_
84+
diff --git a/third_party/blink/renderer/core/editing/selection_controller.cc b/third_party/blink/renderer/core/editing/selection_controller.cc
85+
index 8f129a1d5d..0ce49f8457 100644
86+
--- a/third_party/blink/renderer/core/editing/selection_controller.cc
87+
+++ b/third_party/blink/renderer/core/editing/selection_controller.cc
88+
@@ -63,6 +63,8 @@
89+
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
90+
#include "ui/gfx/geometry/point_conversions.h"
91+
92+
+#include "ui/views/views_features.h"
93+
+
94+
namespace blink {
95+
96+
SelectionController::SelectionController(LocalFrame& frame)
97+
@@ -1260,7 +1262,9 @@ bool SelectionController::HandlePasteGlobalSelection(
98+
Frame* focus_frame =
99+
frame_->GetPage()->GetFocusController().FocusedOrMainFrame();
100+
// Do not paste here if the focus was moved somewhere else.
101+
- if (frame_ == focus_frame)
102+
+ if (frame_ == focus_frame &&
103+
+ !RuntimeEnabledFeatures::MiddleClickAutoscrollEnabled() &&
104+
+ base::FeatureList::IsEnabled(views::features::kMiddleClickCopyPaste))
105+
return frame_->GetEditor().ExecuteCommand("PasteGlobalSelection");
106+
107+
return false;

0 commit comments

Comments
 (0)