Bug 57552 - Find client not told when WKPageCountStringMatches exceeds maximum
Summary: Find client not told when WKPageCountStringMatches exceeds maximum
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: John Sullivan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-03-31 08:44 PDT by John Sullivan
Modified: 2011-03-31 10:40 PDT (History)
0 users

See Also:


Attachments
Patch that uses the same technique as the find-string case. (1.50 KB, text/plain)
2011-03-31 08:46 PDT, John Sullivan
no flags Details
Take two, featuring non-degenerate ChangeLog entry. (1.71 KB, patch)
2011-03-31 08:49 PDT, John Sullivan
no flags Details | Formatted Diff | Diff
Take three, now handles numeric_limits<unsigned>::max() (2.52 KB, patch)
2011-03-31 10:04 PDT, John Sullivan
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Sullivan 2011-03-31 08:44:26 PDT
If the number of string matches on a page exceeds the maximum passed to WKPageCountStringMatches, the callback will report the passed maximum, rather than the special value kWKMoreThanMaximumMatchCount.
Comment 1 John Sullivan 2011-03-31 08:46:21 PDT
Created attachment 87732 [details]
Patch that uses the same technique as the find-string case.
Comment 2 John Sullivan 2011-03-31 08:47:21 PDT
Comment on attachment 87732 [details]
Patch that uses the same technique as the find-string case.

Oops, forgot to save the ChangeLog before creating the patch. New one coming up shortly.
Comment 3 John Sullivan 2011-03-31 08:48:12 PDT
In Radar as <rdar://problem/9214824>
Comment 4 John Sullivan 2011-03-31 08:49:43 PDT
Created attachment 87733 [details]
Take two, featuring non-degenerate ChangeLog entry.
Comment 5 Adam Roben (:aroben) 2011-03-31 08:53:46 PDT
Comment on attachment 87733 [details]
Take two, featuring non-degenerate ChangeLog entry.

View in context: https://bugs.webkit.org/attachment.cgi?id=87733&action=review

> Source/WebKit2/WebProcess/WebPage/FindController.cpp:72
>  void FindController::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
>  {
> -    unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), false, maxMatchCount);
> +    unsigned matchCount = m_webPage->corePage()->markAllMatchesForText(string, core(options), false, maxMatchCount + 1);
>      m_webPage->corePage()->unmarkAllTextMatches();
>  
> +    // Check if we have more matches than allowed.
> +    if (matchCount > maxMatchCount)
> +        matchCount = static_cast<unsigned>(kWKMoreThanMaximumMatchCount);

Do we need to worry about someone passing numeric_limits<unsigned>::max() as the maxMatchCount argument to this function? That would result in underflow.
Comment 6 Darin Adler 2011-03-31 09:15:50 PDT
Comment on attachment 87733 [details]
Take two, featuring non-degenerate ChangeLog entry.

View in context: https://bugs.webkit.org/attachment.cgi?id=87733&action=review

>> Source/WebKit2/WebProcess/WebPage/FindController.cpp:72
>> +        matchCount = static_cast<unsigned>(kWKMoreThanMaximumMatchCount);
> 
> Do we need to worry about someone passing numeric_limits<unsigned>::max() as the maxMatchCount argument to this function? That would result in underflow.

I think you probably mean overflow, resulting in the number 0.

An easy way to handle that overflow would be changing max() to max() - 1.
Comment 7 John Sullivan 2011-03-31 09:58:47 PDT
I'll fix the max() case for both this function and findMatchesForString() and submit another patch.
Comment 8 John Sullivan 2011-03-31 10:04:46 PDT
Created attachment 87754 [details]
Take three, now handles numeric_limits<unsigned>::max()
Comment 9 Adam Roben (:aroben) 2011-03-31 10:06:52 PDT
Comment on attachment 87733 [details]
Take two, featuring non-degenerate ChangeLog entry.

View in context: https://bugs.webkit.org/attachment.cgi?id=87733&action=review

>>> Source/WebKit2/WebProcess/WebPage/FindController.cpp:72
>>> +        matchCount = static_cast<unsigned>(kWKMoreThanMaximumMatchCount);
>> 
>> Do we need to worry about someone passing numeric_limits<unsigned>::max() as the maxMatchCount argument to this function? That would result in underflow.
> 
> I think you probably mean overflow, resulting in the number 0.
> 
> An easy way to handle that overflow would be changing max() to max() - 1.

Right, overflow!
Comment 10 John Sullivan 2011-03-31 10:40:00 PDT
Fixed in <http://trac.webkit.org/changeset/82594>.