Bug 1575542 - Add counter and warnings for deprecated MathML lengths. r=emilio
authorFrédéric Wang <fwang@igalia.com>
Thu, 22 Aug 2019 06:29:26 +0000
changeset 553251 bafc328333083bac2f2efe0f9b829e6daa43ba00
parent 553250 3ba2717d59ffe26de1907378f01b4c0a6e1b5968
child 553252 a852387dee55e3ec356d83c44af9eef2626a4218
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1575542, 1548527, 1548529
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/base/nsDeprecatedOperationList.h
dom/locales/en-US/chrome/dom/dom.properties
dom/mathml/nsMathMLElement.cpp
dom/mathml/nsMathMLElement.h
layout/mathml/nsMathMLmfracFrame.cpp
layout/mathml/nsMathMLmfracFrame.h
layout/mathml/nsMathMLmpaddedFrame.cpp
layout/mathml/nsMathMLmpaddedFrame.h
--- a/dom/base/nsDeprecatedOperationList.h
+++ b/dom/base/nsDeprecatedOperationList.h
@@ -44,8 +44,11 @@ DEPRECATED_OPERATION(DeprecatedTestingIn
 DEPRECATED_OPERATION(DeprecatedTestingMethod)
 DEPRECATED_OPERATION(DeprecatedTestingAttribute)
 DEPRECATED_OPERATION(CreateImageBitmapCanvasRenderingContext2D)
 DEPRECATED_OPERATION(MozRequestFullScreenDeprecatedPrefix)
 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)
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -382,8 +382,15 @@ MozRequestFullScreenDeprecatedPrefixWarn
 # LOCALIZATION NOTE (MozfullscreenchangeDeprecatedPrefixWarning): Do not translate onmozfullscreenchange.
 MozfullscreenchangeDeprecatedPrefixWarning=onmozfullscreenchange is deprecated.
 # LOCALIZATION NOTE (MozfullscreenerrorDeprecatedPrefixWarning): Do not translate onmozfullscreenerror.
 MozfullscreenerrorDeprecatedPrefixWarning=onmozfullscreenerror is deprecated.
 # LOCALIZATION NOTE(External_AddSearchProviderWarning): Do not translate AddSearchProvider.
 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.
--- a/dom/mathml/nsMathMLElement.cpp
+++ b/dom/mathml/nsMathMLElement.cpp
@@ -182,17 +182,18 @@ nsMapRuleToAttributesFunc nsMathMLElemen
   // that satisfy IsAttributeMapped will be stored in the mapped attributes
   // list and available to the mapping function
   return &MapMathMLAttributesInto;
 }
 
 /* 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;
   }
   int32_t i = 0;
   // See if it is one of the 'namedspace' (ranging -7/18em, -6/18, ... 7/18em)
   if (aString.EqualsLiteral("veryverythinmathspace")) {
     i = 1;
   } else if (aString.EqualsLiteral("verythinmathspace")) {
@@ -220,16 +221,17 @@ bool nsMathMLElement::ParseNamedSpaceVal
       i = -5;
     } else if (aString.EqualsLiteral("negativeverythickmathspace")) {
       i = -6;
     } else if (aString.EqualsLiteral("negativeveryverythickmathspace")) {
       i = -7;
     }
   }
   if (0 != i) {
+    aDocument.WarnOnceAbout(dom::Document::eMathML_DeprecatedMathSpaceValue);
     aCSSValue.SetFloatValue(float(i) / float(18), eCSSUnit_EM);
     return true;
   }
 
   return false;
 }
 
 // The REC says:
@@ -280,17 +282,17 @@ bool nsMathMLElement::ParseNumericValue(
   int32_t stringLength = str.Length();
   if (!stringLength) {
     if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
       ReportLengthParseError(aString, aDocument);
     }
     return false;
   }
 
-  if (ParseNamedSpaceValue(str, aCSSValue, aFlags)) {
+  if (aDocument && ParseNamedSpaceValue(str, aCSSValue, aFlags, *aDocument)) {
     return true;
   }
 
   nsAutoString number, unit;
 
   // see if the negative sign is there
   int32_t i = 0;
   char16_t c = str[0];
@@ -541,16 +543,18 @@ void nsMathMLElement::MapMathMLAttribute
         parseSizeKeywords) {
       static const char sizes[3][7] = {"small", "normal", "big"};
       static const int32_t values[MOZ_ARRAY_LENGTH(sizes)] = {
           NS_STYLE_FONT_SIZE_SMALL, NS_STYLE_FONT_SIZE_MEDIUM,
           NS_STYLE_FONT_SIZE_LARGE};
       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;
         }
       }
     } else if (fontSize.GetUnit() == eCSSUnit_Percent) {
       aDecls.SetPercentValue(eCSSProperty_font_size,
                              fontSize.GetPercentValue());
     } else if (fontSize.GetUnit() != eCSSUnit_Null) {
--- a/dom/mathml/nsMathMLElement.h
+++ b/dom/mathml/nsMathMLElement.h
@@ -49,17 +49,18 @@ class nsMathMLElement final : public nsM
 
   enum {
     PARSE_ALLOW_UNITLESS = 0x01,  // unitless 0 will be turned into 0px
     PARSE_ALLOW_NEGATIVE = 0x02,
     PARSE_SUPPRESS_WARNINGS = 0x04,
     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);
 
   static void MapMathMLAttributesInto(const nsMappedAttributes* aAttributes,
                                       mozilla::MappedDeclarations&);
 
   void GetEventTargetParent(mozilla::EventChainPreVisitor& aVisitor) override;
--- a/layout/mathml/nsMathMLmfracFrame.cpp
+++ b/layout/mathml/nsMathMLmfracFrame.cpp
@@ -106,16 +106,17 @@ nscoord nsMathMLmfracFrame::CalcLineThic
   if (!aThicknessAttribute.IsEmpty()) {
     if (StaticPrefs::mathml_mfrac_linethickness_names_disabled()) {
       // length value
       lineThickness = defaultThickness;
       ParseNumericValue(aThicknessAttribute, &lineThickness,
                         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;
         // should visually decrease by at least one pixel, if default is not a
         // pixel
         if (defaultThickness > onePixel &&
             lineThickness > defaultThickness - onePixel) {
           lineThickness = defaultThickness - onePixel;
@@ -126,21 +127,26 @@ nscoord nsMathMLmfracFrame::CalcLineThic
         lineThickness = NSToCoordCeil(defaultThickness * THICK_FRACTION_LINE);
         minimumThickness = onePixel * THICK_FRACTION_LINE_MINIMUM_PIXELS;
         // should visually increase by at least one pixel
         if (lineThickness < defaultThickness + onePixel) {
           lineThickness = defaultThickness + onePixel;
         }
       } 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);
+      }
     }
   }
 
   // use minimum if the lineThickness is a non-zero value less than minimun
   if (lineThickness && lineThickness < minimumThickness)
     lineThickness = minimumThickness;
 
   return lineThickness;
--- a/layout/mathml/nsMathMLmfracFrame.h
+++ b/layout/mathml/nsMathMLmfracFrame.h
@@ -77,22 +77,21 @@ class nsMathMLmfracFrame final : public 
 
   NS_IMETHOD
   TransmitAutomaticData() override;
 
   // override the base method so that we can deal with the fraction line
   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;
 
  protected:
   explicit nsMathMLmfracFrame(ComputedStyle* aStyle,
                               nsPresContext* aPresContext)
       : nsMathMLContainerFrame(aStyle, aPresContext, kClassID),
         mLineRect(),
--- a/layout/mathml/nsMathMLmpaddedFrame.cpp
+++ b/layout/mathml/nsMathMLmpaddedFrame.cpp
@@ -203,17 +203,18 @@ bool nsMathMLmpaddedFrame::ParseAttribut
   else if (unit.EqualsLiteral("height"))
     aPseudoUnit = NS_MATHML_PSEUDO_UNIT_HEIGHT;
   else if (unit.EqualsLiteral("depth"))
     aPseudoUnit = NS_MATHML_PSEUDO_UNIT_DEPTH;
   else if (!gotPercent) {  // percentage can only apply to a pseudo-unit
 
     // 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);
       aPseudoUnit = NS_MATHML_PSEUDO_UNIT_NAMEDSPACE;
       return true;
     }
 
     // see if the input was just a CSS value
--- a/layout/mathml/nsMathMLmpaddedFrame.h
+++ b/layout/mathml/nsMathMLmpaddedFrame.h
@@ -81,18 +81,18 @@ class nsMathMLmpaddedFrame final : publi
   int32_t mHeightPseudoUnit;
   int32_t mDepthPseudoUnit;
   int32_t mLeadingSpacePseudoUnit;
   int32_t mVerticalOffsetPseudoUnit;
 
   // 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,
                    const ReflowOutput& aDesiredSize, nscoord& aValueToUpdate,
                    float aFontSizeInflation) const;
 };
 
 #endif /* nsMathMLmpaddedFrame_h___ */