Bug 1690340 - Part 1: Hide all the panel tools in the developer tools menu. r=jdescottes
[gecko.git] / parser / htmlparser / nsHTMLTags.h
bloba655f354aaff323f2a8be45658635719a446ad7e
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___
9 #include "nsString.h"
10 #include "nsDataHashtable.h"
11 #include "nsHashKeys.h"
14 Declare the enum list using the magic of preprocessing
15 enum values are "eHTMLTag_foo" (where foo is the tag)
17 To change the list of tags, see nsHTMLTagList.h
19 These enum values are used as the index of array in various places.
20 If we change the structure of the enum by adding entries to it or removing
21 entries from it _directly_, not via nsHTMLTagList.h, don't forget to update
22 dom/bindings/BindingUtils.cpp and dom/html/nsHTMLContentSink.cpp as well.
24 #define HTML_TAG(_tag, _classname, _interfacename) eHTMLTag_##_tag,
25 #define HTML_OTHER(_tag) eHTMLTag_##_tag,
26 enum nsHTMLTag {
27 /* this enum must be first and must be zero */
28 eHTMLTag_unknown = 0,
29 #include "nsHTMLTagList.h"
31 /* can't be moved into nsHTMLTagList since gcc3.4 doesn't like a
32 comma at the end of enum list*/
33 eHTMLTag_userdefined
35 #undef HTML_TAG
36 #undef HTML_OTHER
38 // All tags before eHTMLTag_text are HTML tags
39 #define NS_HTML_TAG_MAX int32_t(eHTMLTag_text - 1)
41 class nsHTMLTags {
42 public:
43 using TagStringHash = nsDataHashtable<nsStringHashKey, nsHTMLTag>;
44 using TagAtomHash = nsDataHashtable<nsPtrHashKey<nsAtom>, nsHTMLTag>;
46 static nsresult AddRefTable(void);
47 static void ReleaseTable(void);
49 // Functions for converting string or atom to id
50 static nsHTMLTag StringTagToId(const nsAString& aTagName);
51 static nsHTMLTag AtomTagToId(nsAtom* aTagName) {
52 return StringTagToId(nsDependentAtomString(aTagName));
55 static nsHTMLTag CaseSensitiveStringTagToId(const nsAString& aTagName) {
56 NS_ASSERTION(gTagTable, "no lookup table, needs addref");
58 nsHTMLTag* tag = gTagTable->GetValue(aTagName);
59 return tag ? *tag : eHTMLTag_userdefined;
61 static nsHTMLTag CaseSensitiveAtomTagToId(nsAtom* aTagName) {
62 NS_ASSERTION(gTagAtomTable, "no lookup table, needs addref");
63 NS_ASSERTION(aTagName, "null tagname!");
65 nsHTMLTag* tag = gTagAtomTable->GetValue(aTagName);
66 return tag ? *tag : eHTMLTag_userdefined;
69 #ifdef DEBUG
70 static void TestTagTable();
71 #endif
73 private:
74 static const char16_t* const sTagNames[];
76 static int32_t gTableRefCount;
77 static TagStringHash* gTagTable;
78 static TagAtomHash* gTagAtomTable;
81 #endif /* nsHTMLTags_h___ */