OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 element.style.backgroundColor = ""; | 185 element.style.backgroundColor = ""; |
186 } | 186 } |
187 }, | 187 }, |
188 | 188 |
189 /** | 189 /** |
190 * @param {!WebInspector.CSSStyleDeclaration} style | 190 * @param {!WebInspector.CSSStyleDeclaration} style |
191 */ | 191 */ |
192 _updateMetrics: function(style) | 192 _updateMetrics: function(style) |
193 { | 193 { |
194 // Updating with computed style. | 194 // Updating with computed style. |
195 var metricsElement = document.createElement("div"); | 195 var metricsElement = createElement("div"); |
196 metricsElement.className = "metrics"; | 196 metricsElement.className = "metrics"; |
197 var self = this; | 197 var self = this; |
198 | 198 |
199 /** | 199 /** |
200 * @param {!WebInspector.CSSStyleDeclaration} style | 200 * @param {!WebInspector.CSSStyleDeclaration} style |
201 * @param {string} name | 201 * @param {string} name |
202 * @param {string} side | 202 * @param {string} side |
203 * @param {string} suffix | 203 * @param {string} suffix |
204 * @this {WebInspector.MetricsSidebarPane} | 204 * @this {WebInspector.MetricsSidebarPane} |
205 */ | 205 */ |
206 function createBoxPartElement(style, name, side, suffix) | 206 function createBoxPartElement(style, name, side, suffix) |
207 { | 207 { |
208 var propertyName = (name !== "position" ? name + "-" : "") + side +
suffix; | 208 var propertyName = (name !== "position" ? name + "-" : "") + side +
suffix; |
209 var value = style.getPropertyValue(propertyName); | 209 var value = style.getPropertyValue(propertyName); |
210 if (value === "" || (name !== "position" && value === "0px")) | 210 if (value === "" || (name !== "position" && value === "0px")) |
211 value = "\u2012"; | 211 value = "\u2012"; |
212 else if (name === "position" && value === "auto") | 212 else if (name === "position" && value === "auto") |
213 value = "\u2012"; | 213 value = "\u2012"; |
214 value = value.replace(/px$/, ""); | 214 value = value.replace(/px$/, ""); |
215 value = Number.toFixedIfFloating(value); | 215 value = Number.toFixedIfFloating(value); |
216 | 216 |
217 var element = document.createElement("div"); | 217 var element = createElement("div"); |
218 element.className = side; | 218 element.className = side; |
219 element.textContent = value; | 219 element.textContent = value; |
220 element.addEventListener("dblclick", this.startEditing.bind(this, el
ement, name, propertyName, style), false); | 220 element.addEventListener("dblclick", this.startEditing.bind(this, el
ement, name, propertyName, style), false); |
221 return element; | 221 return element; |
222 } | 222 } |
223 | 223 |
224 function getContentAreaWidthPx(style) | 224 function getContentAreaWidthPx(style) |
225 { | 225 { |
226 var width = style.getPropertyValue("width").replace(/px$/, ""); | 226 var width = style.getPropertyValue("width").replace(/px$/, ""); |
227 if (!isNaN(width) && style.getPropertyValue("box-sizing") === "borde
r-box") { | 227 if (!isNaN(width) && style.getPropertyValue("box-sizing") === "borde
r-box") { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 for (var i = 0; i < boxes.length; ++i) { | 287 for (var i = 0; i < boxes.length; ++i) { |
288 var name = boxes[i]; | 288 var name = boxes[i]; |
289 | 289 |
290 if (name === "margin" && noMarginDisplayType[style.getPropertyValue(
"display")]) | 290 if (name === "margin" && noMarginDisplayType[style.getPropertyValue(
"display")]) |
291 continue; | 291 continue; |
292 if (name === "padding" && noPaddingDisplayType[style.getPropertyValu
e("display")]) | 292 if (name === "padding" && noPaddingDisplayType[style.getPropertyValu
e("display")]) |
293 continue; | 293 continue; |
294 if (name === "position" && noPositionType[style.getPropertyValue("po
sition")]) | 294 if (name === "position" && noPositionType[style.getPropertyValue("po
sition")]) |
295 continue; | 295 continue; |
296 | 296 |
297 var boxElement = document.createElement("div"); | 297 var boxElement = createElement("div"); |
298 boxElement.className = name; | 298 boxElement.className = name; |
299 boxElement._backgroundColor = boxColors[i].toString(WebInspector.Col
or.Format.RGBA); | 299 boxElement._backgroundColor = boxColors[i].toString(WebInspector.Col
or.Format.RGBA); |
300 boxElement._name = name; | 300 boxElement._name = name; |
301 boxElement.style.backgroundColor = boxElement._backgroundColor; | 301 boxElement.style.backgroundColor = boxElement._backgroundColor; |
302 boxElement.addEventListener("mouseover", this._highlightDOMNode.bind
(this, true, name === "position" ? "all" : name), false); | 302 boxElement.addEventListener("mouseover", this._highlightDOMNode.bind
(this, true, name === "position" ? "all" : name), false); |
303 this._boxElements.push(boxElement); | 303 this._boxElements.push(boxElement); |
304 | 304 |
305 if (name === "content") { | 305 if (name === "content") { |
306 var widthElement = document.createElement("span"); | 306 var widthElement = createElement("span"); |
307 widthElement.textContent = getContentAreaWidthPx(style); | 307 widthElement.textContent = getContentAreaWidthPx(style); |
308 widthElement.addEventListener("dblclick", this.startEditing.bind
(this, widthElement, "width", "width", style), false); | 308 widthElement.addEventListener("dblclick", this.startEditing.bind
(this, widthElement, "width", "width", style), false); |
309 | 309 |
310 var heightElement = document.createElement("span"); | 310 var heightElement = createElement("span"); |
311 heightElement.textContent = getContentAreaHeightPx(style); | 311 heightElement.textContent = getContentAreaHeightPx(style); |
312 heightElement.addEventListener("dblclick", this.startEditing.bin
d(this, heightElement, "height", "height", style), false); | 312 heightElement.addEventListener("dblclick", this.startEditing.bin
d(this, heightElement, "height", "height", style), false); |
313 | 313 |
314 boxElement.appendChild(widthElement); | 314 boxElement.appendChild(widthElement); |
315 boxElement.createTextChild(" \u00D7 "); | 315 boxElement.createTextChild(" \u00D7 "); |
316 boxElement.appendChild(heightElement); | 316 boxElement.appendChild(heightElement); |
317 } else { | 317 } else { |
318 var suffix = (name === "border" ? "-width" : ""); | 318 var suffix = (name === "border" ? "-width" : ""); |
319 | 319 |
320 var labelElement = document.createElement("div"); | 320 var labelElement = createElement("div"); |
321 labelElement.className = "label"; | 321 labelElement.className = "label"; |
322 labelElement.textContent = boxLabels[i]; | 322 labelElement.textContent = boxLabels[i]; |
323 boxElement.appendChild(labelElement); | 323 boxElement.appendChild(labelElement); |
324 | 324 |
325 boxElement.appendChild(createBoxPartElement.call(this, style, na
me, "top", suffix)); | 325 boxElement.appendChild(createBoxPartElement.call(this, style, na
me, "top", suffix)); |
326 boxElement.appendChild(document.createElement("br")); | 326 boxElement.appendChild(createElement("br")); |
327 boxElement.appendChild(createBoxPartElement.call(this, style, na
me, "left", suffix)); | 327 boxElement.appendChild(createBoxPartElement.call(this, style, na
me, "left", suffix)); |
328 | 328 |
329 if (previousBox) | 329 if (previousBox) |
330 boxElement.appendChild(previousBox); | 330 boxElement.appendChild(previousBox); |
331 | 331 |
332 boxElement.appendChild(createBoxPartElement.call(this, style, na
me, "right", suffix)); | 332 boxElement.appendChild(createBoxPartElement.call(this, style, na
me, "right", suffix)); |
333 boxElement.appendChild(document.createElement("br")); | 333 boxElement.appendChild(createElement("br")); |
334 boxElement.appendChild(createBoxPartElement.call(this, style, na
me, "bottom", suffix)); | 334 boxElement.appendChild(createBoxPartElement.call(this, style, na
me, "bottom", suffix)); |
335 } | 335 } |
336 | 336 |
337 previousBox = boxElement; | 337 previousBox = boxElement; |
338 } | 338 } |
339 | 339 |
340 metricsElement.appendChild(previousBox); | 340 metricsElement.appendChild(previousBox); |
341 metricsElement.addEventListener("mouseover", this._highlightDOMNode.bind
(this, false, "all"), false); | 341 metricsElement.addEventListener("mouseover", this._highlightDOMNode.bind
(this, false, "all"), false); |
342 this.bodyElement.removeChildren(); | 342 this.bodyElement.removeChildren(); |
343 this.bodyElement.appendChild(metricsElement); | 343 this.bodyElement.appendChild(metricsElement); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 }, | 489 }, |
490 | 490 |
491 editingCommitted: function(element, userInput, previousContent, context) | 491 editingCommitted: function(element, userInput, previousContent, context) |
492 { | 492 { |
493 this.editingEnded(element, context); | 493 this.editingEnded(element, context); |
494 this._applyUserInput(element, userInput, previousContent, context, true)
; | 494 this._applyUserInput(element, userInput, previousContent, context, true)
; |
495 }, | 495 }, |
496 | 496 |
497 __proto__: WebInspector.SidebarPane.prototype | 497 __proto__: WebInspector.SidebarPane.prototype |
498 } | 498 } |
OLD | NEW |