| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 friend class DeprecatedPaintLayerClipper; | 122 friend class DeprecatedPaintLayerClipper; |
| 123 | 123 |
| 124 ClipRectsCacheSlot m_cacheSlot; | 124 ClipRectsCacheSlot m_cacheSlot; |
| 125 LayoutSize subPixelAccumulation; | 125 LayoutSize subPixelAccumulation; |
| 126 ShouldRespectOverflowClip respectOverflowClip; | 126 ShouldRespectOverflowClip respectOverflowClip; |
| 127 ShouldRespectOverflowClip respectOverflowClipForViewport; | 127 ShouldRespectOverflowClip respectOverflowClipForViewport; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 // DeprecatedPaintLayerClipper is responsible for computing and caching clip | |
| 131 // rects. | |
| 132 // | |
| 133 // The main reason for this cache is that we compute the clip rects during | |
| 134 // a layout tree walk but need them during a paint tree walk (see example | |
| 135 // below for some explanations). | |
| 136 // | |
| 137 // A lot of complexity in this class come from the difference in inheritance | |
| 138 // between 'overflow' and 'clip': | |
| 139 // * 'overflow' applies based on the containing blocks chain. | |
| 140 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow) | |
| 141 // * 'clip' applies to all descendants. | |
| 142 // (http://www.w3.org/TR/CSS2/visufx.html#propdef-clip) | |
| 143 // | |
| 144 // Let's take an example: | |
| 145 // <!DOCTYPE html> | |
| 146 // <div id="container" style="position: absolute; height: 100px; width: 100px"> | |
| 147 // <div id="inflow" style="height: 200px; width: 200px; | |
| 148 // background-color: purple"></div> | |
| 149 // <div id="fixed" style="height: 200px; width: 200px; position: fixed; | |
| 150 // background-color: orange"></div> | |
| 151 // </div> | |
| 152 // | |
| 153 // The paint tree looks like: | |
| 154 // html | |
| 155 // / \ | |
| 156 // / \ | |
| 157 // / \ | |
| 158 // container fixed | |
| 159 // | | |
| 160 // | | |
| 161 // inflow | |
| 162 // | |
| 163 // If we add "overflow: hidden" to #container, the overflow clip will apply to | |
| 164 // #inflow but not to #fixed. That's because #fixed's containing block is above | |
| 165 // #container and thus 'overflow' doesn't apply to it. During our tree walk, | |
| 166 // #fixed is a child of #container, which is the reason why we keep 3 clip rects | |
| 167 // depending on the 'position' of the elements. | |
| 168 // | |
| 169 // Now instead if we add "clip: rect(0px, 100px, 100px, 0px)" to #container, | |
| 170 // the clip will apply to both #inflow and #fixed. That's because 'clip' | |
| 171 // applies to any descendant, regardless of containing blocks. Note that | |
| 172 // #container and #fixed are siblings in the paint tree but #container does | |
| 173 // clip #fixed. This is the reason why we compute the painting clip rects during | |
| 174 // a layout tree walk and cache them for painting. | |
| 175 // | |
| 176 // This class is NOT DEPRECATED, DeprecatedPaintLayer is and we match its | |
| 177 // naming. | |
| 178 class DeprecatedPaintLayerClipper { | 130 class DeprecatedPaintLayerClipper { |
| 179 DISALLOW_ALLOCATION(); | 131 DISALLOW_ALLOCATION(); |
| 180 WTF_MAKE_NONCOPYABLE(DeprecatedPaintLayerClipper); | 132 WTF_MAKE_NONCOPYABLE(DeprecatedPaintLayerClipper); |
| 181 public: | 133 public: |
| 182 explicit DeprecatedPaintLayerClipper(LayoutBoxModelObject&); | 134 explicit DeprecatedPaintLayerClipper(LayoutBoxModelObject&); |
| 183 | 135 |
| 184 void clearClipRectsIncludingDescendants(); | 136 void clearClipRectsIncludingDescendants(); |
| 185 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); | 137 void clearClipRectsIncludingDescendants(ClipRectsCacheSlot); |
| 186 | 138 |
| 187 LayoutRect childrenClipRect() const; // Returns the foreground clip rect of
the layer in the document's coordinate space. | 139 LayoutRect childrenClipRect() const; // Returns the foreground clip rect of
the layer in the document's coordinate space. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 214 bool shouldRespectOverflowClip(const ClipRectsContext&) const; | 166 bool shouldRespectOverflowClip(const ClipRectsContext&) const; |
| 215 | 167 |
| 216 // FIXME: Could this be a LayoutBox? | 168 // FIXME: Could this be a LayoutBox? |
| 217 LayoutBoxModelObject& m_layoutObject; | 169 LayoutBoxModelObject& m_layoutObject; |
| 218 mutable OwnPtr<ClipRect> m_clips[NumberOfClipRectsCacheSlots]; | 170 mutable OwnPtr<ClipRect> m_clips[NumberOfClipRectsCacheSlots]; |
| 219 }; | 171 }; |
| 220 | 172 |
| 221 } // namespace blink | 173 } // namespace blink |
| 222 | 174 |
| 223 #endif // LayerClipper_h | 175 #endif // LayerClipper_h |
| OLD | NEW |