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

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

Issue 1304173004: Devtools UI: Add node-specific actions into a ghost toolbar in DOM (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase; remove material breadcrumb from experiment 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 | Annotate | Revision Log
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 22 matching lines...) Expand all
33 * @extends {TreeElement} 33 * @extends {TreeElement}
34 * @param {!WebInspector.DOMNode} node 34 * @param {!WebInspector.DOMNode} node
35 * @param {boolean=} elementCloseTag 35 * @param {boolean=} elementCloseTag
36 */ 36 */
37 WebInspector.ElementsTreeElement = function(node, elementCloseTag) 37 WebInspector.ElementsTreeElement = function(node, elementCloseTag)
38 { 38 {
39 // The title will be updated in onattach. 39 // The title will be updated in onattach.
40 TreeElement.call(this); 40 TreeElement.call(this);
41 this._node = node; 41 this._node = node;
42 42
43 this._decorationsElement = createElementWithClass("div", "hidden"); 43 this._gutterContainer = this.listItemElement.createChild("div", "gutter-cont ainer");
44 this.listItemElement.appendChild(this._decorationsElement); 44 this._decorationsElement = this._gutterContainer.createChild("div", "hidden" );
45 this._decorationsElement.addEventListener("mousedown", this._decorationsClic ked.bind(this));
45 46
46 this._elementCloseTag = elementCloseTag; 47 this._elementCloseTag = elementCloseTag;
47 48
48 if (this._node.nodeType() == Node.ELEMENT_NODE && !elementCloseTag) 49 if (this._node.nodeType() == Node.ELEMENT_NODE && !elementCloseTag)
49 this._canAddAttributes = true; 50 this._canAddAttributes = true;
50 this._searchQuery = null; 51 this._searchQuery = null;
51 this._expandedChildrenLimit = WebInspector.ElementsTreeElement.InitialChildr enLimit; 52 this._expandedChildrenLimit = WebInspector.ElementsTreeElement.InitialChildr enLimit;
52 if (this._node.nodeType() === Node.ELEMENT_NODE && this._node.parentNode && this._node.parentNode.nodeType() === Node.DOCUMENT_NODE && !this._node.parentNod e.parentNode) 53 if (this._node.nodeType() === Node.ELEMENT_NODE && this._node.parentNode && this._node.parentNode.nodeType() === Node.DOCUMENT_NODE && !this._node.parentNod e.parentNode)
53 this.setCollapsible(false); 54 this.setCollapsible(false);
54 } 55 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 158
158 /** 159 /**
159 * @return {boolean} 160 * @return {boolean}
160 */ 161 */
161 isEditing: function() 162 isEditing: function()
162 { 163 {
163 return !!this._editing; 164 return !!this._editing;
164 }, 165 },
165 166
166 /** 167 /**
168 * @return {!Element}
169 */
170 gutterElement: function()
171 {
172 return this._gutterContainer;
173 },
174
175 _decorationsClicked: function()
176 {
177 this.treeOutline.dispatchEventToListeners(WebInspector.ElementsTreeOutli ne.Events.DecorationsClicked, this._node);
178 },
179
180 /**
167 * @param {string} searchQuery 181 * @param {string} searchQuery
168 */ 182 */
169 highlightSearchResults: function(searchQuery) 183 highlightSearchResults: function(searchQuery)
170 { 184 {
171 if (this._searchQuery !== searchQuery) 185 if (this._searchQuery !== searchQuery)
172 this._hideSearchHighlight(); 186 this._hideSearchHighlight();
173 187
174 this._searchQuery = searchQuery; 188 this._searchQuery = searchQuery;
175 this._searchHighlightsVisible = true; 189 this._searchHighlightsVisible = true;
176 this.updateTitle(null, true); 190 this.updateTitle(null, true);
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 tagNameElement.addEventListener('keyup', keyupListener, false); 779 tagNameElement.addEventListener('keyup', keyupListener, false);
766 780
767 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind( this), editingCancelled.bind(this), tagName); 781 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind( this), editingCancelled.bind(this), tagName);
768 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement, config); 782 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement, config);
769 this.listItemElement.getComponentSelection().setBaseAndExtent(tagNameEle ment, 0, tagNameElement, 1); 783 this.listItemElement.getComponentSelection().setBaseAndExtent(tagNameEle ment, 0, tagNameElement, 1);
770 return true; 784 return true;
771 }, 785 },
772 786
773 /** 787 /**
774 * @param {function(string, string)} commitCallback 788 * @param {function(string, string)} commitCallback
789 * @param {function()} disposeCallback
775 * @param {?Protocol.Error} error 790 * @param {?Protocol.Error} error
776 * @param {string} initialValue 791 * @param {string} initialValue
777 */ 792 */
778 _startEditingAsHTML: function(commitCallback, error, initialValue) 793 _startEditingAsHTML: function(commitCallback, disposeCallback, error, initia lValue)
779 { 794 {
780 if (error) 795 if (error)
781 return; 796 return;
782 if (this._editing) 797 if (this._editing)
783 return; 798 return;
784 799
785 function consume(event) 800 function consume(event)
786 { 801 {
787 if (event.eventPhase === Event.AT_TARGET) 802 if (event.eventPhase === Event.AT_TARGET)
788 event.consume(true); 803 event.consume(true);
(...skipping 28 matching lines...) Expand all
817 { 832 {
818 commitCallback(initialValue, newValue); 833 commitCallback(initialValue, newValue);
819 dispose.call(this); 834 dispose.call(this);
820 } 835 }
821 836
822 /** 837 /**
823 * @this {WebInspector.ElementsTreeElement} 838 * @this {WebInspector.ElementsTreeElement}
824 */ 839 */
825 function dispose() 840 function dispose()
826 { 841 {
842 disposeCallback();
827 delete this._editing; 843 delete this._editing;
828 this.treeOutline.setMultilineEditing(null); 844 this.treeOutline.setMultilineEditing(null);
829 845
830 // Remove editor. 846 // Remove editor.
831 this.listItemElement.removeChild(this._htmlEditElement); 847 this.listItemElement.removeChild(this._htmlEditElement);
832 delete this._htmlEditElement; 848 delete this._htmlEditElement;
833 // Unhide children item. 849 // Unhide children item.
834 if (this._childrenListNode) 850 if (this._childrenListNode)
835 this._childrenListNode.style.removeProperty("display"); 851 this._childrenListNode.style.removeProperty("display");
836 // Unhide header items. 852 // Unhide header items.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 if (!depth) 1076 if (!depth)
1061 this.childrenListElement.classList.add("shadow-root-deep"); 1077 this.childrenListElement.classList.add("shadow-root-deep");
1062 else 1078 else
1063 this.childrenListElement.classList.add("shadow-root-depth-" + depth); 1079 this.childrenListElement.classList.add("shadow-root-depth-" + depth);
1064 } 1080 }
1065 var highlightElement = createElement("span"); 1081 var highlightElement = createElement("span");
1066 highlightElement.className = "highlight"; 1082 highlightElement.className = "highlight";
1067 highlightElement.appendChild(nodeInfo); 1083 highlightElement.appendChild(nodeInfo);
1068 this.title = highlightElement; 1084 this.title = highlightElement;
1069 this.updateDecorations(); 1085 this.updateDecorations();
1070 this.listItemElement.insertBefore(this._decorationsElement, this.lis tItemElement.firstChild); 1086 this.listItemElement.insertBefore(this._gutterContainer, this.listIt emElement.firstChild);
1071 delete this._highlightResult; 1087 delete this._highlightResult;
1072 } 1088 }
1073 1089
1074 delete this.selectionElement; 1090 delete this.selectionElement;
1075 if (this.selected) 1091 if (this.selected)
1076 this.updateSelection(); 1092 this.updateSelection();
1077 this._preventFollowingLinksOnDoubleClick(); 1093 this._preventFollowingLinksOnDoubleClick();
1078 this._highlightSearchResults(); 1094 this._highlightSearchResults();
1079 }, 1095 },
1080 1096
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 * @param {!WebInspector.DOMPresentationUtils.MarkerDecorator} decorator 1129 * @param {!WebInspector.DOMPresentationUtils.MarkerDecorator} decorator
1114 */ 1130 */
1115 function collectDecoration(n, decorator) 1131 function collectDecoration(n, decorator)
1116 { 1132 {
1117 var decoration = decorator.decorate(n); 1133 var decoration = decorator.decorate(n);
1118 if (!decoration) 1134 if (!decoration)
1119 return; 1135 return;
1120 (n === node ? decorations : descendantDecorations).push(decoration); 1136 (n === node ? decorations : descendantDecorations).push(decoration);
1121 } 1137 }
1122 1138
1123 Promise.all(promises).then(setTitle.bind(this)); 1139 Promise.all(promises).then(updateDecorationsUI.bind(this));
1124 1140
1125 /** 1141 /**
1126 * @this {WebInspector.ElementsTreeElement} 1142 * @this {WebInspector.ElementsTreeElement}
1127 */ 1143 */
1128 function setTitle() 1144 function updateDecorationsUI()
1129 { 1145 {
1130 this._decorationsElement.removeChildren(); 1146 this._decorationsElement.removeChildren();
1131 this._decorationsElement.classList.add("hidden"); 1147 this._decorationsElement.classList.add("hidden");
1132 if (!decorations.length && !descendantDecorations.length) 1148 if (!decorations.length && !descendantDecorations.length)
1133 return; 1149 return;
1134 1150
1135 var colors = new Set(); 1151 var colors = new Set();
1136 var titles = createElement("div"); 1152 var titles = createElement("div");
1137 1153
1138 for (var decoration of decorations) { 1154 for (var decoration of decorations) {
(...skipping 15 matching lines...) Expand all
1154 descendantColors.add(decoration.color); 1170 descendantColors.add(decoration.color);
1155 } 1171 }
1156 } 1172 }
1157 1173
1158 var offset = 0; 1174 var offset = 0;
1159 processColors.call(this, colors, "elements-gutter-decoration"); 1175 processColors.call(this, colors, "elements-gutter-decoration");
1160 if (!this.expanded) 1176 if (!this.expanded)
1161 processColors.call(this, descendantColors, "elements-gutter-deco ration elements-has-decorated-children"); 1177 processColors.call(this, descendantColors, "elements-gutter-deco ration elements-has-decorated-children");
1162 WebInspector.Tooltip.install(this._decorationsElement, titles); 1178 WebInspector.Tooltip.install(this._decorationsElement, titles);
1163 1179
1180 this._gutterContainer.classList.toggle("has-decorations", this._deco rationsElement.hasChildNodes());
1181
1164 /** 1182 /**
1165 * @param {!Set<string>} colors 1183 * @param {!Set<string>} colors
1166 * @param {string} className 1184 * @param {string} className
1167 * @this {WebInspector.ElementsTreeElement} 1185 * @this {WebInspector.ElementsTreeElement}
1168 */ 1186 */
1169 function processColors(colors, className) 1187 function processColors(colors, className)
1170 { 1188 {
1171 for (var color of colors) { 1189 for (var color of colors) {
1172 var child = this._decorationsElement.createChild("div", clas sName); 1190 var child = this._decorationsElement.createChild("div", clas sName);
1173 this._decorationsElement.classList.remove("hidden"); 1191 this._decorationsElement.classList.remove("hidden");
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 /** 1544 /**
1527 * @param {string} initialValue 1545 * @param {string} initialValue
1528 * @param {string} value 1546 * @param {string} value
1529 */ 1547 */
1530 function commitChange(initialValue, value) 1548 function commitChange(initialValue, value)
1531 { 1549 {
1532 if (initialValue !== value) 1550 if (initialValue !== value)
1533 node.setOuterHTML(value, selectNode); 1551 node.setOuterHTML(value, selectNode);
1534 } 1552 }
1535 1553
1554 function disposeCallback()
1555 {
1556 if (callback)
1557 callback(false);
1558 }
1559
1536 var node = this._node; 1560 var node = this._node;
1537 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange)); 1561 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange, disp oseCallback));
1538 }, 1562 },
1539 1563
1540 _copyCSSPath: function() 1564 _copyCSSPath: function()
1541 { 1565 {
1542 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.cssPath (this._node, true)); 1566 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.cssPath (this._node, true));
1543 }, 1567 },
1544 1568
1545 _copyXPath: function() 1569 _copyXPath: function()
1546 { 1570 {
1547 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.xPath(t his._node, true)); 1571 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.xPath(t his._node, true));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 1610
1587 if (object) 1611 if (object)
1588 object.callFunction(scrollIntoView); 1612 object.callFunction(scrollIntoView);
1589 } 1613 }
1590 1614
1591 this._node.resolveToObject("", scrollIntoViewCallback); 1615 this._node.resolveToObject("", scrollIntoViewCallback);
1592 }, 1616 },
1593 1617
1594 __proto__: TreeElement.prototype 1618 __proto__: TreeElement.prototype
1595 } 1619 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/elements/ElementsPanel.js ('k') | Source/devtools/front_end/elements/ElementsTreeOutline.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698