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") && !Runtime.queryParam
("remoteFrontend")) { |
| 140 this._layoutEditorButton = new WebInspector.ToolbarButton(WebInspect
or.UIString("Toggle Layout Editor"), "layout-editor-toolbar-item"); |
| 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 // We need to correct (turn on/off layout editor) the config which i
s used by inspect element mode, so we re-enable it. |
| 1114 if (WebInspector.inspectElementModeController && WebInspector.inspec
tElementModeController.enabled()) |
| 1115 domModel.setInspectModeEnabled(true, WebInspector.moduleSetting(
"showUAShadowDOM").get()); |
| 1116 } |
| 1117 WebInspector.DOMModel.hideDOMNodeHighlight(); |
| 1118 }, |
| 1119 |
1081 __proto__: WebInspector.Panel.prototype | 1120 __proto__: WebInspector.Panel.prototype |
1082 } | 1121 } |
1083 | 1122 |
1084 /** | 1123 /** |
1085 * @constructor | 1124 * @constructor |
1086 * @implements {WebInspector.ContextMenu.Provider} | 1125 * @implements {WebInspector.ContextMenu.Provider} |
1087 */ | 1126 */ |
1088 WebInspector.ElementsPanel.ContextMenuProvider = function() | 1127 WebInspector.ElementsPanel.ContextMenuProvider = function() |
1089 { | 1128 { |
1090 } | 1129 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 /** | 1289 /** |
1251 * @override | 1290 * @override |
1252 * @param {!WebInspector.DOMNode} node | 1291 * @param {!WebInspector.DOMNode} node |
1253 * @return {?{title: string, color: string}} | 1292 * @return {?{title: string, color: string}} |
1254 */ | 1293 */ |
1255 decorate: function(node) | 1294 decorate: function(node) |
1256 { | 1295 { |
1257 return { color: "#555", title: WebInspector.UIString("Element is hidden"
) }; | 1296 return { color: "#555", title: WebInspector.UIString("Element is hidden"
) }; |
1258 } | 1297 } |
1259 } | 1298 } |
| 1299 |
| 1300 /** |
| 1301 * @constructor |
| 1302 * @extends {WebInspector.DefaultDOMNodeHighlighter} |
| 1303 * @param {!WebInspector.Target} target |
| 1304 * @param {!WebInspector.ElementsTreeOutline} treeOutline |
| 1305 */ |
| 1306 WebInspector.ElementsPanel.LayoutEditorNodeHighlighter = function(target, treeOu
tline) |
| 1307 { |
| 1308 WebInspector.DefaultDOMNodeHighlighter.call(this, target.domAgent()); |
| 1309 this._treeOutline = treeOutline; |
| 1310 } |
| 1311 |
| 1312 WebInspector.ElementsPanel.LayoutEditorNodeHighlighter.prototype = { |
| 1313 /** |
| 1314 * @override |
| 1315 * @param {?WebInspector.DOMNode} node |
| 1316 * @param {!DOMAgent.HighlightConfig} config |
| 1317 * @param {!DOMAgent.BackendNodeId=} backendNodeId |
| 1318 * @param {!RuntimeAgent.RemoteObjectId=} objectId |
| 1319 */ |
| 1320 highlightDOMNode: function(node, config, backendNodeId, objectId) |
| 1321 { |
| 1322 config.showLayoutEditor = config.showInfo; |
| 1323 var selectedNode = this._treeOutline.selectedDOMNode(); |
| 1324 if (objectId || node || backendNodeId || !selectedNode) |
| 1325 WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.ca
ll(this, node, config, backendNodeId, objectId); |
| 1326 else |
| 1327 WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.ca
ll(this, selectedNode, config); |
| 1328 }, |
| 1329 |
| 1330 /** |
| 1331 * @override |
| 1332 * @param {boolean} enabled |
| 1333 * @param {boolean} inspectUAShadowDOM |
| 1334 * @param {!DOMAgent.HighlightConfig} config |
| 1335 * @param {function(?Protocol.Error)=} callback |
| 1336 */ |
| 1337 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac
k) |
| 1338 { |
| 1339 config.showLayoutEditor = config.showInfo; |
| 1340 WebInspector.DefaultDOMNodeHighlighter.prototype.setInspectModeEnabled.c
all(this, enabled, inspectUAShadowDOM, config, callback); |
| 1341 |
| 1342 if (enabled) |
| 1343 return; |
| 1344 |
| 1345 var selectedNode = this._treeOutline.selectedDOMNode(); |
| 1346 if (selectedNode) |
| 1347 WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.ca
ll(this, selectedNode, config); |
| 1348 }, |
| 1349 |
| 1350 __proto__: WebInspector.DefaultDOMNodeHighlighter.prototype |
| 1351 } |
OLD | NEW |