Bug 97265 - snapToSize rounds the incorrectly for negative locations
Summary: snapToSize rounds the incorrectly for negative locations
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Emil A Eklund
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-20 15:22 PDT by Emil A Eklund
Modified: 2012-09-24 09:36 PDT (History)
5 users (show)

See Also:


Attachments
Patch (10.74 KB, patch)
2012-09-20 15:46 PDT, Emil A Eklund
no flags Details | Formatted Diff | Diff
Patch (10.76 KB, patch)
2012-09-21 14:48 PDT, Emil A Eklund
no flags Details | Formatted Diff | Diff
Patch for landing (10.95 KB, patch)
2012-09-21 15:00 PDT, Emil A Eklund
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Emil A Eklund 2012-09-20 15:22:57 PDT
In snapToSize we use the fraction of the location rather than the full location when adjusting the width. This results in the sign being lost which in turn affects rounding.


Downstream chromium bug: http://code.google.com/p/chromium/issues/detail?id=150802
Comment 1 Emil A Eklund 2012-09-20 15:46:08 PDT
Created attachment 165002 [details]
Patch
Comment 2 Eric Seidel (no email) 2012-09-20 15:59:34 PDT
Comment on attachment 165002 [details]
Patch

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

> Source/WebCore/platform/FractionalLayoutUnit.h:810
> +    FractionalLayoutUnit fraction = (location - location.floor()) * (location < 0 ? -1 : 1);

I this the most elegant way to do this?  It seems you're undoing floor's magic, which presumably ignores sign.
Comment 3 Emil A Eklund 2012-09-20 16:01:44 PDT
(In reply to comment #2)
> (From update of attachment 165002 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=165002&action=review
> 
> > Source/WebCore/platform/FractionalLayoutUnit.h:810
> > +    FractionalLayoutUnit fraction = (location - location.floor()) * (location < 0 ? -1 : 1);
> 
> I this the most elegant way to do this?  It seems you're undoing floor's magic, which presumably ignores sign.

I'm sure it is not but it is the best I've managed to come up with so far.
If you have any suggestions I'm all ears.
Comment 4 Levi Weintraub 2012-09-20 17:55:31 PDT
Comment on attachment 165002 [details]
Patch

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

>>> Source/WebCore/platform/FractionalLayoutUnit.h:810
>>> +    FractionalLayoutUnit fraction = (location - location.floor()) * (location < 0 ? -1 : 1);
>> 
>> I this the most elegant way to do this?  It seems you're undoing floor's magic, which presumably ignores sign.
> 
> I'm sure it is not but it is the best I've managed to come up with so far.
> If you have any suggestions I'm all ears.

Isn't the fraction just location.rawValue() % kFixedPointDenominator?
Comment 5 WebKit Review Bot 2012-09-21 01:12:48 PDT
Comment on attachment 165002 [details]
Patch

Attachment 165002 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13932472

New failing tests:
compositing/reflections/reflection-in-composited.html
fast/writing-mode/Kusa-Makura-background-canvas.html
css3/filters/nested-filter.html
media/video-zoom-controls.html
fast/multicol/vertical-lr/float-multicol.html
Comment 6 Emil A Eklund 2012-09-21 14:48:51 PDT
Created attachment 165195 [details]
Patch
Comment 7 Eric Seidel (no email) 2012-09-21 14:53:13 PDT
Comment on attachment 165195 [details]
Patch

LGTM.
Comment 8 Eric Seidel (no email) 2012-09-21 14:53:44 PDT
Comment on attachment 165195 [details]
Patch

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

> Source/WebCore/platform/FractionalLayoutUnit.h:811
> +    fraction.setRawValue(location.rawValue() % kFixedPointDenominator);

A comment about why we do it this way might help, but this is also OK.
Comment 9 Emil A Eklund 2012-09-21 15:00:10 PDT
Created attachment 165199 [details]
Patch for landing
Comment 10 Emil A Eklund 2012-09-21 15:00:35 PDT
Thanks Eric. Added a comment explaining why we do it this way.
Comment 11 WebKit Review Bot 2012-09-21 16:29:53 PDT
Comment on attachment 165199 [details]
Patch for landing

Rejecting attachment 165199 [details] from commit-queue.

New failing tests:
WebFilterOperationsTest.saveAndRestore
media/video-zoom-controls.html
Full output: http://queues.webkit.org/results/13956808
Comment 12 Emil A Eklund 2012-09-24 08:34:50 PDT
Committed r129370: <http://trac.webkit.org/changeset/129370>