commit 2c11ffaf4707c8efc3de8b7ea8a2b8471c50d69d
parent 6063b193214ce6c36548e0cd27ecda14fcd64ead
Author: eri <eri@igalia.com>
Date: Wed, 5 Nov 2025 13:17:28 +0000
Bug 1636428 - Deprecate accent property from the operator dictionary r=emilio,fredw,layout-reviewers,flod
Add counters and warnings for deprecated uses of the accent property
from the operator dictionary.
Add a new mathml.operator_dictionary_accent.disabled property to control
whether the accent property should be parsed from the dictionary. It is
off by default so there are no behaviour changes.
Differential Revision: https://phabricator.services.mozilla.com/D269049
Diffstat:
9 files changed, 214 insertions(+), 15 deletions(-)
diff --git a/dom/base/nsDeprecatedOperationList.h b/dom/base/nsDeprecatedOperationList.h
@@ -47,6 +47,9 @@ DEPRECATED_OPERATION(InitMouseEvent)
DEPRECATED_OPERATION(InitNSMouseEvent)
DEPRECATED_OPERATION(MathML_DeprecatedMathSpaceValue2)
DEPRECATED_OPERATION(MathML_DeprecatedMathVariant)
+DEPRECATED_OPERATION(MathML_DeprecatedMoExplicitAccent)
+DEPRECATED_OPERATION(MathML_DeprecatedMoverNonExplicitAccent)
+DEPRECATED_OPERATION(MathML_DeprecatedMunderNonExplicitAccentunder)
DEPRECATED_OPERATION(FormSubmissionUntrustedEvent)
DEPRECATED_OPERATION(ElementSetCapture)
DEPRECATED_OPERATION(ElementReleaseCapture)
diff --git a/dom/base/use_counter_metrics.yaml b/dom/base/use_counter_metrics.yaml
@@ -15642,6 +15642,57 @@ use.counter.deprecated_ops.page:
send_in_pings:
- use-counters
+ math_ml__deprecated_mo_explicit_accent:
+ type: counter
+ description: >
+ Whether a page used MathML_DeprecatedMoExplicitAccent.
+ Compare against `use.counter.top_level_content_documents_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
+ math_ml__deprecated_mover_non_explicit_accent:
+ type: counter
+ description: >
+ Whether a page used MathML_DeprecatedMoverNonExplicitAccent.
+ Compare against `use.counter.top_level_content_documents_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
+ math_ml__deprecated_munder_non_explicit_accentunder:
+ type: counter
+ description: >
+ Whether a page used MathML_DeprecatedMunderNonExplicitAccentunder.
+ Compare against `use.counter.top_level_content_documents_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
form_submission_untrusted_event:
type: counter
description: >
@@ -16409,6 +16460,57 @@ use.counter.deprecated_ops.doc:
send_in_pings:
- use-counters
+ math_ml__deprecated_mo_explicit_accent:
+ type: counter
+ description: >
+ Whether a document used MathML_DeprecateMoExplicitAccent.
+ Compare against `use.counter.content_documents_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
+ math_ml__deprecated_mover_non_explicit_accent:
+ type: counter
+ description: >
+ Whether a document used MathML_DeprecatedMoverNonExplicitAccent.
+ Compare against `use.counter.content_documents_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
+ math_ml__deprecated_munder_non_explicit_accentunder:
+ type: counter
+ description: >
+ Whether a document used MathML_DeprecatedMunderNonExplicitAccentunder.
+ Compare against `use.counter.content_documents_destroyed`
+ to calculate the rate.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
+ notification_emails:
+ - dom-core@mozilla.com
+ - emilio@mozilla.com
+ expires: never
+ send_in_pings:
+ - use-counters
+
form_submission_untrusted_event:
type: counter
description: >
diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties
@@ -404,6 +404,12 @@ InitNSMouseEventWarning=initNSMouseEvent() is deprecated. Use the MouseEvent() c
MathML_DeprecatedMathSpaceValue2Warning=MathML length value “%S” is deprecated 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 accent and mo (it's the name of a MathML element). %1$S is either accent or accentunder. %2$S is the name of the parent frame.
+MathML_DeprecatedMoExplicitAccentWarning=Setting the accent attribute on mo elements is deprecated. Use the “%1$S” attribute on “%2$S” instead.
+# LOCALIZATION NOTE: Do not translate accent. %S is either mover or munderover.
+MathML_DeprecatedMoverNonExplicitAccentWarning=Inferring the accent property from the core operator is deprecated. Consider adding an explicit accent attribute to “%S”.
+# LOCALIZATION NOTE: Do not translate accentunder. %S is either munder or munderover.
+MathML_DeprecatedMunderNonExplicitAccentunderWarning=Inferring the accentunder property from the core operator is deprecated. Consider adding an explicit accentunder attribute to %S.
FormSubmissionUntrustedEventWarning=Form submission via untrusted submit event is deprecated and will be removed at a future date.
WebShareAPI_Failed=The share operation has failed.
diff --git a/layout/mathml/nsMathMLOperators.cpp b/layout/mathml/nsMathMLOperators.cpp
@@ -6,6 +6,7 @@
#include "nsMathMLOperators.h"
+#include "mozilla/StaticPrefs_mathml.h"
#include "mozilla/intl/UnicodeProperties.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
@@ -16,6 +17,8 @@
#include "nsTArray.h"
#include "nsTHashMap.h"
+using namespace mozilla;
+
// operator dictionary entry
struct OperatorData {
OperatorData(void) : mFlags(0), mLeadingSpace(0.0f), mTrailingSpace(0.0f) {}
@@ -56,7 +59,8 @@ static void SetBooleanProperty(OperatorData* aOperatorData, nsString aName) {
aOperatorData->mFlags |= NS_MATHML_OPERATOR_STRETCHY;
} else if (aName.EqualsLiteral("fence")) {
aOperatorData->mFlags |= NS_MATHML_OPERATOR_FENCE;
- } else if (aName.EqualsLiteral("accent")) {
+ } else if (!StaticPrefs::mathml_operator_dictionary_accent_disabled() &&
+ aName.EqualsLiteral("accent")) {
aOperatorData->mFlags |= NS_MATHML_OPERATOR_ACCENT;
} else if (aName.EqualsLiteral("largeop")) {
aOperatorData->mFlags |= NS_MATHML_OPERATOR_LARGEOP;
@@ -427,7 +431,7 @@ bool nsMathMLOperators::LookupOperatorWithFallback(const nsString& aOperator,
/* static */
bool nsMathMLOperators::IsMirrorableOperator(const nsString& aOperator) {
if (auto codePoint = ToUnicodeCodePoint(aOperator)) {
- return mozilla::intl::UnicodeProperties::IsMirrored(codePoint);
+ return intl::UnicodeProperties::IsMirrored(codePoint);
}
return false;
}
@@ -436,7 +440,7 @@ bool nsMathMLOperators::IsMirrorableOperator(const nsString& aOperator) {
nsString nsMathMLOperators::GetMirroredOperator(const nsString& aOperator) {
nsString result;
if (auto codePoint = ToUnicodeCodePoint(aOperator)) {
- result.Assign(mozilla::intl::UnicodeProperties::CharMirror(codePoint));
+ result.Assign(intl::UnicodeProperties::CharMirror(codePoint));
}
return result;
}
diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp
@@ -11,10 +11,12 @@
#include "gfxContext.h"
#include "mozilla/PresShell.h"
#include "mozilla/StaticPrefs_mathml.h"
+#include "mozilla/dom/Document.h"
#include "mozilla/dom/MathMLElement.h"
#include "nsCSSValue.h"
#include "nsContentUtils.h"
#include "nsFrameSelection.h"
+#include "nsGkAtoms.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"
@@ -225,11 +227,31 @@ void nsMathMLmoFrame::ProcessOperatorData() {
}
// see if the accent attribute is there
- mContent->AsElement()->GetAttr(nsGkAtoms::accent, value);
- if (value.LowerCaseEqualsLiteral("true")) {
- mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
- } else if (value.LowerCaseEqualsLiteral("false")) {
- mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
+ if (mContent->AsElement()->GetAttr(nsGkAtoms::accent, value)) {
+ [&]() {
+ AutoTArray<nsString, 2> params;
+ auto parentName = GetParent()->GetContent()->NodeInfo()->NameAtom();
+ if (parentName == nsGkAtoms::mover) {
+ params.AppendElement(u"accent");
+ params.AppendElement(u"mover");
+ } else if (parentName == nsGkAtoms::munder) {
+ params.AppendElement(u"accentunder");
+ params.AppendElement(u"munder");
+ } else if (parentName == nsGkAtoms::munderover) {
+ params.AppendElement(u"accent/accentunder");
+ params.AppendElement(u"munderover");
+ } else {
+ return;
+ }
+ PresContext()->Document()->WarnOnceAbout(
+ dom::DeprecatedOperations::eMathML_DeprecatedMoExplicitAccent,
+ false, params);
+ }();
+ if (value.LowerCaseEqualsLiteral("true")) {
+ mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
+ } else if (value.LowerCaseEqualsLiteral("false")) {
+ mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
+ }
}
// see if the movablelimits attribute is there
diff --git a/layout/mathml/nsMathMLmunderoverFrame.cpp b/layout/mathml/nsMathMLmunderoverFrame.cpp
@@ -15,6 +15,7 @@
#include "mozilla/StaticPrefs_mathml.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/MathMLElement.h"
+#include "nsIMathMLFrame.h"
#include "nsLayoutUtils.h"
#include "nsMathMLmmultiscriptsFrame.h"
#include "nsPresContext.h"
@@ -231,6 +232,13 @@ XXX The winner is the outermost setting in conflicting settings like these:
} else if (value.LowerCaseEqualsLiteral("false")) {
mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTUNDER;
}
+ } else if (NS_MATHML_EMBELLISH_IS_ACCENTUNDER(mEmbellishData.flags)) {
+ AutoTArray<nsString, 1> params;
+ params.AppendElement(mContent->NodeInfo()->NodeName());
+ PresContext()->Document()->WarnOnceAbout(
+ dom::DeprecatedOperations::
+ eMathML_DeprecatedMunderNonExplicitAccentunder,
+ false, params);
}
}
@@ -252,6 +260,12 @@ XXX The winner is the outermost setting in conflicting settings like these:
} else if (value.LowerCaseEqualsLiteral("false")) {
mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER;
}
+ } else if (NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)) {
+ AutoTArray<nsString, 1> params;
+ params.AppendElement(mContent->NodeInfo()->NodeName());
+ PresContext()->Document()->WarnOnceAbout(
+ dom::DeprecatedOperations::eMathML_DeprecatedMoverNonExplicitAccent,
+ false, params);
}
}
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
@@ -11107,6 +11107,12 @@
value: true
mirror: always
+# Whether to remove the accent property from the operator dictionary.
+- name: mathml.operator_dictionary_accent.disabled
+ type: bool
+ value: false
+ mirror: always
+
# Whether to disable the MathML3 support for the mathvariant attribute. For
# MathML Core, support is restricted to the <mi> element and to value "normal".
# Corresponding automatic italicization on single-char <mi> element is also
diff --git a/testing/web-platform/mozilla/meta/mathml/mathml-console-messages.html.ini b/testing/web-platform/mozilla/meta/mathml/mathml-console-messages.html.ini
@@ -1,2 +1,2 @@
[mathml-console-messages.html]
- prefs: [dom.use_components_shim:false, mathml.legacy_mathvariant_attribute.disabled: false, mathml.mathspace_names.disabled: false]
+ prefs: [dom.use_components_shim:false, mathml.legacy_mathvariant_attribute.disabled: false, mathml.mathspace_names.disabled: false, mathml.operator_dictionary_accent.disabled: false]
diff --git a/testing/web-platform/mozilla/tests/mathml/mathml-console-messages.html b/testing/web-platform/mozilla/tests/mathml/mathml-console-messages.html
@@ -39,16 +39,14 @@
function testMessageForMarkup(markup, regexp, level) {
promise_test(async function() {
let messages = await retrieveConsoleMessagesFor(markup);
-
- // Sometimes MathML messages are logged several times, so just
- // ensure there is at least one.
assert_greater_than_equal(messages.length, 1);
- // Compare against the regexp.
- assert_regexp_match(messages[0].errorMessage, regexp);
+ // Try to match any element in messages against the provided regexp.
+ let found = messages.find(m => regexp.test(m.errorMessage));
+ assert_true(!!found, `regexp ${regexp} not found in array ${messages.map(m => m.errorMessage)}`);
// Check whether this is a warning or an error.
- assert_equals(messages[0].isWarning, level == MessageLevel.WARNING);
+ assert_equals(found.isWarning, level == MessageLevel.WARNING);
}, `Message for ${markup}`);
}
@@ -241,5 +239,49 @@
new RegExp(`mathvariant='${value}'” .* deprecated`),
MessageLevel.WARNING);
});
+
+
+ // MathML_DeprecatedMoExplicitAccent
+ testNoMessageForMarkup(`<math><mrow><mo accent="true">x</mo></mrow></math>`);
+ [
+ ["mover", "accent", `<mover><mi>A</mi><mo accent="true">x</mo></mover>`],
+ ["munder", "accentunder", `<munder><mi>A</mi><mo accent="true">x</mo></munder>`],
+ ["munderover", "accent/accentunder", `<munderover><mi>A</mi><mo accent="true">x</mo><mo>y</mo></munderover>`],
+ ["munderover", "accent/accentunder", `<munderover><mi>A</mi><mo>x</mo><mo accent="true">y</mo></munderover>`],
+ ["munderover", "accent/accentunder", `<munderover><mi>A</mi><mo accent="true">x</mo><mo accent="true">y</mo></munderover>`],
+ ].forEach(([name, accent, markup]) => {
+ testMessageForMarkup(
+ `<math><${markup}></math>`,
+ new RegExp(`Setting the accent attribute on mo elements is deprecated. Use the ${accent} attribute on ${name} instead.`),
+ MessageLevel.WARNING);
+ });
+
+
+ // MathML_DeprecatedMoverNonExplicitAccent
+ // MathML_DeprecatedMunderNonExplicitAccentunder
+ [ "mover", "munder" ].forEach((name) => {
+ testNoMessageForMarkup(`<math><${name}><mi>A</mi><mo>x</mo></${name}></math>`);
+ });
+ testNoMessageForMarkup(`<math><munderover><mi>A</mi><mo>x</mo><mo>y</mo></munderover></math>`);
+ [
+ // Inferring the accent from the operator dictionary.
+ ["mover", "accent", `<mover><mi>B</mi><mo>^</mo></mover>`],
+ ["munder", "accentunder", `<munder><mi>B</mi><mo>^</mo></munder>`],
+ ["munderover", "accent", `<munderover><mi>B</mi><mo>x</mo><mo>^</mo></munderover>`],
+ ["munderover", "accentunder", `<munderover><mi>B</mi><mo>^</mo><mo>x</mo></munderover>`],
+ // Inferring the accent from `accent="true"`.
+ // The last test triggers both accent and accentunder warnings, so we check it twice.
+ ["mover", "accent", `<mover><mi>C</mi><mo accent="true">x</mo></mover>`],
+ ["munder", "accentunder", `<munder><mi>C</mi><mo accent="true">x</mo></munder>`],
+ ["munderover", "accent", `<munderover><mi>C</mi><mo>x</mo><mo accent="true">y</mo></munderover>`],
+ ["munderover", "accentunder", `<munderover><mi>C</mi><mo accent="true">x</mo><mo>y</mo></munderover>`],
+ ["munderover", "accent", `<munderover><mi>C</mi><mo accent="true">x</mo><mo accent="true">y</mo></munderover>`],
+ ["munderover", "accentunder", `<munderover><mi>D</mi><mo accent="true">x</mo><mo accent="true">y</mo></munderover>`],
+ ].forEach(([name, accent, markup]) => {
+ testMessageForMarkup(
+ `<math><${markup}></math>`,
+ new RegExp(`Inferring the ${accent} property from the core operator is deprecated. Consider adding an explicit ${accent} attribute to ${name}.`),
+ MessageLevel.WARNING);
+ });
</script>
</body>