Skip to content

Truly independent web browser

LibWeb: Stretch MathML operators and draw large operators

Andreas Klinga3b072e8e371
diff --git a/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs b/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs
index 71448f3564e..adc24cbdaf1 100644
--- a/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs
+++ b/Libraries/LibWeb/Rust/src/gfx_test_stubs.rs
@@ -48,6 +48,29 @@ extern "C" fn ladybird_gfx_font_glyph_metrics(
unreachable!("no unit test reads a font");
}
+#[unsafe(no_mangle)]
+extern "C" fn ladybird_gfx_font_math_glyph_variants(
+ _font: *const c_void,
+ _glyph_id: u32,
+ _horizontal: bool,
+ _out_variants: *mut libgfx_rust::math_table::FfiMathGlyphVariant,
+ _capacity: usize,
+) -> usize {
+ unreachable!("no unit test reads a font");
+}
+
+#[unsafe(no_mangle)]
+extern "C" fn ladybird_gfx_font_math_glyph_assembly(
+ _font: *const c_void,
+ _glyph_id: u32,
+ _horizontal: bool,
+ _out_parts: *mut libgfx_rust::math_table::FfiMathGlyphPart,
+ _capacity: usize,
+ _out_italics_correction: *mut f32,
+) -> usize {
+ unreachable!("no unit test reads a font");
+}
+
#[unsafe(no_mangle)]
extern "C" fn ladybird_gfx_font_invisible_variant(_font: *const c_void) -> *const c_void {
unreachable!("no unit test reads a font");
diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
index d791e1b5e48..da5ff25407f 100644
--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
@@ -179,6 +179,7 @@ fn sizing_directives_match_ignoring_unobserved(
float_avoidance_inline_size,
outer_float_intrusion_before_list_item_children,
treat_block_axis_percentage_insets_as_auto_beyond_root,
+ math_stretch_size_constraint,
} = *a;
forced_content_inline_size == b.forced_content_inline_size
&& forced_content_block_size == b.forced_content_block_size
@@ -192,6 +193,7 @@ fn sizing_directives_match_ignoring_unobserved(
&& outer_float_intrusion_before_list_item_children == b.outer_float_intrusion_before_list_item_children
&& treat_block_axis_percentage_insets_as_auto_beyond_root
== b.treat_block_axis_percentage_insets_as_auto_beyond_root
+ && math_stretch_size_constraint == b.math_stretch_size_constraint
&& match (
flex_self_block_size_resolution_space,
b.flex_self_block_size_resolution_space,
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index 953554e71ae..c3c785af2c8 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -1994,7 +1994,10 @@ fn execute_formatting_context_run(
body_input
};
+ // NB: A measurement of the box without a stretch size constraint does not tell the size of a stretched
+ // operator.
let cached_atomic_block_size = if !changes_frame
+ && input.sizing.math_stretch_size_constraint.is_none()
&& matches!(
input.participation,
ParticipationInParentFormattingContext::AtomicInline
@@ -2034,19 +2037,25 @@ fn execute_formatting_context_run(
let result = match &mut context_implementation {
FormattingContextImplementation::Block(context) => {
context.run(body_run, body_input);
- let baselines = context.derived_baselines_of_root_box();
- store_derived_baselines(run.records.used_values(run.box_), baselines);
- ChildLayoutResult {
+ let mut result = ChildLayoutResult {
automatic_content_inline_size: context.automatic_content_inline_size(),
min_content_inline_size_from_max_content_layout: context
.min_content_inline_size_from_max_content_layout(),
automatic_content_block_size: context.automatic_content_block_size(),
automatic_line_clamp_max_lines: context.automatic_line_clamp_max_lines(),
- baselines,
+ baselines: context.derived_baselines_of_root_box(),
table_box_in_wrapper_border_box_block_size: context
.table_box_in_wrapper_border_box_block_size(),
..ChildLayoutResult::default()
+ };
+ // https://w3c.github.io/mathml-core/#layout-of-operators
+ // NB: An operator lays out its text in a block formatting context, unless it is drawn with a
+ // stretched or large glyph.
+ if NodeFacts::new(&body_run.callbacks, box_).display().is_math_inside() {
+ math_formatting_context::layout_operator(body_run, &input, &mut result);
}
+ store_derived_baselines(run.records.used_values(run.box_), result.baselines);
+ result
}
FormattingContextImplementation::Flex(context) => {
context.run(body_run, body_input);
diff --git a/Libraries/LibWeb/Rust/src/layout/geometry.rs b/Libraries/LibWeb/Rust/src/layout/geometry.rs
index daa15453953..cb4dcdf4487 100644
--- a/Libraries/LibWeb/Rust/src/layout/geometry.rs
+++ b/Libraries/LibWeb/Rust/src/layout/geometry.rs
@@ -341,6 +341,24 @@ pub(crate) struct RootSizingDirectives {
pub(crate) float_avoidance_inline_size: Option<CssPixels>,
pub(crate) outer_float_intrusion_before_list_item_children: inline_formatting_context::SpaceUsedByFloats,
pub(crate) treat_block_axis_percentage_insets_as_auto_beyond_root: bool,
+ // Input-only: MathML layout lays out an embellished operator with the size its core operator should stretch to
+ // cover.
+ pub(crate) math_stretch_size_constraint: Option<MathStretchSizeConstraint>,
+}
+
+/// The size that MathML layout asks the core operator of an embellished operator to stretch to cover.
+// https://w3c.github.io/mathml-core/#box-model
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub(crate) enum MathStretchSizeConstraint {
+ /// The ink line-ascent and ink line-descent that a core operator stretched along the block axis should cover.
+ Block { ascent: CssPixels, descent: CssPixels },
+ /// The target size that a core operator stretched along the inline axis should cover.
+ Inline(CssPixels),
+ /// AD-HOC: A block stretch size constraint that also covers the in-flow children of the embellished operators
+ /// it passes through. It stands in for laying out an embellished operator with the block stretch size
+ /// constraint (0, 0) and then with its own ink line-ascent and ink line-descent, as a box is laid out
+ /// only once in a run.
+ BlockCoveringContent { ascent: CssPixels, descent: CssPixels },
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
diff --git a/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs
index 8d00aecd24c..bc2d14e8554 100644
--- a/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs
@@ -7,8 +7,10 @@
// https://w3c.github.io/mathml-core/#layout-algorithms
use super::*;
+use crate::layout::formatting_context::ChildLayoutResult;
+use crate::layout::geometry::MathStretchSizeConstraint;
use libgfx_rust::font::FontHandle;
-use libgfx_rust::math_table::{FfiMathData, MathConstant, StretchAxis};
+use libgfx_rust::math_table::{FfiGlyphMetrics, FfiMathData, FfiMathGlyphPart, MathConstant, StretchAxis};
/// The layout algorithm a MathML element's tag name selects when its computed display is block math or inline math.
/// Mirrors the C++ `MathMLLayoutKind`, which the element's construction facts carry.
@@ -696,7 +698,11 @@ impl MathContent {
}
})
.collect();
- MathPaintData { rules, glyph_runs }
+ MathPaintData {
+ rules,
+ glyph_runs,
+ replaces_text: false,
+ }
}
/// The content with its children, rules and glyphs moved by the given line-left offset and baseline shift.
@@ -782,12 +788,255 @@ impl GlyphRun {
}
}
+/// The size of a glyph along a stretch axis: its advance width along the inline axis, and its height along the block
+/// axis.
+fn glyph_size_along(metrics: &FfiGlyphMetrics, axis: StretchAxis) -> f32 {
+ match axis {
+ StretchAxis::Inline => metrics.advance,
+ StretchAxis::Block => metrics.ascent + metrics.descent,
+ }
+}
+
+/// The maximum number of glyphs in a shaped glyph assembly.
+const MAXIMUM_ASSEMBLY_GLYPH_COUNT: usize = u16::MAX as usize;
+
+/// A GlyphAssembly table, with the quantities that building an assembly from it relies on.
+// https://w3c.github.io/mathml-core/#the-glyphassembly-table
+struct GlyphAssembly {
+ assembly: libgfx_rust::math_table::MathGlyphAssembly,
+ axis: StretchAxis,
+ /// omin, MATH.MathVariant.minConnectorOverlap.
+ minimum_overlap: f32,
+ extender_count: usize,
+ non_extender_count: usize,
+ extender_advance_sum: f32,
+ non_extender_advance_sum: f32,
+}
+
+impl GlyphAssembly {
+ /// The GlyphAssembly table of a glyph along an axis, if it is valid.
+ fn new(font: &FontHandle, assembly: libgfx_rust::math_table::MathGlyphAssembly, axis: StretchAxis) -> Option<Self> {
+ let minimum_overlap = font.math_data().min_connector_overlap(axis);
+ let (extenders, non_extenders): (Vec<&FfiMathGlyphPart>, Vec<&FfiMathGlyphPart>) =
+ assembly.parts.iter().partition(|part| part.is_extender);
+ let glyph_assembly = Self {
+ minimum_overlap,
+ extender_count: extenders.len(),
+ non_extender_count: non_extenders.len(),
+ extender_advance_sum: extenders.iter().map(|part| part.full_advance).sum(),
+ non_extender_advance_sum: non_extenders.iter().map(|part| part.full_advance).sum(),
+ assembly,
+ axis,
+ };
+ // User agents must treat the GlyphAssembly as invalid if the following conditions are not satisfied:
+ // - NExt > 0. Otherwise, the assembly cannot be grown by repeating extenders.
+ // - SExt,NonOverlapping > 0. Otherwise, the assembly does not grow when joining extenders.
+ // - For each GlyphPartRecord in GlyphAssembly.partRecords, the values of GlyphPartRecord.startConnectorLength
+ // and GlyphPartRecord.endConnectorLength must be at least omin. Otherwise, it is not possible to satisfy
+ // the condition of MathVariant.minConnectorOverlap.
+ // INTEROP: The start connector of the first part and the end connector of the last part are not checked
+ // unless the part is an extender, as they connect to no other part. Other browsers accept such
+ // assemblies, which fonts commonly have.
+ let parts = &glyph_assembly.assembly.parts;
+ let is_valid = glyph_assembly.extender_count > 0
+ && glyph_assembly.non_overlapping_extender_advance_sum() > 0.0
+ && parts.iter().enumerate().all(|(index, part)| {
+ let start_connects = index > 0 || part.is_extender;
+ let end_connects = index + 1 < parts.len() || part.is_extender;
+ (!start_connects || part.start_connector_length >= minimum_overlap)
+ && (!end_connects || part.end_connector_length >= minimum_overlap)
+ });
+ is_valid.then_some(glyph_assembly)
+ }
+
+ /// SExt,NonOverlapping = SExt − omin NExt is the sum of maximum non overlapping parts of extenders.
+ fn non_overlapping_extender_advance_sum(&self) -> f32 {
+ self.extender_advance_sum - self.minimum_overlap * self.extender_count as f32
+ }
+
+ /// AssemblyGlyphCount(r) = NNonExt + r NExt
+ fn glyph_count(&self, repetitions: usize) -> usize {
+ self.non_extender_count + repetitions * self.extender_count
+ }
+
+ /// AssembySize(o, r) = SNonExt + r SExt − o (AssemblyGlyphCount(r) − 1)
+ fn size(&self, overlap: f32, repetitions: usize) -> f32 {
+ self.non_extender_advance_sum + repetitions as f32 * self.extender_advance_sum
+ - overlap * (self.glyph_count(repetitions) as f32 - 1.0)
+ }
+
+ /// rmin and omax for a target size, or `None` if the assembly would have more than
+ /// `MAXIMUM_ASSEMBLY_GLYPH_COUNT` glyphs.
+ fn repetitions_and_overlap(&self, target: f32) -> Option<(usize, f32)> {
+ // rmin is the minimal number of repetitions needed to obtain an assembly of size at least T, i.e. the minimal
+ // r such that AssembySize(omin, r) ≥ T. It is defined as the maximum between 0 and the ceiling of
+ // ((T − SNonExt + omin (NNonExt − 1)) / SExt,NonOverlapping).
+ let repetitions = ((target - self.non_extender_advance_sum
+ + self.minimum_overlap * (self.non_extender_count as f32 - 1.0))
+ / self.non_overlapping_extender_advance_sum())
+ .ceil()
+ .max(0.0);
+ // AD-HOC: The target size and the font data are untrusted, so an assembly that would need too many glyphs is
+ // not built.
+ let maximum_repetitions =
+ (MAXIMUM_ASSEMBLY_GLYPH_COUNT.checked_sub(self.non_extender_count)? / self.extender_count) as f32;
+ if repetitions > maximum_repetitions {
+ return Option::None;
+ }
+ let repetitions = repetitions as usize;
+ // omax is the maximum overlap possible to build an assembly of size at least T by repeating each extender
+ // rmin times. If AssemblyGlyphCount(rmin) ≤ 1, then the actual overlap value is irrelevant. Otherwise, omax is
+ // defined to be the minimum of:
+ let glyph_count = self.glyph_count(repetitions);
+ if glyph_count <= 1 {
+ return Some((repetitions, 0.0));
+ }
+ // - omax,theorical = (AssembySize(0, rmin) − T) / (AssemblyGlyphCount(rmin) − 1)
+ let mut overlap = (self.size(0.0, repetitions) - target) / (glyph_count as f32 - 1.0);
+ let parts = &self.assembly.parts;
+ for (index, part) in parts.iter().enumerate() {
+ // - GlyphPartRecord.startConnectorLength for all the entries in GlyphAssembly.partRecords, excluding the
+ // last one if it is not an extender.
+ if index > 0 || part.is_extender {
+ overlap = overlap.min(part.start_connector_length);
+ }
+ // - GlyphPartRecord.endConnectorLength for all the entries in GlyphAssembly.partRecords, excluding the
+ // first one if it is not an extender.
+ if index + 1 < parts.len() || part.is_extender {
+ overlap = overlap.min(part.end_connector_length);
+ }
+ }
+ // INTEROP: A part connects to the next part with its end connector and to the previous part with its start
+ // connector, so the connectors that are left out above are swapped: the first part's start connector
+ // and the last part's end connector connect to no part. Other browsers leave out those two connectors
+ // too.
+ Some((repetitions, overlap))
+ }
+
+ /// The glyph assembly shaped for a target size, or `None` if it would have too many glyphs.
+ // https://w3c.github.io/mathml-core/#dfn-shaping-of-the-glyph-assembly
+ fn shape(&self, font: &FontHandle, target: f32) -> Option<GlyphRun> {
+ // 1. Calculate rmin and omax.
+ let (repetitions, overlap) = self.repetitions_and_overlap(target)?;
+ // The glyph assembly stretch size for a target size T is AssembySize(omax, rmin).
+ let stretch_size = self.size(overlap, repetitions);
+ // 2. Set (x, y) to (0, 0), RepetitionCounter to 0 and PartIndex to -1.
+ // 3. Repeat the following steps:
+ // NB: The y coordinate grows towards the line-under here, so the assembly grows upwards by decreasing it.
+ let mut x = 0.0;
+ let mut y = 0.0;
+ let mut glyphs = Vec::with_capacity(self.glyph_count(repetitions));
+ let mut max_advance: f32 = 0.0;
+ let mut max_ascent: f32 = 0.0;
+ let mut max_descent: f32 = 0.0;
+ for part in &self.assembly.parts {
+ // 1. If RepetitionCounter is 0: Increment PartIndex. If PartIndex is GlyphAssembly.partCount then stop.
+ // Otherwise, set Part to GlyphAssembly.partRecords[PartIndex]. Set RepetitionCounter to rmin if Part is
+ // an extender and to 1 otherwise.
+ let repetition_count = if part.is_extender { repetitions } else { 1 };
+ let metrics = font.glyph_metrics(part.glyph_id);
+ max_advance = max_advance.max(metrics.advance);
+ max_ascent = max_ascent.max(metrics.ascent);
+ max_descent = max_descent.max(metrics.descent);
+ for _ in 0..repetition_count {
+ match self.axis {
+ // 2. If the glyph assembly is horizontal then draw the glyph of ID Part.glyphID so that its
+ // (left, baseline) coordinates are at position (x, y). Set x to x + Part.fullAdvance − omax.
+ StretchAxis::Inline => {
+ glyphs.push(MathGlyph {
+ x,
+ y,
+ glyph_id: part.glyph_id,
+ });
+ x += part.full_advance - overlap;
+ }
+ // 3. Otherwise (if the glyph assembly is vertical), then draw the glyph of id Part.glyphID so that
+ // its (left, bottom) coordinates are at position (x, y). Set y to y − Part.fullAdvance + omax.
+ StretchAxis::Block => {
+ glyphs.push(MathGlyph {
+ x,
+ y: y - metrics.descent,
+ glyph_id: part.glyph_id,
+ });
+ y -= part.full_advance - overlap;
+ }
+ }
+ // 4. Decrement RepetitionCounter.
+ }
+ }
+ // If GlyphAssembly is vertical, the width is the maximum advance width of the glyphs of ID
+ // GlyphPartRecord.glyphID for all the GlyphPartRecord in GlyphAssembly.partRecords, the ascent is the glyph
+ // assembly stretch size for a given target size T and the descent is 0. Otherwise, the GlyphAssembly is
+ // horizontal, the width is glyph assembly stretch size for a given target size T while the ascent
+ // (respectively descent) is the maximum ascent (respectively descent) of the glyphs of ID
+ // GlyphPartRecord.glyphID for all the GlyphPartRecord in GlyphAssembly.partRecords.
+ let (advance, ascent, descent) = match self.axis {
+ StretchAxis::Block => (max_advance, stretch_size, 0.0),
+ StretchAxis::Inline => (stretch_size, max_ascent, max_descent),
+ };
+ Some(GlyphRun {
+ font: font.clone(),
+ glyphs,
+ advance: CssPixels::nearest_value_for_f32(advance),
+ ascent: CssPixels::nearest_value_for_f32(ascent),
+ descent: CssPixels::nearest_value_for_f32(descent),
+ })
+ }
+}
+
+// https://w3c.github.io/mathml-core/#dfn-shape-a-stretchy-glyph
+fn shape_stretchy_glyph(font: &FontHandle, glyph_id: u32, axis: StretchAxis, target: CssPixels) -> Option<GlyphRun> {
+ let target = target.to_float();
+ // FIXME: Keep the italic correction that comes with the glyph, for the scripts attached to the operator.
+ let normal_shaping = |glyph_id: u32| GlyphRun::for_glyph(font.clone(), glyph_id);
+ // 1. If there is not any MathGlyphConstruction table in the MathVariants.horizGlyphConstructionOffsets table
+ // (respectively MathVariants.vertGlyphConstructionOffsets table) for the given glyph then exit with failure.
+ // NB: HarfBuzz reads an absent MathGlyphConstruction table like one without variants or assembly.
+ if !font.math_data().has_math_table {
+ return None;
+ }
+ let variants = font.math_glyph_variants(glyph_id, axis);
+ let assembly = font.math_glyph_assembly(glyph_id, axis);
+ if variants.is_empty() && assembly.is_none() {
+ return None;
+ }
+ // 2. If the glyph's advance width (respectively height) is at least T then use normal shaping and bounding box
+ // for that glyph, the MathItalicsCorrectionInfo for that glyph as italic correction and exit with success.
+ if glyph_size_along(&font.glyph_metrics(glyph_id), axis) >= target {
+ return Some(normal_shaping(glyph_id));
+ }
+ // 3. Browse the list of MathGlyphVariantRecord in MathGlyphConstruction.mathGlyphVariantRecord. If one
+ // MathGlyphVariantRecord.advanceMeasurement is at least T then use normal shaping and bounding box for
+ // MathGlyphVariantRecord.variantGlyph, the MathItalicsCorrectionInfo for that glyph as italic correction and
+ // exit with success.
+ if let Some(variant) = variants.iter().find(|variant| variant.advance_measurement >= target) {
+ return Some(normal_shaping(variant.glyph_id));
+ }
+ // 4. If there is valid GlyphAssembly subtable then use the bounding box given by glyph assembly width, glyph
+ // assembly height, glyph assembly ascent, glyph assembly descent, the value GlyphAssembly.italicsCorrection as
+ // italic correction, perform shaping of the glyph assembly and exit with success.
+ // NB: An assembly that would have too many glyphs is not used.
+ if let Some(glyph_run) = assembly
+ .and_then(|assembly| GlyphAssembly::new(font, assembly, axis))
+ .and_then(|assembly| assembly.shape(font, target))
+ {
+ return Some(glyph_run);
+ }
+ // 5. If none of the stretch options above allowed to cover the target size T, then choose last one that was tried
+ // and exit with success.
+ Some(normal_shaping(
+ variants.last().map_or(glyph_id, |variant| variant.glyph_id),
+ ))
+}
+
/// What MathML layout produced for a box that painting draws: fraction bars, radical symbols and the glyphs of
/// stretched operators. Positions are relative to the top-left corner of the content box.
#[derive(Debug, PartialEq)]
pub(crate) struct MathPaintData {
pub(crate) rules: Vec<CssPixelRect>,
pub(crate) glyph_runs: Vec<MathGlyphRun>,
+ /// Whether the glyphs are those of a stretched or large operator, which are painted instead of its text.
+ pub(crate) replaces_text: bool,
}
#[derive(Debug, PartialEq)]
@@ -845,6 +1094,12 @@ impl MathConstants {
self.constant_or(constant, CssPixels::default())
}
+ // displayOperatorMinHeight: MATH.MathConstants.displayOperatorMinHeight or Default fallback constant if the
+ // constant is not available.
+ fn display_operator_min_height(&self) -> CssPixels {
+ self.constant_or_zero(MathConstant::DisplayOperatorMinHeight)
+ }
+
// axisHeight: MATH.MathConstants.axisHeight or half OS/2.sxHeight if the constant is not available.
fn axis_height(&self) -> CssPixels {
self.constant_or(MathConstant::AxisHeight, self.x_height / 2)
@@ -1137,6 +1392,64 @@ impl MathConstants {
}
}
+/// The glyph that an <mo> is drawn with when it is stretched or a large operator.
+struct OperatorGlyph {
+ glyph: GlyphRun,
+ /// Δ, how far the glyph is shifted away from the alphabetic baseline towards the line-under.
+ baseline_shift: CssPixels,
+}
+
+/// Lays out an <mo> whose text was laid out in a block formatting context with the glyph it is drawn with instead,
+/// if it is stretched or a large operator.
+// https://w3c.github.io/mathml-core/#layout-of-operators
+pub(super) fn layout_operator(run: &FormattingContextRun<'_>, input: &LayoutInput, result: &mut ChildLayoutResult) {
+ let context = MathFormattingContext::new(run);
+ let operator = run.box_;
+ if context.kind(operator) != MathLayoutKind::Mo {
+ return;
+ }
+ let Some(OperatorGlyph { glyph, baseline_shift }) =
+ context.operator_glyph(operator, input.sizing.math_stretch_size_constraint)
+ else {
+ return;
+ };
+ let glyphs = glyph;
+ let ascent = glyphs.ascent - baseline_shift;
+ let descent = glyphs.descent + baseline_shift;
+ let inline_size = glyphs.advance;
+ let used = run.records.used_values(operator);
+ // NB: The math content box sizes the content box, unless the width property gives it a size.
+ if sizing_context::is_plain_auto(context.style(operator).width()) {
+ used.content_inline_size.set(inline_size);
+ }
+ result.automatic_content_inline_size = inline_size;
+ result.automatic_content_block_size = ascent + descent;
+ result.baselines = DerivedBaselines {
+ first: Some(ascent),
+ last: Some(ascent),
+ };
+ if run.layout_mode != LayoutMode::Normal {
+ return;
+ }
+ let content = MathContent {
+ inline_size,
+ ascent,
+ descent,
+ glyph_runs: vec![PlacedGlyphRun {
+ line_left_offset: CssPixels::default(),
+ baseline_shift,
+ glyphs,
+ }],
+ ..MathContent::default()
+ };
+ let is_rtl = context.style(operator).direction() == direction::RTL;
+ let paint_data = MathPaintData {
+ replaces_text: true,
+ ..content.paint_data(CssPixels::default(), inline_size, is_rtl)
+ };
+ used.rare_data_mut().math_paint_data = Some(std::sync::Arc::new(paint_data));
+}
+
pub(super) struct MathFormattingContext<'pass> {
run: FormattingContextRun<'pass>,
content: MathContent,
@@ -1398,12 +1711,422 @@ impl<'pass> MathFormattingContext<'pass> {
})
}
- fn layout_child(&self, child: Node, constraints: ContainingBlockConstraints) -> Child {
+ /// The properties of an operator, as the core operator of the outermost embellished operator it is the core
+ /// operator of.
+ fn core_operator_properties(&self, operator: Node) -> Option<OperatorProperties> {
+ let callbacks = &self.run.callbacks;
+ let lays_out_math = |node: Node| !node.is_invalid() && self.kind(node).uses_math_layout();
+ let mut embellished_operator = operator;
+ loop {
+ let parent = callbacks.parent(embellished_operator);
+ if !lays_out_math(parent) || self.core_operator(parent) != Some(operator) {
+ break;
+ }
+ embellished_operator = parent;
+ }
+ let parent = callbacks.parent(embellished_operator);
+ if lays_out_math(parent) {
+ let siblings = self.in_flow_children_of(parent);
+ if let Some(index) = siblings.iter().position(|&sibling| sibling == embellished_operator) {
+ let parent_kind = self.kind(parent);
+ let first_and_last_non_space_like = self.first_and_last_non_space_like(&siblings, parent_kind);
+ return self.embellished_operator_properties(
+ &siblings,
+ index,
+ parent_kind,
+ first_and_last_non_space_like,
+ );
+ }
+ }
+ self.embellished_operator_properties(&[embellished_operator], 0, MathLayoutKind::NotMathML, Option::None)
+ }
+
+ /// The glyph an <mo> is drawn with, if it is stretched or a large operator.
+ // https://w3c.github.io/mathml-core/#layout-of-operators
+ fn operator_glyph(
+ &self,
+ operator: Node,
+ stretch_size_constraint: Option<MathStretchSizeConstraint>,
+ ) -> Option<OperatorGlyph> {
+ // 1. If the content of the <mo> element is not made of a single character c then fall back to the layout
+ // algorithm of 3.2.1.1 Layout of <mtext>. If it is not possible to get a glyph corresponding to c given
+ // directionality dir, then fall back to the layout algorithm of 3.2.1.1 Layout of <mtext>. Otherwise, let g
+ // be the result of running get a glyph corresponding to c given directionality dir.
+ let character = self.operator_character(operator)?;
+ // FIXME: Mirror the glyph for dir rtl.
+ let style = self.style(operator);
+ let font = style.first_available_font();
+ let glyph_id = font.glyph_id_for_code_point(character);
+ if glyph_id == 0 {
+ return Option::None;
+ }
+ // OPTIMIZATION: A stretchy glyph can only be shaped with a font that has a MATH table, so the properties of
+ // the operator are not looked up without one.
+ if !font.math_data().has_math_table {
+ return Option::None;
+ }
+ let properties = self.core_operator_properties(operator)?;
+ let constants = MathConstants::for_style(&style);
+ let axis_height = constants.axis_height();
+ // 2. If the operator has the stretchy property:
+ if properties.flags.stretchy {
+ // - If the stretch axis of the operator is inline:
+ if self.stretch_axis(operator) == StretchAxis::Inline {
+ // 1. If it is not possible to shape a stretchy glyph g in the inline direction with the first available
+ // font then fall back to the layout algorithm of 3.2.1.1 Layout of <mtext>.
+ // 2. The min-content inline size and max-content inline size of the math content are set to the one
+ // obtained by the layout algorithm of 3.2.1.1 Layout of <mtext>.
+ // 3. If there is not any inline stretch size constraint Tinline then fall back to the layout algorithm
+ // of 3.2.1.1 Layout of <mtext>.
+ let Some(MathStretchSizeConstraint::Inline(target)) = stretch_size_constraint else {
+ return Option::None;
+ };
+ // 4. The inline size and (ink) block metrics of the math content are given by algorithm to shape a
+ // stretchy glyph g to inline dimension Tinline.
+ // 5. The painting of the operator is performed by the algorithm to shape a stretchy glyph g stretched
+ // to inline dimension Tinline and at position determined by the previous box metrics.
+ let glyph = shape_stretchy_glyph(&font, glyph_id, StretchAxis::Inline, target)?;
+ return Some(OperatorGlyph {
+ glyph,
+ baseline_shift: CssPixels::default(),
+ });
+ }
+ // - Otherwise, the stretch axis of the operator is block. The following steps are performed:
+ // 1. If it is not possible to shape a stretchy glyph g in the block direction with the first available
+ // font then fall back to the layout algorithm of 3.2.1.1 Layout of <mtext>.
+ // 2. The min-content inline size and max-content inline size of the math content are set to the
+ // preferred inline size of a glyph stretched along the block axis.
+ // 3. If there is not any block stretch size constraint (Uascent, Udescent) then fall back to the layout
+ // algorithm of 3.2.1.1 Layout of <mtext>.
+ // FIXME: Use the preferred inline size of a glyph stretched along the block axis for the min-content and
+ // max-content inline sizes, rather than the inline size of the stretched glyph.
+ let Some(
+ MathStretchSizeConstraint::Block {
+ ascent: unconstrained_ascent,
+ descent: unconstrained_descent,
+ }
+ | MathStretchSizeConstraint::BlockCoveringContent {
+ ascent: unconstrained_ascent,
+ descent: unconstrained_descent,
+ },
+ ) = stretch_size_constraint
+ else {
+ return Option::None;
+ };
+ // 4. If the operator has the symmetric property then set the target sizes Tascent and Tdescent to Sascent
+ // and Sdescent respectively:
+ // Sascent = max(Uascent − AxisHeight, Udescent + AxisHeight) + AxisHeight
+ // Sdescent = max(Uascent − AxisHeight, Udescent + AxisHeight) − AxisHeight
+ // Otherwise set them to Uascent and Udescent respectively.
+ let (mut target_ascent, mut target_descent) = if properties.flags.symmetric {
+ let half_size = (unconstrained_ascent - axis_height).max(unconstrained_descent + axis_height);
+ (half_size + axis_height, half_size - axis_height)
+ } else {
+ (unconstrained_ascent, unconstrained_descent)
+ };
+ // 5. Let minsize and maxsize be the minsize and maxsize properties on the operator. Percentage values are
+ // interpreted relative to the height of g. Let T = Tascent + Tdescent be the target size. If minsize < 0
+ // then set minsize to 0. If maxsize < minsize then set maxsize to minsize. With 0 ≤ minsize ≤
+ // maxsize:
+ // NB: Font-relative lengths for minsize and maxsize rely on the font style of the core operator. The
+ // dictionary sets minsize to 100% and maxsize to ∞, which is represented by `None`.
+ let attributes = self.run.callbacks.arena().math_attribute_facts(operator);
+ let glyph_metrics = font.glyph_metrics(glyph_id);
+ let glyph_height = CssPixels::nearest_value_for_f32(glyph_metrics.ascent + glyph_metrics.descent);
+ let mut minsize = attributes.minsize.resolve(&style, glyph_height).unwrap_or(glyph_height);
+ let mut maxsize = attributes.maxsize.resolve(&style, glyph_height);
+ let target = target_ascent + target_descent;
+ minsize = minsize.max(CssPixels::default());
+ if let Some(size) = maxsize
+ && size < minsize
+ {
+ maxsize = Some(minsize);
+ }
+ let scaled_target_ascent = |size: CssPixels| {
+ CssPixels::nearest_value_for(
+ (f64::from((target_ascent - axis_height).to_float()) * f64::from(size.to_float())
+ / f64::from(target.to_float()))
+ + f64::from(axis_height.to_float()),
+ )
+ .max(CssPixels::default())
+ };
+ // - If T ≤ 0 then set Tascent to minsize / 2 + AxisHeight and then set Tdescent to minsize − Tascent.
+ if target <= CssPixels::default() {
+ target_ascent = minsize / 2 + axis_height;
+ target_descent = minsize - target_ascent;
+ }
+ // - Otherwise, if 0 < T < minsize then set Tascent to max(0, (Tascent − AxisHeight) × minsize / T +
+ // AxisHeight) and Tdescent to minsize − Tascent.
+ else if target < minsize {
+ target_ascent = scaled_target_ascent(minsize);
+ target_descent = minsize - target_ascent;
+ }
+ // - Otherwise, if maxsize < T then set Tascent to max(0, (Tascent − AxisHeight) × maxsize / T +
+ // AxisHeight) and Tdescent to maxsize − Tascent.
+ else if let Some(maxsize) = maxsize
+ && maxsize < target
+ {
+ target_ascent = scaled_target_ascent(maxsize);
+ target_descent = maxsize - target_ascent;
+ }
+ // 6. The inline size, ink line-ascent, ink line-descent, line-ascent and line-descent of the math content
+ // are obtained by the algorithm to shape a stretchy glyph g to block dimension Tascent + Tdescent.
+ let glyph = shape_stretchy_glyph(&font, glyph_id, StretchAxis::Block, target_ascent + target_descent)?;
+ // The inline size of the math content is the width of the stretchy glyph. The stretchy glyph is shifted
+ // towards the line-under by a value Δ so that its center aligns with the center of the target: the ink
+ // ascent of the math content is the ascent of the stretchy glyph − Δ and the ink descent of the math
+ // content is the descent of the stretchy glyph + Δ. These centers have coordinates "½(ascent − descent)"
+ // so Δ = [(ascent of stretchy glyph − descent of stretchy glyph) − (Tascent − Tdescent)] / 2.
+ let delta = ((glyph.ascent - glyph.descent) - (target_ascent - target_descent)) / 2;
+ // 7. The painting of the operator is performed by the algorithm to shape a stretchy glyph g stretched to
+ // block dimension Tascent + Tdescent and at position determined by the previous box metrics shifted by Δ
+ // towards the line-over.
+ return Some(OperatorGlyph {
+ glyph,
+ baseline_shift: delta,
+ });
+ }
+ // 3. If the operator has the largeop property and if math-style on the <mo> element is normal, then:
+ if properties.flags.largeop && style.math_style() == math_style::NORMAL {
+ // 1. If it is not possible to shape a stretchy glyph g in the block direction with the first available
+ // font then fall back to the layout algorithm of 3.2.1.1 Layout of <mtext>.
+ // 2. The min-content inline size and max-content inline size of the math content are set to the preferred
+ // inline size of a glyph stretched along the block axis.
+ // 3. The inline size, ink line-ascent, ink line-descent, line-ascent and line-descent of the math content
+ // are obtained by the algorithm to shape a stretchy glyph g to block dimension DisplayOperatorMinHeight.
+ // The inline size of the math content is the width of the stretchy glyph. The stretchy glyph is shifted
+ // towards the line-under by a value Δ so that its center aligns with the center of the target when
+ // symmetric: the ink ascent of the math content is the ascent of the stretchy glyph − Δ and the ink
+ // descent of the math content is the descent of the stretchy glyph + Δ.
+ // - If the operator has the symmetric property, then Δ = [(ascent of stretchy glyph − descent of
+ // stretchy glyph) − 2 * AxisHeight] / 2.
+ // - Otherwise, Δ = 0.
+ // NB: The min-content and max-content inline sizes are the inline size of the glyph, as it is shaped the
+ // same whatever the stretch size constraint.
+ let glyph = shape_stretchy_glyph(
+ &font,
+ glyph_id,
+ StretchAxis::Block,
+ constants.display_operator_min_height(),
+ )?;
+ let delta = if properties.flags.symmetric {
+ ((glyph.ascent - glyph.descent) - axis_height * 2usize) / 2
+ } else {
+ CssPixels::default()
+ };
+ // 4. The painting of the operator is performed by the algorithm to shape a stretchy glyph g stretched to
+ // block dimension DisplayOperatorMinHeight and at position determined by the previous box metrics
+ // shifted by Δ towards the line-over.
+ return Some(OperatorGlyph {
+ glyph,
+ baseline_shift: delta,
+ });
+ }
+ // 4. Otherwise fall back to the layout algorithm of 3.2.1.1 Layout of <mtext>.
+ Option::None
+ }
+
+ /// Whether the box lays out its in-flow children like an <mrow>, as the layout algorithm its tag name selects
+ /// falls back to that of <mrow> or generates an anonymous <mrow> box.
+ fn lays_out_children_like_mrow(&self, kind: MathLayoutKind, children: &[Node]) -> bool {
+ match (kind, children.len()) {
+ (
+ MathLayoutKind::Mfrac
+ | MathLayoutKind::Msub
+ | MathLayoutKind::Msup
+ | MathLayoutKind::Munder
+ | MathLayoutKind::Mover
+ | MathLayoutKind::Mroot,
+ 2,
+ )
+ | (MathLayoutKind::Msubsup | MathLayoutKind::Munderover, 3)
+ | (MathLayoutKind::Mspace, _) => false,
+ (MathLayoutKind::Mmultiscripts, _) => !self.is_valid_multiscripts(children),
+ _ => true,
+ }
+ }
+
+ /// The index of the in-flow child that the core operator of the box belongs to, if the box is an embellished
+ /// operator.
+ fn embellished_operator_child(&self, children: &[Node]) -> Option<usize> {
+ self.core_operator(self.run.box_)?;
+ let kind = self.kind(self.run.box_);
+ if kind.is_grouping_element() || kind == MathLayoutKind::Mpadded {
+ return children.iter().position(|&child| self.core_operator(child).is_some());
+ }
+ Some(0)
+ }
+
+ /// Whether the in-flow child at `index` is an embellished operator with the stretchy property and the given
+ /// stretch axis.
+ fn is_stretchy_operator_along(
+ &self,
+ children: &[Node],
+ index: usize,
+ first_and_last_non_space_like: Option<(usize, usize)>,
+ axis: StretchAxis,
+ ) -> bool {
+ self.embellished_operator_properties(children, index, self.kind(self.run.box_), first_and_last_non_space_like)
+ .is_some_and(|properties| properties.flags.stretchy && self.stretch_axis(properties.core_operator) == axis)
+ }
+
+ /// Lays out the in-flow children, stretching the operators among them as the layout algorithm of the box asks.
+ fn layout_children(
+ &self,
+ children: &[Node],
+ kind: MathLayoutKind,
+ constraints: ContainingBlockConstraints,
+ stretch_size_constraint: Option<MathStretchSizeConstraint>,
+ ) -> Vec<Child> {
+ // https://w3c.github.io/mathml-core/#algorithm-for-stretching-operators-along-the-block-axis
+ // 1. If there is a block stretch size constraint or an inline stretch size constraint then the element being
+ // laid out is an embellished operator. Lay out the one in-flow child that is an embellished operator with
+ // the same stretch size constraint and all the other in-flow children without any stretch size constraint
+ // and stop.
+ // NB: The same goes for the other layout algorithms, which lay out their first in-flow child with the same
+ // stretch size constraint.
+ if let Some(stretch_size_constraint) = stretch_size_constraint {
+ let embellished_operator_child = self.embellished_operator_child(children);
+ let mut laid_out: Vec<Option<Child>> = children
+ .iter()
+ .enumerate()
+ .map(|(index, &child)| {
+ (Some(index) != embellished_operator_child)
+ .then(|| self.layout_child(child, constraints, Option::None))
+ })
+ .collect();
+ if let Some(index) = embellished_operator_child {
+ let constraint = match stretch_size_constraint {
+ MathStretchSizeConstraint::BlockCoveringContent { ascent, descent } => {
+ MathStretchSizeConstraint::BlockCoveringContent {
+ ascent: laid_out
+ .iter()
+ .flatten()
+ .map(|child| child.ascent)
+ .fold(ascent, CssPixels::max),
+ descent: laid_out
+ .iter()
+ .flatten()
+ .map(|child| child.descent)
+ .fold(descent, CssPixels::max),
+ }
+ }
+ constraint => constraint,
+ };
+ laid_out[index] = Some(self.layout_child(children[index], constraints, Some(constraint)));
+ }
+ return laid_out.into_iter().flatten().collect();
+ }
+ let is_underover = matches!(
+ (kind, children.len()),
+ (MathLayoutKind::Munder | MathLayoutKind::Mover, 2) | (MathLayoutKind::Munderover, 3)
+ );
+ let (axis, first_and_last_non_space_like) = if is_underover {
+ (StretchAxis::Inline, Option::None)
+ } else if self.lays_out_children_like_mrow(kind, children) {
+ (StretchAxis::Block, self.first_and_last_non_space_like(children, kind))
+ } else {
+ return children
+ .iter()
+ .map(|&child| self.layout_child(child, constraints, Option::None))
+ .collect();
+ };
+ // 2. Otherwise, split the list of in-flow children into a first list LToStretch containing embellished
+ // operators with a stretchy property and block stretch axis; and a second list LNotToStretch.
+ // NB: The algorithm for stretching operators along the inline axis, which <munder>, <mover> and <munderover>
+ // use, has the same steps for operators with inline stretch axis, an inline stretch size constraint 0, and
+ // a target size T that is the maximum inline size of the margin boxes of the child boxes laid out.
+ // https://w3c.github.io/mathml-core/#algorithm-for-stretching-operators-along-the-inline-axis
+ let mut to_stretch: Vec<bool> = (0..children.len())
+ .map(|index| self.is_stretchy_operator_along(children, index, first_and_last_non_space_like, axis))
+ .collect();
+ // 3. Perform layout without any stretch size constraint on all the items of LNotToStretch.
+ let mut laid_out: Vec<Option<Child>> = children
+ .iter()
+ .zip(&to_stretch)
+ .map(|(&child, &to_stretch)| (!to_stretch).then(|| self.layout_child(child, constraints, Option::None)))
+ .collect();
+ // 4. If LToStretch is empty then stop.
+ if !to_stretch.contains(&true) {
+ return laid_out.into_iter().flatten().collect();
+ }
+ // 5. If LNotToStretch is empty, perform layout with block stretch size constraint (0, 0) for all the items of
+ // LToStretch.
+ // AD-HOC: A box is laid out once in a run, so the metrics the core operators of the items of LToStretch have
+ // with that stretch size constraint stand in for those of the items, which are then laid out with a
+ // stretch size constraint that also covers their other in-flow children. An operator without a
+ // stretched glyph keeps its unstretched layout.
+ let mut metrics: Vec<(CssPixels, CssPixels, CssPixels)> = laid_out
+ .iter()
+ .flatten()
+ .map(|child| (child.inline_size, child.ascent, child.descent))
+ .collect();
+ let not_to_stretch_is_empty = metrics.is_empty();
+ if not_to_stretch_is_empty {
+ let constraint = match axis {
+ StretchAxis::Block => MathStretchSizeConstraint::Block {
+ ascent: CssPixels::default(),
+ descent: CssPixels::default(),
+ },
+ StretchAxis::Inline => MathStretchSizeConstraint::Inline(CssPixels::default()),
+ };
+ for (index, &child) in children.iter().enumerate() {
+ let operator_glyph = self
+ .core_operator(child)
+ .and_then(|core_operator| self.operator_glyph(core_operator, Some(constraint)));
+ match operator_glyph {
+ Some(OperatorGlyph { glyph, baseline_shift }) => metrics.push((
+ glyph.advance,
+ glyph.ascent - baseline_shift,
+ glyph.descent + baseline_shift,
+ )),
+ Option::None => {
+ let child = self.layout_child(child, constraints, Option::None);
+ metrics.push((child.inline_size, child.ascent, child.descent));
+ laid_out[index] = Some(child);
+ to_stretch[index] = false;
+ }
+ }
+ }
+ }
+ // 6. Calculate the unconstrained target sizes Uascent and Udescent as respectively the maximum ink ascent and
+ // maximum ink descent of the margin boxes of in-flow children that have been laid out in the previous step.
+ let unconstrained_ascent = metrics.iter().map(|metrics| metrics.1).max().unwrap_or_default();
+ let unconstrained_descent = metrics.iter().map(|metrics| metrics.2).max().unwrap_or_default();
+ let constraint = match axis {
+ StretchAxis::Block if not_to_stretch_is_empty => MathStretchSizeConstraint::BlockCoveringContent {
+ ascent: unconstrained_ascent,
+ descent: unconstrained_descent,
+ },
+ StretchAxis::Block => MathStretchSizeConstraint::Block {
+ ascent: unconstrained_ascent,
+ descent: unconstrained_descent,
+ },
+ StretchAxis::Inline => {
+ MathStretchSizeConstraint::Inline(metrics.iter().map(|metrics| metrics.0).max().unwrap_or_default())
+ }
+ };
+ // 7. Lay out or relayout all the elements of LToStretch with block stretch size constraint (Uascent,
+ // Udescent).
+ for (index, &child) in children.iter().enumerate() {
+ if to_stretch[index] {
+ laid_out[index] = Some(self.layout_child(child, constraints, Some(constraint)));
+ }
+ }
+ laid_out.into_iter().flatten().collect()
+ }
+
+ fn layout_child(
+ &self,
+ child: Node,
+ constraints: ContainingBlockConstraints,
+ stretch_size_constraint: Option<MathStretchSizeConstraint>,
+ ) -> Child {
let run = &self.run;
run.records.create_used_values(&run.callbacks, child, constraints);
// NB: MathML layout does not break lines, so each child is laid out at its max-content inline size, as an
// atomic box whose block size follows from its content.
- let input = LayoutInput::new(
+ let mut input = LayoutInput::new(
AvailableSpace {
inline_size: AvailableSize::MaxContent,
block_size: AvailableSize::Indefinite,
@@ -1411,6 +2134,7 @@ impl<'pass> MathFormattingContext<'pass> {
constraints,
ParticipationInParentFormattingContext::AtomicInline,
);
+ input.sizing.math_stretch_size_constraint = stretch_size_constraint;
let used = run.records.used_values(child);
let baselines =
match formatting_context::layout_inside_child(run, None, None, child, run.layout_mode, input, true) {
@@ -1437,11 +2161,13 @@ impl<'pass> MathFormattingContext<'pass> {
let constraints = run
.sizing()
.constraints_for_child_context(root, layout_input.containing_block_constraints);
- let children: Vec<Child> = self
- .in_flow_children()
- .into_iter()
- .map(|child| self.layout_child(child, constraints))
- .collect();
+ let nodes = self.in_flow_children();
+ let children = self.layout_children(
+ &nodes,
+ kind,
+ constraints,
+ layout_input.sizing.math_stretch_size_constraint,
+ );
let root_style = self.style(root);
let constants = MathConstants::for_style(&root_style);
@@ -1477,20 +2203,21 @@ impl<'pass> MathFormattingContext<'pass> {
let inner = self.layout_row_with_operator_spacing(&children, kind, add_space);
self.layout_padded(inner, &root_style)
}
- (MathLayoutKind::Mmultiscripts, _) if self.is_valid_multiscripts(&children) => layout_multiscripts(
+ (MathLayoutKind::Mmultiscripts, _) if self.is_valid_multiscripts(&nodes) => layout_multiscripts(
&children,
- self.prescripts_separator_index(&children),
+ self.prescripts_separator_index(&nodes),
&constants,
is_cramped,
),
(MathLayoutKind::Mroot, 2) => {
- let radical = RadicalMetrics::new(&root_style, &constants);
- layout_root(&children[0], &children[1], &radical, &constants)
+ let base = &children[0];
+ let radical = RadicalMetrics::new(&root_style, &constants, base.ascent + base.descent);
+ layout_root(base, &children[1], &radical, &constants)
}
(MathLayoutKind::Msqrt, _) => {
- let radical = RadicalMetrics::new(&root_style, &constants);
// NB: The children of <msqrt> are laid out in an anonymous <mrow> box.
let base = self.layout_row_with_operator_spacing(&children, kind, true);
+ let radical = RadicalMetrics::new(&root_style, &constants, base.ascent + base.descent);
layout_square_root(base, &radical)
}
_ => {
@@ -1561,14 +2288,14 @@ impl<'pass> MathFormattingContext<'pass> {
self.content = content;
}
- fn prescripts_separator_index(&self, children: &[Child]) -> Option<usize> {
+ fn prescripts_separator_index(&self, children: &[Node]) -> Option<usize> {
children
.iter()
- .position(|child| self.kind(child.node) == MathLayoutKind::Mprescripts)
+ .position(|&child| self.kind(child) == MathLayoutKind::Mprescripts)
}
// https://w3c.github.io/mathml-core/#prescripts-and-tensor-indices-mmultiscripts
- fn is_valid_multiscripts(&self, children: &[Child]) -> bool {
+ fn is_valid_multiscripts(&self, children: &[Node]) -> bool {
// A valid <mmultiscripts> element contains the following in-flow children:
// - A first in-flow child, called the mmultiscripts base, that is not an <mprescripts> element.
// - Followed by an even number of in-flow children called mmultiscripts postscripts, none of them being a
@@ -1577,7 +2304,7 @@ impl<'pass> MathFormattingContext<'pass> {
// mmultiscripts prescripts, none of them being a <mprescripts> element.
let separator_count = children
.iter()
- .filter(|child| self.kind(child.node) == MathLayoutKind::Mprescripts)
+ .filter(|&&child| self.kind(child) == MathLayoutKind::Mprescripts)
.count();
match self.prescripts_separator_index(children) {
Option::None => !children.is_empty() && children.len() % 2 == 1,
@@ -2368,10 +3095,10 @@ struct RadicalMetrics {
}
impl RadicalMetrics {
- fn new(style: &StyleValues<'_>, constants: &MathConstants) -> Self {
+ fn new(style: &StyleValues<'_>, constants: &MathConstants, base_ink_height: CssPixels) -> Self {
// The radical glyph is the glyph obtained as a result of running get a glyph corresponding to the U+221A
// SQUARE ROOT character given dir.
- // FIXME: Stretch the radical glyph to the radical target size, and mirror it for dir rtl.
+ // FIXME: Mirror the radical glyph for dir rtl.
const SQUARE_ROOT: u32 = 0x221A;
let font = style.frozen_font_list().font_for_code_point(
SQUARE_ROOT,
@@ -2385,10 +3112,19 @@ impl RadicalMetrics {
} else {
constants.radical_vertical_gap()
};
+ let rule_thickness = constants.radical_rule_thickness();
+ // The radical target size for the stretchy radical glyph is the sum of RadicalRuleThickness, radical gap and
+ // the ink height of the base.
+ let target_size = rule_thickness + gap + base_ink_height;
+ // The box metrics of the radical glyph and painting of the surd are given by the algorithm to shape a stretchy
+ // glyph to the target size for the radical glyph in the block dimension.
+ // NB: A glyph that cannot be stretched is used as it is.
+ let glyph = shape_stretchy_glyph(&font, glyph_id, StretchAxis::Block, target_size)
+ .unwrap_or_else(|| GlyphRun::for_glyph(font, glyph_id));
Self {
- glyph: GlyphRun::for_glyph(font, glyph_id),
+ glyph,
gap,
- rule_thickness: constants.radical_rule_thickness(),
+ rule_thickness,
extra_ascender: constants.radical_extra_ascender(),
}
}
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/math.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/math.rs
index af70231496e..50e2c848f05 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/math.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/math.rs
@@ -34,6 +34,13 @@ pub(crate) fn paint_foreground<O: Observer>(
return;
};
let color = Color(style.inherited_text().color);
+ // NB: The glyphs of a stretched or large operator are painted instead of its text, so they use the text fill
+ // color like the text would.
+ let glyph_color = if data.replaces_text {
+ Color(style.inherited_text().webkit_text_fill_color)
+ } else {
+ color
+ };
let font_smoothing = style.inherited_text().font_smoothing;
let content_box = paintable_geometry::absolute_rect(recorder.source, paintable);
let converter = recorder.converter;
@@ -71,7 +78,7 @@ pub(crate) fn paint_foreground<O: Observer>(
font_id: FontResourceId(font_id),
glyphs: &glyphs,
},
- color,
+ glyph_color,
ink_rect,
scale,
Orientation::Horizontal,
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs
index 6bbbe15f3ae..3587702f87a 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/mod.rs
@@ -106,10 +106,13 @@ pub(crate) fn paint<O: Observer>(recorder: &mut PaintRecorder<'_, O>, paintable:
}
paint_base(recorder, paintable, phase);
if phase == PaintPhase::Foreground {
- if let Some(data) = paintable_geometry::committed_math_paint_data(recorder.source, paintable) {
- math::paint_foreground(recorder, paintable, &data);
+ let math_paint_data = paintable_geometry::committed_math_paint_data(recorder.source, paintable);
+ if let Some(data) = &math_paint_data {
+ math::paint_foreground(recorder, paintable, data);
}
- if recorder.is_recording_svg_resource_content()
+ if math_paint_data.is_some_and(|data| data.replaces_text) {
+ // NB: The glyph of a stretched or large operator is painted instead of its text.
+ } else if recorder.is_recording_svg_resource_content()
|| recorder
.source
.committed_side_data(paintable)
diff --git a/Tests/LibWeb/Ref/expected/mathml-stretched-operator-text-fill-color-ref.html b/Tests/LibWeb/Ref/expected/mathml-stretched-operator-text-fill-color-ref.html
new file mode 100644
index 00000000000..972f0ddb5a9
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/mathml-stretched-operator-text-fill-color-ref.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<style>
+ @font-face {
+ font-family: stretchy;
+ src: url("../input/wpt-import/fonts/math/stretchy.woff");
+ }
+ math {
+ font-family: stretchy;
+ font-size: 50px;
+ }
+ mo {
+ color: green;
+ }
+</style>
+<math>
+ <mspace height="4em"/>
+ <mo stretchy="true" symmetric="true">&#x295C;</mo>
+</math>
+<script>
+ document.fonts.ready.then(() => document.documentElement.classList.remove("reftest-wait"));
+</script>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/fonts/math/operators.woff b/Tests/LibWeb/Ref/expected/wpt-import/fonts/math/operators.woff
new file mode 100644
index 00000000000..ec4256ffe5c
Binary files /dev/null and b/Tests/LibWeb/Ref/expected/wpt-import/fonts/math/operators.woff differ
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/fonts/math/stretchy.woff b/Tests/LibWeb/Ref/expected/wpt-import/fonts/math/stretchy.woff
new file mode 100644
index 00000000000..ac7d908f6e2
Binary files /dev/null and b/Tests/LibWeb/Ref/expected/wpt-import/fonts/math/stretchy.woff differ
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-2-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-2-ref.html
new file mode 100644
index 00000000000..f1a3c3a0de1
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-2-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 1: mrow</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- mrow whose child is embellished op -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mo stretchy="false">&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-3-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-3-ref.html
new file mode 100644
index 00000000000..ee8474a9fc1
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-3-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 1: mstyle</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- mstyle whose child is embellished op -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mstyle><mo stretchy="false">&#xaf;</mo></mstyle>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-4-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-4-ref.html
new file mode 100644
index 00000000000..d9b33867a4c
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-4-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 1: mpadded</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- mpadded whose child is embellished op -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mpadded><mo stretchy="false">&#xaf;</mo></mpadded>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-1-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-1-ref.html
new file mode 100644
index 00000000000..7c1b2275b60
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-1-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: ignore space-like children</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- first child space-like -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mtext>g</mtext><mo stretchy="false">&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-2-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-2-ref.html
new file mode 100644
index 00000000000..7ee9cfcc12f
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-2-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: ignore space-like children</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- last child space-like -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mo stretchy="false">&#xaf;</mo><mtext>g</mtext></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-3-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-3-ref.html
new file mode 100644
index 00000000000..31b322d6818
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-3-ref.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: ignore space-like children</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- first and last children space-like -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow>
+ <mtext>g</mtext>
+ <mo stretchy="false">&#xaf;</mo>
+ <mtext>h</mtext>
+ </mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-4-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-4-ref.html
new file mode 100644
index 00000000000..601fc1bb546
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-4-ref.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: ignore space-like children</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- many space-like children -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow>
+ <mspace/>
+ <mtext>g</mtext>
+ <mspace/>
+ <mo stretchy="false">&#xaf;</mo>
+ <mspace/>
+ <mspace/>
+ <mtext>h</mtext>
+ </mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-2-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-2-ref.html
new file mode 100644
index 00000000000..15e39a6be9b
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-2-ref.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: maction and mrow-like as space-like children
+ </title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- space-like mrow -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mrow><mspace/></mrow><mo stretchy="false">&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-3-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-3-ref.html
new file mode 100644
index 00000000000..1e4309e28a9
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-3-ref.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: maction and mrow-like as space-like children
+ </title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- space-like mstyle -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow>
+ <mstyle><mspace/></mstyle><mo stretchy="false">&#xaf;</mo>
+ </mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-4-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-4-ref.html
new file mode 100644
index 00000000000..2617f3aa39d
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-4-ref.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: maction and mrow-like as space-like children
+ </title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- space-like mpadded -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow>
+ <mpadded><mspace/></mpadded><mo stretchy="false">&#xaf;</mo>
+ </mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-5-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-5-ref.html
new file mode 100644
index 00000000000..34173e63946
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-5-ref.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: maction and mrow-like as space-like children
+ </title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- space-like mphantom -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow>
+ <mphantom><mspace/></mphantom><mo stretchy="false">&#xaf;</mo>
+ </mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-1-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-1-ref.html
new file mode 100644
index 00000000000..d5b07ee1c9f
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-1-ref.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 4-1: some non-space-like children</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- two embellished operators -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow>
+ <mo stretchy="false">&#xaf;</mo>
+ <mo stretchy="false">&#xaf;</mo>
+ </mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-2-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-2-ref.html
new file mode 100644
index 00000000000..0008d54d419
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-2-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 4-2: some non-space-like children</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- a non-space-like child before-->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mi>g</mi><mo stretchy="false">&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-3-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-3-ref.html
new file mode 100644
index 00000000000..6f3a217cae6
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-3-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 4-3: some non-space-like children</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- a non-space-like child after-->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mo stretchy="false">&#xaf;</mo><mi>g</mi></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-5-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-5-ref.html
new file mode 100644
index 00000000000..bdd4477bcd4
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/embellished-op-5-ref.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 5: vertical stretchy operator</title>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mrow>
+ <mo>|</mo>
+ <mspace height="30px" depth="30px"/>
+ </mrow>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive-ref.html
new file mode 100644
index 00000000000..4496e61736c
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive-ref.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<meta charset="utf-8"/>
+<title>Test case insensitivity of mo boolean attributes (reference)</title>
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+ math {
+ font: 25px/1 Ahem;
+ }
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ mo {
+ font-family: operators;
+ }
+</style>
+<p>
+ <math>
+ <mrow>
+ <mo symmetric="false" stretchy="false">⥯</mo>
+ <mspace height="2em"></mspace>
+ </mrow>
+ </math>
+</p>
+<p>
+ <math>
+ <mrow>
+ <mo symmetric="true" stretchy="true">⥯</mo>
+ <mspace height="1.5em"></mspace>
+ </mrow>
+ </math>
+</p>
+<p>
+ <math displaystyle="true">
+ <mo largeop="false">∑</mo>
+ </math>
+</p>
+<p>
+ <math>
+ <munder>
+ <mo movablelimits="false">∑</mo>
+ <mtext>X</mtext>
+ </munder>
+ </math>
+</p>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-001-ref.html
new file mode 100644
index 00000000000..0c7642a20ac
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-001-ref.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Painting of vertical assembly (reference)</title>
+<style>
+ .container {
+ font-size: 50px;
+ position: absolute;
+ left: 1em;
+ top: 1em;
+ padding: 5px;
+ background: green;
+ width: 4em;
+ height: 8em;
+ }
+</style>
+<body>
+ <p>This test passes if you see a green rectangle and no red.</p>
+ <div class="container">
+ </div>
+</body>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-002-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-002-ref.html
new file mode 100644
index 00000000000..29559f6dd2e
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-002-ref.html
@@ -0,0 +1,147 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+<meta charset="utf-8">
+<title>Painting of a stretchy operator with lspace/rspace (expectation)</title>
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="assert" content="">
+<script src="../../../mathml/support/fonts.js"></script>
+<style>
+ @font-face {
+ font-family: stretchy;
+ src: url("../../../fonts/math/stretchy.woff");
+ }
+ div {
+ margin-bottom: 50px;
+ }
+
+ math {
+ font-size: 25px;
+ line-height: 1;
+ font-family: stretchy, Ahem;
+ color: green;
+ }
+ /* In the reference file, the operator are not visible, so there is no red. */
+ .operator {
+ visibility: hidden;
+ }
+ .frame {
+ position: absolute;
+ box-sizing: border-box;
+ background: green;
+ border: 2px solid green;
+ }
+</style>
+<script>
+ function runTests() {
+ Array.from(document.getElementsByTagName('math')).forEach(math => {
+ const pxPerEm = 25;
+ let isRTL = math.getAttribute("dir") === "rtl";
+ let lspace = pxPerEm * 3;
+ let rspace = pxPerEm * 5;
+ let expectedOperatorLeft = math.getBoundingClientRect().left +
+ (isRTL ? 3 * pxPerEm + rspace : 2 * pxPerEm + lspace);
+ let expectedOperatorWidth = pxPerEm;
+ let actualOperatorBox =
+ math.querySelector(".operator").getBoundingClientRect();
+ let div = document.createElement("div");
+ div.className = 'frame';
+ div.style.left = `${expectedOperatorLeft-1}px`;
+ div.style.top = `${actualOperatorBox.top-1}px`;
+ div.style.width = `${expectedOperatorWidth+2}px`;
+ div.style.height = `${actualOperatorBox.height+2}px`;
+ document.body.appendChild(div);
+ });
+ document.documentElement.classList.remove("reftest-wait");
+ }
+ window.addEventListener("load", () => { loadAllFonts().then(runTests); });
+</script>
+<p>This test passes if you see green boxes and no red.</p>
+<div>
+ <!-- Child of math. -->
+ <math>
+ <mn>22</mn>
+ <mo class="operator" lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ <mn>333</mn>
+ </math>
+</div>
+<div>
+ <!-- Child of mrow. -->
+ <math>
+ <mrow>
+ <mn>22</mn>
+ <mo class="operator" lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ <mn>333</mn>
+ </mrow>
+ </math>
+</div>
+<div>
+ <!-- Child of math, embellished operator. -->
+ <math>
+ <mn>22</mn>
+ <mrow class="operator">
+ <mo lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ </mrow>
+ <mn>333</mn>
+ </math>
+</div>
+<div>
+ <!-- Child of mrow, embellished operator. -->
+ <math>
+ <mrow>
+ <mn>22</mn>
+ <mrow class="operator">
+ <mo lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ </mrow>
+ <mn>333</mn>
+ </mrow>
+ </math>
+</div>
+<div>
+ <!-- Child of math, RTL. -->
+ <math dir="rtl">
+ <mn>22</mn>
+ <mo class="operator" lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ <mn>333</mn>
+ </math>
+</div>
+<div>
+ <!-- Child of mrow, RTL. -->
+ <math dir="rtl">
+ <mrow>
+ <mn>22</mn>
+ <mo class="operator" lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ <mn>333</mn>
+ </mrow>
+ </math>
+</div>
+<div>
+ <!-- Child of math, embellished operator, RTL. -->
+ <math dir="rtl">
+ <mn>22</mn>
+ <mrow class="operator">
+ <mo lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ </mrow>
+ <mn>333</mn>
+ </math>
+</div>
+<div>
+ <!-- Child of mrow, embellished operator, RTL. -->
+ <math dir="rtl">
+ <mrow>
+ <mn>22</mn>
+ <mrow class="operator">
+ <mo lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ </mrow>
+ <mn>333</mn>
+ </mrow>
+ </math>
+</div>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1-ref.html
new file mode 100644
index 00000000000..65b407bdede
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1-ref.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy mover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ #container {
+ width: 800px;
+ height: 600px;
+ overflow: hidden;
+ background: lightblue;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="container">
+ <math display=block>
+ <mover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mn>BBBBBBBBB</mn>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-2-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-2-ref.html
new file mode 100644
index 00000000000..ba63fb14ebd
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-2-ref.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy mover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math display=block>
+ <mrow>
+ <mrow>
+ <mover>
+ <mo stretchy="false">&#x2191;</mo>
+ <mn>B</mn>
+ </mover>
+ </mrow>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1-ref.html
new file mode 100644
index 00000000000..082c5019caa
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1-ref.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Non-stretchy msup</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math >
+ <msup>
+ <mo stretchy="false">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ </msup>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1-ref.html
new file mode 100644
index 00000000000..58782abd324
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+</head>
+ <body>
+ <math >
+ <mrow>
+ <munderover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2-ref.html
new file mode 100644
index 00000000000..8f39ecfee75
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2-ref.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math >
+ <mrow>
+ <msup>
+ <munderover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ <mtext>CCCCCC</mtext>
+ </msup>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3-ref.html
new file mode 100644
index 00000000000..eb09884a8ec
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <mrow>
+ <munderover>
+ <mtext>AAAAAA</mtext>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-001-ref.html
new file mode 100644
index 00000000000..61a7d5fd845
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-001-ref.html
@@ -0,0 +1,167 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8"/>
+<title>Horizontal stretchy operator (reference)</title>
+<style>
+ @font-face {
+ font-family: TestFont;
+ src: url("../../../fonts/math/stretchy.woff");
+ }
+ math, mo {
+ font-family: TestFont;
+ font-size: 50px;
+ }
+</style>
+<body>
+ <p>This test passes if you see green rectangles and no red.</p>
+
+ <div style="position: absolute; left: 3em; top; 3em;
+ width: 1000px; height: 500px; background: lightgreen;">
+
+ <div style="position: absolute; top: 1px; left: 1px;">
+ <!-- stretchy base in munder -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ </munder>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 251px;">
+ <!-- stretchy script in munder -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munder>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 101px; left: 1px;">
+ <!-- stretchy base in mover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ </mover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 101px; left: 251px;">
+ <!-- stretchy script in mover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </mover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 201px; left: 1px;">
+ <!-- stretchy base in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 201px; left: 251px;">
+ <!-- stretchy underscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 301px; left: 1px;">
+ <!-- stretchy overscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 501px;">
+ <!-- stretchy base and underscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 151px; left: 501px;">
+ <!-- stretchy base and overscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 301px; left: 501px;">
+ <!-- stretchy scripts in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 751px;">
+ <!-- Only stretchy operators in munderover. The widest unstretched size
+ is used as the target size. -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="font-size: 1em; color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="font-size: 4em; color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="font-size: 2em; color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+ </div>
+ <script>
+ MathMLFeatureDetection.ensure_for_match_reftest("has_mspace");
+ MathMLFeatureDetection.ensure_for_match_reftest("has_munderover");
+ </script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-003-ref.html
new file mode 100644
index 00000000000..351180fa6d7
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-003-ref.html
@@ -0,0 +1,167 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8"/>
+<title>Horizontal stretchy operator, embellished with an munderover (reference)</title>
+<style>
+ @font-face {
+ font-family: TestFont;
+ src: url("../../../fonts/math/stretchy.woff");
+ }
+ math, mo {
+ font-family: TestFont;
+ font-size: 50px;
+ }
+</style>
+<body>
+ <p>This test passes if you see green rectangles and no red.</p>
+
+ <div style="position: absolute; left: 3em; top; 3em;
+ width: 1000px; height: 500px; background: lightgreen;">
+
+ <div style="position: absolute; top: 1px; left: 1px;">
+ <!-- stretchy base in munder -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ </munder>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 251px;">
+ <!-- stretchy script in munder -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munder>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 101px; left: 1px;">
+ <!-- stretchy base in mover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ </mover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 101px; left: 251px;">
+ <!-- stretchy script in mover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </mover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 201px; left: 1px;">
+ <!-- stretchy base in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 201px; left: 251px;">
+ <!-- stretchy underscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 301px; left: 1px;">
+ <!-- stretchy overscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 501px;">
+ <!-- stretchy base and underscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 151px; left: 501px;">
+ <!-- stretchy base and overscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 301px; left: 501px;">
+ <!-- stretchy scripts in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 751px;">
+ <!-- Only stretchy operators in munderover. The widest unstretched size
+ is used as the target size. -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="font-size: 1em; color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="font-size: 4em; color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="font-size: 2em; color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+ </div>
+ <script>
+ MathMLFeatureDetection.ensure_for_match_reftest("has_mspace");
+ MathMLFeatureDetection.ensure_for_match_reftest("has_munderover");
+ </script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/mathml/support/fonts.js b/Tests/LibWeb/Ref/expected/wpt-import/mathml/support/fonts.js
new file mode 100644
index 00000000000..f05d7278adb
--- /dev/null
+++ b/Tests/LibWeb/Ref/expected/wpt-import/mathml/support/fonts.js
@@ -0,0 +1,9 @@
+function loadAllFonts() {
+ // Use this to wait for all fonts in a testcase to load rather than just using
+ // `document.fonts.ready.then(...)` in the load event, since there are compat
+ // issues between browsers as to whether content initiated font loads are
+ // guaranteed to have been started by this point.
+
+ // FIXME: Use Promise.all() to cause an obvious failure when a font fails to load.
+ return Promise.allSettled([...document.fonts].map(f => f.load()));
+}
diff --git a/Tests/LibWeb/Ref/input/mathml-stretched-operator-text-fill-color.html b/Tests/LibWeb/Ref/input/mathml-stretched-operator-text-fill-color.html
new file mode 100644
index 00000000000..1a7ac19fdf3
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/mathml-stretched-operator-text-fill-color.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<link rel="match" href="../expected/mathml-stretched-operator-text-fill-color-ref.html">
+<style>
+ @font-face {
+ font-family: stretchy;
+ src: url("wpt-import/fonts/math/stretchy.woff");
+ }
+ math {
+ font-family: stretchy;
+ font-size: 50px;
+ }
+ mo {
+ color: red;
+ -webkit-text-fill-color: green;
+ }
+</style>
+<math>
+ <mspace height="4em"/>
+ <mo stretchy="true" symmetric="true">&#x295C;</mo>
+</math>
+<script>
+ document.fonts.ready.then(() => document.documentElement.classList.remove("reftest-wait"));
+</script>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/fonts/math/operators.woff b/Tests/LibWeb/Ref/input/wpt-import/fonts/math/operators.woff
new file mode 100644
index 00000000000..ec4256ffe5c
Binary files /dev/null and b/Tests/LibWeb/Ref/input/wpt-import/fonts/math/operators.woff differ
diff --git a/Tests/LibWeb/Ref/input/wpt-import/fonts/math/stretchy-centered-on-baseline.woff b/Tests/LibWeb/Ref/input/wpt-import/fonts/math/stretchy-centered-on-baseline.woff
new file mode 100644
index 00000000000..fd753edf761
Binary files /dev/null and b/Tests/LibWeb/Ref/input/wpt-import/fonts/math/stretchy-centered-on-baseline.woff differ
diff --git a/Tests/LibWeb/Ref/input/wpt-import/fonts/math/stretchy.woff b/Tests/LibWeb/Ref/input/wpt-import/fonts/math/stretchy.woff
new file mode 100644
index 00000000000..ac7d908f6e2
Binary files /dev/null and b/Tests/LibWeb/Ref/input/wpt-import/fonts/math/stretchy.woff differ
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-1-2.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-1-2.html
new file mode 100644
index 00000000000..2f2e84d4407
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-1-2.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 1: mrow</title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- mrow whose child is embellished op -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mo>&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-1-3.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-1-3.html
new file mode 100644
index 00000000000..3955f4099ba
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-1-3.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 1: mstyle</title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-3-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- mstyle whose child is embellished op -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mstyle><mo>&#xaf;</mo></mstyle>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-1-4.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-1-4.html
new file mode 100644
index 00000000000..6c9fba366da
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-1-4.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 1: mpadded</title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-1-4-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- mpadded whose child is embellished op -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mpadded><mo>&#xaf;</mo></mpadded>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-1.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-1.html
new file mode 100644
index 00000000000..f50b451eed0
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-1.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: ignore space-like children</title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- first child space-like -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mtext>g</mtext><mo>&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-2.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-2.html
new file mode 100644
index 00000000000..4d018fedb75
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-2.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: ignore space-like children</title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- last child space-like -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mo>&#xaf;</mo><mtext>g</mtext></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-3.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-3.html
new file mode 100644
index 00000000000..c73b2a9c7c1
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-3.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: ignore space-like children</title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-3-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- first and last children space-like -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mtext>g</mtext><mo>&#xaf;</mo><mtext>h</mtext></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-4.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-4.html
new file mode 100644
index 00000000000..73bcfade98a
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-2-4.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: ignore space-like children</title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-2-4-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- many space-like children -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow>
+ <mspace/>
+ <mtext>g</mtext>
+ <mspace/>
+ <mo>&#xaf;</mo>
+ <mspace/>
+ <mspace/>
+ <mtext>h</mtext>
+ </mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-2.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-2.html
new file mode 100644
index 00000000000..be065d24958
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-2.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: maction and mrow-like as space-like children
+ </title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- space-like mrow -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mrow><mspace/></mrow><mo>&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-3.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-3.html
new file mode 100644
index 00000000000..31895f591e5
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-3.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: maction and mrow-like as space-like children
+ </title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-3-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- space-like mstyle -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mstyle><mspace/></mstyle><mo>&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-4.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-4.html
new file mode 100644
index 00000000000..e89a9ef1718
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-4.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: maction and mrow-like as space-like children
+ </title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-4-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- space-like mpadded -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow>
+ <mpadded><mspace/></mpadded><mo>&#xaf;</mo>
+ </mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-5.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-5.html
new file mode 100644
index 00000000000..be40f7a48e0
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-3-5.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators: maction and mrow-like as space-like children
+ </title>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-3-5-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- space-like mphantom -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mphantom><mspace/></mphantom><mo>&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-4-1.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-4-1.html
new file mode 100644
index 00000000000..740f1bf4e6b
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-4-1.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="fuzzy" content="maxDifference=0-255; totalPixels=0-108" />
+ <title>embellished operators 4-1: some non-space-like children</title>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- two embellished operators -->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mo>&#xaf;</mo><mo>&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-4-2.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-4-2.html
new file mode 100644
index 00000000000..aa51d0fff0f
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-4-2.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="fuzzy" content="maxDifference=0-255; totalPixels=0-57" />
+ <title>embellished operators 4-2: some non-space-like children</title>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- a non-space-like child before-->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mi>g</mi><mo>&#xaf;</mo></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-4-3.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-4-3.html
new file mode 100644
index 00000000000..62125909cea
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-4-3.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="fuzzy" content="maxDifference=0-255; totalPixels=0-57" />
+ <title>embellished operators 4-3: some non-space-like children</title>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-4-3-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <!-- a non-space-like child after-->
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mover>
+ <mtext>abcdef</mtext>
+ <mrow><mo>&#xaf;</mo><mi>g</mi></mrow>
+ </mover>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-5-1.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-5-1.html
new file mode 100644
index 00000000000..ae81d84d105
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-5-1.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 5: vertical stretchy operator</title>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-5-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mrow>
+ <mrow>
+ <msub>
+ <mo>|</mo>
+ <mspace/>
+ </msub>
+ </mrow>
+ <mspace height="30px" depth="30px"/>
+ </mrow>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-5-2.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-5-2.html
new file mode 100644
index 00000000000..f341d3f0f9f
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/embellished-op-5-2.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>embellished operators 5: vertical stretchy operator</title>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/embellished-op-5-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=21479"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div>
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
+ <mrow>
+ <msub>
+ <mo>|</mo>
+ <mspace/>
+ </msub>
+ <mspace height="30px" depth="30px"/>
+ </mrow>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive.html
new file mode 100644
index 00000000000..caa72576120
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<meta charset="utf-8"/>
+<title>Test case insensitivity of mo boolean attributes</title>
+<link rel="help" href="https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo">
+<link rel="help" href="https://w3c.github.io/mathml-core/#dom-and-javascript">
+<meta name="assert" content="Verifies case insensitivity of mo boolean attributes.">
+<link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/mo-boolean-attributes-case-insensitive-ref.html">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<style>
+ math {
+ font: 25px/1 Ahem;
+ }
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ mo {
+ font-family: operators;
+ }
+</style>
+<p>
+ <math>
+ <mrow>
+ <mo symmetric="false" stretchy="FaLsE">⥯</mo>
+ <mspace height="2em"></mspace>
+ </mrow>
+ </math>
+</p>
+<p>
+ <math>
+ <mrow>
+ <mo symmetric="TrUe" stretchy="true">⥯</mo>
+ <mspace height="1.5em"></mspace>
+ </mrow>
+ </math>
+</p>
+<p>
+ <math displaystyle="true">
+ <mo largeop="FALSe">∑</mo>
+ </math>
+</p>
+<p>
+ <math>
+ <munder>
+ <mo movablelimits="fALse">∑</mo>
+ <mtext>X</mtext>
+ </munder>
+ </math>
+</p>
+<script src="../../../mathml/support/feature-detection.js"></script>
+<script>MathMLFeatureDetection.ensure_for_match_reftest("has_munderover");</script>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-001.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-001.html
new file mode 100644
index 00000000000..f462196fa7d
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-001.html
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+<meta charset="utf-8">
+<title>Painting of vertical assembly</title>
+<link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-001-ref.html">
+<link rel="help" href="https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo">
+<link rel="help" href="https://crbug.com/1409380">
+<meta name="assert" content="Verify that vertical glyph assemblies are painted at the position of their bounding box.">
+<script src="../../../mathml/support/fonts.js"></script>
+<style>
+ .container {
+ font-size: 50px;
+ position: absolute;
+ left: 1em;
+ top: 1em;
+ padding: 5px;
+ background: green;
+ width: 4em;
+ height: 8em;
+ }
+ mo {
+ color: green;
+ background: red;
+ }
+ .frame {
+ position: absolute;
+ box-sizing: border-box;
+ border: 2px solid green;
+ }
+ @font-face {
+ font-family: stretchy;
+ src: url("../../../fonts/math/stretchy.woff");
+ }
+ @font-face {
+ font-family: stretchy-centered-on-baseline;
+ src: url("../../../fonts/math/stretchy-centered-on-baseline.woff");
+ }
+</style>
+<script>
+ function runTests() {
+ // Add a green frame around mo to avoid antialisasing/rounding issues.
+ Array.from(document.getElementsByTagName('mo')).forEach(mo => {
+ let box = mo.getBoundingClientRect();
+ let div = document.createElement("div");
+ div.className = 'frame';
+ div.style.left = `${box.left-1}px`;
+ div.style.top = `${box.top-1}px`;
+ div.style.width = `${box.width+1}px`;
+ div.style.height = `${box.height+1}px`;
+ document.body.appendChild(div);
+ });
+ document.documentElement.classList.remove("reftest-wait");
+ }
+ window.addEventListener("load", () => { loadAllFonts().then(runTests); });
+</script>
+<body>
+ <p>This test passes if you see a green rectangle and no red.</p>
+ <div class="container">
+ <!-- This font uses assembly glyphs with zero ink descent, which is what
+ Latin Modern Math does for U+007C VERTICAL LINE. -->
+ <math style="font-family: stretchy">
+ <mspace height="4em"/>
+ <mo stretchy="true" symmetric="true">&#x295C;</mo>
+ </math>
+ <!-- This font uses assembly glyphs with non-zero ink descent, which is what
+ Cambria Math does for U+007C VERTICAL LINE. -->
+ <math style="font-family: stretchy-centered-on-baseline">
+ <mspace height="4em"/>
+ <mo stretchy="true" symmetric="true">&#x295C;</mo>
+ </math>
+ </div>
+</body>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-002.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-002.html
new file mode 100644
index 00000000000..06551eaf016
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-002.html
@@ -0,0 +1,158 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+<meta charset="utf-8">
+<title>Painting of a stretchy operator with lspace/rspace</title>
+<link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/operators/painting-stretchy-operator-002-ref.html">
+<link rel="help" href="https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo">
+<link rel="stylesheet" type="text/css" href="../../../fonts/ahem.css" />
+<meta name="assert" content="">
+<script src="../../../mathml/support/fonts.js"></script>
+<style>
+ @font-face {
+ font-family: stretchy;
+ src: url("../../../fonts/math/stretchy.woff");
+ }
+ div {
+ margin-bottom: 50px;
+ }
+
+ math {
+ font-size: 25px;
+ line-height: 1;
+ font-family: stretchy, Ahem;
+ color: green;
+ }
+ .operator {
+ color: red;
+ }
+ .frame {
+ position: absolute;
+ box-sizing: border-box;
+ background: green;
+ border: 2px solid green;
+ }
+</style>
+<script>
+ function runTests() {
+ Array.from(document.getElementsByTagName('math')).forEach(math => {
+ // Each math renders as a 2x1 green rectangle for <mn>22</mn>, a red
+ // rectangle for the vertical stretchy <mo> operator (with lspace=3em and
+ // rspace=5em spacing around it) and a 3x1 green rectangle for
+ // <mn>333</mn>. We try and cover the operator with a green rectangle at
+ // the expected horizontal offset. The reftest fails if the stretchy
+ // operator is painted somewhere else.
+ const pxPerEm = 25;
+ let isRTL = math.getAttribute("dir") === "rtl";
+ let lspace = pxPerEm * 3;
+ let rspace = pxPerEm * 5;
+ let expectedOperatorLeft = math.getBoundingClientRect().left +
+ (isRTL ? 3 * pxPerEm + rspace : 2 * pxPerEm + lspace);
+ let expectedOperatorWidth = pxPerEm;
+ let actualOperatorBox =
+ math.querySelector(".operator").getBoundingClientRect();
+ let div = document.createElement("div");
+ div.className = 'frame';
+ div.style.left = `${expectedOperatorLeft-1}px`;
+ div.style.top = `${actualOperatorBox.top-1}px`;
+ div.style.width = `${expectedOperatorWidth+2}px`;
+ div.style.height = `${actualOperatorBox.height+2}px`;
+ document.body.appendChild(div);
+ });
+ document.documentElement.classList.remove("reftest-wait");
+ }
+ window.addEventListener("load", () => { loadAllFonts().then(runTests); });
+</script>
+<p>This test passes if you see green boxes and no red.</p>
+<div>
+ <!-- Child of math. -->
+ <math>
+ <mn>22</mn>
+ <mo class="operator" lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ <mn>333</mn>
+ </math>
+</div>
+<div>
+ <!-- Child of mrow. -->
+ <math>
+ <mrow>
+ <mn>22</mn>
+ <mo class="operator" lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ <mn>333</mn>
+ </mrow>
+ </math>
+</div>
+<div>
+ <!-- Child of math, embellished operator. -->
+ <math>
+ <mn>22</mn>
+ <mrow class="operator">
+ <mo lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ </mrow>
+ <mn>333</mn>
+ </math>
+</div>
+<div>
+ <!-- Child of mrow, embellished operator. -->
+ <math>
+ <mrow>
+ <mn>22</mn>
+ <mrow class="operator">
+ <mo lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ </mrow>
+ <mn>333</mn>
+ </mrow>
+ </math>
+</div>
+<div>
+ <!-- Child of math, RTL. -->
+ <math dir="rtl">
+ <mn>22</mn>
+ <mo class="operator" lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ <mn>333</mn>
+ </math>
+</div>
+<div>
+ <!-- Child of mrow, RTL. -->
+ <math dir="rtl">
+ <mrow>
+ <mn>22</mn>
+ <mo class="operator" lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ <mn>333</mn>
+ </mrow>
+ </math>
+</div>
+<div>
+ <!-- Child of math, embellished operator, RTL. -->
+ <math dir="rtl">
+ <mn>22</mn>
+ <mrow class="operator">
+ <mo lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ </mrow>
+ <mn>333</mn>
+ </math>
+</div>
+<div>
+ <!-- Child of mrow, embellished operator, RTL. -->
+ <math dir="rtl">
+ <mrow>
+ <mn>22</mn>
+ <mrow class="operator">
+ <mo lspace="3em" rspace="5em"
+ stretchy="true" minsize="2em" symmetric="true">&#x295C;</mo>
+ </mrow>
+ <mn>333</mn>
+ </mrow>
+ </math>
+</div>
+<script src="../../../mathml/support/feature-detection.js"></script>
+<script>
+ MathMLFeatureDetection.ensure_for_match_reftest("has_operator_spacing");
+</script>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1a.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1a.html
new file mode 100644
index 00000000000..aa09ca80611
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1a.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy mover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ #container {
+ width: 800px;
+ height: 600px;
+ overflow: hidden;
+ background: lightblue;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="container">
+ <math display=block>
+ <mrow>
+ <mspace width="10em"/>
+ <mrow>
+ <mover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mn>BBBBBBBBB</mn>
+ </mover>
+ </mrow>
+ <mspace width="10em"/>
+ </mrow>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1b.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1b.html
new file mode 100644
index 00000000000..a5433b16fef
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1b.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy mover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ #container {
+ width: 800px;
+ height: 600px;
+ overflow: hidden;
+ background: lightblue;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="container">
+ <math display=block>
+ <mrow>
+ <mspace depth="50em"/>
+ <mrow>
+ <mover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mn>BBBBBBBBB</mn>
+ </mover>
+ </mrow>
+ <mspace depth="50em"/>
+ </mrow>
+ </math>
+ </div>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-2b.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-2b.html
new file mode 100644
index 00000000000..822a28410e7
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-2b.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy mover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-mover-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math display=block>
+ <mrow>
+ <mspace depth="5em"/>
+ <mrow>
+ <mover>
+ <mo stretchy="true">&#x2191;</mo>
+ <mn>B</mn>
+ </mover>
+ </mrow>
+ <mspace depth="5em"/>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1a.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1a.html
new file mode 100644
index 00000000000..a9cc0160496
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1a.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Non-stretchy msup</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math >
+ <msup>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ </msup>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1b.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1b.html
new file mode 100644
index 00000000000..e7653f2347e
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1b.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Non-stretchy msup</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math >
+ <mrow>
+ <msup>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ </msup>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1c.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1c.html
new file mode 100644
index 00000000000..bb728932b54
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1c.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Non-stretchy msup</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math >
+ <mrow>
+ <mrow>
+ <msup>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ </msup>
+ </mrow>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1d.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1d.html
new file mode 100644
index 00000000000..6da1a714a34
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1d.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Non-stretchy msup</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-msup-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math >
+ <mrow>
+ <msup>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ </msup>
+ <mspace width="5em" />
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1a.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1a.html
new file mode 100644
index 00000000000..00a296401e5
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1a.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <mrow>
+ <munderover>
+ <mo stretchy="false">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1b.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1b.html
new file mode 100644
index 00000000000..d1db81d34b7
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1b.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <mrow>
+ <mrow>
+ <munderover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ </mrow>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1c.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1c.html
new file mode 100644
index 00000000000..30b4a919c06
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1c.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <munderover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1d.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1d.html
new file mode 100644
index 00000000000..7029aa5b4a3
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1d.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-1-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <mrow>
+ <munderover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ <mspace width="5em" />
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2a.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2a.html
new file mode 100644
index 00000000000..4008ed74967
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2a.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <mrow>
+ <msup>
+ <munderover>
+ <mo stretchy="false">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ <mtext>CCCCCC</mtext>
+ </msup>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2b.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2b.html
new file mode 100644
index 00000000000..d8589372b75
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2b.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <mrow>
+ <mrow>
+ <msup>
+ <munderover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ <mtext>CCCCCC</mtext>
+ </msup>
+ </mrow>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2c.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2c.html
new file mode 100644
index 00000000000..6f79f3c1213
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2c.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <msup>
+ <munderover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ <mtext>CCCCCC</mtext>
+ </msup>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2d.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2d.html
new file mode 100644
index 00000000000..7f8356fdf57
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2d.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <mrow>
+ <msup>
+ <munderover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ <mtext>CCCCCC</mtext>
+ </msup>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2e.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2e.html
new file mode 100644
index 00000000000..89b8e38aa7e
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2e.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <msup>
+ <mrow>
+ <munderover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ </mrow>
+ <mtext>CCCCCC</mtext>
+ </msup>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2f.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2f.html
new file mode 100644
index 00000000000..a6cf5319387
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2f.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-2-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <msup>
+ <mrow>
+ <mrow>
+ <munderover>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>AAAAAA</mtext>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ </mrow>
+ </mrow>
+ <mtext>CCCCCC</mtext>
+ </msup>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3a.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3a.html
new file mode 100644
index 00000000000..21028dd5f86
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3a.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <mrow>
+ <munderover>
+ <mtext>AAAAAA</mtext>
+ <mo stretchy="false">&#x2192;</mo>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3b.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3b.html
new file mode 100644
index 00000000000..19a9064640c
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3b.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <munderover>
+ <mtext>AAAAAA</mtext>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3c.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3c.html
new file mode 100644
index 00000000000..c39033b9c20
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3c.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <mrow>
+ <munderover>
+ <mtext>AAAAAA</mtext>
+ <mo stretchy="true">&#x2192;</mo>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ <mspace width="5em" />
+ </mrow>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3d.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3d.html
new file mode 100644
index 00000000000..116656e5f12
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3d.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Stretchy munderover</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <link rel="mismatch" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/stretchy-munderover-3-ref.html"/>
+ <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=687807"/>
+ <link rel="stylesheet" href="../../../fonts/ahem.css" />
+ <style>
+ @font-face {
+ font-family: operators;
+ src: url("../../../fonts/math/operators.woff");
+ }
+ math {
+ font: 25px/1 Ahem;
+ }
+ mo {
+ font-family: operators;
+ }
+ </style>
+ </head>
+ <body>
+ <math>
+ <munderover>
+ <mtext>AAAAAA</mtext>
+ <mo stretchy="false">&#x2192;</mo>
+ <mtext>BBBBBB</mtext>
+ </munderover>
+ </math>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-001.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-001.html
new file mode 100644
index 00000000000..0d13851b8e1
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-001.html
@@ -0,0 +1,270 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8"/>
+<title>Horizontal stretchy operator</title>
+<link rel="help" href="https://w3c.github.io/mathml-core/#layout-algorithms">
+<link rel="help" href="https://w3c.github.io/mathml-core/#algorithm-for-stretching-operators-along-the-inline-axis">
+<link rel="help" href="https://w3c.github.io/mathml-core/#layout-of-operators">
+<link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-001-ref.html"/>
+<meta name="assert" content="Verify visual rendering of padding/border/margin on an operator, stretchy along the inline axis.">
+<script src="../../../mathml/support/feature-detection.js"></script>
+<style>
+ @font-face {
+ font-family: TestFont;
+ src: url("../../../fonts/math/stretchy.woff");
+ }
+ math, mo {
+ font-family: TestFont;
+ font-size: 50px;
+ }
+</style>
+<body>
+ <p>This test passes if you see green rectangles and no red.</p>
+ <!-- The red mspace elements below are expected to be covered by the green
+ stretchy mo elements. -->
+
+ <div style="position: absolute; left: 3em; top; 3em;
+ width: 1000px; height: 500px; background: lightgreen;">
+
+ <div style="position: absolute; top: 1px; left: 1px;">
+ <!-- stretchy base in munder -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ </munder>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ </munder>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 251px;">
+ <!-- stretchy script in munder -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </munder>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munder>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 101px; left: 1px;">
+ <!-- stretchy base in mover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ </mover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ </mover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 101px; left: 251px;">
+ <!-- stretchy script in mover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </mover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </mover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 201px; left: 1px;">
+ <!-- stretchy base in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 201px; left: 251px;">
+ <!-- stretchy underscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 301px; left: 1px;">
+ <!-- stretchy overscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 501px;">
+ <!-- stretchy base and underscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 151px; left: 501px;">
+ <!-- stretchy base and overscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 301px; left: 501px;">
+ <!-- stretchy scripts in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 751px;">
+ <!-- Only stretchy operators in munderover. The widest unstretched size
+ is used as the target size. -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="198px" height="198px" style="background: red; margin: 1px;"/>
+ <mspace width="198px" height="98px" style="background: red; margin: 1px;"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="font-size: 1em; color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="font-size: 4em; color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="font-size: 2em; color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+ </div>
+ <script>
+ MathMLFeatureDetection.ensure_for_match_reftest("has_mspace");
+ MathMLFeatureDetection.ensure_for_match_reftest("has_munderover");
+ </script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-003.html b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-003.html
new file mode 100644
index 00000000000..d8cc9cb298c
--- /dev/null
+++ b/Tests/LibWeb/Ref/input/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-003.html
@@ -0,0 +1,272 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8"/>
+<title>Horizontal stretchy operator, embellished with an munderover</title>
+<link rel="help" href="https://w3c.github.io/mathml-core/#layout-algorithms">
+<link rel="help" href="https://w3c.github.io/mathml-core/#algorithm-for-stretching-operators-along-the-inline-axis">
+<link rel="help" href="https://w3c.github.io/mathml-core/#algorithm-for-stretching-operators-along-the-block-axis">
+<link rel="help" href="https://w3c.github.io/mathml-core/#embellished-operators">
+<link rel="help" href="https://w3c.github.io/mathml-core/#layout-of-operators">
+<link rel="match" href="../../../../../expected/wpt-import/mathml/presentation-markup/scripts/underover-stretchy-003-ref.html"/>
+<meta name="assert" content="Verify visual rendering of padding/border/margin on an embellished operator, stretchy along the inline axis.">
+<script src="../../../mathml/support/feature-detection.js"></script>
+<style>
+ @font-face {
+ font-family: TestFont;
+ src: url("../../../fonts/math/stretchy.woff");
+ }
+ math, mo {
+ font-family: TestFont;
+ font-size: 50px;
+ }
+</style>
+<body>
+ <p>This test passes if you see green rectangles and no red.</p>
+ <!-- The red mspace elements below are expected to be covered by the green
+ stretchy mo elements. -->
+
+ <div style="position: absolute; left: 3em; top; 3em;
+ width: 1000px; height: 500px; background: lightgreen;">
+
+ <div style="position: absolute; top: 1px; left: 1px;">
+ <!-- stretchy base in munder -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ </munder>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ <mspace width="200px" height="0px"/>
+ </munder>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 251px;">
+ <!-- stretchy script in munder -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </munder>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munder>
+ <mspace width="200px" height="0px"/>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ </munder>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 101px; left: 1px;">
+ <!-- stretchy base in mover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ </mover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ <mspace width="200px" height="0px"/>
+ </mover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 101px; left: 251px;">
+ <!-- stretchy script in mover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </mover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <mover>
+ <mspace width="200px" height="0px"/>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ </mover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 201px; left: 1px;">
+ <!-- stretchy base in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 201px; left: 251px;">
+ <!-- stretchy underscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ <mspace width="200px" height="0px"/>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 301px; left: 1px;">
+ <!-- stretchy overscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="200px" height="0px"/>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 501px;">
+ <!-- stretchy base and underscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ <mspace width="200px" height="0px"/>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 151px; left: 501px;">
+ <!-- stretchy base and overscript in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ <mspace width="200px" height="0px"/>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 301px; left: 501px;">
+ <!-- stretchy scripts in munderover -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="200px" height="0px"/>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ <munderover><mo lspace="0" rspace="0" style="color: green;">⥚</mo><mspace/><mspace/></munderover>
+ </munderover>
+ </math>
+ </div>
+ </div>
+
+ <div style="position: absolute; top: 1px; left: 751px;">
+ <!-- Only stretchy operators in munderover. The widest unstretched size
+ is used as the target size. -->
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mspace width="198px" height="48px" style="background: red; margin: 1px;"/>
+ <mspace width="198px" height="198px" style="background: red; margin: 1px;"/>
+ <mspace width="198px" height="98px" style="background: red; margin: 1px;"/>
+ </munderover>
+ </math>
+ </div>
+ <div style="position: absolute; left: 0; top: 0;">
+ <math>
+ <munderover>
+ <mo lspace="0" rspace="0" style="font-size: 1em; color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="font-size: 4em; color: green;">⥚</mo>
+ <mo lspace="0" rspace="0" style="font-size: 2em; color: green;">⥚</mo>
+ </munderover>
+ </math>
+ </div>
+ </div>
+ </div>
+ <script>
+ MathMLFeatureDetection.ensure_for_match_reftest("has_mspace");
+ MathMLFeatureDetection.ensure_for_match_reftest("has_munderover");
+ </script>
+</body>
+</html>
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/mrow/inferred-mrow-stretchy.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/mrow/inferred-mrow-stretchy.txt
index fd3cedc1eff..a5f68f9e262 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/mrow/inferred-mrow-stretchy.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/mrow/inferred-mrow-stretchy.txt
@@ -2,18 +2,19 @@ Harness status: OK
Found 14 tests
-14 Fail
-Fail operator stretching inside Mrow
-Fail operator stretching inside Sqrt
-Fail operator stretching inside Style
-Fail operator stretching inside Error
-Fail operator stretching inside Phantom
-Fail operator stretching inside Math
-Fail operator stretching inside Menclose
-Fail operator stretching inside Mpadded
-Fail operator stretching inside Unknown
+13 Pass
+1 Fail
+Pass operator stretching inside Mrow
+Pass operator stretching inside Sqrt
+Pass operator stretching inside Style
+Pass operator stretching inside Error
+Pass operator stretching inside Phantom
+Pass operator stretching inside Math
+Pass operator stretching inside Menclose
+Pass operator stretching inside Mpadded
+Pass operator stretching inside Unknown
Fail operator stretching inside Mtd
-Fail operator stretching inside None
-Fail operator stretching inside Mprescripts
-Fail operator stretching inside Mfenced
-Fail operator stretching inside A
\ No newline at end of file
+Pass operator stretching inside None
+Pass operator stretching inside Mprescripts
+Pass operator stretching inside Mfenced
+Pass operator stretching inside A
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/mrow/stretch-along-block-axis-001.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/mrow/stretch-along-block-axis-001.txt
index 5ac4d0144ba..c1627684ad6 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/mrow/stretch-along-block-axis-001.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/mrow/stretch-along-block-axis-001.txt
@@ -2,10 +2,9 @@ Harness status: OK
Found 5 tests
-1 Pass
-4 Fail
-Fail Taking into account stretch axis.
+5 Pass
+Pass Taking into account stretch axis.
Pass Taking into account stretchy property.
-Fail Only operators with a stretchy property and block stretch axis.
-Fail Operators smaller and larger than non-stretchy siblings.
-Fail Embellished operators
\ No newline at end of file
+Pass Only operators with a stretchy property and block stretch axis.
+Pass Operators smaller and larger than non-stretchy siblings.
+Pass Embellished operators
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/display-operator-min-height-no-workaround.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/display-operator-min-height-no-workaround.txt
index ad3401ff1c6..918509660ab 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/display-operator-min-height-no-workaround.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/display-operator-min-height-no-workaround.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail DisplayOperatorMinHeight is not modified
\ No newline at end of file
+1 Pass
+Pass DisplayOperatorMinHeight is not modified
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/embellished-operator-004.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/embellished-operator-004.txt
index 509e0b301f9..b21d1168e8f 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/embellished-operator-004.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/embellished-operator-004.txt
@@ -2,14 +2,14 @@ Harness status: OK
Found 10 tests
-10 Fail
-Fail Vertical stretching performed for math > mo.
-Fail Vertical stretching performed for Stretching for math[display=block] > mo.
-Fail Vertical stretching performed for math > mrow > mo.
-Fail Vertical stretching performed for Stretching for math[display=block] > mrow > mo.
-Fail Vertical stretching performed for math > mrow > mrow > mo.
-Fail Vertical stretching performed for Stretching for math[display=block] > mrow > mrow > mo.
-Fail Vertical stretching performed for math > mrow > mrow > mrow > mo.
-Fail Vertical stretching performed for Stretching for math[display=block] > mrow > mrow > mrow > mo.
-Fail Vertical stretching performed for math > mrow > mrow > mrow > mrow > mo.
-Fail Vertical stretching performed for Stretching for math[display=block] > mrow > mrow > mrow > mrow > mo.
\ No newline at end of file
+10 Pass
+Pass Vertical stretching performed for math > mo.
+Pass Vertical stretching performed for Stretching for math[display=block] > mo.
+Pass Vertical stretching performed for math > mrow > mo.
+Pass Vertical stretching performed for Stretching for math[display=block] > mrow > mo.
+Pass Vertical stretching performed for math > mrow > mrow > mo.
+Pass Vertical stretching performed for Stretching for math[display=block] > mrow > mrow > mo.
+Pass Vertical stretching performed for math > mrow > mrow > mrow > mo.
+Pass Vertical stretching performed for Stretching for math[display=block] > mrow > mrow > mrow > mo.
+Pass Vertical stretching performed for math > mrow > mrow > mrow > mrow > mo.
+Pass Vertical stretching performed for Stretching for math[display=block] > mrow > mrow > mrow > mrow > mo.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/largeop-hit-testing.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/largeop-hit-testing.txt
index c538adcda14..cbc293af4eb 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/largeop-hit-testing.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/largeop-hit-testing.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Large op hit testing
\ No newline at end of file
+1 Pass
+Pass Large op hit testing
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-axis-height-1.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-axis-height-1.txt
index 822b2d8ad19..36b73c94440 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-axis-height-1.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-axis-height-1.txt
@@ -2,13 +2,14 @@ Harness status: OK
Found 9 tests
-9 Fail
-Fail symmetric stretching with respect to the math axis (size variant)
-Fail symmetric stretching with respect to the math axis (glyph assembly)
-Fail Tascent = Tdescent = 0, minsize = 14em
-Fail Tascent = 6em > AxisHeight, Tdescent = 1em, symmetric = false, minsize = 14em
+8 Pass
+1 Fail
+Pass symmetric stretching with respect to the math axis (size variant)
+Pass symmetric stretching with respect to the math axis (glyph assembly)
+Pass Tascent = Tdescent = 0, minsize = 14em
+Pass Tascent = 6em > AxisHeight, Tdescent = 1em, symmetric = false, minsize = 14em
Fail Tascent = 4em < AxisHeight, Tdescent = 3em, symmetric = false, minsize = 14em
-Fail Tascent = 6em > AxisHeight, Tdescent = 22em, symmetric = false, maxsize = 14em
-Fail Tascent = 4em < AxisHeight, Tdescent = 24em, symmetric = false, maxsize = 14em
-Fail symmetric stretching with respect to the math axis (minsize = 14em)
-Fail symmetric stretching with respect to the math axis (maxsize = 14em)
\ No newline at end of file
+Pass Tascent = 6em > AxisHeight, Tdescent = 22em, symmetric = false, maxsize = 14em
+Pass Tascent = 4em < AxisHeight, Tdescent = 24em, symmetric = false, maxsize = 14em
+Pass symmetric stretching with respect to the math axis (minsize = 14em)
+Pass symmetric stretching with respect to the math axis (maxsize = 14em)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-font-relative-lengths-001.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-font-relative-lengths-001.txt
index 982d62c66e0..37dbabbcb9e 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-font-relative-lengths-001.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-font-relative-lengths-001.txt
@@ -2,9 +2,8 @@ Harness status: OK
Found 4 tests
-3 Pass
-1 Fail
+4 Pass
Pass font-relative lspace refers to the core operator
Pass font-relative rspace refers to the core operator
-Fail font-relative minsize refers to the core operator
+Pass font-relative minsize refers to the core operator
Pass font-relative maxsize refers to the core operator
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-minsize-maxsize-001.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-minsize-maxsize-001.txt
index 160a1507f72..90881ee4b5d 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-minsize-maxsize-001.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-minsize-maxsize-001.txt
@@ -2,11 +2,10 @@ Harness status: OK
Found 6 tests
-1 Pass
-5 Fail
-Fail minsize < 0 is treated as 0
-Fail maxsize < minsize is treated as maxsize = minsize
+6 Pass
+Pass minsize < 0 is treated as 0
+Pass maxsize < minsize is treated as maxsize = minsize
Pass minsize < maxsize < 0 is treated as maxsize = minsize = 0
-Fail target size = 0 is treated as Tascent = Tdescent = minsize/2
-Fail minsize/maxsize percentages are relative to the unstretched size
-Fail default minsize/maxsize values
\ No newline at end of file
+Pass target size = 0 is treated as Tascent = Tdescent = minsize/2
+Pass minsize/maxsize percentages are relative to the unstretched size
+Pass default minsize/maxsize values
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-stretch-properties-001.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-stretch-properties-001.txt
index c26fa167b86..fa29a6af158 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-stretch-properties-001.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-stretch-properties-001.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Stretchy vertical line
\ No newline at end of file
+1 Pass
+Pass Stretchy vertical line
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-stretch-properties-dynamic-001.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-stretch-properties-dynamic-001.txt
index d5841ee05bf..d35b5f703d4 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-stretch-properties-dynamic-001.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/mo-stretch-properties-dynamic-001.txt
@@ -2,9 +2,9 @@ Harness status: OK
Found 5 tests
-5 Fail
-Fail minsize
-Fail maxsize
-Fail largeop
-Fail symmetric
-Fail stretchy
\ No newline at end of file
+5 Pass
+Pass minsize
+Pass maxsize
+Pass largeop
+Pass symmetric
+Pass stretchy
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/symmetric-largeop.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/symmetric-largeop.txt
index f43c1f2194e..2180c4e07d8 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/symmetric-largeop.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/presentation-markup/operators/symmetric-largeop.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Placement of operators
\ No newline at end of file
+1 Pass
+Pass Placement of operators
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/relations/css-styling/displaystyle-1.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/relations/css-styling/displaystyle-1.txt
index a48c2c70fd3..c9726747124 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/relations/css-styling/displaystyle-1.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/relations/css-styling/displaystyle-1.txt
@@ -2,40 +2,40 @@ Harness status: OK
Found 36 tests
-36 Fail
-Fail math element (lowercase)
-Fail math element (explicit display, lowercase)
-Fail mstyle element (lowercase)
-Fail mtable element (lowercase)
-Fail mfrac element (lowercase)
-Fail mroot element (lowercase)
-Fail msub element (lowercase)
-Fail msup element (lowercase)
-Fail msubsup element (lowercase)
-Fail munder element (lowercase)
-Fail mover element (lowercase)
-Fail munderover element (lowercase)
-Fail math element (uppercase)
-Fail math element (explicit display, uppercase)
-Fail mstyle element (uppercase)
-Fail mtable element (uppercase)
-Fail mfrac element (uppercase)
-Fail mroot element (uppercase)
-Fail msub element (uppercase)
-Fail msup element (uppercase)
-Fail msubsup element (uppercase)
-Fail munder element (uppercase)
-Fail mover element (uppercase)
-Fail munderover element (uppercase)
-Fail math element (alternate_case)
-Fail math element (explicit display, alternate_case)
-Fail mstyle element (alternate_case)
-Fail mtable element (alternate_case)
-Fail mfrac element (alternate_case)
-Fail mroot element (alternate_case)
-Fail msub element (alternate_case)
-Fail msup element (alternate_case)
-Fail msubsup element (alternate_case)
-Fail munder element (alternate_case)
-Fail mover element (alternate_case)
-Fail munderover element (alternate_case)
\ No newline at end of file
+36 Pass
+Pass math element (lowercase)
+Pass math element (explicit display, lowercase)
+Pass mstyle element (lowercase)
+Pass mtable element (lowercase)
+Pass mfrac element (lowercase)
+Pass mroot element (lowercase)
+Pass msub element (lowercase)
+Pass msup element (lowercase)
+Pass msubsup element (lowercase)
+Pass munder element (lowercase)
+Pass mover element (lowercase)
+Pass munderover element (lowercase)
+Pass math element (uppercase)
+Pass math element (explicit display, uppercase)
+Pass mstyle element (uppercase)
+Pass mtable element (uppercase)
+Pass mfrac element (uppercase)
+Pass mroot element (uppercase)
+Pass msub element (uppercase)
+Pass msup element (uppercase)
+Pass msubsup element (uppercase)
+Pass munder element (uppercase)
+Pass mover element (uppercase)
+Pass munderover element (uppercase)
+Pass math element (alternate_case)
+Pass math element (explicit display, alternate_case)
+Pass mstyle element (alternate_case)
+Pass mtable element (alternate_case)
+Pass mfrac element (alternate_case)
+Pass mroot element (alternate_case)
+Pass msub element (alternate_case)
+Pass msup element (alternate_case)
+Pass msubsup element (alternate_case)
+Pass munder element (alternate_case)
+Pass mover element (alternate_case)
+Pass munderover element (alternate_case)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/mathml/relations/css-styling/displaystyle-2.txt b/Tests/LibWeb/Text/expected/wpt-import/mathml/relations/css-styling/displaystyle-2.txt
index c477608d0f8..9efa147308c 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/mathml/relations/css-styling/displaystyle-2.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/mathml/relations/css-styling/displaystyle-2.txt
@@ -2,31 +2,31 @@ Harness status: OK
Found 27 tests
-27 Fail
-Fail mtable element (lowercase)
-Fail mfrac element (lowercase)
-Fail mroot element (lowercase)
-Fail msub element (lowercase)
-Fail msup element (lowercase)
-Fail msubsup element (lowercase)
-Fail munder element (lowercase)
-Fail mover element (lowercase)
-Fail munderover element (lowercase)
-Fail mtable element (uppercase)
-Fail mfrac element (uppercase)
-Fail mroot element (uppercase)
-Fail msub element (uppercase)
-Fail msup element (uppercase)
-Fail msubsup element (uppercase)
-Fail munder element (uppercase)
-Fail mover element (uppercase)
-Fail munderover element (uppercase)
-Fail mtable element (alternate_case)
-Fail mfrac element (alternate_case)
-Fail mroot element (alternate_case)
-Fail msub element (alternate_case)
-Fail msup element (alternate_case)
-Fail msubsup element (alternate_case)
-Fail munder element (alternate_case)
-Fail mover element (alternate_case)
-Fail munderover element (alternate_case)
\ No newline at end of file
+27 Pass
+Pass mtable element (lowercase)
+Pass mfrac element (lowercase)
+Pass mroot element (lowercase)
+Pass msub element (lowercase)
+Pass msup element (lowercase)
+Pass msubsup element (lowercase)
+Pass munder element (lowercase)
+Pass mover element (lowercase)
+Pass munderover element (lowercase)
+Pass mtable element (uppercase)
+Pass mfrac element (uppercase)
+Pass mroot element (uppercase)
+Pass msub element (uppercase)
+Pass msup element (uppercase)
+Pass msubsup element (uppercase)
+Pass munder element (uppercase)
+Pass mover element (uppercase)
+Pass munderover element (uppercase)
+Pass mtable element (alternate_case)
+Pass mfrac element (alternate_case)
+Pass mroot element (alternate_case)
+Pass msub element (alternate_case)
+Pass msup element (alternate_case)
+Pass msubsup element (alternate_case)
+Pass munder element (alternate_case)
+Pass mover element (alternate_case)
+Pass munderover element (alternate_case)
\ No newline at end of file