Chromium Code Reviews| 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
|