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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Feb 2 04:55:20 PST 2011


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

           Summary: Rounding errors in converting cm to px
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: PC
        OS/Version: Windows Vista
            Status: NEW
          Severity: Normal
          Priority: P1
         Component: CSS
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: skylined at chromium.org
                CC: eric at webkit.org


Created an attachment (id=80910)
 --> (https://bugs.webkit.org/attachment.cgi?id=80910&action=review)
Repro

It appears webkit is rounding sizes specified in "cm" down, where other browsers are not.
Repro: run the following test in multiple browsers:
<!doctype html>
<script>
  for (var i = 0; i < 5; i++) {
    var iSize = Math.pow(10, i);
    var o = document.createElement('span');
    document.documentElement.appendChild(o);
    o.style.display = 'block';
    o.style.width = iSize + 'cm';
    document.write('1cm = ' + (o.clientWidth / iSize) + 'px +/- ~0.' + new Array(i).join('0') + '5<br/>');
  }
</script>
Chrome/Safari both output the same values, with rounding down errors:
1cm = 37px +/- ~0.5
1cm = 37.7px +/- ~0.05
1cm = 37.79px +/- ~0.005
1cm = 37.795px +/- ~0.0005
1cm = 37.7952px +/- ~0.00005

Firefox/MSIE both output the same values, which seem to get rounded correctly:
1cm = 38px +/- ~0.5
1cm = 37.8px +/- ~0.05
1cm = 37.8px +/- ~0.005
1cm = 37.795px +/- ~0.0005
1cm = 37.7953px +/- ~0.00005

Opera seems to agree with FF/MSIE for the most part, but doesn't appear to limit sizes to 32,767 (0x7FFF), so the last two values are not calculated correctly:
1cm = 38px +/- ~0.5
1cm = 37.8px +/- ~0.05
1cm = 37.8px +/- ~0.005
1cm = 32.767px +/- ~0.0005
1cm = 3.2767px +/- ~0.00005

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list