2012-11-15 20:36:15 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
/* diagnostic reporting for CSS style sheet parser */
|
|
|
|
|
|
|
|
#ifndef mozilla_css_ErrorReporter_h_
|
|
|
|
#define mozilla_css_ErrorReporter_h_
|
|
|
|
|
|
|
|
// XXX turn this off for minimo builds
|
|
|
|
#define CSS_REPORT_PARSE_ERRORS
|
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
struct nsCSSToken;
|
|
|
|
class nsCSSScanner;
|
|
|
|
class nsIURI;
|
|
|
|
|
|
|
|
namespace mozilla {
|
2014-06-20 14:32:49 +04:00
|
|
|
class CSSStyleSheet;
|
|
|
|
|
2012-11-15 20:36:15 +04:00
|
|
|
namespace css {
|
|
|
|
|
|
|
|
class Loader;
|
|
|
|
|
|
|
|
// If CSS_REPORT_PARSE_ERRORS is not defined, all of this class's
|
|
|
|
// methods become inline stubs.
|
2013-04-12 07:20:45 +04:00
|
|
|
class MOZ_STACK_CLASS ErrorReporter {
|
2012-11-15 20:36:15 +04:00
|
|
|
public:
|
|
|
|
ErrorReporter(const nsCSSScanner &aScanner,
|
2014-06-20 14:32:49 +04:00
|
|
|
const CSSStyleSheet *aSheet,
|
2012-11-15 20:36:15 +04:00
|
|
|
const Loader *aLoader,
|
|
|
|
nsIURI *aURI);
|
|
|
|
~ErrorReporter();
|
|
|
|
|
|
|
|
static void ReleaseGlobals();
|
|
|
|
|
|
|
|
void OutputError();
|
2013-12-12 06:09:44 +04:00
|
|
|
void OutputError(uint32_t aLineNumber, uint32_t aLineOffset);
|
2012-11-15 20:36:15 +04:00
|
|
|
void ClearError();
|
|
|
|
|
2012-11-15 20:36:15 +04:00
|
|
|
// In all overloads of ReportUnexpected, aMessage is a stringbundle
|
|
|
|
// name, which will be processed as a format string with the
|
|
|
|
// indicated number of parameters.
|
|
|
|
|
|
|
|
// no parameters
|
2012-11-15 20:36:15 +04:00
|
|
|
void ReportUnexpected(const char *aMessage);
|
2012-11-15 20:36:15 +04:00
|
|
|
// one parameter, a string
|
|
|
|
void ReportUnexpected(const char *aMessage, const nsString& aParam);
|
|
|
|
// one parameter, a token
|
|
|
|
void ReportUnexpected(const char *aMessage, const nsCSSToken& aToken);
|
|
|
|
// two parameters, a token and a character, in that order
|
|
|
|
void ReportUnexpected(const char *aMessage, const nsCSSToken& aToken,
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t aChar);
|
2012-11-15 20:36:15 +04:00
|
|
|
|
|
|
|
// for ReportUnexpectedEOF, aExpected can be either a stringbundle
|
|
|
|
// name or a single character. In the former case there may not be
|
|
|
|
// any format parameters.
|
|
|
|
void ReportUnexpectedEOF(const char *aExpected);
|
2014-01-04 19:02:17 +04:00
|
|
|
void ReportUnexpectedEOF(char16_t aExpected);
|
2012-11-15 20:36:15 +04:00
|
|
|
|
|
|
|
private:
|
2012-11-15 20:36:15 +04:00
|
|
|
void AddToError(const nsString &aErrorText);
|
2012-11-15 20:36:15 +04:00
|
|
|
|
|
|
|
#ifdef CSS_REPORT_PARSE_ERRORS
|
|
|
|
nsAutoString mError;
|
2013-01-11 21:27:43 +04:00
|
|
|
nsString mErrorLine;
|
2012-11-15 20:36:15 +04:00
|
|
|
nsString mFileName;
|
|
|
|
const nsCSSScanner *mScanner;
|
2014-06-20 14:32:49 +04:00
|
|
|
const CSSStyleSheet *mSheet;
|
2012-11-15 20:36:15 +04:00
|
|
|
const Loader *mLoader;
|
|
|
|
nsIURI *mURI;
|
|
|
|
uint64_t mInnerWindowID;
|
|
|
|
uint32_t mErrorLineNumber;
|
2013-01-11 21:27:43 +04:00
|
|
|
uint32_t mPrevErrorLineNumber;
|
2012-11-15 20:36:15 +04:00
|
|
|
uint32_t mErrorColNumber;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef CSS_REPORT_PARSE_ERRORS
|
|
|
|
inline ErrorReporter::ErrorReporter(const nsCSSScanner&,
|
2014-06-20 14:32:49 +04:00
|
|
|
const CSSStyleSheet*,
|
2012-11-15 20:36:15 +04:00
|
|
|
const Loader*,
|
|
|
|
nsIURI*) {}
|
|
|
|
inline ErrorReporter::~ErrorReporter() {}
|
|
|
|
|
|
|
|
inline void ErrorReporter::ReleaseGlobals() {}
|
|
|
|
|
|
|
|
inline void ErrorReporter::OutputError() {}
|
|
|
|
inline void ErrorReporter::ClearError() {}
|
|
|
|
|
|
|
|
inline void ErrorReporter::ReportUnexpected(const char *) {}
|
2012-11-15 20:36:15 +04:00
|
|
|
inline void ErrorReporter::ReportUnexpected(const char *, const nsString &) {}
|
|
|
|
inline void ErrorReporter::ReportUnexpected(const char *, const nsCSSToken &) {}
|
|
|
|
inline void ErrorReporter::ReportUnexpected(const char *, const nsCSSToken &,
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t) {}
|
2012-11-15 20:36:15 +04:00
|
|
|
|
2012-11-15 20:36:15 +04:00
|
|
|
inline void ErrorReporter::ReportUnexpectedEOF(const char *) {}
|
2014-01-04 19:02:17 +04:00
|
|
|
inline void ErrorReporter::ReportUnexpectedEOF(char16_t) {}
|
2012-11-15 20:36:15 +04:00
|
|
|
|
|
|
|
inline void ErrorReporter::AddToError(const nsString &) {}
|
2012-11-15 20:36:15 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace css
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_css_ErrorReporter_h_
|