Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Unified Diff: chrome/browser/resources/ntp4/synthetic_middleclick.js

Issue 1963823002: Dispatch middle click manually by tracking mouse (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl try Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/ntp4/synthetic_middleclick.js
diff --git a/chrome/browser/resources/ntp4/synthetic_middleclick.js b/chrome/browser/resources/ntp4/synthetic_middleclick.js
new file mode 100644
index 0000000000000000000000000000000000000000..affb01ebe0cff9f0f492b105d3b97af0043565b1
--- /dev/null
+++ b/chrome/browser/resources/ntp4/synthetic_middleclick.js
@@ -0,0 +1,17 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var middleButtonMouseDownTarget = null;
Dan Beam 2016/05/24 01:57:31 wrap this in: (function() { ... code ... })();
Navid Zolghadr 2016/05/24 17:51:14 Done.
+document.addEventListener('mousedown', function(e) {
+ if (e.button == 1) {
Dan Beam 2016/05/24 01:57:32 no curlies
Navid Zolghadr 2016/05/24 17:51:14 Done.
+ middleButtonMouseDownTarget = e.target;
+ }
+}, true);
+document.addEventListener('mouseup', function(e) {
+ if (e.button == 1) {
+ if (e.target == middleButtonMouseDownTarget)
Dan Beam 2016/05/24 01:57:32 how does this work with shadow DOM? should you be
Navid Zolghadr 2016/05/24 17:51:14 I don't think there is any shadow DOM here in this
+ e.target.dispatchEvent(new MouseEvent('click', e));
+ middleButtonMouseDownTarget = null;
+ }
+}, true);
Dan Beam 2016/05/12 02:06:24 both of our code has all kind of things wrong with
dtapuska 2016/05/12 02:12:50 Won't this dispatch two click events if the mouse
Navid Zolghadr 2016/05/12 13:56:01 Yes, I believe Dave is right. Dan, your solutions
Dan Beam 2016/05/12 18:59:05 mousing up outside of the window still dispatches
Dan Beam 2016/05/12 19:08:21 obviously it's possible some other listener stops
Navid Zolghadr 2016/05/12 20:53:59 Dan, I totally agree that having a platform suppor

Powered by Google App Engine
This is Rietveld 408576698