OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 this._splitWidget.addEventListener(WebInspector.SplitWidget.Events.SidebarSi zeChanged, this._updateTreeOutlineVisibleWidth.bind(this)); | 43 this._splitWidget.addEventListener(WebInspector.SplitWidget.Events.SidebarSi zeChanged, this._updateTreeOutlineVisibleWidth.bind(this)); |
44 this._splitWidget.show(this.element); | 44 this._splitWidget.show(this.element); |
45 | 45 |
46 this._searchableView = new WebInspector.SearchableView(this); | 46 this._searchableView = new WebInspector.SearchableView(this); |
47 this._searchableView.setMinimumSize(25, 19); | 47 this._searchableView.setMinimumSize(25, 19); |
48 this._searchableView.setPlaceholder(WebInspector.UIString("Find by string, s elector, or XPath")); | 48 this._searchableView.setPlaceholder(WebInspector.UIString("Find by string, s elector, or XPath")); |
49 var stackElement = this._searchableView.element; | 49 var stackElement = this._searchableView.element; |
50 | 50 |
51 this._contentElement = createElement("div"); | 51 this._contentElement = createElement("div"); |
52 var crumbsContainer = createElement("div"); | 52 var crumbsContainer = createElement("div"); |
53 this._showLayoutEditor = false; | |
53 if (Runtime.experiments.isEnabled("materialDesign")) { | 54 if (Runtime.experiments.isEnabled("materialDesign")) { |
54 this._toolbar = this._createElementsToolbar(); | 55 this._toolbar = this._createElementsToolbar(); |
55 var toolbar = stackElement.createChild("div", "elements-topbar hbox"); | 56 var toolbar = stackElement.createChild("div", "elements-topbar hbox"); |
56 toolbar.appendChild(this._toolbar.element); | 57 toolbar.appendChild(this._toolbar.element); |
57 toolbar.appendChild(crumbsContainer); | 58 toolbar.appendChild(crumbsContainer); |
58 stackElement.appendChild(this._contentElement); | 59 stackElement.appendChild(this._contentElement); |
59 } else { | 60 } else { |
60 stackElement.appendChild(this._contentElement); | 61 stackElement.appendChild(this._contentElement); |
61 stackElement.appendChild(crumbsContainer); | 62 stackElement.appendChild(crumbsContainer); |
62 } | 63 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 this._editAsHTMLButton.setAction("elements.edit-as-html"); | 129 this._editAsHTMLButton.setAction("elements.edit-as-html"); |
129 toolbar.appendToolbarItem(this._editAsHTMLButton); | 130 toolbar.appendToolbarItem(this._editAsHTMLButton); |
130 toolbar.appendSeparator(); | 131 toolbar.appendSeparator(); |
131 | 132 |
132 this._forceElementStateButton = new WebInspector.ToolbarMenuButton(WebIn spector.UIString("Force element state"), "pin-toolbar-item", this._showForceElem entStateMenu.bind(this)); | 133 this._forceElementStateButton = new WebInspector.ToolbarMenuButton(WebIn spector.UIString("Force element state"), "pin-toolbar-item", this._showForceElem entStateMenu.bind(this)); |
133 toolbar.appendToolbarItem(this._forceElementStateButton); | 134 toolbar.appendToolbarItem(this._forceElementStateButton); |
134 this._breakpointsButton = new WebInspector.ToolbarMenuButton(WebInspecto r.UIString("Toggle breakpoints"), "add-breakpoint-toolbar-item", this._showBreak pointsMenu.bind(this)); | 135 this._breakpointsButton = new WebInspector.ToolbarMenuButton(WebInspecto r.UIString("Toggle breakpoints"), "add-breakpoint-toolbar-item", this._showBreak pointsMenu.bind(this)); |
135 toolbar.appendToolbarItem(this._breakpointsButton); | 136 toolbar.appendToolbarItem(this._breakpointsButton); |
136 | 137 |
137 toolbar.appendSeparator(); | 138 toolbar.appendSeparator(); |
139 if (Runtime.experiments.isEnabled("layoutEditor")) { | |
dgozman
2015/08/19 22:49:43
&& !Runtime.queryParam("remoteFrontend")
sergeyv
2015/08/19 23:36:42
Done.
| |
140 this._layoutEditorButton = new WebInspector.ToolbarButton(WebInspect or.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.
| |
141 toolbar.appendToolbarItem(this._layoutEditorButton); | |
142 this._layoutEditorButton.addEventListener("click", this._toggleLayou tEditor, this); | |
143 toolbar.appendSeparator(); | |
144 } | |
138 return toolbar; | 145 return toolbar; |
139 }, | 146 }, |
140 | 147 |
141 _toggleHideElement: function() | 148 _toggleHideElement: function() |
142 { | 149 { |
143 var node = this.selectedDOMNode(); | 150 var node = this.selectedDOMNode(); |
144 var treeOutline = this._treeOutlineForNode(node); | 151 var treeOutline = this._treeOutlineForNode(node); |
145 if (!node || !treeOutline) | 152 if (!node || !treeOutline) |
146 return; | 153 return; |
147 treeOutline.toggleHideElement(node); | 154 treeOutline.toggleHideElement(node); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 treeOutline.wireToDOMModel(); | 259 treeOutline.wireToDOMModel(); |
253 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Sel ectedNodeChanged, this._selectedNodeChanged, this); | 260 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Sel ectedNodeChanged, this._selectedNodeChanged, this); |
254 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Nod ePicked, this._onNodePicked, this); | 261 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Nod ePicked, this._onNodePicked, this); |
255 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Ele mentsTreeUpdated, this._updateBreadcrumbIfNeeded, this); | 262 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Ele mentsTreeUpdated, this._updateBreadcrumbIfNeeded, this); |
256 this._treeOutlines.push(treeOutline); | 263 this._treeOutlines.push(treeOutline); |
257 this._modelToTreeOutline.set(domModel, treeOutline); | 264 this._modelToTreeOutline.set(domModel, treeOutline); |
258 | 265 |
259 // Perform attach if necessary. | 266 // Perform attach if necessary. |
260 if (this.isShowing()) | 267 if (this.isShowing()) |
261 this.wasShown(); | 268 this.wasShown(); |
269 | |
270 if (this._showLayoutEditor) | |
271 domModel.setHighlighter(new WebInspector.ElementsPanel.LayoutEditorN odeHighlighter(target, treeOutline)); | |
262 }, | 272 }, |
263 | 273 |
264 /** | 274 /** |
265 * @override | 275 * @override |
266 * @param {!WebInspector.Target} target | 276 * @param {!WebInspector.Target} target |
267 */ | 277 */ |
268 targetRemoved: function(target) | 278 targetRemoved: function(target) |
269 { | 279 { |
270 var domModel = WebInspector.DOMModel.fromTarget(target); | 280 var domModel = WebInspector.DOMModel.fromTarget(target); |
271 if (!domModel) | 281 if (!domModel) |
272 return; | 282 return; |
273 var treeOutline = this._modelToTreeOutline.remove(domModel); | 283 var treeOutline = this._modelToTreeOutline.remove(domModel); |
274 treeOutline.unwireFromDOMModel(); | 284 treeOutline.unwireFromDOMModel(); |
275 this._treeOutlines.remove(treeOutline); | 285 this._treeOutlines.remove(treeOutline); |
276 treeOutline.element.remove(); | 286 treeOutline.element.remove(); |
287 if (this._showLayoutEditor) | |
288 domModel.setHighlighter(null); | |
277 }, | 289 }, |
278 | 290 |
279 _updateTreeOutlineVisibleWidth: function() | 291 _updateTreeOutlineVisibleWidth: function() |
280 { | 292 { |
281 if (!this._treeOutlines.length) | 293 if (!this._treeOutlines.length) |
282 return; | 294 return; |
283 | 295 |
284 var width = this._splitWidget.element.offsetWidth; | 296 var width = this._splitWidget.element.offsetWidth; |
285 if (this._splitWidget.isVertical()) | 297 if (this._splitWidget.isVertical()) |
286 width -= this._splitWidget.sidebarSize(); | 298 width -= this._splitWidget.sidebarSize(); |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 revealAndSelectNode: function(node) | 881 revealAndSelectNode: function(node) |
870 { | 882 { |
871 if (WebInspector.inspectElementModeController && WebInspector.inspectEle mentModeController.enabled()) { | 883 if (WebInspector.inspectElementModeController && WebInspector.inspectEle mentModeController.enabled()) { |
872 InspectorFrontendHost.bringToFront(); | 884 InspectorFrontendHost.bringToFront(); |
873 WebInspector.inspectElementModeController.disable(); | 885 WebInspector.inspectElementModeController.disable(); |
874 } | 886 } |
875 | 887 |
876 this._omitDefaultSelection = true; | 888 this._omitDefaultSelection = true; |
877 WebInspector.inspectorView.setCurrentPanel(this); | 889 WebInspector.inspectorView.setCurrentPanel(this); |
878 node = WebInspector.moduleSetting("showUAShadowDOM").get() ? node : this ._leaveUserAgentShadowDOM(node); | 890 node = WebInspector.moduleSetting("showUAShadowDOM").get() ? node : this ._leaveUserAgentShadowDOM(node); |
879 node.highlightForTwoSeconds(); | 891 if (this._showLayoutEditor) |
892 node.highlight(); | |
893 else | |
894 node.highlightForTwoSeconds(); | |
895 | |
880 this.selectDOMNode(node, true); | 896 this.selectDOMNode(node, true); |
881 delete this._omitDefaultSelection; | 897 delete this._omitDefaultSelection; |
882 | 898 |
883 if (!this._notFirstInspectElement) | 899 if (!this._notFirstInspectElement) |
884 InspectorFrontendHost.inspectElementCompleted(); | 900 InspectorFrontendHost.inspectElementCompleted(); |
885 this._notFirstInspectElement = true; | 901 this._notFirstInspectElement = true; |
886 }, | 902 }, |
887 | 903 |
888 /** | 904 /** |
889 * @param {!Event} event | 905 * @param {!Event} event |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1071 setWidgetBelowDOM: function(widget) | 1087 setWidgetBelowDOM: function(widget) |
1072 { | 1088 { |
1073 if (widget) { | 1089 if (widget) { |
1074 this._elementsPanelTreeOutilneSplit.setSidebarWidget(widget); | 1090 this._elementsPanelTreeOutilneSplit.setSidebarWidget(widget); |
1075 this._elementsPanelTreeOutilneSplit.showBoth(true); | 1091 this._elementsPanelTreeOutilneSplit.showBoth(true); |
1076 } else { | 1092 } else { |
1077 this._elementsPanelTreeOutilneSplit.hideSidebar(true); | 1093 this._elementsPanelTreeOutilneSplit.hideSidebar(true); |
1078 } | 1094 } |
1079 }, | 1095 }, |
1080 | 1096 |
1097 _toggleLayoutEditor: function() | |
1098 { | |
1099 this._showLayoutEditor = !this._showLayoutEditor; | |
1100 this._layoutEditorButton.setToggled(this._showLayoutEditor); | |
1101 var targets = WebInspector.targetManager.targets(); | |
1102 for (var target of targets) { | |
1103 var domModel = WebInspector.DOMModel.fromTarget(target); | |
1104 if (!domModel) | |
1105 continue; | |
1106 | |
1107 var treeOutline = /** @type {!WebInspector.ElementsTreeOutline} */(t his._modelToTreeOutline.get(domModel)); | |
1108 if (this._showLayoutEditor) | |
1109 domModel.setHighlighter(new WebInspector.ElementsPanel.LayoutEdi torNodeHighlighter(target, treeOutline)); | |
1110 else | |
1111 domModel.setHighlighter(null); | |
1112 | |
1113 if (WebInspector.inspectElementModeController && WebInspector.inspec tElementModeController.enabled()) | |
dgozman
2015/08/19 22:49:43
Let's add a comment.
sergeyv
2015/08/19 23:36:41
Done.
| |
1114 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.
| |
1115 } | |
1116 WebInspector.DOMModel.hideDOMNodeHighlight(); | |
1117 }, | |
1118 | |
1081 __proto__: WebInspector.Panel.prototype | 1119 __proto__: WebInspector.Panel.prototype |
1082 } | 1120 } |
1083 | 1121 |
1084 /** | 1122 /** |
1085 * @constructor | 1123 * @constructor |
1086 * @implements {WebInspector.ContextMenu.Provider} | 1124 * @implements {WebInspector.ContextMenu.Provider} |
1087 */ | 1125 */ |
1088 WebInspector.ElementsPanel.ContextMenuProvider = function() | 1126 WebInspector.ElementsPanel.ContextMenuProvider = function() |
1089 { | 1127 { |
1090 } | 1128 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1250 /** | 1288 /** |
1251 * @override | 1289 * @override |
1252 * @param {!WebInspector.DOMNode} node | 1290 * @param {!WebInspector.DOMNode} node |
1253 * @return {?{title: string, color: string}} | 1291 * @return {?{title: string, color: string}} |
1254 */ | 1292 */ |
1255 decorate: function(node) | 1293 decorate: function(node) |
1256 { | 1294 { |
1257 return { color: "#555", title: WebInspector.UIString("Element is hidden" ) }; | 1295 return { color: "#555", title: WebInspector.UIString("Element is hidden" ) }; |
1258 } | 1296 } |
1259 } | 1297 } |
1298 | |
1299 /** | |
1300 * @constructor | |
1301 * @extends {WebInspector.DefaultDOMNodeHighlighter} | |
1302 * @param {!WebInspector.Target} target | |
1303 * @param {!WebInspector.ElementsTreeOutline} treeOutline | |
1304 */ | |
1305 WebInspector.ElementsPanel.LayoutEditorNodeHighlighter = function(target, treeOu tline) | |
1306 { | |
1307 WebInspector.DefaultDOMNodeHighlighter.call(this, target.domAgent()); | |
1308 this._treeOutline = treeOutline; | |
1309 } | |
1310 | |
1311 WebInspector.ElementsPanel.LayoutEditorNodeHighlighter.prototype = { | |
1312 /** | |
1313 * @override | |
1314 * @param {?WebInspector.DOMNode} node | |
1315 * @param {!DOMAgent.HighlightConfig} config | |
1316 * @param {!DOMAgent.BackendNodeId=} backendNodeId | |
1317 * @param {!RuntimeAgent.RemoteObjectId=} objectId | |
1318 */ | |
1319 highlightDOMNode: function(node, config, backendNodeId, objectId) | |
1320 { | |
1321 config.showLayoutEditor = config.showInfo; | |
1322 var selectedNode = this._treeOutline.selectedDOMNode(); | |
1323 if (objectId || node || backendNodeId || !selectedNode) | |
1324 WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.ca ll(this, node, config, backendNodeId, objectId); | |
1325 else | |
1326 WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.ca ll(this, selectedNode, config) | |
dgozman
2015/08/19 22:49:43
nit: semicolon missing
sergeyv
2015/08/19 23:36:42
Done.
| |
1327 }, | |
1328 | |
1329 /** | |
1330 * @override | |
1331 * @param {boolean} enabled | |
1332 * @param {boolean} inspectUAShadowDOM | |
1333 * @param {!DOMAgent.HighlightConfig} config | |
1334 * @param {function(?Protocol.Error)=} callback | |
1335 */ | |
1336 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac k) | |
1337 { | |
1338 config.showLayoutEditor = config.showInfo; | |
1339 WebInspector.DefaultDOMNodeHighlighter.prototype.setInspectModeEnabled.c all(this, enabled, inspectUAShadowDOM, config, callback); | |
1340 | |
1341 if (enabled) | |
1342 return; | |
1343 | |
1344 var selectedNode = this._treeOutline.selectedDOMNode(); | |
1345 if (selectedNode) | |
1346 WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.ca ll(this, selectedNode, config); | |
1347 }, | |
1348 | |
1349 __proto__: WebInspector.DefaultDOMNodeHighlighter.prototype | |
1350 } | |
OLD | NEW |