diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 34f0c7d5427..750d7e1aab3 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1554,8 +1554,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) // notice that we ignore the result NotifyReflowObservers(NS_PRESSHELL_INITIAL_REFLOW); - - StCaretHider caretHider(this); // stack-based class hides caret until dtor. + StCaretHider caretHider(mCaret); // stack-based class hides caret until dtor. WillCauseReflow(); @@ -1693,7 +1692,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight) NotifyReflowObservers(NS_PRESSHELL_RESIZE_REFLOW); mViewManager->CacheWidgetChanges(PR_TRUE); - StCaretHider caretHider(this); // stack-based class hides caret until dtor. + StCaretHider caretHider(mCaret); // stack-based class hides caret until dtor. WillCauseReflow(); if (mPresContext) { @@ -1889,11 +1888,10 @@ NS_IMETHODIMP PresShell::SetCaretEnabled(PRBool aInEnable) if (mDocument) mDocument->FlushPendingNotifications(); - nsCOMPtr sel; - if (NS_SUCCEEDED(GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel))) && sel) - { - result = mCaret->SetCaretVisible(mCaretEnabled, sel); - } + nsCOMPtr domSel; + if (NS_SUCCEEDED(GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel))) && domSel) + mCaret->SetCaretDOMSelection(domSel); + result = mCaret->SetCaretVisible(mCaretEnabled); } return result; @@ -1902,11 +1900,7 @@ NS_IMETHODIMP PresShell::SetCaretEnabled(PRBool aInEnable) NS_IMETHODIMP PresShell::SetCaretReadOnly(PRBool aReadOnly) { - nsCOMPtr domSel; - if (NS_SUCCEEDED(GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel))) && domSel) - { - return mCaret->SetCaretReadOnly(aReadOnly, domSel); - } + return mCaret->SetCaretReadOnly(aReadOnly); return NS_ERROR_FAILURE; } @@ -3356,7 +3350,7 @@ PresShell::Paint(nsIView *aView, if (nsnull != frame) { - StCaretHider caretHider(this); // stack-based class hides caret until dtor. + StCaretHider caretHider(mCaret); // stack-based class hides caret until dtor. // If the frame is absolutely positioned, then the 'clip' property // applies diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 34f0c7d5427..750d7e1aab3 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1554,8 +1554,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) // notice that we ignore the result NotifyReflowObservers(NS_PRESSHELL_INITIAL_REFLOW); - - StCaretHider caretHider(this); // stack-based class hides caret until dtor. + StCaretHider caretHider(mCaret); // stack-based class hides caret until dtor. WillCauseReflow(); @@ -1693,7 +1692,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight) NotifyReflowObservers(NS_PRESSHELL_RESIZE_REFLOW); mViewManager->CacheWidgetChanges(PR_TRUE); - StCaretHider caretHider(this); // stack-based class hides caret until dtor. + StCaretHider caretHider(mCaret); // stack-based class hides caret until dtor. WillCauseReflow(); if (mPresContext) { @@ -1889,11 +1888,10 @@ NS_IMETHODIMP PresShell::SetCaretEnabled(PRBool aInEnable) if (mDocument) mDocument->FlushPendingNotifications(); - nsCOMPtr sel; - if (NS_SUCCEEDED(GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel))) && sel) - { - result = mCaret->SetCaretVisible(mCaretEnabled, sel); - } + nsCOMPtr domSel; + if (NS_SUCCEEDED(GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel))) && domSel) + mCaret->SetCaretDOMSelection(domSel); + result = mCaret->SetCaretVisible(mCaretEnabled); } return result; @@ -1902,11 +1900,7 @@ NS_IMETHODIMP PresShell::SetCaretEnabled(PRBool aInEnable) NS_IMETHODIMP PresShell::SetCaretReadOnly(PRBool aReadOnly) { - nsCOMPtr domSel; - if (NS_SUCCEEDED(GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel))) && domSel) - { - return mCaret->SetCaretReadOnly(aReadOnly, domSel); - } + return mCaret->SetCaretReadOnly(aReadOnly); return NS_ERROR_FAILURE; } @@ -3356,7 +3350,7 @@ PresShell::Paint(nsIView *aView, if (nsnull != frame) { - StCaretHider caretHider(this); // stack-based class hides caret until dtor. + StCaretHider caretHider(mCaret); // stack-based class hides caret until dtor. // If the frame is absolutely positioned, then the 'clip' property // applies diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp index 3ae768647cd..59896d805bd 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp @@ -239,7 +239,10 @@ nsTextAreaSelectionImpl::SetCaretEnabled(PRBool enabled) nsCOMPtr domSel; if (NS_SUCCEEDED(result = mFrameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel)))) { - return caret->SetCaretVisible(enabled, domSel); + nsCOMPtr domSel; + if (NS_SUCCEEDED(GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel))) && domSel) + caret->SetCaretDOMSelection(domSel); + return caret->SetCaretVisible(enabled); } } @@ -261,7 +264,7 @@ nsTextAreaSelectionImpl::SetCaretReadOnly(PRBool aReadOnly) nsCOMPtr domSel; if (NS_SUCCEEDED(result = mFrameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel)))) { - return caret->SetCaretReadOnly(aReadOnly, domSel); + return caret->SetCaretReadOnly(aReadOnly); } } @@ -273,10 +276,20 @@ NS_IMETHODIMP nsTextAreaSelectionImpl::GetCaretEnabled(PRBool *_retval) { if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED; - nsCOMPtr selCon = do_QueryReferent(mPresShellWeak); - if (selCon) + nsresult result; + nsCOMPtr shell = do_QueryReferent(mPresShellWeak, &result); + if (shell) { - return selCon->GetCaretEnabled(_retval);//we can use presshells because there is only 1 caret + nsCOMPtr caret; + if (NS_SUCCEEDED(result = shell->GetCaret(getter_AddRefs(caret)))) + { + nsCOMPtr domSel; + if (NS_SUCCEEDED(result = mFrameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel)))) + { + return caret->GetCaretVisible(_retval); + } + } + } return NS_ERROR_FAILURE; } @@ -540,6 +553,13 @@ nsGfxTextControlFrame2::~nsGfxTextControlFrame2() NS_IMETHODIMP nsGfxTextControlFrame2::Destroy(nsIPresContext* aPresContext) { + mSelCon = 0; + mEditor = 0; + if (mCachedState) + { + delete mCachedState; + mCachedState = nsnull; + } nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE); if (mFormFrame) { mFormFrame->RemoveFormControlFrame(*this); @@ -1725,19 +1745,7 @@ nsGfxTextControlFrame2::GetText(nsString* aText, PRBool aInitialValue) } else { - if (mEditor) - { - nsCOMPtr imeSupport = do_QueryInterface(mEditor); - if(imeSupport) - imeSupport->ForceCompositionEnd(); - nsString format; format.AssignWithConversion("text/plain"); - mEditor->OutputToString(*aText, format, 0); - } - // we've never built our editor, so the content attribute is the value - else - { - rv = nsFormControlHelper::GetInputElementValue(mContent, aText, aInitialValue); - } + GetTextControlFrameState(*aText); } RemoveNewlines(*aText); }