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

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

Issue 2982313002: [MarkersIntersectingRange #2.05] Add DocumentMarkerList::FirstMarkerIntersectingRange() (Closed)
Patch Set: Rebase Created 3 years, 5 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 15e67cb4b31a065da253ce897e6a2f032f53c138..a65f41ca4bef356f5f583e42fe10074bb3e52402 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerListEditor.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerListEditor.cpp
@@ -166,6 +166,26 @@ bool DocumentMarkerListEditor::ShiftMarkersContentIndependent(
return did_shift_marker;
}
+DocumentMarker* DocumentMarkerListEditor::FirstMarkerIntersectingRange(
+ const MarkerList& list,
+ unsigned start_offset,
+ unsigned end_offset) {
+ DCHECK_LE(start_offset, end_offset);
+
+ const auto& marker_it =
+ std::lower_bound(list.begin(), list.end(), start_offset,
+ [](const DocumentMarker* marker, unsigned start_offset) {
+ return marker->EndOffset() <= start_offset;
+ });
+ if (marker_it == list.end())
+ return nullptr;
+
+ DocumentMarker* marker = *marker_it;
+ if (marker->StartOffset() >= end_offset)
+ return nullptr;
+ return marker;
+}
+
HeapVector<Member<DocumentMarker>>
DocumentMarkerListEditor::MarkersIntersectingRange(const MarkerList& list,
unsigned start_offset,

Powered by Google App Engine
This is Rietveld 408576698