| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 entry.clipRects = parentClipRects; | 153 entry.clipRects = parentClipRects; |
| 154 return *parentClipRects; | 154 return *parentClipRects; |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 entry.clipRects = ClipRects::create(clipRects); | 157 entry.clipRects = ClipRects::create(clipRects); |
| 158 return *entry.clipRects; | 158 return *entry.clipRects; |
| 159 } | 159 } |
| 160 | 160 |
| 161 ClipRects& PaintLayerClipper::getClipRects( | 161 ClipRects& PaintLayerClipper::getClipRects( |
| 162 const ClipRectsContext& context) const { | 162 const ClipRectsContext& context) const { |
| 163 if (ClipRects* result = clipRectsIfCached(context)) | 163 // if (ClipRects* result = clipRectsIfCached(context)) |
| 164 return *result; | 164 // return *result; |
| 165 // Note that it's important that we call getClipRects on our parent | 165 // Note that it's important that we call getClipRects on our parent |
| 166 // before we call calculateClipRects so that calculateClipRects will hit | 166 // before we call calculateClipRects so that calculateClipRects will hit |
| 167 // the cache. | 167 // the cache. |
| 168 ClipRects* parentClipRects = nullptr; | 168 ClipRects* parentClipRects = nullptr; |
| 169 if (context.rootLayer != &m_layer && m_layer.parent()) | 169 if (context.rootLayer != &m_layer && m_layer.parent()) |
| 170 parentClipRects = &m_layer.parent()->clipper().getClipRects(context); | 170 parentClipRects = &m_layer.parent()->clipper().getClipRects(context); |
| 171 RefPtr<ClipRects> clipRects = ClipRects::create(); | 171 RefPtr<ClipRects> clipRects = ClipRects::create(); |
| 172 // LOG(ERROR) << "calculateClipRects:" << |
| 173 // m_layer.layoutObject()->debugName(); |
| 172 calculateClipRects(context, *clipRects); | 174 calculateClipRects(context, *clipRects); |
| 173 return storeClipRectsInCache(context, parentClipRects, *clipRects); | 175 return storeClipRectsInCache(context, parentClipRects, *clipRects); |
| 174 } | 176 } |
| 175 | 177 |
| 176 void PaintLayerClipper::clearCache(ClipRectsCacheSlot cacheSlot) { | 178 void PaintLayerClipper::clearCache(ClipRectsCacheSlot cacheSlot) { |
| 177 if (cacheSlot == NumberOfClipRectsCacheSlots) | 179 if (cacheSlot == NumberOfClipRectsCacheSlots) |
| 178 m_layer.clearClipRectsCache(); | 180 m_layer.clearClipRectsCache(); |
| 179 else if (ClipRectsCache* cache = m_layer.clipRectsCache()) | 181 else if (ClipRectsCache* cache = m_layer.clipRectsCache()) |
| 180 cache->clear(cacheSlot); | 182 cache->clear(cacheSlot); |
| 181 | 183 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 foregroundRect.setIsClippedByClipCss(); | 384 foregroundRect.setIsClippedByClipCss(); |
| 383 } | 385 } |
| 384 } | 386 } |
| 385 | 387 |
| 386 void PaintLayerClipper::calculateClipRects(const ClipRectsContext& context, | 388 void PaintLayerClipper::calculateClipRects(const ClipRectsContext& context, |
| 387 ClipRects& clipRects) const { | 389 ClipRects& clipRects) const { |
| 388 const LayoutBoxModelObject& layoutObject = *m_layer.layoutObject(); | 390 const LayoutBoxModelObject& layoutObject = *m_layer.layoutObject(); |
| 389 if (!m_layer.parent() && | 391 if (!m_layer.parent() && |
| 390 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 392 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 391 // The root layer's clip rect is always infinite. | 393 // The root layer's clip rect is always infinite. |
| 394 // LOG(ERROR) << "wat"; |
| 392 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())); | 395 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())); |
| 393 return; | 396 return; |
| 394 } | 397 } |
| 395 | 398 |
| 396 bool isClippingRoot = &m_layer == context.rootLayer; | 399 bool isClippingRoot = &m_layer == context.rootLayer; |
| 397 | 400 |
| 398 // For transformed layers, the root layer was shifted to be us, so there is no | 401 // For transformed layers, the root layer was shifted to be us, so there is no |
| 399 // need to examine the parent. We want to cache clip rects with us as the | 402 // need to examine the parent. We want to cache clip rects with us as the |
| 400 // root. | 403 // root. |
| 401 PaintLayer* parentLayer = !isClippingRoot ? m_layer.parent() : nullptr; | 404 PaintLayer* parentLayer = !isClippingRoot ? m_layer.parent() : nullptr; |
| 402 // Ensure that our parent's clip has been calculated so that we can examine | 405 // Ensure that our parent's clip has been calculated so that we can examine |
| 403 // the values. | 406 // the values. |
| 404 if (parentLayer) { | 407 if (parentLayer) { |
| 405 parentLayer->clipper().getOrCalculateClipRects(context, clipRects); | 408 parentLayer->clipper().getOrCalculateClipRects(context, clipRects); |
| 406 } else { | 409 } else { |
| 407 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())); | 410 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())); |
| 408 } | 411 } |
| 409 | 412 |
| 410 adjustClipRectsForChildren(layoutObject, clipRects); | 413 adjustClipRectsForChildren(layoutObject, clipRects); |
| 411 | 414 // LOG(ERROR) << "just before: " << m_layer.layoutObject()->debugName(); |
| 412 if (shouldClipOverflow(context) || layoutObject.hasClip()) { | 415 if (shouldClipOverflow(context) || layoutObject.hasClip()) { |
| 416 // LOG(ERROR) << "clipping overflow: " << |
| 417 // m_layer.layoutObject()->debugName(); |
| 413 // This offset cannot use convertToLayerCoords, because sometimes our | 418 // This offset cannot use convertToLayerCoords, because sometimes our |
| 414 // rootLayer may be across some transformed layer boundary, for example, in | 419 // rootLayer may be across some transformed layer boundary, for example, in |
| 415 // the PaintLayerCompositor overlapMap, where clipRects are needed in view | 420 // the PaintLayerCompositor overlapMap, where clipRects are needed in view |
| 416 // space. | 421 // space. |
| 417 applyClipRects(context, layoutObject, | 422 LOG(ERROR) << "mapping to ancestor: from=" << layoutObject.debugName() |
| 418 LayoutPoint(layoutObject.localToAncestorPoint( | 423 << " to=" << context.rootLayer->layoutObject()->debugName(); |
| 419 FloatPoint(), context.rootLayer->layoutObject())), | 424 LayoutPoint point(layoutObject.localToAncestorPoint( |
| 420 clipRects); | 425 FloatPoint(), context.rootLayer->layoutObject())); |
| 426 applyClipRects(context, layoutObject, point, clipRects); |
| 421 } | 427 } |
| 422 } | 428 } |
| 423 | 429 |
| 424 static ClipRect backgroundClipRectForPosition(const ClipRects& parentRects, | 430 static ClipRect backgroundClipRectForPosition(const ClipRects& parentRects, |
| 425 EPosition position) { | 431 EPosition position) { |
| 426 if (position == FixedPosition) | 432 if (position == FixedPosition) |
| 427 return parentRects.fixedClipRect(); | 433 return parentRects.fixedClipRect(); |
| 428 | 434 |
| 429 if (position == AbsolutePosition) | 435 if (position == AbsolutePosition) |
| 430 return parentRects.posClipRect(); | 436 return parentRects.posClipRect(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 clippedRectInRootLayerSpace.moveBy( | 478 clippedRectInRootLayerSpace.moveBy( |
| 473 -FloatPoint(context.rootLayer->layoutObject()->paintOffset())); | 479 -FloatPoint(context.rootLayer->layoutObject()->paintOffset())); |
| 474 return ClipRect(LayoutRect(clippedRectInRootLayerSpace)); | 480 return ClipRect(LayoutRect(clippedRectInRootLayerSpace)); |
| 475 } | 481 } |
| 476 | 482 |
| 477 ClipRect PaintLayerClipper::applyOverflowClipToBackgroundRectWithGeometryMapper( | 483 ClipRect PaintLayerClipper::applyOverflowClipToBackgroundRectWithGeometryMapper( |
| 478 const ClipRectsContext& context, | 484 const ClipRectsContext& context, |
| 479 const ClipRect& clip) const { | 485 const ClipRect& clip) const { |
| 480 const LayoutObject& layoutObject = *m_layer.layoutObject(); | 486 const LayoutObject& layoutObject = *m_layer.layoutObject(); |
| 481 FloatRect clipRect(clip.rect()); | 487 FloatRect clipRect(clip.rect()); |
| 488 // fix?? |
| 482 if (shouldClipOverflow(context)) { | 489 if (shouldClipOverflow(context)) { |
| 483 LayoutRect layerBoundsWithVisualOverflow = | 490 LayoutRect layerBoundsWithVisualOverflow = |
| 484 layoutObject.isLayoutView() | 491 layoutObject.isLayoutView() |
| 485 ? toLayoutView(layoutObject).viewRect() | 492 ? toLayoutView(layoutObject).viewRect() |
| 486 : toLayoutBox(layoutObject).visualOverflowRect(); | 493 : toLayoutBox(layoutObject).visualOverflowRect(); |
| 487 toLayoutBox(layoutObject) | 494 toLayoutBox(layoutObject) |
| 488 .flipForWritingMode( | 495 .flipForWritingMode( |
| 489 // PaintLayer are in physical coordinates, so the overflow has to be | 496 // PaintLayer are in physical coordinates, so the overflow has to be |
| 490 // flipped. | 497 // flipped. |
| 491 layerBoundsWithVisualOverflow); | 498 layerBoundsWithVisualOverflow); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 if (context.usesCache()) | 543 if (context.usesCache()) |
| 537 clipRects = getClipRects(context); | 544 clipRects = getClipRects(context); |
| 538 else | 545 else |
| 539 calculateClipRects(context, clipRects); | 546 calculateClipRects(context, clipRects); |
| 540 } | 547 } |
| 541 | 548 |
| 542 bool PaintLayerClipper::shouldClipOverflow( | 549 bool PaintLayerClipper::shouldClipOverflow( |
| 543 const ClipRectsContext& context) const { | 550 const ClipRectsContext& context) const { |
| 544 if (!m_layer.layoutObject()->isBox()) | 551 if (!m_layer.layoutObject()->isBox()) |
| 545 return false; | 552 return false; |
| 553 // LOG(ERROR) << "wat"; |
| 546 const LayoutBox& box = *toLayoutBox(m_layer.layoutObject()); | 554 const LayoutBox& box = *toLayoutBox(m_layer.layoutObject()); |
| 547 | 555 |
| 548 if (!shouldRespectOverflowClip(context)) | 556 if (!shouldRespectOverflowClip(context)) |
| 549 return false; | 557 return false; |
| 550 | |
| 551 return box.shouldClipOverflow(); | 558 return box.shouldClipOverflow(); |
| 552 } | 559 } |
| 553 | 560 |
| 554 bool PaintLayerClipper::shouldRespectOverflowClip( | 561 bool PaintLayerClipper::shouldRespectOverflowClip( |
| 555 const ClipRectsContext& context) const { | 562 const ClipRectsContext& context) const { |
| 556 if (&m_layer != context.rootLayer) | 563 if (&m_layer != context.rootLayer) |
| 557 return true; | 564 return true; |
| 558 | 565 |
| 559 if (context.respectOverflowClip == IgnoreOverflowClip) | 566 if (context.respectOverflowClip == IgnoreOverflowClip) |
| 560 return false; | 567 return false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 572 const LayoutSize& subpixelAccumulation) const { | 579 const LayoutSize& subpixelAccumulation) const { |
| 573 DCHECK(!m_geometryMapper); | 580 DCHECK(!m_geometryMapper); |
| 574 ClipRectsContext context(rootLayer, PaintingClipRects, | 581 ClipRectsContext context(rootLayer, PaintingClipRects, |
| 575 IgnoreOverlayScrollbarSize, subpixelAccumulation); | 582 IgnoreOverlayScrollbarSize, subpixelAccumulation); |
| 576 if (respectOverflowClip == IgnoreOverflowClip) | 583 if (respectOverflowClip == IgnoreOverflowClip) |
| 577 context.setIgnoreOverflowClip(); | 584 context.setIgnoreOverflowClip(); |
| 578 return getClipRects(context); | 585 return getClipRects(context); |
| 579 } | 586 } |
| 580 | 587 |
| 581 } // namespace blink | 588 } // namespace blink |
| OLD | NEW |