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

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

Issue 2781623010: Add DocumentMarker::clone() (Closed)
Patch Set: Remove dependency that's messing with trybots 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 34506d1809171ca1ef41fdc04d995e252f4aa773..88a086d66a04c0dfddc71b9e67c2b84303420bb7 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
@@ -381,7 +381,7 @@ void DocumentMarkerController::removeMarkers(
MarkerList::iterator startPos =
std::upper_bound(list->begin(), list->end(), startOffset, endsBefore);
for (MarkerList::iterator i = startPos; i != list->end();) {
- DocumentMarker marker(*i->get());
+ const DocumentMarker& marker(*i->get());
// markers are returned in order, so stop if we are now past the specified
// range
@@ -401,18 +401,18 @@ void DocumentMarkerController::removeMarkers(
// add either of the resulting slices that are left after removing target
if (startOffset > marker.startOffset()) {
- DocumentMarker newLeft = marker;
- newLeft.setEndOffset(startOffset);
+ DocumentMarker* newLeft =
+ marker.cloneWithNewOffsets(marker.startOffset(), startOffset);
size_t insertIndex = i - list->begin();
- list->insert(insertIndex, RenderedDocumentMarker::create(newLeft));
+ list->insert(insertIndex, RenderedDocumentMarker::create(*newLeft));
// Move to the marker after the inserted one.
i = list->begin() + insertIndex + 1;
}
if (marker.endOffset() > endOffset) {
- DocumentMarker newRight = marker;
- newRight.setStartOffset(endOffset);
+ DocumentMarker* newRight =
+ marker.cloneWithNewOffsets(endOffset, marker.endOffset());
size_t insertIndex = i - list->begin();
- list->insert(insertIndex, RenderedDocumentMarker::create(newRight));
+ list->insert(insertIndex, RenderedDocumentMarker::create(*newRight));
// Move to the marker after the inserted one.
i = list->begin() + insertIndex + 1;
}

Powered by Google App Engine
This is Rietveld 408576698