Skip to content

Commit

Permalink
Bug 1548529 - Remove values "thin", "thick", "medium" values of mfrac…
Browse files Browse the repository at this point in the history
…@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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
fred-wang committed Aug 16, 2019
1 parent c762d7b commit 7175f01
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 27 deletions.
45 changes: 28 additions & 17 deletions layout/mathml/nsMathMLmfracFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "mozilla/gfx/2D.h"
#include "mozilla/PresShell.h"
#include "mozilla/RefPtr.h"
#include "mozilla/StaticPrefs_mathml.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"
#include "nsDisplayList.h"
Expand Down Expand Up @@ -103,28 +104,38 @@ nscoord nsMathMLmfracFrame::CalcLineThickness(nsPresContext* aPresContext,
// default: medium
//
if (!aThicknessAttribute.IsEmpty()) {
if (aThicknessAttribute.EqualsLiteral("thin")) {
lineThickness = NSToCoordFloor(defaultThickness * THIN_FRACTION_LINE);
minimumThickness = onePixel * THIN_FRACTION_LINE_MINIMUM_PIXELS;
// should visually decrease by at least one pixel, if default is not a
// pixel
if (defaultThickness > onePixel &&
lineThickness > defaultThickness - onePixel)
lineThickness = defaultThickness - onePixel;
} else if (aThicknessAttribute.EqualsLiteral("medium")) {
// medium is default
} else if (aThicknessAttribute.EqualsLiteral("thick")) {
lineThickness = NSToCoordCeil(defaultThickness * THICK_FRACTION_LINE);
minimumThickness = onePixel * THICK_FRACTION_LINE_MINIMUM_PIXELS;
// should visually increase by at least one pixel
if (lineThickness < defaultThickness + onePixel)
lineThickness = defaultThickness + onePixel;
} else {
if (StaticPrefs::mathml_mfrac_linethickness_names_disabled()) {
// length value
lineThickness = defaultThickness;
ParseNumericValue(aThicknessAttribute, &lineThickness,
nsMathMLElement::PARSE_ALLOW_UNITLESS, aPresContext,
aComputedStyle, aFontSizeInflation);
} else {
if (aThicknessAttribute.EqualsLiteral("thin")) {
lineThickness = NSToCoordFloor(defaultThickness * THIN_FRACTION_LINE);
minimumThickness = onePixel * THIN_FRACTION_LINE_MINIMUM_PIXELS;
// should visually decrease by at least one pixel, if default is not a
// pixel
if (defaultThickness > onePixel &&
lineThickness > defaultThickness - onePixel) {
lineThickness = defaultThickness - onePixel;
}
} else if (aThicknessAttribute.EqualsLiteral("medium")) {
// medium is default
} else if (aThicknessAttribute.EqualsLiteral("thick")) {
lineThickness = NSToCoordCeil(defaultThickness * THICK_FRACTION_LINE);
minimumThickness = onePixel * THICK_FRACTION_LINE_MINIMUM_PIXELS;
// should visually increase by at least one pixel
if (lineThickness < defaultThickness + onePixel) {
lineThickness = defaultThickness + onePixel;
}
} else {
// length value
lineThickness = defaultThickness;
ParseNumericValue(aThicknessAttribute, &lineThickness,
nsMathMLElement::PARSE_ALLOW_UNITLESS, aPresContext,
aComputedStyle, aFontSizeInflation);
}
}
}

Expand Down
13 changes: 10 additions & 3 deletions layout/mathml/tests/test_bug553917.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@
<math><mspace width="2"/></math>
<math><mo lspace="BADlspace">+</mo></math>
<math><mspace height="BADheight"/></math>
<math><mspace depth="BADdepth"/></math>*/
<math><mspace depth="BADdepth"/></math>
<math><mfrac linethickness="thin"><mn>1</mn><mn>2</mn></mfrac></math>
<math><mfrac linethickness="medium"><mn>1</mn><mn>2</mn></mfrac></math>
<math><mfrac linethickness="thick"><mn>1</mn><mn>2</mn></mfrac></math>
*/
LengthParsingError : {
status: [false, false, false, false, false, false],
args: [["2..0"], ["1.5notaunit"], ["2"],["BADlspace"],["BADheight"],["BADdepth"]]
status: [false, false, false, false, false, false, false, false, false],
args: [["2..0"], ["1.5notaunit"], ["2"],["BADlspace"],["BADheight"],["BADdepth"], ["thin"],["medium"],["thick"]]
},
/*<math><mmultiscripts></mmultiscripts></math>
<math><mmultiscripts><mprescripts/><mprescripts/></mmultiscripts></math>
Expand Down Expand Up @@ -157,6 +161,9 @@
<math><mo lspace="BADlspace">+</mo></math>
<math><mspace height="BADheight"/></math>
<math><mspace depth="BADdepth"/></math>
<math><mfrac linethickness="thin"><mn>1</mn><mn>2</mn></mfrac></math>
<math><mfrac linethickness="medium"><mn>1</mn><mn>2</mn></mfrac></math>
<math><mfrac linethickness="thick"><mn>1</mn><mn>2</mn></mfrac></math>

<!-- MMultiscriptsErrors -->
<math><mmultiscripts></mmultiscripts></math>
Expand Down
2 changes: 1 addition & 1 deletion layout/reftests/mathml/mstyle-1.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<tr>
<td>mfrac: bevelled, linethickness</td>
<td><math xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle bevelled="true" linethickness="thick">
<mstyle bevelled="true" linethickness="10px">
<mfrac>
<mi>a</mi>
<mi>b</mi>
Expand Down
12 changes: 6 additions & 6 deletions layout/reftests/mathml/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ random-if(gtkWidget) == mpadded-9.html mpadded-9-ref.html # bug 1309430
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == munderover-align-accent-true.html munderover-align-accent-true-ref.html # Bug 1392106
== munder-mover-align-accent-true.html munder-mover-align-accent-true-ref.html
== munder-mover-align-accent-false.html munder-mover-align-accent-false-ref.html
== mfrac-linethickness-1.xhtml mfrac-linethickness-1-ref.xhtml
pref(mathml.mfrac_linethickness_names.disabled,false) == mfrac-linethickness-1.xhtml mfrac-linethickness-1-ref.xhtml
== mfrac-linethickness-2.xhtml mfrac-linethickness-2-ref.xhtml
== mfrac-linethickness-3.xhtml mfrac-linethickness-3-ref.xhtml
== mathml-negativespace.html mathml-negativespace-ref.html
Expand Down Expand Up @@ -341,23 +341,23 @@ random-if(gtkWidget) == rowlines-3-2.html rowlines-3-2-ref.html # bug 1309426
== mfrac-A-2.html mfrac-A-2-ref.html
== mfrac-A-3.html mfrac-A-3-ref.html
== mfrac-A-4.html mfrac-A-4-ref.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == mfrac-A-5.html mfrac-A-5-ref.html # bug 1309426
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
== mfrac-A-6.html mfrac-A-6-ref.html
== mfrac-A-7.html mfrac-A-7-ref.html
== mfrac-A-8.html mfrac-A-8-ref.html
== mfrac-B-1.html mfrac-B-1-ref.html
== mfrac-B-2.html mfrac-B-2-3-ref.html
== mfrac-B-3.html mfrac-B-2-3-ref.html
pref(mathml.mfrac_linethickness_names.disabled,false) == mfrac-B-2.html mfrac-B-2-3-ref.html
pref(mathml.mfrac_linethickness_names.disabled,false) == mfrac-B-3.html mfrac-B-2-3-ref.html
fuzzy-if(geckoview&&webrender,0-198,0-781) == mfrac-B-4.html mfrac-B-4-5-ref.html
== mfrac-B-5.html mfrac-B-4-5-ref.html
fuzzy-if(geckoview&&webrender,0-198,0-781) == mfrac-B-6.html mfrac-B-6-7-ref.html
== mfrac-B-7.html mfrac-B-6-7-ref.html
fuzzy-if(OSX,0-1,0-100) fuzzy-if(skiaContent,0-1,0-14) == mfrac-C-1.html mfrac-C-1-ref.html
== mfrac-C-2.html mfrac-C-2-ref.html
pref(mathml.mfrac_linethickness_names.disabled,false) == mfrac-C-2.html mfrac-C-2-ref.html
fuzzy-if(geckoview&&webrender,0-198,0-776) == mfrac-C-3.html mfrac-C-3-ref.html
fuzzy-if(geckoview&&webrender,0-198,0-270) == mfrac-C-4.html mfrac-C-4-ref.html
fuzzy-if(OSX,0-1,0-100) fuzzy-if(skiaContent,0-1,0-14) == mfrac-D-1.html mfrac-D-1-ref.html
== mfrac-D-2.html mfrac-D-2-ref.html
pref(mathml.mfrac_linethickness_names.disabled,false) == mfrac-D-2.html mfrac-D-2-ref.html
fuzzy-if(geckoview&&webrender,0-198,0-776) == mfrac-D-3.html mfrac-D-3-ref.html
fuzzy-if(geckoview&&webrender,0-198,0-270) == mfrac-D-4.html mfrac-D-4-ref.html
== mfrac-E-1.html mfrac-E-1-ref.html
Expand Down
11 changes: 11 additions & 0 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4880,6 +4880,17 @@
value: @IS_NIGHTLY_BUILD@
mirror: always

#---------------------------------------------------------------------------
# Prefs starting with "mathml."
#---------------------------------------------------------------------------

# Whether to disable legacy names "thin", "thick" and "medium" for the
# linethickness attribute of the mfrac element.
- name: mathml.mfrac_linethickness_names.disabled
type: bool
value: @IS_NIGHTLY_BUILD@
mirror: always

#---------------------------------------------------------------------------
# Prefs starting with "media."
#---------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions modules/libpref/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pref_groups = [
'keyword',
'layers',
'layout',
'mathml',
'media',
'mousewheel',
'network',
Expand Down

0 comments on commit 7175f01

Please sign in to comment.