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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 // need to be moved to the appropriate LayoutObject class, probably to a rare | 208 // need to be moved to the appropriate LayoutObject class, probably to a rare |
209 // data field to avoid growing all the LayoutObjects. | 209 // data field to avoid growing all the LayoutObjects. |
210 // | 210 // |
211 // A good example of this is PaintLayerScrollableArea, which can only happen | 211 // A good example of this is PaintLayerScrollableArea, which can only happen |
212 // be instanciated for LayoutBoxes. With the current design, it's hard to know | 212 // be instanciated for LayoutBoxes. With the current design, it's hard to know |
213 // that by reading the code. | 213 // that by reading the code. |
214 class CORE_EXPORT PaintLayer : public DisplayItemClient { | 214 class CORE_EXPORT PaintLayer : public DisplayItemClient { |
215 WTF_MAKE_NONCOPYABLE(PaintLayer); | 215 WTF_MAKE_NONCOPYABLE(PaintLayer); |
216 | 216 |
217 public: | 217 public: |
218 PaintLayer(LayoutBoxModelObject*); | 218 PaintLayer(LayoutBoxModelObject&); |
219 ~PaintLayer() override; | 219 ~PaintLayer() override; |
220 | 220 |
221 // DisplayItemClient methods | 221 // DisplayItemClient methods |
222 String debugName() const final; | 222 String debugName() const final; |
223 LayoutRect visualRect() const final; | 223 LayoutRect visualRect() const final; |
224 | 224 |
225 LayoutBoxModelObject* layoutObject() const { return m_layoutObject; } | 225 LayoutBoxModelObject& layoutObject() const { return m_layoutObject; } |
226 LayoutBox* layoutBox() const { | 226 LayoutBox* layoutBox() const { |
227 return m_layoutObject && m_layoutObject->isBox() | 227 return m_layoutObject.isBox() ? &toLayoutBox(m_layoutObject) : 0; |
228 ? toLayoutBox(m_layoutObject) | |
229 : 0; | |
230 } | 228 } |
231 PaintLayer* parent() const { return m_parent; } | 229 PaintLayer* parent() const { return m_parent; } |
232 PaintLayer* previousSibling() const { return m_previous; } | 230 PaintLayer* previousSibling() const { return m_previous; } |
233 PaintLayer* nextSibling() const { return m_next; } | 231 PaintLayer* nextSibling() const { return m_next; } |
234 PaintLayer* firstChild() const { return m_first; } | 232 PaintLayer* firstChild() const { return m_first; } |
235 PaintLayer* lastChild() const { return m_last; } | 233 PaintLayer* lastChild() const { return m_last; } |
236 | 234 |
237 // TODO(wangxianzhu): Find a better name for it. 'paintContainer' might be | 235 // TODO(wangxianzhu): Find a better name for it. 'paintContainer' might be |
238 // good but we can't use it for now because it conflicts with | 236 // good but we can't use it for now because it conflicts with |
239 // PaintInfo::paintContainer. | 237 // PaintInfo::paintContainer. |
240 PaintLayer* compositingContainer() const; | 238 PaintLayer* compositingContainer() const; |
241 | 239 |
242 void addChild(PaintLayer* newChild, PaintLayer* beforeChild = 0); | 240 void addChild(PaintLayer* newChild, PaintLayer* beforeChild = 0); |
243 PaintLayer* removeChild(PaintLayer*); | 241 PaintLayer* removeChild(PaintLayer*); |
244 | 242 |
245 void removeOnlyThisLayerAfterStyleChange(); | 243 void removeOnlyThisLayerAfterStyleChange(); |
246 void insertOnlyThisLayerAfterStyleChange(); | 244 void insertOnlyThisLayerAfterStyleChange(); |
247 | 245 |
248 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle); | 246 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle); |
249 | 247 |
250 // FIXME: Many people call this function while it has out-of-date information. | 248 // FIXME: Many people call this function while it has out-of-date information. |
251 bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; } | 249 bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; } |
252 | 250 |
253 bool isTransparent() const { | 251 bool isTransparent() const { |
254 return layoutObject()->isTransparent() || | 252 return layoutObject().isTransparent() || |
255 layoutObject()->style()->hasBlendMode() || layoutObject()->hasMask(); | 253 layoutObject().style()->hasBlendMode() || layoutObject().hasMask(); |
256 } | 254 } |
257 | 255 |
258 const PaintLayer* root() const { | 256 const PaintLayer* root() const { |
259 const PaintLayer* curr = this; | 257 const PaintLayer* curr = this; |
260 while (curr->parent()) | 258 while (curr->parent()) |
261 curr = curr->parent(); | 259 curr = curr->parent(); |
262 return curr; | 260 return curr; |
263 } | 261 } |
264 | 262 |
265 const LayoutPoint& location() const { | 263 const LayoutPoint& location() const { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 // Layer::paint*() methods. | 356 // Layer::paint*() methods. |
359 PaintLayer* enclosingLayerForPaintInvalidation() const; | 357 PaintLayer* enclosingLayerForPaintInvalidation() const; |
360 | 358 |
361 PaintLayer* enclosingLayerForPaintInvalidationCrossingFrameBoundaries() const; | 359 PaintLayer* enclosingLayerForPaintInvalidationCrossingFrameBoundaries() const; |
362 | 360 |
363 bool hasAncestorWithFilterThatMovesPixels() const; | 361 bool hasAncestorWithFilterThatMovesPixels() const; |
364 | 362 |
365 bool canUseConvertToLayerCoords() const { | 363 bool canUseConvertToLayerCoords() const { |
366 // These LayoutObjects have an impact on their layers without the | 364 // These LayoutObjects have an impact on their layers without the |
367 // layoutObjects knowing about it. | 365 // layoutObjects knowing about it. |
368 return !layoutObject()->hasTransformRelatedProperty() && | 366 return !layoutObject().hasTransformRelatedProperty() && |
369 !layoutObject()->isSVGRoot(); | 367 !layoutObject().isSVGRoot(); |
370 } | 368 } |
371 | 369 |
372 void convertToLayerCoords(const PaintLayer* ancestorLayer, | 370 void convertToLayerCoords(const PaintLayer* ancestorLayer, |
373 LayoutPoint&) const; | 371 LayoutPoint&) const; |
374 void convertToLayerCoords(const PaintLayer* ancestorLayer, LayoutRect&) const; | 372 void convertToLayerCoords(const PaintLayer* ancestorLayer, LayoutRect&) const; |
375 | 373 |
376 // Does the same as convertToLayerCoords() when not in multicol. For multicol, | 374 // Does the same as convertToLayerCoords() when not in multicol. For multicol, |
377 // however, convertToLayerCoords() calculates the offset in flow-thread | 375 // however, convertToLayerCoords() calculates the offset in flow-thread |
378 // coordinates (what the layout engine uses internally), while this method | 376 // coordinates (what the layout engine uses internally), while this method |
379 // calculates the visual coordinates; i.e. it figures out which column the | 377 // calculates the visual coordinates; i.e. it figures out which column the |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 m_staticInlinePosition = position; | 433 m_staticInlinePosition = position; |
436 } | 434 } |
437 void setStaticBlockPosition(LayoutUnit position) { | 435 void setStaticBlockPosition(LayoutUnit position) { |
438 m_staticBlockPosition = position; | 436 m_staticBlockPosition = position; |
439 } | 437 } |
440 | 438 |
441 LayoutSize subpixelAccumulation() const; | 439 LayoutSize subpixelAccumulation() const; |
442 void setSubpixelAccumulation(const LayoutSize&); | 440 void setSubpixelAccumulation(const LayoutSize&); |
443 | 441 |
444 bool hasTransformRelatedProperty() const { | 442 bool hasTransformRelatedProperty() const { |
445 return layoutObject()->hasTransformRelatedProperty(); | 443 return layoutObject().hasTransformRelatedProperty(); |
446 } | 444 } |
447 // Note that this transform has the transform-origin baked in. | 445 // Note that this transform has the transform-origin baked in. |
448 TransformationMatrix* transform() const { | 446 TransformationMatrix* transform() const { |
449 return m_rareData ? m_rareData->transform.get() : nullptr; | 447 return m_rareData ? m_rareData->transform.get() : nullptr; |
450 } | 448 } |
451 | 449 |
452 // currentTransform computes a transform which takes accelerated animations | 450 // currentTransform computes a transform which takes accelerated animations |
453 // into account. The resulting transform has transform-origin baked in. If the | 451 // into account. The resulting transform has transform-origin baked in. If the |
454 // layer does not have a transform, returns the identity matrix. | 452 // layer does not have a transform, returns the identity matrix. |
455 TransformationMatrix currentTransform() const; | 453 TransformationMatrix currentTransform() const; |
456 TransformationMatrix renderableTransform(GlobalPaintFlags) const; | 454 TransformationMatrix renderableTransform(GlobalPaintFlags) const; |
457 | 455 |
458 // Get the perspective transform, which is applied to transformed sublayers. | 456 // Get the perspective transform, which is applied to transformed sublayers. |
459 // Returns true if the layer has a -webkit-perspective. | 457 // Returns true if the layer has a -webkit-perspective. |
460 // Note that this transform does not have the perspective-origin baked in. | 458 // Note that this transform does not have the perspective-origin baked in. |
461 TransformationMatrix perspectiveTransform() const; | 459 TransformationMatrix perspectiveTransform() const; |
462 FloatPoint perspectiveOrigin() const; | 460 FloatPoint perspectiveOrigin() const; |
463 bool preserves3D() const { return layoutObject()->style()->preserves3D(); } | 461 bool preserves3D() const { return layoutObject().style()->preserves3D(); } |
464 bool has3DTransform() const { | 462 bool has3DTransform() const { |
465 return m_rareData && m_rareData->transform && | 463 return m_rareData && m_rareData->transform && |
466 !m_rareData->transform->isAffine(); | 464 !m_rareData->transform->isAffine(); |
467 } | 465 } |
468 | 466 |
469 // FIXME: reflections should force transform-style to be flat in the style: | 467 // FIXME: reflections should force transform-style to be flat in the style: |
470 // https://bugs.webkit.org/show_bug.cgi?id=106959 | 468 // https://bugs.webkit.org/show_bug.cgi?id=106959 |
471 bool shouldPreserve3D() const { | 469 bool shouldPreserve3D() const { |
472 return !layoutObject()->hasReflection() && | 470 return !layoutObject().hasReflection() && |
473 layoutObject()->style()->preserves3D(); | 471 layoutObject().style()->preserves3D(); |
474 } | 472 } |
475 | 473 |
476 // Returns |true| if any property that renders using filter operations is | 474 // Returns |true| if any property that renders using filter operations is |
477 // used (including, but not limited to, 'filter' and 'box-reflect'). | 475 // used (including, but not limited to, 'filter' and 'box-reflect'). |
478 bool hasFilterInducingProperty() const { | 476 bool hasFilterInducingProperty() const { |
479 return layoutObject()->hasFilterInducingProperty(); | 477 return layoutObject().hasFilterInducingProperty(); |
480 } | 478 } |
481 | 479 |
482 void* operator new(size_t); | 480 void* operator new(size_t); |
483 // Only safe to call from LayoutBoxModelObject::destroyLayer() | 481 // Only safe to call from LayoutBoxModelObject::destroyLayer() |
484 void operator delete(void*); | 482 void operator delete(void*); |
485 | 483 |
486 CompositingState compositingState() const; | 484 CompositingState compositingState() const; |
487 | 485 |
488 // This returns true if our document is in a phase of its lifestyle during | 486 // This returns true if our document is in a phase of its lifestyle during |
489 // which compositing state may legally be read. | 487 // which compositing state may legally be read. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 | 683 |
686 // A clip parent is another compositor concept that has leaked into | 684 // A clip parent is another compositor concept that has leaked into |
687 // blink so that it may be used as a promotion trigger. Layers with clip | 685 // blink so that it may be used as a promotion trigger. Layers with clip |
688 // parents escape the clip of a stacking tree ancestor. The compositor | 686 // parents escape the clip of a stacking tree ancestor. The compositor |
689 // needs to know about clip parents in order to circumvent its normal | 687 // needs to know about clip parents in order to circumvent its normal |
690 // clipping logic. | 688 // clipping logic. |
691 const PaintLayer* clipParent; | 689 const PaintLayer* clipParent; |
692 | 690 |
693 IntRect clippedAbsoluteBoundingBox; | 691 IntRect clippedAbsoluteBoundingBox; |
694 IntRect unclippedAbsoluteBoundingBox; | 692 IntRect unclippedAbsoluteBoundingBox; |
695 const LayoutObject* clippingContainer; | 693 const LayoutBoxModelObject* clippingContainer; |
696 }; | 694 }; |
697 | 695 |
698 void setNeedsCompositingInputsUpdate(); | 696 void setNeedsCompositingInputsUpdate(); |
699 bool childNeedsCompositingInputsUpdate() const { | 697 bool childNeedsCompositingInputsUpdate() const { |
700 return m_childNeedsCompositingInputsUpdate; | 698 return m_childNeedsCompositingInputsUpdate; |
701 } | 699 } |
702 bool needsCompositingInputsUpdate() const { | 700 bool needsCompositingInputsUpdate() const { |
703 return m_needsAncestorDependentCompositingInputsUpdate; | 701 return m_needsAncestorDependentCompositingInputsUpdate; |
704 } | 702 } |
705 | 703 |
(...skipping 28 matching lines...) Expand all Loading... |
734 return m_ancestorDependentCompositingInputs | 732 return m_ancestorDependentCompositingInputs |
735 ? m_ancestorDependentCompositingInputs->transformAncestor | 733 ? m_ancestorDependentCompositingInputs->transformAncestor |
736 : nullptr; | 734 : nullptr; |
737 } | 735 } |
738 const PaintLayer* filterAncestor() const { | 736 const PaintLayer* filterAncestor() const { |
739 DCHECK(!m_needsAncestorDependentCompositingInputsUpdate); | 737 DCHECK(!m_needsAncestorDependentCompositingInputsUpdate); |
740 return m_ancestorDependentCompositingInputs | 738 return m_ancestorDependentCompositingInputs |
741 ? m_ancestorDependentCompositingInputs->filterAncestor | 739 ? m_ancestorDependentCompositingInputs->filterAncestor |
742 : nullptr; | 740 : nullptr; |
743 } | 741 } |
744 const LayoutObject* clippingContainer() const { | 742 const LayoutBoxModelObject* clippingContainer() const { |
745 DCHECK(!m_needsAncestorDependentCompositingInputsUpdate); | 743 DCHECK(!m_needsAncestorDependentCompositingInputsUpdate); |
746 return m_ancestorDependentCompositingInputs->clippingContainer; | 744 return m_ancestorDependentCompositingInputs->clippingContainer; |
747 } | 745 } |
748 const PaintLayer* ancestorOverflowLayer() const { | 746 const PaintLayer* ancestorOverflowLayer() const { |
749 return m_ancestorOverflowLayer; | 747 return m_ancestorOverflowLayer; |
750 } | 748 } |
751 const PaintLayer* ancestorScrollingLayer() const { | 749 const PaintLayer* ancestorScrollingLayer() const { |
752 DCHECK(!m_needsAncestorDependentCompositingInputsUpdate); | 750 DCHECK(!m_needsAncestorDependentCompositingInputsUpdate); |
753 return m_ancestorDependentCompositingInputs | 751 return m_ancestorDependentCompositingInputs |
754 ? m_ancestorDependentCompositingInputs->ancestorScrollingLayer | 752 ? m_ancestorDependentCompositingInputs->ancestorScrollingLayer |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 const LayoutRect& dirtyRect, | 862 const LayoutRect& dirtyRect, |
865 ClipRectsCacheSlot, | 863 ClipRectsCacheSlot, |
866 GeometryMapperOption, | 864 GeometryMapperOption, |
867 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize, | 865 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize, |
868 ShouldRespectOverflowClipType = RespectOverflowClip, | 866 ShouldRespectOverflowClipType = RespectOverflowClip, |
869 const LayoutPoint* offsetFromRoot = 0, | 867 const LayoutPoint* offsetFromRoot = 0, |
870 const LayoutSize& subPixelAccumulation = LayoutSize(), | 868 const LayoutSize& subPixelAccumulation = LayoutSize(), |
871 const LayoutRect* layerBoundingBox = 0); | 869 const LayoutRect* layerBoundingBox = 0); |
872 | 870 |
873 LayoutPoint layoutBoxLocation() const { | 871 LayoutPoint layoutBoxLocation() const { |
874 return layoutObject()->isBox() ? toLayoutBox(layoutObject())->location() | 872 return layoutObject().isBox() ? toLayoutBox(layoutObject()).location() |
875 : LayoutPoint(); | 873 : LayoutPoint(); |
876 } | 874 } |
877 | 875 |
878 enum TransparencyClipBoxBehavior { | 876 enum TransparencyClipBoxBehavior { |
879 PaintingTransparencyClipBox, | 877 PaintingTransparencyClipBox, |
880 HitTestingTransparencyClipBox | 878 HitTestingTransparencyClipBox |
881 }; | 879 }; |
882 | 880 |
883 enum TransparencyClipBoxMode { | 881 enum TransparencyClipBoxMode { |
884 DescendantsOfTransparencyClipBox, | 882 DescendantsOfTransparencyClipBox, |
885 RootOfTransparencyClipBox | 883 RootOfTransparencyClipBox |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 | 1201 |
1204 // These bitfields are part of ancestor/descendant dependent compositing | 1202 // These bitfields are part of ancestor/descendant dependent compositing |
1205 // inputs. | 1203 // inputs. |
1206 unsigned m_hasDescendantWithClipPath : 1; | 1204 unsigned m_hasDescendantWithClipPath : 1; |
1207 unsigned m_hasNonIsolatedDescendantWithBlendMode : 1; | 1205 unsigned m_hasNonIsolatedDescendantWithBlendMode : 1; |
1208 unsigned m_hasAncestorWithClipPath : 1; | 1206 unsigned m_hasAncestorWithClipPath : 1; |
1209 unsigned m_hasRootScrollerAsDescendant : 1; | 1207 unsigned m_hasRootScrollerAsDescendant : 1; |
1210 | 1208 |
1211 unsigned m_selfPaintingStatusChanged : 1; | 1209 unsigned m_selfPaintingStatusChanged : 1; |
1212 | 1210 |
1213 LayoutBoxModelObject* m_layoutObject; | 1211 LayoutBoxModelObject& m_layoutObject; |
1214 | 1212 |
1215 PaintLayer* m_parent; | 1213 PaintLayer* m_parent; |
1216 PaintLayer* m_previous; | 1214 PaintLayer* m_previous; |
1217 PaintLayer* m_next; | 1215 PaintLayer* m_next; |
1218 PaintLayer* m_first; | 1216 PaintLayer* m_first; |
1219 PaintLayer* m_last; | 1217 PaintLayer* m_last; |
1220 | 1218 |
1221 // Our (x,y) coordinates are in our containing layer's coordinate space. | 1219 // Our (x,y) coordinates are in our containing layer's coordinate space. |
1222 LayoutPoint m_location; | 1220 LayoutPoint m_location; |
1223 | 1221 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 | 1254 |
1257 } // namespace blink | 1255 } // namespace blink |
1258 | 1256 |
1259 #ifndef NDEBUG | 1257 #ifndef NDEBUG |
1260 // Outside the WebCore namespace for ease of invocation from gdb. | 1258 // Outside the WebCore namespace for ease of invocation from gdb. |
1261 CORE_EXPORT void showLayerTree(const blink::PaintLayer*); | 1259 CORE_EXPORT void showLayerTree(const blink::PaintLayer*); |
1262 CORE_EXPORT void showLayerTree(const blink::LayoutObject*); | 1260 CORE_EXPORT void showLayerTree(const blink::LayoutObject*); |
1263 #endif | 1261 #endif |
1264 | 1262 |
1265 #endif // Layer_h | 1263 #endif // Layer_h |
OLD | NEW |