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 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 |