Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/PaintPropertyTreeBuilder.h" | 5 #include "core/paint/PaintPropertyTreeBuilder.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include "core/dom/DOMNodeIds.h" | 8 #include "core/dom/DOMNodeIds.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 rounded_paint_offset.X(), rounded_paint_offset.Y()); | 783 rounded_paint_offset.X(), rounded_paint_offset.Y()); |
| 784 auto& properties = *object.GetMutableForPainting().PaintProperties(); | 784 auto& properties = *object.GetMutableForPainting().PaintProperties(); |
| 785 force_subtree_update |= properties.UpdateScrollbarPaintOffset( | 785 force_subtree_update |= properties.UpdateScrollbarPaintOffset( |
| 786 context.current.transform, paint_offset, FloatPoint3D()); | 786 context.current.transform, paint_offset, FloatPoint3D()); |
| 787 } else { | 787 } else { |
| 788 if (auto* properties = object.GetMutableForPainting().PaintProperties()) | 788 if (auto* properties = object.GetMutableForPainting().PaintProperties()) |
| 789 force_subtree_update |= properties->ClearScrollbarPaintOffset(); | 789 force_subtree_update |= properties->ClearScrollbarPaintOffset(); |
| 790 } | 790 } |
| 791 } | 791 } |
| 792 | 792 |
| 793 static bool NeedsOverflowScroll(const LayoutObject& object) { | 793 static bool NeedsOverflowClip(const LayoutObject& object) { |
| 794 return object.IsBox() && ToLayoutBox(object).ShouldClipOverflow(); | 794 return object.IsBox() && ToLayoutBox(object).ShouldClipOverflow(); |
| 795 } | 795 } |
| 796 | 796 |
| 797 void PaintPropertyTreeBuilder::UpdateOverflowClip( | 797 void PaintPropertyTreeBuilder::UpdateOverflowClip( |
| 798 const LayoutObject& object, | 798 const LayoutObject& object, |
| 799 PaintPropertyTreeBuilderFragmentContext& context, | 799 PaintPropertyTreeBuilderFragmentContext& context, |
| 800 bool& force_subtree_update) { | 800 bool& force_subtree_update) { |
| 801 if (object.NeedsPaintPropertyUpdate() || force_subtree_update) { | 801 if (object.NeedsPaintPropertyUpdate() || force_subtree_update) { |
| 802 if (NeedsOverflowScroll(object)) { | 802 if (NeedsOverflowClip(object)) { |
| 803 const LayoutBox& box = ToLayoutBox(object); | 803 const LayoutBox& box = ToLayoutBox(object); |
| 804 LayoutRect clip_rect; | 804 LayoutRect clip_rect = box.OverflowClipRect(context.current.paint_offset); |
| 805 clip_rect = | |
| 806 LayoutRect(box.OverflowClipRect(context.current.paint_offset)); | |
| 807 | 805 |
| 808 auto& properties = *object.GetMutableForPainting().PaintProperties(); | 806 auto& properties = *object.GetMutableForPainting().PaintProperties(); |
| 809 const auto* current_clip = context.current.clip; | 807 const auto* current_clip = context.current.clip; |
| 810 if (box.StyleRef().HasBorderRadius()) { | 808 if (box.StyleRef().HasBorderRadius()) { |
| 811 auto inner_border = box.StyleRef().GetRoundedInnerBorderFor( | 809 auto inner_border = box.StyleRef().GetRoundedInnerBorderFor( |
| 812 LayoutRect(context.current.paint_offset, box.Size())); | 810 LayoutRect(context.current.paint_offset, box.Size())); |
| 813 force_subtree_update |= properties.UpdateInnerBorderRadiusClip( | 811 force_subtree_update |= properties.UpdateInnerBorderRadiusClip( |
| 814 context.current.clip, context.current.transform, inner_border); | 812 context.current.clip, context.current.transform, inner_border); |
| 815 current_clip = properties.InnerBorderRadiusClip(); | 813 current_clip = properties.InnerBorderRadiusClip(); |
| 816 } else { | 814 } else { |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1147 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1145 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 1148 object.GetMutableForPainting().SetShouldDoFullPaintInvalidation( | 1146 object.GetMutableForPainting().SetShouldDoFullPaintInvalidation( |
| 1149 kPaintInvalidationLocationChange); | 1147 kPaintInvalidationLocationChange); |
| 1150 } | 1148 } |
| 1151 object.GetMutableForPainting().SetPaintOffset(context.current.paint_offset); | 1149 object.GetMutableForPainting().SetPaintOffset(context.current.paint_offset); |
| 1152 } | 1150 } |
| 1153 | 1151 |
| 1154 if (!object.IsBox()) | 1152 if (!object.IsBox()) |
| 1155 return; | 1153 return; |
| 1156 const LayoutBox& box = ToLayoutBox(object); | 1154 const LayoutBox& box = ToLayoutBox(object); |
| 1157 if (box.Size() == box.PreviousSize()) | 1155 bool needs_paint_property_update = false; |
| 1158 return; | |
| 1159 | 1156 |
| 1160 // CSS mask and clip-path comes with an implicit clip to the border box. | 1157 // The overflow clip rect may change even if this box's size didn't change, |
| 1161 // Currently only SPv2 generate and take advantage of those. | 1158 // e.g. LayoutMenuList::ControlClipRect() may depend on size of children. |
| 1162 const bool box_generates_property_nodes_for_mask_and_clip_path = | 1159 // 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(
| |
| 1163 RuntimeEnabledFeatures::slimmingPaintV2Enabled() && | 1160 bool had_overflow_clip = |
| 1164 (box.HasMask() || box.HasClipPath()); | 1161 box.PaintProperties() && box.PaintProperties()->OverflowClip(); |
| 1165 // The overflow clip paint property depends on the border box rect through | 1162 if (NeedsOverflowClip(box) != had_overflow_clip) { |
| 1166 // overflowClipRect(). The border box rect's size equals the frame rect's | 1163 needs_paint_property_update = true; |
| 1167 // size so we trigger a paint property update when the frame rect changes. | 1164 } else if (had_overflow_clip && |
| 1168 if (box.ShouldClipOverflow() || | 1165 box.PaintProperties()->OverflowClip()->ClipRect().Rect() != |
| 1166 FloatRect( | |
| 1167 box.OverflowClipRect(context.current.paint_offset))) { | |
| 1168 needs_paint_property_update = true; | |
| 1169 } | |
| 1170 | |
| 1171 if (!needs_paint_property_update && box.Size() != box.PreviousSize()) { | |
| 1172 if (box.HasClip()) { | |
| 1169 // The used value of CSS clip may depend on size of the box, e.g. for | 1173 // The used value of CSS clip may depend on size of the box, e.g. for |
| 1170 // clip: rect(auto auto auto -5px). | 1174 // clip: rect(auto auto auto -5px). |
| 1171 box.HasClip() || | 1175 needs_paint_property_update = true; |
| 1176 } else if (box.StyleRef().HasTransform() || | |
| 1177 box.StyleRef().HasPerspective()) { | |
| 1172 // Relative lengths (e.g., percentage values) in transform, perspective, | 1178 // Relative lengths (e.g., percentage values) in transform, perspective, |
| 1173 // transform-origin, and perspective-origin can depend on the size of the | 1179 // transform-origin, and perspective-origin can depend on the size of the |
| 1174 // frame rect, so force a property update if it changes. TODO(pdr): We | 1180 // frame rect, so force a property update if it changes. TODO(pdr): We |
| 1175 // only need to update properties if there are relative lengths. | 1181 // only need to update properties if there are relative lengths. |
| 1176 box.StyleRef().HasTransform() || box.StyleRef().HasPerspective() || | 1182 needs_paint_property_update = true; |
| 1177 box_generates_property_nodes_for_mask_and_clip_path) | 1183 } else if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && |
| 1184 (box.HasMask() || box.HasClipPath())) { | |
| 1185 // CSS mask and clip-path comes with an implicit clip to the border box. | |
| 1186 // Currently only SPv2 generate and take advantage of those. | |
| 1187 needs_paint_property_update = true; | |
| 1188 } | |
| 1189 } | |
| 1190 | |
| 1191 if (needs_paint_property_update) | |
| 1178 box.GetMutableForPainting().SetNeedsPaintPropertyUpdate(); | 1192 box.GetMutableForPainting().SetNeedsPaintPropertyUpdate(); |
| 1179 } | 1193 } |
| 1180 | 1194 |
| 1181 void PaintPropertyTreeBuilder::UpdatePaintProperties( | 1195 void PaintPropertyTreeBuilder::UpdatePaintProperties( |
| 1182 const LayoutObject& object, | 1196 const LayoutObject& object, |
| 1183 PaintPropertyTreeBuilderContext& full_context) { | 1197 PaintPropertyTreeBuilderContext& full_context) { |
| 1184 bool needs_paint_properties = | 1198 bool needs_paint_properties = |
| 1185 NeedsPaintOffsetTranslation(object) || NeedsTransform(object) || | 1199 NeedsPaintOffsetTranslation(object) || NeedsTransform(object) || |
| 1186 NeedsEffect(object) || NeedsTransformForNonRootSVG(object) || | 1200 NeedsEffect(object) || NeedsTransformForNonRootSVG(object) || |
| 1187 NeedsFilter(object) || NeedsCssClip(object) || | 1201 NeedsFilter(object) || NeedsCssClip(object) || |
| 1188 NeedsScrollbarPaintOffset(object) || NeedsOverflowScroll(object) || | 1202 NeedsScrollbarPaintOffset(object) || NeedsOverflowClip(object) || |
| 1189 NeedsPerspective(object) || NeedsSVGLocalToBorderBoxTransform(object) || | 1203 NeedsPerspective(object) || NeedsSVGLocalToBorderBoxTransform(object) || |
| 1190 NeedsScrollTranslation(object) || NeedsCssClipFixedPosition(object); | 1204 NeedsScrollTranslation(object) || NeedsCssClipFixedPosition(object); |
| 1191 | 1205 |
| 1192 bool had_paint_properties = object.PaintProperties(); | 1206 bool had_paint_properties = object.PaintProperties(); |
| 1193 | 1207 |
| 1194 if (needs_paint_properties) { | 1208 if (needs_paint_properties) { |
| 1195 ObjectPaintProperties& paint_properties = | 1209 ObjectPaintProperties& paint_properties = |
| 1196 object.GetMutableForPainting().EnsurePaintProperties(); | 1210 object.GetMutableForPainting().EnsurePaintProperties(); |
| 1197 if (!had_paint_properties && | 1211 if (!had_paint_properties && |
| 1198 RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1212 RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1272 context.force_subtree_update); | 1286 context.force_subtree_update); |
| 1273 | 1287 |
| 1274 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate(); | 1288 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate(); |
| 1275 } | 1289 } |
| 1276 | 1290 |
| 1277 if (object.CanContainAbsolutePositionObjects()) | 1291 if (object.CanContainAbsolutePositionObjects()) |
| 1278 context.container_for_absolute_position = &object; | 1292 context.container_for_absolute_position = &object; |
| 1279 } | 1293 } |
| 1280 | 1294 |
| 1281 } // namespace blink | 1295 } // namespace blink |
| OLD | NEW |