1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:37:36 +00:00

LibWeb: Parse the math-shift and math-style CSS properties

Currently these have no effect, but they're simple, and `math-style`
influences `math-depth` which is coming next.
This commit is contained in:
Sam Atkins 2023-09-05 20:23:15 +01:00 committed by Sam Atkins
parent 2ef5658f31
commit 6045143d39
5 changed files with 43 additions and 0 deletions

View file

@ -120,6 +120,9 @@ public:
static CSS::OutlineStyle outline_style() { return CSS::OutlineStyle::None; }
static CSS::Length outline_width() { return CSS::Length::make_px(3); }
static CSS::TableLayout table_layout() { return CSS::TableLayout::Auto; }
static CSS::MathShift math_shift() { return CSS::MathShift::Normal; }
static CSS::MathStyle math_style() { return CSS::MathStyle::Normal; }
};
enum class BackgroundSize {
@ -346,6 +349,9 @@ public:
CSS::TableLayout table_layout() const { return m_noninherited.table_layout; }
CSS::MathShift math_shift() const { return m_inherited.math_shift; }
CSS::MathStyle math_style() const { return m_inherited.math_style; }
ComputedValues clone_inherited_values() const
{
ComputedValues clone;
@ -385,6 +391,9 @@ protected:
CSS::TextAnchor text_anchor { InitialValues::text_anchor() };
Vector<ShadowData> text_shadow;
CSS::MathShift math_shift { InitialValues::math_shift() };
CSS::MathStyle math_style { InitialValues::math_style() };
} m_inherited;
struct {
@ -579,6 +588,9 @@ public:
void set_outline_offset(CSS::Length value) { m_noninherited.outline_offset = value; }
void set_outline_style(CSS::OutlineStyle value) { m_noninherited.outline_style = value; }
void set_outline_width(CSS::Length value) { m_noninherited.outline_width = value; }
void set_math_shift(CSS::MathShift value) { m_inherited.math_shift = value; }
void set_math_style(CSS::MathStyle value) { m_inherited.math_style = value; }
};
}

View file

@ -276,6 +276,14 @@
"inside",
"outside"
],
"math-shift": [
"normal",
"compact"
],
"math-style": [
"normal",
"compact"
],
"object-fit": [
"fill",
"contain",

View file

@ -105,6 +105,7 @@
"collapse",
"column",
"column-reverse",
"compact",
"condensed",
"contain",
"content",

View file

@ -1479,6 +1479,20 @@
"unitless-length"
]
},
"math-shift": {
"inherited": true,
"initial": "normal",
"valid-types": [
"math-shift"
]
},
"math-style": {
"inherited": true,
"initial": "normal",
"valid-types": [
"math-style"
]
},
"max-height": {
"inherited": false,
"initial": "none",

View file

@ -789,6 +789,14 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
transfer_table_box_computed_values_to_wrapper_computed_values(wrapper_computed_values);
}
auto math_shift_value = computed_style.property(CSS::PropertyID::MathShift);
if (auto math_shift = value_id_to_math_shift(math_shift_value->to_identifier()); math_shift.has_value())
computed_values.set_math_shift(math_shift.value());
auto math_style_value = computed_style.property(CSS::PropertyID::MathStyle);
if (auto math_style = value_id_to_math_style(math_style_value->to_identifier()); math_style.has_value())
computed_values.set_math_style(math_style.value());
// Update any anonymous children that inherit from this node.
// FIXME: This is pretty hackish. It would be nicer if they shared the inherited style
// data structure somehow, so this wasn't necessary.