| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PaintPropertyTreeBuilder_h | 5 #ifndef PaintPropertyTreeBuilder_h |
| 6 #define PaintPropertyTreeBuilder_h | 6 #define PaintPropertyTreeBuilder_h |
| 7 | 7 |
| 8 #include "platform/geometry/LayoutPoint.h" | 8 #include "platform/geometry/LayoutPoint.h" |
| 9 #include "platform/graphics/paint/ClipPaintPropertyNode.h" | 9 #include "platform/graphics/paint/ClipPaintPropertyNode.h" |
| 10 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 10 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // It's responsible for bookkeeping tree state in other order, for example, the
most recent | 21 // It's responsible for bookkeeping tree state in other order, for example, the
most recent |
| 22 // position container seen. | 22 // position container seen. |
| 23 struct PaintPropertyTreeBuilderContext { | 23 struct PaintPropertyTreeBuilderContext { |
| 24 // State that propagates on the containing block chain (and so is adjusted | 24 // State that propagates on the containing block chain (and so is adjusted |
| 25 // when an absolute or fixed position object is encountered). | 25 // when an absolute or fixed position object is encountered). |
| 26 struct ContainingBlockContext { | 26 struct ContainingBlockContext { |
| 27 // The combination of a transform and paint offset describes a linear sp
ace. | 27 // The combination of a transform and paint offset describes a linear sp
ace. |
| 28 // When a layout object recur to its children, the main context is expec
ted to refer | 28 // When a layout object recur to its children, the main context is expec
ted to refer |
| 29 // the object's border box, then the callee will derive its own border b
ox by translating | 29 // the object's border box, then the callee will derive its own border b
ox by translating |
| 30 // the space with its own layout location. | 30 // the space with its own layout location. |
| 31 TransformPaintPropertyNode* transform = nullptr; | 31 const TransformPaintPropertyNode* transform = nullptr; |
| 32 LayoutPoint paintOffset; | 32 LayoutPoint paintOffset; |
| 33 // Whether newly created children should flatten their inherited transfo
rm | 33 // Whether newly created children should flatten their inherited transfo
rm |
| 34 // (equivalently, draw into the plane of their parent). Should generally | 34 // (equivalently, draw into the plane of their parent). Should generally |
| 35 // be updated whenever |transform| is; flattening only needs to happen | 35 // be updated whenever |transform| is; flattening only needs to happen |
| 36 // to immediate children. | 36 // to immediate children. |
| 37 bool shouldFlattenInheritedTransform = false; | 37 bool shouldFlattenInheritedTransform = false; |
| 38 // Rendering context for 3D sorting. See | 38 // Rendering context for 3D sorting. See |
| 39 // TransformPaintPropertyNode::renderingContextID. | 39 // TransformPaintPropertyNode::renderingContextID. |
| 40 unsigned renderingContextID = 0; | 40 unsigned renderingContextID = 0; |
| 41 // The clip node describes the accumulated raster clip for the current s
ubtree. | 41 // The clip node describes the accumulated raster clip for the current s
ubtree. |
| 42 // Note that the computed raster region in canvas space for a clip node
is independent from | 42 // Note that the computed raster region in canvas space for a clip node
is independent from |
| 43 // the transform and paint offset above. Also the actual raster region m
ay be affected | 43 // the transform and paint offset above. Also the actual raster region m
ay be affected |
| 44 // by layerization and occlusion tracking. | 44 // by layerization and occlusion tracking. |
| 45 ClipPaintPropertyNode* clip = nullptr; | 45 const ClipPaintPropertyNode* clip = nullptr; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 ContainingBlockContext current; | 48 ContainingBlockContext current; |
| 49 | 49 |
| 50 // Separate context for out-of-flow positioned and fixed positioned elements
are needed | 50 // Separate context for out-of-flow positioned and fixed positioned elements
are needed |
| 51 // because they don't use DOM parent as their containing block. | 51 // because they don't use DOM parent as their containing block. |
| 52 // These additional contexts normally pass through untouched, and are only c
opied from | 52 // These additional contexts normally pass through untouched, and are only c
opied from |
| 53 // the main context when the current element serves as the containing block
of corresponding | 53 // the main context when the current element serves as the containing block
of corresponding |
| 54 // positioned descendants. | 54 // positioned descendants. |
| 55 // Overflow clips are also inherited by containing block tree instead of DOM
tree, thus they | 55 // Overflow clips are also inherited by containing block tree instead of DOM
tree, thus they |
| 56 // are included in the additional context too. | 56 // are included in the additional context too. |
| 57 ContainingBlockContext absolutePosition; | 57 ContainingBlockContext absolutePosition; |
| 58 const LayoutObject* containerForAbsolutePosition = nullptr; | 58 const LayoutObject* containerForAbsolutePosition = nullptr; |
| 59 | 59 |
| 60 ContainingBlockContext fixedPosition; | 60 ContainingBlockContext fixedPosition; |
| 61 | 61 |
| 62 // The effect hierarchy is applied by the stacking context tree. It is guara
nteed that every | 62 // The effect hierarchy is applied by the stacking context tree. It is guara
nteed that every |
| 63 // DOM descendant is also a stacking context descendant. Therefore, we don't
need extra | 63 // DOM descendant is also a stacking context descendant. Therefore, we don't
need extra |
| 64 // bookkeeping for effect nodes and can generate the effect tree from a DOM-
order traversal. | 64 // bookkeeping for effect nodes and can generate the effect tree from a DOM-
order traversal. |
| 65 EffectPaintPropertyNode* currentEffect = nullptr; | 65 const EffectPaintPropertyNode* currentEffect = nullptr; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 // Creates paint property tree nodes for special things in the layout tree. | 68 // Creates paint property tree nodes for special things in the layout tree. |
| 69 // Special things include but not limit to: overflow clip, transform, fixed-pos,
animation, | 69 // Special things include but not limit to: overflow clip, transform, fixed-pos,
animation, |
| 70 // mask, filter, ... etc. | 70 // mask, filter, ... etc. |
| 71 // It expects to be invoked for each layout tree node in DOM order during InPreP
aint phase. | 71 // It expects to be invoked for each layout tree node in DOM order during InPreP
aint phase. |
| 72 class PaintPropertyTreeBuilder { | 72 class PaintPropertyTreeBuilder { |
| 73 public: | 73 public: |
| 74 void buildTreeRootNodes(FrameView&, PaintPropertyTreeBuilderContext&); | 74 void buildTreeRootNodes(FrameView&, PaintPropertyTreeBuilderContext&); |
| 75 void buildTreeNodes(FrameView&, PaintPropertyTreeBuilderContext&); | 75 void buildTreeNodes(FrameView&, PaintPropertyTreeBuilderContext&); |
| 76 void buildTreeNodes(const LayoutObject&, PaintPropertyTreeBuilderContext&); | 76 void buildTreeNodes(const LayoutObject&, PaintPropertyTreeBuilderContext&); |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 template <typename PropertyNode, void (ObjectPaintProperties::*Setter)(PassR
efPtr<PropertyNode>)> | |
| 80 static void clearPaintProperty(const LayoutObject&); | |
| 81 | |
| 82 template < | |
| 83 typename PropertyNode, | |
| 84 PropertyNode* (ObjectPaintProperties::*Getter)() const, | |
| 85 void (ObjectPaintProperties::*Setter)(PassRefPtr<PropertyNode>), | |
| 86 typename... Args> | |
| 87 static void updateOrCreatePaintProperty(const LayoutObject&, const PaintProp
ertyTreeBuilderContext&, PropertyNode*& contextProperty, const Args&...); | |
| 88 | |
| 89 static void updatePaintOffsetTranslation(const LayoutObject&, PaintPropertyT
reeBuilderContext&); | 79 static void updatePaintOffsetTranslation(const LayoutObject&, PaintPropertyT
reeBuilderContext&); |
| 90 static void updateTransform(const LayoutObject&, PaintPropertyTreeBuilderCon
text&); | 80 static void updateTransform(const LayoutObject&, PaintPropertyTreeBuilderCon
text&); |
| 91 static void updateEffect(const LayoutObject&, PaintPropertyTreeBuilderContex
t&); | 81 static void updateEffect(const LayoutObject&, PaintPropertyTreeBuilderContex
t&); |
| 92 static void updateCssClip(const LayoutObject&, PaintPropertyTreeBuilderConte
xt&); | 82 static void updateCssClip(const LayoutObject&, PaintPropertyTreeBuilderConte
xt&); |
| 93 static void updateLocalBorderBoxContext(const LayoutObject&, const PaintProp
ertyTreeBuilderContext&); | 83 static void updateLocalBorderBoxContext(const LayoutObject&, const PaintProp
ertyTreeBuilderContext&); |
| 94 static void updateScrollbarPaintOffset(const LayoutObject&, const PaintPrope
rtyTreeBuilderContext&); | 84 static void updateScrollbarPaintOffset(const LayoutObject&, const PaintPrope
rtyTreeBuilderContext&); |
| 95 static void updateOverflowClip(const LayoutObject&, PaintPropertyTreeBuilder
Context&); | 85 static void updateOverflowClip(const LayoutObject&, PaintPropertyTreeBuilder
Context&); |
| 96 static void updatePerspective(const LayoutObject&, PaintPropertyTreeBuilderC
ontext&); | 86 static void updatePerspective(const LayoutObject&, PaintPropertyTreeBuilderC
ontext&); |
| 97 static void updateSvgLocalToBorderBoxTransform(const LayoutObject&, PaintPro
pertyTreeBuilderContext&); | 87 static void updateSvgLocalToBorderBoxTransform(const LayoutObject&, PaintPro
pertyTreeBuilderContext&); |
| 98 static void updateScrollTranslation(const LayoutObject&, PaintPropertyTreeBu
ilderContext&); | 88 static void updateScrollTranslation(const LayoutObject&, PaintPropertyTreeBu
ilderContext&); |
| 99 static void updateOutOfFlowContext(const LayoutObject&, PaintPropertyTreeBui
lderContext&); | 89 static void updateOutOfFlowContext(const LayoutObject&, PaintPropertyTreeBui
lderContext&); |
| 100 }; | 90 }; |
| 101 | 91 |
| 102 } // namespace blink | 92 } // namespace blink |
| 103 | 93 |
| 104 #endif // PaintPropertyTreeBuilder_h | 94 #endif // PaintPropertyTreeBuilder_h |
| OLD | NEW |