Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2857173003: Remove DocumentMarkerController::MarkersInRange() (Closed)
Patch Set: Use std::find_if() Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/ContextMenuClientImpl.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index b57793917546d5efa73323258586309bb06b6ca1..677e428ad4aac5227d3522450e5f734fe8b60980 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -321,6 +321,36 @@ class WebFrameTest : public ::testing::Test {
WebFrame* parent,
WebFrame* new_child);
+ int NumMarkersInRange(const Document* document,
+ const EphemeralRange& range,
+ DocumentMarker::MarkerTypes marker_types) {
+ Node* start_container = range.StartPosition().ComputeContainerNode();
+ unsigned start_offset = static_cast<unsigned>(
+ range.StartPosition().ComputeOffsetInContainerNode());
+
+ Node* end_container = range.EndPosition().ComputeContainerNode();
+ unsigned end_offset = static_cast<unsigned>(
+ range.EndPosition().ComputeOffsetInContainerNode());
+
+ int node_count = 0;
+ for (Node& node : range.Nodes()) {
+ const DocumentMarkerVector& markers_in_node =
+ document->Markers().MarkersFor(&node, marker_types);
+ node_count += std::count_if(
+ markers_in_node.begin(), markers_in_node.end(),
+ [start_offset, end_offset, &node, &start_container,
+ &end_container](const DocumentMarker* marker) {
+ if (node == start_container && marker->EndOffset() <= start_offset)
+ return false;
+ if (node == end_container && marker->StartOffset() >= end_offset)
+ return false;
+ return true;
+ });
+ }
+
+ return node_count;
+ }
+
std::string base_url_;
std::string not_base_url_;
std::string chrome_url_;
@@ -6547,9 +6577,8 @@ TEST_P(ParameterizedWebFrameTest, ReplaceMisspelledRange) {
.ToNormalizedEphemeralRange();
EXPECT_EQ(1, textcheck.NumberOfTimesChecked());
- EXPECT_EQ(1U, document->Markers()
- .MarkersInRange(selection_range, DocumentMarker::kSpelling)
- .size());
+ EXPECT_EQ(1, NumMarkersInRange(document, selection_range,
+ DocumentMarker::kSpelling));
frame->ReplaceMisspelledRange("welcome");
EXPECT_EQ("_welcome_.",
@@ -6596,9 +6625,8 @@ TEST_P(ParameterizedWebFrameTest, RemoveSpellingMarkers) {
.ComputeVisibleSelectionInDOMTreeDeprecated()
.ToNormalizedEphemeralRange();
- EXPECT_EQ(0U, document->Markers()
- .MarkersInRange(selection_range, DocumentMarker::kSpelling)
- .size());
+ EXPECT_EQ(0, NumMarkersInRange(document, selection_range,
+ DocumentMarker::kSpelling));
}
static void GetSpellingMarkerOffsets(WebVector<unsigned>* offsets,
« no previous file with comments | « third_party/WebKit/Source/web/ContextMenuClientImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698