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

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

Issue 2657863004: Move scroll paint property nodes to be owned by the transform tree (Closed)
Patch Set: Rebase & remove parens Created 3 years, 11 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 92d3dd1a450aa3626cb99c5524a6f1520b177062..72d15516de546026111c895369e7654ec2283d76 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayer.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintLayer.cpp
@@ -328,31 +328,50 @@ void PaintLayer::dirtyAncestorChainHasSelfPaintingLayerDescendantStatus() {
}
}
+static const ScrollPaintPropertyNode* nearestScrollNode(
+ const TransformPaintPropertyNode* transform) {
+ if (const auto* scrollNode = transform->scrollNode())
+ return scrollNode;
+ for (const auto* ancestor = transform->parent(); ancestor;
+ ancestor = ancestor->parent()) {
+ if (const auto* scrollNode = ancestor->scrollNode())
+ return scrollNode;
+ }
+ // The root transform node references the root scroll node so a scroll node
+ // should always exist.
+ NOTREACHED();
+ return nullptr;
+}
+
bool PaintLayer::sticksToViewport() const {
if (layoutObject()->style()->position() != FixedPosition &&
layoutObject()->style()->position() != StickyPosition)
return false;
+ // TODO(pdr): This approach of calculating the nearest scroll node is O(n).
+ // An option for improving this is to cache the nearest scroll node in
+ // the local border box properties.
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
const ScrollPaintPropertyNode* ancestorTargetScrollNode;
if (layoutObject()->style()->position() == FixedPosition) {
- ancestorTargetScrollNode = layoutObject()
- ->view()
- ->paintProperties()
- ->localBorderBoxProperties()
- ->scroll();
+ ancestorTargetScrollNode =
+ nearestScrollNode(layoutObject()
+ ->view()
+ ->paintProperties()
+ ->localBorderBoxProperties()
+ ->transform());
} else {
- ancestorTargetScrollNode = layoutObject()
- ->view()
- ->paintProperties()
- ->contentsProperties()
- ->scroll();
+ ancestorTargetScrollNode = nearestScrollNode(layoutObject()
+ ->view()
+ ->paintProperties()
+ ->contentsProperties()
+ ->transform());
}
- return layoutObject()
- ->paintProperties()
- ->localBorderBoxProperties()
- ->scroll() == ancestorTargetScrollNode;
+ return nearestScrollNode(layoutObject()
+ ->paintProperties()
+ ->localBorderBoxProperties()
+ ->transform()) == ancestorTargetScrollNode;
}
return (layoutObject()->style()->position() == FixedPosition &&

Powered by Google App Engine
This is Rietveld 408576698