| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 static void applyClipRects(const ClipRectsContext& context, const LayoutBoxModel
Object& layoutObject, LayoutPoint offset, ClipRects& clipRects) | 69 static void applyClipRects(const ClipRectsContext& context, const LayoutBoxModel
Object& layoutObject, LayoutPoint offset, ClipRects& clipRects) |
| 70 { | 70 { |
| 71 ASSERT(layoutObject.hasClipRelatedProperty()); | 71 ASSERT(layoutObject.hasClipRelatedProperty()); |
| 72 LayoutView* view = layoutObject.view(); | 72 LayoutView* view = layoutObject.view(); |
| 73 ASSERT(view); | 73 ASSERT(view); |
| 74 if (clipRects.fixed() && context.rootLayer->layoutObject() == view) | 74 if (clipRects.fixed() && context.rootLayer->layoutObject() == view) |
| 75 offset -= toIntSize(view->frameView()->scrollPosition()); | 75 offset -= toIntSize(view->frameView()->scrollPosition()); |
| 76 if (layoutObject.hasOverflowClip() || (layoutObject.styleRef().containsPaint
() && layoutObject.isBox())) { | 76 if (layoutObject.hasOverflowClip() || (layoutObject.styleRef().containsPaint
() && layoutObject.isBox())) { |
| 77 ClipRect newOverflowClip = toLayoutBox(layoutObject).overflowClipRect(of
fset, context.scrollbarRelevancy); | 77 ClipRect newOverflowClip = toLayoutBox(layoutObject).overflowClipRect(of
fset, context.overlayScrollbarClipBehavior); |
| 78 newOverflowClip.setHasRadius(layoutObject.styleRef().hasBorderRadius()); | 78 newOverflowClip.setHasRadius(layoutObject.styleRef().hasBorderRadius()); |
| 79 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRects.ov
erflowClipRect())); | 79 clipRects.setOverflowClipRect(intersection(newOverflowClip, clipRects.ov
erflowClipRect())); |
| 80 if (layoutObject.isPositioned()) | 80 if (layoutObject.isPositioned()) |
| 81 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects.pos
ClipRect())); | 81 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects.pos
ClipRect())); |
| 82 if (layoutObject.isLayoutView()) | 82 if (layoutObject.isLayoutView()) |
| 83 clipRects.setFixedClipRect(intersection(newOverflowClip, clipRects.f
ixedClipRect())); | 83 clipRects.setFixedClipRect(intersection(newOverflowClip, clipRects.f
ixedClipRect())); |
| 84 if (layoutObject.styleRef().containsPaint()) { | 84 if (layoutObject.styleRef().containsPaint()) { |
| 85 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects.pos
ClipRect())); | 85 clipRects.setPosClipRect(intersection(newOverflowClip, clipRects.pos
ClipRect())); |
| 86 clipRects.setFixedClipRect(intersection(newOverflowClip, clipRects.f
ixedClipRect())); | 86 clipRects.setFixedClipRect(intersection(newOverflowClip, clipRects.f
ixedClipRect())); |
| 87 } | 87 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 98 { | 98 { |
| 99 ASSERT(context.usesCache()); | 99 ASSERT(context.usesCache()); |
| 100 if (!m_layer.clipRectsCache()) | 100 if (!m_layer.clipRectsCache()) |
| 101 return nullptr; | 101 return nullptr; |
| 102 ClipRectsCache::Entry& entry = m_layer.clipRectsCache()->get(context.cacheSl
ot()); | 102 ClipRectsCache::Entry& entry = m_layer.clipRectsCache()->get(context.cacheSl
ot()); |
| 103 // FIXME: We used to ASSERT that we always got a consistent root layer. | 103 // FIXME: We used to ASSERT that we always got a consistent root layer. |
| 104 // We should add a test that has an inconsistent root. See | 104 // We should add a test that has an inconsistent root. See |
| 105 // http://crbug.com/366118 for an example. | 105 // http://crbug.com/366118 for an example. |
| 106 if (context.rootLayer != entry.root) | 106 if (context.rootLayer != entry.root) |
| 107 return 0; | 107 return 0; |
| 108 ASSERT(entry.scrollbarRelevancy == context.scrollbarRelevancy); | 108 ASSERT(entry.overlayScrollbarClipBehavior == context.overlayScrollbarClipBeh
avior); |
| 109 #ifdef CHECK_CACHED_CLIP_RECTS | 109 #ifdef CHECK_CACHED_CLIP_RECTS |
| 110 // This code is useful to check cached clip rects, but is too expensive to l
eave enabled in debug builds by default. | 110 // This code is useful to check cached clip rects, but is too expensive to l
eave enabled in debug builds by default. |
| 111 ClipRectsContext tempContext(context); | 111 ClipRectsContext tempContext(context); |
| 112 tempContext.cacheSlot = UncachedClipRects; | 112 tempContext.cacheSlot = UncachedClipRects; |
| 113 RefPtr<ClipRects> clipRects = ClipRects::create(); | 113 RefPtr<ClipRects> clipRects = ClipRects::create(); |
| 114 calculateClipRects(tempContext, *clipRects); | 114 calculateClipRects(tempContext, *clipRects); |
| 115 ASSERT(clipRects == *entry.clipRects); | 115 ASSERT(clipRects == *entry.clipRects); |
| 116 #endif | 116 #endif |
| 117 return entry.clipRects.get(); | 117 return entry.clipRects.get(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 ClipRects& PaintLayerClipper::storeClipRectsInCache(const ClipRectsContext& cont
ext, ClipRects* parentClipRects, const ClipRects& clipRects) const | 120 ClipRects& PaintLayerClipper::storeClipRectsInCache(const ClipRectsContext& cont
ext, ClipRects* parentClipRects, const ClipRects& clipRects) const |
| 121 { | 121 { |
| 122 ClipRectsCache::Entry& entry = m_layer.ensureClipRectsCache().get(context.ca
cheSlot()); | 122 ClipRectsCache::Entry& entry = m_layer.ensureClipRectsCache().get(context.ca
cheSlot()); |
| 123 entry.root = context.rootLayer; | 123 entry.root = context.rootLayer; |
| 124 #if ENABLE(ASSERT) | 124 #if ENABLE(ASSERT) |
| 125 entry.scrollbarRelevancy = context.scrollbarRelevancy; | 125 entry.overlayScrollbarClipBehavior = context.overlayScrollbarClipBehavior; |
| 126 #endif | 126 #endif |
| 127 if (parentClipRects) { | 127 if (parentClipRects) { |
| 128 // If our clip rects match the clip rects of our parent, we share storag
e. | 128 // If our clip rects match the clip rects of our parent, we share storag
e. |
| 129 if (clipRects == *parentClipRects) { | 129 if (clipRects == *parentClipRects) { |
| 130 entry.clipRects = parentClipRects; | 130 entry.clipRects = parentClipRects; |
| 131 return *parentClipRects; | 131 return *parentClipRects; |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 entry.clipRects = ClipRects::create(clipRects); | 134 entry.clipRects = ClipRects::create(clipRects); |
| 135 return *entry.clipRects; | 135 return *entry.clipRects; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 LayoutPoint offset; | 207 LayoutPoint offset; |
| 208 if (offsetFromRoot) | 208 if (offsetFromRoot) |
| 209 offset = *offsetFromRoot; | 209 offset = *offsetFromRoot; |
| 210 else | 210 else |
| 211 m_layer.convertToLayerCoords(context.rootLayer, offset); | 211 m_layer.convertToLayerCoords(context.rootLayer, offset); |
| 212 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); | 212 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); |
| 213 | 213 |
| 214 // Update the clip rects that will be passed to child layers. | 214 // Update the clip rects that will be passed to child layers. |
| 215 if ((layoutObject.hasOverflowClip() && shouldRespectOverflowClip(context)) | 215 if ((layoutObject.hasOverflowClip() && shouldRespectOverflowClip(context)) |
| 216 || (layoutObject.styleRef().containsPaint() && layoutObject.isBox())) { | 216 || (layoutObject.styleRef().containsPaint() && layoutObject.isBox())) { |
| 217 foregroundRect.intersect(toLayoutBox(layoutObject).overflowClipRect(offs
et, context.scrollbarRelevancy)); | 217 foregroundRect.intersect(toLayoutBox(layoutObject).overflowClipRect(offs
et, context.overlayScrollbarClipBehavior)); |
| 218 if (layoutObject.styleRef().hasBorderRadius()) | 218 if (layoutObject.styleRef().hasBorderRadius()) |
| 219 foregroundRect.setHasRadius(true); | 219 foregroundRect.setHasRadius(true); |
| 220 | 220 |
| 221 // FIXME: Does not do the right thing with columns yet, since we don't y
et factor in the | 221 // FIXME: Does not do the right thing with columns yet, since we don't y
et factor in the |
| 222 // individual column boxes as overflow. | 222 // individual column boxes as overflow. |
| 223 | 223 |
| 224 // The LayoutView is special since its overflow clipping rect may be lar
ger than its box rect (crbug.com/492871). | 224 // The LayoutView is special since its overflow clipping rect may be lar
ger than its box rect (crbug.com/492871). |
| 225 LayoutRect layerBoundsWithVisualOverflow = layoutObject.isLayoutView() ?
toLayoutView(layoutObject).viewRect() : toLayoutBox(layoutObject).visualOverflo
wRect(); | 225 LayoutRect layerBoundsWithVisualOverflow = layoutObject.isLayoutView() ?
toLayoutView(layoutObject).viewRect() : toLayoutBox(layoutObject).visualOverflo
wRect(); |
| 226 toLayoutBox(layoutObject).flipForWritingMode(layerBoundsWithVisualOverfl
ow); // PaintLayer are in physical coordinates, so the overflow has to be flippe
d. | 226 toLayoutBox(layoutObject).flipForWritingMode(layerBoundsWithVisualOverfl
ow); // PaintLayer are in physical coordinates, so the overflow has to be flippe
d. |
| 227 layerBoundsWithVisualOverflow.moveBy(offset); | 227 layerBoundsWithVisualOverflow.moveBy(offset); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 ClipRects& PaintLayerClipper::paintingClipRects(const PaintLayer* rootLayer, Sho
uldRespectOverflowClipType respectOverflowClip, const LayoutSize& subpixelAccumu
lation) const | 328 ClipRects& PaintLayerClipper::paintingClipRects(const PaintLayer* rootLayer, Sho
uldRespectOverflowClipType respectOverflowClip, const LayoutSize& subpixelAccumu
lation) const |
| 329 { | 329 { |
| 330 ClipRectsContext context(rootLayer, PaintingClipRects, IgnoreOverlayScrollba
rSize, subpixelAccumulation); | 330 ClipRectsContext context(rootLayer, PaintingClipRects, IgnoreOverlayScrollba
rSize, subpixelAccumulation); |
| 331 if (respectOverflowClip == IgnoreOverflowClip) | 331 if (respectOverflowClip == IgnoreOverflowClip) |
| 332 context.setIgnoreOverflowClip(); | 332 context.setIgnoreOverflowClip(); |
| 333 return getClipRects(context); | 333 return getClipRects(context); |
| 334 } | 334 } |
| 335 | 335 |
| 336 } // namespace blink | 336 } // namespace blink |
| OLD | NEW |