diff -r 000000000000 -r 6474c204b198 content/base/public/nsTreeSanitizer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/content/base/public/nsTreeSanitizer.h Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,227 @@ +/* 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 "mozilla/css/StyleRule.h" +#include "nsIPrincipal.h" +#include "mozilla/dom/Element.h" + +class nsIContent; + +/** + * 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 + */ + nsTreeSanitizer(uint32_t aFlags = 0); + + static void InitializeStatics(); + static void ReleaseStatics(); + + /** + * Sanitizes a disconnected DOM fragment freshly obtained from a parser. + * The argument must be of type nsINode::eDOCUMENT_FRAGMENT and, + * consequently, must not be in the document. Furthermore, the fragment + * must have just come from a parser so that it can't have mutation + * event listeners set on it. + */ + void Sanitize(nsIContent* 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(nsIDocument* aDocument); + + private: + + /** + * Whether