Closed Bug 216303 Opened 21 years ago Closed 20 years ago

[FIX]percentage heights don't work for auto-width floats

Categories

(Core :: Layout: Floats, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8beta1

People

(Reporter: timo, Assigned: bzbarsky)

References

()

Details

Attachments

(2 files, 2 obsolete files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 In the page at http://www.cs.helsinki.fi/u/tksuoran/div_height_percentage.html, the three <div> elements should usually have the same size due to CSS height: 90% property. I believe that Mozilla does not support percentages in this case. I tried to put the divs inside a div of different class which had fixed pixel height but the problem remained. Reproducible: Always Steps to Reproduce: 1.Go to http://www.cs.helsinki.fi/u/tksuoran/div_height_percentage.html 2. 3. Actual Results: The <div> elements appear as their height property would be auto. Expected Results: The <div> elements should appear as their height property would 90%, which usually makes the three elements the same height.
http://www.w3.org/TR/CSS21/visudet.html#the-height-property says: <percentage> Specifies a percentage height. The percentage is calculated with respect to the height of the generated box's containing block. If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not positioned, the value is interpreted like 'auto'. Sometimes things like: html, body { height: 100%; } do what you want, although they may have other side-effects.
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
Originally I did not have the html, body { height: 100%; } in my style. I had the bug before that and now that I removed it I still have the bug. Someone suggested it as a fix but it did not work. However at that time I forgot to remove it.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
The problem is that percentage heights don't seem to be working for auto-width floats.
Assignee: other → float
Status: UNCONFIRMED → NEW
Component: Layout → Layout: Floats
Ever confirmed: true
Summary: div { height: 90%; } percentages for CSS height property appears to be ignored. → percentage heights don't work for auto-width floats
Attached file testcase (deleted) —
Severity: trivial → major
Attached file another test case. (obsolete) (deleted) —
percentage unit (100%) inside a auto sized block renders wrong.
Comment on attachment 144940 [details] another test case. my apologies, this test case seems to be bettter suited for Bug #208602. (Browser:Layout:Block and Inline)
Attachment #144940 - Attachment is obsolete: true
Attached patch Patch. (obsolete) (deleted) — Splinter Review
Still need to run the regression tests on this.
Assignee: layout.floats → bzbarsky
Status: NEW → ASSIGNED
Priority: -- → P1
Summary: percentage heights don't work for auto-width floats → [FIX]percentage heights don't work for auto-width floats
Target Milestone: --- → mozilla1.8beta
Attached patch Fix the assert (deleted) — Splinter Review
I ran this through the regression tests, and it passed...
Attachment #170980 - Attachment is obsolete: true
Attachment #170988 - Flags: superreview?(dbaron)
Attachment #170988 - Flags: review?(dbaron)
Comment on attachment 170988 [details] [diff] [review] Fix the assert I'm hoping the logic you're moving doesn't actually do anything useful, but r+sr=dbaron. The assertion doesn't seem bulletproof, though, since widthUnit can be set to auto if aContainingBlockWidth is NS_UNCONSTRAINEDSIZE. You might want to see if you can get the assertion to fire and maybe test to see if the behavior in that case changes at all...
Attachment #170988 - Flags: superreview?(dbaron)
Attachment #170988 - Flags: superreview+
Attachment #170988 - Flags: review?(dbaron)
Attachment #170988 - Flags: review+
widthUnit will be auto only if the actual unit is auto or if the actual unit is percent and NS_UNCONSTRAINEDSIZE == aContainingBlockWidth, as you say. But the assert I added is in the else branch of: if ((NS_UNCONSTRAINEDSIZE == aContainingBlockWidth) && (eStyleUnit_Percent == mStylePosition->mWidth.GetUnit())) { } else if (NS_STYLE_DISPLAY_TABLE == mStyleDisplay->mDisplay) { } else { } (the first condition just didn't make the context, for which I apologize). So the assertion looks correct to me...
ah, ok. Never mind, then.
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 21 years ago20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: