Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 PaintInvalidationState_h | 5 #ifndef PaintInvalidationState_h |
| 6 #define PaintInvalidationState_h | 6 #define PaintInvalidationState_h |
| 7 | 7 |
| 8 #include "platform/geometry/LayoutRect.h" | 8 #include "platform/geometry/LayoutRect.h" |
| 9 #include "platform/transforms/AffineTransform.h" | 9 #include "platform/transforms/AffineTransform.h" |
| 10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 // | 31 // |
| 32 // The main difference with LayoutState is that it was customized for the | 32 // The main difference with LayoutState is that it was customized for the |
| 33 // needs of the paint invalidation systems (keeping visual rectangles | 33 // needs of the paint invalidation systems (keeping visual rectangles |
| 34 // instead of layout specific information). | 34 // instead of layout specific information). |
| 35 class PaintInvalidationState { | 35 class PaintInvalidationState { |
| 36 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 36 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 37 WTF_MAKE_NONCOPYABLE(PaintInvalidationState); | 37 WTF_MAKE_NONCOPYABLE(PaintInvalidationState); |
| 38 public: | 38 public: |
| 39 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo utObject&); | 39 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo utObject&); |
| 40 | 40 |
| 41 // TODO(wangxianzhu): This is temporary for positioned object whose paintInv alidationContainer is different from | |
| 42 // the one we find during tree walk. Remove this after we fix the issue with tree walk in DOM-order. | |
| 43 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo utBoxModelObject&, const LayoutBoxModelObject& paintInvalidationContainer); | |
| 44 | |
| 45 // For root LayoutView, or when sub-frame LayoutView's invalidateTreeIfNeede d() is called directly from | 41 // For root LayoutView, or when sub-frame LayoutView's invalidateTreeIfNeede d() is called directly from |
| 46 // FrameView::invalidateTreeIfNeededRecursive() instead of the owner LayoutP art. | 42 // FrameView::invalidateTreeIfNeededRecursive() instead of the owner LayoutP art. |
| 47 // TODO(wangxianzhu): Eliminate the latter case. | 43 // TODO(wangxianzhu): Eliminate the latter case. |
| 48 PaintInvalidationState(const LayoutView&, Vector<LayoutObject*>& pendingDela yedPaintInvalidations); | 44 PaintInvalidationState(const LayoutView&, Vector<LayoutObject*>& pendingDela yedPaintInvalidations); |
| 49 | 45 |
| 50 // When a PaintInvalidationState is constructed, it can be used to map point s/rects in the object's | 46 // When a PaintInvalidationState is constructed, it can be used to map point s/rects in the object's |
| 51 // local space (border box space for LayoutBoxes). After invalidation of the current object, | 47 // local space (border box space for LayoutBoxes). After invalidation of the current object, |
| 52 // before invalidation of the subtrees, this method must be called to apply clip and scroll offset | 48 // before invalidation of the subtrees, this method must be called to apply clip and scroll offset |
| 53 // etc. for creating child PaintInvalidationStates. | 49 // etc. for creating child PaintInvalidationStates. |
| 54 void updateForChildren(); | 50 void updateForChildren(); |
| 55 | 51 |
| 56 bool forcedSubtreeInvalidationWithinContainer() const { return m_forcedSubtr eeInvalidationWithinContainer; } | 52 bool forcedSubtreeInvalidationWithinContainer() const { return m_forcedSubtr eeInvalidationWithinContainer; } |
| 57 void setForceSubtreeInvalidationWithinContainer() { m_forcedSubtreeInvalidat ionWithinContainer = true; } | 53 void setForceSubtreeInvalidationWithinContainer() { m_forcedSubtreeInvalidat ionWithinContainer = true; } |
| 58 | 54 |
| 59 bool forcedSubtreeInvalidationRectUpdateWithinContainer() const { return m_f orcedSubtreeInvalidationRectUpdateWithinContainer; } | 55 bool forcedSubtreeInvalidationRectUpdateWithinContainer() const { return m_f orcedSubtreeInvalidationRectUpdateWithinContainer; } |
| 60 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre eInvalidationRectUpdateWithinContainer = true; } | 56 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre eInvalidationRectUpdateWithinContainer = true; } |
| 61 | 57 |
| 62 const LayoutBoxModelObject& paintInvalidationContainer() const { return m_pa intInvalidationContainer; } | 58 const LayoutBoxModelObject& paintInvalidationContainer() const { return *m_p aintInvalidationContainer; } |
| 63 | 59 |
| 64 // Computes the position of the current object ((0,0) in the space of the ob ject) | 60 // Computes the position of the current object ((0,0) in the space of the ob ject) |
| 65 // in the space of paint invalidation backing. | 61 // in the space of paint invalidation backing. |
| 66 LayoutPoint computePositionFromPaintInvalidationBacking() const; | 62 LayoutPoint computePositionFromPaintInvalidationBacking() const; |
| 67 | 63 |
| 68 // Returns the rect bounds needed to invalidate paint of this object, | 64 // Returns the rect bounds needed to invalidate paint of this object, |
| 69 // in the space of paint invalidation backing. | 65 // in the space of paint invalidation backing. |
| 70 LayoutRect computePaintInvalidationRectInBacking() const; | 66 LayoutRect computePaintInvalidationRectInBacking() const; |
| 71 | 67 |
| 72 void mapLocalRectToPaintInvalidationBacking(LayoutRect&) const; | 68 void mapLocalRectToPaintInvalidationBacking(LayoutRect&) const; |
| 73 | 69 |
| 74 // Records |obj| as needing paint invalidation on the next frame. See the de finition of PaintInvalidationDelayedFull for more details. | 70 // Records |obj| as needing paint invalidation on the next frame. See the de finition of PaintInvalidationDelayedFull for more details. |
| 75 void pushDelayedPaintInvalidationTarget(LayoutObject& obj) const { m_pending DelayedPaintInvalidations.append(&obj); } | 71 void pushDelayedPaintInvalidationTarget(LayoutObject& obj) const { m_pending DelayedPaintInvalidations.append(&obj); } |
| 76 Vector<LayoutObject*>& pendingDelayedPaintInvalidationTargets() const { retu rn m_pendingDelayedPaintInvalidations; } | 72 Vector<LayoutObject*>& pendingDelayedPaintInvalidationTargets() const { retu rn m_pendingDelayedPaintInvalidations; } |
| 77 | 73 |
| 78 PaintLayer& enclosingSelfPaintingLayer(const LayoutObject&) const; | 74 PaintLayer& enclosingSelfPaintingLayer(const LayoutObject&) const; |
| 79 | 75 |
| 80 #if ENABLE(ASSERT) | 76 #if ENABLE(ASSERT) |
| 81 const LayoutObject& currentObject() const { return m_currentObject; } | 77 const LayoutObject& currentObject() const { return m_currentObject; } |
| 82 #endif | 78 #endif |
| 83 | 79 |
| 84 private: | 80 private: |
| 81 void updateForNormalChildren(); | |
| 82 | |
| 85 LayoutRect computePaintInvalidationRectInBackingForSVG() const; | 83 LayoutRect computePaintInvalidationRectInBackingForSVG() const; |
| 86 | 84 |
| 87 void addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect); | 85 void addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect); |
| 88 | 86 |
| 89 friend class ForceHorriblySlowRectMapping; | 87 friend class ForceHorriblySlowRectMapping; |
| 90 | 88 |
| 91 const LayoutObject& m_currentObject; | 89 const LayoutObject& m_currentObject; |
| 92 | 90 |
| 93 bool m_clipped; | |
| 94 mutable bool m_cachedOffsetsEnabled; | |
| 95 bool m_forcedSubtreeInvalidationWithinContainer; | 91 bool m_forcedSubtreeInvalidationWithinContainer; |
| 96 bool m_forcedSubtreeInvalidationRectUpdateWithinContainer; | 92 bool m_forcedSubtreeInvalidationRectUpdateWithinContainer; |
| 97 | 93 |
| 94 bool m_clipped; | |
| 95 bool m_clippedForAbsolutePosition; | |
| 96 | |
| 97 // Clip rect from paintInvalidationContainer if m_cachedOffsetsEnabled is tr ue. | |
| 98 LayoutRect m_clipRect; | 98 LayoutRect m_clipRect; |
| 99 LayoutRect m_clipRectForAbsolutePosition; | |
| 99 | 100 |
| 100 // x/y offset from paint invalidation container. Includes relative positioni ng and scroll offsets. | 101 // x/y offset from the paintInvalidationContainer if m_cachedOffsetsEnabled is true. |
| 102 // It includes relative positioning and scroll offsets. | |
| 101 LayoutSize m_paintOffset; | 103 LayoutSize m_paintOffset; |
| 104 LayoutSize m_paintOffsetForAbsolutePosition; | |
| 102 | 105 |
| 103 // The current paint invalidation container. | 106 // Whether m_paintOffset[XXX] and m_clipRect[XXX] are valid and can be used |
| 104 // | 107 // to map a rect from space of the current object to space of paintInvalidat ionContainer. |
| 108 mutable bool m_cachedOffsetsEnabled; | |
| 109 bool m_cachedOffsetsForAbsolutePositionEnabled; | |
| 110 | |
| 111 // The following two fields are never null. Declare them as pointers because we need some | |
| 112 // logic to initialize them in the body of the constructor. | |
| 113 | |
| 114 // The current paint invalidation container for normal flow objects. | |
| 105 // It is the enclosing composited object. | 115 // It is the enclosing composited object. |
| 106 const LayoutBoxModelObject& m_paintInvalidationContainer; | 116 const LayoutBoxModelObject* m_paintInvalidationContainer; |
| 117 | |
| 118 // The current paint invalidation container for stacked contents (stacking c ontexts or positioned objects). | |
| 119 // It is the nearest ancestor composited object which establishes a stacking context. | |
|
chrishtr
2016/03/31 22:06:05
Refer to README.md for details on how stacked cont
Xianzhu
2016/04/01 16:07:56
Done.
| |
| 120 const LayoutBoxModelObject* m_paintInvalidationContainerForStackedContents; | |
| 121 | |
| 122 const LayoutObject& m_containerForAbsolutePosition; | |
| 107 | 123 |
| 108 // Transform from the initial viewport coordinate system of an outermost | 124 // Transform from the initial viewport coordinate system of an outermost |
| 109 // SVG root to the userspace _before_ the relevant element. Combining this | 125 // SVG root to the userspace _before_ the relevant element. Combining this |
| 110 // with |m_paintOffset| yields the "final" offset. | 126 // with |m_paintOffset| yields the "final" offset. |
| 111 AffineTransform m_svgTransform; | 127 AffineTransform m_svgTransform; |
| 112 | 128 |
| 113 Vector<LayoutObject*>& m_pendingDelayedPaintInvalidations; | 129 Vector<LayoutObject*>& m_pendingDelayedPaintInvalidations; |
| 114 | 130 |
| 115 PaintLayer& m_enclosingSelfPaintingLayer; | 131 PaintLayer& m_enclosingSelfPaintingLayer; |
| 116 | 132 |
| 117 #if ENABLE(ASSERT) | 133 #if ENABLE(ASSERT) |
| 118 bool m_didUpdateForChildren; | 134 bool m_didUpdateForChildren; |
| 119 #endif | 135 #endif |
| 120 }; | 136 }; |
| 121 | 137 |
| 122 // Suspends the PaintInvalidationState cached offset and clipRect optimization. Used under transforms | |
| 123 // that cannot be represented by PaintInvalidationState (common in SVG) and when paint invalidation | |
| 124 // containers don't follow the common tree-walk algorithm (e.g. when an absolute positioned descendant | |
| 125 // is nested under a relatively positioned inline-block child). | |
| 126 class ForceHorriblySlowRectMapping { | |
| 127 STACK_ALLOCATED(); | |
| 128 WTF_MAKE_NONCOPYABLE(ForceHorriblySlowRectMapping); | |
| 129 public: | |
| 130 ForceHorriblySlowRectMapping(const PaintInvalidationState* paintInvalidation State) | |
| 131 : m_paintInvalidationState(paintInvalidationState) | |
| 132 , m_didDisable(m_paintInvalidationState && m_paintInvalidationState->m_c achedOffsetsEnabled) | |
| 133 { | |
| 134 if (m_paintInvalidationState) | |
| 135 m_paintInvalidationState->m_cachedOffsetsEnabled = false; | |
| 136 } | |
| 137 | |
| 138 ~ForceHorriblySlowRectMapping() | |
| 139 { | |
| 140 if (m_didDisable) | |
| 141 m_paintInvalidationState->m_cachedOffsetsEnabled = true; | |
| 142 } | |
| 143 private: | |
| 144 const PaintInvalidationState* m_paintInvalidationState; | |
| 145 bool m_didDisable; | |
| 146 }; | |
| 147 | |
| 148 } // namespace blink | 138 } // namespace blink |
| 149 | 139 |
| 150 #endif // PaintInvalidationState_h | 140 #endif // PaintInvalidationState_h |
| OLD | NEW |