Add Node change listeners to Layout pane
This CL adds listeners for DOMNode changes to the Layout pane.
Bug: 1109177
Change-Id: I13e0ae67117772b8ce6e05d27aea04b0575e207f
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2354103
Reviewed-by: Changhao Han <[email protected]>
Reviewed-by: Patrick Brosset <[email protected]>
Commit-Queue: Alex Rudenko <[email protected]>
diff --git a/front_end/elements/LayoutSidebarPane.js b/front_end/elements/LayoutSidebarPane.js
index 66030df..4087dac 100644
--- a/front_end/elements/LayoutSidebarPane.js
+++ b/front_end/elements/LayoutSidebarPane.js
@@ -39,9 +39,13 @@
this._settings = [
'showGridBorder', 'showGridLines', 'showGridLineNumbers', 'showGridGaps', 'showGridAreas', 'showGridTrackSizes'
];
- this._node = self.UI.context.flavor(SDK.DOMModel.DOMNode);
this._boundOnSettingChanged = this.onSettingChanged.bind(this);
this._boundOnOverlayChanged = this.onOverlayChanged.bind(this);
+ this._pullNode();
+ }
+
+ _pullNode() {
+ this._node = self.UI.context.flavor(SDK.DOMModel.DOMNode);
}
async _fetchGridNodes() {
@@ -80,6 +84,7 @@
* @return {!Promise<void>}
*/
async doUpdate() {
+ this._pullNode();
this._layoutPane.data = {
gridElements: gridNodesToElements(await this._fetchGridNodes()),
settings: this._mapSettings(),
@@ -117,6 +122,7 @@
const overlayModel = this._node.domModel().overlayModel();
overlayModel.addEventListener(SDK.OverlayModel.Events.PersistentGridOverlayCleared, this.update, this);
overlayModel.addEventListener(SDK.OverlayModel.Events.PersistentGridOverlayStateChanged, this.update, this);
+ self.UI.context.addFlavorChangeListener(SDK.DOMModel.DOMNode, this.update, this);
this.update();
}
@@ -132,5 +138,6 @@
const overlayModel = this._node.domModel().overlayModel();
overlayModel.removeEventListener(SDK.OverlayModel.Events.PersistentGridOverlayCleared, this.update, this);
overlayModel.removeEventListener(SDK.OverlayModel.Events.PersistentGridOverlayStateChanged, this.update, this);
+ self.UI.context.removeFlavorChangeListener(SDK.DOMModel.DOMNode, this.update, this);
}
}