Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/inspector/InspectorHighlight.h" | 6 #include "core/inspector/InspectorHighlight.h" |
| 7 | 7 |
| 8 #include "core/dom/ClientRect.h" | 8 #include "core/dom/ClientRect.h" |
| 9 #include "core/dom/PseudoElement.h" | 9 #include "core/dom/PseudoElement.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 config.contentOutline = Color(128, 0, 0, 0); | 421 config.contentOutline = Color(128, 0, 0, 0); |
| 422 config.padding = Color(0, 255, 0, 0); | 422 config.padding = Color(0, 255, 0, 0); |
| 423 config.border = Color(0, 0, 255, 0); | 423 config.border = Color(0, 0, 255, 0); |
| 424 config.margin = Color(255, 255, 255, 0); | 424 config.margin = Color(255, 255, 255, 0); |
| 425 config.eventTarget = Color(128, 128, 128, 0); | 425 config.eventTarget = Color(128, 128, 128, 0); |
| 426 config.shape = Color(0, 0, 0, 0); | 426 config.shape = Color(0, 0, 0, 0); |
| 427 config.shapeMargin = Color(128, 128, 128, 0); | 427 config.shapeMargin = Color(128, 128, 128, 0); |
| 428 config.showInfo = true; | 428 config.showInfo = true; |
| 429 config.showRulers = true; | 429 config.showRulers = true; |
| 430 config.showExtensionLines = true; | 430 config.showExtensionLines = true; |
| 431 config.showLayoutEditor = false; | |
| 431 return config; | 432 return config; |
| 432 } | 433 } |
| 433 | 434 |
| 435 static Color parseColor(const RefPtr<JSONObject>* colorObject) | |
| 436 { | |
| 437 if (!colorObject || !(*colorObject)) | |
| 438 return Color::transparent; | |
| 439 | |
| 440 int r; | |
| 441 int g; | |
| 442 int b; | |
| 443 bool success = (*colorObject)->getNumber("r", &r); | |
| 444 success |= (*colorObject)->getNumber("g", &g); | |
| 445 success |= (*colorObject)->getNumber("b", &b); | |
| 446 if (!success) | |
| 447 return Color::transparent; | |
| 448 | |
| 449 double a; | |
| 450 success = (*colorObject)->getNumber("a", &a); | |
| 451 if (!success) | |
| 452 return Color(r, g, b); | |
| 453 | |
| 454 // Clamp alpha to the [0..1] range. | |
| 455 if (a < 0) | |
| 456 a = 0; | |
| 457 else if (a > 1) | |
| 458 a = 1; | |
| 459 | |
| 460 return Color(r, g, b, static_cast<int>(a * 255)); | |
| 461 } | |
| 462 | |
| 463 static Color parseConfigColor(const String& fieldName, JSONObject* configObject) | |
| 464 { | |
| 465 const RefPtr<JSONObject> colorObject = configObject->getObject(fieldName); | |
| 466 return parseColor(&colorObject); | |
| 467 } | |
| 468 | |
| 469 // static | |
| 470 PassOwnPtr<InspectorHighlightConfig> InspectorHighlight::highlightConfigFromInsp ectorObject(JSONObject* highlightInspectorObject) | |
|
dgozman
2015/06/23 16:45:06
RefPtr<JSONObject>
| |
| 471 { | |
| 472 OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new InspectorHig hlightConfig()); | |
| 473 bool showInfo = false; // Default: false (do not show a tooltip). | |
| 474 highlightInspectorObject->getBoolean("showInfo", &showInfo); | |
| 475 highlightConfig->showInfo = showInfo; | |
| 476 bool showRulers = false; // Default: false (do not show rulers). | |
| 477 highlightInspectorObject->getBoolean("showRulers", &showRulers); | |
| 478 highlightConfig->showRulers = showRulers; | |
| 479 bool showExtensionLines = false; // Default: false (do not show extension li nes). | |
| 480 highlightInspectorObject->getBoolean("showExtensionLines", &showExtensionLin es); | |
| 481 highlightConfig->showExtensionLines = showExtensionLines; | |
| 482 bool showLayoutEditor = false; | |
| 483 highlightInspectorObject->getBoolean("showLayoutEditor", &showLayoutEditor); | |
| 484 highlightConfig->showLayoutEditor = showLayoutEditor; | |
| 485 highlightConfig->content = parseConfigColor("contentColor", highlightInspect orObject); | |
| 486 highlightConfig->contentOutline = parseConfigColor("contentOutlineColor", hi ghlightInspectorObject); | |
| 487 highlightConfig->padding = parseConfigColor("paddingColor", highlightInspect orObject); | |
| 488 highlightConfig->border = parseConfigColor("borderColor", highlightInspector Object); | |
| 489 highlightConfig->margin = parseConfigColor("marginColor", highlightInspector Object); | |
| 490 highlightConfig->eventTarget = parseConfigColor("eventTargetColor", highligh tInspectorObject); | |
| 491 highlightConfig->shape = parseConfigColor("shapeColor", highlightInspectorOb ject); | |
| 492 highlightConfig->shapeMargin = parseConfigColor("shapeMarginColor", highligh tInspectorObject); | |
| 493 | |
| 494 return highlightConfig.release(); | |
| 495 } | |
| 496 | |
| 497 // static | |
| 498 PassOwnPtr<InspectorHighlightConfig> InspectorHighlight::highlightConfigWithColo rs(const RefPtr<JSONObject>* color, const RefPtr<JSONObject>* outlineColor) | |
|
dgozman
2015/06/23 16:45:06
const RefPtr<>* ???
| |
| 499 { | |
| 500 OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new InspectorHig hlightConfig()); | |
| 501 highlightConfig->content = parseColor(color); | |
| 502 highlightConfig->contentOutline = parseColor(outlineColor); | |
| 503 return highlightConfig.release(); | |
| 504 } | |
| 505 | |
| 506 | |
| 507 | |
| 434 } // namespace blink | 508 } // namespace blink |
| OLD | NEW |