зеркало из https://github.com/mozilla/gecko-dev.git
Bug 761997 - Cleanup nsHTMLEditRules::GetListItemState / nsHTMLEditRules::GetDefinitionListItemTypes; r=ehsan
This commit is contained in:
Родитель
0694b06721
Коммит
abe520efbe
|
@ -703,41 +703,34 @@ nsHTMLEditRules::GetListItemState(bool *aMixed, bool *aLI, bool *aDT, bool *aDD)
|
|||
|
||||
// examine list type for nodes in selection
|
||||
PRInt32 listCount = arrayOfNodes.Count();
|
||||
PRInt32 i;
|
||||
for (i = listCount-1; i>=0; i--)
|
||||
{
|
||||
for (PRInt32 i = listCount - 1; i >= 0; --i) {
|
||||
nsIDOMNode* curNode = arrayOfNodes[i];
|
||||
|
||||
if (nsHTMLEditUtils::IsUnorderedList(curNode) ||
|
||||
nsHTMLEditUtils::IsOrderedList(curNode) ||
|
||||
nsEditor::NodeIsType(curNode, nsEditProperty::li) )
|
||||
{
|
||||
nsCOMPtr<dom::Element> element = do_QueryInterface(curNode);
|
||||
if (!element) {
|
||||
bNonList = true;
|
||||
} else if (element->IsHTML(nsGkAtoms::ul) ||
|
||||
element->IsHTML(nsGkAtoms::ol) ||
|
||||
element->IsHTML(nsGkAtoms::li)) {
|
||||
*aLI = true;
|
||||
}
|
||||
else if (nsEditor::NodeIsType(curNode, nsEditProperty::dt))
|
||||
{
|
||||
} else if (element->IsHTML(nsGkAtoms::dt)) {
|
||||
*aDT = true;
|
||||
}
|
||||
else if (nsEditor::NodeIsType(curNode, nsEditProperty::dd))
|
||||
{
|
||||
} else if (element->IsHTML(nsGkAtoms::dd)) {
|
||||
*aDD = true;
|
||||
}
|
||||
else if (nsEditor::NodeIsType(curNode, nsEditProperty::dl))
|
||||
{
|
||||
} else if (element->IsHTML(nsGkAtoms::dl)) {
|
||||
// need to look inside dl and see which types of items it has
|
||||
bool bDT, bDD;
|
||||
res = GetDefinitionListItemTypes(curNode, bDT, bDD);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
GetDefinitionListItemTypes(element, &bDT, &bDD);
|
||||
*aDT |= bDT;
|
||||
*aDD |= bDD;
|
||||
} else {
|
||||
bNonList = true;
|
||||
}
|
||||
else bNonList = true;
|
||||
}
|
||||
|
||||
// hokey arithmetic with booleans
|
||||
if ( (*aDT + *aDD + bNonList) > 1) *aMixed = true;
|
||||
|
||||
return res;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -5959,22 +5952,24 @@ nsHTMLEditRules::LookInsideDivBQandList(nsCOMArray<nsIDOMNode>& aNodeArray)
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// GetDefinitionListItemTypes:
|
||||
//
|
||||
nsresult
|
||||
nsHTMLEditRules::GetDefinitionListItemTypes(nsIDOMNode *aNode, bool &aDT, bool &aDD)
|
||||
void
|
||||
nsHTMLEditRules::GetDefinitionListItemTypes(dom::Element* aElement, bool* aDT, bool* aDD)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
|
||||
aDT = aDD = false;
|
||||
nsresult res = NS_OK;
|
||||
nsCOMPtr<nsIDOMNode> child, temp;
|
||||
res = aNode->GetFirstChild(getter_AddRefs(child));
|
||||
while (child && NS_SUCCEEDED(res))
|
||||
{
|
||||
if (nsEditor::NodeIsType(child, nsEditProperty::dt)) aDT = true;
|
||||
else if (nsEditor::NodeIsType(child, nsEditProperty::dd)) aDD = true;
|
||||
res = child->GetNextSibling(getter_AddRefs(temp));
|
||||
child = temp;
|
||||
MOZ_ASSERT(aElement);
|
||||
MOZ_ASSERT(aElement->IsHTML(nsGkAtoms::dl));
|
||||
MOZ_ASSERT(aDT);
|
||||
MOZ_ASSERT(aDD);
|
||||
|
||||
*aDT = *aDD = false;
|
||||
for (nsIContent* child = aElement->GetFirstChild();
|
||||
child;
|
||||
child = child->GetNextSibling()) {
|
||||
if (child->IsHTML(nsGkAtoms::dt)) {
|
||||
*aDT = true;
|
||||
} else if (child->IsHTML(nsGkAtoms::dd)) {
|
||||
*aDD = true;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -234,7 +234,7 @@ protected:
|
|||
nsCOMArray<nsIDOMNode>& arrayOfNodes,
|
||||
bool aDontTouchContent=false);
|
||||
nsresult GetListActionNodes(nsCOMArray<nsIDOMNode> &outArrayOfNodes, bool aEntireList, bool aDontTouchContent=false);
|
||||
nsresult GetDefinitionListItemTypes(nsIDOMNode *aNode, bool &aDT, bool &aDD);
|
||||
void GetDefinitionListItemTypes(mozilla::dom::Element* aElement, bool* aDT, bool* aDD);
|
||||
nsresult GetParagraphFormatNodes(nsCOMArray<nsIDOMNode>& outArrayOfNodes, bool aDontTouchContent=false);
|
||||
nsresult LookInsideDivBQandList(nsCOMArray<nsIDOMNode>& aNodeArray);
|
||||
nsresult BustUpInlinesAtRangeEndpoints(nsRangeStore &inRange);
|
||||
|
|
Загрузка…
Ссылка в новой задаче