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

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

Issue 2805553003: DocumentMarkerList refactor as an interface (Closed)
Patch Set: Rebase on renaming patch, respond to comments 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 0c0c599f373fc60d566049c583dc6623a6b26474..43fb66f5d3d763baa901530d059d0b9613a48017 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
@@ -194,11 +194,6 @@ static bool DoesNotOverlap(const Member<RenderedDocumentMarker>& lhv,
return lhv->EndOffset() < rhv->StartOffset();
}
-static bool DoesNotInclude(const Member<RenderedDocumentMarker>& marker,
- size_t start_offset) {
- return marker->EndOffset() < start_offset;
-}
-
static void UpdateMarkerRenderedRect(const Node& node,
RenderedDocumentMarker& marker) {
Range* range = Range::Create(node.GetDocument());
@@ -286,14 +281,11 @@ void DocumentMarkerController::MergeOverlapping(
}
}
-// copies markers from srcNode to dstNode, applying the specified shift delta to
-// 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* src_node,
- unsigned start_offset,
+// Moves markers from src_node to dst_node. Markers are moved if their start
+// offset is less than length. Markers that run past that point are truncated.
+void DocumentMarkerController::MoveMarkers(Node* src_node,
int length,
- Node* dst_node,
- int delta) {
+ Node* dst_node) {
if (length <= 0)
return;
@@ -310,26 +302,25 @@ void DocumentMarkerController::CopyMarkers(Node* src_node,
if (!list)
continue;
- unsigned end_offset = start_offset + length - 1;
- MarkerList::iterator start_pos = std::lower_bound(
- list->begin(), list->end(), start_offset, DoesNotInclude);
- for (MarkerList::iterator i = start_pos; i != list->end(); ++i) {
- DocumentMarker* marker = i->Get();
+ unsigned end_offset = length - 1;
+ MarkerList::iterator it;
+ for (it = list->begin(); it != 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 and apply the shift delta
+ // pin the marker to the specified range
doc_dirty = true;
- if (marker->StartOffset() < start_offset)
- marker->SetStartOffset(start_offset);
if (marker->EndOffset() > end_offset)
marker->SetEndOffset(end_offset);
- marker->ShiftOffsets(delta);
AddMarker(dst_node, *marker);
}
+
+ // Remove the range of markers that were moved to dstNode
+ list->erase(0, it - list->begin());
}
// repaint the affected node

Powered by Google App Engine
This is Rietveld 408576698