| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 4 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
| 5 * Copyright (C) 2009 Joseph Pecoraro | 5 * Copyright (C) 2009 Joseph Pecoraro |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * | 10 * |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 WebInspector.DOMPresentationUtils = {} | 32 WebInspector.DOMPresentationUtils = {} |
| 33 | 33 |
| 34 /** |
| 35 * @param {!WebInspector.DOMNode} node |
| 36 * @param {!Element} parentElement |
| 37 */ |
| 34 WebInspector.DOMPresentationUtils.decorateNodeLabel = function(node, parentEleme
nt) | 38 WebInspector.DOMPresentationUtils.decorateNodeLabel = function(node, parentEleme
nt) |
| 35 { | 39 { |
| 40 var originalNode = node; |
| 41 var isPseudo = node.nodeType() === Node.ELEMENT_NODE && node.pseudoType(); |
| 42 if (isPseudo && node.parentNode) |
| 43 node = node.parentNode; |
| 44 |
| 36 var title = node.nodeNameInCorrectCase(); | 45 var title = node.nodeNameInCorrectCase(); |
| 37 | 46 |
| 38 var nameElement = createElement("span"); | 47 var nameElement = parentElement.createChild("span", "node-label-name"); |
| 39 nameElement.textContent = title; | 48 nameElement.textContent = title; |
| 40 parentElement.appendChild(nameElement); | |
| 41 | 49 |
| 42 var idAttribute = node.getAttribute("id"); | 50 var idAttribute = node.getAttribute("id"); |
| 43 if (idAttribute) { | 51 if (idAttribute) { |
| 44 var idElement = createElement("span"); | 52 var idElement = parentElement.createChild("span", "node-label-id"); |
| 45 parentElement.appendChild(idElement); | |
| 46 | |
| 47 var part = "#" + idAttribute; | 53 var part = "#" + idAttribute; |
| 48 title += part; | 54 title += part; |
| 49 idElement.createTextChild(part); | 55 idElement.createTextChild(part); |
| 50 | 56 |
| 51 // Mark the name as extra, since the ID is more important. | 57 // Mark the name as extra, since the ID is more important. |
| 52 nameElement.className = "extra"; | 58 nameElement.classList.add("extra"); |
| 53 } | 59 } |
| 54 | 60 |
| 55 var classAttribute = node.getAttribute("class"); | 61 var classAttribute = node.getAttribute("class"); |
| 56 if (classAttribute) { | 62 if (classAttribute) { |
| 57 var classes = classAttribute.split(/\s+/); | 63 var classes = classAttribute.split(/\s+/); |
| 58 var foundClasses = {}; | 64 var foundClasses = {}; |
| 59 | 65 |
| 60 if (classes.length) { | 66 if (classes.length) { |
| 61 var classesElement = createElement("span"); | 67 var classesElement = parentElement.createChild("span", "extra node-l
abel-class"); |
| 62 classesElement.className = "extra"; | |
| 63 parentElement.appendChild(classesElement); | |
| 64 | |
| 65 for (var i = 0; i < classes.length; ++i) { | 68 for (var i = 0; i < classes.length; ++i) { |
| 66 var className = classes[i]; | 69 var className = classes[i]; |
| 67 if (className && !(className in foundClasses)) { | 70 if (className && !(className in foundClasses)) { |
| 68 var part = "." + className; | 71 var part = "." + className; |
| 69 title += part; | 72 title += part; |
| 70 classesElement.createTextChild(part); | 73 classesElement.createTextChild(part); |
| 71 foundClasses[className] = true; | 74 foundClasses[className] = true; |
| 72 } | 75 } |
| 73 } | 76 } |
| 74 } | 77 } |
| 75 } | 78 } |
| 79 |
| 80 if (isPseudo) { |
| 81 var pseudoElement = parentElement.createChild("span", "extra node-label-
pseudo"); |
| 82 var pseudoText = "::" + originalNode.pseudoType(); |
| 83 pseudoElement.createTextChild(pseudoText); |
| 84 title += pseudoText; |
| 85 } |
| 76 parentElement.title = title; | 86 parentElement.title = title; |
| 77 } | 87 } |
| 78 | 88 |
| 79 /** | 89 /** |
| 80 * @param {!Element} container | 90 * @param {!Element} container |
| 81 * @param {string} nodeTitle | 91 * @param {string} nodeTitle |
| 82 */ | 92 */ |
| 83 WebInspector.DOMPresentationUtils.createSpansForNodeTitle = function(container,
nodeTitle) | 93 WebInspector.DOMPresentationUtils.createSpansForNodeTitle = function(container,
nodeTitle) |
| 84 { | 94 { |
| 85 var match = nodeTitle.match(/([^#.]+)(#[^.]+)?(\..*)?/); | 95 var match = nodeTitle.match(/([^#.]+)(#[^.]+)?(\..*)?/); |
| 86 container.createChild("span", "webkit-html-tag-name").textContent = match[1]
; | 96 container.createChild("span", "webkit-html-tag-name").textContent = match[1]
; |
| 87 if (match[2]) | 97 if (match[2]) |
| 88 container.createChild("span", "webkit-html-attribute-value").textContent
= match[2]; | 98 container.createChild("span", "webkit-html-attribute-value").textContent
= match[2]; |
| 89 if (match[3]) | 99 if (match[3]) |
| 90 container.createChild("span", "webkit-html-attribute-name").textContent
= match[3]; | 100 container.createChild("span", "webkit-html-attribute-name").textContent
= match[3]; |
| 91 } | 101 } |
| 92 | 102 |
| 93 /** | 103 /** |
| 94 * @param {?WebInspector.DOMNode} node | 104 * @param {?WebInspector.DOMNode} node |
| 95 * @return {!Node} | 105 * @return {!Node} |
| 96 */ | 106 */ |
| 97 WebInspector.DOMPresentationUtils.linkifyNodeReference = function(node) | 107 WebInspector.DOMPresentationUtils.linkifyNodeReference = function(node) |
| 98 { | 108 { |
| 99 if (!node) | 109 if (!node) |
| 100 return createTextNode(WebInspector.UIString("<node>")); | 110 return createTextNode(WebInspector.UIString("<node>")); |
| 101 | 111 |
| 102 var root = createElement("span"); | 112 var root = createElementWithClass("span", "monospace"); |
| 103 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(root); | 113 var shadowRoot = WebInspector.createShadowRootWithCoreStyles(root); |
| 104 shadowRoot.appendChild(WebInspector.Widget.createStyleElement("components/do
mUtils.css")); | 114 shadowRoot.appendChild(WebInspector.Widget.createStyleElement("components/do
mUtils.css")); |
| 105 var link = shadowRoot.createChild("div", "node-link"); | 115 var link = shadowRoot.createChild("div", "node-link"); |
| 106 | 116 |
| 107 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, link); | 117 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, link); |
| 108 | 118 |
| 109 link.addEventListener("click", WebInspector.Revealer.reveal.bind(WebInspecto
r.Revealer, node, undefined), false); | 119 link.addEventListener("click", WebInspector.Revealer.reveal.bind(WebInspecto
r.Revealer, node, undefined), false); |
| 110 link.addEventListener("mouseover", node.highlight.bind(node, undefined, unde
fined), false); | 120 link.addEventListener("mouseover", node.highlight.bind(node, undefined, unde
fined), false); |
| 111 link.addEventListener("mouseleave", WebInspector.DOMModel.hideDOMNodeHighlig
ht.bind(WebInspector.DOMModel), false); | 121 link.addEventListener("mouseleave", WebInspector.DOMModel.hideDOMNodeHighlig
ht.bind(WebInspector.DOMModel), false); |
| 112 | 122 |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 /** | 650 /** |
| 641 * @override | 651 * @override |
| 642 * @param {!WebInspector.DOMNode} node | 652 * @param {!WebInspector.DOMNode} node |
| 643 * @return {?{title: string, color: string}} | 653 * @return {?{title: string, color: string}} |
| 644 */ | 654 */ |
| 645 decorate: function(node) | 655 decorate: function(node) |
| 646 { | 656 { |
| 647 return { title: this._title, color: this._color }; | 657 return { title: this._title, color: this._color }; |
| 648 } | 658 } |
| 649 } | 659 } |
| OLD | NEW |