Last Comment Bug 214844 - [FIX] relatively positioned block w/ overflow:auto should be absolute pos. containing block
: [FIX] relatively positioned block w/ overflow:auto should be absolute pos. co...
Status: RESOLVED FIXED
[patch]
: testcase
Product: Core
Classification: Components
Component: Layout: R & A Pos (show other bugs)
: Trunk
: All All
: -- normal (vote)
: ---
Assigned To: Mats Palmgren (:mats)
: Hixie (not reading bugmail)
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-08-01 20:14 PDT by Andy Stone
Modified: 2003-08-14 21:43 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
example from comment 0 (1.46 KB, text/html)
2003-08-01 22:05 PDT, Chris Casciano
no flags Details
Testcase (548 bytes, text/html)
2003-08-02 03:02 PDT, Mats Palmgren (:mats)
no flags Details
Testcase #2 (overflow:scroll) (551 bytes, text/html)
2003-08-02 08:02 PDT, Mats Palmgren (:mats)
no flags Details
Patch rev. 1 (1.31 KB, patch)
2003-08-02 08:18 PDT, Mats Palmgren (:mats)
dbaron: review+
dbaron: superreview+
Details | Diff | Review
Patch rev. 2 (3.06 KB, patch)
2003-08-02 10:37 PDT, Mats Palmgren (:mats)
dbaron: review+
dbaron: superreview+
asa: approval1.5b+
Details | Diff | Review

Description Andy Stone 2003-08-01 20:14:26 PDT
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

An absolute block should be contained by (and so positioned inside or relative
to the selected corner of) the "the nearest ancestor with a 'position' other
than 'static'," (see CSS2 10.1)
href=http://www.w3.org/TR/REC-CSS2/visudet.html#containing-block-details

EXAMPLE:
<head><style type='text/css'>
#Block2 { display:block; position:relative;  border-width:2px
;border-style:dashed; overflow:auto; width:auto; height:auto;  }
#Block3 {  display:block;position:relative;  border-width:2px
;border-style:dashed; overflow:auto; width:100%; height:100%;  }
#Block4 {  display:block;position:absolute;  border-width:2px
;border-style:dashed; overflow:auto;  left:0 ; top:0 ; width:50% ; height:auto ;
z-index:1 }
#Block5 {  display:block;position:absolute;  border-width:2px
;border-style:dashed; overflow:auto;  left:10 ; top:50 ; width:50% ; height:auto
; z-index:1 }
</style></head><body>
<div id=Block2>
Use up space <br><br>
</div>
<div id=Block3>
<br><br><br><br><br><br><br><br><br><br><br>
If you change the positioning of block 3 to absolute You will see correct
positioning of the children
  <div id=Block4> this is mispositioned so it cant be seen </div>
  <div id=Block5> You can see this, but it is mispositioned relative to the top
left of the screen.  It should be relative to the "the nearest ancestor with a
'position' other than 'static'," (see CSS2 10.1 <a
href=http://www.w3.org/TR/REC-CSS2/visudet.html#containing-block-details>
http://www.w3.org/TR/REC-CSS2/visudet.html#containing-block-details</a> </div>
</div>
</body>


Reproducible: Always

Steps to Reproduce:
Just load the example in the browser

Actual Results:  
A block that should be shown is hidden because it is outside of the dimensions
of the containing block.  A block that should be 50 pixels lower and 10 to the
right from the top left of the containing block appears right at the top left (I
chose the 50/10 so you it would appear there)

Expected Results:  
Change block 3 to "absolute" to see what it should have done (WRT the children).
Comment 1 Chris Casciano 2003-08-01 22:05:06 PDT
Created attachment 129058 [details]
example from comment 0

This is the example given by the reporter... formatted a little with minor
changes (doctype, "px" on css units, etc.)

Reporter, in the future it would be helpful to postt the example on a site and
point to it with the URL field or post the example as an attachment after you
file the bug.
Comment 2 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2003-08-01 23:05:54 PDT
It's the overflow:auto on the DIV with ID block3 that's breaking things.
Comment 3 Mats Palmgren (:mats) 2003-08-02 03:02:55 PDT
Created attachment 129061 [details]
Testcase
Comment 4 Mats Palmgren (:mats) 2003-08-02 03:20:32 PDT
Bug also occurs in Mozilla 1.0.2 and 1.3.1 on Linux
Comment 5 Andy Stone 2003-08-02 06:14:47 PDT
Also, overflow:scroll has the same problem.
All the others work.
Comment 6 Chris Casciano 2003-08-02 07:11:11 PDT
-> All/All (OS X)
Comment 7 Mats Palmgren (:mats) 2003-08-02 08:02:37 PDT
Created attachment 129067 [details]
Testcase #2 (overflow:scroll)
Comment 8 Mats Palmgren (:mats) 2003-08-02 08:15:30 PDT
The problem is that the abs.pos. child ends up on the "absolute list" for
Area(html) rather than the rel.pos. parent's "absolute list".
Taking this since I have a patch.
Comment 9 Mats Palmgren (:mats) 2003-08-02 08:18:14 PDT
Created attachment 129068 [details] [diff] [review]
Patch rev. 1

PushAbsoluteContainingBlock() when rel. pos. too
Comment 10 Mats Palmgren (:mats) 2003-08-02 08:31:48 PDT
FYI, there is similar code in nsCSSFrameConstructor::InitializeSelectFrame and
nsCSSFrameConstructor::ConstructFieldSetFrame.  I did update those too but
couldn't see any improvement - these frame types does not seem to handle
positioned children so I excluded it from the patch.
Comment 11 David Baron :dbaron: ⌚️UTC-7 (review requests must explain patch) 2003-08-02 10:17:05 PDT
Comment on attachment 129068 [details] [diff] [review]
Patch rev. 1

r+sr=dbaron, and it's probably better to fix the other two as well in case
somebody copies the code (which somebody obviously did to create those
functions in the first place!)
Comment 12 Mats Palmgren (:mats) 2003-08-02 10:37:01 PDT
Created attachment 129074 [details] [diff] [review]
Patch rev. 2

OK, this fixes InitializeSelectFrame and ConstructFieldSetFrame too
Comment 13 Boris Zbarsky [:bz] (Out June 25-July 6) 2003-08-09 15:15:28 PDT
Comment on attachment 129074 [details] [diff] [review]
Patch rev. 2

Could this please be approved for 1.5b?  Pretty straightforward correctness
fix...
Comment 14 Asa Dotzler [:asa] 2003-08-14 11:07:30 PDT
Comment on attachment 129074 [details] [diff] [review]
Patch rev. 2

a=asa (on behalf of drivers) for checkin to Mozilla 1.5beta.
Comment 15 Christopher Aillon (sabbatical, not receiving bugmail) 2003-08-14 21:43:40 PDT
Boris asked me to land this, and I did.  Fixed.

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