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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 119 } |
120 | 120 |
121 LayoutRect RenderLayerClipper::childrenClipRect() const | 121 LayoutRect RenderLayerClipper::childrenClipRect() const |
122 { | 122 { |
123 // FIXME: border-radius not accounted for. | 123 // FIXME: border-radius not accounted for. |
124 // FIXME: Regions not accounted for. | 124 // FIXME: Regions not accounted for. |
125 RenderView* renderView = m_renderer->view(); | 125 RenderView* renderView = m_renderer->view(); |
126 RenderLayer* clippingRootLayer = clippingRootForPainting(); | 126 RenderLayer* clippingRootLayer = clippingRootForPainting(); |
127 LayoutRect layerBounds; | 127 LayoutRect layerBounds; |
128 ClipRect backgroundRect, foregroundRect, outlineRect; | 128 ClipRect backgroundRect, foregroundRect, outlineRect; |
129 ClipRectsContext clipRectsContext(clippingRootLayer, 0, TemporaryClipRects); | 129 ClipRectsContext clipRectsContext(clippingRootLayer, TemporaryClipRects); |
130 // Need to use temporary clip rects, because the value of 'dontClipToOverflo
w' may be different from the painting path (<rdar://problem/11844909>). | 130 // Need to use temporary clip rects, because the value of 'dontClipToOverflo
w' may be different from the painting path (<rdar://problem/11844909>). |
131 calculateRects(clipRectsContext, renderView->unscaledDocumentRect(), layerBo
unds, backgroundRect, foregroundRect, outlineRect); | 131 calculateRects(clipRectsContext, renderView->unscaledDocumentRect(), layerBo
unds, backgroundRect, foregroundRect, outlineRect); |
132 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(foregrou
ndRect.rect())).enclosingBoundingBox(); | 132 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(foregrou
ndRect.rect())).enclosingBoundingBox(); |
133 } | 133 } |
134 | 134 |
135 LayoutRect RenderLayerClipper::selfClipRect() const | 135 LayoutRect RenderLayerClipper::selfClipRect() const |
136 { | 136 { |
137 // FIXME: border-radius not accounted for. | 137 // FIXME: border-radius not accounted for. |
138 // FIXME: Regions not accounted for. | |
139 RenderView* renderView = m_renderer->view(); | 138 RenderView* renderView = m_renderer->view(); |
140 RenderLayer* clippingRootLayer = clippingRootForPainting(); | 139 RenderLayer* clippingRootLayer = clippingRootForPainting(); |
141 LayoutRect layerBounds; | 140 LayoutRect layerBounds; |
142 ClipRect backgroundRect, foregroundRect, outlineRect; | 141 ClipRect backgroundRect, foregroundRect, outlineRect; |
143 ClipRectsContext clipRectsContext(clippingRootLayer, 0, PaintingClipRects); | 142 ClipRectsContext clipRectsContext(clippingRootLayer, PaintingClipRects); |
144 calculateRects(clipRectsContext, renderView->documentRect(), layerBounds, ba
ckgroundRect, foregroundRect, outlineRect); | 143 calculateRects(clipRectsContext, renderView->documentRect(), layerBounds, ba
ckgroundRect, foregroundRect, outlineRect); |
145 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(backgrou
ndRect.rect())).enclosingBoundingBox(); | 144 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(backgrou
ndRect.rect())).enclosingBoundingBox(); |
146 } | 145 } |
147 | 146 |
148 LayoutRect RenderLayerClipper::localClipRect() const | 147 LayoutRect RenderLayerClipper::localClipRect() const |
149 { | 148 { |
150 // FIXME: border-radius not accounted for. | 149 // FIXME: border-radius not accounted for. |
151 // FIXME: Regions not accounted for. | |
152 RenderLayer* clippingRootLayer = clippingRootForPainting(); | 150 RenderLayer* clippingRootLayer = clippingRootForPainting(); |
153 LayoutRect layerBounds; | 151 LayoutRect layerBounds; |
154 ClipRect backgroundRect, foregroundRect, outlineRect; | 152 ClipRect backgroundRect, foregroundRect, outlineRect; |
155 ClipRectsContext clipRectsContext(clippingRootLayer, 0, PaintingClipRects); | 153 ClipRectsContext clipRectsContext(clippingRootLayer, PaintingClipRects); |
156 calculateRects(clipRectsContext, PaintInfo::infiniteRect(), layerBounds, bac
kgroundRect, foregroundRect, outlineRect); | 154 calculateRects(clipRectsContext, PaintInfo::infiniteRect(), layerBounds, bac
kgroundRect, foregroundRect, outlineRect); |
157 | 155 |
158 LayoutRect clipRect = backgroundRect.rect(); | 156 LayoutRect clipRect = backgroundRect.rect(); |
159 if (clipRect == PaintInfo::infiniteRect()) | 157 if (clipRect == PaintInfo::infiniteRect()) |
160 return clipRect; | 158 return clipRect; |
161 | 159 |
162 LayoutPoint clippingRootOffset; | 160 LayoutPoint clippingRootOffset; |
163 m_renderer->layer()->convertToLayerCoords(clippingRootLayer, clippingRootOff
set); | 161 m_renderer->layer()->convertToLayerCoords(clippingRootLayer, clippingRootOff
set); |
164 clipRect.moveBy(-clippingRootOffset); | 162 clipRect.moveBy(-clippingRootOffset); |
165 | 163 |
(...skipping 17 matching lines...) Expand all Loading... |
183 if (offsetFromRoot) | 181 if (offsetFromRoot) |
184 offset = *offsetFromRoot; | 182 offset = *offsetFromRoot; |
185 else | 183 else |
186 m_renderer->layer()->convertToLayerCoords(clipRectsContext.rootLayer, of
fset); | 184 m_renderer->layer()->convertToLayerCoords(clipRectsContext.rootLayer, of
fset); |
187 layerBounds = LayoutRect(offset, m_renderer->layer()->size()); | 185 layerBounds = LayoutRect(offset, m_renderer->layer()->size()); |
188 | 186 |
189 // Update the clip rects that will be passed to child layers. | 187 // Update the clip rects that will be passed to child layers. |
190 if (m_renderer->hasOverflowClip()) { | 188 if (m_renderer->hasOverflowClip()) { |
191 // This layer establishes a clip of some kind. | 189 // This layer establishes a clip of some kind. |
192 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsContex
t.respectOverflowClip == RespectOverflowClip) { | 190 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsContex
t.respectOverflowClip == RespectOverflowClip) { |
193 foregroundRect.intersect(toRenderBox(m_renderer)->overflowClipRect(o
ffset, clipRectsContext.region, clipRectsContext.overlayScrollbarSizeRelevancy))
; | 191 foregroundRect.intersect(toRenderBox(m_renderer)->overflowClipRect(o
ffset, clipRectsContext.overlayScrollbarSizeRelevancy)); |
194 if (m_renderer->style()->hasBorderRadius()) | 192 if (m_renderer->style()->hasBorderRadius()) |
195 foregroundRect.setHasRadius(true); | 193 foregroundRect.setHasRadius(true); |
196 } | 194 } |
197 | 195 |
198 // 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 |
199 // 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, |
200 // 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. |
201 if (toRenderBox(m_renderer)->hasVisualOverflow()) { | 199 if (toRenderBox(m_renderer)->hasVisualOverflow()) { |
202 // 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 |
203 // 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. |
204 // 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 |
205 // individual region boxes as overflow. | 203 // individual region boxes as overflow. |
206 LayoutRect layerBoundsWithVisualOverflow = toRenderBox(m_renderer)->
visualOverflowRect(); | 204 LayoutRect layerBoundsWithVisualOverflow = toRenderBox(m_renderer)->
visualOverflowRect(); |
207 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
. |
208 layerBoundsWithVisualOverflow.moveBy(offset); | 206 layerBoundsWithVisualOverflow.moveBy(offset); |
209 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo
ntext.respectOverflowClip == RespectOverflowClip) | 207 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo
ntext.respectOverflowClip == RespectOverflowClip) |
210 backgroundRect.intersect(layerBoundsWithVisualOverflow); | 208 backgroundRect.intersect(layerBoundsWithVisualOverflow); |
211 } else { | 209 } else { |
212 // Shift the bounds to be for our region only. | 210 LayoutRect bounds = toRenderBox(m_renderer)->borderBoxRect(); |
213 LayoutRect bounds = toRenderBox(m_renderer)->borderBoxRectInRegion(c
lipRectsContext.region); | |
214 bounds.moveBy(offset); | 211 bounds.moveBy(offset); |
215 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo
ntext.respectOverflowClip == RespectOverflowClip) | 212 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo
ntext.respectOverflowClip == RespectOverflowClip) |
216 backgroundRect.intersect(bounds); | 213 backgroundRect.intersect(bounds); |
217 } | 214 } |
218 } | 215 } |
219 | 216 |
220 // 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. |
221 if (m_renderer->hasClip()) { | 218 if (m_renderer->hasClip()) { |
222 // 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. |
223 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset, clipRe
ctsContext.region); | 220 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset); |
224 backgroundRect.intersect(newPosClip); | 221 backgroundRect.intersect(newPosClip); |
225 foregroundRect.intersect(newPosClip); | 222 foregroundRect.intersect(newPosClip); |
226 outlineRect.intersect(newPosClip); | 223 outlineRect.intersect(newPosClip); |
227 } | 224 } |
228 } | 225 } |
229 | 226 |
230 void RenderLayerClipper::calculateClipRects(const ClipRectsContext& clipRectsCon
text, ClipRects& clipRects) const | 227 void RenderLayerClipper::calculateClipRects(const ClipRectsContext& clipRectsCon
text, ClipRects& clipRects) const |
231 { | 228 { |
232 if (!m_renderer->layer()->parent()) { | 229 if (!m_renderer->layer()->parent()) { |
233 // 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... |
276 // clipRects are needed in view space. | 273 // clipRects are needed in view space. |
277 LayoutPoint offset; | 274 LayoutPoint offset; |
278 offset = roundedLayoutPoint(m_renderer->localToContainerPoint(FloatPoint
(), clipRectsContext.rootLayer->renderer())); | 275 offset = roundedLayoutPoint(m_renderer->localToContainerPoint(FloatPoint
(), clipRectsContext.rootLayer->renderer())); |
279 RenderView* view = m_renderer->view(); | 276 RenderView* view = m_renderer->view(); |
280 ASSERT(view); | 277 ASSERT(view); |
281 if (view && clipRects.fixed() && clipRectsContext.rootLayer->renderer()
== view) { | 278 if (view && clipRects.fixed() && clipRectsContext.rootLayer->renderer()
== view) { |
282 offset -= view->frameView()->scrollOffsetForFixedPosition(); | 279 offset -= view->frameView()->scrollOffsetForFixedPosition(); |
283 } | 280 } |
284 | 281 |
285 if (m_renderer->hasOverflowClip()) { | 282 if (m_renderer->hasOverflowClip()) { |
286 ClipRect newOverflowClip = toRenderBox(m_renderer)->overflowClipRect
(offset, clipRectsContext.region, clipRectsContext.overlayScrollbarSizeRelevancy
); | 283 ClipRect newOverflowClip = toRenderBox(m_renderer)->overflowClipRect
(offset, clipRectsContext.overlayScrollbarSizeRelevancy); |
287 if (m_renderer->style()->hasBorderRadius()) | 284 if (m_renderer->style()->hasBorderRadius()) |
288 newOverflowClip.setHasRadius(true); | 285 newOverflowClip.setHasRadius(true); |
289 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRect
s.overflowClipRect())); | 286 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRect
s.overflowClipRect())); |
290 if (m_renderer->isPositioned()) | 287 if (m_renderer->isPositioned()) |
291 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects
.posClipRect())); | 288 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects
.posClipRect())); |
292 } | 289 } |
293 if (m_renderer->hasClip()) { | 290 if (m_renderer->hasClip()) { |
294 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset, cl
ipRectsContext.region); | 291 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset); |
295 clipRects.setPosClipRect(intersection(newPosClip, clipRects.posClipR
ect())); | 292 clipRects.setPosClipRect(intersection(newPosClip, clipRects.posClipR
ect())); |
296 clipRects.setOverflowClipRect(intersection(newPosClip, clipRects.ove
rflowClipRect())); | 293 clipRects.setOverflowClipRect(intersection(newPosClip, clipRects.ove
rflowClipRect())); |
297 clipRects.setFixedClipRect(intersection(newPosClip, clipRects.fixedC
lipRect())); | 294 clipRects.setFixedClipRect(intersection(newPosClip, clipRects.fixedC
lipRect())); |
298 } | 295 } |
299 } | 296 } |
300 } | 297 } |
301 | 298 |
302 static inline ClipRect backgroundClipRectForPosition(const ClipRects& parentRect
s, EPosition position) | 299 static inline ClipRect backgroundClipRectForPosition(const ClipRects& parentRect
s, EPosition position) |
303 { | 300 { |
304 if (position == FixedPosition) | 301 if (position == FixedPosition) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 || (current->compositingState() == PaintsIntoOwnBacking) | 364 || (current->compositingState() == PaintsIntoOwnBacking) |
368 ) | 365 ) |
369 return const_cast<RenderLayer*>(current); | 366 return const_cast<RenderLayer*>(current); |
370 } | 367 } |
371 | 368 |
372 ASSERT_NOT_REACHED(); | 369 ASSERT_NOT_REACHED(); |
373 return 0; | 370 return 0; |
374 } | 371 } |
375 | 372 |
376 } // namespace WebCore | 373 } // namespace WebCore |
OLD | NEW |