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

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: 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 { 272 {
259 var listItemElement = this.listItemElement; 273 var listItemElement = this.listItemElement;
260 if (!listItemElement) 274 if (!listItemElement)
261 return; 275 return;
262 276
263 if (!this.selectionElement) { 277 if (!this.selectionElement) {
264 this.selectionElement = createElement("div"); 278 this.selectionElement = createElement("div");
265 this.selectionElement.className = "selection fill"; 279 this.selectionElement.className = "selection fill";
266 listItemElement.insertBefore(this.selectionElement, listItemElement. firstChild); 280 listItemElement.insertBefore(this.selectionElement, listItemElement. firstChild);
267 } 281 }
282 this.selectionElement.style.height = listItemElement.offsetHeight + "px" ;
pfeldman 2015/09/17 00:06:18 Is this related to the dgozman's change rollout?
samli 2015/09/17 18:08:04 Yeah, doesn't show up in my diff locally.
268 }, 283 },
269 284
270 /** 285 /**
271 * @override 286 * @override
272 */ 287 */
273 onbind: function() 288 onbind: function()
274 { 289 {
275 if (!this._elementCloseTag) 290 if (!this._elementCloseTag)
276 this._node[this.treeOutline.treeElementSymbol()] = this; 291 this._node[this.treeOutline.treeElementSymbol()] = this;
277 }, 292 },
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 tagNameElement.addEventListener('keyup', keyupListener, false); 778 tagNameElement.addEventListener('keyup', keyupListener, false);
764 779
765 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind( this), editingCancelled.bind(this), tagName); 780 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind( this), editingCancelled.bind(this), tagName);
766 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement, config); 781 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement, config);
767 this.listItemElement.getComponentSelection().setBaseAndExtent(tagNameEle ment, 0, tagNameElement, 1); 782 this.listItemElement.getComponentSelection().setBaseAndExtent(tagNameEle ment, 0, tagNameElement, 1);
768 return true; 783 return true;
769 }, 784 },
770 785
771 /** 786 /**
772 * @param {function(string, string)} commitCallback 787 * @param {function(string, string)} commitCallback
788 * @param {function()} disposeCallback
773 * @param {?Protocol.Error} error 789 * @param {?Protocol.Error} error
774 * @param {string} initialValue 790 * @param {string} initialValue
775 */ 791 */
776 _startEditingAsHTML: function(commitCallback, error, initialValue) 792 _startEditingAsHTML: function(commitCallback, disposeCallback, error, initia lValue)
777 { 793 {
778 if (error) 794 if (error)
779 return; 795 return;
780 if (this._editing) 796 if (this._editing)
781 return; 797 return;
782 798
783 function consume(event) 799 function consume(event)
784 { 800 {
785 if (event.eventPhase === Event.AT_TARGET) 801 if (event.eventPhase === Event.AT_TARGET)
786 event.consume(true); 802 event.consume(true);
(...skipping 28 matching lines...) Expand all
815 { 831 {
816 commitCallback(initialValue, newValue); 832 commitCallback(initialValue, newValue);
817 dispose.call(this); 833 dispose.call(this);
818 } 834 }
819 835
820 /** 836 /**
821 * @this {WebInspector.ElementsTreeElement} 837 * @this {WebInspector.ElementsTreeElement}
822 */ 838 */
823 function dispose() 839 function dispose()
824 { 840 {
841 disposeCallback();
825 delete this._editing; 842 delete this._editing;
826 this.treeOutline.setMultilineEditing(null); 843 this.treeOutline.setMultilineEditing(null);
827 844
828 // Remove editor. 845 // Remove editor.
829 this.listItemElement.removeChild(this._htmlEditElement); 846 this.listItemElement.removeChild(this._htmlEditElement);
830 delete this._htmlEditElement; 847 delete this._htmlEditElement;
831 // Unhide children item. 848 // Unhide children item.
832 if (this._childrenListNode) 849 if (this._childrenListNode)
833 this._childrenListNode.style.removeProperty("display"); 850 this._childrenListNode.style.removeProperty("display");
834 // Unhide header items. 851 // Unhide header items.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 if (!depth) 1075 if (!depth)
1059 this.childrenListElement.classList.add("shadow-root-deep"); 1076 this.childrenListElement.classList.add("shadow-root-deep");
1060 else 1077 else
1061 this.childrenListElement.classList.add("shadow-root-depth-" + depth); 1078 this.childrenListElement.classList.add("shadow-root-depth-" + depth);
1062 } 1079 }
1063 var highlightElement = createElement("span"); 1080 var highlightElement = createElement("span");
1064 highlightElement.className = "highlight"; 1081 highlightElement.className = "highlight";
1065 highlightElement.appendChild(nodeInfo); 1082 highlightElement.appendChild(nodeInfo);
1066 this.title = highlightElement; 1083 this.title = highlightElement;
1067 this.updateDecorations(); 1084 this.updateDecorations();
1068 this.listItemElement.insertBefore(this._decorationsElement, this.lis tItemElement.firstChild); 1085 this.listItemElement.insertBefore(this._gutterContainer, this.listIt emElement.firstChild);
1069 delete this._highlightResult; 1086 delete this._highlightResult;
1070 } 1087 }
1071 1088
1072 delete this.selectionElement; 1089 delete this.selectionElement;
1073 if (this.selected) 1090 if (this.selected)
1074 this.updateSelection(); 1091 this.updateSelection();
1075 this._preventFollowingLinksOnDoubleClick(); 1092 this._preventFollowingLinksOnDoubleClick();
1076 this._highlightSearchResults(); 1093 this._highlightSearchResults();
1077 }, 1094 },
1078 1095
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 * @param {!WebInspector.DOMPresentationUtils.MarkerDecorator} decorator 1128 * @param {!WebInspector.DOMPresentationUtils.MarkerDecorator} decorator
1112 */ 1129 */
1113 function collectDecoration(n, decorator) 1130 function collectDecoration(n, decorator)
1114 { 1131 {
1115 var decoration = decorator.decorate(n); 1132 var decoration = decorator.decorate(n);
1116 if (!decoration) 1133 if (!decoration)
1117 return; 1134 return;
1118 (n === node ? decorations : descendantDecorations).push(decoration); 1135 (n === node ? decorations : descendantDecorations).push(decoration);
1119 } 1136 }
1120 1137
1121 Promise.all(promises).then(setTitle.bind(this)); 1138 Promise.all(promises).then(setTitle.bind(this)).then(this._updateGutter. bind(this));
1122 1139
1123 /** 1140 /**
1124 * @this {WebInspector.ElementsTreeElement} 1141 * @this {WebInspector.ElementsTreeElement}
1125 */ 1142 */
1126 function setTitle() 1143 function setTitle()
1127 { 1144 {
1128 this._decorationsElement.removeChildren(); 1145 this._decorationsElement.removeChildren();
1129 this._decorationsElement.classList.add("hidden"); 1146 this._decorationsElement.classList.add("hidden");
1130 if (!decorations.length && !descendantDecorations.length) 1147 if (!decorations.length && !descendantDecorations.length)
1131 return; 1148 return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 child.style.backgroundColor = color; 1189 child.style.backgroundColor = color;
1173 child.style.borderColor = color; 1190 child.style.borderColor = color;
1174 if (offset) 1191 if (offset)
1175 child.style.marginLeft = offset + "px"; 1192 child.style.marginLeft = offset + "px";
1176 offset += 3; 1193 offset += 3;
1177 } 1194 }
1178 } 1195 }
1179 } 1196 }
1180 }, 1197 },
1181 1198
1199 _updateGutter: function()
1200 {
1201 this._gutterContainer.classList.toggle("has-decorations", this._decorati onsElement.hasChildNodes());
pfeldman 2015/09/17 00:06:18 Do this within setTitle and rename it?
samli 2015/09/17 18:08:04 Done.
1202 },
1203
1182 /** 1204 /**
1183 * @param {!Node} parentElement 1205 * @param {!Node} parentElement
1184 * @param {string} name 1206 * @param {string} name
1185 * @param {string} value 1207 * @param {string} value
1186 * @param {?WebInspector.ElementsTreeOutline.UpdateRecord} updateRecord 1208 * @param {?WebInspector.ElementsTreeOutline.UpdateRecord} updateRecord
1187 * @param {boolean=} forceValue 1209 * @param {boolean=} forceValue
1188 * @param {!WebInspector.DOMNode=} node 1210 * @param {!WebInspector.DOMNode=} node
1189 */ 1211 */
1190 _buildAttributeDOM: function(parentElement, name, value, updateRecord, force Value, node) 1212 _buildAttributeDOM: function(parentElement, name, value, updateRecord, force Value, node)
1191 { 1213 {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 /** 1546 /**
1525 * @param {string} initialValue 1547 * @param {string} initialValue
1526 * @param {string} value 1548 * @param {string} value
1527 */ 1549 */
1528 function commitChange(initialValue, value) 1550 function commitChange(initialValue, value)
1529 { 1551 {
1530 if (initialValue !== value) 1552 if (initialValue !== value)
1531 node.setOuterHTML(value, selectNode); 1553 node.setOuterHTML(value, selectNode);
1532 } 1554 }
1533 1555
1556 function disposeCallback()
1557 {
1558 if (callback)
1559 callback(false);
1560 }
1561
1534 var node = this._node; 1562 var node = this._node;
1535 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange)); 1563 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange, disp oseCallback));
1536 }, 1564 },
1537 1565
1538 _copyCSSPath: function() 1566 _copyCSSPath: function()
1539 { 1567 {
1540 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.cssPath (this._node, true)); 1568 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.cssPath (this._node, true));
1541 }, 1569 },
1542 1570
1543 _copyXPath: function() 1571 _copyXPath: function()
1544 { 1572 {
1545 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.xPath(t his._node, true)); 1573 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.xPath(t his._node, true));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 1612
1585 if (object) 1613 if (object)
1586 object.callFunction(scrollIntoView); 1614 object.callFunction(scrollIntoView);
1587 } 1615 }
1588 1616
1589 this._node.resolveToObject("", scrollIntoViewCallback); 1617 this._node.resolveToObject("", scrollIntoViewCallback);
1590 }, 1618 },
1591 1619
1592 __proto__: TreeElement.prototype 1620 __proto__: TreeElement.prototype
1593 } 1621 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698