mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 08:59:50 +00:00
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".
26 lines
510 B
C++
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;
|
|
}
|
|
};
|
|
|
|
}
|