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

Side by Side Diff: third_party/WebKit/Source/core/paint/LayerClipRecorder.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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/LayerClipRecorder.h" 5 #include "core/paint/LayerClipRecorder.h"
6 6
7 #include "core/layout/LayoutView.h" 7 #include "core/layout/LayoutView.h"
8 #include "core/paint/ClipRect.h" 8 #include "core/paint/ClipRect.h"
9 #include "core/paint/PaintLayer.h" 9 #include "core/paint/PaintLayer.h"
10 #include "platform/geometry/IntRect.h" 10 #include "platform/geometry/IntRect.h"
(...skipping 12 matching lines...) Expand all
23 const LayoutPoint& fragment_offset, 23 const LayoutPoint& fragment_offset,
24 PaintLayerFlags paint_flags, 24 PaintLayerFlags paint_flags,
25 BorderRadiusClippingRule rule) 25 BorderRadiusClippingRule rule)
26 : graphics_context_(graphics_context), 26 : graphics_context_(graphics_context),
27 layout_object_(layout_object), 27 layout_object_(layout_object),
28 clip_type_(clip_type) { 28 clip_type_(clip_type) {
29 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 29 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
30 return; 30 return;
31 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect()); 31 IntRect snapped_clip_rect = PixelSnappedIntRect(clip_rect.Rect());
32 Vector<FloatRoundedRect> rounded_rects; 32 Vector<FloatRoundedRect> rounded_rects;
33 if (clip_root && clip_rect.HasRadius()) { 33 if (clip_root) {
34 CollectRoundedRectClips(*layout_object.Layer(), clip_root, graphics_context, 34 CollectRoundedRectClips(*layout_object.Layer(), clip_root, graphics_context,
35 fragment_offset, paint_flags, rule, rounded_rects); 35 fragment_offset, paint_flags, rule, rounded_rects);
36 } 36 }
37 37
38 graphics_context_.GetPaintController().CreateAndAppend<ClipDisplayItem>( 38 graphics_context_.GetPaintController().CreateAndAppend<ClipDisplayItem>(
39 layout_object, clip_type_, snapped_clip_rect, rounded_rects); 39 layout_object, clip_type_, snapped_clip_rect, rounded_rects);
40 } 40 }
41 41
42 static bool InContainingBlockChain(PaintLayer* start_layer, 42 static bool InContainingBlockChain(PaintLayer* start_layer,
43 PaintLayer* end_layer) { 43 PaintLayer* end_layer) {
(...skipping 17 matching lines...) Expand all
61 const PaintLayer* clip_root, 61 const PaintLayer* clip_root,
62 GraphicsContext& context, 62 GraphicsContext& context,
63 const LayoutPoint& fragment_offset, 63 const LayoutPoint& fragment_offset,
64 PaintLayerFlags paint_flags, 64 PaintLayerFlags paint_flags,
65 BorderRadiusClippingRule rule, 65 BorderRadiusClippingRule rule,
66 Vector<FloatRoundedRect>& rounded_rect_clips) { 66 Vector<FloatRoundedRect>& rounded_rect_clips) {
67 // If the clip rect has been tainted by a border radius, then we have to walk 67 // If the clip rect has been tainted by a border radius, then we have to walk
68 // up our layer chain applying the clips from any layers with overflow. The 68 // up our layer chain applying the clips from any layers with overflow. The
69 // condition for being able to apply these clips is that the overflow object 69 // condition for being able to apply these clips is that the overflow object
70 // be in our containing block chain so we check that also. 70 // be in our containing block chain so we check that also.
71 #ifndef NDEBUG
72 LOG(INFO) << "CollectRoundedRectClips layer: " << &paint_layer;
73 LOG(INFO) << "CollectRoundedRectClips clip_root: " << clip_root;
74 #endif
71 for (PaintLayer* layer = rule == kIncludeSelfForBorderRadius 75 for (PaintLayer* layer = rule == kIncludeSelfForBorderRadius
72 ? &paint_layer 76 ? &paint_layer
73 : paint_layer.Parent(); 77 : paint_layer.Parent();
74 layer; layer = layer->Parent()) { 78 layer; layer = layer->Parent()) {
75 // Composited scrolling layers handle border-radius clip in the compositor 79 // Composited scrolling layers handle border-radius clip in the compositor
76 // via a mask layer. We do not want to apply a border-radius clip to the 80 // via a mask layer. We do not want to apply a border-radius clip to the
77 // layer contents itself, because that would require re-rastering every 81 // layer contents itself, because that would require re-rastering every
78 // frame to update the clip. We only want to make sure that the mask layer 82 // frame to update the clip. We only want to make sure that the mask layer
79 // is properly clipped so that it can in turn clip the scrolled contents in 83 // is properly clipped so that it can in turn clip the scrolled contents in
80 // the compositor. 84 // the compositor.
85 bool paintingAncestorMask =
86 paint_flags & kPaintLayerPaintingAncestorClippingMaskPhase;
81 if (layer->NeedsCompositedScrolling() && 87 if (layer->NeedsCompositedScrolling() &&
82 !(paint_flags & kPaintLayerPaintingChildClippingMaskPhase || 88 !(paint_flags & kPaintLayerPaintingChildClippingMaskPhase ||
83 paint_flags & kPaintLayerPaintingAncestorClippingMaskPhase)) 89 paintingAncestorMask))
84 break; 90 break;
85 91
86 if (layer->GetLayoutObject().HasOverflowClip() && 92 if (layer->GetLayoutObject().HasOverflowClip() &&
87 layer->GetLayoutObject().Style()->HasBorderRadius() && 93 layer->GetLayoutObject().Style()->HasBorderRadius() &&
88 InContainingBlockChain(&paint_layer, layer)) { 94 InContainingBlockChain(&paint_layer, layer)) {
89 LayoutPoint delta(fragment_offset); 95 LayoutPoint delta(fragment_offset);
90 layer->ConvertToLayerCoords(clip_root, delta); 96 layer->ConvertToLayerCoords(clip_root, delta);
91 97
92 // The PaintLayer's size is pixel-snapped if it is a LayoutBox. We can't 98 // The PaintLayer's size is pixel-snapped if it is a LayoutBox. We can't
93 // use a pre-snapped border rect for clipping, since 99 // use a pre-snapped border rect for clipping, since
94 // getRoundedInnerBorderFor assumes it has not been snapped yet. 100 // getRoundedInnerBorderFor assumes it has not been snapped yet.
95 LayoutSize size(layer->GetLayoutBox() 101 LayoutSize size(layer->GetLayoutBox()
96 ? ToLayoutBox(layer->GetLayoutObject()).Size() 102 ? ToLayoutBox(layer->GetLayoutObject()).Size()
97 : LayoutSize(layer->size())); 103 : LayoutSize(layer->size()));
98 rounded_rect_clips.push_back( 104 FloatRoundedRect clip_rect =
99 layer->GetLayoutObject().Style()->GetRoundedInnerBorderFor( 105 layer->GetLayoutObject().Style()->GetRoundedInnerBorderFor(
100 LayoutRect(delta, size))); 106 LayoutRect(delta, size));
107 rounded_rect_clips.push_back(clip_rect);
108 #ifndef NDEBUG
109 LOG(INFO) << "Adding rect for layer " << layer << " "
110 << clip_rect.ToString();
111 #endif
101 } 112 }
102 113
103 if (layer == clip_root) 114 if (layer == clip_root)
104 break; 115 break;
105 } 116 }
106 } 117 }
107 118
108 LayerClipRecorder::~LayerClipRecorder() { 119 LayerClipRecorder::~LayerClipRecorder() {
109 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 120 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
110 return; 121 return;
111 graphics_context_.GetPaintController().EndItem<EndClipDisplayItem>( 122 graphics_context_.GetPaintController().EndItem<EndClipDisplayItem>(
112 layout_object_, DisplayItem::ClipTypeToEndClipType(clip_type_)); 123 layout_object_, DisplayItem::ClipTypeToEndClipType(clip_type_));
113 } 124 }
114 125
115 } // namespace blink 126 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698