Fix for bug 286300 (Clean up HTML tags enum and related code). r=mrbkap, sr=bz, a=asa.

This commit is contained in:
peterv%propagandism.org 2005-06-16 13:10:58 +00:00
Родитель 555cc2a1f9
Коммит ea82f1a8a5
39 изменённых файлов: 281 добавлений и 550 удалений

Просмотреть файл

@ -216,11 +216,8 @@ mozSanitizingHTMLSerializer::GetIdForContent(nsIContent* aContent)
nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef();
PRInt32 id;
nsresult rv = parserService->HTMLAtomTagToId(aContent->Tag(), &id);
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't map HTML tag to id!");
return id;
return parserService ? parserService->HTMLAtomTagToId(aContent->Tag()) :
eHTMLTag_unknown;
}
NS_IMETHODIMP
@ -474,8 +471,7 @@ mozSanitizingHTMLSerializer::DoOpenContainer(PRInt32 aTag)
nsContentUtils::GetParserServiceWeakRef();
if (!parserService)
return NS_ERROR_OUT_OF_MEMORY;
const PRUnichar* tag_name;
parserService->HTMLIdToStringTag(aTag, &tag_name);
const PRUnichar* tag_name = parserService->HTMLIdToStringTag(aTag);
NS_ENSURE_TRUE(tag_name, NS_ERROR_INVALID_POINTER);
Write(NS_LITERAL_STRING("<") + nsDependentString(tag_name));
@ -522,8 +518,7 @@ mozSanitizingHTMLSerializer::DoCloseContainer(PRInt32 aTag)
nsContentUtils::GetParserServiceWeakRef();
if (!parserService)
return NS_ERROR_OUT_OF_MEMORY;
const PRUnichar* tag_name;
parserService->HTMLIdToStringTag(aTag, &tag_name);
const PRUnichar* tag_name = parserService->HTMLIdToStringTag(aTag);
NS_ENSURE_TRUE(tag_name, NS_ERROR_INVALID_POINTER);
Write(NS_LITERAL_STRING("</") + nsDependentString(tag_name)
@ -765,31 +760,29 @@ mozSanitizingHTMLSerializer::ParseTagPref(const nsCAutoString& tagpref)
return NS_ERROR_OUT_OF_MEMORY;
// Parsing tag
PRInt32 bracket = tagpref.Find("(");
nsCAutoString tag = tagpref;
if (bracket != kNotFound)
tag.Truncate(bracket);
if (tag.Equals(""))
PRInt32 bracket = tagpref.FindChar('(');
if (bracket == 0)
{
printf(" malformed pref: %s\n", tagpref.get());
return NS_ERROR_CANNOT_CONVERT_DATA;
}
nsAutoString tag;
CopyUTF8toUTF16(StringHead(tagpref, bracket), tag);
// Create key
NS_ConvertASCIItoUCS2 tag_widestr(tag);
PRInt32 tag_id;
parserService->HTMLStringTagToId(tag_widestr, &tag_id);
if (tag_id == eHTMLTag_userdefined ||
tag_id == eHTMLTag_unknown)
PRInt32 tag_id = parserService->HTMLStringTagToId(tag);
if (tag_id == eHTMLTag_userdefined)
{
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;
}
nsPRUint32Key tag_key(tag_id);
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;
}
if (bracket == kNotFound)

Просмотреть файл

@ -49,7 +49,7 @@
#include "nsIAtom.h"
#include "nsIDocumentEncoder.h"
#include "nsString.h"
#include "nsIParser.h"
class mozSanitizingHTMLSerializer : public nsIContentSerializer,
public nsIHTMLContentSink,

Просмотреть файл

@ -131,6 +131,8 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
#include "nsILink.h"
#include "nsICharsetAlias.h"
#include "nsIParser.h"
static NS_DEFINE_CID(kCharsetAliasCID, NS_CHARSETALIAS_CID);
// Helper structs for the content->subdoc map

Просмотреть файл

@ -1465,11 +1465,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, PRInt32
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
if (content)
{
PRInt32 id;
parserService->HTMLAtomTagToId(content->Tag(), &id);
PRBool isBlock = PR_FALSE;
parserService->IsBlock(id, isBlock);
parserService->IsBlock(parserService->HTMLAtomTagToId(content->Tag()), isBlock);
if (isBlock)
{
bResetPromotion = PR_FALSE;
@ -1551,11 +1548,8 @@ nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, PRInt32
nsCOMPtr<nsIContent> content = do_QueryInterface(parent);
if (content)
{
PRInt32 id;
parserService->HTMLAtomTagToId(content->Tag(), &id);
PRBool isBlock = PR_FALSE;
parserService->IsBlock(id, isBlock);
parserService->IsBlock(parserService->HTMLAtomTagToId(content->Tag()), isBlock);
if (isBlock)
{
bResetPromotion = PR_FALSE;

Просмотреть файл

@ -801,10 +801,9 @@ nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
if (parserService && (name != nsHTMLAtoms::style)) {
PRBool isContainer;
PRInt32 id;
parserService->HTMLAtomTagToId(name, &id);
parserService->IsContainer(id, isContainer);
parserService->IsContainer(parserService->HTMLAtomTagToId(name),
isContainer);
if (!isContainer) return NS_OK;
}
@ -1066,10 +1065,7 @@ nsHTMLContentSerializer::LineBreakBeforeOpen(nsIAtom* aName,
if (parserService) {
PRBool res;
PRInt32 id;
parserService->HTMLAtomTagToId(aName, &id);
parserService->IsBlock(id, res);
parserService->IsBlock(parserService->HTMLAtomTagToId(aName), res);
return res;
}
}
@ -1167,10 +1163,7 @@ nsHTMLContentSerializer::LineBreakAfterClose(nsIAtom* aName,
if (parserService) {
PRBool res;
PRInt32 id;
parserService->HTMLAtomTagToId(aName, &id);
parserService->IsBlock(id, res);
parserService->IsBlock(parserService->HTMLAtomTagToId(aName), res);
return res;
}
}

Просмотреть файл

@ -1892,11 +1892,8 @@ nsPlainTextSerializer::GetIdForContent(nsIContent* aContent)
nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef();
PRInt32 id;
nsresult rv = parserService->HTMLAtomTagToId(aContent->Tag(), &id);
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't map HTML tag to id!");
return id;
return parserService ? parserService->HTMLAtomTagToId(aContent->Tag()) :
eHTMLTag_unknown;
}
/**

Просмотреть файл

@ -188,7 +188,7 @@ NS_NewHTMLNOTUSEDElement(nsINodeInfo *aNodeInfo, PRBool aFromParser)
}
#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[] = {
NS_NewHTMLUnknownElement,
#include "nsHTMLTagList.h"
@ -757,16 +757,14 @@ HTMLContentSink::SinkTraceNode(PRUint32 aBit,
void* aThis)
{
if (SINK_LOG_TEST(gSinkLogModuleInfo, aBit)) {
nsCOMPtr<nsIDTD> dtd;
if (mParser) {
mParser->GetDTD(getter_AddRefs(dtd));
if (!dtd)
return;
}
const char* cp =
NS_ConvertUCS2toUTF8(dtd->IntTagToStringTag(aTag)).get();
nsIParserService *parserService =
nsContentUtils::GetParserServiceWeakRef();
if (!parserService)
return;
NS_ConvertUTF16toUTF8 tag(parserService->HTMLIdToStringTag(aTag));
PR_LogPrint("%s: this=%p node='%s' stackPos=%d",
aMsg, aThis, cp, aStackPos);
aMsg, aThis, tag.get(), aStackPos);
}
}
#endif
@ -858,8 +856,6 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
nsGenericHTMLElement* aForm,
nsIDocShell* aDocShell)
{
nsresult rv = NS_OK;
// Find/create atom for the tag name
nsCOMPtr<nsINodeInfo> nodeInfo;
@ -869,19 +865,22 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
ToLowerCase(tmp);
nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
rv = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
getter_AddRefs(nodeInfo));
mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
getter_AddRefs(nodeInfo));
} else {
nsCOMPtr<nsIDTD> dtd;
rv = mParser->GetDTD(getter_AddRefs(dtd));
if (NS_SUCCEEDED(rv)) {
rv = mNodeInfoManager->GetNodeInfo(dtd->IntTagToAtom(aNodeType), nsnull,
kNameSpaceID_None,
getter_AddRefs(nodeInfo));
}
nsIParserService *parserService =
nsContentUtils::GetParserServiceWeakRef();
if (!parserService)
return nsnull;
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));
}
NS_ENSURE_SUCCESS(rv, nsnull);
NS_ENSURE_TRUE(nodeInfo, nsnull);
// Make the content object
nsGenericHTMLElement* result = MakeContentObject(aNodeType, nodeInfo, aForm,
@ -906,30 +905,17 @@ NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo)
nsIAtom *name = aNodeInfo->NameAtom();
PRInt32 id;
nsHTMLTag id;
nsRefPtr<nsGenericHTMLElement> result;
if (aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) {
// Find tag in tag table
parserService->HTMLCaseSensitiveAtomTagToId(name, &id);
id = nsHTMLTag(parserService->HTMLCaseSensitiveAtomTagToId(name));
// XXX Temporary fix for
// 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);
result = MakeContentObject(id, aNodeInfo, nsnull, PR_FALSE, PR_FALSE);
}
else {
// Find tag in tag table
parserService->HTMLAtomTagToId(name, &id);
// XXX Temporary fix for
// https://bugzilla.mozilla.org/show_bug.cgi?id=285166
if (id > NS_HTML_TAG_MAX) {
id = eHTMLTag_userdefined;
}
id = nsHTMLTag(parserService->HTMLAtomTagToId(name));
// Reverse map id to name to get the correct character case in
// the tag name.
@ -937,16 +923,13 @@ NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo)
nsCOMPtr<nsINodeInfo> kungFuDeathGrip;
nsINodeInfo *nodeInfo = aNodeInfo;
if (nsHTMLTag(id) != eHTMLTag_userdefined) {
const PRUnichar *tag = nsnull;
parserService->HTMLIdToStringTag(id, &tag);
if (id != eHTMLTag_userdefined) {
nsIAtom *tag = parserService->HTMLIdToAtomTag(id);
NS_ASSERTION(tag, "What? Reverse mapping of id to string broken!!!");
if (!name->Equals(nsDependentString(tag))) {
nsCOMPtr<nsIAtom> atom = do_GetAtom(tag);
if (name != tag) {
nsresult rv =
nsContentUtils::NameChanged(aNodeInfo, atom,
nsContentUtils::NameChanged(aNodeInfo, tag,
getter_AddRefs(kungFuDeathGrip));
NS_ENSURE_SUCCESS(rv, rv);
@ -954,8 +937,7 @@ NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo)
}
}
result = MakeContentObject(nsHTMLTag(id), nodeInfo, nsnull,
PR_FALSE, PR_FALSE);
result = MakeContentObject(id, nodeInfo, nsnull, PR_FALSE, PR_FALSE);
}
return result ? CallQueryInterface(result.get(), aResult)
@ -1125,16 +1107,18 @@ SinkContext::DidAddContent(nsIContent* aContent, PRBool aDidNotify)
#ifdef NS_DEBUG
// Tracing code
nsCOMPtr<nsIDTD> dtd;
mSink->mParser->GetDTD(getter_AddRefs(dtd));
nsHTMLTag tag = nsHTMLTag(mStack[mStackPos - 1].mType);
nsDependentString str(dtd->IntTagToStringTag(tag));
nsIParserService *parserService =
nsContentUtils::GetParserServiceWeakRef();
if (parserService) {
nsHTMLTag tag = nsHTMLTag(mStack[mStackPos - 1].mType);
NS_ConvertUTF16toUTF8 str(parserService->HTMLIdToStringTag(tag));
SINK_TRACE(SINK_TRACE_REFLOW,
("SinkContext::DidAddContent: Insertion notification for "
"parent=%s at position=%d and stackPos=%d",
NS_LossyConvertUCS2toASCII(str).get(),
mStack[mStackPos - 1].mInsertionPoint - 1, mStackPos - 1));
SINK_TRACE(SINK_TRACE_REFLOW,
("SinkContext::DidAddContent: Insertion notification for "
"parent=%s at position=%d and stackPos=%d",
str.get(), mStack[mStackPos - 1].mInsertionPoint - 1,
mStackPos - 1));
}
#endif
mSink->NotifyInsert(parent, aContent,

Просмотреть файл

@ -3079,18 +3079,15 @@ nsHTMLDocument::RemoveFromIdTable(nsIContent *aContent)
nsresult
nsHTMLDocument::UnregisterNamedItems(nsIContent *aContent)
{
nsIAtom *tag = aContent->Tag();
if (tag == nsLayoutAtoms::textTagName) {
if (aContent->IsContentOfType(nsIContent::eTEXT)) {
// Text nodes are not named items nor can they have children.
return NS_OK;
}
nsAutoString value;
nsresult rv = NS_OK;
if (!IsXHTML() && IsNamedItem(aContent, tag, value)) {
if (!IsXHTML() && IsNamedItem(aContent, aContent->Tag(), value)) {
rv = RemoveFromNameTable(value, aContent);
if (NS_FAILED(rv)) {
@ -3116,17 +3113,14 @@ nsHTMLDocument::UnregisterNamedItems(nsIContent *aContent)
nsresult
nsHTMLDocument::RegisterNamedItems(nsIContent *aContent)
{
nsIAtom *tag = aContent->Tag();
if (tag == nsLayoutAtoms::textTagName) {
if (aContent->IsContentOfType(nsIContent::eTEXT)) {
// Text nodes are not named items nor can they have children.
return NS_OK;
}
nsAutoString value;
if (!IsXHTML() && IsNamedItem(aContent, tag, value)) {
if (!IsXHTML() && IsNamedItem(aContent, aContent->Tag(), value)) {
UpdateNameTableEntry(value, aContent);
}
@ -3162,15 +3156,15 @@ FindNamedItems(const nsAString& aName, nsIContent *aContent,
nsIAtom *tag = aContent->Tag();
if (tag == nsLayoutAtoms::textTagName) {
if (aContent->IsContentOfType(nsIContent::eTEXT)) {
// Text nodes are not named items nor can they have children.
return;
}
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);
}

Просмотреть файл

@ -462,15 +462,11 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
if (!parserService)
return NS_ERROR_OUT_OF_MEMORY;
const PRUnichar *name = nsnull;
parserService->HTMLIdToStringTag(nodeType, &name);
nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
NS_ASSERTION(name, "This should not happen!");
result =
mNodeInfoManager->GetNodeInfo(nsDependentString(name), nsnull,
kNameSpaceID_None,
getter_AddRefs(nodeInfo));
result = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
getter_AddRefs(nodeInfo));
}
NS_ENSURE_SUCCESS(result, result);
@ -565,14 +561,12 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
kNameSpaceID_None,
getter_AddRefs(nodeInfo));
} else {
const PRUnichar *name = nsnull;
result = parserService->HTMLIdToStringTag(nodeType, &name);
nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
NS_ASSERTION(name, "This should not happen!");
result =
mNodeInfoManager->GetNodeInfo(nsDependentString(name), nsnull,
kNameSpaceID_None,
getter_AddRefs(nodeInfo));
result = mNodeInfoManager->GetNodeInfo(name, nsnull,
kNameSpaceID_None,
getter_AddRefs(nodeInfo));
}
NS_ENSURE_SUCCESS(result, result);

Просмотреть файл

@ -119,7 +119,7 @@ NS_IMPL_RELEASE_INHERITED(nsXMLCDATASection, nsGenericDOMDataNode)
nsIAtom *
nsXMLCDATASection::Tag() const
{
return nsLayoutAtoms::textTagName;
return nsLayoutAtoms::cdataTagName;
}
PRBool

Просмотреть файл

@ -665,7 +665,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
// first element we've generated?
}
}
else if (tag == nsLayoutAtoms::textTagName) {
else if (tmplKid->IsContentOfType(nsIContent::eTEXT)) {
nsCOMPtr<nsIDOMNode> tmplTextNode = do_QueryInterface(tmplKid);
if (!tmplTextNode) {
NS_ERROR("textnode not implementing nsIDOMNode??");

Просмотреть файл

@ -113,6 +113,7 @@
#include "nsIInlineSpellChecker.h"
#include "nsINameSpaceManager.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_TEXTNODE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_EDITOR,2)
@ -122,13 +123,13 @@ static PRBool gNoisy = PR_FALSE;
#endif
PRInt32 nsEditor::gInstanceCount = 0;
// Value of "ime.password.onFocus.dontCare"
static PRBool gDontCareForIMEOnFocusPassword = PR_FALSE;
// Value of "ime.password.onBlur.dontCare"
static PRBool gDontCareForIMEOnBlurPassword = PR_FALSE;
nsIParserService* nsEditor::sParserService;
//---------------------------------------------------------------------------
//
// nsEditor: base editor class implementation
@ -168,9 +169,6 @@ nsEditor::nsEditor()
, mPhonetic(nsnull)
{
//initialize member variables here
PR_AtomicIncrement(&gInstanceCount);
if (!gTypingTxnName)
gTypingTxnName = NS_NewAtom("Typing");
else
@ -249,11 +247,23 @@ nsEditor::~nsEditor()
delete mPhonetic;
PR_AtomicDecrement(&gInstanceCount);
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)
@ -3833,7 +3843,7 @@ nsEditor::TagCanContain(const nsAString &aParentTag, nsIDOMNode* aChild)
if (IsTextNode(aChild))
{
childStringTag.AssignLiteral("__moz_text");
childStringTag.AssignLiteral("#text");
}
else
{
@ -3849,14 +3859,19 @@ nsEditor::TagCanContainTag(const nsAString &aParentTag, const nsAString &aChildT
{
// if we don't have a dtd then assume we can insert whatever want
if (!mDTD) return PR_TRUE;
PRInt32 childTagEnum, parentTagEnum;
nsAutoString non_const_childTag(aChildTag);
nsresult res = mDTD->StringTagToIntTag(non_const_childTag,&childTagEnum);
if (NS_FAILED(res)) return PR_FALSE;
nsAutoString non_const_parentTag(aParentTag);
res = mDTD->StringTagToIntTag(non_const_parentTag,&parentTagEnum);
if (NS_FAILED(res)) return PR_FALSE;
PRInt32 childTagEnum;
// XXX Should this handle #cdata-section too?
if (aChildTag.EqualsLiteral("#text")) {
childTagEnum = eHTMLTag_text;
}
else {
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);
}
@ -3901,11 +3916,10 @@ nsEditor::IsContainer(nsIDOMNode *aNode)
{
if (!aNode) return PR_FALSE;
nsAutoString stringTag;
PRInt32 tagEnum;
nsresult res = aNode->GetNodeName(stringTag);
if (NS_FAILED(res)) return PR_FALSE;
res = mDTD->StringTagToIntTag(stringTag,&tagEnum);
if (NS_FAILED(res)) return PR_FALSE;
PRInt32 tagEnum = sParserService->HTMLStringTagToId(stringTag);
return mDTD->IsContainer(tagEnum);
}

Просмотреть файл

@ -86,6 +86,7 @@ class RemoveStyleSheetTxn;
class nsIFile;
class nsISelectionController;
class nsIDOMEventReceiver;
class nsIParserService;
#define kMOZEditorBogusNodeAttr NS_LITERAL_STRING("_moz_editor_bogus_node")
#define kMOZEditorBogusNodeValue NS_LITERAL_STRING("TRUE")
@ -135,7 +136,10 @@ public:
* for someone to derive from the nsEditor later? I dont believe so.
*/
virtual ~nsEditor();
static nsresult Init();
static void Shutdown();
//Interfaces for addref and release and queryinterface
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsEditor
NS_DECL_ISUPPORTS
@ -637,7 +641,7 @@ protected:
nsCOMPtr<nsIDOMEventListener> mDragListenerP;
nsCOMPtr<nsIDOMEventListener> mFocusListenerP;
static PRInt32 gInstanceCount;
static nsIParserService *sParserService;
friend PRBool NSCanUnload(nsISupports* serviceMgr);
friend class nsAutoTxnsConserveSelection;

Просмотреть файл

@ -39,7 +39,7 @@
#include "nsIGenericFactory.h"
#include "nsEditorCID.h"
#include "nsEditor.h" // for gInstanceCount
#include "nsEditor.h"
#include "nsPlaintextEditor.h"
#include "nsEditorController.h" //CID
#include "nsIController.h"
@ -95,6 +95,12 @@ Initialize(nsIModule* self)
gInitialized = PR_TRUE;
nsresult rv = nsEditor::Init();
if (NS_FAILED(rv)) {
gInitialized = PR_FALSE;
return rv;
}
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
nsEditProperty::RegisterAtoms();
nsTextServicesDocument::RegisterAtoms();
@ -130,6 +136,7 @@ Shutdown()
if (!gInitialized)
return;
nsEditor::Shutdown();
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
nsHTMLEditor::Shutdown();
nsTextServicesDocument::Shutdown();

Просмотреть файл

@ -157,7 +157,8 @@ nsresult TextEditorTest::TestTextProperties()
TEST_RESULT(result);
TEST_POINTER(doc.get());
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));
TEST_RESULT(result);
TEST_POINTER(nodeList.get());

Просмотреть файл

@ -1323,7 +1323,8 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction,
if (NS_FAILED(res)) return res;
// 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;
// we need to get the doc

Просмотреть файл

@ -130,6 +130,7 @@
#include "nsIFrame.h"
#include "nsIView.h"
#include "nsIWidget.h"
#include "nsIParserService.h"
static NS_DEFINE_CID(kCTransitionalDTDCID, NS_CTRANSITIONAL_DTD_CID);
@ -138,7 +139,6 @@ static char hrefText[] = "href";
static char anchorTxt[] = "anchor";
static char namedanchorText[] = "namedanchor";
nsIParserService* nsHTMLEditor::sParserService;
nsIRangeUtils* nsHTMLEditor::sRangeHelper;
// some prototypes for rules creation shortcuts
@ -231,7 +231,6 @@ nsHTMLEditor::~nsHTMLEditor()
void
nsHTMLEditor::Shutdown()
{
NS_IF_RELEASE(sParserService);
NS_IF_RELEASE(sRangeHelper);
}
@ -544,11 +543,6 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock)
nsIAtom *tagAtom = GetTag(aNode);
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
// even though the parser says they're not:
if (tagAtom==nsEditProperty::body ||
@ -568,10 +562,8 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock)
return NS_OK;
}
PRInt32 id;
rv = sParserService->HTMLAtomTagToId(tagAtom, &id);
if (NS_FAILED(rv)) return rv;
rv = sParserService->IsBlock(id, *aIsBlock);
rv = sParserService->IsBlock(sParserService->HTMLAtomTagToId(tagAtom),
*aIsBlock);
#ifdef DEBUG
// Check this against what we would have said with the old code:
@ -4283,16 +4275,13 @@ nsHTMLEditor::TagCanContainTag(const nsAString& aParentTag, const nsAString& aCh
// if parent is a pre, and child is not inline, say "no"
if ( aParentTag.EqualsLiteral("pre") )
{
if (aChildTag.EqualsLiteral("__moz_text"))
if (aChildTag.EqualsLiteral("#text"))
return PR_TRUE;
PRInt32 childTagEnum, parentTagEnum;
nsAutoString non_const_childTag(aChildTag);
nsAutoString non_const_parentTag(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))
PRInt32 childTagEnum = sParserService->HTMLStringTagToId(aChildTag);
PRInt32 parentTagEnum = sParserService->HTMLStringTagToId(aParentTag);
if (!mDTD->IsInlineElement(childTagEnum, parentTagEnum))
return PR_FALSE;
}
*/

Просмотреть файл

@ -61,7 +61,6 @@
#include "nsEditProperty.h"
#include "nsHTMLCSSUtils.h"
#include "nsIParserService.h"
#include "nsVoidArray.h"
@ -782,9 +781,6 @@ protected:
// for real-time spelling
nsCOMPtr<nsITextServicesDocument> mTextServices;
// Maintain a static parser service ...
static nsIParserService* sParserService;
// And a static range utils service
static nsIRangeUtils* sRangeHelper;

Просмотреть файл

@ -629,7 +629,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction,
if (NS_FAILED(res)) return res;
// 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;
// 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!
PRInt32 nsFind::sInstanceCount = 0;
nsIAtom* nsFind::sTextAtom = nsnull;
nsIAtom* nsFind::sImgAtom = nsnull;
nsIAtom* nsFind::sHRAtom = nsnull;
nsIAtom* nsFind::sCommentAtom = nsnull;
nsIAtom* nsFind::sScriptAtom = nsnull;
nsIAtom* nsFind::sNoframesAtom = nsnull;
nsIAtom* nsFind::sSelectAtom = nsnull;
@ -468,10 +466,8 @@ nsFind::nsFind()
// Initialize the atoms if they aren't already:
if (sInstanceCount <= 0)
{
sTextAtom = NS_NewAtom("__moz_text");
sImgAtom = NS_NewAtom("img");
sHRAtom = NS_NewAtom("hr");
sCommentAtom = NS_NewAtom("__moz_comment");
sScriptAtom = NS_NewAtom("script");
sNoframesAtom = NS_NewAtom("noframes");
sSelectAtom = NS_NewAtom("select");
@ -486,10 +482,8 @@ nsFind::~nsFind()
{
if (sInstanceCount <= 1)
{
NS_IF_RELEASE(sTextAtom);
NS_IF_RELEASE(sImgAtom);
NS_IF_RELEASE(sHRAtom);
NS_IF_RELEASE(sCommentAtom);
NS_IF_RELEASE(sScriptAtom);
NS_IF_RELEASE(sNoframesAtom);
NS_IF_RELEASE(sSelectAtom);
@ -806,11 +800,8 @@ PRBool nsFind::IsBlockNode(nsIContent* aContent)
return PR_FALSE;
}
PRInt32 id;
mParserService->HTMLAtomTagToId(atom, &id);
PRBool isBlock = PR_FALSE;
mParserService->IsBlock(id, isBlock);
mParserService->IsBlock(mParserService->HTMLAtomTagToId(atom), isBlock);
return isBlock;
}
@ -820,7 +811,7 @@ PRBool nsFind::IsTextNode(nsIDOMNode* aNode)
// also implements that interface.
nsCOMPtr<nsIContent> content (do_QueryInterface(aNode));
return content && content->Tag() == sTextAtom;
return content && content->IsContentOfType(nsIContent::eTEXT);
}
PRBool nsFind::IsVisibleNode(nsIDOMNode *aDOMNode)
@ -856,10 +847,9 @@ PRBool nsFind::SkipNode(nsIContent* aContent)
// We may not need to skip comment nodes,
// now that IsTextNode distinguishes them from real text nodes.
return (atom == sCommentAtom ||
return (aContent->IsContentOfType(nsIContent::eCOMMENT) ||
(aContent->IsContentOfType(nsIContent::eHTML) &&
(atom == sScriptAtom ||
atom == sCommentAtom ||
atom == sNoframesAtom ||
atom == sSelectAtom)));
@ -874,7 +864,7 @@ PRBool nsFind::SkipNode(nsIContent* aContent)
{
atom = content->Tag();
if (atom == sCommentAtom ||
if (aContent->IsContentOfType(nsIContent::eCOMMENT) ||
(content->IsContentOfType(nsIContent::eHTML) &&
(atom == sScriptAtom ||
atom == sNoframesAtom ||

Просмотреть файл

@ -69,11 +69,9 @@ protected:
static PRInt32 sInstanceCount;
// HTML tags we treat specially
static nsIAtom* sTextAtom;
static nsIAtom* sImgAtom;
static nsIAtom* sHRAtom;
// Nodes we skip
static nsIAtom* sCommentAtom;
static nsIAtom* sScriptAtom;
static nsIAtom* sNoframesAtom;
static nsIAtom* sSelectAtom;

Просмотреть файл

@ -3763,29 +3763,19 @@ nsCSSFrameConstructor::ConstructTableCellFrame(nsFrameConstructorState& aState,
return rv;
}
PRBool
nsCSSFrameConstructor::MustGeneratePseudoParent(nsIAtom* aTag,
nsIContent* aContent,
nsStyleContext* aStyleContext)
static PRBool
MustGeneratePseudoParent(nsIContent* aContent, nsStyleContext* aStyleContext)
{
if (!aStyleContext)
return PR_FALSE;
if (NS_STYLE_DISPLAY_NONE == aStyleContext->GetStyleDisplay()->mDisplay)
if (!aStyleContext ||
NS_STYLE_DISPLAY_NONE == aStyleContext->GetStyleDisplay()->mDisplay) {
return PR_FALSE;
}
// check tags first
if ((nsLayoutAtoms::textTagName == aTag)) {
if (aContent->IsContentOfType(nsIContent::eTEXT)) {
return !IsOnlyWhitespace(aContent);
}
// exclude tags
if ( nsLayoutAtoms::commentTagName == aTag) {
return PR_FALSE;
}
return PR_TRUE;
return !aContent->IsContentOfType(nsIContent::eCOMMENT);
}
// 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;
PRBool hasPseudoParent = PR_FALSE;
nsIAtom *tag = aContent->Tag();
if (MustGeneratePseudoParent(tag, aContent, aStyleContext)) {
if (MustGeneratePseudoParent(aContent, aStyleContext)) {
// this frame may have a pseudo parent, use block frame type to
// trigger foreign
rv = GetParentFrame(aTableCreator,
@ -6762,7 +6750,7 @@ nsCSSFrameConstructor::ResolveStyleContext(nsIFrame* aParentFrame,
return styleSet->ResolveStyleFor(aContent, parentStyleContext);
} else {
NS_ASSERTION(aContent->Tag() == nsLayoutAtoms::textTagName,
NS_ASSERTION(aContent->IsContentOfType(nsIContent::eTEXT),
"shouldn't waste time creating style contexts for "
"comments and processing instructions");
@ -7467,12 +7455,9 @@ nsCSSFrameConstructor::ConstructFrame(nsFrameConstructorState& aState,
return rv;
}
// Get the element's tag
nsIAtom *tag = aContent->Tag();
// never create frames for comments on PIs
if (tag == nsLayoutAtoms::commentTagName ||
tag == nsLayoutAtoms::processingInstructionTagName)
// never create frames for comments or PIs
if (aContent->IsContentOfType(nsIContent::eCOMMENT) ||
aContent->IsContentOfType(nsIContent::ePROCESSING_INSTRUCTION))
return rv;
nsRefPtr<nsStyleContext> styleContext;
@ -7487,8 +7472,8 @@ nsCSSFrameConstructor::ConstructFrame(nsFrameConstructorState& aState,
}
// construct the frame
rv = ConstructFrameInternal(aState, aContent, aParentFrame,
tag, aContent->GetNameSpaceID(), styleContext,
aFrameItems, PR_FALSE);
aContent->Tag(), aContent->GetNameSpaceID(),
styleContext, aFrameItems, PR_FALSE);
if (NS_SUCCEEDED(rv) && pageBreakAfter) {
// Construct the page break after
ConstructPageBreakFrame(aState, aContent, aParentFrame, styleContext,
@ -11482,7 +11467,7 @@ nsCSSFrameConstructor::FindPrimaryFrameFor(nsFrameManager* aFrameManager,
if (aHint && !*aFrame)
{ // 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
FFWC_slowSearchForText++;

Просмотреть файл

@ -330,10 +330,6 @@ private:
nsIFrame*& aNewCellInnerFrame,
PRBool& aIsPseudoParent);
PRBool MustGeneratePseudoParent(nsIAtom* aTag,
nsIContent* aContent,
nsStyleContext* aContext);
/**
* ConstructTableForeignFrame constructs the frame for a non-table-element
* 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
{
nsIContent *prevSibling;
nsIAtom *tag;
do {
prevSibling = parent->GetChildAt(--index);
tag = prevSibling->Tag();
} while (index &&
(tag == nsLayoutAtoms::textTagName ||
tag == nsLayoutAtoms::commentTagName ||
tag == nsLayoutAtoms::processingInstructionTagName));
(prevSibling->IsContentOfType(nsIContent::eTEXT) ||
prevSibling->IsContentOfType(nsIContent::eCOMMENT) ||
prevSibling->IsContentOfType(nsIContent::ePROCESSING_INSTRUCTION)));
if (prevSibling) {
entry = NS_STATIC_CAST(PrimaryFrameMapEntry*,
PL_DHashTableOperate(&mPrimaryFrameMap, prevSibling,

Просмотреть файл

@ -69,7 +69,6 @@ LAYOUT_ATOM(tty, "tty")
LAYOUT_ATOM(tv, "tv")
// Alphabetical list of standard name space prefixes
LAYOUT_ATOM(htmlNameSpace, "html")
LAYOUT_ATOM(xmlNameSpace, "xml")
LAYOUT_ATOM(xmlnsNameSpace, "xmlns")
@ -85,9 +84,10 @@ LAYOUT_ATOM(overflowList, "Overflow-list")
LAYOUT_ATOM(overflowOutOfFlowList, "OverflowOutOfFlow-list")
LAYOUT_ATOM(popupList, "Popup-list")
LAYOUT_ATOM(commentTagName, "__moz_comment")
LAYOUT_ATOM(textTagName, "__moz_text")
LAYOUT_ATOM(processingInstructionTagName, "__moz_pi")
LAYOUT_ATOM(commentTagName, "#comment")
LAYOUT_ATOM(textTagName, "#text")
LAYOUT_ATOM(cdataTagName, "#cdata-section")
LAYOUT_ATOM(processingInstructionTagName, "#processing-instruction")
LAYOUT_ATOM(documentFragmentNodeName, "#document-fragment")
// Alphabetical list of frame types

Просмотреть файл

@ -2783,13 +2783,10 @@ nsresult
nsFrame::MakeFrameName(const nsAString& aType, nsAString& aResult) const
{
aResult = aType;
if (mContent) {
nsIAtom *tag = mContent->Tag();
if (tag != nsLayoutAtoms::textTagName) {
nsAutoString buf;
tag->ToString(buf);
aResult.Append(NS_LITERAL_STRING("(") + buf + NS_LITERAL_STRING(")"));
}
if (mContent && !mContent->IsContentOfType(nsIContent::eTEXT)) {
nsAutoString buf;
mContent->Tag()->ToString(buf);
aResult.Append(NS_LITERAL_STRING("(") + buf + NS_LITERAL_STRING(")"));
}
char buf[40];
PR_snprintf(buf, sizeof(buf), "(%d)", ContentIndexInContainer(this));
@ -3453,12 +3450,11 @@ nsPeekOffsetStruct nsIFrame::GetExtremeCaretPosition(PRBool aStart)
if (!content)
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 non-text element may make the caret missing)
nsIAtom* tag = content->Tag();
if (tag != nsLayoutAtoms::textTagName) {
if (!content->IsContentOfType(nsIContent::eTEXT)) {
// special case in effect
nsIContent* parent = content->GetParent();
NS_ASSERTION(parent,"element has no parent!");

Просмотреть файл

@ -2834,14 +2834,14 @@ static PRBool IsSignificantChild(nsIContent* aChild, PRBool aTextIsSignificant,
NS_ASSERTION(!aWhitespaceIsSignificant || aTextIsSignificant,
"Nonsensical arguments");
nsIAtom *tag = aChild->Tag(); // skip text, comments, and PIs
if ((tag != nsLayoutAtoms::textTagName) &&
(tag != nsLayoutAtoms::commentTagName) &&
(tag != nsLayoutAtoms::processingInstructionTagName)) {
PRBool isText = aChild->IsContentOfType(nsIContent::eTEXT);
if (!isText && !aChild->IsContentOfType(nsIContent::eCOMMENT) &&
!aChild->IsContentOfType(nsIContent::ePROCESSING_INSTRUCTION)) {
return PR_TRUE;
}
if (aTextIsSignificant && tag == nsLayoutAtoms::textTagName) {
if (aTextIsSignificant && isText) {
if (!aWhitespaceIsSignificant) {
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
enum anyway */
/* XXX: The second parameters in some of the following entries look
like they are just wrong. They should really be NOTUSED. For now,
I'm just emulating what nsHTMLContentSink has done all along.
*/
HTML_OTHER(text, Span)
HTML_OTHER(whitespace, Span)
HTML_OTHER(newline, Span)
HTML_OTHER(comment, Span)
HTML_OTHER(entity, Span)
HTML_OTHER(doctypeDecl, Span)
HTML_OTHER(markupDecl, Span)
HTML_OTHER(instruction, Span)
HTML_OTHER(text)
HTML_OTHER(whitespace)
HTML_OTHER(newline)
HTML_OTHER(comment)
HTML_OTHER(entity)
HTML_OTHER(doctypeDecl)
HTML_OTHER(markupDecl)
HTML_OTHER(instruction)

Просмотреть файл

@ -50,7 +50,7 @@ class nsIAtom;
*/
#define HTML_TAG(_tag, _classname) eHTMLTag_##_tag,
#define HTML_OTHER(_tag, _classname) eHTMLTag_##_tag,
#define HTML_OTHER(_tag) eHTMLTag_##_tag,
enum nsHTMLTag {
/* this enum must be first and must be zero */
eHTMLTag_unknown = 0,

Просмотреть файл

@ -83,7 +83,6 @@ class CToken;
class nsIURI;
class nsIContentSink;
class CParserContext;
class nsIAtom;
class nsIDTD : public nsISupports
{
@ -203,29 +202,6 @@ public:
NS_IMETHOD_(PRInt32) GetType() = 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 \
@ -242,10 +218,5 @@ public:
NS_IMETHOD_(PRBool) IsContainer(PRInt32 aTag) const;\
NS_IMETHOD CollectSkippedContent(PRInt32 aTag, nsAString& aContent, PRInt32 &aLineNo);\
NS_IMETHOD_(void) Terminate();\
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;
NS_IMETHOD_(PRInt32) GetType();
#endif /* nsIDTD_h___ */

Просмотреть файл

@ -41,13 +41,12 @@
#include "nsISupports.h"
#include "nsString.h"
#include "nsHTMLTags.h"
#include "nsIParserNode.h"
#include "nsIParser.h"
#include "nsVoidArray.h"
#include "nsIElementObserver.h"
#define NS_PARSER_CONTRACTID_PREFIX "@mozilla.org/parser"
#define NS_PARSERSERVICE_CONTRACTID NS_PARSER_CONTRACTID_PREFIX "/parser-service;1"
class nsIParser;
class nsIParserNode;
#define NS_PARSERSERVICE_CONTRACTID "@mozilla.org/parser/parser-service;1"
// {90a92e37-abd6-441b-9b39-4064d98e1ede}
#define NS_IPARSERSERVICE_IID \
@ -74,16 +73,66 @@ class nsIParserService : public nsISupports {
public:
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,
PRInt32* aUnicode) const = 0;

Просмотреть файл

@ -2426,40 +2426,6 @@ PRBool CNavDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const
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
* the given childtag is a block element.

Просмотреть файл

@ -372,6 +372,8 @@ protected:
nsresult HandleSavedTokens(PRInt32 anIndex);
nsresult HandleKeyGen(nsIParserNode *aNode);
PRBool IsAlternateTag(eHTMLTags aTag);
PRBool IsBlockElement(PRInt32 aTagID, PRInt32 aParentID) const;
PRBool IsInlineElement(PRInt32 aTagID, PRInt32 aParentID) const;
nsDeque mMisplacedContent;
nsDeque mSkippedContent;

Просмотреть файл

@ -813,79 +813,6 @@ PRBool COtherDTD::CanContain(PRInt32 aParent,PRInt32 aChild) const {
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
* tag is itself a container

Просмотреть файл

@ -1178,18 +1178,6 @@ nsExpatDriver::HandleToken(CToken* aToken,nsIParser* aParser)
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)
nsExpatDriver::IsContainer(PRInt32 aTag) const
{
@ -1201,21 +1189,3 @@ nsExpatDriver::CanContain(PRInt32 aParent,PRInt32 aChild) const
{
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
#define HTML_TAG(_tag, _classname) sHTMLTagUnicodeName_##_tag,
#define HTML_OTHER(_tag, _classname)
#define HTML_OTHER(_tag)
static const PRUnichar* const kTagUnicodeTable[] = {
#include "nsHTMLTagList.h"
};
@ -390,7 +390,7 @@ nsHTMLTags::CaseSensitiveLookupTag(const PRUnichar* aTagName)
PRUint32 tag = NS_PTR_TO_INT32(PL_HashTableLookupConst(gTagTable, aTagName));
return (nsHTMLTag)tag;
return tag == eHTMLTag_unknown ? eHTMLTag_userdefined : (nsHTMLTag)tag;
}
// static
@ -429,34 +429,7 @@ nsHTMLTags::LookupTag(const nsAString& aTagName)
buf[i] = 0;
nsHTMLTag tag = 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;
return CaseSensitiveLookupTag(buf);
}
// static

Просмотреть файл

@ -62,45 +62,40 @@ nsParserService::~nsParserService()
NS_IMPL_ISUPPORTS1(nsParserService, nsIParserService)
NS_IMETHODIMP
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom, PRInt32* aId) const
PRInt32
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom) const
{
nsAutoString tagName;
aAtom->ToString(tagName);
*aId = nsHTMLTags::LookupTag(tagName);
return NS_OK;
return nsHTMLTags::LookupTag(tagName);
}
NS_IMETHODIMP
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom,
PRInt32* aId) const
PRInt32
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const
{
nsAutoString tagName;
aAtom->ToString(tagName);
*aId = nsHTMLTags::CaseSensitiveLookupTag(tagName.get());
return NS_OK;
return nsHTMLTags::CaseSensitiveLookupTag(tagName.get());
}
NS_IMETHODIMP
nsParserService::HTMLStringTagToId(const nsAString &aTagName,
PRInt32* aId) const
PRInt32
nsParserService::HTMLStringTagToId(const nsAString& aTag) const
{
*aId = nsHTMLTags::LookupTag(aTagName);
return NS_OK;
return nsHTMLTags::LookupTag(aTag);
}
NS_IMETHODIMP
nsParserService::HTMLIdToStringTag(PRInt32 aId,
const PRUnichar **aTagName) const
const PRUnichar*
nsParserService::HTMLIdToStringTag(PRInt32 aId) const
{
*aTagName = nsHTMLTags::GetStringValue((nsHTMLTag)aId);
return NS_OK;
return nsHTMLTags::GetStringValue((nsHTMLTag)aId);
}
nsIAtom*
nsParserService::HTMLIdToAtomTag(PRInt32 aId) const
{
return nsHTMLTags::GetAtom((nsHTMLTag)aId);
}
NS_IMETHODIMP
@ -163,7 +158,7 @@ nsParserService::RegisterObserver(nsIElementObserver* aObserver,
}
while (*aTags) {
if(*aTags != eHTMLTag_userdefined && *aTags <= NS_HTML_TAG_MAX) {
if (*aTags <= NS_HTML_TAG_MAX) {
entry->AddObserver(aObserver,*aTags);
}
++aTags;

Просмотреть файл

@ -52,15 +52,16 @@ public:
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* aId) const;
PRInt32 HTMLStringTagToId(const nsAString& aTag) 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,
PRInt32* aUnicode) const;
NS_IMETHOD HTMLConvertUnicodeToEntity(PRInt32 aUnicode,

Просмотреть файл

@ -872,51 +872,6 @@ PRBool CViewSourceHTML::CanContain(PRInt32 aParent,PRInt32 aChild) const{
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
* tag is itself a container