Add ability to count text matches without marking.
Created attachment 64387 [details] Patch
Comment on attachment 64387 [details] Patch WebCore/page/Frame.cpp:1257 + unsigned Frame::markAllMatchesForText(const String& target, bool caseFlag, unsigned limit) This method should be removed. Since WebKit is the only caller, it should switch to using countMatchesForText() and pass in true for markMatches. The WebCore.exp.in file will need to be updated to remove WebCore::Frame::markAllMatchesForText() and to add WebCore::Frame::countMatchesForText(). WebCore/page/Frame.h:211 + unsigned markAllMatchesForText(const String&, bool caseFlag, unsigned limit); This declaration can be removed. WebKit/mac/WebView/WebHTMLView.mm:6206 + - (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(NSUInteger)limit markMatches:(BOOL)markMatches This method should call WebCore::Frame::countMatchesForText() instead of WebCore::Frame::markAllMatchesForText() if it uses it. WebKit/mac/WebView/WebPDFView.mm:633 + - (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(NSUInteger)limit markMatches:(BOOL)markMatches This method should call WebCore::Frame::countMatchesForText() instead of WebCore::Frame::markAllMatchesForText() if it uses it. WebKit/mac/WebView/WebView.mm:4368 + - (NSUInteger)countMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(NSUInteger)limit markMatches:(BOOL)markMatches This method should call WebCore::Frame::countMatchesForText() instead of WebCore::Frame::markAllMatchesForText() if it uses it. r- to address the above issues.
Created attachment 66072 [details] Updated Patch
Attachment 66072 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebCore/page/Page.cpp:529: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] Total errors found: 1 in 13 files If any of these errors are false positives, please file a bug against check-webkit-style.
Comment on attachment 66072 [details] Updated Patch > + // Do a "fake" paint in order to execute the code that computes the rendered rect for > + // each text match. Merge comment into one line? > + Document* doc = document(); > + if (m_view && contentRenderer()) { > + doc->updateLayout(); // Ensure layout is up to date. Get rid of pointless local variable "doc"? > - unsigned markAllMatchesForText(const String&, bool caseFlag, unsigned limit); > + unsigned countMatchesForText(const String&, bool caseFlag, unsigned limit, bool markMatches); A boolean for this is not great, since we’re often passing a constant. I suppose we can live with this, but it’s ugly.
Landed in r66544.