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

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js

Issue 1468623004: Update Polymer from 1.2.1 -> 1.2.3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@travis-yml
Patch Set: local-state.html Created 5 years, 1 month 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-overlay-behavior/iron-overlay-manager-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js
index 128a38229d812eede286b5ef0350362a4efc4717..222ddddef1eb5bc30ea30b9dbcec737a6264ff04 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js
@@ -1,57 +1,71 @@
-Polymer.IronOverlayManager = (function() {
+Polymer.IronOverlayManager = {
- var overlays = [];
- var DEFAULT_Z = 10;
- var backdrops = [];
+ _overlays: [],
+
+ // iframes have a default z-index of 100, so this default should be at least
+ // that.
+ _minimumZ: 101,
+
+ _backdrops: [],
+
+ _applyOverlayZ: function(overlay, aboveZ) {
+ this._setZ(overlay, aboveZ + 2);
+ },
+
+ _setZ: function(element, z) {
+ element.style.zIndex = z;
+ },
// track overlays for z-index and focus managemant
- function addOverlay(overlay) {
- var z0 = currentOverlayZ();
- overlays.push(overlay);
- var z1 = currentOverlayZ();
- if (z1 <= z0) {
- applyOverlayZ(overlay, z0);
+ addOverlay: function(overlay) {
+ var minimumZ = Math.max(this.currentOverlayZ(), this._minimumZ);
+ this._overlays.push(overlay);
+ var newZ = this.currentOverlayZ();
+ if (newZ <= minimumZ) {
+ this._applyOverlayZ(overlay, minimumZ);
}
- }
+ },
- function removeOverlay(overlay) {
- var i = overlays.indexOf(overlay);
+ removeOverlay: function(overlay) {
+ var i = this._overlays.indexOf(overlay);
if (i >= 0) {
- overlays.splice(i, 1);
- setZ(overlay, '');
+ this._overlays.splice(i, 1);
+ this._setZ(overlay, '');
}
- }
-
- function applyOverlayZ(overlay, aboveZ) {
- setZ(overlay, aboveZ + 2);
- }
+ },
- function setZ(element, z) {
- element.style.zIndex = z;
- }
-
- function currentOverlay() {
- var i = overlays.length - 1;
- while (overlays[i] && !overlays[i].opened) {
+ currentOverlay: function() {
+ var i = this._overlays.length - 1;
+ while (this._overlays[i] && !this._overlays[i].opened) {
--i;
}
- return overlays[i];
- }
+ return this._overlays[i];
+ },
- function currentOverlayZ() {
- var z;
- var current = currentOverlay();
+ currentOverlayZ: function() {
+ var z = this._minimumZ;
+ var current = this.currentOverlay();
if (current) {
var z1 = window.getComputedStyle(current).zIndex;
if (!isNaN(z1)) {
z = Number(z1);
}
}
- return z || DEFAULT_Z;
- }
+ return z;
+ },
- function focusOverlay() {
- var current = currentOverlay();
+ /**
+ * Ensures that the minimum z-index of new overlays is at least `minimumZ`.
+ * This does not effect the z-index of any existing overlays.
+ *
+ * @param {number} minimumZ
+ */
+ ensureMinimumZ: function(minimumZ) {
+ this._minimumZ = Math.max(this._minimumZ, minimumZ);
+ },
+
+ focusOverlay: function() {
+ var current = this.currentOverlay();
// We have to be careful to focus the next overlay _after_ any current
// transitions are complete (due to the state being toggled prior to the
// transition). Otherwise, we risk infinite recursion when a transitioning
@@ -63,33 +77,23 @@ Polymer.IronOverlayManager = (function() {
if (current && !current.transitioning) {
current._applyFocus();
}
- }
+ },
- function trackBackdrop(element) {
+ trackBackdrop: function(element) {
// backdrops contains the overlays with a backdrop that are currently
// visible
if (element.opened) {
- backdrops.push(element);
+ this._backdrops.push(element);
} else {
- var index = backdrops.indexOf(element);
+ var index = this._backdrops.indexOf(element);
if (index >= 0) {
- backdrops.splice(index, 1);
+ this._backdrops.splice(index, 1);
}
}
- }
+ },
- function getBackdrops() {
- return backdrops;
+ getBackdrops: function() {
+ return this._backdrops;
}
- return {
- addOverlay: addOverlay,
- removeOverlay: removeOverlay,
- currentOverlay: currentOverlay,
- currentOverlayZ: currentOverlayZ,
- focusOverlay: focusOverlay,
- trackBackdrop: trackBackdrop,
- getBackdrops: getBackdrops
- };
-
- })();
+ };

Powered by Google App Engine
This is Rietveld 408576698