| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // sticky layer position, so we need to update it again here. | 104 // sticky layer position, so we need to update it again here. |
| 105 // TODO(flackr): This should be refactored in the future to be clearer (i.e. | 105 // TODO(flackr): This should be refactored in the future to be clearer (i.e. |
| 106 // update layer position and ancestor inputs updates in the same walk). | 106 // update layer position and ancestor inputs updates in the same walk). |
| 107 paintLayer->updateLayerPosition(); | 107 paintLayer->updateLayerPosition(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 if (paintLayer->isRootLayer() || object.hasOverflowClip()) | 110 if (paintLayer->isRootLayer() || object.hasOverflowClip()) |
| 111 context.ancestorOverflowPaintLayer = paintLayer; | 111 context.ancestorOverflowPaintLayer = paintLayer; |
| 112 } | 112 } |
| 113 | 113 |
| 114 // Returns whether |a| is an ancestor of or equal to |b|. | |
| 115 static bool isAncestorOfOrEqualTo(const ClipPaintPropertyNode* a, | |
| 116 const ClipPaintPropertyNode* b) { | |
| 117 while (b && b != a) { | |
| 118 b = b->parent(); | |
| 119 } | |
| 120 return b == a; | |
| 121 } | |
| 122 | |
| 123 void PrePaintTreeWalk::computeClipRectForContext( | 114 void PrePaintTreeWalk::computeClipRectForContext( |
| 124 const PaintPropertyTreeBuilderContext::ContainingBlockContext& context, | 115 const PaintPropertyTreeBuilderContext::ContainingBlockContext& context, |
| 125 const EffectPaintPropertyNode* effect, | 116 const EffectPaintPropertyNode* effect, |
| 126 const PropertyTreeState& ancestorState, | 117 const PropertyTreeState& ancestorState, |
| 127 const LayoutPoint& ancestorPaintOffset, | 118 const LayoutPoint& ancestorPaintOffset, |
| 128 bool& hasClip, | |
| 129 FloatClipRect& clipRect) { | 119 FloatClipRect& clipRect) { |
| 130 // Only return a non-infinite clip if clips differ, or the "ancestor" state is | |
| 131 // actually an ancestor clip. This ensures no accuracy issues due to | |
| 132 // transforms applied to infinite rects. | |
| 133 if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip())) | |
| 134 clipRect = FloatClipRect(); | |
| 135 | |
| 136 hasClip = true; | |
| 137 PropertyTreeState localState(context.transform, context.clip, effect); | 120 PropertyTreeState localState(context.transform, context.clip, effect); |
| 138 | 121 |
| 139 clipRect = | 122 clipRect = |
| 140 m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState); | 123 m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState); |
| 141 clipRect.moveBy(-FloatPoint(ancestorPaintOffset)); | 124 clipRect.moveBy(-FloatPoint(ancestorPaintOffset)); |
| 142 } | 125 } |
| 143 | 126 |
| 144 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( | 127 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( |
| 145 const LayoutObject& object, | 128 const LayoutObject& object, |
| 146 PrePaintTreeWalkContext& context) { | 129 PrePaintTreeWalkContext& context) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 171 } | 154 } |
| 172 } | 155 } |
| 173 | 156 |
| 174 #ifdef CHECK_CLIP_RECTS | 157 #ifdef CHECK_CLIP_RECTS |
| 175 ClipRects& oldClipRects = | 158 ClipRects& oldClipRects = |
| 176 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) | 159 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) |
| 177 .paintingClipRects(&ancestorTransformedOrRootPaintLayer, | 160 .paintingClipRects(&ancestorTransformedOrRootPaintLayer, |
| 178 respectOverflowClip, LayoutSize()); | 161 respectOverflowClip, LayoutSize()); |
| 179 #endif | 162 #endif |
| 180 | 163 |
| 181 bool hasClip = false; | |
| 182 RefPtr<ClipRects> clipRects = ClipRects::create(); | 164 RefPtr<ClipRects> clipRects = ClipRects::create(); |
| 183 const LayoutPoint& ancestorPaintOffset = | 165 const LayoutPoint& ancestorPaintOffset = |
| 184 context.ancestorTransformedOrRootPaintLayer->layoutObject().paintOffset(); | 166 context.ancestorTransformedOrRootPaintLayer->layoutObject().paintOffset(); |
| 185 | 167 |
| 186 FloatClipRect clipRect; | 168 FloatClipRect clipRect; |
| 187 const EffectPaintPropertyNode* effect = | 169 const EffectPaintPropertyNode* effect = |
| 188 context.treeBuilderContext->currentEffect; | 170 context.treeBuilderContext->currentEffect; |
| 189 computeClipRectForContext(context.treeBuilderContext->current, effect, | 171 computeClipRectForContext(context.treeBuilderContext->current, effect, |
| 190 ancestorState, ancestorPaintOffset, hasClip, | 172 ancestorState, ancestorPaintOffset, clipRect); |
| 191 clipRect); | |
| 192 clipRects->setOverflowClipRect(clipRect); | 173 clipRects->setOverflowClipRect(clipRect); |
| 193 #ifdef CHECK_CLIP_RECTS | 174 #ifdef CHECK_CLIP_RECTS |
| 194 CHECK(!hasClip || | 175 CHECK(clipRects->overflowClipRect() == oldClipRects.overflowClipRect()) |
| 195 clipRects->overflowClipRect() == oldClipRects.overflowClipRect()) | |
| 196 << "rect= " << clipRects->overflowClipRect().toString(); | 176 << "rect= " << clipRects->overflowClipRect().toString(); |
| 197 #endif | 177 #endif |
| 198 | 178 |
| 199 computeClipRectForContext(context.treeBuilderContext->fixedPosition, effect, | 179 computeClipRectForContext(context.treeBuilderContext->fixedPosition, effect, |
| 200 ancestorState, ancestorPaintOffset, hasClip, | 180 ancestorState, ancestorPaintOffset, clipRect); |
| 201 clipRect); | |
| 202 clipRects->setFixedClipRect(clipRect); | 181 clipRects->setFixedClipRect(clipRect); |
| 203 #ifdef CHECK_CLIP_RECTS | 182 #ifdef CHECK_CLIP_RECTS |
| 204 CHECK(hasClip || clipRects->fixedClipRect() == oldClipRects.fixedClipRect()) | 183 CHECK(clipRects->fixedClipRect() == oldClipRects.fixedClipRect()) |
| 205 << " fixed=" << clipRects->fixedClipRect().toString(); | 184 << " fixed=" << clipRects->fixedClipRect().toString(); |
| 206 #endif | 185 #endif |
| 207 | 186 |
| 208 computeClipRectForContext(context.treeBuilderContext->absolutePosition, | 187 computeClipRectForContext(context.treeBuilderContext->absolutePosition, |
| 209 effect, ancestorState, ancestorPaintOffset, hasClip, | 188 effect, ancestorState, ancestorPaintOffset, |
| 210 clipRect); | 189 clipRect); |
| 211 clipRects->setPosClipRect(clipRect); | 190 clipRects->setPosClipRect(clipRect); |
| 212 #ifdef CHECK_CLIP_RECTS | 191 #ifdef CHECK_CLIP_RECTS |
| 213 CHECK(!hasClip || clipRects->posClipRect() == oldClipRects.posClipRect()) | 192 CHECK(clipRects->posClipRect() == oldClipRects.posClipRect()) |
| 214 << " abs=" << clipRects->posClipRect().toString(); | 193 << " abs=" << clipRects->posClipRect().toString(); |
| 215 #endif | 194 #endif |
| 216 | 195 |
| 217 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); | 196 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); |
| 218 | 197 |
| 219 if (!previousClipRects || *clipRects != *previousClipRects) { | 198 if (!previousClipRects || *clipRects != *previousClipRects) { |
| 220 paintLayer.setNeedsRepaint(); | 199 paintLayer.setNeedsRepaint(); |
| 221 paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false); | 200 paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false); |
| 222 paintLayer.setPreviousPaintPhaseFloatEmpty(false); | 201 paintLayer.setPreviousPaintPhaseFloatEmpty(false); |
| 223 paintLayer.setPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); | 202 paintLayer.setPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 roundedIntPoint(context.treeBuilderContext->current.paintOffset); | 259 roundedIntPoint(context.treeBuilderContext->current.paintOffset); |
| 281 walk(*toFrameView(frameViewBase), context); | 260 walk(*toFrameView(frameViewBase), context); |
| 282 } | 261 } |
| 283 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). | 262 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |
| 284 } | 263 } |
| 285 | 264 |
| 286 object.getMutableForPainting().clearPaintFlags(); | 265 object.getMutableForPainting().clearPaintFlags(); |
| 287 } | 266 } |
| 288 | 267 |
| 289 } // namespace blink | 268 } // namespace blink |
| OLD | NEW |