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

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

Issue 2819923003: [SPInvalidation, SPv2] Compute paint offset for paginated content (Closed)
Patch Set: none Created 3 years, 8 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 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 // Initialize the context for current, absolute and fixed position cases. 198 // Initialize the context for current, absolute and fixed position cases.
199 // They are the same, except that scroll translation does not apply to 199 // They are the same, except that scroll translation does not apply to
200 // fixed position descendants. 200 // fixed position descendants.
201 const auto* fixed_transform_node = frame_view.PreTranslation() 201 const auto* fixed_transform_node = frame_view.PreTranslation()
202 ? frame_view.PreTranslation() 202 ? frame_view.PreTranslation()
203 : context.current.transform; 203 : context.current.transform;
204 auto* fixed_scroll_node = context.current.scroll; 204 auto* fixed_scroll_node = context.current.scroll;
205 DCHECK(frame_view.PreTranslation()); 205 DCHECK(frame_view.PreTranslation());
206 context.current.transform = frame_view.PreTranslation(); 206 context.current.transform = frame_view.PreTranslation();
207 context.current.transform_paint_layer = frame_view.GetLayoutView()->Layer();
207 DCHECK(frame_view.ContentClip()); 208 DCHECK(frame_view.ContentClip());
208 context.current.clip = frame_view.ContentClip(); 209 context.current.clip = frame_view.ContentClip();
209 if (const auto* scroll_translation = frame_view.ScrollTranslation()) { 210 if (const auto* scroll_translation = frame_view.ScrollTranslation()) {
210 context.current.transform = scroll_translation; 211 context.current.transform = scroll_translation;
211 context.current.scroll = scroll_translation->ScrollNode(); 212 context.current.scroll = scroll_translation->ScrollNode();
212 } 213 }
213 context.current.paint_offset = LayoutPoint(); 214 context.current.paint_offset = LayoutPoint();
214 context.current.rendering_context_id = 0; 215 context.current.rendering_context_id = 0;
215 context.current.should_flatten_inherited_transform = true; 216 context.current.should_flatten_inherited_transform = true;
216 context.absolute_position = context.current; 217 context.absolute_position = context.current;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 260
260 auto& properties = object.GetMutableForPainting().EnsurePaintProperties(); 261 auto& properties = object.GetMutableForPainting().EnsurePaintProperties();
261 context.force_subtree_update |= properties.UpdatePaintOffsetTranslation( 262 context.force_subtree_update |= properties.UpdatePaintOffsetTranslation(
262 context.current.transform, 263 context.current.transform,
263 TransformationMatrix().Translate(rounded_paint_offset.X(), 264 TransformationMatrix().Translate(rounded_paint_offset.X(),
264 rounded_paint_offset.Y()), 265 rounded_paint_offset.Y()),
265 FloatPoint3D(), context.current.should_flatten_inherited_transform, 266 FloatPoint3D(), context.current.should_flatten_inherited_transform,
266 context.current.rendering_context_id); 267 context.current.rendering_context_id);
267 268
268 context.current.transform = properties.PaintOffsetTranslation(); 269 context.current.transform = properties.PaintOffsetTranslation();
270 context.current.transform_paint_layer = object.Layer();
271
269 context.current.paint_offset = fractional_paint_offset; 272 context.current.paint_offset = fractional_paint_offset;
270 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() && 273 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled() &&
271 object.IsLayoutView()) { 274 object.IsLayoutView()) {
272 context.absolute_position.transform = properties.PaintOffsetTranslation(); 275 context.absolute_position.transform = properties.PaintOffsetTranslation();
276 context.absolute_position.transform_paint_layer = object.Layer();
273 context.fixed_position.transform = properties.PaintOffsetTranslation(); 277 context.fixed_position.transform = properties.PaintOffsetTranslation();
278 context.fixed_position.transform_paint_layer = object.Layer();
274 context.absolute_position.paint_offset = LayoutPoint(); 279 context.absolute_position.paint_offset = LayoutPoint();
275 context.fixed_position.paint_offset = LayoutPoint(); 280 context.fixed_position.paint_offset = LayoutPoint();
276 } 281 }
277 } 282 }
278 283
279 // SVG does not use the general transform update of |updateTransform|, instead 284 // SVG does not use the general transform update of |updateTransform|, instead
280 // creating a transform node for SVG-specific transforms without 3D. 285 // creating a transform node for SVG-specific transforms without 3D.
281 void PaintPropertyTreeBuilder::UpdateTransformForNonRootSVG( 286 void PaintPropertyTreeBuilder::UpdateTransformForNonRootSVG(
282 const LayoutObject& object, 287 const LayoutObject& object,
283 PaintPropertyTreeBuilderContext& context) { 288 PaintPropertyTreeBuilderContext& context) {
(...skipping 16 matching lines...) Expand all
300 context.current.transform, TransformationMatrix(transform), 305 context.current.transform, TransformationMatrix(transform),
301 FloatPoint3D()); 306 FloatPoint3D());
302 } else { 307 } else {
303 if (auto* properties = object.GetMutableForPainting().PaintProperties()) 308 if (auto* properties = object.GetMutableForPainting().PaintProperties())
304 context.force_subtree_update |= properties->ClearTransform(); 309 context.force_subtree_update |= properties->ClearTransform();
305 } 310 }
306 } 311 }
307 312
308 if (object.PaintProperties() && object.PaintProperties()->Transform()) { 313 if (object.PaintProperties() && object.PaintProperties()->Transform()) {
309 context.current.transform = object.PaintProperties()->Transform(); 314 context.current.transform = object.PaintProperties()->Transform();
315 context.current.transform_paint_layer = nullptr;
310 context.current.should_flatten_inherited_transform = false; 316 context.current.should_flatten_inherited_transform = false;
311 context.current.rendering_context_id = 0; 317 context.current.rendering_context_id = 0;
312 } 318 }
313 } 319 }
314 320
315 static CompositingReasons CompositingReasonsForTransform(const LayoutBox& box) { 321 static CompositingReasons CompositingReasonsForTransform(const LayoutBox& box) {
316 const ComputedStyle& style = box.StyleRef(); 322 const ComputedStyle& style = box.StyleRef();
317 CompositingReasons compositing_reasons = kCompositingReasonNone; 323 CompositingReasons compositing_reasons = kCompositingReasonNone;
318 if (CompositingReasonFinder::RequiresCompositingForTransform(box)) 324 if (CompositingReasonFinder::RequiresCompositingForTransform(box))
319 compositing_reasons |= kCompositingReason3DTransform; 325 compositing_reasons |= kCompositingReason3DTransform;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 407 }
402 if (!has_transform) { 408 if (!has_transform) {
403 if (auto* properties = object.GetMutableForPainting().PaintProperties()) 409 if (auto* properties = object.GetMutableForPainting().PaintProperties())
404 context.force_subtree_update |= properties->ClearTransform(); 410 context.force_subtree_update |= properties->ClearTransform();
405 } 411 }
406 } 412 }
407 413
408 const auto* properties = object.PaintProperties(); 414 const auto* properties = object.PaintProperties();
409 if (properties && properties->Transform()) { 415 if (properties && properties->Transform()) {
410 context.current.transform = properties->Transform(); 416 context.current.transform = properties->Transform();
417 if (object.IsBoxModelObject()) {
418 context.current.transform_paint_layer =
419 ToLayoutBoxModelObject(object).Layer();
420 }
411 if (object.StyleRef().Preserves3D()) { 421 if (object.StyleRef().Preserves3D()) {
412 context.current.rendering_context_id = 422 context.current.rendering_context_id =
413 properties->Transform()->RenderingContextId(); 423 properties->Transform()->RenderingContextId();
414 context.current.should_flatten_inherited_transform = false; 424 context.current.should_flatten_inherited_transform = false;
415 } else { 425 } else {
416 context.current.rendering_context_id = 0; 426 context.current.rendering_context_id = 0;
417 context.current.should_flatten_inherited_transform = true; 427 context.current.should_flatten_inherited_transform = true;
418 } 428 }
419 } 429 }
420 } 430 }
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 context.current.rendering_context_id); 821 context.current.rendering_context_id);
812 } else { 822 } else {
813 if (auto* properties = object.GetMutableForPainting().PaintProperties()) 823 if (auto* properties = object.GetMutableForPainting().PaintProperties())
814 context.force_subtree_update |= properties->ClearPerspective(); 824 context.force_subtree_update |= properties->ClearPerspective();
815 } 825 }
816 } 826 }
817 827
818 const auto* properties = object.PaintProperties(); 828 const auto* properties = object.PaintProperties();
819 if (properties && properties->Perspective()) { 829 if (properties && properties->Perspective()) {
820 context.current.transform = properties->Perspective(); 830 context.current.transform = properties->Perspective();
831 if (object.IsBoxModelObject()) {
832 context.current.transform_paint_layer =
833 ToLayoutBoxModelObject(object).Layer();
834 }
821 context.current.should_flatten_inherited_transform = false; 835 context.current.should_flatten_inherited_transform = false;
822 } 836 }
823 } 837 }
824 838
825 void PaintPropertyTreeBuilder::UpdateSvgLocalToBorderBoxTransform( 839 void PaintPropertyTreeBuilder::UpdateSvgLocalToBorderBoxTransform(
826 const LayoutObject& object, 840 const LayoutObject& object,
827 PaintPropertyTreeBuilderContext& context) { 841 PaintPropertyTreeBuilderContext& context) {
828 if (!object.IsSVGRoot()) 842 if (!object.IsSVGRoot())
829 return; 843 return;
830 844
(...skipping 11 matching lines...) Expand all
842 if (auto* properties = object.GetMutableForPainting().PaintProperties()) { 856 if (auto* properties = object.GetMutableForPainting().PaintProperties()) {
843 context.force_subtree_update |= 857 context.force_subtree_update |=
844 properties->ClearSvgLocalToBorderBoxTransform(); 858 properties->ClearSvgLocalToBorderBoxTransform();
845 } 859 }
846 } 860 }
847 } 861 }
848 862
849 const auto* properties = object.PaintProperties(); 863 const auto* properties = object.PaintProperties();
850 if (properties && properties->SvgLocalToBorderBoxTransform()) { 864 if (properties && properties->SvgLocalToBorderBoxTransform()) {
851 context.current.transform = properties->SvgLocalToBorderBoxTransform(); 865 context.current.transform = properties->SvgLocalToBorderBoxTransform();
866 if (object.IsBoxModelObject()) {
867 context.current.transform_paint_layer =
868 ToLayoutBoxModelObject(object).Layer();
869 }
852 context.current.should_flatten_inherited_transform = false; 870 context.current.should_flatten_inherited_transform = false;
853 context.current.rendering_context_id = 0; 871 context.current.rendering_context_id = 0;
854 } 872 }
855 // The paint offset is included in |transformToBorderBox| so SVG does not need 873 // The paint offset is included in |transformToBorderBox| so SVG does not need
856 // to handle paint offset internally. 874 // to handle paint offset internally.
857 context.current.paint_offset = LayoutPoint(); 875 context.current.paint_offset = LayoutPoint();
858 } 876 }
859 877
860 static MainThreadScrollingReasons GetMainThreadScrollingReasons( 878 static MainThreadScrollingReasons GetMainThreadScrollingReasons(
861 const LayoutObject& object, 879 const LayoutObject& object,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 if (!needs_scroll_properties) { 943 if (!needs_scroll_properties) {
926 // Ensure pre-existing properties are cleared. 944 // Ensure pre-existing properties are cleared.
927 if (auto* properties = object.GetMutableForPainting().PaintProperties()) 945 if (auto* properties = object.GetMutableForPainting().PaintProperties())
928 context.force_subtree_update |= properties->ClearScrollTranslation(); 946 context.force_subtree_update |= properties->ClearScrollTranslation();
929 } 947 }
930 } 948 }
931 949
932 if (object.PaintProperties() && 950 if (object.PaintProperties() &&
933 object.PaintProperties()->ScrollTranslation()) { 951 object.PaintProperties()->ScrollTranslation()) {
934 context.current.transform = object.PaintProperties()->ScrollTranslation(); 952 context.current.transform = object.PaintProperties()->ScrollTranslation();
953 if (object.IsBoxModelObject()) {
954 context.current.transform_paint_layer =
955 ToLayoutBoxModelObject(object).Layer();
956 }
935 context.current.scroll = context.current.transform->ScrollNode(); 957 context.current.scroll = context.current.transform->ScrollNode();
936 context.current.should_flatten_inherited_transform = false; 958 context.current.should_flatten_inherited_transform = false;
937 } 959 }
938 } 960 }
939 961
940 void PaintPropertyTreeBuilder::UpdateOutOfFlowContext( 962 void PaintPropertyTreeBuilder::UpdateOutOfFlowContext(
941 const LayoutObject& object, 963 const LayoutObject& object,
942 PaintPropertyTreeBuilderContext& context) { 964 PaintPropertyTreeBuilderContext& context) {
943 if (object.IsLayoutBlock()) 965 if (object.IsLayoutBlock())
944 context.paint_offset_for_float = context.current.paint_offset; 966 context.paint_offset_for_float = context.current.paint_offset;
945 967
946 if (object.CanContainAbsolutePositionObjects()) { 968 if (object.CanContainAbsolutePositionObjects()) {
947 context.absolute_position = context.current; 969 context.absolute_position = context.current;
948 context.container_for_absolute_position = &object; 970 context.container_for_absolute_position = &object;
949 } 971 }
950 972
951 if (object.IsLayoutView()) { 973 if (object.IsLayoutView()) {
952 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 974 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
953 const auto* initial_fixed_transform = context.fixed_position.transform; 975 const auto* initial_fixed_transform = context.fixed_position.transform;
976 const auto* initial_fixed_transform_paint_layer =
977 context.fixed_position.transform_paint_layer;
954 const auto* initial_fixed_scroll = context.fixed_position.scroll; 978 const auto* initial_fixed_scroll = context.fixed_position.scroll;
955 979
956 context.fixed_position = context.current; 980 context.fixed_position = context.current;
957 981
958 // Fixed position transform and scroll nodes should not be affected. 982 // Fixed position transform and scroll nodes should not be affected.
959 context.fixed_position.transform = initial_fixed_transform; 983 context.fixed_position.transform = initial_fixed_transform;
984 context.fixed_position.transform_paint_layer =
985 initial_fixed_transform_paint_layer;
960 context.fixed_position.scroll = initial_fixed_scroll; 986 context.fixed_position.scroll = initial_fixed_scroll;
961 } 987 }
962 } else if (object.CanContainFixedPositionObjects()) { 988 } else if (object.CanContainFixedPositionObjects()) {
963 context.fixed_position = context.current; 989 context.fixed_position = context.current;
964 } else if (object.GetMutableForPainting().PaintProperties() && 990 } else if (object.GetMutableForPainting().PaintProperties() &&
965 object.PaintProperties()->CssClip()) { 991 object.PaintProperties()->CssClip()) {
966 // CSS clip applies to all descendants, even if this object is not a 992 // CSS clip applies to all descendants, even if this object is not a
967 // containing block ancestor of the descendant. It is okay for 993 // containing block ancestor of the descendant. It is okay for
968 // absolute-position descendants because having CSS clip implies being 994 // absolute-position descendants because having CSS clip implies being
969 // absolute position container. However for fixed-position descendants we 995 // absolute position container. However for fixed-position descendants we
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 // This is a weird quirk that table cells paint as children of table rows, 1077 // This is a weird quirk that table cells paint as children of table rows,
1052 // but their location have the row's location baked-in. 1078 // but their location have the row's location baked-in.
1053 // Similar adjustment is done in LayoutTableCell::offsetFromContainer(). 1079 // Similar adjustment is done in LayoutTableCell::offsetFromContainer().
1054 if (object.IsTableCell()) { 1080 if (object.IsTableCell()) {
1055 LayoutObject* parent_row = object.Parent(); 1081 LayoutObject* parent_row = object.Parent();
1056 DCHECK(parent_row && parent_row->IsTableRow()); 1082 DCHECK(parent_row && parent_row->IsTableRow());
1057 context.current.paint_offset.MoveBy( 1083 context.current.paint_offset.MoveBy(
1058 -ToLayoutBox(parent_row)->PhysicalLocation()); 1084 -ToLayoutBox(parent_row)->PhysicalLocation());
1059 } 1085 }
1060 } 1086 }
1087
1088 // In the presence of pagination, recompute from scratch the paint offset.
1089 // The paint offset for a fragmented LayoutObject is the top-left of its
1090 // position in the first fragment in which it participates. See
1091 // crbug.com/648274.
1092 if (PaintLayer* paint_layer = object.PaintingLayer()) {
1093 if (paint_layer->EnclosingPaginationLayer()) {
1094 LayoutPoint local_offset = ToLayoutPoint(
1095 object.OffsetFromAncestorContainer(&paint_layer->GetLayoutObject()));
1096 DCHECK(context.current.transform_paint_layer);
1097 context.current.paint_offset = paint_layer->VisualOffsetFromAncestor(
1098 context.current.transform_paint_layer, local_offset);
1099 }
1100 }
1061 } 1101 }
1062 1102
1063 void PaintPropertyTreeBuilder::UpdateForObjectLocationAndSize( 1103 void PaintPropertyTreeBuilder::UpdateForObjectLocationAndSize(
1064 const LayoutObject& object, 1104 const LayoutObject& object,
1065 PaintPropertyTreeBuilderContext& context) { 1105 PaintPropertyTreeBuilderContext& context) {
1066 #if DCHECK_IS_ON() 1106 #if DCHECK_IS_ON()
1067 FindPaintOffsetNeedingUpdateScope check_scope(object, context); 1107 FindPaintOffsetNeedingUpdateScope check_scope(object, context);
1068 #endif 1108 #endif
1069 1109
1070 if (object.IsBoxModelObject()) { 1110 if (object.IsBoxModelObject()) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 UpdateOverflowClip(object, context); 1197 UpdateOverflowClip(object, context);
1158 UpdatePerspective(object, context); 1198 UpdatePerspective(object, context);
1159 UpdateSvgLocalToBorderBoxTransform(object, context); 1199 UpdateSvgLocalToBorderBoxTransform(object, context);
1160 UpdateScrollAndScrollTranslation(object, context); 1200 UpdateScrollAndScrollTranslation(object, context);
1161 UpdateOutOfFlowContext(object, context); 1201 UpdateOutOfFlowContext(object, context);
1162 1202
1163 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate(); 1203 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate();
1164 } 1204 }
1165 1205
1166 } // namespace blink 1206 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698