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

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

Issue 2820983002: [DMC #1.2] Add DocumentMarkerListEditor::MoveMarkers() (Closed)
Patch Set: Fix nit Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6773d52d4c10b7a5a7333e845192b2079d9496f1..8fd8a1134328f25716b7ae9f7434673b1bf06842 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;
+ const 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
+ 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,
« no previous file with comments | « third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698