mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:38:11 +00:00
LibWeb: Convert width/height and min-/max- versions to LengthPercentage
A lot of this is quite ugly, but it should only be so until I remove Length::Type::Percentage entirely. (Which should happen later in this PR, otherwise, yell at me!) For now, a lot of things have to be resolved twice, first from a LengthPercentage to a Length, and then from a Length to a pixel one.
This commit is contained in:
parent
cb0cce5cdc
commit
dc681913e8
12 changed files with 276 additions and 194 deletions
|
@ -505,59 +505,59 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
|
|||
return BoxShadowStyleValue::create(box_shadow_data.offset_x, box_shadow_data.offset_y, box_shadow_data.blur_radius, box_shadow_data.color);
|
||||
}
|
||||
case CSS::PropertyID::Width:
|
||||
return LengthStyleValue::create(layout_node.computed_values().width());
|
||||
return style_value_for_length_percentage(layout_node.computed_values().width());
|
||||
case CSS::PropertyID::MinWidth:
|
||||
if (layout_node.computed_values().min_width().is_undefined_or_auto())
|
||||
if (layout_node.computed_values().min_width().is_length() && layout_node.computed_values().min_width().length().is_undefined_or_auto())
|
||||
return IdentifierStyleValue::create(CSS::ValueID::Auto);
|
||||
return LengthStyleValue::create(layout_node.computed_values().min_width());
|
||||
return style_value_for_length_percentage(layout_node.computed_values().min_width());
|
||||
case CSS::PropertyID::MaxWidth:
|
||||
if (layout_node.computed_values().max_width().is_undefined())
|
||||
if (layout_node.computed_values().max_width().is_length() && layout_node.computed_values().max_width().length().is_undefined())
|
||||
return IdentifierStyleValue::create(CSS::ValueID::None);
|
||||
return LengthStyleValue::create(layout_node.computed_values().max_width());
|
||||
return style_value_for_length_percentage(layout_node.computed_values().max_width());
|
||||
case CSS::PropertyID::Height:
|
||||
return LengthStyleValue::create(layout_node.computed_values().height());
|
||||
return style_value_for_length_percentage(layout_node.computed_values().height());
|
||||
case CSS::PropertyID::MinHeight:
|
||||
if (layout_node.computed_values().min_height().is_undefined_or_auto())
|
||||
if (layout_node.computed_values().min_height().is_length() && layout_node.computed_values().min_height().length().is_undefined_or_auto())
|
||||
return IdentifierStyleValue::create(CSS::ValueID::Auto);
|
||||
return LengthStyleValue::create(layout_node.computed_values().min_height());
|
||||
return style_value_for_length_percentage(layout_node.computed_values().min_height());
|
||||
case CSS::PropertyID::MaxHeight:
|
||||
if (layout_node.computed_values().max_height().is_undefined())
|
||||
if (layout_node.computed_values().max_height().is_length() && layout_node.computed_values().max_height().length().is_undefined())
|
||||
return IdentifierStyleValue::create(CSS::ValueID::None);
|
||||
return LengthStyleValue::create(layout_node.computed_values().max_height());
|
||||
return style_value_for_length_percentage(layout_node.computed_values().max_height());
|
||||
case CSS::PropertyID::Margin: {
|
||||
auto margin = layout_node.computed_values().margin();
|
||||
auto values = NonnullRefPtrVector<StyleValue> {};
|
||||
values.append(LengthStyleValue::create(margin.top));
|
||||
values.append(LengthStyleValue::create(margin.right));
|
||||
values.append(LengthStyleValue::create(margin.bottom));
|
||||
values.append(LengthStyleValue::create(margin.left));
|
||||
values.append(style_value_for_length_percentage(margin.top));
|
||||
values.append(style_value_for_length_percentage(margin.right));
|
||||
values.append(style_value_for_length_percentage(margin.bottom));
|
||||
values.append(style_value_for_length_percentage(margin.left));
|
||||
return StyleValueList::create(move(values));
|
||||
}
|
||||
case CSS::PropertyID::MarginTop:
|
||||
return LengthStyleValue::create(layout_node.computed_values().margin().top);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().margin().top);
|
||||
case CSS::PropertyID::MarginRight:
|
||||
return LengthStyleValue::create(layout_node.computed_values().margin().right);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().margin().right);
|
||||
case CSS::PropertyID::MarginBottom:
|
||||
return LengthStyleValue::create(layout_node.computed_values().margin().bottom);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().margin().bottom);
|
||||
case CSS::PropertyID::MarginLeft:
|
||||
return LengthStyleValue::create(layout_node.computed_values().margin().left);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().margin().left);
|
||||
case CSS::PropertyID::Padding: {
|
||||
auto padding = layout_node.computed_values().padding();
|
||||
auto values = NonnullRefPtrVector<StyleValue> {};
|
||||
values.append(LengthStyleValue::create(padding.top));
|
||||
values.append(LengthStyleValue::create(padding.right));
|
||||
values.append(LengthStyleValue::create(padding.bottom));
|
||||
values.append(LengthStyleValue::create(padding.left));
|
||||
values.append(style_value_for_length_percentage(padding.top));
|
||||
values.append(style_value_for_length_percentage(padding.right));
|
||||
values.append(style_value_for_length_percentage(padding.bottom));
|
||||
values.append(style_value_for_length_percentage(padding.left));
|
||||
return StyleValueList::create(move(values));
|
||||
}
|
||||
case CSS::PropertyID::PaddingTop:
|
||||
return LengthStyleValue::create(layout_node.computed_values().padding().top);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().padding().top);
|
||||
case CSS::PropertyID::PaddingRight:
|
||||
return LengthStyleValue::create(layout_node.computed_values().padding().right);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().padding().right);
|
||||
case CSS::PropertyID::PaddingBottom:
|
||||
return LengthStyleValue::create(layout_node.computed_values().padding().bottom);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().padding().bottom);
|
||||
case CSS::PropertyID::PaddingLeft:
|
||||
return LengthStyleValue::create(layout_node.computed_values().padding().left);
|
||||
return style_value_for_length_percentage(layout_node.computed_values().padding().left);
|
||||
case CSS::PropertyID::BorderRadius: {
|
||||
auto maybe_top_left_radius = property(CSS::PropertyID::BorderTopLeftRadius);
|
||||
auto maybe_top_right_radius = property(CSS::PropertyID::BorderTopRightRadius);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue