Bug 1560055 part 4. Remove remaining uses of ParseSpecialIntValue. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 28 Jun 2019 21:00:15 +0000
changeset 543447 98d562c4a456194b340cf25181a7c26eb6805415
parent 543446 f094b8e00c4c50160faad3330de66d912b1cc4c4
child 543448 513a8dfd574e23c66cceec4f9aa862efc42b148c
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1560055
milestone69.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 1560055 part 4. Remove remaining uses of ParseSpecialIntValue. r=mccr8 We don't need to parse 'width' on <tr> because we never use the parsed value for anything and neither does the spec. We don't need to parse 'charoff' on <col> because we never use that for anything either, and neither does the spec. Differential Revision: https://phabricator.services.mozilla.com/D36128
dom/base/nsAttrValue.cpp
dom/base/nsAttrValue.h
dom/html/HTMLTableColElement.cpp
dom/html/HTMLTableRowElement.cpp
--- a/dom/base/nsAttrValue.cpp
+++ b/dom/base/nsAttrValue.cpp
@@ -1244,44 +1244,16 @@ bool nsAttrValue::ParseEnumValue(const n
     SetIntValueAndType(EnumTableEntryToValue(aTable, aDefaultValue), eEnum,
                        &aValue);
     return true;
   }
 
   return false;
 }
 
-bool nsAttrValue::ParseSpecialIntValue(const nsAString& aString) {
-  ResetIfSet();
-
-  nsAutoString tmp(aString);
-  nsContentUtils::ParseHTMLIntegerResultFlags result;
-  int32_t originalVal = nsContentUtils::ParseHTMLInteger(aString, &result);
-
-  if (result & nsContentUtils::eParseHTMLInteger_Error) {
-    return false;
-  }
-
-  bool isPercent = result & nsContentUtils::eParseHTMLInteger_IsPercent;
-  int32_t val = std::max(originalVal, 0);
-  bool nonStrict =
-      val != originalVal ||
-      (result & nsContentUtils::eParseHTMLInteger_NonStandard) ||
-      (result & nsContentUtils::eParseHTMLInteger_DidNotConsumeAllInput);
-
-  // % (percent)
-  if (isPercent || tmp.RFindChar('%') >= 0) {
-    isPercent = true;
-  }
-
-  SetIntValueAndType(val, isPercent ? ePercent : eInteger,
-                     nonStrict ? &aString : nullptr);
-  return true;
-}
-
 bool nsAttrValue::DoParseHTMLDimension(const nsAString& aInput,
                                        bool aEnsureNonzero) {
   ResetIfSet();
 
   // We don't use nsContentUtils::ParseHTMLInteger here because we
   // need a bunch of behavioral differences from it.  We _could_ try to
   // use it, but it would not be a great fit.
 
--- a/dom/base/nsAttrValue.h
+++ b/dom/base/nsAttrValue.h
@@ -298,30 +298,16 @@ class nsAttrValue {
    *        cause aDefaultValue->value to be stored as the enumeration value.
    * @return whether the enum value was found or not
    */
   bool ParseEnumValue(const nsAString& aValue, const EnumTable* aTable,
                       bool aCaseSensitive,
                       const EnumTable* aDefaultValue = nullptr);
 
   /**
-   * Parse a string into an integer. Can optionally parse percent (n%).
-   * This method explicitly sets a lower bound of zero on the element,
-   * whether it be percent or raw integer.
-   *
-   * @param aString the string to parse
-   * @return whether the value could be parsed
-   *
-   * @see http://www.whatwg.org/html/#rules-for-parsing-dimension-values
-   *
-   * But note that this function implements something totally different!
-   */
-  bool ParseSpecialIntValue(const nsAString& aString);
-
-  /**
    * Parse a string into a dimension value.  This is similar to
    * https://html.spec.whatwg.org/multipage/#rules-for-parsing-dimension-values
    * but drops the fractional part of the value for now, until we figure out how
    * to store that in our nsAttrValue.
    *
    * The resulting value (if the parse succeeds) is either eInteger or
    * ePercent, depending on whether we found a '%' at the end of the value.
    *
--- a/dom/html/HTMLTableColElement.cpp
+++ b/dom/html/HTMLTableColElement.cpp
@@ -30,19 +30,16 @@ NS_IMPL_ELEMENT_CLONE(HTMLTableColElemen
 
 bool HTMLTableColElement::ParseAttribute(int32_t aNamespaceID,
                                          nsAtom* aAttribute,
                                          const nsAString& aValue,
                                          nsIPrincipal* aMaybeScriptedPrincipal,
                                          nsAttrValue& aResult) {
   if (aNamespaceID == kNameSpaceID_None) {
     /* ignore these attributes, stored simply as strings ch */
-    if (aAttribute == nsGkAtoms::charoff) {
-      return aResult.ParseSpecialIntValue(aValue);
-    }
     if (aAttribute == nsGkAtoms::span) {
       /* protection from unrealistic large colspan values */
       aResult.ParseClampedNonNegativeInt(aValue, 1, 1, MAX_COLSPAN);
       return true;
     }
     if (aAttribute == nsGkAtoms::width) {
       // Spec says to use ParseNonzeroHTMLDimension, but Chrome and Safari both
       // allow 0, and we did all along too, so keep that behavior.  See
--- a/dom/html/HTMLTableRowElement.cpp
+++ b/dom/html/HTMLTableRowElement.cpp
@@ -205,19 +205,16 @@ bool HTMLTableRowElement::ParseAttribute
     if (aAttribute == nsGkAtoms::charoff) {
       return aResult.ParseIntWithBounds(aValue, 0);
     }
     if (aAttribute == nsGkAtoms::height) {
       // Per spec should be ParseNonzeroHTMLDimension, but no browsers do that.
       // See https://github.com/whatwg/html/issues/4716
       return aResult.ParseHTMLDimension(aValue);
     }
-    if (aAttribute == nsGkAtoms::width) {
-      return aResult.ParseSpecialIntValue(aValue);
-    }
     if (aAttribute == nsGkAtoms::align) {
       return ParseTableCellHAlignValue(aValue, aResult);
     }
     if (aAttribute == nsGkAtoms::bgcolor) {
       return aResult.ParseColor(aValue);
     }
     if (aAttribute == nsGkAtoms::valign) {
       return ParseTableVAlignValue(aValue, aResult);