mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +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:
parent
125d161b3f
commit
f3124c492b
6 changed files with 38 additions and 1 deletions
|
@ -72,6 +72,7 @@
|
|||
#include <LibWeb/HTML/HTMLHtmlElement.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Platform/FontPlugin.h>
|
||||
#include <LibWeb/ReferrerPolicy/AbstractOperations.h>
|
||||
#include <stdio.h>
|
||||
|
@ -2243,6 +2244,23 @@ void StyleComputer::transform_box_type_if_needed(StyleProperties& style, DOM::El
|
|||
|
||||
auto new_display = display;
|
||||
|
||||
if (display.is_math_inside()) {
|
||||
// https://w3c.github.io/mathml-core/#new-display-math-value
|
||||
// For elements that are not MathML elements, if the specified value of display is inline math or block math
|
||||
// then the computed value is block flow and inline flow respectively.
|
||||
if (element.namespace_() != Namespace::MathML)
|
||||
new_display = CSS::Display { display.outside(), CSS::DisplayInside::Flow };
|
||||
// For the mtable element the computed value is block table and inline table respectively.
|
||||
else if (element.tag_name().equals_ignoring_ascii_case("mtable"sv))
|
||||
new_display = CSS::Display { display.outside(), CSS::DisplayInside::Table };
|
||||
// For the mtr element, the computed value is table-row.
|
||||
else if (element.tag_name().equals_ignoring_ascii_case("mtr"sv))
|
||||
new_display = CSS::Display { CSS::DisplayInternal::TableRow };
|
||||
// For the mtd element, the computed value is table-cell.
|
||||
else if (element.tag_name().equals_ignoring_ascii_case("mtd"sv))
|
||||
new_display = CSS::Display { CSS::DisplayInternal::TableCell };
|
||||
}
|
||||
|
||||
switch (required_box_type_transformation(style, element, pseudo_element)) {
|
||||
case BoxTypeTransformation::None:
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue