Re: Computed Style and Border Width - Question [CSSOM]

On Tue, Jul 1, 2008 at 6:20 PM, Garrett Smith <dhtmlkitchen@gmail.com>
wrote:

> Webkit seems to do something similar. It seems to me that the behavior
> is not consistent with the way measurements are applied to other
> properties. For example, with the width property, when using
> percentages:-
>
> http://dhtmlkitchen.com/test/bug/float-bug.html
>
> And using the following javascript:
> javascript:var ds =
>
> document.getElementById('blinds').getElementsByTagName('div');alert(getComputedStyle(ds[0],'').width)
>
> FF3: 152.6
>
> The math works out right: 152.6 * 5 = 763
>
> However, with the border width example, it seems that device pixel is used.
>
> But with margin, a CSS Pixel is used. It's inconsistent.
>

Gecko layout uses subpixel precision, so margins, widths, etc are not
rounded to CSS pixels or device pixels. See
http://weblogs.mozillazine.org/roc/archives/2008/01/subpixel_layout.html for
more information about why we do that.

We do make an exception for border widths, by rounding their used values to
device pixels. This is necessary so that borders with the same computed
width are always drawn with the same width, regardless of their subpixel
offset, because an element whose top and bottom borders are different widths
looks really bad. We only do this for borders because in practice this is no
big deal for other lengths.

It's misleading to say that "a CSS pixel is used" or "a device pixel is
used". There's no bug about unit inconsistency here; it's just that borders
are rounded to device pixels and other values aren't.

Rob
-- 
"He was pierced for our transgressions, he was crushed for our iniquities;
the punishment that brought us peace was upon him, and by his wounds we are
healed. We all, like sheep, have gone astray, each of us has turned to his
own way; and the LORD has laid on him the iniquity of us all." [Isaiah
53:5-6]

Received on Tuesday, 1 July 2008 18:37:18 UTC