Open Bug 1781297 Opened 4 years ago Updated 6 months ago

Content moves down in the scrollport, when a reflow occurs, with "float:left;position:sticky" element followed by some cleared tall content

Categories

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

defect

Tracking

()

Tracking Status
firefox146 --- affected

People

(Reporter: dholbert, Unassigned)

References

(Blocks 4 open bugs)

Details

(Keywords: parity-chrome, parity-edge, webcompat:platform-bug)

User Story

user-impact-score:880

Attachments

(3 files, 2 obsolete files)

[I'm spinning this off from bug 1618029 comment 3. Thanks to @toulousevictor for the bug report over there.]

STR:

  1. Click the pin/thumbtack icon at the top left.
  2. Load attached testcase (original URL: https://jsfiddle.net/vctls/mac2Ls0d/16/ )
  3. Scroll down and hover the green folder icon at the very bottom.

EXPECTED RESULTS:
A "shrink" animation should play on the folder.

ACTUAL RESULTS:

  • All of the content from the top of the page seems to snap into the current position of the scrollport
  • The folder icon gets thrown off the bottom (creating additional scrollable area)
  • If you try to scroll up, there's a bunch of blank space before the content now.

Chrome gives EXPECTED RESULTS.
Firefox Nightly 104 gives ACTUAL RESULTS.

(Note: It seems possible this is a version of https://bugzilla.mozilla.org/show_bug.cgi?id=1748891 )

Attached file testcase 2 (reduced) —

Here's a reduced testcase.

STR here:

  1. Scroll the scrollable area to the bottom.
  2. Repeatedly hover/unhover the "Hover me" text.

ACTUAL RESULTS: The scrollbar shows that the scrollable area keeps getting taller (with the content all being moved to the very end).

(In reply to Daniel Holbert [:dholbert] from comment #0)

(Note: It seems possible this is a version of https://bugzilla.mozilla.org/show_bug.cgi?id=1748891 )

The interesting wrinkle here:

  • the sticky-positioned thing is also a float
  • the content that's "propping up" the furthest scrollable area is not itself sticky-positioned, though it is cleared to be below the sticky float, and that clearance seems to be necessary to trigger the bug. (In the original testcase it's cleared via width:100% which forces it below the float so that it fits; in testcase 2, I clear it explicitly via clear:both.)
Summary: Content moves down in the scrollport, when a reflow occurs, with position:sticky → Content moves down in the scrollport, when a reflow occurs, with "float:left;position:sticky" element followed by some cleared tall content

This is kind of reminiscent of bug 1797307, I wonder if it's a duplicate.

Priority: -- → P3
See Also: → 1797307
Blocks: 1959957
Duplicate of this bug: 1448995

Comment on attachment 9287106 [details]
testcase 1 (from reporter) note: depends on external cloudflare-hosted CSS libraries

Sorry, I think testcase 1 must've been the completely wrong file-attachment here. Fortunately the jsfiddle link is still valid. Let me repost a version of that.

Attachment #9287106 - Attachment is obsolete: true

Here's a bugzilla-hosted version of the jsfiddle. This still reproduces the bug for me (though testcase 2 is more reduced and probably better for reasoning about).

The jsfiddle version uses fontawesome for some icons; I replaced the fontawesome stuff with just regular descriptive text ("STEP 1... STEP 2")

Blocks: 1963302

Moving into Layout: Positioned.

Component: Layout: Scrolling and Overflow → Layout: Positioned
Blocks: 1973453
User Story: (updated)
Blocks: 1985980
Blocks: 1998156
User Story: (updated)

(In reply to Daniel Holbert [:dholbert] from comment #1)

Created attachment 9287108 [details]
testcase 2 (reduced)

Here's a reduced testcase.

STR here:

  1. Scroll the scrollable area to the bottom.
  2. Repeatedly hover/unhover the "Hover me" text.

ACTUAL RESULTS: The scrollbar shows that the scrollable area keeps getting taller (with the content all being moved to the very end).

I am playing with the reduced testcase 2. One interest thing is, if we don't scroll to the bottom, e.g. scrollTop = 50, the unexpected empty content (i.e. the displacement of the content) becomes smaller. i.e. The scroll position has impact on the displacement of the unexpected movement, and it seems the reflow wants to put the content to the position without the scroll (i.e. it doesn't align the current scroll position I guess).

Yeah I suspect there's a layout ordering issue. Sticky content usually lays out in-flow, but floats change that, and they may also be laid out multiple times. We probably need to consider the normal position for floating content in general. I guess another interesting case is what happens with float + position: relative. What area do we actually exclude from the flow? Does that match other browsers?

(In reply to Emilio Cobos Álvarez [:emilio] from comment #10)

I guess another interesting case is what happens with float + position: relative. What area do we actually exclude from the flow? Does that match other browsers?

Not sure how related it is, but one known browser inconsistency related to the combination of position:relative and float that we have come across is bug 2002443.

Adding FMPoV related oddity spotted in SO question: here the trigger for "inserting" the odd blank space is page reload. Also, any next reflow triggered by page zoom or resize makes the odd blank space disappear.

Str:

  1. Load the page.
  2. Scroll down.
  3. Reload the page.
  4. Scroll up.

Expected

After reload, document height is preserved and either same scroll position kept (preferably), or viewport at the beginning of the page (like other browsers do; not related to this issue). No extra space above the Cleared block. (Large crimson text that reads "HA!" remains hidden under the Cleared block.)

Actual

After reload, top border of the Cleared block is in the viewport and more scrollable space appears above it, so the page can become progressively taller with each reload. Large crimson text that reads "HA!" is unleashed from beneath the Cleared block.

It seems that the odd blank space's height is related to the scroll position prior to the reload.

Attachment #9557207 - Attachment mime type: text/plain → text/html

Comment on attachment 9557207 [details]
testcase 3 (reload-induced scroll offset grow)

(Ah, sorry, re-tested again with clean profiles and realised it is not a clean MRE, so disregard the previous remark. Sorry for the noise.)

Attachment #9557207 - Attachment is obsolete: true

(In reply to Emilio Cobos Álvarez [:emilio] from comment #10)

I guess another interesting case is what happens with float + position: relative. What area do we actually exclude from the flow? Does that match other browsers?

I tried the case with float + position: relative, and the behavior matches other browsers. (i.e. Cannot reproduce this bug with this setting.) I guess we have to exclude the offsets (e.g. top, left, scroll offset) from the flow, to match other browsers

Still have to dig deeper, but I'd like to put some notes from my investigation last week.

  1. So basically, we hit this bug because we placed the frame with clear:both at the wrong block coordinate (i.e. BStart(WM)). This wrong block coordinate is due to the incorrect clearance value when reflowing this frame.
  2. This clearance value comes from the float manager (nsFloatManager::ClearFloats()). In the float manager, we use the latest FloatInfo (i.e. the frame from the element with position:sticky; float:left in the test) as the reference to compute the clearance.
  3. The FloatInfo was added during the incremental reflow. And we use nsFloatManager::GetRegionFor() to get its region.

So in the reduced test, I noticed the region includes the scroll offset. (For example, if scrollTop = 20, the BStart value of this region is 1200). That's why our final clearance includes the scroll offset. We don't have this issue when using position:relative; float:left because its logical rect doesn't include the scroll offset. We probably have to tweak the region value for sticky positioned element but I'm not sure where is the suitable place to adjust it.

Also, I can reproduce this bug without scrolling. Just change the top value of this position:sticky; float:left; element to be non-zero, e.g. 100px After reflowing, we still get the wrong block coordinate for the element with clear:both.

<style>
  #scrollable { height: 300px; width: 300px; }
  #split { height: 1px; clear: both; }
  #overflowing { height: 200; background: gray; }
  #sticky-box-label {
    position: sticky;
    top: 100px;
    float: left;
    background: yellow;
  }
</style>
<script>
function run() {
  window.setTimeout(() => {
    let box = document.getElementById('overflowing');
    box.style.left = "1px";
  }, 500);
}
</script>
<body onload="run()">
<div id="scrollable">
  <label id="sticky-box-label">Sticky</label>
  <div id="split"></div>
  <div id="overflowing"></div>
</div>
</body>

(In reply to Botond Ballo [:botond] from comment #11)

Not sure how related it is, but one known browser inconsistency related to the combination of position:relative and float that we have come across is bug 2002443.

Probably related to bug 2002443 but it doesn't use clear:both. We may check it once we figure out this bug.

User Story: (updated)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: