Closed Bug 375304 Opened 17 years ago Closed 17 years ago

Wrong absolute positioning when the containing block has a min-height and overflow:hidden

Categories

(Core :: Layout: Positioned, defect, P2)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: fassino, Assigned: roc)

References

Details

(Keywords: regression, testcase, Whiteboard: [dbaron-1.9:RwCo])

Attachments

(3 files, 7 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3

A position:relative box with a min-height and overflow:hidden contains a position:absolute box with bottom:0.  
The absolute box is positioned at the bottom of the content of the containing block, as if no min-height were specified on it.


Reproducible: Always




If the containing block doesn't have both a min-height and overflow:hidden the problem does not occur. 
Doesn't seem present in older versions (1.7), it is present in latest Minefield.
Attached file Minimal test case
The red absolutely positioned box has bottom:0, its containing box is the yellow box having a min-height and overflow:hidden.
Can't seem to find a dupe, so confirming.
That regressed, based on Mac builds, between the 20050428-07 and 20050428-20 builds.

A regression from bug 240276 ?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
OS: Windows XP → All
Hardware: PC → All
Blocks: 240276
Flags: blocking1.9?
Keywords: regression
Flags: blocking1.9? → blocking1.9+
Attached patch Patch? (obsolete) — Splinter Review
This works, but I'm not sure this is what we want to do... (it obviously doesn't handle a horizontal scrollbar correctly, but that's not a new bug.)
Assignee: nobody → sharparrow1
Status: NEW → ASSIGNED
dbaron, roc, any suggestions?
Hmm ... I actually think that's reasonable, if you adjust for the horizontal scrollbar. But don't you want this for computed widths too?
(In reply to comment #5)
> Hmm ... I actually think that's reasonable, if you adjust for the horizontal
> scrollbar. But don't you want this for computed widths too?
> 

I don't think it really matters for computed widths; we come up with the right width anyway.

Hmm, and probably also want to get rid of the hack in nsHTMLReflowState that skips over the scrolled frame for percentage height calculations.
No --- that's already broken, you won't break it worse
Attached patch WIP (obsolete) — Splinter Review
Okay, here's the complete fix; I need to mess with nsHTMLScrollFrame::ReflowContents a bit more, though.
Attachment #270755 - Attachment is obsolete: true
Okay, a bit of an explanation: the second patch is a lot bigger and a lot scarier than the first patch.  However, it's necessary if we want to account for horizontal scrollbars without introducing incremental reflow problems.

If the complete fix is too scary performance-wise to do at this point, we can go with the first patch.  It doesn't account for horizontal scrollbars, but to do height computation including the horizontal scrollbar correctly, we have to do the complete fix.
Attached patch WIP v2 (obsolete) — Splinter Review
This version is a bit more cleaned up and partially tested.
Attachment #270813 - Attachment is obsolete: true
Okay, my current progress: WIP v2 seems to be working correctly for basic cases, and it shouldn't change performance for cases where the NS_FRAME_CONTAINS_RELATIVE_HEIGHT bit is not set or we don't need a horizontal scrollbar.  I mostly need to do some more testing to make sure everything behaves sanely.

Note that the current code isn't always successful at coming up with a minimal arrangement; the
"if (nsRect(nsPoint(0, 0), InsideBorderSize).Contains(scrolledRect)) {" check isn't sufficient to catch all the cases where we don't need a scrollbar because making a little more width available can lead to a large change in the height.  I'm not sure if we care, though; not removing scrollbars when they're no longer needed is suboptimal, but not really wrong, and rather expensive to get right.
(Note to self: CalcQuirkContainingBlockHeight needs to be fixed.)
Attached patch Patch v1 (obsolete) — Splinter Review
Okay, I think this is finished.  I'll make sure to together some reftests (both quirks and standards-mode).
Attachment #270833 - Attachment is obsolete: true
Attachment #273156 - Flags: review?(roc)
     // XXX Adding a horizontal scrollbar could cause absolute children positioned
     // relative to the bottom padding-edge to need to be reflowed. But we don't,
     // because that would be slow.

This comment is incorrect now, right? We are reflowing if anything could be depending on the bottom padding-edge. Where this comment is, you're no longer doing TryLayout in this situation.

+    // XXX Adding a horizontal scrollbar could cause absolute children positioned
+    // relative to the bottom padding-edge to need to be reflowed. But we don't,
+    // because that would be slow.

Similarly, here you just reflowed the scrollbar...

Otherwise this looks good, but a couple of things to consider:
-- The parameters to TryLayout should be switched to H/V to be consistent with everything else. Could be done separately but the code is confusing me as is. Yes, I know I wrote that :-)
-- Could we simplify ReflowContents by moving the ReflowScrolledFrame calls into TryLayout itself, with a check in there to suppress the reflow if only the presence of a horizontal scrollbar is changing and NS_FRAME_CONTAINS_RELATIVE_HEIGHT is not set? We'd need state variables to record the scrollbar configuration used for the last reflow of the scrolled content. Then I think we can dispense with checking style in ReflowContents, it can become an initial ReflowScrolledFrame followed by 6 TryLayout calls (the first one conditional on the size of the child fitting).
Attached patch Real patch v1 (obsolete) — Splinter Review
I accidentally asked for review on the wrong revision of the patch; sorry about that.  I'll be more careful about that in the future.

I believe this version addresses the issue of the comments, and partially addresses the issue of the parameter order by using named variables more frequently. I can switch the parameter order if it would make it easier to review, though. Which order do you prefer?  (Or do you not really care as long as it's consistent?)

This patch also fixes some bugs in the earlier version.

I think moving the calls to ReflowScrolledFrame is complicated enough to warrant a separate patch.
Attachment #273156 - Attachment is obsolete: true
Attachment #273392 - Flags: review?(roc)
Attachment #273156 - Flags: review?(roc)
Comment on attachment 273392 [details] [diff] [review]
Real patch v1

relativeHeight perhaps could be named "heightMatters" or something a bit more descriptive. Other than that, this looks good.

Should have a followup bug to refactor things the way I described.
Attachment #273392 - Flags: superreview+
Attachment #273392 - Flags: review?(roc)
Attachment #273392 - Flags: review+
Attached patch Reftests (obsolete) — Splinter Review
I'd like you to take a quick look over this to make sure I'm not missing any tests (or if you have other suggestions).  This is tricky stuff.

Note that none of the browsers on my computer other than my patched trunk build pass any of the horizontal scrollbar tests.
Attachment #278476 - Flags: review?(roc)
Comment on attachment 278476 [details] [diff] [review]
Reftests

I find it really hard to review tests. Lets go with these.
Attachment #278476 - Flags: review?(roc) → review+
Whiteboard: [dbaron-1.9:RwCo]
I'll take this and land the patch when the tree is open for blocker landings.
Assignee: sharparrow1 → roc
Status: ASSIGNED → NEW
Whiteboard: [dbaron-1.9:RwCo] → [dbaron-1.9:RwCo][needs landing]
Patch is bitrot. bz says reftests are missing stuff.
Whiteboard: [dbaron-1.9:RwCo][needs landing] → [dbaron-1.9:RwCo][needs new patch]
Attached patch unbitrotted patch (obsolete) — Splinter Review
I'll look at the tests later...
Whiteboard: [dbaron-1.9:RwCo][needs new patch] → [dbaron-1.9:RwCo][needs landing]
Boris, Reed says you said "reftests are missing stuff". What did you have in mind?
Ah, Reed says you just meant a hook from reftests/reftest.list.

Checked in with that.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Yeah, it just needed a hook (and some indication of where in the dir tree to put it).
This actually caused a reftest failure in bugs/28811-1a.html and bugs/28811-1b.html, so I'm backing it out. Looks a real bug, an unnecessary horizontal scrollbar appears.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Whiteboard: [dbaron-1.9:RwCo][needs landing] → [dbaron-1.9:RwCo]
The reftest failure is fixed by my patch in bug 399531. So we'll need to land that first.
Depends on: 399531
Whiteboard: [dbaron-1.9:RwCo] → [dbaron-1.9:RwCo][depends on 399531]
Here's the patch and reftests rolled together, ready to be relanded.
Attachment #273392 - Attachment is obsolete: true
Attachment #278476 - Attachment is obsolete: true
Attachment #288052 - Attachment is obsolete: true
Checked in again.
Status: REOPENED → RESOLVED
Closed: 17 years ago17 years ago
Resolution: --- → FIXED
Whiteboard: [dbaron-1.9:RwCo][depends on 399531] → [dbaron-1.9:RwCo]
This caused 28811-1a.html and 28811-1b.html to fail again on Linux and Windows, but curiously not on Mac. This time there is no horizontal scrollbar, instead the problem is that the bottom border of the IFRAME in the reference page appears to be missing. Reopening again.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
This may also have caused a Tp2 regression of bl-bldxp01, not sure. Need to recheck that, there should be another cycle before the backout takes effect.
Unclear if there was a Tp2 regression. Something to watch when relanding.
The regression is basically that if we have a horizontal and a vertical scrollbar, and we resize contents so there's a consistent layout with a vertical but no horizontal scrollbar but no other scrollbar combination gives a consistent layout, and the contents have set relativeHeight, then there is no path that tries the vertical but no horizontal combination. So we fall back to displaying both scrollbars.
Attached patch updated againSplinter Review
This is an updated patch that fixes the regression. I've only changed nsGfxScrollFrame.cpp/.h from the previous iteration so they're the only files that need review again.

I'm addressing the issue I just mentioned, which is that when relativeHeight is set, we don't try all combinations of scrollbar visibilities. The code was getting hard to understand so I've refactored it by moving the calls to ReflowScrolledFrame when scrollbar status has changed from ReflowContents down into TryLayout. I think this makes it much easier to see what's going on. In particular it is now very easy to see that we try all scrollbar combinations.
Attachment #291373 - Flags: superreview?(dbaron)
Attachment #291373 - Flags: review?(dbaron)
Whiteboard: [dbaron-1.9:RwCo] → [dbaron-1.9:RwCo][needs review]
Comment on attachment 291373 [details] [diff] [review]
updated again

r+sr=dbaron
Attachment #291373 - Flags: superreview?(dbaron)
Attachment #291373 - Flags: superreview+
Attachment #291373 - Flags: review?(dbaron)
Attachment #291373 - Flags: review+
checked in again
Status: REOPENED → RESOLVED
Closed: 17 years ago17 years ago
Resolution: --- → FIXED
Whiteboard: [dbaron-1.9:RwCo][needs review] → [dbaron-1.9:RwCo]
Depends on: 407009
Depends on: 407015
Blocks: 301726
Blocks: 308406
Verified in Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9pre) Gecko/2008050704 Minefield/3.0pre.
Status: RESOLVED → VERIFIED
Depends on: 453486
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: