diff --git a/content/base/public/nsISelectionController.idl b/content/base/public/nsISelectionController.idl index 4c9f4b6bec2..82614c13c52 100644 --- a/content/base/public/nsISelectionController.idl +++ b/content/base/public/nsISelectionController.idl @@ -51,7 +51,7 @@ interface nsIDOMNode; interface nsISelection; interface nsISelectionDisplay; -[scriptable, uuid(80d2e85a-4ad2-45be-88e7-8c1fe943ac4d)] +[scriptable, uuid(513b9460-d56a-4c4e-b6f9-0b8ae4372a3b)] interface nsISelectionController : nsISelectionDisplay { const short SELECTION_NONE=0; @@ -140,6 +140,13 @@ interface nsISelectionController : nsISelectionDisplay */ boolean getCaretEnabled(); + /** + * This is true if the caret is enabled, visible, and currently blinking. + * This is still true when the caret is enabled, visible, but in its "off" + * blink cycle. + */ + readonly attribute boolean caretVisible; + /** * 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. @@ -252,6 +259,6 @@ interface nsISelectionController : nsISelectionDisplay }; %{ C++ #define NS_ISELECTIONCONTROLLER_CID \ - { 0xd2d1d179, 0x85a7, 0x11d3, \ - { 0x99, 0x32, 0x0, 0x10, 0x83, 0x1, 0x23, 0x3c }} + { 0x513b9460, 0xd56a, 0x4c4e, \ + { 0xb6, 0xf9, 0x0b, 0x8a, 0xe4, 0x37, 0x2a, 0x3b }} %} diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index 6812346f8d3..19153aebff5 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -242,7 +242,7 @@ NS_IMETHODIMP nsCaret::SetCaretVisible(PRBool inMakeVisible) NS_IMETHODIMP nsCaret::GetCaretVisible(PRBool *outMakeVisible) { NS_ENSURE_ARG_POINTER(outMakeVisible); - *outMakeVisible = mVisible; + *outMakeVisible = (mVisible && MustDrawCaret(PR_TRUE)); return NS_OK; } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 14c58981912..264ebadcf5f 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -920,6 +920,7 @@ public: NS_IMETHOD SetCaretReadOnly(PRBool aReadOnly); NS_IMETHOD GetCaretEnabled(PRBool *aOutEnabled); NS_IMETHOD SetCaretVisibilityDuringSelection(PRBool aVisibility); + NS_IMETHOD GetCaretVisible(PRBool *_retval); virtual void SetCaret(nsICaret *aNewCaret); virtual void RestoreCaret(); @@ -2740,6 +2741,16 @@ NS_IMETHODIMP PresShell::SetCaretVisibilityDuringSelection(PRBool aVisibility) return NS_OK; } +NS_IMETHODIMP PresShell::GetCaretVisible(PRBool *aOutIsVisible) +{ + *aOutIsVisible = PR_FALSE; + if (mCaret) { + nsresult rv = mCaret->GetCaretVisible(aOutIsVisible); + NS_ENSURE_SUCCESS(rv,rv); + } + return NS_OK; +} + NS_IMETHODIMP PresShell::SetSelectionFlags(PRInt16 aInEnable) { mSelectionFlags = aInEnable; diff --git a/layout/base/tests/Makefile.in b/layout/base/tests/Makefile.in index 83e84fa68ac..820d353323d 100644 --- a/layout/base/tests/Makefile.in +++ b/layout/base/tests/Makefile.in @@ -90,6 +90,7 @@ _TEST_FILES = \ test_bug399951.html \ test_bug404209.xhtml \ test_bug416896.html \ + test_bug420499.xul \ $(NULL) # test_bug396024.html is currently disabled because it interacts badly with # the "You can't print-preview while the page is loading" dialog. diff --git a/layout/base/tests/test_bug420499.xul b/layout/base/tests/test_bug420499.xul new file mode 100644 index 00000000000..93757d166fd --- /dev/null +++ b/layout/base/tests/test_bug420499.xul @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Paragraph 1

+

Paragraph 2

+

Paragraph 3

+

Paragraph 4

+

Paragraph 5

+ +
+ + Mozilla Bug 420499 + + + + +
diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 4faf8bcb9a2..99842207169 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -579,6 +579,7 @@ public: NS_IMETHOD SetCaretEnabled(PRBool enabled); NS_IMETHOD SetCaretReadOnly(PRBool aReadOnly); NS_IMETHOD GetCaretEnabled(PRBool *_retval); + NS_IMETHOD GetCaretVisible(PRBool *_retval); NS_IMETHOD SetCaretVisibilityDuringSelection(PRBool aVisibility); NS_IMETHOD CharacterMove(PRBool aForward, PRBool aExtend); NS_IMETHOD CharacterExtendForDelete(); @@ -754,6 +755,12 @@ nsTextInputSelectionImpl::SetCaretReadOnly(PRBool aReadOnly) NS_IMETHODIMP nsTextInputSelectionImpl::GetCaretEnabled(PRBool *_retval) +{ + return GetCaretVisible(_retval); +} + +NS_IMETHODIMP +nsTextInputSelectionImpl::GetCaretVisible(PRBool *_retval) { if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED; nsresult result;