зеркало из https://github.com/mozilla/pjs.git
Fix the behavior of ranges when insertNode is called -- range should not
collapse. Bug 253609, patch by Joshua Welderson <pythonesque+bugzilla@gmail.com>, r=peterv, sr=jst
This commit is contained in:
Родитель
e260aa4524
Коммит
581b57ea10
|
@ -1938,11 +1938,25 @@ nsresult nsRange::InsertNode(nsIDOMNode* aN)
|
|||
nsCOMPtr<nsIDOMNode> tSCParentNode;
|
||||
res = tStartContainer->GetParentNode(getter_AddRefs(tSCParentNode));
|
||||
if(NS_FAILED(res)) return res;
|
||||
|
||||
PRBool isCollapsed;
|
||||
res = GetCollapsed(&isCollapsed);
|
||||
if(NS_FAILED(res)) return res;
|
||||
|
||||
PRInt32 tEndOffset;
|
||||
GetEndOffset(&tEndOffset);
|
||||
|
||||
nsCOMPtr<nsIDOMText> secondPart;
|
||||
res = startTextNode->SplitText(tStartOffset, getter_AddRefs(secondPart));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// SplitText collapses the range; fix that (bug 253609)
|
||||
if (!isCollapsed)
|
||||
{
|
||||
res = SetEnd(secondPart, tEndOffset - tStartOffset);
|
||||
if(NS_FAILED(res)) return res;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tResultNode;
|
||||
return tSCParentNode->InsertBefore(aN, secondPart, getter_AddRefs(tResultNode));
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче