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

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

Issue 2776563003: Only automatically promote sticky position elements which move with scroll. (Closed)
Patch Set: Merge with master Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/compositing/CompositingReasonFinder.h" 5 #include "core/layout/compositing/CompositingReasonFinder.h"
6 6
7 #include "core/CSSPropertyNames.h" 7 #include "core/CSSPropertyNames.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 19 matching lines...) Expand all
30 m_compositingTriggers |= OverflowScrollTrigger; 30 m_compositingTriggers |= OverflowScrollTrigger;
31 m_compositingTriggers |= ViewportConstrainedPositionedTrigger; 31 m_compositingTriggers |= ViewportConstrainedPositionedTrigger;
32 } 32 }
33 } 33 }
34 34
35 bool CompositingReasonFinder::isMainFrame() const { 35 bool CompositingReasonFinder::isMainFrame() const {
36 return m_layoutView.document().isInMainFrame(); 36 return m_layoutView.document().isInMainFrame();
37 } 37 }
38 38
39 CompositingReasons CompositingReasonFinder::directReasons( 39 CompositingReasons CompositingReasonFinder::directReasons(
40 const PaintLayer* layer) const { 40 const PaintLayer* layer,
41 bool ignoreLCDText) const {
41 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 42 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
42 return CompositingReasonNone; 43 return CompositingReasonNone;
43 44
44 DCHECK_EQ(potentialCompositingReasonsFromStyle(layer->layoutObject()), 45 DCHECK_EQ(potentialCompositingReasonsFromStyle(layer->layoutObject()),
45 layer->potentialCompositingReasonsFromStyle()); 46 layer->potentialCompositingReasonsFromStyle());
46 CompositingReasons styleDeterminedDirectCompositingReasons = 47 CompositingReasons styleDeterminedDirectCompositingReasons =
47 layer->potentialCompositingReasonsFromStyle() & 48 layer->potentialCompositingReasonsFromStyle() &
48 CompositingReasonComboAllDirectStyleDeterminedReasons; 49 CompositingReasonComboAllDirectStyleDeterminedReasons;
49 50
50 return styleDeterminedDirectCompositingReasons | 51 return styleDeterminedDirectCompositingReasons |
51 nonStyleDeterminedDirectReasons(layer); 52 nonStyleDeterminedDirectReasons(layer, ignoreLCDText);
52 } 53 }
53 54
54 // This information doesn't appear to be incorporated into CompositingReasons. 55 // This information doesn't appear to be incorporated into CompositingReasons.
55 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const { 56 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const {
56 // Need this done first to determine overflow. 57 // Need this done first to determine overflow.
57 DCHECK(!m_layoutView.needsLayout()); 58 DCHECK(!m_layoutView.needsLayout());
58 if (isMainFrame()) 59 if (isMainFrame())
59 return false; 60 return false;
60 61
61 if (!(m_compositingTriggers & ScrollableInnerFrameTrigger)) 62 if (!(m_compositingTriggers & ScrollableInnerFrameTrigger))
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 bool CompositingReasonFinder::requiresCompositingForTransform( 135 bool CompositingReasonFinder::requiresCompositingForTransform(
135 const LayoutObject& layoutObject) { 136 const LayoutObject& layoutObject) {
136 // Note that we ask the layoutObject if it has a transform, because the style 137 // Note that we ask the layoutObject if it has a transform, because the style
137 // may have transforms, but the layoutObject may be an inline that doesn't 138 // may have transforms, but the layoutObject may be an inline that doesn't
138 // support them. 139 // support them.
139 return layoutObject.hasTransformRelatedProperty() && 140 return layoutObject.hasTransformRelatedProperty() &&
140 layoutObject.styleRef().has3DTransform(); 141 layoutObject.styleRef().has3DTransform();
141 } 142 }
142 143
143 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons( 144 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(
144 const PaintLayer* layer) const { 145 const PaintLayer* layer,
146 bool ignoreLCDText) const {
145 CompositingReasons directReasons = CompositingReasonNone; 147 CompositingReasons directReasons = CompositingReasonNone;
146 LayoutObject& layoutObject = layer->layoutObject(); 148 LayoutObject& layoutObject = layer->layoutObject();
147 149
148 if (m_compositingTriggers & OverflowScrollTrigger && layer->clipParent()) 150 if (m_compositingTriggers & OverflowScrollTrigger && layer->clipParent())
149 directReasons |= CompositingReasonOutOfFlowClipping; 151 directReasons |= CompositingReasonOutOfFlowClipping;
150 152
151 if (layer->needsCompositedScrolling()) 153 if (layer->needsCompositedScrolling())
152 directReasons |= CompositingReasonOverflowScrollingTouch; 154 directReasons |= CompositingReasonOverflowScrollingTouch;
153 155
154 // Composite |layer| if it is inside of an ancestor scrolling layer, but that 156 // Composite |layer| if it is inside of an ancestor scrolling layer, but that
155 // scrolling layer is not on the stacking context ancestor chain of |layer|. 157 // scrolling layer is not on the stacking context ancestor chain of |layer|.
156 // See the definition of the scrollParent property in Layer for more detail. 158 // See the definition of the scrollParent property in Layer for more detail.
157 if (const PaintLayer* scrollingAncestor = layer->ancestorScrollingLayer()) { 159 if (const PaintLayer* scrollingAncestor = layer->ancestorScrollingLayer()) {
158 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollParent()) 160 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollParent())
159 directReasons |= CompositingReasonOverflowScrollingParent; 161 directReasons |= CompositingReasonOverflowScrollingParent;
160 } 162 }
161 163
162 // TODO(flackr): Rename functions and variables to include sticky position 164 if (requiresCompositingForScrollDependentPosition(layer, ignoreLCDText))
163 // (i.e. ScrollDependentPosition rather than PositionFixed).
164 if (requiresCompositingForScrollDependentPosition(layer))
165 directReasons |= CompositingReasonScrollDependentPosition; 165 directReasons |= CompositingReasonScrollDependentPosition;
166 166
167 directReasons |= layoutObject.additionalCompositingReasons(); 167 directReasons |= layoutObject.additionalCompositingReasons();
168 168
169 DCHECK(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); 169 DCHECK(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons));
170 return directReasons; 170 return directReasons;
171 } 171 }
172 172
173 bool CompositingReasonFinder::requiresCompositingForAnimation( 173 bool CompositingReasonFinder::requiresCompositingForAnimation(
174 const ComputedStyle& style) { 174 const ComputedStyle& style) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 208
209 bool CompositingReasonFinder::requiresCompositingForTransformAnimation( 209 bool CompositingReasonFinder::requiresCompositingForTransformAnimation(
210 const ComputedStyle& style) { 210 const ComputedStyle& style) {
211 return style.subtreeWillChangeContents() 211 return style.subtreeWillChangeContents()
212 ? style.isRunningTransformAnimationOnCompositor() 212 ? style.isRunningTransformAnimationOnCompositor()
213 : style.hasCurrentTransformAnimation(); 213 : style.hasCurrentTransformAnimation();
214 } 214 }
215 215
216 bool CompositingReasonFinder::requiresCompositingForScrollDependentPosition( 216 bool CompositingReasonFinder::requiresCompositingForScrollDependentPosition(
217 const PaintLayer* layer) const { 217 const PaintLayer* layer,
218 bool ignoreLCDText) const {
218 if (layer->layoutObject().style()->position() != EPosition::kFixed && 219 if (layer->layoutObject().style()->position() != EPosition::kFixed &&
219 layer->layoutObject().style()->position() != EPosition::kSticky) 220 layer->layoutObject().style()->position() != EPosition::kSticky)
220 return false; 221 return false;
221 222
222 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger) && 223 if (!(ignoreLCDText ||
224 (m_compositingTriggers & ViewportConstrainedPositionedTrigger)) &&
223 (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() || 225 (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() ||
224 !layer->backgroundIsKnownToBeOpaqueInRect( 226 !layer->backgroundIsKnownToBeOpaqueInRect(
225 LayoutRect(layer->boundingBoxForCompositing())) || 227 LayoutRect(layer->boundingBoxForCompositing())) ||
226 layer->compositesWithTransform() || layer->compositesWithOpacity())) { 228 layer->compositesWithTransform() || layer->compositesWithOpacity())) {
227 return false; 229 return false;
228 } 230 }
229 // Don't promote fixed position elements that are descendants of a non-view 231 // Don't promote fixed position elements that are descendants of a non-view
230 // container, e.g. transformed elements. They will stay fixed wrt the 232 // container, e.g. transformed elements. They will stay fixed wrt the
231 // container rather than the enclosing frame. 233 // container rather than the enclosing frame.
232 if (layer->sticksToViewport()) 234 EPosition position = layer->layoutObject().style()->position();
235 if (position == EPosition::kFixed)
236 return layer->fixedToViewport() && m_layoutView.frameView()->isScrollable();
237 DCHECK(position == EPosition::kSticky);
238
239 // Don't promote sticky position elements that cannot move with scrolls.
240 if (!layer->sticksToScroller())
241 return false;
242 if (layer->ancestorOverflowLayer()->isRootLayer())
233 return m_layoutView.frameView()->isScrollable(); 243 return m_layoutView.frameView()->isScrollable();
234 244 return layer->ancestorOverflowLayer()->scrollsOverflow();
235 return layer->layoutObject().style()->position() == EPosition::kSticky &&
236 layer->ancestorOverflowLayer()->scrollsOverflow();
237 } 245 }
238 246
239 } // namespace blink 247 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698