Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 (equalIgnoringCase(matchStatus, "Active")) | |
|
tkent
2017/04/05 04:16:32
Please don't use equalIgnoringCase(). It's unnece
| |
| 1010 return DocumentMarker::MatchStatus::Active; | |
| 1011 if (equalIgnoringCase(matchStatus, "Inactive")) | |
| 1012 return DocumentMarker::MatchStatus::Inactive; | |
| 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::Active | 1034 matchStatusEnum.value()); |
| 1015 : DocumentMarker::MatchStatus::Inactive); | |
| 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 Loading... | |
| 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 |
| OLD | NEW |