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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
index 1a5d77abb68a402b57e8dcae0f7962db231868c9..373ded73a2ea82f67b824e726b067f35ed7542e5 100644
--- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
+++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp
@@ -55,6 +55,7 @@
#include "core/page/scrolling/StickyPositionScrollingConstraints.h"
#include "core/page/scrolling/TopDocumentRootScrollerController.h"
#include "core/paint/FramePaintTiming.h"
+#include "core/paint/LayerClipRecorder.h"
#include "core/paint/ObjectPaintInvalidator.h"
#include "core/paint/PaintInfo.h"
#include "core/paint/PaintLayerPainter.h"
@@ -551,23 +552,37 @@ void CompositedLayerMapping::UpdateCompositingReasons() {
}
bool CompositedLayerMapping::AncestorRoundedCornersWontClip(
chrishtr 2017/06/09 22:45:28 Please unittest this directly.
Stephen Chennney 2017/06/12 14:43:29 Will do.
- const LayoutBoxModelObject& child,
- const LayoutBoxModelObject& clipping_ancestor) {
- LayoutRect local_visual_rect = composited_bounds_;
- child.MapToVisualRectInAncestorSpace(&clipping_ancestor, local_visual_rect);
- FloatRoundedRect rounded_clip_rect =
- clipping_ancestor.Style()->GetRoundedInnerBorderFor(
- clipping_ancestor.LocalVisualRect());
- FloatRect inner_clip_rect = rounded_clip_rect.RadiusCenterRect();
- // The first condition catches cases where the child is certainly inside
- // the rounded corner portion of the border, and cannot be clipped by
- // the rounded portion. The second catches cases where the child is
- // entirely outside the rectangular border (ignoring rounded corners) so
- // is also unaffected by the rounded corners. In both cases the existing
- // rectangular clip is adequate and the mask is unnecessary.
- return inner_clip_rect.Contains(FloatRect(local_visual_rect)) ||
- !local_visual_rect.Intersects(
- EnclosingLayoutRect(rounded_clip_rect.Rect()));
+ 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
+ // Find the root-most clipper. We must process all clips in the chain to
+ // 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.
+ const PaintLayer* clip_root = clipping_container->EnclosingLayer();
+ while (const PaintLayer* new_clip_root =
+ clip_root->ClippingContainer()->EnclosingLayer()) {
+ clip_root = new_clip_root;
+ }
+
+ LayoutPoint offset_to_clipper;
+ owning_layer_.ConvertToLayerCoords(clip_root, offset_to_clipper);
+ Vector<FloatRoundedRect> rounded_rect_clips;
+ LayerClipRecorder::CollectRoundedRectClips(
+ owning_layer_, clip_root, -offset_to_clipper, true,
+ LayerClipRecorder::kDoNotIncludeSelfForBorderRadius, rounded_rect_clips);
+
+ for (auto clip_rect : rounded_rect_clips) {
+ FloatRect inner_clip_rect = clip_rect.RadiusCenterRect();
+ // The first condition catches cases where the child is certainly inside
+ // the rounded corner portion of the border, and cannot be clipped by
+ // the rounded portion. The second catches cases where the child is
+ // entirely outside the rectangular border (ignoring rounded corners) so
+ // is also unaffected by the rounded corners. In both cases the existing
+ // rectangular clip is adequate and the mask is unnecessary.
+ if (!(inner_clip_rect.Contains(FloatRect(composited_bounds_)) ||
+ !composited_bounds_.Intersects(
+ EnclosingLayoutRect(clip_rect.Rect())))) {
+ return false;
+ }
+ }
+ return true;
}
void CompositedLayerMapping::
@@ -619,11 +634,10 @@ void CompositedLayerMapping::
// TODO(schenney): CSS clips are not applied to composited children, and
// should be via mask or by compositing the parent too.
// https://bugs.chromium.org/p/chromium/issues/detail?id=615870
- DCHECK(clipping_container->Style());
- owning_layer_is_masked =
- owning_layer_is_clipped &&
- clipping_container->Style()->HasBorderRadius() &&
- !AncestorRoundedCornersWontClip(GetLayoutObject(), *clipping_container);
+ if (owning_layer_is_clipped) {
+ owning_layer_is_masked =
+ !AncestorRoundedCornersWontClip(clipping_container);
+ }
}
const PaintLayer* CompositedLayerMapping::ScrollParent() {

Powered by Google App Engine
This is Rietveld 408576698