Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(976)

Unified Diff: Source/core/inspector/InspectorHighlight.cpp

Issue 1204453002: Devtools: Create layout editor experiment (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InspectorHighlight.cpp
diff --git a/Source/core/inspector/InspectorHighlight.cpp b/Source/core/inspector/InspectorHighlight.cpp
index 141ce470697d2a65a340439fa60941bda7eee5a5..cb0eaee3c7d63a4e89439544113eb350c255f025 100644
--- a/Source/core/inspector/InspectorHighlight.cpp
+++ b/Source/core/inspector/InspectorHighlight.cpp
@@ -428,7 +428,81 @@ InspectorHighlightConfig InspectorHighlight::defaultConfig()
config.showInfo = true;
config.showRulers = true;
config.showExtensionLines = true;
+ config.showLayoutEditor = false;
return config;
}
+static Color parseColor(const RefPtr<JSONObject>* colorObject)
+{
+ if (!colorObject || !(*colorObject))
+ return Color::transparent;
+
+ int r;
+ int g;
+ int b;
+ bool success = (*colorObject)->getNumber("r", &r);
+ success |= (*colorObject)->getNumber("g", &g);
+ success |= (*colorObject)->getNumber("b", &b);
+ if (!success)
+ return Color::transparent;
+
+ double a;
+ success = (*colorObject)->getNumber("a", &a);
+ if (!success)
+ return Color(r, g, b);
+
+ // Clamp alpha to the [0..1] range.
+ if (a < 0)
+ a = 0;
+ else if (a > 1)
+ a = 1;
+
+ return Color(r, g, b, static_cast<int>(a * 255));
+}
+
+static Color parseConfigColor(const String& fieldName, JSONObject* configObject)
+{
+ const RefPtr<JSONObject> colorObject = configObject->getObject(fieldName);
+ return parseColor(&colorObject);
+}
+
+// static
+PassOwnPtr<InspectorHighlightConfig> InspectorHighlight::highlightConfigFromInspectorObject(JSONObject* highlightInspectorObject)
dgozman 2015/06/23 16:45:06 RefPtr<JSONObject>
+{
+ OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new InspectorHighlightConfig());
+ 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;
+ bool showExtensionLines = false; // Default: false (do not show extension lines).
+ highlightInspectorObject->getBoolean("showExtensionLines", &showExtensionLines);
+ highlightConfig->showExtensionLines = showExtensionLines;
+ bool showLayoutEditor = false;
+ highlightInspectorObject->getBoolean("showLayoutEditor", &showLayoutEditor);
+ highlightConfig->showLayoutEditor = showLayoutEditor;
+ highlightConfig->content = parseConfigColor("contentColor", highlightInspectorObject);
+ highlightConfig->contentOutline = parseConfigColor("contentOutlineColor", highlightInspectorObject);
+ highlightConfig->padding = parseConfigColor("paddingColor", highlightInspectorObject);
+ highlightConfig->border = parseConfigColor("borderColor", highlightInspectorObject);
+ highlightConfig->margin = parseConfigColor("marginColor", highlightInspectorObject);
+ highlightConfig->eventTarget = parseConfigColor("eventTargetColor", highlightInspectorObject);
+ highlightConfig->shape = parseConfigColor("shapeColor", highlightInspectorObject);
+ highlightConfig->shapeMargin = parseConfigColor("shapeMarginColor", highlightInspectorObject);
+
+ return highlightConfig.release();
+}
+
+// static
+PassOwnPtr<InspectorHighlightConfig> InspectorHighlight::highlightConfigWithColors(const RefPtr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor)
dgozman 2015/06/23 16:45:06 const RefPtr<>* ???
+{
+ OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new InspectorHighlightConfig());
+ highlightConfig->content = parseColor(color);
+ highlightConfig->contentOutline = parseColor(outlineColor);
+ return highlightConfig.release();
+}
+
+
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698