Chromium Code Reviews| 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" | |
| 9 #include "wtf/RefPtr.h" | |
| 10 | |
| 8 namespace blink { | 11 namespace blink { |
| 9 | 12 |
| 13 class ClipPaintPropertyNode; | |
| 14 class EffectPaintPropertyNode; | |
| 10 class FrameView; | 15 class FrameView; |
| 11 class LayoutObject; | 16 class LayoutObject; |
| 12 struct PaintPropertyTreeBuilderContext; | 17 class TransformPaintPropertyNode; |
| 13 | 18 |
| 14 // This class walks the whole layout tree, beginning from the root FrameView, ac ross | 19 // The context for PaintPropertyTreeBuilder. |
| 15 // frame boundaries. The walk will collect special things in the layout tree and create | 20 // It's responsible for bookkeeping tree state in other order, for example, the most recent |
| 16 // paint property nodes for them. Special things include but not limit to: overf low clip, | 21 // position container seen. |
| 17 // transform, fixed-pos, animation, mask, filter, ... etc. | 22 struct PaintPropertyTreeBuilderContext { |
| 18 // It expects to be invoked after layout clean, i.e. during InPaintPropertyUpdat e phase. | 23 PaintPropertyTreeBuilderContext() |
| 24 : currentTransform(nullptr) | |
| 25 , currentClip(nullptr) | |
| 26 , transformForAbsolutePosition(nullptr) | |
| 27 , containerForAbsolutePosition(nullptr) | |
| 28 , clipForAbsolutePosition(nullptr) | |
| 29 , transformForFixedPosition(nullptr) | |
| 30 , clipForFixedPosition(nullptr) | |
| 31 , currentEffect(nullptr) { } | |
| 32 | |
| 33 // The combination of a transform and paint offset describes a linear space. | |
| 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 | |
| 45 // 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. | |
| 47 // 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 | |
| 49 // positioned descendants. | |
| 50 // Overflow clips are also inherited by containing block tree instead of DOM tree, thus they | |
| 51 // are included in the additional context too. | |
| 52 TransformPaintPropertyNode* transformForAbsolutePosition; | |
| 53 LayoutPoint paintOffsetForAbsolutePosition; | |
| 54 const LayoutObject* containerForAbsolutePosition; | |
| 55 ClipPaintPropertyNode* clipForAbsolutePosition; | |
| 56 | |
| 57 TransformPaintPropertyNode* transformForFixedPosition; | |
| 58 LayoutPoint paintOffsetForFixedPosition; | |
| 59 ClipPaintPropertyNode* clipForFixedPosition; | |
| 60 | |
| 61 // 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 | |
| 63 // bookkeeping for effect nodes and can generate the effect tree from a DOM- order traversal. | |
| 64 EffectPaintPropertyNode* currentEffect; | |
| 65 }; | |
| 66 | |
| 67 // Holds references to root property nodes to keep them alive during tree walk. | |
| 68 struct PaintPropertyTreeBuilderRootContext : public PaintPropertyTreeBuilderCont ext { | |
| 69 RefPtr<TransformPaintPropertyNode> transformRoot; | |
| 70 RefPtr<ClipPaintPropertyNode> clipRoot; | |
| 71 RefPtr<EffectPaintPropertyNode> effectRoot; | |
| 72 }; | |
| 73 | |
| 74 // Creates paint property tree nodes for special things in the layout tree. | |
| 75 // Special things include but not limit to: overflow cllip, transform, fixed-pos , animation, | |
|
pdr.
2016/05/31 23:17:39
Nittt: clip
Xianzhu
2016/05/31 23:41:40
Donne.
| |
| 76 // mask, filter, ... etc. | |
| 77 // It expects to be invoked for each layout tree node in DOM order during InPreP aint phase. | |
| 19 class PaintPropertyTreeBuilder { | 78 class PaintPropertyTreeBuilder { |
| 20 public: | 79 public: |
| 21 void buildPropertyTrees(FrameView& rootFrame); | 80 void buildTreeRootNodes(FrameView&, PaintPropertyTreeBuilderRootContext&); |
| 81 void buildTreeNodes(FrameView&, PaintPropertyTreeBuilderContext&); | |
| 82 void buildTreeNodes(const LayoutObject&, PaintPropertyTreeBuilderContext&); | |
| 22 | 83 |
| 23 private: | 84 private: |
| 24 void walk(FrameView&, const PaintPropertyTreeBuilderContext&); | 85 static void updatePaintOffsetTranslation(const LayoutObject&, PaintPropertyT reeBuilderContext&); |
| 25 | 86 static void updateTransform(const LayoutObject&, PaintPropertyTreeBuilderCon text&); |
| 26 static void updatePaintOffsetTranslation(LayoutObject&, PaintPropertyTreeBui lderContext&); | 87 static void updateEffect(const LayoutObject&, PaintPropertyTreeBuilderContex t&); |
| 27 static void updateTransform(LayoutObject&, PaintPropertyTreeBuilderContext&) ; | 88 static void updateCssClip(const LayoutObject&, PaintPropertyTreeBuilderConte xt&); |
| 28 static void updateEffect(LayoutObject&, PaintPropertyTreeBuilderContext&); | 89 static void updateLocalBorderBoxContext(const LayoutObject&, const PaintProp ertyTreeBuilderContext&); |
| 29 static void updateCssClip(LayoutObject&, PaintPropertyTreeBuilderContext&); | 90 static void updateScrollbarPaintOffset(const LayoutObject&, const PaintPrope rtyTreeBuilderContext&); |
| 30 static void updateLocalBorderBoxContext(LayoutObject&, const PaintPropertyTr eeBuilderContext&); | 91 static void updateOverflowClip(const LayoutObject&, PaintPropertyTreeBuilder Context&); |
| 31 static void updateScrollbarPaintOffset(LayoutObject&, const PaintPropertyTre eBuilderContext&); | 92 static void updatePerspective(const LayoutObject&, PaintPropertyTreeBuilderC ontext&); |
| 32 static void updateOverflowClip(LayoutObject&, PaintPropertyTreeBuilderContex t&); | 93 static void updateSvgLocalTransform(const LayoutObject&, PaintPropertyTreeBu ilderContext&); |
| 33 static void updatePerspective(LayoutObject&, PaintPropertyTreeBuilderContext &); | 94 static void updateScrollTranslation(const LayoutObject&, PaintPropertyTreeBu ilderContext&); |
| 34 static void updateSvgLocalTransform(LayoutObject&, PaintPropertyTreeBuilderC ontext&); | 95 static void updateOutOfFlowContext(const LayoutObject&, PaintPropertyTreeBui lderContext&); |
| 35 static void updateScrollTranslation(LayoutObject&, PaintPropertyTreeBuilderC ontext&); | |
| 36 static void updateOutOfFlowContext(LayoutObject&, PaintPropertyTreeBuilderCo ntext&); | |
| 37 | |
| 38 void walk(LayoutObject&, const PaintPropertyTreeBuilderContext&); | |
| 39 }; | 96 }; |
| 40 | 97 |
| 41 } // namespace blink | 98 } // namespace blink |
| 42 | 99 |
| 43 #endif // PaintPropertyTreeBuilder_h | 100 #endif // PaintPropertyTreeBuilder_h |
| OLD | NEW |