| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 this._gutterContainer = this.listItemElement.createChild("div", "gutter-cont
ainer"); | 43 this._gutterContainer = this.listItemElement.createChild("div", "gutter-cont
ainer"); |
| 44 this._gutterContainer.addEventListener("click", this._showContextMenu.bind(t
his)); | 44 this._gutterContainer.addEventListener("click", this._showContextMenu.bind(t
his)); |
| 45 this._decorationsElement = this._gutterContainer.createChild("div", "hidden"
); | 45 this._decorationsElement = this._gutterContainer.createChild("div", "hidden"
); |
| 46 | 46 |
| 47 this._elementCloseTag = elementCloseTag; | 47 this._elementCloseTag = elementCloseTag; |
| 48 | 48 |
| 49 if (this._node.nodeType() === Node.ELEMENT_NODE && !elementCloseTag) | 49 if (this._node.nodeType() === Node.ELEMENT_NODE && !elementCloseTag) |
| 50 this._canAddAttributes = true; | 50 this._canAddAttributes = true; |
| 51 this._searchQuery = null; | 51 this._searchQuery = null; |
| 52 this._expandedChildrenLimit = WebInspector.ElementsTreeElement.InitialChildr
enLimit; | 52 this._expandedChildrenLimit = WebInspector.ElementsTreeElement.InitialChildr
enLimit; |
| 53 } | 53 }; |
| 54 | 54 |
| 55 WebInspector.ElementsTreeElement.InitialChildrenLimit = 500; | 55 WebInspector.ElementsTreeElement.InitialChildrenLimit = 500; |
| 56 | 56 |
| 57 // A union of HTML4 and HTML5-Draft elements that explicitly | 57 // A union of HTML4 and HTML5-Draft elements that explicitly |
| 58 // or implicitly (for HTML5) forbid the closing tag. | 58 // or implicitly (for HTML5) forbid the closing tag. |
| 59 WebInspector.ElementsTreeElement.ForbiddenClosingTagElements = new Set([ | 59 WebInspector.ElementsTreeElement.ForbiddenClosingTagElements = new Set([ |
| 60 "area", "base", "basefont", "br", "canvas", "col", "command", "embed", "fram
e", | 60 "area", "base", "basefont", "br", "canvas", "col", "command", "embed", "fram
e", |
| 61 "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source
", "track", "wbr" | 61 "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source
", "track", "wbr" |
| 62 ]); | 62 ]); |
| 63 | 63 |
| 64 // These tags we do not allow editing their tag name. | 64 // These tags we do not allow editing their tag name. |
| 65 WebInspector.ElementsTreeElement.EditTagBlacklist = new Set([ | 65 WebInspector.ElementsTreeElement.EditTagBlacklist = new Set([ |
| 66 "html", "head", "body" | 66 "html", "head", "body" |
| 67 ]); | 67 ]); |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * @param {!WebInspector.ElementsTreeElement} treeElement | 70 * @param {!WebInspector.ElementsTreeElement} treeElement |
| 71 */ | 71 */ |
| 72 WebInspector.ElementsTreeElement.animateOnDOMUpdate = function(treeElement) | 72 WebInspector.ElementsTreeElement.animateOnDOMUpdate = function(treeElement) |
| 73 { | 73 { |
| 74 var tagName = treeElement.listItemElement.querySelector(".webkit-html-tag-na
me"); | 74 var tagName = treeElement.listItemElement.querySelector(".webkit-html-tag-na
me"); |
| 75 WebInspector.runCSSAnimationOnce(tagName || treeElement.listItemElement, "do
m-update-highlight"); | 75 WebInspector.runCSSAnimationOnce(tagName || treeElement.listItemElement, "do
m-update-highlight"); |
| 76 } | 76 }; |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * @param {!WebInspector.DOMNode} node | 79 * @param {!WebInspector.DOMNode} node |
| 80 * @return {!Array<!WebInspector.DOMNode>} | 80 * @return {!Array<!WebInspector.DOMNode>} |
| 81 */ | 81 */ |
| 82 WebInspector.ElementsTreeElement.visibleShadowRoots = function(node) | 82 WebInspector.ElementsTreeElement.visibleShadowRoots = function(node) |
| 83 { | 83 { |
| 84 var roots = node.shadowRoots(); | 84 var roots = node.shadowRoots(); |
| 85 if (roots.length && !WebInspector.moduleSetting("showUAShadowDOM").get()) | 85 if (roots.length && !WebInspector.moduleSetting("showUAShadowDOM").get()) |
| 86 roots = roots.filter(filter); | 86 roots = roots.filter(filter); |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * @param {!WebInspector.DOMNode} root | 89 * @param {!WebInspector.DOMNode} root |
| 90 */ | 90 */ |
| 91 function filter(root) | 91 function filter(root) |
| 92 { | 92 { |
| 93 return root.shadowRootType() !== WebInspector.DOMNode.ShadowRootTypes.Us
erAgent; | 93 return root.shadowRootType() !== WebInspector.DOMNode.ShadowRootTypes.Us
erAgent; |
| 94 } | 94 } |
| 95 return roots; | 95 return roots; |
| 96 } | 96 }; |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * @param {!WebInspector.DOMNode} node | 99 * @param {!WebInspector.DOMNode} node |
| 100 * @return {boolean} | 100 * @return {boolean} |
| 101 */ | 101 */ |
| 102 WebInspector.ElementsTreeElement.canShowInlineText = function(node) | 102 WebInspector.ElementsTreeElement.canShowInlineText = function(node) |
| 103 { | 103 { |
| 104 if (node.importedDocument() || node.templateContent() || WebInspector.Elemen
tsTreeElement.visibleShadowRoots(node).length || node.hasPseudoElements()) | 104 if (node.importedDocument() || node.templateContent() || WebInspector.Elemen
tsTreeElement.visibleShadowRoots(node).length || node.hasPseudoElements()) |
| 105 return false; | 105 return false; |
| 106 if (node.nodeType() !== Node.ELEMENT_NODE) | 106 if (node.nodeType() !== Node.ELEMENT_NODE) |
| 107 return false; | 107 return false; |
| 108 if (!node.firstChild || node.firstChild !== node.lastChild || node.firstChil
d.nodeType() !== Node.TEXT_NODE) | 108 if (!node.firstChild || node.firstChild !== node.lastChild || node.firstChil
d.nodeType() !== Node.TEXT_NODE) |
| 109 return false; | 109 return false; |
| 110 var textChild = node.firstChild; | 110 var textChild = node.firstChild; |
| 111 var maxInlineTextChildLength = 80; | 111 var maxInlineTextChildLength = 80; |
| 112 if (textChild.nodeValue().length < maxInlineTextChildLength) | 112 if (textChild.nodeValue().length < maxInlineTextChildLength) |
| 113 return true; | 113 return true; |
| 114 return false; | 114 return false; |
| 115 } | 115 }; |
| 116 | 116 |
| 117 /** | 117 /** |
| 118 * @param {!WebInspector.ContextSubMenuItem} subMenu | 118 * @param {!WebInspector.ContextSubMenuItem} subMenu |
| 119 * @param {!WebInspector.DOMNode} node | 119 * @param {!WebInspector.DOMNode} node |
| 120 */ | 120 */ |
| 121 WebInspector.ElementsTreeElement.populateForcedPseudoStateItems = function(subMe
nu, node) | 121 WebInspector.ElementsTreeElement.populateForcedPseudoStateItems = function(subMe
nu, node) |
| 122 { | 122 { |
| 123 const pseudoClasses = ["active", "hover", "focus", "visited"]; | 123 const pseudoClasses = ["active", "hover", "focus", "visited"]; |
| 124 var forcedPseudoState = WebInspector.CSSModel.fromNode(node).pseudoState(nod
e); | 124 var forcedPseudoState = WebInspector.CSSModel.fromNode(node).pseudoState(nod
e); |
| 125 for (var i = 0; i < pseudoClasses.length; ++i) { | 125 for (var i = 0; i < pseudoClasses.length; ++i) { |
| 126 var pseudoClassForced = forcedPseudoState.indexOf(pseudoClasses[i]) >= 0
; | 126 var pseudoClassForced = forcedPseudoState.indexOf(pseudoClasses[i]) >= 0
; |
| 127 subMenu.appendCheckboxItem(":" + pseudoClasses[i], setPseudoStateCallbac
k.bind(null, pseudoClasses[i], !pseudoClassForced), pseudoClassForced, false); | 127 subMenu.appendCheckboxItem(":" + pseudoClasses[i], setPseudoStateCallbac
k.bind(null, pseudoClasses[i], !pseudoClassForced), pseudoClassForced, false); |
| 128 } | 128 } |
| 129 | 129 |
| 130 /** | 130 /** |
| 131 * @param {string} pseudoState | 131 * @param {string} pseudoState |
| 132 * @param {boolean} enabled | 132 * @param {boolean} enabled |
| 133 */ | 133 */ |
| 134 function setPseudoStateCallback(pseudoState, enabled) | 134 function setPseudoStateCallback(pseudoState, enabled) |
| 135 { | 135 { |
| 136 WebInspector.CSSModel.fromNode(node).forcePseudoState(node, pseudoState,
enabled); | 136 WebInspector.CSSModel.fromNode(node).forcePseudoState(node, pseudoState,
enabled); |
| 137 } | 137 } |
| 138 } | 138 }; |
| 139 | 139 |
| 140 WebInspector.ElementsTreeElement.prototype = { | 140 WebInspector.ElementsTreeElement.prototype = { |
| 141 /** | 141 /** |
| 142 * @return {boolean} | 142 * @return {boolean} |
| 143 */ | 143 */ |
| 144 isClosingTag: function() | 144 isClosingTag: function() |
| 145 { | 145 { |
| 146 return !!this._elementCloseTag; | 146 return !!this._elementCloseTag; |
| 147 }, | 147 }, |
| 148 | 148 |
| (...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 this._node.resolveToObject("", scrollIntoViewCallback); | 1634 this._node.resolveToObject("", scrollIntoViewCallback); |
| 1635 }, | 1635 }, |
| 1636 | 1636 |
| 1637 _editAsHTML: function() | 1637 _editAsHTML: function() |
| 1638 { | 1638 { |
| 1639 var promise = WebInspector.Revealer.revealPromise(this.node()); | 1639 var promise = WebInspector.Revealer.revealPromise(this.node()); |
| 1640 promise.then(() => WebInspector.actionRegistry.action("elements.edit-as-
html").execute()); | 1640 promise.then(() => WebInspector.actionRegistry.action("elements.edit-as-
html").execute()); |
| 1641 }, | 1641 }, |
| 1642 | 1642 |
| 1643 __proto__: TreeElement.prototype | 1643 __proto__: TreeElement.prototype |
| 1644 } | 1644 }; |
| OLD | NEW |