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

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

Issue 2802543002: Update window.internals.addTextMatchMarker() to take enum instead of bool (Closed)
Patch Set: Fix one more test, add k prefix Created 3 years, 8 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 2a87e985d6004a31dcb953b1c46a88a4f74465a0..ec9db11a24432a1646ed9c610967bfd68a565ae2 100644
--- a/third_party/WebKit/Source/core/testing/Internals.cpp
+++ b/third_party/WebKit/Source/core/testing/Internals.cpp
@@ -1004,15 +1004,34 @@ String Internals::markerDescriptionForNode(Node* node,
return marker->description();
}
-void Internals::addTextMatchMarker(const Range* range, bool isActive) {
+static WTF::Optional<DocumentMarker::MatchStatus> matchStatusFrom(
+ const String& matchStatus) {
+ if (equalIgnoringASCIICase(matchStatus, "kActive"))
+ return DocumentMarker::MatchStatus::kActive;
+ if (equalIgnoringASCIICase(matchStatus, "kInactive"))
+ return DocumentMarker::MatchStatus::kInactive;
+ return WTF::nullopt;
+}
+
+void Internals::addTextMatchMarker(const Range* range,
+ const String& matchStatus,
+ ExceptionState& exceptionState) {
DCHECK(range);
if (!range->ownerDocument().view())
return;
+ WTF::Optional<DocumentMarker::MatchStatus> matchStatusEnum =
+ matchStatusFrom(matchStatus);
+ if (!matchStatusEnum) {
+ exceptionState.throwDOMException(
+ SyntaxError,
+ "The match status provided ('" + matchStatus + "') is invalid.");
+ return;
+ }
+
range->ownerDocument().updateStyleAndLayoutIgnorePendingStylesheets();
- range->ownerDocument().markers().addTextMatchMarker(
- EphemeralRange(range), isActive ? DocumentMarker::MatchStatus::kActive
- : DocumentMarker::MatchStatus::kInactive);
+ range->ownerDocument().markers().addTextMatchMarker(EphemeralRange(range),
+ matchStatusEnum.value());
// This simulates what the production code does after
// DocumentMarkerController::addTextMatchMarker().
« 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