Skip to content

Commit a521c02

Browse files
AtkinsSJawesomekling
authored andcommitted
LibWeb: Add resolved style lookup for margin/padding shorthands
1 parent fc7af21 commit a521c02

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,15 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
480480
if (layout_node.computed_values().max_height().is_undefined())
481481
return IdentifierStyleValue::create(CSS::ValueID::None);
482482
return LengthStyleValue::create(layout_node.computed_values().max_height());
483+
case CSS::PropertyID::Margin: {
484+
auto margin = layout_node.computed_values().margin();
485+
auto values = NonnullRefPtrVector<StyleValue> {};
486+
values.append(LengthStyleValue::create(margin.top));
487+
values.append(LengthStyleValue::create(margin.right));
488+
values.append(LengthStyleValue::create(margin.bottom));
489+
values.append(LengthStyleValue::create(margin.left));
490+
return StyleValueList::create(move(values));
491+
}
483492
case CSS::PropertyID::MarginTop:
484493
return LengthStyleValue::create(layout_node.computed_values().margin().top);
485494
case CSS::PropertyID::MarginRight:
@@ -488,6 +497,15 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
488497
return LengthStyleValue::create(layout_node.computed_values().margin().bottom);
489498
case CSS::PropertyID::MarginLeft:
490499
return LengthStyleValue::create(layout_node.computed_values().margin().left);
500+
case CSS::PropertyID::Padding: {
501+
auto padding = layout_node.computed_values().padding();
502+
auto values = NonnullRefPtrVector<StyleValue> {};
503+
values.append(LengthStyleValue::create(padding.top));
504+
values.append(LengthStyleValue::create(padding.right));
505+
values.append(LengthStyleValue::create(padding.bottom));
506+
values.append(LengthStyleValue::create(padding.left));
507+
return StyleValueList::create(move(values));
508+
}
491509
case CSS::PropertyID::PaddingTop:
492510
return LengthStyleValue::create(layout_node.computed_values().padding().top);
493511
case CSS::PropertyID::PaddingRight:

0 commit comments

Comments
 (0)