Closed
Bug 733875
Opened 13 years ago
Closed 13 years ago
absolutely-positioned content within a fixed-size relatively-positioned block will behave as if its container is zero-height, if we add a -moz-box grandparent
Categories
(Core :: Layout: Positioned, defect)
Core
Layout: Positioned
Tracking
()
RESOLVED
FIXED
mozilla13
People
(Reporter: dholbert, Assigned: dholbert)
References
Details
Attachments
(4 files, 1 obsolete file)
See attached testcase. In both cases, we've got
<grandparent>
<parent: fixed-size, relatively-positioned div>
<child: absolutely positioned child>
...both of which are blocks. However -- if the grandparent is display:-moz-box (with no other style set), then the child ends up doing its absolute positioning differently.
In particular, it does its positioning such that "top" and "bottom" are offset from the same y-position, basically -- it behaves as if its parent has 0 height (even though the parent has a fixed-height of 200px). The only reason you see any blue (for the child) in the attached testcase is because of the padding. If you remove the padding, there's no blue.
ttaubert reported this as "testcase 5" on bug 640443, but I'm spinning it off to this bug because I think it's a separate issue from what bug 640443 describes.
Assignee | ||
Comment 1•13 years ago
|
||
(In reply to Daniel Holbert [:dholbert] from comment #0)
> Created attachment 603823 [details]
> testcase 1
>
> See attached testcase. In both cases, we've got
> <grandparent>
> <parent: fixed-size, relatively-positioned div>
> <child: absolutely positioned child>
>
> ...both of which are blocks. However -- if the grandparent is
> display:-moz-box (with no other style set), then the child ends up doing its
> absolute positioning differently.
>
> In particular, it does its positioning such that "top" and "bottom" are
> offset from the same y-position, basically -- it behaves as if its parent
> has 0 height.
Here's a similar testcase to demonstrate this in a different way. In this version, there's no padding & no 'top' specification -- just 'bottom'.
In the reference (no -moz-box), this puts the blue block at the bottom of its container.
But in the -moz-box grandparent case, this puts the blue block just above its container. So -- it looks like "bottom" and "top" are offset w.r.t. the same y-position.
Assignee | ||
Updated•13 years ago
|
Summary: absolutely-positioned content within a fixed-size relatively-positioned block will get a different height, if we add a -moz-box wrapper around the block → absolutely-positioned content within a fixed-size relatively-positioned block will behave as if its container is zero-height, if we add a -moz-box wrapper around the block
Assignee | ||
Updated•13 years ago
|
Summary: absolutely-positioned content within a fixed-size relatively-positioned block will behave as if its container is zero-height, if we add a -moz-box wrapper around the block → absolutely-positioned content within a fixed-size relatively-positioned block will behave as if its container is zero-height, if we add a -moz-box grandparent
Assignee | ||
Comment 2•13 years ago
|
||
I believe this is needed for ttaubert's about:newtab work; setting blocking flag accordingly.
Blocks: 729878
Assignee | ||
Updated•13 years ago
|
Attachment #603830 -
Attachment is patch: false
Attachment #603830 -
Attachment mime type: text/plain → text/html
Assignee | ||
Updated•13 years ago
|
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Assignee | ||
Comment 3•13 years ago
|
||
So, from the perspective of the parent (a fixed-size, relpos block): when it's inside of a -moz-box, it doesn't find out its size until it receives a call to child->SetBounds() here:
http://mxr.mozilla.org/mozilla-central/source/layout/xul/base/src/nsSprocketLayout.cpp#487
which is well after it has reflowed its positioned children.
So -- during reflow, the block doesn't know its size yet, and it ends up passing aContainingBlockWidth=0, aContainingBlockHeight=0 into its call to nsAbsoluteContainingBlock::Reflow, since that's what it's got as its desired size in its reflow metrics at that point. So it ends up reflowing the child as if the containing block had zero height.
To fix this, I think we need to trigger another call to nsAbsoluteContainingBlock::Reflow _after_ the SetBounds call in nsSprocketLayout.cpp, or something like that.
![]() |
||
Comment 4•13 years ago
|
||
Yeah, welcome to the mess that is mixing multiple layout models!
Does this break percentage heights inside the block too, if you give the block a fixed height or whatnot? Or does sprocket layout end up respecting that?
I really think that now that updating overflow areas doesn't need reflow we should move all abs pos reflow off to a post-reflow callback or equivalent so it happens once the geometry is fully known. That would fix not only this case but also tables...
Assignee | ||
Comment 5•13 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #4)
> Does this break percentage heights inside the block too, if you give the
> block a fixed height or whatnot?
Yup, it totally does... gah. See attached testcase.
Assignee | ||
Comment 6•13 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #4)
> I really think that now that updating overflow areas doesn't need reflow we
> should move all abs pos reflow off to a post-reflow callback or equivalent
> so it happens once the geometry is fully known. That would fix not only
> this case but also tables...
That sounds pretty good. I think we need a shorter-term fix for this, though, so the about:newtab rewrite can land. Patch coming up.
Assignee | ||
Comment 7•13 years ago
|
||
This is basically like the fix for bug 640443 -- adding a ReflowAbsoluteFrames call to DoLayout() -- but in this case it's the nsFrame version of DoLayout. (which is the method inherited by our parent-block in this case). This is late enough for us to have our size figured out.
Assignee | ||
Comment 8•13 years ago
|
||
(fix v1 doesn't help with percentages, of course, but it's nice & simple and it'll hopefully let bug 729878 move forward)
Tim, could you confirm whether this fixes the issue for you? From my testing, it fixes testcases 1 & 2 here, and (combined with bug 640443's patch) it fixes your testcase 5 on bug 640443.
Comment 9•13 years ago
|
||
Comment on attachment 603981 [details] [diff] [review]
fix v1
Awesome, thank you very much! Those patches make the new about:newtab layout finally work. I owe you a beer or something next time I'm in MV :)
Assignee | ||
Comment 10•13 years ago
|
||
Yay, that's great news!
I just need to sort out the assertion I mentioned in bug 640443 comment 33, and then we'll be good. Hopefully I can settle that tomorrow.
Assignee | ||
Comment 11•13 years ago
|
||
This uses an unconstrained available height, like the latest patch in bug 640443, so we don't create continuation frames. (In this case we probably _could_ create continuation frames, since the container is something block-like
(Technically the container here could be any frame that establishes an abspos containing block & doesn't implement its own DoLayout method -- but I think we don't want continuation frames anyway, since our moz-box grandparent isn't splittable and our parent gets XUL DoLayout calls instead of Reflow calls.)
Attachment #603981 -
Attachment is obsolete: true
Attachment #604179 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 12•13 years ago
|
||
(er, sorry, didn't quite finish editing that comment before posting -- the gist is there, though.)
![]() |
||
Comment 13•13 years ago
|
||
Comment on attachment 604179 [details] [diff] [review]
fix v2
r=me
Attachment #604179 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 14•13 years ago
|
||
OS: Linux → All
Hardware: x86_64 → All
Target Milestone: --- → mozilla13
Assignee | ||
Updated•13 years ago
|
Component: Layout → Layout: R & A Pos
QA Contact: layout → layout.r-and-a-pos
Assignee | ||
Comment 15•13 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•13 years ago
|
Attachment #603980 -
Attachment description: testcase 3 (%-height instead of abspos) → testcase 3 (%-height instead of abspos)[not fixed by this bug]
You need to log in
before you can comment on or make changes to this bug.
Description
•