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

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

Issue 1053123007: Invalidate paint of tickmarks on document change (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 | (options.medialCapitalAsWordStart ? TreatMedialCapitalAsWordStart : 0) 144 | (options.medialCapitalAsWordStart ? TreatMedialCapitalAsWordStart : 0)
145 | (options.findNext ? 0 : StartInSelection); 145 | (options.findNext ? 0 : StartInSelection);
146 m_activeMatch = ownerFrame().frame()->editor().findStringAndScrollToVisible( searchText, m_activeMatch.get(), findOptions); 146 m_activeMatch = ownerFrame().frame()->editor().findStringAndScrollToVisible( searchText, m_activeMatch.get(), findOptions);
147 147
148 if (!m_activeMatch) { 148 if (!m_activeMatch) {
149 // If we're finding next the next active match might not be in the curre nt frame. 149 // If we're finding next the next active match might not be in the curre nt frame.
150 // In this case we don't want to clear the matches cache. 150 // In this case we don't want to clear the matches cache.
151 if (!options.findNext) 151 if (!options.findNext)
152 clearFindMatchesCache(); 152 clearFindMatchesCache();
153 153
154 ownerFrame().invalidateAll(); 154 ownerFrame().frameView()->invalidatePaintForTickmarks();
155 return false; 155 return false;
156 } 156 }
157 157
158 #if OS(ANDROID) 158 #if OS(ANDROID)
159 ownerFrame().viewImpl()->zoomToFindInPageRect(ownerFrame().frameView()->cont entsToRootFrame(enclosingIntRect(LayoutObject::absoluteBoundingBoxRectForRange(m _activeMatch.get())))); 159 ownerFrame().viewImpl()->zoomToFindInPageRect(ownerFrame().frameView()->cont entsToRootFrame(enclosingIntRect(LayoutObject::absoluteBoundingBoxRectForRange(m _activeMatch.get()))));
160 #endif 160 #endif
161 161
162 setMarkerActive(m_activeMatch.get(), true); 162 setMarkerActive(m_activeMatch.get(), true);
163 WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_curr entActiveMatchFrame; 163 WebLocalFrameImpl* oldActiveFrame = mainFrameImpl->ensureTextFinder().m_curr entActiveMatchFrame;
164 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame(); 164 mainFrameImpl->ensureTextFinder().m_currentActiveMatchFrame = &ownerFrame();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 void TextFinder::stopFindingAndClearSelection() 200 void TextFinder::stopFindingAndClearSelection()
201 { 201 {
202 cancelPendingScopingEffort(); 202 cancelPendingScopingEffort();
203 203
204 // Remove all markers for matches found and turn off the highlighting. 204 // Remove all markers for matches found and turn off the highlighting.
205 ownerFrame().frame()->document()->markers().removeMarkers(DocumentMarker::Te xtMatch); 205 ownerFrame().frame()->document()->markers().removeMarkers(DocumentMarker::Te xtMatch);
206 ownerFrame().frame()->editor().setMarkedTextMatchesAreHighlighted(false); 206 ownerFrame().frame()->editor().setMarkedTextMatchesAreHighlighted(false);
207 clearFindMatchesCache(); 207 clearFindMatchesCache();
208 208
209 // Let the frame know that we don't want tickmarks or highlighting anymore. 209 // Let the frame know that we don't want tickmarks anymore.
210 ownerFrame().invalidateAll(); 210 ownerFrame().frameView()->invalidatePaintForTickmarks();
211 } 211 }
212 212
213 void TextFinder::reportFindInPageResultToAccessibility(int identifier) 213 void TextFinder::reportFindInPageResultToAccessibility(int identifier)
214 { 214 {
215 AXObjectCacheImpl* axObjectCache = toAXObjectCacheImpl(ownerFrame().frame()- >document()->existingAXObjectCache()); 215 AXObjectCacheImpl* axObjectCache = toAXObjectCacheImpl(ownerFrame().frame()- >document()->existingAXObjectCache());
216 if (!axObjectCache) 216 if (!axObjectCache)
217 return; 217 return;
218 218
219 AXObject* startObject = axObjectCache->get(m_activeMatch->startContainer()); 219 AXObject* startObject = axObjectCache->get(m_activeMatch->startContainer());
220 AXObject* endObject = axObjectCache->get(m_activeMatch->endContainer()); 220 AXObject* endObject = axObjectCache->get(m_activeMatch->endContainer());
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 } 404 }
405 405
406 void TextFinder::finishCurrentScopingEffort(int identifier) 406 void TextFinder::finishCurrentScopingEffort(int identifier)
407 { 407 {
408 flushCurrentScopingEffort(identifier); 408 flushCurrentScopingEffort(identifier);
409 409
410 m_scopingInProgress = false; 410 m_scopingInProgress = false;
411 m_lastFindRequestCompletedWithNoMatches = !m_lastMatchCount; 411 m_lastFindRequestCompletedWithNoMatches = !m_lastMatchCount;
412 412
413 // This frame is done, so show any scrollbar tickmarks we haven't drawn yet. 413 // This frame is done, so show any scrollbar tickmarks we haven't drawn yet.
414 ownerFrame().invalidateScrollbar(); 414 ownerFrame().frameView()->invalidatePaintForTickmarks();
415 } 415 }
416 416
417 void TextFinder::cancelPendingScopingEffort() 417 void TextFinder::cancelPendingScopingEffort()
418 { 418 {
419 #if ENABLE(OILPAN) 419 #if ENABLE(OILPAN)
420 for (DeferredScopeStringMatches* deferredWork : m_deferredScopingWork) 420 for (DeferredScopeStringMatches* deferredWork : m_deferredScopingWork)
421 deferredWork->dispose(); 421 deferredWork->dispose();
422 #endif 422 #endif
423 m_deferredScopingWork.clear(); 423 m_deferredScopingWork.clear();
424 424
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 m_deferredScopingWork.remove(index); 737 m_deferredScopingWork.remove(index);
738 738
739 scopeStringMatches(identifier, searchText, options, reset); 739 scopeStringMatches(identifier, searchText, options, reset);
740 } 740 }
741 741
742 void TextFinder::invalidateIfNecessary() 742 void TextFinder::invalidateIfNecessary()
743 { 743 {
744 if (m_lastMatchCount <= m_nextInvalidateAfter) 744 if (m_lastMatchCount <= m_nextInvalidateAfter)
745 return; 745 return;
746 746
747 // FIXME: (http://b/1088165) Optimize the drawing of the tickmarks and 747 // FIXME: (http://crbug.com/6819) Optimize the drawing of the tickmarks and
748 // remove this. This calculation sets a milestone for when next to 748 // remove this. This calculation sets a milestone for when next to
749 // invalidate the scrollbar and the content area. We do this so that we 749 // invalidate the scrollbar and the content area. We do this so that we
750 // don't spend too much time drawing the scrollbar over and over again. 750 // don't spend too much time drawing the scrollbar over and over again.
751 // Basically, up until the first 500 matches there is no throttle. 751 // Basically, up until the first 500 matches there is no throttle.
752 // After the first 500 matches, we set set the milestone further and 752 // After the first 500 matches, we set set the milestone further and
753 // further out (750, 1125, 1688, 2K, 3K). 753 // further out (750, 1125, 1688, 2K, 3K).
754 static const int startSlowingDownAfter = 500; 754 static const int startSlowingDownAfter = 500;
755 static const int slowdown = 750; 755 static const int slowdown = 750;
756 756
757 int i = m_lastMatchCount / startSlowingDownAfter; 757 int i = m_lastMatchCount / startSlowingDownAfter;
758 m_nextInvalidateAfter += i * slowdown; 758 m_nextInvalidateAfter += i * slowdown;
759 ownerFrame().invalidateScrollbar(); 759 ownerFrame().frameView()->invalidatePaintForTickmarks();
760 } 760 }
761 761
762 void TextFinder::flushCurrentScoping() 762 void TextFinder::flushCurrentScoping()
763 { 763 {
764 flushCurrentScopingEffort(m_findRequestIdentifier); 764 flushCurrentScopingEffort(m_findRequestIdentifier);
765 } 765 }
766 766
767 void TextFinder::setMatchMarkerActive(bool active) 767 void TextFinder::setMatchMarkerActive(bool active)
768 { 768 {
769 setMarkerActive(m_activeMatch.get(), active); 769 setMarkerActive(m_activeMatch.get(), active);
(...skipping 20 matching lines...) Expand all
790 { 790 {
791 visitor->trace(m_ownerFrame); 791 visitor->trace(m_ownerFrame);
792 visitor->trace(m_currentActiveMatchFrame); 792 visitor->trace(m_currentActiveMatchFrame);
793 visitor->trace(m_activeMatch); 793 visitor->trace(m_activeMatch);
794 visitor->trace(m_resumeScopingFromRange); 794 visitor->trace(m_resumeScopingFromRange);
795 visitor->trace(m_deferredScopingWork); 795 visitor->trace(m_deferredScopingWork);
796 visitor->trace(m_findMatchesCache); 796 visitor->trace(m_findMatchesCache);
797 } 797 }
798 798
799 } // namespace blink 799 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/web/WebLocalFrameImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698