[webkit-dev] offsetWidth/Height/Left/Top int to float

Ion Rosca rosca at adobe.com
Mon Jun 18 07:56:30 PDT 2012


Hello,

I have some questions regarding zooming and offsetWidth/Height/Top/Left.
Currently, Element.offset* properties return imprecise values when zooming in/out. One of the bugs describing this problem would be Issue 104074: offsetWidth of element is shrinking when zooming in<http://code.google.com/p/chromium/issues/detail?id=104074> with a simple test case<http://jsfiddle.net/V4HQc/>.
The product I’m working on also embeds WebKit and it would really need more precision from Element.offset*. We’ve done some testing by making offset*s to return floats and this approach appears to improve precision a lot.

I found in archive<http://lists.webkit.org/pipermail/webkit-dev/2011-June.txt> an email from Levi Weintraub<mailto:leviw at chromium.org>, sent in June 2011, saying:
… Changing rendering (and hit testing) to use floats does not necessarily mean
that we need to expose floats through the dom api, however if we are to
support sub-pixel layout (i.e. style=?left: 12.3px?) this would be required.
Specifically we?d need to change the offsetLeft/Top/Width/Height properties
to return floating point values [2]<https://bugs.webkit.org/show_bug.cgi?id=54018>.
The meta bug 60318<https://bugs.webkit.org/show_bug.cgi?id=60318>  (Switch away from integers …) Levi was working on is already fixed and the inner bugs (addressing this problem) bug 54018<https://bugs.webkit.org/show_bug.cgi?id=54018> (Make offset* return doubles instead of ints) and bug 39884<https://bugs.webkit.org/show_bug.cgi?id=39884> - Full Page Zoom: rounding errors with element metrics are still opened and theirs resolution is not clear.

What’s your opinion on this subject? Were there some other discussions on it I couldn’t find? Is there a chance for making offset properties returning floats to be accepted? What are the implications of making this change in terms of specifications?

Thank you,
Ion Rosca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20120618/c21443e3/attachment.html>


More information about the webkit-dev mailing list