OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 applyCommandToComposite(DeleteFromTextNodeCommand::create(node, offset, coun
t)); | 331 applyCommandToComposite(DeleteFromTextNodeCommand::create(node, offset, coun
t)); |
332 } | 332 } |
333 | 333 |
334 void CompositeEditCommand::replaceTextInNode(PassRefPtr<Text> node, unsigned off
set, unsigned count, const String& replacementText) | 334 void CompositeEditCommand::replaceTextInNode(PassRefPtr<Text> node, unsigned off
set, unsigned count, const String& replacementText) |
335 { | 335 { |
336 applyCommandToComposite(DeleteFromTextNodeCommand::create(node.get(), offset
, count)); | 336 applyCommandToComposite(DeleteFromTextNodeCommand::create(node.get(), offset
, count)); |
337 if (!replacementText.isEmpty()) | 337 if (!replacementText.isEmpty()) |
338 applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset,
replacementText)); | 338 applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset,
replacementText)); |
339 } | 339 } |
340 | 340 |
| 341 static void copyMarkers(const Vector<DocumentMarker*>& markerPointers, Vector<Do
cumentMarker>& markers) |
| 342 { |
| 343 size_t arraySize = markerPointers.size(); |
| 344 markers.reserveCapacity(arraySize); |
| 345 for (size_t i = 0; i < arraySize; ++i) |
| 346 markers.append(*markerPointers[i]); |
| 347 } |
| 348 |
341 void CompositeEditCommand::replaceTextInNodePreservingMarkers(PassRefPtr<Text> p
rpNode, unsigned offset, unsigned count, const String& replacementText) | 349 void CompositeEditCommand::replaceTextInNodePreservingMarkers(PassRefPtr<Text> p
rpNode, unsigned offset, unsigned count, const String& replacementText) |
342 { | 350 { |
343 RefPtr<Text> node(prpNode); | 351 RefPtr<Text> node(prpNode); |
344 DocumentMarkerController* markerController = document()->markers(); | 352 DocumentMarkerController* markerController = document()->markers(); |
345 Vector<DocumentMarker*> markers = markerController->markersInRange(Range::cr
eate(document(), node, offset, node, offset + count).get(), DocumentMarker::AllM
arkers()); | 353 Vector<DocumentMarker> markers; |
| 354 copyMarkers(markerController->markersInRange(Range::create(document(), node,
offset, node, offset + count).get(), DocumentMarker::AllMarkers()), markers); |
346 replaceTextInNode(node, offset, count, replacementText); | 355 replaceTextInNode(node, offset, count, replacementText); |
347 RefPtr<Range> newRange = Range::create(document(), node, offset, node, offse
t + replacementText.length()); | 356 RefPtr<Range> newRange = Range::create(document(), node, offset, node, offse
t + replacementText.length()); |
348 for (size_t i = 0; i < markers.size(); ++i) { | 357 for (size_t i = 0; i < markers.size(); ++i) { |
349 if (markers[i]->hasDescription()) | 358 if (markers[i].hasDescription()) |
350 markerController->addMarker(newRange.get(), markers[i]->type(), mark
ers[i]->description()); | 359 markerController->addMarker(newRange.get(), markers[i].type(), marke
rs[i].description()); |
351 else | 360 else |
352 markerController->addMarker(newRange.get(), markers[i]->type()); | 361 markerController->addMarker(newRange.get(), markers[i].type()); |
353 } | 362 } |
354 } | 363 } |
355 | 364 |
356 Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos) | 365 Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos) |
357 { | 366 { |
358 if (!isTabSpanTextNode(pos.anchorNode())) | 367 if (!isTabSpanTextNode(pos.anchorNode())) |
359 return pos; | 368 return pos; |
360 | 369 |
361 if (pos.anchorType() == Position::PositionIsAfterAnchor) | 370 if (pos.anchorType() == Position::PositionIsAfterAnchor) |
362 return positionInParentAfterNode(pos.anchorNode()); | 371 return positionInParentAfterNode(pos.anchorNode()); |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 return node.release(); | 1263 return node.release(); |
1255 } | 1264 } |
1256 | 1265 |
1257 PassRefPtr<Element> createBlockPlaceholderElement(Document* document) | 1266 PassRefPtr<Element> createBlockPlaceholderElement(Document* document) |
1258 { | 1267 { |
1259 RefPtr<Element> breakNode = document->createElement(brTag, false); | 1268 RefPtr<Element> breakNode = document->createElement(brTag, false); |
1260 return breakNode.release(); | 1269 return breakNode.release(); |
1261 } | 1270 } |
1262 | 1271 |
1263 } // namespace WebCore | 1272 } // namespace WebCore |
OLD | NEW |