Changeset 95621 in webkit
- Timestamp:
- Sep 21, 2011 6:33:10 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r95619 r95621 1 2011-09-21 Pavel Feldman <pfeldman@google.com> 2 3 Web Inspector: paint box model colors in Metrics sidebar at all times, do not draw box outlines. 4 https://bugs.webkit.org/show_bug.cgi?id=68240 5 6 Today we paint backgrounds in Metrics box model on hover only - should be painted at all 7 times for the reference. Outlining boxes is highlight is wrong since outlines are outside 8 the corresponding box regions. We've seen few reports on that + Firebug does not do borders 9 for that reason. 10 11 Reviewed by Yury Semikhatsky. 12 13 * inspector/DOMNodeHighlighter.cpp: 14 * inspector/DOMNodeHighlighter.h: 15 * inspector/Inspector.json: 16 * inspector/InspectorDOMAgent.cpp: 17 (WebCore::InspectorDOMAgent::setHighlightDataFromConfig): 18 * inspector/front-end/Color.js: 19 * inspector/front-end/MetricsSidebarPane.js: 20 (WebInspector.MetricsSidebarPane.prototype._highlightDOMNode): 21 (WebInspector.MetricsSidebarPane.prototype._updateMetrics): 22 * inspector/front-end/inspector.css: 23 (.metrics .label): 24 * inspector/front-end/inspector.js: 25 (WebInspector.buildHighlightConfig): 26 1 27 2011-09-21 Andreas Kling <kling@webkit.org> 2 28 -
trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp
r93772 r95621 100 100 } 101 101 102 void drawOutlinedQuadWithClip(GraphicsContext& context, const FloatQuad& quad, const FloatQuad& clipQuad, const Color& fillColor , const Color& outlineColor)102 void drawOutlinedQuadWithClip(GraphicsContext& context, const FloatQuad& quad, const FloatQuad& clipQuad, const Color& fillColor) 103 103 { 104 104 context.save(); 105 105 Path clipQuadPath = quadToPath(clipQuad); 106 106 context.clipOut(clipQuadPath); 107 drawOutlinedQuad(context, quad, fillColor, outlineColor);107 drawOutlinedQuad(context, quad, fillColor, Color::transparent); 108 108 context.restore(); 109 109 } … … 111 111 void drawHighlightForBox(GraphicsContext& context, const FloatQuad& contentQuad, const FloatQuad& paddingQuad, const FloatQuad& borderQuad, const FloatQuad& marginQuad, HighlightData* highlightData) 112 112 { 113 bool hasMargin = highlightData->margin != Color::transparent || highlightData->marginOutline != Color::transparent;114 bool hasBorder = highlightData->border != Color::transparent || highlightData->borderOutline != Color::transparent;115 bool hasPadding = highlightData->padding != Color::transparent || highlightData->paddingOutline != Color::transparent;113 bool hasMargin = highlightData->margin != Color::transparent; 114 bool hasBorder = highlightData->border != Color::transparent; 115 bool hasPadding = highlightData->padding != Color::transparent; 116 116 bool hasContent = highlightData->content != Color::transparent || highlightData->contentOutline != Color::transparent; 117 117 … … 119 119 Color clipColor; 120 120 if (hasMargin && (!hasBorder || marginQuad != borderQuad)) { 121 drawOutlinedQuadWithClip(context, marginQuad, borderQuad, highlightData->margin , highlightData->marginOutline);121 drawOutlinedQuadWithClip(context, marginQuad, borderQuad, highlightData->margin); 122 122 clipQuad = borderQuad; 123 clipColor = highlightData->marginOutline;124 123 } 125 124 if (hasBorder && (!hasPadding || borderQuad != paddingQuad)) { 126 drawOutlinedQuadWithClip(context, borderQuad, paddingQuad, highlightData->border , highlightData->borderOutline);125 drawOutlinedQuadWithClip(context, borderQuad, paddingQuad, highlightData->border); 127 126 clipQuad = paddingQuad; 128 clipColor = highlightData->borderOutline;129 127 } 130 128 if (hasPadding && (!hasContent || paddingQuad != contentQuad)) { 131 drawOutlinedQuadWithClip(context, paddingQuad, contentQuad, highlightData->padding , highlightData->paddingOutline);129 drawOutlinedQuadWithClip(context, paddingQuad, contentQuad, highlightData->padding); 132 130 clipQuad = contentQuad; 133 clipColor = highlightData->paddingOutline;134 131 } 135 132 if (hasContent) 136 133 drawOutlinedQuad(context, contentQuad, highlightData->content, highlightData->contentOutline); 137 else {138 if (clipColor.isValid())139 drawOutlinedQuadWithClip(context, clipQuad, clipQuad, clipColor, clipColor);140 }141 134 } 142 135 … … 144 137 { 145 138 for (size_t i = 0; i < lineBoxQuads.size(); ++i) 146 drawOutlinedQuad(context, lineBoxQuads[i], highlightData->content, highlightData->contentOutline);139 drawOutlinedQuad(context, lineBoxQuads[i], highlightData->content, Color::transparent); 147 140 } 148 141 -
trunk/Source/WebCore/inspector/DOMNodeHighlighter.h
r93603 r95621 47 47 Color contentOutline; 48 48 Color padding; 49 Color paddingOutline;50 49 Color border; 51 Color borderOutline;52 50 Color margin; 53 Color marginOutline;54 51 bool showInfo; 55 52 -
trunk/Source/WebCore/inspector/Inspector.json
r95614 r95621 891 891 }, 892 892 { 893 "id": " BoxHighlightConfig",893 "id": "HighlightConfig", 894 894 "type": "object", 895 895 "properties": [ 896 896 { "name": "showInfo", "type": "boolean", "optional": true, "description": "Whether the node info tooltip should be shown (default: false)." }, 897 897 { "name": "contentColor", "$ref": "RGBA", "optional": true, "description": "The content box highlight fill color (default: transparent)." }, 898 { "name": "contentOutlineColor", "$ref": "RGBA", "optional": true, "description": "The content box highlight outline color (default: transparent)." },899 898 { "name": "paddingColor", "$ref": "RGBA", "optional": true, "description": "The padding highlight fill color (default: transparent)." }, 900 { "name": "paddingOutlineColor", "$ref": "RGBA", "optional": true, "description": "The padding highlight outline color (default: transparent)." },901 899 { "name": "borderColor", "$ref": "RGBA", "optional": true, "description": "The border highlight fill color (default: transparent)." }, 902 { "name": "borderOutlineColor", "$ref": "RGBA", "optional": true, "description": "The border highlight outline color (default: transparent)." },903 900 { "name": "marginColor", "$ref": "RGBA", "optional": true, "description": "The margin highlight fill color (default: transparent)." }, 904 { "name": "marginOutlineColor", "$ref": "RGBA", "optional": true, "description": "The margin highlight outline color (default: transparent)." }905 901 ], 906 902 "description": "Configuration data for the highlighting of page elements." … … 931 927 { "name": "nodeId", "$ref": "NodeId", "description": "Query selector result." } 932 928 ], 933 "description": "Executes <code>querySelector</code> on a given node. Setting <code>documentWide</code> to true starts selecting from the document node."929 "description": "Executes <code>querySelector</code> on a given node." 934 930 }, 935 931 { … … 942 938 { "name": "nodeIds", "type": "array", "items": { "$ref": "NodeId" }, "description": "Query selector result." } 943 939 ], 944 "description": "Executes <code>querySelectorAll</code> on a given node. Setting <code>documentWide</code> to true starts selecting from the document node."940 "description": "Executes <code>querySelectorAll</code> on a given node." 945 941 }, 946 942 { … … 1065 1061 "parameters": [ 1066 1062 { "name": "enabled", "type": "boolean", "description": "True to enable inspection mode, false to disable it." }, 1067 { "name": "highlightConfig", "$ref": " BoxHighlightConfig", "optional": true, "description": "A descriptor for the highlight appearance of hovered-over nodes. May be omitted if <code>enabled == false</code>." }1063 { "name": "highlightConfig", "$ref": "HighlightConfig", "optional": true, "description": "A descriptor for the highlight appearance of hovered-over nodes. May be omitted if <code>enabled == false</code>." } 1068 1064 ], 1069 1065 "description": "Enters the 'inspect' mode. In this mode, elements that user is hovering over are highlighted. Backend then generates 'inspect' command upon element selection." … … 1085 1081 "parameters": [ 1086 1082 { "name": "nodeId", "$ref": "NodeId", "description": "Identifier of the node to highlight." }, 1087 { "name": "highlightConfig", "$ref": " BoxHighlightConfig", "description": "A descriptor for the highlight appearance." }1083 { "name": "highlightConfig", "$ref": "HighlightConfig", "description": "A descriptor for the highlight appearance." } 1088 1084 ], 1089 1085 "description": "Highlights DOM node with given id." -
trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp
r95614 r95621 1058 1058 m_highlightData->contentOutline = parseConfigColor("contentOutlineColor", highlightConfig); 1059 1059 m_highlightData->padding = parseConfigColor("paddingColor", highlightConfig); 1060 m_highlightData->paddingOutline = parseConfigColor("paddingOutlineColor", highlightConfig);1061 1060 m_highlightData->border = parseConfigColor("borderColor", highlightConfig); 1062 m_highlightData->borderOutline = parseConfigColor("borderOutlineColor", highlightConfig);1063 1061 m_highlightData->margin = parseConfigColor("marginColor", highlightConfig); 1064 m_highlightData->marginOutline = parseConfigColor("marginOutlineColor", highlightConfig);1065 1062 return true; 1066 1063 } -
trunk/Source/WebCore/inspector/front-end/Color.js
r93603 r95621 685 685 WebInspector.Color.PageHighlight = { 686 686 Content: WebInspector.Color.fromRGBA(111, 168, 220, .66), 687 ContentLight: WebInspector.Color.fromRGBA(111, 168, 220, .5), 687 688 ContentOutline: WebInspector.Color.fromRGBA(9, 83, 148), 688 689 Padding: WebInspector.Color.fromRGBA(147, 196, 125, .55), 689 Padding Outline: WebInspector.Color.fromRGBA(55, 118, 28),690 PaddingLight: WebInspector.Color.fromRGBA(147, 196, 125, .4), 690 691 Border: WebInspector.Color.fromRGBA(255, 229, 153, .66), 691 Border Outline: WebInspector.Color.fromRGBA(127, 96, 0),692 BorderLight: WebInspector.Color.fromRGBA(255, 229, 153, .5), 692 693 Margin: WebInspector.Color.fromRGBA(246, 178, 107, .66), 693 Margin Outline: WebInspector.Color.fromRGBA(180, 95, 4)694 MarginLight: WebInspector.Color.fromRGBA(246, 178, 107, .5) 694 695 } -
trunk/Source/WebCore/inspector/front-end/MetricsSidebarPane.js
r94754 r95621 102 102 _highlightDOMNode: function(showHighlight, mode, event) 103 103 { 104 function enclosingOrSelfWithClassInArray(element, classNames)105 {106 for (var node = element; node && node !== element.ownerDocument; node = node.parentNode) {107 if (node.nodeType === Node.ELEMENT_NODE) {108 for (var i = 0; i < classNames.length; ++i) {109 if (node.hasStyleClass(classNames[i]))110 return node;111 }112 }113 }114 return null;115 }116 117 function getBoxRectangleElement(element)118 {119 if (!element)120 return null;121 return enclosingOrSelfWithClassInArray(element, ["metrics", "margin", "border", "padding", "content"]);122 }123 124 104 event.stopPropagation(); 125 var fromElement = getBoxRectangleElement(event.fromElement); 126 var toElement = getBoxRectangleElement(event.toElement); 127 128 if (fromElement === toElement) 129 return; 130 131 function handleMouseOver(element) 132 { 133 element.addStyleClass("hovered"); 134 135 var bgColor; 136 if (element.hasStyleClass("margin")) 137 bgColor = WebInspector.Color.PageHighlight.Margin.toString("original"); 138 else if (element.hasStyleClass("border")) 139 bgColor = WebInspector.Color.PageHighlight.Border.toString("original"); 140 else if (element.hasStyleClass("padding")) 141 bgColor = WebInspector.Color.PageHighlight.Padding.toString("original"); 142 else if (element.hasStyleClass("content")) 143 bgColor = WebInspector.Color.PageHighlight.Content.toString("original"); 144 if (bgColor) 145 element.style.backgroundColor = bgColor; 146 } 147 148 function handleMouseOut(element) 149 { 150 element.style.backgroundColor = ""; 151 element.removeStyleClass("hovered"); 152 } 153 154 if (showHighlight) { 155 // Into element. 156 if (this.node && toElement) 157 handleMouseOver(toElement); 158 var nodeId = this.node ? this.node.id : 0; 159 } else { 160 // Out of element. 161 if (fromElement) 162 handleMouseOut(fromElement); 163 var nodeId = 0; 164 } 105 var nodeId = showHighlight && this.node ? this.node.id : 0; 165 106 if (nodeId) { 166 107 if (this._highlightMode === mode) 167 108 return; 168 109 this._highlightMode = mode; 169 } else 110 WebInspector.highlightDOMNode(nodeId, mode); 111 } else { 170 112 delete this._highlightMode; 171 WebInspector.highlightDOMNode(nodeId, mode); 113 WebInspector.highlightDOMNode(0, ""); 114 } 115 116 for (var i = 0; this._boxElements && i < this._boxElements.length; ++i) { 117 var element = this._boxElements[i]; 118 if (!nodeId || mode === "all" || element._name === mode) 119 element.style.backgroundColor = element._backgroundColor; 120 else 121 element.style.backgroundColor = ""; 122 } 172 123 }, 173 124 … … 249 200 250 201 var boxes = ["content", "padding", "border", "margin", "position"]; 202 var boxColors = [ 203 WebInspector.Color.PageHighlight.Content, 204 WebInspector.Color.PageHighlight.Padding, 205 WebInspector.Color.PageHighlight.Border, 206 WebInspector.Color.PageHighlight.Margin, 207 WebInspector.Color.fromRGBA(0, 0, 0, 0) 208 ]; 251 209 var boxLabels = [WebInspector.UIString("content"), WebInspector.UIString("padding"), WebInspector.UIString("border"), WebInspector.UIString("margin"), WebInspector.UIString("position")]; 252 210 var previousBox; 211 this._boxElements = []; 253 212 for (var i = 0; i < boxes.length; ++i) { 254 213 var name = boxes[i]; … … 263 222 var boxElement = document.createElement("div"); 264 223 boxElement.className = name; 224 boxElement._backgroundColor = boxColors[i].toString("original"); 225 boxElement._name = name; 226 boxElement.style.backgroundColor = boxElement._backgroundColor; 265 227 boxElement.addEventListener("mouseover", this._highlightDOMNode.bind(this, true, name === "position" ? "all" : name), false); 266 boxElement.addEventListener("mouseout", this._highlightDOMNode.bind(this, false, ""), false);228 this._boxElements.push(boxElement); 267 229 268 230 if (name === "content") { … … 302 264 303 265 metricsElement.appendChild(previousBox); 304 metricsElement.addEventListener("mouseover", this._highlightDOMNode.bind(this, true, ""), false); 305 metricsElement.addEventListener("mouseout", this._highlightDOMNode.bind(this, false, ""), false); 266 metricsElement.addEventListener("mouseover", this._highlightDOMNode.bind(this, false, ""), false); 306 267 this.bodyElement.removeChildren(); 307 268 this.bodyElement.appendChild(metricsElement); … … 456 417 if (!("originalPropertyData" in self)) 457 418 self.originalPropertyData = self.previousPropertyDataCandidate; 458 if ("_highlightMode" in self) { 419 420 if (typeof self._highlightMode !== "undefined") { 459 421 WebInspector.highlightDOMNode(0, ""); 460 422 WebInspector.highlightDOMNode(self.node.id, self._highlightMode); 461 423 } 424 462 425 if (commitEditor) { 463 426 self.dispatchEventToListeners("metrics edited"); -
trunk/Source/WebCore/inspector/front-end/inspector.css
r95611 r95621 1870 1870 .metrics .label { 1871 1871 position: absolute; 1872 margin-top: -10px; 1873 font-size: 9px; 1874 color: grey; 1875 background-color: white; 1872 font-size: 10px; 1873 color: black; 1876 1874 margin-left: 3px; 1877 1875 padding-left: 2px; 1878 1876 padding-right: 2px; 1879 }1880 1881 .metrics .hovered > .label {1882 border: 1px solid black;1883 1877 } 1884 1878 -
trunk/Source/WebCore/inspector/front-end/inspector.js
r95553 r95621 369 369 mode = mode || "all"; 370 370 var highlightConfig = { showInfo: mode === "all" }; 371 if (mode === "all" || mode === "content") {371 if (mode === "all" || mode === "content") 372 372 highlightConfig.contentColor = WebInspector.Color.PageHighlight.Content.toProtocolRGBA(); 373 highlightConfig.contentOutlineColor = WebInspector.Color.PageHighlight.ContentOutline.toProtocolRGBA(); 374 } 375 376 if (mode === "all" || mode === "padding") { 373 374 if (mode === "all" || mode === "padding") 377 375 highlightConfig.paddingColor = WebInspector.Color.PageHighlight.Padding.toProtocolRGBA(); 378 highlightConfig.paddingOutlineColor = WebInspector.Color.PageHighlight.PaddingOutline.toProtocolRGBA(); 379 } 380 381 if (mode === "all" || mode === "border") { 376 377 if (mode === "all" || mode === "border") 382 378 highlightConfig.borderColor = WebInspector.Color.PageHighlight.Border.toProtocolRGBA(); 383 highlightConfig.borderOutlineColor = WebInspector.Color.PageHighlight.BorderOutline.toProtocolRGBA(); 384 } 385 386 if (mode === "all" || mode === "margin") { 379 380 if (mode === "all" || mode === "margin") 387 381 highlightConfig.marginColor = WebInspector.Color.PageHighlight.Margin.toProtocolRGBA(); 388 highlightConfig.marginOutlineColor = WebInspector.Color.PageHighlight.MarginOutline.toProtocolRGBA();389 }390 382 391 383 return highlightConfig; … … 398 390 delete this._hideDOMNodeHighlightTimeout; 399 391 } 400 401 if (this._highlightedDOMNodeId === nodeId)402 return;403 392 404 393 this._highlightedDOMNodeId = nodeId;
Note: See TracChangeset
for help on using the changeset viewer.