Bug 1575542 - Add counter and warnings for deprecated MathML lengths. r=emilio

This commit introduces new counters and deprecation warnings for the following
MathML features:
* mathspace names (bug 1575542)
* mathsize names (bug 1548527)
* linethickness names (bug 1548529)

Note: helper parsing functions for mfrac and mpadded are changed to non-static
in order to pass the document parameter needed to log warnings to the console.

Change manually tested with
    <math>
      <mspace width="thinmathspace"></mspace>
      <mpadded width="2thickmathspace"></mpadded>
      <mfrac linethickness="thin"><mn>1</mn><mn>2</mn></mfrac>
      <mtext mathsize="big">3</mtext>
    </math>

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Frédéric Wang 2019-08-22 06:29:26 +00:00
parent 19da5d26be
commit 8f3b2a9292
8 changed files with 33 additions and 12 deletions

View File

@ -49,3 +49,6 @@ DEPRECATED_OPERATION(MozfullscreenchangeDeprecatedPrefix)
DEPRECATED_OPERATION(MozfullscreenerrorDeprecatedPrefix)
DEPRECATED_OPERATION(External_AddSearchProvider)
DEPRECATED_OPERATION(MouseEvent_MozPressure)
DEPRECATED_OPERATION(MathML_DeprecatedLineThicknessValue)
DEPRECATED_OPERATION(MathML_DeprecatedMathSizeValue)
DEPRECATED_OPERATION(MathML_DeprecatedMathSpaceValue)

View File

@ -387,3 +387,10 @@ MozfullscreenerrorDeprecatedPrefixWarning=onmozfullscreenerror is deprecated.
External_AddSearchProviderWarning=AddSearchProvider is deprecated.
# LOCALIZATION NOTE: Do not translate "MouseEvent.mozPressure" and "PointerEvent.pressure".
MouseEvent_MozPressureWarning=MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead.
# LOCALIZATION NOTE: Do not translate thin, medium, thick and linethickness.
MathML_DeprecatedLineThicknessValueWarning=“thin”, “medium” and “thick” are deprecated values for the linethickness attribute and will be removed at a future date.
# LOCALIZATION NOTE: Do not translate small, normal, big and mathsize.
MathML_DeprecatedMathSizeValueWarning=“small”, “normal” and “big” are deprecated values for the mathsize attribute and will be removed at a future date.
# 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.

View File

@ -187,7 +187,8 @@ nsMapRuleToAttributesFunc nsMathMLElement::GetAttributeMappingFunction() const {
/* static */
bool nsMathMLElement::ParseNamedSpaceValue(const nsString& aString,
nsCSSValue& aCSSValue,
uint32_t aFlags) {
uint32_t aFlags,
const Document& aDocument) {
if (StaticPrefs::mathml_mathspace_names_disabled()) {
return false;
}
@ -225,6 +226,7 @@ bool nsMathMLElement::ParseNamedSpaceValue(const nsString& aString,
}
}
if (0 != i) {
aDocument.WarnOnceAbout(dom::Document::eMathML_DeprecatedMathSpaceValue);
aCSSValue.SetFloatValue(float(i) / float(18), eCSSUnit_EM);
return true;
}
@ -285,7 +287,7 @@ bool nsMathMLElement::ParseNumericValue(const nsString& aString,
return false;
}
if (ParseNamedSpaceValue(str, aCSSValue, aFlags)) {
if (aDocument && ParseNamedSpaceValue(str, aCSSValue, aFlags, *aDocument)) {
return true;
}
@ -546,6 +548,8 @@ void nsMathMLElement::MapMathMLAttributesInto(
str.CompressWhitespace();
for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
if (str.EqualsASCII(sizes[i])) {
aDecls.Document()->WarnOnceAbout(
dom::Document::eMathML_DeprecatedMathSizeValue);
aDecls.SetKeywordValue(eCSSProperty_font_size, values[i]);
break;
}

View File

@ -54,7 +54,8 @@ class nsMathMLElement final : public nsMathMLElementBase,
CONVERT_UNITLESS_TO_PERCENT = 0x08
};
static bool ParseNamedSpaceValue(const nsString& aString,
nsCSSValue& aCSSValue, uint32_t aFlags);
nsCSSValue& aCSSValue, uint32_t aFlags,
const Document& aDocument);
static bool ParseNumericValue(const nsString& aString, nsCSSValue& aCSSValue,
uint32_t aFlags, Document* aDocument);

View File

@ -111,6 +111,7 @@ nscoord nsMathMLmfracFrame::CalcLineThickness(nsPresContext* aPresContext,
nsMathMLElement::PARSE_ALLOW_UNITLESS, aPresContext,
aComputedStyle, aFontSizeInflation);
} else {
bool isDeprecatedLineThicknessValue = true;
if (aThicknessAttribute.EqualsLiteral("thin")) {
lineThickness = NSToCoordFloor(defaultThickness * THIN_FRACTION_LINE);
minimumThickness = onePixel * THIN_FRACTION_LINE_MINIMUM_PIXELS;
@ -131,11 +132,16 @@ nscoord nsMathMLmfracFrame::CalcLineThickness(nsPresContext* aPresContext,
}
} else {
// length value
isDeprecatedLineThicknessValue = false;
lineThickness = defaultThickness;
ParseNumericValue(aThicknessAttribute, &lineThickness,
nsMathMLElement::PARSE_ALLOW_UNITLESS, aPresContext,
aComputedStyle, aFontSizeInflation);
}
if (isDeprecatedLineThicknessValue) {
mContent->OwnerDoc()->WarnOnceAbout(
dom::Document::eMathML_DeprecatedLineThicknessValue);
}
}
}

View File

@ -82,12 +82,11 @@ class nsMathMLmfracFrame final : public nsMathMLContainerFrame {
virtual nscoord FixInterFrameSpacing(ReflowOutput& aDesiredSize) override;
// helper to translate the thickness attribute into a usable form
static nscoord CalcLineThickness(nsPresContext* aPresContext,
ComputedStyle* aComputedStyle,
nsString& aThicknessAttribute,
nscoord onePixel,
nscoord aDefaultRuleThickness,
float aFontSizeInflation);
nscoord CalcLineThickness(nsPresContext* aPresContext,
ComputedStyle* aComputedStyle,
nsString& aThicknessAttribute, nscoord onePixel,
nscoord aDefaultRuleThickness,
float aFontSizeInflation);
uint8_t ScriptIncrement(nsIFrame* aFrame) override;

View File

@ -208,7 +208,8 @@ bool nsMathMLmpaddedFrame::ParseAttribute(nsString& aString, int32_t& aSign,
// see if the unit is a named-space
if (nsMathMLElement::ParseNamedSpaceValue(
unit, aCSSValue, nsMathMLElement::PARSE_ALLOW_NEGATIVE)) {
unit, aCSSValue, nsMathMLElement::PARSE_ALLOW_NEGATIVE,
*mContent->OwnerDoc())) {
// re-scale properly, and we know that the unit of the named-space is 'em'
floatValue *= aCSSValue.GetFloatValue();
aCSSValue.SetFloatValue(floatValue, eCSSUnit_EM);

View File

@ -86,8 +86,8 @@ class nsMathMLmpaddedFrame final : public nsMathMLContainerFrame {
// helpers to process the attributes
void ProcessAttributes();
static bool ParseAttribute(nsString& aString, int32_t& aSign,
nsCSSValue& aCSSValue, int32_t& aPseudoUnit);
bool ParseAttribute(nsString& aString, int32_t& aSign, nsCSSValue& aCSSValue,
int32_t& aPseudoUnit);
void UpdateValue(int32_t aSign, int32_t aPseudoUnit,
const nsCSSValue& aCSSValue,