0

Implement symmetric attribute

This is the second patch of a series of CL to implement MathML stretchy
operators. It adds step 4 from [1] to the operator algorithm in order
to ensure that some vertical operators (e.g. fences) are stretched
symmetrically above and below the math axis.

[1] https://w3c.github.io/mathml-core/#layout-of-operators

Bug: 6606, 1124301
Change-Id: I1a75f03a946d0781ce73f52f99b70c871b2dfeed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3013795
Commit-Queue: Frédéric Wang <fwang@igalia.com>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#905033}
This commit is contained in:
Frédéric Wang
2021-07-24 06:56:20 +00:00
committed by Chromium LUCI CQ
parent c57dd7a31a
commit 1b2791131a
10 changed files with 16 additions and 56 deletions

@ -66,7 +66,19 @@ scoped_refptr<const NGLayoutResult> NGMathOperatorLayoutAlgorithm::Layout() {
ConstraintSpace().TargetStretchBlockSizes()) {
target_stretch_ascent = target_stretch_block_sizes->ascent;
target_stretch_descent = target_stretch_block_sizes->descent;
// TODO(http://crbug.com/1124301) Implement symmetric attribute.
if (element->HasBooleanProperty(MathMLOperatorElement::kSymmetric)) {
// "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"
LayoutUnit axis = MathAxisHeight(Style());
LayoutUnit half_target_stretch_size = std::max(
target_stretch_ascent - axis, target_stretch_descent + axis);
target_stretch_ascent = half_target_stretch_size + axis;
target_stretch_descent = half_target_stretch_size - axis;
}
// TODO(http://crbug.com/1124301) Implement minsize, maxsize attributes.
operator_target_size = target_stretch_ascent + target_stretch_descent;
}

@ -1253,7 +1253,8 @@ crbug.com/1127222 external/wpt/mathml/presentation-markup/mrow/legacy-mrow-like-
# into account fallback parameters.
crbug.com/6606 [ Win ] external/wpt/mathml/presentation-markup/fractions/frac-1.html [ Failure ]
# This test fails on macOS.
# Tests failing only on certain platforms.
crbug.com/6606 [ Win ] external/wpt/mathml/presentation-markup/operators/mo-axis-height-1.html [ Failure ]
crbug.com/6606 [ Mac ] external/wpt/mathml/relations/text-and-math/use-typo-metrics-1.html [ Failure ]
# These tests fail because we don't support the MathML href attribute, which is

@ -1,5 +0,0 @@
This is a testharness.js-based test.
FAIL AxisHeight (size variant) assert_approx_equals: mo: size expected 140 +/- 5 but got 70
FAIL AxisHeight (glyph assembly) assert_approx_equals: mo: size expected 300 +/- 5 but got 200
Harness: the test ran to completion.

@ -2,7 +2,7 @@ This is a testharness.js-based test.
FAIL minsize assert_approx_equals: attach expected 100 +/- 1 but got 25
FAIL maxsize assert_approx_equals: attach expected 100 +/- 1 but got 150
PASS largeop
FAIL symmetric assert_approx_equals: set true expected 150 +/- 1 but got 75
PASS symmetric
PASS stretchy
Harness: the test ran to completion.

@ -1,8 +0,0 @@
This is a testharness.js-based test.
FAIL Operator dictionary chunk 1 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 2 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 3 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 4 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 5 - symmetric assert_true: symmetric is supported expected true got false
Harness: the test ran to completion.

@ -1,8 +0,0 @@
This is a testharness.js-based test.
FAIL Operator dictionary chunk 1 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 2 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 3 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 4 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 5 - symmetric assert_true: symmetric is supported expected true got false
Harness: the test ran to completion.

@ -1,8 +0,0 @@
This is a testharness.js-based test.
FAIL Operator dictionary chunk 1 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 2 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 3 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 4 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 5 - symmetric assert_true: symmetric is supported expected true got false
Harness: the test ran to completion.

@ -1,8 +0,0 @@
This is a testharness.js-based test.
FAIL Operator dictionary chunk 1 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 2 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 3 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 4 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 5 - symmetric assert_true: symmetric is supported expected true got false
Harness: the test ran to completion.

@ -1,8 +0,0 @@
This is a testharness.js-based test.
FAIL Operator dictionary chunk 1 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 2 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 3 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 4 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 5 - symmetric assert_true: symmetric is supported expected true got false
Harness: the test ran to completion.

@ -1,8 +0,0 @@
This is a testharness.js-based test.
FAIL Operator dictionary chunk 1 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 2 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 3 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 4 - symmetric assert_true: symmetric is supported expected true got false
FAIL Operator dictionary chunk 5 - symmetric assert_true: symmetric is supported expected true got false
Harness: the test ran to completion.