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

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js

Issue 1261403002: Add paper-menu-button and its dependencies to third_party/polymer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reproduce.sh Created 5 years, 5 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: third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js
index a6516eb8ddaa5e77c0bf1d80d943d2837c6ffde3..f9b7f99b5355b26d0e6606fe3b1dfe80c650061a 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-behaviors/iron-button-state-extracted.js
@@ -77,6 +77,8 @@
'space:keyup': '_spaceKeyUpHandler',
},
+ _mouseEventRe: /^mouse/,
+
_tapHandler: function() {
if (this.toggles) {
// a tap is needed to toggle the active state
@@ -97,7 +99,33 @@
this.fire('change');
},
- _downHandler: function() {
+ _eventSourceIsPrimaryInput: function(event) {
+ event = event.detail.sourceEvent || event;
+
+ // Always true for non-mouse events....
+ if (!this._mouseEventRe.test(event.type)) {
+ return true;
+ }
+
+ // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
+ if ('buttons' in event) {
+ return event.buttons === 1;
+ }
+
+ // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/which
+ if (typeof event.which === 'number') {
+ return event.which < 2;
+ }
+
+ // http://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
+ return event.button < 1;
+ },
+
+ _downHandler: function(event) {
+ if (!this._eventSourceIsPrimaryInput(event)) {
+ return;
+ }
+
this._setPointerDown(true);
this._setPressed(true);
this._setReceivedFocusFromKeyboard(false);

Powered by Google App Engine
This is Rietveld 408576698