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 27 matching lines...) Expand all Loading... |
38 * version of this file under the LGPL, indicate your decision by | 38 * version of this file under the LGPL, indicate your decision by |
39 * deletingthe provisions above and replace them with the notice and | 39 * deletingthe provisions above and replace them with the notice and |
40 * other provisions required by the MPL or the GPL, as the case may be. | 40 * other provisions required by the MPL or the GPL, as the case may be. |
41 * If you do not delete the provisions above, a recipient may use your | 41 * If you do not delete the provisions above, a recipient may use your |
42 * version of this file under any of the LGPL, the MPL or the GPL. | 42 * version of this file under any of the LGPL, the MPL or the GPL. |
43 */ | 43 */ |
44 | 44 |
45 #ifndef DeprecatedPaintLayerClipper_h | 45 #ifndef DeprecatedPaintLayerClipper_h |
46 #define DeprecatedPaintLayerClipper_h | 46 #define DeprecatedPaintLayerClipper_h |
47 | 47 |
48 #include "core/layout/ClipRects.h" | |
49 #include "core/layout/ClipRectsCache.h" | 48 #include "core/layout/ClipRectsCache.h" |
50 #include "core/layout/LayoutBox.h" | 49 #include "core/layout/LayoutBox.h" |
51 #include "wtf/Allocator.h" | 50 #include "wtf/Allocator.h" |
52 | 51 |
53 namespace blink { | 52 namespace blink { |
54 | 53 |
55 class DeprecatedPaintLayer; | 54 class DeprecatedPaintLayer; |
56 | 55 |
57 // This is the state information passed down | |
58 // on the stack for calculating clip rects. | |
59 struct ClipRectComputationState { | |
60 STACK_ALLOCATED(); | |
61 ClipRectComputationState() | |
62 { | |
63 currentClipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())); | |
64 stackingContextClipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())
); | |
65 } | |
66 // Depending on the value of context.isComputingPaintingRect() can have diff
erent meanings | |
67 // In painting, this ClipRects is used for statically positioned elements, | |
68 // outside painting, it is the only ClipRects, and is used for all elements. | |
69 ClipRects currentClipRects; | |
70 // During painting this ClipRects is used for positioned elements. It can ha
ve | |
71 // a rootLayer further up the tree than currentClipRects because its root mu
st be | |
72 // beyond the enclosing stacking context. See resetPaintRects. | |
73 ClipRects stackingContextClipRects; | |
74 }; | |
75 | |
76 enum ShouldRespectOverflowClip { | 56 enum ShouldRespectOverflowClip { |
77 IgnoreOverflowClip, | 57 IgnoreOverflowClip, |
78 RespectOverflowClip | 58 RespectOverflowClip |
79 }; | 59 }; |
80 | 60 |
81 class ClipRectsContext { | 61 class ClipRectsContext { |
82 STACK_ALLOCATED(); | 62 STACK_ALLOCATED(); |
83 public: | 63 public: |
84 ClipRectsContext(const DeprecatedPaintLayer* root, ClipRectsCacheSlot slot,
OverlayScrollbarSizeRelevancy relevancy = IgnoreOverlayScrollbarSize, const Layo
utSize& accumulation = LayoutSize()) | 64 ClipRectsContext(const DeprecatedPaintLayer* root, ClipRectsCacheSlot slot,
OverlayScrollbarSizeRelevancy relevancy = IgnoreOverlayScrollbarSize, const Layo
utSize& accumulation = LayoutSize()) |
85 : rootLayer(root) | 65 : rootLayer(root) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 ClipRects* getClipRects(const ClipRectsContext&) const; | 122 ClipRects* getClipRects(const ClipRectsContext&) const; |
143 | 123 |
144 ClipRect backgroundClipRect(const ClipRectsContext&) const; | 124 ClipRect backgroundClipRect(const ClipRectsContext&) const; |
145 | 125 |
146 // This method figures out our layerBounds in coordinates relative to | 126 // This method figures out our layerBounds in coordinates relative to |
147 // |rootLayer|. It also computes our background and foreground clip rects | 127 // |rootLayer|. It also computes our background and foreground clip rects |
148 // for painting/event handling. | 128 // for painting/event handling. |
149 // Pass offsetFromRoot if known. | 129 // Pass offsetFromRoot if known. |
150 void calculateRects(const ClipRectsContext&, const LayoutRect& paintDirtyRec
t, LayoutRect& layerBounds, | 130 void calculateRects(const ClipRectsContext&, const LayoutRect& paintDirtyRec
t, LayoutRect& layerBounds, |
151 ClipRect& backgroundRect, ClipRect& foregroundRect, ClipRect& outlineRec
t, const LayoutPoint* offsetFromRoot = 0) const; | 131 ClipRect& backgroundRect, ClipRect& foregroundRect, ClipRect& outlineRec
t, const LayoutPoint* offsetFromRoot = 0) const; |
152 void calculateClipRects(const ClipRectsContext&, ClipRectComputationState&)
const; | 132 private: |
| 133 void calculateClipRects(const ClipRectsContext&, ClipRects&) const; |
| 134 ClipRects* clipRectsIfCached(const ClipRectsContext&) const; |
| 135 ClipRects* storeClipRectsInCache(const ClipRectsContext&, ClipRects* parentC
lipRects, const ClipRects&) const; |
| 136 |
| 137 // cachedClipRects looks buggy: It doesn't check whether context.rootLayer a
nd entry.root match. |
| 138 // FIXME: Move callers to clipRectsIfCached, which does the proper checks. |
| 139 ClipRects* cachedClipRects(const ClipRectsContext& context) const |
| 140 { |
| 141 return m_cache ? m_cache->get(context.cacheSlot()).clipRects.get() : 0; |
| 142 } |
| 143 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const; |
153 | 144 |
154 DeprecatedPaintLayer* clippingRootForPainting() const; | 145 DeprecatedPaintLayer* clippingRootForPainting() const; |
155 | 146 |
156 void precalculateAbsoluteClipRects(); | 147 ClipRectsCache& cache() const |
157 | 148 { |
158 private: | 149 if (!m_cache) |
159 void setClipRect(const ClipRectsContext&, const ClipRectComputationState&) c
onst; | 150 m_cache = adoptPtr(new ClipRectsCache); |
160 void addClipsFromThisObject(const ClipRectsContext&, ClipRects&) const; | 151 return *m_cache; |
161 void updateClipRectBasedOnPosition(ClipRects*) const; | 152 } |
162 | |
163 ClipRect uncachedBackgroundClipRect(const ClipRectsContext&) const; | |
164 void uncachedCalculateClipRects(const ClipRectsContext&, ClipRects&) const; | |
165 | 153 |
166 bool shouldRespectOverflowClip(const ClipRectsContext&) const; | 154 bool shouldRespectOverflowClip(const ClipRectsContext&) const; |
167 | 155 |
168 // FIXME: Could this be a LayoutBox? | 156 // FIXME: Could this be a LayoutBox? |
169 LayoutBoxModelObject& m_layoutObject; | 157 LayoutBoxModelObject& m_layoutObject; |
170 mutable OwnPtr<ClipRect> m_clips[NumberOfClipRectsCacheSlots]; | 158 mutable OwnPtr<ClipRectsCache> m_cache; |
171 }; | 159 }; |
172 | 160 |
173 } // namespace blink | 161 } // namespace blink |
174 | 162 |
175 #endif // LayerClipper_h | 163 #endif // LayerClipper_h |
OLD | NEW |