Skip to content

Commit d4d0c85

Browse files
committed
Bug 1548529 - Remove values "thin", "thick", "medium" values of mfrac@linethickness. r=emilio
See w3c/mathml#4 and https://groups.google.com/forum/#!topic/mozilla.dev.platform/G91-vBeC3Rw This commit introduces a new preference option mathml.mfrac_linethickness_names.disabled to disable linethickness names. For now, these names are only disabled in Nightly builds. Announcements and actual disabling of this and other MathML features will be considered later. * test_bug553917.html is updated to check that these values now cause an error message to be logged into the console. * mstyle-1.xhtml is updated to use a numeric linethickness since the point of the test is just to check that the attribute is not supported on mstyle, not about the actual attribute value. * Other fractions tests relying on linethickness names are executed with the proper preference adjustment. * mathml/presentation-markup/fractions/frac-linethickness-001.html is now closer to its expectation ; however the test still fails because nonzero unitless values are not removed yet. See w3c/mathml#24 Differential Revision: https://phabricator.services.mozilla.com/D42323
1 parent 2129052 commit d4d0c85

File tree

6 files changed

+57
-27
lines changed

6 files changed

+57
-27
lines changed

layout/mathml/nsMathMLmfracFrame.cpp

+28-17
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "mozilla/gfx/2D.h"
1111
#include "mozilla/PresShell.h"
1212
#include "mozilla/RefPtr.h"
13+
#include "mozilla/StaticPrefs_mathml.h"
1314
#include "nsLayoutUtils.h"
1415
#include "nsPresContext.h"
1516
#include "nsDisplayList.h"
@@ -103,28 +104,38 @@ nscoord nsMathMLmfracFrame::CalcLineThickness(nsPresContext* aPresContext,
103104
// default: medium
104105
//
105106
if (!aThicknessAttribute.IsEmpty()) {
106-
if (aThicknessAttribute.EqualsLiteral("thin")) {
107-
lineThickness = NSToCoordFloor(defaultThickness * THIN_FRACTION_LINE);
108-
minimumThickness = onePixel * THIN_FRACTION_LINE_MINIMUM_PIXELS;
109-
// should visually decrease by at least one pixel, if default is not a
110-
// pixel
111-
if (defaultThickness > onePixel &&
112-
lineThickness > defaultThickness - onePixel)
113-
lineThickness = defaultThickness - onePixel;
114-
} else if (aThicknessAttribute.EqualsLiteral("medium")) {
115-
// medium is default
116-
} else if (aThicknessAttribute.EqualsLiteral("thick")) {
117-
lineThickness = NSToCoordCeil(defaultThickness * THICK_FRACTION_LINE);
118-
minimumThickness = onePixel * THICK_FRACTION_LINE_MINIMUM_PIXELS;
119-
// should visually increase by at least one pixel
120-
if (lineThickness < defaultThickness + onePixel)
121-
lineThickness = defaultThickness + onePixel;
122-
} else {
107+
if (StaticPrefs::mathml_mfrac_linethickness_names_disabled()) {
123108
// length value
124109
lineThickness = defaultThickness;
125110
ParseNumericValue(aThicknessAttribute, &lineThickness,
126111
nsMathMLElement::PARSE_ALLOW_UNITLESS, aPresContext,
127112
aComputedStyle, aFontSizeInflation);
113+
} else {
114+
if (aThicknessAttribute.EqualsLiteral("thin")) {
115+
lineThickness = NSToCoordFloor(defaultThickness * THIN_FRACTION_LINE);
116+
minimumThickness = onePixel * THIN_FRACTION_LINE_MINIMUM_PIXELS;
117+
// should visually decrease by at least one pixel, if default is not a
118+
// pixel
119+
if (defaultThickness > onePixel &&
120+
lineThickness > defaultThickness - onePixel) {
121+
lineThickness = defaultThickness - onePixel;
122+
}
123+
} else if (aThicknessAttribute.EqualsLiteral("medium")) {
124+
// medium is default
125+
} else if (aThicknessAttribute.EqualsLiteral("thick")) {
126+
lineThickness = NSToCoordCeil(defaultThickness * THICK_FRACTION_LINE);
127+
minimumThickness = onePixel * THICK_FRACTION_LINE_MINIMUM_PIXELS;
128+
// should visually increase by at least one pixel
129+
if (lineThickness < defaultThickness + onePixel) {
130+
lineThickness = defaultThickness + onePixel;
131+
}
132+
} else {
133+
// length value
134+
lineThickness = defaultThickness;
135+
ParseNumericValue(aThicknessAttribute, &lineThickness,
136+
nsMathMLElement::PARSE_ALLOW_UNITLESS, aPresContext,
137+
aComputedStyle, aFontSizeInflation);
138+
}
128139
}
129140
}
130141

layout/mathml/tests/test_bug553917.html

+10-3
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@
5252
<math><mspace width="2"/></math>
5353
<math><mo lspace="BADlspace">+</mo></math>
5454
<math><mspace height="BADheight"/></math>
55-
<math><mspace depth="BADdepth"/></math>*/
55+
<math><mspace depth="BADdepth"/></math>
56+
<math><mfrac linethickness="thin"><mn>1</mn><mn>2</mn></mfrac></math>
57+
<math><mfrac linethickness="medium"><mn>1</mn><mn>2</mn></mfrac></math>
58+
<math><mfrac linethickness="thick"><mn>1</mn><mn>2</mn></mfrac></math>
59+
*/
5660
LengthParsingError : {
57-
status: [false, false, false, false, false, false],
58-
args: [["2..0"], ["1.5notaunit"], ["2"],["BADlspace"],["BADheight"],["BADdepth"]]
61+
status: [false, false, false, false, false, false, false, false, false],
62+
args: [["2..0"], ["1.5notaunit"], ["2"],["BADlspace"],["BADheight"],["BADdepth"], ["thin"],["medium"],["thick"]]
5963
},
6064
/*<math><mmultiscripts></mmultiscripts></math>
6165
<math><mmultiscripts><mprescripts/><mprescripts/></mmultiscripts></math>
@@ -157,6 +161,9 @@
157161
<math><mo lspace="BADlspace">+</mo></math>
158162
<math><mspace height="BADheight"/></math>
159163
<math><mspace depth="BADdepth"/></math>
164+
<math><mfrac linethickness="thin"><mn>1</mn><mn>2</mn></mfrac></math>
165+
<math><mfrac linethickness="medium"><mn>1</mn><mn>2</mn></mfrac></math>
166+
<math><mfrac linethickness="thick"><mn>1</mn><mn>2</mn></mfrac></math>
160167

161168
<!-- MMultiscriptsErrors -->
162169
<math><mmultiscripts></mmultiscripts></math>

layout/reftests/mathml/mstyle-1.xhtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<tr>
3939
<td>mfrac: bevelled, linethickness</td>
4040
<td><math xmlns="http://www.w3.org/1998/Math/MathML">
41-
<mstyle bevelled="true" linethickness="thick">
41+
<mstyle bevelled="true" linethickness="10px">
4242
<mfrac>
4343
<mi>a</mi>
4444
<mi>b</mi>

layout/reftests/mathml/reftest.list

+6-6
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ random-if(gtkWidget) == mpadded-9.html mpadded-9-ref.html # bug 1309430
149149
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == munderover-align-accent-true.html munderover-align-accent-true-ref.html # Bug 1392106
150150
== munder-mover-align-accent-true.html munder-mover-align-accent-true-ref.html
151151
== munder-mover-align-accent-false.html munder-mover-align-accent-false-ref.html
152-
== mfrac-linethickness-1.xhtml mfrac-linethickness-1-ref.xhtml
152+
pref(mathml.mfrac_linethickness_names.disabled,false) == mfrac-linethickness-1.xhtml mfrac-linethickness-1-ref.xhtml
153153
== mfrac-linethickness-2.xhtml mfrac-linethickness-2-ref.xhtml
154154
== mfrac-linethickness-3.xhtml mfrac-linethickness-3-ref.xhtml
155155
== mathml-negativespace.html mathml-negativespace-ref.html
@@ -341,23 +341,23 @@ random-if(gtkWidget) == rowlines-3-2.html rowlines-3-2-ref.html # bug 1309426
341341
== mfrac-A-2.html mfrac-A-2-ref.html
342342
== mfrac-A-3.html mfrac-A-3-ref.html
343343
== mfrac-A-4.html mfrac-A-4-ref.html
344-
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == mfrac-A-5.html mfrac-A-5-ref.html # bug 1309426
344+
pref(mathml.mfrac_linethickness_names.disabled,false) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == mfrac-A-5.html mfrac-A-5-ref.html # bug 1309426
345345
== mfrac-A-6.html mfrac-A-6-ref.html
346346
== mfrac-A-7.html mfrac-A-7-ref.html
347347
== mfrac-A-8.html mfrac-A-8-ref.html
348348
== mfrac-B-1.html mfrac-B-1-ref.html
349-
== mfrac-B-2.html mfrac-B-2-3-ref.html
350-
== mfrac-B-3.html mfrac-B-2-3-ref.html
349+
pref(mathml.mfrac_linethickness_names.disabled,false) == mfrac-B-2.html mfrac-B-2-3-ref.html
350+
pref(mathml.mfrac_linethickness_names.disabled,false) == mfrac-B-3.html mfrac-B-2-3-ref.html
351351
fuzzy-if(geckoview&&webrender,0-198,0-781) == mfrac-B-4.html mfrac-B-4-5-ref.html
352352
== mfrac-B-5.html mfrac-B-4-5-ref.html
353353
fuzzy-if(geckoview&&webrender,0-198,0-781) == mfrac-B-6.html mfrac-B-6-7-ref.html
354354
== mfrac-B-7.html mfrac-B-6-7-ref.html
355355
fuzzy-if(OSX,0-1,0-100) fuzzy-if(skiaContent,0-1,0-14) == mfrac-C-1.html mfrac-C-1-ref.html
356-
== mfrac-C-2.html mfrac-C-2-ref.html
356+
pref(mathml.mfrac_linethickness_names.disabled,false) == mfrac-C-2.html mfrac-C-2-ref.html
357357
fuzzy-if(geckoview&&webrender,0-198,0-776) == mfrac-C-3.html mfrac-C-3-ref.html
358358
fuzzy-if(geckoview&&webrender,0-198,0-270) == mfrac-C-4.html mfrac-C-4-ref.html
359359
fuzzy-if(OSX,0-1,0-100) fuzzy-if(skiaContent,0-1,0-14) == mfrac-D-1.html mfrac-D-1-ref.html
360-
== mfrac-D-2.html mfrac-D-2-ref.html
360+
pref(mathml.mfrac_linethickness_names.disabled,false) == mfrac-D-2.html mfrac-D-2-ref.html
361361
fuzzy-if(geckoview&&webrender,0-198,0-776) == mfrac-D-3.html mfrac-D-3-ref.html
362362
fuzzy-if(geckoview&&webrender,0-198,0-270) == mfrac-D-4.html mfrac-D-4-ref.html
363363
== mfrac-E-1.html mfrac-E-1-ref.html

modules/libpref/init/StaticPrefList.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -4880,6 +4880,17 @@
48804880
value: @IS_NIGHTLY_BUILD@
48814881
mirror: always
48824882

4883+
#---------------------------------------------------------------------------
4884+
# Prefs starting with "mathml."
4885+
#---------------------------------------------------------------------------
4886+
4887+
# Whether to disable legacy names "thin", "thick" and "medium" for the
4888+
# linethickness attribute of the mfrac element.
4889+
- name: mathml.mfrac_linethickness_names.disabled
4890+
type: bool
4891+
value: @IS_NIGHTLY_BUILD@
4892+
mirror: always
4893+
48834894
#---------------------------------------------------------------------------
48844895
# Prefs starting with "media."
48854896
#---------------------------------------------------------------------------

modules/libpref/moz.build

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pref_groups = [
5454
'keyword',
5555
'layers',
5656
'layout',
57+
'mathml',
5758
'media',
5859
'mousewheel',
5960
'network',

0 commit comments

Comments
 (0)