Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / ErrorReporter.h
blob3f24cf089fed68691ff4c5e82fe17fd7259e83a0
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* diagnostic reporting for CSS style sheet parser */
9 #ifndef mozilla_css_ErrorReporter_h_
10 #define mozilla_css_ErrorReporter_h_
12 #include "nsString.h"
14 struct nsCSSToken;
15 class nsIURI;
17 namespace mozilla {
18 class StyleSheet;
20 namespace dom {
21 class Document;
24 namespace css {
26 class Loader;
28 // FIXME(emilio): Probably better to call this ErrorBuilder or something?
29 class MOZ_STACK_CLASS ErrorReporter final {
30 public:
31 explicit ErrorReporter(uint64_t aInnerWindowId);
32 ~ErrorReporter();
34 static void ReleaseGlobals();
35 static void EnsureGlobalsInitialized() {
36 if (MOZ_UNLIKELY(!sInitialized)) {
37 InitGlobals();
41 static bool ShouldReportErrors(const dom::Document&);
42 static bool ShouldReportErrors(const StyleSheet*, const Loader*);
43 static uint64_t FindInnerWindowId(const StyleSheet*, const Loader*);
45 void OutputError(const nsACString& aSource, const nsACString& aSelectors,
46 uint32_t aLineNumber, uint32_t aColNumber, nsIURI* aURI);
47 void ClearError();
49 // In all overloads of ReportUnexpected, aMessage is a stringbundle
50 // name, which will be processed as a format string with the
51 // indicated number of parameters.
53 // no parameters
54 void ReportUnexpected(const char* aMessage);
55 // one parameter which has already been escaped appropriately
56 void ReportUnexpectedUnescaped(const char* aMessage,
57 const nsTArray<nsString>& aParam);
59 private:
60 void AddToError(const nsString& aErrorText);
61 static void InitGlobals();
63 static bool sInitialized;
64 static bool sReportErrors;
66 nsString mError;
67 const uint64_t mInnerWindowId;
70 } // namespace css
71 } // namespace mozilla
73 #endif // mozilla_css_ErrorReporter_h_