Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / content / xul / templates / public / nsIXULTemplateBuilder.idl
blob8e4773eb6f333f64bceca2780522f795849d4235
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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.
15 * The Original Code is mozilla.org code.
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.
22 * Contributor(s):
23 * Chris Waterson <waterson@netscape.com>
24 * Ben Goodger <ben@netscape.com>
25 * Jan Varga <varga@ku.sk>
26 * Benjamin Smedberg <bsmedberg@covad.net>
27 * Neil Deakin <enndeakin@sympatico.ca>
29 * Alternatively, the contents of this file may be used under the terms of
30 * either of the GNU General Public License Version 2 or later (the "GPL"),
31 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
32 * in which case the provisions of the GPL or the LGPL are applicable instead
33 * of those above. If you wish to allow use of your version of this file only
34 * under the terms of either the GPL or the LGPL, and not to allow others to
35 * use your version of this file under the terms of the MPL, indicate your
36 * decision by deleting the provisions above and replace them with the notice
37 * and other provisions required by the GPL or the LGPL. If you do not delete
38 * the provisions above, a recipient may use your version of this file under
39 * the terms of any one of the MPL, the GPL or the LGPL.
41 * ***** END LICENSE BLOCK ***** */
43 #include "domstubs.idl"
44 #include "nsISupports.idl"
46 interface nsIAtom;
47 interface nsIContent;
48 interface nsIXULBuilderListener;
49 interface nsIXULTemplateResult;
50 interface nsIXULTemplateRuleFilter;
51 interface nsIXULTemplateQueryProcessor;
52 interface nsIRDFResource;
53 interface nsIRDFCompositeDataSource;
55 /**
56 * A template builder, given an input source of data, a template, and a
57 * reference point, generates a list of results from the input, and copies
58 * part of the template for each result. Templates may generate content
59 * recursively, using the same template, but with the previous iteration's
60 * results as the reference point. As an example, for an XML datasource the
61 * initial reference point would be a specific node in the DOM tree and a
62 * template might generate a list of all child nodes. For the next iteration,
63 * those children would be used to generate output for their child nodes and
64 * so forth.
66 * A template builder is attached to a single DOM node; this node is called
67 * the root node and is expected to contain a XUL template element as a direct
68 * child. Different template builders may be specialized in the manner in
69 * which they generate and display the resulting content from the template.
71 * The structure of a template is as follows:
73 * <rootnode datasources="" ref="">
74 * <template>
75 * <queryset>
76 * <query>
77 * </query>
78 * <rule>
79 * <conditions>...</conditions>
80 * <bindings>...</bindings>
81 * <action>...</action>
82 * </rule>
83 * </queryset>
84 * </template>
85 * </rootnode>
87 * The datasources attribute on the root node is used to identify the source
88 * of data to be used. The ref attribute is used to specify the reference
89 * point for the query. Currently, the datasource will either be an
90 * nsIRDFDataSource or a DOM node. In the future, other datasource types may
91 * be used.
93 * The <queryset> element contains a single query and one or more <rule>
94 * elements. There may be more than one <queryset> if multiple queries are
95 * desired, and this element is optional if only one query is needed -- in
96 * that case the <query> and <rule>s are allowed to be children of the
97 * <template> node
99 * The contents of the query are processed by a separate component called a
100 * query processor. This query processor is expected to use this query to
101 * generate results when asked by the template builder. The template builder
102 * then generates output for each result based on the <rule> elements.
104 * This allows the query processor to be specific to a particular kind of
105 * input data or query syntax, while the template builder remains independent
106 * of the kind of data being used. Due to this, the query processor will be
107 * supplied with the datasource and query which the template builder handles
108 * in an opaque way, while the query processor handles these more
109 * specifically.
111 * Results implement the nsIXULTemplateResult interface and may be identified
112 * by an id which must be unique within a given set of query results.
114 * Each query may be accompanied by one or more <rule> elements. These rules
115 * are evaluated by the template builder for each result produced by the
116 * query. A rule consists of conditions that cause a rule to be either
117 * accepted or rejected. The condition syntax allows for common conditional
118 * handling; additional filtering may be applied by adding a custom filter
119 * to a rule with the builder's addRuleFilter method.
121 * If a result passes a rule's conditions, this is considered a match, and the
122 * content within the rule's <action> body is inserted as a sibling of the
123 * <template>, assuming the template builder creates real DOM content. Only
124 * one rule will match a result. For a tree builder, for example, the content
125 * within the action body is used to create the tree rows instead. A matching
126 * result must have its ruleMatched method called. When a result no longer
127 * matches, the result's hasBeenRemoved method must be called.
129 * Optionally, the rule may have a <bindings> section which may be used to
130 * define additional variables to be used within an action body. Each of these
131 * declared bindings must be supplied to the query processor via its
132 * addBinding method. The bindings are evaluated after a rule has matched.
134 * Templates may generate content recursively, using the previous iteration's
135 * results as reference point to invoke the same queries. Since the reference
136 * point is different, different output will typically be generated.
138 * The reference point nsIXULTemplateResult object for the first iteration is
139 * determined by calling the query processor's translateRef method using the
140 * value of the root node's ref attribute. This object may be retrieved later
141 * via the builder's rootResult property.
143 * For convenience, each reference point as well as all results implement the
144 * nsIXULTemplateResult interface, allowing the result objects from each
145 * iteration to be used directly as the reference points for the next
146 * iteration.
148 * When using multiple queries, each may generate results with the same id.
149 * More than one of these results may match one of the rules in their
150 * respective queries, however only the result for the earliest matching query
151 * in the template becomes the active match and generates output. The
152 * addResult, removeResult, replaceResult and resultBindingChanged methods may
153 * be called by the query processor to indicate that the set of valid results
154 * has changed, such that a different query may match. If a different match
155 * would become active, the content for the existing match is removed and the
156 * content for the new match is generated. A query processor is not required
157 * to provide any support for updating results after they have been generated.
159 * See http://wiki.mozilla.org/XUL:Templates_Plan for details about templates.
161 [scriptable, uuid(A583B676-5B02-4F9C-A0C9-CB850CB99818)]
162 interface nsIXULTemplateBuilder : nsISupports
165 * The root node in the DOM to which this builder is attached.
167 readonly attribute nsIDOMElement root;
170 * The opaque datasource object that is used for the template. This object
171 * is created by the getDataSource method of the query processor. May be
172 * null if the datasource has not been loaded yet. Set this attribute to
173 * use a different datasource and rebuild the template.
175 * For an RDF datasource, this will be the same as the database. For XML
176 * this will be the nsIDOMNode for the datasource document or node for
177 * an inline reference (such as #name). Other query processors may use
178 * other types for the datasource.
180 attribute nsISupports datasource;
183 * The composite datasource that the template builder observes
184 * and uses to create content. This is used only for RDF queries and is
185 * maintained for backwards compatibility. It will be the same object as
186 * the datasource property. For non-RDF queries, it will always be null.
188 readonly attribute nsIRDFCompositeDataSource database;
191 * The virtual result representing the starting reference point,
192 * determined by calling the query processor's translateRef method
193 * with the root node's ref attribute as an argument.
195 readonly attribute nsIXULTemplateResult rootResult;
198 * The query processor used to generate results.
200 [noscript] readonly attribute nsIXULTemplateQueryProcessor queryProcessor;
203 * Force the template builder to rebuild its content. All existing content
204 * will be removed first. The query processor's done() method will be
205 * invoked during cleanup, followed by its initializeForBuilding method
206 * when the content is to be regenerated.
209 void rebuild();
212 * Reload any of our RDF datasources that support nsIRDFRemoteDatasource.
214 * @note This is a temporary hack so that remote-XUL authors can
215 * reload remote datasources. When RDF becomes remote-scriptable,
216 * this will no longer be necessary.
218 void refresh();
221 * Inform the template builder that a new result is available. The builder
222 * will add this result to the set of results. The query node that the
223 * new result applies to must be specified using the aQueryNode parameter.
225 * The builder will apply the rules associated with the query to the new
226 * result, unless a result with the same id from an earlier query
227 * supersedes it, and the result's RuleMatched method will be called if it
228 * matches.
230 * @param aResult the result to add
231 * @param aQueryNode the query that the result applies to
233 * @throws NS_ERROR_NULL_POINTER if aResult or aQueryNode are null
235 void addResult(in nsIXULTemplateResult aResult, in nsIDOMNode aQueryNode);
238 * Inform the template builder that a result no longer applies. The builder
239 * will call the remove content generated for the result, if any. If a different
240 * query would then match instead, it will become the active match. This
241 * method will have no effect if the result isn't known to the builder.
243 * @param aResult the result to remove
245 * @throws NS_ERROR_NULL_POINTER if aResult is null
247 void removeResult(in nsIXULTemplateResult aResult);
250 * Inform the template builder that one result should be replaced with
251 * another. Both the old result (aOldResult) and the new result
252 * (aNewResult) must have the same id. The query node that the new result
253 * applies to must be specified using the aQueryNode parameter.
255 * This method is expected to have the same effect as calling both
256 * removeResult for the old result and addResult for the new result.
258 * @param aOldResult the old result
259 * @param aNewResult the new result
260 * @param aQueryNode the query that the new result applies to
262 * @throws NS_ERROR_NULL_POINTER if either argument is null, or
263 * NS_ERROR_INVALID_ARG if the ids don't match
265 void replaceResult(in nsIXULTemplateResult aOldResult,
266 in nsIXULTemplateResult aNewResult,
267 in nsIDOMNode aQueryNode);
270 * Inform the template builder that one or more of the optional bindings
271 * for a result has changed. In this case, the rules are not reapplied as
272 * it is expected that the same rule will still apply. The builder will
273 * resynchronize any variables that are referenced in the action body.
275 * @param aResult the result to change
277 * @throws NS_ERROR_NULL_POINTER if aResult is null
279 void resultBindingChanged(in nsIXULTemplateResult aResult);
282 * Return the result for a given id. Only one such result is returned and
283 * is always the result with that id associated with the active match.
284 * This method will return null is there is no result for the id.
286 * @param aId the id to return the result for
288 nsIXULTemplateResult getResultForId(in AString aId);
291 * Retrieve the result corresponding to a generated element, or null is
292 * there isn't one.
294 * @param aContent element to result the result of
296 nsIXULTemplateResult getResultForContent(in nsIDOMElement aElement);
299 * Returns true if the node has content generated for it. This method is
300 * intended to be called only by the RDF query processor. If aTag is set,
301 * the content must have a tag name that matches aTag. aTag may be ignored
302 * for builders that don't generate real DOM content.
304 * @param aNode node to check
305 * @param aTag tag that must match
307 boolean hasGeneratedContent(in nsIRDFResource aNode, in nsIAtom aTag);
310 * Adds a rule filter for a given rule, which may be used for specialized
311 * rule filtering. Any existing filter on the rule is removed. The default
312 * conditions specified inside the <rule> tag are applied before the
313 * rule filter is applied, meaning that the filter may be used to further
314 * filter out results but not reaccept results that have already been
315 * rejected.
317 * @param aRule the rule to apply the filter to
318 * @param aFilter the filter to add
320 void addRuleFilter(in nsIDOMNode aRule, in nsIXULTemplateRuleFilter aFilter);
323 * Called to initialize a XUL content builder on a particular root
324 * element. This element presumably has a ``datasources''
325 * attribute, which the builder will parse to set up the template
326 * builder's datasources.
328 [noscript] void init(in nsIContent aElement);
331 * Invoked lazily by a XUL element that needs its child content built.
332 * If aForceCreation is true, then the contents of an element will be
333 * generated even if it is closed. If false, the element will only
334 * generate its contents if it is open. This behaviour is used with menus.
336 [noscript] void createContents(in nsIContent aElement,
337 in boolean aForceCreation);
340 * Add a listener to this template builder. The template builder
341 * holds a strong reference to the listener.
343 void addListener(in nsIXULBuilderListener aListener);
346 * Remove a listener from this template builder.
348 void removeListener(in nsIXULBuilderListener aListener);
352 * nsIXULTreeBuilderObserver
353 * This interface allows clients of the XULTreeBuilder to define domain
354 * specific handling of specific nsITreeView methods that
355 * XULTreeBuilder does not implement.
357 [scriptable, uuid(a5480e0d-ac7c-42e5-aca5-d7f0bbffa207)]
358 interface nsIXULTreeBuilderObserver : nsISupports
360 const long DROP_BEFORE = -1;
361 const long DROP_ON = 0;
362 const long DROP_AFTER = 1;
364 * Methods used by the drag feedback code to determine if a drag is allowable at
365 * the current location. To get the behavior where drops are only allowed on
366 * items, such as the mailNews folder pane, always return false whe
367 * the orientation is not DROP_ON.
369 boolean canDrop(in long index, in long orientation);
372 * Called when the user drops something on this view. The |orientation| param
373 * specifies before/on/after the given |row|.
375 void onDrop(in long row, in long orientation);
377 /**
378 * Called when an item is opened or closed.
380 void onToggleOpenState (in long index);
382 /**
383 * Called when a header is clicked.
385 void onCycleHeader(in wstring colID, in nsIDOMElement elt);
388 * Called when a cell in a non-selectable cycling column (e.g.
389 * unread/flag/etc.) is clicked.
391 void onCycleCell(in long row, in wstring colID);
393 /**
394 * Called when selection in the tree changes
396 void onSelectionChanged();
399 * A command API that can be used to invoke commands on the selection.
400 * The tree will automatically invoke this method when certain keys
401 * are pressed. For example, when the DEL key is pressed, performAction
402 * will be called with the "delete" string.
404 void onPerformAction(in wstring action);
407 * A command API that can be used to invoke commands on a specific row.
409 void onPerformActionOnRow(in wstring action, in long row);
412 * A command API that can be used to invoke commands on a specific cell.
414 void onPerformActionOnCell(in wstring action, in long row, in wstring colID);
417 [scriptable, uuid(06b31b15-ebf5-4e74-a0e2-6bc0a18a3969)]
418 interface nsIXULTreeBuilder : nsISupports
421 * Retrieve the RDF resource associated with the specified row.
423 nsIRDFResource getResourceAtIndex(in long aRowIndex);
426 * Retrieve the index associated with specified RDF resource.
428 long getIndexOfResource(in nsIRDFResource resource);
430 /**
431 * Add a Tree Builder Observer to handle Tree View
432 * methods that the base builder does not implement.
434 void addObserver(in nsIXULTreeBuilderObserver aObserver);
436 /**
437 * Remove an Tree Builder Observer.
439 void removeObserver(in nsIXULTreeBuilderObserver aObserver);
441 /**
442 * Sort the contents of the tree using the specified column.
444 void sort(in nsIDOMElement aColumnElement);