Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp |
| index 723063240c45796675049c24957c8cabfd33b823..3ca0272a18c56e0da3172fc649819a4d854f84a4 100644 |
| --- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp |
| +++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp |
| @@ -322,25 +322,8 @@ void DocumentMarkerController::MoveMarkers(Node* src_node, |
| dst_markers->at(marker_list_index) = new MarkerList; |
| MarkerList* dst_list = dst_markers->at(marker_list_index); |
| - unsigned end_offset = length - 1; |
| - MarkerList::iterator it; |
| - for (it = src_list->begin(); it != src_list->end(); ++it) { |
| - DocumentMarker* marker = it->Get(); |
| - |
| - // stop if we are now past the specified range |
| - if (marker->StartOffset() > end_offset) |
| - break; |
| - |
| - // pin the marker to the specified range |
| + if (DocumentMarkerListEditor::MoveMarkers(src_list, length, dst_list)) |
| doc_dirty = true; |
| - if (marker->EndOffset() > end_offset) |
| - marker->SetEndOffset(end_offset); |
| - |
| - DocumentMarkerListEditor::AddMarker(dst_list, marker); |
| - } |
| - |
| - // Remove the range of markers that were moved to dst_node |
| - src_list->erase(0, it - src_list->begin()); |
| } |
| // repaint the affected node |
| @@ -350,6 +333,35 @@ void DocumentMarkerController::MoveMarkers(Node* src_node, |
| } |
| } |
| +// TODO(rlanday): move DocumentMarkerListEditor into its own .h/.cpp files |
| +bool DocumentMarkerListEditor::MoveMarkers(MarkerList* src_list, |
| + int length, |
| + MarkerList* dst_list) { |
| + DCHECK_GT(length, 0); |
| + bool doc_dirty = false; |
| + unsigned end_offset = length - 1; |
|
yosin_UTC9
2017/04/20 01:26:56
nit: s/unsigned/const unsigned/
|
| + MarkerList::iterator it; |
| + for (it = src_list->begin(); it != src_list->end(); ++it) { |
| + DocumentMarker* marker = it->Get(); |
| + |
| + // stop if we are now past the specified range |
| + if (marker->StartOffset() > end_offset) |
| + break; |
| + |
| + // pin the marker to the specified range |
| + doc_dirty = true; |
| + if (marker->EndOffset() > end_offset) |
| + marker->SetEndOffset(end_offset); |
| + |
| + DocumentMarkerListEditor::AddMarker(dst_list, marker); |
| + } |
| + |
| + // Remove the range of markers that were moved to dst_node |
| + src_list->erase(0, it - src_list->begin()); |
| + |
| + return doc_dirty; |
| +} |
| + |
| void DocumentMarkerController::RemoveMarkers( |
| Node* node, |
| unsigned start_offset, |