Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintLayer.cpp b/third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| index ec9a1f44e5a2daeadd5c3321c54722094c5db494..92abf8ab394556e78919d8155b0e371467a459ec 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp |
| @@ -70,6 +70,7 @@ |
| #include "core/page/Page.h" |
| #include "core/page/scrolling/RootScrollerController.h" |
| #include "core/page/scrolling/ScrollingCoordinator.h" |
| +#include "core/page/scrolling/StickyPositionScrollingConstraints.h" |
| #include "core/paint/BoxReflectionUtils.h" |
| #include "core/paint/FilterEffectBuilder.h" |
| #include "core/paint/ObjectPaintInvalidator.h" |
| @@ -329,9 +330,17 @@ void PaintLayer::dirtyAncestorChainHasSelfPaintingLayerDescendantStatus() { |
| } |
| } |
| -bool PaintLayer::sticksToViewport() const { |
| - if (layoutObject().style()->position() != EPosition::kFixed && |
| - layoutObject().style()->position() != EPosition::kSticky) |
| +bool PaintLayer::sticksToScroller() const { |
| + return layoutObject().style()->position() == EPosition::kSticky && |
| + ancestorOverflowLayer() |
| + ->getScrollableArea() |
| + ->stickyConstraintsMap() |
| + .at(const_cast<PaintLayer*>(this)) |
| + .anchorEdges(); |
| +} |
| + |
| +bool PaintLayer::fixedToViewport() const { |
| + if (layoutObject().style()->position() != EPosition::kFixed) |
| return false; |
| // TODO(pdr): This approach of calculating the nearest scroll node is O(n). |
| @@ -340,30 +349,24 @@ bool PaintLayer::sticksToViewport() const { |
| if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| const auto* viewProperties = layoutObject().view()->paintProperties(); |
| const ScrollPaintPropertyNode* ancestorTargetScrollNode; |
| - if (layoutObject().style()->position() == EPosition::kFixed) { |
| - ancestorTargetScrollNode = viewProperties->localBorderBoxProperties() |
| - ->transform() |
| - ->findEnclosingScrollNode(); |
| - } else { |
| - ancestorTargetScrollNode = viewProperties->contentsProperties() |
| - ->transform() |
| - ->findEnclosingScrollNode(); |
|
flackr
2017/02/24 22:59:44
Do we still need to something like this for sticks
|
| - } |
| + ancestorTargetScrollNode = viewProperties->localBorderBoxProperties() |
| + ->transform() |
| + ->findEnclosingScrollNode(); |
| const auto* properties = layoutObject().paintProperties(); |
| const auto* transform = properties->localBorderBoxProperties()->transform(); |
| return transform->findEnclosingScrollNode() == ancestorTargetScrollNode; |
| } |
| - return (layoutObject().style()->position() == EPosition::kFixed && |
| - layoutObject().containerForFixedPosition() == |
| - layoutObject().view()) || |
| - (layoutObject().style()->position() == EPosition::kSticky && |
| - (!ancestorScrollingLayer() || ancestorScrollingLayer() == root())); |
|
flackr
2017/02/24 22:59:44
ancestorScrollingLayer was not the correct "scroll
|
| + return layoutObject().containerForFixedPosition() == layoutObject().view(); |
| } |
| bool PaintLayer::scrollsWithRespectTo(const PaintLayer* other) const { |
| - if (sticksToViewport() != other->sticksToViewport()) |
| + if (fixedToViewport() != other->fixedToViewport()) |
| + return true; |
| + // If either element sticks we cannot trivially determine that the layers do |
| + // not scroll with respect to each other. |
| + if (sticksToScroller() || other->sticksToScroller()) |
| return true; |
| return ancestorScrollingLayer() != other->ancestorScrollingLayer(); |
| } |