| 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..7b357808a2677bfb48a2d14efa920a0d499b80e9 100644
|
| --- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp
|
| @@ -367,16 +367,35 @@ DocumentMarker* DocumentMarkerController::MarkerAtPosition(
|
| DocumentMarker::MarkerTypes marker_types) {
|
| if (!PossiblyHasMarkers(marker_types))
|
| return nullptr;
|
| +
|
| Node* const node = position.ComputeContainerNode();
|
| + MarkerLists* const markers = markers_.at(node);
|
| + if (!markers)
|
| + return nullptr;
|
| +
|
| const unsigned offset =
|
| static_cast<unsigned>(position.ComputeOffsetInContainerNode());
|
|
|
| - const auto& markers = MarkersFor(node, marker_types);
|
| - const auto& it =
|
| - std::find_if(markers.begin(), markers.end(), [=](DocumentMarker* marker) {
|
| - return marker->StartOffset() < offset && offset < marker->EndOffset();
|
| - });
|
| - return it == markers.end() ? nullptr : *it;
|
| + // This position can't be in the interior of a marker if it occurs at an
|
| + // endpoint of the node
|
| + if (offset == 0 ||
|
| + offset == static_cast<unsigned>(node->MaxCharacterOffset()))
|
| + return nullptr;
|
| +
|
| + // Query each of the DocumentMarkerLists until we find a marker at the
|
| + // specified position (or have gone through all the MarkerTypes)
|
| + for (DocumentMarker::MarkerType type : marker_types) {
|
| + const DocumentMarkerList* const list = ListForType(markers, type);
|
| + if (!list)
|
| + continue;
|
| +
|
| + const HeapVector<Member<DocumentMarker>>& results =
|
| + list->MarkersIntersectingRange(offset, offset);
|
| + if (!results.IsEmpty())
|
| + return results.front();
|
| + }
|
| +
|
| + return nullptr;
|
| }
|
|
|
| DocumentMarkerVector DocumentMarkerController::MarkersFor(
|
|
|