ladybird/Userland/Libraries/LibWeb/Painting/ScrollFrame.h
Aliaksandr Kalenik 866608532a LibWeb: Add parent-child relationship between scroll frames
This allows the calculation of the cumulative scroll offset for a scroll
frame by adding its scroll offset to the parent’s scroll offset, rather
than traversing the containing block chain. While it doesn't greatly
simplify calculations for typical scroll frames, it serves as a
preparation for supporting "position: sticky".
2024-08-30 19:03:06 +02:00

26 lines
510 B
C++

/*
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/PixelUnits.h>
namespace Web::Painting {
struct ScrollFrame : public RefCounted<ScrollFrame> {
i32 id { -1 };
CSSPixelPoint own_offset;
RefPtr<ScrollFrame const> parent;
CSSPixelPoint cumulative_offset() const
{
if (parent)
return parent->cumulative_offset() + own_offset;
return own_offset;
}
};
}