mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 03:37:35 +00:00
LibWeb: Add CSS logical property aliases for margin and padding sides
These just map to the LTR+TB defaults for now, as we don't yet resolve any of the inputs to the logical property selection algorithm.
This commit is contained in:
parent
941092e3ad
commit
abd6380cce
4 changed files with 131 additions and 0 deletions
|
@ -283,6 +283,34 @@ static bool contains(Edge a, Edge b)
|
|||
|
||||
static void set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, StyleValue const& value, DOM::Document& document, CSS::CSSStyleDeclaration const* declaration)
|
||||
{
|
||||
auto map_logical_property_to_real_property = [](PropertyID property_id) -> Optional<PropertyID> {
|
||||
// FIXME: Honor writing-mode, direction and text-orientation.
|
||||
switch (property_id) {
|
||||
case PropertyID::MarginBlockStart:
|
||||
return PropertyID::MarginTop;
|
||||
case PropertyID::MarginBlockEnd:
|
||||
return PropertyID::MarginBottom;
|
||||
case PropertyID::MarginInlineStart:
|
||||
return PropertyID::MarginLeft;
|
||||
case PropertyID::MarginInlineEnd:
|
||||
return PropertyID::MarginRight;
|
||||
case PropertyID::PaddingBlockStart:
|
||||
return PropertyID::PaddingTop;
|
||||
case PropertyID::PaddingBlockEnd:
|
||||
return PropertyID::PaddingBottom;
|
||||
case PropertyID::PaddingInlineStart:
|
||||
return PropertyID::PaddingLeft;
|
||||
case PropertyID::PaddingInlineEnd:
|
||||
return PropertyID::PaddingRight;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
auto real_property_id = map_logical_property_to_real_property(property_id);
|
||||
if (real_property_id.has_value())
|
||||
return set_property_expanding_shorthands(style, real_property_id.value(), value, document, declaration);
|
||||
|
||||
if (value.is_composite()) {
|
||||
auto& composite_value = value.as_composite();
|
||||
auto& properties = composite_value.sub_properties();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue