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

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

Issue 1221923003: Update bower.json for Polymer elements and add PRESUBMIT.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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-resizable-behavior/iron-resizable-behavior-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/iron-resizable-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/iron-resizable-behavior-extracted.js
index f199bc9dfae2afbf4e3d4e18b88ca0f9e663bda3..37efb02d4aaf57c179cbb4afc7330d8969e38029 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/iron-resizable-behavior-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/iron-resizable-behavior-extracted.js
@@ -17,9 +17,21 @@
**/
Polymer.IronResizableBehavior = {
properties: {
+ /**
+ * The closest ancestor element that implements `IronResizableBehavior`.
+ */
_parentResizable: {
type: Object,
observer: '_parentResizableChanged'
+ },
+
+ /**
+ * True if this element is currently notifying its descedant elements of
+ * resize.
+ */
+ _notifyingDescendant: {
+ type: Boolean,
+ value: false
}
},
@@ -37,7 +49,8 @@
attached: function() {
this.fire('iron-request-resize-notifications', null, {
node: this,
- bubbles: true
+ bubbles: true,
+ cancelable: true
});
if (!this._parentResizable) {
@@ -66,16 +79,12 @@
}
this._interestedResizables.forEach(function(resizable) {
- // TODO(cdata): Currently behaviors cannot define "abstract" methods..
- if (!this.resizerShouldNotify || this.resizerShouldNotify(resizable)) {
- resizable.notifyResize();
+ if (this.resizerShouldNotify(resizable)) {
+ this._notifyDescendant(resizable);
}
}, this);
- this.fire('iron-resize', null, {
- node: this,
- bubbles: false
- });
+ this._fireResize();
},
/**
@@ -95,18 +104,42 @@
if (index > -1) {
this._interestedResizables.splice(index, 1);
+ this.unlisten(target, 'iron-resize', '_onDescendantIronResize');
}
},
- // TODO(cdata): Currently behaviors cannot define "abstract" methods.
- // resizerShouldNotify: function(el) { return true; },
+ /**
+ * This method can be overridden to filter nested elements that should or
+ * should not be notified by the current element. Return true if an element
+ * should be notified, or false if it should not be notified.
+ *
+ * @param {HTMLElement} element A candidate descendant element that
+ * implements `IronResizableBehavior`.
+ * @return {boolean} True if the `element` should be notified of resize.
+ */
+ resizerShouldNotify: function(element) { return true; },
- _parentResizableChanged: function(parentResizable) {
- if (parentResizable) {
- window.removeEventListener('resize', this._boundNotifyResize);
+ _onDescendantIronResize: function(event) {
+ if (this._notifyingDescendant) {
+ event.stopPropagation();
+ return;
+ }
+
+ // NOTE(cdata): In ShadowDOM, event retargetting makes echoing of the
+ // otherwise non-bubbling event "just work." We do it manually here for
+ // the case where Polymer is not using shadow roots for whatever reason:
+ if (!Polymer.Settings.useShadow) {
+ this._fireResize();
}
},
+ _fireResize: function() {
+ this.fire('iron-resize', null, {
+ node: this,
+ bubbles: false
+ });
+ },
+
_onIronRequestResizeNotifications: function(event) {
var target = event.path ? event.path[0] : event.target;
@@ -116,10 +149,31 @@
if (this._interestedResizables.indexOf(target) === -1) {
this._interestedResizables.push(target);
+ this.listen(target, 'iron-resize', '_onDescendantIronResize');
}
target.assignParentResizable(this);
+ this._notifyDescendant(target);
event.stopPropagation();
+ },
+
+ _parentResizableChanged: function(parentResizable) {
+ if (parentResizable) {
+ window.removeEventListener('resize', this._boundNotifyResize);
+ }
+ },
+
+ _notifyDescendant: function(descendant) {
+ // NOTE(cdata): In IE10, attached is fired on children first, so it's
+ // important not to notify them if the parent is not attached yet (or
+ // else they will get redundantly notified when the parent attaches).
+ if (!this.isAttached) {
+ return;
+ }
+
+ this._notifyingDescendant = true;
+ descendant.notifyResize();
+ this._notifyingDescendant = false;
}
};

Powered by Google App Engine
This is Rietveld 408576698