summaryrefslogtreecommitdiffstats
path: root/parser/html/nsHtml5ElementName.h
diff options
context:
space:
mode:
Diffstat (limited to 'parser/html/nsHtml5ElementName.h')
-rw-r--r--parser/html/nsHtml5ElementName.h70
1 files changed, 54 insertions, 16 deletions
diff --git a/parser/html/nsHtml5ElementName.h b/parser/html/nsHtml5ElementName.h
index 57e80679d..6bf31a0ad 100644
--- a/parser/html/nsHtml5ElementName.h
+++ b/parser/html/nsHtml5ElementName.h
@@ -44,13 +44,14 @@
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
#include "nsIContentHandle.h"
+#include "nsHtml5Portability.h"
class nsHtml5StreamParser;
+class nsHtml5AttributeName;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5MetaScanner;
-class nsHtml5AttributeName;
class nsHtml5UTF16Buffer;
class nsHtml5StateSnapshot;
class nsHtml5Portability;
@@ -58,6 +59,25 @@ class nsHtml5Portability;
class nsHtml5ElementName
{
+ public:
+ static const int32_t GROUP_MASK = 127;
+
+ static const int32_t NOT_INTERNED = (1 << 30);
+
+ static const int32_t SPECIAL = (1 << 29);
+
+ static const int32_t FOSTER_PARENTING = (1 << 28);
+
+ static const int32_t SCOPING = (1 << 27);
+
+ static const int32_t SCOPING_AS_SVG = (1 << 26);
+
+ static const int32_t SCOPING_AS_MATHML = (1 << 25);
+
+ static const int32_t HTML_INTEGRATION_POINT = (1 << 24);
+
+ static const int32_t OPTIONAL_END_TAG = (1 << 23);
+
private:
nsIAtom* name;
nsIAtom* camelCaseName;
@@ -78,9 +98,32 @@ class nsHtml5ElementName
return flags;
}
- int32_t getGroup();
- bool isInterned();
- static nsHtml5ElementName* elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
+ inline int32_t getGroup()
+ {
+ return flags & nsHtml5ElementName::GROUP_MASK;
+ }
+
+ inline bool isInterned()
+ {
+ return !(flags & nsHtml5ElementName::NOT_INTERNED);
+ }
+
+ inline static nsHtml5ElementName* elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
+ {
+ uint32_t hash = nsHtml5ElementName::bufToHash(buf, length);
+ int32_t index = nsHtml5ElementName::ELEMENT_HASHES.binarySearch(hash);
+ if (index < 0) {
+ return nullptr;
+ } else {
+ nsHtml5ElementName* elementName = nsHtml5ElementName::ELEMENT_NAMES[index];
+ nsIAtom* name = elementName->name;
+ if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
+ return nullptr;
+ }
+ return elementName;
+ }
+ }
+
private:
inline static uint32_t bufToHash(char16_t* buf, int32_t length)
{
@@ -116,7 +159,13 @@ class nsHtml5ElementName
public:
nsHtml5ElementName();
~nsHtml5ElementName();
- void setNameForNonInterned(nsIAtom* name);
+ inline void setNameForNonInterned(nsIAtom* name)
+ {
+ this->name = name;
+ this->camelCaseName = name;
+ MOZ_ASSERT(this->flags == nsHtml5ElementName::NOT_INTERNED);
+ }
+
static nsHtml5ElementName* ELT_ISINDEX;
static nsHtml5ElementName* ELT_AND;
static nsHtml5ElementName* ELT_ARG;
@@ -523,16 +572,5 @@ class nsHtml5ElementName
static void releaseStatics();
};
-#define NS_HTML5ELEMENT_NAME_GROUP_MASK 127
-#define NS_HTML5ELEMENT_NAME_NOT_INTERNED (1 << 30)
-#define NS_HTML5ELEMENT_NAME_SPECIAL (1 << 29)
-#define NS_HTML5ELEMENT_NAME_FOSTER_PARENTING (1 << 28)
-#define NS_HTML5ELEMENT_NAME_SCOPING (1 << 27)
-#define NS_HTML5ELEMENT_NAME_SCOPING_AS_SVG (1 << 26)
-#define NS_HTML5ELEMENT_NAME_SCOPING_AS_MATHML (1 << 25)
-#define NS_HTML5ELEMENT_NAME_HTML_INTEGRATION_POINT (1 << 24)
-#define NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG (1 << 23)
-
-
#endif