mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
LibWeb: Move width into LayoutStyle
This patch also adds the ability for Length to contain percentage values. This is a little off-spec, but will make storing and dealing with lengths a lot easier. To resolve a Length to a px-or-auto Length, there are now helpers for that. After calling them, you no longer have to think about em, rem, %, and such things.
This commit is contained in:
parent
959464fce4
commit
ecacab8618
6 changed files with 53 additions and 29 deletions
|
@ -45,13 +45,13 @@ float LayoutReplaced::calculate_width() const
|
|||
{
|
||||
// 10.3.2 [Inline,] replaced elements
|
||||
|
||||
auto& style = this->specified_style();
|
||||
auto& specified_style = this->specified_style();
|
||||
auto auto_value = Length::make_auto();
|
||||
auto zero_value = Length::make_px(0);
|
||||
auto& containing_block = *this->containing_block();
|
||||
|
||||
auto margin_left = style.length_or_fallback(CSS::PropertyID::MarginLeft, zero_value, containing_block.width());
|
||||
auto margin_right = style.length_or_fallback(CSS::PropertyID::MarginRight, zero_value, containing_block.width());
|
||||
auto margin_left = specified_style.length_or_fallback(CSS::PropertyID::MarginLeft, zero_value, containing_block.width());
|
||||
auto margin_right = specified_style.length_or_fallback(CSS::PropertyID::MarginRight, zero_value, containing_block.width());
|
||||
|
||||
// A computed value of 'auto' for 'margin-left' or 'margin-right' becomes a used value of '0'.
|
||||
if (margin_left.is_auto())
|
||||
|
@ -59,8 +59,8 @@ float LayoutReplaced::calculate_width() const
|
|||
if (margin_right.is_auto())
|
||||
margin_right = zero_value;
|
||||
|
||||
auto specified_width = style.length_or_fallback(CSS::PropertyID::Width, auto_value, containing_block.width());
|
||||
auto specified_height = style.length_or_fallback(CSS::PropertyID::Height, auto_value, containing_block.height());
|
||||
auto specified_width = style().width().resolved_or_auto(*this, containing_block.width());
|
||||
auto specified_height = specified_style.length_or_fallback(CSS::PropertyID::Height, auto_value, containing_block.height());
|
||||
|
||||
// FIXME: Actually compute 'width'
|
||||
auto computed_width = specified_width;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue