Bug 1240799 - Apply axis height for mfrac elements without bar. r=fredw

This commit is contained in:
James Kitchener 2016-02-20 02:59:00 +01:00
parent cca1f2884f
commit afc6912cf5
23 changed files with 484 additions and 1 deletions

View File

@ -0,0 +1,32 @@
Tests in this directory have been imported from
https://github.com/MathML/MathMLinHTML5-tests
Copyright (c) 2016 MathML Association
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,23 @@
[DEFAULT]
[test_fraction-parameters.html]
support-files =
fonts/fraction-axisheight7000-rulethickness1000.woff
fonts/fraction-denominatordisplaystylegapmin5000-rulethickness1000.woff
fonts/fraction-denominatordisplaystyleshiftdown6000-rulethickness1000.woff
fonts/fraction-denominatorgapmin4000-rulethickness1000.woff
fonts/fraction-denominatorshiftdown3000-rulethickness1000.woff
fonts/fraction-numeratordisplaystylegapmin8000-rulethickness1000.woff
fonts/fraction-numeratordisplaystyleshiftup2000-rulethickness1000.woff
fonts/fraction-numeratorgapmin9000-rulethickness1000.woff
fonts/fraction-numeratorshiftup11000-rulethickness1000.woff
fonts/fraction-rulethickness10000.woff
[test_stack-parameters.html]
support-files =
fonts/stack-axisheight7000.woff
fonts/stack-bottomdisplaystyleshiftdown5000.woff
fonts/stack-bottomshiftdown6000.woff
fonts/stack-displaystylegapmin4000.woff
fonts/stack-gapmin8000.woff
fonts/stack-topdisplaystyleshiftup3000.woff
fonts/stack-topshiftup9000.woff

View File

@ -0,0 +1,244 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fraction parameters</title>
<link rel="help" href="http://www.mathml-association.org/MathMLinHTML5/S3.html#SS3.SSS2">
<meta name="assert" content="Element mfrac correctly uses the fraction parameters from the MATH table.">
<!-- Copyright 2016 MathML Association
Licensed under 3-Clause BSD-License -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
math, mspace {
font-size: 10px;
}
@font-face {
font-family: axisheight7000-rulethickness1000;
src: url("fonts/fraction-axisheight7000-rulethickness1000.woff");
}
@font-face {
font-family: denominatordisplaystylegapmin5000-rulethickness1000;
src: url("fonts/fraction-denominatordisplaystylegapmin5000-rulethickness1000.woff");
}
@font-face {
font-family: denominatordisplaystyleshiftdown6000-rulethickness1000;
src: url("fonts/fraction-denominatordisplaystyleshiftdown6000-rulethickness1000.woff");
}
@font-face {
font-family: denominatorgapmin4000-rulethickness1000;
src: url("fonts/fraction-denominatorgapmin4000-rulethickness1000.woff");
}
@font-face {
font-family: denominatorshiftdown3000-rulethickness1000;
src: url("fonts/fraction-denominatorshiftdown3000-rulethickness1000.woff");
}
@font-face {
font-family: numeratordisplaystylegapmin8000-rulethickness1000;
src: url("fonts/fraction-numeratordisplaystylegapmin8000-rulethickness1000.woff");
}
@font-face {
font-family: numeratordisplaystyleshiftup2000-rulethickness1000;
src: url("fonts/fraction-numeratordisplaystyleshiftup2000-rulethickness1000.woff");
}
@font-face {
font-family: numeratorgapmin9000-rulethickness1000;
src: url("fonts/fraction-numeratorgapmin9000-rulethickness1000.woff");
}
@font-face {
font-family: numeratorshiftup11000-rulethickness1000;
src: url("fonts/fraction-numeratorshiftup11000-rulethickness1000.woff");
}
@font-face {
font-family: rulethickness10000;
src: url("fonts/fraction-rulethickness10000.woff");
}
</style>
<script>
var emToPx = 10 / 1000; // font-size: 10px, font.em = 1000
var epsilon = 1;
function getBox(aId) {
return document.getElementById(aId).getBoundingClientRect();
}
var test_loaded = async_test("Page Loaded");
window.addEventListener("load", function() {
// FIXME: Use an API to wait for the Web fonts to arrive.
window.setTimeout(runTests, 250);
});
function runTests() {
test(function() {
var v1 = 7000 * emToPx;
var v2 = 1000 * emToPx;
assert_approx_equals(getBox("ref0001").top - getBox("num0001").bottom,
v1 + v2 / 2, epsilon, "mfrac: axis height");
}, "AxisHeight");
test(function() {
var v1 = 5000 * emToPx;
assert_approx_equals(getBox("den0002").top - getBox("ref0002").bottom,
v1, epsilon, "mfrac: denominator gap");
}, "DenominatorDisplayStyleGapMin");
test(function() {
var v1 = 6000 * emToPx;
assert_approx_equals(getBox("den0003").top - getBox("ref0003").bottom,
v1, epsilon, "mfrac: denominator shift");
}, "DenominatorDisplayStyleShiftDown");
test(function() {
var v1 = 4000 * emToPx;
assert_approx_equals(getBox("den0004").top - getBox("ref0004").bottom,
v1, epsilon, "mfrac: denominator gap");
}, "DenominatorGapMin");
test(function() {
var v1 = 3000 * emToPx;
assert_approx_equals(getBox("den0005").top - getBox("ref0005").bottom,
v1, epsilon, "mfrac: denominator shift");
}, "DenominatorShiftDown");
test(function() {
var v1 = 8000 * emToPx;
assert_approx_equals(getBox("ref0006").top - getBox("num0006").bottom,
v1, epsilon, "mfrac: numerator gap");
}, "NumeratorDisplayStyleGapMin");
test(function() {
var v1 = 2000 * emToPx;
assert_approx_equals(getBox("ref0007").top - getBox("num0007").bottom,
v1, epsilon, "mfrac: numerator shift");
}, "NumeratorDisplayStyleShiftDown");
test(function() {
var v1 = 9000 * emToPx;
assert_approx_equals(getBox("ref0008").top - getBox("num0008").bottom,
v1, epsilon, "mfrac: numerator gap");
}, "NumeratorGapMin");
test(function() {
var v1 = 11000 * emToPx;
assert_approx_equals(getBox("ref0009").top - getBox("num0009").bottom,
v1, epsilon, "mfrac: numerator shift");
}, "NumeratorShiftDown");
test(function() {
var v1 = 10000 * emToPx;
assert_approx_equals(getBox("den0010").top - getBox("num0010").bottom,
v1, epsilon, "mfrac: rule thickness");
}, "FractionRuleThickness");
test_loaded.done();
}
</script>
</head>
<body>
<p>
<math style="font-family: axisheight7000-rulethickness1000;">
<mspace id="ref0001" depth="1em" width="3em" mathbackground="green"/>
<mfrac>
<mspace width="3em" height="1em" id="num0001" mathbackground="blue"/>
<mspace width="3em"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math display="block" style="font-family: denominatordisplaystylegapmin5000-rulethickness1000;">
<mspace id="ref0002" width="3em"
height=".5em" depth=".5em" mathbackground="green"/>
<mfrac>
<mspace width="3em"/>
<mspace width="3em" height="1em" id="den0002" mathbackground="blue"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math display="block" style="font-family: denominatordisplaystyleshiftdown6000-rulethickness1000;">
<mspace id="ref0003" width="3em" height="1em" mathbackground="green"/>
<mfrac>
<mspace width="3em"/>
<mspace width="3em" depth="1em" id="den0003" mathbackground="blue"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math style="font-family: denominatorgapmin4000-rulethickness1000;">
<mspace id="ref0004" width="3em"
height=".5em" depth=".5em" mathbackground="green"/>
<mfrac>
<mspace width="3em"/>
<mspace width="3em" height="1em" id="den0004" mathbackground="blue"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math style="font-family: denominatorshiftdown3000-rulethickness1000;">
<mspace id="ref0005" width="3em" height="1em" mathbackground="green"/>
<mfrac>
<mspace width="3em"/>
<mspace width="3em" depth="1em" id="den0005" mathbackground="blue"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math display="block" style="font-family: numeratordisplaystylegapmin8000-rulethickness1000;">
<mspace id="ref0006" width="3em"
height=".5em" depth=".5em" mathbackground="green"/>
<mfrac>
<mspace width="3em" depth="1em" id="num0006" mathbackground="blue"/>
<mspace width="3em"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math display="block" style="font-family: numeratordisplaystyleshiftup2000-rulethickness1000;">
<mspace id="ref0007" width="3em"
depth="1em" mathbackground="green"/>
<mfrac>
<mspace width="3em" height="1em" id="num0007" mathbackground="blue"/>
<mspace width="3em"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math style="font-family: numeratorgapmin9000-rulethickness1000;">
<mspace id="ref0008" width="3em"
height=".5em" depth=".5em" mathbackground="green"/>
<mfrac>
<mspace width="3em" depth="1em" id="num0008" mathbackground="blue"/>
<mspace width="3em"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math style="font-family: numeratorshiftup11000-rulethickness1000;">
<mspace id="ref0009" width="3em"
depth="1em" mathbackground="green"/>
<mfrac>
<mspace width="3em" height="1em" id="num0009" mathbackground="blue"/>
<mspace width="3em"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math style="font-family: rulethickness10000">
<mfrac>
<mspace width="3em" height="1em" id="num0010" mathbackground="blue"/>
<mspace width="3em" depth="1em" id="den0010" mathbackground="green"/>
</mfrac>
</math>
</p>
<hr/>
</body>
</html>

View File

@ -0,0 +1,176 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Stack parameters</title>
<link rel="help" href="http://www.mathml-association.org/MathMLinHTML5/S3.html#SS3.SSS2">
<meta name="assert" content="Element mfrac correctly uses the stack parameters from the MATH table.">
<!-- Copyright 2016 MathML Association
Licensed under 3-Clause BSD-License -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
math, mspace {
font-size: 10px;
}
@font-face {
font-family: axisheight7000;
src: url("fonts/stack-axisheight7000.woff");
}
@font-face {
font-family: bottomdisplaystyleshiftdown5000;
src: url("fonts/stack-bottomdisplaystyleshiftdown5000.woff");
}
@font-face {
font-family: bottomshiftdown6000;
src: url("fonts/stack-bottomshiftdown6000.woff");
}
@font-face {
font-family: displaystylegapmin4000;
src: url("fonts/stack-displaystylegapmin4000.woff");
}
@font-face {
font-family: gapmin8000;
src: url("fonts/stack-gapmin8000.woff");
}
@font-face {
font-family: topdisplaystyleshiftup3000;
src: url("fonts/stack-topdisplaystyleshiftup3000.woff");
}
@font-face {
font-family: topshiftup9000;
src: url("fonts/stack-topshiftup9000.woff");
}
</style>
<script>
var emToPx = 10 / 1000; // font-size: 10px, font.em = 1000
var epsilon = 1;
function getBox(aId) {
return document.getElementById(aId).getBoundingClientRect();
}
var test_loaded = async_test("Page Loaded");
window.addEventListener("load", function() {
// FIXME: Use an API to wait for the Web fonts to arrive.
window.setTimeout(runTests, 250);
});
function runTests() {
test(function() {
var v = 7000 * emToPx;
assert_approx_equals(getBox("ref0001").top - getBox("num0001").bottom,
v, epsilon, "mfrac: axis height");
}, "AxisHeight");
test(function() {
var v = 5000 * emToPx;
assert_approx_equals(getBox("den0002").top - getBox("ref0002").bottom,
v, epsilon, "mfrac: denominator shift");
}, "BottomDisplayStyleShiftDown");
test(function() {
var v = 6000 * emToPx;
assert_approx_equals(getBox("den0003").top - getBox("ref0003").bottom,
v, epsilon, "mfrac: denominator shift");
}, "BottomShiftDown");
test(function() {
var v = 4000 * emToPx;
assert_approx_equals(getBox("den0004").top - getBox("num0004").bottom,
v, epsilon, "mfrac: gap");
}, "DisplayStyleGapMin");
test(function() {
var v = 8000 * emToPx;
assert_approx_equals(getBox("den0005").top - getBox("num0005").bottom,
v, epsilon, "mfrac: gap");
}, "GapMin");
test(function() {
var v = 3000 * emToPx;
assert_approx_equals(getBox("ref0006").top - getBox("num0006").bottom,
v, epsilon, "mfrac: numerator shift");
}, "TopDisplayStyleShiftUp");
test(function() {
var v = 9000 * emToPx;
assert_approx_equals(getBox("ref0007").top - getBox("num0007").bottom,
v, epsilon, "mfrac: numerator shift");
}, "ToShiftUp");
test_loaded.done();
}
</script>
</head>
<body>
<p>
<math style="font-family: axisheight7000;">
<mspace id="ref0001" depth="1em" width="3em" mathbackground="green"/>
<mfrac linethickness="0px">
<mspace width="3em" height="1em" id="num0001" mathbackground="blue"/>
<mspace width="3em"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math display="block" style="font-family: bottomdisplaystyleshiftdown5000;">
<mspace id="ref0002" width="3em" height="1em" mathbackground="green"/>
<mfrac linethickness="0px">
<mspace width="3em"/>
<mspace width="3em" depth="1em" id="den0002" mathbackground="blue"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math style="font-family: bottomshiftdown6000;">
<mspace id="ref0003" width="3em" height="1em" mathbackground="green"/>
<mfrac linethickness="0px">
<mspace width="3em"/>
<mspace width="3em" depth="1em" id="den0003" mathbackground="blue"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math display="block" style="font-family: displaystylegapmin4000;">
<mfrac linethickness="0px">
<mspace width="3em" height="1em" id="num0004" mathbackground="blue"/>
<mspace width="3em" depth="1em" id="den0004" mathbackground="green"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math style="font-family: gapmin8000;">
<mfrac linethickness="0px">
<mspace width="3em" height="1em" id="num0005" mathbackground="blue"/>
<mspace width="3em" depth="1em" id="den0005" mathbackground="green"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math display="block" style="font-family: topdisplaystyleshiftup3000;">
<mspace id="ref0006" width="3em" depth="1em" mathbackground="green"/>
<mfrac linethickness="0px">
<mspace width="3em" height="1em" id="num0006" mathbackground="blue"/>
<mspace width="3em"/>
</mfrac>
</math>
</p>
<hr/>
<p>
<math style="font-family: topshiftup9000;">
<mspace id="ref0007" width="3em" depth="1em" mathbackground="green"/>
<mfrac linethickness="0px">
<mspace width="3em" height="1em" id="num0007" mathbackground="blue"/>
<mspace width="3em"/>
</mfrac>
</math>
</p>
<hr/>
</body>
</html>

View File

@ -8,7 +8,10 @@ with Files('**'):
BUG_COMPONENT = ('Core', 'MathML')
if CONFIG['ENABLE_TESTS']:
MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
MOCHITEST_MANIFESTS += [
'imptests/mochitest.ini',
'tests/mochitest.ini',
]
UNIFIED_SOURCES += [
'nsMathMLChar.cpp',

View File

@ -333,6 +333,11 @@ nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget,
gfxFontEntry::StackGapMin,
oneDevPixel);
}
// Factor in axis height
// http://www.mathml-association.org/MathMLinHTML5/S3.html#SS3.SSS2
numShift += axisHeight;
denShift += axisHeight;
nscoord actualClearance =
(numShift - bmNum.descent) - (bmDen.ascent - denShift);
// actualClearance should be >= minClearance