mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1548524 - Remove attributes deprecated from MathML3. r=emilio
See https://github.com/mathml-refresh/mathml/issues/5#issuecomment-475506856 and https://groups.google.com/forum/#!topic/mozilla.dev.platform/kl5c87mBlO0 This patch introduces a new preference mathml.deprecated_style_attributes.disabled in order to disable legacy support for attributes background, color, fontfamily, fontsize, fontstyle and fontweight. Note that xlink:href will be handled separately in bug 1575870. * A new counter and deprecation message is introduced for these attributes. In nsMathMLElement, the old WarnDeprecated calls are replaced with a single call to WarnOnceAbout for the deprecate attributes. Notice that for some reason, the color attribute used to send warning in both ParseAttribute and MapMathMLAttributesInto. * sMtableStyles is removed and replaced with a simple comparison. * sMathML3Attributes is split into two tables: one for script attributes which will be handled in bug 1548471 and one for style attributes, handled here. The attributes in this second table is now ignored when the feature flag is disabled. * test_bug553917.html is updated so that it no longer checks the old warning messages for these attributes. New warning messages have been verified manually. * Reftests checking support for these attributes are run with the support enabled. * Finally, WPT tests are run with the support disabled and a new test is added to verify that these attributes are no longer mapped to CSS. Differential Revision: https://phabricator.services.mozilla.com/D43111 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
231a277008
commit
3f8a2878fa
@ -52,3 +52,4 @@ DEPRECATED_OPERATION(MouseEvent_MozPressure)
|
||||
DEPRECATED_OPERATION(MathML_DeprecatedLineThicknessValue)
|
||||
DEPRECATED_OPERATION(MathML_DeprecatedMathSizeValue)
|
||||
DEPRECATED_OPERATION(MathML_DeprecatedMathSpaceValue)
|
||||
DEPRECATED_OPERATION(MathML_DeprecatedStyleAttribute)
|
||||
|
@ -394,3 +394,5 @@ MathML_DeprecatedMathSizeValueWarning=“small”, “normal” and “big” ar
|
||||
# LOCALIZATION NOTE: Do not translate veryverythinmathspace, verythinmathspace,
|
||||
# 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.
|
||||
# LOCALIZATION NOTE: Do not translate MathML, background, color, fontfamily, fontsize, fontstyle and fontweight.
|
||||
MathML_DeprecatedStyleAttributeWarning=MathML attributes “background”, “color”, “fontfamily”, “fontsize”, “fontstyle” and “fontweight” are deprecated and will be removed at a future date.
|
||||
|
@ -111,10 +111,6 @@ bool nsMathMLElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
||||
MOZ_ASSERT(IsMathMLElement());
|
||||
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (aAttribute == nsGkAtoms::color) {
|
||||
WarnDeprecated(nsGkAtoms::color->GetUTF16String(),
|
||||
nsGkAtoms::mathcolor_->GetUTF16String(), OwnerDoc());
|
||||
}
|
||||
if (aAttribute == nsGkAtoms::color || aAttribute == nsGkAtoms::mathcolor_ ||
|
||||
aAttribute == nsGkAtoms::background ||
|
||||
aAttribute == nsGkAtoms::mathbackground_) {
|
||||
@ -136,9 +132,6 @@ bool nsMathMLElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
||||
aMaybeScriptedPrincipal, aResult);
|
||||
}
|
||||
|
||||
static Element::MappedAttributeEntry sMtableStyles[] = {{nsGkAtoms::width},
|
||||
{nullptr}};
|
||||
|
||||
// https://mathml-refresh.github.io/mathml-core/#global-attributes
|
||||
static Element::MappedAttributeEntry sGlobalAttributes[] = {
|
||||
{nsGkAtoms::dir},
|
||||
@ -150,12 +143,11 @@ static Element::MappedAttributeEntry sGlobalAttributes[] = {
|
||||
// XXXfredw: Also map displaystyle to CSS math-style?
|
||||
{nullptr}};
|
||||
|
||||
// XXXfredw: Add a runtime flag to disable these attributes.
|
||||
static Element::MappedAttributeEntry sMathML3Attributes[] = {
|
||||
// XXXfredw(bug 1548471)
|
||||
{nsGkAtoms::scriptminsize_},
|
||||
{nsGkAtoms::scriptsizemultiplier_},
|
||||
// XXXfredw(bug 1548524)
|
||||
// XXXfredw(bug 1548471): Add a runtime flag to disable these attributes.
|
||||
static Element::MappedAttributeEntry sDeprecatedScriptAttributes[] = {
|
||||
{nsGkAtoms::scriptminsize_}, {nsGkAtoms::scriptsizemultiplier_}, {nullptr}};
|
||||
|
||||
static Element::MappedAttributeEntry sDeprecatedStyleAttributes[] = {
|
||||
{nsGkAtoms::background},
|
||||
{nsGkAtoms::color},
|
||||
{nsGkAtoms::fontfamily_},
|
||||
@ -167,14 +159,16 @@ static Element::MappedAttributeEntry sMathML3Attributes[] = {
|
||||
bool nsMathMLElement::IsAttributeMapped(const nsAtom* aAttribute) const {
|
||||
MOZ_ASSERT(IsMathMLElement());
|
||||
|
||||
static const MappedAttributeEntry* const mtableMap[] = {
|
||||
sMtableStyles, sGlobalAttributes, sMathML3Attributes};
|
||||
if (mNodeInfo->Equals(nsGkAtoms::mtable_))
|
||||
return FindAttributeDependence(aAttribute, mtableMap);
|
||||
static const MappedAttributeEntry* const globalMap[] = {
|
||||
sGlobalAttributes, sDeprecatedScriptAttributes};
|
||||
static const MappedAttributeEntry* const styleMap[] = {
|
||||
sDeprecatedStyleAttributes};
|
||||
|
||||
static const MappedAttributeEntry* const mathmlMap[] = {sGlobalAttributes,
|
||||
sMathML3Attributes};
|
||||
return FindAttributeDependence(aAttribute, mathmlMap);
|
||||
return FindAttributeDependence(aAttribute, globalMap) ||
|
||||
(!StaticPrefs::mathml_deprecated_style_attributes_disabled() &&
|
||||
FindAttributeDependence(aAttribute, styleMap)) ||
|
||||
(mNodeInfo->Equals(nsGkAtoms::mtable_) &&
|
||||
aAttribute == nsGkAtoms::width);
|
||||
}
|
||||
|
||||
nsMapRuleToAttributesFunc nsMathMLElement::GetAttributeMappingFunction() const {
|
||||
@ -526,8 +520,8 @@ void nsMathMLElement::MapMathMLAttributesInto(
|
||||
parseSizeKeywords = false;
|
||||
value = aAttributes->GetAttr(nsGkAtoms::fontsize_);
|
||||
if (value) {
|
||||
WarnDeprecated(nsGkAtoms::fontsize_->GetUTF16String(),
|
||||
nsGkAtoms::mathsize_->GetUTF16String(), aDecls.Document());
|
||||
aDecls.Document()->WarnOnceAbout(
|
||||
dom::Document::eMathML_DeprecatedStyleAttribute);
|
||||
}
|
||||
}
|
||||
if (value && value->Type() == nsAttrValue::eString &&
|
||||
@ -572,9 +566,8 @@ void nsMathMLElement::MapMathMLAttributesInto(
|
||||
//
|
||||
value = aAttributes->GetAttr(nsGkAtoms::fontfamily_);
|
||||
if (value) {
|
||||
WarnDeprecated(nsGkAtoms::fontfamily_->GetUTF16String(),
|
||||
nsGkAtoms::mathvariant_->GetUTF16String(),
|
||||
aDecls.Document());
|
||||
aDecls.Document()->WarnOnceAbout(
|
||||
dom::Document::eMathML_DeprecatedStyleAttribute);
|
||||
}
|
||||
if (value && value->Type() == nsAttrValue::eString &&
|
||||
!aDecls.PropertyIsSet(eCSSProperty_font_family)) {
|
||||
@ -593,9 +586,8 @@ void nsMathMLElement::MapMathMLAttributesInto(
|
||||
// -moz-math-variant is specified.
|
||||
value = aAttributes->GetAttr(nsGkAtoms::fontstyle_);
|
||||
if (value) {
|
||||
WarnDeprecated(nsGkAtoms::fontstyle_->GetUTF16String(),
|
||||
nsGkAtoms::mathvariant_->GetUTF16String(),
|
||||
aDecls.Document());
|
||||
aDecls.Document()->WarnOnceAbout(
|
||||
dom::Document::eMathML_DeprecatedStyleAttribute);
|
||||
if (value->Type() == nsAttrValue::eString &&
|
||||
!aDecls.PropertyIsSet(eCSSProperty_font_style)) {
|
||||
nsAutoString str(value->GetStringValue());
|
||||
@ -622,9 +614,8 @@ void nsMathMLElement::MapMathMLAttributesInto(
|
||||
// -moz-math-variant is specified.
|
||||
value = aAttributes->GetAttr(nsGkAtoms::fontweight_);
|
||||
if (value) {
|
||||
WarnDeprecated(nsGkAtoms::fontweight_->GetUTF16String(),
|
||||
nsGkAtoms::mathvariant_->GetUTF16String(),
|
||||
aDecls.Document());
|
||||
aDecls.Document()->WarnOnceAbout(
|
||||
dom::Document::eMathML_DeprecatedStyleAttribute);
|
||||
if (value->Type() == nsAttrValue::eString &&
|
||||
!aDecls.PropertyIsSet(eCSSProperty_font_weight)) {
|
||||
nsAutoString str(value->GetStringValue());
|
||||
@ -722,9 +713,8 @@ void nsMathMLElement::MapMathMLAttributesInto(
|
||||
if (!value) {
|
||||
value = aAttributes->GetAttr(nsGkAtoms::background);
|
||||
if (value) {
|
||||
WarnDeprecated(nsGkAtoms::background->GetUTF16String(),
|
||||
nsGkAtoms::mathbackground_->GetUTF16String(),
|
||||
aDecls.Document());
|
||||
aDecls.Document()->WarnOnceAbout(
|
||||
dom::Document::eMathML_DeprecatedStyleAttribute);
|
||||
}
|
||||
}
|
||||
if (value) {
|
||||
@ -755,9 +745,8 @@ void nsMathMLElement::MapMathMLAttributesInto(
|
||||
if (!value) {
|
||||
value = aAttributes->GetAttr(nsGkAtoms::color);
|
||||
if (value) {
|
||||
WarnDeprecated(nsGkAtoms::color->GetUTF16String(),
|
||||
nsGkAtoms::mathcolor_->GetUTF16String(),
|
||||
aDecls.Document());
|
||||
aDecls.Document()->WarnOnceAbout(
|
||||
dom::Document::eMathML_DeprecatedStyleAttribute);
|
||||
}
|
||||
}
|
||||
nscolor color;
|
||||
|
@ -37,9 +37,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=553917
|
||||
<math fontsize="10"></math>
|
||||
<math xlink:href="http://www.mozilla.org"></math>*/
|
||||
DeprecatedSupersededBy: {
|
||||
status: [false, false, false, false, false],
|
||||
args: [["fontfamily","mathvariant"],["color","mathcolor"], ["background","mathbackground"],
|
||||
["fontsize","mathsize"], ["xlink:href","href"]] },
|
||||
status: [false],
|
||||
args: [["xlink:href","href"]] },
|
||||
/*<math><mpadded width="BAD!"></mpadded></math>
|
||||
<math><mpadded height="BAD!"></mpadded></math>
|
||||
<math><mpadded voffset="BAD!"></mpadded></math>*/
|
||||
@ -199,10 +198,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=553917
|
||||
<math><munderover></munderover></math>
|
||||
|
||||
<!-- DeprecatedSupersededBy -->
|
||||
<math fontfamily="serif"></math>
|
||||
<math color="#112233"></math>
|
||||
<math background="#FFFFFF"></math>
|
||||
<math fontsize="10"></math>
|
||||
<math xlink:href="http://www.mozilla.org"></math>
|
||||
|
||||
<!-- AttributeParsingError -->
|
||||
|
@ -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.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
|
||||
pref(mathml.deprecated_style_attributes.disabled,false) 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
|
||||
@ -287,9 +287,9 @@ fails-if(Android&&!webrender) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu
|
||||
fails-if(Android&&!webrender) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == mathvariant-1c.html mathvariant-1c-ref.html # Bug 1010679, Bug 1392106
|
||||
== mathvariant-1d.html mathvariant-1d-ref.html
|
||||
fails-if(Android&&!webrender) fails-if(OSX) == mathvariant-2.html mathvariant-2-ref.html # Bugs 1010678, 1010679
|
||||
== mathvariant-3.html mathvariant-3-ref.html
|
||||
pref(mathml.deprecated_style_attributes.disabled,false) == mathvariant-3.html mathvariant-3-ref.html
|
||||
== mathvariant-4.html mathvariant-4-ref.html
|
||||
== mathvariant-5.html mathvariant-5-ref.html
|
||||
pref(mathml.deprecated_style_attributes.disabled,false) == mathvariant-5.html mathvariant-5-ref.html
|
||||
== dtls-1.html dtls-1-ref.html
|
||||
== dtls-2.html dtls-2-ref.html
|
||||
== dtls-3.html dtls-3-ref.html
|
||||
|
@ -5002,6 +5002,13 @@
|
||||
# Prefs starting with "mathml."
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# Whether to disable deprecated style attributes background, color, fontfamily,
|
||||
# fontsize, fontstyle and fontweight.
|
||||
- name: mathml.deprecated_style_attributes.disabled
|
||||
type: bool
|
||||
value: @IS_NIGHTLY_BUILD@
|
||||
mirror: always
|
||||
|
||||
# Whether to disable legacy MathML number values that are not valid CSS numbers
|
||||
# (e.g. "1234.")
|
||||
- name: mathml.legacy_number_syntax.disabled
|
||||
|
@ -1 +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]
|
||||
prefs: [mathml.deprecated_style_attributes.disabled: true, 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]
|
||||
|
@ -5,7 +5,7 @@
|
||||
<title>Attribute mapping</title>
|
||||
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#legacy-mathml-style-attributes">
|
||||
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#attributes-common-to-html-and-mathml-elements">
|
||||
<meta name="assert" content="Verify that dir, mathcolor, mathbackground and mathsize are mapped to CSS">
|
||||
<meta name="assert" content="Verify that dir, mathcolor, mathbackground and mathsize are mapped to CSS but that deprecated MathML3 attributes are not.">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/mathml/support/mathml-fragments.js"></script>
|
||||
@ -70,6 +70,23 @@
|
||||
element.setAttribute("mathsize", "30Px");
|
||||
assert_equals(style.getPropertyValue("font-size"), "30px", "case insensitive");
|
||||
}, `mathsize on the ${tag} element is mapped to CSS font-size`);
|
||||
|
||||
test(function() {
|
||||
var properties = ["background-color", "color", "fontfamily", "font-size", "font-style", "font-weight"];
|
||||
var oldStyle = {};
|
||||
properties.forEach(property => {
|
||||
oldStyle[property] = style.getPropertyValue(property);
|
||||
});
|
||||
element.setAttribute("background", "red");
|
||||
element.setAttribute("color", "blue");
|
||||
element.setAttribute("fontfamily", "monospace");
|
||||
element.setAttribute("fontsize", "50px");
|
||||
element.setAttribute("fontstyle", "italic");
|
||||
element.setAttribute("fontweight", "bold");
|
||||
properties.forEach(property => {
|
||||
assert_equals(style.getPropertyValue(property), oldStyle[property], `${property}`);
|
||||
});
|
||||
}, `deprecated MathML3 attributes on the ${tag} element are not mapped to CSS`);
|
||||
});
|
||||
|
||||
done();
|
||||
|
Loading…
Reference in New Issue
Block a user