1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef nsIHTMLDocument_h
39 : #define nsIHTMLDocument_h
40 :
41 : #include "nsISupports.h"
42 : #include "nsCompatibility.h"
43 :
44 : class nsIDOMHTMLFormElement;
45 : class nsIContent;
46 : class nsIScriptElement;
47 : class nsIEditor;
48 : class nsContentList;
49 : class nsWrapperCache;
50 :
51 : #define NS_IHTMLDOCUMENT_IID \
52 : { 0xa921276f, 0x5e70, 0x42e0, \
53 : { 0xb8, 0x36, 0x7e, 0x6a, 0xb8, 0x30, 0xb3, 0xc0 } }
54 :
55 : /**
56 : * HTML document extensions to nsIDocument.
57 : */
58 : class nsIHTMLDocument : public nsISupports
59 : {
60 : public:
61 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLDOCUMENT_IID)
62 :
63 : /**
64 : * Set compatibility mode for this document
65 : */
66 : virtual void SetCompatibilityMode(nsCompatibility aMode) = 0;
67 :
68 : virtual nsresult ResolveName(const nsAString& aName,
69 : nsIContent *aForm,
70 : nsISupports **aResult,
71 : nsWrapperCache **aCache) = 0;
72 :
73 : /**
74 : * Called when form->BindToTree() is called so that document knows
75 : * immediately when a form is added
76 : */
77 : virtual void AddedForm() = 0;
78 : /**
79 : * Called when form->SetDocument() is called so that document knows
80 : * immediately when a form is removed
81 : */
82 : virtual void RemovedForm() = 0;
83 : /**
84 : * Called to get a better count of forms than document.forms can provide
85 : * without calling FlushPendingNotifications (bug 138892).
86 : */
87 : // XXXbz is this still needed now that we can flush just content,
88 : // not the rest?
89 : virtual PRInt32 GetNumFormsSynchronous() = 0;
90 :
91 : virtual bool IsWriting() = 0;
92 :
93 : virtual bool GetIsFrameset() = 0;
94 : virtual void SetIsFrameset(bool aFrameset) = 0;
95 :
96 : /**
97 : * Get the list of form elements in the document.
98 : */
99 : virtual nsContentList* GetForms() = 0;
100 :
101 : /**
102 : * Get the list of form controls in the document (all elements in
103 : * the document that are of type nsIContent::eHTML_FORM_CONTROL).
104 : */
105 : virtual nsContentList* GetFormControls() = 0;
106 :
107 : /**
108 : * Should be called when an element's editable changes as a result of
109 : * changing its contentEditable attribute/property.
110 : *
111 : * @param aElement the element for which the contentEditable
112 : * attribute/property was changed
113 : * @param aChange +1 if the contentEditable attribute/property was changed to
114 : * true, -1 if it was changed to false
115 : */
116 : virtual nsresult ChangeContentEditableCount(nsIContent *aElement,
117 : PRInt32 aChange) = 0;
118 :
119 : enum EditingState {
120 : eTearingDown = -2,
121 : eSettingUp = -1,
122 : eOff = 0,
123 : eDesignMode,
124 : eContentEditable
125 : };
126 :
127 : /**
128 : * Returns whether the document is editable.
129 : */
130 246 : bool IsEditingOn()
131 : {
132 246 : return GetEditingState() == eDesignMode ||
133 246 : GetEditingState() == eContentEditable;
134 : }
135 :
136 : /**
137 : * Returns the editing state of the document (not editable, contentEditable or
138 : * designMode).
139 : */
140 : virtual EditingState GetEditingState() = 0;
141 :
142 : /**
143 : * Set the editing state of the document. Don't use this if you want
144 : * to enable/disable editing, call EditingStateChanged() or
145 : * SetDesignMode().
146 : */
147 : virtual nsresult SetEditingState(EditingState aState) = 0;
148 :
149 : /**
150 : * Disables getting and setting cookies
151 : */
152 : virtual void DisableCookieAccess() = 0;
153 :
154 : /**
155 : * Called when this nsIHTMLDocument's editor is destroyed.
156 : */
157 : virtual void TearingDownEditor(nsIEditor *aEditor) = 0;
158 :
159 : virtual void SetIsXHTML(bool aXHTML) = 0;
160 :
161 : virtual void SetDocWriteDisabled(bool aDisabled) = 0;
162 : };
163 :
164 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLDocument, NS_IHTMLDOCUMENT_IID)
165 :
166 : #endif /* nsIHTMLDocument_h */
|