Bug 133417

Summary: [iOS][WK2] Round the UIScrollView content size to device pixel
Product: WebKit Reporter: Benjamin Poulain <benjamin>
Component: New BugsAssignee: Benjamin Poulain <benjamin>
Status: RESOLVED FIXED    
Severity: Normal Keywords: InRadar
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch simon.fraser: review+

Description Benjamin Poulain 2014-05-30 21:54:49 PDT
[iOS][WK2] Round the UIScrollView content size to device pixel
Comment 1 Benjamin Poulain 2014-05-30 21:56:41 PDT
Created attachment 232314 [details]
Patch
Comment 2 Benjamin Poulain 2014-05-30 21:57:22 PDT
<rdar://problem/15922440>
Comment 3 zalan 2014-05-30 22:13:45 PDT
Comment on attachment 232314 [details]
Patch

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

> Source/WebKit2/ChangeLog:11
> +        This patch ensure the content size as seen by the API is rounded to device pixels.

rounded or floored?

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:455
> +static inline CGFloat floorFloatToPixels(CGFloat input, float deviceScaleFactor)

We've been using roundToDevicePixel, floorToDevicePixel terms in WebCore. Having 'float' in the function name doesn't add any useful information, while it's missing what the rounding unit is.
Any explanation why we floor instead of round or ceil? (I guess, it's because you don't want garbage at the edges, but it'd be helpful to explain it in the changelog)
Comment 4 Ian Henderson 2014-05-31 01:22:16 PDT
Comment on attachment 232314 [details]
Patch

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

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:460
> +static CGSize roundScrollViewCountentSize(const WebKit::WebPageProxy& page, const CGSize& contentSize)

"Countent" -> "Content"

Is there a reason to pass contentSize by const reference instead of by value here?  It seems likely it'll all be inlined anyway.

Everything else looks good to me, thanks!
Comment 5 Benjamin Poulain 2014-05-31 01:31:10 PDT
> Is there a reason to pass contentSize by const reference instead of by value here?  It seems likely it'll all be inlined anyway.

It is an habit. We pass stuff by const reference when they cannot be passed as registers. The "default" is to use const reference for non POD.

Here the CGSize can be passed by registers, so I should not have used const references.
Comment 6 Benjamin Poulain 2014-06-02 15:00:25 PDT
Created attachment 232401 [details]
Patch
Comment 7 Simon Fraser (smfr) 2014-06-02 15:05:04 PDT
Comment on attachment 232401 [details]
Patch

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

> Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:460
> +static CGSize roundScrollViewContentSize(const WebKit::WebPageProxy& page, CGSize contentSize)

Why not just pass in page.deviceScaleFactor()?
Comment 8 Benjamin Poulain 2014-06-02 15:10:07 PDT
(In reply to comment #7)
> (From update of attachment 232401 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=232401&action=review
> 
> > Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:460
> > +static CGSize roundScrollViewContentSize(const WebKit::WebPageProxy& page, CGSize contentSize)
> 
> Why not just pass in page.deviceScaleFactor()?

Too many call sites, the repetition is not worth it.
Comment 9 Benjamin Poulain 2014-06-02 15:19:33 PDT
Committed r169549: <http://trac.webkit.org/changeset/169549>