1 /* -*- Mode: IDL; 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 the Mozilla XTF project.
16 *
17 * The Initial Developer of the Original Code is
18 * Alex Fritze.
19 * Portions created by the Initial Developer are Copyright (C) 2004
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Alex Fritze <alex@croczilla.com> (original author)
24 * Olli Pettay <Olli.Pettay@helsinki.fi>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40 #include "nsISupports.idl"
41 interface nsIAtom;
42 interface nsIDOMDocument;
43 interface nsIDOMElement;
44 interface nsIDOMNode;
45 interface nsIDOMAttr;
46 interface nsIDOMEvent;
47 interface nsIXTFElementWrapper;
48
49 [scriptable, uuid(4f144387-796d-4baf-8641-5db45dba1808)]
50 interface nsIXTFElement : nsISupports
51 {
52 // onCreated will be called before any notifications are sent to
53 // the xtf element.
54 //
55 // @param wrapper is a weak proxy to the wrapping element
56 // (i.e. holding a reference to this will not create a cycle).
57 void onCreated(in nsIXTFElementWrapper wrapper);
58
59 // called when the wrapper object is being destroyed.
60 void onDestroyed();
61
62 // If isAttributeHandler is set to 'true', the xtf element indicates
63 // that it wants to manage its own attributes. In this case it needs
64 // to implement the nsIXTFAttributeHandler interface in addition to
65 // its other interfaces. 'isAttributeHandler' must remain constant
66 // for the entire lifetime of the xtf element (i.e. before any
67 // onCreated()-calls until after onDestroyed()-calls).
68 readonly attribute boolean isAttributeHandler;
69
70 // getScriptingInterfaces: This array serves 2 purposes: a) All
71 // interfaces in this array will automatically be accessible when
72 // our wrapper element is used from JS (other interfaces need to be
73 // explicitly QI'ed for), and b) All these interfaces are callable
74 // from unpriviliged script.
75 // @note 'Normal' DOM interfaces are always automatically scriptable.
76 void getScriptingInterfaces(out unsigned long count,
77 [array, size_is(count), retval] out nsIIDPtr array);
78
79 // Notification mask constants:
80 // To receive a given event set the corresponding bit in
81 // nsIXTFElementWrapper::notificationMask.
82 const unsigned long NOTIFY_WILL_CHANGE_DOCUMENT = 0x00000001;
83 const unsigned long NOTIFY_DOCUMENT_CHANGED = 0x00000002;
84
85 const unsigned long NOTIFY_WILL_CHANGE_PARENT = 0x00000004;
86 const unsigned long NOTIFY_PARENT_CHANGED = 0x00000008;
87
88 const unsigned long NOTIFY_WILL_INSERT_CHILD = 0x00000010;
89 const unsigned long NOTIFY_CHILD_INSERTED = 0x00000020;
90
91 const unsigned long NOTIFY_WILL_APPEND_CHILD = 0x00000040;
92 const unsigned long NOTIFY_CHILD_APPENDED = 0x00000080;
93
94 const unsigned long NOTIFY_WILL_REMOVE_CHILD = 0x00000100;
95 const unsigned long NOTIFY_CHILD_REMOVED = 0x00000200;
96
97 const unsigned long NOTIFY_WILL_SET_ATTRIBUTE = 0x00000400;
98 const unsigned long NOTIFY_ATTRIBUTE_SET = 0x00000800;
99
100 const unsigned long NOTIFY_WILL_REMOVE_ATTRIBUTE = 0x00001000;
101 const unsigned long NOTIFY_ATTRIBUTE_REMOVED = 0x00002000;
102
103 const unsigned long NOTIFY_BEGIN_ADDING_CHILDREN = 0x00004000;
104 const unsigned long NOTIFY_DONE_ADDING_CHILDREN = 0x00008000;
105
106 const unsigned long NOTIFY_HANDLE_DEFAULT = 0x00010000;
107
108 const unsigned long NOTIFY_PERFORM_ACCESSKEY = 0x00020000;
109
110 // Event notifications:
111
112 void willChangeDocument(in nsIDOMDocument newDoc);
113 void documentChanged(in nsIDOMDocument newDoc);
114
115 void willChangeParent(in nsIDOMElement newParent);
116 void parentChanged(in nsIDOMElement newParent);
117
118 void willInsertChild(in nsIDOMNode child, in unsigned long index);
119 void childInserted(in nsIDOMNode child, in unsigned long index);
120
121 void willAppendChild(in nsIDOMNode child);
122 void childAppended(in nsIDOMNode child);
123
124 void willRemoveChild(in unsigned long index);
125 void childRemoved(in unsigned long index);
126
127 void willSetAttribute(in nsIAtom name, in AString newValue);
128 void attributeSet(in nsIAtom name, in AString newValue);
129
130 void willRemoveAttribute(in nsIAtom name);
131 void attributeRemoved(in nsIAtom name);
132
133 // These are for batching of child insertions during document load
134
135 // beginAddingChildren is called before any attributes or child nodes are
136 // added to the element.
137 void beginAddingChildren();
138 void doneAddingChildren();
139
140 // The default handler for DOM Events.
141 // This method is called after the normal DOM event flow.
142 // If the return value is true, the event is marked as handled and
143 // other default handlers won't be able to handle it again.
144 boolean handleDefault(in nsIDOMEvent aEvent);
145
146 // Set this element to be equivalent to |aElement|. This does not need
147 // to worry about copying attributes or child nodes, but should copy any
148 // other needed state.
149 void cloneState(in nsIDOMElement aElement);
150
151 /**
152 * Returns accesskey attribute node.
153 */
154 readonly attribute nsIDOMAttr accesskeyNode;
155
156 /**
157 * Performs accesskey. The method is called when accesskey is activated.
158 */
159 void performAccesskey();
160 };