layout/style/ErrorReporter.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /* diagnostic reporting for CSS style sheet parser */
michael@0 7
michael@0 8 #ifndef mozilla_css_ErrorReporter_h_
michael@0 9 #define mozilla_css_ErrorReporter_h_
michael@0 10
michael@0 11 // XXX turn this off for minimo builds
michael@0 12 #define CSS_REPORT_PARSE_ERRORS
michael@0 13
michael@0 14 #include "nsString.h"
michael@0 15
michael@0 16 struct nsCSSToken;
michael@0 17 class nsCSSStyleSheet;
michael@0 18 class nsCSSScanner;
michael@0 19 class nsIURI;
michael@0 20
michael@0 21 namespace mozilla {
michael@0 22 namespace css {
michael@0 23
michael@0 24 class Loader;
michael@0 25
michael@0 26 // If CSS_REPORT_PARSE_ERRORS is not defined, all of this class's
michael@0 27 // methods become inline stubs.
michael@0 28 class MOZ_STACK_CLASS ErrorReporter {
michael@0 29 public:
michael@0 30 ErrorReporter(const nsCSSScanner &aScanner,
michael@0 31 const nsCSSStyleSheet *aSheet,
michael@0 32 const Loader *aLoader,
michael@0 33 nsIURI *aURI);
michael@0 34 ~ErrorReporter();
michael@0 35
michael@0 36 static void ReleaseGlobals();
michael@0 37
michael@0 38 void OutputError();
michael@0 39 void OutputError(uint32_t aLineNumber, uint32_t aLineOffset);
michael@0 40 void ClearError();
michael@0 41
michael@0 42 // In all overloads of ReportUnexpected, aMessage is a stringbundle
michael@0 43 // name, which will be processed as a format string with the
michael@0 44 // indicated number of parameters.
michael@0 45
michael@0 46 // no parameters
michael@0 47 void ReportUnexpected(const char *aMessage);
michael@0 48 // one parameter, a string
michael@0 49 void ReportUnexpected(const char *aMessage, const nsString& aParam);
michael@0 50 // one parameter, a token
michael@0 51 void ReportUnexpected(const char *aMessage, const nsCSSToken& aToken);
michael@0 52 // two parameters, a token and a character, in that order
michael@0 53 void ReportUnexpected(const char *aMessage, const nsCSSToken& aToken,
michael@0 54 char16_t aChar);
michael@0 55
michael@0 56 // for ReportUnexpectedEOF, aExpected can be either a stringbundle
michael@0 57 // name or a single character. In the former case there may not be
michael@0 58 // any format parameters.
michael@0 59 void ReportUnexpectedEOF(const char *aExpected);
michael@0 60 void ReportUnexpectedEOF(char16_t aExpected);
michael@0 61
michael@0 62 private:
michael@0 63 void AddToError(const nsString &aErrorText);
michael@0 64
michael@0 65 #ifdef CSS_REPORT_PARSE_ERRORS
michael@0 66 nsAutoString mError;
michael@0 67 nsString mErrorLine;
michael@0 68 nsString mFileName;
michael@0 69 const nsCSSScanner *mScanner;
michael@0 70 const nsCSSStyleSheet *mSheet;
michael@0 71 const Loader *mLoader;
michael@0 72 nsIURI *mURI;
michael@0 73 uint64_t mInnerWindowID;
michael@0 74 uint32_t mErrorLineNumber;
michael@0 75 uint32_t mPrevErrorLineNumber;
michael@0 76 uint32_t mErrorColNumber;
michael@0 77 #endif
michael@0 78 };
michael@0 79
michael@0 80 #ifndef CSS_REPORT_PARSE_ERRORS
michael@0 81 inline ErrorReporter::ErrorReporter(const nsCSSScanner&,
michael@0 82 const nsCSSStyleSheet*,
michael@0 83 const Loader*,
michael@0 84 nsIURI*) {}
michael@0 85 inline ErrorReporter::~ErrorReporter() {}
michael@0 86
michael@0 87 inline void ErrorReporter::ReleaseGlobals() {}
michael@0 88
michael@0 89 inline void ErrorReporter::OutputError() {}
michael@0 90 inline void ErrorReporter::ClearError() {}
michael@0 91
michael@0 92 inline void ErrorReporter::ReportUnexpected(const char *) {}
michael@0 93 inline void ErrorReporter::ReportUnexpected(const char *, const nsString &) {}
michael@0 94 inline void ErrorReporter::ReportUnexpected(const char *, const nsCSSToken &) {}
michael@0 95 inline void ErrorReporter::ReportUnexpected(const char *, const nsCSSToken &,
michael@0 96 char16_t) {}
michael@0 97
michael@0 98 inline void ErrorReporter::ReportUnexpectedEOF(const char *) {}
michael@0 99 inline void ErrorReporter::ReportUnexpectedEOF(char16_t) {}
michael@0 100
michael@0 101 inline void ErrorReporter::AddToError(const nsString &) {}
michael@0 102 #endif
michael@0 103
michael@0 104 } // namespace css
michael@0 105 } // namespace mozilla
michael@0 106
michael@0 107 #endif // mozilla_css_ErrorReporter_h_

mercurial