content/base/src/nsContentListDeclarations.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:8a22b3d66647
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 nsContentListDeclarations_h
7 #define nsContentListDeclarations_h
8
9 #include <stdint.h>
10 #include "nsCOMPtr.h"
11 #include "nsStringFwd.h"
12
13 class nsContentList;
14 class nsIAtom;
15 class nsIContent;
16 class nsINode;
17
18 // Magic namespace id that means "match all namespaces". This is
19 // negative so it won't collide with actual namespace constants.
20 #define kNameSpaceID_Wildcard INT32_MIN
21
22 // This is a callback function type that can be used to implement an
23 // arbitrary matching algorithm. aContent is the content that may
24 // match the list, while aNamespaceID, aAtom, and aData are whatever
25 // was passed to the list's constructor.
26 typedef bool (*nsContentListMatchFunc)(nsIContent* aContent,
27 int32_t aNamespaceID,
28 nsIAtom* aAtom,
29 void* aData);
30
31 typedef void (*nsContentListDestroyFunc)(void* aData);
32
33 /**
34 * A function that allocates the matching data for this
35 * FuncStringContentList. Returning aString is perfectly fine; in
36 * that case the destructor function should be a no-op.
37 */
38 typedef void* (*nsFuncStringContentListDataAllocator)(nsINode* aRootNode,
39 const nsString* aString);
40
41 // If aMatchNameSpaceId is kNameSpaceID_Unknown, this will return a
42 // content list which matches ASCIIToLower(aTagname) against HTML
43 // elements in HTML documents and aTagname against everything else.
44 // For any other value of aMatchNameSpaceId, the list will match
45 // aTagname against all elements.
46 already_AddRefed<nsContentList>
47 NS_GetContentList(nsINode* aRootNode,
48 int32_t aMatchNameSpaceId,
49 const nsAString& aTagname);
50
51 already_AddRefed<nsContentList>
52 NS_GetFuncStringNodeList(nsINode* aRootNode,
53 nsContentListMatchFunc aFunc,
54 nsContentListDestroyFunc aDestroyFunc,
55 nsFuncStringContentListDataAllocator aDataAllocator,
56 const nsAString& aString);
57 already_AddRefed<nsContentList>
58 NS_GetFuncStringHTMLCollection(nsINode* aRootNode,
59 nsContentListMatchFunc aFunc,
60 nsContentListDestroyFunc aDestroyFunc,
61 nsFuncStringContentListDataAllocator aDataAllocator,
62 const nsAString& aString);
63
64 #endif // nsContentListDeclarations_h

mercurial