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

Unified Diff: third_party/WebKit/Source/core/testing/Internals.cpp

Issue 2906953002: [DMC #26] Add CompositionMarker::Thickness enum (Closed)
Patch Set: Rebase Created 3 years, 7 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/testing/Internals.cpp
diff --git a/third_party/WebKit/Source/core/testing/Internals.cpp b/third_party/WebKit/Source/core/testing/Internals.cpp
index 6829be1f8447ec9f0b27c28584da1f167635c161..4f71ec46e387a89a8637838b949b9e822e8c1c86 100644
--- a/third_party/WebKit/Source/core/testing/Internals.cpp
+++ b/third_party/WebKit/Source/core/testing/Internals.cpp
@@ -1061,14 +1061,32 @@ static bool ParseColor(const String& value,
return true;
}
+static WTF::Optional<CompositionMarker::Thickness> ThicknessFrom(
+ const String& thickness) {
+ if (EqualIgnoringASCIICase(thickness, "thin"))
+ return CompositionMarker::Thickness::kThin;
+ if (EqualIgnoringASCIICase(thickness, "thick"))
+ return CompositionMarker::Thickness::kThick;
+ return WTF::nullopt;
+}
+
void Internals::addCompositionMarker(const Range* range,
const String& underline_color_value,
- bool thick,
+ const String& thickness_value,
const String& background_color_value,
ExceptionState& exception_state) {
DCHECK(range);
range->OwnerDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
+ WTF::Optional<CompositionMarker::Thickness> thickness =
+ ThicknessFrom(thickness_value);
+ if (!thickness) {
+ exception_state.ThrowDOMException(
+ kSyntaxError,
+ "The thickness provided ('" + thickness_value + "') is invalid.");
+ return;
+ }
+
Color underline_color;
Color background_color;
if (ParseColor(underline_color_value, underline_color, exception_state,
@@ -1076,7 +1094,8 @@ void Internals::addCompositionMarker(const Range* range,
ParseColor(background_color_value, background_color, exception_state,
"Invalid background color.")) {
range->OwnerDocument().Markers().AddCompositionMarker(
- EphemeralRange(range), underline_color, thick, background_color);
+ EphemeralRange(range), underline_color, thickness.value(),
+ background_color);
}
}
« no previous file with comments | « third_party/WebKit/Source/core/testing/Internals.h ('k') | third_party/WebKit/Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698