Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 | 148 |
| 149 void RenderLayerClipper::clearClipRectsIncludingDescendants(ClipRectsCacheSlot c acheSlot) | 149 void RenderLayerClipper::clearClipRectsIncludingDescendants(ClipRectsCacheSlot c acheSlot) |
| 150 { | 150 { |
| 151 if (m_cache) | 151 if (m_cache) |
| 152 m_cache->clear(cacheSlot); | 152 m_cache->clear(cacheSlot); |
| 153 | 153 |
| 154 for (RenderLayer* layer = m_renderer.layer()->firstChild(); layer; layer = l ayer->nextSibling()) | 154 for (RenderLayer* layer = m_renderer.layer()->firstChild(); layer; layer = l ayer->nextSibling()) |
| 155 layer->clipper().clearClipRectsIncludingDescendants(cacheSlot); | 155 layer->clipper().clearClipRectsIncludingDescendants(cacheSlot); |
| 156 } | 156 } |
| 157 | 157 |
| 158 LayoutRect RenderLayerClipper::childrenClipRect() const | |
|
ojan
2015/02/28 01:55:24
This was just dead code.
| |
| 159 { | |
| 160 // FIXME: border-radius not accounted for. | |
| 161 // FIXME: Regions not accounted for. | |
| 162 RenderLayer* clippingRootLayer = clippingRootForPainting(); | |
| 163 LayoutRect layerBounds; | |
| 164 ClipRect backgroundRect, foregroundRect; | |
| 165 // Need to use uncached clip rects, because the value of 'dontClipToOverflow ' may be different from the painting path (<rdar://problem/11844909>). | |
| 166 ClipRectsContext context(clippingRootLayer, UncachedClipRects); | |
| 167 calculateRects(context, m_renderer.view()->unscaledDocumentRect(), layerBoun ds, backgroundRect, foregroundRect); | |
| 168 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(foregrou ndRect.rect())).enclosingBoundingBox(); | |
| 169 } | |
| 170 | |
| 171 LayoutRect RenderLayerClipper::localClipRect() const | 158 LayoutRect RenderLayerClipper::localClipRect() const |
| 172 { | 159 { |
| 173 // FIXME: border-radius not accounted for. | 160 // FIXME: border-radius not accounted for. |
| 174 RenderLayer* clippingRootLayer = clippingRootForPainting(); | 161 RenderLayer* clippingRootLayer = clippingRootForPainting(); |
| 175 LayoutRect layerBounds; | 162 LayoutRect layerBounds; |
| 176 ClipRect backgroundRect, foregroundRect; | 163 ClipRect backgroundRect; |
| 177 ClipRectsContext context(clippingRootLayer, PaintingClipRects); | 164 ClipRectsContext context(clippingRootLayer, PaintingClipRects); |
| 178 calculateRects(context, PaintInfo::infiniteRect(), layerBounds, backgroundRe ct, foregroundRect); | 165 calculateRects(context, PaintInfo::infiniteRect(), layerBounds, backgroundRe ct); |
| 179 | 166 |
| 180 LayoutRect clipRect = backgroundRect.rect(); | 167 LayoutRect clipRect = backgroundRect.rect(); |
| 181 if (clipRect == PaintInfo::infiniteRect()) | 168 if (clipRect == PaintInfo::infiniteRect()) |
| 182 return clipRect; | 169 return clipRect; |
| 183 | 170 |
| 184 LayoutPoint clippingRootOffset; | 171 LayoutPoint clippingRootOffset; |
| 185 m_renderer.layer()->convertToLayerCoords(clippingRootLayer, clippingRootOffs et); | 172 m_renderer.layer()->convertToLayerCoords(clippingRootLayer, clippingRootOffs et); |
| 186 clipRect.moveBy(-clippingRootOffset); | 173 clipRect.moveBy(-clippingRootOffset); |
| 187 | 174 |
| 188 return clipRect; | 175 return clipRect; |
| 189 } | 176 } |
| 190 | 177 |
| 191 void RenderLayerClipper::calculateRects(const ClipRectsContext& context, const L ayoutRect& paintDirtyRect, LayoutRect& layerBounds, | 178 void RenderLayerClipper::calculateRects(const ClipRectsContext& context, const L ayoutRect& paintDirtyRect, LayoutRect& layerBounds, |
| 192 ClipRect& backgroundRect, ClipRect& foregroundRect, const LayoutPoint* offse tFromRoot) const | 179 ClipRect& backgroundRect, const LayoutPoint* offsetFromRoot) const |
| 193 { | 180 { |
| 194 bool isClippingRoot = m_renderer.layer() == context.rootLayer; | 181 bool isClippingRoot = m_renderer.layer() == context.rootLayer; |
| 195 | 182 |
| 196 if (!isClippingRoot && m_renderer.layer()->parent()) { | 183 if (!isClippingRoot && m_renderer.layer()->parent()) { |
| 197 backgroundRect = backgroundClipRect(context); | 184 backgroundRect = backgroundClipRect(context); |
| 198 backgroundRect.move(roundedIntSize(context.subPixelAccumulation)); | 185 backgroundRect.move(roundedIntSize(context.subPixelAccumulation)); |
| 199 backgroundRect.intersect(paintDirtyRect); | 186 backgroundRect.intersect(paintDirtyRect); |
| 200 } else { | 187 } else { |
| 201 backgroundRect = paintDirtyRect; | 188 backgroundRect = paintDirtyRect; |
| 202 } | 189 } |
| 203 | 190 |
| 204 foregroundRect = backgroundRect; | |
| 205 | |
| 206 LayoutPoint offset; | 191 LayoutPoint offset; |
| 207 if (offsetFromRoot) | 192 if (offsetFromRoot) |
| 208 offset = *offsetFromRoot; | 193 offset = *offsetFromRoot; |
| 209 else | 194 else |
| 210 m_renderer.layer()->convertToLayerCoords(context.rootLayer, offset); | 195 m_renderer.layer()->convertToLayerCoords(context.rootLayer, offset); |
| 211 layerBounds = LayoutRect(offset, m_renderer.layer()->size()); | 196 layerBounds = LayoutRect(offset, m_renderer.layer()->size()); |
| 212 | 197 |
| 213 // Update the clip rects that will be passed to child layers. | 198 // Update the clip rects that will be passed to child layers. |
| 214 if (m_renderer.hasOverflowClip()) { | 199 if (m_renderer.hasOverflowClip()) { |
| 215 foregroundRect.intersect(m_renderer.overflowClipRect(offset)); | |
| 216 if (m_renderer.style()->hasBorderRadius()) | |
| 217 foregroundRect.setHasRadius(true); | |
| 218 | |
| 219 // If we establish an overflow clip at all, then go ahead and make sure our background | 200 // If we establish an overflow clip at all, then go ahead and make sure our background |
| 220 // rect is intersected with our layer's bounds including our visual over flow, | 201 // rect is intersected with our layer's bounds including our visual over flow, |
| 221 // since any visual overflow like box-shadow or border-outset is not cli pped by overflow:auto/hidden. | 202 // since any visual overflow like box-shadow or border-outset is not cli pped by overflow:auto/hidden. |
| 222 if (m_renderer.hasVisualOverflow()) { | 203 if (m_renderer.hasVisualOverflow()) { |
| 223 // FIXME: Perhaps we should be propagating the borderbox as the clip rect for children, even though | 204 // FIXME: Perhaps we should be propagating the borderbox as the clip rect for children, even though |
| 224 // we may need to inflate our clip specifically for shadows o r outsets. | 205 // we may need to inflate our clip specifically for shadows o r outsets. |
| 225 // FIXME: Does not do the right thing with CSS regions yet, since we don't yet factor in the | 206 // FIXME: Does not do the right thing with CSS regions yet, since we don't yet factor in the |
| 226 // individual region boxes as overflow. | 207 // individual region boxes as overflow. |
| 227 LayoutRect layerBoundsWithVisualOverflow = m_renderer.visualOverflow Rect(); | 208 LayoutRect layerBoundsWithVisualOverflow = m_renderer.visualOverflow Rect(); |
| 228 layerBoundsWithVisualOverflow.moveBy(offset); | 209 layerBoundsWithVisualOverflow.moveBy(offset); |
| 229 backgroundRect.intersect(layerBoundsWithVisualOverflow); | 210 backgroundRect.intersect(layerBoundsWithVisualOverflow); |
| 230 } else { | 211 } else { |
| 231 LayoutRect bounds = m_renderer.borderBoxRect(); | 212 LayoutRect bounds = m_renderer.borderBoxRect(); |
| 232 bounds.moveBy(offset); | 213 bounds.moveBy(offset); |
| 233 backgroundRect.intersect(bounds); | 214 backgroundRect.intersect(bounds); |
| 234 } | 215 } |
| 235 } | 216 } |
| 236 | 217 |
| 237 // CSS clip (different than clipping due to overflow) can clip to any box, e ven if it falls outside of the border box. | 218 // CSS clip (different than clipping due to overflow) can clip to any box, e ven if it falls outside of the border box. |
| 238 if (m_renderer.hasClip()) { | 219 if (m_renderer.hasClip()) { |
| 239 // Clip applies to *us* as well, so go ahead and update the damageRect. | 220 // Clip applies to *us* as well, so go ahead and update the damageRect. |
| 240 LayoutRect newPosClip = m_renderer.clipRect(offset); | 221 LayoutRect newPosClip = m_renderer.clipRect(offset); |
| 241 backgroundRect.intersect(newPosClip); | 222 backgroundRect.intersect(newPosClip); |
| 242 foregroundRect.intersect(newPosClip); | |
| 243 } | 223 } |
| 244 } | 224 } |
| 245 | 225 |
| 246 void RenderLayerClipper::calculateClipRects(const ClipRectsContext& context, Cli pRects& clipRects) const | 226 void RenderLayerClipper::calculateClipRects(const ClipRectsContext& context, Cli pRects& clipRects) const |
| 247 { | 227 { |
| 248 if (!m_renderer.layer()->parent()) { | 228 if (!m_renderer.layer()->parent()) { |
| 249 // The root layer's clip rect is always infinite. | 229 // The root layer's clip rect is always infinite. |
| 250 clipRects.reset(PaintInfo::infiniteRect()); | 230 clipRects.reset(PaintInfo::infiniteRect()); |
| 251 return; | 231 return; |
| 252 } | 232 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 ASSERT(current); | 299 ASSERT(current); |
| 320 if (current->renderer()->transform()) | 300 if (current->renderer()->transform()) |
| 321 return const_cast<RenderLayer*>(current); | 301 return const_cast<RenderLayer*>(current); |
| 322 } | 302 } |
| 323 | 303 |
| 324 ASSERT_NOT_REACHED(); | 304 ASSERT_NOT_REACHED(); |
| 325 return 0; | 305 return 0; |
| 326 } | 306 } |
| 327 | 307 |
| 328 } // namespace blink | 308 } // namespace blink |
| OLD | NEW |