This commit is contained in:
mjudge%netscape.com 1998-12-08 18:26:06 +00:00
Родитель f4b7dee737
Коммит c549a78e51
11 изменённых файлов: 145 добавлений и 169 удалений

Просмотреть файл

@ -57,12 +57,6 @@
#endif
// Find/Serach Includes
#if XP_NEW_SELECTION
#else
#include "nsISelection.h"
#include "nsSelectionRange.h"
#include "nsSelectionPoint.h"
#endif
const PRInt32 kForward = 0;
const PRInt32 kBackward = 1;
@ -1446,6 +1440,8 @@ PRBool nsHTMLDocument::SearchBlock(BlockText & aBlockText,
}
}
#if 0
//DEBUG MJUDGE
if (str) {
PRInt32 inx = str - contentStr;
@ -1474,7 +1470,7 @@ PRBool nsHTMLDocument::SearchBlock(BlockText & aBlockText,
found = PR_TRUE;
}
#endif //0
delete[] searchStr;
delete[] contentStr;
@ -1838,7 +1834,8 @@ nsIDOMNode * FindDOMNode(nsIDOMNode * aNode, nsIContent * aContent)
*/
NS_IMETHODIMP nsHTMLDocument::FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound)
{
#if 0
//DEBUG MJUDGE
aIsFound = PR_FALSE;
mShouldMatchCase = aMatchCase;
@ -2121,6 +2118,7 @@ NS_IMETHODIMP nsHTMLDocument::FindNext(const nsString &aSearchStr, PRBool aMatch
NS_RELEASE(startContent);
NS_RELEASE(endContent);
}
#endif //0
return NS_OK;
}

Просмотреть файл

@ -38,6 +38,8 @@
#include "nsIEventStateManager.h"
#include "nsDOMEvent.h"
#include "nsHTMLParts.h"
#include "nsISelection.h"
#include "nsLayoutCID.h"
static PRBool gsNoisyRefs = PR_FALSE;
#undef NOISY
@ -142,6 +144,8 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIPresShellIID, NS_IPRESSHELL_IID);
static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID);
static NS_DEFINE_IID(kIViewObserverIID, NS_IVIEWOBSERVER_IID);
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
class PresShell : public nsIPresShell, public nsIViewObserver,
private nsIDocumentObserver
@ -215,6 +219,8 @@ public:
virtual nsIPresContext* GetPresContext();
virtual nsIViewManager* GetViewManager();
virtual nsIStyleSet* GetStyleSet();
virtual nsresult SetFocus(nsIFrame *aFrame);
virtual nsresult GetSelection(nsISelection **aSelection);
NS_IMETHOD EnterReflowLock();
NS_IMETHOD ExitReflowLock();
virtual void BeginObservingDocument();
@ -261,6 +267,8 @@ protected:
PRUint32 mReflowLockCount;
PRBool mIsDestroying;
nsIFrame* mCurrentEventFrame;
nsIFrame* mFocusEventFrame; //keeps track of which frame has focus.
nsISelection *mSelection;
};
#ifdef NS_DEBUG
@ -322,6 +330,7 @@ PresShell::PresShell()
{
//XXX joki 11/17 - temporary event hack.
mIsDestroying = PR_FALSE;
nsRepository::CreateInstance(kRangeListCID, nsnull, kISelectionIID, (void **) &mSelection);
}
#ifdef NS_DEBUG
@ -394,6 +403,7 @@ PresShell::~PresShell()
mDocument->DeleteShell(this);
NS_RELEASE(mDocument);
}
NS_IF_RELEASE(mSelection);
mRefCnt = 0;
}
@ -483,6 +493,27 @@ PresShell::GetStyleSet()
return mStyleSet;
}
nsresult
PresShell::SetFocus(nsIFrame *aFrame)
{
if (!aFrame)
return NS_ERROR_NULL_POINTER;
mFocusEventFrame = aFrame;
return NS_OK;
}
nsresult
PresShell::GetSelection(nsISelection **aSelection)
{
if (!aSelection || !mSelection)
return NS_ERROR_NULL_POINTER;
return mSelection->QueryInterface(kISelectionIID,(void **)aSelection);
}
// Make shell be a document observer
void
PresShell::BeginObservingDocument()
@ -816,6 +847,9 @@ PresShell::ClearFrameRefs(nsIFrame* aFrame)
if (aFrame == mCurrentEventFrame) {
mCurrentEventFrame = nsnull;
}
if (aFrame == mFocusEventFrame) {
mFocusEventFrame = nsnull;
}
}
NS_IMETHODIMP PresShell :: CreateRenderingContext(nsIFrame *aFrame,
@ -1142,6 +1176,10 @@ NS_IMETHODIMP PresShell :: HandleEvent(nsIView *aView,
frame = (nsIFrame *)clientData;
if (nsnull != frame) {
if (mSelection && mFocusEventFrame && aEvent->eventStructType == NS_KEY_EVENT)
{
mSelection->HandleKeyEvent(aEvent, mFocusEventFrame);
}
frame->GetFrameForPoint(aEvent->point, &mCurrentEventFrame);
if (nsnull != mCurrentEventFrame) {
//Once we have the targetFrame, handle the event in this order

Просмотреть файл

@ -36,7 +36,6 @@
#include "nsISizeOfHandler.h"
#include "nsIDOMText.h"
#include "nsSelectionRange.h"
#include "nsDocument.h"
#include "nsIDeviceContext.h"
#include "nsIPresShell.h"
@ -66,29 +65,12 @@ PRInt32 fTrackerAddListMax = 0;
nsIDocument *gDoc = nsnull;
// [HACK] Foward Declarations
void RefreshContentFrames(nsIPresContext& aPresContext, nsIContent * aStartContent, nsIContent * aEndContent);
void ForceDrawFrame(nsFrame * aFrame);
void resetContentTrackers();
void RefreshFromContentTrackers(nsIPresContext& aPresContext);
void addRangeToSelectionTrackers(nsIContent * aStartContent, nsIContent * aEndContent, PRUint32 aType);
void RefreshContentFrames(nsIPresContext& aPresContext, nsIContent * aStartContent, nsIContent * aEndContent);
// Initialize Global Selection Data
nsIFrame * nsFrame::mCurrentFrame = nsnull;
PRBool nsFrame::mDoingSelection = PR_FALSE;
PRBool nsFrame::mDidDrag = PR_FALSE;
PRInt32 nsFrame::mStartPos = 0;
// Selection data is valid only from the Mouse Press to the Mouse Release
#if XP_NEW_SELECTION
#else
nsSelectionRange * nsFrame::mSelectionRange = nsnull;
nsISelection * nsFrame::mSelection = nsnull;
nsSelectionPoint * nsFrame::mStartSelectionPoint = nsnull;
nsSelectionPoint * nsFrame::mEndSelectionPoint = nsnull;
#endif
//----------------------------------------------------------------------
@ -248,14 +230,6 @@ nsFrame::~nsFrame()
mView = nsnull;
}
if (mStartSelectionPoint != nsnull) {
delete mStartSelectionPoint;
mStartSelectionPoint = nsnull;
}
if (mEndSelectionPoint != nsnull) {
delete mEndSelectionPoint;
mEndSelectionPoint = nsnull;
}
}
/////////////////////////////////////////////////////////////////////////////
@ -602,23 +576,7 @@ NS_IMETHODIMP nsFrame::Paint(nsIPresContext& aPresContext,
nsIPresShell * shell = aPresContext.GetShell();
nsIDocument * doc = shell->GetDocument();
if (mSelectionRange == nsnull) { // Get Selection Object
#if XP_NEW_SELECTION
#else
nsISelection * selection;
#endif
doc->GetSelection(selection);
mSelectionRange = selection->GetRange();
clearAfterPaint = PR_TRUE;
NS_RELEASE(selection);
}
nsIContent * selStartContent = mSelectionRange->GetStartContent(); // ref counted
nsIContent * selEndContent = mSelectionRange->GetEndContent(); // ref counted
if (doc->IsInRange(selStartContent, selEndContent, content)) {
if (content && doc && doc->IsInSelection(content)) {
nsRect rect;
GetRect(rect);
rect.width--;
@ -629,14 +587,9 @@ NS_IMETHODIMP nsFrame::Paint(nsIPresContext& aPresContext,
aRenderingContext.DrawLine(rect.x, rect.y+rect.height, rect.x+rect.width, rect.y);
}
if (clearAfterPaint) {
mSelectionRange = nsnull;
}
NS_IF_RELEASE(selStartContent);
NS_IF_RELEASE(selEndContent);
NS_RELEASE(content);
NS_RELEASE(doc);
NS_RELEASE(shell);
NS_IF_RELEASE(content);
NS_IF_RELEASE(doc);
NS_IF_RELEASE(shell);
return NS_OK;
}
@ -676,8 +629,7 @@ NS_IMETHODIMP nsFrame::HandleEvent(nsIPresContext& aPresContext,
} else if (aEvent->message == NS_MOUSE_MOVE) {
mDidDrag = PR_TRUE;
HandleDrag(aPresContext, aEvent, aEventStatus);
if (SELECTION_DEBUG) printf("HandleEvent(Drag)::mSelectionRange %s\n", mSelectionRange->ToString());
//DEBUG MJUDGE DEBUG MESSAGE FOR DRAGGING FROM SELECTION
} else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
HandlePress(aPresContext, aEvent, aEventStatus);
}
@ -699,6 +651,8 @@ NS_IMETHODIMP nsFrame::HandlePress(nsIPresContext& aPresContext,
return NS_OK;
}
#if 0
//DEBUG MJUDGE
nsFrame * currentFrame = this;
nsIPresShell * shell = aPresContext.GetShell();
nsMouseEvent * mouseEvent = (nsMouseEvent *)aEvent;
@ -706,10 +660,7 @@ NS_IMETHODIMP nsFrame::HandlePress(nsIPresContext& aPresContext,
gDoc = shell->GetDocument();
#if XP_NEW_SELECTION
#else
nsISelection * selection;
#endif
gDoc->GetSelection(selection);
shell->CreateRenderingContext(this, acx);
@ -874,6 +825,7 @@ NS_IMETHODIMP nsFrame::HandlePress(nsIPresContext& aPresContext,
NS_RELEASE(selection);
aEventStatus = nsEventStatus_eIgnore;
#endif //0
return NS_OK;
}
@ -882,6 +834,8 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
#if 0
//DEBUG MJUDGE
if (DisplaySelection(aPresContext) == PR_FALSE)
{
aEventStatus = nsEventStatus_eIgnore;
@ -999,6 +953,7 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
RefreshFromContentTrackers(aPresContext);
aEventStatus = nsEventStatus_eIgnore;
#endif //0
return NS_OK;
}
@ -1046,6 +1001,8 @@ void nsFrame::AdjustPointsInNewContent(nsIPresContext& aPresContext,
// Get new Cursor Poition in the new content
PRInt32 newPos;
#if 0
//DEBUG MJUDGE
GetPosition(aPresContext, aRendContext, aEvent, aNewFrame, actualOffset, newPos);
@ -1086,6 +1043,7 @@ void nsFrame::AdjustPointsInNewContent(nsIPresContext& aPresContext,
if (SELECTION_DEBUG) printf("--\n--\n--\n--\n--\n--\n--\n Should be here. #102\n");
//return;
}
#endif //0
}
/********************************************************
@ -1094,6 +1052,7 @@ void nsFrame::AdjustPointsInNewContent(nsIPresContext& aPresContext,
void nsFrame::AdjustPointsInSameContent(nsIPresContext& aPresContext,
nsIRenderingContext * aRendContext,
nsGUIEvent * aEvent) {
#if 0
PRUint32 actualOffset = 0;
// Get new Cursor Poition in the same content
@ -1141,6 +1100,7 @@ void nsFrame::AdjustPointsInSameContent(nsIPresContext& aPresContext,
if (SELECTION_DEBUG) printf("Start %s End %s\n", mStartSelectionPoint->ToString(), mEndSelectionPoint->ToString());
//}
#endif //0
}
NS_IMETHODIMP
@ -1747,6 +1707,8 @@ void nsFrame::NewContentIsBefore(nsIPresContext& aPresContext,
nsIContent * aCurrentContent,
nsIFrame * aNewFrame)
{
#if 0
//DEBUG MJUDGE
if (SELECTION_DEBUG) printf("New Frame, New content is before.\n");
// Dragging mouse to the left or backward in content
//
@ -1814,6 +1776,7 @@ void nsFrame::NewContentIsBefore(nsIPresContext& aPresContext,
NS_RELEASE(selEndContent);
NS_RELEASE(doc);
NS_RELEASE(shell);
#endif //0
}
/********************************************************
@ -1883,6 +1846,9 @@ void nsFrame::NewContentIsAfter(nsIPresContext& aPresContext,
nsIContent * aCurrentContent,
nsIFrame * aNewFrame)
{
#if 0
//DEBUG MJUDGE
if (SELECTION_DEBUG) printf("New Frame, New content is after.\n");
@ -2000,6 +1966,7 @@ void nsFrame::NewContentIsAfter(nsIPresContext& aPresContext,
NS_RELEASE(selEndContent);
NS_RELEASE(doc);
NS_RELEASE(shell);
#endif //0
}
/**

Просмотреть файл

@ -351,14 +351,6 @@ protected:
static PRInt32 mStartPos;
// Selection data is valid only from the Mouse Press to the Mouse Release
#if XP_NEW_SELECTION
#else
static nsSelectionRange * mSelectionRange;
static nsISelection * mSelection;
static nsSelectionPoint * mStartSelectionPoint;
static nsSelectionPoint * mEndSelectionPoint;
#endif //XP_NEW_SELECTION
///////////////////////////////////

Просмотреть файл

@ -39,11 +39,6 @@
#include "nsIDocument.h"
#include "nsIDeviceContext.h"
#include "nsXIFConverter.h"
#if XP_NEW_SELECTION
#else
#include "nsISelection.h"
#endif
#include "nsSelectionRange.h"
#include "nsHTMLAtoms.h"
#include "nsITextContent.h"
@ -580,16 +575,15 @@ TextFrame::ComputeSelectionInfo(nsIRenderingContext& aRenderingContext,
PRInt32* aIndicies, PRInt32 aTextLength,
SelectionInfo& aResult)
{
#if 0
//DEBUG MJUDGE HERE IS WHERE THE WORK IS
// Assume, for now, that the selection misses this section of
// content completely.
aResult.mStartOffset = aTextLength;
aResult.mEndOffset = aTextLength;
aResult.mEmptySelection = PR_FALSE;
#if XP_NEW_SELECTION
#else
nsISelection * selection;
#endif
aDocument->GetSelection(selection);
nsSelectionRange * range = selection->GetRange();
@ -674,6 +668,7 @@ TextFrame::ComputeSelectionInfo(nsIRenderingContext& aRenderingContext,
NS_IF_RELEASE(startContent);
NS_IF_RELEASE(endContent);
NS_RELEASE(selection);
#endif //0
}
#define XP_IS_SPACE_W XP_IS_SPACE

Просмотреть файл

@ -36,7 +36,6 @@
#include "nsISizeOfHandler.h"
#include "nsIDOMText.h"
#include "nsSelectionRange.h"
#include "nsDocument.h"
#include "nsIDeviceContext.h"
#include "nsIPresShell.h"
@ -66,29 +65,12 @@ PRInt32 fTrackerAddListMax = 0;
nsIDocument *gDoc = nsnull;
// [HACK] Foward Declarations
void RefreshContentFrames(nsIPresContext& aPresContext, nsIContent * aStartContent, nsIContent * aEndContent);
void ForceDrawFrame(nsFrame * aFrame);
void resetContentTrackers();
void RefreshFromContentTrackers(nsIPresContext& aPresContext);
void addRangeToSelectionTrackers(nsIContent * aStartContent, nsIContent * aEndContent, PRUint32 aType);
void RefreshContentFrames(nsIPresContext& aPresContext, nsIContent * aStartContent, nsIContent * aEndContent);
// Initialize Global Selection Data
nsIFrame * nsFrame::mCurrentFrame = nsnull;
PRBool nsFrame::mDoingSelection = PR_FALSE;
PRBool nsFrame::mDidDrag = PR_FALSE;
PRInt32 nsFrame::mStartPos = 0;
// Selection data is valid only from the Mouse Press to the Mouse Release
#if XP_NEW_SELECTION
#else
nsSelectionRange * nsFrame::mSelectionRange = nsnull;
nsISelection * nsFrame::mSelection = nsnull;
nsSelectionPoint * nsFrame::mStartSelectionPoint = nsnull;
nsSelectionPoint * nsFrame::mEndSelectionPoint = nsnull;
#endif
//----------------------------------------------------------------------
@ -248,14 +230,6 @@ nsFrame::~nsFrame()
mView = nsnull;
}
if (mStartSelectionPoint != nsnull) {
delete mStartSelectionPoint;
mStartSelectionPoint = nsnull;
}
if (mEndSelectionPoint != nsnull) {
delete mEndSelectionPoint;
mEndSelectionPoint = nsnull;
}
}
/////////////////////////////////////////////////////////////////////////////
@ -602,23 +576,7 @@ NS_IMETHODIMP nsFrame::Paint(nsIPresContext& aPresContext,
nsIPresShell * shell = aPresContext.GetShell();
nsIDocument * doc = shell->GetDocument();
if (mSelectionRange == nsnull) { // Get Selection Object
#if XP_NEW_SELECTION
#else
nsISelection * selection;
#endif
doc->GetSelection(selection);
mSelectionRange = selection->GetRange();
clearAfterPaint = PR_TRUE;
NS_RELEASE(selection);
}
nsIContent * selStartContent = mSelectionRange->GetStartContent(); // ref counted
nsIContent * selEndContent = mSelectionRange->GetEndContent(); // ref counted
if (doc->IsInRange(selStartContent, selEndContent, content)) {
if (content && doc && doc->IsInSelection(content)) {
nsRect rect;
GetRect(rect);
rect.width--;
@ -629,14 +587,9 @@ NS_IMETHODIMP nsFrame::Paint(nsIPresContext& aPresContext,
aRenderingContext.DrawLine(rect.x, rect.y+rect.height, rect.x+rect.width, rect.y);
}
if (clearAfterPaint) {
mSelectionRange = nsnull;
}
NS_IF_RELEASE(selStartContent);
NS_IF_RELEASE(selEndContent);
NS_RELEASE(content);
NS_RELEASE(doc);
NS_RELEASE(shell);
NS_IF_RELEASE(content);
NS_IF_RELEASE(doc);
NS_IF_RELEASE(shell);
return NS_OK;
}
@ -676,8 +629,7 @@ NS_IMETHODIMP nsFrame::HandleEvent(nsIPresContext& aPresContext,
} else if (aEvent->message == NS_MOUSE_MOVE) {
mDidDrag = PR_TRUE;
HandleDrag(aPresContext, aEvent, aEventStatus);
if (SELECTION_DEBUG) printf("HandleEvent(Drag)::mSelectionRange %s\n", mSelectionRange->ToString());
//DEBUG MJUDGE DEBUG MESSAGE FOR DRAGGING FROM SELECTION
} else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
HandlePress(aPresContext, aEvent, aEventStatus);
}
@ -699,6 +651,8 @@ NS_IMETHODIMP nsFrame::HandlePress(nsIPresContext& aPresContext,
return NS_OK;
}
#if 0
//DEBUG MJUDGE
nsFrame * currentFrame = this;
nsIPresShell * shell = aPresContext.GetShell();
nsMouseEvent * mouseEvent = (nsMouseEvent *)aEvent;
@ -706,10 +660,7 @@ NS_IMETHODIMP nsFrame::HandlePress(nsIPresContext& aPresContext,
gDoc = shell->GetDocument();
#if XP_NEW_SELECTION
#else
nsISelection * selection;
#endif
gDoc->GetSelection(selection);
shell->CreateRenderingContext(this, acx);
@ -874,6 +825,7 @@ NS_IMETHODIMP nsFrame::HandlePress(nsIPresContext& aPresContext,
NS_RELEASE(selection);
aEventStatus = nsEventStatus_eIgnore;
#endif //0
return NS_OK;
}
@ -882,6 +834,8 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
{
#if 0
//DEBUG MJUDGE
if (DisplaySelection(aPresContext) == PR_FALSE)
{
aEventStatus = nsEventStatus_eIgnore;
@ -999,6 +953,7 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
RefreshFromContentTrackers(aPresContext);
aEventStatus = nsEventStatus_eIgnore;
#endif //0
return NS_OK;
}
@ -1046,6 +1001,8 @@ void nsFrame::AdjustPointsInNewContent(nsIPresContext& aPresContext,
// Get new Cursor Poition in the new content
PRInt32 newPos;
#if 0
//DEBUG MJUDGE
GetPosition(aPresContext, aRendContext, aEvent, aNewFrame, actualOffset, newPos);
@ -1086,6 +1043,7 @@ void nsFrame::AdjustPointsInNewContent(nsIPresContext& aPresContext,
if (SELECTION_DEBUG) printf("--\n--\n--\n--\n--\n--\n--\n Should be here. #102\n");
//return;
}
#endif //0
}
/********************************************************
@ -1094,6 +1052,7 @@ void nsFrame::AdjustPointsInNewContent(nsIPresContext& aPresContext,
void nsFrame::AdjustPointsInSameContent(nsIPresContext& aPresContext,
nsIRenderingContext * aRendContext,
nsGUIEvent * aEvent) {
#if 0
PRUint32 actualOffset = 0;
// Get new Cursor Poition in the same content
@ -1141,6 +1100,7 @@ void nsFrame::AdjustPointsInSameContent(nsIPresContext& aPresContext,
if (SELECTION_DEBUG) printf("Start %s End %s\n", mStartSelectionPoint->ToString(), mEndSelectionPoint->ToString());
//}
#endif //0
}
NS_IMETHODIMP
@ -1747,6 +1707,8 @@ void nsFrame::NewContentIsBefore(nsIPresContext& aPresContext,
nsIContent * aCurrentContent,
nsIFrame * aNewFrame)
{
#if 0
//DEBUG MJUDGE
if (SELECTION_DEBUG) printf("New Frame, New content is before.\n");
// Dragging mouse to the left or backward in content
//
@ -1814,6 +1776,7 @@ void nsFrame::NewContentIsBefore(nsIPresContext& aPresContext,
NS_RELEASE(selEndContent);
NS_RELEASE(doc);
NS_RELEASE(shell);
#endif //0
}
/********************************************************
@ -1883,6 +1846,9 @@ void nsFrame::NewContentIsAfter(nsIPresContext& aPresContext,
nsIContent * aCurrentContent,
nsIFrame * aNewFrame)
{
#if 0
//DEBUG MJUDGE
if (SELECTION_DEBUG) printf("New Frame, New content is after.\n");
@ -2000,6 +1966,7 @@ void nsFrame::NewContentIsAfter(nsIPresContext& aPresContext,
NS_RELEASE(selEndContent);
NS_RELEASE(doc);
NS_RELEASE(shell);
#endif //0
}
/**

Просмотреть файл

@ -351,14 +351,6 @@ protected:
static PRInt32 mStartPos;
// Selection data is valid only from the Mouse Press to the Mouse Release
#if XP_NEW_SELECTION
#else
static nsSelectionRange * mSelectionRange;
static nsISelection * mSelection;
static nsSelectionPoint * mStartSelectionPoint;
static nsSelectionPoint * mEndSelectionPoint;
#endif //XP_NEW_SELECTION
///////////////////////////////////

Просмотреть файл

@ -38,6 +38,8 @@
#include "nsIEventStateManager.h"
#include "nsDOMEvent.h"
#include "nsHTMLParts.h"
#include "nsISelection.h"
#include "nsLayoutCID.h"
static PRBool gsNoisyRefs = PR_FALSE;
#undef NOISY
@ -142,6 +144,8 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIPresShellIID, NS_IPRESSHELL_IID);
static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID);
static NS_DEFINE_IID(kIViewObserverIID, NS_IVIEWOBSERVER_IID);
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID);
class PresShell : public nsIPresShell, public nsIViewObserver,
private nsIDocumentObserver
@ -215,6 +219,8 @@ public:
virtual nsIPresContext* GetPresContext();
virtual nsIViewManager* GetViewManager();
virtual nsIStyleSet* GetStyleSet();
virtual nsresult SetFocus(nsIFrame *aFrame);
virtual nsresult GetSelection(nsISelection **aSelection);
NS_IMETHOD EnterReflowLock();
NS_IMETHOD ExitReflowLock();
virtual void BeginObservingDocument();
@ -261,6 +267,8 @@ protected:
PRUint32 mReflowLockCount;
PRBool mIsDestroying;
nsIFrame* mCurrentEventFrame;
nsIFrame* mFocusEventFrame; //keeps track of which frame has focus.
nsISelection *mSelection;
};
#ifdef NS_DEBUG
@ -322,6 +330,7 @@ PresShell::PresShell()
{
//XXX joki 11/17 - temporary event hack.
mIsDestroying = PR_FALSE;
nsRepository::CreateInstance(kRangeListCID, nsnull, kISelectionIID, (void **) &mSelection);
}
#ifdef NS_DEBUG
@ -394,6 +403,7 @@ PresShell::~PresShell()
mDocument->DeleteShell(this);
NS_RELEASE(mDocument);
}
NS_IF_RELEASE(mSelection);
mRefCnt = 0;
}
@ -483,6 +493,27 @@ PresShell::GetStyleSet()
return mStyleSet;
}
nsresult
PresShell::SetFocus(nsIFrame *aFrame)
{
if (!aFrame)
return NS_ERROR_NULL_POINTER;
mFocusEventFrame = aFrame;
return NS_OK;
}
nsresult
PresShell::GetSelection(nsISelection **aSelection)
{
if (!aSelection || !mSelection)
return NS_ERROR_NULL_POINTER;
return mSelection->QueryInterface(kISelectionIID,(void **)aSelection);
}
// Make shell be a document observer
void
PresShell::BeginObservingDocument()
@ -816,6 +847,9 @@ PresShell::ClearFrameRefs(nsIFrame* aFrame)
if (aFrame == mCurrentEventFrame) {
mCurrentEventFrame = nsnull;
}
if (aFrame == mFocusEventFrame) {
mFocusEventFrame = nsnull;
}
}
NS_IMETHODIMP PresShell :: CreateRenderingContext(nsIFrame *aFrame,
@ -1142,6 +1176,10 @@ NS_IMETHODIMP PresShell :: HandleEvent(nsIView *aView,
frame = (nsIFrame *)clientData;
if (nsnull != frame) {
if (mSelection && mFocusEventFrame && aEvent->eventStructType == NS_KEY_EVENT)
{
mSelection->HandleKeyEvent(aEvent, mFocusEventFrame);
}
frame->GetFrameForPoint(aEvent->point, &mCurrentEventFrame);
if (nsnull != mCurrentEventFrame) {
//Once we have the targetFrame, handle the event in this order

Просмотреть файл

@ -39,11 +39,6 @@
#include "nsIDocument.h"
#include "nsIDeviceContext.h"
#include "nsXIFConverter.h"
#if XP_NEW_SELECTION
#else
#include "nsISelection.h"
#endif
#include "nsSelectionRange.h"
#include "nsHTMLAtoms.h"
#include "nsITextContent.h"
@ -580,16 +575,15 @@ TextFrame::ComputeSelectionInfo(nsIRenderingContext& aRenderingContext,
PRInt32* aIndicies, PRInt32 aTextLength,
SelectionInfo& aResult)
{
#if 0
//DEBUG MJUDGE HERE IS WHERE THE WORK IS
// Assume, for now, that the selection misses this section of
// content completely.
aResult.mStartOffset = aTextLength;
aResult.mEndOffset = aTextLength;
aResult.mEmptySelection = PR_FALSE;
#if XP_NEW_SELECTION
#else
nsISelection * selection;
#endif
aDocument->GetSelection(selection);
nsSelectionRange * range = selection->GetRange();
@ -674,6 +668,7 @@ TextFrame::ComputeSelectionInfo(nsIRenderingContext& aRenderingContext,
NS_IF_RELEASE(startContent);
NS_IF_RELEASE(endContent);
NS_RELEASE(selection);
#endif //0
}
#define XP_IS_SPACE_W XP_IS_SPACE

Просмотреть файл

@ -22,10 +22,6 @@
#include "nsIDocument.h"
#include "nsXIFConverter.h"
#include "nsSelectionRange.h"
#if XP_NEW_SELECTION
#else
#include "nsISelection.h"
#endif
#include "nsCRT.h"
#include "nsIEventStateManager.h"
#include "nsIPrivateDOMEvent.h"
@ -423,12 +419,11 @@ nsGenericDOMDataNode::ConvertContentToXIF(nsXIFConverter& aConverter) const
{
const nsIContent* content = mContent;
#if 0
//DEBUG MJUDGE
if (aConverter.GetUseSelection() == PR_TRUE && mDocument->IsInSelection(content))
{
#if XP_NEW_SELECTION
#else
nsISelection* sel;
#endif
mDocument->GetSelection(sel);
if (sel != nsnull)
{
@ -465,6 +460,7 @@ nsGenericDOMDataNode::ConvertContentToXIF(nsXIFConverter& aConverter) const
NS_RELEASE(sel);
}
else
#endif //0
{
nsString buffer;
mText.AppendTo(buffer);

Просмотреть файл

@ -57,12 +57,6 @@
#endif
// Find/Serach Includes
#if XP_NEW_SELECTION
#else
#include "nsISelection.h"
#include "nsSelectionRange.h"
#include "nsSelectionPoint.h"
#endif
const PRInt32 kForward = 0;
const PRInt32 kBackward = 1;
@ -1446,6 +1440,8 @@ PRBool nsHTMLDocument::SearchBlock(BlockText & aBlockText,
}
}
#if 0
//DEBUG MJUDGE
if (str) {
PRInt32 inx = str - contentStr;
@ -1474,7 +1470,7 @@ PRBool nsHTMLDocument::SearchBlock(BlockText & aBlockText,
found = PR_TRUE;
}
#endif //0
delete[] searchStr;
delete[] contentStr;
@ -1838,7 +1834,8 @@ nsIDOMNode * FindDOMNode(nsIDOMNode * aNode, nsIContent * aContent)
*/
NS_IMETHODIMP nsHTMLDocument::FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound)
{
#if 0
//DEBUG MJUDGE
aIsFound = PR_FALSE;
mShouldMatchCase = aMatchCase;
@ -2121,6 +2118,7 @@ NS_IMETHODIMP nsHTMLDocument::FindNext(const nsString &aSearchStr, PRBool aMatch
NS_RELEASE(startContent);
NS_RELEASE(endContent);
}
#endif //0
return NS_OK;
}