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

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: Split tests, check layer sizes, document 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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 501
501 void CompositedLayerMapping::UpdateCompositingReasons() { 502 void CompositedLayerMapping::UpdateCompositingReasons() {
502 // All other layers owned by this mapping will have the same compositing 503 // All other layers owned by this mapping will have the same compositing
503 // reason for their lifetime, so they are initialized only when created. 504 // reason for their lifetime, so they are initialized only when created.
504 graphics_layer_->SetCompositingReasons(owning_layer_.GetCompositingReasons()); 505 graphics_layer_->SetCompositingReasons(owning_layer_.GetCompositingReasons());
505 graphics_layer_->SetSquashingDisallowedReasons( 506 graphics_layer_->SetSquashingDisallowedReasons(
506 owning_layer_.GetSquashingDisallowedReasons()); 507 owning_layer_.GetSquashingDisallowedReasons());
507 } 508 }
508 509
509 bool CompositedLayerMapping::AncestorRoundedCornersWontClip( 510 bool CompositedLayerMapping::AncestorRoundedCornersWontClip(
510 const LayoutBoxModelObject& child, 511 const PaintLayer* compositing_ancestor) {
511 const LayoutBoxModelObject& clipping_ancestor) { 512 // Find all clips up to the ancestor compositing container to correctly
512 LayoutRect local_visual_rect = composited_bounds_; 513 // handle nested clips.
513 child.MapToVisualRectInAncestorSpace(&clipping_ancestor, local_visual_rect); 514 LayoutPoint offset_to_clipper;
514 FloatRoundedRect rounded_clip_rect = 515 owning_layer_.ConvertToLayerCoords(compositing_ancestor, offset_to_clipper);
515 clipping_ancestor.Style()->GetRoundedInnerBorderFor( 516 Vector<FloatRoundedRect> rounded_rect_clips;
516 clipping_ancestor.LocalVisualRect()); 517 LayerClipRecorder::CollectRoundedRectClips(
517 FloatRect inner_clip_rect = rounded_clip_rect.RadiusCenterRect(); 518 owning_layer_, compositing_ancestor, -offset_to_clipper, true,
518 // The first condition catches cases where the child is certainly inside 519 LayerClipRecorder::kDoNotIncludeSelfForBorderRadius, rounded_rect_clips);
519 // the rounded corner portion of the border, and cannot be clipped by 520
520 // the rounded portion. The second catches cases where the child is 521 for (auto clip_rect : rounded_rect_clips) {
521 // entirely outside the rectangular border (ignoring rounded corners) so 522 FloatRect inner_clip_rect = clip_rect.RadiusCenterRect();
522 // is also unaffected by the rounded corners. In both cases the existing 523 // The first condition catches cases where the child is certainly inside
523 // rectangular clip is adequate and the mask is unnecessary. 524 // the rounded corner portion of the border, and cannot be clipped by
524 return inner_clip_rect.Contains(FloatRect(local_visual_rect)) || 525 // the rounded portion. The second catches cases where the child is
525 !local_visual_rect.Intersects( 526 // entirely outside the rectangular border (ignoring rounded corners) so
526 EnclosingLayoutRect(rounded_clip_rect.Rect())); 527 // is also unaffected by the rounded corners. In both cases the existing
528 // rectangular clip is adequate and the mask is unnecessary.
529 if (!(inner_clip_rect.Contains(FloatRect(composited_bounds_)) ||
530 !composited_bounds_.Intersects(
531 EnclosingLayoutRect(clip_rect.Rect())))) {
532 return false;
533 }
534 }
535 return true;
527 } 536 }
528 537
529 void CompositedLayerMapping:: 538 void CompositedLayerMapping::
530 OwningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor( 539 OwningLayerClippedOrMaskedByLayerNotAboveCompositedAncestor(
531 const PaintLayer* scroll_parent, 540 const PaintLayer* scroll_parent,
532 bool& owning_layer_is_clipped, 541 bool& owning_layer_is_clipped,
533 bool& owning_layer_is_masked) { 542 bool& owning_layer_is_masked) {
534 owning_layer_is_clipped = false; 543 owning_layer_is_clipped = false;
535 owning_layer_is_masked = false; 544 owning_layer_is_masked = false;
536 545
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 577
569 ClipRect clip_rect; 578 ClipRect clip_rect;
570 owning_layer_.Clipper(PaintLayer::kDoNotUseGeometryMapper) 579 owning_layer_.Clipper(PaintLayer::kDoNotUseGeometryMapper)
571 .CalculateBackgroundClipRect(clip_rects_context, clip_rect); 580 .CalculateBackgroundClipRect(clip_rects_context, clip_rect);
572 IntRect parent_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); 581 IntRect parent_clip_rect = PixelSnappedIntRect(clip_rect.Rect());
573 owning_layer_is_clipped = parent_clip_rect != LayoutRect::InfiniteIntRect(); 582 owning_layer_is_clipped = parent_clip_rect != LayoutRect::InfiniteIntRect();
574 583
575 // TODO(schenney): CSS clips are not applied to composited children, and 584 // TODO(schenney): CSS clips are not applied to composited children, and
576 // should be via mask or by compositing the parent too. 585 // should be via mask or by compositing the parent too.
577 // https://bugs.chromium.org/p/chromium/issues/detail?id=615870 586 // https://bugs.chromium.org/p/chromium/issues/detail?id=615870
578 DCHECK(clipping_container->Style()); 587 if (owning_layer_is_clipped) {
579 owning_layer_is_masked = 588 owning_layer_is_masked =
580 owning_layer_is_clipped && 589 !AncestorRoundedCornersWontClip(compositing_ancestor);
581 clipping_container->Style()->HasBorderRadius() && 590 }
582 !AncestorRoundedCornersWontClip(GetLayoutObject(), *clipping_container);
583 } 591 }
584 592
585 const PaintLayer* CompositedLayerMapping::ScrollParent() { 593 const PaintLayer* CompositedLayerMapping::ScrollParent() {
586 const PaintLayer* scroll_parent = owning_layer_.ScrollParent(); 594 const PaintLayer* scroll_parent = owning_layer_.ScrollParent();
587 if (scroll_parent && !scroll_parent->NeedsCompositedScrolling()) 595 if (scroll_parent && !scroll_parent->NeedsCompositedScrolling())
588 return nullptr; 596 return nullptr;
589 return scroll_parent; 597 return scroll_parent;
590 } 598 }
591 599
592 bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration() { 600 bool CompositedLayerMapping::UpdateGraphicsLayerConfiguration() {
(...skipping 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after
3647 } else if (graphics_layer == decoration_outline_layer_.get()) { 3655 } else if (graphics_layer == decoration_outline_layer_.get()) {
3648 name = "Decoration Layer"; 3656 name = "Decoration Layer";
3649 } else { 3657 } else {
3650 NOTREACHED(); 3658 NOTREACHED();
3651 } 3659 }
3652 3660
3653 return name; 3661 return name;
3654 } 3662 }
3655 3663
3656 } // namespace blink 3664 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698