| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 return; | 232 return; |
| 233 | 233 |
| 234 if (!this.selectionElement) { | 234 if (!this.selectionElement) { |
| 235 this.selectionElement = createElement('div'); | 235 this.selectionElement = createElement('div'); |
| 236 this.selectionElement.className = 'selection fill'; | 236 this.selectionElement.className = 'selection fill'; |
| 237 this.selectionElement.style.setProperty('margin-left', (-this._computeLeft
Indent()) + 'px'); | 237 this.selectionElement.style.setProperty('margin-left', (-this._computeLeft
Indent()) + 'px'); |
| 238 listItemElement.insertBefore(this.selectionElement, listItemElement.firstC
hild); | 238 listItemElement.insertBefore(this.selectionElement, listItemElement.firstC
hild); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 _createHint() { |
| 243 if (this.listItemElement && !this._hintElement) { |
| 244 this._hintElement = this.listItemElement.createChild('span', 'selected-hin
t'); |
| 245 this._hintElement.title = Common.UIString('Use $0 in the console to refer
to this element.'); |
| 246 } |
| 247 } |
| 248 |
| 242 /** | 249 /** |
| 243 * @override | 250 * @override |
| 244 */ | 251 */ |
| 245 onbind() { | 252 onbind() { |
| 246 if (!this._elementCloseTag) | 253 if (!this._elementCloseTag) |
| 247 this._node[this.treeOutline.treeElementSymbol()] = this; | 254 this._node[this.treeOutline.treeElementSymbol()] = this; |
| 248 } | 255 } |
| 249 | 256 |
| 250 /** | 257 /** |
| 251 * @override | 258 * @override |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 * @return {boolean} | 328 * @return {boolean} |
| 322 */ | 329 */ |
| 323 onselect(selectedByUser) { | 330 onselect(selectedByUser) { |
| 324 this.treeOutline.suppressRevealAndSelect = true; | 331 this.treeOutline.suppressRevealAndSelect = true; |
| 325 this.treeOutline.selectDOMNode(this._node, selectedByUser); | 332 this.treeOutline.selectDOMNode(this._node, selectedByUser); |
| 326 if (selectedByUser) { | 333 if (selectedByUser) { |
| 327 this._node.highlight(); | 334 this._node.highlight(); |
| 328 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ChangeInspectedNodeIn
ElementsPanel); | 335 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ChangeInspectedNodeIn
ElementsPanel); |
| 329 } | 336 } |
| 330 this._createSelection(); | 337 this._createSelection(); |
| 338 this._createHint(); |
| 331 this.treeOutline.suppressRevealAndSelect = false; | 339 this.treeOutline.suppressRevealAndSelect = false; |
| 332 return true; | 340 return true; |
| 333 } | 341 } |
| 334 | 342 |
| 335 /** | 343 /** |
| 336 * @override | 344 * @override |
| 337 * @return {boolean} | 345 * @return {boolean} |
| 338 */ | 346 */ |
| 339 ondelete() { | 347 ondelete() { |
| 340 var startTagTreeElement = this.treeOutline.findTreeElement(this._node); | 348 var startTagTreeElement = this.treeOutline.findTreeElement(this._node); |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 var child = this.listItemElement.firstChild; | 757 var child = this.listItemElement.firstChild; |
| 750 while (child) { | 758 while (child) { |
| 751 child.style.display = 'none'; | 759 child.style.display = 'none'; |
| 752 child = child.nextSibling; | 760 child = child.nextSibling; |
| 753 } | 761 } |
| 754 // Hide children item. | 762 // Hide children item. |
| 755 if (this.childrenListElement) | 763 if (this.childrenListElement) |
| 756 this.childrenListElement.style.display = 'none'; | 764 this.childrenListElement.style.display = 'none'; |
| 757 // Append editor. | 765 // Append editor. |
| 758 this.listItemElement.appendChild(this._htmlEditElement); | 766 this.listItemElement.appendChild(this._htmlEditElement); |
| 759 this.listItemElement.classList.add('editing-as-html'); | |
| 760 this.treeOutline.element.addEventListener('mousedown', consume, false); | 767 this.treeOutline.element.addEventListener('mousedown', consume, false); |
| 761 | 768 |
| 762 self.runtime.extension(UI.TextEditorFactory).instance().then(gotFactory.bind
(this)); | 769 self.runtime.extension(UI.TextEditorFactory).instance().then(gotFactory.bind
(this)); |
| 763 | 770 |
| 764 /** | 771 /** |
| 765 * @param {!UI.TextEditorFactory} factory | 772 * @param {!UI.TextEditorFactory} factory |
| 766 * @this {Elements.ElementsTreeElement} | 773 * @this {Elements.ElementsTreeElement} |
| 767 */ | 774 */ |
| 768 function gotFactory(factory) { | 775 function gotFactory(factory) { |
| 769 var editor = factory.createEditor({ | 776 var editor = factory.createEditor({ |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 } | 810 } |
| 804 | 811 |
| 805 /** | 812 /** |
| 806 * @this {Elements.ElementsTreeElement} | 813 * @this {Elements.ElementsTreeElement} |
| 807 */ | 814 */ |
| 808 function dispose() { | 815 function dispose() { |
| 809 this._editing.editor.widget().element.removeEventListener('blur', this._ed
iting.commit, true); | 816 this._editing.editor.widget().element.removeEventListener('blur', this._ed
iting.commit, true); |
| 810 this._editing.editor.widget().detach(); | 817 this._editing.editor.widget().detach(); |
| 811 delete this._editing; | 818 delete this._editing; |
| 812 | 819 |
| 813 this.listItemElement.classList.remove('editing-as-html'); | |
| 814 // Remove editor. | 820 // Remove editor. |
| 815 this.listItemElement.removeChild(this._htmlEditElement); | 821 this.listItemElement.removeChild(this._htmlEditElement); |
| 816 delete this._htmlEditElement; | 822 delete this._htmlEditElement; |
| 817 // Unhide children item. | 823 // Unhide children item. |
| 818 if (this.childrenListElement) | 824 if (this.childrenListElement) |
| 819 this.childrenListElement.style.removeProperty('display'); | 825 this.childrenListElement.style.removeProperty('display'); |
| 820 // Unhide header items. | 826 // Unhide header items. |
| 821 var child = this.listItemElement.firstChild; | 827 var child = this.listItemElement.firstChild; |
| 822 while (child) { | 828 while (child) { |
| 823 child.style.removeProperty('display'); | 829 child.style.removeProperty('display'); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 else | 1047 else |
| 1042 this.childrenListElement.classList.add('shadow-root-depth-' + depth); | 1048 this.childrenListElement.classList.add('shadow-root-depth-' + depth); |
| 1043 } | 1049 } |
| 1044 var highlightElement = createElement('span'); | 1050 var highlightElement = createElement('span'); |
| 1045 highlightElement.className = 'highlight'; | 1051 highlightElement.className = 'highlight'; |
| 1046 highlightElement.appendChild(nodeInfo); | 1052 highlightElement.appendChild(nodeInfo); |
| 1047 this.title = highlightElement; | 1053 this.title = highlightElement; |
| 1048 this.updateDecorations(); | 1054 this.updateDecorations(); |
| 1049 this.listItemElement.insertBefore(this._gutterContainer, this.listItemElem
ent.firstChild); | 1055 this.listItemElement.insertBefore(this._gutterContainer, this.listItemElem
ent.firstChild); |
| 1050 delete this._highlightResult; | 1056 delete this._highlightResult; |
| 1057 delete this.selectionElement; |
| 1058 delete this._hintElement; |
| 1059 if (this.selected) { |
| 1060 this._createSelection(); |
| 1061 this._createHint(); |
| 1062 } |
| 1051 } | 1063 } |
| 1052 | 1064 |
| 1053 delete this.selectionElement; | |
| 1054 if (this.selected) | |
| 1055 this._createSelection(); | |
| 1056 this._highlightSearchResults(); | 1065 this._highlightSearchResults(); |
| 1057 } | 1066 } |
| 1058 | 1067 |
| 1059 /** | 1068 /** |
| 1060 * @return {number} | 1069 * @return {number} |
| 1061 */ | 1070 */ |
| 1062 _computeLeftIndent() { | 1071 _computeLeftIndent() { |
| 1063 var treeElement = this.parent; | 1072 var treeElement = this.parent; |
| 1064 var depth = 0; | 1073 var depth = 0; |
| 1065 while (treeElement !== null) { | 1074 while (treeElement !== null) { |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 Elements.ElementsTreeElement.ForbiddenClosingTagElements = new Set([ | 1618 Elements.ElementsTreeElement.ForbiddenClosingTagElements = new Set([ |
| 1610 'area', 'base', 'basefont', 'br', 'canvas', 'col', 'command', 'embed',
'frame', 'hr', | 1619 'area', 'base', 'basefont', 'br', 'canvas', 'col', 'command', 'embed',
'frame', 'hr', |
| 1611 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source',
'track', 'wbr' | 1620 'img', 'input', 'keygen', 'link', 'menuitem', 'meta', 'param', 'source',
'track', 'wbr' |
| 1612 ]); | 1621 ]); |
| 1613 | 1622 |
| 1614 // These tags we do not allow editing their tag name. | 1623 // These tags we do not allow editing their tag name. |
| 1615 Elements.ElementsTreeElement.EditTagBlacklist = new Set(['html', 'head', 'body']
); | 1624 Elements.ElementsTreeElement.EditTagBlacklist = new Set(['html', 'head', 'body']
); |
| 1616 | 1625 |
| 1617 /** @typedef {{cancel: function(), commit: function(), resize: function(), edito
r:!UI.TextEditor}} */ | 1626 /** @typedef {{cancel: function(), commit: function(), resize: function(), edito
r:!UI.TextEditor}} */ |
| 1618 Elements.MultilineEditorController; | 1627 Elements.MultilineEditorController; |
| OLD | NEW |