Chromium Code Reviews| 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/ClipPaintPropertyNode.h" | |
|
Xianzhu
2016/08/15 17:09:04
Nit: The XXXPaintPropertyNode.h headers are actual
chrishtr
2016/10/05 23:28:32
Done.
| |
| 53 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | |
| 54 #include "platform/graphics/paint/GeometryMapper.h" | |
| 55 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | |
| 56 | |
| 51 #include "wtf/Allocator.h" | 57 #include "wtf/Allocator.h" |
| 52 | 58 |
| 53 namespace blink { | 59 namespace blink { |
| 54 | 60 |
| 55 class PaintLayer; | 61 class PaintLayer; |
| 56 | 62 |
| 57 enum ShouldRespectOverflowClipType { | 63 enum ShouldRespectOverflowClipType { |
| 58 IgnoreOverflowClip, | 64 IgnoreOverflowClip, |
| 59 RespectOverflowClip | 65 RespectOverflowClip |
| 60 }; | 66 }; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 | 105 |
| 100 ClipRectsCacheSlot m_cacheSlot; | 106 ClipRectsCacheSlot m_cacheSlot; |
| 101 LayoutSize subPixelAccumulation; | 107 LayoutSize subPixelAccumulation; |
| 102 ShouldRespectOverflowClipType respectOverflowClip; | 108 ShouldRespectOverflowClipType respectOverflowClip; |
| 103 ShouldRespectOverflowClipType respectOverflowClipForViewport; | 109 ShouldRespectOverflowClipType respectOverflowClipForViewport; |
| 104 }; | 110 }; |
| 105 | 111 |
| 106 // PaintLayerClipper is responsible for computing and caching clip | 112 // PaintLayerClipper is responsible for computing and caching clip |
| 107 // rects. | 113 // rects. |
| 108 // | 114 // |
| 115 // These clip rects have two types: background and foreground. | |
| 116 // | |
| 117 // The "background rect" for a PaintLayer is almost the same as its visual | |
| 118 // rect in the space of some ancestor PaintLayer (specified by a parameter). | |
| 119 // The only difference is that unclipped rect at the start is LayoutRect::infini teIntRect, | |
| 120 // rather than the local overflow bounds of the PaintLayer. Thus, for example | |
| 121 // if there are no clips then the background rect will be infinite. | |
| 122 // Also, whether overflow clip of the ancestor should be applied is a 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 // | |
| 109 // 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 |
| 110 // 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 |
| 111 // below for some explanations). | 131 // below for some explanations). |
| 112 // | 132 // |
| 113 // 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 |
| 114 // between 'overflow' and 'clip': | 134 // between 'overflow' and 'clip': |
| 115 // * 'overflow' applies based on the containing blocks chain. | 135 // * 'overflow' applies based on the containing blocks chain. |
| 116 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow) | 136 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow) |
| 117 // * 'clip' applies to all descendants. | 137 // * 'clip' applies to all descendants. |
| 118 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-clip) | 138 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-clip) |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 144 // | 164 // |
| 145 // 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, |
| 146 // 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' |
| 147 // applies to any descendant, regardless of containing blocks. Note that | 167 // applies to any descendant, regardless of containing blocks. Note that |
| 148 // #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 |
| 149 // 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 |
| 150 // a layout tree walk and cache them for painting. | 170 // a layout tree walk and cache them for painting. |
| 151 class CORE_EXPORT PaintLayerClipper { | 171 class CORE_EXPORT PaintLayerClipper { |
| 152 DISALLOW_NEW(); | 172 DISALLOW_NEW(); |
| 153 public: | 173 public: |
| 154 explicit PaintLayerClipper(const PaintLayer& layer) : m_layer(layer) { } | 174 explicit PaintLayerClipper(const PaintLayer&); |
| 155 | 175 |
| 156 void clearClipRectsIncludingDescendants(); | 176 void clearClipRectsIncludingDescendants(); |
| 157 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); | 177 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); |
| 158 | 178 |
| 159 // Returns the background clip rect of the layer in the local coordinate spa ce. Only looks for clips up to the given ancestor. | 179 // Returns the background clip rect of the layer in the local coordinate spa ce. Only looks for clips up to the given ancestor. |
| 160 LayoutRect localClipRect(const PaintLayer* ancestorLayer) const; | 180 LayoutRect localClipRect(const PaintLayer* ancestorLayer) const; |
| 161 | 181 |
| 162 ClipRect backgroundClipRect(const ClipRectsContext&) const; | 182 ClipRect backgroundClipRect(const ClipRectsContext&) const; |
| 163 | 183 |
| 164 // This method figures out our layerBounds in coordinates relative to | 184 // This method figures out our layerBounds in coordinates relative to |
| 165 // |rootLayer|. It also computes our background and foreground clip rects | 185 // |rootLayer|. It also computes our background and foreground clip rects |
| 166 // for painting/event handling. | 186 // for painting/event handling. |
| 167 // Pass offsetFromRoot if known. | 187 // Pass offsetFromRoot if known. |
| 168 void calculateRects(const ClipRectsContext&, const LayoutRect& paintDirtyRec t, LayoutRect& layerBounds, | 188 void calculateRects(const ClipRectsContext&, const LayoutRect& paintDirtyRec t, LayoutRect& layerBounds, |
| 169 ClipRect& backgroundRect, ClipRect& foregroundRect, const LayoutPoint* o ffsetFromRoot = 0) const; | 189 ClipRect& backgroundRect, ClipRect& foregroundRect, const LayoutPoint* o ffsetFromRoot = 0) const; |
| 170 | 190 |
| 171 ClipRects& paintingClipRects(const PaintLayer* rootLayer, ShouldRespectOverf lowClipType, const LayoutSize& subpixelAccumulation) const; | 191 ClipRects& paintingClipRects(const PaintLayer* rootLayer, ShouldRespectOverf lowClipType, const LayoutSize& subpixelAccumulation) const; |
| 172 | 192 |
| 173 private: | 193 private: |
| 174 ClipRects& getClipRects(const ClipRectsContext&) const; | 194 ClipRects& getClipRects(const ClipRectsContext&) const; |
| 175 | 195 |
| 176 void calculateClipRects(const ClipRectsContext&, ClipRects&) const; | 196 void calculateClipRects(const ClipRectsContext&, ClipRects&) const; |
| 177 ClipRects* clipRectsIfCached(const ClipRectsContext&) const; | 197 ClipRects* clipRectsIfCached(const ClipRectsContext&) const; |
| 178 ClipRects& storeClipRectsInCache(const ClipRectsContext&, ClipRects* parentC lipRects, const ClipRects&) const; | 198 ClipRects& storeClipRectsInCache(const ClipRectsContext&, ClipRects* parentC lipRects, const ClipRects&) const; |
| 179 | 199 |
| 180 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const; | 200 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const; |
| 181 | 201 |
| 182 bool shouldRespectOverflowClip(const ClipRectsContext&) const; | 202 bool shouldRespectOverflowClip(const ClipRectsContext&) const; |
| 183 | 203 |
| 204 ClipRect clipRectWithGeometryMapper(const ClipRectsContext&, bool isForegrou nd) const; | |
| 205 | |
| 184 const PaintLayer& m_layer; | 206 const PaintLayer& m_layer; |
| 207 std::unique_ptr<GeometryMapper> m_geometryMapper; | |
| 185 }; | 208 }; |
| 186 | 209 |
| 187 } // namespace blink | 210 } // namespace blink |
| 188 | 211 |
| 189 #endif // LayerClipper_h | 212 #endif // LayerClipper_h |
| OLD | NEW |