mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 12:55:46 +00:00
Add an accessor for the caret, RefreshCaret, and a couple of other private caret methods in nsPresShell.
This commit is contained in:
parent
61fc5b2481
commit
a99f1c6f2c
@ -21,6 +21,7 @@
|
|||||||
#include "nslayout.h"
|
#include "nslayout.h"
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsCoord.h"
|
#include "nsCoord.h"
|
||||||
|
|
||||||
class nsIContent;
|
class nsIContent;
|
||||||
class nsIDocument;
|
class nsIDocument;
|
||||||
class nsIDocumentObserver;
|
class nsIDocumentObserver;
|
||||||
@ -35,6 +36,7 @@ class nsIPageSequenceFrame;
|
|||||||
class nsIDOMSelection;
|
class nsIDOMSelection;
|
||||||
class nsString;
|
class nsString;
|
||||||
class nsStringArray;
|
class nsStringArray;
|
||||||
|
class nsICaret;
|
||||||
|
|
||||||
#define NS_IPRESSHELL_IID \
|
#define NS_IPRESSHELL_IID \
|
||||||
{ 0x76e79c60, 0x944e, 0x11d1, \
|
{ 0x76e79c60, 0x944e, 0x11d1, \
|
||||||
@ -180,12 +182,23 @@ public:
|
|||||||
NS_IMETHOD CantRenderReplacedElement(nsIPresContext* aPresContext,
|
NS_IMETHOD CantRenderReplacedElement(nsIPresContext* aPresContext,
|
||||||
nsIFrame* aFrame) = 0;
|
nsIFrame* aFrame) = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrolls the view of the document so that the anchor with the specified
|
* Scrolls the view of the document so that the anchor with the specified
|
||||||
* name is displayed at the top of the window
|
* name is displayed at the top of the window
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD GoToAnchor(const nsString& aAnchorName) const = 0;
|
NS_IMETHOD GoToAnchor(const nsString& aAnchorName) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the caret, if it exists. AddRefs it.
|
||||||
|
*/
|
||||||
|
NS_IMETHOD GetCaret(nsICaret **outCaret) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh the caret. Called by frames when they redraw
|
||||||
|
*/
|
||||||
|
NS_IMETHOD RefreshCaret() = 0;
|
||||||
|
|
||||||
// XXX events
|
// XXX events
|
||||||
// XXX selection
|
// XXX selection
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ FrameHashTable::Remove(nsIFrame* aKey)
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
// Class IID's
|
// Class IID's
|
||||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||||
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
|
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
|
||||||
static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID);
|
static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID);
|
||||||
|
|
||||||
@ -174,6 +174,7 @@ static NS_DEFINE_IID(kIDOMRangeIID, NS_IDOMRANGE_IID);
|
|||||||
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
||||||
static NS_DEFINE_IID(kIFocusTrackerIID, NS_IFOCUSTRACKER_IID);
|
static NS_DEFINE_IID(kIFocusTrackerIID, NS_IFOCUSTRACKER_IID);
|
||||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||||
|
static NS_DEFINE_IID(kICaretIID, NS_ICARET_IID);
|
||||||
static NS_DEFINE_IID(kICaretID, NS_ICARET_IID);
|
static NS_DEFINE_IID(kICaretID, NS_ICARET_IID);
|
||||||
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
|
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
|
||||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||||
@ -299,6 +300,11 @@ public:
|
|||||||
|
|
||||||
NS_IMETHOD GetFocus(nsIFrame **aFrame, nsIFrame **aAnchorFrame);
|
NS_IMETHOD GetFocus(nsIFrame **aFrame, nsIFrame **aAnchorFrame);
|
||||||
|
|
||||||
|
// caret handling
|
||||||
|
NS_IMETHOD GetCaret(nsICaret **outCaret);
|
||||||
|
NS_IMETHOD RefreshCaret();
|
||||||
|
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
void HandleCantRenderReplacedElementEvent(nsIFrame* aFrame);
|
void HandleCantRenderReplacedElementEvent(nsIFrame* aFrame);
|
||||||
|
|
||||||
@ -307,6 +313,12 @@ protected:
|
|||||||
|
|
||||||
nsresult ReconstructFrames(void);
|
nsresult ReconstructFrames(void);
|
||||||
|
|
||||||
|
// turn the caret on and off.
|
||||||
|
nsresult EnableCaret();
|
||||||
|
nsresult DisableCaret();
|
||||||
|
|
||||||
|
PRBool mCaretEnabled;
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
void VerifyIncrementalReflow();
|
void VerifyIncrementalReflow();
|
||||||
PRBool mInVerifyReflow;
|
PRBool mInVerifyReflow;
|
||||||
@ -550,6 +562,8 @@ PresShell::Init(nsIDocument* aDocument,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
mCaretEnabled = PR_FALSE;
|
||||||
|
|
||||||
// Important: this has to happen after the selection has been set up
|
// Important: this has to happen after the selection has been set up
|
||||||
#ifdef SHOW_CARET
|
#ifdef SHOW_CARET
|
||||||
nsCaretProperties *caretProperties = NewCaretProperties();
|
nsCaretProperties *caretProperties = NewCaretProperties();
|
||||||
@ -754,6 +768,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
|||||||
{
|
{
|
||||||
nsIContent* root = nsnull;
|
nsIContent* root = nsnull;
|
||||||
|
|
||||||
|
DisableCaret();
|
||||||
EnterReflowLock();
|
EnterReflowLock();
|
||||||
|
|
||||||
if (nsnull != mPresContext) {
|
if (nsnull != mPresContext) {
|
||||||
@ -814,6 +829,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExitReflowLock();
|
ExitReflowLock();
|
||||||
|
EnableCaret();
|
||||||
|
|
||||||
return NS_OK; //XXX this needs to be real. MMP
|
return NS_OK; //XXX this needs to be real. MMP
|
||||||
}
|
}
|
||||||
@ -821,6 +837,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
||||||
{
|
{
|
||||||
|
DisableCaret();
|
||||||
EnterReflowLock();
|
EnterReflowLock();
|
||||||
|
|
||||||
if (nsnull != mPresContext) {
|
if (nsnull != mPresContext) {
|
||||||
@ -874,7 +891,8 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
ExitReflowLock();
|
ExitReflowLock();
|
||||||
|
EnableCaret();
|
||||||
|
|
||||||
return NS_OK; //XXX this needs to be real. MMP
|
return NS_OK; //XXX this needs to be real. MMP
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -898,7 +916,37 @@ PresShell::GetFocus(nsIFrame **aFrame, nsIFrame **aAnchorFrame){
|
|||||||
*aAnchorFrame = mAnchorEventFrame;
|
*aAnchorFrame = mAnchorEventFrame;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMETHODIMP PresShell::GetCaret(nsICaret **outCaret)
|
||||||
|
{
|
||||||
|
if (!outCaret || !mCaret)
|
||||||
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
return mCaret->QueryInterface(kICaretIID,(void **)outCaret);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP PresShell::RefreshCaret()
|
||||||
|
{
|
||||||
|
if (mCaret)
|
||||||
|
mCaret->Refresh();
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult PresShell::DisableCaret()
|
||||||
|
{
|
||||||
|
if (mCaret)
|
||||||
|
return mCaret->SetCaretVisible(PR_FALSE);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult PresShell::EnableCaret()
|
||||||
|
{
|
||||||
|
if (mCaret && mCaretEnabled)
|
||||||
|
return mCaret->SetCaretVisible(PR_TRUE);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PresShell::StyleChangeReflow()
|
PresShell::StyleChangeReflow()
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "nslayout.h"
|
#include "nslayout.h"
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsCoord.h"
|
#include "nsCoord.h"
|
||||||
|
|
||||||
class nsIContent;
|
class nsIContent;
|
||||||
class nsIDocument;
|
class nsIDocument;
|
||||||
class nsIDocumentObserver;
|
class nsIDocumentObserver;
|
||||||
@ -35,6 +36,7 @@ class nsIPageSequenceFrame;
|
|||||||
class nsIDOMSelection;
|
class nsIDOMSelection;
|
||||||
class nsString;
|
class nsString;
|
||||||
class nsStringArray;
|
class nsStringArray;
|
||||||
|
class nsICaret;
|
||||||
|
|
||||||
#define NS_IPRESSHELL_IID \
|
#define NS_IPRESSHELL_IID \
|
||||||
{ 0x76e79c60, 0x944e, 0x11d1, \
|
{ 0x76e79c60, 0x944e, 0x11d1, \
|
||||||
@ -180,12 +182,23 @@ public:
|
|||||||
NS_IMETHOD CantRenderReplacedElement(nsIPresContext* aPresContext,
|
NS_IMETHOD CantRenderReplacedElement(nsIPresContext* aPresContext,
|
||||||
nsIFrame* aFrame) = 0;
|
nsIFrame* aFrame) = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrolls the view of the document so that the anchor with the specified
|
* Scrolls the view of the document so that the anchor with the specified
|
||||||
* name is displayed at the top of the window
|
* name is displayed at the top of the window
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD GoToAnchor(const nsString& aAnchorName) const = 0;
|
NS_IMETHOD GoToAnchor(const nsString& aAnchorName) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the caret, if it exists. AddRefs it.
|
||||||
|
*/
|
||||||
|
NS_IMETHOD GetCaret(nsICaret **outCaret) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh the caret. Called by frames when they redraw
|
||||||
|
*/
|
||||||
|
NS_IMETHOD RefreshCaret() = 0;
|
||||||
|
|
||||||
// XXX events
|
// XXX events
|
||||||
// XXX selection
|
// XXX selection
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ FrameHashTable::Remove(nsIFrame* aKey)
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
// Class IID's
|
// Class IID's
|
||||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||||
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
|
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
|
||||||
static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID);
|
static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID);
|
||||||
|
|
||||||
@ -174,6 +174,7 @@ static NS_DEFINE_IID(kIDOMRangeIID, NS_IDOMRANGE_IID);
|
|||||||
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
||||||
static NS_DEFINE_IID(kIFocusTrackerIID, NS_IFOCUSTRACKER_IID);
|
static NS_DEFINE_IID(kIFocusTrackerIID, NS_IFOCUSTRACKER_IID);
|
||||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||||
|
static NS_DEFINE_IID(kICaretIID, NS_ICARET_IID);
|
||||||
static NS_DEFINE_IID(kICaretID, NS_ICARET_IID);
|
static NS_DEFINE_IID(kICaretID, NS_ICARET_IID);
|
||||||
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
|
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
|
||||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||||
@ -299,6 +300,11 @@ public:
|
|||||||
|
|
||||||
NS_IMETHOD GetFocus(nsIFrame **aFrame, nsIFrame **aAnchorFrame);
|
NS_IMETHOD GetFocus(nsIFrame **aFrame, nsIFrame **aAnchorFrame);
|
||||||
|
|
||||||
|
// caret handling
|
||||||
|
NS_IMETHOD GetCaret(nsICaret **outCaret);
|
||||||
|
NS_IMETHOD RefreshCaret();
|
||||||
|
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
void HandleCantRenderReplacedElementEvent(nsIFrame* aFrame);
|
void HandleCantRenderReplacedElementEvent(nsIFrame* aFrame);
|
||||||
|
|
||||||
@ -307,6 +313,12 @@ protected:
|
|||||||
|
|
||||||
nsresult ReconstructFrames(void);
|
nsresult ReconstructFrames(void);
|
||||||
|
|
||||||
|
// turn the caret on and off.
|
||||||
|
nsresult EnableCaret();
|
||||||
|
nsresult DisableCaret();
|
||||||
|
|
||||||
|
PRBool mCaretEnabled;
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
void VerifyIncrementalReflow();
|
void VerifyIncrementalReflow();
|
||||||
PRBool mInVerifyReflow;
|
PRBool mInVerifyReflow;
|
||||||
@ -550,6 +562,8 @@ PresShell::Init(nsIDocument* aDocument,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
mCaretEnabled = PR_FALSE;
|
||||||
|
|
||||||
// Important: this has to happen after the selection has been set up
|
// Important: this has to happen after the selection has been set up
|
||||||
#ifdef SHOW_CARET
|
#ifdef SHOW_CARET
|
||||||
nsCaretProperties *caretProperties = NewCaretProperties();
|
nsCaretProperties *caretProperties = NewCaretProperties();
|
||||||
@ -754,6 +768,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
|||||||
{
|
{
|
||||||
nsIContent* root = nsnull;
|
nsIContent* root = nsnull;
|
||||||
|
|
||||||
|
DisableCaret();
|
||||||
EnterReflowLock();
|
EnterReflowLock();
|
||||||
|
|
||||||
if (nsnull != mPresContext) {
|
if (nsnull != mPresContext) {
|
||||||
@ -814,6 +829,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExitReflowLock();
|
ExitReflowLock();
|
||||||
|
EnableCaret();
|
||||||
|
|
||||||
return NS_OK; //XXX this needs to be real. MMP
|
return NS_OK; //XXX this needs to be real. MMP
|
||||||
}
|
}
|
||||||
@ -821,6 +837,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
||||||
{
|
{
|
||||||
|
DisableCaret();
|
||||||
EnterReflowLock();
|
EnterReflowLock();
|
||||||
|
|
||||||
if (nsnull != mPresContext) {
|
if (nsnull != mPresContext) {
|
||||||
@ -874,7 +891,8 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
ExitReflowLock();
|
ExitReflowLock();
|
||||||
|
EnableCaret();
|
||||||
|
|
||||||
return NS_OK; //XXX this needs to be real. MMP
|
return NS_OK; //XXX this needs to be real. MMP
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -898,7 +916,37 @@ PresShell::GetFocus(nsIFrame **aFrame, nsIFrame **aAnchorFrame){
|
|||||||
*aAnchorFrame = mAnchorEventFrame;
|
*aAnchorFrame = mAnchorEventFrame;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMETHODIMP PresShell::GetCaret(nsICaret **outCaret)
|
||||||
|
{
|
||||||
|
if (!outCaret || !mCaret)
|
||||||
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
return mCaret->QueryInterface(kICaretIID,(void **)outCaret);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP PresShell::RefreshCaret()
|
||||||
|
{
|
||||||
|
if (mCaret)
|
||||||
|
mCaret->Refresh();
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult PresShell::DisableCaret()
|
||||||
|
{
|
||||||
|
if (mCaret)
|
||||||
|
return mCaret->SetCaretVisible(PR_FALSE);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult PresShell::EnableCaret()
|
||||||
|
{
|
||||||
|
if (mCaret && mCaretEnabled)
|
||||||
|
return mCaret->SetCaretVisible(PR_TRUE);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PresShell::StyleChangeReflow()
|
PresShell::StyleChangeReflow()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user