/* 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/. */ #ifndef nsTreeSanitizer_h_ #define nsTreeSanitizer_h_ #include "nsAtom.h" #include "nsHashKeys.h" #include "nsHashtablesFwd.h" #include "nsIPrincipal.h" #include "nsTArray.h" #include "nsTHashSet.h" #include "mozilla/UniquePtr.h" #include "mozilla/dom/NameSpaceConstants.h" #include "mozilla/dom/SanitizerBinding.h" class nsIContent; class nsIGlobalObject; class nsINode; namespace mozilla { class DeclarationBlock; enum class StyleSanitizationKind : uint8_t; } // namespace mozilla namespace mozilla::dom { class DocumentFragment; class Element; } // namespace mozilla::dom /** * See the documentation of nsIParserUtils::sanitize for documentation * about the default behavior and the configuration options of this sanitizer. */ class nsTreeSanitizer { public: /** * The constructor. * * @param aFlags Flags from nsIParserUtils */ explicit nsTreeSanitizer(uint32_t aFlags = 0); static void InitializeStatics(); static void ReleaseStatics(); /** * Sanitizes a disconnected DOM fragment freshly obtained from a parser. * The fragment must have just come from a parser so that it can't have * mutation event listeners set on it. */ void Sanitize(mozilla::dom::DocumentFragment* aFragment); /** * Sanitizes a disconnected (not in a docshell) document freshly obtained * from a parser. The document must not be embedded in a docshell and must * not have had a chance to get mutation event listeners attached to it. * The root element must be . */ void Sanitize(mozilla::dom::Document* aDocument); /** * Provides additional options for usage from the Web Sanitizer API * which allows modifying the allow-list from above */ void WithWebSanitizerOptions(nsIGlobalObject* aGlobal, const mozilla::dom::SanitizerConfig& aOptions); /** * Removes conditional CSS from this subtree. */ static void RemoveConditionalCSSFromSubtree(nsINode* aRoot); private: /** * Whether