Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: Source/core/rendering/RenderLayerClipper.cpp

Issue 153233002: *** DO NOT LAND *** Remove regions support, keeping a bare minimum to support "region-based"... (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 = clippingRootForPainting(); 124 RenderLayer* clippingRootLayer = clippingRootForPainting();
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.
137 RenderView* renderView = m_renderer->view(); 136 RenderView* renderView = m_renderer->view();
138 RenderLayer* clippingRootLayer = clippingRootForPainting(); 137 RenderLayer* clippingRootLayer = clippingRootForPainting();
139 LayoutRect layerBounds; 138 LayoutRect layerBounds;
140 ClipRect backgroundRect, foregroundRect, outlineRect; 139 ClipRect backgroundRect, foregroundRect, outlineRect;
141 ClipRectsContext clipRectsContext(clippingRootLayer, 0, PaintingClipRects); 140 ClipRectsContext clipRectsContext(clippingRootLayer, PaintingClipRects);
142 calculateRects(clipRectsContext, renderView->documentRect(), layerBounds, ba ckgroundRect, foregroundRect, outlineRect); 141 calculateRects(clipRectsContext, renderView->documentRect(), layerBounds, ba ckgroundRect, foregroundRect, outlineRect);
143 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(backgrou ndRect.rect())).enclosingBoundingBox(); 142 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(backgrou ndRect.rect())).enclosingBoundingBox();
144 } 143 }
145 144
146 LayoutRect RenderLayerClipper::localClipRect() const 145 LayoutRect RenderLayerClipper::localClipRect() const
147 { 146 {
148 // FIXME: border-radius not accounted for. 147 // FIXME: border-radius not accounted for.
149 // FIXME: Regions not accounted for.
150 RenderLayer* clippingRootLayer = clippingRootForPainting(); 148 RenderLayer* clippingRootLayer = clippingRootForPainting();
151 LayoutRect layerBounds; 149 LayoutRect layerBounds;
152 ClipRect backgroundRect, foregroundRect, outlineRect; 150 ClipRect backgroundRect, foregroundRect, outlineRect;
153 ClipRectsContext clipRectsContext(clippingRootLayer, 0, PaintingClipRects); 151 ClipRectsContext clipRectsContext(clippingRootLayer, PaintingClipRects);
154 calculateRects(clipRectsContext, PaintInfo::infiniteRect(), layerBounds, bac kgroundRect, foregroundRect, outlineRect); 152 calculateRects(clipRectsContext, PaintInfo::infiniteRect(), layerBounds, bac kgroundRect, foregroundRect, outlineRect);
155 153
156 LayoutRect clipRect = backgroundRect.rect(); 154 LayoutRect clipRect = backgroundRect.rect();
157 if (clipRect == PaintInfo::infiniteRect()) 155 if (clipRect == PaintInfo::infiniteRect())
158 return clipRect; 156 return clipRect;
159 157
160 LayoutPoint clippingRootOffset; 158 LayoutPoint clippingRootOffset;
161 m_renderer->layer()->convertToLayerCoords(clippingRootLayer, clippingRootOff set); 159 m_renderer->layer()->convertToLayerCoords(clippingRootLayer, clippingRootOff set);
162 clipRect.moveBy(-clippingRootOffset); 160 clipRect.moveBy(-clippingRootOffset);
163 161
(...skipping 17 matching lines...) Expand all
181 if (offsetFromRoot) 179 if (offsetFromRoot)
182 offset = *offsetFromRoot; 180 offset = *offsetFromRoot;
183 else 181 else
184 m_renderer->layer()->convertToLayerCoords(clipRectsContext.rootLayer, of fset); 182 m_renderer->layer()->convertToLayerCoords(clipRectsContext.rootLayer, of fset);
185 layerBounds = LayoutRect(offset, m_renderer->layer()->size()); 183 layerBounds = LayoutRect(offset, m_renderer->layer()->size());
186 184
187 // Update the clip rects that will be passed to child layers. 185 // Update the clip rects that will be passed to child layers.
188 if (m_renderer->hasOverflowClip()) { 186 if (m_renderer->hasOverflowClip()) {
189 // This layer establishes a clip of some kind. 187 // This layer establishes a clip of some kind.
190 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsContex t.respectOverflowClip == RespectOverflowClip) { 188 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsContex t.respectOverflowClip == RespectOverflowClip) {
191 foregroundRect.intersect(toRenderBox(m_renderer)->overflowClipRect(o ffset, clipRectsContext.region, clipRectsContext.overlayScrollbarSizeRelevancy)) ; 189 foregroundRect.intersect(toRenderBox(m_renderer)->overflowClipRect(o ffset, clipRectsContext.overlayScrollbarSizeRelevancy));
192 if (m_renderer->style()->hasBorderRadius()) 190 if (m_renderer->style()->hasBorderRadius())
193 foregroundRect.setHasRadius(true); 191 foregroundRect.setHasRadius(true);
194 } 192 }
195 193
196 // If we establish an overflow clip at all, then go ahead and make sure our background 194 // 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, 195 // 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. 196 // since any visual overflow like box-shadow or border-outset is not cli pped by overflow:auto/hidden.
199 if (toRenderBox(m_renderer)->hasVisualOverflow()) { 197 if (toRenderBox(m_renderer)->hasVisualOverflow()) {
200 // FIXME: Perhaps we should be propagating the borderbox as the clip rect for children, even though 198 // 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. 199 // 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 200 // 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. 201 // individual region boxes as overflow.
204 LayoutRect layerBoundsWithVisualOverflow = toRenderBox(m_renderer)-> visualOverflowRect(); 202 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 . 203 toRenderBox(m_renderer)->flipForWritingMode(layerBoundsWithVisualOve rflow); // Layers are in physical coordinates, so the overflow has to be flipped .
206 layerBoundsWithVisualOverflow.moveBy(offset); 204 layerBoundsWithVisualOverflow.moveBy(offset);
207 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo ntext.respectOverflowClip == RespectOverflowClip) 205 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo ntext.respectOverflowClip == RespectOverflowClip)
208 backgroundRect.intersect(layerBoundsWithVisualOverflow); 206 backgroundRect.intersect(layerBoundsWithVisualOverflow);
209 } else { 207 } else {
210 // Shift the bounds to be for our region only. 208 LayoutRect bounds = toRenderBox(m_renderer)->borderBoxRect();
211 LayoutRect bounds = toRenderBox(m_renderer)->borderBoxRectInRegion(c lipRectsContext.region);
212 bounds.moveBy(offset); 209 bounds.moveBy(offset);
213 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo ntext.respectOverflowClip == RespectOverflowClip) 210 if (m_renderer->layer() != clipRectsContext.rootLayer || clipRectsCo ntext.respectOverflowClip == RespectOverflowClip)
214 backgroundRect.intersect(bounds); 211 backgroundRect.intersect(bounds);
215 } 212 }
216 } 213 }
217 214
218 // CSS clip (different than clipping due to overflow) can clip to any box, e ven if it falls outside of the border box. 215 // 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()) { 216 if (m_renderer->hasClip()) {
220 // Clip applies to *us* as well, so go ahead and update the damageRect. 217 // Clip applies to *us* as well, so go ahead and update the damageRect.
221 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset, clipRe ctsContext.region); 218 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset);
222 backgroundRect.intersect(newPosClip); 219 backgroundRect.intersect(newPosClip);
223 foregroundRect.intersect(newPosClip); 220 foregroundRect.intersect(newPosClip);
224 outlineRect.intersect(newPosClip); 221 outlineRect.intersect(newPosClip);
225 } 222 }
226 } 223 }
227 224
228 void RenderLayerClipper::calculateClipRects(const ClipRectsContext& clipRectsCon text, ClipRects& clipRects) const 225 void RenderLayerClipper::calculateClipRects(const ClipRectsContext& clipRectsCon text, ClipRects& clipRects) const
229 { 226 {
230 if (!m_renderer->layer()->parent()) { 227 if (!m_renderer->layer()->parent()) {
231 // The root layer's clip rect is always infinite. 228 // The root layer's clip rect is always infinite.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // clipRects are needed in view space. 271 // clipRects are needed in view space.
275 LayoutPoint offset; 272 LayoutPoint offset;
276 offset = roundedLayoutPoint(m_renderer->localToContainerPoint(FloatPoint (), clipRectsContext.rootLayer->renderer())); 273 offset = roundedLayoutPoint(m_renderer->localToContainerPoint(FloatPoint (), clipRectsContext.rootLayer->renderer()));
277 RenderView* view = m_renderer->view(); 274 RenderView* view = m_renderer->view();
278 ASSERT(view); 275 ASSERT(view);
279 if (view && clipRects.fixed() && clipRectsContext.rootLayer->renderer() == view) { 276 if (view && clipRects.fixed() && clipRectsContext.rootLayer->renderer() == view) {
280 offset -= view->frameView()->scrollOffsetForFixedPosition(); 277 offset -= view->frameView()->scrollOffsetForFixedPosition();
281 } 278 }
282 279
283 if (m_renderer->hasOverflowClip()) { 280 if (m_renderer->hasOverflowClip()) {
284 ClipRect newOverflowClip = toRenderBox(m_renderer)->overflowClipRect (offset, clipRectsContext.region, clipRectsContext.overlayScrollbarSizeRelevancy ); 281 ClipRect newOverflowClip = toRenderBox(m_renderer)->overflowClipRect (offset, clipRectsContext.overlayScrollbarSizeRelevancy);
285 if (m_renderer->style()->hasBorderRadius()) 282 if (m_renderer->style()->hasBorderRadius())
286 newOverflowClip.setHasRadius(true); 283 newOverflowClip.setHasRadius(true);
287 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRect s.overflowClipRect())); 284 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRect s.overflowClipRect()));
288 if (m_renderer->isPositioned()) 285 if (m_renderer->isPositioned())
289 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects .posClipRect())); 286 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects .posClipRect()));
290 } 287 }
291 if (m_renderer->hasClip()) { 288 if (m_renderer->hasClip()) {
292 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset, cl ipRectsContext.region); 289 LayoutRect newPosClip = toRenderBox(m_renderer)->clipRect(offset);
293 clipRects.setPosClipRect(intersection(newPosClip, clipRects.posClipR ect())); 290 clipRects.setPosClipRect(intersection(newPosClip, clipRects.posClipR ect()));
294 clipRects.setOverflowClipRect(intersection(newPosClip, clipRects.ove rflowClipRect())); 291 clipRects.setOverflowClipRect(intersection(newPosClip, clipRects.ove rflowClipRect()));
295 clipRects.setFixedClipRect(intersection(newPosClip, clipRects.fixedC lipRect())); 292 clipRects.setFixedClipRect(intersection(newPosClip, clipRects.fixedC lipRect()));
296 } 293 }
297 } 294 }
298 } 295 }
299 296
300 static inline ClipRect backgroundClipRectForPosition(const ClipRects& parentRect s, EPosition position) 297 static inline ClipRect backgroundClipRectForPosition(const ClipRects& parentRect s, EPosition position)
301 { 298 {
302 if (position == FixedPosition) 299 if (position == FixedPosition)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 || (current->compositingState() == PaintsIntoOwnBacking) 362 || (current->compositingState() == PaintsIntoOwnBacking)
366 ) 363 )
367 return const_cast<RenderLayer*>(current); 364 return const_cast<RenderLayer*>(current);
368 } 365 }
369 366
370 ASSERT_NOT_REACHED(); 367 ASSERT_NOT_REACHED();
371 return 0; 368 return 0;
372 } 369 }
373 370
374 } // namespace WebCore 371 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderLayerClipper.h ('k') | Source/core/rendering/RenderLayerCompositor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698