OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/editing/markers/TextMatchMarkerListImpl.h" | 5 #include "core/editing/markers/TextMatchMarkerListImpl.h" |
6 | 6 |
7 #include "core/dom/Node.h" | 7 #include "core/dom/Node.h" |
8 #include "core/dom/Range.h" | 8 #include "core/dom/Range.h" |
9 #include "core/editing/EphemeralRange.h" | 9 #include "core/editing/EphemeralRange.h" |
10 #include "core/editing/markers/DocumentMarkerListEditor.h" | 10 #include "core/editing/markers/DocumentMarkerListEditor.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (!rendered_marker->IsValid()) | 74 if (!rendered_marker->IsValid()) |
75 UpdateMarkerRenderedRect(node, *rendered_marker); | 75 UpdateMarkerRenderedRect(node, *rendered_marker); |
76 if (!rendered_marker->IsRendered()) | 76 if (!rendered_marker->IsRendered()) |
77 continue; | 77 continue; |
78 result.push_back(rendered_marker->RenderedRect()); | 78 result.push_back(rendered_marker->RenderedRect()); |
79 } | 79 } |
80 | 80 |
81 return result; | 81 return result; |
82 } | 82 } |
83 | 83 |
| 84 bool TextMatchMarkerListImpl::SetTextMatchMarkersActive(unsigned start_offset, |
| 85 unsigned end_offset, |
| 86 bool active) { |
| 87 bool doc_dirty = false; |
| 88 const auto start = std::upper_bound( |
| 89 markers_.begin(), markers_.end(), start_offset, |
| 90 [](size_t start_offset, const Member<DocumentMarker>& marker) { |
| 91 return start_offset < marker->EndOffset(); |
| 92 }); |
| 93 for (auto it = start; it != markers_.end(); ++it) { |
| 94 DocumentMarker& marker = **it; |
| 95 // Markers are returned in order, so stop if we are now past the specified |
| 96 // range. |
| 97 if (marker.StartOffset() >= end_offset) |
| 98 break; |
| 99 marker.SetIsActiveMatch(active); |
| 100 doc_dirty = true; |
| 101 } |
| 102 return doc_dirty; |
| 103 } |
| 104 |
84 } // namespace blink | 105 } // namespace blink |
OLD | NEW |