summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dom/base/CustomElementRegistry.cpp10
-rw-r--r--dom/base/nsContentUtils.cpp5
-rw-r--r--dom/base/nsDocument.cpp1
-rw-r--r--dom/base/nsDocumentEncoder.cpp22
-rw-r--r--dom/base/nsHTMLContentSerializer.cpp22
-rwxr-xr-xdom/base/nsXHTMLContentSerializer.cpp28
-rw-r--r--dom/base/nsXMLContentSerializer.cpp13
-rw-r--r--dom/bindings/BindingUtils.cpp10
-rw-r--r--dom/html/nsHTMLContentSink.cpp9
-rw-r--r--dom/xul/XULDocument.cpp1
-rw-r--r--editor/libeditor/EditorBase.cpp4
-rw-r--r--editor/libeditor/HTMLEditor.cpp78
-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
18 files changed, 77 insertions, 193 deletions
diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp
index 99452df650..e4d4c0670f 100644
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -11,7 +11,7 @@
#include "mozilla/dom/HTMLElementBinding.h"
#include "mozilla/dom/WebComponentsBinding.h"
#include "mozilla/dom/DocGroup.h"
-#include "nsIParserService.h"
+#include "nsHTMLTags.h"
#include "jsapi.h"
namespace mozilla {
@@ -588,14 +588,8 @@ CustomElementRegistry::Define(const nsAString& aName,
return;
}
- nsIParserService* ps = nsContentUtils::GetParserService();
- if (!ps) {
- aRv.Throw(NS_ERROR_UNEXPECTED);
- return;
- }
-
// bgsound and multicol are unknown html element.
- int32_t tag = ps->HTMLCaseSensitiveAtomTagToId(extendsAtom);
+ int32_t tag = nsHTMLTags::CaseSensitiveAtomTagToId(extendsAtom);
if (tag == eHTMLTag_userdefined ||
tag == eHTMLTag_bgsound ||
tag == eHTMLTag_multicol) {
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
index f4828b162c..a68f5ef87d 100644
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -102,6 +102,7 @@
#include "nsHostObjectProtocolHandler.h"
#include "nsHtml5Module.h"
#include "nsHtml5StringParser.h"
+#include "nsHTMLTags.h"
#include "nsIAddonPolicyService.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIAsyncVerifyRedirectCallback.h"
@@ -501,6 +502,8 @@ nsContentUtils::Init()
return NS_OK;
}
+ nsHTMLTags::AddRefTable();
+
sNameSpaceManager = nsNameSpaceManager::GetInstance();
NS_ENSURE_TRUE(sNameSpaceManager, NS_ERROR_OUT_OF_MEMORY);
@@ -1927,6 +1930,8 @@ nsContentUtils::Shutdown()
{
sInitialized = false;
+ nsHTMLTags::ReleaseTable();
+
NS_IF_RELEASE(sContentPolicyService);
sTriedToGetContentPolicy = false;
uint32_t i;
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index 130580fad1..87d860c6ae 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -116,7 +116,6 @@
#include "nsBidiUtils.h"
-#include "nsIParserService.h"
#include "nsContentCreatorFunctions.h"
#include "nsIScriptContext.h"
diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp
index de41a7331d..2f5c3dc0a3 100644
--- a/dom/base/nsDocumentEncoder.cpp
+++ b/dom/base/nsDocumentEncoder.cpp
@@ -32,7 +32,6 @@
#include "nsIDOMDocument.h"
#include "nsGkAtoms.h"
#include "nsIContent.h"
-#include "nsIParserService.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptSecurityManager.h"
@@ -40,6 +39,7 @@
#include "nsISelectionPrivate.h"
#include "nsITransferable.h" // for kUnicodeMime
#include "nsContentUtils.h"
+#include "nsElementTable.h"
#include "nsNodeUtils.h"
#include "nsUnicharUtils.h"
#include "nsReadableUtils.h"
@@ -1741,9 +1741,6 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
rv = GetNodeLocation(node, address_of(parent), &offset);
NS_ENSURE_SUCCESS(rv, rv);
if (offset == -1) return NS_OK; // we hit generated content; STOP
- nsIParserService *parserService = nsContentUtils::GetParserService();
- if (!parserService)
- return NS_ERROR_OUT_OF_MEMORY;
while ((IsFirstNode(node)) && (!IsRoot(parent)) && (parent != common))
{
if (bResetPromotion)
@@ -1751,11 +1748,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
if (content && content->IsHTMLElement())
{
- bool isBlock = false;
- parserService->IsBlock(parserService->HTMLAtomTagToId(
- content->NodeInfo()->NameAtom()), isBlock);
- if (isBlock)
- {
+ if (nsHTMLElement::IsBlock(nsHTMLTags::AtomTagToId(
+ content->NodeInfo()->NameAtom()))) {
bResetPromotion = false;
}
}
@@ -1824,9 +1818,6 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
rv = GetNodeLocation(node, address_of(parent), &offset);
NS_ENSURE_SUCCESS(rv, rv);
if (offset == -1) return NS_OK; // we hit generated content; STOP
- nsIParserService *parserService = nsContentUtils::GetParserService();
- if (!parserService)
- return NS_ERROR_OUT_OF_MEMORY;
while ((IsLastNode(node)) && (!IsRoot(parent)) && (parent != common))
{
if (bResetPromotion)
@@ -1834,11 +1825,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, int32_t
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
if (content && content->IsHTMLElement())
{
- bool isBlock = false;
- parserService->IsBlock(parserService->HTMLAtomTagToId(
- content->NodeInfo()->NameAtom()), isBlock);
- if (isBlock)
- {
+ if (nsHTMLElement::IsBlock(nsHTMLTags::AtomTagToId(
+ content->NodeInfo()->NameAtom()))) {
bResetPromotion = false;
}
}
diff --git a/dom/base/nsHTMLContentSerializer.cpp b/dom/base/nsHTMLContentSerializer.cpp
index c135c4cf85..ea9c5a66ff 100644
--- a/dom/base/nsHTMLContentSerializer.cpp
+++ b/dom/base/nsHTMLContentSerializer.cpp
@@ -15,6 +15,7 @@
#include "nsIDOMElement.h"
#include "nsIContent.h"
#include "nsIDocument.h"
+#include "nsElementTable.h"
#include "nsNameSpaceManager.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
@@ -347,20 +348,13 @@ nsHTMLContentSerializer::AppendElementEnd(Element* aElement,
}
if (ns == kNameSpaceID_XHTML) {
- nsIParserService* parserService = nsContentUtils::GetParserService();
-
- if (parserService) {
- bool isContainer;
-
- parserService->
- IsContainer(parserService->HTMLCaseSensitiveAtomTagToId(name),
- isContainer);
- if (!isContainer) {
- // Keep this in sync with the cleanup at the end of this method.
- MOZ_ASSERT(name != nsGkAtoms::body);
- MaybeLeaveFromPreContent(content);
- return NS_OK;
- }
+ bool isContainer =
+ nsHTMLElement::IsContainer(nsHTMLTags::CaseSensitiveAtomTagToId(name));
+ if (!isContainer) {
+ // Keep this in sync with the cleanup at the end of this method.
+ MOZ_ASSERT(name != nsGkAtoms::body);
+ MaybeLeaveFromPreContent(content);
+ return NS_OK;
}
}
diff --git a/dom/base/nsXHTMLContentSerializer.cpp b/dom/base/nsXHTMLContentSerializer.cpp
index 0a39ef6636..aa330364b6 100755
--- a/dom/base/nsXHTMLContentSerializer.cpp
+++ b/dom/base/nsXHTMLContentSerializer.cpp
@@ -15,6 +15,7 @@
#include "nsIDOMElement.h"
#include "nsIContent.h"
#include "nsIDocument.h"
+#include "nsElementTable.h"
#include "nsNameSpaceManager.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
@@ -27,7 +28,6 @@
#include "nsEscape.h"
#include "nsITextToSubURI.h"
#include "nsCRT.h"
-#include "nsIParserService.h"
#include "nsContentUtils.h"
#include "nsLWBrkCIID.h"
#include "nsIScriptElement.h"
@@ -667,18 +667,7 @@ nsXHTMLContentSerializer::LineBreakBeforeOpen(int32_t aNamespaceID, nsIAtom* aNa
aName == nsGkAtoms::html) {
return true;
}
- else {
- nsIParserService* parserService = nsContentUtils::GetParserService();
-
- if (parserService) {
- bool res;
- parserService->
- IsBlock(parserService->HTMLCaseSensitiveAtomTagToId(aName), res);
- return res;
- }
- }
-
- return mAddSpace;
+ return nsHTMLElement::IsBlock(nsHTMLTags::CaseSensitiveAtomTagToId(aName));
}
bool
@@ -761,18 +750,7 @@ nsXHTMLContentSerializer::LineBreakAfterClose(int32_t aNamespaceID, nsIAtom* aNa
(aName == nsGkAtoms::div)) {
return true;
}
- else {
- nsIParserService* parserService = nsContentUtils::GetParserService();
-
- if (parserService) {
- bool res;
- parserService->
- IsBlock(parserService->HTMLCaseSensitiveAtomTagToId(aName), res);
- return res;
- }
- }
-
- return false;
+ return nsHTMLElement::IsBlock(nsHTMLTags::CaseSensitiveAtomTagToId(aName));
}
diff --git a/dom/base/nsXMLContentSerializer.cpp b/dom/base/nsXMLContentSerializer.cpp
index f12bb8fdc7..71a675e11b 100644
--- a/dom/base/nsXMLContentSerializer.cpp
+++ b/dom/base/nsXMLContentSerializer.cpp
@@ -19,7 +19,7 @@
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDocumentEncoder.h"
-#include "nsIParserService.h"
+#include "nsElementTable.h"
#include "nsNameSpaceManager.h"
#include "nsTextFragment.h"
#include "nsString.h"
@@ -994,14 +994,9 @@ ElementNeedsSeparateEndTag(Element* aElement, Element* aOriginalElement)
// HTML container tags should have a separate end tag even if empty, per spec.
// See
// https://w3c.github.io/DOM-Parsing/#dfn-concept-xml-serialization-algorithm
- bool isHTMLContainer = true; // Default in case we get no parser service.
- nsIParserService* parserService = nsContentUtils::GetParserService();
- if (parserService) {
- nsIAtom* localName = aElement->NodeInfo()->NameAtom();
- parserService->IsContainer(
- parserService->HTMLCaseSensitiveAtomTagToId(localName),
- isHTMLContainer);
- }
+ nsIAtom* localName = aElement->NodeInfo()->NameAtom();
+ bool isHTMLContainer =
+ nsHTMLElement::IsContainer(nsHTMLTags::CaseSensitiveAtomTagToId(localName));
return isHTMLContainer;
}
diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp
index f76f14d95f..51274f1af0 100644
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -23,9 +23,9 @@
#include "nsContentCreatorFunctions.h"
#include "nsContentUtils.h"
#include "nsGlobalWindow.h"
+#include "nsHTMLTags.h"
#include "nsIDocShell.h"
#include "nsIDOMGlobalPropertyInitializer.h"
-#include "nsIParserService.h"
#include "nsIPermissionManager.h"
#include "nsIPrincipal.h"
#include "nsIXPConnect.h"
@@ -3493,13 +3493,7 @@ CreateHTMLElement(const GlobalObject& aGlobal, const JS::CallArgs& aCallArgs,
// Step 5.
// If the definition is for a customized built-in element, the localName
// should be defined in the specification.
- nsIParserService* parserService = nsContentUtils::GetParserService();
- if (!parserService) {
- aRv.Throw(NS_ERROR_UNEXPECTED);
- return nullptr;
- }
-
- tag = parserService->HTMLCaseSensitiveAtomTagToId(definition->mLocalName);
+ tag = nsHTMLTags::CaseSensitiveAtomTagToId(definition->mLocalName);
if (tag == eHTMLTag_userdefined) {
aRv.ThrowTypeError<MSG_ILLEGAL_CONSTRUCTOR>();
return nullptr;
diff --git a/dom/html/nsHTMLContentSink.cpp b/dom/html/nsHTMLContentSink.cpp
index 1fe5d2a865..1c390a53ec 100644
--- a/dom/html/nsHTMLContentSink.cpp
+++ b/dom/html/nsHTMLContentSink.cpp
@@ -14,6 +14,7 @@
#include "nsContentSink.h"
#include "nsCOMPtr.h"
+#include "nsHTMLTags.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsIHTMLContentSink.h"
@@ -59,8 +60,6 @@
#include "nsIScriptGlobalObject.h"
#include "nsNameSpaceManager.h"
-#include "nsIParserService.h"
-
#include "nsIStyleSheetLinkingElement.h"
#include "nsITimer.h"
#include "nsError.h"
@@ -262,10 +261,6 @@ NS_NewHTMLElement(Element** aResult, already_AddRefed<mozilla::dom::NodeInfo>&&
RefPtr<mozilla::dom::NodeInfo> nodeInfo = aNodeInfo;
- nsIParserService* parserService = nsContentUtils::GetParserService();
- if (!parserService)
- return NS_ERROR_OUT_OF_MEMORY;
-
nsIAtom *name = nodeInfo->NameAtom();
RefPtr<nsIAtom> tagAtom = nodeInfo->NameAtom();
RefPtr<nsIAtom> typeAtom = aIs ? NS_Atomize(*aIs) : tagAtom;
@@ -273,7 +268,7 @@ NS_NewHTMLElement(Element** aResult, already_AddRefed<mozilla::dom::NodeInfo>&&
NS_ASSERTION(nodeInfo->NamespaceEquals(kNameSpaceID_XHTML),
"Trying to HTML elements that don't have the XHTML namespace");
- int32_t tag = parserService->HTMLCaseSensitiveAtomTagToId(name);
+ int32_t tag = nsHTMLTags::CaseSensitiveAtomTagToId(name);
bool isCustomElementName = (tag == eHTMLTag_userdefined &&
nsContentUtils::IsCustomElementName(name));
diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp
index 1dcb55aee4..929efc1afc 100644
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -66,7 +66,6 @@
#include "nsContentUtils.h"
#include "nsIParser.h"
#include "nsCharsetSource.h"
-#include "nsIParserService.h"
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/css/Loader.h"
#include "nsIScriptError.h"
diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp
index 27983df31b..3f419a74ed 100644
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -107,16 +107,12 @@
#include "prtime.h" // for PR_Now
class nsIOutputStream;
-class nsIParserService;
class nsITransferable;
#ifdef DEBUG
#include "nsIDOMHTMLDocument.h" // for nsIDOMHTMLDocument
#endif
-// Defined in nsEditorRegistration.cpp
-extern nsIParserService *sParserService;
-
namespace mozilla {
using namespace dom;
diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp
index 766ab81cfd..04a710cde1 100644
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -63,13 +63,13 @@
#include "nsIWidget.h"
#include "nsIFrame.h"
-#include "nsIParserService.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/DocumentFragment.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/HTMLBodyElement.h"
+#include "nsElementTable.h"
#include "nsTextFragment.h"
#include "nsContentList.h"
#include "mozilla/StyleSheet.h"
@@ -690,49 +690,6 @@ HTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
return TypedText(str, eTypedText);
}
-static void
-AssertParserServiceIsCorrect(nsIAtom* aTag, bool aIsBlock)
-{
-#ifdef DEBUG
- // Check this against what we would have said with the old code:
- if (aTag == nsGkAtoms::p ||
- aTag == nsGkAtoms::div ||
- aTag == nsGkAtoms::blockquote ||
- aTag == nsGkAtoms::h1 ||
- aTag == nsGkAtoms::h2 ||
- aTag == nsGkAtoms::h3 ||
- aTag == nsGkAtoms::h4 ||
- aTag == nsGkAtoms::h5 ||
- aTag == nsGkAtoms::h6 ||
- aTag == nsGkAtoms::ul ||
- aTag == nsGkAtoms::ol ||
- aTag == nsGkAtoms::dl ||
- aTag == nsGkAtoms::noscript ||
- aTag == nsGkAtoms::form ||
- aTag == nsGkAtoms::hr ||
- aTag == nsGkAtoms::table ||
- aTag == nsGkAtoms::fieldset ||
- aTag == nsGkAtoms::address ||
- aTag == nsGkAtoms::col ||
- aTag == nsGkAtoms::colgroup ||
- aTag == nsGkAtoms::li ||
- aTag == nsGkAtoms::dt ||
- aTag == nsGkAtoms::dd ||
- aTag == nsGkAtoms::legend) {
- if (!aIsBlock) {
- nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: "));
-
- nsAutoString tagName;
- aTag->ToString(tagName);
- assertmsg.Append(tagName);
- char* assertstr = ToNewCString(assertmsg);
- NS_ASSERTION(aIsBlock, assertstr);
- free(assertstr);
- }
- }
-#endif // DEBUG
-}
-
/**
* Returns true if the id represents an element of block type.
* Can be used to determine if a new paragraph should be started.
@@ -742,8 +699,8 @@ HTMLEditor::NodeIsBlockStatic(const nsINode* aElement)
{
MOZ_ASSERT(aElement);
- // Nodes we know we want to treat as block
- // even though the parser says they're not:
+ // We want to treat these as block nodes even though nsHTMLElement says
+ // they're not.
if (aElement->IsAnyOfHTMLElements(nsGkAtoms::body,
nsGkAtoms::head,
nsGkAtoms::tbody,
@@ -752,27 +709,13 @@ HTMLEditor::NodeIsBlockStatic(const nsINode* aElement)
nsGkAtoms::tr,
nsGkAtoms::th,
nsGkAtoms::td,
- nsGkAtoms::li,
nsGkAtoms::dt,
- nsGkAtoms::dd,
- nsGkAtoms::pre)) {
+ nsGkAtoms::dd)) {
return true;
}
- bool isBlock;
-#ifdef DEBUG
- // XXX we can't use DebugOnly here because VC++ is stupid (bug 802884)
- nsresult rv =
-#endif
- nsContentUtils::GetParserService()->
- IsBlock(nsContentUtils::GetParserService()->HTMLAtomTagToId(
- aElement->NodeInfo()->NameAtom()),
- isBlock);
- MOZ_ASSERT(rv == NS_OK);
-
- AssertParserServiceIsCorrect(aElement->NodeInfo()->NameAtom(), isBlock);
-
- return isBlock;
+ return nsHTMLElement::IsBlock(
+ nsHTMLTags::AtomTagToId(aElement->NodeInfo()->NameAtom()));
}
nsresult
@@ -3538,17 +3481,15 @@ bool
HTMLEditor::TagCanContainTag(nsIAtom& aParentTag,
nsIAtom& aChildTag)
{
- nsIParserService* parserService = nsContentUtils::GetParserService();
-
int32_t childTagEnum;
// XXX Should this handle #cdata-section too?
if (&aChildTag == nsGkAtoms::textTagName) {
childTagEnum = eHTMLTag_text;
} else {
- childTagEnum = parserService->HTMLAtomTagToId(&aChildTag);
+ childTagEnum = nsHTMLTags::AtomTagToId(&aChildTag);
}
- int32_t parentTagEnum = parserService->HTMLAtomTagToId(&aParentTag);
+ int32_t parentTagEnum = nsHTMLTags::AtomTagToId(&aParentTag);
return HTMLEditUtils::CanContain(parentTagEnum, childTagEnum);
}
@@ -3562,8 +3503,7 @@ HTMLEditor::IsContainer(nsINode* aNode)
if (aNode->IsNodeOfType(nsINode::eTEXT)) {
tagEnum = eHTMLTag_text;
} else {
- tagEnum =
- nsContentUtils::GetParserService()->HTMLStringTagToId(aNode->NodeName());
+ tagEnum = nsHTMLTags::StringTagToId(aNode->NodeName());
}
return HTMLEditUtils::IsContainer(tagEnum);
diff --git a/parser/htmlparser/moz.build b/parser/htmlparser/moz.build
index 7e5da29a5a..3a91ae1421 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 86fbdad861..52507a9765 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 28d2fa532b..e3479db8d1 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 e98d2c4cd8..681c374897 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 27a23b89fe..07d542f08a 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 d89badd01d..ab5c20c70e 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;
}