Bumping manifests a=b2g-bump
[gecko.git] / layout / style / ErrorReporter.h
blob3a57a3be5ccda15871ba5bb1a5f2b8e38c7936e7
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 nsCSSScanner;
18 class nsIURI;
20 namespace mozilla {
21 class CSSStyleSheet;
23 namespace css {
25 class Loader;
27 // If CSS_REPORT_PARSE_ERRORS is not defined, all of this class's
28 // methods become inline stubs.
29 class MOZ_STACK_CLASS ErrorReporter {
30 public:
31 ErrorReporter(const nsCSSScanner &aScanner,
32 const CSSStyleSheet *aSheet,
33 const Loader *aLoader,
34 nsIURI *aURI);
35 ~ErrorReporter();
37 static void ReleaseGlobals();
39 void OutputError();
40 void OutputError(uint32_t aLineNumber, uint32_t aLineOffset);
41 void ClearError();
43 // In all overloads of ReportUnexpected, aMessage is a stringbundle
44 // name, which will be processed as a format string with the
45 // indicated number of parameters.
47 // no parameters
48 void ReportUnexpected(const char *aMessage);
49 // one parameter, a string
50 void ReportUnexpected(const char *aMessage, const nsString& aParam);
51 // one parameter, a token
52 void ReportUnexpected(const char *aMessage, const nsCSSToken& aToken);
53 // two parameters, a token and a character, in that order
54 void ReportUnexpected(const char *aMessage, const nsCSSToken& aToken,
55 char16_t aChar);
57 // for ReportUnexpectedEOF, aExpected can be either a stringbundle
58 // name or a single character. In the former case there may not be
59 // any format parameters.
60 void ReportUnexpectedEOF(const char *aExpected);
61 void ReportUnexpectedEOF(char16_t aExpected);
63 private:
64 void AddToError(const nsString &aErrorText);
66 #ifdef CSS_REPORT_PARSE_ERRORS
67 nsAutoString mError;
68 nsString mErrorLine;
69 nsString mFileName;
70 const nsCSSScanner *mScanner;
71 const CSSStyleSheet *mSheet;
72 const Loader *mLoader;
73 nsIURI *mURI;
74 uint64_t mInnerWindowID;
75 uint32_t mErrorLineNumber;
76 uint32_t mPrevErrorLineNumber;
77 uint32_t mErrorColNumber;
78 #endif
81 #ifndef CSS_REPORT_PARSE_ERRORS
82 inline ErrorReporter::ErrorReporter(const nsCSSScanner&,
83 const CSSStyleSheet*,
84 const Loader*,
85 nsIURI*) {}
86 inline ErrorReporter::~ErrorReporter() {}
88 inline void ErrorReporter::ReleaseGlobals() {}
90 inline void ErrorReporter::OutputError() {}
91 inline void ErrorReporter::ClearError() {}
93 inline void ErrorReporter::ReportUnexpected(const char *) {}
94 inline void ErrorReporter::ReportUnexpected(const char *, const nsString &) {}
95 inline void ErrorReporter::ReportUnexpected(const char *, const nsCSSToken &) {}
96 inline void ErrorReporter::ReportUnexpected(const char *, const nsCSSToken &,
97 char16_t) {}
99 inline void ErrorReporter::ReportUnexpectedEOF(const char *) {}
100 inline void ErrorReporter::ReportUnexpectedEOF(char16_t) {}
102 inline void ErrorReporter::AddToError(const nsString &) {}
103 #endif
105 } // namespace css
106 } // namespace mozilla
108 #endif // mozilla_css_ErrorReporter_h_