1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/src/nsContentListDeclarations.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsContentListDeclarations_h 1.10 +#define nsContentListDeclarations_h 1.11 + 1.12 +#include <stdint.h> 1.13 +#include "nsCOMPtr.h" 1.14 +#include "nsStringFwd.h" 1.15 + 1.16 +class nsContentList; 1.17 +class nsIAtom; 1.18 +class nsIContent; 1.19 +class nsINode; 1.20 + 1.21 +// Magic namespace id that means "match all namespaces". This is 1.22 +// negative so it won't collide with actual namespace constants. 1.23 +#define kNameSpaceID_Wildcard INT32_MIN 1.24 + 1.25 +// This is a callback function type that can be used to implement an 1.26 +// arbitrary matching algorithm. aContent is the content that may 1.27 +// match the list, while aNamespaceID, aAtom, and aData are whatever 1.28 +// was passed to the list's constructor. 1.29 +typedef bool (*nsContentListMatchFunc)(nsIContent* aContent, 1.30 + int32_t aNamespaceID, 1.31 + nsIAtom* aAtom, 1.32 + void* aData); 1.33 + 1.34 +typedef void (*nsContentListDestroyFunc)(void* aData); 1.35 + 1.36 +/** 1.37 + * A function that allocates the matching data for this 1.38 + * FuncStringContentList. Returning aString is perfectly fine; in 1.39 + * that case the destructor function should be a no-op. 1.40 + */ 1.41 +typedef void* (*nsFuncStringContentListDataAllocator)(nsINode* aRootNode, 1.42 + const nsString* aString); 1.43 + 1.44 +// If aMatchNameSpaceId is kNameSpaceID_Unknown, this will return a 1.45 +// content list which matches ASCIIToLower(aTagname) against HTML 1.46 +// elements in HTML documents and aTagname against everything else. 1.47 +// For any other value of aMatchNameSpaceId, the list will match 1.48 +// aTagname against all elements. 1.49 +already_AddRefed<nsContentList> 1.50 +NS_GetContentList(nsINode* aRootNode, 1.51 + int32_t aMatchNameSpaceId, 1.52 + const nsAString& aTagname); 1.53 + 1.54 +already_AddRefed<nsContentList> 1.55 +NS_GetFuncStringNodeList(nsINode* aRootNode, 1.56 + nsContentListMatchFunc aFunc, 1.57 + nsContentListDestroyFunc aDestroyFunc, 1.58 + nsFuncStringContentListDataAllocator aDataAllocator, 1.59 + const nsAString& aString); 1.60 +already_AddRefed<nsContentList> 1.61 +NS_GetFuncStringHTMLCollection(nsINode* aRootNode, 1.62 + nsContentListMatchFunc aFunc, 1.63 + nsContentListDestroyFunc aDestroyFunc, 1.64 + nsFuncStringContentListDataAllocator aDataAllocator, 1.65 + const nsAString& aString); 1.66 + 1.67 +#endif // nsContentListDeclarations_h