#include "third_party/blink/renderer/core/paint/paint_property_tree_builder.h"
#include <memory>
#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "cc/base/features.h"
#include "cc/input/main_thread_scrolling_reason.h"
#include "cc/input/overscroll_behavior.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/core/animation/element_animations.h"
#include "third_party/blink/renderer/core/dom/dom_node_ids.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/html_select_element.h"
#include "third_party/blink/renderer/core/html/forms/text_control_element.h"
#include "third_party/blink/renderer/core/layout/anchor_position_scroll_data.h"
#include "third_party/blink/renderer/core/layout/block_break_token.h"
#include "third_party/blink/renderer/core/layout/fragmentainer_iterator.h"
#include "third_party/blink/renderer/core/layout/fragmentation_utils.h"
#include "third_party/blink/renderer/core/layout/geometry/transform_state.h"
#include "third_party/blink/renderer/core/layout/geometry/writing_mode_converter.h"
#include "third_party/blink/renderer/core/layout/inline/fragment_item.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/layout/layout_image.h"
#include "third_party/blink/renderer/core/layout/layout_inline.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_replaced.h"
#include "third_party/blink/renderer/core/layout/layout_video.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/pagination_utils.h"
#include "third_party/blink/renderer/core/layout/physical_box_fragment.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_clipper.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_root.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_viewport_container.h"
#include "third_party/blink/renderer/core/layout/svg/svg_layout_support.h"
#include "third_party/blink/renderer/core/layout/svg/svg_resources.h"
#include "third_party/blink/renderer/core/layout/svg/transform_helper.h"
#include "third_party/blink/renderer/core/layout/table/layout_table.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_row.h"
#include "third_party/blink/renderer/core/layout/table/layout_table_section.h"
#include "third_party/blink/renderer/core/page/link_highlight.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/scrolling/snap_coordinator.h"
#include "third_party/blink/renderer/core/page/scrolling/sticky_position_scrolling_constraints.h"
#include "third_party/blink/renderer/core/page/scrolling/top_document_root_scroller_controller.h"
#include "third_party/blink/renderer/core/paint/clip_path_clipper.h"
#include "third_party/blink/renderer/core/paint/compositing/compositing_reason_finder.h"
#include "third_party/blink/renderer/core/paint/css_mask_painter.h"
#include "third_party/blink/renderer/core/paint/cull_rect_updater.h"
#include "third_party/blink/renderer/core/paint/find_paint_offset_needing_update.h"
#include "third_party/blink/renderer/core/paint/find_properties_needing_update.h"
#include "third_party/blink/renderer/core/paint/object_paint_properties.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/paint/paint_property_tree_printer.h"
#include "third_party/blink/renderer/core/paint/pre_paint_disable_side_effects_scope.h"
#include "third_party/blink/renderer/core/paint/rounded_border_geometry.h"
#include "third_party/blink/renderer/core/paint/svg_root_painter.h"
#include "third_party/blink/renderer/core/paint/transform_utils.h"
#include "third_party/blink/renderer/core/style/computed_style_base_constants.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/core/style/style_overflow_clip_margin.h"
#include "third_party/blink/renderer/core/view_transition/view_transition.h"
#include "third_party/blink/renderer/core/view_transition/view_transition_utils.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
#include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h"
#include "third_party/blink/renderer/platform/graphics/paint/effect_paint_property_node.h"
#include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
#include "third_party/skia/include/core/SkRRect.h"
#include "ui/gfx/geometry/outsets_f.h"
#include "ui/gfx/geometry/transform.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
namespace blink {
namespace {
bool AreSubtreeUpdateReasonsIsolationPiercing(unsigned reasons) { … }
}
PaintPropertyTreeBuilderFragmentContext::
PaintPropertyTreeBuilderFragmentContext()
: … { … }
PaintPropertyTreeBuilderContext::PaintPropertyTreeBuilderContext()
: … { … }
void VisualViewportPaintPropertyTreeBuilder::Update(
LocalFrameView& main_frame_view,
VisualViewport& visual_viewport,
PaintPropertyTreeBuilderContext& full_context) { … }
void PaintPropertyTreeBuilder::SetupContextForFrame(
LocalFrameView& frame_view,
PaintPropertyTreeBuilderContext& full_context) { … }
namespace {
class FragmentPaintPropertyTreeBuilder { … };
static bool NeedsScrollOrScrollTranslation(
const LayoutObject& object,
CompositingReasons direct_compositing_reasons,
bool allow_scrolled_overflow_hidden = true) { … }
static bool NeedsScrollNode(const LayoutObject& object,
CompositingReasons direct_compositing_reasons) { … }
static bool NeedsReplacedContentTransform(const LayoutObject& object) { … }
static bool NeedsPaintOffsetTranslationForOverflowControls(
const LayoutBoxModelObject& object) { … }
static bool IsInLocalSubframe(const LayoutObject& object) { … }
static bool NeedsIsolationNodes(const LayoutObject& object) { … }
static bool NeedsStickyTranslation(const LayoutObject& object) { … }
static bool NeedsAnchorPositionScrollTranslation(const LayoutObject& object) { … }
static bool NeedsPaintOffsetTranslation(
const LayoutObject& object,
CompositingReasons direct_compositing_reasons,
const LayoutObject* container_for_fixed_position,
const PaintLayer* painting_layer) { … }
bool FragmentPaintPropertyTreeBuilder::CanPropagateSubpixelAccumulation()
const { … }
void FragmentPaintPropertyTreeBuilder::UpdateForPaintOffsetTranslation(
std::optional<gfx::Vector2d>& paint_offset_translation) { … }
void FragmentPaintPropertyTreeBuilder::UpdatePaintOffsetTranslation(
const std::optional<gfx::Vector2d>& paint_offset_translation) { … }
void FragmentPaintPropertyTreeBuilder::UpdateStickyTranslation() { … }
void FragmentPaintPropertyTreeBuilder::UpdateAnchorPositionScrollTranslation() { … }
static void DirectlyUpdateCcTransform(
const TransformPaintPropertyNode& transform,
const LayoutObject& object,
PaintPropertyChangeType& change_type) { … }
static void DirectlyUpdateCcOpacity(const LayoutObject& object,
ObjectPaintProperties& properties,
PaintPropertyChangeType& change_type) { … }
static CompositingReasons CompositingReasonsForTransformProperty() { … }
static bool NeedsTransformForSVGChild(
const LayoutObject& object,
CompositingReasons direct_compositing_reasons) { … }
TransformPaintPropertyNode::TransformAndOrigin
FragmentPaintPropertyTreeBuilder::TransformAndOriginForSVGChild() const { … }
void FragmentPaintPropertyTreeBuilder::UpdateTransformForSVGChild(
CompositingReasons direct_compositing_reasons) { … }
static gfx::Point3F GetTransformOrigin(const LayoutBox& box,
const PhysicalRect& reference_box) { … }
static bool NeedsIndividualTransform(
const LayoutObject& object,
CompositingReasons relevant_compositing_reasons,
bool (*style_test)(const ComputedStyle&)) { … }
static bool NeedsTranslate(const LayoutObject& object,
CompositingReasons direct_compositing_reasons) { … }
static bool NeedsRotate(const LayoutObject& object,
CompositingReasons direct_compositing_reasons) { … }
static bool NeedsScale(const LayoutObject& object,
CompositingReasons direct_compositing_reasons) { … }
static bool NeedsOffset(const LayoutObject& object,
CompositingReasons direct_compositing_reasons) { … }
static bool NeedsTransform(const LayoutObject& object,
CompositingReasons direct_compositing_reasons) { … }
static bool UpdateBoxSizeAndCheckActiveAnimationAxisAlignment(
const LayoutBox& object,
CompositingReasons compositing_reasons) { … }
static TransformPaintPropertyNode::TransformAndOrigin TransformAndOriginState(
const LayoutBox& box,
const PhysicalRect& reference_box,
void (*compute_matrix)(const LayoutBox& box,
const PhysicalRect& reference_box,
gfx::Transform& matrix)) { … }
static bool IsLayoutShiftRootTransform(
const TransformPaintPropertyNode& transform) { … }
void FragmentPaintPropertyTreeBuilder::UpdateIndividualTransform(
bool (*needs_property)(const LayoutObject&, CompositingReasons),
void (*compute_matrix)(const LayoutBox& box,
const PhysicalRect& reference_box,
gfx::Transform& matrix),
CompositingReasons compositing_reasons_for_property,
CompositorElementIdNamespace compositor_namespace,
bool (ComputedStyle::*running_on_compositor_test)() const,
const TransformPaintPropertyNode* (ObjectPaintProperties::*getter)() const,
PaintPropertyChangeType (ObjectPaintProperties::*updater)(
const TransformPaintPropertyNodeOrAlias&,
TransformPaintPropertyNode::State&&,
const TransformPaintPropertyNode::AnimationState&),
bool (ObjectPaintProperties::*clearer)()) { … }
void FragmentPaintPropertyTreeBuilder::UpdateTranslate() { … }
void FragmentPaintPropertyTreeBuilder::UpdateRotate() { … }
void FragmentPaintPropertyTreeBuilder::UpdateScale() { … }
void FragmentPaintPropertyTreeBuilder::UpdateOffset() { … }
void FragmentPaintPropertyTreeBuilder::UpdateTransform() { … }
static bool NeedsClipPathClipOrMask(const LayoutObject& object) { … }
static bool NeedsEffectForViewTransition(const LayoutObject& object) { … }
static bool NeedsEffectIgnoringClipPath(
const LayoutObject& object,
CompositingReasons direct_compositing_reasons) { … }
bool FragmentPaintPropertyTreeBuilder::NeedsEffect() const { … }
bool FragmentPaintPropertyTreeBuilder::EffectCanUseCurrentClipAsOutputClip()
const { … }
void FragmentPaintPropertyTreeBuilder::UpdateEffect() { … }
void FragmentPaintPropertyTreeBuilder::UpdateElementCaptureEffect() { … }
void FragmentPaintPropertyTreeBuilder::
UpdateViewTransitionSubframeRootEffect() { … }
void FragmentPaintPropertyTreeBuilder::UpdateViewTransitionEffect() { … }
void FragmentPaintPropertyTreeBuilder::UpdateViewTransitionClip() { … }
static bool IsLinkHighlighted(const LayoutObject& object) { … }
static bool IsClipPathDescendant(const LayoutObject& object) { … }
static bool NeedsFilter(const LayoutObject& object,
const PaintPropertyTreeBuilderContext& full_context) { … }
static void UpdateFilterEffect(const LayoutObject& object,
const EffectPaintPropertyNode* effect_node,
CompositorFilterOperations& filter) { … }
void FragmentPaintPropertyTreeBuilder::UpdateFilter() { … }
static FloatRoundedRect ToSnappedClipRect(const PhysicalRect& rect) { … }
static bool NeedsCssClip(const LayoutObject& object) { … }
void FragmentPaintPropertyTreeBuilder::UpdateCssClip() { … }
static std::optional<FloatRoundedRect> PathToRRect(const Path& path) { … }
void FragmentPaintPropertyTreeBuilder::UpdateClipPathClip() { … }
static bool ReplacedElementAlwaysClipsToContentBox(
const LayoutReplaced& replaced) { … }
static bool NeedsOverflowClipForReplacedContents(
const LayoutReplaced& replaced) { … }
static bool NeedsOverflowClip(const LayoutObject& object) { … }
void FragmentPaintPropertyTreeBuilder::UpdateLocalBorderBoxContext() { … }
bool FragmentPaintPropertyTreeBuilder::NeedsOverflowControlsClip() const { … }
static bool NeedsInnerBorderRadiusClip(const LayoutObject& object) { … }
void FragmentPaintPropertyTreeBuilder::UpdateOverflowControlsClip() { … }
static bool NeedsBackgroundClip(const LayoutObject& object) { … }
void FragmentPaintPropertyTreeBuilder::UpdateBackgroundClip() { … }
static void AdjustRoundedClipForOverflowClipMargin(
const LayoutBox& box,
gfx::RectF& layout_clip_rect,
FloatRoundedRect& paint_clip_rect) { … }
void FragmentPaintPropertyTreeBuilder::UpdateInnerBorderRadiusClip() { … }
void FragmentPaintPropertyTreeBuilder::UpdateOverflowClip() { … }
static gfx::PointF PerspectiveOrigin(const LayoutBox& box) { … }
static bool NeedsPerspective(const LayoutObject& object) { … }
void FragmentPaintPropertyTreeBuilder::UpdatePerspective() { … }
void FragmentPaintPropertyTreeBuilder::UpdateReplacedContentTransform() { … }
MainThreadScrollingReasons
FragmentPaintPropertyTreeBuilder::GetMainThreadScrollingReasons(
bool user_scrollable) const { … }
void FragmentPaintPropertyTreeBuilder::UpdateScrollAndScrollTranslation() { … }
void FragmentPaintPropertyTreeBuilder::UpdateOutOfFlowContext() { … }
void FragmentPaintPropertyTreeBuilder::UpdateTransformIsolationNode() { … }
void FragmentPaintPropertyTreeBuilder::UpdateEffectIsolationNode() { … }
void FragmentPaintPropertyTreeBuilder::UpdateClipIsolationNode() { … }
void FragmentPaintPropertyTreeBuilder::UpdatePaintOffset() { … }
void FragmentPaintPropertyTreeBuilder::SetNeedsPaintPropertyUpdateIfNeeded() { … }
void FragmentPaintPropertyTreeBuilder::UpdateForObjectLocation(
std::optional<gfx::Vector2d>& paint_offset_translation) { … }
static bool IsLayoutShiftRoot(const LayoutObject& object,
const FragmentData& fragment) { … }
void FragmentPaintPropertyTreeBuilder::UpdateForSelf() { … }
void FragmentPaintPropertyTreeBuilder::UpdateForChildren() { … }
void FragmentPaintPropertyTreeBuilder::UpdateLayoutShiftRootChanged(
bool is_layout_shift_root) { … }
}
void PaintPropertyTreeBuilder::InitPaintProperties() { … }
FragmentData& PaintPropertyTreeBuilder::GetFragmentData() const { … }
void PaintPropertyTreeBuilder::UpdateFragmentData() { … }
bool PaintPropertyTreeBuilder::ObjectTypeMightNeedPaintProperties() const { … }
void PaintPropertyTreeBuilder::UpdatePaintingLayer() { … }
void PaintPropertyTreeBuilder::UpdateForSelf() { … }
void PaintPropertyTreeBuilder::UpdateGlobalMainThreadScrollingReasons() { … }
void PaintPropertyTreeBuilder::UpdateForChildren() { … }
void PaintPropertyTreeBuilder::UpdateForPageBorderBox(
const PhysicalBoxFragment& page_container) { … }
bool PaintPropertyTreeBuilder::ScheduleDeferredTransformNodeUpdate(
LayoutObject& object) { … }
bool PaintPropertyTreeBuilder::ScheduleDeferredOpacityNodeUpdate(
LayoutObject& object) { … }
void PaintPropertyTreeBuilder::DirectlyUpdateTransformMatrix(
const LayoutObject& object) { … }
void PaintPropertyTreeBuilder::DirectlyUpdateOpacityValue(
const LayoutObject& object) { … }
void PaintPropertyTreeBuilder::IssueInvalidationsAfterUpdate() { … }
bool PaintPropertyTreeBuilder::CanDoDeferredTransformNodeUpdate(
const LayoutObject& object) { … }
bool PaintPropertyTreeBuilder::CanDoDeferredOpacityNodeUpdate(
const LayoutObject& object) { … }
}