| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // We should add a test that has an inconsistent root. See | 106 // We should add a test that has an inconsistent root. See |
| 107 // http://crbug.com/366118 for an example. | 107 // http://crbug.com/366118 for an example. |
| 108 if (context.rootLayer != entry.root) | 108 if (context.rootLayer != entry.root) |
| 109 return 0; | 109 return 0; |
| 110 ASSERT(entry.scrollbarRelevancy == context.scrollbarRelevancy); | 110 ASSERT(entry.scrollbarRelevancy == context.scrollbarRelevancy); |
| 111 | 111 |
| 112 #ifdef CHECK_CACHED_CLIP_RECTS | 112 #ifdef CHECK_CACHED_CLIP_RECTS |
| 113 // This code is useful to check cached clip rects, but is too expensive to l
eave enabled in debug builds by default. | 113 // This code is useful to check cached clip rects, but is too expensive to l
eave enabled in debug builds by default. |
| 114 ClipRectsContext tempContext(context); | 114 ClipRectsContext tempContext(context); |
| 115 tempContext.cacheSlot = UncachedClipRects; | 115 tempContext.cacheSlot = UncachedClipRects; |
| 116 ClipRects clipRects; | 116 RefPtr<ClipRects> clipRects = ClipRects::create(); |
| 117 calculateClipRects(tempContext, clipRects); | 117 calculateClipRects(tempContext, *clipRects); |
| 118 ASSERT(clipRects == *entry.clipRects); | 118 ASSERT(clipRects == *entry.clipRects); |
| 119 #endif | 119 #endif |
| 120 | 120 |
| 121 return entry.clipRects.get(); | 121 return entry.clipRects.get(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 ClipRects* RenderLayerClipper::storeClipRectsInCache(const ClipRectsContext& con
text, ClipRects* parentClipRects, const ClipRects& clipRects) const | 124 ClipRects* RenderLayerClipper::storeClipRectsInCache(const ClipRectsContext& con
text, ClipRects* parentClipRects, const ClipRects& clipRects) const |
| 125 { | 125 { |
| 126 ClipRectsCache::Entry& entry = cache().get(context.cacheSlot); | 126 ClipRectsCache::Entry& entry = cache().get(context.cacheSlot); |
| 127 entry.root = context.rootLayer; | 127 entry.root = context.rootLayer; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 146 if (ClipRects* result = clipRectsIfCached(context)) | 146 if (ClipRects* result = clipRectsIfCached(context)) |
| 147 return result; | 147 return result; |
| 148 | 148 |
| 149 // Note that it's important that we call getClipRects on our parent | 149 // Note that it's important that we call getClipRects on our parent |
| 150 // before we call calculateClipRects so that calculateClipRects will hit | 150 // before we call calculateClipRects so that calculateClipRects will hit |
| 151 // the cache. | 151 // the cache. |
| 152 ClipRects* parentClipRects = 0; | 152 ClipRects* parentClipRects = 0; |
| 153 if (context.rootLayer != m_renderer.layer() && m_renderer.layer()->parent()) | 153 if (context.rootLayer != m_renderer.layer() && m_renderer.layer()->parent()) |
| 154 parentClipRects = m_renderer.layer()->parent()->clipper().getClipRects(c
ontext); | 154 parentClipRects = m_renderer.layer()->parent()->clipper().getClipRects(c
ontext); |
| 155 | 155 |
| 156 ClipRects clipRects; | 156 RefPtr<ClipRects> clipRects = ClipRects::create(); |
| 157 calculateClipRects(context, clipRects); | 157 calculateClipRects(context, *clipRects); |
| 158 return storeClipRectsInCache(context, parentClipRects, clipRects); | 158 return storeClipRectsInCache(context, parentClipRects, *clipRects); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void RenderLayerClipper::clearClipRectsIncludingDescendants() | 161 void RenderLayerClipper::clearClipRectsIncludingDescendants() |
| 162 { | 162 { |
| 163 m_cache = nullptr; | 163 m_cache = nullptr; |
| 164 | 164 |
| 165 for (RenderLayer* layer = m_renderer.layer()->firstChild(); layer; layer = l
ayer->nextSibling()) | 165 for (RenderLayer* layer = m_renderer.layer()->firstChild(); layer; layer = l
ayer->nextSibling()) |
| 166 layer->clipper().clearClipRectsIncludingDescendants(); | 166 layer->clipper().clearClipRectsIncludingDescendants(); |
| 167 } | 167 } |
| 168 | 168 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 return parentRects.posClipRect(); | 318 return parentRects.posClipRect(); |
| 319 | 319 |
| 320 return parentRects.overflowClipRect(); | 320 return parentRects.overflowClipRect(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 ClipRect RenderLayerClipper::backgroundClipRect(const ClipRectsContext& context)
const | 323 ClipRect RenderLayerClipper::backgroundClipRect(const ClipRectsContext& context)
const |
| 324 { | 324 { |
| 325 ASSERT(m_renderer.layer()->parent()); | 325 ASSERT(m_renderer.layer()->parent()); |
| 326 ASSERT(m_renderer.view()); | 326 ASSERT(m_renderer.view()); |
| 327 | 327 |
| 328 ClipRects parentClipRects; | 328 RefPtr<ClipRects> parentClipRects = ClipRects::create(); |
| 329 if (m_renderer.layer() == context.rootLayer) | 329 if (m_renderer.layer() == context.rootLayer) |
| 330 parentClipRects.reset(PaintInfo::infiniteRect()); | 330 parentClipRects->reset(PaintInfo::infiniteRect()); |
| 331 else | 331 else |
| 332 m_renderer.layer()->parent()->clipper().getOrCalculateClipRects(context,
parentClipRects); | 332 m_renderer.layer()->parent()->clipper().getOrCalculateClipRects(context,
*parentClipRects); |
| 333 | 333 |
| 334 ClipRect result = backgroundClipRectForPosition(parentClipRects, m_renderer.
style()->position()); | 334 ClipRect result = backgroundClipRectForPosition(*parentClipRects, m_renderer
.style()->position()); |
| 335 | 335 |
| 336 // Note: infinite clipRects should not be scrolled here, otherwise they will
accidentally no longer be considered infinite. | 336 // Note: infinite clipRects should not be scrolled here, otherwise they will
accidentally no longer be considered infinite. |
| 337 if (parentClipRects.fixed() && context.rootLayer->renderer() == m_renderer.v
iew() && result != PaintInfo::infiniteRect()) | 337 if (parentClipRects->fixed() && context.rootLayer->renderer() == m_renderer.
view() && result != PaintInfo::infiniteRect()) |
| 338 result.move(m_renderer.view()->frameView()->scrollOffsetForFixedPosition
()); | 338 result.move(m_renderer.view()->frameView()->scrollOffsetForFixedPosition
()); |
| 339 | 339 |
| 340 return result; | 340 return result; |
| 341 } | 341 } |
| 342 | 342 |
| 343 void RenderLayerClipper::getOrCalculateClipRects(const ClipRectsContext& context
, ClipRects& clipRects) const | 343 void RenderLayerClipper::getOrCalculateClipRects(const ClipRectsContext& context
, ClipRects& clipRects) const |
| 344 { | 344 { |
| 345 if (context.usesCache()) | 345 if (context.usesCache()) |
| 346 clipRects = *getClipRects(context); | 346 clipRects = *getClipRects(context); |
| 347 else | 347 else |
| (...skipping 18 matching lines...) Expand all Loading... |
| 366 ASSERT(current); | 366 ASSERT(current); |
| 367 if (current->transform() || current->isPaintInvalidationContainer()) | 367 if (current->transform() || current->isPaintInvalidationContainer()) |
| 368 return const_cast<RenderLayer*>(current); | 368 return const_cast<RenderLayer*>(current); |
| 369 } | 369 } |
| 370 | 370 |
| 371 ASSERT_NOT_REACHED(); | 371 ASSERT_NOT_REACHED(); |
| 372 return 0; | 372 return 0; |
| 373 } | 373 } |
| 374 | 374 |
| 375 } // namespace blink | 375 } // namespace blink |
| OLD | NEW |