Bug 81016

Summary: [mac/chromium] Change platform code to use pixelSnappedRect methods
Product: WebKit Reporter: Emil A Eklund <eae>
Component: PlatformAssignee: Emil A Eklund <eae>
Status: RESOLVED FIXED    
Severity: Normal CC: dglazkov, eric, leviw, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 60318, 81413    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch for landing none

Description Emil A Eklund 2012-03-13 11:54:46 PDT
Change platform code to use Node::getPixelSnappedRect, pixelSnappedBoundingBoxRect and pixelSnappedAbsoluteClippedOverflowRect to avoid exposing subpixel types to the platform layer.
Comment 1 Emil A Eklund 2012-03-13 11:57:36 PDT
Created attachment 131688 [details]
Patch
Comment 2 Eric Seidel (no email) 2012-03-13 12:03:42 PDT
Comment on attachment 131688 [details]
Patch

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

> Source/WebKit/chromium/src/WebViewImpl.cpp:810
> -        IntRect rect = node->Node::getRect();
> +        IntRect rect = node->Node::getPixelSnappedRect();

Why does this method have "get" in the name?  That's generlaly disroucaged in WebKIt?  Is it DOM API or somethign?

> Source/WebKit/mac/WebView/WebFrame.mm:1297
> +    float printWidth = root->style()->isHorizontalWritingMode() ? static_cast<float>(documentRect.width()) / printScaleFactor : pageSize.width;

Isn't there a .toFloat() method instead of a static_cast?  I guess that's only for hte rect as a whole since LayoutUnit isn't a class yet...

> Source/WebKit/mac/WebView/WebView.mm:2039
> +        WebDashboardRegion *webRegion = [[WebDashboardRegion alloc] initWithRect:pixelSnappedIntRect(region.bounds) clip:pixelSnappedIntRect(region.clip) type:type];

Are bounds/clip LayoutRects here?

> Source/WebKit/mac/WebView/WebView.mm:2500
> +        [rectsArray addObject:[NSValue valueWithRect:pixelSnappedIntRect(repaintRects[i])]];

Here too?  I'm surprised you need these functions much at this layer. Apple Graphics APIs all function in floats.
Comment 3 Emil A Eklund 2012-03-13 12:07:11 PDT
Comment on attachment 131688 [details]
Patch

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

>> Source/WebKit/chromium/src/WebViewImpl.cpp:810
>> +        IntRect rect = node->Node::getPixelSnappedRect();
> 
> Why does this method have "get" in the name?  That's generlaly disroucaged in WebKIt?  Is it DOM API or somethign?

To be consistent with the current API. I'd gladly rename both to rect and pixelSnappedRect respectively.

>> Source/WebKit/mac/WebView/WebFrame.mm:1297
>> +    float printWidth = root->style()->isHorizontalWritingMode() ? static_cast<float>(documentRect.width()) / printScaleFactor : pageSize.width;
> 
> Isn't there a .toFloat() method instead of a static_cast?  I guess that's only for hte rect as a whole since LayoutUnit isn't a class yet...

LayoutUnit has a toFloat method, int doesn't though. This way it'll work both with LayoutRect defined as an IntRect and as a FractionalLayoutRect.

>> Source/WebKit/mac/WebView/WebView.mm:2039
>> +        WebDashboardRegion *webRegion = [[WebDashboardRegion alloc] initWithRect:pixelSnappedIntRect(region.bounds) clip:pixelSnappedIntRect(region.clip) type:type];
> 
> Are bounds/clip LayoutRects here?

Yeah.

>> Source/WebKit/mac/WebView/WebView.mm:2500
>> +        [rectsArray addObject:[NSValue valueWithRect:pixelSnappedIntRect(repaintRects[i])]];
> 
> Here too?  I'm surprised you need these functions much at this layer. Apple Graphics APIs all function in floats.

The APIs are all float but we do most painting snapped to device pixels.
Comment 4 Early Warning System Bot 2012-03-13 12:51:29 PDT
Comment on attachment 131688 [details]
Patch

Attachment 131688 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/11949585
Comment 5 WebKit Review Bot 2012-03-13 13:21:35 PDT
Comment on attachment 131688 [details]
Patch

Attachment 131688 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/11941746
Comment 6 Early Warning System Bot 2012-03-13 13:48:36 PDT
Comment on attachment 131688 [details]
Patch

Attachment 131688 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/11949618
Comment 7 Emil A Eklund 2012-03-13 15:11:40 PDT
Created attachment 131723 [details]
Patch
Comment 8 WebKit Review Bot 2012-03-13 17:19:00 PDT
Comment on attachment 131723 [details]
Patch

Attachment 131723 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/11949730
Comment 9 Early Warning System Bot 2012-03-14 02:19:24 PDT
Comment on attachment 131723 [details]
Patch

Attachment 131723 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/11942968
Comment 10 Early Warning System Bot 2012-03-14 02:50:55 PDT
Comment on attachment 131723 [details]
Patch

Attachment 131723 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/11951140
Comment 11 Emil A Eklund 2012-03-14 18:12:29 PDT
Created attachment 131968 [details]
Patch
Comment 12 Emil A Eklund 2012-03-16 14:29:07 PDT
Eric, would you mind taking another look at this when you get a chance?
Comment 13 Eric Seidel (no email) 2012-03-16 14:40:21 PDT
Comment on attachment 131968 [details]
Patch

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

Thank you for the reminder.  bug mail gets lost in the torrent...

> Source/WebCore/dom/Node.h:378
>      virtual LayoutRect getRect() const;
> +    IntRect getPixelSnappedRect() const { return pixelSnappedIntRect(getRect()); }

I really don't like the "get" here.  "Rect" is also not very useful, as you don't know what "rect" it means. :(
Comment 14 Emil A Eklund 2012-03-16 14:54:15 PDT
Thanks Eric!

> > Source/WebCore/dom/Node.h:378
> >      virtual LayoutRect getRect() const;
> > +    IntRect getPixelSnappedRect() const { return pixelSnappedIntRect(getRect()); }
> 
> I really don't like the "get" here.  "Rect" is also not very useful, as you don't know what "rect" it means. :(

If we can come up with a better name I'll gladly do the work to rename it. I filed bug 81413 to track this.
Comment 15 WebKit Review Bot 2012-03-16 16:08:04 PDT
Comment on attachment 131968 [details]
Patch

Rejecting attachment 131968 [details] from commit-queue.

Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2

Last 500 characters of output:
webkit-commit-queue/Source/WebKit/chromium/webkit --revision 126866 --non-interactive --force --accept theirs-conflict --ignore-externals' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'
48>At revision 126866.

________ running '/usr/bin/python tools/clang/scripts/update.py --mac-only' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'

________ running '/usr/bin/python gyp_webkit' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'
Updating webkit projects from gyp files...

Full output: http://queues.webkit.org/results/11963520
Comment 16 Emil A Eklund 2012-03-19 14:22:26 PDT
Created attachment 132671 [details]
Patch for landing
Comment 17 WebKit Review Bot 2012-03-19 16:34:11 PDT
Comment on attachment 132671 [details]
Patch for landing

Clearing flags on attachment: 132671

Committed r111268: <http://trac.webkit.org/changeset/111268>
Comment 18 WebKit Review Bot 2012-03-19 16:34:16 PDT
All reviewed patches have been landed.  Closing bug.