Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| index 206782a6454c44ec37bdf59615489fea93970959..2a5b8cb4a5a944b726e609cce8f75923b3db6e19 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| @@ -790,7 +790,7 @@ void PaintPropertyTreeBuilder::UpdateScrollbarPaintOffset( |
| } |
| } |
| -static bool NeedsOverflowScroll(const LayoutObject& object) { |
| +static bool NeedsOverflowClip(const LayoutObject& object) { |
| return object.IsBox() && ToLayoutBox(object).ShouldClipOverflow(); |
| } |
| @@ -799,11 +799,9 @@ void PaintPropertyTreeBuilder::UpdateOverflowClip( |
| PaintPropertyTreeBuilderFragmentContext& context, |
| bool& force_subtree_update) { |
| if (object.NeedsPaintPropertyUpdate() || force_subtree_update) { |
| - if (NeedsOverflowScroll(object)) { |
| + if (NeedsOverflowClip(object)) { |
| const LayoutBox& box = ToLayoutBox(object); |
| - LayoutRect clip_rect; |
| - clip_rect = |
| - LayoutRect(box.OverflowClipRect(context.current.paint_offset)); |
| + LayoutRect clip_rect = box.OverflowClipRect(context.current.paint_offset); |
| auto& properties = *object.GetMutableForPainting().PaintProperties(); |
| const auto* current_clip = context.current.clip; |
| @@ -1154,27 +1152,43 @@ void PaintPropertyTreeBuilder::UpdateForObjectLocationAndSize( |
| if (!object.IsBox()) |
| return; |
| const LayoutBox& box = ToLayoutBox(object); |
| - if (box.Size() == box.PreviousSize()) |
| - return; |
| + bool needs_paint_property_update = false; |
| + |
| + // The overflow clip rect may change even if this box's size didn't change, |
| + // e.g. LayoutMenuList::ControlClipRect() may depend on size of children. |
| + // Check for change of overflow clip rect to ensure paint property update. |
|
pdr.
2017/05/12 23:20:30
In other areas of code we mark the object as needi
Xianzhu
2017/05/13 00:16:02
ControlClipRect() is calculated from other propert
pdr.
2017/05/13 02:05:09
Is this just needed for ControlClipRect or is it n
Xianzhu
2017/05/13 04:55:06
SetNeedsPaintPropertyUpdate() in AdjustInnerStyle(
|
| + bool had_overflow_clip = |
| + box.PaintProperties() && box.PaintProperties()->OverflowClip(); |
| + if (NeedsOverflowClip(box) != had_overflow_clip) { |
| + needs_paint_property_update = true; |
| + } else if (had_overflow_clip && |
| + box.PaintProperties()->OverflowClip()->ClipRect().Rect() != |
| + FloatRect( |
| + box.OverflowClipRect(context.current.paint_offset))) { |
| + needs_paint_property_update = true; |
| + } |
| - // CSS mask and clip-path comes with an implicit clip to the border box. |
| - // Currently only SPv2 generate and take advantage of those. |
| - const bool box_generates_property_nodes_for_mask_and_clip_path = |
| - RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| - (box.HasMask() || box.HasClipPath()); |
| - // The overflow clip paint property depends on the border box rect through |
| - // overflowClipRect(). The border box rect's size equals the frame rect's |
| - // size so we trigger a paint property update when the frame rect changes. |
| - if (box.ShouldClipOverflow() || |
| + if (!needs_paint_property_update && box.Size() != box.PreviousSize()) { |
| + if (box.HasClip()) { |
| // The used value of CSS clip may depend on size of the box, e.g. for |
| // clip: rect(auto auto auto -5px). |
| - box.HasClip() || |
| + needs_paint_property_update = true; |
| + } else if (box.StyleRef().HasTransform() || |
| + box.StyleRef().HasPerspective()) { |
| // Relative lengths (e.g., percentage values) in transform, perspective, |
| // transform-origin, and perspective-origin can depend on the size of the |
| // frame rect, so force a property update if it changes. TODO(pdr): We |
| // only need to update properties if there are relative lengths. |
| - box.StyleRef().HasTransform() || box.StyleRef().HasPerspective() || |
| - box_generates_property_nodes_for_mask_and_clip_path) |
| + needs_paint_property_update = true; |
| + } else if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| + (box.HasMask() || box.HasClipPath())) { |
| + // CSS mask and clip-path comes with an implicit clip to the border box. |
| + // Currently only SPv2 generate and take advantage of those. |
| + needs_paint_property_update = true; |
| + } |
| + } |
| + |
| + if (needs_paint_property_update) |
| box.GetMutableForPainting().SetNeedsPaintPropertyUpdate(); |
| } |
| @@ -1185,7 +1199,7 @@ void PaintPropertyTreeBuilder::UpdatePaintProperties( |
| NeedsPaintOffsetTranslation(object) || NeedsTransform(object) || |
| NeedsEffect(object) || NeedsTransformForNonRootSVG(object) || |
| NeedsFilter(object) || NeedsCssClip(object) || |
| - NeedsScrollbarPaintOffset(object) || NeedsOverflowScroll(object) || |
| + NeedsScrollbarPaintOffset(object) || NeedsOverflowClip(object) || |
| NeedsPerspective(object) || NeedsSVGLocalToBorderBoxTransform(object) || |
| NeedsScrollTranslation(object) || NeedsCssClipFixedPosition(object); |