OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 3 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
4 * | 4 * |
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
6 * | 6 * |
7 * Other contributors: | 7 * Other contributors: |
8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
10 * Christian Biesinger <cbiesinger@web.de> | 10 * Christian Biesinger <cbiesinger@web.de> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // FIXME: remove this once the compositing query ASSERTS are no longer hit. | 83 // FIXME: remove this once the compositing query ASSERTS are no longer hit. |
84 class CORE_EXPORT DisableCompositingQueryAsserts { | 84 class CORE_EXPORT DisableCompositingQueryAsserts { |
85 STACK_ALLOCATED(); | 85 STACK_ALLOCATED(); |
86 WTF_MAKE_NONCOPYABLE(DisableCompositingQueryAsserts); | 86 WTF_MAKE_NONCOPYABLE(DisableCompositingQueryAsserts); |
87 public: | 87 public: |
88 DisableCompositingQueryAsserts(); | 88 DisableCompositingQueryAsserts(); |
89 private: | 89 private: |
90 TemporaryChange<CompositingQueryMode> m_disabler; | 90 TemporaryChange<CompositingQueryMode> m_disabler; |
91 }; | 91 }; |
92 | 92 |
| 93 struct PaintLayerRareData { |
| 94 PaintLayerRareData(); |
| 95 ~PaintLayerRareData(); |
| 96 |
| 97 // Our current relative position offset. |
| 98 LayoutSize offsetForInFlowPosition; |
| 99 |
| 100 OwnPtr<TransformationMatrix> transform; |
| 101 |
| 102 // Pointer to the enclosing Layer that caused us to be paginated. It is 0 if
we are not paginated. |
| 103 // |
| 104 // See LayoutMultiColumnFlowThread and |
| 105 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/m
ulti-column-layout |
| 106 // for more information about the multicol implementation. It's important to
understand the |
| 107 // difference between flow thread coordinates and visual coordinates when wo
rking with multicol |
| 108 // in Layer, since Layer is one of the few places where we have to worry abo
ut the |
| 109 // visual ones. Internally we try to use flow-thread coordinates whenever po
ssible. |
| 110 PaintLayer* enclosingPaginationLayer; |
| 111 |
| 112 // These compositing reasons are updated whenever style changes, not while u
pdating compositing layers. |
| 113 // They should not be used to infer the compositing state of this layer. |
| 114 CompositingReasons potentialCompositingReasonsFromStyle; |
| 115 |
| 116 // Once computed, indicates all that a layer needs to become composited usin
g the CompositingReasons enum bitfield. |
| 117 CompositingReasons compositingReasons; |
| 118 |
| 119 // If the layer paints into its own backings, this keeps track of the backin
gs. |
| 120 // It's nullptr if the layer is not composited or paints into grouped backin
g. |
| 121 OwnPtr<CompositedLayerMapping> compositedLayerMapping; |
| 122 |
| 123 // If the layer paints into grouped backing (i.e. squashed), this points to
the |
| 124 // grouped CompositedLayerMapping. It's null if the layer is not composited
or |
| 125 // paints into its own backing. |
| 126 CompositedLayerMapping* groupedMapping; |
| 127 |
| 128 IntRect blockSelectionGapsBounds; |
| 129 |
| 130 OwnPtr<PaintLayerReflectionInfo> reflectionInfo; |
| 131 |
| 132 // The accumulated subpixel offset of a composited layer's composited bounds
compared to absolute coordinates. |
| 133 LayoutSize subpixelAccumulation; |
| 134 }; |
| 135 |
93 // PaintLayer is an old object that handles lots of unrelated operations. | 136 // PaintLayer is an old object that handles lots of unrelated operations. |
94 // | 137 // |
95 // We want it to die at some point and be replaced by more focused objects, | 138 // We want it to die at some point and be replaced by more focused objects, |
96 // which would remove (or at least compartimentalize) a lot of complexity. | 139 // which would remove (or at least compartimentalize) a lot of complexity. |
97 // See the STATUS OF PAINTLAYER section below. | 140 // See the STATUS OF PAINTLAYER section below. |
98 // | 141 // |
99 // The class is central to painting and hit-testing. That's because it handles | 142 // The class is central to painting and hit-testing. That's because it handles |
100 // a lot of tasks (we included ones done by associated satellite objects for | 143 // a lot of tasks (we included ones done by associated satellite objects for |
101 // historical reasons): | 144 // historical reasons): |
102 // - Complex painting operations (opacity, clipping, filters, reflections, ...). | 145 // - Complex painting operations (opacity, clipping, filters, reflections, ...). |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // need to be moved to the appropriate LayoutObject class, probably to a rare | 197 // need to be moved to the appropriate LayoutObject class, probably to a rare |
155 // data field to avoid growing all the LayoutObjects. | 198 // data field to avoid growing all the LayoutObjects. |
156 // | 199 // |
157 // A good example of this is PaintLayerScrollableArea, which can only happen | 200 // A good example of this is PaintLayerScrollableArea, which can only happen |
158 // be instanciated for LayoutBoxes. With the current design, it's hard to know | 201 // be instanciated for LayoutBoxes. With the current design, it's hard to know |
159 // that by reading the code. | 202 // that by reading the code. |
160 class CORE_EXPORT PaintLayer : public DisplayItemClient { | 203 class CORE_EXPORT PaintLayer : public DisplayItemClient { |
161 WTF_MAKE_NONCOPYABLE(PaintLayer); | 204 WTF_MAKE_NONCOPYABLE(PaintLayer); |
162 public: | 205 public: |
163 PaintLayer(LayoutBoxModelObject*, PaintLayerType); | 206 PaintLayer(LayoutBoxModelObject*, PaintLayerType); |
164 ~PaintLayer(); | 207 ~PaintLayer() override; |
165 | 208 |
166 // DisplayItemClient methods | 209 // DisplayItemClient methods |
167 String debugName() const final; | 210 String debugName() const final; |
168 IntRect visualRect() const override; | 211 IntRect visualRect() const final; |
169 | 212 |
170 LayoutBoxModelObject* layoutObject() const { return m_layoutObject; } | 213 LayoutBoxModelObject* layoutObject() const { return m_layoutObject; } |
171 LayoutBox* layoutBox() const { return m_layoutObject && m_layoutObject->isBo
x() ? toLayoutBox(m_layoutObject) : 0; } | 214 LayoutBox* layoutBox() const { return m_layoutObject && m_layoutObject->isBo
x() ? toLayoutBox(m_layoutObject) : 0; } |
172 PaintLayer* parent() const { return m_parent; } | 215 PaintLayer* parent() const { return m_parent; } |
173 PaintLayer* previousSibling() const { return m_previous; } | 216 PaintLayer* previousSibling() const { return m_previous; } |
174 PaintLayer* nextSibling() const { return m_next; } | 217 PaintLayer* nextSibling() const { return m_next; } |
175 PaintLayer* firstChild() const { return m_first; } | 218 PaintLayer* firstChild() const { return m_first; } |
176 PaintLayer* lastChild() const { return m_last; } | 219 PaintLayer* lastChild() const { return m_last; } |
177 | 220 |
178 // TODO(wangxianzhu): Find a better name for it. 'paintContainer' might be g
ood but | 221 // TODO(wangxianzhu): Find a better name for it. 'paintContainer' might be g
ood but |
179 // we can't use it for now because it conflicts with PaintInfo::paintContain
er. | 222 // we can't use it for now because it conflicts with PaintInfo::paintContain
er. |
180 PaintLayer* compositingContainer() const; | 223 PaintLayer* compositingContainer() const; |
181 | 224 |
182 void addChild(PaintLayer* newChild, PaintLayer* beforeChild = 0); | 225 void addChild(PaintLayer* newChild, PaintLayer* beforeChild = 0); |
183 PaintLayer* removeChild(PaintLayer*); | 226 PaintLayer* removeChild(PaintLayer*); |
184 | 227 |
185 void removeOnlyThisLayer(); | 228 void removeOnlyThisLayer(); |
186 void insertOnlyThisLayer(); | 229 void insertOnlyThisLayer(); |
187 | 230 |
188 void styleChanged(StyleDifference, const ComputedStyle* oldStyle); | 231 void styleChanged(StyleDifference, const ComputedStyle* oldStyle); |
189 | 232 |
190 // FIXME: Many people call this function while it has out-of-date informatio
n. | 233 // FIXME: Many people call this function while it has out-of-date informatio
n. |
191 bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; } | 234 bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; } |
192 | 235 |
193 void setLayerType(PaintLayerType layerType) { m_layerType = layerType; } | 236 void setLayerType(PaintLayerType layerType) { m_layerType = layerType; ASSER
T(static_cast<PaintLayerType>(m_layerType) == layerType); } |
194 | 237 |
195 bool isTransparent() const { return layoutObject()->isTransparent() || layou
tObject()->style()->hasBlendMode() || layoutObject()->hasMask(); } | 238 bool isTransparent() const { return layoutObject()->isTransparent() || layou
tObject()->style()->hasBlendMode() || layoutObject()->hasMask(); } |
196 | 239 |
197 bool isReflection() const { return layoutObject()->isReplica(); } | 240 bool isReflection() const { return layoutObject()->isReplica(); } |
198 PaintLayerReflectionInfo* reflectionInfo() { return m_reflectionInfo.get();
} | 241 PaintLayerReflectionInfo* reflectionInfo() { return m_rareData ? m_rareData-
>reflectionInfo.get() : nullptr; } |
199 const PaintLayerReflectionInfo* reflectionInfo() const { return m_reflection
Info.get(); } | 242 const PaintLayerReflectionInfo* reflectionInfo() const { return const_cast<P
aintLayer*>(this)->reflectionInfo(); } |
200 | 243 |
201 const PaintLayer* root() const | 244 const PaintLayer* root() const |
202 { | 245 { |
203 const PaintLayer* curr = this; | 246 const PaintLayer* curr = this; |
204 while (curr->parent()) | 247 while (curr->parent()) |
205 curr = curr->parent(); | 248 curr = curr->parent(); |
206 return curr; | 249 return curr; |
207 } | 250 } |
208 | 251 |
209 const LayoutPoint& location() const { ASSERT(!m_needsPositionUpdate); return
m_location; } | 252 const LayoutPoint& location() const { ASSERT(!m_needsPositionUpdate); return
m_location; } |
210 // FIXME: size() should ASSERT(!m_needsPositionUpdate) as well, but that fai
ls in some tests, | 253 // FIXME: size() should ASSERT(!m_needsPositionUpdate) as well, but that fai
ls in some tests, |
211 // for example, fast/repaint/clipped-relative.html. | 254 // for example, fast/repaint/clipped-relative.html. |
212 const IntSize& size() const { return m_size; } | 255 const IntSize& size() const { return m_size; } |
213 void setSizeHackForLayoutTreeAsText(const IntSize& size) { m_size = size; } | 256 void setSizeHackForLayoutTreeAsText(const IntSize& size) { m_size = size; } |
214 | 257 |
215 LayoutRect rect() const { return LayoutRect(location(), LayoutSize(size()));
} | 258 LayoutRect rect() const { return LayoutRect(location(), LayoutSize(size()));
} |
216 | 259 |
217 bool isRootLayer() const { return m_isRootLayer; } | 260 bool isRootLayer() const { return m_isRootLayer; } |
218 | 261 |
219 PaintLayerCompositor* compositor() const; | 262 PaintLayerCompositor* compositor() const; |
220 | 263 |
221 // Notification from the layoutObject that its content changed (e.g. current
frame of image changed). | 264 // Notification from the layoutObject that its content changed (e.g. current
frame of image changed). |
222 // Allows updates of layer content without invalidating paint. | 265 // Allows updates of layer content without invalidating paint. |
223 void contentChanged(ContentChangeType); | 266 void contentChanged(ContentChangeType); |
224 | 267 |
225 void updateLayerPositionsAfterLayout(); | 268 void updateLayerPositionsAfterLayout(); |
226 void updateLayerPositionsAfterOverflowScroll(const DoubleSize& scrollDelta); | 269 void updateLayerPositionsAfterOverflowScroll(const DoubleSize& scrollDelta); |
227 | 270 |
228 PaintLayer* enclosingPaginationLayer() const { return m_enclosingPaginationL
ayer; } | 271 PaintLayer* enclosingPaginationLayer() const { return m_rareData ? m_rareDat
a->enclosingPaginationLayer : nullptr; } |
229 | 272 |
230 void updateTransformationMatrix(); | 273 void updateTransformationMatrix(); |
231 PaintLayer* renderingContextRoot(); | 274 PaintLayer* renderingContextRoot(); |
232 | 275 |
233 const LayoutSize& offsetForInFlowPosition() const { return m_offsetForInFlow
Position; } | 276 LayoutSize offsetForInFlowPosition() const { return m_rareData ? m_rareData-
>offsetForInFlowPosition : LayoutSize(); } |
234 | 277 |
235 void addBlockSelectionGapsBounds(const LayoutRect&); | 278 void addBlockSelectionGapsBounds(const LayoutRect&); |
236 void clearBlockSelectionGapsBounds(); | 279 void clearBlockSelectionGapsBounds(); |
237 void invalidatePaintForBlockSelectionGaps(); | 280 void invalidatePaintForBlockSelectionGaps(); |
238 IntRect blockSelectionGapsBounds() const; | 281 IntRect blockSelectionGapsBounds() const; |
239 bool hasBlockSelectionGapBounds() const; | 282 bool hasBlockSelectionGapBounds() const; |
240 | 283 |
241 PaintLayerStackingNode* stackingNode() { return m_stackingNode.get(); } | 284 PaintLayerStackingNode* stackingNode() { return m_stackingNode.get(); } |
242 const PaintLayerStackingNode* stackingNode() const { return m_stackingNode.g
et(); } | 285 const PaintLayerStackingNode* stackingNode() const { return m_stackingNode.g
et(); } |
243 | 286 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 LayoutUnit staticBlockPosition() const { return m_staticBlockPosition; } | 377 LayoutUnit staticBlockPosition() const { return m_staticBlockPosition; } |
335 | 378 |
336 void setStaticInlinePosition(LayoutUnit position) { m_staticInlinePosition =
position; } | 379 void setStaticInlinePosition(LayoutUnit position) { m_staticInlinePosition =
position; } |
337 void setStaticBlockPosition(LayoutUnit position) { m_staticBlockPosition = p
osition; } | 380 void setStaticBlockPosition(LayoutUnit position) { m_staticBlockPosition = p
osition; } |
338 | 381 |
339 LayoutSize subpixelAccumulation() const; | 382 LayoutSize subpixelAccumulation() const; |
340 void setSubpixelAccumulation(const LayoutSize&); | 383 void setSubpixelAccumulation(const LayoutSize&); |
341 | 384 |
342 bool hasTransformRelatedProperty() const { return layoutObject()->hasTransfo
rmRelatedProperty(); } | 385 bool hasTransformRelatedProperty() const { return layoutObject()->hasTransfo
rmRelatedProperty(); } |
343 // Note that this transform has the transform-origin baked in. | 386 // Note that this transform has the transform-origin baked in. |
344 TransformationMatrix* transform() const { return m_transform.get(); } | 387 TransformationMatrix* transform() const { return m_rareData ? m_rareData->tr
ansform.get() : nullptr; } |
345 void setTransform(PassOwnPtr<TransformationMatrix> transform) { m_transform
= transform; } | |
346 void clearTransform() { m_transform.clear(); } | |
347 | 388 |
348 // currentTransform computes a transform which takes accelerated animations
into account. The | 389 // currentTransform computes a transform which takes accelerated animations
into account. The |
349 // resulting transform has transform-origin baked in. If the layer does not
have a transform, | 390 // resulting transform has transform-origin baked in. If the layer does not
have a transform, |
350 // returns the identity matrix. | 391 // returns the identity matrix. |
351 TransformationMatrix currentTransform() const; | 392 TransformationMatrix currentTransform() const; |
352 TransformationMatrix renderableTransform(GlobalPaintFlags) const; | 393 TransformationMatrix renderableTransform(GlobalPaintFlags) const; |
353 | 394 |
354 // Get the perspective transform, which is applied to transformed sublayers. | 395 // Get the perspective transform, which is applied to transformed sublayers. |
355 // Returns true if the layer has a -webkit-perspective. | 396 // Returns true if the layer has a -webkit-perspective. |
356 // Note that this transform does not have the perspective-origin baked in. | 397 // Note that this transform does not have the perspective-origin baked in. |
357 TransformationMatrix perspectiveTransform() const; | 398 TransformationMatrix perspectiveTransform() const; |
358 FloatPoint perspectiveOrigin() const; | 399 FloatPoint perspectiveOrigin() const; |
359 bool preserves3D() const { return layoutObject()->style()->transformStyle3D(
) == TransformStyle3DPreserve3D; } | 400 bool preserves3D() const { return layoutObject()->style()->transformStyle3D(
) == TransformStyle3DPreserve3D; } |
360 bool has3DTransform() const { return m_transform && !m_transform->isAffine()
; } | 401 bool has3DTransform() const { return m_rareData && m_rareData->transform &&
!m_rareData->transform->isAffine(); } |
361 | 402 |
362 // FIXME: reflections should force transform-style to be flat in the style:
https://bugs.webkit.org/show_bug.cgi?id=106959 | 403 // FIXME: reflections should force transform-style to be flat in the style:
https://bugs.webkit.org/show_bug.cgi?id=106959 |
363 bool shouldPreserve3D() const { return !layoutObject()->hasReflection() && l
ayoutObject()->style()->transformStyle3D() == TransformStyle3DPreserve3D; } | 404 bool shouldPreserve3D() const { return !layoutObject()->hasReflection() && l
ayoutObject()->style()->transformStyle3D() == TransformStyle3DPreserve3D; } |
364 | 405 |
365 void filterNeedsPaintInvalidation(); | 406 void filterNeedsPaintInvalidation(); |
366 bool hasFilter() const { return layoutObject()->hasFilter(); } | 407 bool hasFilter() const { return layoutObject()->hasFilter(); } |
367 | 408 |
368 void* operator new(size_t); | 409 void* operator new(size_t); |
369 // Only safe to call from LayoutBoxModelObject::destroyLayer() | 410 // Only safe to call from LayoutBoxModelObject::destroyLayer() |
370 void operator delete(void*); | 411 void operator delete(void*); |
371 | 412 |
372 CompositingState compositingState() const; | 413 CompositingState compositingState() const; |
373 | 414 |
374 // This returns true if our document is in a phase of its lifestyle during w
hich | 415 // This returns true if our document is in a phase of its lifestyle during w
hich |
375 // compositing state may legally be read. | 416 // compositing state may legally be read. |
376 bool isAllowedToQueryCompositingState() const; | 417 bool isAllowedToQueryCompositingState() const; |
377 | 418 |
378 // Don't null check this. | 419 // Don't null check this. |
379 // FIXME: Rename. | 420 // FIXME: Rename. |
380 CompositedLayerMapping* compositedLayerMapping() const; | 421 CompositedLayerMapping* compositedLayerMapping() const; |
381 GraphicsLayer* graphicsLayerBacking() const; | 422 GraphicsLayer* graphicsLayerBacking() const; |
382 GraphicsLayer* graphicsLayerBackingForScrolling() const; | 423 GraphicsLayer* graphicsLayerBackingForScrolling() const; |
383 // NOTE: If you are using hasCompositedLayerMapping to determine the state o
f compositing for this layer, | 424 // NOTE: If you are using hasCompositedLayerMapping to determine the state o
f compositing for this layer, |
384 // (and not just to do bookkeeping related to the mapping like, say, allocat
ing or deallocating a mapping), | 425 // (and not just to do bookkeeping related to the mapping like, say, allocat
ing or deallocating a mapping), |
385 // then you may have incorrect logic. Use compositingState() instead. | 426 // then you may have incorrect logic. Use compositingState() instead. |
386 // FIXME: This is identical to null checking compositedLayerMapping(), why n
ot just call that? | 427 // FIXME: This is identical to null checking compositedLayerMapping(), why n
ot just call that? |
387 bool hasCompositedLayerMapping() const { return m_compositedLayerMapping.get
(); } | 428 bool hasCompositedLayerMapping() const { return m_rareData && m_rareData->co
mpositedLayerMapping; } |
388 void ensureCompositedLayerMapping(); | 429 void ensureCompositedLayerMapping(); |
389 void clearCompositedLayerMapping(bool layerBeingDestroyed = false); | 430 void clearCompositedLayerMapping(bool layerBeingDestroyed = false); |
390 CompositedLayerMapping* groupedMapping() const { return m_groupedMapping; } | 431 CompositedLayerMapping* groupedMapping() const { return m_rareData ? m_rareD
ata->groupedMapping : nullptr; } |
391 enum SetGroupMappingOptions { | 432 enum SetGroupMappingOptions { |
392 InvalidateLayerAndRemoveFromMapping, | 433 InvalidateLayerAndRemoveFromMapping, |
393 DoNotInvalidateLayerAndRemoveFromMapping | 434 DoNotInvalidateLayerAndRemoveFromMapping |
394 }; | 435 }; |
395 void setGroupedMapping(CompositedLayerMapping*, SetGroupMappingOptions); | 436 void setGroupedMapping(CompositedLayerMapping*, SetGroupMappingOptions); |
396 | 437 |
397 bool hasCompositedMask() const; | 438 bool hasCompositedMask() const; |
398 bool hasCompositedClippingMask() const; | 439 bool hasCompositedClippingMask() const; |
399 bool needsCompositedScrolling() const { return m_scrollableArea && m_scrolla
bleArea->needsCompositedScrolling(); } | 440 bool needsCompositedScrolling() const { return m_scrollableArea && m_scrolla
bleArea->needsCompositedScrolling(); } |
400 | 441 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 // Compute rects only for this layer | 500 // Compute rects only for this layer |
460 void computeSelfHitTestRects(LayerHitTestRects&) const; | 501 void computeSelfHitTestRects(LayerHitTestRects&) const; |
461 | 502 |
462 // FIXME: This should probably return a ScrollableArea but a lot of internal
methods are mistakenly exposed. | 503 // FIXME: This should probably return a ScrollableArea but a lot of internal
methods are mistakenly exposed. |
463 PaintLayerScrollableArea* scrollableArea() const { return m_scrollableArea.g
et(); } | 504 PaintLayerScrollableArea* scrollableArea() const { return m_scrollableArea.g
et(); } |
464 PaintLayerClipper& clipper() { return m_clipper; } | 505 PaintLayerClipper& clipper() { return m_clipper; } |
465 const PaintLayerClipper& clipper() const { return m_clipper; } | 506 const PaintLayerClipper& clipper() const { return m_clipper; } |
466 | 507 |
467 bool scrollsOverflow() const; | 508 bool scrollsOverflow() const; |
468 | 509 |
469 CompositingReasons potentialCompositingReasonsFromStyle() const { return m_p
otentialCompositingReasonsFromStyle; } | 510 CompositingReasons potentialCompositingReasonsFromStyle() const { return m_r
areData ? m_rareData->potentialCompositingReasonsFromStyle : CompositingReasonNo
ne; } |
470 void setPotentialCompositingReasonsFromStyle(CompositingReasons reasons) { A
SSERT(reasons == (reasons & CompositingReasonComboAllStyleDeterminedReasons)); m
_potentialCompositingReasonsFromStyle = reasons; } | 511 void setPotentialCompositingReasonsFromStyle(CompositingReasons reasons) |
| 512 { |
| 513 ASSERT(reasons == (reasons & CompositingReasonComboAllStyleDeterminedRea
sons)); |
| 514 if (m_rareData || reasons != CompositingReasonNone) |
| 515 ensureRareData().potentialCompositingReasonsFromStyle = reasons; |
| 516 } |
471 | 517 |
472 bool hasStyleDeterminedDirectCompositingReasons() const { return m_potential
CompositingReasonsFromStyle & CompositingReasonComboAllDirectStyleDeterminedReas
ons; } | 518 bool hasStyleDeterminedDirectCompositingReasons() const { return potentialCo
mpositingReasonsFromStyle() & CompositingReasonComboAllDirectStyleDeterminedReas
ons; } |
473 | 519 |
474 class AncestorDependentCompositingInputs { | 520 class AncestorDependentCompositingInputs { |
475 DISALLOW_NEW(); | 521 DISALLOW_NEW(); |
476 public: | 522 public: |
477 AncestorDependentCompositingInputs() | 523 AncestorDependentCompositingInputs() |
478 : opacityAncestor(0) | 524 : clippingContainer(nullptr) |
479 , transformAncestor(0) | |
480 , filterAncestor(0) | |
481 , clippingContainer(0) | |
482 , ancestorScrollingLayer(0) | |
483 , nearestFixedPositionLayer(0) | |
484 , scrollParent(0) | |
485 , clipParent(0) | |
486 , hasAncestorWithClipPath(false) | |
487 { } | 525 { } |
488 | 526 |
489 IntRect clippedAbsoluteBoundingBox; | 527 IntRect clippedAbsoluteBoundingBox; |
| 528 const LayoutObject* clippingContainer; |
| 529 }; |
| 530 |
| 531 class RareAncestorDependentCompositingInputs { |
| 532 public: |
| 533 RareAncestorDependentCompositingInputs() |
| 534 : opacityAncestor(nullptr) |
| 535 , transformAncestor(nullptr) |
| 536 , filterAncestor(nullptr) |
| 537 , ancestorScrollingLayer(nullptr) |
| 538 , nearestFixedPositionLayer(nullptr) |
| 539 , scrollParent(nullptr) |
| 540 , clipParent(nullptr) |
| 541 { } |
| 542 |
| 543 bool isDefault() const { return !opacityAncestor && !transformAncestor &
& !filterAncestor && !ancestorScrollingLayer && !nearestFixedPositionLayer && !s
crollParent && !clipParent; } |
| 544 |
490 const PaintLayer* opacityAncestor; | 545 const PaintLayer* opacityAncestor; |
491 const PaintLayer* transformAncestor; | 546 const PaintLayer* transformAncestor; |
492 const PaintLayer* filterAncestor; | 547 const PaintLayer* filterAncestor; |
493 const LayoutObject* clippingContainer; | |
494 const PaintLayer* ancestorScrollingLayer; | 548 const PaintLayer* ancestorScrollingLayer; |
495 const PaintLayer* nearestFixedPositionLayer; | 549 const PaintLayer* nearestFixedPositionLayer; |
496 | 550 |
497 // A scroll parent is a compositor concept. It's only needed in blink | 551 // A scroll parent is a compositor concept. It's only needed in blink |
498 // because we need to use it as a promotion trigger. A layer has a | 552 // because we need to use it as a promotion trigger. A layer has a |
499 // scroll parent if neither its compositor scrolling ancestor, nor any | 553 // scroll parent if neither its compositor scrolling ancestor, nor any |
500 // other layer scrolled by this ancestor, is a stacking ancestor of this | 554 // other layer scrolled by this ancestor, is a stacking ancestor of this |
501 // layer. Layers with scroll parents must be scrolled with the main | 555 // layer. Layers with scroll parents must be scrolled with the main |
502 // scrolling layer by the compositor. | 556 // scrolling layer by the compositor. |
503 const PaintLayer* scrollParent; | 557 const PaintLayer* scrollParent; |
504 | 558 |
505 // A clip parent is another compositor concept that has leaked into | 559 // A clip parent is another compositor concept that has leaked into |
506 // blink so that it may be used as a promotion trigger. Layers with clip | 560 // blink so that it may be used as a promotion trigger. Layers with clip |
507 // parents escape the clip of a stacking tree ancestor. The compositor | 561 // parents escape the clip of a stacking tree ancestor. The compositor |
508 // needs to know about clip parents in order to circumvent its normal | 562 // needs to know about clip parents in order to circumvent its normal |
509 // clipping logic. | 563 // clipping logic. |
510 const PaintLayer* clipParent; | 564 const PaintLayer* clipParent; |
511 | |
512 unsigned hasAncestorWithClipPath : 1; | |
513 }; | |
514 | |
515 class DescendantDependentCompositingInputs { | |
516 DISALLOW_NEW(); | |
517 public: | |
518 DescendantDependentCompositingInputs() | |
519 : hasDescendantWithClipPath(false) | |
520 , hasNonIsolatedDescendantWithBlendMode(false) | |
521 { } | |
522 | |
523 unsigned hasDescendantWithClipPath : 1; | |
524 unsigned hasNonIsolatedDescendantWithBlendMode : 1; | |
525 }; | 565 }; |
526 | 566 |
527 void setNeedsCompositingInputsUpdate(); | 567 void setNeedsCompositingInputsUpdate(); |
528 bool childNeedsCompositingInputsUpdate() const { return m_childNeedsComposit
ingInputsUpdate; } | 568 bool childNeedsCompositingInputsUpdate() const { return m_childNeedsComposit
ingInputsUpdate; } |
529 bool needsCompositingInputsUpdate() const | 569 bool needsCompositingInputsUpdate() const |
530 { | 570 { |
531 // While we're updating the compositing inputs, these values may differ. | 571 // While we're updating the compositing inputs, these values may differ. |
532 // We should never be asking for this value when that is the case. | 572 // We should never be asking for this value when that is the case. |
533 ASSERT(m_needsDescendantDependentCompositingInputsUpdate == m_needsAnces
torDependentCompositingInputsUpdate); | 573 ASSERT(m_needsDescendantDependentCompositingInputsUpdate == m_needsAnces
torDependentCompositingInputsUpdate); |
534 return m_needsDescendantDependentCompositingInputsUpdate; | 574 return m_needsDescendantDependentCompositingInputsUpdate; |
535 } | 575 } |
536 | 576 |
537 void updateAncestorDependentCompositingInputs(const AncestorDependentComposi
tingInputs&); | 577 void updateAncestorDependentCompositingInputs(const AncestorDependentComposi
tingInputs&, const RareAncestorDependentCompositingInputs&, bool hasAncestorWith
ClipPath); |
538 void updateDescendantDependentCompositingInputs(const DescendantDependentCom
positingInputs&); | 578 void updateDescendantDependentCompositingInputs(bool hasDescendantWithClipPa
th, bool hasNonIsolatedDescendantWithBlendMode); |
539 void didUpdateCompositingInputs(); | 579 void didUpdateCompositingInputs(); |
540 | 580 |
541 const AncestorDependentCompositingInputs& ancestorDependentCompositingInputs
() const { ASSERT(!m_needsAncestorDependentCompositingInputsUpdate); return m_an
cestorDependentCompositingInputs; } | 581 IntRect clippedAbsoluteBoundingBox() const { ASSERT(!m_needsAncestorDependen
tCompositingInputsUpdate); return m_ancestorDependentCompositingInputs.clippedAb
soluteBoundingBox; } |
542 const DescendantDependentCompositingInputs& descendantDependentCompositingIn
puts() const { ASSERT(!m_needsDescendantDependentCompositingInputsUpdate); retur
n m_descendantDependentCompositingInputs; } | 582 const PaintLayer* opacityAncestor() const { ASSERT(!m_needsAncestorDependent
CompositingInputsUpdate); return m_rareAncestorDependentCompositingInputs ? m_ra
reAncestorDependentCompositingInputs->opacityAncestor : nullptr; } |
543 | 583 const PaintLayer* transformAncestor() const { ASSERT(!m_needsAncestorDepende
ntCompositingInputsUpdate); return m_rareAncestorDependentCompositingInputs ? m_
rareAncestorDependentCompositingInputs->transformAncestor : nullptr; } |
544 IntRect clippedAbsoluteBoundingBox() const { return ancestorDependentComposi
tingInputs().clippedAbsoluteBoundingBox; } | 584 const PaintLayer* filterAncestor() const { ASSERT(!m_needsAncestorDependentC
ompositingInputsUpdate); return m_rareAncestorDependentCompositingInputs ? m_rar
eAncestorDependentCompositingInputs->filterAncestor : nullptr; } |
545 const PaintLayer* opacityAncestor() const { return ancestorDependentComposit
ingInputs().opacityAncestor; } | 585 const LayoutObject* clippingContainer() const { ASSERT(!m_needsAncestorDepen
dentCompositingInputsUpdate); return m_ancestorDependentCompositingInputs.clippi
ngContainer; } |
546 const PaintLayer* transformAncestor() const { return ancestorDependentCompos
itingInputs().transformAncestor; } | 586 const PaintLayer* ancestorScrollingLayer() const { ASSERT(!m_needsAncestorDe
pendentCompositingInputsUpdate); return m_rareAncestorDependentCompositingInputs
? m_rareAncestorDependentCompositingInputs->ancestorScrollingLayer : nullptr; } |
547 const PaintLayer* filterAncestor() const { return ancestorDependentCompositi
ngInputs().filterAncestor; } | 587 const PaintLayer* nearestFixedPositionLayer() const { ASSERT(!m_needsAncesto
rDependentCompositingInputsUpdate); return m_rareAncestorDependentCompositingInp
uts ? m_rareAncestorDependentCompositingInputs->nearestFixedPositionLayer : null
ptr; } |
548 const LayoutObject* clippingContainer() const { return ancestorDependentComp
ositingInputs().clippingContainer; } | 588 const PaintLayer* scrollParent() const { ASSERT(!m_needsAncestorDependentCom
positingInputsUpdate); return m_rareAncestorDependentCompositingInputs ? m_rareA
ncestorDependentCompositingInputs->scrollParent : nullptr; } |
549 const PaintLayer* ancestorScrollingLayer() const { return ancestorDependentC
ompositingInputs().ancestorScrollingLayer; } | 589 const PaintLayer* clipParent() const { ASSERT(!m_needsAncestorDependentCompo
sitingInputsUpdate); return m_rareAncestorDependentCompositingInputs ? m_rareAnc
estorDependentCompositingInputs->clipParent : nullptr; } |
550 const PaintLayer* nearestFixedPositionLayer() const { return ancestorDepende
ntCompositingInputs().nearestFixedPositionLayer; } | 590 bool hasAncestorWithClipPath() const { ASSERT(!m_needsAncestorDependentCompo
sitingInputsUpdate); return m_hasAncestorWithClipPath; } |
551 PaintLayer* scrollParent() const { return const_cast<PaintLayer*>(ancestorDe
pendentCompositingInputs().scrollParent); } | 591 bool hasDescendantWithClipPath() const { ASSERT(!m_needsDescendantDependentC
ompositingInputsUpdate); return m_hasDescendantWithClipPath; } |
552 PaintLayer* clipParent() const { return const_cast<PaintLayer*>(ancestorDepe
ndentCompositingInputs().clipParent); } | |
553 bool hasAncestorWithClipPath() const { return ancestorDependentCompositingIn
puts().hasAncestorWithClipPath; } | |
554 bool hasDescendantWithClipPath() const { return descendantDependentCompositi
ngInputs().hasDescendantWithClipPath; } | |
555 bool hasNonIsolatedDescendantWithBlendMode() const; | 592 bool hasNonIsolatedDescendantWithBlendMode() const; |
556 | 593 |
557 bool lostGroupedMapping() const { ASSERT(isAllowedToQueryCompositingState())
; return m_lostGroupedMapping; } | 594 bool lostGroupedMapping() const { ASSERT(isAllowedToQueryCompositingState())
; return m_lostGroupedMapping; } |
558 void setLostGroupedMapping(bool b) { m_lostGroupedMapping = b; } | 595 void setLostGroupedMapping(bool b) { m_lostGroupedMapping = b; } |
559 | 596 |
560 CompositingReasons compositingReasons() const { ASSERT(isAllowedToQueryCompo
sitingState()); return m_compositingReasons; } | 597 CompositingReasons compositingReasons() const { ASSERT(isAllowedToQueryCompo
sitingState()); return m_rareData ? m_rareData->compositingReasons : Compositing
ReasonNone; } |
561 void setCompositingReasons(CompositingReasons, CompositingReasons mask = Com
positingReasonAll); | 598 void setCompositingReasons(CompositingReasons, CompositingReasons mask = Com
positingReasonAll); |
562 | 599 |
563 bool hasCompositingDescendant() const { ASSERT(isAllowedToQueryCompositingSt
ate()); return m_hasCompositingDescendant; } | 600 bool hasCompositingDescendant() const { ASSERT(isAllowedToQueryCompositingSt
ate()); return m_hasCompositingDescendant; } |
564 void setHasCompositingDescendant(bool); | 601 void setHasCompositingDescendant(bool); |
565 | 602 |
566 bool shouldIsolateCompositedDescendants() const { ASSERT(isAllowedToQueryCom
positingState()); return m_shouldIsolateCompositedDescendants; } | 603 bool shouldIsolateCompositedDescendants() const { ASSERT(isAllowedToQueryCom
positingState()); return m_shouldIsolateCompositedDescendants; } |
567 void setShouldIsolateCompositedDescendants(bool); | 604 void setShouldIsolateCompositedDescendants(bool); |
568 | 605 |
569 void updateDescendantDependentFlags(); | 606 void updateDescendantDependentFlags(); |
570 | 607 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 743 |
707 void updateOrRemoveFilterClients(); | 744 void updateOrRemoveFilterClients(); |
708 | 745 |
709 void updatePaginationRecursive(bool needsPaginationUpdate = false); | 746 void updatePaginationRecursive(bool needsPaginationUpdate = false); |
710 void clearPaginationRecursive(); | 747 void clearPaginationRecursive(); |
711 | 748 |
712 void blockSelectionGapsBoundsChanged(); | 749 void blockSelectionGapsBoundsChanged(); |
713 | 750 |
714 void markCompositingContainerChainForNeedsRepaint(); | 751 void markCompositingContainerChainForNeedsRepaint(); |
715 | 752 |
716 PaintLayerType m_layerType; | 753 PaintLayerRareData& ensureRareData() |
| 754 { |
| 755 if (!m_rareData) |
| 756 m_rareData = adoptPtr(new PaintLayerRareData); |
| 757 return *m_rareData; |
| 758 } |
| 759 |
| 760 unsigned m_layerType : 2; // PaintLayerType |
717 | 761 |
718 // Self-painting layer is an optimization where we avoid the heavy Layer pai
nting | 762 // Self-painting layer is an optimization where we avoid the heavy Layer pai
nting |
719 // machinery for a Layer allocated only to handle the overflow clip case. | 763 // machinery for a Layer allocated only to handle the overflow clip case. |
720 // FIXME(crbug.com/332791): Self-painting layer should be merged into the ov
erflow-only concept. | 764 // FIXME(crbug.com/332791): Self-painting layer should be merged into the ov
erflow-only concept. |
721 unsigned m_isSelfPaintingLayer : 1; | 765 unsigned m_isSelfPaintingLayer : 1; |
722 | 766 |
723 // If have no self-painting descendants, we don't have to walk our children
during painting. This can lead to | 767 // If have no self-painting descendants, we don't have to walk our children
during painting. This can lead to |
724 // significant savings, especially if the tree has lots of non-self-painting
layers grouped together (e.g. table cells). | 768 // significant savings, especially if the tree has lots of non-self-painting
layers grouped together (e.g. table cells). |
725 mutable unsigned m_hasSelfPaintingLayerDescendant : 1; | 769 mutable unsigned m_hasSelfPaintingLayerDescendant : 1; |
726 mutable unsigned m_hasSelfPaintingLayerDescendantDirty : 1; | 770 mutable unsigned m_hasSelfPaintingLayerDescendantDirty : 1; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 // True if this layout layer just lost its grouped mapping due to the Compos
itedLayerMapping being destroyed, | 807 // True if this layout layer just lost its grouped mapping due to the Compos
itedLayerMapping being destroyed, |
764 // and we don't yet know to what graphics layer this Layer will be assigned. | 808 // and we don't yet know to what graphics layer this Layer will be assigned. |
765 unsigned m_lostGroupedMapping : 1; | 809 unsigned m_lostGroupedMapping : 1; |
766 | 810 |
767 unsigned m_needsRepaint : 1; | 811 unsigned m_needsRepaint : 1; |
768 unsigned m_previousPaintResult : 1; // PaintLayerPainter::PaintResult | 812 unsigned m_previousPaintResult : 1; // PaintLayerPainter::PaintResult |
769 | 813 |
770 unsigned m_needsPaintPhaseDescendantOutlines : 1; | 814 unsigned m_needsPaintPhaseDescendantOutlines : 1; |
771 unsigned m_needsPaintPhaseFloat : 1; | 815 unsigned m_needsPaintPhaseFloat : 1; |
772 | 816 |
| 817 // These bitfields are part of ancestor/descendant dependent compositing inp
uts. |
| 818 unsigned m_hasDescendantWithClipPath : 1; |
| 819 unsigned m_hasNonIsolatedDescendantWithBlendMode : 1; |
| 820 unsigned m_hasAncestorWithClipPath : 1; |
| 821 |
773 LayoutBoxModelObject* m_layoutObject; | 822 LayoutBoxModelObject* m_layoutObject; |
774 | 823 |
775 PaintLayer* m_parent; | 824 PaintLayer* m_parent; |
776 PaintLayer* m_previous; | 825 PaintLayer* m_previous; |
777 PaintLayer* m_next; | 826 PaintLayer* m_next; |
778 PaintLayer* m_first; | 827 PaintLayer* m_first; |
779 PaintLayer* m_last; | 828 PaintLayer* m_last; |
780 | 829 |
781 // Our current relative position offset. | |
782 LayoutSize m_offsetForInFlowPosition; | |
783 | |
784 // Our (x,y) coordinates are in our parent layer's coordinate space. | 830 // Our (x,y) coordinates are in our parent layer's coordinate space. |
785 LayoutPoint m_location; | 831 LayoutPoint m_location; |
786 | 832 |
787 // The layer's size. | 833 // The layer's size. |
788 // | 834 // |
789 // If the associated LayoutBoxModelObject is a LayoutBox, it's its border | 835 // If the associated LayoutBoxModelObject is a LayoutBox, it's its border |
790 // box. Otherwise, this is the LayoutInline's lines' bounding box. | 836 // box. Otherwise, this is the LayoutInline's lines' bounding box. |
791 IntSize m_size; | 837 IntSize m_size; |
792 | 838 |
793 // Cached normal flow values for absolute positioned elements with static le
ft/top values. | 839 // Cached normal flow values for absolute positioned elements with static le
ft/top values. |
794 LayoutUnit m_staticInlinePosition; | 840 LayoutUnit m_staticInlinePosition; |
795 LayoutUnit m_staticBlockPosition; | 841 LayoutUnit m_staticBlockPosition; |
796 | 842 |
797 OwnPtr<TransformationMatrix> m_transform; | 843 AncestorDependentCompositingInputs m_ancestorDependentCompositingInputs; |
| 844 OwnPtr<RareAncestorDependentCompositingInputs> m_rareAncestorDependentCompos
itingInputs; |
798 | 845 |
799 // Pointer to the enclosing Layer that caused us to be paginated. It is 0 if
we are not paginated. | |
800 // | |
801 // See LayoutMultiColumnFlowThread and | |
802 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/m
ulti-column-layout | |
803 // for more information about the multicol implementation. It's important to
understand the | |
804 // difference between flow thread coordinates and visual coordinates when wo
rking with multicol | |
805 // in Layer, since Layer is one of the few places where we have to worry abo
ut the | |
806 // visual ones. Internally we try to use flow-thread coordinates whenever po
ssible. | |
807 PaintLayer* m_enclosingPaginationLayer; | |
808 | |
809 // These compositing reasons are updated whenever style changes, not while u
pdating compositing layers. | |
810 // They should not be used to infer the compositing state of this layer. | |
811 CompositingReasons m_potentialCompositingReasonsFromStyle; | |
812 | |
813 // Once computed, indicates all that a layer needs to become composited usin
g the CompositingReasons enum bitfield. | |
814 CompositingReasons m_compositingReasons; | |
815 | |
816 DescendantDependentCompositingInputs m_descendantDependentCompositingInputs; | |
817 AncestorDependentCompositingInputs m_ancestorDependentCompositingInputs; | |
818 | |
819 IntRect m_blockSelectionGapsBounds; | |
820 | |
821 OwnPtr<CompositedLayerMapping> m_compositedLayerMapping; | |
822 OwnPtrWillBePersistent<PaintLayerScrollableArea> m_scrollableArea; | 846 OwnPtrWillBePersistent<PaintLayerScrollableArea> m_scrollableArea; |
823 | 847 |
824 CompositedLayerMapping* m_groupedMapping; | |
825 | |
826 PaintLayerClipper m_clipper; // FIXME: Lazily allocate? | 848 PaintLayerClipper m_clipper; // FIXME: Lazily allocate? |
827 OwnPtr<PaintLayerStackingNode> m_stackingNode; | 849 OwnPtr<PaintLayerStackingNode> m_stackingNode; |
828 OwnPtr<PaintLayerReflectionInfo> m_reflectionInfo; | |
829 | |
830 LayoutSize m_subpixelAccumulation; // The accumulated subpixel offset of a c
omposited layer's composited bounds compared to absolute coordinates. | |
831 | 850 |
832 IntSize m_previousScrollOffsetAccumulationForPainting; | 851 IntSize m_previousScrollOffsetAccumulationForPainting; |
833 RefPtr<ClipRects> m_previousPaintingClipRects; | 852 RefPtr<ClipRects> m_previousPaintingClipRects; |
834 LayoutRect m_previousPaintDirtyRect; | 853 LayoutRect m_previousPaintDirtyRect; |
| 854 |
| 855 OwnPtr<PaintLayerRareData> m_rareData; |
835 }; | 856 }; |
836 | 857 |
837 } // namespace blink | 858 } // namespace blink |
838 | 859 |
839 #ifndef NDEBUG | 860 #ifndef NDEBUG |
840 // Outside the WebCore namespace for ease of invocation from gdb. | 861 // Outside the WebCore namespace for ease of invocation from gdb. |
841 void showLayerTree(const blink::PaintLayer*); | 862 void showLayerTree(const blink::PaintLayer*); |
842 void showLayerTree(const blink::LayoutObject*); | 863 void showLayerTree(const blink::LayoutObject*); |
843 #endif | 864 #endif |
844 | 865 |
845 #endif // Layer_h | 866 #endif // Layer_h |
OLD | NEW |