From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- dom/base/nsTreeSanitizer.h | 276 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 dom/base/nsTreeSanitizer.h (limited to 'dom/base/nsTreeSanitizer.h') diff --git a/dom/base/nsTreeSanitizer.h b/dom/base/nsTreeSanitizer.h new file mode 100644 index 0000000000..68682ef1c3 --- /dev/null +++ b/dom/base/nsTreeSanitizer.h @@ -0,0 +1,276 @@ +/* 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 "nsIPrincipal.h" +#include "nsTHashtable.h" + +class nsIContent; +class nsINode; + +namespace mozilla { +class DeclarationBlock; +} + +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 MOZ_STACK_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); + + private: + /** + * Whether