OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "web/TextFinder.h" | 5 #include "web/TextFinder.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/NodeList.h" | 9 #include "core/dom/NodeList.h" |
10 #include "core/dom/Range.h" | 10 #include "core/dom/Range.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 TextFinder& TextFinderTest::GetTextFinder() const { | 60 TextFinder& TextFinderTest::GetTextFinder() const { |
61 return *text_finder_; | 61 return *text_finder_; |
62 } | 62 } |
63 | 63 |
64 WebFloatRect TextFinderTest::FindInPageRect(Node* start_container, | 64 WebFloatRect TextFinderTest::FindInPageRect(Node* start_container, |
65 int start_offset, | 65 int start_offset, |
66 Node* end_container, | 66 Node* end_container, |
67 int end_offset) { | 67 int end_offset) { |
68 Range* range = Range::Create(start_container->GetDocument(), start_container, | 68 const Position start_position(start_container, start_offset); |
69 start_offset, end_container, end_offset); | 69 const Position end_position(end_container, end_offset); |
| 70 const EphemeralRange range(start_position, end_position); |
70 return WebFloatRect(FindInPageRectFromRange(range)); | 71 return WebFloatRect(FindInPageRectFromRange(range)); |
71 } | 72 } |
72 | 73 |
73 TEST_F(TextFinderTest, FindTextSimple) { | 74 TEST_F(TextFinderTest, FindTextSimple) { |
74 GetDocument().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ"); | 75 GetDocument().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ"); |
75 GetDocument().UpdateStyleAndLayout(); | 76 GetDocument().UpdateStyleAndLayout(); |
76 Node* text_node = GetDocument().body()->firstChild(); | 77 Node* text_node = GetDocument().body()->firstChild(); |
77 | 78 |
78 int identifier = 0; | 79 int identifier = 0; |
79 WebString search_text(String("FindMe")); | 80 WebString search_text(String("FindMe")); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 // of the TimeProxyPlatform timer is greater than timeout threshold. | 618 // of the TimeProxyPlatform timer is greater than timeout threshold. |
618 GetTextFinder().StartScopingStringMatches(identifier, search_pattern, | 619 GetTextFinder().StartScopingStringMatches(identifier, search_pattern, |
619 find_options); | 620 find_options); |
620 while (GetTextFinder().ScopingInProgress()) | 621 while (GetTextFinder().ScopingInProgress()) |
621 RunPendingTasks(); | 622 RunPendingTasks(); |
622 | 623 |
623 EXPECT_EQ(4, GetTextFinder().TotalMatchCount()); | 624 EXPECT_EQ(4, GetTextFinder().TotalMatchCount()); |
624 } | 625 } |
625 | 626 |
626 } // namespace blink | 627 } // namespace blink |
OLD | NEW |