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

Side by Side Diff: third_party/WebKit/Source/core/paint/LayerClipRecorder.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 // 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 11 matching lines...) Expand all
22 const PaintLayer* clip_root, 22 const PaintLayer* clip_root,
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 bool painting_masks =
33 (paint_flags & kPaintLayerPaintingChildClippingMaskPhase ||
34 paint_flags & kPaintLayerPaintingAncestorClippingMaskPhase);
32 Vector<FloatRoundedRect> rounded_rects; 35 Vector<FloatRoundedRect> rounded_rects;
33 if (clip_root && clip_rect.HasRadius()) { 36 if (clip_root && (clip_rect.HasRadius() || painting_masks)) {
34 CollectRoundedRectClips(*layout_object.Layer(), clip_root, graphics_context, 37 CollectRoundedRectClips(*layout_object.Layer(), clip_root, fragment_offset,
35 fragment_offset, paint_flags, rule, rounded_rects); 38 painting_masks, rule, rounded_rects);
36 } 39 }
37 40
38 graphics_context_.GetPaintController().CreateAndAppend<ClipDisplayItem>( 41 graphics_context_.GetPaintController().CreateAndAppend<ClipDisplayItem>(
39 layout_object, clip_type_, snapped_clip_rect, rounded_rects); 42 layout_object, clip_type_, snapped_clip_rect, rounded_rects);
40 } 43 }
41 44
42 static bool InContainingBlockChain(PaintLayer* start_layer, 45 static bool InContainingBlockChain(PaintLayer* start_layer,
43 PaintLayer* end_layer) { 46 PaintLayer* end_layer) {
44 if (start_layer == end_layer) 47 if (start_layer == end_layer)
45 return true; 48 return true;
46 49
47 LayoutView* view = start_layer->GetLayoutObject().View(); 50 LayoutView* view = start_layer->GetLayoutObject().View();
48 for (const LayoutBlock* current_block = 51 for (const LayoutBlock* current_block =
49 start_layer->GetLayoutObject().ContainingBlock(); 52 start_layer->GetLayoutObject().ContainingBlock();
50 current_block && current_block != view; 53 current_block && current_block != view;
51 current_block = current_block->ContainingBlock()) { 54 current_block = current_block->ContainingBlock()) {
52 if (current_block->Layer() == end_layer) 55 if (current_block->Layer() == end_layer)
53 return true; 56 return true;
54 } 57 }
55 58
56 return false; 59 return false;
57 } 60 }
58 61
59 void LayerClipRecorder::CollectRoundedRectClips( 62 void LayerClipRecorder::CollectRoundedRectClips(
60 PaintLayer& paint_layer, 63 PaintLayer& paint_layer,
61 const PaintLayer* clip_root, 64 const PaintLayer* clip_root,
62 GraphicsContext& context, 65 const LayoutPoint& offset_within_layer,
63 const LayoutPoint& fragment_offset, 66 bool cross_composited_scrollers,
64 PaintLayerFlags paint_flags,
65 BorderRadiusClippingRule rule, 67 BorderRadiusClippingRule rule,
66 Vector<FloatRoundedRect>& rounded_rect_clips) { 68 Vector<FloatRoundedRect>& rounded_rect_clips) {
67 // If the clip rect has been tainted by a border radius, then we have to walk 69 // 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 70 // 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 71 // 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. 72 // be in our containing block chain so we check that also.
71 for (PaintLayer* layer = rule == kIncludeSelfForBorderRadius 73 for (PaintLayer* layer = rule == kIncludeSelfForBorderRadius
72 ? &paint_layer 74 ? &paint_layer
73 : paint_layer.Parent(); 75 : paint_layer.Parent();
74 layer; layer = layer->Parent()) { 76 layer; layer = layer->Parent()) {
75 // Composited scrolling layers handle border-radius clip in the compositor 77 // 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 78 // 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 79 // 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 80 // 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 81 // is properly clipped so that it can in turn clip the scrolled contents in
80 // the compositor. 82 // the compositor.
81 if (layer->NeedsCompositedScrolling() && 83 if (!cross_composited_scrollers && layer->NeedsCompositedScrolling())
82 !(paint_flags & kPaintLayerPaintingChildClippingMaskPhase ||
83 paint_flags & kPaintLayerPaintingAncestorClippingMaskPhase))
84 break; 84 break;
85 85
86 if (layer->GetLayoutObject().HasOverflowClip() && 86 if (layer->GetLayoutObject().HasOverflowClip() &&
87 layer->GetLayoutObject().Style()->HasBorderRadius() && 87 layer->GetLayoutObject().Style()->HasBorderRadius() &&
88 InContainingBlockChain(&paint_layer, layer)) { 88 InContainingBlockChain(&paint_layer, layer)) {
89 LayoutPoint delta(fragment_offset); 89 LayoutPoint delta(offset_within_layer);
90 layer->ConvertToLayerCoords(clip_root, delta); 90 layer->ConvertToLayerCoords(clip_root, delta);
91 91
92 // The PaintLayer's size is pixel-snapped if it is a LayoutBox. We can't 92 // 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 93 // use a pre-snapped border rect for clipping, since
94 // getRoundedInnerBorderFor assumes it has not been snapped yet. 94 // getRoundedInnerBorderFor assumes it has not been snapped yet.
95 LayoutSize size(layer->GetLayoutBox() 95 LayoutSize size(layer->GetLayoutBox()
96 ? ToLayoutBox(layer->GetLayoutObject()).Size() 96 ? ToLayoutBox(layer->GetLayoutObject()).Size()
97 : LayoutSize(layer->size())); 97 : LayoutSize(layer->size()));
98 rounded_rect_clips.push_back( 98 rounded_rect_clips.push_back(
99 layer->GetLayoutObject().Style()->GetRoundedInnerBorderFor( 99 layer->GetLayoutObject().Style()->GetRoundedInnerBorderFor(
100 LayoutRect(delta, size))); 100 LayoutRect(delta, size)));
101 } 101 }
102 102
103 if (layer == clip_root) 103 if (layer == clip_root)
104 break; 104 break;
105 } 105 }
106 } 106 }
107 107
108 LayerClipRecorder::~LayerClipRecorder() { 108 LayerClipRecorder::~LayerClipRecorder() {
109 if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) 109 if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled())
110 return; 110 return;
111 graphics_context_.GetPaintController().EndItem<EndClipDisplayItem>( 111 graphics_context_.GetPaintController().EndItem<EndClipDisplayItem>(
112 layout_object_, DisplayItem::ClipTypeToEndClipType(clip_type_)); 112 layout_object_, DisplayItem::ClipTypeToEndClipType(clip_type_));
113 } 113 }
114 114
115 } // namespace blink 115 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/LayerClipRecorder.h ('k') | third_party/WebKit/Source/core/paint/PaintLayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698