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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp

Issue 2893893003: Some simple cleanup in PaintPropertyTreeBuilder. (Closed)
Patch Set: none Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 } else { 743 } else {
744 PropertyTreeState local_border_box = 744 PropertyTreeState local_border_box =
745 PropertyTreeState(context.current.transform, context.current.clip, 745 PropertyTreeState(context.current.transform, context.current.clip,
746 context.current_effect); 746 context.current_effect);
747 object.GetMutableForPainting().SetLocalBorderBoxProperties( 747 object.GetMutableForPainting().SetLocalBorderBoxProperties(
748 local_border_box); 748 local_border_box);
749 } 749 }
750 } 750 }
751 751
752 static bool NeedsScrollbarPaintOffset(const LayoutObject& object) { 752 static bool NeedsScrollbarPaintOffset(const LayoutObject& object) {
753 if (object.IsBoxModelObject()) { 753 if (!object.IsBoxModelObject())
754 if (auto* area = ToLayoutBoxModelObject(object).GetScrollableArea()) { 754 return false;
755 if (area->HorizontalScrollbar() || area->VerticalScrollbar()) 755 if (auto* area = ToLayoutBoxModelObject(object).GetScrollableArea()) {
756 return true; 756 if (area->HorizontalScrollbar() || area->VerticalScrollbar())
757 } 757 return true;
758 } 758 }
759 return false; 759 return false;
760 } 760 }
761 761
762 // TODO(trchen): Remove this once we bake the paint offset into frameRect. 762 // TODO(trchen): Remove this once we bake the paint offset into frameRect.
763 void PaintPropertyTreeBuilder::UpdateScrollbarPaintOffset( 763 void PaintPropertyTreeBuilder::UpdateScrollbarPaintOffset(
764 const LayoutObject& object, 764 const LayoutObject& object,
765 ObjectPaintProperties& properties, 765 ObjectPaintProperties& properties,
766 PaintPropertyTreeBuilderFragmentContext& context, 766 PaintPropertyTreeBuilderFragmentContext& context,
767 bool& force_subtree_update) { 767 bool& force_subtree_update) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 // reasons at frame boundaries, so we can early-out when not at a LayoutView. 908 // reasons at frame boundaries, so we can early-out when not at a LayoutView.
909 // TODO(pdr): Need to find a solution to the style-related main thread 909 // TODO(pdr): Need to find a solution to the style-related main thread
910 // scrolling reasons such as opacity and transform which violate this. 910 // scrolling reasons such as opacity and transform which violate this.
911 if (!object.IsLayoutView()) 911 if (!object.IsLayoutView())
912 return ancestor_reasons; 912 return ancestor_reasons;
913 return GetMainThreadScrollingReasons(*object.GetFrameView(), 913 return GetMainThreadScrollingReasons(*object.GetFrameView(),
914 ancestor_reasons); 914 ancestor_reasons);
915 } 915 }
916 916
917 static bool NeedsScrollTranslation(const LayoutObject& object) { 917 static bool NeedsScrollTranslation(const LayoutObject& object) {
918 if (object.HasOverflowClip()) { 918 if (!object.HasOverflowClip())
919 const LayoutBox& box = ToLayoutBox(object); 919 return false;
920 auto* scrollable_area = box.GetScrollableArea(); 920 const LayoutBox& box = ToLayoutBox(object);
921 IntSize scroll_offset = box.ScrolledContentOffset(); 921 auto* scrollable_area = box.GetScrollableArea();
922 if (!scroll_offset.IsZero() || scrollable_area->ScrollsOverflow()) 922 IntSize scroll_offset = box.ScrolledContentOffset();
923 return true; 923 return !scroll_offset.IsZero() || scrollable_area->ScrollsOverflow();
wkorman 2017/05/18 23:47:22 Can scrollable area ever be null? Should we null-
chrishtr 2017/05/19 00:21:35 No, because HasOverflowClip ensures it. I don't kn
924 }
925 return false;
926 } 924 }
927 925
928 void PaintPropertyTreeBuilder::UpdateScrollAndScrollTranslation( 926 void PaintPropertyTreeBuilder::UpdateScrollAndScrollTranslation(
929 const LayoutObject& object, 927 const LayoutObject& object,
930 ObjectPaintProperties& properties, 928 ObjectPaintProperties& properties,
931 PaintPropertyTreeBuilderFragmentContext& context, 929 PaintPropertyTreeBuilderFragmentContext& context,
932 bool& force_subtree_update) { 930 bool& force_subtree_update) {
933 if (object.NeedsPaintPropertyUpdate() || force_subtree_update) { 931 if (object.NeedsPaintPropertyUpdate() || force_subtree_update) {
934 if (NeedsScrollTranslation(object)) { 932 if (NeedsScrollTranslation(object)) {
935 const LayoutBox& box = ToLayoutBox(object); 933 const LayoutBox& box = ToLayoutBox(object);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 } 968 }
971 } 969 }
972 970
973 if (properties.ScrollTranslation()) { 971 if (properties.ScrollTranslation()) {
974 context.current.transform = properties.ScrollTranslation(); 972 context.current.transform = properties.ScrollTranslation();
975 context.current.scroll = context.current.transform->ScrollNode(); 973 context.current.scroll = context.current.transform->ScrollNode();
976 context.current.should_flatten_inherited_transform = false; 974 context.current.should_flatten_inherited_transform = false;
977 } 975 }
978 } 976 }
979 977
980 static bool NeedsCssClipFixedPosition(const LayoutObject& object) {
981 return !object.IsLayoutView() && !object.CanContainFixedPositionObjects() &&
wkorman 2017/05/18 23:47:21 NeedsCssClip is obviously redundant with the one c
chrishtr 2017/05/19 00:21:35 The logic in UpdatePaintProperties looks like: bo
wkorman 2017/05/19 00:32:30 Ah. LOL.
982 NeedsCssClip(object);
983 }
984
985 void PaintPropertyTreeBuilder::UpdateOutOfFlowContext( 978 void PaintPropertyTreeBuilder::UpdateOutOfFlowContext(
986 const LayoutObject& object, 979 const LayoutObject& object,
987 PaintPropertyTreeBuilderFragmentContext& context, 980 PaintPropertyTreeBuilderFragmentContext& context,
988 bool& force_subtree_update) { 981 bool& force_subtree_update) {
989 if (!object.IsBoxModelObject() && !object.PaintProperties()) 982 if (!object.IsBoxModelObject() && !object.PaintProperties())
990 return; 983 return;
991 984
992 if (object.IsLayoutBlock()) 985 if (object.IsLayoutBlock())
993 context.paint_offset_for_float = context.current.paint_offset; 986 context.paint_offset_for_float = context.current.paint_offset;
994 987
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 1156
1164 void PaintPropertyTreeBuilder::UpdatePaintProperties( 1157 void PaintPropertyTreeBuilder::UpdatePaintProperties(
1165 const LayoutObject& object, 1158 const LayoutObject& object,
1166 PaintPropertyTreeBuilderContext& full_context) { 1159 PaintPropertyTreeBuilderContext& full_context) {
1167 bool needs_paint_properties = 1160 bool needs_paint_properties =
1168 NeedsPaintOffsetTranslation(object) || NeedsTransform(object) || 1161 NeedsPaintOffsetTranslation(object) || NeedsTransform(object) ||
1169 NeedsEffect(object) || NeedsTransformForNonRootSVG(object) || 1162 NeedsEffect(object) || NeedsTransformForNonRootSVG(object) ||
1170 NeedsFilter(object) || NeedsCssClip(object) || 1163 NeedsFilter(object) || NeedsCssClip(object) ||
1171 NeedsScrollbarPaintOffset(object) || NeedsOverflowClip(object) || 1164 NeedsScrollbarPaintOffset(object) || NeedsOverflowClip(object) ||
1172 NeedsPerspective(object) || NeedsSVGLocalToBorderBoxTransform(object) || 1165 NeedsPerspective(object) || NeedsSVGLocalToBorderBoxTransform(object) ||
1173 NeedsScrollTranslation(object) || NeedsCssClipFixedPosition(object); 1166 NeedsScrollTranslation(object);
1167
1174 bool had_paint_properties = object.PaintProperties(); 1168 bool had_paint_properties = object.PaintProperties();
1175 1169
1176 if (needs_paint_properties && !had_paint_properties) { 1170 if (needs_paint_properties && !had_paint_properties) {
1177 ObjectPaintProperties& paint_properties = 1171 ObjectPaintProperties& paint_properties =
1178 object.GetMutableForPainting().EnsurePaintProperties(); 1172 object.GetMutableForPainting().EnsurePaintProperties();
1179 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 1173 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
1180 paint_properties.SetCompositorElementId( 1174 paint_properties.SetCompositorElementId(
1181 CreateDomNodeBasedCompositorElementId(object)); 1175 CreateDomNodeBasedCompositorElementId(object));
1182 } 1176 }
1183 } else if (!needs_paint_properties && had_paint_properties) { 1177 } else if (!needs_paint_properties && had_paint_properties) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 context.force_subtree_update); 1270 context.force_subtree_update);
1277 1271
1278 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate(); 1272 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate();
1279 } 1273 }
1280 1274
1281 if (object.CanContainAbsolutePositionObjects()) 1275 if (object.CanContainAbsolutePositionObjects())
1282 context.container_for_absolute_position = &object; 1276 context.container_for_absolute_position = &object;
1283 } 1277 }
1284 1278
1285 } // namespace blink 1279 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698