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/. */
6 #ifndef nsHTMLTags_h___
7 #define nsHTMLTags_h___
11 #include "nsTHashMap.h"
12 #include "nsHashKeys.h"
15 Declare the enum list using the magic of preprocessing
16 enum values are "eHTMLTag_foo" (where foo is the tag)
18 To change the list of tags, see nsHTMLTagList.h
20 These enum values are used as the index of array in various places.
21 If we change the structure of the enum by adding entries to it or removing
22 entries from it _directly_, not via nsHTMLTagList.h, don't forget to update
23 dom/bindings/BindingUtils.cpp and dom/html/nsHTMLContentSink.cpp as well.
25 #define HTML_TAG(_tag, _classname, _interfacename) eHTMLTag_##_tag,
26 #define HTML_OTHER(_tag) eHTMLTag_##_tag,
28 /* this enum must be first and must be zero */
30 #include "nsHTMLTagList.h"
32 /* can't be moved into nsHTMLTagList since gcc3.4 doesn't like a
33 comma at the end of enum list*/
39 // All tags before eHTMLTag_text are HTML tags
40 #define NS_HTML_TAG_MAX int32_t(eHTMLTag_text - 1)
44 using TagStringHash
= nsTHashMap
<nsStringHashKey
, nsHTMLTag
>;
45 using TagAtomHash
= nsTHashMap
<nsPtrHashKey
<nsAtom
>, nsHTMLTag
>;
47 static nsresult
AddRefTable(void);
48 static void ReleaseTable(void);
50 // Functions for converting string or atom to id
51 static nsHTMLTag
StringTagToId(const nsAString
& aTagName
);
52 static nsHTMLTag
AtomTagToId(nsAtom
* aTagName
) {
53 return StringTagToId(nsDependentAtomString(aTagName
));
56 static nsHTMLTag
CaseSensitiveStringTagToId(const nsAString
& aTagName
) {
57 NS_ASSERTION(gTagTable
, "no lookup table, needs addref");
59 return gTagTable
->MaybeGet(aTagName
).valueOr(eHTMLTag_userdefined
);
61 static nsHTMLTag
CaseSensitiveAtomTagToId(nsAtom
* aTagName
) {
62 NS_ASSERTION(gTagAtomTable
, "no lookup table, needs addref");
63 NS_ASSERTION(aTagName
, "null tagname!");
65 return gTagAtomTable
->MaybeGet(aTagName
).valueOr(eHTMLTag_userdefined
);
69 static void TestTagTable();
73 static const char16_t
* const sTagNames
[];
75 static int32_t gTableRefCount
;
76 static TagStringHash
* gTagTable
;
77 static TagAtomHash
* gTagAtomTable
;
80 #endif /* nsHTMLTags_h___ */