+2006-07-31 Darin Adler <darin@apple.com>
+
+ Reviewed by Tim Hatcher.
+
+ - http://bugzilla.opendarwin.org/show_bug.cgi?id=10168
+ add a first cut at a Metrics pane to the inspector
+
+ * WebInspector/webInspector/inspector.css: Add styles for the new metrics pane.
+ * WebInspector/webInspector/inspector.html: Add the new metrics pane, starting with
+ the table to show the box model.
+ * WebInspector/webInspector/inspector.js: Add the new metrics pane. Add back some
+ "title" attributes so we have more tooltips. Removed the optional parameter to
+ getComputedStyle.
+
2006-07-31 Anders Carlsson <acarlsson@apple.com>
Reviewed by John.
Reviewed by Tim Hatcher.
- Bug 10163: some improvements for the inspector
- http://bugzilla.opendarwin.org/show_bug.cgi?id=10163
+ - http://bugzilla.opendarwin.org/show_bug.cgi?id=10163
+ some improvements for the inspector
* WebInspector/WebInspector.m:
(+[WebInspector sharedWebInspector:]): Fixed bug that could cause the inspector
<div id="stylePropertiesScrollbar" class="scrollbar"></div>
</div>
</div>
- <div id="metricsPane" class="pane" style="display: none; text-align: center"><br /><br /><br />(not finished)</div>
+ <div id="metricsPane" class="pane" style="display: none">
+ <div id="noMetrics" style="display: none">No metrics</div>
+ <table class="boxModelTable" id="marginBoxTable" cellpadding=0 cellspacing=0>
+ <tr><td valign="top"><div style="position:relative"><div class="boxModelLabel">margin</div></div></td><td id="margin-top"></td><td></td></tr>
+ <tr><td class="horizontalCell" id="margin-left"></td><td>
+ <table class="boxModelTable" id="borderBoxTable" cellpadding=0 cellspacing=0>
+ <tr><td valign="top"><div style="position:relative"><div class="boxModelLabel">border</div></div></td><td id="border-top"></td><td></td></tr>
+ <tr><td class="horizontalCell" id="border-left"></td><td>
+ <table class="boxModelTable" id="paddingBoxTable" cellpadding=0 cellspacing=0>
+ <tr><td valign="top"><div style="position:relative"><div class="boxModelLabel">padding</div></div></td><td id="padding-top"></td><td></td></tr>
+ <tr><td class="horizontalCell" id="padding-left"></td><td>
+ <div id="content"></div></div>
+ </td><td class="horizontalCell" id="padding-right"></td></tr>
+ <tr><td></td><td id="padding-bottom"></td><td></td></tr>
+ </table>
+ </td><td class="horizontalCell" id="border-right"></td></tr>
+ <tr><td></td><td id="border-bottom"></td><td></td></tr>
+ </table>
+ </td><td class="horizontalCell" id="margin-right"></td></tr>
+ <tr><td></td><td id="margin-bottom"></td><td></td></tr>
+ </table>
+ </div>
<div id="propertiesPane" class="pane" style="display: none">
<div id="jsProperties" class="scrollArea">
<div class="view"><div id="jsPropertiesScrollview"><ul class="propertyList" id="jsPropertiesList"></ul></div></div>
span = document.createElement("span");
span.className = "value";
span.textContent = attr.value;
- span.title = span.textContent;
+ span.title = attr.value;
li.appendChild(span);
if (attr.style) {
var propertyCount = [];
- var computedStyle = focusedNode.ownerDocument.defaultView.getComputedStyle(focusedNode, "");
+ var computedStyle = focusedNode.ownerDocument.defaultView.getComputedStyle(focusedNode);
if (computedStyle && computedStyle.length) {
var computedObj = {
isComputedStyle: true,
var cell = document.createElement("div");
cell.className = "cell selector";
- cell.title = styleRules[i].selectorText;
- cell.textContent = cell.title;
+ var text = styleRules[i].selectorText;
+ cell.textContent = text;
+ cell.title = text;
row.appendChild(cell);
cell = document.createElement("div");
cell.className = "cell stylesheet";
+ var sheet;
if (styleRules[i].subtitle != null)
- cell.title = styleRules[i].subtitle;
+ sheet = styleRules[i].subtitle;
else if (styleRules[i].parentStyleSheet && styleRules[i].parentStyleSheet.href)
- cell.title = styleRules[i].parentStyleSheet.href;
+ sheet = styleRules[i].parentStyleSheet.href;
else
- cell.title = "inline stylesheet";
- cell.textContent = cell.title;
+ sheet = "inline stylesheet";
+ cell.textContent = sheet;
+ cell.title = sheet;
row.appendChild(cell);
row.styleRuleIndex = i;
if (priority.length)
textValue += " !" + priority;
span.textContent = textValue;
+ span.title = textValue;
li.appendChild(span);
var colors = value.match(/(rgb\([0-9]+, [0-9]+, [0-9]+\))|(rgba\([0-9]+, [0-9]+, [0-9]+, [0-9]+\))/g);
switchPane("style");
}
+function setMetric(style, name, suffix)
+{
+ var value = style.getPropertyValue(name + suffix);
+ if (value == "" || value == "0px")
+ value = "\u2012";
+ else
+ value = value.replace(/px$/, "");
+ document.getElementById(name).textContent = value;
+}
+
+function setBoxMetrics(style, box, suffix)
+{
+ setMetric(style, box + "-left", suffix);
+ setMetric(style, box + "-right", suffix);
+ setMetric(style, box + "-top", suffix);
+ setMetric(style, box + "-bottom", suffix);
+}
+
function updateMetricsPane()
{
+ var style;
+ var focusedNode = Inspector.focusedDOMNode();
+ if (focusedNode.nodeType == Node.ELEMENT_NODE)
+ style = focusedNode.ownerDocument.defaultView.getComputedStyle(focusedNode);
+ if (!style || style.length == 0) {
+ document.getElementById("noMetrics").style.display = null;
+ document.getElementById("marginBoxTable").style.display = "none";
+ return;
+ }
+
+ document.getElementById("noMetrics").style.display = "none";
+ document.getElementById("marginBoxTable").style.display = null;
+
+ setBoxMetrics(style, "margin", "");
+ setBoxMetrics(style, "border", "-width");
+ setBoxMetrics(style, "padding", "");
+
+ var size = style.getPropertyValue("width").replace(/px$/, "")
+ + " \u00D7 "
+ + style.getPropertyValue("height").replace(/px$/, "");
+ document.getElementById("content").textContent = size;
}
function updatePropertiesPane()
span = document.createElement("span");
span.className = "value";
span.textContent = value;
+ span.title = value;
li.appendChild(span);
list.appendChild(li);