Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gecko Bug 1916988] Support CSS width/height properties on MathML elements. #48375

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion mathml/relations/css-styling/width-height-001.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>width, height, inline-size and block-size</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#layout-algorithms">
<meta name="assert" content="Verify that width, height, inline-size and block-size properties are ignored.">
<meta name="assert" content="Verify that width, height, inline-size and block-size properties set the size of the content box.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
Expand All @@ -30,6 +30,7 @@
document.body.insertAdjacentHTML("beforeend", `<div style="position: absolute;"><math><mrow>${MathMLFragments[tag]}</mrow></math></div>`);
let div = document.body.lastElementChild;
let element = FragmentHelper.element(div.firstElementChild);
FragmentHelper.forceNonEmptyDescendants(element);

test(function() {
assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`);
Expand All @@ -49,6 +50,35 @@
assert_approx_equals(box.height, 700, epsilon, "height");
}, `inline-size and block-size properties on ${tag}`);

// Test that if we specify a size smaller than the content, then
// it is used too. Note that we skip mtable, which follows CSS
// tables rules and behave differently in that case.
if (tag != "mtable") {
test(function() {
assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`);
var style = `width: 2px; height: 1px;`;
element.setAttribute("style", style);
let box = element.getBoundingClientRect();
assert_approx_equals(box.width, 2, epsilon, "width");
assert_approx_equals(box.height, 1, epsilon, "height");
}, `width and height properties on ${tag} (content overflowing)`);
}

div.style = "display: none;"; // Hide the div after measurement.

document.body.insertAdjacentHTML("beforeend", `<div style="position: absolute;"><div style="display: inline-block"><math><mrow>${MathMLFragments[tag]}</mrow></math></div></div>`);
let shrinkWrapDiv = document.body.lastElementChild.firstElementChild;
element = FragmentHelper.element(shrinkWrapDiv.firstElementChild);
FragmentHelper.forceNonEmptyDescendants(element);

test(function() {
assert_true(MathMLFeatureDetection[`has_${tag}`](), `${tag} is supported`);
var style = `width: 300px;`;
element.setAttribute("style", style);
let box = shrinkWrapDiv.getBoundingClientRect();
assert_approx_equals(box.width, 300, epsilon);
}, `width property on ${tag} (preferred width)`);

div.style = "display: none;"; // Hide the div after measurement.
}

Expand Down
63 changes: 62 additions & 1 deletion mathml/relations/css-styling/width-height-004.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
}
[data-name] {
width: 7em;
height: 3em;
border: 1px solid blue;
}
</style>
Expand Down Expand Up @@ -64,6 +63,18 @@
<mtext>X</mtext>
</mfrac>
</math>
<math>
<mfrac data-name="mfrac (horizontal overflow)">
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
</mfrac>
</math>
<math dir="rtl">
<mfrac data-name="RTL mfrac (horizontal overflow)">
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
</mfrac>
</math>
</div>

<div class="test">
Expand All @@ -79,6 +90,18 @@
<mtext>X</mtext>
</mfrac>
</math>
<math>
<mfrac linethickness="0" data-name="mfrac without bar (horizontal overflow)">
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
</mfrac>
</math>
<math dir="rtl">
<mfrac linethickness="0" data-name="RTL mfrac without bar (horizontal overflow)">
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
</mfrac>
</math>
</div>

<div class="test">
Expand All @@ -94,6 +117,18 @@
<mtext>X</mtext>
</munder>
</math>
<math>
<munder data-name="munder (horizontal overflow)">
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
</munder>
</math>
<math dir="rtl">
<munder data-name="RTL munder (horizontal overflow)">
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
</munder>
</math>
</div>

<div class="test">
Expand All @@ -109,6 +144,18 @@
<mtext>X</mtext>
</mover>
</math>
<math>
<mover data-name="mover (horizontal overflow)">
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
</mover>
</math>
<math dir="rtl">
<mover data-name="RTL mover (horizontal overflow)">
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
</mover>
</math>
</div>

<div class="test">
Expand All @@ -126,6 +173,20 @@
<mtext>X</mtext>
</munderover>
</math>
<math>
<munderover data-name="munderover (horizontal overflow)">
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
</munderover>
</math>
<math dir="rtl">
<munderover data-name="RTL munderover (horizontal overflow)">
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
<mtext>XXXXXXXXXXXX</mtext>
</munderover>
</math>
</div>

</body>
Expand Down
Loading