Last Comment Bug 216303 - [FIX]percentage heights don't work for auto-width floats
: [FIX]percentage heights don't work for auto-width floats
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Layout: Floats (show other bugs)
: Trunk
: All All
P1 major with 1 vote (vote)
: mozilla1.8beta1
Assigned To: Boris Zbarsky [:bz] (still a bit busy)
: Hixie (not reading bugmail)
: Jet Villegas (:jet)
Mentors:
http://www.cs.helsinki.fi/u/tksuoran/...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-08-15 12:44 PDT by Timo K. Suoranta
Modified: 2005-01-24 17:14 PST (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
testcase (633 bytes, application/xhtml+xml; charset=UTF-8)
2003-08-15 13:54 PDT, David Baron :dbaron: ⌚️UTC-8
no flags Details
another test case. (1.28 KB, text/html)
2004-03-27 22:10 PST, Carlos C.
no flags Details
Patch. (5.91 KB, patch)
2005-01-11 17:06 PST, Boris Zbarsky [:bz] (still a bit busy)
no flags Details | Diff | Splinter Review
Fix the assert (5.92 KB, patch)
2005-01-11 19:38 PST, Boris Zbarsky [:bz] (still a bit busy)
dbaron: review+
dbaron: superreview+
Details | Diff | Splinter Review

Description User image Timo K. Suoranta 2003-08-15 12:44:40 PDT
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.
Comment 1 User image David Baron :dbaron: ⌚️UTC-8 2003-08-15 13:08:00 PDT
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.
Comment 2 User image Timo K. Suoranta 2003-08-15 13:36:54 PDT
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.
Comment 3 User image David Baron :dbaron: ⌚️UTC-8 2003-08-15 13:53:05 PDT
The problem is that percentage heights don't seem to be working for auto-width
floats.
Comment 4 User image David Baron :dbaron: ⌚️UTC-8 2003-08-15 13:54:33 PDT
Created attachment 129875 [details]
testcase
Comment 5 User image Carlos C. 2004-03-27 22:10:46 PST
Created attachment 144940 [details]
another test case.

percentage unit (100%) inside a auto sized block renders wrong.
Comment 6 User image Carlos C. 2004-03-28 04:49:48 PST
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)
Comment 7 User image Boris Zbarsky [:bz] (still a bit busy) 2005-01-11 17:06:14 PST
Created attachment 170980 [details] [diff] [review]
Patch.

Still need to run the regression tests on this.
Comment 8 User image Boris Zbarsky [:bz] (still a bit busy) 2005-01-11 19:38:08 PST
Created attachment 170988 [details] [diff] [review]
Fix the assert

I ran this through the regression tests, and it passed...
Comment 9 User image David Baron :dbaron: ⌚️UTC-8 2005-01-24 14:45:04 PST
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...
Comment 10 User image Boris Zbarsky [:bz] (still a bit busy) 2005-01-24 15:34:21 PST
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...
Comment 11 User image David Baron :dbaron: ⌚️UTC-8 2005-01-24 15:36:04 PST
ah, ok.  Never mind, then.
Comment 12 User image Boris Zbarsky [:bz] (still a bit busy) 2005-01-24 17:14:53 PST
Fixed.

Note You need to log in before you can comment on or make changes to this bug.