diff --git a/content/html/content/crashtests/606430-1.html b/content/html/content/crashtests/606430-1.html new file mode 100644 index 000000000000..c347e3c9f199 --- /dev/null +++ b/content/html/content/crashtests/606430-1.html @@ -0,0 +1,31 @@ + + +
+ + + + + diff --git a/content/html/content/crashtests/crashtests.list b/content/html/content/crashtests/crashtests.list index a49c79e9bcab..e2b540a06766 100644 --- a/content/html/content/crashtests/crashtests.list +++ b/content/html/content/crashtests/crashtests.list @@ -20,3 +20,4 @@ load 580507-1.xhtml load 590387.html load 596785-1.html load 596785-2.html +load 606430-1.html diff --git a/content/html/content/src/nsTextEditorState.cpp b/content/html/content/src/nsTextEditorState.cpp index 33bc3630bbb0..2fa49de42f1f 100644 --- a/content/html/content/src/nsTextEditorState.cpp +++ b/content/html/content/src/nsTextEditorState.cpp @@ -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; }