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

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: Fix the issue with missing masks 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/layout/api/LayoutAPIShim.h" 48 #include "core/layout/api/LayoutAPIShim.h"
49 #include "core/layout/api/LayoutEmbeddedContentItem.h" 49 #include "core/layout/api/LayoutEmbeddedContentItem.h"
50 #include "core/layout/compositing/PaintLayerCompositor.h" 50 #include "core/layout/compositing/PaintLayerCompositor.h"
51 #include "core/loader/resource/ImageResourceContent.h" 51 #include "core/loader/resource/ImageResourceContent.h"
52 #include "core/page/ChromeClient.h" 52 #include "core/page/ChromeClient.h"
53 #include "core/page/Page.h" 53 #include "core/page/Page.h"
54 #include "core/page/scrolling/ScrollingCoordinator.h" 54 #include "core/page/scrolling/ScrollingCoordinator.h"
55 #include "core/page/scrolling/StickyPositionScrollingConstraints.h" 55 #include "core/page/scrolling/StickyPositionScrollingConstraints.h"
56 #include "core/page/scrolling/TopDocumentRootScrollerController.h" 56 #include "core/page/scrolling/TopDocumentRootScrollerController.h"
57 #include "core/paint/FramePaintTiming.h" 57 #include "core/paint/FramePaintTiming.h"
58 #include "core/paint/LayerClipRecorder.h"
58 #include "core/paint/ObjectPaintInvalidator.h" 59 #include "core/paint/ObjectPaintInvalidator.h"
59 #include "core/paint/PaintInfo.h" 60 #include "core/paint/PaintInfo.h"
60 #include "core/paint/PaintLayerPainter.h" 61 #include "core/paint/PaintLayerPainter.h"
61 #include "core/paint/PaintLayerStackingNodeIterator.h" 62 #include "core/paint/PaintLayerStackingNodeIterator.h"
62 #include "core/paint/ScrollableAreaPainter.h" 63 #include "core/paint/ScrollableAreaPainter.h"
63 #include "core/paint/TransformRecorder.h" 64 #include "core/paint/TransformRecorder.h"
64 #include "core/plugins/PluginView.h" 65 #include "core/plugins/PluginView.h"
65 #include "core/probe/CoreProbes.h" 66 #include "core/probe/CoreProbes.h"
66 #include "platform/LengthFunctions.h" 67 #include "platform/LengthFunctions.h"
67 #include "platform/RuntimeEnabledFeatures.h" 68 #include "platform/RuntimeEnabledFeatures.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 544 }
544 545
545 void CompositedLayerMapping::UpdateCompositingReasons() { 546 void CompositedLayerMapping::UpdateCompositingReasons() {
546 // All other layers owned by this mapping will have the same compositing 547 // All other layers owned by this mapping will have the same compositing
547 // reason for their lifetime, so they are initialized only when created. 548 // reason for their lifetime, so they are initialized only when created.
548 graphics_layer_->SetCompositingReasons(owning_layer_.GetCompositingReasons()); 549 graphics_layer_->SetCompositingReasons(owning_layer_.GetCompositingReasons());
549 graphics_layer_->SetSquashingDisallowedReasons( 550 graphics_layer_->SetSquashingDisallowedReasons(
550 owning_layer_.GetSquashingDisallowedReasons()); 551 owning_layer_.GetSquashingDisallowedReasons());
551 } 552 }
552 553
553 bool CompositedLayerMapping::AncestorRoundedCornersWontClip( 554 bool CompositedLayerMapping::AncestorRoundedCornersWontClip(
chrishtr 2017/06/09 22:45:28 Please unittest this directly.
Stephen Chennney 2017/06/12 14:43:29 Will do.
554 const LayoutBoxModelObject& child, 555 const LayoutBoxModelObject* clipping_container) {
chrishtr 2017/06/09 22:45:28 I don't think this argument is necessary. Just ite
Stephen Chennney 2017/06/12 14:43:29 The argument is just because I happen to have alre
Stephen Chennney 2017/06/12 15:04:55 Misunderstood. I see what you mean now and have ma
555 const LayoutBoxModelObject& clipping_ancestor) { 556 // Find the root-most clipper. We must process all clips in the chain to
556 LayoutRect local_visual_rect = composited_bounds_; 557 // the root to correctly handle nested clips.
chrishtr 2017/06/09 22:45:28 You don't need to look above above compositing_anc
Stephen Chennney 2017/06/12 14:43:29 Yes. I get that now.
557 child.MapToVisualRectInAncestorSpace(&clipping_ancestor, local_visual_rect); 558 const PaintLayer* clip_root = clipping_container->EnclosingLayer();
558 FloatRoundedRect rounded_clip_rect = 559 while (const PaintLayer* new_clip_root =
559 clipping_ancestor.Style()->GetRoundedInnerBorderFor( 560 clip_root->ClippingContainer()->EnclosingLayer()) {
560 clipping_ancestor.LocalVisualRect()); 561 clip_root = new_clip_root;
561 FloatRect inner_clip_rect = rounded_clip_rect.RadiusCenterRect(); 562 }
562 // The first condition catches cases where the child is certainly inside 563
563 // the rounded corner portion of the border, and cannot be clipped by 564 LayoutPoint offset_to_clipper;
564 // the rounded portion. The second catches cases where the child is 565 owning_layer_.ConvertToLayerCoords(clip_root, offset_to_clipper);
565 // entirely outside the rectangular border (ignoring rounded corners) so 566 Vector<FloatRoundedRect> rounded_rect_clips;
566 // is also unaffected by the rounded corners. In both cases the existing 567 LayerClipRecorder::CollectRoundedRectClips(
567 // rectangular clip is adequate and the mask is unnecessary. 568 owning_layer_, clip_root, -offset_to_clipper, true,
568 return inner_clip_rect.Contains(FloatRect(local_visual_rect)) || 569 LayerClipRecorder::kDoNotIncludeSelfForBorderRadius, rounded_rect_clips);
569 !local_visual_rect.Intersects( 570
570 EnclosingLayoutRect(rounded_clip_rect.Rect())); 571 for (auto clip_rect : rounded_rect_clips) {
572 FloatRect inner_clip_rect = clip_rect.RadiusCenterRect();
573 // The first condition catches cases where the child is certainly inside
574 // the rounded corner portion of the border, and cannot be clipped by
575 // the rounded portion. The second catches cases where the child is
576 // entirely outside the rectangular border (ignoring rounded corners) so
577 // is also unaffected by the rounded corners. In both cases the existing
578 // rectangular clip is adequate and the mask is unnecessary.
579 if (!(inner_clip_rect.Contains(FloatRect(composited_bounds_)) ||
580 !composited_bounds_.Intersects(
581 EnclosingLayoutRect(clip_rect.Rect())))) {
582 return false;
583 }
584 }
585 return true;
571 } 586 }
572 587
573 void CompositedLayerMapping:: 588 void CompositedLayerMapping::
574 OwningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor( 589 OwningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor(
575 const PaintLayer* scroll_parent, 590 const PaintLayer* scroll_parent,
576 bool& owning_layer_is_clipped, 591 bool& owning_layer_is_clipped,
577 bool& owning_layer_is_masked) { 592 bool& owning_layer_is_masked) {
578 owning_layer_is_clipped = false; 593 owning_layer_is_clipped = false;
579 owning_layer_is_masked = false; 594 owning_layer_is_masked = false;
580 595
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 627
613 ClipRect clip_rect; 628 ClipRect clip_rect;
614 owning_layer_.Clipper(PaintLayer::kDoNotUseGeometryMapper) 629 owning_layer_.Clipper(PaintLayer::kDoNotUseGeometryMapper)
615 .CalculateBackgroundClipRect(clip_rects_context, clip_rect); 630 .CalculateBackgroundClipRect(clip_rects_context, clip_rect);
616 IntRect parent_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); 631 IntRect parent_clip_rect = PixelSnappedIntRect(clip_rect.Rect());
617 owning_layer_is_clipped = parent_clip_rect != LayoutRect::InfiniteIntRect(); 632 owning_layer_is_clipped = parent_clip_rect != LayoutRect::InfiniteIntRect();
618 633
619 // TODO(schenney): CSS clips are not applied to composited children, and 634 // TODO(schenney): CSS clips are not applied to composited children, and
620 // should be via mask or by compositing the parent too. 635 // should be via mask or by compositing the parent too.
621 // https://bugs.chromium.org/p/chromium/issues/detail?id=615870 636 // https://bugs.chromium.org/p/chromium/issues/detail?id=615870
622 DCHECK(clipping_container->Style()); 637 if (owning_layer_is_clipped) {
623 owning_layer_is_masked = 638 owning_layer_is_masked =
624 owning_layer_is_clipped && 639 !AncestorRoundedCornersWontClip(clipping_container);
625 clipping_container->Style()->HasBorderRadius() && 640 }
626 !AncestorRoundedCornersWontClip(GetLayoutObject(), *clipping_container);
627 } 641 }
628 642
629 const PaintLayer* CompositedLayerMapping::ScrollParent() { 643 const PaintLayer* CompositedLayerMapping::ScrollParent() {
630 const PaintLayer* scroll_parent = owning_layer_.ScrollParent(); 644 const PaintLayer* scroll_parent = owning_layer_.ScrollParent();
631 if (scroll_parent && !scroll_parent->NeedsCompositedScrolling()) 645 if (scroll_parent && !scroll_parent->NeedsCompositedScrolling())
632 return nullptr; 646 return nullptr;
633 return scroll_parent; 647 return scroll_parent;
634 } 648 }
635 649
636 bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration() { 650 bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration() {
(...skipping 3028 matching lines...) Expand 10 before | Expand all | Expand 10 after
3665 } else if (graphics_layer == decoration_outline_layer_.get()) { 3679 } else if (graphics_layer == decoration_outline_layer_.get()) {
3666 name = "Decoration Layer"; 3680 name = "Decoration Layer";
3667 } else { 3681 } else {
3668 NOTREACHED(); 3682 NOTREACHED();
3669 } 3683 }
3670 3684
3671 return name; 3685 return name;
3672 } 3686 }
3673 3687
3674 } // namespace blink 3688 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698