| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/paint/PrePaintTreeWalk.h" | 5 #include "core/paint/PrePaintTreeWalk.h" |
| 6 | 6 |
| 7 #include "core/dom/DocumentLifecycle.h" | 7 #include "core/dom/DocumentLifecycle.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" | 10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 localContext.needToUpdatePaintPropertySubtree = true; | 53 localContext.needToUpdatePaintPropertySubtree = true; |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 // Paint properties can depend on their ancestor properties so ensure the | 56 // Paint properties can depend on their ancestor properties so ensure the |
| 57 // entire subtree is rebuilt on any changes. | 57 // entire subtree is rebuilt on any changes. |
| 58 // TODO(pdr): Add additional granularity to the needs update approach such as | 58 // TODO(pdr): Add additional granularity to the needs update approach such as |
| 59 // the ability to do local updates that don't change the subtree. | 59 // the ability to do local updates that don't change the subtree. |
| 60 if (localContext.needToUpdatePaintPropertySubtree) | 60 if (localContext.needToUpdatePaintPropertySubtree) |
| 61 frameView.setNeedsPaintPropertyUpdate(); | 61 frameView.setNeedsPaintPropertyUpdate(); |
| 62 | 62 |
| 63 m_propertyTreeBuilder.updateProperties(frameView, | 63 auto propertyTreeStructureChanged = m_propertyTreeBuilder.updateProperties( |
| 64 localContext.treeBuilderContext); | 64 frameView, localContext.treeBuilderContext); |
| 65 | 65 |
| 66 m_paintInvalidator.invalidatePaintIfNeeded( | 66 m_paintInvalidator.invalidatePaintIfNeeded( |
| 67 frameView, localContext.paintInvalidatorContext); | 67 frameView, localContext.paintInvalidatorContext); |
| 68 | 68 |
| 69 if (propertyTreeStructureChanged) |
| 70 localContext.needToUpdatePaintPropertySubtree = true; |
| 71 |
| 69 if (LayoutView* layoutView = frameView.layoutView()) | 72 if (LayoutView* layoutView = frameView.layoutView()) |
| 70 walk(*layoutView, localContext); | 73 walk(*layoutView, localContext); |
| 71 | 74 |
| 72 #if DCHECK_IS_ON() | 75 #if DCHECK_IS_ON() |
| 73 frameView.layoutView()->assertSubtreeClearedPaintInvalidationFlags(); | 76 frameView.layoutView()->assertSubtreeClearedPaintInvalidationFlags(); |
| 74 #endif | 77 #endif |
| 75 | 78 |
| 76 frameView.clearNeedsPaintPropertyUpdate(); | 79 frameView.clearNeedsPaintPropertyUpdate(); |
| 77 } | 80 } |
| 78 | 81 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 92 // mayNeedpaintInvalidation will be true when locations change which will | 95 // mayNeedpaintInvalidation will be true when locations change which will |
| 93 // affect paint properties (e.g., PaintOffset). | 96 // affect paint properties (e.g., PaintOffset). |
| 94 localContext.needToUpdatePaintPropertySubtree = true; | 97 localContext.needToUpdatePaintPropertySubtree = true; |
| 95 } else if (object.shouldDoFullPaintInvalidation()) { | 98 } else if (object.shouldDoFullPaintInvalidation()) { |
| 96 // shouldDoFullPaintInvalidation will be true when locations or overflow | 99 // shouldDoFullPaintInvalidation will be true when locations or overflow |
| 97 // changes which will affect paint properties (e.g., PaintOffset, scroll). | 100 // changes which will affect paint properties (e.g., PaintOffset, scroll). |
| 98 localContext.needToUpdatePaintPropertySubtree = true; | 101 localContext.needToUpdatePaintPropertySubtree = true; |
| 99 } | 102 } |
| 100 } | 103 } |
| 101 | 104 |
| 105 // Early out from the treewalk if possible. |
| 106 if (!object.descendantNeedsPaintPropertyUpdate() && |
| 107 !localContext.needToUpdatePaintPropertySubtree && |
| 108 !context.paintInvalidatorContext.forcedSubtreeInvalidationFlags && |
| 109 !object.shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState(
)) { |
| 110 object.getMutableForPainting().clearPaintInvalidationFlags(); |
| 111 object.getMutableForPainting().clearNeedsPaintPropertyUpdate(); |
| 112 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate(); |
| 113 return; |
| 114 } |
| 115 |
| 102 // Paint properties can depend on their ancestor properties so ensure the | 116 // Paint properties can depend on their ancestor properties so ensure the |
| 103 // entire subtree is rebuilt on any changes. | 117 // entire subtree is rebuilt on any changes. |
| 104 // TODO(pdr): Add additional granularity to the needs update approach such as | 118 // TODO(pdr): Add additional granularity to the needs update approach such as |
| 105 // the ability to do local updates that don't change the subtree. | 119 // the ability to do local updates that don't change the subtree. |
| 106 if (localContext.needToUpdatePaintPropertySubtree) | 120 if (localContext.needToUpdatePaintPropertySubtree) |
| 107 object.getMutableForPainting().setNeedsPaintPropertyUpdate(); | 121 object.getMutableForPainting().setNeedsPaintPropertyUpdate(); |
| 108 | 122 |
| 109 // TODO(pdr): Ensure multi column works with incremental property tree | 123 // TODO(pdr): Ensure multi column works with incremental property tree |
| 110 // construction. | 124 // construction. |
| 111 if (object.isLayoutMultiColumnSpannerPlaceholder()) { | 125 if (object.isLayoutMultiColumnSpannerPlaceholder()) { |
| 112 // Walk multi-column spanner as if it replaces the placeholder. | 126 // Walk multi-column spanner as if it replaces the placeholder. |
| 113 // Set the flag so that the tree builder can specially handle out-of-flow | 127 // Set the flag so that the tree builder can specially handle out-of-flow |
| 114 // positioned descendants if their containers are between the multi-column | 128 // positioned descendants if their containers are between the multi-column |
| 115 // container and the spanner. See PaintPropertyTreeBuilder for details. | 129 // container and the spanner. See PaintPropertyTreeBuilder for details. |
| 116 localContext.treeBuilderContext.isUnderMultiColumnSpanner = true; | 130 localContext.treeBuilderContext.isUnderMultiColumnSpanner = true; |
| 117 walk(*toLayoutMultiColumnSpannerPlaceholder(object) | 131 const auto& placeholder = toLayoutMultiColumnSpannerPlaceholder(object); |
| 118 .layoutObjectInFlowThread(), | 132 walk(*placeholder.layoutObjectInFlowThread(), localContext); |
| 119 localContext); | |
| 120 object.getMutableForPainting().clearPaintInvalidationFlags(); | 133 object.getMutableForPainting().clearPaintInvalidationFlags(); |
| 134 object.getMutableForPainting().clearNeedsPaintPropertyUpdate(); |
| 135 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate(); |
| 121 return; | 136 return; |
| 122 } | 137 } |
| 123 | 138 |
| 124 m_propertyTreeBuilder.updatePropertiesForSelf( | 139 bool propertyTreeStructureChanged = false; |
| 140 propertyTreeStructureChanged |= m_propertyTreeBuilder.updatePropertiesForSelf( |
| 125 object, localContext.treeBuilderContext); | 141 object, localContext.treeBuilderContext); |
| 126 m_paintInvalidator.invalidatePaintIfNeeded( | 142 m_paintInvalidator.invalidatePaintIfNeeded( |
| 127 object, localContext.paintInvalidatorContext); | 143 object, localContext.paintInvalidatorContext); |
| 128 m_propertyTreeBuilder.updatePropertiesForChildren( | 144 propertyTreeStructureChanged |= |
| 129 object, localContext.treeBuilderContext); | 145 m_propertyTreeBuilder.updatePropertiesForChildren( |
| 146 object, localContext.treeBuilderContext); |
| 147 |
| 148 if (propertyTreeStructureChanged) |
| 149 localContext.needToUpdatePaintPropertySubtree = true; |
| 130 | 150 |
| 131 for (const LayoutObject* child = object.slowFirstChild(); child; | 151 for (const LayoutObject* child = object.slowFirstChild(); child; |
| 132 child = child->nextSibling()) { | 152 child = child->nextSibling()) { |
| 133 // Column spanners are walked through their placeholders. See above. | 153 // Column spanners are walked through their placeholders. See above. |
| 134 if (child->isColumnSpanAll()) | 154 if (child->isColumnSpanAll()) |
| 135 continue; | 155 continue; |
| 136 walk(*child, localContext); | 156 walk(*child, localContext); |
| 137 } | 157 } |
| 138 | 158 |
| 139 if (object.isLayoutPart()) { | 159 if (object.isLayoutPart()) { |
| 140 const LayoutPart& layoutPart = toLayoutPart(object); | 160 const LayoutPart& layoutPart = toLayoutPart(object); |
| 141 Widget* widget = layoutPart.widget(); | 161 Widget* widget = layoutPart.widget(); |
| 142 if (widget && widget->isFrameView()) { | 162 if (widget && widget->isFrameView()) { |
| 143 localContext.treeBuilderContext.current.paintOffset += | 163 localContext.treeBuilderContext.current.paintOffset += |
| 144 layoutPart.replacedContentRect().location() - | 164 layoutPart.replacedContentRect().location() - |
| 145 widget->frameRect().location(); | 165 widget->frameRect().location(); |
| 146 localContext.treeBuilderContext.current.paintOffset = | 166 localContext.treeBuilderContext.current.paintOffset = |
| 147 roundedIntPoint(localContext.treeBuilderContext.current.paintOffset); | 167 roundedIntPoint(localContext.treeBuilderContext.current.paintOffset); |
| 148 walk(*toFrameView(widget), localContext); | 168 walk(*toFrameView(widget), localContext); |
| 149 } | 169 } |
| 150 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). | 170 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |
| 151 } | 171 } |
| 152 | 172 |
| 153 object.getMutableForPainting().clearPaintInvalidationFlags(); | 173 object.getMutableForPainting().clearPaintInvalidationFlags(); |
| 154 object.getMutableForPainting().clearNeedsPaintPropertyUpdate(); | 174 object.getMutableForPainting().clearNeedsPaintPropertyUpdate(); |
| 175 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate(); |
| 155 } | 176 } |
| 156 | 177 |
| 157 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |