| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 6 * | 6 * |
| 7 * Other contributors: | 7 * Other contributors: |
| 8 * Robert O'Callahan <roc+@cs.cmu.edu> | 8 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 9 * David Baron <dbaron@fas.harvard.edu> | 9 * David Baron <dbaron@fas.harvard.edu> |
| 10 * Christian Biesinger <cbiesinger@web.de> | 10 * Christian Biesinger <cbiesinger@web.de> |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 m_layer.clipRectsCache()->get(context.cacheSlot()); | 121 m_layer.clipRectsCache()->get(context.cacheSlot()); |
| 122 // FIXME: We used to ASSERT that we always got a consistent root layer. | 122 // FIXME: We used to ASSERT that we always got a consistent root layer. |
| 123 // We should add a test that has an inconsistent root. See | 123 // We should add a test that has an inconsistent root. See |
| 124 // http://crbug.com/366118 for an example. | 124 // http://crbug.com/366118 for an example. |
| 125 if (context.rootLayer != entry.root) | 125 if (context.rootLayer != entry.root) |
| 126 return 0; | 126 return 0; |
| 127 #if DCHECK_IS_ON() | 127 #if DCHECK_IS_ON() |
| 128 DCHECK(entry.overlayScrollbarClipBehavior == | 128 DCHECK(entry.overlayScrollbarClipBehavior == |
| 129 context.overlayScrollbarClipBehavior); | 129 context.overlayScrollbarClipBehavior); |
| 130 #endif | 130 #endif |
| 131 return entry.clipRects.get(); | 131 return &entry.clipRects; |
| 132 } | 132 } |
| 133 | 133 |
| 134 ClipRects& PaintLayerClipper::storeClipRectsInCache( | 134 ClipRects& PaintLayerClipper::storeClipRectsInCache( |
| 135 const ClipRectsContext& context, | 135 const ClipRectsContext& context, |
| 136 ClipRects* parentClipRects, | 136 ClipRects* parentClipRects, |
| 137 const ClipRects& clipRects) const { | 137 const ClipRects& clipRects) const { |
| 138 ClipRectsCache::Entry& entry = | 138 ClipRectsCache::Entry& entry = |
| 139 m_layer.ensureClipRectsCache().get(context.cacheSlot()); | 139 m_layer.ensureClipRectsCache().get(context.cacheSlot()); |
| 140 entry.root = context.rootLayer; | 140 entry.root = context.rootLayer; |
| 141 #if DCHECK_IS_ON() | 141 #if DCHECK_IS_ON() |
| 142 entry.overlayScrollbarClipBehavior = context.overlayScrollbarClipBehavior; | 142 entry.overlayScrollbarClipBehavior = context.overlayScrollbarClipBehavior; |
| 143 #endif | 143 #endif |
| 144 if (parentClipRects) { | 144 if (parentClipRects) { |
| 145 // If our clip rects match the clip rects of our parent, we share storage. | 145 // If our clip rects match the clip rects of our parent, we share storage. |
| 146 if (clipRects == *parentClipRects) { | 146 if (clipRects == *parentClipRects) { |
| 147 entry.clipRects = parentClipRects; | 147 entry.clipRects = *parentClipRects; |
| 148 return *parentClipRects; | 148 return *parentClipRects; |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 entry.clipRects = ClipRects::create(clipRects); | 151 entry.clipRects = clipRects; |
| 152 return *entry.clipRects; | 152 return entry.clipRects; |
| 153 } | 153 } |
| 154 | 154 |
| 155 ClipRects& PaintLayerClipper::getClipRects( | 155 ClipRects& PaintLayerClipper::getClipRects( |
| 156 const ClipRectsContext& context) const { | 156 const ClipRectsContext& context) const { |
| 157 DCHECK(!m_geometryMapper); | 157 DCHECK(!m_geometryMapper); |
| 158 if (ClipRects* result = clipRectsIfCached(context)) | 158 if (ClipRects* result = clipRectsIfCached(context)) |
| 159 return *result; | 159 return *result; |
| 160 // Note that it's important that we call getClipRects on our parent | 160 // Note that it's important that we call getClipRects on our parent |
| 161 // before we call calculateClipRects so that calculateClipRects will hit | 161 // before we call calculateClipRects so that calculateClipRects will hit |
| 162 // the cache. | 162 // the cache. |
| 163 ClipRects* parentClipRects = nullptr; | 163 ClipRects* parentClipRects = nullptr; |
| 164 if (context.rootLayer != &m_layer && m_layer.parent()) { | 164 if (context.rootLayer != &m_layer && m_layer.parent()) { |
| 165 parentClipRects = | 165 parentClipRects = |
| 166 &PaintLayerClipper(*m_layer.parent(), nullptr).getClipRects(context); | 166 &PaintLayerClipper(*m_layer.parent(), nullptr).getClipRects(context); |
| 167 } | 167 } |
| 168 RefPtr<ClipRects> clipRects = ClipRects::create(); | 168 ClipRects clipRects; |
| 169 calculateClipRects(context, *clipRects); | 169 calculateClipRects(context, clipRects); |
| 170 return storeClipRectsInCache(context, parentClipRects, *clipRects); | 170 return storeClipRectsInCache(context, parentClipRects, clipRects); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void PaintLayerClipper::clearCache(ClipRectsCacheSlot cacheSlot) { | 173 void PaintLayerClipper::clearCache(ClipRectsCacheSlot cacheSlot) { |
| 174 if (cacheSlot == NumberOfClipRectsCacheSlots) | 174 if (cacheSlot == NumberOfClipRectsCacheSlots) |
| 175 m_layer.clearClipRectsCache(); | 175 m_layer.clearClipRectsCache(); |
| 176 else if (ClipRectsCache* cache = m_layer.clipRectsCache()) | 176 else if (ClipRectsCache* cache = m_layer.clipRectsCache()) |
| 177 cache->clear(cacheSlot); | 177 cache->clear(cacheSlot); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void PaintLayerClipper::clearClipRectsIncludingDescendants() { | 180 void PaintLayerClipper::clearClipRectsIncludingDescendants() { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 ClipRect testBackgroundClipRect = | 526 ClipRect testBackgroundClipRect = |
| 527 PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context); | 527 PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context); |
| 528 CHECK_RECTS_EQ(testBackgroundClipRect, output); | 528 CHECK_RECTS_EQ(testBackgroundClipRect, output); |
| 529 #endif | 529 #endif |
| 530 return; | 530 return; |
| 531 } | 531 } |
| 532 DCHECK(m_layer.parent()); | 532 DCHECK(m_layer.parent()); |
| 533 LayoutView* layoutView = m_layer.layoutObject().view(); | 533 LayoutView* layoutView = m_layer.layoutObject().view(); |
| 534 DCHECK(layoutView); | 534 DCHECK(layoutView); |
| 535 | 535 |
| 536 RefPtr<ClipRects> parentClipRects = ClipRects::create(); | 536 ClipRects parentClipRects; |
| 537 if (&m_layer == context.rootLayer) { | 537 if (&m_layer == context.rootLayer) { |
| 538 parentClipRects->reset(LayoutRect(LayoutRect::infiniteIntRect())); | 538 parentClipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())); |
| 539 } else { | 539 } else { |
| 540 PaintLayerClipper(*m_layer.parent(), m_geometryMapper) | 540 PaintLayerClipper(*m_layer.parent(), m_geometryMapper) |
| 541 .getOrCalculateClipRects(context, *parentClipRects); | 541 .getOrCalculateClipRects(context, parentClipRects); |
| 542 } | 542 } |
| 543 | 543 |
| 544 output = backgroundClipRectForPosition( | 544 output = backgroundClipRectForPosition( |
| 545 *parentClipRects, m_layer.layoutObject().styleRef().position()); | 545 parentClipRects, m_layer.layoutObject().styleRef().position()); |
| 546 | 546 |
| 547 // Note: infinite clipRects should not be scrolled here, otherwise they will | 547 // Note: infinite clipRects should not be scrolled here, otherwise they will |
| 548 // accidentally no longer be considered infinite. | 548 // accidentally no longer be considered infinite. |
| 549 if (parentClipRects->fixed() && | 549 if (parentClipRects.fixed() && |
| 550 &context.rootLayer->layoutObject() == layoutView && | 550 &context.rootLayer->layoutObject() == layoutView && |
| 551 output != LayoutRect(LayoutRect::infiniteIntRect())) | 551 output != LayoutRect(LayoutRect::infiniteIntRect())) |
| 552 output.move(LayoutSize(layoutView->frameView()->getScrollOffset())); | 552 output.move(LayoutSize(layoutView->frameView()->getScrollOffset())); |
| 553 } | 553 } |
| 554 | 554 |
| 555 void PaintLayerClipper::getOrCalculateClipRects(const ClipRectsContext& context, | 555 void PaintLayerClipper::getOrCalculateClipRects(const ClipRectsContext& context, |
| 556 ClipRects& clipRects) const { | 556 ClipRects& clipRects) const { |
| 557 DCHECK(!m_geometryMapper); | 557 DCHECK(!m_geometryMapper); |
| 558 | 558 |
| 559 if (context.usesCache()) | 559 if (context.usesCache()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 DCHECK(!m_geometryMapper); | 596 DCHECK(!m_geometryMapper); |
| 597 ClipRectsContext context(rootLayer, PaintingClipRects, | 597 ClipRectsContext context(rootLayer, PaintingClipRects, |
| 598 IgnorePlatformOverlayScrollbarSize, | 598 IgnorePlatformOverlayScrollbarSize, |
| 599 subpixelAccumulation); | 599 subpixelAccumulation); |
| 600 if (respectOverflowClip == IgnoreOverflowClip) | 600 if (respectOverflowClip == IgnoreOverflowClip) |
| 601 context.setIgnoreOverflowClip(); | 601 context.setIgnoreOverflowClip(); |
| 602 return getClipRects(context); | 602 return getClipRects(context); |
| 603 } | 603 } |
| 604 | 604 |
| 605 } // namespace blink | 605 } // namespace blink |
| OLD | NEW |