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

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: Created 3 years, 10 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 d9d504bf573b63b0e753f78cd7ab3c20467d2b50..bed249106fd77bef7ae08c8a77a189d36d55541a 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 {
+ EPosition position = layer->layoutObject().style()->position();
+ if (position != EPosition::kFixed && position != EPosition::kSticky)
return false;
- if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger) &&
+ if (!(ignoreLCDText ||
+ (m_compositingTriggers & ViewportConstrainedPositionedTrigger)) &&
(!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() ||
!layer->backgroundIsKnownToBeOpaqueInRect(
LayoutRect(layer->boundingBoxForCompositing())) ||
@@ -229,10 +231,15 @@ 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())
+ if (position == EPosition::kFixed)
+ return layer->fixedToViewport() && m_layoutView.frameView()->isScrollable();
+
+ // 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->layoutObject().style()->position() == EPosition::kSticky &&
- layer->ancestorOverflowLayer()->scrollsOverflow();
+ return layer->ancestorOverflowLayer()->scrollsOverflow();
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698