Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 15 matching lines...) Expand all Loading... | |
| 26 m_compositingTriggers = 0; | 26 m_compositingTriggers = 0; |
| 27 | 27 |
| 28 Settings& settings = m_layoutView.document().page()->settings(); | 28 Settings& settings = m_layoutView.document().page()->settings(); |
| 29 if (settings.preferCompositingToLCDTextEnabled()) { | 29 if (settings.preferCompositingToLCDTextEnabled()) { |
| 30 m_compositingTriggers |= ScrollableInnerFrameTrigger; | 30 m_compositingTriggers |= ScrollableInnerFrameTrigger; |
| 31 m_compositingTriggers |= OverflowScrollTrigger; | 31 m_compositingTriggers |= OverflowScrollTrigger; |
| 32 m_compositingTriggers |= ViewportConstrainedPositionedTrigger; | 32 m_compositingTriggers |= ViewportConstrainedPositionedTrigger; |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool CompositingReasonFinder::hasOverflowScrollTrigger() const | 36 bool CompositingReasonFinder::hasOverflowScrollTrigger(const PaintLayer* layer) const |
| 37 { | 37 { |
| 38 return m_compositingTriggers & OverflowScrollTrigger; | 38 return m_compositingTriggers & OverflowScrollTrigger |
| 39 || !layer->layoutObject()->style()->visitedDependentColor(CSSPropertyBac kgroundColor).hasAlpha(); | |
|
chrishtr
2016/05/25 15:55:22
You'll also have to ensure that the scroller is po
| |
| 39 } | 40 } |
| 40 | 41 |
| 41 bool CompositingReasonFinder::isMainFrame() const | 42 bool CompositingReasonFinder::isMainFrame() const |
| 42 { | 43 { |
| 43 // FIXME: LocalFrame::isMainFrame() is probably better. | 44 // FIXME: LocalFrame::isMainFrame() is probably better. |
| 44 return !m_layoutView.document().ownerElement(); | 45 return !m_layoutView.document().ownerElement(); |
| 45 } | 46 } |
| 46 | 47 |
| 47 CompositingReasons CompositingReasonFinder::directReasons(const PaintLayer* laye r) const | 48 CompositingReasons CompositingReasonFinder::directReasons(const PaintLayer* laye r) const |
| 48 { | 49 { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 // Note that we ask the layoutObject if it has a transform, because the styl e may have transforms, | 137 // Note that we ask the layoutObject if it has a transform, because the styl e may have transforms, |
| 137 // but the layoutObject may be an inline that doesn't support them. | 138 // but the layoutObject may be an inline that doesn't support them. |
| 138 return layoutObject->hasTransformRelatedProperty() && layoutObject->style()- >has3DTransform(); | 139 return layoutObject->hasTransformRelatedProperty() && layoutObject->style()- >has3DTransform(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons t PaintLayer* layer) const | 142 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons t PaintLayer* layer) const |
| 142 { | 143 { |
| 143 CompositingReasons directReasons = CompositingReasonNone; | 144 CompositingReasons directReasons = CompositingReasonNone; |
| 144 LayoutObject* layoutObject = layer->layoutObject(); | 145 LayoutObject* layoutObject = layer->layoutObject(); |
| 145 | 146 |
| 146 if (hasOverflowScrollTrigger()) { | 147 if (hasOverflowScrollTrigger(layer)) { |
| 147 if (layer->clipParent()) | 148 if (layer->clipParent()) |
| 148 directReasons |= CompositingReasonOutOfFlowClipping; | 149 directReasons |= CompositingReasonOutOfFlowClipping; |
| 149 | 150 |
| 150 if (layer->needsCompositedScrolling()) | 151 if (layer->needsCompositedScrolling()) |
| 151 directReasons |= CompositingReasonOverflowScrollingTouch; | 152 directReasons |= CompositingReasonOverflowScrollingTouch; |
| 152 } | 153 } |
| 153 | 154 |
| 154 // Composite |layer| if it is inside of an ancestor scrolling layer, but tha t | 155 // Composite |layer| if it is inside of an ancestor scrolling layer, but tha t |
| 155 // scrolling layer is not not on the stacking context ancestor chain of |lay er|. | 156 // scrolling layer is not not on the stacking context ancestor chain of |lay er|. |
| 156 // See the definition of the scrollParent property in Layer for more detail. | 157 // See the definition of the scrollParent property in Layer for more detail. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 179 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const PaintLay er* layer) const | 180 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const PaintLay er* layer) const |
| 180 { | 181 { |
| 181 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) | 182 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) |
| 182 return false; | 183 return false; |
| 183 // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements. | 184 // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements. |
| 184 // They will stay fixed wrt the container rather than the enclosing frame. | 185 // They will stay fixed wrt the container rather than the enclosing frame. |
| 185 return layer->scrollsWithViewport() && m_layoutView.frameView()->isScrollabl e(); | 186 return layer->scrollsWithViewport() && m_layoutView.frameView()->isScrollabl e(); |
| 186 } | 187 } |
| 187 | 188 |
| 188 } // namespace blink | 189 } // namespace blink |
| OLD | NEW |