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

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp

Issue 1739613002: DevTools: validate protocol input parameters. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined a test. Created 4 years, 10 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: third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
index 5ebde8a03daf47aad183b9e6dfd1d563d5ca91dc..ccec715960b1b486a95e99d9fbf4848c54092ef5 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorDOMAgent.cpp
@@ -97,13 +97,9 @@ namespace {
const size_t maxTextSize = 10000;
const UChar ellipsisUChar[] = { 0x2026, 0 };
-Color parseColor(const Maybe<protocol::DOM::RGBA>& maybeRgba)
+Color parseColor(protocol::DOM::RGBA* rgba)
{
- if (!maybeRgba.isJust())
- return Color::transparent;
-
- protocol::DOM::RGBA* rgba = maybeRgba.fromJust();
- if (!rgba->hasR() && !rgba->hasG() && !rgba->hasB())
+ if (!rgba)
return Color::transparent;
int r = rgba->getR();
@@ -1169,8 +1165,8 @@ void InspectorDOMAgent::highlightQuad(ErrorString* errorString, PassOwnPtr<proto
void InspectorDOMAgent::innerHighlightQuad(PassOwnPtr<FloatQuad> quad, const Maybe<protocol::DOM::RGBA>& color, const Maybe<protocol::DOM::RGBA>& outlineColor)
{
OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new InspectorHighlightConfig());
- highlightConfig->content = parseColor(color);
- highlightConfig->contentOutline = parseColor(outlineColor);
+ highlightConfig->content = parseColor(color.fromMaybe(nullptr));
+ highlightConfig->contentOutline = parseColor(outlineColor.fromMaybe(nullptr));
if (m_client)
m_client->highlightQuad(quad, *highlightConfig);
}
@@ -1227,8 +1223,8 @@ void InspectorDOMAgent::highlightFrame(
if (frame && frame->deprecatedLocalOwner()) {
OwnPtr<InspectorHighlightConfig> highlightConfig = adoptPtr(new InspectorHighlightConfig());
highlightConfig->showInfo = true; // Always show tooltips for frames.
- highlightConfig->content = parseColor(color);
- highlightConfig->contentOutline = parseColor(outlineColor);
+ highlightConfig->content = parseColor(color.fromMaybe(nullptr));
+ highlightConfig->contentOutline = parseColor(outlineColor.fromMaybe(nullptr));
if (m_client)
m_client->highlightNode(frame->deprecatedLocalOwner(), *highlightConfig, false);
}

Powered by Google App Engine
This is Rietveld 408576698