Bug 1850713: remove duplicated setting of early hint preloader id in `ScriptLoader...
[gecko.git] / dom / base / nsContentListDeclarations.h
blob8c737bfa38307edc7db55d70f8e9d88421ded2a2
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/. */
7 #ifndef nsContentListDeclarations_h
8 #define nsContentListDeclarations_h
10 #include <stdint.h>
11 #include "nsCOMPtr.h"
12 #include "nsStringFwd.h"
14 class nsContentList;
15 class nsAtom;
16 class nsIContent;
17 class nsINode;
19 namespace mozilla::dom {
20 class Element;
21 } // namespace mozilla::dom
23 // Magic namespace id that means "match all namespaces". This is
24 // negative so it won't collide with actual namespace constants.
25 #define kNameSpaceID_Wildcard INT32_MIN
27 // This is a callback function type that can be used to implement an
28 // arbitrary matching algorithm. aContent is the content that may
29 // match the list, while aNamespaceID, aAtom, and aData are whatever
30 // was passed to the list's constructor.
31 using nsContentListMatchFunc = bool (*)(mozilla::dom::Element* aElement,
32 int32_t aNamespaceID, nsAtom* aAtom,
33 void* aData);
35 using nsContentListDestroyFunc = void (*)(void* aData);
37 /**
38 * A function that allocates the matching data for this
39 * FuncStringContentList. Returning aString is perfectly fine; in
40 * that case the destructor function should be a no-op.
42 using nsFuncStringContentListDataAllocator = void* (*)(nsINode* aRootNode,
43 const nsString* aString);
45 // If aMatchNameSpaceId is kNameSpaceID_Unknown, this will return a
46 // content list which matches ASCIIToLower(aTagname) against HTML
47 // elements in HTML documents and aTagname against everything else.
48 // For any other value of aMatchNameSpaceId, the list will match
49 // aTagname against all elements.
50 already_AddRefed<nsContentList> NS_GetContentList(nsINode* aRootNode,
51 int32_t aMatchNameSpaceId,
52 const nsAString& aTagname);
54 template <class ListType>
55 already_AddRefed<nsContentList> GetFuncStringContentList(
56 nsINode* aRootNode, nsContentListMatchFunc aFunc,
57 nsContentListDestroyFunc aDestroyFunc,
58 nsFuncStringContentListDataAllocator aDataAllocator,
59 const nsAString& aString);
61 #endif // nsContentListDeclarations_h