Chromium Code Reviews| 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 d9f0719b00d002cb16301afbaf210a432526875c..4ef3690a29281056d2f8edf8c36fe73652a0c71d 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 (equalIgnoringCase(matchStatus, "Active")) |
|
tkent
2017/04/05 04:16:32
Please don't use equalIgnoringCase(). It's unnece
|
| + return DocumentMarker::MatchStatus::Active; |
| + if (equalIgnoringCase(matchStatus, "Inactive")) |
| + return DocumentMarker::MatchStatus::Inactive; |
| + 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::Active |
| - : DocumentMarker::MatchStatus::Inactive); |
| + range->ownerDocument().markers().addTextMatchMarker(EphemeralRange(range), |
| + matchStatusEnum.value()); |
| // This simulates what the production code does after |
| // DocumentMarkerController::addTextMatchMarker(). |