- Revision
- 134415
- Author
- [email protected]
- Date
- 2012-11-13 07:23:12 -0800 (Tue, 13 Nov 2012)
Log Message
Merge 133885 - Web Inspector: Add option to disable rulers (Elements panel)
https://bugs.webkit.org/show_bug.cgi?id=101554
Reviewed by Pavel Feldman.
A new setting, showMetricsRulers, has been introduced (off by default, so users need to opt in to see the rulers).
The setting value is passed into InspectorDOMAgent, down to the InspectorOverlayPage, which affects the drawGrid() and
drawRulers() calls. As a side effect, the issue when the rulers were painted for elements having no renderers has been fixed.
No new tests, a UI change.
* English.lproj/localizedStrings.js: Add "Show rulers" string.
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::highlightConfigFromInspectorObject): Copy over the showRulers value.
* inspector/InspectorOverlay.cpp:
(WebCore::buildObjectForHighlight): Copy over the showRulers value.
* inspector/InspectorOverlay.h:
(HighlightConfig): Add |bool showRulers|.
(WebCore::Highlight::Highlight): Initialize fields.
(Highlight): Add |bool showRulers|.
(WebCore::Highlight::setDataFromConfig):
* inspector/InspectorOverlayPage.html:
* inspector/front-end/DOMAgent.js: Make use of WebInspector.settings.showMetricsRulers when building the highlight DTO.
* inspector/front-end/Settings.js: Add showMetricsRulers.
* inspector/front-end/SettingsScreen.js:
(WebInspector.GenericSettingsTab): Add "Show rulers" checkbox in the Elements panel section.
[email protected]
Review URL: https://codereview.chromium.org/11366221
Modified Paths
Diff
Modified: branches/chromium/1312/Source/WebCore/English.lproj/localizedStrings.js (134414 => 134415)
--- branches/chromium/1312/Source/WebCore/English.lproj/localizedStrings.js 2012-11-13 15:15:04 UTC (rev 134414)
+++ branches/chromium/1312/Source/WebCore/English.lproj/localizedStrings.js 2012-11-13 15:23:12 UTC (rev 134415)
@@ -369,6 +369,7 @@
localizedStrings["Show console."] = "Show console.";
localizedStrings["Show function definition"] = "Show function definition";
localizedStrings["Show inherited"] = "Show inherited";
+localizedStrings["Show rulers"] = "Show rulers";
localizedStrings["Show Shadow DOM"] = "Show Shadow DOM";
localizedStrings["Show the records that are shorter than %s"] = "Show the records that are shorter than %s";
localizedStrings["Show times as percentages."] = "Show times as percentages.";
Modified: branches/chromium/1312/Source/WebCore/inspector/InspectorDOMAgent.cpp (134414 => 134415)
--- branches/chromium/1312/Source/WebCore/inspector/InspectorDOMAgent.cpp 2012-11-13 15:15:04 UTC (rev 134414)
+++ branches/chromium/1312/Source/WebCore/inspector/InspectorDOMAgent.cpp 2012-11-13 15:23:12 UTC (rev 134415)
@@ -1042,6 +1042,9 @@
bool showInfo = false; // Default: false (do not show a tooltip).
highlightInspectorObject->getBoolean("showInfo", &showInfo);
highlightConfig->showInfo = showInfo;
+ bool showRulers = false; // Default: false (do not show rulers).
+ highlightInspectorObject->getBoolean("showRulers", &showRulers);
+ highlightConfig->showRulers = showRulers;
highlightConfig->content = parseConfigColor("contentColor", highlightInspectorObject);
highlightConfig->contentOutline = parseConfigColor("contentOutlineColor", highlightInspectorObject);
highlightConfig->padding = parseConfigColor("paddingColor", highlightInspectorObject);
Modified: branches/chromium/1312/Source/WebCore/inspector/InspectorOverlay.cpp (134414 => 134415)
--- branches/chromium/1312/Source/WebCore/inspector/InspectorOverlay.cpp 2012-11-13 15:15:04 UTC (rev 134414)
+++ branches/chromium/1312/Source/WebCore/inspector/InspectorOverlay.cpp 2012-11-13 15:23:12 UTC (rev 134415)
@@ -109,7 +109,7 @@
if (!renderer || !containingFrame)
return;
- highlight->setColors(highlightConfig);
+ highlight->setDataFromConfig(highlightConfig);
FrameView* containingView = containingFrame->view();
FrameView* mainView = containingFrame->page()->mainFrame()->view();
IntRect boundingBox = pixelSnappedIntRect(containingView->contentsToRootView(renderer->absoluteBoundingBoxRect()));
@@ -186,7 +186,7 @@
{
if (!page)
return;
- highlight->setColors(highlightConfig);
+ highlight->setDataFromConfig(highlightConfig);
FloatRect highlightRect(*rect);
highlight->type = HighlightTypeRects;
highlight->quads.append(highlightRect);
@@ -336,6 +336,7 @@
for (size_t i = 0; i < highlight.quads.size(); ++i)
array->pushArray(buildArrayForQuad(highlight.quads[i]));
object->setArray("quads", array.release());
+ object->setBoolean("showRulers", highlight.showRulers);
object->setString("contentColor", highlight.contentColor.serialized());
object->setString("contentOutlineColor", highlight.contentOutlineColor.serialized());
object->setString("paddingColor", highlight.paddingColor.serialized());
Modified: branches/chromium/1312/Source/WebCore/inspector/InspectorOverlay.h (134414 => 134415)
--- branches/chromium/1312/Source/WebCore/inspector/InspectorOverlay.h 2012-11-13 15:15:04 UTC (rev 134414)
+++ branches/chromium/1312/Source/WebCore/inspector/InspectorOverlay.h 2012-11-13 15:23:12 UTC (rev 134415)
@@ -58,6 +58,7 @@
Color border;
Color margin;
bool showInfo;
+ bool showRulers;
};
enum HighlightType {
@@ -66,13 +67,20 @@
};
struct Highlight {
- void setColors(const HighlightConfig& highlightConfig)
+ Highlight()
+ : type(HighlightTypeNode)
+ , showRulers(false)
{
+ }
+
+ void setDataFromConfig(const HighlightConfig& highlightConfig)
+ {
contentColor = highlightConfig.content;
contentOutlineColor = highlightConfig.contentOutline;
paddingColor = highlightConfig.padding;
borderColor = highlightConfig.border;
marginColor = highlightConfig.margin;
+ showRulers = highlightConfig.showRulers;
}
Color contentColor;
@@ -85,6 +93,7 @@
// When the type is Rects, this is just a list of quads.
HighlightType type;
Vector<FloatQuad> quads;
+ bool showRulers;
};
class InspectorOverlay {
Modified: branches/chromium/1312/Source/WebCore/inspector/InspectorOverlayPage.html (134414 => 134415)
--- branches/chromium/1312/Source/WebCore/inspector/InspectorOverlayPage.html 2012-11-13 15:15:04 UTC (rev 134414)
+++ branches/chromium/1312/Source/WebCore/inspector/InspectorOverlayPage.html 2012-11-13 15:23:12 UTC (rev 134415)
@@ -124,6 +124,8 @@
function _drawGrid(highlight, rulerAtRight, rulerAtBottom)
{
+ if (!highlight.showRulers)
+ return;
context.save();
var width = canvas.width;
@@ -403,6 +405,8 @@
function _drawRulers(highlight, rulerAtRight, rulerAtBottom)
{
+ if (!highlight.showRulers)
+ return;
context.save();
var width = canvas.width;
var height = canvas.height;
Modified: branches/chromium/1312/Source/WebCore/inspector/front-end/DOMAgent.js (134414 => 134415)
--- branches/chromium/1312/Source/WebCore/inspector/front-end/DOMAgent.js 2012-11-13 15:15:04 UTC (rev 134414)
+++ branches/chromium/1312/Source/WebCore/inspector/front-end/DOMAgent.js 2012-11-13 15:23:12 UTC (rev 134415)
@@ -1242,7 +1242,7 @@
_buildHighlightConfig: function(mode)
{
mode = mode || "all";
- var highlightConfig = { showInfo: mode === "all" };
+ var highlightConfig = { showInfo: mode === "all", showRulers: WebInspector.settings.showMetricsRulers.get() };
if (mode === "all" || mode === "content")
highlightConfig.contentColor = WebInspector.Color.PageHighlight.Content.toProtocolRGBA();
Modified: branches/chromium/1312/Source/WebCore/inspector/front-end/Settings.js (134414 => 134415)
--- branches/chromium/1312/Source/WebCore/inspector/front-end/Settings.js 2012-11-13 15:15:04 UTC (rev 134414)
+++ branches/chromium/1312/Source/WebCore/inspector/front-end/Settings.js 2012-11-13 15:23:12 UTC (rev 134415)
@@ -108,6 +108,7 @@
this.lastDockState = this.createSetting("lastDockState", "");
this.cssReloadEnabled = this.createSetting("cssReloadEnabled", false);
this.cssReloadTimeout = this.createSetting("cssReloadTimeout", 1000);
+ this.showMetricsRulers = this.createSetting("showMetricsRulers", false);
// If there are too many breakpoints in a storage, it is likely due to a recent bug that caused
// periodical breakpoints duplication leading to inspector slowness.
Modified: branches/chromium/1312/Source/WebCore/inspector/front-end/SettingsScreen.js (134414 => 134415)
--- branches/chromium/1312/Source/WebCore/inspector/front-end/SettingsScreen.js 2012-11-13 15:15:04 UTC (rev 134414)
+++ branches/chromium/1312/Source/WebCore/inspector/front-end/SettingsScreen.js 2012-11-13 15:23:12 UTC (rev 134415)
@@ -267,6 +267,7 @@
p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show user agent styles"), WebInspector.settings.showUserAgentStyles));
p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Word wrap"), WebInspector.settings.domWordWrap));
p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show Shadow DOM"), WebInspector.settings.showShadowDOM));
+ p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show rulers"), WebInspector.settings.showMetricsRulers));
p = this._appendSection(WebInspector.UIString("Rendering"));
p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show paint rectangles"), WebInspector.settings.showPaintRects));