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

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: Rebase on dgozman changes 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
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 var domModel = WebInspector.DOMModel.fromTarget(node.target());
dgozman 2015/08/28 23:44:11 Not used.
sergeyv 2015/09/02 00:40:58 Done.
896 node.highlight(); 891 if (!this._showLayoutEditor)
897 else
898 node.highlightForTwoSeconds(); 892 node.highlightForTwoSeconds();
899 893
900 this.selectDOMNode(node, true); 894 this.selectDOMNode(node, true);
901 delete this._omitDefaultSelection; 895 delete this._omitDefaultSelection;
902 896
903 if (!this._notFirstInspectElement) 897 if (!this._notFirstInspectElement)
904 InspectorFrontendHost.inspectElementCompleted(); 898 InspectorFrontendHost.inspectElementCompleted();
905 this._notFirstInspectElement = true; 899 this._notFirstInspectElement = true;
906 }, 900 },
907 901
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 } else { 1090 } else {
1097 this._elementsPanelTreeOutilneSplit.hideSidebar(true); 1091 this._elementsPanelTreeOutilneSplit.hideSidebar(true);
1098 } 1092 }
1099 }, 1093 },
1100 1094
1101 _toggleLayoutEditor: function() 1095 _toggleLayoutEditor: function()
1102 { 1096 {
1103 this._showLayoutEditor = !this._showLayoutEditor; 1097 this._showLayoutEditor = !this._showLayoutEditor;
1104 this._layoutEditorButton.setToggled(this._showLayoutEditor); 1098 this._layoutEditorButton.setToggled(this._showLayoutEditor);
1105 var targets = WebInspector.targetManager.targets(); 1099 var targets = WebInspector.targetManager.targets();
1100
1101 if (this._showLayoutEditor)
1102 WebInspector.inspectElementModeController.disable();
1103 else
1104 WebInspector.inspectElementModeController.enable();
1105
1106 for (var target of targets) { 1106 for (var target of targets) {
1107 var domModel = WebInspector.DOMModel.fromTarget(target); 1107 var domModel = WebInspector.DOMModel.fromTarget(target);
1108 if (!domModel) 1108 if (!domModel)
1109 continue; 1109 continue;
1110 1110
1111 var treeOutline = /** @type {!WebInspector.ElementsTreeOutline} */(t his._modelToTreeOutline.get(domModel)); 1111 domModel.setInspectModeEnabled(this._showLayoutEditor, "showLayoutEd itor");
1112 if (this._showLayoutEditor)
1113 domModel.setHighlighter(new WebInspector.ElementsPanel.LayoutEdi torNodeHighlighter(target, treeOutline));
1114 else
1115 domModel.setHighlighter(null);
1116
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.
1118 if (WebInspector.inspectElementModeController && WebInspector.inspec tElementModeController.enabled())
1119 domModel.setInspectModeEnabled(true, WebInspector.moduleSetting( "showUAShadowDOM").get());
1120 } 1112 }
1121 WebInspector.DOMModel.hideDOMNodeHighlight(); 1113 WebInspector.DOMModel.hideDOMNodeHighlight();
1122 }, 1114 },
1123 1115
1124 __proto__: WebInspector.Panel.prototype 1116 __proto__: WebInspector.Panel.prototype
1125 } 1117 }
1126 1118
1127 /** 1119 /**
1128 * @constructor 1120 * @constructor
1129 * @implements {WebInspector.ContextMenu.Provider} 1121 * @implements {WebInspector.ContextMenu.Provider}
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 WebInspector.ElementsPanel.HiddenMarkerDecorator.prototype = { 1284 WebInspector.ElementsPanel.HiddenMarkerDecorator.prototype = {
1293 /** 1285 /**
1294 * @override 1286 * @override
1295 * @param {!WebInspector.DOMNode} node 1287 * @param {!WebInspector.DOMNode} node
1296 * @return {?{title: string, color: string}} 1288 * @return {?{title: string, color: string}}
1297 */ 1289 */
1298 decorate: function(node) 1290 decorate: function(node)
1299 { 1291 {
1300 return { color: "#555", title: WebInspector.UIString("Element is hidden" ) }; 1292 return { color: "#555", title: WebInspector.UIString("Element is hidden" ) };
1301 } 1293 }
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 {boolean} enabled
1337 * @param {boolean} inspectUAShadowDOM
1338 * @param {!DOMAgent.HighlightConfig} config
1339 * @param {function(?Protocol.Error)=} callback
1340 */
1341 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac k)
1342 {
1343 config.showLayoutEditor = config.showInfo;
1344 WebInspector.DefaultDOMNodeHighlighter.prototype.setInspectModeEnabled.c all(this, enabled, inspectUAShadowDOM, config, callback);
1345
1346 if (enabled)
1347 return;
1348
1349 var selectedNode = this._treeOutline.selectedDOMNode();
1350 if (selectedNode)
1351 WebInspector.DefaultDOMNodeHighlighter.prototype.highlightDOMNode.ca ll(this, selectedNode, config);
1352 },
1353
1354 __proto__: WebInspector.DefaultDOMNodeHighlighter.prototype
1355 } 1294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698