| 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" |
| 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 12 #include "wtf/RefPtr.h" | 12 #include "wtf/RefPtr.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 class FrameView; | 16 class FrameView; |
| 17 class LayoutObject; | 17 class LayoutObject; |
| 18 | 18 |
| 19 // The context for PaintPropertyTreeBuilder. | 19 // The context for PaintPropertyTreeBuilder. |
| 20 // It's responsible for bookkeeping tree state in other order, for example, the
most recent | 20 // It's responsible for bookkeeping tree state in other order, for example, the
most recent |
| 21 // position container seen. | 21 // position container seen. |
| 22 struct PaintPropertyTreeBuilderContext { | 22 struct PaintPropertyTreeBuilderContext { |
| 23 PaintPropertyTreeBuilderContext() | 23 // State that propagates on the containing block chain (and so is adjusted |
| 24 : currentTransform(nullptr) | 24 // when an absolute or fixed position object is encountered). |
| 25 , currentClip(nullptr) | 25 struct ContainingBlockContext { |
| 26 , transformForAbsolutePosition(nullptr) | 26 // The combination of a transform and paint offset describes a linear sp
ace. |
| 27 , containerForAbsolutePosition(nullptr) | 27 // When a layout object recur to its children, the main context is expec
ted to refer |
| 28 , clipForAbsolutePosition(nullptr) | 28 // the object's border box, then the callee will derive its own border b
ox by translating |
| 29 , transformForFixedPosition(nullptr) | 29 // the space with its own layout location. |
| 30 , clipForFixedPosition(nullptr) | 30 TransformPaintPropertyNode* transform = nullptr; |
| 31 , currentEffect(nullptr) { } | 31 LayoutPoint paintOffset; |
| 32 // The clip node describes the accumulated raster clip for the current s
ubtree. |
| 33 // Note that the computed raster region in canvas space for a clip node
is independent from |
| 34 // the transform and paint offset above. Also the actual raster region m
ay be affected |
| 35 // by layerization and occlusion tracking. |
| 36 ClipPaintPropertyNode* clip = nullptr; |
| 37 }; |
| 32 | 38 |
| 33 // The combination of a transform and paint offset describes a linear space. | 39 ContainingBlockContext current; |
| 34 // When a layout object recur to its children, the main context is expected
to refer | |
| 35 // the object's border box, then the callee will derive its own border box b
y translating | |
| 36 // the space with its own layout location. | |
| 37 TransformPaintPropertyNode* currentTransform; | |
| 38 LayoutPoint paintOffset; | |
| 39 // The clip node describes the accumulated raster clip for the current subtr
ee. | |
| 40 // Note that the computed raster region in canvas space for a clip node is i
ndependent from | |
| 41 // the transform and paint offset above. Also the actual raster region may b
e affected | |
| 42 // by layerization and occlusion tracking. | |
| 43 ClipPaintPropertyNode* currentClip; | |
| 44 | 40 |
| 45 // Separate context for out-of-flow positioned and fixed positioned elements
are needed | 41 // Separate context for out-of-flow positioned and fixed positioned elements
are needed |
| 46 // because they don't use DOM parent as their containing block. | 42 // because they don't use DOM parent as their containing block. |
| 47 // These additional contexts normally pass through untouched, and are only c
opied from | 43 // These additional contexts normally pass through untouched, and are only c
opied from |
| 48 // the main context when the current element serves as the containing block
of corresponding | 44 // the main context when the current element serves as the containing block
of corresponding |
| 49 // positioned descendants. | 45 // positioned descendants. |
| 50 // Overflow clips are also inherited by containing block tree instead of DOM
tree, thus they | 46 // Overflow clips are also inherited by containing block tree instead of DOM
tree, thus they |
| 51 // are included in the additional context too. | 47 // are included in the additional context too. |
| 52 TransformPaintPropertyNode* transformForAbsolutePosition; | 48 ContainingBlockContext absolutePosition; |
| 53 LayoutPoint paintOffsetForAbsolutePosition; | 49 const LayoutObject* containerForAbsolutePosition = nullptr; |
| 54 const LayoutObject* containerForAbsolutePosition; | |
| 55 ClipPaintPropertyNode* clipForAbsolutePosition; | |
| 56 | 50 |
| 57 TransformPaintPropertyNode* transformForFixedPosition; | 51 ContainingBlockContext fixedPosition; |
| 58 LayoutPoint paintOffsetForFixedPosition; | |
| 59 ClipPaintPropertyNode* clipForFixedPosition; | |
| 60 | 52 |
| 61 // The effect hierarchy is applied by the stacking context tree. It is guara
nteed that every | 53 // The effect hierarchy is applied by the stacking context tree. It is guara
nteed that every |
| 62 // DOM descendant is also a stacking context descendant. Therefore, we don't
need extra | 54 // DOM descendant is also a stacking context descendant. Therefore, we don't
need extra |
| 63 // bookkeeping for effect nodes and can generate the effect tree from a DOM-
order traversal. | 55 // bookkeeping for effect nodes and can generate the effect tree from a DOM-
order traversal. |
| 64 EffectPaintPropertyNode* currentEffect; | 56 EffectPaintPropertyNode* currentEffect = nullptr; |
| 65 }; | 57 }; |
| 66 | 58 |
| 67 // Creates paint property tree nodes for special things in the layout tree. | 59 // Creates paint property tree nodes for special things in the layout tree. |
| 68 // Special things include but not limit to: overflow clip, transform, fixed-pos,
animation, | 60 // Special things include but not limit to: overflow clip, transform, fixed-pos,
animation, |
| 69 // mask, filter, ... etc. | 61 // mask, filter, ... etc. |
| 70 // It expects to be invoked for each layout tree node in DOM order during InPreP
aint phase. | 62 // It expects to be invoked for each layout tree node in DOM order during InPreP
aint phase. |
| 71 class PaintPropertyTreeBuilder { | 63 class PaintPropertyTreeBuilder { |
| 72 public: | 64 public: |
| 73 void buildTreeRootNodes(FrameView&, PaintPropertyTreeBuilderContext&); | 65 void buildTreeRootNodes(FrameView&, PaintPropertyTreeBuilderContext&); |
| 74 void buildTreeNodes(FrameView&, PaintPropertyTreeBuilderContext&); | 66 void buildTreeNodes(FrameView&, PaintPropertyTreeBuilderContext&); |
| 75 void buildTreeNodes(const LayoutObject&, PaintPropertyTreeBuilderContext&); | 67 void buildTreeNodes(const LayoutObject&, PaintPropertyTreeBuilderContext&); |
| 76 | 68 |
| 77 private: | 69 private: |
| 78 static void updatePaintOffsetTranslation(const LayoutObject&, PaintPropertyT
reeBuilderContext&); | 70 static void updatePaintOffsetTranslation(const LayoutObject&, PaintPropertyT
reeBuilderContext&); |
| 79 static void updateTransform(const LayoutObject&, PaintPropertyTreeBuilderCon
text&); | 71 static void updateTransform(const LayoutObject&, PaintPropertyTreeBuilderCon
text&); |
| 80 static void updateEffect(const LayoutObject&, PaintPropertyTreeBuilderContex
t&); | 72 static void updateEffect(const LayoutObject&, PaintPropertyTreeBuilderContex
t&); |
| 81 static void updateCssClip(const LayoutObject&, PaintPropertyTreeBuilderConte
xt&); | 73 static void updateCssClip(const LayoutObject&, PaintPropertyTreeBuilderConte
xt&); |
| 82 static void updateLocalBorderBoxContext(const LayoutObject&, const PaintProp
ertyTreeBuilderContext&); | 74 static void updateLocalBorderBoxContext(const LayoutObject&, const PaintProp
ertyTreeBuilderContext&); |
| 83 static void updateScrollbarPaintOffset(const LayoutObject&, const PaintPrope
rtyTreeBuilderContext&); | 75 static void updateScrollbarPaintOffset(const LayoutObject&, const PaintPrope
rtyTreeBuilderContext&); |
| 84 static void updateOverflowClip(const LayoutObject&, PaintPropertyTreeBuilder
Context&); | 76 static void updateOverflowClip(const LayoutObject&, PaintPropertyTreeBuilder
Context&); |
| 85 static void updatePerspective(const LayoutObject&, PaintPropertyTreeBuilderC
ontext&); | 77 static void updatePerspective(const LayoutObject&, PaintPropertyTreeBuilderC
ontext&); |
| 86 static void updateSvgLocalToBorderBoxTransform(const LayoutObject&, PaintPro
pertyTreeBuilderContext&); | 78 static void updateSvgLocalToBorderBoxTransform(const LayoutObject&, PaintPro
pertyTreeBuilderContext&); |
| 87 static void updateScrollTranslation(const LayoutObject&, PaintPropertyTreeBu
ilderContext&); | 79 static void updateScrollTranslation(const LayoutObject&, PaintPropertyTreeBu
ilderContext&); |
| 88 static void updateOutOfFlowContext(const LayoutObject&, PaintPropertyTreeBui
lderContext&); | 80 static void updateOutOfFlowContext(const LayoutObject&, PaintPropertyTreeBui
lderContext&); |
| 89 }; | 81 }; |
| 90 | 82 |
| 91 } // namespace blink | 83 } // namespace blink |
| 92 | 84 |
| 93 #endif // PaintPropertyTreeBuilder_h | 85 #endif // PaintPropertyTreeBuilder_h |
| OLD | NEW |