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