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

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

Issue 2810463002: Clean up DocumentMarkerController::copyMarkers() (now it's moveMarkers()) (Closed)
Patch Set: 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 5190265f33c8bfcc2b2d67973e228330fb6b1a12..b3def90b7cd0b15f705cb89aaaf2dd9d53fa14ab 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
@@ -291,10 +291,10 @@ void DocumentMarkerController::mergeOverlapping(
}
}
-// copies markers from srcNode to dstNode, applying the specified shift delta to
+// moves markers from srcNode to dstNode, applying the specified shift delta to
Xiaocheng 2017/04/08 02:46:40 Also remove the comment related to shifting. It's
// the copies. The shift is useful if, e.g., the caller has created the dstNode
// from a non-prefix substring of the srcNode.
-void DocumentMarkerController::copyMarkers(Node* srcNode,
+void DocumentMarkerController::moveMarkers(Node* srcNode,
unsigned startOffset,
int length,
Node* dstNode,
@@ -321,8 +321,9 @@ void DocumentMarkerController::copyMarkers(Node* srcNode,
unsigned endOffset = startOffset + length - 1;
MarkerList::iterator startPos = std::lower_bound(
list->begin(), list->end(), startOffset, doesNotInclude);
- for (MarkerList::iterator i = startPos; i != list->end(); ++i) {
- DocumentMarker* marker = i->get();
+ MarkerList::iterator it;
+ for (it = startPos; it != list->end(); ++it) {
+ DocumentMarker* marker = it->get();
// stop if we are now past the specified range
if (marker->startOffset() > endOffset)
@@ -338,6 +339,9 @@ void DocumentMarkerController::copyMarkers(Node* srcNode,
addMarker(dstNode, *marker);
}
+
+ // Remove the range of markers that were moved to dstNode
+ list->erase(startPos - list->begin(), it - startPos);
}
// repaint the affected node

Powered by Google App Engine
This is Rietveld 408576698