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::textFinder() const { | 60 TextFinder& TextFinderTest::textFinder() const { |
61 return *m_textFinder; | 61 return *m_textFinder; |
62 } | 62 } |
63 | 63 |
64 WebFloatRect TextFinderTest::findInPageRect(Node* startContainer, | 64 WebFloatRect TextFinderTest::findInPageRect(Node* startContainer, |
65 int startOffset, | 65 int startOffset, |
66 Node* endContainer, | 66 Node* endContainer, |
67 int endOffset) { | 67 int endOffset) { |
68 Range* range = Range::create(startContainer->document(), startContainer, | 68 const Position startPosition(startContainer, startOffset); |
69 startOffset, endContainer, endOffset); | 69 const Position endPosition(endContainer, endOffset); |
| 70 EphemeralRange range(startPosition, endPosition); |
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 document().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ"); | 75 document().body()->setInnerHTML("XXXXFindMeYYYYfindmeZZZZ"); |
75 document().updateStyleAndLayout(); | 76 document().updateStyleAndLayout(); |
76 Node* textNode = document().body()->firstChild(); | 77 Node* textNode = document().body()->firstChild(); |
77 | 78 |
78 int identifier = 0; | 79 int identifier = 0; |
79 WebString searchText(String("FindMe")); | 80 WebString searchText(String("FindMe")); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 // of the TimeProxyPlatform timer is greater than timeout threshold. | 605 // of the TimeProxyPlatform timer is greater than timeout threshold. |
605 textFinder().startScopingStringMatches(identifier, searchPattern, | 606 textFinder().startScopingStringMatches(identifier, searchPattern, |
606 findOptions); | 607 findOptions); |
607 while (textFinder().scopingInProgress()) | 608 while (textFinder().scopingInProgress()) |
608 runPendingTasks(); | 609 runPendingTasks(); |
609 | 610 |
610 EXPECT_EQ(4, textFinder().totalMatchCount()); | 611 EXPECT_EQ(4, textFinder().totalMatchCount()); |
611 } | 612 } |
612 | 613 |
613 } // namespace blink | 614 } // namespace blink |
OLD | NEW |