mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 21:28:55 +00:00
Speed up mapping HTML tag enums to atoms by using an array of static atoms, indexed by enum value. This avoids a UTF16 to UTF8 conversion and atom table lookup for each tag. Add a CString version of nsINodeInfoManager::GetNodeInfo(), convert literal string callers to use that version, and remove some unused variants of GetNodeInfo(). Bug 223595, r=axel@pike.org, sr=jst.
This commit is contained in:
parent
f908a4ae39
commit
78f1cb532a
@ -347,15 +347,13 @@ public:
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo) = 0;
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo) = 0;
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, const nsAString& aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo) = 0;
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, const nsAString& aPrefix,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo) = 0;
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aQualifiedName,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo) = 0;
|
||||
|
||||
NS_IMETHOD GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo) = 0;
|
||||
|
||||
/*
|
||||
* Retrieve a pointer to the document that owns this node info
|
||||
* manager.
|
||||
|
@ -189,7 +189,7 @@ NS_NewDocumentFragment(nsIDOMDocumentFragment** aInstancePtrResult,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = nimgr->GetNodeInfo(NS_LITERAL_STRING("#document-fragment"),
|
||||
rv = nimgr->GetNodeInfo(NS_LITERAL_CSTRING("#document-fragment"),
|
||||
nsnull, kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -228,59 +228,8 @@ NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
NS_ENSURE_ARG(!aName.IsEmpty());
|
||||
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return GetNodeInfo(name, aPrefix, aNamespaceID, aNodeInfo);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aName,
|
||||
const nsAString& aPrefix, PRInt32 aNamespaceID,
|
||||
nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
NS_ENSURE_ARG(!aName.IsEmpty());
|
||||
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
if (!aPrefix.IsEmpty()) {
|
||||
prefix = do_GetAtom(aPrefix);
|
||||
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
return GetNodeInfo(name, prefix, aNamespaceID, aNodeInfo);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetNodeInfo(const nsAString& aName,
|
||||
const nsAString& aPrefix,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
NS_ENSURE_ARG(!aName.IsEmpty());
|
||||
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
|
||||
if (!aPrefix.IsEmpty()) {
|
||||
prefix = do_GetAtom(aPrefix);
|
||||
NS_ENSURE_TRUE(prefix, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
PRInt32 nsid;
|
||||
nsresult rv = nsContentUtils::GetNSManagerWeakRef()->RegisterNameSpace(aNamespaceURI, nsid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return GetNodeInfo(name, prefix, nsid, aNodeInfo);
|
||||
return nsNodeInfoManager::GetNodeInfo(NS_ConvertUTF16toUTF8(aName),
|
||||
aPrefix, aNamespaceID, aNodeInfo);
|
||||
}
|
||||
|
||||
|
||||
@ -322,9 +271,22 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo);
|
||||
return nsNodeInfoManager::GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeInfoManager::GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo)
|
||||
{
|
||||
NS_ENSURE_ARG(!aName.IsEmpty());
|
||||
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
|
||||
NS_ENSURE_TRUE(name, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return GetNodeInfo(name, aPrefix, aNamespaceID, aNodeInfo);
|
||||
}
|
||||
|
||||
|
||||
nsIDocument*
|
||||
nsNodeInfoManager::GetDocument() const
|
||||
{
|
||||
|
@ -60,14 +60,13 @@ public:
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo);
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo);
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, const nsAString& aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo);
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aName, const nsAString& aPrefix,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo);
|
||||
NS_IMETHOD GetNodeInfo(const nsAString& aQualifiedName,
|
||||
const nsAString& aNamespaceURI,
|
||||
nsINodeInfo** aNodeInfo);
|
||||
|
||||
NS_IMETHOD GetNodeInfo(const nsACString& aName, nsIAtom *aPrefix,
|
||||
PRInt32 aNamespaceID, nsINodeInfo** aNodeInfo);
|
||||
|
||||
virtual nsIDocument* GetDocument() const;
|
||||
NS_IMETHOD GetDocumentPrincipal(nsIPrincipal** aPrincipal);
|
||||
NS_IMETHOD SetDocumentPrincipal(nsIPrincipal* aPrincipal);
|
||||
|
@ -889,8 +889,7 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
|
||||
if (aNodeType == eHTMLTag_userdefined) {
|
||||
nsAutoString tmp;
|
||||
tmp.Append(aNode.GetText());
|
||||
NS_ConvertUTF16toUTF8 tmp(aNode.GetText());
|
||||
ToLowerCase(tmp);
|
||||
|
||||
rv = mNodeInfoManager->GetNodeInfo(tmp, nsnull, kNameSpaceID_None,
|
||||
@ -899,9 +898,8 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
|
||||
nsCOMPtr<nsIDTD> dtd;
|
||||
rv = mParser->GetDTD(getter_AddRefs(dtd));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsDependentString tag(dtd->IntTagToStringTag(aNodeType));
|
||||
|
||||
rv = mNodeInfoManager->GetNodeInfo(tag, nsnull, kNameSpaceID_None,
|
||||
rv = mNodeInfoManager->GetNodeInfo(dtd->IntTagToAtom(aNodeType), nsnull,
|
||||
kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
}
|
||||
}
|
||||
@ -2259,7 +2257,7 @@ HTMLContentSink::Init(nsIDocument* aDoc,
|
||||
}
|
||||
|
||||
// Make head part
|
||||
rv = mNodeInfoManager->GetNodeInfo(NS_LITERAL_STRING("head"),
|
||||
rv = mNodeInfoManager->GetNodeInfo(NS_LITERAL_CSTRING("head"),
|
||||
nsnull, kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -4021,7 +4019,7 @@ HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode)
|
||||
// Create content object
|
||||
nsCOMPtr<nsIHTMLContent> element;
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
mNodeInfoManager->GetNodeInfo(NS_LITERAL_STRING("base"), nsnull,
|
||||
mNodeInfoManager->GetNodeInfo(NS_LITERAL_CSTRING("base"), nsnull,
|
||||
kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
|
||||
@ -4173,7 +4171,7 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode)
|
||||
|
||||
// Create content object
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
rv = mNodeInfoManager->GetNodeInfo(NS_LITERAL_STRING("meta"), nsnull,
|
||||
rv = mNodeInfoManager->GetNodeInfo(NS_LITERAL_CSTRING("meta"), nsnull,
|
||||
kNameSpaceID_None,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -1578,7 +1578,7 @@ nsHTMLDocument::CreateElement(const nsAString& aTagName,
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
|
||||
nsAutoString tmp(aTagName);
|
||||
NS_ConvertUTF16toUTF8 tmp(aTagName);
|
||||
|
||||
if (!IsXHTML()) {
|
||||
ToLowerCase(tmp);
|
||||
|
@ -41,6 +41,8 @@
|
||||
|
||||
#include "nsAString.h"
|
||||
|
||||
class nsIAtom;
|
||||
|
||||
/*
|
||||
Declare the enum list using the magic of preprocessing
|
||||
enum values are "eHTMLTag_foo" (where foo is the tag)
|
||||
@ -73,6 +75,7 @@ public:
|
||||
static nsHTMLTag LookupTag(const nsAString& aTagName);
|
||||
static nsHTMLTag CaseSensitiveLookupTag(const PRUnichar* aTagName);
|
||||
static const PRUnichar *GetStringValue(nsHTMLTag aEnum);
|
||||
static nsIAtom *GetAtom(nsHTMLTag aEnum);
|
||||
};
|
||||
|
||||
#define eHTMLTags nsHTMLTag
|
||||
|
@ -84,6 +84,7 @@ class CToken;
|
||||
class nsIURI;
|
||||
class nsIContentSink;
|
||||
class CParserContext;
|
||||
class nsIAtom;
|
||||
|
||||
class nsIDTD : public nsISupports
|
||||
{
|
||||
@ -220,6 +221,8 @@ public:
|
||||
|
||||
NS_IMETHOD_(const PRUnichar *) IntTagToStringTag(PRInt32 aIntTag) const = 0;
|
||||
|
||||
NS_IMETHOD_(nsIAtom *) IntTagToAtom(PRInt32 aIntTag) const = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) IsBlockElement(PRInt32 aTagID,
|
||||
PRInt32 aParentID) const = 0;
|
||||
|
||||
@ -244,6 +247,7 @@ public:
|
||||
NS_IMETHOD_(PRInt32) GetType(); \
|
||||
NS_IMETHOD StringTagToIntTag(const nsAString &aTag, PRInt32* aIntTag) const ;\
|
||||
NS_IMETHOD_(const PRUnichar *) IntTagToStringTag(PRInt32 aIntTag) const ;\
|
||||
NS_IMETHOD_(nsIAtom *) IntTagToAtom(PRInt32 aIntTag) const;\
|
||||
NS_IMETHOD_(PRBool) IsBlockElement(PRInt32 aTagID,PRInt32 aParentID) const;\
|
||||
NS_IMETHOD_(PRBool) IsInlineElement(PRInt32 aTagID,PRInt32 aParentID) const;
|
||||
#endif /* nsIDTD_h___ */
|
||||
|
@ -2585,6 +2585,17 @@ CNavDTD::IntTagToStringTag(PRInt32 aIntTag) const
|
||||
return str_ptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIAtom *)
|
||||
CNavDTD::IntTagToAtom(PRInt32 aIntTag) const
|
||||
{
|
||||
nsIAtom *atom = nsHTMLTags::GetAtom((nsHTMLTag)aIntTag);
|
||||
|
||||
NS_ASSERTION(atom, "Bad tag enum passed to CNavDTD::IntTagToAtom()"
|
||||
"!!");
|
||||
|
||||
return atom;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not
|
||||
* the given childtag is a block element.
|
||||
|
@ -906,6 +906,17 @@ COtherDTD::IntTagToStringTag(PRInt32 aIntTag) const
|
||||
return str_ptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIAtom *)
|
||||
COtherDTD::IntTagToAtom(PRInt32 aIntTag) const
|
||||
{
|
||||
nsIAtom *atom = nsHTMLTags::GetAtom((nsHTMLTag)aIntTag);
|
||||
|
||||
NS_ASSERTION(atom, "Bad tag enum passed to COtherDTD::IntTagToAtom()"
|
||||
"!!");
|
||||
|
||||
return atom;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not
|
||||
* the given childtag is a block element.
|
||||
|
@ -1196,4 +1196,10 @@ nsExpatDriver::IntTagToStringTag(PRInt32 aIntTag) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIAtom *)
|
||||
nsExpatDriver::IntTagToAtom(PRInt32 aIntTag) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "plhash.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStaticAtom.h"
|
||||
|
||||
// C++ sucks! There's no way to do this with a macro, at least not
|
||||
// that I know, if you know how to do this with a macro then please do
|
||||
@ -275,19 +276,17 @@ static const PRUnichar* const kTagUnicodeTable[] = {
|
||||
#include "nsHTMLTagList.h"
|
||||
};
|
||||
#undef HTML_TAG
|
||||
#undef HTML_OTHER
|
||||
|
||||
// static array of tag atoms
|
||||
static nsIAtom* kTagAtomTable[eHTMLTag_userdefined - 1];
|
||||
|
||||
#ifdef DEBUG
|
||||
// static array of ASCII tag names for debugging purposes
|
||||
#define HTML_TAG(_tag, _classname) #_tag,
|
||||
#define HTML_OTHER(_tag, _classname)
|
||||
static const char* const kTagASCIIDebugTable[] = {
|
||||
// static array of tag StaticAtom structs
|
||||
#define HTML_TAG(_tag, _classname) { #_tag, &kTagAtomTable[eHTMLTag_##_tag - 1] },
|
||||
static const nsStaticAtom kTagAtoms_info[] = {
|
||||
#include "nsHTMLTagList.h"
|
||||
};
|
||||
#undef HTML_TAG
|
||||
#undef HTML_OTHER
|
||||
#endif
|
||||
|
||||
static PRInt32 gTableRefCount;
|
||||
static PLHashTable* gTagTable;
|
||||
@ -345,12 +344,15 @@ nsHTMLTags::AddRefTable(void)
|
||||
NS_ASSERTION(sMaxTagNameLength == NS_HTMLTAG_NAME_MAX_LENGTH,
|
||||
"NS_HTMLTAG_NAME_MAX_LENGTH not set correctly!");
|
||||
|
||||
// Fill in our static atom pointers
|
||||
NS_RegisterStaticAtoms(kTagAtoms_info, NS_ARRAY_LENGTH(kTagAtoms_info));
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
// let's verify that all names in the the table are lowercase...
|
||||
for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
|
||||
nsCAutoString temp1(kTagASCIIDebugTable[i]);
|
||||
nsCAutoString temp2(kTagASCIIDebugTable[i]);
|
||||
nsCAutoString temp1(kTagAtoms_info[i].mString);
|
||||
nsCAutoString temp2(kTagAtoms_info[i].mString);
|
||||
ToLowerCase(temp1);
|
||||
NS_ASSERTION(temp1.Equals(temp2), "upper case char in table");
|
||||
}
|
||||
@ -359,7 +361,7 @@ nsHTMLTags::AddRefTable(void)
|
||||
// correct.
|
||||
for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
|
||||
nsAutoString temp1(kTagUnicodeTable[i]);
|
||||
nsAutoString temp2; temp2.AssignWithConversion(kTagASCIIDebugTable[i]);
|
||||
nsAutoString temp2; temp2.AssignWithConversion(kTagAtoms_info[i].mString);
|
||||
NS_ASSERTION(temp1.Equals(temp2), "Bad unicode tag name!");
|
||||
}
|
||||
}
|
||||
@ -473,6 +475,17 @@ nsHTMLTags::GetStringValue(nsHTMLTag aEnum)
|
||||
return kTagUnicodeTable[aEnum - 1];
|
||||
}
|
||||
|
||||
// static
|
||||
nsIAtom *
|
||||
nsHTMLTags::GetAtom(nsHTMLTag aEnum)
|
||||
{
|
||||
if (aEnum <= eHTMLTag_unknown || aEnum > NS_HTML_TAG_MAX) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return kTagAtomTable[aEnum - 1];
|
||||
}
|
||||
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
||||
|
@ -903,6 +903,17 @@ CViewSourceHTML::IntTagToStringTag(PRInt32 aIntTag) const
|
||||
return str_ptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIAtom *)
|
||||
CViewSourceHTML::IntTagToAtom(PRInt32 aIntTag) const
|
||||
{
|
||||
nsIAtom *atom = nsHTMLTags::GetAtom((nsHTMLTag)aIntTag);
|
||||
|
||||
NS_ASSERTION(atom, "Bad tag enum passed to COtherDTD::IntTagToAtom()"
|
||||
"!!");
|
||||
|
||||
return atom;
|
||||
}
|
||||
|
||||
PRBool CViewSourceHTML::IsBlockElement(PRInt32 aTagID,PRInt32 aParentID) const {
|
||||
PRBool result=PR_FALSE;
|
||||
return result;
|
||||
|
@ -388,10 +388,8 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
|
||||
NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfoManager->GetNodeInfo(NS_LITERAL_STRING("scrollbar"),
|
||||
NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"),
|
||||
getter_AddRefs(nodeInfo));
|
||||
nodeInfoManager->GetNodeInfo(NS_LITERAL_CSTRING("scrollbar"), nsnull,
|
||||
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
|
||||
|
||||
ScrollbarStyles styles = GetScrollbarStyles();
|
||||
if (styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO
|
||||
|
@ -388,10 +388,8 @@ nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
|
||||
NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfoManager->GetNodeInfo(NS_LITERAL_STRING("scrollbar"),
|
||||
NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"),
|
||||
getter_AddRefs(nodeInfo));
|
||||
nodeInfoManager->GetNodeInfo(NS_LITERAL_CSTRING("scrollbar"), nsnull,
|
||||
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
|
||||
|
||||
ScrollbarStyles styles = GetScrollbarStyles();
|
||||
if (styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO
|
||||
|
@ -132,20 +132,16 @@ nsDocElementBoxFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
|
||||
|
||||
// create the top-secret popupgroup node. shhhhh!
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfoManager->GetNodeInfo(NS_LITERAL_STRING("popupgroup"),
|
||||
NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"),
|
||||
getter_AddRefs(nodeInfo));
|
||||
nodeInfoManager->GetNodeInfo(NS_LITERAL_CSTRING("popupgroup"), nsnull,
|
||||
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
|
||||
aAnonymousItems.AppendElement(content);
|
||||
|
||||
// create the top-secret default tooltip node. shhhhh!
|
||||
nodeInfoManager->GetNodeInfo(NS_LITERAL_STRING("tooltip"),
|
||||
NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"),
|
||||
getter_AddRefs(nodeInfo));
|
||||
nodeInfoManager->GetNodeInfo(NS_LITERAL_CSTRING("tooltip"), nsnull,
|
||||
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
|
||||
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
|
||||
content->SetAttr(nsnull, nsXULAtoms::defaultz, NS_LITERAL_STRING("true"), PR_FALSE);
|
||||
aAnonymousItems.AppendElement(content);
|
||||
|
@ -41,6 +41,8 @@
|
||||
|
||||
#include "nsAString.h"
|
||||
|
||||
class nsIAtom;
|
||||
|
||||
/*
|
||||
Declare the enum list using the magic of preprocessing
|
||||
enum values are "eHTMLTag_foo" (where foo is the tag)
|
||||
@ -73,6 +75,7 @@ public:
|
||||
static nsHTMLTag LookupTag(const nsAString& aTagName);
|
||||
static nsHTMLTag CaseSensitiveLookupTag(const PRUnichar* aTagName);
|
||||
static const PRUnichar *GetStringValue(nsHTMLTag aEnum);
|
||||
static nsIAtom *GetAtom(nsHTMLTag aEnum);
|
||||
};
|
||||
|
||||
#define eHTMLTags nsHTMLTag
|
||||
|
@ -84,6 +84,7 @@ class CToken;
|
||||
class nsIURI;
|
||||
class nsIContentSink;
|
||||
class CParserContext;
|
||||
class nsIAtom;
|
||||
|
||||
class nsIDTD : public nsISupports
|
||||
{
|
||||
@ -220,6 +221,8 @@ public:
|
||||
|
||||
NS_IMETHOD_(const PRUnichar *) IntTagToStringTag(PRInt32 aIntTag) const = 0;
|
||||
|
||||
NS_IMETHOD_(nsIAtom *) IntTagToAtom(PRInt32 aIntTag) const = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) IsBlockElement(PRInt32 aTagID,
|
||||
PRInt32 aParentID) const = 0;
|
||||
|
||||
@ -244,6 +247,7 @@ public:
|
||||
NS_IMETHOD_(PRInt32) GetType(); \
|
||||
NS_IMETHOD StringTagToIntTag(const nsAString &aTag, PRInt32* aIntTag) const ;\
|
||||
NS_IMETHOD_(const PRUnichar *) IntTagToStringTag(PRInt32 aIntTag) const ;\
|
||||
NS_IMETHOD_(nsIAtom *) IntTagToAtom(PRInt32 aIntTag) const;\
|
||||
NS_IMETHOD_(PRBool) IsBlockElement(PRInt32 aTagID,PRInt32 aParentID) const;\
|
||||
NS_IMETHOD_(PRBool) IsInlineElement(PRInt32 aTagID,PRInt32 aParentID) const;
|
||||
#endif /* nsIDTD_h___ */
|
||||
|
@ -2585,6 +2585,17 @@ CNavDTD::IntTagToStringTag(PRInt32 aIntTag) const
|
||||
return str_ptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIAtom *)
|
||||
CNavDTD::IntTagToAtom(PRInt32 aIntTag) const
|
||||
{
|
||||
nsIAtom *atom = nsHTMLTags::GetAtom((nsHTMLTag)aIntTag);
|
||||
|
||||
NS_ASSERTION(atom, "Bad tag enum passed to CNavDTD::IntTagToAtom()"
|
||||
"!!");
|
||||
|
||||
return atom;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not
|
||||
* the given childtag is a block element.
|
||||
|
@ -906,6 +906,17 @@ COtherDTD::IntTagToStringTag(PRInt32 aIntTag) const
|
||||
return str_ptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIAtom *)
|
||||
COtherDTD::IntTagToAtom(PRInt32 aIntTag) const
|
||||
{
|
||||
nsIAtom *atom = nsHTMLTags::GetAtom((nsHTMLTag)aIntTag);
|
||||
|
||||
NS_ASSERTION(atom, "Bad tag enum passed to COtherDTD::IntTagToAtom()"
|
||||
"!!");
|
||||
|
||||
return atom;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to determine whether or not
|
||||
* the given childtag is a block element.
|
||||
|
@ -1196,4 +1196,10 @@ nsExpatDriver::IntTagToStringTag(PRInt32 aIntTag) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIAtom *)
|
||||
nsExpatDriver::IntTagToAtom(PRInt32 aIntTag) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "plhash.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStaticAtom.h"
|
||||
|
||||
// C++ sucks! There's no way to do this with a macro, at least not
|
||||
// that I know, if you know how to do this with a macro then please do
|
||||
@ -275,19 +276,17 @@ static const PRUnichar* const kTagUnicodeTable[] = {
|
||||
#include "nsHTMLTagList.h"
|
||||
};
|
||||
#undef HTML_TAG
|
||||
#undef HTML_OTHER
|
||||
|
||||
// static array of tag atoms
|
||||
static nsIAtom* kTagAtomTable[eHTMLTag_userdefined - 1];
|
||||
|
||||
#ifdef DEBUG
|
||||
// static array of ASCII tag names for debugging purposes
|
||||
#define HTML_TAG(_tag, _classname) #_tag,
|
||||
#define HTML_OTHER(_tag, _classname)
|
||||
static const char* const kTagASCIIDebugTable[] = {
|
||||
// static array of tag StaticAtom structs
|
||||
#define HTML_TAG(_tag, _classname) { #_tag, &kTagAtomTable[eHTMLTag_##_tag - 1] },
|
||||
static const nsStaticAtom kTagAtoms_info[] = {
|
||||
#include "nsHTMLTagList.h"
|
||||
};
|
||||
#undef HTML_TAG
|
||||
#undef HTML_OTHER
|
||||
#endif
|
||||
|
||||
static PRInt32 gTableRefCount;
|
||||
static PLHashTable* gTagTable;
|
||||
@ -345,12 +344,15 @@ nsHTMLTags::AddRefTable(void)
|
||||
NS_ASSERTION(sMaxTagNameLength == NS_HTMLTAG_NAME_MAX_LENGTH,
|
||||
"NS_HTMLTAG_NAME_MAX_LENGTH not set correctly!");
|
||||
|
||||
// Fill in our static atom pointers
|
||||
NS_RegisterStaticAtoms(kTagAtoms_info, NS_ARRAY_LENGTH(kTagAtoms_info));
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
// let's verify that all names in the the table are lowercase...
|
||||
for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
|
||||
nsCAutoString temp1(kTagASCIIDebugTable[i]);
|
||||
nsCAutoString temp2(kTagASCIIDebugTable[i]);
|
||||
nsCAutoString temp1(kTagAtoms_info[i].mString);
|
||||
nsCAutoString temp2(kTagAtoms_info[i].mString);
|
||||
ToLowerCase(temp1);
|
||||
NS_ASSERTION(temp1.Equals(temp2), "upper case char in table");
|
||||
}
|
||||
@ -359,7 +361,7 @@ nsHTMLTags::AddRefTable(void)
|
||||
// correct.
|
||||
for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
|
||||
nsAutoString temp1(kTagUnicodeTable[i]);
|
||||
nsAutoString temp2; temp2.AssignWithConversion(kTagASCIIDebugTable[i]);
|
||||
nsAutoString temp2; temp2.AssignWithConversion(kTagAtoms_info[i].mString);
|
||||
NS_ASSERTION(temp1.Equals(temp2), "Bad unicode tag name!");
|
||||
}
|
||||
}
|
||||
@ -473,6 +475,17 @@ nsHTMLTags::GetStringValue(nsHTMLTag aEnum)
|
||||
return kTagUnicodeTable[aEnum - 1];
|
||||
}
|
||||
|
||||
// static
|
||||
nsIAtom *
|
||||
nsHTMLTags::GetAtom(nsHTMLTag aEnum)
|
||||
{
|
||||
if (aEnum <= eHTMLTag_unknown || aEnum > NS_HTML_TAG_MAX) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return kTagAtomTable[aEnum - 1];
|
||||
}
|
||||
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
||||
|
@ -903,6 +903,17 @@ CViewSourceHTML::IntTagToStringTag(PRInt32 aIntTag) const
|
||||
return str_ptr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsIAtom *)
|
||||
CViewSourceHTML::IntTagToAtom(PRInt32 aIntTag) const
|
||||
{
|
||||
nsIAtom *atom = nsHTMLTags::GetAtom((nsHTMLTag)aIntTag);
|
||||
|
||||
NS_ASSERTION(atom, "Bad tag enum passed to COtherDTD::IntTagToAtom()"
|
||||
"!!");
|
||||
|
||||
return atom;
|
||||
}
|
||||
|
||||
PRBool CViewSourceHTML::IsBlockElement(PRInt32 aTagID,PRInt32 aParentID) const {
|
||||
PRBool result=PR_FALSE;
|
||||
return result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user