summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 21:15:06 +0000
committerarv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 21:15:06 +0000
commit027db59033125d49ab7cbf4a553e6be7c83b0960 (patch)
treed01e3b38d9f1ea87803d7c3dc6b3142c36302800
parenta1f11117524b3e70e1de961f817cb0b899a8bb53 (diff)
downloadchromium_src-027db59033125d49ab7cbf4a553e6be7c83b0960.zip
chromium_src-027db59033125d49ab7cbf4a553e6be7c83b0960.tar.gz
chromium_src-027db59033125d49ab7cbf4a553e6be7c83b0960.tar.bz2
Bookmark manager: Fix middle click regression.
Now that WebKit no longer dispatches click events for middle clicks we have to emulate it. BUG=11938 TEST=Middle click one of the bookmarks in the bookmark manager. It should be opened in a background tab. Review URL: http://codereview.chromium.org/3889001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63109 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js43
1 files changed, 35 insertions, 8 deletions
diff --git a/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js b/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js
index 9404af6..64f5976 100644
--- a/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js
+++ b/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js
@@ -216,16 +216,43 @@ cr.define('bmm', function() {
* Handles mousedown events so that we can prevent the auto scroll as
* necessary.
* @private
- * @param {!Event} e The mousedown event object.
+ * @param {!MouseEvent} e The mousedown event object.
*/
handleMouseDown_: function(e) {
- // When the user does a middle click we need to prevent the auto scroll
- // in case the user is trying to middle click to open a bookmark in a
- // background tab.
- // We do not do this in case the target is an input since middle click
- // is also paste on Linux and we don't want to break that.
- if (e.button == 1 && e.target.tagName != 'INPUT')
- e.preventDefault();
+ if (e.button == 1) {
+ // WebKit no longer fires click events for middle clicks so we manually
+ // listen to mouse up to dispatch a click event.
+ this.addEventListener('mouseup', this.handleMiddleMouseUp_);
+
+ // When the user does a middle click we need to prevent the auto scroll
+ // in case the user is trying to middle click to open a bookmark in a
+ // background tab.
+ // We do not do this in case the target is an input since middle click
+ // is also paste on Linux and we don't want to break that.
+ if (e.target.tagName != 'INPUT')
+ e.preventDefault();
+ }
+ },
+
+ /**
+ * WebKit no longer dispatches click events for middle clicks so we need
+ * to emulate it.
+ * @private
+ * @param {!MouseEvent} e The mouse up event object.
+ */
+ handleMiddleMouseUp_: function(e) {
+ this.removeEventListener('mouseup', this.handleMiddleMouseUp_);
+ if (e.button == 1) {
+ var clickEvent = document.createEvent('MouseEvent');
+ clickEvent.initMouseEvent('click',
+ true, // canBubble
+ true, // cancelable,
+ e.view, e.detail,
+ e.screenX, e.screenY, e.clientX, e.clientY,
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
+ e.button, e.relatedTarget);
+ e.target.dispatchEvent(clickEvent);
+ }
},
// Bookmark model update callbacks