| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 117 } |
| 118 | 118 |
| 119 LayoutRect RenderLayerClipper::childrenClipRect() const | 119 LayoutRect RenderLayerClipper::childrenClipRect() const |
| 120 { | 120 { |
| 121 // FIXME: border-radius not accounted for. | 121 // FIXME: border-radius not accounted for. |
| 122 // FIXME: Regions not accounted for. | 122 // FIXME: Regions not accounted for. |
| 123 RenderView* renderView = m_renderer->view(); | 123 RenderView* renderView = m_renderer->view(); |
| 124 RenderLayer* clippingRootLayer = m_renderer->layer()->clippingRootForPaintin
g(); | 124 RenderLayer* clippingRootLayer = m_renderer->layer()->clippingRootForPaintin
g(); |
| 125 LayoutRect layerBounds; | 125 LayoutRect layerBounds; |
| 126 ClipRect backgroundRect, foregroundRect, outlineRect; | 126 ClipRect backgroundRect, foregroundRect, outlineRect; |
| 127 ClipRectsContext clipRectsContext(clippingRootLayer, 0, TemporaryClipRects); | 127 ClipRectsContext clipRectsContext(clippingRootLayer, TemporaryClipRects); |
| 128 // Need to use temporary clip rects, because the value of 'dontClipToOverflo
w' may be different from the painting path (<rdar://problem/11844909>). | 128 // Need to use temporary clip rects, because the value of 'dontClipToOverflo
w' may be different from the painting path (<rdar://problem/11844909>). |
| 129 calculateRects(clipRectsContext, renderView->unscaledDocumentRect(), layerBo
unds, backgroundRect, foregroundRect, outlineRect); | 129 calculateRects(clipRectsContext, renderView->unscaledDocumentRect(), layerBo
unds, backgroundRect, foregroundRect, outlineRect); |
| 130 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(foregrou
ndRect.rect())).enclosingBoundingBox(); | 130 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(foregrou
ndRect.rect())).enclosingBoundingBox(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 LayoutRect RenderLayerClipper::selfClipRect() const | 133 LayoutRect RenderLayerClipper::selfClipRect() const |
| 134 { | 134 { |
| 135 // FIXME: border-radius not accounted for. | 135 // FIXME: border-radius not accounted for. |
| 136 // FIXME: Regions not accounted for. | 136 // FIXME: Regions not accounted for. |
| 137 RenderView* renderView = m_renderer->view(); | 137 RenderView* renderView = m_renderer->view(); |
| 138 RenderLayer* clippingRootLayer = m_renderer->layer()->clippingRootForPaintin
g(); | 138 RenderLayer* clippingRootLayer = m_renderer->layer()->clippingRootForPaintin
g(); |
| 139 LayoutRect layerBounds; | 139 LayoutRect layerBounds; |
| 140 ClipRect backgroundRect, foregroundRect, outlineRect; | 140 ClipRect backgroundRect, foregroundRect, outlineRect; |
| 141 ClipRectsContext clipRectsContext(clippingRootLayer, 0, PaintingClipRects); | 141 ClipRectsContext clipRectsContext(clippingRootLayer, PaintingClipRects); |
| 142 calculateRects(clipRectsContext, renderView->documentRect(), layerBounds, ba
ckgroundRect, foregroundRect, outlineRect); | 142 calculateRects(clipRectsContext, renderView->documentRect(), layerBounds, ba
ckgroundRect, foregroundRect, outlineRect); |
| 143 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(backgrou
ndRect.rect())).enclosingBoundingBox(); | 143 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(backgrou
ndRect.rect())).enclosingBoundingBox(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 LayoutRect RenderLayerClipper::localClipRect() const | 146 LayoutRect RenderLayerClipper::localClipRect() const |
| 147 { | 147 { |
| 148 // FIXME: border-radius not accounted for. | 148 // FIXME: border-radius not accounted for. |
| 149 // FIXME: Regions not accounted for. | 149 // FIXME: Regions not accounted for. |
| 150 RenderLayer* clippingRootLayer = m_renderer->layer()->clippingRootForPaintin
g(); | 150 RenderLayer* clippingRootLayer = m_renderer->layer()->clippingRootForPaintin
g(); |
| 151 LayoutRect layerBounds; | 151 LayoutRect layerBounds; |
| 152 ClipRect backgroundRect, foregroundRect, outlineRect; | 152 ClipRect backgroundRect, foregroundRect, outlineRect; |
| 153 ClipRectsContext clipRectsContext(clippingRootLayer, 0, PaintingClipRects); | 153 ClipRectsContext clipRectsContext(clippingRootLayer, PaintingClipRects); |
| 154 calculateRects(clipRectsContext, PaintInfo::infiniteRect(), layerBounds, bac
kgroundRect, foregroundRect, outlineRect); | 154 calculateRects(clipRectsContext, PaintInfo::infiniteRect(), layerBounds, bac
kgroundRect, foregroundRect, outlineRect); |
| 155 | 155 |
| 156 LayoutRect clipRect = backgroundRect.rect(); | 156 LayoutRect clipRect = backgroundRect.rect(); |
| 157 if (clipRect == PaintInfo::infiniteRect()) | 157 if (clipRect == PaintInfo::infiniteRect()) |
| 158 return clipRect; | 158 return clipRect; |
| 159 | 159 |
| 160 LayoutPoint clippingRootOffset; | 160 LayoutPoint clippingRootOffset; |
| 161 m_renderer->layer()->convertToLayerCoords(clippingRootLayer, clippingRootOff
set); | 161 m_renderer->layer()->convertToLayerCoords(clippingRootLayer, clippingRootOff
set); |
| 162 clipRect.moveBy(-clippingRootOffset); | 162 clipRect.moveBy(-clippingRootOffset); |
| 163 | 163 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 181 if (offsetFromRoot) | 181 if (offsetFromRoot) |
| 182 offset = *offsetFromRoot; | 182 offset = *offsetFromRoot; |
| 183 else | 183 else |
| 184 m_renderer->layer()->convertToLayerCoords(clipRectsContext.rootLayer, of
fset); | 184 m_renderer->layer()->convertToLayerCoords(clipRectsContext.rootLayer, of
fset); |
| 185 layerBounds = LayoutRect(offset, m_renderer->layer()->size()); | 185 layerBounds = LayoutRect(offset, m_renderer->layer()->size()); |
| 186 | 186 |
| 187 // Update the clip rects that will be passed to child layers. | 187 // Update the clip rects that will be passed to child layers. |
| 188 if (m_renderer->hasOverflowClip()) { | 188 if (m_renderer->hasOverflowClip()) { |
| 189 // This layer establishes a clip of some kind. | 189 // This layer establishes a clip of some kind. |
| 190 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsContex
t.respectOverflowClip == RespectOverflowClip) { | 190 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsContex
t.respectOverflowClip == RespectOverflowClip) { |
| 191 foregroundRect.intersect(toRenderBox(m_renderer)->overflowClipRect(o
ffset, clipRectsContext.region, clipRectsContext.overlayScrollbarSizeRelevancy))
; | 191 foregroundRect.intersect(toRenderBox(m_renderer)->overflowClipRect(o
ffset, clipRectsContext.overlayScrollbarSizeRelevancy)); |
| 192 if (m_renderer->style()->hasBorderRadius()) | 192 if (m_renderer->style()->hasBorderRadius()) |
| 193 foregroundRect.setHasRadius(true); | 193 foregroundRect.setHasRadius(true); |
| 194 } | 194 } |
| 195 | 195 |
| 196 // If we establish an overflow clip at all, then go ahead and make sure
our background | 196 // If we establish an overflow clip at all, then go ahead and make sure
our background |
| 197 // rect is intersected with our layer's bounds including our visual over
flow, | 197 // rect is intersected with our layer's bounds including our visual over
flow, |
| 198 // since any visual overflow like box-shadow or border-outset is not cli
pped by overflow:auto/hidden. | 198 // since any visual overflow like box-shadow or border-outset is not cli
pped by overflow:auto/hidden. |
| 199 if (toRenderBox(m_renderer)->hasVisualOverflow()) { | 199 if (toRenderBox(m_renderer)->hasVisualOverflow()) { |
| 200 // FIXME: Perhaps we should be propagating the borderbox as the clip
rect for children, even though | 200 // FIXME: Perhaps we should be propagating the borderbox as the clip
rect for children, even though |
| 201 // we may need to inflate our clip specifically for shadows o
r outsets. | 201 // we may need to inflate our clip specifically for shadows o
r outsets. |
| 202 // FIXME: Does not do the right thing with CSS regions yet, since we
don't yet factor in the | 202 // FIXME: Does not do the right thing with CSS regions yet, since we
don't yet factor in the |
| 203 // individual region boxes as overflow. | 203 // individual region boxes as overflow. |
| 204 LayoutRect layerBoundsWithVisualOverflow = toRenderBox(m_renderer)->
visualOverflowRect(); | 204 LayoutRect layerBoundsWithVisualOverflow = toRenderBox(m_renderer)->
visualOverflowRect(); |
| 205 toRenderBox(m_renderer)->flipForWritingMode(layerBoundsWithVisualOve
rflow); // Layers are in physical coordinates, so the overflow has to be flipped
. | 205 toRenderBox(m_renderer)->flipForWritingMode(layerBoundsWithVisualOve
rflow); // Layers are in physical coordinates, so the overflow has to be flipped
. |
| 206 layerBoundsWithVisualOverflow.moveBy(offset); | 206 layerBoundsWithVisualOverflow.moveBy(offset); |
| 207 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo
ntext.respectOverflowClip == RespectOverflowClip) | 207 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo
ntext.respectOverflowClip == RespectOverflowClip) |
| 208 backgroundRect.intersect(layerBoundsWithVisualOverflow); | 208 backgroundRect.intersect(layerBoundsWithVisualOverflow); |
| 209 } else { | 209 } else { |
| 210 // Shift the bounds to be for our region only. | 210 LayoutRect bounds = toRenderBox(m_renderer)->borderBoxRect(); |
| 211 LayoutRect bounds = toRenderBox(m_renderer)->borderBoxRectInRegion(c
lipRectsContext.region); | |
| 212 bounds.moveBy(offset); | 211 bounds.moveBy(offset); |
| 213 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo
ntext.respectOverflowClip == RespectOverflowClip) | 212 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo
ntext.respectOverflowClip == RespectOverflowClip) |
| 214 backgroundRect.intersect(bounds); | 213 backgroundRect.intersect(bounds); |
| 215 } | 214 } |
| 216 } | 215 } |
| 217 | 216 |
| 218 // CSS clip (different than clipping due to overflow) can clip to any box, e
ven if it falls outside of the border box. | 217 // CSS clip (different than clipping due to overflow) can clip to any box, e
ven if it falls outside of the border box. |
| 219 if (m_renderer->hasClip()) { | 218 if (m_renderer->hasClip()) { |
| 220 // Clip applies to *us* as well, so go ahead and update the damageRect. | 219 // Clip applies to *us* as well, so go ahead and update the damageRect. |
| 221 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset, clipRe
ctsContext.region); | 220 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset); |
| 222 backgroundRect.intersect(newPosClip); | 221 backgroundRect.intersect(newPosClip); |
| 223 foregroundRect.intersect(newPosClip); | 222 foregroundRect.intersect(newPosClip); |
| 224 outlineRect.intersect(newPosClip); | 223 outlineRect.intersect(newPosClip); |
| 225 } | 224 } |
| 226 } | 225 } |
| 227 | 226 |
| 228 void RenderLayerClipper::calculateClipRects(const ClipRectsContext& clipRectsCon
text, ClipRects& clipRects) const | 227 void RenderLayerClipper::calculateClipRects(const ClipRectsContext& clipRectsCon
text, ClipRects& clipRects) const |
| 229 { | 228 { |
| 230 if (!m_renderer->layer()->parent()) { | 229 if (!m_renderer->layer()->parent()) { |
| 231 // The root layer's clip rect is always infinite. | 230 // The root layer's clip rect is always infinite. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // clipRects are needed in view space. | 273 // clipRects are needed in view space. |
| 275 LayoutPoint offset; | 274 LayoutPoint offset; |
| 276 offset = roundedLayoutPoint(m_renderer->localToContainerPoint(FloatPoint
(), clipRectsContext.rootLayer->renderer())); | 275 offset = roundedLayoutPoint(m_renderer->localToContainerPoint(FloatPoint
(), clipRectsContext.rootLayer->renderer())); |
| 277 RenderView* view = m_renderer->view(); | 276 RenderView* view = m_renderer->view(); |
| 278 ASSERT(view); | 277 ASSERT(view); |
| 279 if (view && clipRects.fixed() && clipRectsContext.rootLayer->renderer()
== view) { | 278 if (view && clipRects.fixed() && clipRectsContext.rootLayer->renderer()
== view) { |
| 280 offset -= view->frameView()->scrollOffsetForFixedPosition(); | 279 offset -= view->frameView()->scrollOffsetForFixedPosition(); |
| 281 } | 280 } |
| 282 | 281 |
| 283 if (m_renderer->hasOverflowClip()) { | 282 if (m_renderer->hasOverflowClip()) { |
| 284 ClipRect newOverflowClip = toRenderBox(m_renderer)->overflowClipRect
(offset, clipRectsContext.region, clipRectsContext.overlayScrollbarSizeRelevancy
); | 283 ClipRect newOverflowClip = toRenderBox(m_renderer)->overflowClipRect
(offset, clipRectsContext.overlayScrollbarSizeRelevancy); |
| 285 if (m_renderer->style()->hasBorderRadius()) | 284 if (m_renderer->style()->hasBorderRadius()) |
| 286 newOverflowClip.setHasRadius(true); | 285 newOverflowClip.setHasRadius(true); |
| 287 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRect
s.overflowClipRect())); | 286 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRect
s.overflowClipRect())); |
| 288 if (m_renderer->isPositioned()) | 287 if (m_renderer->isPositioned()) |
| 289 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects
.posClipRect())); | 288 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects
.posClipRect())); |
| 290 } | 289 } |
| 291 if (m_renderer->hasClip()) { | 290 if (m_renderer->hasClip()) { |
| 292 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset, cl
ipRectsContext.region); | 291 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset); |
| 293 clipRects.setPosClipRect(intersection(newPosClip, clipRects.posClipR
ect())); | 292 clipRects.setPosClipRect(intersection(newPosClip, clipRects.posClipR
ect())); |
| 294 clipRects.setOverflowClipRect(intersection(newPosClip, clipRects.ove
rflowClipRect())); | 293 clipRects.setOverflowClipRect(intersection(newPosClip, clipRects.ove
rflowClipRect())); |
| 295 clipRects.setFixedClipRect(intersection(newPosClip, clipRects.fixedC
lipRect())); | 294 clipRects.setFixedClipRect(intersection(newPosClip, clipRects.fixedC
lipRect())); |
| 296 } | 295 } |
| 297 } | 296 } |
| 298 } | 297 } |
| 299 | 298 |
| 300 static inline ClipRect backgroundClipRectForPosition(const ClipRects& parentRect
s, EPosition position) | 299 static inline ClipRect backgroundClipRectForPosition(const ClipRects& parentRect
s, EPosition position) |
| 301 { | 300 { |
| 302 if (position == FixedPosition) | 301 if (position == FixedPosition) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 if (clipRectsContext.clipRectsType == TemporaryClipRects) { | 342 if (clipRectsContext.clipRectsType == TemporaryClipRects) { |
| 344 parentClipper.calculateClipRects(clipRectsContext, clipRects); | 343 parentClipper.calculateClipRects(clipRectsContext, clipRects); |
| 345 return; | 344 return; |
| 346 } | 345 } |
| 347 | 346 |
| 348 parentClipper.updateClipRects(clipRectsContext); | 347 parentClipper.updateClipRects(clipRectsContext); |
| 349 clipRects = *parentClipper.clipRects(clipRectsContext); | 348 clipRects = *parentClipper.clipRects(clipRectsContext); |
| 350 } | 349 } |
| 351 | 350 |
| 352 } // namespace WebCore | 351 } // namespace WebCore |
| OLD | NEW |