more Is* method usage / code cleanup; r=glazman, sr=bz, bug=212683
This commit is contained in:
@@ -948,9 +948,7 @@ nsHTMLEditRules::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
|
|||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
|
nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
|
||||||
|
|
||||||
if (nsHTMLEditUtils::IsList(curNode) ||
|
if (nsHTMLEditUtils::IsNodeThatCanOutdent(curNode))
|
||||||
nsHTMLEditUtils::IsListItem(curNode) ||
|
|
||||||
nsHTMLEditUtils::IsBlockquote(curNode))
|
|
||||||
{
|
{
|
||||||
*aCanOutdent = PR_TRUE;
|
*aCanOutdent = PR_TRUE;
|
||||||
break;
|
break;
|
||||||
@@ -992,14 +990,12 @@ nsHTMLEditRules::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
|
|||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
// test start parent heirachy
|
// test start parent hierarchy
|
||||||
res = mHTMLEditor->GetStartNodeAndOffset(selection, address_of(parent), &selOffset);
|
res = mHTMLEditor->GetStartNodeAndOffset(selection, address_of(parent), &selOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
while (parent && (parent!=root))
|
while (parent && (parent!=root))
|
||||||
{
|
{
|
||||||
if (nsHTMLEditUtils::IsList(parent) ||
|
if (nsHTMLEditUtils::IsNodeThatCanOutdent(parent))
|
||||||
nsHTMLEditUtils::IsListItem(parent) ||
|
|
||||||
nsHTMLEditUtils::IsBlockquote(parent))
|
|
||||||
{
|
{
|
||||||
*aCanOutdent = PR_TRUE;
|
*aCanOutdent = PR_TRUE;
|
||||||
break;
|
break;
|
||||||
@@ -1008,14 +1004,12 @@ nsHTMLEditRules::GetIndentState(PRBool *aCanIndent, PRBool *aCanOutdent)
|
|||||||
tmp->GetParentNode(getter_AddRefs(parent));
|
tmp->GetParentNode(getter_AddRefs(parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
// test end parent heirachy
|
// test end parent hierarchy
|
||||||
res = mHTMLEditor->GetEndNodeAndOffset(selection, address_of(parent), &selOffset);
|
res = mHTMLEditor->GetEndNodeAndOffset(selection, address_of(parent), &selOffset);
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
while (parent && (parent!=root))
|
while (parent && (parent!=root))
|
||||||
{
|
{
|
||||||
if (nsHTMLEditUtils::IsList(parent) ||
|
if (nsHTMLEditUtils::IsNodeThatCanOutdent(parent))
|
||||||
nsHTMLEditUtils::IsListItem(parent) ||
|
|
||||||
nsHTMLEditUtils::IsBlockquote(parent))
|
|
||||||
{
|
{
|
||||||
*aCanOutdent = PR_TRUE;
|
*aCanOutdent = PR_TRUE;
|
||||||
break;
|
break;
|
||||||
@@ -1056,7 +1050,7 @@ nsHTMLEditRules::GetParagraphState(PRBool *aMixed, nsAString &outFormat)
|
|||||||
nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
|
nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
|
||||||
nsAutoString format;
|
nsAutoString format;
|
||||||
// if it is a known format node we have it easy
|
// if it is a known format node we have it easy
|
||||||
if (IsBlockNode(curNode) && !IsFormatNode(curNode))
|
if (IsBlockNode(curNode) && !nsHTMLEditUtils::IsFormatNode(curNode))
|
||||||
{
|
{
|
||||||
// arrayOfNodes.RemoveObject(curNode);
|
// arrayOfNodes.RemoveObject(curNode);
|
||||||
res = AppendInnerFormatNodes(arrayOfNodes, curNode);
|
res = AppendInnerFormatNodes(arrayOfNodes, curNode);
|
||||||
@@ -1093,7 +1087,7 @@ nsHTMLEditRules::GetParagraphState(PRBool *aMixed, nsAString &outFormat)
|
|||||||
nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
|
nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
|
||||||
nsAutoString format;
|
nsAutoString format;
|
||||||
// if it is a known format node we have it easy
|
// if it is a known format node we have it easy
|
||||||
if (IsFormatNode(curNode))
|
if (nsHTMLEditUtils::IsFormatNode(curNode))
|
||||||
GetFormatString(curNode, format);
|
GetFormatString(curNode, format);
|
||||||
else if (IsBlockNode(curNode))
|
else if (IsBlockNode(curNode))
|
||||||
{
|
{
|
||||||
@@ -1114,7 +1108,7 @@ nsHTMLEditRules::GetParagraphState(PRBool *aMixed, nsAString &outFormat)
|
|||||||
format.Truncate(0);
|
format.Truncate(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (IsFormatNode(node))
|
else if (nsHTMLEditUtils::IsFormatNode(node))
|
||||||
{
|
{
|
||||||
GetFormatString(node, format);
|
GetFormatString(node, format);
|
||||||
break;
|
break;
|
||||||
@@ -1141,18 +1135,6 @@ nsHTMLEditRules::GetParagraphState(PRBool *aMixed, nsAString &outFormat)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
|
||||||
nsHTMLEditRules::IsFormatNode(nsIDOMNode *aNode)
|
|
||||||
{
|
|
||||||
if (!aNode) return NS_ERROR_NULL_POINTER;
|
|
||||||
if (nsHTMLEditUtils::IsParagraph(aNode) ||
|
|
||||||
nsHTMLEditUtils::IsPre(aNode) ||
|
|
||||||
nsHTMLEditUtils::IsHeader(aNode) ||
|
|
||||||
nsHTMLEditUtils::IsAddress(aNode) )
|
|
||||||
return PR_TRUE;
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLEditRules::AppendInnerFormatNodes(nsCOMArray<nsIDOMNode>& aArray,
|
nsHTMLEditRules::AppendInnerFormatNodes(nsCOMArray<nsIDOMNode>& aArray,
|
||||||
nsIDOMNode *aNode)
|
nsIDOMNode *aNode)
|
||||||
@@ -1176,7 +1158,7 @@ nsHTMLEditRules::AppendInnerFormatNodes(nsCOMArray<nsIDOMNode>& aArray,
|
|||||||
{
|
{
|
||||||
childList->Item(j, getter_AddRefs(child));
|
childList->Item(j, getter_AddRefs(child));
|
||||||
PRBool isBlock = IsBlockNode(child);
|
PRBool isBlock = IsBlockNode(child);
|
||||||
PRBool isFormat = IsFormatNode(child);
|
PRBool isFormat = nsHTMLEditUtils::IsFormatNode(child);
|
||||||
if (isBlock && !isFormat) // if it's a div, etc, recurse
|
if (isBlock && !isFormat) // if it's a div, etc, recurse
|
||||||
AppendInnerFormatNodes(aArray, child);
|
AppendInnerFormatNodes(aArray, child);
|
||||||
else if (isFormat)
|
else if (isFormat)
|
||||||
@@ -1198,12 +1180,9 @@ nsHTMLEditRules::GetFormatString(nsIDOMNode *aNode, nsAString &outFormat)
|
|||||||
{
|
{
|
||||||
if (!aNode) return NS_ERROR_NULL_POINTER;
|
if (!aNode) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsCOMPtr<nsIAtom> atom = mHTMLEditor->GetTag(aNode);
|
if (nsHTMLEditUtils::IsFormatNode(aNode))
|
||||||
if (nsEditProperty::p == atom ||
|
|
||||||
nsEditProperty::address == atom ||
|
|
||||||
nsEditProperty::pre == atom ||
|
|
||||||
nsHTMLEditUtils::IsHeader(aNode))
|
|
||||||
{
|
{
|
||||||
|
nsCOMPtr<nsIAtom> atom = nsEditor::GetTag(aNode);
|
||||||
atom->ToString(outFormat);
|
atom->ToString(outFormat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2771,7 +2750,7 @@ nsHTMLEditRules::DeleteNonTableElements(nsIDOMNode *aNode)
|
|||||||
{
|
{
|
||||||
if (!aNode) return NS_ERROR_NULL_POINTER;
|
if (!aNode) return NS_ERROR_NULL_POINTER;
|
||||||
nsresult res = NS_OK;
|
nsresult res = NS_OK;
|
||||||
if (nsHTMLEditUtils::IsTableElement(aNode) && !nsHTMLEditUtils::IsTable(aNode))
|
if (nsHTMLEditUtils::IsTableElementButNotTable(aNode))
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNodeList> children;
|
nsCOMPtr<nsIDOMNodeList> children;
|
||||||
aNode->GetChildNodes(getter_AddRefs(children));
|
aNode->GetChildNodes(getter_AddRefs(children));
|
||||||
@@ -3296,10 +3275,7 @@ 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));
|
||||||
if (nsHTMLEditUtils::IsPre(curBlock) ||
|
if (nsHTMLEditUtils::IsFormatNode(curBlock))
|
||||||
nsHTMLEditUtils::IsParagraph(curBlock) ||
|
|
||||||
nsHTMLEditUtils::IsHeader(curBlock) ||
|
|
||||||
nsHTMLEditUtils::IsAddress(curBlock))
|
|
||||||
{
|
{
|
||||||
// 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.
|
||||||
@@ -5629,7 +5605,7 @@ nsHTMLEditRules::GetNodesForOperation(nsCOMArray<nsIDOMRange>& inArrayOfRanges,
|
|||||||
for (i=listCount-1; i>=0; i--)
|
for (i=listCount-1; i>=0; i--)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMNode> node = outArrayOfNodes[i];
|
nsCOMPtr<nsIDOMNode> node = outArrayOfNodes[i];
|
||||||
if ( (nsHTMLEditUtils::IsTableElement(node) && !nsHTMLEditUtils::IsTable(node)) )
|
if (nsHTMLEditUtils::IsTableElementButNotTable(node))
|
||||||
{
|
{
|
||||||
PRInt32 j=i;
|
PRInt32 j=i;
|
||||||
outArrayOfNodes.RemoveObjectAt(i);
|
outArrayOfNodes.RemoveObjectAt(i);
|
||||||
@@ -5791,7 +5767,7 @@ nsHTMLEditRules::GetListActionNodes(nsCOMArray<nsIDOMNode> &outArrayOfNodes,
|
|||||||
|
|
||||||
// scan for table elements and divs. If we find table elements other than table,
|
// scan for table elements and divs. If we find table elements other than table,
|
||||||
// replace it with a list of any editable non-table content.
|
// replace it with a list of any editable non-table content.
|
||||||
if (nsHTMLEditUtils::IsTableElement(testNode) && !nsHTMLEditUtils::IsTable(testNode))
|
if (nsHTMLEditUtils::IsTableElementButNotTable(testNode))
|
||||||
{
|
{
|
||||||
PRInt32 j=i;
|
PRInt32 j=i;
|
||||||
outArrayOfNodes.RemoveObjectAt(i);
|
outArrayOfNodes.RemoveObjectAt(i);
|
||||||
@@ -6438,7 +6414,7 @@ nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection,
|
|||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
NS_PRECONDITION(PR_TRUE == nsHTMLEditUtils::IsListItem(aListItem),
|
NS_PRECONDITION(PR_TRUE == nsHTMLEditUtils::IsListItem(aListItem),
|
||||||
"expected a list item and didnt get one");
|
"expected a list item and didn't get one");
|
||||||
|
|
||||||
// if we are in an empty listitem, then we want to pop up out of the list
|
// if we are in an empty listitem, then we want to pop up out of the list
|
||||||
PRBool isEmpty;
|
PRBool isEmpty;
|
||||||
@@ -6591,8 +6567,8 @@ nsHTMLEditRules::MakeBlockquote(nsCOMArray<nsIDOMNode>& arrayOfNodes)
|
|||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
|
|
||||||
// if the node is a table element or list item, dive inside
|
// if the node is a table element or list item, dive inside
|
||||||
if ( (nsHTMLEditUtils::IsTableElement(curNode) && !(nsHTMLEditUtils::IsTable(curNode))) ||
|
if (nsHTMLEditUtils::IsTableElementButNotTable(curNode) ||
|
||||||
nsHTMLEditUtils::IsListItem(curNode) )
|
nsHTMLEditUtils::IsListItem(curNode))
|
||||||
{
|
{
|
||||||
curBlock = 0; // forget any previous block
|
curBlock = 0; // forget any previous block
|
||||||
// recursion time
|
// recursion time
|
||||||
@@ -6670,10 +6646,7 @@ 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 (nsHTMLEditUtils::IsPre(curNode) ||
|
if (nsHTMLEditUtils::IsFormatNode(curNode))
|
||||||
nsHTMLEditUtils::IsParagraph(curNode) ||
|
|
||||||
nsHTMLEditUtils::IsHeader(curNode) ||
|
|
||||||
nsHTMLEditUtils::IsAddress(curNode))
|
|
||||||
{
|
{
|
||||||
// process any partial progress saved
|
// process any partial progress saved
|
||||||
if (curBlock)
|
if (curBlock)
|
||||||
@@ -6731,10 +6704,7 @@ nsHTMLEditRules::RemoveBlockStyle(nsCOMArray<nsIDOMNode>& arrayOfNodes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
curBlock = mHTMLEditor->GetBlockNodeParent(curNode);
|
curBlock = mHTMLEditor->GetBlockNodeParent(curNode);
|
||||||
if (nsHTMLEditUtils::IsPre(curBlock) ||
|
if (nsHTMLEditUtils::IsFormatNode(curBlock))
|
||||||
nsHTMLEditUtils::IsParagraph(curBlock) ||
|
|
||||||
nsHTMLEditUtils::IsHeader(curBlock) ||
|
|
||||||
nsHTMLEditUtils::IsAddress(curBlock))
|
|
||||||
{
|
{
|
||||||
firstNode = curNode;
|
firstNode = curNode;
|
||||||
lastNode = curNode;
|
lastNode = curNode;
|
||||||
@@ -6818,10 +6788,7 @@ 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) ||
|
||||||
nsHTMLEditUtils::IsPre(curNode) ||
|
nsHTMLEditUtils::IsFormatNode(curNode))
|
||||||
nsHTMLEditUtils::IsParagraph(curNode) ||
|
|
||||||
nsHTMLEditUtils::IsHeader(curNode) ||
|
|
||||||
nsHTMLEditUtils::IsAddress(curNode))
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
@@ -7658,39 +7625,25 @@ nsHTMLEditRules::RemoveEmptyNodes()
|
|||||||
PRBool bIsCandidate = PR_FALSE;
|
PRBool bIsCandidate = PR_FALSE;
|
||||||
PRBool bIsEmptyNode = PR_FALSE;
|
PRBool bIsEmptyNode = PR_FALSE;
|
||||||
PRBool bIsMailCite = PR_FALSE;
|
PRBool bIsMailCite = PR_FALSE;
|
||||||
|
|
||||||
// dont delete the body
|
// don't delete the body
|
||||||
if (!nsTextEditUtils::IsBody(node))
|
if (!nsTextEditUtils::IsBody(node))
|
||||||
{
|
{
|
||||||
// only consider certain nodes to be empty for purposes of removal
|
// only consider certain nodes to be empty for purposes of removal
|
||||||
if ( (bIsMailCite = nsHTMLEditUtils::IsMailCite(node)) ||
|
if ( (bIsMailCite = nsHTMLEditUtils::IsMailCite(node)) ||
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::a) ||
|
nsEditor::NodeIsType(node, nsEditProperty::a) ||
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::b) ||
|
nsHTMLEditUtils::IsInlineStyle(node) ||
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::i) ||
|
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::u) ||
|
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::tt) ||
|
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::s) ||
|
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::strike) ||
|
|
||||||
nsHTMLEditUtils::IsBig(node) ||
|
|
||||||
nsHTMLEditUtils::IsSmall(node) ||
|
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::blink) ||
|
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::sub) ||
|
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::sup) ||
|
|
||||||
nsEditor::NodeIsType(node, nsEditProperty::font) ||
|
|
||||||
nsHTMLEditUtils::IsList(node) ||
|
nsHTMLEditUtils::IsList(node) ||
|
||||||
nsHTMLEditUtils::IsDiv(node) )
|
nsHTMLEditUtils::IsDiv(node) )
|
||||||
{
|
{
|
||||||
bIsCandidate = PR_TRUE;
|
bIsCandidate = PR_TRUE;
|
||||||
}
|
}
|
||||||
// these node types are candidates if selection is not in them
|
// these node types are candidates if selection is not in them
|
||||||
else if (nsHTMLEditUtils::IsParagraph(node) ||
|
else if (nsHTMLEditUtils::IsFormatNode(node) ||
|
||||||
nsHTMLEditUtils::IsHeader(node) ||
|
|
||||||
nsHTMLEditUtils::IsListItem(node) ||
|
nsHTMLEditUtils::IsListItem(node) ||
|
||||||
nsHTMLEditUtils::IsBlockquote(node)||
|
nsHTMLEditUtils::IsBlockquote(node) )
|
||||||
nsHTMLEditUtils::IsPre(node) ||
|
|
||||||
nsHTMLEditUtils::IsAddress(node) )
|
|
||||||
{
|
{
|
||||||
// if it is one of these, dont delete if sel inside.
|
// if it is one of these, don't delete if selection inside.
|
||||||
// this is so we can create empty headings, etc, for the
|
// this is so we can create empty headings, etc, for the
|
||||||
// user to type into.
|
// user to type into.
|
||||||
PRBool bIsSelInNode;
|
PRBool bIsSelInNode;
|
||||||
|
|||||||
@@ -174,7 +174,6 @@ protected:
|
|||||||
nsresult DidAbsolutePosition();
|
nsresult DidAbsolutePosition();
|
||||||
nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsAString *alignType);
|
nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsAString *alignType);
|
||||||
nsresult AlignBlockContents(nsIDOMNode *aNode, const nsAString *alignType);
|
nsresult AlignBlockContents(nsIDOMNode *aNode, const nsAString *alignType);
|
||||||
PRBool IsFormatNode(nsIDOMNode *aNode);
|
|
||||||
nsresult AppendInnerFormatNodes(nsCOMArray<nsIDOMNode>& aArray,
|
nsresult AppendInnerFormatNodes(nsCOMArray<nsIDOMNode>& aArray,
|
||||||
nsIDOMNode *aNode);
|
nsIDOMNode *aNode);
|
||||||
nsresult GetFormatString(nsIDOMNode *aNode, nsAString &outFormat);
|
nsresult GetFormatString(nsIDOMNode *aNode, nsAString &outFormat);
|
||||||
|
|||||||
@@ -58,6 +58,64 @@ nsHTMLEditUtils::IsBig(nsIDOMNode *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// IsInlineStyle true if node is an inline style
|
||||||
|
//
|
||||||
|
PRBool
|
||||||
|
nsHTMLEditUtils::IsInlineStyle(nsIDOMNode *node)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsInlineStyle");
|
||||||
|
nsCOMPtr<nsIAtom> nodeAtom = nsEditor::GetTag(node);
|
||||||
|
return (nodeAtom == nsEditProperty::b)
|
||||||
|
|| (nodeAtom == nsEditProperty::i)
|
||||||
|
|| (nodeAtom == nsEditProperty::u)
|
||||||
|
|| (nodeAtom == nsEditProperty::tt)
|
||||||
|
|| (nodeAtom == nsEditProperty::s)
|
||||||
|
|| (nodeAtom == nsEditProperty::strike)
|
||||||
|
|| (nodeAtom == nsEditProperty::big)
|
||||||
|
|| (nodeAtom == nsEditProperty::small)
|
||||||
|
|| (nodeAtom == nsEditProperty::blink)
|
||||||
|
|| (nodeAtom == nsEditProperty::sub)
|
||||||
|
|| (nodeAtom == nsEditProperty::sup)
|
||||||
|
|| (nodeAtom == nsEditProperty::font);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// IsFormatNode true if node is a format node
|
||||||
|
//
|
||||||
|
PRBool
|
||||||
|
nsHTMLEditUtils::IsFormatNode(nsIDOMNode *node)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsFormatNode");
|
||||||
|
nsCOMPtr<nsIAtom> nodeAtom = nsEditor::GetTag(node);
|
||||||
|
return (nodeAtom == nsEditProperty::p)
|
||||||
|
|| (nodeAtom == nsEditProperty::pre)
|
||||||
|
|| (nodeAtom == nsEditProperty::h1)
|
||||||
|
|| (nodeAtom == nsEditProperty::h2)
|
||||||
|
|| (nodeAtom == nsEditProperty::h3)
|
||||||
|
|| (nodeAtom == nsEditProperty::h4)
|
||||||
|
|| (nodeAtom == nsEditProperty::h5)
|
||||||
|
|| (nodeAtom == nsEditProperty::h6)
|
||||||
|
|| (nodeAtom == nsEditProperty::address);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// IsNodeThatCanOutdent true if node is a list, list item, or blockquote
|
||||||
|
//
|
||||||
|
PRBool
|
||||||
|
nsHTMLEditUtils::IsNodeThatCanOutdent(nsIDOMNode *node)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::IsNodeThatCanOutdent");
|
||||||
|
nsCOMPtr<nsIAtom> nodeAtom = nsEditor::GetTag(node);
|
||||||
|
return (nodeAtom == nsEditProperty::ul)
|
||||||
|
|| (nodeAtom == nsEditProperty::ol)
|
||||||
|
|| (nodeAtom == nsEditProperty::dl)
|
||||||
|
|| (nodeAtom == nsEditProperty::li)
|
||||||
|
|| (nodeAtom == nsEditProperty::dd)
|
||||||
|
|| (nodeAtom == nsEditProperty::dt)
|
||||||
|
|| (nodeAtom == nsEditProperty::blockquote);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
PRBool
|
PRBool
|
||||||
@@ -140,6 +198,22 @@ nsHTMLEditUtils::IsTableElement(nsIDOMNode *node)
|
|||||||
|| (nodeAtom == nsEditProperty::caption);
|
|| (nodeAtom == nsEditProperty::caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// IsTableElementButNotTable: true if node an html td, tr, ... (doesn't include table)
|
||||||
|
//
|
||||||
|
PRBool
|
||||||
|
nsHTMLEditUtils::IsTableElementButNotTable(nsIDOMNode *node)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(node, "null node passed to nsHTMLEditor::IsTableElementButNotTable");
|
||||||
|
nsCOMPtr<nsIAtom> nodeAtom = nsEditor::GetTag(node);
|
||||||
|
return (nodeAtom == nsEditProperty::tr)
|
||||||
|
|| (nodeAtom == nsEditProperty::td)
|
||||||
|
|| (nodeAtom == nsEditProperty::th)
|
||||||
|
|| (nodeAtom == nsEditProperty::thead)
|
||||||
|
|| (nodeAtom == nsEditProperty::tfoot)
|
||||||
|
|| (nodeAtom == nsEditProperty::tbody)
|
||||||
|
|| (nodeAtom == nsEditProperty::caption);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// IsTable: true if node an html table
|
// IsTable: true if node an html table
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ public:
|
|||||||
static PRBool IsSmall(nsIDOMNode *aNode);
|
static PRBool IsSmall(nsIDOMNode *aNode);
|
||||||
|
|
||||||
// from nsHTMLEditRules:
|
// from nsHTMLEditRules:
|
||||||
|
static PRBool IsInlineStyle(nsIDOMNode *aNode);
|
||||||
|
static PRBool IsFormatNode(nsIDOMNode *aNode);
|
||||||
|
static PRBool IsNodeThatCanOutdent(nsIDOMNode *aNode);
|
||||||
static PRBool IsHeader(nsIDOMNode *aNode);
|
static PRBool IsHeader(nsIDOMNode *aNode);
|
||||||
static PRBool IsParagraph(nsIDOMNode *aNode);
|
static PRBool IsParagraph(nsIDOMNode *aNode);
|
||||||
static PRBool IsHR(nsIDOMNode *aNode);
|
static PRBool IsHR(nsIDOMNode *aNode);
|
||||||
@@ -59,6 +62,7 @@ public:
|
|||||||
static PRBool IsTable(nsIDOMNode *aNode);
|
static PRBool IsTable(nsIDOMNode *aNode);
|
||||||
static PRBool IsTableRow(nsIDOMNode *aNode);
|
static PRBool IsTableRow(nsIDOMNode *aNode);
|
||||||
static PRBool IsTableElement(nsIDOMNode *aNode);
|
static PRBool IsTableElement(nsIDOMNode *aNode);
|
||||||
|
static PRBool IsTableElementButNotTable(nsIDOMNode *aNode);
|
||||||
static PRBool IsTableCell(nsIDOMNode *aNode);
|
static PRBool IsTableCell(nsIDOMNode *aNode);
|
||||||
static PRBool IsTableCellOrCaption(nsIDOMNode *aNode);
|
static PRBool IsTableCellOrCaption(nsIDOMNode *aNode);
|
||||||
static PRBool IsList(nsIDOMNode *aNode);
|
static PRBool IsList(nsIDOMNode *aNode);
|
||||||
|
|||||||
@@ -5524,14 +5524,14 @@ nsHTMLEditor::IsEmptyNodeImpl( nsIDOMNode *aNode,
|
|||||||
if (isListItemOrCell)
|
if (isListItemOrCell)
|
||||||
{
|
{
|
||||||
if (nsHTMLEditUtils::IsList(node) || nsHTMLEditUtils::IsTable(node))
|
if (nsHTMLEditUtils::IsList(node) || nsHTMLEditUtils::IsTable(node))
|
||||||
{ // break out if we find we aren't emtpy
|
{ // break out if we find we aren't empty
|
||||||
*outIsEmptyNode = PR_FALSE;
|
*outIsEmptyNode = PR_FALSE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// is it a form widget?
|
// is it a form widget?
|
||||||
else if (nsHTMLEditUtils::IsFormWidget(aNode))
|
else if (nsHTMLEditUtils::IsFormWidget(aNode))
|
||||||
{ // break out if we find we aren't emtpy
|
{ // break out if we find we aren't empty
|
||||||
*outIsEmptyNode = PR_FALSE;
|
*outIsEmptyNode = PR_FALSE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -5993,18 +5993,7 @@ nsHTMLEditor::CopyLastEditableChildStyles(nsIDOMNode * aPreviousBlock, nsIDOMNod
|
|||||||
}
|
}
|
||||||
nsCOMPtr<nsIDOMNode> newStyles = nsnull, deepestStyle = nsnull;
|
nsCOMPtr<nsIDOMNode> newStyles = nsnull, deepestStyle = nsnull;
|
||||||
while (child && (child != aPreviousBlock)) {
|
while (child && (child != aPreviousBlock)) {
|
||||||
if (nsEditor::NodeIsType(child, nsEditProperty::b) ||
|
if (nsHTMLEditUtils::IsInlineStyle(child) ||
|
||||||
nsEditor::NodeIsType(child, nsEditProperty::i) ||
|
|
||||||
nsEditor::NodeIsType(child, nsEditProperty::u) ||
|
|
||||||
nsEditor::NodeIsType(child, nsEditProperty::tt) ||
|
|
||||||
nsEditor::NodeIsType(child, nsEditProperty::s) ||
|
|
||||||
nsEditor::NodeIsType(child, nsEditProperty::strike) ||
|
|
||||||
nsHTMLEditUtils::IsBig(child) ||
|
|
||||||
nsHTMLEditUtils::IsSmall(child) ||
|
|
||||||
nsEditor::NodeIsType(child, nsEditProperty::blink) ||
|
|
||||||
nsEditor::NodeIsType(child, nsEditProperty::sub) ||
|
|
||||||
nsEditor::NodeIsType(child, nsEditProperty::sup) ||
|
|
||||||
nsEditor::NodeIsType(child, nsEditProperty::font) ||
|
|
||||||
nsEditor::NodeIsType(child, nsEditProperty::span)) {
|
nsEditor::NodeIsType(child, nsEditProperty::span)) {
|
||||||
nsAutoString domTagName;
|
nsAutoString domTagName;
|
||||||
child->GetNodeName(domTagName);
|
child->GetNodeName(domTagName);
|
||||||
|
|||||||
Reference in New Issue
Block a user