summaryrefslogtreecommitdiffstats
path: root/parser
diff options
context:
space:
mode:
Diffstat (limited to 'parser')
-rw-r--r--parser/htmlparser/moz.build1
-rw-r--r--parser/htmlparser/nsElementTable.cpp17
-rw-r--r--parser/htmlparser/nsElementTable.h1
-rw-r--r--parser/htmlparser/nsHTMLTags.cpp20
-rw-r--r--parser/htmlparser/nsHTMLTags.h11
-rw-r--r--parser/htmlparser/nsParserService.cpp17
6 files changed, 37 insertions, 30 deletions
diff --git a/parser/htmlparser/moz.build b/parser/htmlparser/moz.build
index 7e5da29a5..3a91ae142 100644
--- a/parser/htmlparser/moz.build
+++ b/parser/htmlparser/moz.build
@@ -15,6 +15,7 @@ XPIDL_SOURCES += [
XPIDL_MODULE = 'htmlparser'
EXPORTS += [
+ 'nsElementTable.h',
'nsHTMLTagList.h',
'nsHTMLTags.h',
'nsIContentSink.h',
diff --git a/parser/htmlparser/nsElementTable.cpp b/parser/htmlparser/nsElementTable.cpp
index 86fbdad86..52507a976 100644
--- a/parser/htmlparser/nsElementTable.cpp
+++ b/parser/htmlparser/nsElementTable.cpp
@@ -174,14 +174,23 @@ const nsHTMLElement gHTMLElements[] = {
/*********************************************************************************************/
-bool nsHTMLElement::IsContainer(eHTMLTags aChild)
+bool nsHTMLElement::IsMemberOf(int32_t aSet) const
{
- return !gHTMLElements[aChild].mLeaf;
+ return TestBits(aSet, mParentBits);
}
-bool nsHTMLElement::IsMemberOf(int32_t aSet) const
+bool nsHTMLElement::IsContainer(eHTMLTags aId)
+{
+ return !gHTMLElements[aId].mLeaf;
+}
+
+bool nsHTMLElement::IsBlock(eHTMLTags aId)
{
- return TestBits(aSet,mParentBits);
+ return gHTMLElements[aId].IsMemberOf(kBlock) ||
+ gHTMLElements[aId].IsMemberOf(kBlockEntity) ||
+ gHTMLElements[aId].IsMemberOf(kHeading) ||
+ gHTMLElements[aId].IsMemberOf(kPreformatted)||
+ gHTMLElements[aId].IsMemberOf(kList);
}
#ifdef DEBUG
diff --git a/parser/htmlparser/nsElementTable.h b/parser/htmlparser/nsElementTable.h
index 28d2fa532..e3479db8d 100644
--- a/parser/htmlparser/nsElementTable.h
+++ b/parser/htmlparser/nsElementTable.h
@@ -87,6 +87,7 @@ struct nsHTMLElement {
bool mLeaf;
static bool IsContainer(eHTMLTags aTag);
+ static bool IsBlock(eHTMLTags aTag);
};
extern const nsHTMLElement gHTMLElements[];
diff --git a/parser/htmlparser/nsHTMLTags.cpp b/parser/htmlparser/nsHTMLTags.cpp
index e98d2c4cd..681c37489 100644
--- a/parser/htmlparser/nsHTMLTags.cpp
+++ b/parser/htmlparser/nsHTMLTags.cpp
@@ -161,7 +161,7 @@ nsHTMLTags::ReleaseTable(void)
// static
nsHTMLTag
-nsHTMLTags::LookupTag(const nsAString& aTagName)
+nsHTMLTags::StringTagToId(const nsAString& aTagName)
{
uint32_t length = aTagName.Length();
@@ -195,7 +195,7 @@ nsHTMLTags::LookupTag(const nsAString& aTagName)
buf[i] = 0;
- return CaseSensitiveLookupTag(buf);
+ return CaseSensitiveStringTagToId(buf);
}
#ifdef DEBUG
@@ -210,33 +210,33 @@ nsHTMLTags::TestTagTable()
// Make sure we can find everything we are supposed to
for (int i = 0; i < NS_HTML_TAG_MAX; ++i) {
tag = sTagUnicodeTable[i];
- id = LookupTag(nsDependentString(tag));
+ id = StringTagToId(nsDependentString(tag));
NS_ASSERTION(id != eHTMLTag_userdefined, "can't find tag id");
const char16_t* check = GetStringValue(id);
NS_ASSERTION(0 == nsCRT::strcmp(check, tag), "can't map id back to tag");
nsAutoString uname(tag);
ToUpperCase(uname);
- NS_ASSERTION(id == LookupTag(uname), "wrong id");
+ NS_ASSERTION(id == StringTagToId(uname), "wrong id");
- NS_ASSERTION(id == CaseSensitiveLookupTag(tag), "wrong id");
+ NS_ASSERTION(id == CaseSensitiveStringTagToId(tag), "wrong id");
atom = NS_Atomize(tag);
- NS_ASSERTION(id == CaseSensitiveLookupTag(atom), "wrong id");
+ NS_ASSERTION(id == CaseSensitiveAtomTagToId(atom), "wrong id");
NS_ASSERTION(atom == GetAtom(id), "can't map id back to atom");
}
// Make sure we don't find things that aren't there
- id = LookupTag(NS_LITERAL_STRING("@"));
+ id = StringTagToId(NS_LITERAL_STRING("@"));
NS_ASSERTION(id == eHTMLTag_userdefined, "found @");
- id = LookupTag(NS_LITERAL_STRING("zzzzz"));
+ id = StringTagToId(NS_LITERAL_STRING("zzzzz"));
NS_ASSERTION(id == eHTMLTag_userdefined, "found zzzzz");
atom = NS_Atomize("@");
- id = CaseSensitiveLookupTag(atom);
+ id = CaseSensitiveAtomTagToId(atom);
NS_ASSERTION(id == eHTMLTag_userdefined, "found @");
atom = NS_Atomize("zzzzz");
- id = CaseSensitiveLookupTag(atom);
+ id = CaseSensitiveAtomTagToId(atom);
NS_ASSERTION(id == eHTMLTag_userdefined, "found zzzzz");
tag = GetStringValue((nsHTMLTag) 0);
diff --git a/parser/htmlparser/nsHTMLTags.h b/parser/htmlparser/nsHTMLTags.h
index 27a23b89f..07d542f08 100644
--- a/parser/htmlparser/nsHTMLTags.h
+++ b/parser/htmlparser/nsHTMLTags.h
@@ -46,8 +46,13 @@ public:
static void ReleaseTable(void);
// Functions for converting string or atom to id
- static nsHTMLTag LookupTag(const nsAString& aTagName);
- static nsHTMLTag CaseSensitiveLookupTag(const char16_t* aTagName)
+ static nsHTMLTag StringTagToId(const nsAString& aTagName);
+ static nsHTMLTag AtomTagToId(nsIAtom* aTagName)
+ {
+ return StringTagToId(nsDependentAtomString(aTagName));
+ }
+
+ static nsHTMLTag CaseSensitiveStringTagToId(const char16_t* aTagName)
{
NS_ASSERTION(gTagTable, "no lookup table, needs addref");
NS_ASSERTION(aTagName, "null tagname!");
@@ -56,7 +61,7 @@ public:
return tag ? (nsHTMLTag)NS_PTR_TO_INT32(tag) : eHTMLTag_userdefined;
}
- static nsHTMLTag CaseSensitiveLookupTag(nsIAtom* aTagName)
+ static nsHTMLTag CaseSensitiveAtomTagToId(nsIAtom* aTagName)
{
NS_ASSERTION(gTagAtomTable, "no lookup table, needs addref");
NS_ASSERTION(aTagName, "null tagname!");
diff --git a/parser/htmlparser/nsParserService.cpp b/parser/htmlparser/nsParserService.cpp
index d89badd01..ab5c20c70 100644
--- a/parser/htmlparser/nsParserService.cpp
+++ b/parser/htmlparser/nsParserService.cpp
@@ -25,19 +25,19 @@ NS_IMPL_ISUPPORTS(nsParserService, nsIParserService)
int32_t
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom) const
{
- return nsHTMLTags::LookupTag(nsDependentAtomString(aAtom));
+ return nsHTMLTags::StringTagToId(nsDependentAtomString(aAtom));
}
int32_t
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const
{
- return nsHTMLTags::CaseSensitiveLookupTag(aAtom);
+ return nsHTMLTags::CaseSensitiveAtomTagToId(aAtom);
}
int32_t
nsParserService::HTMLStringTagToId(const nsAString& aTag) const
{
- return nsHTMLTags::LookupTag(aTag);
+ return nsHTMLTags::StringTagToId(aTag);
}
const char16_t*
@@ -84,16 +84,7 @@ nsParserService::IsContainer(int32_t aId, bool& aIsContainer) const
NS_IMETHODIMP
nsParserService::IsBlock(int32_t aId, bool& aIsBlock) const
{
- if((aId>eHTMLTag_unknown) && (aId<eHTMLTag_userdefined)) {
- aIsBlock=((gHTMLElements[aId].IsMemberOf(kBlock)) ||
- (gHTMLElements[aId].IsMemberOf(kBlockEntity)) ||
- (gHTMLElements[aId].IsMemberOf(kHeading)) ||
- (gHTMLElements[aId].IsMemberOf(kPreformatted))||
- (gHTMLElements[aId].IsMemberOf(kList)));
- }
- else {
- aIsBlock = false;
- }
+ aIsBlock = nsHTMLElement::IsBlock((eHTMLTags)aId);
return NS_OK;
}