Chromium Code Reviews| 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 b629b20b3212183d45bdf9cba90c1df3961766e7..1bc44c0bafbcf78c2753f95b5065063cff022157 100644 |
| --- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerListEditor.cpp |
| +++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerListEditor.cpp |
| @@ -52,32 +52,25 @@ bool DocumentMarkerListEditor::MoveMarkers(MarkerList* src_list, |
| return didMoveMarker; |
| } |
| -// TODO(rlanday): this method was created by cutting and pasting code from |
| -// DocumentMarkerController::RemoveMarkers(), it should be refactored in a |
| -// future CL |
| bool DocumentMarkerListEditor::RemoveMarkers(MarkerList* list, |
| unsigned start_offset, |
| int length) { |
| - bool doc_dirty = false; |
| const unsigned end_offset = start_offset + length; |
| + |
|
yosin_UTC9
2017/06/02 01:11:45
nit: Please remove an extra blank line.
|
| MarkerList::iterator start_pos = std::upper_bound( |
| list->begin(), list->end(), start_offset, |
| [](size_t start_offset, const Member<DocumentMarker>& marker) { |
| return start_offset < marker->EndOffset(); |
| }); |
| - for (MarkerList::iterator i = start_pos; i != list->end();) { |
| - const DocumentMarker& marker = *i->Get(); |
| - |
| - // markers are returned in order, so stop if we are now past the specified |
| - // range |
| - if (marker.StartOffset() >= end_offset) |
| - break; |
| - list->erase(i - list->begin()); |
| - doc_dirty = true; |
| - } |
| + MarkerList::iterator end_pos = std::lower_bound( |
| + list->begin(), list->end(), end_offset, |
| + [](const Member<DocumentMarker>& marker, size_t end_offset) { |
| + return marker->StartOffset() < end_offset; |
| + }); |
| - return doc_dirty; |
| + list->erase(start_pos - list->begin(), end_pos - start_pos); |
| + return start_pos != end_pos; |
| } |
| // TODO(rlanday): make this not take O(n^2) time when all the markers are |