Bug 606430 - "ASSERTION: EnsureEditorInitialized has been called while a previous call was in progress"; r=bzbarsky a=blocking-final+

This commit is contained in:
Ehsan Akhgari 2010-10-22 18:42:07 -04:00
Родитель b42904ff2d
Коммит 02f52a1b02
3 изменённых файлов: 57 добавлений и 1 удалений

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

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<script>
function boom()
{
var r = document.documentElement;
var i = document.getElementById("i");
document.removeChild(r);
document.appendChild(r);
w("dump('A\\n')");
document.removeChild(r);
w("dump('B\\n')");
document.appendChild(r);
function w(s)
{
var ns = document.createElement("script");
var nt = document.createTextNode(s);
ns.appendChild(nt);
i.appendChild(ns);
}
}
</script>
</head>
<body onload="boom();"><input id="i"></body>
</html>

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

@ -20,3 +20,4 @@ load 580507-1.xhtml
load 590387.html
load 596785-1.html
load 596785-2.html
load 606430-1.html

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

@ -78,6 +78,30 @@ struct SelectionState {
PRInt32 mEnd;
};
class RestoreSelectionState : public nsRunnable {
public:
RestoreSelectionState(nsTextControlFrame *aFrame, PRInt32 aStart, PRInt32 aEnd)
: mFrame(aFrame),
mWeakFrame(aFrame),
mStart(aStart),
mEnd(aEnd)
{
}
NS_IMETHOD Run() {
if (mWeakFrame.IsAlive()) {
mFrame->SetSelectionRange(mStart, mEnd);
}
return NS_OK;
}
private:
nsTextControlFrame* mFrame;
nsWeakFrame mWeakFrame;
PRInt32 mStart;
PRInt32 mEnd;
};
/*static*/
PRBool
nsITextControlElement::GetWrapPropertyEnum(nsIContent* aContent,
@ -1329,7 +1353,7 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue)
// Restore our selection after being bound to a new frame
if (mSelState) {
mBoundFrame->SetSelectionRange(mSelState->mStart, mSelState->mEnd);
nsContentUtils::AddScriptRunner(new RestoreSelectionState(mBoundFrame, mSelState->mStart, mSelState->mEnd));
mSelState = nsnull;
}