Bug 131000

Summary: Need an Objective-C API or SPI for Find in Page
Product: WebKit Reporter: Alice Liu <alice.barraclough>
Component: WebKit2Assignee: Alice Liu <alice.barraclough>
Status: RESOLVED FIXED    
Severity: Normal CC: alice.barraclough, andersca, commit-queue, mitz, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch
none
Patch
none
Patch mitz: review+

Description Alice Liu 2014-03-31 18:28:41 PDT
WebKit2 has a C API for finding in page, but no Cocoa one.
Comment 1 Alice Liu 2014-03-31 18:35:38 PDT
Created attachment 228229 [details]
patch

patch for build bot test, first.
Comment 2 Alice Liu 2014-03-31 18:55:53 PDT
Created attachment 228230 [details]
Patch
Comment 3 Alice Liu 2014-03-31 19:03:06 PDT
Created attachment 228231 [details]
Patch
Comment 4 WebKit Commit Bot 2014-03-31 19:04:32 PDT
Attachment 228231 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h:43:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h:134:  Missing spaces around =  [whitespace/operators] [4]
Total errors found: 2 in 14 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Alice Liu 2014-03-31 19:16:05 PDT
(In reply to comment #4)
> ERROR: Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h:43:  Place brace on its own line for function definitions.  [whitespace/braces] [4]

This isn't incorrect style for a NS_OPTIONS typedef.  Style for functions is being applied in the wrong context. 

> ERROR: Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h:134:  Missing spaces around =  [whitespace/operators] [4]

This isn't incorrect style for property declarations. This matches the style of the line directly above it. Style for assignment operator is being applied in the wrong context. 

> If any of these errors are false positives, please file a bug against check-webkit-style.

How to do this?  I did not find a component by the name of "check-webkit-style" when selecting the component for a new bug.
Comment 6 Alice Liu 2014-03-31 19:21:47 PDT
The gtk-wk2 build failure is irrelevant.  It was caused by http://trac.webkit.org/changeset/166553.
Comment 7 mitz 2014-04-01 20:38:52 PDT
Comment on attachment 228231 [details]
Patch

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

Looks great! I can imagine a version of this API where there is no delegate, and the “find” and “count” methods take completion handler blocks, but as SPI this is a great start.

> Source/WebKit2/UIProcess/API/APIFindClient.h:43
> +    virtual void didCountStringMatches(WebKit::WebPageProxy*, const WTF::String&, uint32_t matchCount) { }
> +    virtual void didFindString(WebKit::WebPageProxy*, const WTF::String&, uint32_t matchCount) { }
> +    virtual void didFailToFindString(WebKit::WebPageProxy*, const WTF::String&) { }

No need to qualify String with WTF:: since WTFString.h, which you’re including, says “using WTF::String”.

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:1227
> +- (UIView *)_hostForFindUI

Why not call this _viewForFindUI? “Host” has other meanings, and isn’t a term we normally use to describe the role of a view.

> Source/WebKit2/UIProcess/Cocoa/FindClient.h:45
> +    RetainPtr<id <_WKFindDelegate> > delegate();

No need for the space between the > >.

> Source/WebKit2/UIProcess/Cocoa/FindClient.h:55
> +    WeakObjCPtr<id <_WKFindDelegate> > m_delegate;

Ditto.

> Source/WebKit2/UIProcess/Cocoa/FindClient.mm:40
> +RetainPtr<id <_WKFindDelegate> > FindClient::delegate()

Ditto.

> Source/WebKit2/UIProcess/Cocoa/FindClient.mm:45
> +void FindClient::setDelegate(id <_WKFindDelegate> delegate)

Ditto.
Comment 8 Alice Liu 2014-04-02 12:43:28 PDT
(In reply to comment #7)
> > Source/WebKit2/UIProcess/API/APIFindClient.h:43
> > +    virtual void didCountStringMatches(WebKit::WebPageProxy*, const WTF::String&, uint32_t matchCount) { }
> > +    virtual void didFindString(WebKit::WebPageProxy*, const WTF::String&, uint32_t matchCount) { }
> > +    virtual void didFailToFindString(WebKit::WebPageProxy*, const WTF::String&) { }
> 
> No need to qualify String with WTF:: since WTFString.h, which you’re including, says “using WTF::String”.

I tried removing WTF:: and it resulted in a compile time error in WebPageProxy.  I think the compiler is assuming API::String if the WTF:: is not present to clarify which String class. 

thanks for reviewing.
Comment 9 Anders Carlsson 2014-04-02 12:44:53 PDT
(In reply to comment #8)
> (In reply to comment #7)

> > No need to qualify String with WTF:: since WTFString.h, which you’re including, says “using WTF::String”.
> 
> I tried removing WTF:: and it resulted in a compile time error in WebPageProxy.  I think the compiler is assuming API::String if the WTF:: is not present to clarify which String class. 
> 

Yeah it is needed to resolve the API::String vs WTF::String ambiguity.
Comment 10 Alice Liu 2014-04-02 12:52:15 PDT
Committed r166658: <http://trac.webkit.org/changeset/166658>