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

Unified Diff: third_party/WebKit/Source/core/layout/compositing/CompositingReasonFinder.cpp

Issue 2716583005: Do not promote position sticky or fixed elements unless they move with scroll. (Closed)
Patch Set: Avoid computing constraints for non-anchored sticky and add/update tests. 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/layout/compositing/CompositingReasonFinder.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositingReasonFinder.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositingReasonFinder.cpp
index a241925f30d7005a06a2797d6c20320d986afadc..58a96ad99c9412cf4d8bb88eac644d7223b6f859 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositingReasonFinder.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositingReasonFinder.cpp
@@ -37,7 +37,8 @@ bool CompositingReasonFinder::isMainFrame() const {
}
CompositingReasons CompositingReasonFinder::directReasons(
- const PaintLayer* layer) const {
+ const PaintLayer* layer,
+ bool ignoreLCDText) const {
if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
return CompositingReasonNone;
@@ -48,7 +49,7 @@ CompositingReasons CompositingReasonFinder::directReasons(
CompositingReasonComboAllDirectStyleDeterminedReasons;
return styleDeterminedDirectCompositingReasons |
- nonStyleDeterminedDirectReasons(layer);
+ nonStyleDeterminedDirectReasons(layer, ignoreLCDText);
}
// This information doesn't appear to be incorporated into CompositingReasons.
@@ -141,7 +142,8 @@ bool CompositingReasonFinder::requiresCompositingForTransform(
}
CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(
- const PaintLayer* layer) const {
+ const PaintLayer* layer,
+ bool ignoreLCDText) const {
CompositingReasons directReasons = CompositingReasonNone;
LayoutObject& layoutObject = layer->layoutObject();
@@ -159,9 +161,7 @@ CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(
directReasons |= CompositingReasonOverflowScrollingParent;
}
- // TODO(flackr): Rename functions and variables to include sticky position
- // (i.e. ScrollDependentPosition rather than PositionFixed).
- if (requiresCompositingForScrollDependentPosition(layer))
+ if (requiresCompositingForScrollDependentPosition(layer, ignoreLCDText))
directReasons |= CompositingReasonScrollDependentPosition;
directReasons |= layoutObject.additionalCompositingReasons();
@@ -214,12 +214,14 @@ bool CompositingReasonFinder::requiresCompositingForTransformAnimation(
}
bool CompositingReasonFinder::requiresCompositingForScrollDependentPosition(
- const PaintLayer* layer) const {
- if (layer->layoutObject().style()->position() != EPosition::kFixed &&
- layer->layoutObject().style()->position() != EPosition::kSticky)
+ const PaintLayer* layer,
+ bool ignoreLCDText) const {
+ if (!layer->layoutObject().style()->hasViewportConstrainedPosition() &&
+ !layer->layoutObject().style()->hasStickyConstrainedPosition())
return false;
- if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger) &&
+ if (!(ignoreLCDText ||
+ (m_compositingTriggers & ViewportConstrainedPositionedTrigger)) &&
(!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() ||
!layer->backgroundIsKnownToBeOpaqueInRect(
LayoutRect(layer->boundingBoxForCompositing())) ||
@@ -229,11 +231,10 @@ bool CompositingReasonFinder::requiresCompositingForScrollDependentPosition(
// Don't promote fixed position elements that are descendants of a non-view
// container, e.g. transformed elements. They will stay fixed wrt the
// container rather than the enclosing frame.
- if (layer->sticksToViewport())
- return m_layoutView.frameView()->isScrollable();
-
- if (layer->layoutObject().style()->position() != EPosition::kSticky)
- return false;
+ EPosition position = layer->layoutObject().style()->position();
+ if (position == EPosition::kFixed)
+ return layer->fixedToViewport() && m_layoutView.frameView()->isScrollable();
+ DCHECK(position == EPosition::kSticky);
// Don't promote nested sticky elements; the compositor can't handle them.
// TODO(smcgruer): Add cc nested sticky support (http://crbug.com/672710)
@@ -241,11 +242,17 @@ bool CompositingReasonFinder::requiresCompositingForScrollDependentPosition(
layer->ancestorOverflowLayer()->getScrollableArea();
DCHECK(scrollableArea->stickyConstraintsMap().contains(
const_cast<PaintLayer*>(layer)));
+ if (scrollableArea->stickyConstraintsMap()
+ .at(const_cast<PaintLayer*>(layer))
+ .hasAncestorStickyElement())
+ return false;
- return layer->ancestorOverflowLayer()->scrollsOverflow() &&
- !scrollableArea->stickyConstraintsMap()
- .at(const_cast<PaintLayer*>(layer))
- .hasAncestorStickyElement();
+ // Don't promote sticky position elements that cannot move with scrolls.
+ if (!layer->sticksToScroller())
+ return false;
+ if (layer->ancestorOverflowLayer()->isRootLayer())
+ return m_layoutView.frameView()->isScrollable();
+ return layer->ancestorOverflowLayer()->scrollsOverflow();
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698