Chromium Code Reviews| 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 |