Changeset 35876 in webkit
- Timestamp:
- Aug 21, 2008 1:12:47 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r35875 r35876 1 2008-08-21 Timothy Hatcher <timothy@apple.com> 2 3 Make the Inspector's Metrics sidebar pane editable. 4 5 https://bugs.webkit.org/show_bug.cgi?id=17218 6 rdar://problem/5732818 7 8 Reviewed by Kevin McCullough. 9 10 * page/inspector/ElementsPanel.js: 11 (WebInspector.ElementsPanel): Add an event listener for 12 the "metrics edited" event, so the Styles pane is updated. 13 * page/inspector/MetricsSidebarPane.js: 14 (WebInspector.MetricsSidebarPane.prototype.update): Remember the node 15 so future updates work. Add a double click event listener for the 16 metric values to start editing. 17 (WebInspector.MetricsSidebarPane.prototype.startEditing): 18 Call WebInspector.startEditing with some context. 19 (WebInspector.MetricsSidebarPane.prototype.editingCancelled): 20 (WebInspector.MetricsSidebarPane.prototype.editingCommitted): 21 Set the user input on the elements inline style. Fire the 22 "metrics edited" event. 23 1 24 2008-08-21 Steve Falkenburg <sfalken@apple.com> 2 25 -
trunk/WebCore/page/inspector/ElementsPanel.js
r35576 r35876 62 62 this.sidebarPanes.styles.expanded = true; 63 63 64 this.sidebarPanes.metrics.addEventListener("metrics edited", this._metricsPaneEdited, this); 65 64 66 this.sidebarElement = document.createElement("div"); 65 67 this.sidebarElement.id = "elements-sidebar"; … … 410 412 else 411 413 InspectorController.hideDOMNodeHighlight(); 414 }, 415 416 _metricsPaneEdited: function() 417 { 418 this.sidebarPanes.styles.needsUpdate = true; 419 this.updateStyles(true); 412 420 }, 413 421 -
trunk/WebCore/page/inspector/MetricsSidebarPane.js
r35859 r35876 39 39 body.removeChildren(); 40 40 41 if (!node) 41 if (node) 42 this.node = node; 43 else 44 node = this.node; 45 46 if (!node || !node.ownerDocument.defaultView) 42 47 return; 43 48 … … 53 58 function createBoxPartElement(style, name, side, suffix) 54 59 { 55 var value = style.getPropertyValue((name !== "position" ? name + "-" : "") + side + suffix); 60 var propertyName = (name !== "position" ? name + "-" : "") + side + suffix; 61 var value = style.getPropertyValue(propertyName); 56 62 if (value === "" || (name !== "position" && value === "0px")) 57 63 value = "\u2012"; … … 63 69 element.className = side; 64 70 element.textContent = value; 71 element.addEventListener("dblclick", this.startEditing.bind(this, element, name, propertyName), false); 65 72 return element; 66 73 } … … 110 117 if (name === "content") { 111 118 var width = style.width.replace(/px$/, ""); 119 var widthElement = document.createElement("span"); 120 widthElement.textContent = width; 121 widthElement.addEventListener("dblclick", this.startEditing.bind(this, widthElement, "width", "width"), false); 122 112 123 var height = style.height.replace(/px$/, ""); 113 boxElement.textContent = width + " \u00D7 " + height; 124 var heightElement = document.createElement("span"); 125 heightElement.textContent = height; 126 heightElement.addEventListener("dblclick", this.startEditing.bind(this, heightElement, "height", "height"), false); 127 128 boxElement.appendChild(widthElement); 129 boxElement.appendChild(document.createTextNode(" \u00D7 ")); 130 boxElement.appendChild(heightElement); 114 131 } else { 115 132 var suffix = (name === "border" ? "-width" : ""); … … 120 137 boxElement.appendChild(labelElement); 121 138 122 boxElement.appendChild(createBoxPartElement(style, name, "top", suffix)); 123 boxElement.appendChild(createBoxPartElement(style, name, "left", suffix)); 139 boxElement.appendChild(createBoxPartElement.call(this, style, name, "top", suffix)); 140 boxElement.appendChild(document.createElement("br")); 141 boxElement.appendChild(createBoxPartElement.call(this, style, name, "left", suffix)); 124 142 125 143 if (previousBox) 126 144 boxElement.appendChild(previousBox); 127 145 128 boxElement.appendChild(createBoxPartElement(style, name, "right", suffix)); 129 boxElement.appendChild(createBoxPartElement(style, name, "bottom", suffix)); 146 boxElement.appendChild(createBoxPartElement.call(this, style, name, "right", suffix)); 147 boxElement.appendChild(document.createElement("br")); 148 boxElement.appendChild(createBoxPartElement.call(this, style, name, "bottom", suffix)); 130 149 } 131 150 … … 135 154 metricsElement.appendChild(previousBox); 136 155 body.appendChild(metricsElement); 156 }, 157 158 startEditing: function(targetElement, box, styleProperty) 159 { 160 if (WebInspector.isBeingEdited(targetElement)) 161 return; 162 163 var context = { box: box, styleProperty: styleProperty }; 164 165 WebInspector.startEditing(targetElement, this.editingCommitted.bind(this), this.editingCancelled.bind(this), context); 166 }, 167 168 editingCancelled: function(element, context) 169 { 170 this.update(); 171 }, 172 173 editingCommitted: function(element, userInput, previousContent, context) 174 { 175 if (userInput === previousContent) 176 return this.editingCancelled(element, context); // nothing changed, so cancel 177 178 if (context.box !== "position" && (!userInput || userInput === "\u2012")) 179 userInput = "0px"; 180 else if (context.box === "position" && (!userInput || userInput === "\u2012")) 181 userInput = "auto"; 182 183 // Append a "px" unit if the user input was just a number. 184 if (/^\d+$/.test(userInput)) 185 userInput += "px"; 186 187 this.node.style.setProperty(context.styleProperty, userInput, ""); 188 189 this.dispatchEventToListeners("metrics edited"); 190 191 this.update(); 137 192 } 138 193 } -
trunk/WebCore/page/inspector/inspector.css
r35859 r35876 1393 1393 border: 1px rgb(66%, 66%, 66%) dotted; 1394 1394 display: inline-block; 1395 text-align: center; 1395 1396 padding: 3px; 1396 1397 margin: 3px; … … 1400 1401 border: 1px dashed; 1401 1402 display: inline-block; 1403 text-align: center; 1402 1404 vertical-align: middle; 1403 1405 padding: 3px; … … 1408 1410 border: 1px black solid; 1409 1411 display: inline-block; 1412 text-align: center; 1410 1413 vertical-align: middle; 1411 1414 padding: 3px; … … 1416 1419 border: 1px grey dashed; 1417 1420 display: inline-block; 1421 text-align: center; 1418 1422 vertical-align: middle; 1419 1423 padding: 3px; … … 1425 1429 border: 1px grey solid; 1426 1430 display: inline-block; 1431 text-align: center; 1427 1432 vertical-align: middle; 1428 1433 padding: 3px; … … 1433 1438 } 1434 1439 1440 .metrics .content span { 1441 display: inline-block; 1442 } 1443 1444 .metrics .editing { 1445 position: relative; 1446 z-index: 100; 1447 } 1448 1435 1449 .metrics .left { 1436 1450 display: inline-block; 1437 text-align: center;1438 1451 vertical-align: middle; 1439 1452 } … … 1441 1454 .metrics .right { 1442 1455 display: inline-block; 1443 text-align: center;1444 1456 vertical-align: middle; 1445 1457 } 1446 1458 1447 1459 .metrics .top { 1448 text-align: center;1460 display: inline-block; 1449 1461 } 1450 1462 1451 1463 .metrics .bottom { 1452 text-align: center;1464 display: inline-block; 1453 1465 } 1454 1466
Note: See TracChangeset
for help on using the changeset viewer.