code cleanup (remove some NS_LITERAL_STRINGs in favor of existing ut

ility methods); r=cmanske, sr=tor, bug=209548
This commit is contained in:
brade%netscape.com 2003-07-17 23:44:13 +00:00
parent c53cbbda66
commit 55cece0652

View File

@ -1216,7 +1216,7 @@ nsHTMLEditRules::GetFormatString(nsIDOMNode *aNode, nsAString &outFormat)
} }
else else
{ {
format.Truncate(0); format.Truncate();
} }
outFormat = format; outFormat = format;
@ -3307,18 +3307,10 @@ nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection,
nsCOMPtr<nsIDOMNode> curBlockPar; nsCOMPtr<nsIDOMNode> curBlockPar;
if (!curBlock) return NS_ERROR_NULL_POINTER; if (!curBlock) return NS_ERROR_NULL_POINTER;
curBlock->GetParentNode(getter_AddRefs(curBlockPar)); curBlock->GetParentNode(getter_AddRefs(curBlockPar));
nsAutoString curBlockTag; if (nsHTMLEditUtils::IsPre(curBlock) ||
nsEditor::GetTagString(curBlock, curBlockTag); nsHTMLEditUtils::IsParagraph(curBlock) ||
ToLowerCase(curBlockTag); nsHTMLEditUtils::IsHeader(curBlock) ||
if ((curBlockTag.Equals(NS_LITERAL_STRING("pre"))) || nsHTMLEditUtils::IsAddress(curBlock))
(curBlockTag.Equals(NS_LITERAL_STRING("p"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h1"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h2"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h3"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h4"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h5"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h6"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("address"))))
{ {
// if the first editable node after selection is a br, consume it. Otherwise // if the first editable node after selection is a br, consume it. Otherwise
// it gets pushed into a following block after the split, which is visually bad. // it gets pushed into a following block after the split, which is visually bad.
@ -6689,15 +6681,10 @@ nsHTMLEditRules::RemoveBlockStyle(nsCOMArray<nsIDOMNode>& arrayOfNodes)
ToLowerCase(curNodeTag); ToLowerCase(curNodeTag);
// if curNode is a address, p, header, address, or pre, remove it // if curNode is a address, p, header, address, or pre, remove it
if ((curNodeTag.Equals(NS_LITERAL_STRING("pre"))) || if (nsHTMLEditUtils::IsPre(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("p"))) || nsHTMLEditUtils::IsParagraph(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("h1"))) || nsHTMLEditUtils::IsHeader(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("h2"))) || nsHTMLEditUtils::IsAddress(curNode))
(curNodeTag.Equals(NS_LITERAL_STRING("h3"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("h4"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("h5"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("h6"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("address"))))
{ {
// process any partial progress saved // process any partial progress saved
if (curBlock) if (curBlock)
@ -6710,16 +6697,14 @@ nsHTMLEditRules::RemoveBlockStyle(nsCOMArray<nsIDOMNode>& arrayOfNodes)
res = mHTMLEditor->RemoveBlockContainer(curNode); res = mHTMLEditor->RemoveBlockContainer(curNode);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
else if ((curNodeTag.Equals(NS_LITERAL_STRING("table"))) || else if (nsHTMLEditUtils::IsTable(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("tbody"))) || (curNodeTag.Equals(NS_LITERAL_STRING("tbody"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("tr"))) || (curNodeTag.Equals(NS_LITERAL_STRING("tr"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("td"))) || (curNodeTag.Equals(NS_LITERAL_STRING("td"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("ol"))) || nsHTMLEditUtils::IsList(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("ul"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("dl"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("li"))) || (curNodeTag.Equals(NS_LITERAL_STRING("li"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("blockquote"))) || nsHTMLEditUtils::IsBlockquote(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("div")))) nsHTMLEditUtils::IsDiv(curNode))
{ {
// process any partial progress saved // process any partial progress saved
if (curBlock) if (curBlock)
@ -6757,17 +6742,10 @@ nsHTMLEditRules::RemoveBlockStyle(nsCOMArray<nsIDOMNode>& arrayOfNodes)
} }
} }
curBlock = mHTMLEditor->GetBlockNodeParent(curNode); curBlock = mHTMLEditor->GetBlockNodeParent(curNode);
nsEditor::GetTagString(curBlock, curBlockTag); if (nsHTMLEditUtils::IsPre(curBlock) ||
ToLowerCase(curBlockTag); nsHTMLEditUtils::IsParagraph(curBlock) ||
if ((curBlockTag.Equals(NS_LITERAL_STRING("pre"))) || nsHTMLEditUtils::IsHeader(curBlock) ||
(curBlockTag.Equals(NS_LITERAL_STRING("p"))) || nsHTMLEditUtils::IsAddress(curBlock))
(curBlockTag.Equals(NS_LITERAL_STRING("h1"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h2"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h3"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h4"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h5"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("h6"))) ||
(curBlockTag.Equals(NS_LITERAL_STRING("address"))))
{ {
firstNode = curNode; firstNode = curNode;
lastNode = curNode; lastNode = curNode;
@ -6851,30 +6829,23 @@ nsHTMLEditRules::ApplyBlockStyle(nsCOMArray<nsIDOMNode>& arrayOfNodes, const nsA
// it with a new block of correct type. // it with a new block of correct type.
// xxx floppy moose: pre cant hold everything the others can // xxx floppy moose: pre cant hold everything the others can
if (nsHTMLEditUtils::IsMozDiv(curNode) || if (nsHTMLEditUtils::IsMozDiv(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("pre"))) || nsHTMLEditUtils::IsPre(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("p"))) || nsHTMLEditUtils::IsParagraph(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("h1"))) || nsHTMLEditUtils::IsHeader(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("h2"))) || nsHTMLEditUtils::IsAddress(curNode))
(curNodeTag.Equals(NS_LITERAL_STRING("h3"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("h4"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("h5"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("h6"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("address"))))
{ {
curBlock = 0; // forget any previous block used for previous inline nodes curBlock = 0; // forget any previous block used for previous inline nodes
res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock), *aBlockTag); res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock), *aBlockTag);
if (NS_FAILED(res)) return res; if (NS_FAILED(res)) return res;
} }
else if ((curNodeTag.Equals(NS_LITERAL_STRING("table"))) || else if (nsHTMLEditUtils::IsTable(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("tbody"))) || (curNodeTag.Equals(NS_LITERAL_STRING("tbody"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("tr"))) || (curNodeTag.Equals(NS_LITERAL_STRING("tr"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("td"))) || (curNodeTag.Equals(NS_LITERAL_STRING("td"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("ol"))) || nsHTMLEditUtils::IsList(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("ul"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("dl"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("li"))) || (curNodeTag.Equals(NS_LITERAL_STRING("li"))) ||
(curNodeTag.Equals(NS_LITERAL_STRING("blockquote"))) || nsHTMLEditUtils::IsBlockquote(curNode) ||
(curNodeTag.Equals(NS_LITERAL_STRING("div")))) nsHTMLEditUtils::IsDiv(curNode))
{ {
curBlock = 0; // forget any previous block used for previous inline nodes curBlock = 0; // forget any previous block used for previous inline nodes
// recursion time // recursion time