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

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

Issue 2776203002: Migrate WTF::Vector::remove() to ::erase() (Closed)
Patch Set: rebase, repatch VectorTest 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
7 * reserved. 7 * reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 size_t index = firstOverlapping - list->begin(); 278 size_t index = firstOverlapping - list->begin();
279 list->insert(index, toInsert); 279 list->insert(index, toInsert);
280 MarkerList::iterator inserted = list->begin() + index; 280 MarkerList::iterator inserted = list->begin() + index;
281 firstOverlapping = inserted + 1; 281 firstOverlapping = inserted + 1;
282 for (MarkerList::iterator i = firstOverlapping; 282 for (MarkerList::iterator i = firstOverlapping;
283 i != list->end() && (*i)->startOffset() <= (*inserted)->endOffset();) { 283 i != list->end() && (*i)->startOffset() <= (*inserted)->endOffset();) {
284 (*inserted)->setStartOffset( 284 (*inserted)->setStartOffset(
285 std::min((*inserted)->startOffset(), (*i)->startOffset())); 285 std::min((*inserted)->startOffset(), (*i)->startOffset()));
286 (*inserted)->setEndOffset( 286 (*inserted)->setEndOffset(
287 std::max((*inserted)->endOffset(), (*i)->endOffset())); 287 std::max((*inserted)->endOffset(), (*i)->endOffset()));
288 list->remove(i - list->begin()); 288 list->erase(i - list->begin());
289 } 289 }
290 } 290 }
291 291
292 // copies markers from srcNode to dstNode, applying the specified shift delta to 292 // copies markers from srcNode to dstNode, applying the specified shift delta to
293 // the copies. The shift is useful if, e.g., the caller has created the dstNode 293 // the copies. The shift is useful if, e.g., the caller has created the dstNode
294 // from a non-prefix substring of the srcNode. 294 // from a non-prefix substring of the srcNode.
295 void DocumentMarkerController::copyMarkers(Node* srcNode, 295 void DocumentMarkerController::copyMarkers(Node* srcNode,
296 unsigned startOffset, 296 unsigned startOffset,
297 int length, 297 int length,
298 Node* dstNode, 298 Node* dstNode,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 // markers are returned in order, so stop if we are now past the specified 386 // markers are returned in order, so stop if we are now past the specified
387 // range 387 // range
388 if (marker.startOffset() >= endOffset) 388 if (marker.startOffset() >= endOffset)
389 break; 389 break;
390 390
391 // at this point we know that marker and target intersect in some way 391 // at this point we know that marker and target intersect in some way
392 docDirty = true; 392 docDirty = true;
393 393
394 // pitch the old marker 394 // pitch the old marker
395 list->remove(i - list->begin()); 395 list->erase(i - list->begin());
396 396
397 if (shouldRemovePartiallyOverlappingMarker) { 397 if (shouldRemovePartiallyOverlappingMarker) {
398 // Stop here. Don't add resulting slices back. 398 // Stop here. Don't add resulting slices back.
399 continue; 399 continue;
400 } 400 }
401 401
402 // add either of the resulting slices that are left after removing target 402 // add either of the resulting slices that are left after removing target
403 if (startOffset > marker.startOffset()) { 403 if (startOffset > marker.startOffset()) {
404 DocumentMarker newLeft = marker; 404 DocumentMarker newLeft = marker;
405 newLeft.setEndOffset(startOffset); 405 newLeft.setEndOffset(startOffset);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 for (size_t markerListIndex = 0; 618 for (size_t markerListIndex = 0;
619 markerListIndex < DocumentMarker::MarkerTypeIndexesCount; 619 markerListIndex < DocumentMarker::MarkerTypeIndexesCount;
620 ++markerListIndex) { 620 ++markerListIndex) {
621 Member<MarkerList>& list = markers[markerListIndex]; 621 Member<MarkerList>& list = markers[markerListIndex];
622 if (!list) 622 if (!list)
623 continue; 623 continue;
624 bool removedMarkers = false; 624 bool removedMarkers = false;
625 for (size_t j = list->size(); j > 0; --j) { 625 for (size_t j = list->size(); j > 0; --j) {
626 if (shouldRemoveMarker(*list->at(j - 1), 626 if (shouldRemoveMarker(*list->at(j - 1),
627 static_cast<const Text&>(node))) { 627 static_cast<const Text&>(node))) {
628 list->remove(j - 1); 628 list->erase(j - 1);
629 removedMarkers = true; 629 removedMarkers = true;
630 } 630 }
631 } 631 }
632 if (removedMarkers && 632 if (removedMarkers &&
633 markerListIndex == DocumentMarker::TextMatchMarkerIndex) 633 markerListIndex == DocumentMarker::TextMatchMarkerIndex)
634 invalidatePaintForTickmarks(node); 634 invalidatePaintForTickmarks(node);
635 } 635 }
636 } 636 }
637 } 637 }
638 638
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 } 883 }
884 884
885 } // namespace blink 885 } // namespace blink
886 886
887 #ifndef NDEBUG 887 #ifndef NDEBUG
888 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { 888 void showDocumentMarkers(const blink::DocumentMarkerController* controller) {
889 if (controller) 889 if (controller)
890 controller->showMarkers(); 890 controller->showMarkers();
891 } 891 }
892 #endif 892 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/EditingStyle.cpp ('k') | third_party/WebKit/Source/core/events/EventListenerMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698