| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // depending on the 'position' of the elements. | 142 // depending on the 'position' of the elements. |
| 143 // | 143 // |
| 144 // Now instead if we add "clip: rect(0px, 100px, 100px, 0px)" to #container, | 144 // Now instead if we add "clip: rect(0px, 100px, 100px, 0px)" to #container, |
| 145 // the clip will apply to both #inflow and #fixed. That's because 'clip' | 145 // the clip will apply to both #inflow and #fixed. That's because 'clip' |
| 146 // applies to any descendant, regardless of containing blocks. Note that | 146 // applies to any descendant, regardless of containing blocks. Note that |
| 147 // #container and #fixed are siblings in the paint tree but #container does | 147 // #container and #fixed are siblings in the paint tree but #container does |
| 148 // clip #fixed. This is the reason why we compute the painting clip rects during | 148 // clip #fixed. This is the reason why we compute the painting clip rects during |
| 149 // a layout tree walk and cache them for painting. | 149 // a layout tree walk and cache them for painting. |
| 150 class CORE_EXPORT PaintLayerClipper { | 150 class CORE_EXPORT PaintLayerClipper { |
| 151 DISALLOW_NEW(); | 151 DISALLOW_NEW(); |
| 152 WTF_MAKE_NONCOPYABLE(PaintLayerClipper); | |
| 153 public: | 152 public: |
| 154 explicit PaintLayerClipper(const LayoutBoxModelObject&); | 153 explicit PaintLayerClipper(const PaintLayer& layer) : m_layer(layer) { } |
| 155 | 154 |
| 156 void clearClipRectsIncludingDescendants(); | 155 void clearClipRectsIncludingDescendants(); |
| 157 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); | 156 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); |
| 158 | 157 |
| 159 // Returns the background clip rect of the layer in the local coordinate spa
ce. Only looks for clips up to the given ancestor. | 158 // 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; | 159 LayoutRect localClipRect(const PaintLayer* ancestorLayer) const; |
| 161 | 160 |
| 162 ClipRect backgroundClipRect(const ClipRectsContext&) const; | 161 ClipRect backgroundClipRect(const ClipRectsContext&) const; |
| 163 | 162 |
| 164 // This method figures out our layerBounds in coordinates relative to | 163 // This method figures out our layerBounds in coordinates relative to |
| 165 // |rootLayer|. It also computes our background and foreground clip rects | 164 // |rootLayer|. It also computes our background and foreground clip rects |
| 166 // for painting/event handling. | 165 // for painting/event handling. |
| 167 // Pass offsetFromRoot if known. | 166 // Pass offsetFromRoot if known. |
| 168 void calculateRects(const ClipRectsContext&, const LayoutRect& paintDirtyRec
t, LayoutRect& layerBounds, | 167 void calculateRects(const ClipRectsContext&, const LayoutRect& paintDirtyRec
t, LayoutRect& layerBounds, |
| 169 ClipRect& backgroundRect, ClipRect& foregroundRect, const LayoutPoint* o
ffsetFromRoot = 0) const; | 168 ClipRect& backgroundRect, ClipRect& foregroundRect, const LayoutPoint* o
ffsetFromRoot = 0) const; |
| 170 | 169 |
| 171 ClipRects* paintingClipRects(const PaintLayer* rootLayer, ShouldRespectOverf
lowClip, const LayoutSize& subpixelAccumulation) const; | 170 ClipRects& paintingClipRects(const PaintLayer* rootLayer, ShouldRespectOverf
lowClip, const LayoutSize& subpixelAccumulation) const; |
| 172 | 171 |
| 173 private: | 172 private: |
| 174 ClipRects* getClipRects(const ClipRectsContext&) const; | 173 ClipRects& getClipRects(const ClipRectsContext&) const; |
| 175 | 174 |
| 176 void calculateClipRects(const ClipRectsContext&, ClipRects&) const; | 175 void calculateClipRects(const ClipRectsContext&, ClipRects&) const; |
| 177 ClipRects* clipRectsIfCached(const ClipRectsContext&) const; | 176 ClipRects* clipRectsIfCached(const ClipRectsContext&) const; |
| 178 ClipRects* storeClipRectsInCache(const ClipRectsContext&, ClipRects* parentC
lipRects, const ClipRects&) const; | 177 ClipRects& storeClipRectsInCache(const ClipRectsContext&, ClipRects* parentC
lipRects, const ClipRects&) const; |
| 179 | 178 |
| 180 // cachedClipRects looks buggy: It doesn't check whether context.rootLayer a
nd entry.root match. | |
| 181 // FIXME: Move callers to clipRectsIfCached, which does the proper checks. | |
| 182 ClipRects* cachedClipRects(const ClipRectsContext& context) const | |
| 183 { | |
| 184 return m_cache ? m_cache->get(context.cacheSlot()).clipRects.get() : 0; | |
| 185 } | |
| 186 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const; | 179 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const; |
| 187 | 180 |
| 188 ClipRectsCache& cache() const | |
| 189 { | |
| 190 if (!m_cache) | |
| 191 m_cache = adoptPtr(new ClipRectsCache); | |
| 192 return *m_cache; | |
| 193 } | |
| 194 | |
| 195 bool shouldRespectOverflowClip(const ClipRectsContext&) const; | 181 bool shouldRespectOverflowClip(const ClipRectsContext&) const; |
| 196 | 182 |
| 197 // FIXME: Could this be a LayoutBox? | 183 const PaintLayer& m_layer; |
| 198 const LayoutBoxModelObject& m_layoutObject; | |
| 199 | |
| 200 // Lazily created by 'cache() const'. | |
| 201 mutable OwnPtr<ClipRectsCache> m_cache; | |
| 202 }; | 184 }; |
| 203 | 185 |
| 204 } // namespace blink | 186 } // namespace blink |
| 205 | 187 |
| 206 #endif // LayerClipper_h | 188 #endif // LayerClipper_h |
| OLD | NEW |