Index: third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp |
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp |
index fb1fcc9d8f69d83a452acd46f82bc360fc14e200..41ad53bb761c86c918dfd58bcca20afe03cbcf34 100644 |
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp |
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp |
@@ -329,4 +329,34 @@ TEST_F(DocumentMarkerControllerTest, RemoveSpellingMarkersUnderWords) { |
EXPECT_EQ(DocumentMarker::kTextMatch, marker.GetType()); |
} |
+TEST_F(DocumentMarkerControllerTest, MarkersIntersectingRange) { |
+ SetBodyInnerHTML("<div contenteditable>123456789</div>"); |
+ GetDocument().UpdateStyleAndLayout(); |
+ Element* div = GetDocument().QuerySelector("div"); |
+ Node* text = div->firstChild(); |
+ |
+ // Add a spelling marker on "123" |
+ MarkerController().AddSpellingMarker( |
+ EphemeralRange(Position(text, 0), Position(text, 3))); |
+ // Add a grammar marker on "456" |
Xiaocheng
2017/06/22 03:25:10
s/grammar/text match/
|
+ MarkerController().AddTextMatchMarker( |
+ EphemeralRange(Position(text, 3), Position(text, 6)), |
+ TextMatchMarker::MatchStatus::kInactive); |
+ // Add a grammar marker on "789" |
+ MarkerController().AddSpellingMarker( |
+ EphemeralRange(Position(text, 6), Position(text, 9))); |
+ |
+ // Query for spellcheck markers intersecting "3456". The text match marker |
+ // should not be returned, nor should the spelling marker touching the range. |
+ const Vector<std::pair<Node*, DocumentMarker*>>& results = |
+ MarkerController().MarkersIntersectingRange( |
+ EphemeralRange(Position(text, 2), Position(text, 6)), |
+ DocumentMarker::MisspellingMarkers()); |
+ |
+ EXPECT_EQ(1u, results.size()); |
+ EXPECT_EQ(DocumentMarker::kSpelling, results[0].second->GetType()); |
+ EXPECT_EQ(0u, results[0].second->StartOffset()); |
+ EXPECT_EQ(3u, results[0].second->EndOffset()); |
+} |
+ |
} // namespace blink |