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

Unified Diff: Source/WebCore/editing/CompositeEditCommand.cpp

Issue 7541053: Merge 91308 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/782/
Patch Set: Created 9 years, 4 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
« no previous file with comments | « LayoutTests/editing/undo/replace-text-in-node-preserving-markers-crash-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/editing/CompositeEditCommand.cpp
===================================================================
--- Source/WebCore/editing/CompositeEditCommand.cpp (revision 92518)
+++ Source/WebCore/editing/CompositeEditCommand.cpp (working copy)
@@ -338,18 +338,27 @@
applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset, replacementText));
}
+static void copyMarkers(const Vector<DocumentMarker*>& markerPointers, Vector<DocumentMarker>& markers)
+{
+ size_t arraySize = markerPointers.size();
+ markers.reserveCapacity(arraySize);
+ for (size_t i = 0; i < arraySize; ++i)
+ markers.append(*markerPointers[i]);
+}
+
void CompositeEditCommand::replaceTextInNodePreservingMarkers(PassRefPtr<Text> prpNode, unsigned offset, unsigned count, const String& replacementText)
{
RefPtr<Text> node(prpNode);
DocumentMarkerController* markerController = document()->markers();
- Vector<DocumentMarker*> markers = markerController->markersInRange(Range::create(document(), node, offset, node, offset + count).get(), DocumentMarker::AllMarkers());
+ Vector<DocumentMarker> markers;
+ copyMarkers(markerController->markersInRange(Range::create(document(), node, offset, node, offset + count).get(), DocumentMarker::AllMarkers()), markers);
replaceTextInNode(node, offset, count, replacementText);
RefPtr<Range> newRange = Range::create(document(), node, offset, node, offset + replacementText.length());
for (size_t i = 0; i < markers.size(); ++i) {
- if (markers[i]->hasDescription())
- markerController->addMarker(newRange.get(), markers[i]->type(), markers[i]->description());
+ if (markers[i].hasDescription())
+ markerController->addMarker(newRange.get(), markers[i].type(), markers[i].description());
else
- markerController->addMarker(newRange.get(), markers[i]->type());
+ markerController->addMarker(newRange.get(), markers[i].type());
}
}
« no previous file with comments | « LayoutTests/editing/undo/replace-text-in-node-preserving-markers-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698