[Webkit-unassigned] [Bug 53586] Rounding errors in converting cm to px

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Feb 8 10:54:53 PST 2019


https://bugs.webkit.org/show_bug.cgi?id=53586

yevseytsev <yevseytsev at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yevseytsev at gmail.com

--- Comment #2 from yevseytsev <yevseytsev at gmail.com> ---
Hello, I decided to start my contributions to WebKit from some bug triaging, and found out this bug. After reproducing the bug's code (Feb 2019) I actually got the following results for different browsers:

SAFARI
1cm = 38px +/- ~0.5
1cm = 37.8px +/- ~0.5
1cm = 37.8px +/- ~0.05
1cm = 37.795px +/- ~0.005
1cm = 37.7953px +/- ~0.0005

FIREFOX
1cm = 38px +/- ~0.5
1cm = 37.8px +/- ~0.5
1cm = 37.8px +/- ~0.05
1cm = 37.795px +/- ~0.005
1cm = 37.7953px +/- ~0.0005

GOOGLE CHROME
1cm = 38px +/- ~0.5
1cm = 37.8px +/- ~0.5
1cm = 37.8px +/- ~0.05
1cm = 37.795px +/- ~0.005
1cm = 37.7953px +/- ~0.0005

OPERA
1cm = 38px +/- ~0.5
1cm = 37.8px +/- ~0.5
1cm = 37.8px +/- ~0.05
1cm = 37.795px +/- ~0.005
1cm = 37.7953px +/- ~0.0005

All the values are the same for all 4 browsers, which means that the bug was fixed.
After researching the implementation of "roundForImpreciseConversion" function in Source/WebCore/css/CSSPrimitiveValue.h file I found out the following code:

template<typename T> inline T roundForImpreciseConversion(double value)
{
    // Dimension calculations are imprecise, often resulting in values of e.g.
    // 44.99998.  We need to go ahead and round if we're really close to the
    // next integer value.
    value += (value < 0) ? -0.01 : +0.01;
    return ((value > std::numeric_limits<T>::max()) || (value < std::numeric_limits<T>::min())) ? 0 : static_cast<T>(value);
}

I believe that after Sanders Shen's (weizhengshen at gmail.com) edit (24 Feb, 2012), macpherson at chromium.org did the final edit to "return" function code to fix this bug (20 Mar, 2012).

I think this bug is no longer a bug, because any of that 4 browsers does not have any rounding errors. 

As well we can't talk about WebKit bugs anymore in context of Chrome(desktop) and Opera, because in April 2013, Google and Opera Software announced the transition to the Blink engine. WebKit powers a Google Chrome only on iOS version of the browser.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20190208/7f7a7bed/attachment.html>


More information about the webkit-unassigned mailing list