Bug in position: sticky if the element using it is inside a container that has a stacking context. |
|||||||
Issue description
Chrome Version: 56.0.2924.87 (64-bit)
OS: OSX 10.12.3
What steps will reproduce the problem?
Consider the following snippet:
<div id="scrollingElement" style="position: relative; width: 500px; height: 500px; overflow-y: scroll; background-color: red;">
<div id="stackingContext" style="position: relative; height: 1000px; z-index: 1;">
<div id="sticky" style="position: sticky; height: 50px; background-color: green;"></div>
</div>
</div>
JSBin: http://output.jsbin.com/risusem
What is the expected result?
The div with position: sticky; should stick to the top of the scrolling element #scrollingElement.
What happens instead?
The div with position: sticky; bounces back and forth. If you remove z-index:1 from #stackingContext, then div with position: sticky; works as expected.
,
Feb 14 2017
,
Feb 14 2017
Note: 'bounce' behavior only shows up when composited. When not composited, position-sticky div just scrolls off the top of the page, which also seems wrong at first glance.
,
Feb 15 2017
,
Feb 16 2017
Re #3, the sticky element has no anchor edge defined, so it should behave like a regular relative position element and scroll off as you scroll up. The bounce looks like it comes from the parent_relative_sticky_box_rect incorrectly not including the scroll position which smcgruer is fixing in his patch for nested sticky position iirc. Can you split this part of your patch out into a separate bug and add this (with forced promotion) as a test case? We should however not be promoting this sticky position element since it doesn't have any anchor edges but we are simply because it is sticky position inside a scroller which scrolls. I'll put up a patch to fix this.
,
Feb 16 2017
Passing this bug over for the compositing position fix.
,
Feb 17 2017
,
Feb 20 2017
,
Mar 2 2017
Issue 697462 has been merged into this issue.
,
Mar 3 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e4819386ba4f91ce923c8c870927480566624001 commit e4819386ba4f91ce923c8c870927480566624001 Author: smcgruer <smcgruer@chromium.org> Date: Fri Mar 03 00:04:15 2017 Correct for enclosing layers scroll position in parentRelativeStickyBoxOffset The offset calculated in CompositedLayerMapping for parent_relative_sticky_box_offset calls |convertToLayerCoords| on the enclosing layer. This method relies on location() however which includes the scroll offset if the enclosing layer is not already the scroll ancestor, e.g. if you had the following layer setup: ScrollAncestor | +-- IntermediateLayer | +-- StickyLayer To correct for this, add back in the scroll offset for the case where the enclosing layer is not the scroll ancestor. BUG= 692263 CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 Review-Url: https://codereview.chromium.org/2698843004 Cr-Commit-Position: refs/heads/master@{#454444} [add] https://crrev.com/e4819386ba4f91ce923c8c870927480566624001/third_party/WebKit/LayoutTests/compositing/overflow/composited-sticky-element-enclosing-layers-expected.html [add] https://crrev.com/e4819386ba4f91ce923c8c870927480566624001/third_party/WebKit/LayoutTests/compositing/overflow/composited-sticky-element-enclosing-layers.html [modify] https://crrev.com/e4819386ba4f91ce923c8c870927480566624001/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp [modify] https://crrev.com/e4819386ba4f91ce923c8c870927480566624001/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.h [modify] https://crrev.com/e4819386ba4f91ce923c8c870927480566624001/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp
,
Mar 3 2017
The compositing position should now be correct; http://output.jsbin.com/risusem scrolls off the top of the page for both low and high DPI (since there's no sticky anchor), and a test case like https://output.jsbin.com/reqeniy sticks properly. Passing back to flackr as #5 mentioned an additional fix to not promote this case anyway; I'm unsure if that CL ever went in.
,
Mar 6 2017
I filed issue 696058 for not promoting unnecessarily. Setting this to fixed. |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by chrishtr@chromium.org
, Feb 14 2017Components: Blink>Paint