New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 692263 link

Starred by 8 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All , Mac
Pri: 2
Type: Bug



Sign in to add a comment

Bug in position: sticky if the element using it is inside a container that has a stacking context.

Project Member Reported by egarciad@chromium.org, Feb 14 2017

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.
 
Cc: flackr@chromium.org smcgruer@chromium.org
Components: Blink>Paint
flackr, smcgruer could you take a look?
Labels: -Pri-3 Pri-2
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.
Status: Available (was: Untriaged)

Comment 5 by flackr@chromium.org, Feb 16 2017

Owner: flackr@chromium.org
Status: Started (was: Available)
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.

Comment 6 by flackr@chromium.org, Feb 16 2017

Components: -Blink>Paint Blink>Compositing
Labels: Hotlist-ThreadedRendering
Owner: smcgruer@chromium.org
Passing this bug over for the compositing position fix.
Cc: ajha@chromium.org
 Issue 690896  has been merged into this issue.
Cc: kavvaru@chromium.org
 Issue 692043  has been merged into this issue.
 Issue 697462  has been merged into this issue.
Project Member

Comment 10 by bugdroid1@chromium.org, 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

Owner: flackr@chromium.org
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.
Owner: smcgruer@chromium.org
Status: Fixed (was: Started)
I filed  issue 696058  for not promoting unnecessarily. Setting this to fixed.

Sign in to add a comment