| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // sticky layer position, so we need to update it again here. | 117 // sticky layer position, so we need to update it again here. |
| 118 // TODO(flackr): This should be refactored in the future to be clearer (i.e. | 118 // TODO(flackr): This should be refactored in the future to be clearer (i.e. |
| 119 // update layer position and ancestor inputs updates in the same walk). | 119 // update layer position and ancestor inputs updates in the same walk). |
| 120 paintLayer->updateLayerPosition(); | 120 paintLayer->updateLayerPosition(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 if (paintLayer->isRootLayer() || object.hasOverflowClip()) | 123 if (paintLayer->isRootLayer() || object.hasOverflowClip()) |
| 124 context.ancestorOverflowPaintLayer = paintLayer; | 124 context.ancestorOverflowPaintLayer = paintLayer; |
| 125 } | 125 } |
| 126 | 126 |
| 127 // Returns whether |a| is an ancestor of or equal to |b|. | |
| 128 static bool isAncestorOfOrEqualTo(const ClipPaintPropertyNode* a, | |
| 129 const ClipPaintPropertyNode* b) { | |
| 130 while (b && b != a) { | |
| 131 b = b->parent(); | |
| 132 } | |
| 133 return b == a; | |
| 134 } | |
| 135 | |
| 136 void PrePaintTreeWalk::computeClipRectForContext( | 127 void PrePaintTreeWalk::computeClipRectForContext( |
| 137 const PaintPropertyTreeBuilderContext::ContainingBlockContext& context, | 128 const PaintPropertyTreeBuilderContext::ContainingBlockContext& context, |
| 138 const EffectPaintPropertyNode* effect, | 129 const EffectPaintPropertyNode* effect, |
| 139 const PropertyTreeState& ancestorState, | 130 const PropertyTreeState& ancestorState, |
| 140 const LayoutPoint& ancestorPaintOffset, | 131 const LayoutPoint& ancestorPaintOffset, |
| 141 bool& hasClip, | |
| 142 FloatClipRect& clipRect) { | 132 FloatClipRect& clipRect) { |
| 143 // Only return a non-infinite clip if clips differ, or the "ancestor" state is | |
| 144 // actually an ancestor clip. This ensures no accuracy issues due to | |
| 145 // transforms applied to infinite rects. | |
| 146 if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip())) | |
| 147 clipRect = FloatClipRect(); | |
| 148 | |
| 149 hasClip = true; | |
| 150 PropertyTreeState localState(context.transform, context.clip, effect); | 133 PropertyTreeState localState(context.transform, context.clip, effect); |
| 151 | 134 |
| 152 clipRect = | 135 clipRect = |
| 153 m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState); | 136 m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState); |
| 154 clipRect.moveBy(-FloatPoint(ancestorPaintOffset)); | 137 clipRect.moveBy(-FloatPoint(ancestorPaintOffset)); |
| 155 } | 138 } |
| 156 | 139 |
| 157 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( | 140 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( |
| 158 const LayoutObject& object, | 141 const LayoutObject& object, |
| 159 PrePaintTreeWalkContext& context) { | 142 PrePaintTreeWalkContext& context) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 184 } | 167 } |
| 185 } | 168 } |
| 186 | 169 |
| 187 #ifdef CHECK_CLIP_RECTS | 170 #ifdef CHECK_CLIP_RECTS |
| 188 ClipRects& oldClipRects = | 171 ClipRects& oldClipRects = |
| 189 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) | 172 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) |
| 190 .paintingClipRects(&ancestorTransformedOrRootPaintLayer, | 173 .paintingClipRects(&ancestorTransformedOrRootPaintLayer, |
| 191 respectOverflowClip, LayoutSize()); | 174 respectOverflowClip, LayoutSize()); |
| 192 #endif | 175 #endif |
| 193 | 176 |
| 194 bool hasClip = false; | |
| 195 RefPtr<ClipRects> clipRects = ClipRects::create(); | 177 RefPtr<ClipRects> clipRects = ClipRects::create(); |
| 196 const LayoutPoint& ancestorPaintOffset = | 178 const LayoutPoint& ancestorPaintOffset = |
| 197 context.ancestorTransformedOrRootPaintLayer->layoutObject().paintOffset(); | 179 context.ancestorTransformedOrRootPaintLayer->layoutObject().paintOffset(); |
| 198 | 180 |
| 199 FloatClipRect clipRect; | 181 FloatClipRect clipRect; |
| 200 const EffectPaintPropertyNode* effect = | 182 const EffectPaintPropertyNode* effect = |
| 201 context.treeBuilderContext->currentEffect; | 183 context.treeBuilderContext->currentEffect; |
| 202 computeClipRectForContext(context.treeBuilderContext->current, effect, | 184 computeClipRectForContext(context.treeBuilderContext->current, effect, |
| 203 ancestorState, ancestorPaintOffset, hasClip, | 185 ancestorState, ancestorPaintOffset, clipRect); |
| 204 clipRect); | |
| 205 clipRects->setOverflowClipRect(clipRect); | 186 clipRects->setOverflowClipRect(clipRect); |
| 206 #ifdef CHECK_CLIP_RECTS | 187 #ifdef CHECK_CLIP_RECTS |
| 207 CHECK(!hasClip || | 188 CHECK(clipRects->overflowClipRect() == oldClipRects.overflowClipRect()) |
| 208 clipRects->overflowClipRect() == oldClipRects.overflowClipRect()) | |
| 209 << "rect= " << clipRects->overflowClipRect().toString(); | 189 << "rect= " << clipRects->overflowClipRect().toString(); |
| 210 #endif | 190 #endif |
| 211 | 191 |
| 212 computeClipRectForContext(context.treeBuilderContext->fixedPosition, effect, | 192 computeClipRectForContext(context.treeBuilderContext->fixedPosition, effect, |
| 213 ancestorState, ancestorPaintOffset, hasClip, | 193 ancestorState, ancestorPaintOffset, clipRect); |
| 214 clipRect); | |
| 215 clipRects->setFixedClipRect(clipRect); | 194 clipRects->setFixedClipRect(clipRect); |
| 216 #ifdef CHECK_CLIP_RECTS | 195 #ifdef CHECK_CLIP_RECTS |
| 217 CHECK(hasClip || clipRects->fixedClipRect() == oldClipRects.fixedClipRect()) | 196 CHECK(clipRects->fixedClipRect() == oldClipRects.fixedClipRect()) |
| 218 << " fixed=" << clipRects->fixedClipRect().toString(); | 197 << " fixed=" << clipRects->fixedClipRect().toString(); |
| 219 #endif | 198 #endif |
| 220 | 199 |
| 221 computeClipRectForContext(context.treeBuilderContext->absolutePosition, | 200 computeClipRectForContext(context.treeBuilderContext->absolutePosition, |
| 222 effect, ancestorState, ancestorPaintOffset, hasClip, | 201 effect, ancestorState, ancestorPaintOffset, |
| 223 clipRect); | 202 clipRect); |
| 224 clipRects->setPosClipRect(clipRect); | 203 clipRects->setPosClipRect(clipRect); |
| 225 #ifdef CHECK_CLIP_RECTS | 204 #ifdef CHECK_CLIP_RECTS |
| 226 CHECK(!hasClip || clipRects->posClipRect() == oldClipRects.posClipRect()) | 205 CHECK(clipRects->posClipRect() == oldClipRects.posClipRect()) |
| 227 << " abs=" << clipRects->posClipRect().toString(); | 206 << " abs=" << clipRects->posClipRect().toString(); |
| 228 #endif | 207 #endif |
| 229 | 208 |
| 230 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); | 209 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); |
| 231 | 210 |
| 232 if (!previousClipRects || *clipRects != *previousClipRects) { | 211 if (!previousClipRects || *clipRects != *previousClipRects) { |
| 233 paintLayer.setNeedsRepaint(); | 212 paintLayer.setNeedsRepaint(); |
| 234 paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false); | 213 paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false); |
| 235 paintLayer.setPreviousPaintPhaseFloatEmpty(false); | 214 paintLayer.setPreviousPaintPhaseFloatEmpty(false); |
| 236 paintLayer.setPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); | 215 paintLayer.setPreviousPaintPhaseDescendantBlockBackgroundsEmpty(false); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } | 294 } |
| 316 walk(*toFrameView(frameViewBase), context); | 295 walk(*toFrameView(frameViewBase), context); |
| 317 } | 296 } |
| 318 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). | 297 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |
| 319 } | 298 } |
| 320 | 299 |
| 321 object.getMutableForPainting().clearPaintFlags(); | 300 object.getMutableForPainting().clearPaintFlags(); |
| 322 } | 301 } |
| 323 | 302 |
| 324 } // namespace blink | 303 } // namespace blink |
| OLD | NEW |