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

RESOLVED FIXED in mozilla1.8beta1

Status

()

Core
Layout: Floats
P1
major
RESOLVED FIXED
14 years ago
13 years ago

People

(Reporter: Timo K. Suoranta, Assigned: bz)

Tracking

Trunk
mozilla1.8beta1
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(2 attachments, 2 obsolete attachments)

(Reporter)

Description

14 years ago
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
Last Resolved: 14 years ago
Resolution: --- → INVALID
(Reporter)

Comment 2

14 years ago
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
Created attachment 129875 [details]
testcase
Severity: trivial → major

Comment 5

14 years ago
Created attachment 144940 [details]
another test case.

percentage unit (100%) inside a auto sized block renders wrong.

Comment 6

14 years ago
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
Created attachment 170980 [details] [diff] [review]
Patch.

Still need to run the regression tests on this.
Assignee: layout.floats → bzbarsky
Status: NEW → ASSIGNED
(Assignee)

Updated

13 years ago
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
Created attachment 170988 [details] [diff] [review]
Fix the assert

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
Last Resolved: 14 years ago13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.