Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 list.clear(); | 374 list.clear(); |
| 375 ++emptyListsCount; | 375 ++emptyListsCount; |
| 376 continue; | 376 continue; |
| 377 } | 377 } |
| 378 if (!markerTypes.contains((*list->begin())->type())) | 378 if (!markerTypes.contains((*list->begin())->type())) |
| 379 continue; | 379 continue; |
| 380 unsigned endOffset = startOffset + length; | 380 unsigned endOffset = startOffset + length; |
| 381 MarkerList::iterator startPos = | 381 MarkerList::iterator startPos = |
| 382 std::upper_bound(list->begin(), list->end(), startOffset, endsBefore); | 382 std::upper_bound(list->begin(), list->end(), startOffset, endsBefore); |
| 383 for (MarkerList::iterator i = startPos; i != list->end();) { | 383 for (MarkerList::iterator i = startPos; i != list->end();) { |
| 384 DocumentMarker marker(*i->get()); | 384 DocumentMarker* marker = (*i)->clone(); |
|
Xiaocheng
2017/03/30 02:20:28
No need to change this part. |marker| should refer
| |
| 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->erase(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->clone(); |
| 405 newLeft.setEndOffset(startOffset); | 405 newLeft->setEndOffset(startOffset); |
| 406 size_t insertIndex = i - list->begin(); | 406 size_t insertIndex = i - list->begin(); |
| 407 list->insert(insertIndex, RenderedDocumentMarker::create(newLeft)); | 407 list->insert(insertIndex, RenderedDocumentMarker::create(*newLeft)); |
| 408 // Move to the marker after the inserted one. | 408 // Move to the marker after the inserted one. |
| 409 i = list->begin() + insertIndex + 1; | 409 i = list->begin() + insertIndex + 1; |
| 410 } | 410 } |
| 411 if (marker.endOffset() > endOffset) { | 411 if (marker->endOffset() > endOffset) { |
| 412 DocumentMarker newRight = marker; | 412 DocumentMarker* newRight = marker->clone(); |
| 413 newRight.setStartOffset(endOffset); | 413 newRight->setStartOffset(endOffset); |
| 414 size_t insertIndex = i - list->begin(); | 414 size_t insertIndex = i - list->begin(); |
| 415 list->insert(insertIndex, RenderedDocumentMarker::create(newRight)); | 415 list->insert(insertIndex, RenderedDocumentMarker::create(*newRight)); |
| 416 // Move to the marker after the inserted one. | 416 // Move to the marker after the inserted one. |
| 417 i = list->begin() + insertIndex + 1; | 417 i = list->begin() + insertIndex + 1; |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 if (list->isEmpty()) { | 421 if (list->isEmpty()) { |
| 422 list.clear(); | 422 list.clear(); |
| 423 ++emptyListsCount; | 423 ++emptyListsCount; |
| 424 } | 424 } |
| 425 } | 425 } |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| OLD | NEW |