зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 286300 (Clean up HTML tags enum and related code). r=mrbkap, sr=bz, a=asa.
This commit is contained in:
Родитель
555cc2a1f9
Коммит
ea82f1a8a5
|
@ -216,11 +216,8 @@ mozSanitizingHTMLSerializer::GetIdForContent(nsIContent* aContent)
|
||||||
|
|
||||||
nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef();
|
nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef();
|
||||||
|
|
||||||
PRInt32 id;
|
return parserService ? parserService->HTMLAtomTagToId(aContent->Tag()) :
|
||||||
nsresult rv = parserService->HTMLAtomTagToId(aContent->Tag(), &id);
|
eHTMLTag_unknown;
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't map HTML tag to id!");
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -474,8 +471,7 @@ mozSanitizingHTMLSerializer::DoOpenContainer(PRInt32 aTag)
|
||||||
nsContentUtils::GetParserServiceWeakRef();
|
nsContentUtils::GetParserServiceWeakRef();
|
||||||
if (!parserService)
|
if (!parserService)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
const PRUnichar* tag_name;
|
const PRUnichar* tag_name = parserService->HTMLIdToStringTag(aTag);
|
||||||
parserService->HTMLIdToStringTag(aTag, &tag_name);
|
|
||||||
NS_ENSURE_TRUE(tag_name, NS_ERROR_INVALID_POINTER);
|
NS_ENSURE_TRUE(tag_name, NS_ERROR_INVALID_POINTER);
|
||||||
|
|
||||||
Write(NS_LITERAL_STRING("<") + nsDependentString(tag_name));
|
Write(NS_LITERAL_STRING("<") + nsDependentString(tag_name));
|
||||||
|
@ -522,8 +518,7 @@ mozSanitizingHTMLSerializer::DoCloseContainer(PRInt32 aTag)
|
||||||
nsContentUtils::GetParserServiceWeakRef();
|
nsContentUtils::GetParserServiceWeakRef();
|
||||||
if (!parserService)
|
if (!parserService)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
const PRUnichar* tag_name;
|
const PRUnichar* tag_name = parserService->HTMLIdToStringTag(aTag);
|
||||||
parserService->HTMLIdToStringTag(aTag, &tag_name);
|
|
||||||
NS_ENSURE_TRUE(tag_name, NS_ERROR_INVALID_POINTER);
|
NS_ENSURE_TRUE(tag_name, NS_ERROR_INVALID_POINTER);
|
||||||
|
|
||||||
Write(NS_LITERAL_STRING("</") + nsDependentString(tag_name)
|
Write(NS_LITERAL_STRING("</") + nsDependentString(tag_name)
|
||||||
|
@ -765,31 +760,29 @@ mozSanitizingHTMLSerializer::ParseTagPref(const nsCAutoString& tagpref)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
// Parsing tag
|
// Parsing tag
|
||||||
PRInt32 bracket = tagpref.Find("(");
|
PRInt32 bracket = tagpref.FindChar('(');
|
||||||
nsCAutoString tag = tagpref;
|
if (bracket == 0)
|
||||||
if (bracket != kNotFound)
|
|
||||||
tag.Truncate(bracket);
|
|
||||||
if (tag.Equals(""))
|
|
||||||
{
|
{
|
||||||
printf(" malformed pref: %s\n", tagpref.get());
|
printf(" malformed pref: %s\n", tagpref.get());
|
||||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsAutoString tag;
|
||||||
|
CopyUTF8toUTF16(StringHead(tagpref, bracket), tag);
|
||||||
|
|
||||||
// Create key
|
// Create key
|
||||||
NS_ConvertASCIItoUCS2 tag_widestr(tag);
|
PRInt32 tag_id = parserService->HTMLStringTagToId(tag);
|
||||||
PRInt32 tag_id;
|
if (tag_id == eHTMLTag_userdefined)
|
||||||
parserService->HTMLStringTagToId(tag_widestr, &tag_id);
|
|
||||||
if (tag_id == eHTMLTag_userdefined ||
|
|
||||||
tag_id == eHTMLTag_unknown)
|
|
||||||
{
|
{
|
||||||
printf(" unknown tag <%s>, won't add.\n", tag.get());
|
printf(" unknown tag <%s>, won't add.\n",
|
||||||
|
NS_ConvertUTF16toUTF8(tag).get());
|
||||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||||
}
|
}
|
||||||
nsPRUint32Key tag_key(tag_id);
|
nsPRUint32Key tag_key(tag_id);
|
||||||
|
|
||||||
if (mAllowedTags.Exists(&tag_key))
|
if (mAllowedTags.Exists(&tag_key))
|
||||||
{
|
{
|
||||||
printf(" duplicate tag: %s\n", tag.get());
|
printf(" duplicate tag: %s\n", NS_ConvertUTF16toUTF8(tag).get());
|
||||||
return NS_ERROR_CANNOT_CONVERT_DATA;
|
return NS_ERROR_CANNOT_CONVERT_DATA;
|
||||||
}
|
}
|
||||||
if (bracket == kNotFound)
|
if (bracket == kNotFound)
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
#include "nsIAtom.h"
|
#include "nsIAtom.h"
|
||||||
#include "nsIDocumentEncoder.h"
|
#include "nsIDocumentEncoder.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
#include "nsIParser.h"
|
||||||
|
|
||||||
class mozSanitizingHTMLSerializer : public nsIContentSerializer,
|
class mozSanitizingHTMLSerializer : public nsIContentSerializer,
|
||||||
public nsIHTMLContentSink,
|
public nsIHTMLContentSink,
|
||||||
|
|
|
@ -131,6 +131,8 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
|
||||||
#include "nsILink.h"
|
#include "nsILink.h"
|
||||||
|
|
||||||
#include "nsICharsetAlias.h"
|
#include "nsICharsetAlias.h"
|
||||||
|
#include "nsIParser.h"
|
||||||
|
|
||||||
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
|
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
|
||||||
|
|
||||||
// Helper structs for the content->subdoc map
|
// Helper structs for the content->subdoc map
|
||||||
|
|
|
@ -1465,11 +1465,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, PRInt32
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
|
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
|
||||||
if (content)
|
if (content)
|
||||||
{
|
{
|
||||||
PRInt32 id;
|
|
||||||
parserService->HTMLAtomTagToId(content->Tag(), &id);
|
|
||||||
|
|
||||||
PRBool isBlock = PR_FALSE;
|
PRBool isBlock = PR_FALSE;
|
||||||
parserService->IsBlock(id, isBlock);
|
parserService->IsBlock(parserService->HTMLAtomTagToId(content->Tag()), isBlock);
|
||||||
if (isBlock)
|
if (isBlock)
|
||||||
{
|
{
|
||||||
bResetPromotion = PR_FALSE;
|
bResetPromotion = PR_FALSE;
|
||||||
|
@ -1551,11 +1548,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, PRInt32
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
|
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
|
||||||
if (content)
|
if (content)
|
||||||
{
|
{
|
||||||
PRInt32 id;
|
|
||||||
parserService->HTMLAtomTagToId(content->Tag(), &id);
|
|
||||||
|
|
||||||
PRBool isBlock = PR_FALSE;
|
PRBool isBlock = PR_FALSE;
|
||||||
parserService->IsBlock(id, isBlock);
|
parserService->IsBlock(parserService->HTMLAtomTagToId(content->Tag()), isBlock);
|
||||||
if (isBlock)
|
if (isBlock)
|
||||||
{
|
{
|
||||||
bResetPromotion = PR_FALSE;
|
bResetPromotion = PR_FALSE;
|
||||||
|
|
|
@ -801,10 +801,9 @@ nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
||||||
|
|
||||||
if (parserService && (name != nsHTMLAtoms::style)) {
|
if (parserService && (name != nsHTMLAtoms::style)) {
|
||||||
PRBool isContainer;
|
PRBool isContainer;
|
||||||
PRInt32 id;
|
|
||||||
|
|
||||||
parserService->HTMLAtomTagToId(name, &id);
|
parserService->IsContainer(parserService->HTMLAtomTagToId(name),
|
||||||
parserService->IsContainer(id, isContainer);
|
isContainer);
|
||||||
if (!isContainer) return NS_OK;
|
if (!isContainer) return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,10 +1065,7 @@ nsHTMLContentSerializer::LineBreakBeforeOpen(nsIAtom* aName,
|
||||||
|
|
||||||
if (parserService) {
|
if (parserService) {
|
||||||
PRBool res;
|
PRBool res;
|
||||||
PRInt32 id;
|
parserService->IsBlock(parserService->HTMLAtomTagToId(aName), res);
|
||||||
|
|
||||||
parserService->HTMLAtomTagToId(aName, &id);
|
|
||||||
parserService->IsBlock(id, res);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1167,10 +1163,7 @@ nsHTMLContentSerializer::LineBreakAfterClose(nsIAtom* aName,
|
||||||
|
|
||||||
if (parserService) {
|
if (parserService) {
|
||||||
PRBool res;
|
PRBool res;
|
||||||
PRInt32 id;
|
parserService->IsBlock(parserService->HTMLAtomTagToId(aName), res);
|
||||||
|
|
||||||
parserService->HTMLAtomTagToId(aName, &id);
|
|
||||||
parserService->IsBlock(id, res);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1892,11 +1892,8 @@ nsPlainTextSerializer::GetIdForContent(nsIContent* aContent)
|
||||||
|
|
||||||
nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef();
|
nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef();
|
||||||
|
|
||||||
PRInt32 id;
|
return parserService ? parserService->HTMLAtomTagToId(aContent->Tag()) :
|
||||||
nsresult rv = parserService->HTMLAtomTagToId(aContent->Tag(), &id);
|
eHTMLTag_unknown;
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't map HTML tag to id!");
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -188,7 +188,7 @@ NS_NewHTMLNOTUSEDElement(nsINodeInfo *aNodeInfo, PRBool aFromParser)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HTML_TAG(_tag, _classname) NS_NewHTML##_classname##Element,
|
#define HTML_TAG(_tag, _classname) NS_NewHTML##_classname##Element,
|
||||||
#define HTML_OTHER(_tag, _classname) NS_NewHTML##_classname##Element,
|
#define HTML_OTHER(_tag) NS_NewHTMLNOTUSEDElement,
|
||||||
static const contentCreatorCallback sContentCreatorCallbacks[] = {
|
static const contentCreatorCallback sContentCreatorCallbacks[] = {
|
||||||
NS_NewHTMLUnknownElement,
|
NS_NewHTMLUnknownElement,
|
||||||
#include "nsHTMLTagList.h"
|
#include "nsHTMLTagList.h"
|
||||||
|
@ -757,16 +757,14 @@ HTMLContentSink::SinkTraceNode(PRUint32 aBit,
|
||||||
void* aThis)
|
void* aThis)
|
||||||
{
|
{
|
||||||
if (SINK_LOG_TEST(gSinkLogModuleInfo, aBit)) {
|
if (SINK_LOG_TEST(gSinkLogModuleInfo, aBit)) {
|
||||||
nsCOMPtr<nsIDTD> dtd;
|
nsIParserService *parserService =
|
||||||
if (mParser) {
|
nsContentUtils::GetParserServiceWeakRef();
|
||||||
mParser->GetDTD(getter_AddRefs(dtd));
|
if (!parserService)
|
||||||
if (!dtd)
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
const char* cp =
|
NS_ConvertUTF16toUTF8 tag(parserService->HTMLIdToStringTag(aTag));
|
||||||
NS_ConvertUCS2toUTF8(dtd->IntTagToStringTag(aTag)).get();
|
|
||||||
PR_LogPrint("%s: this=%p node='%s' stackPos=%d",
|
PR_LogPrint("%s: this=%p node='%s' stackPos=%d",
|
||||||
aMsg, aThis, cp, aStackPos);
|
aMsg, aThis, tag.get(), aStackPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -858,8 +856,6 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
|
||||||
nsGenericHTMLElement* aForm,
|
nsGenericHTMLElement* aForm,
|
||||||
nsIDocShell* aDocShell)
|
nsIDocShell* aDocShell)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
|
||||||
|
|
||||||
// Find/create atom for the tag name
|
// Find/create atom for the tag name
|
||||||
|
|
||||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||||
|
@ -869,19 +865,22 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
|
||||||
ToLowerCase(tmp);
|
ToLowerCase(tmp);
|
||||||
|
|
||||||
nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
|
nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
|
||||||
rv = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
|
mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
|
||||||
getter_AddRefs(nodeInfo));
|
getter_AddRefs(nodeInfo));
|
||||||
} else {
|
} else {
|
||||||
nsCOMPtr<nsIDTD> dtd;
|
nsIParserService *parserService =
|
||||||
rv = mParser->GetDTD(getter_AddRefs(dtd));
|
nsContentUtils::GetParserServiceWeakRef();
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (!parserService)
|
||||||
rv = mNodeInfoManager->GetNodeInfo(dtd->IntTagToAtom(aNodeType), nsnull,
|
return nsnull;
|
||||||
kNameSpaceID_None,
|
|
||||||
|
nsIAtom *name = parserService->HTMLIdToAtomTag(aNodeType);
|
||||||
|
NS_ASSERTION(name, "What? Reverse mapping of id to string broken!!!");
|
||||||
|
|
||||||
|
mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
|
||||||
getter_AddRefs(nodeInfo));
|
getter_AddRefs(nodeInfo));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
NS_ENSURE_TRUE(nodeInfo, nsnull);
|
||||||
|
|
||||||
// Make the content object
|
// Make the content object
|
||||||
nsGenericHTMLElement* result = MakeContentObject(aNodeType, nodeInfo, aForm,
|
nsGenericHTMLElement* result = MakeContentObject(aNodeType, nodeInfo, aForm,
|
||||||
|
@ -906,30 +905,17 @@ NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo)
|
||||||
|
|
||||||
nsIAtom *name = aNodeInfo->NameAtom();
|
nsIAtom *name = aNodeInfo->NameAtom();
|
||||||
|
|
||||||
PRInt32 id;
|
nsHTMLTag id;
|
||||||
nsRefPtr<nsGenericHTMLElement> result;
|
nsRefPtr<nsGenericHTMLElement> result;
|
||||||
if (aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) {
|
if (aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) {
|
||||||
// Find tag in tag table
|
// Find tag in tag table
|
||||||
parserService->HTMLCaseSensitiveAtomTagToId(name, &id);
|
id = nsHTMLTag(parserService->HTMLCaseSensitiveAtomTagToId(name));
|
||||||
|
|
||||||
// XXX Temporary fix for
|
result = MakeContentObject(id, aNodeInfo, nsnull, PR_FALSE, PR_FALSE);
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=285166
|
|
||||||
if (id > NS_HTML_TAG_MAX) {
|
|
||||||
id = eHTMLTag_userdefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = MakeContentObject(nsHTMLTag(id), aNodeInfo, nsnull,
|
|
||||||
PR_FALSE, PR_FALSE);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Find tag in tag table
|
// Find tag in tag table
|
||||||
parserService->HTMLAtomTagToId(name, &id);
|
id = nsHTMLTag(parserService->HTMLAtomTagToId(name));
|
||||||
|
|
||||||
// XXX Temporary fix for
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=285166
|
|
||||||
if (id > NS_HTML_TAG_MAX) {
|
|
||||||
id = eHTMLTag_userdefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reverse map id to name to get the correct character case in
|
// Reverse map id to name to get the correct character case in
|
||||||
// the tag name.
|
// the tag name.
|
||||||
|
@ -937,16 +923,13 @@ NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo)
|
||||||
nsCOMPtr<nsINodeInfo> kungFuDeathGrip;
|
nsCOMPtr<nsINodeInfo> kungFuDeathGrip;
|
||||||
nsINodeInfo *nodeInfo = aNodeInfo;
|
nsINodeInfo *nodeInfo = aNodeInfo;
|
||||||
|
|
||||||
if (nsHTMLTag(id) != eHTMLTag_userdefined) {
|
if (id != eHTMLTag_userdefined) {
|
||||||
const PRUnichar *tag = nsnull;
|
nsIAtom *tag = parserService->HTMLIdToAtomTag(id);
|
||||||
parserService->HTMLIdToStringTag(id, &tag);
|
|
||||||
NS_ASSERTION(tag, "What? Reverse mapping of id to string broken!!!");
|
NS_ASSERTION(tag, "What? Reverse mapping of id to string broken!!!");
|
||||||
|
|
||||||
if (!name->Equals(nsDependentString(tag))) {
|
if (name != tag) {
|
||||||
nsCOMPtr<nsIAtom> atom = do_GetAtom(tag);
|
|
||||||
|
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
nsContentUtils::NameChanged(aNodeInfo, atom,
|
nsContentUtils::NameChanged(aNodeInfo, tag,
|
||||||
getter_AddRefs(kungFuDeathGrip));
|
getter_AddRefs(kungFuDeathGrip));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
@ -954,8 +937,7 @@ NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = MakeContentObject(nsHTMLTag(id), nodeInfo, nsnull,
|
result = MakeContentObject(id, nodeInfo, nsnull, PR_FALSE, PR_FALSE);
|
||||||
PR_FALSE, PR_FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result ? CallQueryInterface(result.get(), aResult)
|
return result ? CallQueryInterface(result.get(), aResult)
|
||||||
|
@ -1125,16 +1107,18 @@ SinkContext::DidAddContent(nsIContent* aContent, PRBool aDidNotify)
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
// Tracing code
|
// Tracing code
|
||||||
nsCOMPtr<nsIDTD> dtd;
|
nsIParserService *parserService =
|
||||||
mSink->mParser->GetDTD(getter_AddRefs(dtd));
|
nsContentUtils::GetParserServiceWeakRef();
|
||||||
|
if (parserService) {
|
||||||
nsHTMLTag tag = nsHTMLTag(mStack[mStackPos - 1].mType);
|
nsHTMLTag tag = nsHTMLTag(mStack[mStackPos - 1].mType);
|
||||||
nsDependentString str(dtd->IntTagToStringTag(tag));
|
NS_ConvertUTF16toUTF8 str(parserService->HTMLIdToStringTag(tag));
|
||||||
|
|
||||||
SINK_TRACE(SINK_TRACE_REFLOW,
|
SINK_TRACE(SINK_TRACE_REFLOW,
|
||||||
("SinkContext::DidAddContent: Insertion notification for "
|
("SinkContext::DidAddContent: Insertion notification for "
|
||||||
"parent=%s at position=%d and stackPos=%d",
|
"parent=%s at position=%d and stackPos=%d",
|
||||||
NS_LossyConvertUCS2toASCII(str).get(),
|
str.get(), mStack[mStackPos - 1].mInsertionPoint - 1,
|
||||||
mStack[mStackPos - 1].mInsertionPoint - 1, mStackPos - 1));
|
mStackPos - 1));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mSink->NotifyInsert(parent, aContent,
|
mSink->NotifyInsert(parent, aContent,
|
||||||
|
|
|
@ -3079,18 +3079,15 @@ nsHTMLDocument::RemoveFromIdTable(nsIContent *aContent)
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLDocument::UnregisterNamedItems(nsIContent *aContent)
|
nsHTMLDocument::UnregisterNamedItems(nsIContent *aContent)
|
||||||
{
|
{
|
||||||
nsIAtom *tag = aContent->Tag();
|
if (aContent->IsContentOfType(nsIContent::eTEXT)) {
|
||||||
|
|
||||||
if (tag == nsLayoutAtoms::textTagName) {
|
|
||||||
// Text nodes are not named items nor can they have children.
|
// Text nodes are not named items nor can they have children.
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoString value;
|
nsAutoString value;
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
if (!IsXHTML() && IsNamedItem(aContent, tag, value)) {
|
if (!IsXHTML() && IsNamedItem(aContent, aContent->Tag(), value)) {
|
||||||
rv = RemoveFromNameTable(value, aContent);
|
rv = RemoveFromNameTable(value, aContent);
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
@ -3116,17 +3113,14 @@ nsHTMLDocument::UnregisterNamedItems(nsIContent *aContent)
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLDocument::RegisterNamedItems(nsIContent *aContent)
|
nsHTMLDocument::RegisterNamedItems(nsIContent *aContent)
|
||||||
{
|
{
|
||||||
nsIAtom *tag = aContent->Tag();
|
if (aContent->IsContentOfType(nsIContent::eTEXT)) {
|
||||||
|
|
||||||
if (tag == nsLayoutAtoms::textTagName) {
|
|
||||||
// Text nodes are not named items nor can they have children.
|
// Text nodes are not named items nor can they have children.
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoString value;
|
nsAutoString value;
|
||||||
|
|
||||||
if (!IsXHTML() && IsNamedItem(aContent, tag, value)) {
|
if (!IsXHTML() && IsNamedItem(aContent, aContent->Tag(), value)) {
|
||||||
UpdateNameTableEntry(value, aContent);
|
UpdateNameTableEntry(value, aContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3162,15 +3156,15 @@ FindNamedItems(const nsAString& aName, nsIContent *aContent,
|
||||||
|
|
||||||
nsIAtom *tag = aContent->Tag();
|
nsIAtom *tag = aContent->Tag();
|
||||||
|
|
||||||
if (tag == nsLayoutAtoms::textTagName) {
|
if (aContent->IsContentOfType(nsIContent::eTEXT)) {
|
||||||
// Text nodes are not named items nor can they have children.
|
// Text nodes are not named items nor can they have children.
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAutoString value;
|
nsAutoString value;
|
||||||
|
|
||||||
if (!aIsXHTML && IsNamedItem(aContent, tag, value) && value.Equals(aName)) {
|
if (!aIsXHTML && IsNamedItem(aContent, aContent->Tag(), value) &&
|
||||||
|
value.Equals(aName)) {
|
||||||
aEntry.mContentList->AppendElement(aContent);
|
aEntry.mContentList->AppendElement(aContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -462,14 +462,10 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
|
||||||
if (!parserService)
|
if (!parserService)
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
const PRUnichar *name = nsnull;
|
nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
|
||||||
|
|
||||||
parserService->HTMLIdToStringTag(nodeType, &name);
|
|
||||||
NS_ASSERTION(name, "This should not happen!");
|
NS_ASSERTION(name, "This should not happen!");
|
||||||
|
|
||||||
result =
|
result = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
|
||||||
mNodeInfoManager->GetNodeInfo(nsDependentString(name), nsnull,
|
|
||||||
kNameSpaceID_None,
|
|
||||||
getter_AddRefs(nodeInfo));
|
getter_AddRefs(nodeInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,12 +561,10 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
|
||||||
kNameSpaceID_None,
|
kNameSpaceID_None,
|
||||||
getter_AddRefs(nodeInfo));
|
getter_AddRefs(nodeInfo));
|
||||||
} else {
|
} else {
|
||||||
const PRUnichar *name = nsnull;
|
nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
|
||||||
result = parserService->HTMLIdToStringTag(nodeType, &name);
|
|
||||||
NS_ASSERTION(name, "This should not happen!");
|
NS_ASSERTION(name, "This should not happen!");
|
||||||
|
|
||||||
result =
|
result = mNodeInfoManager->GetNodeInfo(name, nsnull,
|
||||||
mNodeInfoManager->GetNodeInfo(nsDependentString(name), nsnull,
|
|
||||||
kNameSpaceID_None,
|
kNameSpaceID_None,
|
||||||
getter_AddRefs(nodeInfo));
|
getter_AddRefs(nodeInfo));
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ NS_IMPL_RELEASE_INHERITED(nsXMLCDATASection, nsGenericDOMDataNode)
|
||||||
nsIAtom *
|
nsIAtom *
|
||||||
nsXMLCDATASection::Tag() const
|
nsXMLCDATASection::Tag() const
|
||||||
{
|
{
|
||||||
return nsLayoutAtoms::textTagName;
|
return nsLayoutAtoms::cdataTagName;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
PRBool
|
||||||
|
|
|
@ -665,7 +665,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||||
// first element we've generated?
|
// first element we've generated?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tag == nsLayoutAtoms::textTagName) {
|
else if (tmplKid->IsContentOfType(nsIContent::eTEXT)) {
|
||||||
nsCOMPtr<nsIDOMNode> tmplTextNode = do_QueryInterface(tmplKid);
|
nsCOMPtr<nsIDOMNode> tmplTextNode = do_QueryInterface(tmplKid);
|
||||||
if (!tmplTextNode) {
|
if (!tmplTextNode) {
|
||||||
NS_ERROR("textnode not implementing nsIDOMNode??");
|
NS_ERROR("textnode not implementing nsIDOMNode??");
|
||||||
|
|
|
@ -113,6 +113,7 @@
|
||||||
#include "nsIInlineSpellChecker.h"
|
#include "nsIInlineSpellChecker.h"
|
||||||
#include "nsINameSpaceManager.h"
|
#include "nsINameSpaceManager.h"
|
||||||
#include "nsIHTMLDocument.h"
|
#include "nsIHTMLDocument.h"
|
||||||
|
#include "nsIParserService.h"
|
||||||
|
|
||||||
#define NS_ERROR_EDITOR_NO_SELECTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,1)
|
#define NS_ERROR_EDITOR_NO_SELECTION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,1)
|
||||||
#define NS_ERROR_EDITOR_NO_TEXTNODE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,2)
|
#define NS_ERROR_EDITOR_NO_TEXTNODE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,2)
|
||||||
|
@ -122,13 +123,13 @@ static PRBool gNoisy = PR_FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
PRInt32 nsEditor::gInstanceCount = 0;
|
|
||||||
|
|
||||||
// Value of "ime.password.onFocus.dontCare"
|
// Value of "ime.password.onFocus.dontCare"
|
||||||
static PRBool gDontCareForIMEOnFocusPassword = PR_FALSE;
|
static PRBool gDontCareForIMEOnFocusPassword = PR_FALSE;
|
||||||
// Value of "ime.password.onBlur.dontCare"
|
// Value of "ime.password.onBlur.dontCare"
|
||||||
static PRBool gDontCareForIMEOnBlurPassword = PR_FALSE;
|
static PRBool gDontCareForIMEOnBlurPassword = PR_FALSE;
|
||||||
|
|
||||||
|
nsIParserService* nsEditor::sParserService;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// nsEditor: base editor class implementation
|
// nsEditor: base editor class implementation
|
||||||
|
@ -168,9 +169,6 @@ nsEditor::nsEditor()
|
||||||
, mPhonetic(nsnull)
|
, mPhonetic(nsnull)
|
||||||
{
|
{
|
||||||
//initialize member variables here
|
//initialize member variables here
|
||||||
|
|
||||||
PR_AtomicIncrement(&gInstanceCount);
|
|
||||||
|
|
||||||
if (!gTypingTxnName)
|
if (!gTypingTxnName)
|
||||||
gTypingTxnName = NS_NewAtom("Typing");
|
gTypingTxnName = NS_NewAtom("Typing");
|
||||||
else
|
else
|
||||||
|
@ -249,11 +247,23 @@ nsEditor::~nsEditor()
|
||||||
|
|
||||||
delete mPhonetic;
|
delete mPhonetic;
|
||||||
|
|
||||||
PR_AtomicDecrement(&gInstanceCount);
|
|
||||||
|
|
||||||
NS_IF_RELEASE(mViewManager);
|
NS_IF_RELEASE(mViewManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
nsresult
|
||||||
|
nsEditor::Init()
|
||||||
|
{
|
||||||
|
return CallGetService("@mozilla.org/parser/parser-service;1",
|
||||||
|
&sParserService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
void
|
||||||
|
nsEditor::Shutdown()
|
||||||
|
{
|
||||||
|
NS_IF_RELEASE(sParserService);
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS4(nsEditor, nsIEditor, nsIEditorIMESupport, nsISupportsWeakReference, nsIPhonetic)
|
NS_IMPL_ISUPPORTS4(nsEditor, nsIEditor, nsIEditorIMESupport, nsISupportsWeakReference, nsIPhonetic)
|
||||||
|
|
||||||
|
@ -3833,7 +3843,7 @@ nsEditor::TagCanContain(const nsAString &aParentTag, nsIDOMNode* aChild)
|
||||||
|
|
||||||
if (IsTextNode(aChild))
|
if (IsTextNode(aChild))
|
||||||
{
|
{
|
||||||
childStringTag.AssignLiteral("__moz_text");
|
childStringTag.AssignLiteral("#text");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3850,13 +3860,18 @@ nsEditor::TagCanContainTag(const nsAString &aParentTag, const nsAString &aChildT
|
||||||
// if we don't have a dtd then assume we can insert whatever want
|
// if we don't have a dtd then assume we can insert whatever want
|
||||||
if (!mDTD) return PR_TRUE;
|
if (!mDTD) return PR_TRUE;
|
||||||
|
|
||||||
PRInt32 childTagEnum, parentTagEnum;
|
PRInt32 childTagEnum;
|
||||||
nsAutoString non_const_childTag(aChildTag);
|
// XXX Should this handle #cdata-section too?
|
||||||
nsresult res = mDTD->StringTagToIntTag(non_const_childTag,&childTagEnum);
|
if (aChildTag.EqualsLiteral("#text")) {
|
||||||
if (NS_FAILED(res)) return PR_FALSE;
|
childTagEnum = eHTMLTag_text;
|
||||||
nsAutoString non_const_parentTag(aParentTag);
|
}
|
||||||
res = mDTD->StringTagToIntTag(non_const_parentTag,&parentTagEnum);
|
else {
|
||||||
if (NS_FAILED(res)) return PR_FALSE;
|
childTagEnum = sParserService->HTMLStringTagToId(aChildTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRInt32 parentTagEnum = sParserService->HTMLStringTagToId(aParentTag);
|
||||||
|
NS_ASSERTION(parentTagEnum < NS_HTML_TAG_MAX,
|
||||||
|
"Fix the caller, this type of node can never contain children.");
|
||||||
|
|
||||||
return mDTD->CanContain(parentTagEnum, childTagEnum);
|
return mDTD->CanContain(parentTagEnum, childTagEnum);
|
||||||
}
|
}
|
||||||
|
@ -3901,11 +3916,10 @@ nsEditor::IsContainer(nsIDOMNode *aNode)
|
||||||
{
|
{
|
||||||
if (!aNode) return PR_FALSE;
|
if (!aNode) return PR_FALSE;
|
||||||
nsAutoString stringTag;
|
nsAutoString stringTag;
|
||||||
PRInt32 tagEnum;
|
|
||||||
nsresult res = aNode->GetNodeName(stringTag);
|
nsresult res = aNode->GetNodeName(stringTag);
|
||||||
if (NS_FAILED(res)) return PR_FALSE;
|
if (NS_FAILED(res)) return PR_FALSE;
|
||||||
res = mDTD->StringTagToIntTag(stringTag,&tagEnum);
|
PRInt32 tagEnum = sParserService->HTMLStringTagToId(stringTag);
|
||||||
if (NS_FAILED(res)) return PR_FALSE;
|
|
||||||
return mDTD->IsContainer(tagEnum);
|
return mDTD->IsContainer(tagEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ class RemoveStyleSheetTxn;
|
||||||
class nsIFile;
|
class nsIFile;
|
||||||
class nsISelectionController;
|
class nsISelectionController;
|
||||||
class nsIDOMEventReceiver;
|
class nsIDOMEventReceiver;
|
||||||
|
class nsIParserService;
|
||||||
|
|
||||||
#define kMOZEditorBogusNodeAttr NS_LITERAL_STRING("_moz_editor_bogus_node")
|
#define kMOZEditorBogusNodeAttr NS_LITERAL_STRING("_moz_editor_bogus_node")
|
||||||
#define kMOZEditorBogusNodeValue NS_LITERAL_STRING("TRUE")
|
#define kMOZEditorBogusNodeValue NS_LITERAL_STRING("TRUE")
|
||||||
|
@ -136,6 +137,9 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual ~nsEditor();
|
virtual ~nsEditor();
|
||||||
|
|
||||||
|
static nsresult Init();
|
||||||
|
static void Shutdown();
|
||||||
|
|
||||||
//Interfaces for addref and release and queryinterface
|
//Interfaces for addref and release and queryinterface
|
||||||
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
|
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
@ -637,7 +641,7 @@ protected:
|
||||||
nsCOMPtr<nsIDOMEventListener> mDragListenerP;
|
nsCOMPtr<nsIDOMEventListener> mDragListenerP;
|
||||||
nsCOMPtr<nsIDOMEventListener> mFocusListenerP;
|
nsCOMPtr<nsIDOMEventListener> mFocusListenerP;
|
||||||
|
|
||||||
static PRInt32 gInstanceCount;
|
static nsIParserService *sParserService;
|
||||||
|
|
||||||
friend PRBool NSCanUnload(nsISupports* serviceMgr);
|
friend PRBool NSCanUnload(nsISupports* serviceMgr);
|
||||||
friend class nsAutoTxnsConserveSelection;
|
friend class nsAutoTxnsConserveSelection;
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
#include "nsIGenericFactory.h"
|
#include "nsIGenericFactory.h"
|
||||||
#include "nsEditorCID.h"
|
#include "nsEditorCID.h"
|
||||||
#include "nsEditor.h" // for gInstanceCount
|
#include "nsEditor.h"
|
||||||
#include "nsPlaintextEditor.h"
|
#include "nsPlaintextEditor.h"
|
||||||
#include "nsEditorController.h" //CID
|
#include "nsEditorController.h" //CID
|
||||||
#include "nsIController.h"
|
#include "nsIController.h"
|
||||||
|
@ -95,6 +95,12 @@ Initialize(nsIModule* self)
|
||||||
|
|
||||||
gInitialized = PR_TRUE;
|
gInitialized = PR_TRUE;
|
||||||
|
|
||||||
|
nsresult rv = nsEditor::Init();
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
gInitialized = PR_FALSE;
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
||||||
nsEditProperty::RegisterAtoms();
|
nsEditProperty::RegisterAtoms();
|
||||||
nsTextServicesDocument::RegisterAtoms();
|
nsTextServicesDocument::RegisterAtoms();
|
||||||
|
@ -130,6 +136,7 @@ Shutdown()
|
||||||
if (!gInitialized)
|
if (!gInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
nsEditor::Shutdown();
|
||||||
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
||||||
nsHTMLEditor::Shutdown();
|
nsHTMLEditor::Shutdown();
|
||||||
nsTextServicesDocument::Shutdown();
|
nsTextServicesDocument::Shutdown();
|
||||||
|
|
|
@ -157,7 +157,8 @@ nsresult TextEditorTest::TestTextProperties()
|
||||||
TEST_RESULT(result);
|
TEST_RESULT(result);
|
||||||
TEST_POINTER(doc.get());
|
TEST_POINTER(doc.get());
|
||||||
nsCOMPtr<nsIDOMNodeList>nodeList;
|
nsCOMPtr<nsIDOMNodeList>nodeList;
|
||||||
nsAutoString textTag(NS_LITERAL_STRING("__moz_text"));
|
// XXX This is broken, text nodes are not elements.
|
||||||
|
nsAutoString textTag(NS_LITERAL_STRING("#text"));
|
||||||
result = doc->GetElementsByTagName(textTag, getter_AddRefs(nodeList));
|
result = doc->GetElementsByTagName(textTag, getter_AddRefs(nodeList));
|
||||||
TEST_RESULT(result);
|
TEST_RESULT(result);
|
||||||
TEST_POINTER(nodeList.get());
|
TEST_POINTER(nodeList.get());
|
||||||
|
|
|
@ -1323,7 +1323,8 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
|
|
||||||
// dont put text in places that cant have it
|
// dont put text in places that cant have it
|
||||||
if (!mHTMLEditor->IsTextNode(selNode) && !mHTMLEditor->CanContainTag(selNode, NS_LITERAL_STRING("__moz_text")))
|
if (!mHTMLEditor->IsTextNode(selNode) &&
|
||||||
|
!mHTMLEditor->CanContainTag(selNode, NS_LITERAL_STRING("#text")))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// we need to get the doc
|
// we need to get the doc
|
||||||
|
|
|
@ -130,6 +130,7 @@
|
||||||
#include "nsIFrame.h"
|
#include "nsIFrame.h"
|
||||||
#include "nsIView.h"
|
#include "nsIView.h"
|
||||||
#include "nsIWidget.h"
|
#include "nsIWidget.h"
|
||||||
|
#include "nsIParserService.h"
|
||||||
|
|
||||||
static NS_DEFINE_CID(kCTransitionalDTDCID, NS_CTRANSITIONAL_DTD_CID);
|
static NS_DEFINE_CID(kCTransitionalDTDCID, NS_CTRANSITIONAL_DTD_CID);
|
||||||
|
|
||||||
|
@ -138,7 +139,6 @@ static char hrefText[] = "href";
|
||||||
static char anchorTxt[] = "anchor";
|
static char anchorTxt[] = "anchor";
|
||||||
static char namedanchorText[] = "namedanchor";
|
static char namedanchorText[] = "namedanchor";
|
||||||
|
|
||||||
nsIParserService* nsHTMLEditor::sParserService;
|
|
||||||
nsIRangeUtils* nsHTMLEditor::sRangeHelper;
|
nsIRangeUtils* nsHTMLEditor::sRangeHelper;
|
||||||
|
|
||||||
// some prototypes for rules creation shortcuts
|
// some prototypes for rules creation shortcuts
|
||||||
|
@ -231,7 +231,6 @@ nsHTMLEditor::~nsHTMLEditor()
|
||||||
void
|
void
|
||||||
nsHTMLEditor::Shutdown()
|
nsHTMLEditor::Shutdown()
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE(sParserService);
|
|
||||||
NS_IF_RELEASE(sRangeHelper);
|
NS_IF_RELEASE(sRangeHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,11 +543,6 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock)
|
||||||
nsIAtom *tagAtom = GetTag(aNode);
|
nsIAtom *tagAtom = GetTag(aNode);
|
||||||
if (!tagAtom) return NS_ERROR_NULL_POINTER;
|
if (!tagAtom) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
if (!sParserService) {
|
|
||||||
rv = CallGetService("@mozilla.org/parser/parser-service;1", &sParserService);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nodes we know we want to treat as block
|
// Nodes we know we want to treat as block
|
||||||
// even though the parser says they're not:
|
// even though the parser says they're not:
|
||||||
if (tagAtom==nsEditProperty::body ||
|
if (tagAtom==nsEditProperty::body ||
|
||||||
|
@ -568,10 +562,8 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt32 id;
|
rv = sParserService->IsBlock(sParserService->HTMLAtomTagToId(tagAtom),
|
||||||
rv = sParserService->HTMLAtomTagToId(tagAtom, &id);
|
*aIsBlock);
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
rv = sParserService->IsBlock(id, *aIsBlock);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Check this against what we would have said with the old code:
|
// Check this against what we would have said with the old code:
|
||||||
|
@ -4283,15 +4275,12 @@ nsHTMLEditor::TagCanContainTag(const nsAString& aParentTag, const nsAString& aCh
|
||||||
// if parent is a pre, and child is not inline, say "no"
|
// if parent is a pre, and child is not inline, say "no"
|
||||||
if ( aParentTag.EqualsLiteral("pre") )
|
if ( aParentTag.EqualsLiteral("pre") )
|
||||||
{
|
{
|
||||||
if (aChildTag.EqualsLiteral("__moz_text"))
|
if (aChildTag.EqualsLiteral("#text"))
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
PRInt32 childTagEnum, parentTagEnum;
|
|
||||||
nsAutoString non_const_childTag(aChildTag);
|
PRInt32 childTagEnum = sParserService->HTMLStringTagToId(aChildTag);
|
||||||
nsAutoString non_const_parentTag(aParentTag);
|
PRInt32 parentTagEnum = sParserService->HTMLStringTagToId(aParentTag);
|
||||||
nsresult res = mDTD->StringTagToIntTag(non_const_childTag,&childTagEnum);
|
|
||||||
if (NS_FAILED(res)) return PR_FALSE;
|
|
||||||
res = mDTD->StringTagToIntTag(non_const_parentTag,&parentTagEnum);
|
|
||||||
if (NS_FAILED(res)) return PR_FALSE;
|
|
||||||
if (!mDTD->IsInlineElement(childTagEnum, parentTagEnum))
|
if (!mDTD->IsInlineElement(childTagEnum, parentTagEnum))
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
|
|
||||||
#include "nsEditProperty.h"
|
#include "nsEditProperty.h"
|
||||||
#include "nsHTMLCSSUtils.h"
|
#include "nsHTMLCSSUtils.h"
|
||||||
#include "nsIParserService.h"
|
|
||||||
|
|
||||||
#include "nsVoidArray.h"
|
#include "nsVoidArray.h"
|
||||||
|
|
||||||
|
@ -782,9 +781,6 @@ protected:
|
||||||
// for real-time spelling
|
// for real-time spelling
|
||||||
nsCOMPtr<nsITextServicesDocument> mTextServices;
|
nsCOMPtr<nsITextServicesDocument> mTextServices;
|
||||||
|
|
||||||
// Maintain a static parser service ...
|
|
||||||
static nsIParserService* sParserService;
|
|
||||||
|
|
||||||
// And a static range utils service
|
// And a static range utils service
|
||||||
static nsIRangeUtils* sRangeHelper;
|
static nsIRangeUtils* sRangeHelper;
|
||||||
|
|
||||||
|
|
|
@ -629,7 +629,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
|
|
||||||
// don't put text in places that can't have it
|
// don't put text in places that can't have it
|
||||||
if (!mEditor->IsTextNode(selNode) && !mEditor->CanContainTag(selNode, NS_LITERAL_STRING("__moz_text")))
|
if (!mEditor->IsTextNode(selNode) && !mEditor->CanContainTag(selNode, NS_LITERAL_STRING("#text")))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// we need to get the doc
|
// we need to get the doc
|
||||||
|
|
|
@ -447,10 +447,8 @@ NS_NewFindContentIterator(PRBool aFindBackward,
|
||||||
|
|
||||||
// Sure would be nice if we could just get these from somewhere else!
|
// Sure would be nice if we could just get these from somewhere else!
|
||||||
PRInt32 nsFind::sInstanceCount = 0;
|
PRInt32 nsFind::sInstanceCount = 0;
|
||||||
nsIAtom* nsFind::sTextAtom = nsnull;
|
|
||||||
nsIAtom* nsFind::sImgAtom = nsnull;
|
nsIAtom* nsFind::sImgAtom = nsnull;
|
||||||
nsIAtom* nsFind::sHRAtom = nsnull;
|
nsIAtom* nsFind::sHRAtom = nsnull;
|
||||||
nsIAtom* nsFind::sCommentAtom = nsnull;
|
|
||||||
nsIAtom* nsFind::sScriptAtom = nsnull;
|
nsIAtom* nsFind::sScriptAtom = nsnull;
|
||||||
nsIAtom* nsFind::sNoframesAtom = nsnull;
|
nsIAtom* nsFind::sNoframesAtom = nsnull;
|
||||||
nsIAtom* nsFind::sSelectAtom = nsnull;
|
nsIAtom* nsFind::sSelectAtom = nsnull;
|
||||||
|
@ -468,10 +466,8 @@ nsFind::nsFind()
|
||||||
// Initialize the atoms if they aren't already:
|
// Initialize the atoms if they aren't already:
|
||||||
if (sInstanceCount <= 0)
|
if (sInstanceCount <= 0)
|
||||||
{
|
{
|
||||||
sTextAtom = NS_NewAtom("__moz_text");
|
|
||||||
sImgAtom = NS_NewAtom("img");
|
sImgAtom = NS_NewAtom("img");
|
||||||
sHRAtom = NS_NewAtom("hr");
|
sHRAtom = NS_NewAtom("hr");
|
||||||
sCommentAtom = NS_NewAtom("__moz_comment");
|
|
||||||
sScriptAtom = NS_NewAtom("script");
|
sScriptAtom = NS_NewAtom("script");
|
||||||
sNoframesAtom = NS_NewAtom("noframes");
|
sNoframesAtom = NS_NewAtom("noframes");
|
||||||
sSelectAtom = NS_NewAtom("select");
|
sSelectAtom = NS_NewAtom("select");
|
||||||
|
@ -486,10 +482,8 @@ nsFind::~nsFind()
|
||||||
{
|
{
|
||||||
if (sInstanceCount <= 1)
|
if (sInstanceCount <= 1)
|
||||||
{
|
{
|
||||||
NS_IF_RELEASE(sTextAtom);
|
|
||||||
NS_IF_RELEASE(sImgAtom);
|
NS_IF_RELEASE(sImgAtom);
|
||||||
NS_IF_RELEASE(sHRAtom);
|
NS_IF_RELEASE(sHRAtom);
|
||||||
NS_IF_RELEASE(sCommentAtom);
|
|
||||||
NS_IF_RELEASE(sScriptAtom);
|
NS_IF_RELEASE(sScriptAtom);
|
||||||
NS_IF_RELEASE(sNoframesAtom);
|
NS_IF_RELEASE(sNoframesAtom);
|
||||||
NS_IF_RELEASE(sSelectAtom);
|
NS_IF_RELEASE(sSelectAtom);
|
||||||
|
@ -806,11 +800,8 @@ PRBool nsFind::IsBlockNode(nsIContent* aContent)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt32 id;
|
|
||||||
mParserService->HTMLAtomTagToId(atom, &id);
|
|
||||||
|
|
||||||
PRBool isBlock = PR_FALSE;
|
PRBool isBlock = PR_FALSE;
|
||||||
mParserService->IsBlock(id, isBlock);
|
mParserService->IsBlock(mParserService->HTMLAtomTagToId(atom), isBlock);
|
||||||
return isBlock;
|
return isBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,7 +811,7 @@ PRBool nsFind::IsTextNode(nsIDOMNode* aNode)
|
||||||
// also implements that interface.
|
// also implements that interface.
|
||||||
nsCOMPtr<nsIContent> content (do_QueryInterface(aNode));
|
nsCOMPtr<nsIContent> content (do_QueryInterface(aNode));
|
||||||
|
|
||||||
return content && content->Tag() == sTextAtom;
|
return content && content->IsContentOfType(nsIContent::eTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool nsFind::IsVisibleNode(nsIDOMNode *aDOMNode)
|
PRBool nsFind::IsVisibleNode(nsIDOMNode *aDOMNode)
|
||||||
|
@ -856,10 +847,9 @@ PRBool nsFind::SkipNode(nsIContent* aContent)
|
||||||
|
|
||||||
// We may not need to skip comment nodes,
|
// We may not need to skip comment nodes,
|
||||||
// now that IsTextNode distinguishes them from real text nodes.
|
// now that IsTextNode distinguishes them from real text nodes.
|
||||||
return (atom == sCommentAtom ||
|
return (aContent->IsContentOfType(nsIContent::eCOMMENT) ||
|
||||||
(aContent->IsContentOfType(nsIContent::eHTML) &&
|
(aContent->IsContentOfType(nsIContent::eHTML) &&
|
||||||
(atom == sScriptAtom ||
|
(atom == sScriptAtom ||
|
||||||
atom == sCommentAtom ||
|
|
||||||
atom == sNoframesAtom ||
|
atom == sNoframesAtom ||
|
||||||
atom == sSelectAtom)));
|
atom == sSelectAtom)));
|
||||||
|
|
||||||
|
@ -874,7 +864,7 @@ PRBool nsFind::SkipNode(nsIContent* aContent)
|
||||||
{
|
{
|
||||||
atom = content->Tag();
|
atom = content->Tag();
|
||||||
|
|
||||||
if (atom == sCommentAtom ||
|
if (aContent->IsContentOfType(nsIContent::eCOMMENT) ||
|
||||||
(content->IsContentOfType(nsIContent::eHTML) &&
|
(content->IsContentOfType(nsIContent::eHTML) &&
|
||||||
(atom == sScriptAtom ||
|
(atom == sScriptAtom ||
|
||||||
atom == sNoframesAtom ||
|
atom == sNoframesAtom ||
|
||||||
|
|
|
@ -69,11 +69,9 @@ protected:
|
||||||
static PRInt32 sInstanceCount;
|
static PRInt32 sInstanceCount;
|
||||||
|
|
||||||
// HTML tags we treat specially
|
// HTML tags we treat specially
|
||||||
static nsIAtom* sTextAtom;
|
|
||||||
static nsIAtom* sImgAtom;
|
static nsIAtom* sImgAtom;
|
||||||
static nsIAtom* sHRAtom;
|
static nsIAtom* sHRAtom;
|
||||||
// Nodes we skip
|
// Nodes we skip
|
||||||
static nsIAtom* sCommentAtom;
|
|
||||||
static nsIAtom* sScriptAtom;
|
static nsIAtom* sScriptAtom;
|
||||||
static nsIAtom* sNoframesAtom;
|
static nsIAtom* sNoframesAtom;
|
||||||
static nsIAtom* sSelectAtom;
|
static nsIAtom* sSelectAtom;
|
||||||
|
|
|
@ -3763,29 +3763,19 @@ nsCSSFrameConstructor::ConstructTableCellFrame(nsFrameConstructorState& aState,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
static PRBool
|
||||||
nsCSSFrameConstructor::MustGeneratePseudoParent(nsIAtom* aTag,
|
MustGeneratePseudoParent(nsIContent* aContent, nsStyleContext* aStyleContext)
|
||||||
nsIContent* aContent,
|
|
||||||
nsStyleContext* aStyleContext)
|
|
||||||
{
|
{
|
||||||
if (!aStyleContext)
|
if (!aStyleContext ||
|
||||||
|
NS_STYLE_DISPLAY_NONE == aStyleContext->GetStyleDisplay()->mDisplay) {
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (NS_STYLE_DISPLAY_NONE == aStyleContext->GetStyleDisplay()->mDisplay)
|
if (aContent->IsContentOfType(nsIContent::eTEXT)) {
|
||||||
return PR_FALSE;
|
|
||||||
|
|
||||||
// check tags first
|
|
||||||
|
|
||||||
if ((nsLayoutAtoms::textTagName == aTag)) {
|
|
||||||
return !IsOnlyWhitespace(aContent);
|
return !IsOnlyWhitespace(aContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// exclude tags
|
return !aContent->IsContentOfType(nsIContent::eCOMMENT);
|
||||||
if ( nsLayoutAtoms::commentTagName == aTag) {
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return PR_TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is called when a non table related element is a child of a table, row group,
|
// this is called when a non table related element is a child of a table, row group,
|
||||||
|
@ -3804,9 +3794,7 @@ nsCSSFrameConstructor::ConstructTableForeignFrame(nsFrameConstructorState& aStat
|
||||||
nsIFrame* parentFrame = nsnull;
|
nsIFrame* parentFrame = nsnull;
|
||||||
PRBool hasPseudoParent = PR_FALSE;
|
PRBool hasPseudoParent = PR_FALSE;
|
||||||
|
|
||||||
nsIAtom *tag = aContent->Tag();
|
if (MustGeneratePseudoParent(aContent, aStyleContext)) {
|
||||||
|
|
||||||
if (MustGeneratePseudoParent(tag, aContent, aStyleContext)) {
|
|
||||||
// this frame may have a pseudo parent, use block frame type to
|
// this frame may have a pseudo parent, use block frame type to
|
||||||
// trigger foreign
|
// trigger foreign
|
||||||
rv = GetParentFrame(aTableCreator,
|
rv = GetParentFrame(aTableCreator,
|
||||||
|
@ -6762,7 +6750,7 @@ nsCSSFrameConstructor::ResolveStyleContext(nsIFrame* aParentFrame,
|
||||||
return styleSet->ResolveStyleFor(aContent, parentStyleContext);
|
return styleSet->ResolveStyleFor(aContent, parentStyleContext);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
NS_ASSERTION(aContent->Tag() == nsLayoutAtoms::textTagName,
|
NS_ASSERTION(aContent->IsContentOfType(nsIContent::eTEXT),
|
||||||
"shouldn't waste time creating style contexts for "
|
"shouldn't waste time creating style contexts for "
|
||||||
"comments and processing instructions");
|
"comments and processing instructions");
|
||||||
|
|
||||||
|
@ -7467,12 +7455,9 @@ nsCSSFrameConstructor::ConstructFrame(nsFrameConstructorState& aState,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the element's tag
|
// never create frames for comments or PIs
|
||||||
nsIAtom *tag = aContent->Tag();
|
if (aContent->IsContentOfType(nsIContent::eCOMMENT) ||
|
||||||
|
aContent->IsContentOfType(nsIContent::ePROCESSING_INSTRUCTION))
|
||||||
// never create frames for comments on PIs
|
|
||||||
if (tag == nsLayoutAtoms::commentTagName ||
|
|
||||||
tag == nsLayoutAtoms::processingInstructionTagName)
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
nsRefPtr<nsStyleContext> styleContext;
|
nsRefPtr<nsStyleContext> styleContext;
|
||||||
|
@ -7487,8 +7472,8 @@ nsCSSFrameConstructor::ConstructFrame(nsFrameConstructorState& aState,
|
||||||
}
|
}
|
||||||
// construct the frame
|
// construct the frame
|
||||||
rv = ConstructFrameInternal(aState, aContent, aParentFrame,
|
rv = ConstructFrameInternal(aState, aContent, aParentFrame,
|
||||||
tag, aContent->GetNameSpaceID(), styleContext,
|
aContent->Tag(), aContent->GetNameSpaceID(),
|
||||||
aFrameItems, PR_FALSE);
|
styleContext, aFrameItems, PR_FALSE);
|
||||||
if (NS_SUCCEEDED(rv) && pageBreakAfter) {
|
if (NS_SUCCEEDED(rv) && pageBreakAfter) {
|
||||||
// Construct the page break after
|
// Construct the page break after
|
||||||
ConstructPageBreakFrame(aState, aContent, aParentFrame, styleContext,
|
ConstructPageBreakFrame(aState, aContent, aParentFrame, styleContext,
|
||||||
|
@ -11482,7 +11467,7 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsFrameManager* aFrameManager,
|
||||||
|
|
||||||
if (aHint && !*aFrame)
|
if (aHint && !*aFrame)
|
||||||
{ // if we had a hint, and we didn't get a frame, see if we should try the slow way
|
{ // if we had a hint, and we didn't get a frame, see if we should try the slow way
|
||||||
if (aContent->Tag() == nsLayoutAtoms::textTagName)
|
if (aContent->IsContentOfType(nsIContent::eTEXT))
|
||||||
{
|
{
|
||||||
#ifdef NOISY_FINDFRAME
|
#ifdef NOISY_FINDFRAME
|
||||||
FFWC_slowSearchForText++;
|
FFWC_slowSearchForText++;
|
||||||
|
|
|
@ -330,10 +330,6 @@ private:
|
||||||
nsIFrame*& aNewCellInnerFrame,
|
nsIFrame*& aNewCellInnerFrame,
|
||||||
PRBool& aIsPseudoParent);
|
PRBool& aIsPseudoParent);
|
||||||
|
|
||||||
PRBool MustGeneratePseudoParent(nsIAtom* aTag,
|
|
||||||
nsIContent* aContent,
|
|
||||||
nsStyleContext* aContext);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ConstructTableForeignFrame constructs the frame for a non-table-element
|
* ConstructTableForeignFrame constructs the frame for a non-table-element
|
||||||
* child of a table-element frame (where "table-element" can mean rows,
|
* child of a table-element frame (where "table-element" can mean rows,
|
||||||
|
|
|
@ -385,14 +385,12 @@ nsFrameManager::GetPrimaryFrameFor(nsIContent* aContent)
|
||||||
if (index > 0) // no use looking if it's the first child
|
if (index > 0) // no use looking if it's the first child
|
||||||
{
|
{
|
||||||
nsIContent *prevSibling;
|
nsIContent *prevSibling;
|
||||||
nsIAtom *tag;
|
|
||||||
do {
|
do {
|
||||||
prevSibling = parent->GetChildAt(--index);
|
prevSibling = parent->GetChildAt(--index);
|
||||||
tag = prevSibling->Tag();
|
|
||||||
} while (index &&
|
} while (index &&
|
||||||
(tag == nsLayoutAtoms::textTagName ||
|
(prevSibling->IsContentOfType(nsIContent::eTEXT) ||
|
||||||
tag == nsLayoutAtoms::commentTagName ||
|
prevSibling->IsContentOfType(nsIContent::eCOMMENT) ||
|
||||||
tag == nsLayoutAtoms::processingInstructionTagName));
|
prevSibling->IsContentOfType(nsIContent::ePROCESSING_INSTRUCTION)));
|
||||||
if (prevSibling) {
|
if (prevSibling) {
|
||||||
entry = NS_STATIC_CAST(PrimaryFrameMapEntry*,
|
entry = NS_STATIC_CAST(PrimaryFrameMapEntry*,
|
||||||
PL_DHashTableOperate(&mPrimaryFrameMap, prevSibling,
|
PL_DHashTableOperate(&mPrimaryFrameMap, prevSibling,
|
||||||
|
|
|
@ -69,7 +69,6 @@ LAYOUT_ATOM(tty, "tty")
|
||||||
LAYOUT_ATOM(tv, "tv")
|
LAYOUT_ATOM(tv, "tv")
|
||||||
|
|
||||||
// Alphabetical list of standard name space prefixes
|
// Alphabetical list of standard name space prefixes
|
||||||
LAYOUT_ATOM(htmlNameSpace, "html")
|
|
||||||
LAYOUT_ATOM(xmlNameSpace, "xml")
|
LAYOUT_ATOM(xmlNameSpace, "xml")
|
||||||
LAYOUT_ATOM(xmlnsNameSpace, "xmlns")
|
LAYOUT_ATOM(xmlnsNameSpace, "xmlns")
|
||||||
|
|
||||||
|
@ -85,9 +84,10 @@ LAYOUT_ATOM(overflowList, "Overflow-list")
|
||||||
LAYOUT_ATOM(overflowOutOfFlowList, "OverflowOutOfFlow-list")
|
LAYOUT_ATOM(overflowOutOfFlowList, "OverflowOutOfFlow-list")
|
||||||
LAYOUT_ATOM(popupList, "Popup-list")
|
LAYOUT_ATOM(popupList, "Popup-list")
|
||||||
|
|
||||||
LAYOUT_ATOM(commentTagName, "__moz_comment")
|
LAYOUT_ATOM(commentTagName, "#comment")
|
||||||
LAYOUT_ATOM(textTagName, "__moz_text")
|
LAYOUT_ATOM(textTagName, "#text")
|
||||||
LAYOUT_ATOM(processingInstructionTagName, "__moz_pi")
|
LAYOUT_ATOM(cdataTagName, "#cdata-section")
|
||||||
|
LAYOUT_ATOM(processingInstructionTagName, "#processing-instruction")
|
||||||
LAYOUT_ATOM(documentFragmentNodeName, "#document-fragment")
|
LAYOUT_ATOM(documentFragmentNodeName, "#document-fragment")
|
||||||
|
|
||||||
// Alphabetical list of frame types
|
// Alphabetical list of frame types
|
||||||
|
|
|
@ -2783,14 +2783,11 @@ nsresult
|
||||||
nsFrame::MakeFrameName(const nsAString& aType, nsAString& aResult) const
|
nsFrame::MakeFrameName(const nsAString& aType, nsAString& aResult) const
|
||||||
{
|
{
|
||||||
aResult = aType;
|
aResult = aType;
|
||||||
if (mContent) {
|
if (mContent && !mContent->IsContentOfType(nsIContent::eTEXT)) {
|
||||||
nsIAtom *tag = mContent->Tag();
|
|
||||||
if (tag != nsLayoutAtoms::textTagName) {
|
|
||||||
nsAutoString buf;
|
nsAutoString buf;
|
||||||
tag->ToString(buf);
|
mContent->Tag()->ToString(buf);
|
||||||
aResult.Append(NS_LITERAL_STRING("(") + buf + NS_LITERAL_STRING(")"));
|
aResult.Append(NS_LITERAL_STRING("(") + buf + NS_LITERAL_STRING(")"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
char buf[40];
|
char buf[40];
|
||||||
PR_snprintf(buf, sizeof(buf), "(%d)", ContentIndexInContainer(this));
|
PR_snprintf(buf, sizeof(buf), "(%d)", ContentIndexInContainer(this));
|
||||||
AppendASCIItoUTF16(buf, aResult);
|
AppendASCIItoUTF16(buf, aResult);
|
||||||
|
@ -3453,12 +3450,11 @@ nsPeekOffsetStruct nsIFrame::GetExtremeCaretPosition(PRBool aStart)
|
||||||
if (!content)
|
if (!content)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
// special case: if this is not a __moz_text element,
|
// special case: if this is not a textnode,
|
||||||
// position the caret to the offset of its parent instead
|
// position the caret to the offset of its parent instead
|
||||||
// (position the caret to non-text element may make the caret missing)
|
// (position the caret to non-text element may make the caret missing)
|
||||||
|
|
||||||
nsIAtom* tag = content->Tag();
|
if (!content->IsContentOfType(nsIContent::eTEXT)) {
|
||||||
if (tag != nsLayoutAtoms::textTagName) {
|
|
||||||
// special case in effect
|
// special case in effect
|
||||||
nsIContent* parent = content->GetParent();
|
nsIContent* parent = content->GetParent();
|
||||||
NS_ASSERTION(parent,"element has no parent!");
|
NS_ASSERTION(parent,"element has no parent!");
|
||||||
|
|
|
@ -2834,14 +2834,14 @@ static PRBool IsSignificantChild(nsIContent* aChild, PRBool aTextIsSignificant,
|
||||||
NS_ASSERTION(!aWhitespaceIsSignificant || aTextIsSignificant,
|
NS_ASSERTION(!aWhitespaceIsSignificant || aTextIsSignificant,
|
||||||
"Nonsensical arguments");
|
"Nonsensical arguments");
|
||||||
|
|
||||||
nsIAtom *tag = aChild->Tag(); // skip text, comments, and PIs
|
PRBool isText = aChild->IsContentOfType(nsIContent::eTEXT);
|
||||||
if ((tag != nsLayoutAtoms::textTagName) &&
|
|
||||||
(tag != nsLayoutAtoms::commentTagName) &&
|
if (!isText && !aChild->IsContentOfType(nsIContent::eCOMMENT) &&
|
||||||
(tag != nsLayoutAtoms::processingInstructionTagName)) {
|
!aChild->IsContentOfType(nsIContent::ePROCESSING_INSTRUCTION)) {
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aTextIsSignificant && tag == nsLayoutAtoms::textTagName) {
|
if (aTextIsSignificant && isText) {
|
||||||
if (!aWhitespaceIsSignificant) {
|
if (!aWhitespaceIsSignificant) {
|
||||||
nsCOMPtr<nsITextContent> text = do_QueryInterface(aChild);
|
nsCOMPtr<nsITextContent> text = do_QueryInterface(aChild);
|
||||||
|
|
||||||
|
|
|
@ -176,15 +176,11 @@ HTML_TAG(xmp, Span)
|
||||||
/* These are not for tags. But they will be included in the nsHTMLTag
|
/* These are not for tags. But they will be included in the nsHTMLTag
|
||||||
enum anyway */
|
enum anyway */
|
||||||
|
|
||||||
/* XXX: The second parameters in some of the following entries look
|
HTML_OTHER(text)
|
||||||
like they are just wrong. They should really be NOTUSED. For now,
|
HTML_OTHER(whitespace)
|
||||||
I'm just emulating what nsHTMLContentSink has done all along.
|
HTML_OTHER(newline)
|
||||||
*/
|
HTML_OTHER(comment)
|
||||||
HTML_OTHER(text, Span)
|
HTML_OTHER(entity)
|
||||||
HTML_OTHER(whitespace, Span)
|
HTML_OTHER(doctypeDecl)
|
||||||
HTML_OTHER(newline, Span)
|
HTML_OTHER(markupDecl)
|
||||||
HTML_OTHER(comment, Span)
|
HTML_OTHER(instruction)
|
||||||
HTML_OTHER(entity, Span)
|
|
||||||
HTML_OTHER(doctypeDecl, Span)
|
|
||||||
HTML_OTHER(markupDecl, Span)
|
|
||||||
HTML_OTHER(instruction, Span)
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class nsIAtom;
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#define HTML_TAG(_tag, _classname) eHTMLTag_##_tag,
|
#define HTML_TAG(_tag, _classname) eHTMLTag_##_tag,
|
||||||
#define HTML_OTHER(_tag, _classname) eHTMLTag_##_tag,
|
#define HTML_OTHER(_tag) eHTMLTag_##_tag,
|
||||||
enum nsHTMLTag {
|
enum nsHTMLTag {
|
||||||
/* this enum must be first and must be zero */
|
/* this enum must be first and must be zero */
|
||||||
eHTMLTag_unknown = 0,
|
eHTMLTag_unknown = 0,
|
||||||
|
|
|
@ -83,7 +83,6 @@ class CToken;
|
||||||
class nsIURI;
|
class nsIURI;
|
||||||
class nsIContentSink;
|
class nsIContentSink;
|
||||||
class CParserContext;
|
class CParserContext;
|
||||||
class nsIAtom;
|
|
||||||
|
|
||||||
class nsIDTD : public nsISupports
|
class nsIDTD : public nsISupports
|
||||||
{
|
{
|
||||||
|
@ -203,29 +202,6 @@ public:
|
||||||
NS_IMETHOD_(PRInt32) GetType() = 0;
|
NS_IMETHOD_(PRInt32) GetType() = 0;
|
||||||
|
|
||||||
NS_IMETHOD CollectSkippedContent(PRInt32 aTag, nsAString& aContent, PRInt32 &aLineNo) = 0;
|
NS_IMETHOD CollectSkippedContent(PRInt32 aTag, nsAString& aContent, PRInt32 &aLineNo) = 0;
|
||||||
|
|
||||||
/* XXX Temporary measure, pending further work by RickG */
|
|
||||||
|
|
||||||
|
|
||||||
// Whaaaa! These are useless methods, use nsIParserService!
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
|
||||||
* become useful.
|
|
||||||
*/
|
|
||||||
NS_IMETHOD StringTagToIntTag(const nsAString &aTag,
|
|
||||||
PRInt32* aIntTag) const = 0;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
NS_IMETHOD_(PRBool) IsInlineElement(PRInt32 aTagID,
|
|
||||||
PRInt32 aParentID) const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NS_DECL_NSIDTD \
|
#define NS_DECL_NSIDTD \
|
||||||
|
@ -242,10 +218,5 @@ public:
|
||||||
NS_IMETHOD_(PRBool) IsContainer(PRInt32 aTag) const;\
|
NS_IMETHOD_(PRBool) IsContainer(PRInt32 aTag) const;\
|
||||||
NS_IMETHOD CollectSkippedContent(PRInt32 aTag, nsAString& aContent, PRInt32 &aLineNo);\
|
NS_IMETHOD CollectSkippedContent(PRInt32 aTag, nsAString& aContent, PRInt32 &aLineNo);\
|
||||||
NS_IMETHOD_(void) Terminate();\
|
NS_IMETHOD_(void) Terminate();\
|
||||||
NS_IMETHOD_(PRInt32) GetType(); \
|
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___ */
|
#endif /* nsIDTD_h___ */
|
||||||
|
|
|
@ -41,13 +41,12 @@
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsHTMLTags.h"
|
#include "nsHTMLTags.h"
|
||||||
#include "nsIParserNode.h"
|
|
||||||
#include "nsIParser.h"
|
|
||||||
#include "nsVoidArray.h"
|
|
||||||
#include "nsIElementObserver.h"
|
#include "nsIElementObserver.h"
|
||||||
|
|
||||||
#define NS_PARSER_CONTRACTID_PREFIX "@mozilla.org/parser"
|
class nsIParser;
|
||||||
#define NS_PARSERSERVICE_CONTRACTID NS_PARSER_CONTRACTID_PREFIX "/parser-service;1"
|
class nsIParserNode;
|
||||||
|
|
||||||
|
#define NS_PARSERSERVICE_CONTRACTID "@mozilla.org/parser/parser-service;1"
|
||||||
|
|
||||||
// {90a92e37-abd6-441b-9b39-4064d98e1ede}
|
// {90a92e37-abd6-441b-9b39-4064d98e1ede}
|
||||||
#define NS_IPARSERSERVICE_IID \
|
#define NS_IPARSERSERVICE_IID \
|
||||||
|
@ -74,16 +73,66 @@ class nsIParserService : public nsISupports {
|
||||||
public:
|
public:
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPARSERSERVICE_IID)
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPARSERSERVICE_IID)
|
||||||
|
|
||||||
NS_IMETHOD HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const = 0;
|
/**
|
||||||
|
* Looks up the nsHTMLTag enum value corresponding to the tag in aAtom. The
|
||||||
|
* lookup happens case insensitively.
|
||||||
|
*
|
||||||
|
* @param aAtom The tag to look up.
|
||||||
|
*
|
||||||
|
* @return PRInt32 The nsHTMLTag enum value corresponding to the tag in aAtom
|
||||||
|
* or eHTMLTag_userdefined if the tag does not correspond to
|
||||||
|
* any of the tag nsHTMLTag enum values.
|
||||||
|
*/
|
||||||
|
virtual PRInt32 HTMLAtomTagToId(nsIAtom* aAtom) const = 0;
|
||||||
|
|
||||||
NS_IMETHOD HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom,
|
/**
|
||||||
PRInt32* aId) const = 0;
|
* Looks up the nsHTMLTag enum value corresponding to the tag in aAtom.
|
||||||
|
*
|
||||||
|
* @param aAtom The tag to look up.
|
||||||
|
*
|
||||||
|
* @return PRInt32 The nsHTMLTag enum value corresponding to the tag in aAtom
|
||||||
|
* or eHTMLTag_userdefined if the tag does not correspond to
|
||||||
|
* any of the tag nsHTMLTag enum values.
|
||||||
|
*/
|
||||||
|
virtual PRInt32 HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const = 0;
|
||||||
|
|
||||||
NS_IMETHOD HTMLStringTagToId(const nsAString &aTagName,
|
/**
|
||||||
PRInt32* aId) const = 0;
|
* Looks up the nsHTMLTag enum value corresponding to the tag in aTag. The
|
||||||
|
* lookup happens case insensitively.
|
||||||
|
*
|
||||||
|
* @param aTag The tag to look up.
|
||||||
|
*
|
||||||
|
* @return PRInt32 The nsHTMLTag enum value corresponding to the tag in aTag
|
||||||
|
* or eHTMLTag_userdefined if the tag does not correspond to
|
||||||
|
* any of the tag nsHTMLTag enum values.
|
||||||
|
*/
|
||||||
|
virtual PRInt32 HTMLStringTagToId(const nsAString& aTag) const = 0;
|
||||||
|
|
||||||
NS_IMETHOD HTMLIdToStringTag(PRInt32 aId,
|
/**
|
||||||
const PRUnichar **aTagName) const = 0;
|
* Gets the tag corresponding to the nsHTMLTag enum value in aId. The
|
||||||
|
* returned tag will be in lowercase.
|
||||||
|
*
|
||||||
|
* @param aId The nsHTMLTag enum value to get the tag for.
|
||||||
|
*
|
||||||
|
* @return const PRUnichar* The tag corresponding to the nsHTMLTag enum
|
||||||
|
* value, or nsnull if the enum value doesn't
|
||||||
|
* correspond to a tag (eHTMLTag_unknown,
|
||||||
|
* eHTMLTag_userdefined, eHTMLTag_text, ...).
|
||||||
|
*/
|
||||||
|
virtual const PRUnichar *HTMLIdToStringTag(PRInt32 aId) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the tag corresponding to the nsHTMLTag enum value in aId. The
|
||||||
|
* returned tag will be in lowercase.
|
||||||
|
*
|
||||||
|
* @param aId The nsHTMLTag enum value to get the tag for.
|
||||||
|
*
|
||||||
|
* @return nsIAtom* The tag corresponding to the nsHTMLTag enum value, or
|
||||||
|
* nsnull if the enum value doesn't correspond to a tag
|
||||||
|
* (eHTMLTag_unknown, eHTMLTag_userdefined, eHTMLTag_text,
|
||||||
|
* ...).
|
||||||
|
*/
|
||||||
|
virtual nsIAtom *HTMLIdToAtomTag(PRInt32 aId) const = 0;
|
||||||
|
|
||||||
NS_IMETHOD HTMLConvertEntityToUnicode(const nsAString& aEntity,
|
NS_IMETHOD HTMLConvertEntityToUnicode(const nsAString& aEntity,
|
||||||
PRInt32* aUnicode) const = 0;
|
PRInt32* aUnicode) const = 0;
|
||||||
|
|
|
@ -2426,40 +2426,6 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
|
||||||
* become useful.
|
|
||||||
*/
|
|
||||||
NS_IMETHODIMP CNavDTD::StringTagToIntTag(const nsAString &aTag,
|
|
||||||
PRInt32* aIntTag) const
|
|
||||||
{
|
|
||||||
*aIntTag = nsHTMLTags::LookupTag(aTag);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(const PRUnichar *)
|
|
||||||
CNavDTD::IntTagToStringTag(PRInt32 aIntTag) const
|
|
||||||
{
|
|
||||||
const PRUnichar *str_ptr = nsHTMLTags::GetStringValue((nsHTMLTag)aIntTag);
|
|
||||||
|
|
||||||
NS_ASSERTION(str_ptr, "Bad tag enum passed to CNavDTD::IntTagToStringTag()"
|
|
||||||
"!!");
|
|
||||||
|
|
||||||
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
|
* This method is called to determine whether or not
|
||||||
* the given childtag is a block element.
|
* the given childtag is a block element.
|
||||||
|
|
|
@ -372,6 +372,8 @@ protected:
|
||||||
nsresult HandleSavedTokens(PRInt32 anIndex);
|
nsresult HandleSavedTokens(PRInt32 anIndex);
|
||||||
nsresult HandleKeyGen(nsIParserNode *aNode);
|
nsresult HandleKeyGen(nsIParserNode *aNode);
|
||||||
PRBool IsAlternateTag(eHTMLTags aTag);
|
PRBool IsAlternateTag(eHTMLTags aTag);
|
||||||
|
PRBool IsBlockElement(PRInt32 aTagID, PRInt32 aParentID) const;
|
||||||
|
PRBool IsInlineElement(PRInt32 aTagID, PRInt32 aParentID) const;
|
||||||
|
|
||||||
nsDeque mMisplacedContent;
|
nsDeque mMisplacedContent;
|
||||||
nsDeque mSkippedContent;
|
nsDeque mSkippedContent;
|
||||||
|
|
|
@ -813,79 +813,6 @@ PRBool COtherDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
|
||||||
* become useful.
|
|
||||||
*/
|
|
||||||
NS_IMETHODIMP
|
|
||||||
COtherDTD::StringTagToIntTag(const nsAString &aTag,
|
|
||||||
PRInt32* aIntTag) const
|
|
||||||
{
|
|
||||||
*aIntTag = nsHTMLTags::LookupTag(aTag);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(const PRUnichar *)
|
|
||||||
COtherDTD::IntTagToStringTag(PRInt32 aIntTag) const
|
|
||||||
{
|
|
||||||
const PRUnichar *str_ptr = nsHTMLTags::GetStringValue((nsHTMLTag)aIntTag);
|
|
||||||
|
|
||||||
NS_ASSERTION(str_ptr, "Bad tag enum passed to COtherDTD::IntTagToStringTag()"
|
|
||||||
"!!");
|
|
||||||
|
|
||||||
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.
|
|
||||||
*
|
|
||||||
* @update gess 6June2000
|
|
||||||
* @param aChildID -- tag id of child
|
|
||||||
* @param aParentID -- tag id of parent (or eHTMLTag_unknown)
|
|
||||||
* @return PR_TRUE if this tag is a block tag
|
|
||||||
*/
|
|
||||||
PRBool COtherDTD::IsBlockElement(PRInt32 aChildID,PRInt32 aParentID) const {
|
|
||||||
PRBool result=PR_FALSE;
|
|
||||||
|
|
||||||
if(gElementTable) {
|
|
||||||
CElement *theElement=gElementTable->GetElement((eHTMLTags)aChildID);
|
|
||||||
result = (theElement) ? theElement->IsBlockElement((eHTMLTags)aParentID) : PR_FALSE;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called to determine whether or not
|
|
||||||
* the given childtag is an inline element.
|
|
||||||
*
|
|
||||||
* @update gess 6June2000
|
|
||||||
* @param aChildID -- tag id of child
|
|
||||||
* @param aParentID -- tag id of parent (or eHTMLTag_unknown)
|
|
||||||
* @return PR_TRUE if this tag is an inline element
|
|
||||||
*/
|
|
||||||
PRBool COtherDTD::IsInlineElement(PRInt32 aChildID,PRInt32 aParentID) const {
|
|
||||||
PRBool result=PR_FALSE;
|
|
||||||
|
|
||||||
if(gElementTable) {
|
|
||||||
CElement *theElement=gElementTable->GetElement((eHTMLTags)aChildID);
|
|
||||||
result = (theElement) ? theElement->IsInlineElement((eHTMLTags)aParentID) : PR_FALSE;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method gets called to determine whether a given
|
* This method gets called to determine whether a given
|
||||||
* tag is itself a container
|
* tag is itself a container
|
||||||
|
|
|
@ -1178,18 +1178,6 @@ nsExpatDriver::HandleToken(CToken* aToken,nsIParser* aParser)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP_(PRBool)
|
|
||||||
nsExpatDriver::IsBlockElement(PRInt32 aTagID,PRInt32 aParentID) const
|
|
||||||
{
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(PRBool)
|
|
||||||
nsExpatDriver::IsInlineElement(PRInt32 aTagID,PRInt32 aParentID) const
|
|
||||||
{
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(PRBool)
|
NS_IMETHODIMP_(PRBool)
|
||||||
nsExpatDriver::IsContainer(PRInt32 aTag) const
|
nsExpatDriver::IsContainer(PRInt32 aTag) const
|
||||||
{
|
{
|
||||||
|
@ -1201,21 +1189,3 @@ nsExpatDriver::CanContain(PRInt32 aParent,PRInt32 aChild) const
|
||||||
{
|
{
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsExpatDriver::StringTagToIntTag(const nsAString &aTag, PRInt32* aIntTag) const
|
|
||||||
{
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(const PRUnichar *)
|
|
||||||
nsExpatDriver::IntTagToStringTag(PRInt32 aIntTag) const
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(nsIAtom *)
|
|
||||||
nsExpatDriver::IntTagToAtom(PRInt32 aIntTag) const
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -266,7 +266,7 @@ static const PRUnichar sHTMLTagUnicodeName_xmp[] =
|
||||||
|
|
||||||
// static array of unicode tag names
|
// static array of unicode tag names
|
||||||
#define HTML_TAG(_tag, _classname) sHTMLTagUnicodeName_##_tag,
|
#define HTML_TAG(_tag, _classname) sHTMLTagUnicodeName_##_tag,
|
||||||
#define HTML_OTHER(_tag, _classname)
|
#define HTML_OTHER(_tag)
|
||||||
static const PRUnichar* const kTagUnicodeTable[] = {
|
static const PRUnichar* const kTagUnicodeTable[] = {
|
||||||
#include "nsHTMLTagList.h"
|
#include "nsHTMLTagList.h"
|
||||||
};
|
};
|
||||||
|
@ -390,7 +390,7 @@ nsHTMLTags::CaseSensitiveLookupTag(const PRUnichar* aTagName)
|
||||||
|
|
||||||
PRUint32 tag = NS_PTR_TO_INT32(PL_HashTableLookupConst(gTagTable, aTagName));
|
PRUint32 tag = NS_PTR_TO_INT32(PL_HashTableLookupConst(gTagTable, aTagName));
|
||||||
|
|
||||||
return (nsHTMLTag)tag;
|
return tag == eHTMLTag_unknown ? eHTMLTag_userdefined : (nsHTMLTag)tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -429,34 +429,7 @@ nsHTMLTags::LookupTag(const nsAString& aTagName)
|
||||||
|
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
|
|
||||||
nsHTMLTag tag = CaseSensitiveLookupTag(buf);
|
return CaseSensitiveLookupTag(buf);
|
||||||
|
|
||||||
// hack: this can come out when rickg provides a way for the editor to ask
|
|
||||||
// CanContain() questions without having to first fetch the parsers
|
|
||||||
// internal enum values for a tag name.
|
|
||||||
|
|
||||||
// Hmm, this hack would be faster if we'd put these strings in the
|
|
||||||
// hash table. But maybe it's not worth it...
|
|
||||||
|
|
||||||
if (tag == eHTMLTag_unknown) {
|
|
||||||
// "__moz_text"
|
|
||||||
static const PRUnichar moz_text[] =
|
|
||||||
{'_', '_', 'm', 'o', 'z', '_', 't', 'e', 'x', 't', PRUnichar(0) };
|
|
||||||
|
|
||||||
// "#text"
|
|
||||||
static const PRUnichar text[] =
|
|
||||||
{'#', 't', 'e', 'x', 't', PRUnichar(0) };
|
|
||||||
|
|
||||||
if (nsCRT::strcmp(buf, moz_text) == 0) {
|
|
||||||
tag = eHTMLTag_text;
|
|
||||||
} else if (nsCRT::strcmp(buf, text) == 0) {
|
|
||||||
tag = eHTMLTag_text;
|
|
||||||
} else {
|
|
||||||
tag = eHTMLTag_userdefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -62,45 +62,40 @@ nsParserService::~nsParserService()
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsParserService, nsIParserService)
|
NS_IMPL_ISUPPORTS1(nsParserService, nsIParserService)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
PRInt32
|
||||||
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const
|
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom) const
|
||||||
{
|
{
|
||||||
nsAutoString tagName;
|
nsAutoString tagName;
|
||||||
aAtom->ToString(tagName);
|
aAtom->ToString(tagName);
|
||||||
|
|
||||||
*aId = nsHTMLTags::LookupTag(tagName);
|
return nsHTMLTags::LookupTag(tagName);
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
PRInt32
|
||||||
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom,
|
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const
|
||||||
PRInt32* aId) const
|
|
||||||
{
|
{
|
||||||
nsAutoString tagName;
|
nsAutoString tagName;
|
||||||
aAtom->ToString(tagName);
|
aAtom->ToString(tagName);
|
||||||
|
|
||||||
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName.get());
|
return nsHTMLTags::CaseSensitiveLookupTag(tagName.get());
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
PRInt32
|
||||||
nsParserService::HTMLStringTagToId(const nsAString &aTagName,
|
nsParserService::HTMLStringTagToId(const nsAString& aTag) const
|
||||||
PRInt32* aId) const
|
|
||||||
{
|
{
|
||||||
*aId = nsHTMLTags::LookupTag(aTagName);
|
return nsHTMLTags::LookupTag(aTag);
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
const PRUnichar*
|
||||||
nsParserService::HTMLIdToStringTag(PRInt32 aId,
|
nsParserService::HTMLIdToStringTag(PRInt32 aId) const
|
||||||
const PRUnichar **aTagName) const
|
|
||||||
{
|
{
|
||||||
*aTagName = nsHTMLTags::GetStringValue((nsHTMLTag)aId);
|
return nsHTMLTags::GetStringValue((nsHTMLTag)aId);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
nsIAtom*
|
||||||
|
nsParserService::HTMLIdToAtomTag(PRInt32 aId) const
|
||||||
|
{
|
||||||
|
return nsHTMLTags::GetAtom((nsHTMLTag)aId);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -163,7 +158,7 @@ nsParserService::RegisterObserver(nsIElementObserver* aObserver,
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*aTags) {
|
while (*aTags) {
|
||||||
if(*aTags != eHTMLTag_userdefined && *aTags <= NS_HTML_TAG_MAX) {
|
if (*aTags <= NS_HTML_TAG_MAX) {
|
||||||
entry->AddObserver(aObserver,*aTags);
|
entry->AddObserver(aObserver,*aTags);
|
||||||
}
|
}
|
||||||
++aTags;
|
++aTags;
|
||||||
|
|
|
@ -52,14 +52,15 @@ public:
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
NS_IMETHOD HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const;
|
PRInt32 HTMLAtomTagToId(nsIAtom* aAtom) const;
|
||||||
|
|
||||||
NS_IMETHOD HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const;
|
PRInt32 HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const;
|
||||||
|
|
||||||
NS_IMETHOD HTMLStringTagToId(const nsAString &aTagName,
|
PRInt32 HTMLStringTagToId(const nsAString& aTag) const;
|
||||||
PRInt32* aId) const;
|
|
||||||
|
|
||||||
NS_IMETHOD HTMLIdToStringTag(PRInt32 aId, const PRUnichar **aTagName) const;
|
const PRUnichar *HTMLIdToStringTag(PRInt32 aId) const;
|
||||||
|
|
||||||
|
nsIAtom *HTMLIdToAtomTag(PRInt32 aId) const;
|
||||||
|
|
||||||
NS_IMETHOD HTMLConvertEntityToUnicode(const nsAString& aEntity,
|
NS_IMETHOD HTMLConvertEntityToUnicode(const nsAString& aEntity,
|
||||||
PRInt32* aUnicode) const;
|
PRInt32* aUnicode) const;
|
||||||
|
|
|
@ -872,51 +872,6 @@ PRBool CViewSourceHTML::CanContain(PRInt32 aParent,PRInt32 aChild) const{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Give rest of world access to our tag enums, so that CanContain(), etc,
|
|
||||||
* become useful.
|
|
||||||
*/
|
|
||||||
NS_IMETHODIMP
|
|
||||||
CViewSourceHTML::StringTagToIntTag(const nsAString &aTag,
|
|
||||||
PRInt32* aIntTag) const
|
|
||||||
{
|
|
||||||
*aIntTag = nsHTMLTags::LookupTag(aTag);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP_(const PRUnichar *)
|
|
||||||
CViewSourceHTML::IntTagToStringTag(PRInt32 aIntTag) const
|
|
||||||
{
|
|
||||||
const PRUnichar *str_ptr = nsHTMLTags::GetStringValue((nsHTMLTag)aIntTag);
|
|
||||||
|
|
||||||
NS_ASSERTION(str_ptr, "Bad tag enum passed to COtherDTD::IntTagToStringTag()"
|
|
||||||
"!!");
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRBool CViewSourceHTML::IsInlineElement(PRInt32 aTagID,PRInt32 aParentID) const {
|
|
||||||
PRBool result=PR_FALSE;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method gets called to determine whether a given
|
* This method gets called to determine whether a given
|
||||||
* tag is itself a container
|
* tag is itself a container
|
||||||
|
|
Загрузка…
Ссылка в новой задаче