// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_ANCHOR_POSITION_SCROLL_DATA_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_ANCHOR_POSITION_SCROLL_DATA_H_ #include "third_party/blink/renderer/core/dom/element_rare_data_field.h" #include "third_party/blink/renderer/core/layout/geometry/physical_offset.h" #include "third_party/blink/renderer/core/scroll/scroll_snapshot_client.h" #include "third_party/blink/renderer/platform/graphics/compositor_element_id.h" #include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/wtf/vector.h" #include "ui/gfx/geometry/vector2d.h" #include "ui/gfx/geometry/vector2d_f.h" namespace blink { class AnchorPositionVisibilityObserver; class Element; class LayoutObject; // Created for each anchor-positioned element. // // https://drafts.csswg.org/css-anchor-position-1/#scroll // // To adjust the location of the anchor-positioned element based on scroll, // sticky and anchor-positioning offsets between this element and the anchor, // this class stores a snapshot of all the scroll adjustment containers [1] of // the anchor up to the containing block (exclusively) of the anchor-positioned // element, along the containing block hierarchy. Note that "containing block" // is in the spec meaning, which corresponds to LayoutObject::Container() // instead of ContainingBlock(). // // [1] An element is a scroll adjustment container if it is a scroll container, // has sticky position, or is anchor-positioned. // // https://drafts.csswg.org/css-anchor-position-1/#fallback // // Also stores a snapshot of the scroll offset of the scroll container of the // anchor-positioned element, which affects position fallback. // // The snapshot passed as input to the position fallback and position visibility // algorithm. // // The snapshot is updated once per frame update on top of animation frame to // avoid layout cycling. If there is any change, we trigger an update to // layout and/or paint. class AnchorPositionScrollData : public GarbageCollected<AnchorPositionScrollData>, public ScrollSnapshotClient, public ElementRareDataField { … }; template <> struct DowncastTraits<AnchorPositionScrollData> { … }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_ANCHOR_POSITION_SCROLL_DATA_H_