1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#include "nsFrame.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsGUIEvent.h"
|
1998-07-23 06:55:33 +04:00
|
|
|
#include "nsDOMEvent.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsStyleConsts.h"
|
1998-05-08 20:33:07 +04:00
|
|
|
#include "nsIPresShell.h"
|
1998-05-20 20:24:13 +04:00
|
|
|
#include "prlog.h"
|
|
|
|
#include "prprf.h"
|
|
|
|
#include <stdarg.h>
|
1998-06-02 09:28:11 +04:00
|
|
|
#include "nsIPtr.h"
|
1998-06-06 01:06:24 +04:00
|
|
|
#include "nsISizeOfHandler.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-27 20:44:52 +04:00
|
|
|
#include "nsIDOMText.h"
|
1998-05-08 22:33:42 +04:00
|
|
|
#include "nsSelectionRange.h"
|
|
|
|
#include "nsDocument.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
1998-10-01 08:46:11 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-07-18 22:18:20 +04:00
|
|
|
// Some Misc #defines
|
1998-07-23 02:01:46 +04:00
|
|
|
#define SELECTION_DEBUG 0
|
1998-07-18 22:18:20 +04:00
|
|
|
#define FORCE_SELECTION_UPDATE 1
|
|
|
|
#define TRACKER_DEBUG 0
|
|
|
|
#define CALC_DEBUG 0
|
|
|
|
|
|
|
|
// Tracker Data
|
|
|
|
#define kInsertInRemoveList 0
|
|
|
|
#define kInsertInAddList 1
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
// Kludged Content stuff
|
|
|
|
nsIFrame * fFrameArray[1024];
|
|
|
|
nsIContent * fContentArray[1024];
|
|
|
|
PRInt32 fMax = -1;
|
|
|
|
|
|
|
|
nsIContent * fTrackerContentArrayRemoveList[1024];
|
|
|
|
PRInt32 fTrackerRemoveListMax = 0;
|
|
|
|
nsIContent * fTrackerContentArrayAddList[1024];
|
|
|
|
PRInt32 fTrackerAddListMax = 0;
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-07-18 03:00:54 +04:00
|
|
|
nsIDocument *gDoc = nsnull;
|
|
|
|
|
1998-04-27 20:44:52 +04:00
|
|
|
// [HACK] Foward Declarations
|
1998-05-08 22:33:42 +04:00
|
|
|
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);
|
|
|
|
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
// 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
|
|
|
|
nsSelectionRange * nsFrame::mSelectionRange = nsnull;
|
|
|
|
nsISelection * nsFrame::mSelection = nsnull;
|
|
|
|
|
|
|
|
nsSelectionPoint * nsFrame::mStartSelectionPoint = nsnull;
|
|
|
|
nsSelectionPoint * nsFrame::mEndSelectionPoint = nsnull;
|
|
|
|
|
1998-05-20 20:24:13 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static PRBool gShowFrameBorders = PR_FALSE;
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_LAYOUT void nsIFrame::ShowFrameBorders(PRBool aEnable)
|
|
|
|
{
|
|
|
|
gShowFrameBorders = aEnable;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_LAYOUT PRBool nsIFrame::GetShowFrameBorders()
|
|
|
|
{
|
|
|
|
return gShowFrameBorders;
|
|
|
|
}
|
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
////////////////////////////////////////////////
|
|
|
|
// Debug Listing Helper Class
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
class TableListFilter : public nsIListFilter
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
static char* kTagTable[];
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
TableListFilter()
|
|
|
|
{};
|
|
|
|
|
|
|
|
virtual ~TableListFilter()
|
|
|
|
{};
|
|
|
|
|
|
|
|
virtual PRBool OutputTag(nsAutoString *aTag) const
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
if (nsnull!=aTag && 0!=aTag->Length())
|
|
|
|
{
|
|
|
|
for (PRInt32 i=0; ; i++)
|
|
|
|
{
|
|
|
|
const char *tableTag = kTagTable[i];
|
|
|
|
if (nsnull==tableTag)
|
|
|
|
break;
|
|
|
|
if (aTag->EqualsIgnoreCase(tableTag))
|
|
|
|
{
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
char* TableListFilter::kTagTable[] = {
|
|
|
|
"table",
|
|
|
|
"tbody", "thead", "tfoot",
|
|
|
|
"tr", "td", "th",
|
|
|
|
"colgroup", "col",
|
|
|
|
//"caption", captions are left out because there's no caption frame
|
|
|
|
// to hang a decent output method on.
|
|
|
|
""
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_LAYOUT nsIListFilter * nsIFrame::GetFilter(nsString *aFilterName)
|
|
|
|
{
|
|
|
|
nsIListFilter *result = nsnull;
|
|
|
|
if (nsnull!=aFilterName)
|
|
|
|
{
|
|
|
|
if (aFilterName->EqualsIgnoreCase("table"))
|
|
|
|
{
|
|
|
|
static nsIListFilter * tableListFilter;
|
|
|
|
if (nsnull==tableListFilter)
|
|
|
|
tableListFilter = new TableListFilter();
|
|
|
|
result = tableListFilter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-05-20 20:24:13 +04:00
|
|
|
/**
|
|
|
|
* Note: the log module is created during library initialization which
|
|
|
|
* means that you cannot perform logging before then.
|
|
|
|
*/
|
|
|
|
PRLogModuleInfo* nsIFrame::gLogModule = PR_NewLogModule("frame");
|
|
|
|
|
|
|
|
static PRLogModuleInfo* gFrameVerifyTreeLogModuleInfo;
|
|
|
|
|
|
|
|
static PRBool gFrameVerifyTreeEnable = PRBool(0x55);
|
|
|
|
|
|
|
|
NS_LAYOUT PRBool
|
|
|
|
nsIFrame::GetVerifyTreeEnable()
|
|
|
|
{
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
if (gFrameVerifyTreeEnable == PRBool(0x55)) {
|
|
|
|
if (nsnull == gFrameVerifyTreeLogModuleInfo) {
|
|
|
|
gFrameVerifyTreeLogModuleInfo = PR_NewLogModule("frameverifytree");
|
|
|
|
gFrameVerifyTreeEnable = 0 != gFrameVerifyTreeLogModuleInfo->level;
|
|
|
|
printf("Note: frameverifytree is %sabled\n",
|
|
|
|
gFrameVerifyTreeEnable ? "en" : "dis");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return gFrameVerifyTreeEnable;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_LAYOUT void
|
|
|
|
nsIFrame::SetVerifyTreeEnable(PRBool aEnabled)
|
|
|
|
{
|
|
|
|
gFrameVerifyTreeEnable = aEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_LAYOUT PRLogModuleInfo*
|
|
|
|
nsIFrame::GetLogModuleInfo()
|
|
|
|
{
|
|
|
|
return gLogModule;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
|
|
|
|
|
|
|
nsresult
|
1998-05-06 03:56:50 +04:00
|
|
|
nsFrame::NewFrame(nsIFrame** aInstancePtrResult,
|
1998-04-14 00:24:54 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
|
|
|
if (nsnull == aInstancePtrResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1998-05-06 03:56:50 +04:00
|
|
|
nsIFrame* it = new nsFrame(aContent, aParent);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*aInstancePtrResult = it;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* nsFrame::operator new(size_t size)
|
|
|
|
{
|
|
|
|
void* result = new char[size];
|
|
|
|
|
|
|
|
nsCRT::zero(result, size);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-05-06 03:56:50 +04:00
|
|
|
nsFrame::nsFrame(nsIContent* aContent, nsIFrame* aParent)
|
|
|
|
: mContent(aContent), mContentParent(aParent), mGeometricParent(aParent)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ADDREF(mContent);
|
1998-05-29 06:10:12 +04:00
|
|
|
mState = NS_FRAME_FIRST_REFLOW;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsFrame::~nsFrame()
|
|
|
|
{
|
1998-08-04 22:19:51 +04:00
|
|
|
NS_IF_RELEASE(mContent);
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_IF_RELEASE(mStyleContext);
|
|
|
|
if (nsnull != mView) {
|
|
|
|
// Break association between view and frame
|
1998-08-08 08:23:33 +04:00
|
|
|
mView->Destroy();
|
|
|
|
mView = nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-08-04 02:22:27 +04:00
|
|
|
|
|
|
|
if (mStartSelectionPoint != nsnull) {
|
|
|
|
delete mStartSelectionPoint;
|
|
|
|
mStartSelectionPoint = nsnull;
|
|
|
|
}
|
|
|
|
if (mEndSelectionPoint != nsnull) {
|
|
|
|
delete mEndSelectionPoint;
|
|
|
|
mEndSelectionPoint = nsnull;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports
|
|
|
|
|
|
|
|
nsresult nsFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
static NS_DEFINE_IID(kClassIID, kIFrameIID);
|
1998-10-01 08:46:11 +04:00
|
|
|
if (aIID.Equals(kIHTMLReflowIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIHTMLReflow*)this;
|
|
|
|
return NS_OK;
|
|
|
|
} else if (aIID.Equals(kClassIID) || aIID.Equals(kISupportsIID)) {
|
1998-04-14 00:24:54 +04:00
|
|
|
*aInstancePtr = (void*)this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsFrame::AddRef(void)
|
|
|
|
{
|
1998-09-24 05:50:16 +04:00
|
|
|
NS_WARNING("not supported for frames");
|
|
|
|
return 1;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsFrame::Release(void)
|
|
|
|
{
|
1998-09-24 05:50:16 +04:00
|
|
|
NS_WARNING("not supported for frames");
|
|
|
|
return 1;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIFrame
|
|
|
|
|
1998-09-10 23:32:14 +04:00
|
|
|
NS_IMETHODIMP nsFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
if (nsnull != aChildList) {
|
|
|
|
NS_ERROR("not a container");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-28 06:52:54 +04:00
|
|
|
NS_METHOD nsFrame::DeleteFrame(nsIPresContext& aPresContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-08-28 06:52:54 +04:00
|
|
|
//XXX Why is this done in nsFrame instead of some frame class
|
1998-08-08 08:23:33 +04:00
|
|
|
// that actually loads images?
|
1998-08-28 06:52:54 +04:00
|
|
|
aPresContext.StopLoadImage(this);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-08-10 06:28:23 +04:00
|
|
|
//Set to prevent event dispatch during destruct
|
|
|
|
if (nsnull != mView) {
|
1998-08-28 06:52:54 +04:00
|
|
|
mView->SetClientData(nsnull);
|
1998-08-10 06:28:23 +04:00
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
delete this;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-06-06 01:06:24 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::SizeOf(nsISizeOfHandler* aHandler) const
|
|
|
|
{
|
|
|
|
aHandler->Add(sizeof(*this));
|
|
|
|
SizeOfWithoutThis(aHandler);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFrame::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const
|
|
|
|
{
|
|
|
|
// Note: style context's are accounted for via the style system's
|
|
|
|
// sizeof support
|
|
|
|
|
|
|
|
// Note: content is accounted for via the content system's sizeof
|
|
|
|
// support
|
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetContent(nsIContent*& aContent) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
if (nsnull != mContent) {
|
|
|
|
NS_ADDREF(mContent);
|
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
aContent = mContent;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-05-06 03:56:50 +04:00
|
|
|
NS_METHOD nsFrame::GetContentIndex(PRInt32& aIndexInParent) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-08-30 00:20:38 +04:00
|
|
|
nsIContent* parent;
|
|
|
|
mContent->GetParent(parent);
|
1998-05-07 04:08:20 +04:00
|
|
|
if (nsnull != parent) {
|
1998-08-30 00:20:38 +04:00
|
|
|
parent->IndexOf(mContent, aIndexInParent);
|
1998-05-07 04:08:20 +04:00
|
|
|
NS_RELEASE(parent);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aIndexInParent = 0;
|
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetStyleContext(nsIPresContext* aPresContext,
|
|
|
|
nsIStyleContext*& aStyleContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-22 10:32:55 +04:00
|
|
|
if ((nsnull == mStyleContext) && (nsnull != aPresContext)) {
|
1998-04-14 00:24:54 +04:00
|
|
|
mStyleContext = aPresContext->ResolveStyleContextFor(mContent, mGeometricParent); // XXX should be content parent???
|
1998-04-29 03:25:07 +04:00
|
|
|
if (nsnull != mStyleContext) {
|
1998-05-02 00:43:02 +04:00
|
|
|
DidSetStyleContext(aPresContext);
|
1998-04-29 03:25:07 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
NS_IF_ADDREF(mStyleContext);
|
1998-04-17 05:41:24 +04:00
|
|
|
aStyleContext = mStyleContext;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-05-02 00:43:02 +04:00
|
|
|
NS_METHOD nsFrame::SetStyleContext(nsIPresContext* aPresContext,nsIStyleContext* aContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aContext, "null ptr");
|
|
|
|
if (aContext != mStyleContext) {
|
|
|
|
NS_IF_RELEASE(mStyleContext);
|
|
|
|
if (nsnull != aContext) {
|
|
|
|
mStyleContext = aContext;
|
|
|
|
NS_ADDREF(aContext);
|
1998-05-02 00:43:02 +04:00
|
|
|
DidSetStyleContext(aPresContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-29 03:25:07 +04:00
|
|
|
// Subclass hook for style post processing
|
1998-05-02 00:43:02 +04:00
|
|
|
NS_METHOD nsFrame::DidSetStyleContext(nsIPresContext* aPresContext)
|
1998-04-29 03:25:07 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-06-05 10:09:09 +04:00
|
|
|
NS_METHOD nsFrame::GetStyleData(nsStyleStructID aSID, const nsStyleStruct*& aStyleStruct) const
|
1998-04-17 05:41:24 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
|
|
|
|
if (mStyleContext) {
|
1998-06-05 10:09:09 +04:00
|
|
|
aStyleStruct = mStyleContext->GetStyleData(aSID);
|
1998-04-17 05:41:24 +04:00
|
|
|
} else {
|
|
|
|
aStyleStruct = nsnull;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Geometric and content parent member functions
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetContentParent(nsIFrame*& aParent) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
aParent = mContentParent;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::SetContentParent(const nsIFrame* aParent)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
mContentParent = (nsIFrame*)aParent;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetGeometricParent(nsIFrame*& aParent) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
aParent = mGeometricParent;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::SetGeometricParent(const nsIFrame* aParent)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
mGeometricParent = (nsIFrame*)aParent;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bounding rect member functions
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetRect(nsRect& aRect) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
aRect = mRect;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetOrigin(nsPoint& aPoint) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
aPoint.x = mRect.x;
|
|
|
|
aPoint.y = mRect.y;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetSize(nsSize& aSize) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
aSize.width = mRect.width;
|
|
|
|
aSize.height = mRect.height;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::SetRect(const nsRect& aRect)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
MoveTo(aRect.x, aRect.y);
|
|
|
|
SizeTo(aRect.width, aRect.height);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::MoveTo(nscoord aX, nscoord aY)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-06-26 04:31:44 +04:00
|
|
|
mRect.x = aX;
|
|
|
|
mRect.y = aY;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-27 06:13:28 +04:00
|
|
|
// Let the view know
|
1998-05-29 01:55:13 +04:00
|
|
|
if ((nsnull != mView) && (0 == (mState & NS_FRAME_IN_REFLOW))) {
|
|
|
|
// Position view relative to its parent, not relative to our
|
1998-05-27 06:13:28 +04:00
|
|
|
// parent frame (our parent frame may not have a view).
|
|
|
|
nsIView* parentWithView;
|
|
|
|
nsPoint origin;
|
|
|
|
GetOffsetFromView(origin, parentWithView);
|
1998-08-30 23:16:11 +04:00
|
|
|
nsIViewManager *vm;
|
|
|
|
mView->GetViewManager(vm);
|
1998-06-03 02:04:54 +04:00
|
|
|
vm->MoveViewTo(mView, origin.x, origin.y);
|
|
|
|
NS_RELEASE(vm);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::SizeTo(nscoord aWidth, nscoord aHeight)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-07 20:13:09 +04:00
|
|
|
mRect.width = aWidth;
|
|
|
|
mRect.height = aHeight;
|
1998-04-17 05:41:24 +04:00
|
|
|
|
1998-05-07 20:13:09 +04:00
|
|
|
// Let the view know
|
1998-05-29 01:55:13 +04:00
|
|
|
if ((nsnull != mView) && (0 == (mState & NS_FRAME_IN_REFLOW))) {
|
1998-08-30 23:16:11 +04:00
|
|
|
nsIViewManager *vm;
|
|
|
|
mView->GetViewManager(vm);
|
1998-06-03 02:04:54 +04:00
|
|
|
vm->ResizeView(mView, aWidth, aHeight);
|
|
|
|
NS_RELEASE(vm);
|
1998-05-07 20:13:09 +04:00
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Child frame enumeration
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::FirstChild(nsIFrame*& aFirstChild) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
aFirstChild = nsnull;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-08-04 03:39:16 +04:00
|
|
|
PRBool nsFrame::DisplaySelection(nsIPresContext& aPresContext, PRBool isOkToTurnOn)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
|
|
|
nsIPresShell *shell = aPresContext.GetShell();
|
|
|
|
if (nsnull != shell) {
|
|
|
|
nsIDocument *doc = shell->GetDocument();
|
|
|
|
if (nsnull != doc) {
|
|
|
|
result = doc->GetDisplaySelection();
|
|
|
|
if (isOkToTurnOn && !result) {
|
|
|
|
doc->SetDisplaySelection(PR_TRUE);
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
1998-07-27 22:05:35 +04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-07-27 22:05:35 +04:00
|
|
|
if (DisplaySelection(aPresContext) == PR_FALSE)
|
|
|
|
return NS_OK;
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
PRBool clearAfterPaint = PR_FALSE;
|
|
|
|
|
|
|
|
// Get Content
|
|
|
|
nsIContent * content;
|
|
|
|
GetContent(content);
|
1998-08-30 00:20:38 +04:00
|
|
|
PRInt32 n;
|
|
|
|
content->ChildCount(n);
|
|
|
|
if (n > 0) {
|
1998-05-19 01:03:55 +04:00
|
|
|
NS_RELEASE(content);
|
1998-05-08 22:33:42 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-18 03:00:54 +04:00
|
|
|
nsIPresShell * shell = aPresContext.GetShell();
|
|
|
|
nsIDocument * doc = shell->GetDocument();
|
1998-05-08 22:33:42 +04:00
|
|
|
if (mSelectionRange == nsnull) { // Get Selection Object
|
1998-09-09 20:11:59 +04:00
|
|
|
nsISelection * selection;
|
|
|
|
doc->GetSelection(selection);
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
mSelectionRange = selection->GetRange();
|
|
|
|
|
|
|
|
clearAfterPaint = PR_TRUE;
|
|
|
|
NS_RELEASE(selection);
|
|
|
|
}
|
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
nsIContent * selStartContent = mSelectionRange->GetStartContent(); // ref counted
|
|
|
|
nsIContent * selEndContent = mSelectionRange->GetEndContent(); // ref counted
|
1998-07-18 03:00:54 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
if (doc->IsInRange(selStartContent, selEndContent, content)) {
|
1998-05-08 22:33:42 +04:00
|
|
|
nsRect rect;
|
|
|
|
GetRect(rect);
|
|
|
|
rect.width--;
|
|
|
|
rect.height--;
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,0,255));
|
|
|
|
aRenderingContext.DrawRect(rect);
|
|
|
|
aRenderingContext.DrawLine(rect.x, rect.y, rect.x+rect.width, rect.y+rect.height);
|
|
|
|
aRenderingContext.DrawLine(rect.x, rect.y+rect.height, rect.x+rect.width, rect.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clearAfterPaint) {
|
|
|
|
mSelectionRange = nsnull;
|
|
|
|
}
|
1998-08-04 02:22:27 +04:00
|
|
|
NS_IF_RELEASE(selStartContent);
|
|
|
|
NS_IF_RELEASE(selEndContent);
|
1998-05-08 22:33:42 +04:00
|
|
|
NS_RELEASE(content);
|
1998-07-18 03:00:54 +04:00
|
|
|
NS_RELEASE(doc);
|
|
|
|
NS_RELEASE(shell);
|
1998-07-27 22:05:35 +04:00
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-27 20:44:52 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::HandleEvent(nsIPresContext& aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus& aEventStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-06-08 04:57:15 +04:00
|
|
|
aEventStatus = nsEventStatus_eIgnore;
|
|
|
|
|
1998-08-06 11:55:05 +04:00
|
|
|
if (nsnull != mContent) {
|
1998-07-23 06:55:33 +04:00
|
|
|
mContent->HandleDOMEvent(aPresContext, (nsEvent*)aEvent, nsnull, DOM_EVENT_INIT, aEventStatus);
|
1998-06-24 01:53:02 +04:00
|
|
|
}
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-08-04 03:39:16 +04:00
|
|
|
if (DisplaySelection(aPresContext) == PR_FALSE) {
|
|
|
|
if (aEvent->message != NS_MOUSE_LEFT_BUTTON_DOWN) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-08-06 11:55:05 +04:00
|
|
|
if(nsEventStatus_eConsumeNoDefault != aEventStatus) {
|
1998-08-06 02:38:24 +04:00
|
|
|
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
|
|
|
|
} else if (aEvent->message == NS_MOUSE_MOVE && mDoingSelection ||
|
|
|
|
aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
|
|
|
// no-op
|
1998-06-08 04:57:15 +04:00
|
|
|
} else {
|
|
|
|
return NS_OK;
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Message: %d-------------------------------------------------------------\n",aEvent->message);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
|
1998-06-08 04:57:15 +04:00
|
|
|
if (aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) {
|
|
|
|
if (mDoingSelection) {
|
1998-08-28 19:58:37 +04:00
|
|
|
HandleRelease(aPresContext, aEvent, aEventStatus);
|
1998-06-08 04:57:15 +04:00
|
|
|
}
|
|
|
|
} else if (aEvent->message == NS_MOUSE_MOVE) {
|
|
|
|
mDidDrag = PR_TRUE;
|
1998-08-28 19:58:37 +04:00
|
|
|
HandleDrag(aPresContext, aEvent, aEventStatus);
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("HandleEvent(Drag)::mSelectionRange %s\n", mSelectionRange->ToString());
|
1998-06-08 04:57:15 +04:00
|
|
|
|
|
|
|
} else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
|
1998-08-28 19:58:37 +04:00
|
|
|
HandlePress(aPresContext, aEvent, aEventStatus);
|
1998-06-08 04:57:15 +04:00
|
|
|
}
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
/**
|
|
|
|
* Handles the Mouse Press Event for the frame
|
|
|
|
*/
|
1998-04-27 20:44:52 +04:00
|
|
|
NS_METHOD nsFrame::HandlePress(nsIPresContext& aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
1998-08-28 19:58:37 +04:00
|
|
|
nsEventStatus& aEventStatus)
|
1998-04-27 20:44:52 +04:00
|
|
|
{
|
1998-08-04 03:39:16 +04:00
|
|
|
if (DisplaySelection(aPresContext, PR_TRUE) == PR_FALSE)
|
1998-07-27 22:05:35 +04:00
|
|
|
{
|
|
|
|
aEventStatus = nsEventStatus_eIgnore;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-02 05:12:39 +04:00
|
|
|
nsFrame * currentFrame = this;
|
|
|
|
nsIPresShell * shell = aPresContext.GetShell();
|
|
|
|
nsMouseEvent * mouseEvent = (nsMouseEvent *)aEvent;
|
|
|
|
nsIRenderingContext * acx;
|
1998-07-18 03:00:54 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
gDoc = shell->GetDocument();
|
|
|
|
|
1998-09-09 20:11:59 +04:00
|
|
|
nsISelection * selection;
|
|
|
|
gDoc->GetSelection(selection);
|
|
|
|
|
1998-10-02 05:12:39 +04:00
|
|
|
shell->CreateRenderingContext(this, acx);
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
mSelectionRange = selection->GetRange();
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-07-23 01:56:48 +04:00
|
|
|
PRUint32 actualOffset = 0;
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
mDoingSelection = PR_TRUE;
|
|
|
|
mDidDrag = PR_FALSE;
|
|
|
|
mCurrentFrame = currentFrame;
|
|
|
|
|
1998-10-02 05:12:39 +04:00
|
|
|
GetPosition(aPresContext, acx, aEvent, currentFrame, actualOffset, mStartPos);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Click count is 1
|
1998-05-08 22:33:42 +04:00
|
|
|
nsIContent * newContent;
|
|
|
|
currentFrame->GetContent(newContent);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
mCurrentFrame = currentFrame;
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
if (mStartSelectionPoint == nsnull) {
|
|
|
|
mStartSelectionPoint = new nsSelectionPoint(nsnull, -1, PR_TRUE);
|
|
|
|
}
|
|
|
|
if (mEndSelectionPoint == nsnull) {
|
|
|
|
mEndSelectionPoint = new nsSelectionPoint(nsnull, -1, PR_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
mSelectionRange->GetStartPoint(mStartSelectionPoint);
|
|
|
|
mSelectionRange->GetEndPoint(mEndSelectionPoint);
|
|
|
|
|
|
|
|
resetContentTrackers();
|
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
// Get the Current Start and End Content Pointers
|
|
|
|
nsIContent * selStartContent = mSelectionRange->GetStartContent(); // ref counted
|
|
|
|
nsIContent * selEndContent = mSelectionRange->GetEndContent(); // ref counted
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("****** Shift[%s]\n", (mouseEvent->isShift?"Down":"Up"));
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
PRBool inRange = gDoc->IsInRange(selStartContent, selEndContent, newContent);
|
1998-07-18 03:00:54 +04:00
|
|
|
|
|
|
|
if (inRange) {
|
1998-05-08 22:33:42 +04:00
|
|
|
//resetContentTrackers();
|
1998-07-18 22:18:20 +04:00
|
|
|
if (TRACKER_DEBUG) printf("Adding split range to removed selection. Shift[%s]\n", (mouseEvent->isShift?"Down":"Up"));
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
if (mouseEvent->isShift) {
|
1998-08-04 02:22:27 +04:00
|
|
|
if (newContent == selStartContent && newContent == selEndContent) {
|
|
|
|
addRangeToSelectionTrackers(newContent, newContent, kInsertInAddList);
|
|
|
|
} else {
|
1998-08-06 02:38:24 +04:00
|
|
|
if (selStartContent == newContent) {
|
|
|
|
// Trackers just do painting so add all the content nodes in the remove list
|
|
|
|
// even though you might think you shouldn't put the start content node there
|
|
|
|
addRangeToSelectionTrackers(selStartContent, selEndContent, kInsertInRemoveList);
|
|
|
|
} else if (selEndContent == newContent) {
|
|
|
|
// just repaint the end content node
|
|
|
|
addRangeToSelectionTrackers(selEndContent, selEndContent, kInsertInAddList);
|
|
|
|
} else {
|
|
|
|
if (gDoc->IsBefore(newContent, selEndContent)) {
|
|
|
|
addRangeToSelectionTrackers(newContent, selEndContent, kInsertInRemoveList);
|
|
|
|
} else {
|
|
|
|
addRangeToSelectionTrackers(selEndContent, newContent, kInsertInRemoveList);
|
|
|
|
}
|
|
|
|
}
|
1998-08-04 02:22:27 +04:00
|
|
|
}
|
1998-05-08 22:33:42 +04:00
|
|
|
mEndSelectionPoint->SetPoint(newContent, mStartPos, PR_FALSE);
|
|
|
|
} else {
|
1998-08-04 02:22:27 +04:00
|
|
|
addRangeToSelectionTrackers(selStartContent, selEndContent, kInsertInRemoveList); // removed from selection
|
1998-07-23 01:56:48 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
mStartSelectionPoint->SetPoint(newContent, mStartPos, PR_TRUE);
|
1998-08-04 02:22:27 +04:00
|
|
|
mEndSelectionPoint->SetPoint(newContent, mStartPos, PR_TRUE);
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
addRangeToSelectionTrackers(newContent, newContent, kInsertInAddList); // add to selection
|
|
|
|
}
|
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
} else if (gDoc->IsBefore(newContent, selStartContent)) {
|
1998-05-08 22:33:42 +04:00
|
|
|
if (mouseEvent->isShift) {
|
|
|
|
if (mStartSelectionPoint->IsAnchor()) {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("New Content is before, Start will now be end\n");
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
addRangeToSelectionTrackers(selStartContent, selEndContent, kInsertInRemoveList); // removed from selection
|
1998-07-23 01:56:48 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
mEndSelectionPoint->SetPoint(selStartContent, mStartSelectionPoint->GetOffset(), PR_TRUE);
|
1998-05-08 22:33:42 +04:00
|
|
|
mStartSelectionPoint->SetPoint(newContent, mStartPos, PR_FALSE);
|
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
// End Point has changed
|
|
|
|
nsIContent * endcontent = mEndSelectionPoint->GetContent(); // ref counted
|
|
|
|
addRangeToSelectionTrackers(newContent, endcontent, kInsertInAddList); // add to selection
|
|
|
|
NS_RELEASE(endcontent);
|
1998-05-08 22:33:42 +04:00
|
|
|
} else {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("New Content is before, Appending to Beginning\n");
|
1998-08-04 02:22:27 +04:00
|
|
|
addRangeToSelectionTrackers(newContent, selEndContent, kInsertInAddList); // add to selection
|
1998-05-08 22:33:42 +04:00
|
|
|
mStartSelectionPoint->SetPoint(newContent, mStartPos, PR_FALSE);
|
|
|
|
}
|
1998-04-27 20:44:52 +04:00
|
|
|
} else {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Adding full range to removed selection. (insert selection)\n");
|
1998-08-04 02:22:27 +04:00
|
|
|
addRangeToSelectionTrackers(selStartContent, selEndContent, kInsertInRemoveList); // removed from selection
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
mEndSelectionPoint->SetPoint(newContent, mStartPos, PR_TRUE);
|
1998-07-23 01:56:48 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
mStartSelectionPoint->SetPoint(newContent, mStartPos, PR_TRUE);
|
|
|
|
|
|
|
|
addRangeToSelectionTrackers(newContent, newContent, kInsertInAddList); // add to selection
|
|
|
|
}
|
|
|
|
} else { // Content is After End
|
|
|
|
|
|
|
|
if (mouseEvent->isShift) {
|
1998-08-08 00:15:36 +04:00
|
|
|
if (selStartContent == nsnull && selEndContent == nsnull) {
|
|
|
|
// Shift Click without first clicking in the window
|
|
|
|
// is interpreted the same as just clicking in a window
|
|
|
|
mEndSelectionPoint->SetPoint(newContent, mStartPos, PR_TRUE);
|
|
|
|
mStartSelectionPoint->SetPoint(newContent, mStartPos, PR_TRUE);
|
|
|
|
addRangeToSelectionTrackers(newContent, newContent, kInsertInAddList); // add to selection
|
|
|
|
|
|
|
|
} else if (mStartSelectionPoint->IsAnchor()) {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("New Content is after, Append new content\n");
|
1998-08-04 02:22:27 +04:00
|
|
|
addRangeToSelectionTrackers(selEndContent, newContent, kInsertInAddList); // add to selection
|
1998-05-08 22:33:42 +04:00
|
|
|
mEndSelectionPoint->SetPoint(newContent, mStartPos, PR_FALSE);
|
1998-08-08 00:15:36 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
} else {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("New Content is after, End will now be Start\n");
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
addRangeToSelectionTrackers(selStartContent, selEndContent, kInsertInRemoveList); // removed from selection
|
|
|
|
mStartSelectionPoint->SetPoint(selEndContent, mEndSelectionPoint->GetOffset(), PR_TRUE);
|
1998-05-08 22:33:42 +04:00
|
|
|
mEndSelectionPoint->SetPoint(newContent, mStartPos, PR_FALSE);
|
1998-08-04 02:22:27 +04:00
|
|
|
addRangeToSelectionTrackers(newContent, newContent, kInsertInAddList); // add to selection
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (TRACKER_DEBUG) printf("Adding full range to removed selection.\n");
|
1998-08-04 02:22:27 +04:00
|
|
|
addRangeToSelectionTrackers(selStartContent, selEndContent, kInsertInRemoveList); // removed from selection
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
mEndSelectionPoint->SetPoint(newContent, mStartPos, PR_TRUE);
|
1998-07-23 01:56:48 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
mStartSelectionPoint->SetPoint(newContent, mStartPos, PR_TRUE);
|
|
|
|
|
|
|
|
addRangeToSelectionTrackers(newContent, newContent, kInsertInAddList); // add to selection
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
|
|
|
}
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
|
|
|
|
mSelectionRange->SetStartPoint(mStartSelectionPoint);
|
|
|
|
mSelectionRange->SetEndPoint(mEndSelectionPoint);
|
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
//if (selStartContent) printf("selStartContent count %d\n", selStartContent->Release());
|
|
|
|
//if (selEndContent) printf("selEndContent count %d\n", selEndContent->Release());
|
|
|
|
//if (newContent) printf("newContent count %d\n", newContent->Release());
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
NS_IF_RELEASE(selStartContent);
|
|
|
|
NS_IF_RELEASE(selEndContent);
|
|
|
|
NS_IF_RELEASE(newContent);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
RefreshFromContentTrackers(aPresContext);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("HandleEvent::mSelectionRange %s\n", mSelectionRange->ToString());
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-10-02 05:12:39 +04:00
|
|
|
NS_IF_RELEASE(acx);
|
|
|
|
|
1998-04-27 20:44:52 +04:00
|
|
|
// Force Update
|
1998-05-08 22:33:42 +04:00
|
|
|
ForceDrawFrame(this);
|
|
|
|
|
1998-07-18 03:00:54 +04:00
|
|
|
NS_RELEASE(shell);
|
|
|
|
NS_RELEASE(selection);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
aEventStatus = nsEventStatus_eIgnore;
|
|
|
|
return NS_OK;
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-27 20:44:52 +04:00
|
|
|
NS_METHOD nsFrame::HandleDrag(nsIPresContext& aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
1998-08-28 19:58:37 +04:00
|
|
|
nsEventStatus& aEventStatus)
|
1998-04-27 20:44:52 +04:00
|
|
|
{
|
1998-07-27 22:05:35 +04:00
|
|
|
if (DisplaySelection(aPresContext) == PR_FALSE)
|
|
|
|
{
|
|
|
|
aEventStatus = nsEventStatus_eIgnore;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
// Keep old start and end
|
|
|
|
nsIContent * startContent = mSelectionRange->GetStartContent(); // ref counted
|
|
|
|
nsIContent * endContent = mSelectionRange->GetEndContent(); // ref counted
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-04-27 20:44:52 +04:00
|
|
|
mDidDrag = PR_TRUE;
|
|
|
|
|
1998-10-02 05:12:39 +04:00
|
|
|
nsIPresShell *ps = aPresContext.GetShell();
|
|
|
|
nsIRenderingContext *acx;
|
|
|
|
|
|
|
|
ps->CreateRenderingContext(this, acx);
|
|
|
|
NS_RELEASE(ps);
|
|
|
|
|
1998-08-28 19:58:37 +04:00
|
|
|
//if (aFrame != nsnull) {
|
1998-05-08 22:33:42 +04:00
|
|
|
//printf("nsFrame::HandleDrag\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Check to see if we have changed frame
|
1998-08-28 19:58:37 +04:00
|
|
|
if (this != mCurrentFrame) {
|
1998-04-27 20:44:52 +04:00
|
|
|
// We are in a new Frame!
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("HandleDrag::Different Frame in selection!\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Get Content for current Frame
|
|
|
|
nsIContent * currentContent;
|
|
|
|
mCurrentFrame->GetContent(currentContent);
|
|
|
|
|
|
|
|
// Get Content for New Frame
|
|
|
|
nsIContent * newContent;
|
1998-08-28 19:58:37 +04:00
|
|
|
this->GetContent(newContent);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Check to see if we are still in the same Content
|
|
|
|
if (currentContent == newContent) {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("HandleDrag::New Frame, same content.\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-10-02 05:12:39 +04:00
|
|
|
AdjustPointsInSameContent(aPresContext, acx, aEvent);
|
1998-08-04 02:53:27 +04:00
|
|
|
addRangeToSelectionTrackers(currentContent, currentContent, kInsertInAddList);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-07-18 03:00:54 +04:00
|
|
|
} else if (gDoc->IsBefore(newContent, currentContent)) {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("HandleDrag::New Frame, is Before.\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
resetContentTrackers();
|
1998-10-02 05:12:39 +04:00
|
|
|
NewContentIsBefore(aPresContext, acx, aEvent, newContent, currentContent, this);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
} else { // Content is AFTER
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("HandleDrag::New Frame, is After.\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
resetContentTrackers();
|
1998-10-02 05:12:39 +04:00
|
|
|
NewContentIsAfter(aPresContext, acx, aEvent, newContent, currentContent, this);
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
1998-08-28 19:58:37 +04:00
|
|
|
mCurrentFrame = this;
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
NS_RELEASE(currentContent);
|
|
|
|
NS_RELEASE(newContent);
|
1998-09-03 05:16:27 +04:00
|
|
|
} else if ((nsnull != mStartSelectionPoint) && (nsnull != mEndSelectionPoint)) {
|
1998-08-06 02:38:24 +04:00
|
|
|
if (SELECTION_DEBUG) printf("HandleDrag::Same Frame.\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Same Frame as before
|
1998-07-18 22:18:20 +04:00
|
|
|
//if (SELECTION_DEBUG) printf("\nSame Start: %s\n", mStartSelectionPoint->ToString());
|
|
|
|
//if (SELECTION_DEBUG) printf("Same End: %s\n", mEndSelectionPoint->ToString());
|
1998-04-27 20:44:52 +04:00
|
|
|
// [TODO] Uncomment these soon
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
nsIContent * selStartContent = mStartSelectionPoint->GetContent();
|
|
|
|
nsIContent * selEndContent = mEndSelectionPoint->GetContent();
|
|
|
|
|
|
|
|
if (selStartContent == selEndContent) {
|
1998-08-06 02:38:24 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Start & End Frame are the same: \n");
|
1998-10-02 05:12:39 +04:00
|
|
|
AdjustPointsInSameContent(aPresContext, acx, aEvent);
|
1998-04-27 20:44:52 +04:00
|
|
|
} else {
|
1998-08-06 02:38:24 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Start & End Frame are different: \n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Get Content for New Frame
|
|
|
|
nsIContent * newContent;
|
1998-08-28 19:58:37 +04:00
|
|
|
this->GetContent(newContent);
|
1998-07-23 01:56:48 +04:00
|
|
|
PRInt32 newPos = -1;
|
|
|
|
PRUint32 actualOffset = 0;
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-10-02 05:12:39 +04:00
|
|
|
GetPosition(aPresContext, acx, aEvent, this, actualOffset, newPos);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
if (newContent == selStartContent) {
|
1998-08-06 02:38:24 +04:00
|
|
|
if (SELECTION_DEBUG) printf("New Content equals Start Content\n");
|
1998-05-08 22:33:42 +04:00
|
|
|
mStartSelectionPoint->SetOffset(newPos);
|
|
|
|
mSelectionRange->SetStartPoint(mStartSelectionPoint);
|
1998-08-04 02:22:27 +04:00
|
|
|
} else if (newContent == selEndContent) {
|
1998-08-06 02:38:24 +04:00
|
|
|
if (SELECTION_DEBUG) printf("New Content equals End Content\n");
|
1998-05-08 22:33:42 +04:00
|
|
|
mEndSelectionPoint->SetOffset(newPos);
|
|
|
|
mSelectionRange->SetEndPoint(mEndSelectionPoint);
|
1998-04-27 20:44:52 +04:00
|
|
|
} else {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("=====\n=====\n=====\n=====\n=====\n=====\n Should NOT be here.\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
|
|
|
|
1998-07-18 22:18:20 +04:00
|
|
|
//if (SELECTION_DEBUG) printf("*Same Start: "+mStartSelectionPoint->GetOffset()+
|
1998-05-08 22:33:42 +04:00
|
|
|
// " "+mStartSelectionPoint->IsAnchor()+
|
1998-08-06 02:38:24 +04:00
|
|
|
// " End: "+mEndSelectionPoint->GetOffset() +
|
1998-05-08 22:33:42 +04:00
|
|
|
// " "+mEndSelectionPoint->IsAnchor());
|
|
|
|
NS_RELEASE(newContent);
|
|
|
|
}
|
1998-08-04 02:22:27 +04:00
|
|
|
NS_IF_RELEASE(selStartContent);
|
|
|
|
NS_IF_RELEASE(selEndContent);
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
1998-08-28 19:58:37 +04:00
|
|
|
//}
|
1998-08-04 02:22:27 +04:00
|
|
|
|
1998-08-06 02:38:24 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
NS_IF_RELEASE(startContent);
|
|
|
|
NS_IF_RELEASE(endContent);
|
|
|
|
|
1998-10-02 05:12:39 +04:00
|
|
|
NS_IF_RELEASE(acx);
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
// Force Update
|
|
|
|
ForceDrawFrame(this);
|
|
|
|
//RefreshContentFrames(aPresContext, startContent, endContent);
|
|
|
|
RefreshFromContentTrackers(aPresContext);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
aEventStatus = nsEventStatus_eIgnore;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsFrame::HandleRelease(nsIPresContext& aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
1998-08-28 19:58:37 +04:00
|
|
|
nsEventStatus& aEventStatus)
|
1998-04-27 20:44:52 +04:00
|
|
|
{
|
|
|
|
mDoingSelection = PR_FALSE;
|
|
|
|
aEventStatus = nsEventStatus_eIgnore;
|
1998-07-18 03:00:54 +04:00
|
|
|
NS_IF_RELEASE(gDoc);
|
1998-04-27 20:44:52 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//-- GetPosition
|
|
|
|
//--------------------------------------------------------------------------
|
1998-10-02 05:12:39 +04:00
|
|
|
NS_IMETHODIMP nsFrame::GetPosition(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext * aRendContext,
|
|
|
|
nsGUIEvent * aEvent,
|
|
|
|
nsIFrame * aNewFrame,
|
|
|
|
PRUint32& aAcutalContentOffset,
|
|
|
|
PRInt32& aOffset)
|
|
|
|
{
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
//PRInt32 offset;
|
|
|
|
//PRInt32 width;
|
|
|
|
//CalcCursorPosition(aPresContext, aEvent, aNewFrame, offset, width);
|
|
|
|
//offset += aNewFrame->GetContentOffset();
|
|
|
|
|
|
|
|
//return offset;
|
1998-07-23 01:56:48 +04:00
|
|
|
aAcutalContentOffset = 0;
|
1998-10-02 05:12:39 +04:00
|
|
|
aOffset = -1;
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Adjusts the Starting and Ending TextPoint for a Range
|
|
|
|
*********************************************************/
|
|
|
|
void nsFrame::AdjustPointsInNewContent(nsIPresContext& aPresContext,
|
1998-10-02 05:12:39 +04:00
|
|
|
nsIRenderingContext * aRendContext,
|
1998-05-08 22:33:42 +04:00
|
|
|
nsGUIEvent * aEvent,
|
|
|
|
nsIFrame * aNewFrame) {
|
1998-07-23 01:56:48 +04:00
|
|
|
PRUint32 actualOffset = 0;
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
// Get new Cursor Poition in the new content
|
1998-10-02 05:12:39 +04:00
|
|
|
PRInt32 newPos;
|
|
|
|
|
|
|
|
GetPosition(aPresContext, aRendContext, aEvent, aNewFrame, actualOffset, newPos);
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
if (mStartSelectionPoint->IsAnchor()) {
|
|
|
|
if (newPos == mStartSelectionPoint->GetOffset()) {
|
|
|
|
mEndSelectionPoint->SetOffset(newPos);
|
|
|
|
mEndSelectionPoint->SetAnchor(PR_TRUE);
|
|
|
|
mSelectionRange->SetEndPoint(mEndSelectionPoint);
|
|
|
|
} else if (newPos < mStartSelectionPoint->GetOffset()) {
|
|
|
|
mEndSelectionPoint->SetOffset(mStartSelectionPoint->GetOffset());
|
|
|
|
mEndSelectionPoint->SetAnchor(PR_TRUE);
|
|
|
|
mStartSelectionPoint->SetOffset(newPos);
|
|
|
|
mStartSelectionPoint->SetAnchor(PR_FALSE);
|
|
|
|
mSelectionRange->SetRange(mStartSelectionPoint, mEndSelectionPoint);
|
|
|
|
} else {
|
|
|
|
mEndSelectionPoint->SetOffset(newPos);
|
|
|
|
mSelectionRange->SetEndPoint(mEndSelectionPoint);
|
|
|
|
}
|
|
|
|
} else if (mEndSelectionPoint->IsAnchor()) {
|
|
|
|
int endPos = mEndSelectionPoint->GetOffset();
|
|
|
|
if (newPos == mEndSelectionPoint->GetOffset()) {
|
|
|
|
mStartSelectionPoint->SetOffset(newPos);
|
|
|
|
mStartSelectionPoint->SetAnchor(PR_TRUE);
|
|
|
|
mSelectionRange->SetStartPoint(mStartSelectionPoint);
|
|
|
|
} else if (newPos > mEndSelectionPoint->GetOffset()) {
|
|
|
|
mEndSelectionPoint->SetOffset(newPos);
|
|
|
|
mEndSelectionPoint->SetAnchor(PR_FALSE);
|
|
|
|
mStartSelectionPoint->SetOffset(endPos);
|
|
|
|
mStartSelectionPoint->SetAnchor(PR_TRUE);
|
|
|
|
mSelectionRange->SetRange(mStartSelectionPoint, mEndSelectionPoint);
|
|
|
|
} else {
|
|
|
|
mStartSelectionPoint->SetOffset(newPos);
|
|
|
|
mSelectionRange->SetStartPoint(mStartSelectionPoint);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// [TODO] Should get here
|
|
|
|
// throw exception
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("--\n--\n--\n--\n--\n--\n--\n Should be here. #102\n");
|
1998-05-08 22:33:42 +04:00
|
|
|
//return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Adjusts the Starting and Ending TextPoint for a Range
|
|
|
|
*********************************************************/
|
|
|
|
void nsFrame::AdjustPointsInSameContent(nsIPresContext& aPresContext,
|
1998-10-02 05:12:39 +04:00
|
|
|
nsIRenderingContext * aRendContext,
|
1998-05-08 22:33:42 +04:00
|
|
|
nsGUIEvent * aEvent) {
|
1998-07-23 01:56:48 +04:00
|
|
|
PRUint32 actualOffset = 0;
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
// Get new Cursor Poition in the same content
|
1998-10-02 05:12:39 +04:00
|
|
|
PRInt32 newPos;
|
|
|
|
GetPosition(aPresContext, aRendContext, aEvent, mCurrentFrame, actualOffset, newPos);
|
1998-08-28 19:58:37 +04:00
|
|
|
//newPos += actualOffset;
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("AdjustTextPointsInSameContent newPos: %d\n", newPos);
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
if (mStartSelectionPoint->IsAnchor()) {
|
|
|
|
if (newPos == mStartSelectionPoint->GetOffset()) {
|
|
|
|
mEndSelectionPoint->SetOffset(newPos);
|
|
|
|
mEndSelectionPoint->SetAnchor(PR_TRUE);
|
|
|
|
mSelectionRange->SetEndPoint(mEndSelectionPoint);
|
|
|
|
} else if (newPos < mStartSelectionPoint->GetOffset()) {
|
|
|
|
mStartSelectionPoint->SetOffset(newPos);
|
|
|
|
mStartSelectionPoint->SetAnchor(PR_FALSE);
|
|
|
|
mEndSelectionPoint->SetAnchor(PR_TRUE);
|
|
|
|
mSelectionRange->SetRange(mStartSelectionPoint, mEndSelectionPoint);
|
|
|
|
} else {
|
|
|
|
mEndSelectionPoint->SetAnchor(PR_FALSE);
|
|
|
|
mEndSelectionPoint->SetOffset(newPos);
|
|
|
|
mSelectionRange->SetEndPoint(mEndSelectionPoint);
|
|
|
|
}
|
|
|
|
} else if (mEndSelectionPoint->IsAnchor()) {
|
|
|
|
if (newPos == mEndSelectionPoint->GetOffset()) {
|
|
|
|
mStartSelectionPoint->SetOffset(newPos);
|
|
|
|
mStartSelectionPoint->SetAnchor(PR_TRUE);
|
|
|
|
mSelectionRange->SetStartPoint(mStartSelectionPoint);
|
|
|
|
} else if (newPos > mEndSelectionPoint->GetOffset()) {
|
|
|
|
mEndSelectionPoint->SetOffset(newPos);
|
|
|
|
mEndSelectionPoint->SetAnchor(PR_FALSE);
|
|
|
|
mStartSelectionPoint->SetAnchor(PR_TRUE);
|
|
|
|
mSelectionRange->SetRange(mStartSelectionPoint, mEndSelectionPoint);
|
|
|
|
} else {
|
|
|
|
mStartSelectionPoint->SetAnchor(PR_FALSE);
|
|
|
|
mStartSelectionPoint->SetOffset(newPos);
|
|
|
|
mSelectionRange->SetStartPoint(mStartSelectionPoint);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// [TODO] Should get here
|
|
|
|
// throw exception
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("--\n--\n--\n--\n--\n--\n--\n Should be here. #101\n");
|
1998-05-08 22:33:42 +04:00
|
|
|
//return;
|
|
|
|
}
|
|
|
|
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Start %s End %s\n", mStartSelectionPoint->ToString(), mEndSelectionPoint->ToString());
|
1998-05-08 22:33:42 +04:00
|
|
|
//}
|
|
|
|
}
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-07-17 08:52:12 +04:00
|
|
|
NS_METHOD nsFrame::GetCursorAndContentAt(nsIPresContext& aPresContext,
|
1998-04-17 05:41:24 +04:00
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsIFrame** aFrame,
|
1998-07-17 08:52:12 +04:00
|
|
|
nsIContent** aContent,
|
1998-04-17 05:41:24 +04:00
|
|
|
PRInt32& aCursor)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-07-17 08:52:12 +04:00
|
|
|
*aContent = mContent;
|
1998-04-17 05:41:24 +04:00
|
|
|
aCursor = NS_STYLE_CURSOR_INHERIT;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Resize and incremental reflow
|
1998-05-14 04:47:32 +04:00
|
|
|
NS_METHOD
|
|
|
|
nsFrame::GetFrameState(nsFrameState& aResult)
|
|
|
|
{
|
|
|
|
aResult = mState;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
|
|
|
nsFrame::SetFrameState(nsFrameState aNewState)
|
|
|
|
{
|
|
|
|
mState = aNewState;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-01 08:46:11 +04:00
|
|
|
// nsIHTMLReflow member functions
|
1998-05-14 04:47:32 +04:00
|
|
|
|
|
|
|
NS_METHOD
|
|
|
|
nsFrame::WillReflow(nsIPresContext& aPresContext)
|
|
|
|
{
|
1998-06-25 20:33:10 +04:00
|
|
|
NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("WillReflow: oldState=%x", mState));
|
1998-05-14 04:47:32 +04:00
|
|
|
mState |= NS_FRAME_IN_REFLOW;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
|
|
|
nsFrame::DidReflow(nsIPresContext& aPresContext,
|
|
|
|
nsDidReflowStatus aStatus)
|
|
|
|
{
|
1998-06-25 20:33:10 +04:00
|
|
|
NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsFrame::DidReflow: aStatus=%d", aStatus));
|
1998-05-14 04:47:32 +04:00
|
|
|
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
|
1998-05-29 06:10:12 +04:00
|
|
|
mState &= ~(NS_FRAME_IN_REFLOW | NS_FRAME_FIRST_REFLOW);
|
1998-05-29 01:55:13 +04:00
|
|
|
|
|
|
|
if (nsnull != mView) {
|
|
|
|
// Position and size view relative to its parent, not relative to our
|
|
|
|
// parent frame (our parent frame may not have a view).
|
|
|
|
nsIView* parentWithView;
|
|
|
|
nsPoint origin;
|
|
|
|
GetOffsetFromView(origin, parentWithView);
|
1998-08-30 23:16:11 +04:00
|
|
|
nsIViewManager *vm;
|
|
|
|
mView->GetViewManager(vm);
|
1998-06-03 02:04:54 +04:00
|
|
|
vm->ResizeView(mView, mRect.width, mRect.height);
|
|
|
|
vm->MoveViewTo(mView, origin.x, origin.y);
|
|
|
|
NS_RELEASE(vm);
|
1998-05-29 01:55:13 +04:00
|
|
|
}
|
1998-05-14 04:47:32 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-02 08:10:00 +04:00
|
|
|
NS_METHOD nsFrame::Reflow(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
aDesiredSize.width = 0;
|
|
|
|
aDesiredSize.height = 0;
|
|
|
|
aDesiredSize.ascent = 0;
|
|
|
|
aDesiredSize.descent = 0;
|
1998-05-25 21:31:49 +04:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-05-12 08:17:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-05-25 21:31:49 +04:00
|
|
|
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-01 08:46:11 +04:00
|
|
|
NS_METHOD nsFrame::GetReflowMetrics(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics)
|
|
|
|
{
|
|
|
|
aMetrics.width = mRect.width;
|
|
|
|
aMetrics.height = mRect.height;
|
|
|
|
aMetrics.ascent = mRect.height;
|
|
|
|
aMetrics.descent = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-30 03:44:25 +04:00
|
|
|
NS_METHOD nsFrame::ContentChanged(nsIPresContext* aPresContext,
|
1998-05-08 08:45:37 +04:00
|
|
|
nsIContent* aChild,
|
|
|
|
nsISupports* aSubContent)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-30 03:44:25 +04:00
|
|
|
NS_IMETHODIMP nsFrame::AttributeChanged(nsIPresContext* aPresContext,
|
1998-09-18 23:53:27 +04:00
|
|
|
nsIContent* aChild,
|
1998-09-30 03:44:25 +04:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aHint)
|
1998-09-18 23:53:27 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Flow member functions
|
|
|
|
|
1998-05-22 08:54:11 +04:00
|
|
|
NS_METHOD nsFrame::IsSplittable(nsSplittableType& aIsSplittable) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-22 08:54:11 +04:00
|
|
|
aIsSplittable = NS_FRAME_NOT_SPLITTABLE;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-07-15 07:23:23 +04:00
|
|
|
NS_METHOD nsFrame::CreateContinuingFrame(nsIPresContext& aPresContext,
|
1998-05-07 04:08:20 +04:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aStyleContext,
|
|
|
|
nsIFrame*& aContinuingFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
1998-04-17 05:41:24 +04:00
|
|
|
aContinuingFrame = nsnull;
|
1998-05-08 21:02:35 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetPrevInFlow(nsIFrame*& aPrevInFlow) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
aPrevInFlow = nsnull;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::SetPrevInFlow(nsIFrame*)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
1998-05-08 21:02:35 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetNextInFlow(nsIFrame*& aNextInFlow) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
aNextInFlow = nsnull;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::SetNextInFlow(nsIFrame*)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
1998-05-08 21:02:35 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::AppendToFlow(nsIFrame* aAfterFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
1998-05-08 21:02:35 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::PrependToFlow(nsIFrame* aBeforeFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
1998-05-08 21:02:35 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::RemoveFromFlow()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
1998-05-08 21:02:35 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::BreakFromPrevFlow()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
1998-05-08 21:02:35 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::BreakFromNextFlow()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
1998-05-08 21:02:35 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Associated view object
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetView(nsIView*& aView) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
aView = mView;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::SetView(nsIView* aView)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-08-28 06:52:54 +04:00
|
|
|
nsresult rv;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull != aView) {
|
|
|
|
mView = aView;
|
1998-08-28 06:52:54 +04:00
|
|
|
aView->SetClientData(this);
|
|
|
|
rv = NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-08-28 06:52:54 +04:00
|
|
|
else
|
|
|
|
rv = NS_OK;
|
|
|
|
|
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Find the first geometric parent that has a view
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetParentWithView(nsIFrame*& aParent) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
aParent = mGeometricParent;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
while (nsnull != aParent) {
|
|
|
|
nsIView* parView;
|
|
|
|
|
|
|
|
aParent->GetView(parView);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull != parView) {
|
|
|
|
break;
|
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
aParent->GetGeometricParent(aParent);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the offset from this frame to the closest geometric parent that
|
|
|
|
// has a view. Also returns the containing view or null in case of error
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetOffsetFromView(nsPoint& aOffset, nsIView*& aView) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* frame = (nsIFrame*)this;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
aView = nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
aOffset.MoveTo(0, 0);
|
|
|
|
do {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsPoint origin;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
frame->GetOrigin(origin);
|
|
|
|
aOffset += origin;
|
1998-04-17 05:41:24 +04:00
|
|
|
frame->GetGeometricParent(frame);
|
|
|
|
if (nsnull != frame) {
|
|
|
|
frame->GetView(aView);
|
|
|
|
}
|
|
|
|
} while ((nsnull != frame) && (nsnull == aView));
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetWindow(nsIWidget*& aWindow) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* frame = (nsIFrame*)this;
|
|
|
|
|
|
|
|
aWindow = nsnull;
|
1998-04-14 00:24:54 +04:00
|
|
|
while (nsnull != frame) {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIView* view;
|
|
|
|
|
|
|
|
frame->GetView(view);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull != view) {
|
1998-08-30 23:16:11 +04:00
|
|
|
view->GetWidget(aWindow);
|
1998-04-17 05:41:24 +04:00
|
|
|
if (nsnull != aWindow) {
|
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
frame->GetParentWithView(frame);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_POSTCONDITION(nsnull != aWindow, "no window in frame tree");
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-09-25 03:56:15 +04:00
|
|
|
void
|
|
|
|
nsFrame::Invalidate(const nsRect& aDamageRect,
|
|
|
|
PRBool aImmediate) const
|
1998-06-02 09:28:11 +04:00
|
|
|
{
|
1998-08-30 23:16:11 +04:00
|
|
|
nsIViewManager* viewManager = nsnull;
|
1998-06-02 09:28:11 +04:00
|
|
|
|
1998-09-25 03:56:15 +04:00
|
|
|
PRUint32 flags = aImmediate ? NS_VMREFRESH_IMMEDIATE : NS_VMREFRESH_NO_SYNC;
|
1998-06-02 09:28:11 +04:00
|
|
|
if (nsnull != mView) {
|
1998-08-30 23:16:11 +04:00
|
|
|
mView->GetViewManager(viewManager);
|
1998-09-25 03:56:15 +04:00
|
|
|
viewManager->UpdateView(mView, aDamageRect, flags);
|
1998-06-02 09:28:11 +04:00
|
|
|
|
|
|
|
} else {
|
1998-08-08 08:23:33 +04:00
|
|
|
nsRect rect(aDamageRect);
|
|
|
|
nsPoint offset;
|
|
|
|
nsIView* view;
|
1998-06-02 09:28:11 +04:00
|
|
|
|
1998-08-08 08:23:33 +04:00
|
|
|
GetOffsetFromView(offset, view);
|
|
|
|
NS_ASSERTION(nsnull != view, "no view");
|
1998-06-02 09:28:11 +04:00
|
|
|
rect += offset;
|
1998-08-30 23:16:11 +04:00
|
|
|
view->GetViewManager(viewManager);
|
1998-09-25 03:56:15 +04:00
|
|
|
viewManager->UpdateView(view, rect, flags);
|
1998-06-02 09:28:11 +04:00
|
|
|
}
|
1998-08-30 23:16:11 +04:00
|
|
|
|
|
|
|
NS_IF_RELEASE(viewManager);
|
1998-06-02 09:28:11 +04:00
|
|
|
}
|
1998-05-14 02:38:09 +04:00
|
|
|
|
|
|
|
// Style sizing methods
|
|
|
|
NS_METHOD nsFrame::IsPercentageBase(PRBool& aBase) const
|
|
|
|
{
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStylePosition* position;
|
|
|
|
GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)position);
|
1998-05-14 02:38:09 +04:00
|
|
|
if (position->mPosition != NS_STYLE_POSITION_NORMAL) {
|
|
|
|
aBase = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
1998-06-05 10:09:09 +04:00
|
|
|
const nsStyleDisplay* display;
|
|
|
|
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
1998-05-14 02:38:09 +04:00
|
|
|
if ((display->mDisplay == NS_STYLE_DISPLAY_BLOCK) ||
|
|
|
|
(display->mDisplay == NS_STYLE_DISPLAY_LIST_ITEM)) {
|
|
|
|
aBase = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aBase = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsFrame::GetAutoMarginSize(PRUint8 aSide, nscoord& aSize) const
|
|
|
|
{
|
|
|
|
aSize = 0; // XXX probably not right, subclass override?
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Sibling pointer used to link together frames
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::GetNextSibling(nsIFrame*& aNextSibling) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
aNextSibling = mNextSibling;
|
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::SetNextSibling(nsIFrame* aNextSibling)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
mNextSibling = aNextSibling;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-06-04 02:49:45 +04:00
|
|
|
// Transparency query
|
|
|
|
NS_METHOD nsFrame::IsTransparent(PRBool& aTransparent) const
|
|
|
|
{
|
|
|
|
//XXX this needs to be overridden in just about every leaf class? MMP
|
|
|
|
aTransparent = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-06 00:57:57 +04:00
|
|
|
NS_METHOD nsFrame::Scrolled(nsIView *aView)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Debugging
|
1998-09-03 01:59:54 +04:00
|
|
|
NS_METHOD nsFrame::List(FILE* out, PRInt32 aIndent, nsIListFilter *aFilter) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-09-03 01:59:54 +04:00
|
|
|
// if a filter is present, only output this frame if the filter says we should
|
|
|
|
nsIAtom* tag;
|
|
|
|
nsAutoString tagString;
|
|
|
|
mContent->GetTag(tag);
|
|
|
|
if (tag != nsnull)
|
|
|
|
{
|
|
|
|
tag->ToString(tagString);
|
|
|
|
NS_RELEASE(tag);
|
1998-06-03 19:45:48 +04:00
|
|
|
}
|
1998-09-03 01:59:54 +04:00
|
|
|
if ((nsnull==aFilter) || (PR_TRUE==aFilter->OutputTag(&tagString)))
|
|
|
|
{
|
|
|
|
// Indent
|
|
|
|
for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out);
|
|
|
|
|
|
|
|
// Output the tag and rect
|
|
|
|
ListTag(out);
|
|
|
|
if (nsnull != mView) {
|
|
|
|
fprintf(out, " [view=%p]", mView);
|
|
|
|
}
|
|
|
|
fputs(" ", out);
|
|
|
|
out << mRect;
|
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
|
|
|
fputs("<>\n", out);
|
1998-05-18 20:53:09 +04:00
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Output the frame's tag
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::ListTag(FILE* out) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-08-30 00:20:38 +04:00
|
|
|
nsIAtom* tag;
|
|
|
|
mContent->GetTag(tag);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (tag != nsnull) {
|
|
|
|
nsAutoString buf;
|
|
|
|
tag->ToString(buf);
|
|
|
|
fputs(buf, out);
|
|
|
|
NS_RELEASE(tag);
|
|
|
|
}
|
1998-05-06 03:56:50 +04:00
|
|
|
PRInt32 contentIndex;
|
|
|
|
|
|
|
|
GetContentIndex(contentIndex);
|
|
|
|
fprintf(out, "(%d)@%p", contentIndex, this);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsFrame::VerifyTree() const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-05-28 23:00:31 +04:00
|
|
|
NS_ASSERTION(0 == (mState & NS_FRAME_IN_REFLOW), "frame is in reflow");
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Handles a when the cursor enters new content that is before
|
|
|
|
* the content that the cursor is currently in
|
|
|
|
*********************************************************/
|
|
|
|
void nsFrame::NewContentIsBefore(nsIPresContext& aPresContext,
|
1998-10-02 05:12:39 +04:00
|
|
|
nsIRenderingContext * aRendContext,
|
1998-04-27 20:44:52 +04:00
|
|
|
nsGUIEvent * aEvent,
|
|
|
|
nsIContent * aNewContent,
|
|
|
|
nsIContent * aCurrentContent,
|
|
|
|
nsIFrame * aNewFrame)
|
|
|
|
{
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("New Frame, New content is before.\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
// Dragging mouse to the left or backward in content
|
|
|
|
//
|
|
|
|
// 1) The cursor is being dragged backward in the content
|
|
|
|
// and the mouse is "after" the anchor in the content
|
|
|
|
// and the current piece of content is being removed from the selection
|
|
|
|
//
|
|
|
|
// This section cover two cases:
|
|
|
|
// 2) The cursor is being dragged backward in the content
|
|
|
|
// and the mouse is "before" the anchor in the content
|
|
|
|
// and each new piece of content is being added to the selection
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
if ((nsnull == mStartSelectionPoint) || (nsnull == mEndSelectionPoint)) {
|
|
|
|
return;
|
|
|
|
}
|
1998-08-04 02:22:27 +04:00
|
|
|
nsIPresShell * shell = aPresContext.GetShell();
|
|
|
|
nsIDocument * doc = shell->GetDocument();
|
|
|
|
nsIContent * selStartContent = mStartSelectionPoint->GetContent();
|
|
|
|
nsIContent * selEndContent = mEndSelectionPoint->GetContent();
|
1998-07-19 01:44:11 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
PRBool inRange = doc->IsInRange(selStartContent, selEndContent, aNewContent);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Check to see if the new content is in the selection
|
1998-07-18 22:18:20 +04:00
|
|
|
if (inRange) {
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Case #1 - Remove Current Content from Selection (at End)
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Case #1 - (Before) New Content is in selected Range.\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
if (aNewContent == selStartContent) {
|
1998-04-27 20:44:52 +04:00
|
|
|
// [TODO] This is where we might have to delete from end to new content
|
|
|
|
|
|
|
|
// Returns the new End Point, if Start and End are on the
|
|
|
|
// same content then End Point's Cursor is set to Start's
|
1998-08-04 02:22:27 +04:00
|
|
|
mEndSelectionPoint->SetContent(selStartContent);
|
1998-10-02 05:12:39 +04:00
|
|
|
AdjustPointsInNewContent(aPresContext, aRendContext, aEvent, aNewFrame);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
} else {
|
1998-07-23 01:56:48 +04:00
|
|
|
PRUint32 actualOffset = 0;
|
1998-10-02 05:12:39 +04:00
|
|
|
PRInt32 newPos;
|
|
|
|
GetPosition(aPresContext, aRendContext, aEvent, aNewFrame, actualOffset, newPos);
|
1998-05-08 22:33:42 +04:00
|
|
|
mEndSelectionPoint->SetPoint(aNewContent, newPos, PR_FALSE);
|
|
|
|
mSelectionRange->SetEndPoint(mEndSelectionPoint);
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// The current content is being removed from Selection
|
1998-05-08 22:33:42 +04:00
|
|
|
addRangeToSelectionTrackers(aNewContent, aCurrentContent, kInsertInRemoveList);
|
1998-04-27 20:44:52 +04:00
|
|
|
} else {
|
|
|
|
// Case #2 - Add new content to selection (At Start)
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Case #2 - (Before) New Content is NOT in selected Range. Moving Start Backward.\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-07-23 01:56:48 +04:00
|
|
|
PRUint32 actualOffset = 0;
|
1998-10-02 05:12:39 +04:00
|
|
|
PRInt32 newPos;
|
|
|
|
|
|
|
|
GetPosition(aPresContext, aRendContext, aEvent, aNewFrame, actualOffset, newPos);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Create new TextPoint and move Start Point backward
|
1998-05-08 22:33:42 +04:00
|
|
|
mStartSelectionPoint->SetPoint(aNewContent, newPos, PR_FALSE); // position is set correctly in adjustTextPoints
|
|
|
|
mSelectionRange->SetStartPoint(mStartSelectionPoint);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// The New Content is added to Tracker
|
1998-05-08 22:33:42 +04:00
|
|
|
addRangeToSelectionTrackers(aNewContent, aCurrentContent, kInsertInAddList);
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
1998-08-04 02:22:27 +04:00
|
|
|
NS_RELEASE(selStartContent);
|
|
|
|
NS_RELEASE(selEndContent);
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Refreshes each content's frame
|
|
|
|
*********************************************************/
|
|
|
|
void RefreshAllContentFrames(nsIFrame * aFrame, nsIContent * aContent)
|
|
|
|
{
|
|
|
|
nsIContent* frameContent;
|
|
|
|
aFrame->GetContent(frameContent);
|
|
|
|
if (frameContent == aContent) {
|
|
|
|
ForceDrawFrame((nsFrame *)aFrame);
|
|
|
|
}
|
|
|
|
NS_RELEASE(frameContent);
|
|
|
|
|
|
|
|
aFrame->FirstChild(aFrame);
|
|
|
|
while (aFrame) {
|
|
|
|
RefreshAllContentFrames(aFrame, aContent);
|
|
|
|
aFrame->GetNextSibling(aFrame);
|
|
|
|
}
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Refreshes each content's frame
|
|
|
|
*********************************************************/
|
|
|
|
void RefreshContentFrames(nsIPresContext& aPresContext,
|
|
|
|
nsIContent * aStartContent,
|
|
|
|
nsIContent * aEndContent)
|
|
|
|
{
|
|
|
|
//-------------------------------------
|
|
|
|
// Undraw all the current selected frames
|
|
|
|
// XXX Kludge for now
|
1998-08-04 02:22:27 +04:00
|
|
|
nsIPresShell * shell = aPresContext.GetShell();
|
|
|
|
nsIFrame * rootFrame = shell->GetRootFrame();
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
PRBool foundStart = PR_FALSE;
|
|
|
|
for (PRInt32 i=0;i<fMax;i++) {
|
|
|
|
nsIContent * node = (nsIContent *)fContentArray[i];
|
|
|
|
if (node == aStartContent) {
|
|
|
|
foundStart = PR_TRUE;
|
1998-08-04 02:22:27 +04:00
|
|
|
//ForceDrawFrame((nsFrame *)shell->FindFrameWithContent(node));
|
|
|
|
RefreshAllContentFrames(rootFrame, node);
|
1998-05-08 22:33:42 +04:00
|
|
|
if (aStartContent == aEndContent) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (foundStart) {
|
1998-08-04 02:22:27 +04:00
|
|
|
//ForceDrawFrame((nsFrame *)shell->FindFrameWithContent(node));
|
|
|
|
RefreshAllContentFrames(rootFrame, node);
|
1998-05-08 22:33:42 +04:00
|
|
|
} else if (aEndContent == node) {
|
1998-08-04 02:22:27 +04:00
|
|
|
//ForceDrawFrame((nsFrame *)shell->FindFrameWithContent(node));
|
|
|
|
RefreshAllContentFrames(rootFrame, node);
|
1998-05-08 22:33:42 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-08-04 02:22:27 +04:00
|
|
|
//NS_RELEASE(rootFrame);
|
|
|
|
NS_RELEASE(shell);
|
1998-05-08 22:33:42 +04:00
|
|
|
//-------------------------------------
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Handles a when the cursor enters new content that is After
|
|
|
|
* the content that the cursor is currently in
|
|
|
|
*********************************************************/
|
|
|
|
void nsFrame::NewContentIsAfter(nsIPresContext& aPresContext,
|
1998-10-02 05:12:39 +04:00
|
|
|
nsIRenderingContext * aRendContext,
|
1998-04-27 20:44:52 +04:00
|
|
|
nsGUIEvent * aEvent,
|
|
|
|
nsIContent * aNewContent,
|
|
|
|
nsIContent * aCurrentContent,
|
|
|
|
nsIFrame * aNewFrame)
|
|
|
|
{
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("New Frame, New content is after.\n");
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Dragging Mouse to the Right
|
|
|
|
//
|
|
|
|
// 3) The cursor is being dragged foward in the content
|
|
|
|
// and the mouse is "before" the anchor in the content
|
|
|
|
// and the current piece of content is being removed from the selection
|
|
|
|
//
|
|
|
|
// This section cover two cases:
|
|
|
|
// 4) The cursor is being dragged foward in the content
|
|
|
|
// and the mouse is "after" the anchor in the content
|
|
|
|
// and each new piece of content is being added to the selection
|
|
|
|
//
|
|
|
|
|
|
|
|
// Check to see if the new content is in the selection
|
1998-08-04 02:22:27 +04:00
|
|
|
nsIPresShell * shell = aPresContext.GetShell();
|
|
|
|
nsIDocument * doc = shell->GetDocument();
|
|
|
|
nsIContent * selStartContent = mStartSelectionPoint->GetContent();
|
|
|
|
nsIContent * selEndContent = mEndSelectionPoint->GetContent();
|
1998-07-19 01:44:11 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
PRBool inRange = doc->IsInRange(selStartContent, selEndContent, aNewContent);
|
1998-07-18 03:00:54 +04:00
|
|
|
|
1998-07-18 22:18:20 +04:00
|
|
|
if (inRange) {
|
1998-04-27 20:44:52 +04:00
|
|
|
// Case #3 - Remove Content (from Start)
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Case #3 - (After) New Content is in selected Range.\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
// Remove Current Content in Tracker, but leave New Content in Selection
|
|
|
|
addRangeToSelectionTrackers(mStartSelectionPoint->GetContent(), aNewContent, kInsertInRemoveList);
|
|
|
|
|
1998-07-23 01:56:48 +04:00
|
|
|
PRUint32 actualOffset = 0;
|
1998-04-27 20:44:52 +04:00
|
|
|
// [TODO] Always get nearest Text content
|
1998-10-02 05:12:39 +04:00
|
|
|
PRInt32 newPos;
|
|
|
|
GetPosition(aPresContext, aRendContext, aEvent, aNewFrame, actualOffset, newPos);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Check to see if the new Content is the same as the End Point's
|
1998-08-04 02:22:27 +04:00
|
|
|
if (aNewContent == selEndContent) {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("New Content matches End Point\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
mStartSelectionPoint->SetContent(aNewContent);
|
1998-10-02 05:12:39 +04:00
|
|
|
AdjustPointsInNewContent(aPresContext, aRendContext, aEvent, aNewFrame);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
} else {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("New Content does NOT matches End Point\n");
|
1998-05-08 22:33:42 +04:00
|
|
|
mStartSelectionPoint->SetPoint(aNewContent, newPos, PR_FALSE);
|
|
|
|
mSelectionRange->SetStartPoint(mStartSelectionPoint);
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG)
|
1998-04-27 20:44:52 +04:00
|
|
|
printf("Case #4 - (After) Adding New Content\n");
|
|
|
|
|
|
|
|
// Case #2 - Adding Content (at End)
|
1998-07-23 01:56:48 +04:00
|
|
|
PRUint32 actualOffset = 0;
|
1998-04-27 20:44:52 +04:00
|
|
|
// The new content is not in the selection
|
1998-10-02 05:12:39 +04:00
|
|
|
PRInt32 newPos;
|
|
|
|
GetPosition(aPresContext, aRendContext, aEvent, aNewFrame, actualOffset, newPos);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
// Check to see if we need to create a new SelectionPoint and add it
|
1998-04-27 20:44:52 +04:00
|
|
|
// or do we simply move the existing start or end point
|
1998-08-04 02:22:27 +04:00
|
|
|
if (selStartContent == selEndContent) {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Case #4 - Start & End Content the Same\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
// Move start or end point
|
|
|
|
// Get new Cursor Poition in the new content
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
if (mStartSelectionPoint->IsAnchor()) {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Case #4 - Start is Anchor\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
// Since the Start is the Anchor just adjust the end
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
// XXX Note this includes the current End point (it should be end->nextContent)
|
1998-08-04 02:22:27 +04:00
|
|
|
addRangeToSelectionTrackers(selEndContent, aNewContent, kInsertInAddList);
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
mEndSelectionPoint->SetPoint(aNewContent, newPos, PR_FALSE);
|
|
|
|
mSelectionRange->SetEndPoint(mEndSelectionPoint);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
} else {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Case #4 - Start is NOT Anchor\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
// Because End was the anchor, we need to set the Start Point to
|
|
|
|
// the End's Offset and set it to be the new anchor
|
1998-08-04 02:22:27 +04:00
|
|
|
addRangeToSelectionTrackers(selStartContent,selEndContent, kInsertInRemoveList);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
int endPos = mEndSelectionPoint->GetOffset();
|
|
|
|
mStartSelectionPoint->SetOffset(endPos);
|
|
|
|
mStartSelectionPoint->SetAnchor(PR_TRUE);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// The Start point was being moved so when it jumped to the new frame
|
|
|
|
// we needed to make it the new End Point
|
1998-05-08 22:33:42 +04:00
|
|
|
mEndSelectionPoint->SetPoint(aNewContent, newPos, PR_FALSE);
|
|
|
|
mSelectionRange->SetRange(mStartSelectionPoint, mEndSelectionPoint);
|
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
// The Content values have changed so go get new contents
|
|
|
|
nsIContent * startContent = mStartSelectionPoint->GetContent();
|
|
|
|
nsIContent * endContent = mEndSelectionPoint->GetContent();
|
|
|
|
addRangeToSelectionTrackers(startContent, endContent, kInsertInRemoveList);
|
|
|
|
NS_RELEASE(startContent);
|
|
|
|
NS_RELEASE(endContent);
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
|
|
|
} else {
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("Case #4 - Start & End Content NOT the Same\n");
|
1998-04-27 20:44:52 +04:00
|
|
|
// Adjust the end point
|
1998-05-08 22:33:42 +04:00
|
|
|
mEndSelectionPoint->SetPoint(aNewContent, newPos, PR_FALSE);
|
|
|
|
mSelectionRange->SetRange(mStartSelectionPoint, mEndSelectionPoint);
|
1998-04-27 20:44:52 +04:00
|
|
|
|
|
|
|
// Add New Content to Selection Tracker
|
1998-08-04 02:22:27 +04:00
|
|
|
// The Content values have changed so go get new contents
|
|
|
|
// NOTE: selEndContent holds the "old" end content pointer
|
|
|
|
// and endContent hold the "new" content pointer
|
|
|
|
nsIContent * endContent = mEndSelectionPoint->GetContent();
|
|
|
|
addRangeToSelectionTrackers(selEndContent, endContent, kInsertInAddList);
|
|
|
|
NS_RELEASE(endContent);
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
|
|
|
}
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
NS_RELEASE(selStartContent);
|
|
|
|
NS_RELEASE(selEndContent);
|
|
|
|
NS_RELEASE(doc);
|
|
|
|
NS_RELEASE(shell);
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void ForceDrawFrame(nsFrame * aFrame)//, PRBool)
|
|
|
|
{
|
|
|
|
if (aFrame == nsnull) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsRect rect;
|
|
|
|
nsIView * view;
|
|
|
|
nsPoint pnt;
|
|
|
|
aFrame->GetOffsetFromView(pnt, view);
|
|
|
|
aFrame->GetRect(rect);
|
|
|
|
rect.x = pnt.x;
|
|
|
|
rect.y = pnt.y;
|
|
|
|
if (view != nsnull) {
|
1998-08-30 23:16:11 +04:00
|
|
|
nsIViewManager * viewMgr;
|
|
|
|
view->GetViewManager(viewMgr);
|
1998-05-08 22:33:42 +04:00
|
|
|
if (viewMgr != nsnull) {
|
|
|
|
viewMgr->UpdateView(view, rect, 0);
|
1998-08-04 02:22:27 +04:00
|
|
|
NS_RELEASE(viewMgr);
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
1998-08-04 02:22:27 +04:00
|
|
|
//viewMgr->UpdateView(view, rect, NS_VMREFRESH_DOUBLE_BUFFER | NS_VMREFRESH_IMMEDIATE);
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
// Selection Tracker Methods
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//----------------------------
|
|
|
|
//
|
|
|
|
//----------------------------
|
|
|
|
void resetContentTrackers() {
|
1998-08-04 02:22:27 +04:00
|
|
|
PRInt32 i;
|
|
|
|
for (i=0;i<fTrackerRemoveListMax;i++) {
|
|
|
|
NS_RELEASE(fTrackerContentArrayRemoveList[i]);
|
|
|
|
}
|
|
|
|
for (i=0;i<fTrackerAddListMax;i++) {
|
|
|
|
NS_RELEASE(fTrackerContentArrayAddList[i]);
|
|
|
|
}
|
1998-05-08 22:33:42 +04:00
|
|
|
fTrackerRemoveListMax = 0;
|
1998-08-04 02:22:27 +04:00
|
|
|
fTrackerAddListMax = 0;
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------
|
|
|
|
//
|
|
|
|
//----------------------------
|
|
|
|
void RefreshFromContentTrackers(nsIPresContext& aPresContext) {
|
1998-05-20 20:24:13 +04:00
|
|
|
|
1998-05-20 03:11:28 +04:00
|
|
|
PRInt32 i;
|
1998-05-08 22:33:42 +04:00
|
|
|
nsIPresShell * shell = aPresContext.GetShell();
|
1998-08-04 02:22:27 +04:00
|
|
|
nsIFrame * rootFrame = shell->GetRootFrame();
|
1998-05-20 03:11:28 +04:00
|
|
|
for (i=0;i<fTrackerRemoveListMax;i++) {
|
1998-08-04 02:22:27 +04:00
|
|
|
RefreshAllContentFrames(rootFrame, fTrackerContentArrayRemoveList[i]);
|
|
|
|
//ForceDrawFrame((nsFrame *)shell->FindFrameWithContent(fTrackerContentArrayRemoveList[i]));
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("ForceDrawFrame (remove) content 0x%X\n", fTrackerContentArrayRemoveList[i]);
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
|
|
|
for (i=0;i<fTrackerAddListMax;i++) {
|
1998-08-04 02:22:27 +04:00
|
|
|
//nsIFrame * frame = shell->FindFrameWithContent(fTrackerContentArrayAddList[i]);
|
|
|
|
//ForceDrawFrame((nsFrame *)frame);
|
|
|
|
RefreshAllContentFrames(rootFrame, fTrackerContentArrayAddList[i]);
|
1998-07-18 22:18:20 +04:00
|
|
|
if (SELECTION_DEBUG) printf("ForceDrawFrame (add) content 0x%X\n", fTrackerContentArrayAddList[i]);
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
1998-08-04 02:22:27 +04:00
|
|
|
NS_RELEASE(shell);
|
1998-05-08 22:33:42 +04:00
|
|
|
resetContentTrackers();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------
|
|
|
|
//
|
|
|
|
//----------------------------
|
|
|
|
void addRangeToSelectionTrackers(nsIContent * aStartContent, nsIContent * aEndContent, PRUint32 aType)
|
|
|
|
{
|
|
|
|
if (aStartContent == nsnull || aEndContent == nsnull) {
|
|
|
|
return;
|
|
|
|
}
|
1998-07-18 22:18:20 +04:00
|
|
|
nsIContent ** contentList = (aType == kInsertInRemoveList?fTrackerContentArrayRemoveList:fTrackerContentArrayAddList);
|
|
|
|
int inx = (aType == kInsertInRemoveList?fTrackerRemoveListMax:fTrackerAddListMax);
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
NS_ADDREF(aStartContent);
|
1998-07-18 22:18:20 +04:00
|
|
|
nsIContent * contentPtr = aStartContent;
|
|
|
|
while (contentPtr != aEndContent) {
|
|
|
|
contentList[inx++] = contentPtr;
|
1998-08-04 02:22:27 +04:00
|
|
|
contentPtr = gDoc->GetNextContent(contentPtr); // This does an AddRef
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
1998-07-18 22:18:20 +04:00
|
|
|
contentList[inx++] = aEndContent;
|
|
|
|
|
|
|
|
if (SELECTION_DEBUG) printf("Adding to %s %d\n", (aType == kInsertInRemoveList?"Remove Array":"Add Array"), inx);
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
if (aType == kInsertInRemoveList) {
|
|
|
|
fTrackerRemoveListMax = inx;
|
|
|
|
} else { // kInsertInAddList
|
|
|
|
fTrackerAddListMax = inx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-20 20:24:13 +04:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
static void
|
|
|
|
GetTagName(nsFrame* aFrame, nsIContent* aContent, PRIntn aResultSize,
|
|
|
|
char* aResult)
|
|
|
|
{
|
|
|
|
char namebuf[40];
|
|
|
|
namebuf[0] = 0;
|
|
|
|
if (nsnull != aContent) {
|
1998-08-30 00:20:38 +04:00
|
|
|
nsIAtom* tag;
|
|
|
|
aContent->GetTag(tag);
|
1998-05-20 20:24:13 +04:00
|
|
|
if (nsnull != tag) {
|
|
|
|
nsAutoString tmp;
|
|
|
|
tag->ToString(tmp);
|
|
|
|
tmp.ToCString(namebuf, sizeof(namebuf));
|
|
|
|
NS_RELEASE(tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PR_snprintf(aResult, aResultSize, "%s@%p", namebuf, aFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFrame::Trace(const char* aMethod, PRBool aEnter)
|
|
|
|
{
|
|
|
|
if (NS_FRAME_LOG_TEST(gLogModule, NS_FRAME_TRACE_CALLS)) {
|
|
|
|
char tagbuf[40];
|
|
|
|
GetTagName(this, mContent, sizeof(tagbuf), tagbuf);
|
|
|
|
PR_LogPrint("%s: %s %s", tagbuf, aEnter ? "enter" : "exit", aMethod);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFrame::Trace(const char* aMethod, PRBool aEnter, nsReflowStatus aStatus)
|
|
|
|
{
|
|
|
|
if (NS_FRAME_LOG_TEST(gLogModule, NS_FRAME_TRACE_CALLS)) {
|
|
|
|
char tagbuf[40];
|
|
|
|
GetTagName(this, mContent, sizeof(tagbuf), tagbuf);
|
|
|
|
PR_LogPrint("%s: %s %s, status=%scomplete%s",
|
|
|
|
tagbuf, aEnter ? "enter" : "exit", aMethod,
|
|
|
|
NS_FRAME_IS_NOT_COMPLETE(aStatus) ? "not" : "",
|
|
|
|
(NS_FRAME_REFLOW_NEXTINFLOW & aStatus) ? "+reflow" : "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsFrame::TraceMsg(const char* aFormatString, ...)
|
|
|
|
{
|
|
|
|
if (NS_FRAME_LOG_TEST(gLogModule, NS_FRAME_TRACE_CALLS)) {
|
|
|
|
// Format arguments into a buffer
|
|
|
|
char argbuf[200];
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, aFormatString);
|
|
|
|
PR_vsnprintf(argbuf, sizeof(argbuf), aFormatString, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
char tagbuf[40];
|
|
|
|
GetTagName(this, mContent, sizeof(tagbuf), tagbuf);
|
|
|
|
PR_LogPrint("%s: %s", tagbuf, argbuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|