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/DocumentMarkerListEditor.h" | 5 #include "core/editing/markers/DocumentMarkerListEditor.h" |
6 | 6 |
7 #include "core/editing/markers/SpellCheckMarkerListImpl.h" | 7 #include "core/editing/markers/SpellCheckMarkerListImpl.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 marker.SetStartOffset(result.value().start_offset); | 159 marker.SetStartOffset(result.value().start_offset); |
160 marker.SetEndOffset(result.value().end_offset); | 160 marker.SetEndOffset(result.value().end_offset); |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 list->erase(erase_range_begin - list->begin(), | 164 list->erase(erase_range_begin - list->begin(), |
165 erase_range_end - erase_range_begin); | 165 erase_range_end - erase_range_begin); |
166 return did_shift_marker; | 166 return did_shift_marker; |
167 } | 167 } |
168 | 168 |
| 169 HeapVector<Member<DocumentMarker>> |
| 170 DocumentMarkerListEditor::MarkersIntersectingRange(const MarkerList& list, |
| 171 unsigned start_offset, |
| 172 unsigned end_offset) { |
| 173 DCHECK_LE(start_offset, end_offset); |
| 174 |
| 175 const auto& start_it = |
| 176 std::lower_bound(list.begin(), list.end(), start_offset, |
| 177 [](const DocumentMarker* marker, unsigned start_offset) { |
| 178 return marker->EndOffset() <= start_offset; |
| 179 }); |
| 180 const auto& end_it = |
| 181 std::upper_bound(list.begin(), list.end(), end_offset, |
| 182 [](unsigned end_offset, const DocumentMarker* marker) { |
| 183 return end_offset <= marker->StartOffset(); |
| 184 }); |
| 185 |
| 186 HeapVector<Member<DocumentMarker>> results; |
| 187 std::copy(start_it, end_it, std::back_inserter(results)); |
| 188 return results; |
| 189 } |
| 190 |
169 } // namespace blink | 191 } // namespace blink |
OLD | NEW |