-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mathml] Implement special drawing of largeop operator in displaystyle
This implements special drawing of largeop <mo> element in display style as described in step 3. of [1]. A new algorithm is introduced for that purpose and in particular only used for <mo> elements that are made of a single glyph. Existing painting logic for stretchy radical symbol is reused and adapted to work with largeop operators. [1] https://mathml-refresh.github.io/mathml-core/#layout-of-operators Bug: 6606 Change-Id: Icca70f4bf464417809970fecc101e5aa7f149621
- Loading branch information
1 parent
5168e59
commit 55927da
Showing
3 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
mathml/presentation-markup/operators/largeop-hit-testing.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Test hit testing on large operators</title> | ||
<meta name="assert" content="Verify that hit testing works on large operators."> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/mathml/support/feature-detection.js"></script> | ||
<style> | ||
@font-face { | ||
font-family: TestFont; | ||
src: url("/fonts/math/largeop-displayoperatorminheight5000.woff"); | ||
} | ||
mo { | ||
font-family: TestFont; | ||
font-size: 16px; | ||
} | ||
</style> | ||
<script> | ||
function getBox(aId) { | ||
return document.getElementById(aId).getBoundingClientRect(); | ||
} | ||
|
||
setup({ explicit_done: true }); | ||
window.addEventListener("load", () => { document.fonts.ready.then(runTests); }); | ||
|
||
function runTests() { | ||
|
||
test(function() { | ||
assert_true(MathMLFeatureDetection.has_operator_spacing()); | ||
|
||
let bbox = getBox("largeop"); | ||
let hit = document.getElementById("largeop"); | ||
let reference = getBox("reference"); | ||
assert_true(bbox.height > reference.height, "height of large op is bigger than the equivalent normal operator"); | ||
assert_equals(hit, document.elementFromPoint(bbox.left + 1, bbox.top + 1), "hit testing top-left corner of large op works"); | ||
assert_equals(hit, document.elementFromPoint(bbox.right - 1, bbox.bottom - 1), "hit testing bottom-right corner of large op works"); | ||
}, "Large op hit testing"); | ||
|
||
done(); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<math> | ||
<mtable> | ||
<mtr> | ||
<mtd> | ||
<mstyle displaystyle="false"> | ||
<mo id="reference">⫿</mo> | ||
</mstyle> | ||
</mtd> | ||
<mtd> | ||
<mstyle displaystyle="true"> | ||
<mo id="largeop">⫿</mo> | ||
</mstyle> | ||
</mtd> | ||
</mtr> | ||
</mtable> | ||
</math> | ||
</body> | ||
</html> |
18 changes: 18 additions & 0 deletions
18
mathml/relations/css-styling/padding-border-margin/padding-border-margin-002-ref.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>Padding/border/margin on largeop (reference)</title> | ||
<body> | ||
<p>This test passes if you see a cyan rectangle of width 300px and | ||
height 1500px, surrounded by a 10px blue padding, surrounded by a 10px | ||
blue/yellow dashed border, itself | ||
surrounded by a 10px pink margin.</p> | ||
</div> | ||
<div style="background: pink; position: absolute; left: 10px; top: 4em;"> | ||
<div style="background: blue; border: 10px dashed yellow; padding: 10px; margin: 10px;"> | ||
<div style="width: 300px; height: 1500px; background: cyan;"></div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
34 changes: 34 additions & 0 deletions
34
mathml/relations/css-styling/padding-border-margin/padding-border-margin-002.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>Padding/border/margin on largeop</title> | ||
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#layout-algorithms"> | ||
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#the-math-style-property"> | ||
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#layout-of-operators"> | ||
<link rel="match" href="padding-border-margin-002-ref.html"/> | ||
<meta name="assert" content="Verify visual rendering of padding/border/margin on a displaystyle mo element with the largeop property."> | ||
<style> | ||
@font-face { | ||
font-family: TestFont; | ||
src: url("/fonts/math/largeop-displayoperatorminheight5000.woff"); | ||
} | ||
math { | ||
/* Largeop variant for U+2AFF has width 100px | ||
and height 300 * 5000 / 1000 = 1500px */ | ||
font-family: TestFont; | ||
font-size: 300px; | ||
} | ||
</style> | ||
<body> | ||
<p>This test passes if you see a cyan rectangle of width 300px and | ||
height 1500px, surrounded by a 10px blue padding, surrounded by a 10px | ||
blue/yellow dashed border, itself | ||
surrounded by a 10px pink margin.</p> | ||
<div style="background: pink; position: absolute; left: 10px; top: 4em;"> | ||
<math displaystyle="true"> | ||
<mo largeop="true" lspace="0" rspace="0" style="background: blue; border: 10px dashed yellow; padding: 10px; margin: 10px; color: cyan;">⫿</mo> | ||
</math> | ||
</div> | ||
</body> | ||
</html> |