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

Side by Side Diff: third_party/WebKit/Source/web/TextFinder.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "public/web/WebFindOptions.h" 51 #include "public/web/WebFindOptions.h"
52 #include "public/web/WebFrameClient.h" 52 #include "public/web/WebFrameClient.h"
53 #include "public/web/WebViewClient.h" 53 #include "public/web/WebViewClient.h"
54 #include "web/FindInPageCoordinates.h" 54 #include "web/FindInPageCoordinates.h"
55 #include "web/WebLocalFrameImpl.h" 55 #include "web/WebLocalFrameImpl.h"
56 #include "web/WebViewImpl.h" 56 #include "web/WebViewImpl.h"
57 #include "wtf/CurrentTime.h" 57 #include "wtf/CurrentTime.h"
58 58
59 namespace blink { 59 namespace blink {
60 60
61 TextFinder::FindMatch::FindMatch(PassRefPtrWillBeRawPtr<Range> range, int ordina l) 61 TextFinder::FindMatch::FindMatch(RawPtr<Range> range, int ordinal)
62 : m_range(range) 62 : m_range(range)
63 , m_ordinal(ordinal) 63 , m_ordinal(ordinal)
64 { 64 {
65 } 65 }
66 66
67 DEFINE_TRACE(TextFinder::FindMatch) 67 DEFINE_TRACE(TextFinder::FindMatch)
68 { 68 {
69 visitor->trace(m_range); 69 visitor->trace(m_range);
70 } 70 }
71 71
72 class TextFinder::DeferredScopeStringMatches : public NoBaseWillBeGarbageCollect edFinalized<TextFinder::DeferredScopeStringMatches> { 72 class TextFinder::DeferredScopeStringMatches : public GarbageCollectedFinalized< TextFinder::DeferredScopeStringMatches> {
73 public: 73 public:
74 static PassOwnPtrWillBeRawPtr<DeferredScopeStringMatches> create(TextFinder* textFinder, int identifier, const WebString& searchText, const WebFindOptions& options, bool reset) 74 static RawPtr<DeferredScopeStringMatches> create(TextFinder* textFinder, int identifier, const WebString& searchText, const WebFindOptions& options, bool re set)
75 { 75 {
76 return adoptPtrWillBeNoop(new DeferredScopeStringMatches(textFinder, ide ntifier, searchText, options, reset)); 76 return new DeferredScopeStringMatches(textFinder, identifier, searchText , options, reset);
77 } 77 }
78 78
79 DEFINE_INLINE_TRACE() 79 DEFINE_INLINE_TRACE()
80 { 80 {
81 visitor->trace(m_textFinder); 81 visitor->trace(m_textFinder);
82 } 82 }
83 83
84 void dispose() 84 void dispose()
85 { 85 {
86 if (m_timer.isActive()) 86 if (m_timer.isActive())
(...skipping 11 matching lines...) Expand all
98 { 98 {
99 m_timer.startOneShot(0.0, BLINK_FROM_HERE); 99 m_timer.startOneShot(0.0, BLINK_FROM_HERE);
100 } 100 }
101 101
102 void doTimeout(Timer<DeferredScopeStringMatches>*) 102 void doTimeout(Timer<DeferredScopeStringMatches>*)
103 { 103 {
104 m_textFinder->callScopeStringMatches(this, m_identifier, m_searchText, m _options, m_reset); 104 m_textFinder->callScopeStringMatches(this, m_identifier, m_searchText, m _options, m_reset);
105 } 105 }
106 106
107 Timer<DeferredScopeStringMatches> m_timer; 107 Timer<DeferredScopeStringMatches> m_timer;
108 RawPtrWillBeMember<TextFinder> m_textFinder; 108 Member<TextFinder> m_textFinder;
109 const int m_identifier; 109 const int m_identifier;
110 const WebString m_searchText; 110 const WebString m_searchText;
111 const WebFindOptions m_options; 111 const WebFindOptions m_options;
112 const bool m_reset; 112 const bool m_reset;
113 }; 113 };
114 114
115 bool TextFinder::find(int identifier, const WebString& searchText, const WebFind Options& options, bool wrapWithinFrame, WebRect* selectionRect, bool* activeNow) 115 bool TextFinder::find(int identifier, const WebString& searchText, const WebFind Options& options, bool wrapWithinFrame, WebRect* selectionRect, bool* activeNow)
116 { 116 {
117 if (!ownerFrame().frame() || !ownerFrame().frame()->page()) 117 if (!ownerFrame().frame() || !ownerFrame().frame()->page())
118 return false; 118 return false;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // Find next occurrence of the search string. 306 // Find next occurrence of the search string.
307 // FIXME: (http://crbug.com/6818) This WebKit operation may run for long er 307 // FIXME: (http://crbug.com/6818) This WebKit operation may run for long er
308 // than the timeout value, and is not interruptible as it is currently 308 // than the timeout value, and is not interruptible as it is currently
309 // written. We may need to rewrite it with interruptibility in mind, or 309 // written. We may need to rewrite it with interruptibility in mind, or
310 // find an alternative. 310 // find an alternative.
311 const EphemeralRangeInFlatTree result = findPlainText(EphemeralRangeInFl atTree(searchStart, searchEnd), searchText, options.matchCase ? 0 : CaseInsensit ive); 311 const EphemeralRangeInFlatTree result = findPlainText(EphemeralRangeInFl atTree(searchStart, searchEnd), searchText, options.matchCase ? 0 : CaseInsensit ive);
312 if (result.isCollapsed()) { 312 if (result.isCollapsed()) {
313 // Not found. 313 // Not found.
314 break; 314 break;
315 } 315 }
316 RefPtrWillBeRawPtr<Range> resultRange = Range::create(result.document(), toPositionInDOMTree(result.startPosition()), toPositionInDOMTree(result.endPosi tion())); 316 RawPtr<Range> resultRange = Range::create(result.document(), toPositionI nDOMTree(result.startPosition()), toPositionInDOMTree(result.endPosition()));
317 if (resultRange->collapsed()) { 317 if (resultRange->collapsed()) {
318 // resultRange will be collapsed if the matched text spans over mult iple TreeScopes. 318 // resultRange will be collapsed if the matched text spans over mult iple TreeScopes.
319 // FIXME: Show such matches to users. 319 // FIXME: Show such matches to users.
320 searchStart = result.endPosition(); 320 searchStart = result.endPosition();
321 continue; 321 continue;
322 } 322 }
323 323
324 ++matchCount; 324 ++matchCount;
325 325
326 // Catch a special case where Find found something but doesn't know what 326 // Catch a special case where Find found something but doesn't know what
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 match.m_rect = FloatRect(); 503 match.m_rect = FloatRect();
504 else if (!m_findMatchRectsAreValid) 504 else if (!m_findMatchRectsAreValid)
505 match.m_rect = findInPageRectFromRange(match.m_range.get()); 505 match.m_rect = findInPageRectFromRange(match.m_range.get());
506 506
507 if (match.m_rect.isEmpty()) 507 if (match.m_rect.isEmpty())
508 ++deadMatches; 508 ++deadMatches;
509 } 509 }
510 510
511 // Remove any invalid matches from the cache. 511 // Remove any invalid matches from the cache.
512 if (deadMatches) { 512 if (deadMatches) {
513 WillBeHeapVector<FindMatch> filteredMatches; 513 HeapVector<FindMatch> filteredMatches;
514 filteredMatches.reserveCapacity(m_findMatchesCache.size() - deadMatches) ; 514 filteredMatches.reserveCapacity(m_findMatchesCache.size() - deadMatches) ;
515 515
516 for (const FindMatch& match : m_findMatchesCache) { 516 for (const FindMatch& match : m_findMatchesCache) {
517 if (!match.m_rect.isEmpty()) 517 if (!match.m_rect.isEmpty())
518 filteredMatches.append(match); 518 filteredMatches.append(match);
519 } 519 }
520 520
521 m_findMatchesCache.swap(filteredMatches); 521 m_findMatchesCache.swap(filteredMatches);
522 } 522 }
523 523
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 distanceSquared = currentDistanceSquared; 596 distanceSquared = currentDistanceSquared;
597 } 597 }
598 } 598 }
599 return nearest; 599 return nearest;
600 } 600 }
601 601
602 int TextFinder::selectFindMatch(unsigned index, WebRect* selectionRect) 602 int TextFinder::selectFindMatch(unsigned index, WebRect* selectionRect)
603 { 603 {
604 ASSERT_WITH_SECURITY_IMPLICATION(index < m_findMatchesCache.size()); 604 ASSERT_WITH_SECURITY_IMPLICATION(index < m_findMatchesCache.size());
605 605
606 RefPtrWillBeRawPtr<Range> range = m_findMatchesCache[index].m_range; 606 RawPtr<Range> range = m_findMatchesCache[index].m_range;
607 if (!range->boundaryPointsValid() || !range->startContainer()->inDocument()) 607 if (!range->boundaryPointsValid() || !range->startContainer()->inDocument())
608 return -1; 608 return -1;
609 609
610 // Check if the match is already selected. 610 // Check if the match is already selected.
611 TextFinder& mainFrameTextFinder = ownerFrame().viewImpl()->mainFrameImpl()-> ensureTextFinder(); 611 TextFinder& mainFrameTextFinder = ownerFrame().viewImpl()->mainFrameImpl()-> ensureTextFinder();
612 WebLocalFrameImpl* activeMatchFrame = mainFrameTextFinder.m_currentActiveMat chFrame; 612 WebLocalFrameImpl* activeMatchFrame = mainFrameTextFinder.m_currentActiveMat chFrame;
613 if (&ownerFrame() != activeMatchFrame || !m_activeMatch || !areRangesEqual(m _activeMatch.get(), range.get())) { 613 if (&ownerFrame() != activeMatchFrame || !m_activeMatch || !areRangesEqual(m _activeMatch.get(), range.get())) {
614 if (isActiveMatchFrameValid()) 614 if (isActiveMatchFrameValid())
615 activeMatchFrame->ensureTextFinder().setMatchMarkerActive(false); 615 activeMatchFrame->ensureTextFinder().setMatchMarkerActive(false);
616 616
(...skipping 26 matching lines...) Expand all
643 activeMatchRect = ownerFrame().frameView()->contentsToRootFrame(activeMa tchBoundingBox); 643 activeMatchRect = ownerFrame().frameView()->contentsToRootFrame(activeMa tchBoundingBox);
644 ownerFrame().viewImpl()->zoomToFindInPageRect(activeMatchRect); 644 ownerFrame().viewImpl()->zoomToFindInPageRect(activeMatchRect);
645 } 645 }
646 646
647 if (selectionRect) 647 if (selectionRect)
648 *selectionRect = activeMatchRect; 648 *selectionRect = activeMatchRect;
649 649
650 return ordinalOfFirstMatch() + m_activeMatchIndexInCurrentFrame + 1; 650 return ordinalOfFirstMatch() + m_activeMatchIndexInCurrentFrame + 1;
651 } 651 }
652 652
653 PassOwnPtrWillBeRawPtr<TextFinder> TextFinder::create(WebLocalFrameImpl& ownerFr ame) 653 RawPtr<TextFinder> TextFinder::create(WebLocalFrameImpl& ownerFrame)
654 { 654 {
655 return adoptPtrWillBeNoop(new TextFinder(ownerFrame)); 655 return new TextFinder(ownerFrame);
656 } 656 }
657 657
658 TextFinder::TextFinder(WebLocalFrameImpl& ownerFrame) 658 TextFinder::TextFinder(WebLocalFrameImpl& ownerFrame)
659 : m_ownerFrame(&ownerFrame) 659 : m_ownerFrame(&ownerFrame)
660 , m_currentActiveMatchFrame(nullptr) 660 , m_currentActiveMatchFrame(nullptr)
661 , m_activeMatchIndexInCurrentFrame(-1) 661 , m_activeMatchIndexInCurrentFrame(-1)
662 , m_resumeScopingFromRange(nullptr) 662 , m_resumeScopingFromRange(nullptr)
663 , m_lastMatchCount(-1) 663 , m_lastMatchCount(-1)
664 , m_totalMatchCount(-1) 664 , m_totalMatchCount(-1)
665 , m_framesScopingCount(-1) 665 , m_framesScopingCount(-1)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 visitor->trace(m_ownerFrame); 813 visitor->trace(m_ownerFrame);
814 visitor->trace(m_currentActiveMatchFrame); 814 visitor->trace(m_currentActiveMatchFrame);
815 visitor->trace(m_activeMatch); 815 visitor->trace(m_activeMatch);
816 visitor->trace(m_resumeScopingFromRange); 816 visitor->trace(m_resumeScopingFromRange);
817 visitor->trace(m_deferredScopingWork); 817 visitor->trace(m_deferredScopingWork);
818 visitor->trace(m_findMatchesCache); 818 visitor->trace(m_findMatchesCache);
819 #endif 819 #endif
820 } 820 }
821 821
822 } // namespace blink 822 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/TextFinder.h ('k') | third_party/WebKit/Source/web/ValidationMessageClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698