Commit ef8fbdd7 authored by Frédéric Wang's avatar Frédéric Wang Committed by Chromium LUCI CQ

Treat mmultiscripts with two <mprescripts> children as invalid

Per [1], mmultiscripts can only have one in-flow <mprescripts/> child so
this CL fixes IsValidMultiscript() to align with the specification.
It also makes similar adjustment for the corresponding fatal checks in
NGMathScriptsLayoutAlgorithm::GatherChildren (rather than just checking
the index of a previous <mprescripts> is nonzero, which does not work if
there is no post-scripts). This fixes an assertion about node not being
laid out due to the fact that the mmultiscripts algorithm only performs
layout of at most one <mprescript>.

[1] https://mathml-refresh.github.io/mathml-core/#prescripts-and-tensor-indices-mmultiscripts

Bug: 1158375, 6606
Change-Id: I26964b2ef287585392db7f1854251b4b21075aef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593643
Commit-Queue: Frédéric Wang <fwang@igalia.com>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837987}
parent f48f030a
...@@ -79,13 +79,15 @@ inline bool IsValidMultiscript(const NGBlockNode& node) { ...@@ -79,13 +79,15 @@ inline bool IsValidMultiscript(const NGBlockNode& node) {
if (!child || IsPrescriptDelimiter(child)) if (!child || IsPrescriptDelimiter(child))
return false; return false;
bool number_of_scripts_is_even = true; bool number_of_scripts_is_even = true;
bool prescript_delimiter_found = false;
while (child) { while (child) {
child = To<NGBlockNode>(NextSiblingInFlow(child)); child = To<NGBlockNode>(NextSiblingInFlow(child));
if (!child) if (!child)
continue; continue;
if (IsPrescriptDelimiter(child)) { if (IsPrescriptDelimiter(child)) {
if (!number_of_scripts_is_even) if (!number_of_scripts_is_even || prescript_delimiter_found)
return false; return false;
prescript_delimiter_found = true;
continue; continue;
} }
number_of_scripts_is_even = !number_of_scripts_is_even; number_of_scripts_is_even = !number_of_scripts_is_even;
......
...@@ -148,7 +148,7 @@ void NGMathScriptsLayoutAlgorithm::GatherChildren( ...@@ -148,7 +148,7 @@ void NGMathScriptsLayoutAlgorithm::GatherChildren(
// The structure of mmultiscripts is specified here: // The structure of mmultiscripts is specified here:
// https://mathml-refresh.github.io/mathml-core/#prescripts-and-tensor-indices-mmultiscripts // https://mathml-refresh.github.io/mathml-core/#prescripts-and-tensor-indices-mmultiscripts
if (IsPrescriptDelimiter(block_child)) { if (IsPrescriptDelimiter(block_child)) {
if (!number_of_scripts_is_even || *first_prescript_index > 0) { if (!number_of_scripts_is_even || *prescripts) {
NOTREACHED(); NOTREACHED();
return; return;
} }
......
<!DOCTYPE html>
<math>
<mmultiscripts>
<mrow></mrow>
<mprescripts></mprescripts>
<mprescripts></mprescripts>
</mmultiscripts>
</math>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment