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

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

Issue 2819173002: [DMC #1.1] Refactor DocumentMarkerController::MoveMarkers() (Closed)
Patch Set: Refactor without adding a helper method yet 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
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 5d47585ad720c1d5d7a22a050c6b320aad83a7d4..9ad0fc5352746f93893401dfa5b36ac3a8d89266 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
@@ -294,18 +294,31 @@ void DocumentMarkerController::MoveMarkers(Node* src_node,
return;
DCHECK(!markers_.IsEmpty());
- MarkerLists* markers = markers_.at(src_node);
- if (!markers)
+ MarkerLists* src_markers = markers_.at(src_node);
+ if (!src_markers)
return;
+ if (!markers_.Contains(dst_node)) {
+ markers_.insert(dst_node,
+ new MarkerLists(DocumentMarker::kMarkerTypeIndexesCount));
+ }
+ MarkerLists* dst_markers = markers_.at(dst_node);
+
bool doc_dirty = false;
- for (Member<MarkerList> list : *markers) {
- if (!list)
+ for (size_t marker_list_index = 0; marker_list_index < src_markers->size();
+ marker_list_index++) {
+ MarkerList* src_list = src_markers->at(marker_list_index);
+ if (!src_list)
continue;
+ if (!dst_markers->at(marker_list_index)) {
+ 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 = list->begin(); it != list->end(); ++it) {
+ for (it = src_list->begin(); it != src_list->end(); ++it) {
DocumentMarker* marker = it->Get();
// stop if we are now past the specified range
@@ -317,11 +330,11 @@ void DocumentMarkerController::MoveMarkers(Node* src_node,
if (marker->EndOffset() > end_offset)
marker->SetEndOffset(end_offset);
- AddMarker(dst_node, *marker);
+ DocumentMarkerListEditor::AddMarker(dst_list, marker);
}
- // Remove the range of markers that were moved to dstNode
- list->erase(0, it - list->begin());
+ // Remove the range of markers that were moved to dst_node
+ src_list->erase(0, it - src_list->begin());
}
// repaint the affected node

Powered by Google App Engine
This is Rietveld 408576698