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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 static_cast<unsigned>(position.ComputeOffsetInContainerNode()); | 372 static_cast<unsigned>(position.ComputeOffsetInContainerNode()); |
| 373 | 373 |
| 374 const auto& markers = MarkersFor(node, marker_types); | 374 const auto& markers = MarkersFor(node, marker_types); |
| 375 const auto& it = | 375 const auto& it = |
| 376 std::find_if(markers.begin(), markers.end(), [=](DocumentMarker* marker) { | 376 std::find_if(markers.begin(), markers.end(), [=](DocumentMarker* marker) { |
| 377 return marker->StartOffset() < offset && offset < marker->EndOffset(); | 377 return marker->StartOffset() < offset && offset < marker->EndOffset(); |
| 378 }); | 378 }); |
| 379 return it == markers.end() ? nullptr : *it; | 379 return it == markers.end() ? nullptr : *it; |
| 380 } | 380 } |
| 381 | 381 |
| 382 Vector<std::pair<Node*, DocumentMarker*>> | |
|
rlanday
2017/06/22 02:16:04
kouhei@: Is it safe to return a Vector of std::pai
kouhei (in TOK)
2017/06/22 03:31:49
No.
Please use HeapVector<pair<Member<Node>, Membe
Xiaocheng
2017/06/22 03:39:09
For my curiosity: The lifetime of the returned vec
| |
| 383 DocumentMarkerController::MarkersIntersectingRange( | |
| 384 const EphemeralRange& range, | |
| 385 DocumentMarker::MarkerTypes types) { | |
| 386 Node* const range_start_container = | |
| 387 range.StartPosition().ComputeContainerNode(); | |
| 388 const unsigned range_start_offset = | |
| 389 range.StartPosition().ComputeOffsetInContainerNode(); | |
| 390 Node* const range_end_container = range.EndPosition().ComputeContainerNode(); | |
| 391 const unsigned range_end_offset = | |
| 392 range.EndPosition().ComputeOffsetInContainerNode(); | |
| 393 | |
| 394 Vector<std::pair<Node*, DocumentMarker*>> node_marker_pairs; | |
|
kouhei (in TOK)
2017/06/22 03:31:49
also here
| |
| 395 for (Node& node : range.Nodes()) { | |
|
yosin_UTC9
2017/06/22 03:13:40
nit: s/Node&/const Node&/
rlanday
2017/06/22 03:27:10
This needs to be non-const since we return a non-c
| |
| 396 MarkerLists* markers = markers_.at(&node); | |
|
yosin_UTC9
2017/06/22 03:13:40
nit: s/MarkerLists*/const MarkerLists* const/
rlanday
2017/06/22 03:27:10
ListForType() only works with a non-const pointer
| |
| 397 if (!markers) | |
| 398 continue; | |
| 399 | |
| 400 for (DocumentMarker::MarkerType type : types) { | |
| 401 DocumentMarkerList* const list = ListForType(markers, type); | |
| 402 if (!list) | |
| 403 continue; | |
| 404 | |
| 405 unsigned start_offset = | |
|
yosin_UTC9
2017/06/22 03:13:40
nit: s/unsigned/const unsigned/
| |
| 406 (node == range_start_container ? range_start_offset : 0); | |
|
yosin_UTC9
2017/06/22 03:13:40
nit: No need to have parenthesis.
| |
| 407 unsigned end_offset = | |
|
yosin_UTC9
2017/06/22 03:13:40
nit: s/unsigned/const unsigned/
| |
| 408 (node == range_end_container ? range_end_offset | |
|
yosin_UTC9
2017/06/22 03:13:40
nit: No need to have parenthesis.
| |
| 409 : node.MaxCharacterOffset()); | |
| 410 | |
| 411 const DocumentMarkerVector& markers_from_this_list = | |
| 412 list->MarkersIntersectingRange(start_offset, end_offset); | |
| 413 for (DocumentMarker* marker : markers_from_this_list) | |
| 414 node_marker_pairs.push_back(std::make_pair(&node, marker)); | |
| 415 } | |
| 416 } | |
| 417 | |
| 418 return node_marker_pairs; | |
| 419 } | |
| 420 | |
| 382 DocumentMarkerVector DocumentMarkerController::MarkersFor( | 421 DocumentMarkerVector DocumentMarkerController::MarkersFor( |
| 383 Node* node, | 422 Node* node, |
| 384 DocumentMarker::MarkerTypes marker_types) { | 423 DocumentMarker::MarkerTypes marker_types) { |
| 385 DocumentMarkerVector result; | 424 DocumentMarkerVector result; |
| 386 | 425 |
| 387 MarkerLists* markers = markers_.at(node); | 426 MarkerLists* markers = markers_.at(node); |
| 388 if (!markers) | 427 if (!markers) |
| 389 return result; | 428 return result; |
| 390 | 429 |
| 391 for (DocumentMarker::MarkerType type : DocumentMarker::AllMarkers()) { | 430 for (DocumentMarker::MarkerType type : DocumentMarker::AllMarkers()) { |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 733 } | 772 } |
| 734 | 773 |
| 735 } // namespace blink | 774 } // namespace blink |
| 736 | 775 |
| 737 #ifndef NDEBUG | 776 #ifndef NDEBUG |
| 738 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { | 777 void showDocumentMarkers(const blink::DocumentMarkerController* controller) { |
| 739 if (controller) | 778 if (controller) |
| 740 controller->ShowMarkers(); | 779 controller->ShowMarkers(); |
| 741 } | 780 } |
| 742 #endif | 781 #endif |
| OLD | NEW |