diff --git a/mozilla/content/base/public/nsISelectionController.idl b/mozilla/content/base/public/nsISelectionController.idl index ad32dc879da..da495c774b9 100644 --- a/mozilla/content/base/public/nsISelectionController.idl +++ b/mozilla/content/base/public/nsISelectionController.idl @@ -128,6 +128,14 @@ interface nsISelectionController : nsISelectionDisplay */ boolean getCaretEnabled(); + /** + * Show the caret even in selections. By default the caret is hidden unless the + * selection is collapsed. Use this function to show the caret even in selections. + * @param aVisibility PR_TRUE to show the caret in selections. PR_FALSE to hide. + * @return always NS_OK + */ + void setCaretVisibilityDuringSelection(in boolean visibility); + /** CharacterMove will move the selection one character forward/backward in the document. * this will also have the effect of collapsing the selection if the aExtend = PR_FALSE * the "point" of selection that is extended is considered the "focus" point. diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 12d303c3a3c..a8f3516e441 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1193,6 +1193,7 @@ public: NS_IMETHOD SetCaretWidth(PRInt16 aPixels); NS_IMETHOD SetCaretReadOnly(PRBool aReadOnly); NS_IMETHOD GetCaretEnabled(PRBool *aOutEnabled); + NS_IMETHOD SetCaretVisibilityDuringSelection(PRBool aVisibility); NS_IMETHOD SetSelectionFlags(PRInt16 aInEnable); NS_IMETHOD GetSelectionFlags(PRInt16 *aOutEnable); @@ -3190,6 +3191,13 @@ NS_IMETHODIMP PresShell::GetCaretEnabled(PRBool *aOutEnabled) return NS_OK; } +NS_IMETHODIMP PresShell::SetCaretVisibilityDuringSelection(PRBool aVisibility) +{ + if (mCaret) + mCaret->SetVisibilityDuringSelection(aVisibility); + return NS_OK; +} + NS_IMETHODIMP PresShell::SetSelectionFlags(PRInt16 aInEnable) { mSelectionFlags = aInEnable; diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 78e6cbf3bba..3e26f958b07 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -428,6 +428,7 @@ public: NS_IMETHOD SetCaretWidth(PRInt16 twips); NS_IMETHOD SetCaretReadOnly(PRBool aReadOnly); NS_IMETHOD GetCaretEnabled(PRBool *_retval); + NS_IMETHOD SetCaretVisibilityDuringSelection(PRBool aVisibility); NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend); NS_IMETHOD WordMove(PRBool aForward, PRBool aExtend); NS_IMETHOD LineMove(PRBool aForward, PRBool aExtend); @@ -676,6 +677,27 @@ nsTextInputSelectionImpl::GetCaretEnabled(PRBool *_retval) return NS_ERROR_FAILURE; } +NS_IMETHODIMP +nsTextInputSelectionImpl::SetCaretVisibilityDuringSelection(PRBool aVisibility) +{ + if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED; + nsresult result; + nsCOMPtr shell = do_QueryReferent(mPresShellWeak, &result); + if (shell) + { + 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->SetVisibilityDuringSelection(aVisibility); + } + } + + } + return NS_ERROR_FAILURE; +} NS_IMETHODIMP nsTextInputSelectionImpl::CharacterMove(PRBool aForward, PRBool aExtend) diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 12d303c3a3c..a8f3516e441 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1193,6 +1193,7 @@ public: NS_IMETHOD SetCaretWidth(PRInt16 aPixels); NS_IMETHOD SetCaretReadOnly(PRBool aReadOnly); NS_IMETHOD GetCaretEnabled(PRBool *aOutEnabled); + NS_IMETHOD SetCaretVisibilityDuringSelection(PRBool aVisibility); NS_IMETHOD SetSelectionFlags(PRInt16 aInEnable); NS_IMETHOD GetSelectionFlags(PRInt16 *aOutEnable); @@ -3190,6 +3191,13 @@ NS_IMETHODIMP PresShell::GetCaretEnabled(PRBool *aOutEnabled) return NS_OK; } +NS_IMETHODIMP PresShell::SetCaretVisibilityDuringSelection(PRBool aVisibility) +{ + if (mCaret) + mCaret->SetVisibilityDuringSelection(aVisibility); + return NS_OK; +} + NS_IMETHODIMP PresShell::SetSelectionFlags(PRInt16 aInEnable) { mSelectionFlags = aInEnable; diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index 78e6cbf3bba..3e26f958b07 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -428,6 +428,7 @@ public: NS_IMETHOD SetCaretWidth(PRInt16 twips); NS_IMETHOD SetCaretReadOnly(PRBool aReadOnly); NS_IMETHOD GetCaretEnabled(PRBool *_retval); + NS_IMETHOD SetCaretVisibilityDuringSelection(PRBool aVisibility); NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend); NS_IMETHOD WordMove(PRBool aForward, PRBool aExtend); NS_IMETHOD LineMove(PRBool aForward, PRBool aExtend); @@ -676,6 +677,27 @@ nsTextInputSelectionImpl::GetCaretEnabled(PRBool *_retval) return NS_ERROR_FAILURE; } +NS_IMETHODIMP +nsTextInputSelectionImpl::SetCaretVisibilityDuringSelection(PRBool aVisibility) +{ + if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED; + nsresult result; + nsCOMPtr shell = do_QueryReferent(mPresShellWeak, &result); + if (shell) + { + 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->SetVisibilityDuringSelection(aVisibility); + } + } + + } + return NS_ERROR_FAILURE; +} NS_IMETHODIMP nsTextInputSelectionImpl::CharacterMove(PRBool aForward, PRBool aExtend) diff --git a/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp b/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp index 67fb370f31d..b3c54ae031c 100644 --- a/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp +++ b/mozilla/widget/src/xpwidgets/nsXPLookAndFeel.cpp @@ -85,6 +85,7 @@ nsLookAndFeelIntPref nsXPLookAndFeel::sIntPrefs[] = PR_FALSE, nsLookAndFeelTypeInt, 0 }, { "ui.caretBlinkTime", eMetric_CaretBlinkTime, PR_FALSE, nsLookAndFeelTypeInt, 0 }, { "ui.caretWidthTwips", eMetric_SingleLineCaretWidth, PR_FALSE, nsLookAndFeelTypeInt, 0 }, + { "ui.caretVisibleWithSelection", eMetric_ShowCaretDuringSelection, PR_FALSE, nsLookAndFeelTypeInt, 0 }, { "ui.submenuDelay", eMetric_SubmenuDelay, PR_FALSE, nsLookAndFeelTypeInt, 0 }, { "ui.dragFullWindow", eMetric_DragFullWindow, PR_FALSE, nsLookAndFeelTypeInt, 0 }, { "ui.dragThresholdX", eMetric_DragThresholdX, PR_FALSE, nsLookAndFeelTypeInt, 0 },