Chromium Code Reviews| Index: Source/devtools/front_end/elements/ElementsPanel.js |
| diff --git a/Source/devtools/front_end/elements/ElementsPanel.js b/Source/devtools/front_end/elements/ElementsPanel.js |
| index 073be86290aa16286827fe661f75c6cc9bef3eb7..b8dd6dcbe48f9b39721ba511b95e29830653ccad 100644 |
| --- a/Source/devtools/front_end/elements/ElementsPanel.js |
| +++ b/Source/devtools/front_end/elements/ElementsPanel.js |
| @@ -50,6 +50,7 @@ WebInspector.ElementsPanel = function() |
| this._contentElement = createElement("div"); |
| var crumbsContainer = createElement("div"); |
| + this._showLayoutEditor = false; |
| if (Runtime.experiments.isEnabled("materialDesign")) { |
| this._toolbar = this._createElementsToolbar(); |
| var toolbar = stackElement.createChild("div", "elements-topbar hbox"); |
| @@ -135,6 +136,12 @@ WebInspector.ElementsPanel.prototype = { |
| toolbar.appendToolbarItem(this._breakpointsButton); |
| toolbar.appendSeparator(); |
| + if (Runtime.experiments.isEnabled("layoutEditor")) { |
|
dgozman
2015/08/19 22:49:43
&& !Runtime.queryParam("remoteFrontend")
sergeyv
2015/08/19 23:36:42
Done.
|
| + this._layoutEditorButton = new WebInspector.ToolbarButton(WebInspector.UIString("Turn on Layout Editor"), "layout-editor"); |
|
dgozman
2015/08/19 22:49:43
Toggle Layout Editor
sergeyv
2015/08/19 23:36:42
Done.
|
| + toolbar.appendToolbarItem(this._layoutEditorButton); |
| + this._layoutEditorButton.addEventListener("click", this._toggleLayoutEditor, this); |
| + toolbar.appendSeparator(); |
| + } |
| return toolbar; |
| }, |
| @@ -259,6 +266,9 @@ WebInspector.ElementsPanel.prototype = { |
| // Perform attach if necessary. |
| if (this.isShowing()) |
| this.wasShown(); |
| + |
| + if (this._showLayoutEditor) |
| + domModel.setHighlighter(new WebInspector.ElementsPanel.LayoutEditorNodeHighlighter(target, treeOutline)); |
| }, |
| /** |
| @@ -274,6 +284,8 @@ WebInspector.ElementsPanel.prototype = { |
| treeOutline.unwireFromDOMModel(); |
| this._treeOutlines.remove(treeOutline); |
| treeOutline.element.remove(); |
| + if (this._showLayoutEditor) |
| + domModel.setHighlighter(null); |
| }, |
| _updateTreeOutlineVisibleWidth: function() |
| @@ -876,7 +888,11 @@ WebInspector.ElementsPanel.prototype = { |
| this._omitDefaultSelection = true; |
| WebInspector.inspectorView.setCurrentPanel(this); |
| node = WebInspector.moduleSetting("showUAShadowDOM").get() ? node : this._leaveUserAgentShadowDOM(node); |
| - node.highlightForTwoSeconds(); |
| + if (this._showLayoutEditor) |
| + node.highlight(); |
| + else |
| + node.highlightForTwoSeconds(); |
| + |
| this.selectDOMNode(node, true); |
| delete this._omitDefaultSelection; |
| @@ -1078,6 +1094,28 @@ WebInspector.ElementsPanel.prototype = { |
| } |
| }, |
| + _toggleLayoutEditor: function() |
| + { |
| + this._showLayoutEditor = !this._showLayoutEditor; |
| + this._layoutEditorButton.setToggled(this._showLayoutEditor); |
| + var targets = WebInspector.targetManager.targets(); |
| + for (var target of targets) { |
| + var domModel = WebInspector.DOMModel.fromTarget(target); |
| + if (!domModel) |
| + continue; |
| + |
| + var treeOutline = /** @type {!WebInspector.ElementsTreeOutline} */(this._modelToTreeOutline.get(domModel)); |
| + if (this._showLayoutEditor) |
| + domModel.setHighlighter(new WebInspector.ElementsPanel.LayoutEditorNodeHighlighter(target, treeOutline)); |
| + else |
| + domModel.setHighlighter(null); |
| + |
| + if (WebInspector.inspectElementModeController && WebInspector.inspectElementModeController.enabled()) |
|
dgozman
2015/08/19 22:49:43
Let's add a comment.
sergeyv
2015/08/19 23:36:41
Done.
|
| + domModel.setInspectModeEnabled(true, WebInspector.moduleSetting("showUAShadowDOM").get()) |
|
dgozman
2015/08/19 22:49:43
nit: semicolon missing
sergeyv
2015/08/19 23:36:42
Done.
|
| + } |
| + WebInspector.DOMModel.hideDOMNodeHighlight(); |
| + }, |
| + |
| __proto__: WebInspector.Panel.prototype |
| } |
| @@ -1257,3 +1295,56 @@ WebInspector.ElementsPanel.HiddenMarkerDecorator.prototype = { |
| return { color: "#555", title: WebInspector.UIString("Element is hidden") }; |
| } |
| } |
| + |
| +/** |
| + * @constructor |
| + * @extends {WebInspector.DefaultDOMNodeHighlighter} |
| + * @param {!WebInspector.Target} target |
| + * @param {!WebInspector.ElementsTreeOutline} treeOutline |
| + */ |
| +WebInspector.ElementsPanel.LayoutEditorNodeHighlighter = function(target, treeOutline) |
| +{ |
| + WebInspector.DefaultDOMNodeHighlighter.call(this, target.domAgent()); |
| + this._treeOutline = treeOutline; |
| +} |
| + |
| +WebInspector.ElementsPanel.LayoutEditorNodeHighlighter.prototype = { |
| + /** |
| + * @override |
| + * @param {?WebInspector.DOMNode} node |
| + * @param {!DOMAgent.HighlightConfig} config |
| + * @param {!DOMAgent.BackendNodeId=} backendNodeId |
| + * @param {!RuntimeAgent.RemoteObjectId=} objectId |
| + */ |
| + highlightDOMNode: function(node, config, backendNodeId, objectId) |
| + { |
| + config.showLayoutEditor = config.showInfo; |
| + var selectedNode = this._treeOutline.selectedDOMNode(); |
| + if (objectId || node || backendNodeId || !selectedNode) |
| + WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.call(this, node, config, backendNodeId, objectId); |
| + else |
| + WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.call(this, selectedNode, config) |
|
dgozman
2015/08/19 22:49:43
nit: semicolon missing
sergeyv
2015/08/19 23:36:42
Done.
|
| + }, |
| + |
| + /** |
| + * @override |
| + * @param {boolean} enabled |
| + * @param {boolean} inspectUAShadowDOM |
| + * @param {!DOMAgent.HighlightConfig} config |
| + * @param {function(?Protocol.Error)=} callback |
| + */ |
| + setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callback) |
| + { |
| + config.showLayoutEditor = config.showInfo; |
| + WebInspector.DefaultDOMNodeHighlighter.prototype.setInspectModeEnabled.call(this, enabled, inspectUAShadowDOM, config, callback); |
| + |
| + if (enabled) |
| + return; |
| + |
| + var selectedNode = this._treeOutline.selectedDOMNode(); |
| + if (selectedNode) |
| + WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.call(this, selectedNode, config); |
| + }, |
| + |
| + __proto__: WebInspector.DefaultDOMNodeHighlighter.prototype |
| +} |