Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef nsIHTMLDocument_h
8 : #define nsIHTMLDocument_h
9 :
10 : #include "nsISupports.h"
11 : #include "nsCompatibility.h"
12 :
13 : class nsIContent;
14 : class nsIEditor;
15 : class nsContentList;
16 :
17 : #define NS_IHTMLDOCUMENT_IID \
18 : { 0xcf814492, 0x303c, 0x4718, \
19 : { 0x9a, 0x3e, 0x39, 0xbc, 0xd5, 0x2c, 0x10, 0xdb } }
20 :
21 : /**
22 : * HTML document extensions to nsIDocument.
23 : */
24 7 : class nsIHTMLDocument : public nsISupports
25 : {
26 : public:
27 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLDOCUMENT_IID)
28 :
29 : /**
30 : * Set compatibility mode for this document
31 : */
32 : virtual void SetCompatibilityMode(nsCompatibility aMode) = 0;
33 :
34 : /**
35 : * Called when form->BindToTree() is called so that document knows
36 : * immediately when a form is added
37 : */
38 : virtual void AddedForm() = 0;
39 : /**
40 : * Called when form->SetDocument() is called so that document knows
41 : * immediately when a form is removed
42 : */
43 : virtual void RemovedForm() = 0;
44 : /**
45 : * Called to get a better count of forms than document.forms can provide
46 : * without calling FlushPendingNotifications (bug 138892).
47 : */
48 : // XXXbz is this still needed now that we can flush just content,
49 : // not the rest?
50 : virtual int32_t GetNumFormsSynchronous() = 0;
51 :
52 : virtual bool IsWriting() = 0;
53 :
54 : /**
55 : * Get the list of form elements in the document.
56 : */
57 : virtual nsContentList* GetForms() = 0;
58 :
59 : /**
60 : * Get the list of form controls in the document (all elements in
61 : * the document that are of type nsIContent::eHTML_FORM_CONTROL).
62 : */
63 : virtual nsContentList* GetFormControls() = 0;
64 :
65 : /**
66 : * Should be called when an element's editable changes as a result of
67 : * changing its contentEditable attribute/property.
68 : *
69 : * @param aElement the element for which the contentEditable
70 : * attribute/property was changed
71 : * @param aChange +1 if the contentEditable attribute/property was changed to
72 : * true, -1 if it was changed to false
73 : */
74 : virtual nsresult ChangeContentEditableCount(nsIContent *aElement,
75 : int32_t aChange) = 0;
76 :
77 : enum EditingState {
78 : eTearingDown = -2,
79 : eSettingUp = -1,
80 : eOff = 0,
81 : eDesignMode,
82 : eContentEditable
83 : };
84 :
85 : /**
86 : * Returns whether the document is editable.
87 : */
88 41 : bool IsEditingOn()
89 : {
90 82 : return GetEditingState() == eDesignMode ||
91 82 : GetEditingState() == eContentEditable;
92 : }
93 :
94 : /**
95 : * Returns the editing state of the document (not editable, contentEditable or
96 : * designMode).
97 : */
98 : virtual EditingState GetEditingState() = 0;
99 :
100 : /**
101 : * Set the editing state of the document. Don't use this if you want
102 : * to enable/disable editing, call EditingStateChanged() or
103 : * SetDesignMode().
104 : */
105 : virtual nsresult SetEditingState(EditingState aState) = 0;
106 :
107 : /**
108 : * Disables getting and setting cookies
109 : */
110 : virtual void DisableCookieAccess() = 0;
111 :
112 : /**
113 : * Called when this nsIHTMLDocument's editor is destroyed.
114 : */
115 : virtual void TearingDownEditor(nsIEditor *aEditor) = 0;
116 :
117 : virtual void SetIsXHTML(bool aXHTML) = 0;
118 :
119 : virtual void SetDocWriteDisabled(bool aDisabled) = 0;
120 : };
121 :
122 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLDocument, NS_IHTMLDOCUMENT_IID)
123 :
124 : #endif /* nsIHTMLDocument_h */
|