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

Side by Side Diff: sky/engine/core/rendering/RenderLayerClipper.cpp

Issue 964723004: Some minor cleanup to RenderLayerClipper. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « sky/engine/core/rendering/RenderBox.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 */ 42 */
43 43
44 #include "sky/engine/config.h" 44 #include "sky/engine/config.h"
45 #include "sky/engine/core/rendering/RenderLayerClipper.h" 45 #include "sky/engine/core/rendering/RenderLayerClipper.h"
46 46
47 #include "sky/engine/core/rendering/RenderLayer.h" 47 #include "sky/engine/core/rendering/RenderLayer.h"
48 #include "sky/engine/core/rendering/RenderView.h" 48 #include "sky/engine/core/rendering/RenderView.h"
49 49
50 namespace blink { 50 namespace blink {
51 51
52 static void adjustClipRectsForChildren(const RenderObject& renderer, ClipRects& clipRects)
53 {
54 if (renderer.style()->position() == AbsolutePosition) {
55 clipRects.setOverflowClipRect(clipRects.posClipRect());
56 }
57 }
58
59 static void applyClipRects(const ClipRectsContext& context, RenderObject& render er, LayoutPoint offset, ClipRects& clipRects)
60 {
61 ASSERT(renderer.hasOverflowClip() || renderer.hasClip());
62
63 if (renderer.hasOverflowClip()) {
64 ClipRect newOverflowClip = toRenderBox(renderer).overflowClipRect(offset );
65 newOverflowClip.setHasRadius(renderer.style()->hasBorderRadius());
66 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRects.ov erflowClipRect()));
67 if (renderer.isPositioned())
68 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects.pos ClipRect()));
69 }
70
71 if (renderer.hasClip()) {
72 LayoutRect newClip = toRenderBox(renderer).clipRect(offset);
73 clipRects.setPosClipRect(intersection(newClip, clipRects.posClipRect())) ;
74 clipRects.setOverflowClipRect(intersection(newClip, clipRects.overflowCl ipRect()));
75 }
76 }
77
78 RenderLayerClipper::RenderLayerClipper(RenderBox& renderer) 52 RenderLayerClipper::RenderLayerClipper(RenderBox& renderer)
79 : m_renderer(renderer) 53 : m_renderer(renderer)
80 { 54 {
81 } 55 }
82 56
83 ClipRects* RenderLayerClipper::clipRectsIfCached(const ClipRectsContext& context ) const 57 ClipRects* RenderLayerClipper::clipRectsIfCached(const ClipRectsContext& context ) const
84 { 58 {
85 ASSERT(context.usesCache()); 59 ASSERT(context.usesCache());
86 if (!m_cache) 60 if (!m_cache)
87 return 0; 61 return 0;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // FIXME: Why don't we just call getClipRects here? 216 // FIXME: Why don't we just call getClipRects here?
243 if (context.usesCache() && parentLayer->clipper().cachedClipRects(contex t)) { 217 if (context.usesCache() && parentLayer->clipper().cachedClipRects(contex t)) {
244 clipRects = *parentLayer->clipper().cachedClipRects(context); 218 clipRects = *parentLayer->clipper().cachedClipRects(context);
245 } else { 219 } else {
246 parentLayer->clipper().calculateClipRects(context, clipRects); 220 parentLayer->clipper().calculateClipRects(context, clipRects);
247 } 221 }
248 } else { 222 } else {
249 clipRects.reset(PaintInfo::infiniteRect()); 223 clipRects.reset(PaintInfo::infiniteRect());
250 } 224 }
251 225
252 adjustClipRectsForChildren(m_renderer, clipRects); 226 if (m_renderer.style()->position() == AbsolutePosition) {
227 clipRects.setOverflowClipRect(clipRects.posClipRect());
228 }
253 229
230 // This offset cannot use convertToLayerCoords, because sometimes our rootLa yer may be across
231 // some transformed layer boundary, for example, in the RenderLayerComposito r overlapMap, where
232 // clipRects are needed in view space.
233 LayoutPoint offset = roundedLayoutPoint(m_renderer.localToContainerPoint(Flo atPoint(), context.rootLayer->renderer()));
254 if (m_renderer.hasOverflowClip()) { 234 if (m_renderer.hasOverflowClip()) {
255 // This offset cannot use convertToLayerCoords, because sometimes our ro otLayer may be across 235 ClipRect newOverflowClip = m_renderer.overflowClipRect(offset);
256 // some transformed layer boundary, for example, in the RenderLayerCompo sitor overlapMap, where 236 newOverflowClip.setHasRadius(m_renderer.style()->hasBorderRadius());
257 // clipRects are needed in view space. 237 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRects.ov erflowClipRect()));
258 applyClipRects(context, m_renderer, roundedLayoutPoint(m_renderer.localT oContainerPoint(FloatPoint(), context.rootLayer->renderer())), clipRects); 238 if (m_renderer.isPositioned())
239 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects.pos ClipRect()));
240 }
241
242 if (m_renderer.hasClip()) {
243 LayoutRect newClip = m_renderer.clipRect(offset);
244 clipRects.setPosClipRect(intersection(newClip, clipRects.posClipRect())) ;
245 clipRects.setOverflowClipRect(intersection(newClip, clipRects.overflowCl ipRect()));
259 } 246 }
260 } 247 }
261 248
262 static ClipRect backgroundClipRectForPosition(const ClipRects& parentRects, EPos ition position)
263 {
264 if (position == AbsolutePosition)
265 return parentRects.posClipRect();
266 return parentRects.overflowClipRect();
267 }
268
269 ClipRect RenderLayerClipper::backgroundClipRect(const ClipRectsContext& context) const 249 ClipRect RenderLayerClipper::backgroundClipRect(const ClipRectsContext& context) const
270 { 250 {
271 ASSERT(m_renderer.layer()->parent()); 251 ASSERT(m_renderer.layer()->parent());
272 ASSERT(m_renderer.view()); 252 ASSERT(m_renderer.view());
273 253
274 ClipRects parentClipRects; 254 ClipRects parentClipRects;
275 if (m_renderer.layer() == context.rootLayer) 255 if (m_renderer.layer() == context.rootLayer)
276 parentClipRects.reset(PaintInfo::infiniteRect()); 256 parentClipRects.reset(PaintInfo::infiniteRect());
277 else 257 else
278 m_renderer.layer()->parent()->clipper().getOrCalculateClipRects(context, parentClipRects); 258 m_renderer.layer()->parent()->clipper().getOrCalculateClipRects(context, parentClipRects);
279 259
280 return backgroundClipRectForPosition(parentClipRects, m_renderer.style()->po sition()); 260 if (m_renderer.style()->position() == AbsolutePosition)
261 return parentClipRects.posClipRect();
262 return parentClipRects.overflowClipRect();
281 } 263 }
282 264
283 void RenderLayerClipper::getOrCalculateClipRects(const ClipRectsContext& context , ClipRects& clipRects) const 265 void RenderLayerClipper::getOrCalculateClipRects(const ClipRectsContext& context , ClipRects& clipRects) const
284 { 266 {
285 if (context.usesCache()) 267 if (context.usesCache())
286 clipRects = *getClipRects(context); 268 clipRects = *getClipRects(context);
287 else 269 else
288 calculateClipRects(context, clipRects); 270 calculateClipRects(context, clipRects);
289 } 271 }
290 272
291 RenderLayer* RenderLayerClipper::clippingRootForPainting() const 273 RenderLayer* RenderLayerClipper::clippingRootForPainting() const
292 { 274 {
293 const RenderLayer* current = m_renderer.layer(); 275 const RenderLayer* current = m_renderer.layer();
294 while (current) { 276 while (current) {
295 if (current->isRootLayer()) 277 if (current->isRootLayer())
296 return const_cast<RenderLayer*>(current); 278 return const_cast<RenderLayer*>(current);
297 279
298 current = current->compositingContainer(); 280 current = current->compositingContainer();
299 ASSERT(current); 281 ASSERT(current);
300 if (current->renderer()->transform()) 282 if (current->renderer()->transform())
301 return const_cast<RenderLayer*>(current); 283 return const_cast<RenderLayer*>(current);
302 } 284 }
303 285
304 ASSERT_NOT_REACHED(); 286 ASSERT_NOT_REACHED();
305 return 0; 287 return 0;
306 } 288 }
307 289
308 } // namespace blink 290 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBox.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698