Fix for bug 286300 (Clean up HTML tags enum and related code). r=mrbkap, sr=bz, a=asa.
git-svn-id: svn://10.0.0.236/trunk@174703 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user