Bug 1845461 - Add deprecation warning and use counter for deprecated mathvariant usages. r=emilio,flod

Differential Revision: https://phabricator.services.mozilla.com/D184561
This commit is contained in:
Frederic Wang 2023-08-01 07:47:15 +00:00
parent 4a8fbd6d00
commit abdcf26c27
6 changed files with 65 additions and 0 deletions

View File

@ -57,6 +57,17 @@ let gExceptionsList = [
key: "ImportMapExternalNotSupported", key: "ImportMapExternalNotSupported",
type: "single-quote", type: "single-quote",
}, },
{
file: "dom.properties",
key: "MathML_DeprecatedMathVariantWarning",
type: "single-quote",
},
// dom.properties is packaged twice so we need to have two exceptions for this string.
{
file: "dom.properties",
key: "MathML_DeprecatedMathVariantWarning",
type: "single-quote",
},
]; ];
/** /**

View File

@ -48,6 +48,7 @@ DEPRECATED_OPERATION(MozInputSource)
DEPRECATED_OPERATION(InitMouseEvent) DEPRECATED_OPERATION(InitMouseEvent)
DEPRECATED_OPERATION(InitNSMouseEvent) DEPRECATED_OPERATION(InitNSMouseEvent)
DEPRECATED_OPERATION(MathML_DeprecatedMathSpaceValue) DEPRECATED_OPERATION(MathML_DeprecatedMathSpaceValue)
DEPRECATED_OPERATION(MathML_DeprecatedMathVariant)
DEPRECATED_OPERATION(MathML_DeprecatedStixgeneralOperatorStretching) DEPRECATED_OPERATION(MathML_DeprecatedStixgeneralOperatorStretching)
DEPRECATED_OPERATION(FormSubmissionUntrustedEvent) DEPRECATED_OPERATION(FormSubmissionUntrustedEvent)
DEPRECATED_OPERATION(ElementSetCapture) DEPRECATED_OPERATION(ElementSetCapture)

View File

@ -389,6 +389,8 @@ InitNSMouseEventWarning=initNSMouseEvent() is deprecated. Use the MouseEvent() c
# LOCALIZATION NOTE: Do not translate veryverythinmathspace, verythinmathspace, # LOCALIZATION NOTE: Do not translate veryverythinmathspace, verythinmathspace,
# thinmathspace, mediummathspace, thickmathspace, verythickmathspace, veryverythickmathspace and MathML. # thinmathspace, mediummathspace, thickmathspace, verythickmathspace, veryverythickmathspace and MathML.
MathML_DeprecatedMathSpaceValueWarning=“veryverythinmathspace”, “verythinmathspace”, “thinmathspace”, “mediummathspace”, “thickmathspace”, “verythickmathspace” and “veryverythickmathspace” are deprecated values for MathML lengths and will be removed at a future date. MathML_DeprecatedMathSpaceValueWarning=“veryverythinmathspace”, “verythinmathspace”, “thinmathspace”, “mediummathspace”, “thickmathspace”, “verythickmathspace” and “veryverythickmathspace” are deprecated values for MathML lengths and will be removed at a future date.
# LOCALIZATION NOTE: Do not translate mathvariant or MathML. %S is the deprecated value of the mathvariant attribute.
MathML_DeprecatedMathVariantWarning=“mathvariant='%S'” on MathML elements is deprecated and will be removed at a future date.
# LOCALIZATION NOTE: Do not translate MathML and STIXGeneral. %S is a documentation URL. # LOCALIZATION NOTE: Do not translate MathML and STIXGeneral. %S is a documentation URL.
MathML_DeprecatedStixgeneralOperatorStretchingWarning=Support for rendering stretched MathML operators with STIXGeneral fonts is deprecated and may be removed at a future date. For details about newer fonts that will continue to be supported, see %S MathML_DeprecatedStixgeneralOperatorStretchingWarning=Support for rendering stretched MathML operators with STIXGeneral fonts is deprecated and may be removed at a future date. For details about newer fonts that will continue to be supported, see %S
FormSubmissionUntrustedEventWarning=Form submission via untrusted submit event is deprecated and will be removed at a future date. FormSubmissionUntrustedEventWarning=Form submission via untrusted submit event is deprecated and will be removed at a future date.

View File

@ -519,6 +519,20 @@ void MathMLElement::MapGlobalMathMLAttributesInto(
StyleMathVariant::Stretched}; StyleMathVariant::Stretched};
for (uint32_t i = 0; i < ArrayLength(sizes); ++i) { for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
if (str.LowerCaseEqualsASCII(sizes[i])) { if (str.LowerCaseEqualsASCII(sizes[i])) {
if (values[i] != StyleMathVariant::Normal) {
// Warn about deprecated mathvariant attribute values. Strictly
// speaking, we should also warn about mathvariant="normal" if the
// element is not an <mi>. However this would require exposing the
// tag name via aBuilder. Moreover, this use case is actually to
// revert the effect of a non-normal mathvariant value on an
// ancestor element, which should consequently have already
// triggered a warning.
AutoTArray<nsString, 1> params;
params.AppendElement(str);
aBuilder.Document().WarnOnceAbout(
dom::DeprecatedOperations::eMathML_DeprecatedMathVariant, false,
params);
}
aBuilder.SetKeywordValue(eCSSProperty__moz_math_variant, values[i]); aBuilder.SetKeywordValue(eCSSProperty__moz_math_variant, values[i]);
break; break;
} }

View File

@ -2,6 +2,7 @@
support-files = support-files =
file_disabled_iframe.html file_disabled_iframe.html
[test_bug1845461.html]
[test_bug330964.html] [test_bug330964.html]
[test_bug553917.html] [test_bug553917.html]
[test_bug827713-2.html] [test_bug827713-2.html]

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1845461
-->
<html>
<head>
<title>Test for Bug 1845461</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="application/javascript">
const allow_legacy_mathvariant = !SpecialPowers.getBoolPref('mathml.legacy_mathvariant_attribute.disabled');
let errorMessages = [];
SpecialPowers.registerConsoleListener(
function (msg) {
if (msg.message == "SENTINEL") {
is(errorMessages.length, allow_legacy_mathvariant ? 1 : 0,
"number of errors");
if (allow_legacy_mathvariant) {
is(errorMessages[0], "“mathvariant='fraktur'” on MathML elements is deprecated and will be removed at a future date.",
"error message");
}
SimpleTest.finish();
} else if (msg.isScriptError) {
errorMessages.push(msg.errorMessage);
}
});
SimpleTest.waitForExplicitFinish();
</script>
</head>
<body onload="SpecialPowers.postConsoleSentinel();">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1845461">Mozilla Bug 1845461</a>
<math><mi mathvariant="normal">A</mi></math>
<math><mi mathvariant="fraktur">A</mi></math>
</body>
</html>