Closed Bug 509694 Opened 17 years ago Closed 13 years ago

Box size changes when swapping between fractional-pixel padding and identical fractional-pixel border

Categories

(Core :: Layout, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: csg, Unassigned)

References

()

Details

Attachments

(2 files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2a2pre) Gecko/20090810 Minefield/3.6a2pre Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2a2pre) Gecko/20090810 Minefield/3.6a2pre The result of calculating dimensions of a given box seems to be different for padding and border if using fractional numbers for defining them (e.g. "padding: 0.25em"). For a given CSS layout (see attachments) which does interchange a certain padding with a (new) border of same width / height on :hover (or :active, :focus) this causes a little "jumping" of following layout elements (always in example). In addition, _sometimes_ this does cause flickering of links/buttons, making navigational buttons (links) of the page unusable. (This is mostly reported by users, but one time watched by myself.) Reproducible: Always Steps to Reproduce: 1. Load the "bad" example into a current Firefox 2. Hover the first (top) blue button (link) with the mouse 3. Watch position of the second button below (and size of the hovered first button) Actual Results: Second button does move up a little bit and / because size of hovered (first) button does decrease. This is not the case in all other main browsers like Opera, Safari (PC) and even Microsoft Internet Explorer 8. (It violates my understanding of the CSS specification, too.) Expected Results: Changing layout of hovered button, but without changes in size or position - as given in the "good" example attached too. In case you want to change CSS code in the examples (to narrow down the problem further), watch out the comments in the attached test case (not online URL!) which do spot important points needed to reproduce the bug. Particularly, the anchor element ("a") must be block level and width / height of padding / border must be fractional *and* must not be end in ".5". Thus, "0.5em" or "1.0em" does *not* cause the bug, but "0.25em" or even "4.25px" do. This problem does arise at least since version 2.x of Firefox (Ubuntu Linux 7.10) and stays until version 3.5 and the last nightly build (some versions tested on Windows XP, some on different versions of Ubuntu Linux), with and without extensions. Hint: This bug may relate to incomplete bug No. 485279 .
The URL has changed to http://msie8www.c2web.de/ - the original site will be fixed by workaround today.
Other as stated inside report, the bug is *not* present in version 2 (Bug not present in Firefox 2.0.22pre while rechecking today). So, this seems to be a version 3 bug only. (Successfully rechecked today: Bug present in at least Firefox 3.5.2 and Minefield 3.6a2pre.)
I stumbled upon this bug while going through Core bugs (in particular, those with "CSS") that are languishing in Firefox::General. There are a bunch of tradeoffs here, and we've made them so that swapping between border and padding can cause changes in side, but so that a bunch of other important things work well. In particular: Gecko does layout using sub-pixel coordinates. This means that widths, heights, margins, padding, etc., can have sub-pixel edges. This means that, for example, four boxes with 25% width will (a) always fill their container and (b) never overflow. When we paint, we snap all of these edges to the nearest pixel. This means that the four boxes mentioned previously might end up with apparent widths differing by 1 pixel (if the container's width is not a multiple of 4four). However, that behavior is bad for borders, so we snap the widths of all borders to the nearest pixel before doing layout, so that, for example, a 1.5px border will always end up the same width on all sides. (That was the change made in Firefox 3 -- bug 287624). That's why swapping between non-pixel-rounded values of 'border' and 'padding' can change layout. I think there's a legitimated tradeoff here, and we're probably making it the right way. In theory, we could do the same thing we do for borders for padding and margin -- except padding and margin also take percentage values, which are one of the reasons we want subpixel calculations in the first place. Or maybe we could do snapping for non-percentage values of padding and margin, but leave percentage values alone. (Maybe even width and height and other properties too?)
Status: UNCONFIRMED → NEW
Component: General → Layout
Ever confirmed: true
Product: Firefox → Core
QA Contact: general → layout
Summary: Box size does change on :hover when using fractional numbers in CSS for height of padding and border → Box size changes when swapping between fractional-pixel padding and identical fractional-pixel border
Oops, noticed some typos: s/changes in side/changes in size/ s/legitimated/legitimate/
Some updates: * The Testcase-URL http://msie8www.c2web.de/index.php is no longer available (I cleaned up that webspace some time ago). * The bug is fixed at least in Firefox 20.0 (the 2 attachments works fine for me now). So I'm closing here now.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
I think the underlying issue described is still present, but I think it's something we don't intend to fix.
Resolution: INVALID → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: