michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsXMLPrettyPrinter_h__ michael@0: #define nsXMLPrettyPrinter_h__ michael@0: michael@0: #include "nsStubDocumentObserver.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: class nsIDocument; michael@0: michael@0: class nsXMLPrettyPrinter : public nsStubDocumentObserver michael@0: { michael@0: public: michael@0: nsXMLPrettyPrinter(); michael@0: virtual ~nsXMLPrettyPrinter(); michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: // nsIMutationObserver michael@0: NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED michael@0: NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED michael@0: NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED michael@0: NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED michael@0: NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED michael@0: michael@0: /** michael@0: * This will prettyprint the document if the document is loaded in a michael@0: * displayed window. michael@0: * michael@0: * @param aDocument document to prettyprint michael@0: * @param [out] aDidPrettyPrint if true, and error not returned, actually michael@0: * went ahead with prettyprinting the document. michael@0: */ michael@0: nsresult PrettyPrint(nsIDocument* aDocument, bool* aDidPrettyPrint); michael@0: michael@0: /** michael@0: * Unhook the prettyprinter michael@0: */ michael@0: void Unhook(); michael@0: private: michael@0: /** michael@0: * Signals for unhooking by setting mUnhookPending if the node changed is michael@0: * non-anonymous content. michael@0: * michael@0: * @param aContent content that has changed michael@0: */ michael@0: void MaybeUnhook(nsIContent* aContent); michael@0: michael@0: nsIDocument* mDocument; //weak. Set as long as we're observing the document michael@0: bool mUnhookPending; michael@0: }; michael@0: michael@0: nsresult NS_NewXMLPrettyPrinter(nsXMLPrettyPrinter** aPrinter); michael@0: michael@0: #endif //nsXMLPrettyPrinter_h__