mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibWeb: Add "position: sticky" support
Sticky positioning is implemented by modifying the algorithm for assigning and refreshing scroll frames. Now, elements with "position: sticky" are assigned their own scroll frame, and their position is refreshed independently from regular scroll boxes. Refreshing the scroll offsets for sticky boxes does not require display list invalidation. A separate hash map is used for the scroll frames of sticky boxes. This is necessary because a single paintable box can have two scroll frames if it 1) has "position: sticky" and 2) contains scrollable overflow.
This commit is contained in:
committed by
Alexander Kalenik
parent
866608532a
commit
30b636e90b
@@ -376,6 +376,24 @@ void LayoutState::commit(Box& root)
|
||||
auto& paintable_box = const_cast<Painting::PaintableBox&>(*box.paintable_box());
|
||||
if (!paintable_box.scroll_offset().is_zero())
|
||||
paintable_box.set_scroll_offset(paintable_box.scroll_offset());
|
||||
|
||||
if (box.is_sticky_position()) {
|
||||
auto sticky_insets = make<Painting::PaintableBox::StickyInsets>();
|
||||
auto const& inset = box.computed_values().inset();
|
||||
if (!inset.top().is_auto()) {
|
||||
sticky_insets->top = inset.top().to_px(box, used_values.containing_block_used_values()->content_height());
|
||||
}
|
||||
if (!inset.right().is_auto()) {
|
||||
sticky_insets->right = inset.right().to_px(box, used_values.containing_block_used_values()->content_width());
|
||||
}
|
||||
if (!inset.bottom().is_auto()) {
|
||||
sticky_insets->bottom = inset.bottom().to_px(box, used_values.containing_block_used_values()->content_height());
|
||||
}
|
||||
if (!inset.left().is_auto()) {
|
||||
sticky_insets->left = inset.left().to_px(box, used_values.containing_block_used_values()->content_width());
|
||||
}
|
||||
paintable_box.set_sticky_insets(move(sticky_insets));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user