Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: third_party/WebKit/Source/core/editing/markers/DocumentMarkerListEditor.cpp

Issue 2952953002: [MarkersIntersectingRange #1] Add DocumentMarkerList::MarkersIntersectingRange() (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/markers/DocumentMarkerListEditor.cpp
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerListEditor.cpp b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerListEditor.cpp
index f8c1e23cd8168975b3a6a297d470d457dad1c62d..15e67cb4b31a065da253ce897e6a2f032f53c138 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerListEditor.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerListEditor.cpp
@@ -166,4 +166,26 @@ bool DocumentMarkerListEditor::ShiftMarkersContentIndependent(
return did_shift_marker;
}
+HeapVector<Member<DocumentMarker>>
+DocumentMarkerListEditor::MarkersIntersectingRange(const MarkerList& list,
+ unsigned start_offset,
+ unsigned end_offset) {
+ DCHECK_LE(start_offset, end_offset);
+
+ const auto& start_it =
+ std::lower_bound(list.begin(), list.end(), start_offset,
+ [](const DocumentMarker* marker, unsigned start_offset) {
+ return marker->EndOffset() <= start_offset;
+ });
+ const auto& end_it =
+ std::upper_bound(list.begin(), list.end(), end_offset,
+ [](unsigned end_offset, const DocumentMarker* marker) {
+ return end_offset <= marker->StartOffset();
+ });
+
+ HeapVector<Member<DocumentMarker>> results;
+ std::copy(start_it, end_it, std::back_inserter(results));
+ return results;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698