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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 String Internals::markerDescriptionForNode(Node* node, 997 String Internals::markerDescriptionForNode(Node* node,
998 const String& markerType, 998 const String& markerType,
999 unsigned index, 999 unsigned index,
1000 ExceptionState& exceptionState) { 1000 ExceptionState& exceptionState) {
1001 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState); 1001 DocumentMarker* marker = markerAt(node, markerType, index, exceptionState);
1002 if (!marker) 1002 if (!marker)
1003 return String(); 1003 return String();
1004 return marker->description(); 1004 return marker->description();
1005 } 1005 }
1006 1006
1007 void Internals::addTextMatchMarker(const Range* range, bool isActive) { 1007 static WTF::Optional<DocumentMarker::MatchStatus> matchStatusFrom(
1008 const String& matchStatus) {
1009 if (equalIgnoringASCIICase(matchStatus, "kActive"))
1010 return DocumentMarker::MatchStatus::kActive;
1011 if (equalIgnoringASCIICase(matchStatus, "kInactive"))
1012 return DocumentMarker::MatchStatus::kInactive;
1013 return WTF::nullopt;
1014 }
1015
1016 void Internals::addTextMatchMarker(const Range* range,
1017 const String& matchStatus,
1018 ExceptionState& exceptionState) {
1008 DCHECK(range); 1019 DCHECK(range);
1009 if (!range->ownerDocument().view()) 1020 if (!range->ownerDocument().view())
1010 return; 1021 return;
1011 1022
1023 WTF::Optional<DocumentMarker::MatchStatus> matchStatusEnum =
1024 matchStatusFrom(matchStatus);
1025 if (!matchStatusEnum) {
1026 exceptionState.throwDOMException(
1027 SyntaxError,
1028 "The match status provided ('" + matchStatus + "') is invalid.");
1029 return;
1030 }
1031
1012 range->ownerDocument().updateStyleAndLayoutIgnorePendingStylesheets(); 1032 range->ownerDocument().updateStyleAndLayoutIgnorePendingStylesheets();
1013 range->ownerDocument().markers().addTextMatchMarker( 1033 range->ownerDocument().markers().addTextMatchMarker(EphemeralRange(range),
1014 EphemeralRange(range), isActive ? DocumentMarker::MatchStatus::kActive 1034 matchStatusEnum.value());
1015 : DocumentMarker::MatchStatus::kInactive);
1016 1035
1017 // This simulates what the production code does after 1036 // This simulates what the production code does after
1018 // DocumentMarkerController::addTextMatchMarker(). 1037 // DocumentMarkerController::addTextMatchMarker().
1019 range->ownerDocument().view()->invalidatePaintForTickmarks(); 1038 range->ownerDocument().view()->invalidatePaintForTickmarks();
1020 } 1039 }
1021 1040
1022 static bool parseColor(const String& value, 1041 static bool parseColor(const String& value,
1023 Color& color, 1042 Color& color,
1024 ExceptionState& exceptionState, 1043 ExceptionState& exceptionState,
1025 String errorMessage) { 1044 String errorMessage) {
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3221 3240
3222 void Internals::crash() { 3241 void Internals::crash() {
3223 CHECK(false) << "Intentional crash"; 3242 CHECK(false) << "Intentional crash";
3224 } 3243 }
3225 3244
3226 void Internals::setIsLowEndDevice(bool isLowEndDevice) { 3245 void Internals::setIsLowEndDevice(bool isLowEndDevice) {
3227 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); 3246 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice);
3228 } 3247 }
3229 3248
3230 } // namespace blink 3249 } // namespace blink
OLDNEW
« 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