Commit df7b1383 authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

[mathml] Implement the <munder>, <mover>, <munderover> elements

Implement the <munder>, <mover>, <munderover> elements and add a layout
algorithm [1] covering all three elements. This patch does
not yet cover all details of the algorithm (accent, stretchy operators)
to keep the patch simple, however FIXMEs are added.

[1] https://mathml-refresh.github.io/mathml-core/#underscripts-and-overscripts-munder-mover-munderover

Bug: 6606
Change-Id: I8a20bb3105b733ef57413114aed0e6b536597c46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2119538
Commit-Queue: Rob Buis <rbuis@igalia.com>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756225}
parent dabd5140
...@@ -46,7 +46,7 @@ math[display="block"] { ...@@ -46,7 +46,7 @@ math[display="block"] {
outline: auto 1px -webkit-focus-ring-color; outline: auto 1px -webkit-focus-ring-color;
} }
maction, merror, mfrac, mphantom, mrow, mspace, mstyle maction, merror, mfrac, mphantom, mrow, mspace, mstyle, munder, mover, munderover
{ {
display: math; display: math;
} }
......
...@@ -427,6 +427,8 @@ blink_core_sources("layout") { ...@@ -427,6 +427,8 @@ blink_core_sources("layout") {
"ng/mathml/ng_math_row_layout_algorithm.h", "ng/mathml/ng_math_row_layout_algorithm.h",
"ng/mathml/ng_math_space_layout_algorithm.cc", "ng/mathml/ng_math_space_layout_algorithm.cc",
"ng/mathml/ng_math_space_layout_algorithm.h", "ng/mathml/ng_math_space_layout_algorithm.h",
"ng/mathml/ng_math_under_over_layout_algorithm.cc",
"ng/mathml/ng_math_under_over_layout_algorithm.h",
"ng/ng_absolute_utils.cc", "ng/ng_absolute_utils.cc",
"ng/ng_absolute_utils.h", "ng/ng_absolute_utils.h",
"ng/ng_block_break_token.cc", "ng/ng_block_break_token.cc",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "third_party/blink/renderer/core/layout/ng/ng_length_utils.h" #include "third_party/blink/renderer/core/layout/ng/ng_length_utils.h"
#include "third_party/blink/renderer/core/layout/ng/ng_space_utils.h" #include "third_party/blink/renderer/core/layout/ng/ng_space_utils.h"
#include "third_party/blink/renderer/core/mathml/mathml_fraction_element.h" #include "third_party/blink/renderer/core/mathml/mathml_fraction_element.h"
#include "third_party/blink/renderer/core/mathml/mathml_under_over_element.h"
namespace blink { namespace blink {
...@@ -69,6 +70,21 @@ bool IsValidMathMLFraction(const NGBlockNode& node) { ...@@ -69,6 +70,21 @@ bool IsValidMathMLFraction(const NGBlockNode& node) {
return InFlowChildCountIs(node, 2); return InFlowChildCountIs(node, 2);
} }
bool IsValidMathMLUnderOver(const NGBlockNode& node) {
auto* scripted =
DynamicTo<MathMLUnderOverElement>(node.GetLayoutBox()->GetNode());
switch (scripted->scriptType()) {
case MathMLUnderOverElement::ScriptType::kUnder:
case MathMLUnderOverElement::ScriptType::kOver:
return InFlowChildCountIs(node, 2);
case MathMLUnderOverElement::ScriptType::kUnderOver:
return InFlowChildCountIs(node, 3);
default:
NOTREACHED();
return false;
}
}
namespace { namespace {
inline LayoutUnit DefaultFractionLineThickness(const ComputedStyle& style) { inline LayoutUnit DefaultFractionLineThickness(const ComputedStyle& style) {
......
...@@ -26,6 +26,7 @@ NGLayoutInputNode FirstChildInFlow(const NGBlockNode&); ...@@ -26,6 +26,7 @@ NGLayoutInputNode FirstChildInFlow(const NGBlockNode&);
NGLayoutInputNode NextSiblingInFlow(const NGBlockNode&); NGLayoutInputNode NextSiblingInFlow(const NGBlockNode&);
bool IsValidMathMLFraction(const NGBlockNode&); bool IsValidMathMLFraction(const NGBlockNode&);
bool IsValidMathMLUnderOver(const NGBlockNode&);
inline float RuleThicknessFallback(const ComputedStyle& style) { inline float RuleThicknessFallback(const ComputedStyle& style) {
// This function returns a value for the default rule thickness (TeX's // This function returns a value for the default rule thickness (TeX's
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_MATHML_NG_MATH_UNDER_OVER_LAYOUT_ALGORITHM_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_MATHML_NG_MATH_UNDER_OVER_LAYOUT_ALGORITHM_H_
#include "third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.h"
#include "third_party/blink/renderer/core/layout/ng/ng_layout_algorithm.h"
namespace blink {
class CORE_EXPORT NGMathUnderOverLayoutAlgorithm
: public NGLayoutAlgorithm<NGBlockNode,
NGBoxFragmentBuilder,
NGBlockBreakToken> {
public:
explicit NGMathUnderOverLayoutAlgorithm(
const NGLayoutAlgorithmParams& params);
scoped_refptr<const NGLayoutResult> Layout() override;
base::Optional<MinMaxSizes> ComputeMinMaxSizes(
const MinMaxSizesInput&) const override;
private:
void GatherChildren(NGBlockNode* base,
NGBlockNode* second,
NGBlockNode* third);
const NGBoxStrut border_scrollbar_padding_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_MATHML_NG_MATH_UNDER_OVER_LAYOUT_ALGORITHM_H_
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "third_party/blink/renderer/core/layout/ng/mathml/ng_math_layout_utils.h" #include "third_party/blink/renderer/core/layout/ng/mathml/ng_math_layout_utils.h"
#include "third_party/blink/renderer/core/layout/ng/mathml/ng_math_row_layout_algorithm.h" #include "third_party/blink/renderer/core/layout/ng/mathml/ng_math_row_layout_algorithm.h"
#include "third_party/blink/renderer/core/layout/ng/mathml/ng_math_space_layout_algorithm.h" #include "third_party/blink/renderer/core/layout/ng/mathml/ng_math_space_layout_algorithm.h"
#include "third_party/blink/renderer/core/layout/ng/mathml/ng_math_under_over_layout_algorithm.h"
#include "third_party/blink/renderer/core/layout/ng/ng_block_break_token.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_break_token.h"
#include "third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h"
#include "third_party/blink/renderer/core/layout/ng/ng_box_fragment.h" #include "third_party/blink/renderer/core/layout/ng/ng_box_fragment.h"
...@@ -55,6 +56,7 @@ ...@@ -55,6 +56,7 @@
#include "third_party/blink/renderer/core/mathml/mathml_element.h" #include "third_party/blink/renderer/core/mathml/mathml_element.h"
#include "third_party/blink/renderer/core/mathml/mathml_fraction_element.h" #include "third_party/blink/renderer/core/mathml/mathml_fraction_element.h"
#include "third_party/blink/renderer/core/mathml/mathml_space_element.h" #include "third_party/blink/renderer/core/mathml/mathml_space_element.h"
#include "third_party/blink/renderer/core/mathml/mathml_under_over_element.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h" #include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/text/writing_mode.h" #include "third_party/blink/renderer/platform/text/writing_mode.h"
...@@ -104,6 +106,9 @@ NOINLINE void DetermineMathMLAlgorithmAndRun( ...@@ -104,6 +106,9 @@ NOINLINE void DetermineMathMLAlgorithmAndRun(
else if (IsA<MathMLFractionElement>(element) && else if (IsA<MathMLFractionElement>(element) &&
IsValidMathMLFraction(params.node)) IsValidMathMLFraction(params.node))
CreateAlgorithmAndRun<NGMathFractionLayoutAlgorithm>(params, callback); CreateAlgorithmAndRun<NGMathFractionLayoutAlgorithm>(params, callback);
else if (IsA<MathMLUnderOverElement>(element) &&
IsValidMathMLUnderOver(params.node))
CreateAlgorithmAndRun<NGMathUnderOverLayoutAlgorithm>(params, callback);
else else
CreateAlgorithmAndRun<NGMathRowLayoutAlgorithm>(params, callback); CreateAlgorithmAndRun<NGMathRowLayoutAlgorithm>(params, callback);
} }
......
...@@ -14,5 +14,7 @@ blink_core_sources("mathml") { ...@@ -14,5 +14,7 @@ blink_core_sources("mathml") {
"mathml_row_element.h", "mathml_row_element.h",
"mathml_space_element.cc", "mathml_space_element.cc",
"mathml_space_element.h", "mathml_space_element.h",
"mathml_under_over_element.cc",
"mathml_under_over_element.h",
] ]
} }
...@@ -75,6 +75,18 @@ ...@@ -75,6 +75,18 @@
name: "mtext", name: "mtext",
interfaceName: "MathMLElement", interfaceName: "MathMLElement",
}, },
{
name: "mover",
interfaceName: "MathMLUnderOverElement",
},
{
name: "munder",
interfaceName: "MathMLUnderOverElement",
},
{
name: "munderover",
interfaceName: "MathMLUnderOverElement",
},
{ {
name: "semantics", name: "semantics",
interfaceName: "MathMLRowElement", interfaceName: "MathMLRowElement",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/mathml/mathml_under_over_element.h"
#include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
static MathMLUnderOverElement::ScriptType scriptTypeOf(
const QualifiedName& tagName) {
if (tagName == mathml_names::kMunderTag)
return MathMLUnderOverElement::ScriptType::kUnder;
if (tagName == mathml_names::kMoverTag)
return MathMLUnderOverElement::ScriptType::kOver;
DCHECK_EQ(tagName, mathml_names::kMunderoverTag);
return MathMLUnderOverElement::ScriptType::kUnderOver;
}
MathMLUnderOverElement::MathMLUnderOverElement(const QualifiedName& tagName,
Document& document)
: MathMLElement(tagName, document), script_type_(scriptTypeOf(tagName)) {}
LayoutObject* MathMLUnderOverElement::CreateLayoutObject(
const ComputedStyle& style,
LegacyLayout legacy) {
if (!RuntimeEnabledFeatures::MathMLCoreEnabled() ||
!style.IsDisplayMathType() || legacy == LegacyLayout::kForce)
return MathMLElement::CreateLayoutObject(style, legacy);
return new LayoutNGMathMLBlock(this);
}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_MATHML_MATHML_UNDER_OVER_ELEMENT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_MATHML_MATHML_UNDER_OVER_ELEMENT_H_
#include "third_party/blink/renderer/core/mathml/mathml_element.h"
namespace blink {
class Document;
class CORE_EXPORT MathMLUnderOverElement final : public MathMLElement {
public:
MathMLUnderOverElement(const QualifiedName& tagName, Document& document);
enum class ScriptType {
kUnder,
kOver,
kUnderOver,
};
ScriptType scriptType() const { return script_type_; }
private:
const ScriptType script_type_;
LayoutObject* CreateLayoutObject(const ComputedStyle&,
LegacyLayout legacy) override;
};
template <>
inline bool IsElementOfType<const MathMLUnderOverElement>(const Node& node) {
return IsA<MathMLUnderOverElement>(node);
}
template <>
struct DowncastTraits<MathMLUnderOverElement> {
static bool AllowFrom(const Node& node) {
auto* mathml_element = DynamicTo<MathMLElement>(node);
return mathml_element && AllowFrom(*mathml_element);
}
static bool AllowFrom(const MathMLElement& mathml_element) {
return mathml_element.HasTagName(mathml_names::kMunderTag) ||
mathml_element.HasTagName(mathml_names::kMoverTag) ||
mathml_element.HasTagName(mathml_names::kMunderoverTag);
}
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_MATHML_MATHML_UNDER_OVER_ELEMENT_H_
...@@ -1630,6 +1630,7 @@ crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-axis-height- ...@@ -1630,6 +1630,7 @@ crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-axis-height-
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-form-dynamic.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-form-dynamic.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-form-minus-plus.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-form-minus-plus.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-form.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-form.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-movablelimits.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-paint-lspace-rspace.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-paint-lspace-rspace.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/operator-dictionary-001.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/operators/operator-dictionary-001.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/operator-dictionary-002.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/operators/operator-dictionary-002.html [ Failure ]
...@@ -1640,8 +1641,6 @@ crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/subsup-3.html [ F ...@@ -1640,8 +1641,6 @@ crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/subsup-3.html [ F
crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/subsup-5.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/subsup-5.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/subsup-parameters-1.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/subsup-parameters-1.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/subsup-parameters-2.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/subsup-parameters-2.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/underover-1.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/underover-parameters-1.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/underover-parameters-2.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/underover-parameters-2.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/underover-parameters-3.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/underover-parameters-3.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/underover-parameters-4.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/underover-parameters-4.html [ Failure ]
...@@ -1680,9 +1679,6 @@ crbug.com/6606 external/wpt/mathml/relations/css-styling/mathvariant-sans-serif. ...@@ -1680,9 +1679,6 @@ crbug.com/6606 external/wpt/mathml/relations/css-styling/mathvariant-sans-serif.
crbug.com/6606 external/wpt/mathml/relations/css-styling/mathvariant-script.html [ Failure ] crbug.com/6606 external/wpt/mathml/relations/css-styling/mathvariant-script.html [ Failure ]
crbug.com/6606 external/wpt/mathml/relations/css-styling/mathvariant-stretched.html [ Failure ] crbug.com/6606 external/wpt/mathml/relations/css-styling/mathvariant-stretched.html [ Failure ]
crbug.com/6606 external/wpt/mathml/relations/css-styling/mathvariant-tailed.html [ Failure ] crbug.com/6606 external/wpt/mathml/relations/css-styling/mathvariant-tailed.html [ Failure ]
crbug.com/6606 external/wpt/mathml/relations/css-styling/padding-border-margin/border-002.html [ Failure ]
crbug.com/6606 external/wpt/mathml/relations/css-styling/padding-border-margin/margin-002.html [ Failure ]
crbug.com/6606 external/wpt/mathml/relations/css-styling/padding-border-margin/padding-002.html [ Failure ]
crbug.com/6606 external/wpt/mathml/relations/css-styling/visibility-003.html [ Failure ] crbug.com/6606 external/wpt/mathml/relations/css-styling/visibility-003.html [ Failure ]
crbug.com/6606 external/wpt/mathml/relations/css-styling/width-height-001.html [ Failure ] crbug.com/6606 external/wpt/mathml/relations/css-styling/width-height-001.html [ Failure ]
crbug.com/6606 external/wpt/mathml/relations/html5-tree/href-click-1.html [ Failure ] crbug.com/6606 external/wpt/mathml/relations/html5-tree/href-click-1.html [ Failure ]
......
This is a testharness.js-based test.
PASS Border properties on maction
PASS Border properties on maction (rtl)
PASS Border properties on menclose
PASS Border properties on menclose (rtl)
PASS Border properties on merror
PASS Border properties on merror (rtl)
PASS Border properties on mfrac
PASS Border properties on mfrac (rtl)
PASS Border properties on mi
PASS Border properties on mi (rtl)
PASS Border properties on mmultiscripts
PASS Border properties on mmultiscripts (rtl)
PASS Border properties on mn
PASS Border properties on mn (rtl)
PASS Border properties on mo
PASS Border properties on mo (rtl)
PASS Border properties on mover
PASS Border properties on mover (rtl)
PASS Border properties on mpadded
PASS Border properties on mpadded (rtl)
PASS Border properties on mphantom
PASS Border properties on mphantom (rtl)
FAIL Border properties on mroot assert_true: mroot is supported expected true got false
FAIL Border properties on mroot (rtl) assert_true: mroot is supported expected true got false
PASS Border properties on mrow
PASS Border properties on mrow (rtl)
PASS Border properties on ms
PASS Border properties on ms (rtl)
PASS Border properties on mspace
FAIL Border properties on msqrt assert_true: msqrt is supported expected true got false
FAIL Border properties on msqrt (rtl) assert_true: msqrt is supported expected true got false
PASS Border properties on mstyle
PASS Border properties on mstyle (rtl)
PASS Border properties on msub
PASS Border properties on msub (rtl)
PASS Border properties on msubsup
PASS Border properties on msubsup (rtl)
PASS Border properties on msup
PASS Border properties on msup (rtl)
PASS Border properties on mtable
PASS Border properties on mtable (rtl)
PASS Border properties on mtext
PASS Border properties on mtext (rtl)
PASS Border properties on munder
PASS Border properties on munder (rtl)
PASS Border properties on munderover
PASS Border properties on munderover (rtl)
PASS Border properties on semantics
PASS Border properties on semantics (rtl)
Harness: the test ran to completion.
This is a testharness.js-based test.
Found 73 tests; 67 PASS, 6 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS Margin properties on maction
PASS Margin properties on maction (rtl)
PASS Margin properties on maction (no margin-collapsing)
PASS Margin properties on menclose
PASS Margin properties on menclose (rtl)
PASS Margin properties on menclose (no margin-collapsing)
PASS Margin properties on merror
PASS Margin properties on merror (rtl)
PASS Margin properties on merror (no margin-collapsing)
PASS Margin properties on mfrac
PASS Margin properties on mfrac (rtl)
PASS Margin properties on mfrac (no margin-collapsing)
PASS Margin properties on mi
PASS Margin properties on mi (rtl)
PASS Margin properties on mi (no margin-collapsing)
PASS Margin properties on mmultiscripts
PASS Margin properties on mmultiscripts (rtl)
PASS Margin properties on mmultiscripts (no margin-collapsing)
PASS Margin properties on mn
PASS Margin properties on mn (rtl)
PASS Margin properties on mn (no margin-collapsing)
PASS Margin properties on mo
PASS Margin properties on mo (rtl)
PASS Margin properties on mo (no margin-collapsing)
PASS Margin properties on mover
PASS Margin properties on mover (rtl)
PASS Margin properties on mover (no margin-collapsing)
PASS Margin properties on mpadded
PASS Margin properties on mpadded (rtl)
PASS Margin properties on mpadded (no margin-collapsing)
PASS Margin properties on mphantom
PASS Margin properties on mphantom (rtl)
PASS Margin properties on mphantom (no margin-collapsing)
FAIL Margin properties on mroot assert_true: mroot is supported expected true got false
FAIL Margin properties on mroot (rtl) assert_true: mroot is supported expected true got false
FAIL Margin properties on mroot (no margin-collapsing) assert_true: mroot is supported expected true got false
PASS Margin properties on mrow
PASS Margin properties on mrow (rtl)
PASS Margin properties on mrow (no margin-collapsing)
PASS Margin properties on ms
PASS Margin properties on ms (rtl)
PASS Margin properties on ms (no margin-collapsing)
PASS Margin properties on mspace
FAIL Margin properties on msqrt assert_true: msqrt is supported expected true got false
FAIL Margin properties on msqrt (rtl) assert_true: msqrt is supported expected true got false
FAIL Margin properties on msqrt (no margin-collapsing) assert_true: msqrt is supported expected true got false
PASS Margin properties on mstyle
PASS Margin properties on mstyle (rtl)
PASS Margin properties on mstyle (no margin-collapsing)
PASS Margin properties on msub
PASS Margin properties on msub (rtl)
PASS Margin properties on msub (no margin-collapsing)
PASS Margin properties on msubsup
PASS Margin properties on msubsup (rtl)
PASS Margin properties on msubsup (no margin-collapsing)
PASS Margin properties on msup
PASS Margin properties on msup (rtl)
PASS Margin properties on msup (no margin-collapsing)
PASS Margin properties on mtable
PASS Margin properties on mtable (rtl)
PASS Margin properties on mtable (no margin-collapsing)
PASS Margin properties on mtext
PASS Margin properties on mtext (rtl)
PASS Margin properties on mtext (no margin-collapsing)
PASS Margin properties on munder
PASS Margin properties on munder (rtl)
PASS Margin properties on munder (no margin-collapsing)
PASS Margin properties on munderover
PASS Margin properties on munderover (rtl)
PASS Margin properties on munderover (no margin-collapsing)
PASS Margin properties on semantics
PASS Margin properties on semantics (rtl)
PASS Margin properties on semantics (no margin-collapsing)
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Margin properties on the children of menclose
PASS Margin properties on the children of merror
PASS Margin properties on the children of mfrac
FAIL Margin properties on the children of mmultiscripts assert_approx_equals: block size expected 345 +/- 1 but got 305
PASS Margin properties on the children of mover
PASS Margin properties on the children of mpadded
PASS Margin properties on the children of mphantom
FAIL Margin properties on the children of mroot assert_true: mroot is supported expected true got false
PASS Margin properties on the children of mrow
FAIL Margin properties on the children of msqrt assert_true: msqrt is supported expected true got false
PASS Margin properties on the children of mstyle
FAIL Margin properties on the children of msub assert_approx_equals: block size expected 230 +/- 1 but got 210
FAIL Margin properties on the children of msubsup assert_approx_equals: block size expected 345 +/- 1 but got 305
FAIL Margin properties on the children of msup assert_approx_equals: block size expected 230 +/- 1 but got 210
PASS Margin properties on the children of munder
PASS Margin properties on the children of munderover
Harness: the test ran to completion.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>margin</title>
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#layout-algorithms">
<meta name="assert" content="Verify that margin is taken into account on children.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<script src="/mathml/support/mathml-fragments.js"></script>
<script src="/mathml/support/layout-comparison.js"></script>
<script>
var epsilon = 1;
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests() {
for (tag in MathMLFragments) {
if (!FragmentHelper.isValidChildOfMrow(tag) ||
FragmentHelper.isEmpty(tag) ||
FragmentHelper.isTokenElement(tag) ||
tag == "semantics" ||
tag == "maction" ||
tag == "mtable")
continue;
test(function() {
assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`);
document.body.insertAdjacentHTML("beforeend", `<hr/><div>\
<div style="display: inline-block; border: 1px dashed blue;"><math>${MathMLFragments[tag]}</math></div><br/>\
<div style="display: inline-block; border: 1px dashed green;"><math>${MathMLFragments[tag]}</math></div>\
</div>`);
var div = document.body.lastElementChild;
var elementShrinkWrapContainer = div.firstElementChild;
var element = elementShrinkWrapContainer.firstElementChild.firstElementChild;
var elementContainer = div.firstElementChild;
var referenceShrinkWrapContainer = div.lastElementChild;
var reference = referenceShrinkWrapContainer.firstElementChild.firstElementChild;
FragmentHelper.forceNonEmptyElement(element);
FragmentHelper.forceNonEmptyElement(reference);
var mspaceWidth = 20, mspaceHeight = 40, mspaceDepth = 30;
var marginLeft = 10, marginRight = 15, marginTop = 20, marginBottom = 25;
Array.from(element.children).forEach(mrow => {
mrow.outerHTML = `<mspace width="${mspaceWidth}px" height="${mspaceHeight}px" depth='${mspaceDepth}px' style='background: blue; margin-left: ${marginLeft}px; margin-right: ${marginRight}px; margin-top: ${marginTop}px; margin-bottom: ${marginBottom}px;'></mspace>`;
});
Array.from(reference.children).forEach(mrow => {
mrow.outerHTML = `<mspace width="${marginLeft+mspaceWidth+marginRight}px" height="${mspaceHeight+marginTop}px" depth='${mspaceDepth+marginBottom}px' style='background: green;'></mspace>`;
});
// Compare sizes.
compareSize(element, reference, epsilon);
// Compare children positions.
var elementBox = element.getBoundingClientRect();
var referenceBox = reference.getBoundingClientRect();
for (var i = 0; i < element.children.length; i++) {
var childBox = element.children[i].getBoundingClientRect();
var referenceChildBox = reference.children[i].getBoundingClientRect();
assert_approx_equals(childBox.width + marginLeft + marginRight, referenceChildBox.width, epsilon, "inline size (child ${i})");
assert_approx_equals(childBox.height + marginTop + marginBottom, referenceChildBox.height, epsilon, "block size (child ${i})");
assert_approx_equals(childBox.left - marginLeft - elementBox.left,
referenceChildBox.left - referenceBox.left,
epsilon,
`inline position (child ${i})`);
assert_approx_equals(childBox.top - marginTop - elementBox.top,
referenceChildBox.top - referenceBox.top,
epsilon,
`block position (child ${i})`);
}
// Compare preferred widths.
assert_approx_equals(elementShrinkWrapContainer.offsetWidth, referenceShrinkWrapContainer.offsetWidth, epsilon, "preferred width");
}, `Margin properties on the children of ${tag}`);
}
done();
}
</script>
</head>
<body>
<div id="log"></div>
</body>
</html>
This is a testharness.js-based test.
PASS Padding properties on maction
PASS Padding properties on maction (rtl)
PASS Padding properties on menclose
PASS Padding properties on menclose (rtl)
PASS Padding properties on merror
PASS Padding properties on merror (rtl)
PASS Padding properties on mfrac
PASS Padding properties on mfrac (rtl)
PASS Padding properties on mi
PASS Padding properties on mi (rtl)
PASS Padding properties on mmultiscripts
PASS Padding properties on mmultiscripts (rtl)
PASS Padding properties on mn
PASS Padding properties on mn (rtl)
PASS Padding properties on mo
PASS Padding properties on mo (rtl)
PASS Padding properties on mover
PASS Padding properties on mover (rtl)
PASS Padding properties on mpadded
PASS Padding properties on mpadded (rtl)
PASS Padding properties on mphantom
PASS Padding properties on mphantom (rtl)
FAIL Padding properties on mroot assert_true: mroot is supported expected true got false
FAIL Padding properties on mroot (rtl) assert_true: mroot is supported expected true got false
PASS Padding properties on mrow
PASS Padding properties on mrow (rtl)
PASS Padding properties on ms
PASS Padding properties on ms (rtl)
PASS Padding properties on mspace
FAIL Padding properties on msqrt assert_true: msqrt is supported expected true got false
FAIL Padding properties on msqrt (rtl) assert_true: msqrt is supported expected true got false
PASS Padding properties on mstyle
PASS Padding properties on mstyle (rtl)
PASS Padding properties on msub
PASS Padding properties on msub (rtl)
PASS Padding properties on msubsup
PASS Padding properties on msubsup (rtl)
PASS Padding properties on msup
PASS Padding properties on msup (rtl)
PASS Padding properties on mtable
PASS Padding properties on mtable (rtl)
PASS Padding properties on mtext
PASS Padding properties on mtext (rtl)
PASS Padding properties on munder
PASS Padding properties on munder (rtl)
PASS Padding properties on munderover
PASS Padding properties on munderover (rtl)
PASS Padding properties on semantics
PASS Padding properties on semantics (rtl)
Harness: the test ran to completion.
...@@ -132,6 +132,14 @@ var FragmentHelper = { ...@@ -132,6 +132,14 @@ var FragmentHelper = {
tag == "mtd"); tag == "mtd");
}, },
isTokenElement: function(tag) {
return (tag == "mi" ||
tag == "mtext" ||
tag == "mo" ||
tag == "mn" ||
tag == "ms")
},
isEmpty: function(tag) { isEmpty: function(tag) {
return tag === "mspace" || tag == "mprescripts" || tag == "none"; return tag === "mspace" || tag == "mprescripts" || tag == "none";
}, },
......
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