Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayer.cpp

Issue 2776563003: Only automatically promote sticky position elements which move with scroll. (Closed)
Patch Set: Merge with master Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 67f936682ca98f391266d6b6215caa1edb818859..29b5bbb6709e0086ca4cfeffedcf0e04ffd0e570 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
@@ -69,6 +69,7 @@
#include "core/layout/svg/LayoutSVGRoot.h"
#include "core/page/Page.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"
@@ -327,9 +328,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).
@@ -339,31 +348,23 @@ bool PaintLayer::sticksToViewport() const {
const auto* viewBorderBoxProperties =
layoutObject().view()->localBorderBoxProperties();
const ScrollPaintPropertyNode* ancestorTargetScrollNode;
- if (layoutObject().style()->position() == EPosition::kFixed) {
- ancestorTargetScrollNode =
- viewBorderBoxProperties->transform()->findEnclosingScrollNode();
- } else {
- ancestorTargetScrollNode = layoutObject()
- .view()
- ->contentsProperties()
- ->transform()
- ->findEnclosingScrollNode();
- }
+ ancestorTargetScrollNode =
+ viewBorderBoxProperties->transform()->findEnclosingScrollNode();
const auto* transform =
layoutObject().localBorderBoxProperties()->transform();
return transform->findEnclosingScrollNode() == ancestorTargetScrollNode;
}
- return (layoutObject().style()->position() == EPosition::kFixed &&
- layoutObject().containerForFixedPosition() ==
- layoutObject().view()) ||
- (layoutObject().style()->position() == EPosition::kSticky &&
- (!ancestorScrollingLayer() || ancestorScrollingLayer() == root()));
+ 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();
}
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698