W3C home > Mailing lists > Public > www-style@w3.org > July 2008

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

From: Robert O'Callahan <robert@ocallahan.org>
Date: Wed, 2 Jul 2008 06:36:43 +1200
Message-ID: <11e306600807011136m6a441256r661272e6c9e81df5@mail.gmail.com>
To: "Garrett Smith" <dhtmlkitchen@gmail.com>
Cc: Www-style <www-style@w3.org>
On Tue, Jul 1, 2008 at 6:20 PM, Garrett Smith <dhtmlkitchen@gmail.com>

> 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.

"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
Received on Tuesday, 1 July 2008 18:37:18 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:38 UTC