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 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 unsigned Internals::activeMarkerCountForNode(Node* node) { | 947 unsigned Internals::activeMarkerCountForNode(Node* node) { |
948 DCHECK(node); | 948 DCHECK(node); |
949 | 949 |
950 // Only TextMatch markers can be active. | 950 // Only TextMatch markers can be active. |
951 DocumentMarker::MarkerType markerType = DocumentMarker::TextMatch; | 951 DocumentMarker::MarkerType markerType = DocumentMarker::TextMatch; |
952 DocumentMarkerVector markers = | 952 DocumentMarkerVector markers = |
953 node->document().markers().markersFor(node, markerType); | 953 node->document().markers().markersFor(node, markerType); |
954 | 954 |
955 unsigned activeMarkerCount = 0; | 955 unsigned activeMarkerCount = 0; |
956 for (const auto& marker : markers) { | 956 for (const auto& marker : markers) { |
957 if (marker->activeMatch()) | 957 if (marker->activeMatch() == DocumentMarker::MatchStatus::Active) |
958 activeMarkerCount++; | 958 activeMarkerCount++; |
959 } | 959 } |
960 | 960 |
961 return activeMarkerCount; | 961 return activeMarkerCount; |
962 } | 962 } |
963 | 963 |
964 DocumentMarker* Internals::markerAt(Node* node, | 964 DocumentMarker* Internals::markerAt(Node* node, |
965 const String& markerType, | 965 const String& markerType, |
966 unsigned index, | 966 unsigned index, |
967 ExceptionState& exceptionState) { | 967 ExceptionState& exceptionState) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 void Internals::addTextMatchMarker(const Range* range, bool isActive) { |
1008 DCHECK(range); | 1008 DCHECK(range); |
1009 if (!range->ownerDocument().view()) | 1009 if (!range->ownerDocument().view()) |
1010 return; | 1010 return; |
1011 | 1011 |
1012 range->ownerDocument().updateStyleAndLayoutIgnorePendingStylesheets(); | 1012 range->ownerDocument().updateStyleAndLayoutIgnorePendingStylesheets(); |
1013 range->ownerDocument().markers().addTextMatchMarker(EphemeralRange(range), | 1013 range->ownerDocument().markers().addTextMatchMarker( |
1014 isActive); | 1014 EphemeralRange(range), isActive ? DocumentMarker::MatchStatus::Active |
| 1015 : DocumentMarker::MatchStatus::Inactive); |
1015 | 1016 |
1016 // This simulates what the production code does after | 1017 // This simulates what the production code does after |
1017 // DocumentMarkerController::addTextMatchMarker(). | 1018 // DocumentMarkerController::addTextMatchMarker(). |
1018 range->ownerDocument().view()->invalidatePaintForTickmarks(); | 1019 range->ownerDocument().view()->invalidatePaintForTickmarks(); |
1019 } | 1020 } |
1020 | 1021 |
1021 static bool parseColor(const String& value, | 1022 static bool parseColor(const String& value, |
1022 Color& color, | 1023 Color& color, |
1023 ExceptionState& exceptionState, | 1024 ExceptionState& exceptionState, |
1024 String errorMessage) { | 1025 String errorMessage) { |
(...skipping 20 matching lines...) Expand all Loading... |
1045 "Invalid background color.")) { | 1046 "Invalid background color.")) { |
1046 range->ownerDocument().markers().addCompositionMarker( | 1047 range->ownerDocument().markers().addCompositionMarker( |
1047 range->startPosition(), range->endPosition(), underlineColor, thick, | 1048 range->startPosition(), range->endPosition(), underlineColor, thick, |
1048 backgroundColor); | 1049 backgroundColor); |
1049 } | 1050 } |
1050 } | 1051 } |
1051 | 1052 |
1052 void Internals::setMarkersActive(Node* node, | 1053 void Internals::setMarkersActive(Node* node, |
1053 unsigned startOffset, | 1054 unsigned startOffset, |
1054 unsigned endOffset, | 1055 unsigned endOffset, |
1055 bool active) { | 1056 bool isActive) { |
1056 DCHECK(node); | 1057 DCHECK(node); |
1057 node->document().markers().setMarkersActive(node, startOffset, endOffset, | 1058 node->document().markers().setMarkersActive( |
1058 active); | 1059 node, startOffset, endOffset, |
| 1060 isActive ? DocumentMarker::MatchStatus::Active |
| 1061 : DocumentMarker::MatchStatus::Inactive); |
1059 } | 1062 } |
1060 | 1063 |
1061 void Internals::setMarkedTextMatchesAreHighlighted(Document* document, | 1064 void Internals::setMarkedTextMatchesAreHighlighted(Document* document, |
1062 bool highlight) { | 1065 bool highlight) { |
1063 if (!document || !document->frame()) | 1066 if (!document || !document->frame()) |
1064 return; | 1067 return; |
1065 | 1068 |
1066 document->frame()->editor().setMarkedTextMatchesAreHighlighted(highlight); | 1069 document->frame()->editor().setMarkedTextMatchesAreHighlighted(highlight); |
1067 } | 1070 } |
1068 | 1071 |
(...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3220 | 3223 |
3221 void Internals::crash() { | 3224 void Internals::crash() { |
3222 CHECK(false) << "Intentional crash"; | 3225 CHECK(false) << "Intentional crash"; |
3223 } | 3226 } |
3224 | 3227 |
3225 void Internals::setIsLowEndDevice(bool isLowEndDevice) { | 3228 void Internals::setIsLowEndDevice(bool isLowEndDevice) { |
3226 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); | 3229 MemoryCoordinator::setIsLowEndDeviceForTesting(isLowEndDevice); |
3227 } | 3230 } |
3228 | 3231 |
3229 } // namespace blink | 3232 } // namespace blink |
OLD | NEW |