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 30 matching lines...) Expand all Loading... |
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 PaintLayerClipper_h | 45 #ifndef PaintLayerClipper_h |
46 #define PaintLayerClipper_h | 46 #define PaintLayerClipper_h |
47 | 47 |
48 #include "core/CoreExport.h" | 48 #include "core/CoreExport.h" |
49 #include "core/layout/ClipRectsCache.h" | 49 #include "core/layout/ClipRectsCache.h" |
50 #include "core/layout/ScrollEnums.h" | 50 #include "core/layout/ScrollEnums.h" |
| 51 |
| 52 #include "platform/graphics/paint/GeometryMapper.h" |
| 53 |
51 #include "wtf/Allocator.h" | 54 #include "wtf/Allocator.h" |
52 | 55 |
53 namespace blink { | 56 namespace blink { |
54 | 57 |
55 class PaintLayer; | 58 class PaintLayer; |
56 | 59 |
57 enum ShouldRespectOverflowClipType { IgnoreOverflowClip, RespectOverflowClip }; | 60 enum ShouldRespectOverflowClipType { IgnoreOverflowClip, RespectOverflowClip }; |
58 | 61 |
59 class ClipRectsContext { | 62 class ClipRectsContext { |
60 STACK_ALLOCATED(); | 63 STACK_ALLOCATED(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 100 |
98 ClipRectsCacheSlot m_cacheSlot; | 101 ClipRectsCacheSlot m_cacheSlot; |
99 LayoutSize subPixelAccumulation; | 102 LayoutSize subPixelAccumulation; |
100 ShouldRespectOverflowClipType respectOverflowClip; | 103 ShouldRespectOverflowClipType respectOverflowClip; |
101 ShouldRespectOverflowClipType respectOverflowClipForViewport; | 104 ShouldRespectOverflowClipType respectOverflowClipForViewport; |
102 }; | 105 }; |
103 | 106 |
104 // PaintLayerClipper is responsible for computing and caching clip | 107 // PaintLayerClipper is responsible for computing and caching clip |
105 // rects. | 108 // rects. |
106 // | 109 // |
| 110 // These clip rects have two types: background and foreground. |
| 111 // |
| 112 // The "background rect" for a PaintLayer is almost the same as its visual |
| 113 // rect in the space of some ancestor PaintLayer (specified by rootLayer on |
| 114 // ClipRectsContext). |
| 115 // The only differences are that: |
| 116 // * The unclipped rect at the start is LayoutRect::infiniteIntRect, |
| 117 // rather than the local overflow bounds of the PaintLayer. |
| 118 // * CSS clip, the extent of visualOverflowRect(), and SVG root viewport |
| 119 // clipping is applied. |
| 120 // Thus, for example if there are no clips then the background rect will be |
| 121 // infinite. Also, whether overflow clip of the ancestor should be applied is a |
| 122 // parameter. |
| 123 // |
| 124 // The "foreground rect" for a PaintLayer is its "background rect", intersected |
| 125 // with any clip applied by this PaintLayer to its children. |
| 126 |
| 127 // Motivation for this class: |
| 128 // |
107 // The main reason for this cache is that we compute the clip rects during | 129 // The main reason for this cache is that we compute the clip rects during |
108 // a layout tree walk but need them during a paint tree walk (see example | 130 // a layout tree walk but need them during a paint tree walk (see example |
109 // below for some explanations). | 131 // below for some explanations). |
110 // | 132 // |
111 // A lot of complexity in this class come from the difference in inheritance | 133 // A lot of complexity in this class come from the difference in inheritance |
112 // between 'overflow' and 'clip': | 134 // between 'overflow' and 'clip': |
113 // * 'overflow' applies based on the containing blocks chain. | 135 // * 'overflow' applies based on the containing blocks chain. |
114 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow) | 136 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow) |
115 // * 'clip' applies to all descendants. | 137 // * 'clip' applies to all descendants. |
116 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-clip) | 138 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-clip) |
(...skipping 26 matching lines...) Expand all Loading... |
143 // Now instead if we add "clip: rect(0px, 100px, 100px, 0px)" to #container, | 165 // Now instead if we add "clip: rect(0px, 100px, 100px, 0px)" to #container, |
144 // the clip will apply to both #inflow and #fixed. That's because 'clip' | 166 // the clip will apply to both #inflow and #fixed. That's because 'clip' |
145 // applies to any descendant, regardless of containing blocks. Note that | 167 // applies to any descendant, regardless of containing blocks. Note that |
146 // #container and #fixed are siblings in the paint tree but #container does | 168 // #container and #fixed are siblings in the paint tree but #container does |
147 // clip #fixed. This is the reason why we compute the painting clip rects during | 169 // clip #fixed. This is the reason why we compute the painting clip rects during |
148 // a layout tree walk and cache them for painting. | 170 // a layout tree walk and cache them for painting. |
149 class CORE_EXPORT PaintLayerClipper { | 171 class CORE_EXPORT PaintLayerClipper { |
150 DISALLOW_NEW(); | 172 DISALLOW_NEW(); |
151 | 173 |
152 public: | 174 public: |
153 explicit PaintLayerClipper(const PaintLayer& layer) : m_layer(layer) {} | 175 explicit PaintLayerClipper(const PaintLayer&, bool useGeometryMapper); |
154 | 176 |
155 void clearClipRectsIncludingDescendants(); | 177 void clearClipRectsIncludingDescendants(); |
156 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); | 178 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); |
157 | 179 |
158 // Returns the background clip rect of the layer in the local coordinate | 180 // Returns the background clip rect of the layer in the local coordinate |
159 // space. Only looks for clips up to the given ancestor. | 181 // space. Only looks for clips up to the given ancestor. |
160 LayoutRect localClipRect(const PaintLayer* ancestorLayer) const; | 182 LayoutRect localClipRect(const PaintLayer* ancestorLayer) const; |
161 | 183 |
| 184 // Computes the same thing as backgroundRect in calculateRects(), but skips |
| 185 // apllying CSS clip and the visualOverflowRect() of |m_layer|. |
162 ClipRect backgroundClipRect(const ClipRectsContext&) const; | 186 ClipRect backgroundClipRect(const ClipRectsContext&) const; |
163 | 187 |
164 // This method figures out our layerBounds in coordinates relative to | 188 // This method figures out our layerBounds in coordinates relative to |
165 // |rootLayer|. It also computes our background and foreground clip rects | 189 // |rootLayer|. It also computes our background and foreground clip rects |
166 // for painting/event handling. | 190 // for painting/event handling. Pass offsetFromRoot if known. |
167 // Pass offsetFromRoot if known. | |
168 void calculateRects(const ClipRectsContext&, | 191 void calculateRects(const ClipRectsContext&, |
169 const LayoutRect& paintDirtyRect, | 192 const LayoutRect& paintDirtyRect, |
170 LayoutRect& layerBounds, | 193 LayoutRect& layerBounds, |
171 ClipRect& backgroundRect, | 194 ClipRect& backgroundRect, |
172 ClipRect& foregroundRect, | 195 ClipRect& foregroundRect, |
173 const LayoutPoint* offsetFromRoot = 0) const; | 196 const LayoutPoint* offsetFromRoot = 0) const; |
174 | 197 |
175 ClipRects& paintingClipRects(const PaintLayer* rootLayer, | 198 ClipRects& paintingClipRects(const PaintLayer* rootLayer, |
176 ShouldRespectOverflowClipType, | 199 ShouldRespectOverflowClipType, |
177 const LayoutSize& subpixelAccumulation) const; | 200 const LayoutSize& subpixelAccumulation) const; |
178 | 201 |
179 private: | 202 private: |
180 ClipRects& getClipRects(const ClipRectsContext&) const; | 203 ClipRects& getClipRects(const ClipRectsContext&) const; |
181 | 204 |
182 void calculateClipRects(const ClipRectsContext&, ClipRects&) const; | 205 void calculateClipRects(const ClipRectsContext&, ClipRects&) const; |
183 ClipRects* clipRectsIfCached(const ClipRectsContext&) const; | 206 ClipRects* clipRectsIfCached(const ClipRectsContext&) const; |
184 ClipRects& storeClipRectsInCache(const ClipRectsContext&, | 207 ClipRects& storeClipRectsInCache(const ClipRectsContext&, |
185 ClipRects* parentClipRects, | 208 ClipRects* parentClipRects, |
186 const ClipRects&) const; | 209 const ClipRects&) const; |
187 | 210 |
188 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const; | 211 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const; |
189 | 212 |
190 bool shouldRespectOverflowClip(const ClipRectsContext&) const; | 213 bool shouldRespectOverflowClip(const ClipRectsContext&) const; |
191 | 214 |
| 215 ClipRect clipRectWithGeometryMapper(const ClipRectsContext&, |
| 216 bool isForeground) const; |
| 217 void mapLocalToRootWithGeometryMapper(const ClipRectsContext&, |
| 218 LayoutRect& localRect) const; |
| 219 void calculateRectsWithGeometryMapper( |
| 220 const ClipRectsContext&, |
| 221 const LayoutRect& paintDirtyRect, |
| 222 LayoutRect& layerBounds, |
| 223 ClipRect& backgroundRect, |
| 224 ClipRect& foregroundRect, |
| 225 const LayoutPoint* offsetFromRoot = 0) const; |
| 226 |
| 227 ClipRect applyOverflowClipToBackgroundRectWithGeometryMapper( |
| 228 const ClipRectsContext&, |
| 229 const ClipRect&) const; |
| 230 |
192 const PaintLayer& m_layer; | 231 const PaintLayer& m_layer; |
| 232 std::unique_ptr<GeometryMapper> m_geometryMapper; |
193 }; | 233 }; |
194 | 234 |
195 } // namespace blink | 235 } // namespace blink |
196 | 236 |
197 #endif // LayerClipper_h | 237 #endif // LayerClipper_h |
OLD | NEW |