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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2923683002: Fix nested border radius with composited child. (Closed)
Patch Set: Add tests and fix tests Created 3 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 543 }
544 544
545 void CompositedLayerMapping::UpdateCompositingReasons() { 545 void CompositedLayerMapping::UpdateCompositingReasons() {
546 // All other layers owned by this mapping will have the same compositing 546 // All other layers owned by this mapping will have the same compositing
547 // reason for their lifetime, so they are initialized only when created. 547 // reason for their lifetime, so they are initialized only when created.
548 graphics_layer_->SetCompositingReasons(owning_layer_.GetCompositingReasons()); 548 graphics_layer_->SetCompositingReasons(owning_layer_.GetCompositingReasons());
549 graphics_layer_->SetSquashingDisallowedReasons( 549 graphics_layer_->SetSquashingDisallowedReasons(
550 owning_layer_.GetSquashingDisallowedReasons()); 550 owning_layer_.GetSquashingDisallowedReasons());
551 } 551 }
552 552
553 bool CompositedLayerMapping::AncestorRoundedCornersWontClip(
554 const LayoutBoxModelObject& child,
555 const LayoutBoxModelObject& clipping_ancestor) {
556 LayoutRect local_visual_rect = composited_bounds_;
557 child.MapToVisualRectInAncestorSpace(&clipping_ancestor, local_visual_rect);
558 FloatRoundedRect rounded_clip_rect =
559 clipping_ancestor.Style()->GetRoundedInnerBorderFor(
560 clipping_ancestor.LocalVisualRect());
561 FloatRect inner_clip_rect = rounded_clip_rect.RadiusCenterRect();
562 // The first condition catches cases where the child is certainly inside
563 // the rounded corner portion of the border, and cannot be clipped by
564 // the rounded portion. The second catches cases where the child is
565 // entirely outside the rectangular border (ignoring rounded corners) so
566 // is also unaffected by the rounded corners. In both cases the existing
567 // rectangular clip is adequate and the mask is unnecessary.
568 return inner_clip_rect.Contains(FloatRect(local_visual_rect)) ||
569 !local_visual_rect.Intersects(
570 EnclosingLayoutRect(rounded_clip_rect.Rect()));
571 }
572
573 void CompositedLayerMapping:: 553 void CompositedLayerMapping::
574 OwningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor( 554 OwningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor(
575 const PaintLayer* scroll_parent, 555 const PaintLayer* scroll_parent,
576 bool& owning_layer_is_clipped, 556 bool& owning_layer_is_clipped,
577 bool& owning_layer_is_masked) { 557 bool& owning_layer_is_masked) {
578 owning_layer_is_clipped = false; 558 owning_layer_is_clipped = false;
579 owning_layer_is_masked = false; 559 owning_layer_is_masked = false;
580 560
581 if (!owning_layer_.Parent()) 561 if (!owning_layer_.Parent())
582 return; 562 return;
(...skipping 21 matching lines...) Expand all
604 // setting up m_ancestorClippingLayer otherwise 584 // setting up m_ancestorClippingLayer otherwise
605 // updateAncestorClippingLayerGeometry will fail as the clip rect will be 585 // updateAncestorClippingLayerGeometry will fail as the clip rect will be
606 // infinite. 586 // infinite.
607 // FIXME: this should use cached clip rects, but this sometimes give 587 // FIXME: this should use cached clip rects, but this sometimes give
608 // inaccurate results (and trips the ASSERTS in PaintLayerClipper). 588 // inaccurate results (and trips the ASSERTS in PaintLayerClipper).
609 ClipRectsContext clip_rects_context(compositing_ancestor, kUncachedClipRects, 589 ClipRectsContext clip_rects_context(compositing_ancestor, kUncachedClipRects,
610 kIgnorePlatformOverlayScrollbarSize); 590 kIgnorePlatformOverlayScrollbarSize);
611 clip_rects_context.SetIgnoreOverflowClip(); 591 clip_rects_context.SetIgnoreOverflowClip();
612 592
613 ClipRect clip_rect; 593 ClipRect clip_rect;
614 owning_layer_.Clipper(PaintLayer::kDoNotUseGeometryMapper) 594 owning_layer_.Clipper(PaintLayer::kDoNotUseGeometryMapper)
chrishtr 2017/06/09 17:29:30 1. clip_rect will be in the space of compositing_a
Stephen Chennney 2017/06/09 20:52:37 Acknowledged.
615 .CalculateBackgroundClipRect(clip_rects_context, clip_rect); 595 .CalculateBackgroundClipRect(clip_rects_context, clip_rect);
616 IntRect parent_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); 596 IntRect parent_clip_rect = PixelSnappedIntRect(clip_rect.Rect());
617 owning_layer_is_clipped = parent_clip_rect != LayoutRect::InfiniteIntRect(); 597 owning_layer_is_clipped = parent_clip_rect != LayoutRect::InfiniteIntRect();
618 598
619 // TODO(schenney): CSS clips are not applied to composited children, and 599 // TODO(schenney): CSS clips are not applied to composited children, and
620 // should be via mask or by compositing the parent too. 600 // should be via mask or by compositing the parent too.
621 // https://bugs.chromium.org/p/chromium/issues/detail?id=615870 601 // https://bugs.chromium.org/p/chromium/issues/detail?id=615870
622 DCHECK(clipping_container->Style()); 602 DCHECK(clipping_container->Style());
623 owning_layer_is_masked = 603 bool clip_rect_has_radius = clip_rect.HasRadius();
624 owning_layer_is_clipped && 604 LayoutRect local_visual_rect = composited_bounds_;
chrishtr 2017/06/09 17:29:30 2. local_visual_rect is in the space of owning_lay
Stephen Chennney 2017/06/09 20:52:37 Acknowledged.
625 clipping_container->Style()->HasBorderRadius() && 605 GetLayoutObject().MapToVisualRectInAncestorSpace(clipping_container,
chrishtr 2017/06/09 17:29:30 (1) and (2) lead me to conclude that you should us
Stephen Chennney 2017/06/09 20:52:37 Acknowledged.
626 !AncestorRoundedCornersWontClip(GetLayoutObject(), *clipping_container); 606 local_visual_rect);
607 clip_rect.Intersect(local_visual_rect);
608 owning_layer_is_masked = owning_layer_is_clipped && clip_rect_has_radius &&
609 !clip_rect.IsEmpty() &&
610 clip_rect.Rect() != local_visual_rect;
611
612 #ifndef NDEBUG
613 LOG(INFO) << "clipped? " << owning_layer_is_clipped << " masked? "
614 << owning_layer_is_masked << "clip_rect: " << clip_rect.ToString()
615 << " local rect " << local_visual_rect.ToString();
616 #endif
627 } 617 }
628 618
629 const PaintLayer* CompositedLayerMapping::ScrollParent() { 619 const PaintLayer* CompositedLayerMapping::ScrollParent() {
630 const PaintLayer* scroll_parent = owning_layer_.ScrollParent(); 620 const PaintLayer* scroll_parent = owning_layer_.ScrollParent();
631 if (scroll_parent && !scroll_parent->NeedsCompositedScrolling()) 621 if (scroll_parent && !scroll_parent->NeedsCompositedScrolling())
632 return nullptr; 622 return nullptr;
633 return scroll_parent; 623 return scroll_parent;
634 } 624 }
635 625
636 bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration() { 626 bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration() {
(...skipping 3026 matching lines...) Expand 10 before | Expand all | Expand 10 after
3663 } else if (graphics_layer == decoration_outline_layer_.get()) { 3653 } else if (graphics_layer == decoration_outline_layer_.get()) {
3664 name = "Decoration Layer"; 3654 name = "Decoration Layer";
3665 } else { 3655 } else {
3666 NOTREACHED(); 3656 NOTREACHED();
3667 } 3657 }
3668 3658
3669 return name; 3659 return name;
3670 } 3660 }
3671 3661
3672 } // namespace blink 3662 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698