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