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 17 matching lines...) Expand all Loading... |
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 WebInspector.DOMPresentationUtils.decorateNodeLabel = function(node, parentEleme
nt) | 34 WebInspector.DOMPresentationUtils.decorateNodeLabel = function(node, parentEleme
nt) |
35 { | 35 { |
36 var title = node.nodeNameInCorrectCase(); | 36 var title = node.nodeNameInCorrectCase(); |
37 | 37 |
38 var nameElement = document.createElement("span"); | 38 var nameElement = createElement("span"); |
39 nameElement.textContent = title; | 39 nameElement.textContent = title; |
40 parentElement.appendChild(nameElement); | 40 parentElement.appendChild(nameElement); |
41 | 41 |
42 var idAttribute = node.getAttribute("id"); | 42 var idAttribute = node.getAttribute("id"); |
43 if (idAttribute) { | 43 if (idAttribute) { |
44 var idElement = document.createElement("span"); | 44 var idElement = createElement("span"); |
45 parentElement.appendChild(idElement); | 45 parentElement.appendChild(idElement); |
46 | 46 |
47 var part = "#" + idAttribute; | 47 var part = "#" + idAttribute; |
48 title += part; | 48 title += part; |
49 idElement.createTextChild(part); | 49 idElement.createTextChild(part); |
50 | 50 |
51 // Mark the name as extra, since the ID is more important. | 51 // Mark the name as extra, since the ID is more important. |
52 nameElement.className = "extra"; | 52 nameElement.className = "extra"; |
53 } | 53 } |
54 | 54 |
55 var classAttribute = node.getAttribute("class"); | 55 var classAttribute = node.getAttribute("class"); |
56 if (classAttribute) { | 56 if (classAttribute) { |
57 var classes = classAttribute.split(/\s+/); | 57 var classes = classAttribute.split(/\s+/); |
58 var foundClasses = {}; | 58 var foundClasses = {}; |
59 | 59 |
60 if (classes.length) { | 60 if (classes.length) { |
61 var classesElement = document.createElement("span"); | 61 var classesElement = createElement("span"); |
62 classesElement.className = "extra"; | 62 classesElement.className = "extra"; |
63 parentElement.appendChild(classesElement); | 63 parentElement.appendChild(classesElement); |
64 | 64 |
65 for (var i = 0; i < classes.length; ++i) { | 65 for (var i = 0; i < classes.length; ++i) { |
66 var className = classes[i]; | 66 var className = classes[i]; |
67 if (className && !(className in foundClasses)) { | 67 if (className && !(className in foundClasses)) { |
68 var part = "." + className; | 68 var part = "." + className; |
69 title += part; | 69 title += part; |
70 classesElement.createTextChild(part); | 70 classesElement.createTextChild(part); |
71 foundClasses[className] = true; | 71 foundClasses[className] = true; |
(...skipping 18 matching lines...) Expand all Loading... |
90 container.createChild("span", "webkit-html-attribute-name").textContent
= match[3]; | 90 container.createChild("span", "webkit-html-attribute-name").textContent
= match[3]; |
91 } | 91 } |
92 | 92 |
93 /** | 93 /** |
94 * @param {?WebInspector.DOMNode} node | 94 * @param {?WebInspector.DOMNode} node |
95 * @return {!Node} | 95 * @return {!Node} |
96 */ | 96 */ |
97 WebInspector.DOMPresentationUtils.linkifyNodeReference = function(node) | 97 WebInspector.DOMPresentationUtils.linkifyNodeReference = function(node) |
98 { | 98 { |
99 if (!node) | 99 if (!node) |
100 return document.createTextNode(WebInspector.UIString("<node>")); | 100 return createTextNode(WebInspector.UIString("<node>")); |
101 | 101 |
102 var link = document.createElement("span"); | 102 var link = createElement("span"); |
103 link.className = "node-link"; | 103 link.className = "node-link"; |
104 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, link); | 104 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, link); |
105 | 105 |
106 link.addEventListener("click", WebInspector.Revealer.reveal.bind(WebInspecto
r.Revealer, node, undefined), false); | 106 link.addEventListener("click", WebInspector.Revealer.reveal.bind(WebInspecto
r.Revealer, node, undefined), false); |
107 link.addEventListener("mouseover", node.highlight.bind(node, undefined, unde
fined), false); | 107 link.addEventListener("mouseover", node.highlight.bind(node, undefined, unde
fined), false); |
108 link.addEventListener("mouseout", node.domModel().hideDOMNodeHighlight.bind(
node.domModel()), false); | 108 link.addEventListener("mouseout", node.domModel().hideDOMNodeHighlight.bind(
node.domModel()), false); |
109 | 109 |
110 return link; | 110 return link; |
111 } | 111 } |
112 | 112 |
113 /** | 113 /** |
114 * @param {string} imageURL | 114 * @param {string} imageURL |
115 * @param {!WebInspector.Target} target | 115 * @param {!WebInspector.Target} target |
116 * @param {boolean} showDimensions | 116 * @param {boolean} showDimensions |
117 * @param {function(!Element=)} userCallback | 117 * @param {function(!Element=)} userCallback |
118 * @param {!Object=} precomputedDimensions | 118 * @param {!Object=} precomputedDimensions |
119 */ | 119 */ |
120 WebInspector.DOMPresentationUtils.buildImagePreviewContents = function(target, i
mageURL, showDimensions, userCallback, precomputedDimensions) | 120 WebInspector.DOMPresentationUtils.buildImagePreviewContents = function(target, i
mageURL, showDimensions, userCallback, precomputedDimensions) |
121 { | 121 { |
122 var resource = target.resourceTreeModel.resourceForURL(imageURL); | 122 var resource = target.resourceTreeModel.resourceForURL(imageURL); |
123 if (!resource) { | 123 if (!resource) { |
124 userCallback(); | 124 userCallback(); |
125 return; | 125 return; |
126 } | 126 } |
127 | 127 |
128 var imageElement = document.createElement("img"); | 128 var imageElement = createElement("img"); |
129 imageElement.addEventListener("load", buildContent, false); | 129 imageElement.addEventListener("load", buildContent, false); |
130 imageElement.addEventListener("error", errorCallback, false); | 130 imageElement.addEventListener("error", errorCallback, false); |
131 resource.populateImageSource(imageElement); | 131 resource.populateImageSource(imageElement); |
132 | 132 |
133 function errorCallback() | 133 function errorCallback() |
134 { | 134 { |
135 // Drop the event parameter when invoking userCallback. | 135 // Drop the event parameter when invoking userCallback. |
136 userCallback(); | 136 userCallback(); |
137 } | 137 } |
138 | 138 |
139 function buildContent() | 139 function buildContent() |
140 { | 140 { |
141 var container = document.createElement("table"); | 141 var container = createElement("table"); |
142 container.className = "image-preview-container"; | 142 container.className = "image-preview-container"; |
143 var naturalWidth = precomputedDimensions ? precomputedDimensions.natural
Width : imageElement.naturalWidth; | 143 var naturalWidth = precomputedDimensions ? precomputedDimensions.natural
Width : imageElement.naturalWidth; |
144 var naturalHeight = precomputedDimensions ? precomputedDimensions.natura
lHeight : imageElement.naturalHeight; | 144 var naturalHeight = precomputedDimensions ? precomputedDimensions.natura
lHeight : imageElement.naturalHeight; |
145 var offsetWidth = precomputedDimensions ? precomputedDimensions.offsetWi
dth : naturalWidth; | 145 var offsetWidth = precomputedDimensions ? precomputedDimensions.offsetWi
dth : naturalWidth; |
146 var offsetHeight = precomputedDimensions ? precomputedDimensions.offsetH
eight : naturalHeight; | 146 var offsetHeight = precomputedDimensions ? precomputedDimensions.offsetH
eight : naturalHeight; |
147 var description; | 147 var description; |
148 if (showDimensions) { | 148 if (showDimensions) { |
149 if (offsetHeight === naturalHeight && offsetWidth === naturalWidth) | 149 if (offsetHeight === naturalHeight && offsetWidth === naturalWidth) |
150 description = WebInspector.UIString("%d \xd7 %d pixels", offsetW
idth, offsetHeight); | 150 description = WebInspector.UIString("%d \xd7 %d pixels", offsetW
idth, offsetHeight); |
151 else | 151 else |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 509 |
510 WebInspector.DOMNodePathStep.prototype = { | 510 WebInspector.DOMNodePathStep.prototype = { |
511 /** | 511 /** |
512 * @return {string} | 512 * @return {string} |
513 */ | 513 */ |
514 toString: function() | 514 toString: function() |
515 { | 515 { |
516 return this.value; | 516 return this.value; |
517 } | 517 } |
518 } | 518 } |
OLD | NEW |