1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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 nsIXULDocument_h___ 7 #define nsIXULDocument_h___ 8 9 #include "nsISupports.h" 10 #include "nsString.h" 11 #include "nsCOMArray.h" 12 13 class nsIXULTemplateBuilder; 14 class nsIContent; 15 16 17 // 81ba4be5-6cc5-478a-9b08-b3e7ed524455 18 #define NS_IXULDOCUMENT_IID \ 19 {0x81ba4be5, 0x6cc5, 0x478a, {0x9b, 0x08, 0xb3, 0xe7, 0xed, 0x52, 0x44, 0x55}} 20 21 22 /* 23 * An XUL-specific extension to nsIDocument. Includes methods for 24 * setting the root resource of the document content model, a factory 25 * method for constructing the children of a node, etc. 26 */ 27 class nsIXULDocument : public nsISupports 28 { 29 public: 30 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXULDOCUMENT_IID) 31 32 /** 33 * Get the elements for a particular resource --- all elements whose 'id' 34 * or 'ref' is aID. The nsCOMArray will be truncated and filled in with 35 * nsIContent pointers. 36 */ 37 virtual void GetElementsForID(const nsAString& aID, nsCOMArray<nsIContent>& aElements) = 0; 38 39 /** 40 * Notify the XUL document that a subtree has been added 41 */ 42 NS_IMETHOD AddSubtreeToDocument(nsIContent* aElement) = 0; 43 44 /** 45 * Notify the XUL document that a subtree has been removed 46 */ 47 NS_IMETHOD RemoveSubtreeFromDocument(nsIContent* aElement) = 0; 48 49 /** 50 * Attach a XUL template builder to the specified content node. 51 * @param aBuilder the template builder to attach, or null if 52 * the builder is to be removed. 53 */ 54 NS_IMETHOD SetTemplateBuilderFor(nsIContent* aContent, nsIXULTemplateBuilder* aBuilder) = 0; 55 56 /** 57 * Retrieve the XUL template builder that's attached to a content 58 * node. 59 */ 60 NS_IMETHOD GetTemplateBuilderFor(nsIContent* aContent, nsIXULTemplateBuilder** aResult) = 0; 61 62 /** 63 * This is invoked whenever the prototype for this document is loaded 64 * and should be walked, regardless of whether the XUL cache is 65 * disabled, whether the protototype was loaded, whether the 66 * prototype was loaded from the cache or created by parsing the 67 * actual XUL source, etc. 68 * 69 * @param aResumeWalk whether this should also call ResumeWalk(). 70 * Sometimes the caller of OnPrototypeLoadDone resumes the walk itself 71 */ 72 NS_IMETHOD OnPrototypeLoadDone(bool aResumeWalk) = 0; 73 74 /** 75 * Callback notifying when a document could not be parsed properly. 76 */ 77 virtual bool OnDocumentParserError() = 0; 78 79 /** 80 * Reset the document direction so that it is recomputed. 81 */ 82 virtual void ResetDocumentDirection() = 0; 83 84 virtual void ResetDocumentLWTheme() = 0; 85 }; 86 87 NS_DEFINE_STATIC_IID_ACCESSOR(nsIXULDocument, NS_IXULDOCUMENT_IID) 88 89 // factory functions 90 nsresult NS_NewXULDocument(nsIXULDocument** result); 91 92 #endif // nsIXULDocument_h___ 93