Bug 750063 - Allow passing null to nsTextEditRules::CreateMozBR's outparam; r=ehsan

This commit is contained in:
Ms2ger 2012-05-05 11:00:05 +02:00
Родитель 7b542cc079
Коммит bea07aa61a
3 изменённых файлов: 29 добавлений и 32 удалений

Просмотреть файл

@ -4687,7 +4687,7 @@ nsHTMLEditRules::WillAlign(nsISelection *aSelection,
NS_ENSURE_SUCCESS(res, res);
*aHandled = true;
// put in a moz-br so that it won't get deleted
res = CreateMozBR(theDiv, 0, address_of(brNode));
res = CreateMozBR(theDiv, 0);
NS_ENSURE_SUCCESS(res, res);
res = aSelection->Collapse(theDiv, 0);
selectionResetter.Abort(); // don't reset our selection in this case.
@ -6538,10 +6538,8 @@ nsHTMLEditRules::ReturnInHeader(nsISelection *aSelection,
bool bIsEmptyNode;
res = mHTMLEditor->IsEmptyNode(prevItem, &bIsEmptyNode);
NS_ENSURE_SUCCESS(res, res);
if (bIsEmptyNode)
{
nsCOMPtr<nsIDOMNode> brNode;
res = CreateMozBR(prevItem, 0, address_of(brNode));
if (bIsEmptyNode) {
res = CreateMozBR(prevItem, 0);
NS_ENSURE_SUCCESS(res, res);
}
}
@ -6853,14 +6851,10 @@ nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection,
bool bIsEmptyNode;
res = mHTMLEditor->IsEmptyNode(prevItem, &bIsEmptyNode);
NS_ENSURE_SUCCESS(res, res);
if (bIsEmptyNode)
{
nsCOMPtr<nsIDOMNode> brNode;
res = CreateMozBR(prevItem, 0, address_of(brNode));
if (bIsEmptyNode) {
res = CreateMozBR(prevItem, 0);
NS_ENSURE_SUCCESS(res, res);
}
else
{
} else {
res = mHTMLEditor->IsEmptyNode(aListItem, &bIsEmptyNode, true);
NS_ENSURE_SUCCESS(res, res);
if (bIsEmptyNode)
@ -7551,11 +7545,11 @@ nsHTMLEditRules::AdjustSpecialBreaks(bool aSafeToAskFrames)
// and we want the br's to be after them. Also, we want the br
// to be after the selection if the selection is in this node.
PRUint32 len;
nsCOMPtr<nsIDOMNode> brNode, theNode = arrayOfNodes[0];
nsCOMPtr<nsIDOMNode> theNode = arrayOfNodes[0];
arrayOfNodes.RemoveObjectAt(0);
res = nsEditor::GetLengthOfDOMNode(theNode, len);
NS_ENSURE_SUCCESS(res, res);
res = CreateMozBR(theNode, (PRInt32)len, address_of(brNode));
res = CreateMozBR(theNode, (PRInt32)len);
NS_ENSURE_SUCCESS(res, res);
}
@ -7746,9 +7740,8 @@ nsHTMLEditRules::AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection
return NS_OK;
}
nsCOMPtr<nsIDOMNode> brNode;
// we know we can skip the rest of this routine given the cirumstance
return CreateMozBR(selNode, selOffset, address_of(brNode));
return CreateMozBR(selNode, selOffset);
}
}
@ -7782,7 +7775,7 @@ nsHTMLEditRules::AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection
// the user will see no new line for the break. Also, things
// like table cells won't grow in height.
nsCOMPtr<nsIDOMNode> brNode;
res = CreateMozBR(selNode, selOffset, address_of(brNode));
res = CreateMozBR(selNode, selOffset, getter_AddRefs(brNode));
NS_ENSURE_SUCCESS(res, res);
res = nsEditor::GetNodeLocation(brNode, address_of(selNode), &selOffset);
NS_ENSURE_SUCCESS(res, res);
@ -8444,14 +8437,13 @@ nsHTMLEditRules::InsertMozBRIfNeeded(nsIDOMNode *aNode)
if (!IsBlockNode(aNode)) return NS_OK;
bool isEmpty;
nsCOMPtr<nsIDOMNode> brNode;
nsresult res = mHTMLEditor->IsEmptyNode(aNode, &isEmpty);
NS_ENSURE_SUCCESS(res, res);
if (isEmpty)
{
res = CreateMozBR(aNode, 0, address_of(brNode));
if (!isEmpty) {
return NS_OK;
}
return res;
return CreateMozBR(aNode, 0);
}
NS_IMETHODIMP

Просмотреть файл

@ -1103,8 +1103,7 @@ nsTextEditRules::CreateTrailingBRIfNeeded()
if (!lastChild->IsHTML(nsGkAtoms::br)) {
nsAutoTxnsConserveSelection dontSpazMySelection(mEditor);
nsCOMPtr<nsIDOMNode> domBody = do_QueryInterface(body);
nsCOMPtr<nsIDOMNode> unused;
return CreateMozBR(domBody, body->Length(), address_of(unused));
return CreateMozBR(domBody, body->Length());
}
// Check to see if the trailing BR is a former bogus node - this will have
@ -1334,21 +1333,26 @@ nsTextEditRules::FillBufWithPWChars(nsAString *aOutString, PRInt32 aLength)
// CreateMozBR: put a BR node with moz attribute at {aNode, aOffset}
//
nsresult
nsTextEditRules::CreateMozBR(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outBRNode)
nsTextEditRules::CreateMozBR(nsIDOMNode* inParent, PRInt32 inOffset,
nsIDOMNode** outBRNode)
{
NS_ENSURE_TRUE(inParent && outBRNode, NS_ERROR_NULL_POINTER);
NS_ENSURE_TRUE(inParent, NS_ERROR_NULL_POINTER);
nsresult res = mEditor->CreateBR(inParent, inOffset, outBRNode);
nsCOMPtr<nsIDOMNode> brNode;
nsresult res = mEditor->CreateBR(inParent, inOffset, address_of(brNode));
NS_ENSURE_SUCCESS(res, res);
// give it special moz attr
nsCOMPtr<nsIDOMElement> brElem = do_QueryInterface(*outBRNode);
if (brElem)
{
nsCOMPtr<nsIDOMElement> brElem = do_QueryInterface(brNode);
if (brElem) {
res = mEditor->SetAttribute(brElem, NS_LITERAL_STRING("type"), NS_LITERAL_STRING("_moz"));
NS_ENSURE_SUCCESS(res, res);
}
return res;
if (outBRNode) {
brNode.forget(outBRNode);
}
return NS_OK;
}
NS_IMETHODIMP

Просмотреть файл

@ -226,7 +226,8 @@ protected:
/** Remove IME composition text from password buffer */
nsresult RemoveIMETextFromPWBuf(PRUint32 &aStart, nsAString *aIMEString);
nsresult CreateMozBR(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outBRNode);
nsresult CreateMozBR(nsIDOMNode* inParent, PRInt32 inOffset,
nsIDOMNode** outBRNode = nsnull);
nsresult CheckBidiLevelForDeletion(nsISelection *aSelection,
nsIDOMNode *aSelNode,