1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:37:34 +00:00

LibWeb: Add display: math

This is a `<display-inside>` keyword added by the MathML spec, and has
the rough meaning of "display in the default way". It enables the
standard layout rules for each MathML element (and is ignored for
anything that isn't a MathML element).

I believe we'll need an actual MathML formatting context to do the
layout correctly, but we can at least support a couple of elements that
behave the same as HTML ones.
This commit is contained in:
Sam Atkins 2023-09-07 16:03:20 +01:00 committed by Sam Atkins
parent 125d161b3f
commit f3124c492b
6 changed files with 38 additions and 1 deletions

View file

@ -100,6 +100,7 @@ public:
bool is_flex_inside() const { return is_outside_and_inside() && inside() == DisplayInside::Flex; }
bool is_grid_inside() const { return is_outside_and_inside() && inside() == DisplayInside::Grid; }
bool is_ruby_inside() const { return is_outside_and_inside() && inside() == DisplayInside::Ruby; }
bool is_math_inside() const { return is_outside_and_inside() && inside() == DisplayInside::Math; }
enum class Short {
None,
@ -119,6 +120,7 @@ public:
Ruby,
Table,
InlineTable,
Math,
};
static Display from_short(Short short_)
@ -158,6 +160,11 @@ public:
return Display { DisplayOutside::Block, DisplayInside::Table };
case Short::InlineTable:
return Display { DisplayOutside::Inline, DisplayInside::Table };
case Short::Math:
// NOTE: The spec ( https://w3c.github.io/mathml-core/#new-display-math-value ) does not
// mention what the outside value for `display: math` should be.
// The UA stylesheet does `* { display: block math; }` so let's go with that.
return Display { DisplayOutside::Block, DisplayInside::Math };
}
VERIFY_NOT_REACHED();
}