Bug 1373525 - layout: Remove unused classes nsAutoScannerChanger and nsAutoCSSParserInputStateRestorer. r=dholbert
authorChris Peterson <cpeterson@mozilla.com>
Wed, 07 Jun 2017 00:03:03 -0700
changeset 414167 5b2269c9a15dcf67de271cffb882b569d3c5ef8f
parent 414166 2cd5acf5ef6178b604d11acf7dd939cb681c36f4
child 414168 6275675d2e5f63a6f38cf7e21c68f77fd402994e
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1373525
milestone56.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 1373525 - layout: Remove unused classes nsAutoScannerChanger and nsAutoCSSParserInputStateRestorer. r=dholbert layout/style/nsCSSParser.cpp:524:12 [-Wunused-member-function] unused member function 'DoNotRestore' layout/style/nsCSSParser.cpp:563:7 [-Wunused-member-function] unused member function 'nsAutoScannerChanger' layout/style/nsCSSParser.cpp:587:7 [-Wunused-member-function] unused member function '~nsAutoScannerChanger' layout/style/nsCSSParser.cpp:1236:8 [-Wunused-member-function] unused member function 'ParseSingleTokenVariantWithRestrictions' MozReview-Commit-ID: JRTBxrNcZzT
layout/style/nsCSSParser.cpp
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -500,111 +500,16 @@ protected:
   // the caller must hold on to aString until parsing is done
   void InitScanner(nsCSSScanner& aScanner,
                    css::ErrorReporter& aReporter,
                    nsIURI* aSheetURI, nsIURI* aBaseURI,
                    nsIPrincipal* aSheetPrincipal);
   void ReleaseScanner(void);
 
   /**
-   * This is a RAII class which behaves like an "AutoRestore<>" for our parser
-   * input state. When instantiated, this class saves the current parser input
-   * state (in a CSSParserInputState object), and it restores the parser to
-   * that state when destructed, unless "DoNotRestore()" has been called.
-  */
-  class MOZ_RAII nsAutoCSSParserInputStateRestorer {
-    public:
-      explicit nsAutoCSSParserInputStateRestorer(CSSParserImpl* aParser
-                                                 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-        : mParser(aParser),
-          mShouldRestore(true)
-      {
-        MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-        mParser->SaveInputState(mSavedState);
-      }
-
-      void DoNotRestore()
-      {
-        mShouldRestore = false;
-      }
-
-      ~nsAutoCSSParserInputStateRestorer()
-      {
-        if (mShouldRestore) {
-          mParser->RestoreSavedInputState(mSavedState);
-        }
-      }
-
-    private:
-      MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-      CSSParserImpl* mParser;
-      CSSParserInputState mSavedState;
-      bool mShouldRestore;
-  };
-
-  /**
-   * This is a RAII class which creates a temporary nsCSSScanner for the given
-   * string, and reconfigures aParser to use *that* scanner instead of its
-   * existing scanner, until we go out of scope.  (This allows us to rewrite
-   * a portion of a stylesheet using a temporary string, and switch to parsing
-   * that rewritten section, and then resume parsing the original stylesheet.)
-   *
-   * aParser must have a non-null nsCSSScanner (which we'll be temporarily
-   * replacing) and ErrorReporter (which this class will co-opt for the
-   * temporary parser). While we're in scope, we also suppress error reporting,
-   * so it doesn't really matter which reporter we use. We suppress reporting
-   * because this class is only used with CSS that is synthesized & didn't
-   * come directly from an author, and it would be confusing if we reported
-   * syntax errors for CSS that an author didn't provide.
-   *
-   * XXXdholbert we could also change this & report errors, if needed. Might
-   * want to customize the error reporting somehow though.
-   */
-  class MOZ_RAII nsAutoScannerChanger {
-    public:
-      nsAutoScannerChanger(CSSParserImpl* aParser,
-                           const nsAString& aStringToScan
-                           MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
-        : mParser(aParser),
-          mOriginalScanner(aParser->mScanner),
-          mStringScanner(aStringToScan, 0),
-          mParserStateRestorer(aParser),
-          mErrorSuppresser(aParser)
-      {
-        MOZ_ASSERT(mOriginalScanner,
-                   "Shouldn't use nsAutoScannerChanger unless we already "
-                   "have a scanner");
-        MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-
-        // Set & setup the new scanner:
-        mParser->mScanner = &mStringScanner;
-        mStringScanner.SetErrorReporter(mParser->mReporter);
-
-        // We might've had push-back on our original scanner (and if we did,
-        // that fact is saved via mParserStateRestorer).  But we don't have
-        // push-back in mStringScanner, so clear that flag.
-        mParser->mHavePushBack = false;
-      }
-
-      ~nsAutoScannerChanger()
-      {
-        // Restore original scanner. All other cleanup is done by RAII members.
-        mParser->mScanner = mOriginalScanner;
-      }
-
-    private:
-      MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-      CSSParserImpl* mParser;
-      nsCSSScanner *mOriginalScanner;
-      nsCSSScanner mStringScanner;
-      nsAutoCSSParserInputStateRestorer mParserStateRestorer;
-      nsAutoSuppressErrors mErrorSuppresser;
-  };
-
-  /**
    * Saves the current input state, which includes any currently pushed
    * back token, and the current position of the scanner.
    */
   void SaveInputState(CSSParserInputState& aState);
 
   /**
    * Restores the saved input state by pushing back any saved pushback
    * token and calling RestoreSavedPosition on the scanner.
@@ -1229,31 +1134,16 @@ protected:
                                             const KTableEntry aKeywordTable[])
   {
     MOZ_ASSERT(!(aVariantMask & VARIANT_MULTIPLE_TOKENS),
                "use ParseVariant for variants in VARIANT_MULTIPLE_TOKENS");
     CSSParseResult result = ParseVariant(aValue, aVariantMask, aKeywordTable);
     MOZ_ASSERT(result != CSSParseResult::Error);
     return result == CSSParseResult::Ok;
   }
-  bool ParseSingleTokenVariantWithRestrictions(
-      nsCSSValue& aValue,
-      int32_t aVariantMask,
-      const KTableEntry aKeywordTable[],
-      uint32_t aRestrictions)
-  {
-    MOZ_ASSERT(!(aVariantMask & VARIANT_MULTIPLE_TOKENS),
-               "use ParseVariantWithRestrictions for variants in "
-               "VARIANT_MULTIPLE_TOKENS");
-    CSSParseResult result =
-      ParseVariantWithRestrictions(aValue, aVariantMask, aKeywordTable,
-                                   aRestrictions);
-    MOZ_ASSERT(result != CSSParseResult::Error);
-    return result == CSSParseResult::Ok;
-  }
   bool ParseSingleTokenNonNegativeVariant(nsCSSValue& aValue,
                                           int32_t aVariantMask,
                                           const KTableEntry aKeywordTable[])
   {
     MOZ_ASSERT(!(aVariantMask & VARIANT_MULTIPLE_TOKENS),
                "use ParseNonNegativeVariant for variants in "
                "VARIANT_MULTIPLE_TOKENS");
     CSSParseResult result =