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
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
{
31 ErrorReporter(const nsCSSScanner
&aScanner
,
32 const CSSStyleSheet
*aSheet
,
33 const Loader
*aLoader
,
37 static void ReleaseGlobals();
40 void OutputError(uint32_t aLineNumber
, uint32_t aLineOffset
);
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.
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
,
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
);
64 void AddToError(const nsString
&aErrorText
);
66 #ifdef CSS_REPORT_PARSE_ERRORS
70 const nsCSSScanner
*mScanner
;
71 const CSSStyleSheet
*mSheet
;
72 const Loader
*mLoader
;
74 uint64_t mInnerWindowID
;
75 uint32_t mErrorLineNumber
;
76 uint32_t mPrevErrorLineNumber
;
77 uint32_t mErrorColNumber
;
81 #ifndef CSS_REPORT_PARSE_ERRORS
82 inline ErrorReporter::ErrorReporter(const nsCSSScanner
&,
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
&,
99 inline void ErrorReporter::ReportUnexpectedEOF(const char *) {}
100 inline void ErrorReporter::ReportUnexpectedEOF(char16_t
) {}
102 inline void ErrorReporter::AddToError(const nsString
&) {}
106 } // namespace mozilla
108 #endif // mozilla_css_ErrorReporter_h_