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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 // Returns whether |a| is an ancestor of or equal to |b|. | 108 // Returns whether |a| is an ancestor of or equal to |b|. |
109 static bool isAncestorOfOrEqualTo(const ClipPaintPropertyNode* a, | 109 static bool isAncestorOfOrEqualTo(const ClipPaintPropertyNode* a, |
110 const ClipPaintPropertyNode* b) { | 110 const ClipPaintPropertyNode* b) { |
111 while (b && b != a) { | 111 while (b && b != a) { |
112 b = b->parent(); | 112 b = b->parent(); |
113 } | 113 } |
114 return b == a; | 114 return b == a; |
115 } | 115 } |
116 | 116 |
117 void PrePaintTreeWalk::computeClipRectForContext( | 117 FloatClipRect PrePaintTreeWalk::clipRectForContext( |
118 const PaintPropertyTreeBuilderContext::ContainingBlockContext& context, | 118 const PaintPropertyTreeBuilderContext::ContainingBlockContext& context, |
119 const EffectPaintPropertyNode* effect, | 119 const EffectPaintPropertyNode* effect, |
120 const PropertyTreeState& ancestorState, | 120 const PropertyTreeState& ancestorState, |
121 const LayoutPoint& ancestorPaintOffset, | 121 const LayoutPoint& ancestorPaintOffset, |
122 bool& hasClip, | 122 bool& hasClip) { |
123 FloatClipRect& clipRect) { | |
124 // Only return a non-infinite clip if clips differ, or the "ancestor" state is | 123 // Only return a non-infinite clip if clips differ, or the "ancestor" state is |
125 // actually an ancestor clip. This ensures no accuracy issues due to | 124 // actually an ancestor clip. This ensures no accuracy issues due to |
126 // transforms applied to infinite rects. | 125 // transforms applied to infinite rects. |
127 if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip())) | 126 if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip())) |
128 clipRect = FloatClipRect(); | 127 return FloatClipRect(); |
129 | 128 |
130 hasClip = true; | 129 hasClip = true; |
| 130 |
131 PropertyTreeState localState(context.transform, context.clip, effect); | 131 PropertyTreeState localState(context.transform, context.clip, effect); |
132 | 132 |
133 clipRect = | 133 FloatClipRect rect( |
134 m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState); | 134 m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState)); |
135 clipRect.moveBy(-FloatPoint(ancestorPaintOffset)); | 135 |
| 136 rect.moveBy(-FloatPoint(ancestorPaintOffset)); |
| 137 return rect; |
136 } | 138 } |
137 | 139 |
138 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( | 140 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( |
139 const LayoutObject& object, | 141 const LayoutObject& object, |
140 PrePaintTreeWalkContext& context) { | 142 PrePaintTreeWalkContext& context) { |
141 if (!object.hasLayer()) | 143 if (!object.hasLayer()) |
142 return; | 144 return; |
143 | 145 |
144 PaintLayer& paintLayer = *toLayoutBoxModelObject(object).layer(); | 146 PaintLayer& paintLayer = *toLayoutBoxModelObject(object).layer(); |
145 if (object.styleRef().hasTransform() || | 147 if (object.styleRef().hasTransform() || |
(...skipping 25 matching lines...) Expand all Loading... |
171 ClipRects& oldClipRects = | 173 ClipRects& oldClipRects = |
172 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) | 174 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) |
173 .paintingClipRects(&ancestorTransformedOrRootPaintLayer, | 175 .paintingClipRects(&ancestorTransformedOrRootPaintLayer, |
174 respectOverflowClip, LayoutSize()); | 176 respectOverflowClip, LayoutSize()); |
175 #endif | 177 #endif |
176 | 178 |
177 bool hasClip = false; | 179 bool hasClip = false; |
178 RefPtr<ClipRects> clipRects = ClipRects::create(); | 180 RefPtr<ClipRects> clipRects = ClipRects::create(); |
179 const LayoutPoint& ancestorPaintOffset = | 181 const LayoutPoint& ancestorPaintOffset = |
180 context.ancestorTransformedOrRootPaintLayer->layoutObject().paintOffset(); | 182 context.ancestorTransformedOrRootPaintLayer->layoutObject().paintOffset(); |
181 | 183 clipRects->setOverflowClipRect( |
182 FloatClipRect clipRect; | 184 clipRectForContext(context.treeBuilderContext.current, effect, |
183 computeClipRectForContext(context.treeBuilderContext.current, effect, | 185 ancestorState, ancestorPaintOffset, hasClip)); |
184 ancestorState, ancestorPaintOffset, hasClip, | |
185 clipRect); | |
186 clipRects->setOverflowClipRect(clipRect); | |
187 #ifdef CHECK_CLIP_RECTS | 186 #ifdef CHECK_CLIP_RECTS |
188 CHECK(!hasClip || | 187 CHECK(!hasClip || |
189 clipRects->overflowClipRect() == oldClipRects.overflowClipRect()) | 188 clipRects->overflowClipRect() == oldClipRects.overflowClipRect()) |
190 << "rect= " << clipRects->overflowClipRect().toString(); | 189 << "rect= " << clipRects->overflowClipRect().toString(); |
191 #endif | 190 #endif |
192 | 191 |
193 computeClipRectForContext(context.treeBuilderContext.fixedPosition, effect, | 192 clipRects->setFixedClipRect( |
194 ancestorState, ancestorPaintOffset, hasClip, | 193 clipRectForContext(context.treeBuilderContext.fixedPosition, effect, |
195 clipRect); | 194 ancestorState, ancestorPaintOffset, hasClip)); |
196 clipRects->setFixedClipRect(clipRect); | |
197 #ifdef CHECK_CLIP_RECTS | 195 #ifdef CHECK_CLIP_RECTS |
198 CHECK(hasClip || clipRects->fixedClipRect() == oldClipRects.fixedClipRect()) | 196 CHECK(hasClip || clipRects->fixedClipRect() == oldClipRects.fixedClipRect()) |
199 << " fixed=" << clipRects->fixedClipRect().toString(); | 197 << " fixed=" << clipRects->fixedClipRect().toString(); |
200 #endif | 198 #endif |
201 | 199 |
202 computeClipRectForContext(context.treeBuilderContext.absolutePosition, effect, | 200 clipRects->setPosClipRect( |
203 ancestorState, ancestorPaintOffset, hasClip, | 201 clipRectForContext(context.treeBuilderContext.absolutePosition, effect, |
204 clipRect); | 202 ancestorState, ancestorPaintOffset, hasClip)); |
205 clipRects->setPosClipRect(clipRect); | |
206 #ifdef CHECK_CLIP_RECTS | 203 #ifdef CHECK_CLIP_RECTS |
207 CHECK(!hasClip || clipRects->posClipRect() == oldClipRects.posClipRect()) | 204 CHECK(!hasClip || clipRects->posClipRect() == oldClipRects.posClipRect()) |
208 << " abs=" << clipRects->posClipRect().toString(); | 205 << " abs=" << clipRects->posClipRect().toString(); |
209 #endif | 206 #endif |
210 | 207 |
211 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); | 208 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); |
212 | 209 |
213 if (!previousClipRects || *clipRects != *previousClipRects) { | 210 if (!previousClipRects || *clipRects != *previousClipRects) { |
214 paintLayer.setNeedsRepaint(); | 211 paintLayer.setNeedsRepaint(); |
215 paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false); | 212 paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 roundedIntPoint(context->treeBuilderContext.current.paintOffset); | 277 roundedIntPoint(context->treeBuilderContext.current.paintOffset); |
281 walk(*toFrameView(frameViewBase), *context); | 278 walk(*toFrameView(frameViewBase), *context); |
282 } | 279 } |
283 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). | 280 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |
284 } | 281 } |
285 | 282 |
286 object.getMutableForPainting().clearPaintFlags(); | 283 object.getMutableForPainting().clearPaintFlags(); |
287 } | 284 } |
288 | 285 |
289 } // namespace blink | 286 } // namespace blink |
OLD | NEW |