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

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js

Issue 2089563002: [Polymer] update polymer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: polymer update Created 4 years, 6 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-list/iron-list-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js
index 4d55a0ce9d769c7f9f6b297492ea2a8c151ba462..50fda9d32d4382b9c38d37c8d5430b67247c3c81 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-list/iron-list-extracted.js
@@ -5,6 +5,7 @@
var DEFAULT_PHYSICAL_COUNT = 3;
var HIDDEN_Y = '-10000px';
var DEFAULT_GRID_SIZE = 200;
+ var SECRET_TABINDEX = -100;
Polymer({
@@ -836,14 +837,24 @@
if (!el || el._templateInstance.__key__ !== key) {
return;
}
-
if (dot >= 0) {
path = this.as + '.' + path.substring(dot+1);
el._templateInstance.notifyPath(path, value, true);
} else {
+ // Update selection if needed
+ var currentItem = el._templateInstance[this.as];
+ if (Array.isArray(this.selectedItems)) {
+ for (var i = 0; i < this.selectedItems.length; i++) {
+ if (this.selectedItems[i] === currentItem) {
+ this.set('selectedItems.' + i, value);
+ break;
+ }
+ }
+ } else if (this.selectedItem === currentItem) {
+ this.set('selectedItem', value);
+ }
el._templateInstance[this.as] = value;
}
-
},
/**
@@ -1031,9 +1042,9 @@
},
_updateGridMetrics: function() {
- this._viewportWidth = this._scrollTargetWidth;
+ this._viewportWidth = this.$.items.offsetWidth;
// Set item width to the value of the _physicalItems offsetWidth
- this._itemWidth = this._physicalCount > 0 ? this._physicalItems[0].offsetWidth : DEFAULT_GRID_SIZE;
+ this._itemWidth = this._physicalCount > 0 ? this._physicalItems[0].getBoundingClientRect().width : DEFAULT_GRID_SIZE;
// Set row height to the value of the _physicalItems offsetHeight
this._rowHeight = this._physicalCount > 0 ? this._physicalItems[0].offsetHeight : DEFAULT_GRID_SIZE;
// If in grid mode compute how many items with exist in each row
@@ -1360,12 +1371,32 @@
* Select an item from an event object.
*/
_selectionHandler: function(e) {
- if (this.selectionEnabled) {
- var model = this.modelForElement(e.target);
- if (model) {
- this.toggleSelectionForItem(model[this.as]);
- }
+ var model = this.modelForElement(e.target);
+ if (!model) {
+ return;
+ }
+ var modelTabIndex, activeElTabIndex;
+ var target = Polymer.dom(e).path[0];
+ var activeEl = Polymer.dom(this.domHost ? this.domHost.root : document).activeElement;
+ var physicalItem = this._physicalItems[this._getPhysicalIndex(model[this.indexAs])];
+ // Safari does not focus certain form controls via mouse
+ // https://bugs.webkit.org/show_bug.cgi?id=118043
+ if (target.localName === 'input' ||
+ target.localName === 'button' ||
+ target.localName === 'select') {
+ return;
+ }
+ // Set a temporary tabindex
+ modelTabIndex = model.tabIndex;
+ model.tabIndex = SECRET_TABINDEX;
+ activeElTabIndex = activeEl ? activeEl.tabIndex : -1;
+ model.tabIndex = modelTabIndex;
+ // Only select the item if the tap wasn't on a focusable child
+ // or the element bound to `tabIndex`
+ if (activeEl && physicalItem.contains(activeEl) && activeElTabIndex !== SECRET_TABINDEX) {
+ return;
}
+ this.toggleSelectionForItem(model[this.as]);
},
_multiSelectionChanged: function(multiSelection) {
@@ -1438,19 +1469,18 @@
}
var physicalItem = this._physicalItems[this._getPhysicalIndex(idx)];
- var SECRET = ~(Math.random() * 100);
var model = physicalItem._templateInstance;
var focusable;
// set a secret tab index
- model.tabIndex = SECRET;
+ model.tabIndex = SECRET_TABINDEX;
// check if focusable element is the physical item
- if (physicalItem.tabIndex === SECRET) {
+ if (physicalItem.tabIndex === SECRET_TABINDEX) {
focusable = physicalItem;
}
// search for the element which tabindex is bound to the secret tab index
if (!focusable) {
- focusable = Polymer.dom(physicalItem).querySelector('[tabindex="' + SECRET + '"]');
+ focusable = Polymer.dom(physicalItem).querySelector('[tabindex="' + SECRET_TABINDEX + '"]');
}
// restore the tab index
model.tabIndex = 0;

Powered by Google App Engine
This is Rietveld 408576698