LibWeb: Propagate scrollbar-width property from root element to viewport

This commit is contained in:
Aliaksandr Kalenik 2024-06-01 19:07:58 +03:00 committed by Andreas Kling
parent 50920b0595
commit eb909118bf
Notes: sideshowbarker 2024-07-16 16:23:32 +09:00

View file

@ -1026,6 +1026,15 @@ void Document::invalidate_layout()
schedule_layout_update(); schedule_layout_update();
} }
static void propagate_scrollbar_width_to_viewport(Element& root_element, Layout::Viewport& viewport)
{
// https://drafts.csswg.org/css-scrollbars/#scrollbar-width
// UAs must apply the scrollbar-color value set on the root element to the viewport.
auto& viewport_computed_values = viewport.mutable_computed_values();
auto& root_element_computed_values = root_element.layout_node()->computed_values();
viewport_computed_values.set_scrollbar_width(root_element_computed_values.scrollbar_width());
}
static void propagate_overflow_to_viewport(Element& root_element, Layout::Viewport& viewport) static void propagate_overflow_to_viewport(Element& root_element, Layout::Viewport& viewport)
{ {
// https://drafts.csswg.org/css-overflow-3/#overflow-propagation // https://drafts.csswg.org/css-overflow-3/#overflow-propagation
@ -1090,6 +1099,7 @@ void Document::update_layout()
if (document_element && document_element->layout_node()) { if (document_element && document_element->layout_node()) {
propagate_overflow_to_viewport(*document_element, *m_layout_root); propagate_overflow_to_viewport(*document_element, *m_layout_root);
propagate_scrollbar_width_to_viewport(*document_element, *m_layout_root);
} }
} }