mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibWeb: Generate logical property mappings
To support this, how we declare logical property aliases has changed. Instead of `logical-alias-for` being a list of properties, it's now an object with a `group` and `mapping`. The group is the name of a logical property group in LogicalPropertyGroups.json. The mapping is which side/dimension/corner this property is. Hopefully it's self-explanatory enough. The generated code is very much a copy of what was previously in `StyleComputer::map_logical_alias_to_physical_property_id()`, so there should be no behaviour change.
This commit is contained in:
parent
4c48a51860
commit
69d4811ef7
Notes:
github-actions[bot]
2025-07-08 17:46:32 +00:00
Author: https://github.com/AtkinsSJ
Commit: 69d4811ef7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5287
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/tcl3 ✅
9 changed files with 561 additions and 646 deletions
|
@ -700,7 +700,7 @@ RefPtr<CSSStyleValue const> CSSStyleProperties::style_value_for_computed_propert
|
|||
|
||||
return style_value_for_computed_property(
|
||||
layout_node,
|
||||
StyleComputer::map_logical_alias_to_physical_property_id(property_id, StyleComputer::LogicalAliasMappingContext { computed_properties->writing_mode(), computed_properties->direction() }));
|
||||
map_logical_alias_to_physical_property(property_id, LogicalAliasMappingContext { computed_properties->writing_mode(), computed_properties->direction() }));
|
||||
}
|
||||
|
||||
// A limited number of properties have special rules for producing their "resolved value".
|
||||
|
|
56
Libraries/LibWeb/CSS/LogicalPropertyGroups.json
Normal file
56
Libraries/LibWeb/CSS/LogicalPropertyGroups.json
Normal file
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"border-color": {
|
||||
"top": "border-top-color",
|
||||
"right": "border-right-color",
|
||||
"bottom": "border-bottom-color",
|
||||
"left": "border-left-color"
|
||||
},
|
||||
"border-radius": {
|
||||
"top-left": "border-top-left-radius",
|
||||
"bottom-left": "border-bottom-left-radius",
|
||||
"top-right": "border-top-right-radius",
|
||||
"bottom-right": "border-bottom-right-radius"
|
||||
},
|
||||
"border-style": {
|
||||
"top": "border-top-style",
|
||||
"right": "border-right-style",
|
||||
"bottom": "border-bottom-style",
|
||||
"left": "border-left-style"
|
||||
},
|
||||
"border-width": {
|
||||
"top": "border-top-width",
|
||||
"right": "border-right-width",
|
||||
"bottom": "border-bottom-width",
|
||||
"left": "border-left-width"
|
||||
},
|
||||
"inset": {
|
||||
"top": "top",
|
||||
"right": "right",
|
||||
"bottom": "bottom",
|
||||
"left": "left"
|
||||
},
|
||||
"margin": {
|
||||
"top": "margin-top",
|
||||
"right": "margin-right",
|
||||
"bottom": "margin-bottom",
|
||||
"left": "margin-left"
|
||||
},
|
||||
"max-size": {
|
||||
"width": "max-width",
|
||||
"height": "max-height"
|
||||
},
|
||||
"min-size": {
|
||||
"width": "min-width",
|
||||
"height": "min-height"
|
||||
},
|
||||
"padding": {
|
||||
"top": "padding-top",
|
||||
"right": "padding-right",
|
||||
"bottom": "padding-bottom",
|
||||
"left": "padding-left"
|
||||
},
|
||||
"size": {
|
||||
"width": "width",
|
||||
"height": "height"
|
||||
}
|
||||
}
|
|
@ -481,10 +481,10 @@
|
|||
"percentages-resolve-to": "length"
|
||||
},
|
||||
"block-size": {
|
||||
"logical-alias-for": [
|
||||
"height",
|
||||
"width"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "size",
|
||||
"mapping": "block-size"
|
||||
},
|
||||
"initial": "auto",
|
||||
"max-values": 1
|
||||
},
|
||||
|
@ -515,30 +515,24 @@
|
|||
]
|
||||
},
|
||||
"border-block-end-color": {
|
||||
"logical-alias-for": [
|
||||
"border-top-color",
|
||||
"border-right-color",
|
||||
"border-bottom-color",
|
||||
"border-left-color"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-color",
|
||||
"mapping": "block-end"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-block-end-style": {
|
||||
"logical-alias-for": [
|
||||
"border-top-style",
|
||||
"border-right-style",
|
||||
"border-bottom-style",
|
||||
"border-left-style"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-style",
|
||||
"mapping": "block-end"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-block-end-width": {
|
||||
"logical-alias-for": [
|
||||
"border-top-width",
|
||||
"border-right-width",
|
||||
"border-bottom-width",
|
||||
"border-left-width"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-width",
|
||||
"mapping": "block-end"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-block-start": {
|
||||
|
@ -551,30 +545,24 @@
|
|||
]
|
||||
},
|
||||
"border-block-start-color": {
|
||||
"logical-alias-for": [
|
||||
"border-top-color",
|
||||
"border-right-color",
|
||||
"border-bottom-color",
|
||||
"border-left-color"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-color",
|
||||
"mapping": "block-start"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-block-start-style": {
|
||||
"logical-alias-for": [
|
||||
"border-top-style",
|
||||
"border-right-style",
|
||||
"border-bottom-style",
|
||||
"border-left-style"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-style",
|
||||
"mapping": "block-start"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-block-start-width": {
|
||||
"logical-alias-for": [
|
||||
"border-top-width",
|
||||
"border-right-width",
|
||||
"border-bottom-width",
|
||||
"border-left-width"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-width",
|
||||
"mapping": "block-start"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-block-style": {
|
||||
|
@ -688,21 +676,17 @@
|
|||
]
|
||||
},
|
||||
"border-end-end-radius": {
|
||||
"logical-alias-for": [
|
||||
"border-top-left-radius",
|
||||
"border-bottom-left-radius",
|
||||
"border-top-right-radius",
|
||||
"border-bottom-right-radius"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-radius",
|
||||
"mapping": "end-end"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-end-start-radius": {
|
||||
"logical-alias-for": [
|
||||
"border-top-left-radius",
|
||||
"border-bottom-left-radius",
|
||||
"border-top-right-radius",
|
||||
"border-bottom-right-radius"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-radius",
|
||||
"mapping": "end-start"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-image": {
|
||||
|
@ -795,30 +779,24 @@
|
|||
]
|
||||
},
|
||||
"border-inline-end-color": {
|
||||
"logical-alias-for": [
|
||||
"border-top-color",
|
||||
"border-right-color",
|
||||
"border-bottom-color",
|
||||
"border-left-color"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-color",
|
||||
"mapping": "inline-end"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-inline-end-style": {
|
||||
"logical-alias-for": [
|
||||
"border-top-style",
|
||||
"border-right-style",
|
||||
"border-bottom-style",
|
||||
"border-left-style"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-style",
|
||||
"mapping": "inline-end"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-inline-end-width": {
|
||||
"logical-alias-for": [
|
||||
"border-top-width",
|
||||
"border-right-width",
|
||||
"border-bottom-width",
|
||||
"border-left-width"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-width",
|
||||
"mapping": "inline-end"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-inline-start": {
|
||||
|
@ -831,30 +809,24 @@
|
|||
]
|
||||
},
|
||||
"border-inline-start-color": {
|
||||
"logical-alias-for": [
|
||||
"border-top-color",
|
||||
"border-right-color",
|
||||
"border-bottom-color",
|
||||
"border-left-color"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-color",
|
||||
"mapping": "inline-start"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-inline-start-style": {
|
||||
"logical-alias-for": [
|
||||
"border-top-style",
|
||||
"border-right-style",
|
||||
"border-bottom-style",
|
||||
"border-left-style"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-style",
|
||||
"mapping": "inline-start"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-inline-start-width": {
|
||||
"logical-alias-for": [
|
||||
"border-top-width",
|
||||
"border-right-width",
|
||||
"border-bottom-width",
|
||||
"border-left-width"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-width",
|
||||
"mapping": "inline-start"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-inline-style": {
|
||||
|
@ -992,21 +964,17 @@
|
|||
]
|
||||
},
|
||||
"border-start-end-radius": {
|
||||
"logical-alias-for": [
|
||||
"border-top-left-radius",
|
||||
"border-bottom-left-radius",
|
||||
"border-top-right-radius",
|
||||
"border-bottom-right-radius"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-radius",
|
||||
"mapping": "start-end"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-start-start-radius": {
|
||||
"logical-alias-for": [
|
||||
"border-top-left-radius",
|
||||
"border-bottom-left-radius",
|
||||
"border-top-right-radius",
|
||||
"border-bottom-right-radius"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "border-radius",
|
||||
"mapping": "start-start"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"border-style": {
|
||||
|
@ -1997,10 +1965,10 @@
|
|||
]
|
||||
},
|
||||
"inline-size": {
|
||||
"logical-alias-for": [
|
||||
"width",
|
||||
"height"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "size",
|
||||
"mapping": "inline-size"
|
||||
},
|
||||
"initial": "auto",
|
||||
"max-values": 1
|
||||
},
|
||||
|
@ -2040,21 +2008,17 @@
|
|||
"percentages-resolve-to": "length"
|
||||
},
|
||||
"inset-block-end": {
|
||||
"logical-alias-for": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "inset",
|
||||
"mapping": "block-end"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"inset-block-start": {
|
||||
"logical-alias-for": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "inset",
|
||||
"mapping": "block-start"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"inset-inline": {
|
||||
|
@ -2074,21 +2038,17 @@
|
|||
"percentages-resolve-to": "length"
|
||||
},
|
||||
"inset-inline-end": {
|
||||
"logical-alias-for": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "inset",
|
||||
"mapping": "inline-end"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"inset-inline-start": {
|
||||
"logical-alias-for": [
|
||||
"top",
|
||||
"right",
|
||||
"bottom",
|
||||
"left"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "inset",
|
||||
"mapping": "inline-start"
|
||||
},
|
||||
"max-values": 1
|
||||
},
|
||||
"isolation": {
|
||||
|
@ -2245,20 +2205,16 @@
|
|||
"percentages-resolve-to": "length"
|
||||
},
|
||||
"margin-block-end": {
|
||||
"logical-alias-for": [
|
||||
"margin-top",
|
||||
"margin-right",
|
||||
"margin-bottom",
|
||||
"margin-left"
|
||||
]
|
||||
"logical-alias-for": {
|
||||
"group": "margin",
|
||||
"mapping": "block-end"
|
||||
}
|
||||
},
|
||||
"margin-block-start": {
|
||||
"logical-alias-for": [
|
||||
"margin-top",
|
||||
"margin-right",
|
||||
"margin-bottom",
|
||||
"margin-left"
|
||||
]
|
||||
"logical-alias-for": {
|
||||
"group": "margin",
|
||||
"mapping": "block-start"
|
||||
}
|
||||
},
|
||||
"margin-bottom": {
|
||||
"animation-type": "by-computed-value",
|
||||
|
@ -2293,20 +2249,16 @@
|
|||
"percentages-resolve-to": "length"
|
||||
},
|
||||
"margin-inline-end": {
|
||||
"logical-alias-for": [
|
||||
"margin-top",
|
||||
"margin-right",
|
||||
"margin-bottom",
|
||||
"margin-left"
|
||||
]
|
||||
"logical-alias-for": {
|
||||
"group": "margin",
|
||||
"mapping": "inline-end"
|
||||
}
|
||||
},
|
||||
"margin-inline-start": {
|
||||
"logical-alias-for": [
|
||||
"margin-top",
|
||||
"margin-right",
|
||||
"margin-bottom",
|
||||
"margin-left"
|
||||
]
|
||||
"logical-alias-for": {
|
||||
"group": "margin",
|
||||
"mapping": "inline-start"
|
||||
}
|
||||
},
|
||||
"margin-left": {
|
||||
"animation-type": "by-computed-value",
|
||||
|
@ -2416,10 +2368,10 @@
|
|||
]
|
||||
},
|
||||
"max-block-size": {
|
||||
"logical-alias-for": [
|
||||
"max-height",
|
||||
"max-width"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "max-size",
|
||||
"mapping": "block-size"
|
||||
},
|
||||
"initial": "none"
|
||||
},
|
||||
"max-height": {
|
||||
|
@ -2442,10 +2394,10 @@
|
|||
]
|
||||
},
|
||||
"max-inline-size": {
|
||||
"logical-alias-for": [
|
||||
"max-width",
|
||||
"max-height"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "max-size",
|
||||
"mapping": "inline-size"
|
||||
},
|
||||
"initial": "none"
|
||||
},
|
||||
"max-width": {
|
||||
|
@ -2468,10 +2420,10 @@
|
|||
]
|
||||
},
|
||||
"min-block-size": {
|
||||
"logical-alias-for": [
|
||||
"min-height",
|
||||
"min-width"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "min-size",
|
||||
"mapping": "block-size"
|
||||
},
|
||||
"initial": "0"
|
||||
},
|
||||
"min-height": {
|
||||
|
@ -2494,10 +2446,10 @@
|
|||
]
|
||||
},
|
||||
"min-inline-size": {
|
||||
"logical-alias-for": [
|
||||
"min-width",
|
||||
"min-height"
|
||||
],
|
||||
"logical-alias-for": {
|
||||
"group": "min-size",
|
||||
"mapping": "inline-size"
|
||||
},
|
||||
"initial": "0"
|
||||
},
|
||||
"min-width": {
|
||||
|
@ -2678,20 +2630,16 @@
|
|||
"percentages-resolve-to": "length"
|
||||
},
|
||||
"padding-block-end": {
|
||||
"logical-alias-for": [
|
||||
"padding-top",
|
||||
"padding-right",
|
||||
"padding-bottom",
|
||||
"padding-left"
|
||||
]
|
||||
"logical-alias-for": {
|
||||
"group": "padding",
|
||||
"mapping": "block-end"
|
||||
}
|
||||
},
|
||||
"padding-block-start": {
|
||||
"logical-alias-for": [
|
||||
"padding-top",
|
||||
"padding-right",
|
||||
"padding-bottom",
|
||||
"padding-left"
|
||||
]
|
||||
"logical-alias-for": {
|
||||
"group": "padding",
|
||||
"mapping": "block-start"
|
||||
}
|
||||
},
|
||||
"padding-bottom": {
|
||||
"animation-type": "by-computed-value",
|
||||
|
@ -2720,20 +2668,16 @@
|
|||
"percentages-resolve-to": "length"
|
||||
},
|
||||
"padding-inline-end": {
|
||||
"logical-alias-for": [
|
||||
"padding-top",
|
||||
"padding-right",
|
||||
"padding-bottom",
|
||||
"padding-left"
|
||||
]
|
||||
"logical-alias-for": {
|
||||
"group": "padding",
|
||||
"mapping": "inline-end"
|
||||
}
|
||||
},
|
||||
"padding-inline-start": {
|
||||
"logical-alias-for": [
|
||||
"padding-top",
|
||||
"padding-right",
|
||||
"padding-bottom",
|
||||
"padding-left"
|
||||
]
|
||||
"logical-alias-for": {
|
||||
"group": "padding",
|
||||
"mapping": "inline-start"
|
||||
}
|
||||
},
|
||||
"padding-left": {
|
||||
"animation-type": "by-computed-value",
|
||||
|
|
|
@ -888,395 +888,6 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i
|
|||
set_longhand_property(property_id, value);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-writing-modes-4/#logical-to-physical
|
||||
PropertyID StyleComputer::map_logical_alias_to_physical_property_id(PropertyID property_id, LogicalAliasMappingContext mapping_context)
|
||||
{
|
||||
// FIXME: Note: The used direction depends on the computed writing-mode and text-orientation: in vertical writing
|
||||
// modes, a text-orientation value of upright forces the used direction to ltr.
|
||||
auto used_direction = mapping_context.direction;
|
||||
switch (property_id) {
|
||||
case PropertyID::BlockSize:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::Height;
|
||||
return PropertyID::Width;
|
||||
case PropertyID::BorderBlockEndColor:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::BorderBottomColor;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::BorderLeftColor;
|
||||
return PropertyID::BorderRightColor;
|
||||
case PropertyID::BorderBlockEndStyle:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::BorderBottomStyle;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::BorderLeftStyle;
|
||||
return PropertyID::BorderRightStyle;
|
||||
case PropertyID::BorderBlockEndWidth:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::BorderBottomWidth;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::BorderLeftWidth;
|
||||
return PropertyID::BorderRightWidth;
|
||||
case PropertyID::BorderBlockStartColor:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::BorderTopColor;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::BorderRightColor;
|
||||
return PropertyID::BorderLeftColor;
|
||||
case PropertyID::BorderBlockStartStyle:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::BorderTopStyle;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::BorderRightStyle;
|
||||
return PropertyID::BorderLeftStyle;
|
||||
case PropertyID::BorderBlockStartWidth:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::BorderTopWidth;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::BorderRightWidth;
|
||||
return PropertyID::BorderLeftWidth;
|
||||
case PropertyID::BorderEndEndRadius:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomRightRadius;
|
||||
return PropertyID::BorderBottomLeftRadius;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomLeftRadius;
|
||||
return PropertyID::BorderTopLeftRadius;
|
||||
}
|
||||
|
||||
if (mapping_context.writing_mode == WritingMode::VerticalLr) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomRightRadius;
|
||||
return PropertyID::BorderTopRightRadius;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopRightRadius;
|
||||
return PropertyID::BorderBottomRightRadius;
|
||||
case PropertyID::BorderEndStartRadius:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomLeftRadius;
|
||||
return PropertyID::BorderBottomRightRadius;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopLeftRadius;
|
||||
return PropertyID::BorderBottomLeftRadius;
|
||||
}
|
||||
|
||||
if (mapping_context.writing_mode == WritingMode::VerticalLr) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopRightRadius;
|
||||
return PropertyID::BorderBottomRightRadius;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomRightRadius;
|
||||
return PropertyID::BorderTopRightRadius;
|
||||
case PropertyID::BorderInlineStartColor:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderLeftColor;
|
||||
return PropertyID::BorderRightColor;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopColor;
|
||||
return PropertyID::BorderBottomColor;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomColor;
|
||||
return PropertyID::BorderTopColor;
|
||||
case PropertyID::BorderInlineStartStyle:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderLeftStyle;
|
||||
return PropertyID::BorderRightStyle;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopStyle;
|
||||
return PropertyID::BorderBottomStyle;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomStyle;
|
||||
return PropertyID::BorderTopStyle;
|
||||
|
||||
case PropertyID::BorderInlineStartWidth:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderLeftWidth;
|
||||
return PropertyID::BorderRightWidth;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopWidth;
|
||||
return PropertyID::BorderBottomWidth;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomWidth;
|
||||
return PropertyID::BorderTopWidth;
|
||||
case PropertyID::BorderInlineEndColor:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderRightColor;
|
||||
return PropertyID::BorderLeftColor;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomColor;
|
||||
return PropertyID::BorderTopColor;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopColor;
|
||||
return PropertyID::BorderBottomColor;
|
||||
case PropertyID::BorderInlineEndStyle:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderRightStyle;
|
||||
return PropertyID::BorderLeftStyle;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomStyle;
|
||||
return PropertyID::BorderTopStyle;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopStyle;
|
||||
return PropertyID::BorderBottomStyle;
|
||||
case PropertyID::BorderInlineEndWidth:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderRightWidth;
|
||||
return PropertyID::BorderLeftWidth;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomWidth;
|
||||
return PropertyID::BorderTopWidth;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopWidth;
|
||||
return PropertyID::BorderBottomWidth;
|
||||
case PropertyID::BorderStartEndRadius:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopRightRadius;
|
||||
return PropertyID::BorderTopLeftRadius;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomRightRadius;
|
||||
return PropertyID::BorderTopRightRadius;
|
||||
}
|
||||
|
||||
if (mapping_context.writing_mode == WritingMode::VerticalLr) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomLeftRadius;
|
||||
return PropertyID::BorderTopLeftRadius;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopLeftRadius;
|
||||
return PropertyID::BorderBottomLeftRadius;
|
||||
case PropertyID::BorderStartStartRadius:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopLeftRadius;
|
||||
return PropertyID::BorderTopRightRadius;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopRightRadius;
|
||||
return PropertyID::BorderBottomRightRadius;
|
||||
}
|
||||
|
||||
if (mapping_context.writing_mode == WritingMode::VerticalLr) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderTopLeftRadius;
|
||||
return PropertyID::BorderBottomLeftRadius;
|
||||
}
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::BorderBottomLeftRadius;
|
||||
return PropertyID::BorderTopLeftRadius;
|
||||
case PropertyID::MarginBlockStart:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::MarginTop;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::MarginRight;
|
||||
return PropertyID::MarginLeft;
|
||||
case PropertyID::MarginBlockEnd:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::MarginBottom;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::MarginLeft;
|
||||
return PropertyID::MarginRight;
|
||||
case PropertyID::MarginInlineStart:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::MarginLeft;
|
||||
return PropertyID::MarginRight;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::MarginTop;
|
||||
return PropertyID::MarginBottom;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::MarginBottom;
|
||||
return PropertyID::MarginTop;
|
||||
case PropertyID::MarginInlineEnd:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::MarginRight;
|
||||
return PropertyID::MarginLeft;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::MarginBottom;
|
||||
return PropertyID::MarginTop;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::MarginTop;
|
||||
return PropertyID::MarginBottom;
|
||||
case PropertyID::MaxBlockSize:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::MaxHeight;
|
||||
return PropertyID::MaxWidth;
|
||||
case PropertyID::MaxInlineSize:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::MaxWidth;
|
||||
return PropertyID::MaxHeight;
|
||||
case PropertyID::MinBlockSize:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::MinHeight;
|
||||
return PropertyID::MinWidth;
|
||||
case PropertyID::MinInlineSize:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::MinWidth;
|
||||
return PropertyID::MinHeight;
|
||||
case PropertyID::PaddingBlockStart:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::PaddingTop;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::PaddingRight;
|
||||
return PropertyID::PaddingLeft;
|
||||
case PropertyID::PaddingBlockEnd:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::PaddingBottom;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::PaddingLeft;
|
||||
return PropertyID::PaddingRight;
|
||||
case PropertyID::PaddingInlineStart:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::PaddingLeft;
|
||||
return PropertyID::PaddingRight;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::PaddingTop;
|
||||
return PropertyID::PaddingBottom;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::PaddingBottom;
|
||||
return PropertyID::PaddingTop;
|
||||
case PropertyID::PaddingInlineEnd:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::PaddingRight;
|
||||
return PropertyID::PaddingLeft;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::PaddingBottom;
|
||||
return PropertyID::PaddingTop;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::PaddingTop;
|
||||
return PropertyID::PaddingBottom;
|
||||
case PropertyID::InlineSize:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::Width;
|
||||
return PropertyID::Height;
|
||||
case PropertyID::InsetBlockStart:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::Top;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::Right;
|
||||
return PropertyID::Left;
|
||||
case PropertyID::InsetBlockEnd:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb)
|
||||
return PropertyID::Bottom;
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl))
|
||||
return PropertyID::Left;
|
||||
return PropertyID::Right;
|
||||
case PropertyID::InsetInlineStart:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::Left;
|
||||
return PropertyID::Right;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::Top;
|
||||
return PropertyID::Bottom;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::Bottom;
|
||||
return PropertyID::Top;
|
||||
case PropertyID::InsetInlineEnd:
|
||||
if (mapping_context.writing_mode == WritingMode::HorizontalTb) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::Right;
|
||||
return PropertyID::Left;
|
||||
}
|
||||
|
||||
if (first_is_one_of(mapping_context.writing_mode, WritingMode::VerticalRl, WritingMode::SidewaysRl, WritingMode::VerticalLr)) {
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::Bottom;
|
||||
return PropertyID::Top;
|
||||
}
|
||||
|
||||
if (used_direction == Direction::Ltr)
|
||||
return PropertyID::Top;
|
||||
return PropertyID::Bottom;
|
||||
default:
|
||||
VERIFY(!property_is_logical_alias(property_id));
|
||||
return property_id;
|
||||
}
|
||||
}
|
||||
|
||||
void StyleComputer::cascade_declarations(
|
||||
CascadedProperties& cascaded_properties,
|
||||
DOM::Element& element,
|
||||
|
@ -1334,7 +945,7 @@ void StyleComputer::cascade_declarations(
|
|||
if (property_is_logical_alias(longhand_id)) {
|
||||
if (!logical_alias_mapping_context.has_value())
|
||||
return;
|
||||
physical_property_id = map_logical_alias_to_physical_property_id(longhand_id, logical_alias_mapping_context.value());
|
||||
physical_property_id = map_logical_alias_to_physical_property(longhand_id, logical_alias_mapping_context.value());
|
||||
} else {
|
||||
physical_property_id = longhand_id;
|
||||
}
|
||||
|
@ -1523,7 +1134,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
|
|||
style_value = Parser::Parser::resolve_unresolved_style_value(Parser::ParsingParams { element.document() }, element, pseudo_element, property_id, style_value->as_unresolved());
|
||||
|
||||
for_each_property_expanding_shorthands(property_id, *style_value, [&](PropertyID longhand_id, CSSStyleValue const& longhand_value) {
|
||||
auto physical_longhand_id = map_logical_alias_to_physical_property_id(longhand_id, LogicalAliasMappingContext { computed_properties.writing_mode(), computed_properties.direction() });
|
||||
auto physical_longhand_id = map_logical_alias_to_physical_property(longhand_id, LogicalAliasMappingContext { computed_properties.writing_mode(), computed_properties.direction() });
|
||||
auto physical_longhand_id_bitmap_index = to_underlying(physical_longhand_id) - to_underlying(first_longhand_property_id);
|
||||
|
||||
// Don't overwrite values if this is the result of a UseInitial
|
||||
|
@ -2532,7 +2143,7 @@ void StyleComputer::compute_font(ComputedProperties& style, DOM::Element const*
|
|||
}
|
||||
}
|
||||
|
||||
StyleComputer::LogicalAliasMappingContext StyleComputer::compute_logical_alias_mapping_context(DOM::Element& element, Optional<CSS::PseudoElement> pseudo_element, ComputeStyleMode mode) const
|
||||
LogicalAliasMappingContext StyleComputer::compute_logical_alias_mapping_context(DOM::Element& element, Optional<PseudoElement> pseudo_element, ComputeStyleMode mode) const
|
||||
{
|
||||
auto normalize_value = [&](auto property_id, auto value) {
|
||||
if (!value || value->is_inherit() || value->is_unset()) {
|
||||
|
|
|
@ -131,13 +131,6 @@ public:
|
|||
static void for_each_property_expanding_shorthands(PropertyID, CSSStyleValue const&, Function<void(PropertyID, CSSStyleValue const&)> const& set_longhand_property);
|
||||
static NonnullRefPtr<CSSStyleValue const> get_inherit_value(CSS::PropertyID, DOM::Element const*, Optional<CSS::PseudoElement> = {});
|
||||
|
||||
struct LogicalAliasMappingContext {
|
||||
CSS::WritingMode writing_mode;
|
||||
CSS::Direction direction;
|
||||
// TODO: text-orientation
|
||||
};
|
||||
static PropertyID map_logical_alias_to_physical_property_id(PropertyID, LogicalAliasMappingContext);
|
||||
|
||||
static Optional<String> user_agent_style_sheet_source(StringView name);
|
||||
|
||||
explicit StyleComputer(DOM::Document&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue