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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 var listItemElement = this.listItemElement; | 259 var listItemElement = this.listItemElement; |
260 if (!listItemElement) | 260 if (!listItemElement) |
261 return; | 261 return; |
262 | 262 |
263 if (!this.selectionElement) { | 263 if (!this.selectionElement) { |
264 this.selectionElement = createElement("div"); | 264 this.selectionElement = createElement("div"); |
265 this.selectionElement.className = "selection selected"; | 265 this.selectionElement.className = "selection selected"; |
266 listItemElement.insertBefore(this.selectionElement, listItemElement.
firstChild); | 266 listItemElement.insertBefore(this.selectionElement, listItemElement.
firstChild); |
267 } | 267 } |
268 | 268 |
| 269 this._updateActionsToolbar(); |
269 this.selectionElement.style.height = listItemElement.offsetHeight + "px"
; | 270 this.selectionElement.style.height = listItemElement.offsetHeight + "px"
; |
270 }, | 271 }, |
271 | 272 |
| 273 _updateActionsToolbar: function() |
| 274 { |
| 275 if (!Runtime.experiments.isEnabled("materialDesign")) |
| 276 return; |
| 277 var actionsToolbar = this.treeOutline.nodeActionsElement(); |
| 278 if (this.selected && this._node.nodeType() === Node.ELEMENT_NODE && acti
onsToolbar.parentElement !== this.listItemElement) { |
| 279 this.listItemElement.insertBefore(actionsToolbar, this.selectionElem
ent.nextSibling); |
| 280 delete this._forceShowActions; |
| 281 } |
| 282 |
| 283 if (actionsToolbar.parentElement === this.listItemElement) { |
| 284 actionsToolbar.classList.toggle("markers-present", this._decorations
Element.hasChildNodes()); |
| 285 if (!this.treeOutline.nodeActionsVisible() && this._decorationsEleme
nt.hasChildNodes()) { |
| 286 this.treeOutline.toggleNodeActions(true); |
| 287 this._forceShowActions = true; |
| 288 } |
| 289 } |
| 290 }, |
| 291 |
272 /** | 292 /** |
273 * @override | 293 * @override |
274 */ | 294 */ |
275 onbind: function() | 295 onbind: function() |
276 { | 296 { |
277 if (!this._elementCloseTag) | 297 if (!this._elementCloseTag) |
278 this._node[this.treeOutline.treeElementSymbol()] = this; | 298 this._node[this.treeOutline.treeElementSymbol()] = this; |
279 }, | 299 }, |
280 | 300 |
281 /** | 301 /** |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 tagNameElement.addEventListener('keyup', keyupListener, false); | 785 tagNameElement.addEventListener('keyup', keyupListener, false); |
766 | 786 |
767 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind(
this), editingCancelled.bind(this), tagName); | 787 var config = new WebInspector.InplaceEditor.Config(editingComitted.bind(
this), editingCancelled.bind(this), tagName); |
768 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement,
config); | 788 this._editing = WebInspector.InplaceEditor.startEditing(tagNameElement,
config); |
769 this.listItemElement.getComponentSelection().setBaseAndExtent(tagNameEle
ment, 0, tagNameElement, 1); | 789 this.listItemElement.getComponentSelection().setBaseAndExtent(tagNameEle
ment, 0, tagNameElement, 1); |
770 return true; | 790 return true; |
771 }, | 791 }, |
772 | 792 |
773 /** | 793 /** |
774 * @param {function(string, string)} commitCallback | 794 * @param {function(string, string)} commitCallback |
| 795 * @param {function()} disposeCallback |
775 * @param {?Protocol.Error} error | 796 * @param {?Protocol.Error} error |
776 * @param {string} initialValue | 797 * @param {string} initialValue |
777 */ | 798 */ |
778 _startEditingAsHTML: function(commitCallback, error, initialValue) | 799 _startEditingAsHTML: function(commitCallback, disposeCallback, error, initia
lValue) |
779 { | 800 { |
780 if (error) | 801 if (error) |
781 return; | 802 return; |
782 if (this._editing) | 803 if (this._editing) |
783 return; | 804 return; |
784 | 805 |
785 function consume(event) | 806 function consume(event) |
786 { | 807 { |
787 if (event.eventPhase === Event.AT_TARGET) | 808 if (event.eventPhase === Event.AT_TARGET) |
788 event.consume(true); | 809 event.consume(true); |
(...skipping 28 matching lines...) Expand all Loading... |
817 { | 838 { |
818 commitCallback(initialValue, newValue); | 839 commitCallback(initialValue, newValue); |
819 dispose.call(this); | 840 dispose.call(this); |
820 } | 841 } |
821 | 842 |
822 /** | 843 /** |
823 * @this {WebInspector.ElementsTreeElement} | 844 * @this {WebInspector.ElementsTreeElement} |
824 */ | 845 */ |
825 function dispose() | 846 function dispose() |
826 { | 847 { |
| 848 disposeCallback(); |
827 delete this._editing; | 849 delete this._editing; |
828 this.treeOutline.setMultilineEditing(null); | 850 this.treeOutline.setMultilineEditing(null); |
829 | 851 |
830 // Remove editor. | 852 // Remove editor. |
831 this.listItemElement.removeChild(this._htmlEditElement); | 853 this.listItemElement.removeChild(this._htmlEditElement); |
832 delete this._htmlEditElement; | 854 delete this._htmlEditElement; |
833 // Unhide children item. | 855 // Unhide children item. |
834 if (this._childrenListNode) | 856 if (this._childrenListNode) |
835 this._childrenListNode.style.removeProperty("display"); | 857 this._childrenListNode.style.removeProperty("display"); |
836 // Unhide header items. | 858 // Unhide header items. |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 * @param {!WebInspector.DOMPresentationUtils.MarkerDecorator} decorator | 1135 * @param {!WebInspector.DOMPresentationUtils.MarkerDecorator} decorator |
1114 */ | 1136 */ |
1115 function collectDecoration(n, decorator) | 1137 function collectDecoration(n, decorator) |
1116 { | 1138 { |
1117 var decoration = decorator.decorate(n); | 1139 var decoration = decorator.decorate(n); |
1118 if (!decoration) | 1140 if (!decoration) |
1119 return; | 1141 return; |
1120 (n === node ? decorations : descendantDecorations).push(decoration); | 1142 (n === node ? decorations : descendantDecorations).push(decoration); |
1121 } | 1143 } |
1122 | 1144 |
1123 Promise.all(promises).then(setTitle.bind(this)); | 1145 Promise.all(promises).then(setTitle.bind(this)).then(this._updateActions
Toolbar.bind(this)); |
1124 | 1146 |
1125 /** | 1147 /** |
1126 * @this {WebInspector.ElementsTreeElement} | 1148 * @this {WebInspector.ElementsTreeElement} |
1127 */ | 1149 */ |
1128 function setTitle() | 1150 function setTitle() |
1129 { | 1151 { |
1130 this._decorationsElement.removeChildren(); | 1152 this._decorationsElement.removeChildren(); |
1131 this._decorationsElement.classList.add("hidden"); | 1153 this._decorationsElement.classList.add("hidden"); |
1132 if (!decorations.length && !descendantDecorations.length) | 1154 if (!decorations.length && !descendantDecorations.length) |
1133 return; | 1155 return; |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 /** | 1548 /** |
1527 * @param {string} initialValue | 1549 * @param {string} initialValue |
1528 * @param {string} value | 1550 * @param {string} value |
1529 */ | 1551 */ |
1530 function commitChange(initialValue, value) | 1552 function commitChange(initialValue, value) |
1531 { | 1553 { |
1532 if (initialValue !== value) | 1554 if (initialValue !== value) |
1533 node.setOuterHTML(value, selectNode); | 1555 node.setOuterHTML(value, selectNode); |
1534 } | 1556 } |
1535 | 1557 |
| 1558 function disposeCallback() |
| 1559 { |
| 1560 if (callback) |
| 1561 callback(false); |
| 1562 } |
| 1563 |
1536 var node = this._node; | 1564 var node = this._node; |
1537 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange)); | 1565 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange, disp
oseCallback)); |
1538 }, | 1566 }, |
1539 | 1567 |
1540 _copyCSSPath: function() | 1568 _copyCSSPath: function() |
1541 { | 1569 { |
1542 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.cssPath
(this._node, true)); | 1570 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.cssPath
(this._node, true)); |
1543 }, | 1571 }, |
1544 | 1572 |
1545 _copyXPath: function() | 1573 _copyXPath: function() |
1546 { | 1574 { |
1547 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.xPath(t
his._node, true)); | 1575 InspectorFrontendHost.copyText(WebInspector.DOMPresentationUtils.xPath(t
his._node, true)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 | 1614 |
1587 if (object) | 1615 if (object) |
1588 object.callFunction(scrollIntoView); | 1616 object.callFunction(scrollIntoView); |
1589 } | 1617 } |
1590 | 1618 |
1591 this._node.resolveToObject("", scrollIntoViewCallback); | 1619 this._node.resolveToObject("", scrollIntoViewCallback); |
1592 }, | 1620 }, |
1593 | 1621 |
1594 __proto__: TreeElement.prototype | 1622 __proto__: TreeElement.prototype |
1595 } | 1623 } |
OLD | NEW |