Index: third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp |
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp |
index a9309fae840172d93c5b50057c0fa4918ed1b977..2999e8abf25fcaabe1e63d8f0557696c333b2be0 100644 |
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp |
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp |
@@ -379,6 +379,45 @@ DocumentMarker* DocumentMarkerController::MarkerAtPosition( |
return it == markers.end() ? nullptr : *it; |
} |
+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
|
+DocumentMarkerController::MarkersIntersectingRange( |
+ const EphemeralRange& range, |
+ DocumentMarker::MarkerTypes types) { |
+ Node* const range_start_container = |
+ range.StartPosition().ComputeContainerNode(); |
+ const unsigned range_start_offset = |
+ range.StartPosition().ComputeOffsetInContainerNode(); |
+ Node* const range_end_container = range.EndPosition().ComputeContainerNode(); |
+ const unsigned range_end_offset = |
+ range.EndPosition().ComputeOffsetInContainerNode(); |
+ |
+ Vector<std::pair<Node*, DocumentMarker*>> node_marker_pairs; |
kouhei (in TOK)
2017/06/22 03:31:49
also here
|
+ 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
|
+ 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
|
+ if (!markers) |
+ continue; |
+ |
+ for (DocumentMarker::MarkerType type : types) { |
+ DocumentMarkerList* const list = ListForType(markers, type); |
+ if (!list) |
+ continue; |
+ |
+ unsigned start_offset = |
yosin_UTC9
2017/06/22 03:13:40
nit: s/unsigned/const unsigned/
|
+ (node == range_start_container ? range_start_offset : 0); |
yosin_UTC9
2017/06/22 03:13:40
nit: No need to have parenthesis.
|
+ unsigned end_offset = |
yosin_UTC9
2017/06/22 03:13:40
nit: s/unsigned/const unsigned/
|
+ (node == range_end_container ? range_end_offset |
yosin_UTC9
2017/06/22 03:13:40
nit: No need to have parenthesis.
|
+ : node.MaxCharacterOffset()); |
+ |
+ const DocumentMarkerVector& markers_from_this_list = |
+ list->MarkersIntersectingRange(start_offset, end_offset); |
+ for (DocumentMarker* marker : markers_from_this_list) |
+ node_marker_pairs.push_back(std::make_pair(&node, marker)); |
+ } |
+ } |
+ |
+ return node_marker_pairs; |
+} |
+ |
DocumentMarkerVector DocumentMarkerController::MarkersFor( |
Node* node, |
DocumentMarker::MarkerTypes marker_types) { |