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

Side by Side Diff: Source/devtools/front_end/elements/ElementsPanel.js

Issue 1311783003: Devtools[LayoutEditor]: Rework layout-editor workflow (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@resize
Patch Set: Address comments Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « Source/devtools/front_end/components/InspectorView.js ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Sel ectedNodeChanged, this._selectedNodeChanged, this); 264 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Sel ectedNodeChanged, this._selectedNodeChanged, this);
265 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Nod ePicked, this._onNodePicked, this); 265 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Nod ePicked, this._onNodePicked, this);
266 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Ele mentsTreeUpdated, this._updateBreadcrumbIfNeeded, this); 266 treeOutline.addEventListener(WebInspector.ElementsTreeOutline.Events.Ele mentsTreeUpdated, this._updateBreadcrumbIfNeeded, this);
267 this._treeOutlines.push(treeOutline); 267 this._treeOutlines.push(treeOutline);
268 this._modelToTreeOutline.set(domModel, treeOutline); 268 this._modelToTreeOutline.set(domModel, treeOutline);
269 269
270 // Perform attach if necessary. 270 // Perform attach if necessary.
271 if (this.isShowing()) 271 if (this.isShowing())
272 this.wasShown(); 272 this.wasShown();
273 273
274 if (this._showLayoutEditor)
275 domModel.setHighlighter(new WebInspector.ElementsPanel.LayoutEditorN odeHighlighter(target, treeOutline));
276 }, 274 },
277 275
278 /** 276 /**
279 * @override 277 * @override
280 * @param {!WebInspector.Target} target 278 * @param {!WebInspector.Target} target
281 */ 279 */
282 targetRemoved: function(target) 280 targetRemoved: function(target)
283 { 281 {
284 var domModel = WebInspector.DOMModel.fromTarget(target); 282 var domModel = WebInspector.DOMModel.fromTarget(target);
285 if (!domModel) 283 if (!domModel)
286 return; 284 return;
287 var treeOutline = this._modelToTreeOutline.remove(domModel); 285 var treeOutline = this._modelToTreeOutline.remove(domModel);
288 treeOutline.unwireFromDOMModel(); 286 treeOutline.unwireFromDOMModel();
289 this._treeOutlines.remove(treeOutline); 287 this._treeOutlines.remove(treeOutline);
290 treeOutline.element.remove(); 288 treeOutline.element.remove();
291 if (this._showLayoutEditor)
292 domModel.setHighlighter(null);
293 }, 289 },
294 290
295 _updateTreeOutlineVisibleWidth: function() 291 _updateTreeOutlineVisibleWidth: function()
296 { 292 {
297 if (!this._treeOutlines.length) 293 if (!this._treeOutlines.length)
298 return; 294 return;
299 295
300 var width = this._splitWidget.element.offsetWidth; 296 var width = this._splitWidget.element.offsetWidth;
301 if (this._splitWidget.isVertical()) 297 if (this._splitWidget.isVertical())
302 width -= this._splitWidget.sidebarSize(); 298 width -= this._splitWidget.sidebarSize();
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 { 873 {
878 var userAgentShadowRoot = node.ancestorUserAgentShadowRoot(); 874 var userAgentShadowRoot = node.ancestorUserAgentShadowRoot();
879 return userAgentShadowRoot ? /** @type {!WebInspector.DOMNode} */ (userA gentShadowRoot.parentNode) : node; 875 return userAgentShadowRoot ? /** @type {!WebInspector.DOMNode} */ (userA gentShadowRoot.parentNode) : node;
880 }, 876 },
881 877
882 /** 878 /**
883 * @param {!WebInspector.DOMNode} node 879 * @param {!WebInspector.DOMNode} node
884 */ 880 */
885 revealAndSelectNode: function(node) 881 revealAndSelectNode: function(node)
886 { 882 {
887 if (WebInspector.inspectElementModeController && WebInspector.inspectEle mentModeController.enabled()) { 883 if (WebInspector.inspectElementModeController && WebInspector.inspectEle mentModeController.started())
888 InspectorFrontendHost.bringToFront(); 884 WebInspector.inspectElementModeController.stop();
889 WebInspector.inspectElementModeController.disable();
890 }
891 885
892 this._omitDefaultSelection = true; 886 this._omitDefaultSelection = true;
893 WebInspector.inspectorView.setCurrentPanel(this); 887
888 WebInspector.inspectorView.setCurrentPanel(this, this._showLayoutEditor) ;
894 node = WebInspector.moduleSetting("showUAShadowDOM").get() ? node : this ._leaveUserAgentShadowDOM(node); 889 node = WebInspector.moduleSetting("showUAShadowDOM").get() ? node : this ._leaveUserAgentShadowDOM(node);
895 if (this._showLayoutEditor) 890 if (!this._showLayoutEditor)
896 node.highlight();
897 else
898 node.highlightForTwoSeconds(); 891 node.highlightForTwoSeconds();
899 892
900 this.selectDOMNode(node, true); 893 this.selectDOMNode(node, true);
901 delete this._omitDefaultSelection; 894 delete this._omitDefaultSelection;
902 895
903 if (!this._notFirstInspectElement) 896 if (!this._notFirstInspectElement)
904 InspectorFrontendHost.inspectElementCompleted(); 897 InspectorFrontendHost.inspectElementCompleted();
905 this._notFirstInspectElement = true; 898 this._notFirstInspectElement = true;
906 }, 899 },
907 900
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 } else { 1089 } else {
1097 this._elementsPanelTreeOutilneSplit.hideSidebar(true); 1090 this._elementsPanelTreeOutilneSplit.hideSidebar(true);
1098 } 1091 }
1099 }, 1092 },
1100 1093
1101 _toggleLayoutEditor: function() 1094 _toggleLayoutEditor: function()
1102 { 1095 {
1103 this._showLayoutEditor = !this._showLayoutEditor; 1096 this._showLayoutEditor = !this._showLayoutEditor;
1104 this._layoutEditorButton.setToggled(this._showLayoutEditor); 1097 this._layoutEditorButton.setToggled(this._showLayoutEditor);
1105 var targets = WebInspector.targetManager.targets(); 1098 var targets = WebInspector.targetManager.targets();
1106 for (var target of targets) {
1107 var domModel = WebInspector.DOMModel.fromTarget(target);
1108 if (!domModel)
1109 continue;
1110 1099
1111 var treeOutline = /** @type {!WebInspector.ElementsTreeOutline} */(t his._modelToTreeOutline.get(domModel)); 1100 if (this._showLayoutEditor)
1112 if (this._showLayoutEditor) 1101 WebInspector.inspectElementModeController.disable();
1113 domModel.setHighlighter(new WebInspector.ElementsPanel.LayoutEdi torNodeHighlighter(target, treeOutline)); 1102 else
1114 else 1103 WebInspector.inspectElementModeController.enable();
1115 domModel.setHighlighter(null);
1116 1104
1117 // We need to correct (turn on/off layout editor) the config which i s used by inspect element mode, so we re-enable it. 1105 var mode = this._showLayoutEditor ? DOMAgent.InspectMode.ShowLayoutEdito r : DOMAgent.InspectMode.None;
1118 if (WebInspector.inspectElementModeController && WebInspector.inspec tElementModeController.enabled()) 1106 for (var domModel of WebInspector.DOMModel.instances())
1119 domModel.setInspectMode(WebInspector.moduleSetting("showUAShadow DOM").get() ? DOMAgent.InspectMode.SearchForUAShadowDOM : DOMAgent.InspectMode.S earchForNode); 1107 domModel.setInspectMode(mode);
1120 }
1121 WebInspector.DOMModel.hideDOMNodeHighlight();
1122 }, 1108 },
1123 1109
1124 __proto__: WebInspector.Panel.prototype 1110 __proto__: WebInspector.Panel.prototype
1125 } 1111 }
1126 1112
1127 /** 1113 /**
1128 * @constructor 1114 * @constructor
1129 * @implements {WebInspector.ContextMenu.Provider} 1115 * @implements {WebInspector.ContextMenu.Provider}
1130 */ 1116 */
1131 WebInspector.ElementsPanel.ContextMenuProvider = function() 1117 WebInspector.ElementsPanel.ContextMenuProvider = function()
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 WebInspector.ElementsPanel.HiddenMarkerDecorator.prototype = { 1278 WebInspector.ElementsPanel.HiddenMarkerDecorator.prototype = {
1293 /** 1279 /**
1294 * @override 1280 * @override
1295 * @param {!WebInspector.DOMNode} node 1281 * @param {!WebInspector.DOMNode} node
1296 * @return {?{title: string, color: string}} 1282 * @return {?{title: string, color: string}}
1297 */ 1283 */
1298 decorate: function(node) 1284 decorate: function(node)
1299 { 1285 {
1300 return { color: "#555", title: WebInspector.UIString("Element is hidden" ) }; 1286 return { color: "#555", title: WebInspector.UIString("Element is hidden" ) };
1301 } 1287 }
1302 }
1303
1304 /**
1305 * @constructor
1306 * @extends {WebInspector.DefaultDOMNodeHighlighter}
1307 * @param {!WebInspector.Target} target
1308 * @param {!WebInspector.ElementsTreeOutline} treeOutline
1309 */
1310 WebInspector.ElementsPanel.LayoutEditorNodeHighlighter = function(target, treeOu tline)
1311 {
1312 WebInspector.DefaultDOMNodeHighlighter.call(this, target.domAgent());
1313 this._treeOutline = treeOutline;
1314 }
1315
1316 WebInspector.ElementsPanel.LayoutEditorNodeHighlighter.prototype = {
1317 /**
1318 * @override
1319 * @param {?WebInspector.DOMNode} node
1320 * @param {!DOMAgent.HighlightConfig} config
1321 * @param {!DOMAgent.BackendNodeId=} backendNodeId
1322 * @param {!RuntimeAgent.RemoteObjectId=} objectId
1323 */
1324 highlightDOMNode: function(node, config, backendNodeId, objectId)
1325 {
1326 config.showLayoutEditor = config.showInfo;
1327 var selectedNode = this._treeOutline.selectedDOMNode();
1328 if (objectId || node || backendNodeId || !selectedNode)
1329 WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.ca ll(this, node, config, backendNodeId, objectId);
1330 else
1331 WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.ca ll(this, selectedNode, config);
1332 },
1333
1334 /**
1335 * @override
1336 * @param {!DOMAgent.InspectMode} mode
1337 * @param {!DOMAgent.HighlightConfig} config
1338 * @param {function(?Protocol.Error)=} callback
1339 */
1340 setInspectMode: function(mode, config, callback)
1341 {
1342 config.showLayoutEditor = config.showInfo;
1343 WebInspector.DefaultDOMNodeHighlighter.prototype.setInspectMode.call(thi s, mode, config, callback);
1344
1345 if (mode !== DOMAgent.InspectMode.None)
1346 return;
1347
1348 var selectedNode = this._treeOutline.selectedDOMNode();
1349 if (selectedNode)
1350 WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.ca ll(this, selectedNode, config);
1351 },
1352
1353 __proto__: WebInspector.DefaultDOMNodeHighlighter.prototype
1354 } 1288 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/components/InspectorView.js ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698