Bug 137358

Summary: [iOS] Teach WKPDFView to navigate to pageNumber links
Product: WebKit Reporter: Andy Estes <aestes>
Component: New BugsAssignee: Andy Estes <aestes>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch thorton: review+

Description Andy Estes 2014-10-02 13:43:33 PDT
[iOS] Teach WKPDFView to navigate to pageNumber links
Comment 1 Andy Estes 2014-10-02 14:05:14 PDT
rdar://problem/18334903
Comment 2 Andy Estes 2014-10-02 14:18:15 PDT
Created attachment 239137 [details]
Patch
Comment 3 WebKit Commit Bot 2014-10-02 14:20:20 PDT
Attachment 239137 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/ios/WKPDFView.mm:356:  The parameter name "url" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Tim Horton 2014-10-02 14:27:27 PDT
Comment on attachment 239137 [details]
Patch

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

> Source/WebKit2/UIProcess/ios/WKPDFView.mm:359
> +        urlString = String::format("#page%lu", pageNumber);

I'm not sure String::format is the best way to do this. I realize that this isn't performance critical code, but still probably not a great example to set.
Comment 5 Andy Estes 2014-10-02 14:30:16 PDT
(In reply to comment #4)
> (From update of attachment 239137 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=239137&action=review
> 
> > Source/WebKit2/UIProcess/ios/WKPDFView.mm:359
> > +        urlString = String::format("#page%lu", pageNumber);
> 
> I'm not sure String::format is the best way to do this. I realize that this isn't performance critical code, but still probably not a great example to set.

What's the alternative? append '0' + pageNumber as a character literal?
Comment 6 Andy Estes 2014-10-02 14:39:16 PDT
Oh never mind, WTFString has a bunch of number conversion functions.
Comment 7 Andy Estes 2014-10-02 14:51:21 PDT
Committed r174232: <http://trac.webkit.org/changeset/174232>
Comment 8 Darin Adler 2014-10-02 16:05:53 PDT
Comment on attachment 239137 [details]
Patch

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

>>> Source/WebKit2/UIProcess/ios/WKPDFView.mm:359
>>> +        urlString = String::format("#page%lu", pageNumber);
>> 
>> I'm not sure String::format is the best way to do this. I realize that this isn't performance critical code, but still probably not a great example to set.
> 
> What's the alternative? append '0' + pageNumber as a character literal?

One alternative is to use StringBuilder and appendNumber. I don’t think it’s higher performance than String::format, but it does avoid the assumption that NSUInteger is always unsigned long, which this code makes by using %lu for it.