| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // #container and thus 'overflow' doesn't apply to it. During our tree walk, | 140 // #container and thus 'overflow' doesn't apply to it. During our tree walk, |
| 141 // #fixed is a child of #container, which is the reason why we keep 3 clip rects | 141 // #fixed is a child of #container, which is the reason why we keep 3 clip rects |
| 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 PaintLayerClipper { | 150 class CORE_EXPORT PaintLayerClipper { |
| 151 DISALLOW_NEW(); | 151 DISALLOW_NEW(); |
| 152 WTF_MAKE_NONCOPYABLE(PaintLayerClipper); | 152 WTF_MAKE_NONCOPYABLE(PaintLayerClipper); |
| 153 public: | 153 public: |
| 154 explicit PaintLayerClipper(const LayoutBoxModelObject&); | 154 explicit PaintLayerClipper(const LayoutBoxModelObject&); |
| 155 | 155 |
| 156 void clearClipRectsIncludingDescendants(); | 156 void clearClipRectsIncludingDescendants(); |
| 157 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); | 157 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); |
| 158 | 158 |
| 159 LayoutRect childrenClipRect() const; // Returns the foreground clip rect of
the layer in the document's coordinate space. | |
| 160 | |
| 161 // Returns the background clip rect of the layer in the local coordinate spa
ce. Only looks for clips up to the given ancestor. | 159 // Returns the background clip rect of the layer in the local coordinate spa
ce. Only looks for clips up to the given ancestor. |
| 162 LayoutRect localClipRect(const PaintLayer* ancestorLayer) const; | 160 LayoutRect localClipRect(const PaintLayer* ancestorLayer) const; |
| 163 | 161 |
| 164 ClipRect backgroundClipRect(const ClipRectsContext&) const; | 162 ClipRect backgroundClipRect(const ClipRectsContext&) const; |
| 165 | 163 |
| 166 // This method figures out our layerBounds in coordinates relative to | 164 // This method figures out our layerBounds in coordinates relative to |
| 167 // |rootLayer|. It also computes our background and foreground clip rects | 165 // |rootLayer|. It also computes our background and foreground clip rects |
| 168 // for painting/event handling. | 166 // for painting/event handling. |
| 169 // Pass offsetFromRoot if known. | 167 // Pass offsetFromRoot if known. |
| 170 void calculateRects(const ClipRectsContext&, const LayoutRect& paintDirtyRec
t, LayoutRect& layerBounds, | 168 void calculateRects(const ClipRectsContext&, const LayoutRect& paintDirtyRec
t, LayoutRect& layerBounds, |
| 171 ClipRect& backgroundRect, ClipRect& foregroundRect, const LayoutPoint* o
ffsetFromRoot = 0) const; | 169 ClipRect& backgroundRect, ClipRect& foregroundRect, const LayoutPoint* o
ffsetFromRoot = 0) const; |
| 172 private: | 170 private: |
| 173 ClipRects* getClipRects(const ClipRectsContext&) const; | 171 ClipRects* getClipRects(const ClipRectsContext&) const; |
| 174 | 172 |
| 175 void calculateClipRects(const ClipRectsContext&, ClipRects&) const; | 173 void calculateClipRects(const ClipRectsContext&, ClipRects&) const; |
| 176 ClipRects* clipRectsIfCached(const ClipRectsContext&) const; | 174 ClipRects* clipRectsIfCached(const ClipRectsContext&) const; |
| 177 ClipRects* storeClipRectsInCache(const ClipRectsContext&, ClipRects* parentC
lipRects, const ClipRects&) const; | 175 ClipRects* storeClipRectsInCache(const ClipRectsContext&, ClipRects* parentC
lipRects, const ClipRects&) const; |
| 178 | 176 |
| 179 // cachedClipRects looks buggy: It doesn't check whether context.rootLayer a
nd entry.root match. | 177 // cachedClipRects looks buggy: It doesn't check whether context.rootLayer a
nd entry.root match. |
| 180 // FIXME: Move callers to clipRectsIfCached, which does the proper checks. | 178 // FIXME: Move callers to clipRectsIfCached, which does the proper checks. |
| 181 ClipRects* cachedClipRects(const ClipRectsContext& context) const | 179 ClipRects* cachedClipRects(const ClipRectsContext& context) const |
| 182 { | 180 { |
| 183 return m_cache ? m_cache->get(context.cacheSlot()).clipRects.get() : 0; | 181 return m_cache ? m_cache->get(context.cacheSlot()).clipRects.get() : 0; |
| 184 } | 182 } |
| 185 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const; | 183 void getOrCalculateClipRects(const ClipRectsContext&, ClipRects&) const; |
| 186 | 184 |
| 187 PaintLayer* clippingRootForPainting() const; | |
| 188 | |
| 189 ClipRectsCache& cache() const | 185 ClipRectsCache& cache() const |
| 190 { | 186 { |
| 191 if (!m_cache) | 187 if (!m_cache) |
| 192 m_cache = adoptPtr(new ClipRectsCache); | 188 m_cache = adoptPtr(new ClipRectsCache); |
| 193 return *m_cache; | 189 return *m_cache; |
| 194 } | 190 } |
| 195 | 191 |
| 196 bool shouldRespectOverflowClip(const ClipRectsContext&) const; | 192 bool shouldRespectOverflowClip(const ClipRectsContext&) const; |
| 197 | 193 |
| 198 // FIXME: Could this be a LayoutBox? | 194 // FIXME: Could this be a LayoutBox? |
| 199 const LayoutBoxModelObject& m_layoutObject; | 195 const LayoutBoxModelObject& m_layoutObject; |
| 200 | 196 |
| 201 // Lazily created by 'cache() const'. | 197 // Lazily created by 'cache() const'. |
| 202 mutable OwnPtr<ClipRectsCache> m_cache; | 198 mutable OwnPtr<ClipRectsCache> m_cache; |
| 203 }; | 199 }; |
| 204 | 200 |
| 205 } // namespace blink | 201 } // namespace blink |
| 206 | 202 |
| 207 #endif // LayerClipper_h | 203 #endif // LayerClipper_h |
| OLD | NEW |