From cd459b00c54fd02ef1c7db21404b7413fe27a08a Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 14 Apr 2012 15:08:26 +0200 Subject: [PATCH] Bug 742884 - Part c: Cleanup nsHTMLEditRules::GetListState; r=ehsan --- editor/libeditor/html/nsHTMLEditRules.cpp | 54 +++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index 38d134f7d93a..679fd487da93 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -685,41 +685,41 @@ nsHTMLEditRules::GetListState(bool *aMixed, bool *aOL, bool *aUL, bool *aDL) nsresult res = GetListActionNodes(arrayOfNodes, false, true); NS_ENSURE_SUCCESS(res, res); - // examine list type for nodes in selection + // Examine list type for nodes in selection. PRInt32 listCount = arrayOfNodes.Count(); - PRInt32 i; - for (i=listCount-1; i>=0; i--) - { - nsIDOMNode* curNode = arrayOfNodes[i]; - - if (nsHTMLEditUtils::IsUnorderedList(curNode)) + for (PRInt32 i = listCount - 1; i >= 0; --i) { + nsIDOMNode* curDOMNode = arrayOfNodes[i]; + nsCOMPtr curElement = do_QueryInterface(curDOMNode); + + if (!curElement) { + bNonList = true; + } else if (curElement->IsHTML(nsGkAtoms::ul)) { *aUL = true; - else if (nsHTMLEditUtils::IsOrderedList(curNode)) + } else if (curElement->IsHTML(nsGkAtoms::ol)) { *aOL = true; - else if (nsEditor::NodeIsType(curNode, nsEditProperty::li)) - { - nsCOMPtr parent; - PRInt32 offset; - res = nsEditor::GetNodeLocation(curNode, address_of(parent), &offset); - NS_ENSURE_SUCCESS(res, res); - if (nsHTMLEditUtils::IsUnorderedList(parent)) - *aUL = true; - else if (nsHTMLEditUtils::IsOrderedList(parent)) - *aOL = true; - } - else if (nsEditor::NodeIsType(curNode, nsEditProperty::dl) || - nsEditor::NodeIsType(curNode, nsEditProperty::dt) || - nsEditor::NodeIsType(curNode, nsEditProperty::dd) ) - { + } else if (curElement->IsHTML(nsGkAtoms::li)) { + if (nsINode* parent = curElement->GetElementParent()) { + if (parent->AsElement()->IsHTML(nsGkAtoms::ul)) { + *aUL = true; + } else if (parent->AsElement()->IsHTML(nsGkAtoms::ol)) { + *aOL = true; + } + } + } else if (curElement->IsHTML(nsGkAtoms::dl) || + curElement->IsHTML(nsGkAtoms::dt) || + curElement->IsHTML(nsGkAtoms::dd)) { *aDL = true; + } else { + bNonList = true; } - else bNonList = true; } // hokey arithmetic with booleans - if ( (*aUL + *aOL + *aDL + bNonList) > 1) *aMixed = true; - - return res; + if ((*aUL + *aOL + *aDL + bNonList) > 1) { + *aMixed = true; + } + + return NS_OK; } nsresult