mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
LibWeb: Assign correct viewport dimensions when making style for ICB
The ICB (initial containing block) gets its style from StyleComputer's create_document_style(). It's basically a generic style for the root of the layout tree. With this patch, we now assign the width and height of the viewport rect as two CSS "px" lengths to the "width" and "height" properties of the ICB style. (Previously they were just defaulting to "auto" and we assigned override dimensions during layout.) This fixes an issue where position:absolute elements with relative width and/or height were not dimensioned correctly, since the values were relative to the width and/or height of the ICB style.
This commit is contained in:
parent
c9c55d86a4
commit
9c05639d35
1 changed files with 5 additions and 0 deletions
|
@ -937,6 +937,11 @@ NonnullRefPtr<StyleProperties> StyleComputer::create_document_style() const
|
|||
compute_font(style, nullptr);
|
||||
compute_defaulted_values(style, nullptr);
|
||||
absolutize_values(style, nullptr);
|
||||
if (auto* browsing_context = m_document.browsing_context()) {
|
||||
auto viewport_rect = browsing_context->viewport_rect();
|
||||
style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect.width())));
|
||||
style->set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect.height())));
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue