| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 if (auto* existing_content_clip = frame_view.ContentClip()) { | 65 if (auto* existing_content_clip = frame_view.ContentClip()) { |
| 66 existing_content_clip->Update(std::move(parent), | 66 existing_content_clip->Update(std::move(parent), |
| 67 std::move(local_transform_space), clip_rect); | 67 std::move(local_transform_space), clip_rect); |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 frame_view.SetContentClip(ClipPaintPropertyNode::Create( | 70 frame_view.SetContentClip(ClipPaintPropertyNode::Create( |
| 71 std::move(parent), std::move(local_transform_space), clip_rect)); | 71 std::move(parent), std::move(local_transform_space), clip_rect)); |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 | 74 |
| 75 static CompositorElementId CreateDomNodeBasedCompositorElementId( | 75 static CompositorElementId CreatePaintLayereBasedCompositorElementId( |
| 76 const LayoutObject& object) { | 76 const LayoutObject& object) { |
| 77 // TODO(wkorman): Centralize this implementation with similar across | 77 DCHECK(object.IsBoxModelObject() && object.HasLayer()); |
| 78 // animation, scrolling and compositing logic. | 78 return CompositorElementIdFromPaintLayerId( |
| 79 return CompositorElementIdFromDOMNodeId( | 79 ToLayoutBoxModelObject(object).Layer()->UniqueId(), |
| 80 DOMNodeIds::IdForNode(object.GetNode()), | |
| 81 CompositorElementIdNamespace::kPrimary); | 80 CompositorElementIdNamespace::kPrimary); |
| 82 } | 81 } |
| 83 | 82 |
| 84 // True if a new property was created or a main thread scrolling reason changed | 83 // True if a new property was created or a main thread scrolling reason changed |
| 85 // (which can affect descendants), false if an existing one was updated. | 84 // (which can affect descendants), false if an existing one was updated. |
| 86 static bool UpdateScrollTranslation( | 85 static bool UpdateScrollTranslation( |
| 87 FrameView& frame_view, | 86 FrameView& frame_view, |
| 88 PassRefPtr<const TransformPaintPropertyNode> parent, | 87 PassRefPtr<const TransformPaintPropertyNode> parent, |
| 89 const TransformationMatrix& matrix, | 88 const TransformationMatrix& matrix, |
| 90 const FloatPoint3D& origin, | 89 const FloatPoint3D& origin, |
| 91 PassRefPtr<const ScrollPaintPropertyNode> scroll_parent, | 90 PassRefPtr<const ScrollPaintPropertyNode> scroll_parent, |
| 92 const IntSize& clip, | 91 const IntSize& clip, |
| 93 const IntSize& bounds, | 92 const IntSize& bounds, |
| 94 bool user_scrollable_horizontal, | 93 bool user_scrollable_horizontal, |
| 95 bool user_scrollable_vertical, | 94 bool user_scrollable_vertical, |
| 96 MainThreadScrollingReasons main_thread_scrolling_reasons, | 95 MainThreadScrollingReasons main_thread_scrolling_reasons, |
| 97 WebLayerScrollClient* scroll_client) { | 96 WebLayerScrollClient* scroll_client) { |
| 98 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); | 97 DCHECK(!RuntimeEnabledFeatures::rootLayerScrollingEnabled()); |
| 99 CompositorElementId compositor_element_id = | 98 CompositorElementId compositor_element_id = |
| 100 CreateDomNodeBasedCompositorElementId(*frame_view.GetLayoutView()); | 99 CreatePaintLayereBasedCompositorElementId(*frame_view.GetLayoutView()); |
| 101 if (auto* existing_scroll_translation = frame_view.ScrollTranslation()) { | 100 if (auto* existing_scroll_translation = frame_view.ScrollTranslation()) { |
| 102 auto existing_reasons = existing_scroll_translation->ScrollNode() | 101 auto existing_reasons = existing_scroll_translation->ScrollNode() |
| 103 ->GetMainThreadScrollingReasons(); | 102 ->GetMainThreadScrollingReasons(); |
| 104 existing_scroll_translation->UpdateScrollTranslation( | 103 existing_scroll_translation->UpdateScrollTranslation( |
| 105 std::move(parent), matrix, origin, false, 0, kCompositingReasonNone, | 104 std::move(parent), matrix, origin, false, 0, kCompositingReasonNone, |
| 106 compositor_element_id, std::move(scroll_parent), clip, bounds, | 105 compositor_element_id, std::move(scroll_parent), clip, bounds, |
| 107 user_scrollable_horizontal, user_scrollable_vertical, | 106 user_scrollable_horizontal, user_scrollable_vertical, |
| 108 main_thread_scrolling_reasons, scroll_client); | 107 main_thread_scrolling_reasons, scroll_client); |
| 109 return existing_reasons != main_thread_scrolling_reasons; | 108 return existing_reasons != main_thread_scrolling_reasons; |
| 110 } | 109 } |
| (...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 NeedsFilter(object) || NeedsCssClip(object) || | 1187 NeedsFilter(object) || NeedsCssClip(object) || |
| 1189 NeedsScrollbarPaintOffset(object) || NeedsOverflowClip(object) || | 1188 NeedsScrollbarPaintOffset(object) || NeedsOverflowClip(object) || |
| 1190 NeedsPerspective(object) || NeedsSVGLocalToBorderBoxTransform(object) || | 1189 NeedsPerspective(object) || NeedsSVGLocalToBorderBoxTransform(object) || |
| 1191 NeedsScrollTranslation(object) || NeedsCssClipFixedPosition(object); | 1190 NeedsScrollTranslation(object) || NeedsCssClipFixedPosition(object); |
| 1192 | 1191 |
| 1193 bool had_paint_properties = object.PaintProperties(); | 1192 bool had_paint_properties = object.PaintProperties(); |
| 1194 | 1193 |
| 1195 if (needs_paint_properties && !had_paint_properties) { | 1194 if (needs_paint_properties && !had_paint_properties) { |
| 1196 ObjectPaintProperties& paint_properties = | 1195 ObjectPaintProperties& paint_properties = |
| 1197 object.GetMutableForPainting().EnsurePaintProperties(); | 1196 object.GetMutableForPainting().EnsurePaintProperties(); |
| 1198 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 1197 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && object.HasLayer()) { |
| 1199 paint_properties.SetCompositorElementId( | 1198 paint_properties.SetCompositorElementId( |
| 1200 CreateDomNodeBasedCompositorElementId(object)); | 1199 CreatePaintLayereBasedCompositorElementId(object)); |
| 1201 } | 1200 } |
| 1202 } else if (!needs_paint_properties && had_paint_properties) { | 1201 } else if (!needs_paint_properties && had_paint_properties) { |
| 1203 object.GetMutableForPainting().ClearPaintProperties(); | 1202 object.GetMutableForPainting().ClearPaintProperties(); |
| 1204 full_context.force_subtree_update = true; | 1203 full_context.force_subtree_update = true; |
| 1205 } | 1204 } |
| 1206 } | 1205 } |
| 1207 | 1206 |
| 1208 static inline bool ObjectTypeMightNeedPaintProperties( | 1207 static inline bool ObjectTypeMightNeedPaintProperties( |
| 1209 const LayoutObject& object) { | 1208 const LayoutObject& object) { |
| 1210 return object.IsBoxModelObject() || object.IsSVG(); | 1209 return object.IsBoxModelObject() || object.IsSVG(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 context.force_subtree_update); | 1279 context.force_subtree_update); |
| 1281 | 1280 |
| 1282 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate(); | 1281 context.force_subtree_update |= object.SubtreeNeedsPaintPropertyUpdate(); |
| 1283 } | 1282 } |
| 1284 | 1283 |
| 1285 if (object.CanContainAbsolutePositionObjects()) | 1284 if (object.CanContainAbsolutePositionObjects()) |
| 1286 context.container_for_absolute_position = &object; | 1285 context.container_for_absolute_position = &object; |
| 1287 } | 1286 } |
| 1288 | 1287 |
| 1289 } // namespace blink | 1288 } // namespace blink |
| OLD | NEW |