Skip to content

Commit

Permalink
Bug 1575596 - MathML Lengths: Do not accept numbers ending with a dot…
Browse files Browse the repository at this point in the history
…. r=emilio

See w3c/mathml#23
and https://groups.google.com/forum/#!topic/mozilla.dev.platform/wIjm9JjVHNg

This commit introduces a new preference option
mathml.legacy_number_syntax.disabled to disable legacy MathML numbers
(e.g. "1234.") that are not supported by CSS. This feature is now disabled by
default.

* test_bug553917.html is updated to check that such legacy values now cause an
  error message to be logged into the console when the feature is disabled.
* Legacy MathML features are now disabled for WPT mathml test in a global
  __dir__.ini file. Removing legacy numbers allow to pass
  mathml/relations/css-styling/lengths-2.html

Differential Revision: https://phabricator.services.mozilla.com/D42907

--HG--
extra : moz-landing-system : lando
  • Loading branch information
fred-wang committed Aug 21, 2019
1 parent 49c5b44 commit 90172ba
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 17 deletions.
7 changes: 7 additions & 0 deletions dom/mathml/nsMathMLElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,13 @@ bool nsMathMLElement::ParseNumericValue(const nsString& aString,
}
number.Append(c);
}
if (StaticPrefs::mathml_legacy_number_syntax_disabled() &&
gotDot && str[i - 1] == '.') {
if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
ReportLengthParseError(aString, aDocument);
}
return false; // Number ending with a dot.
}

// Convert number to floating point
nsresult errorCode;
Expand Down
5 changes: 5 additions & 0 deletions layout/mathml/tests/test_bug553917.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
const allow_mathsize_names = !SpecialPowers.getBoolPref('mathml.mathsize_names.disabled');
const allow_nonzero_unitless_lengths = !SpecialPowers.getBoolPref('mathml.nonzero_unitless_lengths.disabled');
const allow_mathspace_names = !SpecialPowers.getBoolPref('mathml.mathspace_names.disabled');
const allow_legacy_numbers = !SpecialPowers.getBoolPref('mathml.legacy_number_syntax.disabled');

var g_errorInfo = {
/*<math><mroot></mroot></math>
Expand Down Expand Up @@ -71,6 +72,7 @@
<math><mspace width="thickmathspace"/></math>
<math><mspace width="verythickmathspace"/></math>
<math><mspace width="veryverythickmathspace"/></math>
<math><mspace width="12345."/></math>
<math><mo minsize="17">+</mo></math>
*/
LengthParsingError : {
Expand All @@ -93,6 +95,7 @@
allow_mathspace_names,
allow_mathspace_names,
allow_mathspace_names,
allow_legacy_numbers,
allow_nonzero_unitless_lengths,
],
args: [["2..0px"],
Expand All @@ -114,6 +117,7 @@
["thickmathspace"],
["verythickmathspace"],
["veryverythickmathspace"],
["12345."],
["17"]
]
},
Expand Down Expand Up @@ -230,6 +234,7 @@
<math><mspace width="thickmathspace"/></math>
<math><mspace width="verythickmathspace"/></math>
<math><mspace width="veryverythickmathspace"/></math>
<math><mspace width="12345."/></math>

<!-- MMultiscriptsErrors -->
<math><mmultiscripts></mmultiscripts></math>
Expand Down
2 changes: 1 addition & 1 deletion layout/reftests/mathml/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
== 347496-1.xhtml 347496-1-ref.xhtml
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == 355548-1.xml 355548-1-ref.xml # Bug 1392106
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == 355548-2.xml 355548-2-ref.xml # Bug 1392106
pref(mathml.nonzero_unitless_lengths.disabled,false) pref(mathml.mathsize_names.disabled,false) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == 355548-3.xml 355548-3-ref.xml # Bug 1392106
pref(mathml.legacy_number_syntax.disabled,false) pref(mathml.nonzero_unitless_lengths.disabled,false) pref(mathml.mathsize_names.disabled,false) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == 355548-3.xml 355548-3-ref.xml # Bug 1392106
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == 355548-4.xml 355548-4-ref.xml # Bug 1392106
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == 355548-5.xml 355548-5-ref.xml # Bug 1392106
== 370692-1.xhtml 370692-1-ref.xhtml
Expand Down
7 changes: 7 additions & 0 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4913,6 +4913,13 @@
# Prefs starting with "mathml."
#---------------------------------------------------------------------------

# Whether to disable legacy MathML number values that are not valid CSS numbers
# (e.g. "1234.")
- name: mathml.legacy_number_syntax.disabled
type: bool
value: true
mirror: always

# Whether to disable legacy names "small", "normal" and "big" for the
# mathsize attribute.
- name: mathml.mathsize_names.disabled
Expand Down
1 change: 1 addition & 0 deletions testing/web-platform/meta/mathml/__dir__.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prefs: [mathml.legacy_number_syntax.disabled: true, mathml.mathsize_names.disabled:true, mathml.mathspace_names.disabled: true, mathml.mfrac_linethickness_names.disabled:true, mathml.nonzero_unitless_lengths.disabled:true]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[frac-linethickness-002.html]
prefs: [mathml.mathspace_names.disabled:true]

[Negative]
expected: FAIL

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 90172ba

Please sign in to comment.