|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsXMLPrettyPrinter_h__ |
|
7 #define nsXMLPrettyPrinter_h__ |
|
8 |
|
9 #include "nsStubDocumentObserver.h" |
|
10 #include "nsCOMPtr.h" |
|
11 |
|
12 class nsIDocument; |
|
13 |
|
14 class nsXMLPrettyPrinter : public nsStubDocumentObserver |
|
15 { |
|
16 public: |
|
17 nsXMLPrettyPrinter(); |
|
18 virtual ~nsXMLPrettyPrinter(); |
|
19 |
|
20 NS_DECL_ISUPPORTS |
|
21 |
|
22 // nsIMutationObserver |
|
23 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED |
|
24 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED |
|
25 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED |
|
26 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED |
|
27 NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED |
|
28 |
|
29 /** |
|
30 * This will prettyprint the document if the document is loaded in a |
|
31 * displayed window. |
|
32 * |
|
33 * @param aDocument document to prettyprint |
|
34 * @param [out] aDidPrettyPrint if true, and error not returned, actually |
|
35 * went ahead with prettyprinting the document. |
|
36 */ |
|
37 nsresult PrettyPrint(nsIDocument* aDocument, bool* aDidPrettyPrint); |
|
38 |
|
39 /** |
|
40 * Unhook the prettyprinter |
|
41 */ |
|
42 void Unhook(); |
|
43 private: |
|
44 /** |
|
45 * Signals for unhooking by setting mUnhookPending if the node changed is |
|
46 * non-anonymous content. |
|
47 * |
|
48 * @param aContent content that has changed |
|
49 */ |
|
50 void MaybeUnhook(nsIContent* aContent); |
|
51 |
|
52 nsIDocument* mDocument; //weak. Set as long as we're observing the document |
|
53 bool mUnhookPending; |
|
54 }; |
|
55 |
|
56 nsresult NS_NewXMLPrettyPrinter(nsXMLPrettyPrinter** aPrinter); |
|
57 |
|
58 #endif //nsXMLPrettyPrinter_h__ |