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 22 matching lines...) Expand all Loading... |
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 | 45 |
46 this._elementCloseTag = elementCloseTag; | 46 this._elementCloseTag = elementCloseTag; |
47 | 47 |
48 if (this._node.nodeType() == Node.ELEMENT_NODE && !elementCloseTag) | 48 if (this._node.nodeType() == Node.ELEMENT_NODE && !elementCloseTag) |
49 this._canAddAttributes = true; | 49 this._canAddAttributes = true; |
50 this._searchQuery = null; | 50 this._searchQuery = null; |
51 this._expandedChildrenLimit = WebInspector.ElementsTreeElement.InitialChildr
enLimit; | 51 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) | 52 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); | 53 this.setCollapsible(false); |
54 } | 54 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 /** | 158 /** |
159 * @return {boolean} | 159 * @return {boolean} |
160 */ | 160 */ |
161 isEditing: function() | 161 isEditing: function() |
162 { | 162 { |
163 return !!this._editing; | 163 return !!this._editing; |
164 }, | 164 }, |
165 | 165 |
166 /** | 166 /** |
| 167 * @return {!Element} |
| 168 */ |
| 169 gutterElement: function() |
| 170 { |
| 171 return this._gutterContainer; |
| 172 }, |
| 173 |
| 174 /** |
167 * @param {string} searchQuery | 175 * @param {string} searchQuery |
168 */ | 176 */ |
169 highlightSearchResults: function(searchQuery) | 177 highlightSearchResults: function(searchQuery) |
170 { | 178 { |
171 if (this._searchQuery !== searchQuery) | 179 if (this._searchQuery !== searchQuery) |
172 this._hideSearchHighlight(); | 180 this._hideSearchHighlight(); |
173 | 181 |
174 this._searchQuery = searchQuery; | 182 this._searchQuery = searchQuery; |
175 this._searchHighlightsVisible = true; | 183 this._searchHighlightsVisible = true; |
176 this.updateTitle(null, true); | 184 this.updateTitle(null, true); |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 tagNameElement.addEventListener('keyup', keyupListener, false); | 773 tagNameElement.addEventListener('keyup', keyupListener, false); |
766 | 774 |
767 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind(
this), editingCancelled.bind(this), tagName); | 775 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind(
this), editingCancelled.bind(this), tagName); |
768 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement,
config); | 776 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement,
config); |
769 this.listItemElement.getComponentSelection().setBaseAndExtent(tagNameEle
ment, 0, tagNameElement, 1); | 777 this.listItemElement.getComponentSelection().setBaseAndExtent(tagNameEle
ment, 0, tagNameElement, 1); |
770 return true; | 778 return true; |
771 }, | 779 }, |
772 | 780 |
773 /** | 781 /** |
774 * @param {function(string, string)} commitCallback | 782 * @param {function(string, string)} commitCallback |
| 783 * @param {function()} disposeCallback |
775 * @param {?Protocol.Error} error | 784 * @param {?Protocol.Error} error |
776 * @param {string} initialValue | 785 * @param {string} initialValue |
777 */ | 786 */ |
778 _startEditingAsHTML: function(commitCallback, error, initialValue) | 787 _startEditingAsHTML: function(commitCallback, disposeCallback, error, initia
lValue) |
779 { | 788 { |
780 if (error) | 789 if (error) |
781 return; | 790 return; |
782 if (this._editing) | 791 if (this._editing) |
783 return; | 792 return; |
784 | 793 |
785 function consume(event) | 794 function consume(event) |
786 { | 795 { |
787 if (event.eventPhase === Event.AT_TARGET) | 796 if (event.eventPhase === Event.AT_TARGET) |
788 event.consume(true); | 797 event.consume(true); |
(...skipping 28 matching lines...) Expand all Loading... |
817 { | 826 { |
818 commitCallback(initialValue, newValue); | 827 commitCallback(initialValue, newValue); |
819 dispose.call(this); | 828 dispose.call(this); |
820 } | 829 } |
821 | 830 |
822 /** | 831 /** |
823 * @this {WebInspector.ElementsTreeElement} | 832 * @this {WebInspector.ElementsTreeElement} |
824 */ | 833 */ |
825 function dispose() | 834 function dispose() |
826 { | 835 { |
| 836 disposeCallback(); |
827 delete this._editing; | 837 delete this._editing; |
828 this.treeOutline.setMultilineEditing(null); | 838 this.treeOutline.setMultilineEditing(null); |
829 | 839 |
830 // Remove editor. | 840 // Remove editor. |
831 this.listItemElement.removeChild(this._htmlEditElement); | 841 this.listItemElement.removeChild(this._htmlEditElement); |
832 delete this._htmlEditElement; | 842 delete this._htmlEditElement; |
833 // Unhide children item. | 843 // Unhide children item. |
834 if (this._childrenListNode) | 844 if (this._childrenListNode) |
835 this._childrenListNode.style.removeProperty("display"); | 845 this._childrenListNode.style.removeProperty("display"); |
836 // Unhide header items. | 846 // Unhide header items. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 if (!depth) | 1070 if (!depth) |
1061 this.childrenListElement.classList.add("shadow-root-deep"); | 1071 this.childrenListElement.classList.add("shadow-root-deep"); |
1062 else | 1072 else |
1063 this.childrenListElement.classList.add("shadow-root-depth-"
+ depth); | 1073 this.childrenListElement.classList.add("shadow-root-depth-"
+ depth); |
1064 } | 1074 } |
1065 var highlightElement = createElement("span"); | 1075 var highlightElement = createElement("span"); |
1066 highlightElement.className = "highlight"; | 1076 highlightElement.className = "highlight"; |
1067 highlightElement.appendChild(nodeInfo); | 1077 highlightElement.appendChild(nodeInfo); |
1068 this.title = highlightElement; | 1078 this.title = highlightElement; |
1069 this.updateDecorations(); | 1079 this.updateDecorations(); |
1070 this.listItemElement.insertBefore(this._decorationsElement, this.lis
tItemElement.firstChild); | 1080 this.listItemElement.insertBefore(this._gutterContainer, this.listIt
emElement.firstChild); |
1071 delete this._highlightResult; | 1081 delete this._highlightResult; |
1072 } | 1082 } |
1073 | 1083 |
1074 delete this.selectionElement; | 1084 delete this.selectionElement; |
1075 if (this.selected) | 1085 if (this.selected) |
1076 this.updateSelection(); | 1086 this.updateSelection(); |
1077 this._preventFollowingLinksOnDoubleClick(); | 1087 this._preventFollowingLinksOnDoubleClick(); |
1078 this._highlightSearchResults(); | 1088 this._highlightSearchResults(); |
1079 }, | 1089 }, |
1080 | 1090 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 * @param {!WebInspector.DOMPresentationUtils.MarkerDecorator} decorator | 1123 * @param {!WebInspector.DOMPresentationUtils.MarkerDecorator} decorator |
1114 */ | 1124 */ |
1115 function collectDecoration(n, decorator) | 1125 function collectDecoration(n, decorator) |
1116 { | 1126 { |
1117 var decoration = decorator.decorate(n); | 1127 var decoration = decorator.decorate(n); |
1118 if (!decoration) | 1128 if (!decoration) |
1119 return; | 1129 return; |
1120 (n === node ? decorations : descendantDecorations).push(decoration); | 1130 (n === node ? decorations : descendantDecorations).push(decoration); |
1121 } | 1131 } |
1122 | 1132 |
1123 Promise.all(promises).then(setTitle.bind(this)); | 1133 Promise.all(promises).then(setTitle.bind(this)).then(this._updateGutter.
bind(this)); |
1124 | 1134 |
1125 /** | 1135 /** |
1126 * @this {WebInspector.ElementsTreeElement} | 1136 * @this {WebInspector.ElementsTreeElement} |
1127 */ | 1137 */ |
1128 function setTitle() | 1138 function setTitle() |
1129 { | 1139 { |
1130 this._decorationsElement.removeChildren(); | 1140 this._decorationsElement.removeChildren(); |
1131 this._decorationsElement.classList.add("hidden"); | 1141 this._decorationsElement.classList.add("hidden"); |
1132 if (!decorations.length && !descendantDecorations.length) | 1142 if (!decorations.length && !descendantDecorations.length) |
1133 return; | 1143 return; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 child.style.backgroundColor = color; | 1184 child.style.backgroundColor = color; |
1175 child.style.borderColor = color; | 1185 child.style.borderColor = color; |
1176 if (offset) | 1186 if (offset) |
1177 child.style.marginLeft = offset + "px"; | 1187 child.style.marginLeft = offset + "px"; |
1178 offset += 3; | 1188 offset += 3; |
1179 } | 1189 } |
1180 } | 1190 } |
1181 } | 1191 } |
1182 }, | 1192 }, |
1183 | 1193 |
| 1194 _updateGutter: function() |
| 1195 { |
| 1196 this._gutterContainer.classList.toggle("has-decorations", this._decorati
onsElement.hasChildNodes()); |
| 1197 }, |
| 1198 |
1184 /** | 1199 /** |
1185 * @param {!Node} parentElement | 1200 * @param {!Node} parentElement |
1186 * @param {string} name | 1201 * @param {string} name |
1187 * @param {string} value | 1202 * @param {string} value |
1188 * @param {?WebInspector.ElementsTreeOutline.UpdateRecord} updateRecord | 1203 * @param {?WebInspector.ElementsTreeOutline.UpdateRecord} updateRecord |
1189 * @param {boolean=} forceValue | 1204 * @param {boolean=} forceValue |
1190 * @param {!WebInspector.DOMNode=} node | 1205 * @param {!WebInspector.DOMNode=} node |
1191 */ | 1206 */ |
1192 _buildAttributeDOM: function(parentElement, name, value, updateRecord, force
Value, node) | 1207 _buildAttributeDOM: function(parentElement, name, value, updateRecord, force
Value, node) |
1193 { | 1208 { |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 /** | 1541 /** |
1527 * @param {string} initialValue | 1542 * @param {string} initialValue |
1528 * @param {string} value | 1543 * @param {string} value |
1529 */ | 1544 */ |
1530 function commitChange(initialValue, value) | 1545 function commitChange(initialValue, value) |
1531 { | 1546 { |
1532 if (initialValue !== value) | 1547 if (initialValue !== value) |
1533 node.setOuterHTML(value, selectNode); | 1548 node.setOuterHTML(value, selectNode); |
1534 } | 1549 } |
1535 | 1550 |
| 1551 function disposeCallback() |
| 1552 { |
| 1553 if (callback) |
| 1554 callback(false); |
| 1555 } |
| 1556 |
1536 var node = this._node; | 1557 var node = this._node; |
1537 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange)); | 1558 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange, disp
oseCallback)); |
1538 }, | 1559 }, |
1539 | 1560 |
1540 _copyCSSPath: function() | 1561 _copyCSSPath: function() |
1541 { | 1562 { |
1542 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.cssPath
(this._node, true)); | 1563 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.cssPath
(this._node, true)); |
1543 }, | 1564 }, |
1544 | 1565 |
1545 _copyXPath: function() | 1566 _copyXPath: function() |
1546 { | 1567 { |
1547 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.xPath(t
his._node, true)); | 1568 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.xPath(t
his._node, true)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 | 1607 |
1587 if (object) | 1608 if (object) |
1588 object.callFunction(scrollIntoView); | 1609 object.callFunction(scrollIntoView); |
1589 } | 1610 } |
1590 | 1611 |
1591 this._node.resolveToObject("", scrollIntoViewCallback); | 1612 this._node.resolveToObject("", scrollIntoViewCallback); |
1592 }, | 1613 }, |
1593 | 1614 |
1594 __proto__: TreeElement.prototype | 1615 __proto__: TreeElement.prototype |
1595 } | 1616 } |
OLD | NEW |