content/xml/document/src/nsXMLPrettyPrinter.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/xml/document/src/nsXMLPrettyPrinter.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsXMLPrettyPrinter_h__
    1.10 +#define nsXMLPrettyPrinter_h__
    1.11 +
    1.12 +#include "nsStubDocumentObserver.h"
    1.13 +#include "nsCOMPtr.h"
    1.14 +
    1.15 +class nsIDocument;
    1.16 +
    1.17 +class nsXMLPrettyPrinter : public nsStubDocumentObserver
    1.18 +{
    1.19 +public:
    1.20 +    nsXMLPrettyPrinter();
    1.21 +    virtual ~nsXMLPrettyPrinter();
    1.22 +
    1.23 +    NS_DECL_ISUPPORTS
    1.24 +
    1.25 +    // nsIMutationObserver
    1.26 +    NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
    1.27 +    NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
    1.28 +    NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
    1.29 +    NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
    1.30 +    NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
    1.31 +
    1.32 +    /**
    1.33 +     * This will prettyprint the document if the document is loaded in a
    1.34 +     * displayed window.
    1.35 +     *
    1.36 +     * @param aDocument  document to prettyprint
    1.37 +     * @param [out] aDidPrettyPrint if true, and error not returned, actually
    1.38 +     *              went ahead with prettyprinting the document.
    1.39 +     */
    1.40 +    nsresult PrettyPrint(nsIDocument* aDocument, bool* aDidPrettyPrint);
    1.41 +
    1.42 +    /**
    1.43 +     * Unhook the prettyprinter
    1.44 +     */
    1.45 +    void Unhook();
    1.46 +private:
    1.47 +    /**
    1.48 +     * Signals for unhooking by setting mUnhookPending if the node changed is
    1.49 +     * non-anonymous content.
    1.50 +     *
    1.51 +     * @param aContent  content that has changed
    1.52 +     */
    1.53 +    void MaybeUnhook(nsIContent* aContent);
    1.54 +
    1.55 +    nsIDocument* mDocument; //weak. Set as long as we're observing the document
    1.56 +    bool mUnhookPending;
    1.57 +};
    1.58 +
    1.59 +nsresult NS_NewXMLPrettyPrinter(nsXMLPrettyPrinter** aPrinter);
    1.60 +
    1.61 +#endif //nsXMLPrettyPrinter_h__

mercurial