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