summaryrefslogtreecommitdiffstats
path: root/layout/style/ErrorReporter.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /layout/style/ErrorReporter.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'layout/style/ErrorReporter.h')
-rw-r--r--layout/style/ErrorReporter.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/layout/style/ErrorReporter.h b/layout/style/ErrorReporter.h
new file mode 100644
index 000000000..f3d7fa1da
--- /dev/null
+++ b/layout/style/ErrorReporter.h
@@ -0,0 +1,113 @@
+/* -*- 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 {
+class CSSStyleSheet;
+
+namespace css {
+
+class Loader;
+
+// If CSS_REPORT_PARSE_ERRORS is not defined, all of this class's
+// methods become inline stubs.
+class MOZ_STACK_CLASS ErrorReporter {
+public:
+ ErrorReporter(const nsCSSScanner &aScanner,
+ const CSSStyleSheet *aSheet,
+ const Loader *aLoader,
+ nsIURI *aURI);
+ ~ErrorReporter();
+
+ static void ReleaseGlobals();
+
+ void OutputError();
+ void OutputError(uint32_t aLineNumber, uint32_t aLineOffset);
+ void ClearError();
+
+ // 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
+ void ReportUnexpected(const char *aMessage);
+ // 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,
+ char16_t aChar);
+ // two parameters, a param and a value
+ void ReportUnexpected(const char *aMessage, const nsString& aParam,
+ const nsString& aValue);
+
+ // 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);
+ void ReportUnexpectedEOF(char16_t aExpected);
+
+private:
+ void AddToError(const nsString &aErrorText);
+
+#ifdef CSS_REPORT_PARSE_ERRORS
+ nsAutoString mError;
+ nsString mErrorLine;
+ nsString mFileName;
+ const nsCSSScanner *mScanner;
+ const CSSStyleSheet *mSheet;
+ const Loader *mLoader;
+ nsIURI *mURI;
+ uint64_t mInnerWindowID;
+ uint32_t mErrorLineNumber;
+ uint32_t mPrevErrorLineNumber;
+ uint32_t mErrorColNumber;
+#endif
+};
+
+#ifndef CSS_REPORT_PARSE_ERRORS
+inline ErrorReporter::ErrorReporter(const nsCSSScanner&,
+ const CSSStyleSheet*,
+ const Loader*,
+ nsIURI*) {}
+inline ErrorReporter::~ErrorReporter() {}
+
+inline void ErrorReporter::ReleaseGlobals() {}
+
+inline void ErrorReporter::OutputError() {}
+inline void ErrorReporter::ClearError() {}
+
+inline void ErrorReporter::ReportUnexpected(const char *) {}
+inline void ErrorReporter::ReportUnexpected(const char *, const nsString &) {}
+inline void ErrorReporter::ReportUnexpected(const char *, const nsCSSToken &) {}
+inline void ErrorReporter::ReportUnexpected(const char *, const nsCSSToken &,
+ char16_t) {}
+inline void ErrorReporter::ReportUnexpected(const char *, const nsString &,
+ const nsString &) {}
+
+inline void ErrorReporter::ReportUnexpectedEOF(const char *) {}
+inline void ErrorReporter::ReportUnexpectedEOF(char16_t) {}
+
+inline void ErrorReporter::AddToError(const nsString &) {}
+#endif
+
+} // namespace css
+} // namespace mozilla
+
+#endif // mozilla_css_ErrorReporter_h_