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.
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsFrame.h"
|
1999-02-01 20:31:10 +03:00
|
|
|
#include "nsFrameList.h"
|
1998-10-10 03:46:02 +04:00
|
|
|
#include "nsLineLayout.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#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 "nsDocument.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
1998-10-01 08:46:11 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1998-11-18 08:25:26 +03:00
|
|
|
#include "nsIEventStateManager.h"
|
1999-02-12 02:12:28 +03:00
|
|
|
#include "nsIDOMSelection.h"
|
|
|
|
#include "nsIFrameSelection.h"
|
1999-01-15 04:29:15 +03:00
|
|
|
#include "nsHTMLParts.h"
|
1999-01-23 01:48:00 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1999-02-10 21:55:25 +03:00
|
|
|
#include "nsFrameTraversal.h"
|
|
|
|
#include "nsCOMPtr.h"
|
1999-03-25 09:43:38 +03:00
|
|
|
#include "nsStyleChangeList.h"
|
1999-02-10 21:55:25 +03:00
|
|
|
|
1999-06-22 03:24:33 +04:00
|
|
|
#define NORMAL_DRAG_HANDLING 1 // remove this to simulate a start-drag event.
|
1999-05-27 01:08:14 +04:00
|
|
|
#if !NORMAL_DRAG_HANDLING
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsIDragService.h"
|
|
|
|
#include "nsIDragSession.h"
|
|
|
|
#include "nsITransferable.h"
|
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
|
|
|
|
// Define Class IDs -- i hate having to do this
|
|
|
|
static NS_DEFINE_IID(kCDragServiceCID, NS_DRAGSERVICE_CID);
|
|
|
|
static NS_DEFINE_IID(kCTransferableCID, NS_TRANSFERABLE_CID);
|
|
|
|
#endif
|
|
|
|
|
1999-02-10 21:55:25 +03: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
|
|
|
|
1999-06-20 00:36:44 +04:00
|
|
|
#include "nsICaret.h"
|
|
|
|
#include "nsILineIterator.h"
|
1998-04-27 20:44:52 +04:00
|
|
|
// [HACK] Foward Declarations
|
1998-05-08 22:33:42 +04:00
|
|
|
void ForceDrawFrame(nsFrame * aFrame);
|
1999-07-15 22:19:03 +04:00
|
|
|
//non Hack prototypes
|
|
|
|
static void GetLastLeaf(nsIFrame **aFrame);
|
1999-02-08 20:56:00 +03:00
|
|
|
#if 0
|
1999-09-01 05:02:16 +04:00
|
|
|
static void GetFirstLeaf(nsIFrame **aFrame);
|
1998-12-19 00:04:33 +03:00
|
|
|
static void RefreshContentFrames(nsIPresContext& aPresContext, nsIContent * aStartContent, nsIContent * aEndContent);
|
1999-02-08 20:56:00 +03:00
|
|
|
#endif
|
1998-05-08 22:33:42 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
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-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.
|
|
|
|
*/
|
1999-02-26 20:05:20 +03:00
|
|
|
static PRLogModuleInfo* gLogModule;
|
1998-05-20 20:24:13 +04:00
|
|
|
|
1999-04-28 02:14:17 +04:00
|
|
|
#ifdef NS_DEBUG
|
1998-05-20 20:24:13 +04:00
|
|
|
static PRLogModuleInfo* gFrameVerifyTreeLogModuleInfo;
|
1999-04-28 02:14:17 +04:00
|
|
|
#endif
|
1998-05-20 20:24:13 +04:00
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
1999-02-26 20:05:20 +03:00
|
|
|
if (nsnull == gLogModule) {
|
|
|
|
gLogModule = PR_NewLogModule("frame");
|
|
|
|
}
|
1998-05-20 20:24:13 +04:00
|
|
|
return gLogModule;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
1999-02-12 02:12:28 +03:00
|
|
|
static NS_DEFINE_IID(kIFrameSelection, NS_IFRAMESELECTION_IID);
|
1998-04-14 00:24:54 +04:00
|
|
|
nsresult
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_NewEmptyFrame(nsIFrame** aNewFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
nsFrame* it = new nsFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-26 23:02:06 +03:00
|
|
|
NS_IMPL_ZEROING_OPERATOR_NEW(nsFrame)
|
1999-02-26 20:05:20 +03:00
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsFrame::nsFrame()
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-07-24 06:37:06 +04:00
|
|
|
mState = NS_FRAME_FIRST_REFLOW | NS_FRAME_SYNC_FRAME_AND_VIEW | NS_FRAME_IS_DIRTY;
|
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
|
|
|
|
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-12-03 09:31:43 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::Init(nsIPresContext& aPresContext,
|
|
|
|
nsIContent* aContent,
|
1999-01-14 08:16:23 +03:00
|
|
|
nsIFrame* aParent,
|
1999-02-25 06:27:57 +03:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1998-12-03 09:31:43 +03:00
|
|
|
{
|
|
|
|
mContent = aContent;
|
|
|
|
NS_IF_ADDREF(mContent);
|
1999-01-14 08:16:23 +03:00
|
|
|
mParent = aParent;
|
1998-12-03 09:31:43 +03:00
|
|
|
return SetStyleContext(&aPresContext, aContext);
|
|
|
|
}
|
|
|
|
|
1998-11-10 09:05:32 +03:00
|
|
|
NS_IMETHODIMP nsFrame::SetInitialChildList(nsIPresContext& aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-09-10 23:32:14 +04:00
|
|
|
{
|
1998-11-10 09:05:32 +03:00
|
|
|
// XXX This shouldn't be getting called at all, but currently is for backwards
|
|
|
|
// compatility reasons...
|
|
|
|
#if 0
|
|
|
|
NS_ERROR("not a container");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
#else
|
|
|
|
NS_ASSERTION(nsnull == aChildList, "not a container");
|
1998-09-10 23:32:14 +04:00
|
|
|
return NS_OK;
|
1998-11-10 09:05:32 +03:00
|
|
|
#endif
|
1998-09-10 23:32:14 +04:00
|
|
|
}
|
|
|
|
|
1999-01-15 04:29:15 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::AppendFrames(nsIPresContext& aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
1999-08-19 07:51:25 +04:00
|
|
|
NS_PRECONDITION(PR_FALSE, "not a container");
|
1999-01-15 04:29:15 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::InsertFrames(nsIPresContext& aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
1999-08-19 07:51:25 +04:00
|
|
|
NS_PRECONDITION(PR_FALSE, "not a container");
|
1999-01-15 04:29:15 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::RemoveFrame(nsIPresContext& aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
1999-08-19 07:51:25 +04:00
|
|
|
NS_PRECONDITION(PR_FALSE, "not a container");
|
1999-01-15 04:29:15 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
1999-07-22 08:32:31 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::ReplaceFrame(nsIPresContext& aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame,
|
|
|
|
nsIFrame* aNewFrame)
|
|
|
|
{
|
1999-08-19 07:51:25 +04:00
|
|
|
NS_PRECONDITION(PR_FALSE, "not a container");
|
1999-07-22 08:32:31 +04:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
1999-01-15 04:29:15 +03:00
|
|
|
NS_IMETHODIMP
|
1999-07-22 06:24:52 +04:00
|
|
|
nsFrame::Destroy(nsIPresContext& aPresContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-06-25 08:22:15 +04:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext.GetShell(getter_AddRefs(shell));
|
|
|
|
|
1999-07-17 03:25:15 +04:00
|
|
|
// XXX Rather than always doing this it would be better if it was part of
|
1999-06-25 08:22:15 +04:00
|
|
|
// a frame observer mechanism and the pres shell could register as an
|
|
|
|
// observer of the frame while the reflow command is pending...
|
|
|
|
if (shell) {
|
1999-07-17 03:25:15 +04:00
|
|
|
shell->NotifyDestroyingFrame(this);
|
1999-06-25 08:22:15 +04:00
|
|
|
}
|
|
|
|
|
1999-05-04 00:51:30 +04:00
|
|
|
if ((mState & NS_FRAME_EXTERNAL_REFERENCE) ||
|
|
|
|
(mState & NS_FRAME_SELECTED_CONTENT)) {
|
1999-06-25 08:22:15 +04:00
|
|
|
if (shell) {
|
1998-11-19 03:43:36 +03:00
|
|
|
shell->ClearFrameRefs(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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?
|
1999-04-14 01:51:00 +04:00
|
|
|
aPresContext.StopAllLoadImagesFor(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
|
1999-02-10 03:42:56 +03:00
|
|
|
nsFrame::GetContent(nsIContent** aContent) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-10 03:42:56 +03:00
|
|
|
NS_PRECONDITION(nsnull != aContent, "null OUT parameter pointer");
|
1998-11-13 02:03:35 +03:00
|
|
|
NS_IF_ADDREF(mContent);
|
1999-02-10 03:42:56 +03:00
|
|
|
*aContent = mContent;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-01-22 21:58:14 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const
|
|
|
|
{
|
|
|
|
aStart = 0;
|
|
|
|
aEnd = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-01-16 03:00:50 +03:00
|
|
|
NS_IMETHODIMP
|
1999-02-10 03:42:56 +03:00
|
|
|
nsFrame::GetStyleContext(nsIStyleContext** aStyleContext) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-10 03:42:56 +03:00
|
|
|
NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer");
|
1998-11-03 23:23:15 +03:00
|
|
|
NS_ASSERTION(nsnull != mStyleContext, "frame should always have style context");
|
1998-04-14 00:24:54 +04:00
|
|
|
NS_IF_ADDREF(mStyleContext);
|
1999-02-10 03:42:56 +03:00
|
|
|
*aStyleContext = mStyleContext;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP nsFrame::SetStyleContext(nsIPresContext* aPresContext,nsIStyleContext* aContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-04-10 21:32:22 +04:00
|
|
|
// NS_PRECONDITION(0 == (mState & NS_FRAME_IN_REFLOW), "Shouldn't set style context during reflow");
|
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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP nsFrame::DidSetStyleContext(nsIPresContext* aPresContext)
|
1998-04-29 03:25:07 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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
|
|
|
}
|
|
|
|
|
1999-03-25 09:43:38 +03:00
|
|
|
void nsFrame::CaptureStyleChangeFor(nsIFrame* aFrame,
|
|
|
|
nsIStyleContext* aOldContext,
|
|
|
|
nsIStyleContext* aNewContext,
|
|
|
|
PRInt32 aParentChange,
|
|
|
|
nsStyleChangeList* aChangeList,
|
|
|
|
PRInt32* aLocalChange)
|
|
|
|
{
|
|
|
|
if (aChangeList && aLocalChange) { // does caller really want change data?
|
|
|
|
PRInt32 change = NS_STYLE_HINT_NONE;
|
|
|
|
if (aOldContext) {
|
|
|
|
aNewContext->CalcStyleDifference(aOldContext, change);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsIStyleContext* parent = aNewContext->GetParent();
|
|
|
|
if (parent) {
|
|
|
|
aNewContext->CalcStyleDifference(parent, change);
|
|
|
|
NS_RELEASE(parent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aParentChange < change) { // found larger change, record it
|
|
|
|
aChangeList->AppendChange(aFrame, change);
|
|
|
|
*aLocalChange = change;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aLocalChange = aParentChange;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-03 23:23:15 +03:00
|
|
|
NS_IMETHODIMP nsFrame::ReResolveStyleContext(nsIPresContext* aPresContext,
|
1999-03-25 09:43:38 +03:00
|
|
|
nsIStyleContext* aParentContext,
|
|
|
|
PRInt32 aParentChange,
|
|
|
|
nsStyleChangeList* aChangeList,
|
|
|
|
PRInt32* aLocalChange)
|
1998-11-03 23:23:15 +03:00
|
|
|
{
|
1999-02-05 06:58:27 +03:00
|
|
|
// XXX TURN THIS ON NS_PRECONDITION(0 == (mState & NS_FRAME_IN_REFLOW), "Shouldn't set style context during reflow");
|
1998-11-03 23:23:15 +03:00
|
|
|
NS_ASSERTION(nsnull != mStyleContext, "null style context");
|
1999-03-25 09:43:38 +03:00
|
|
|
|
|
|
|
nsresult result = NS_COMFALSE;
|
|
|
|
|
1998-11-03 23:23:15 +03:00
|
|
|
if (nsnull != mStyleContext) {
|
|
|
|
nsIAtom* pseudoTag = nsnull;
|
|
|
|
mStyleContext->GetPseudoType(pseudoTag);
|
|
|
|
nsIStyleContext* newContext;
|
|
|
|
if (nsnull != pseudoTag) {
|
1999-03-25 09:43:38 +03:00
|
|
|
result = aPresContext->ResolvePseudoStyleContextFor(mContent, pseudoTag,
|
|
|
|
aParentContext,
|
|
|
|
PR_FALSE, &newContext);
|
1998-11-03 23:23:15 +03:00
|
|
|
}
|
|
|
|
else {
|
1999-03-25 09:43:38 +03:00
|
|
|
result = aPresContext->ResolveStyleContextFor(mContent, aParentContext,
|
|
|
|
PR_FALSE, &newContext);
|
1998-11-03 23:23:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(nsnull != newContext, "failed to get new style context");
|
|
|
|
if (nsnull != newContext) {
|
|
|
|
if (newContext != mStyleContext) {
|
1999-03-25 09:43:38 +03:00
|
|
|
nsIStyleContext* oldContext = mStyleContext;
|
1998-11-03 23:23:15 +03:00
|
|
|
mStyleContext = newContext;
|
1999-03-25 09:43:38 +03:00
|
|
|
result = DidSetStyleContext(aPresContext);
|
|
|
|
CaptureStyleChangeFor(this, oldContext, newContext,
|
|
|
|
aParentChange, aChangeList, aLocalChange);
|
|
|
|
NS_RELEASE(oldContext);
|
1998-11-03 23:23:15 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_RELEASE(newContext);
|
1999-03-25 09:43:38 +03:00
|
|
|
result = NS_COMFALSE;
|
1998-11-03 23:23:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-03-25 09:43:38 +03:00
|
|
|
return result;
|
1998-11-03 23:23:15 +03:00
|
|
|
}
|
|
|
|
|
1999-01-14 08:16:23 +03:00
|
|
|
// Geometric parent member functions
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-02-10 04:36:30 +03:00
|
|
|
NS_IMETHODIMP nsFrame::GetParent(nsIFrame** aParent) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-10 04:36:30 +03:00
|
|
|
NS_PRECONDITION(nsnull != aParent, "null OUT parameter pointer");
|
|
|
|
*aParent = mParent;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-01-14 08:16:23 +03:00
|
|
|
NS_IMETHODIMP nsFrame::SetParent(const nsIFrame* aParent)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-14 08:16:23 +03:00
|
|
|
mParent = (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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-17 00:09:32 +04:00
|
|
|
if (nsnull != mView) {
|
|
|
|
// If we should keep the view position and size in sync with the frame
|
|
|
|
// then position the view. Don't do this if we're in the middle of reflow.
|
|
|
|
// Instead wait until the DidReflow() notification
|
|
|
|
if (NS_FRAME_SYNC_FRAME_AND_VIEW == (mState & (NS_FRAME_IN_REFLOW |
|
|
|
|
NS_FRAME_SYNC_FRAME_AND_VIEW))) {
|
|
|
|
// Position view relative to its parent, not relative to our
|
|
|
|
// parent frame (our parent frame may not have a view).
|
|
|
|
nsIView* parentWithView;
|
|
|
|
nsPoint origin;
|
1999-02-10 08:38:18 +03:00
|
|
|
GetOffsetFromView(origin, &parentWithView);
|
1998-10-17 00:09:32 +04:00
|
|
|
nsIViewManager *vm;
|
|
|
|
mView->GetViewManager(vm);
|
|
|
|
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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-17 00:09:32 +04:00
|
|
|
if (nsnull != mView) {
|
|
|
|
// If we should keep the view position and size in sync with the frame
|
|
|
|
// then resize the view. Don't do this if we're in the middle of reflow.
|
|
|
|
// Instead wait until the DidReflow() notification
|
|
|
|
if (NS_FRAME_SYNC_FRAME_AND_VIEW == (mState & (NS_FRAME_IN_REFLOW |
|
|
|
|
NS_FRAME_SYNC_FRAME_AND_VIEW))) {
|
|
|
|
// Resize the view to be the same size as the frame
|
|
|
|
nsIViewManager *vm;
|
|
|
|
mView->GetViewManager(vm);
|
|
|
|
vm->ResizeView(mView, aWidth, aHeight);
|
|
|
|
NS_RELEASE(vm);
|
|
|
|
}
|
1998-05-07 20:13:09 +04:00
|
|
|
}
|
1998-10-17 00:09:32 +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-11-09 22:59:33 +03:00
|
|
|
NS_IMETHODIMP
|
1999-02-10 05:25:01 +03:00
|
|
|
nsFrame::GetAdditionalChildListName(PRInt32 aIndex, nsIAtom** aListName) const
|
1998-11-09 22:59:33 +03:00
|
|
|
{
|
1999-02-10 05:25:01 +03:00
|
|
|
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
|
1998-11-09 22:59:33 +03:00
|
|
|
NS_PRECONDITION(aIndex >= 0, "invalid index number");
|
1999-02-10 05:25:01 +03:00
|
|
|
*aListName = nsnull;
|
1998-11-09 22:59:33 +03:00
|
|
|
return aIndex < 0 ? NS_ERROR_INVALID_ARG : NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-10 05:25:01 +03:00
|
|
|
NS_IMETHODIMP nsFrame::FirstChild(nsIAtom* aListName, nsIFrame** aFirstChild) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-10 05:25:01 +03:00
|
|
|
*aFirstChild = nsnull;
|
1998-11-09 22:40:27 +03:00
|
|
|
return nsnull == aListName ? NS_OK : NS_ERROR_INVALID_ARG;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
PRBool
|
|
|
|
nsFrame::DisplaySelection(nsIPresContext& aPresContext, PRBool isOkToTurnOn)
|
1998-08-04 03:39:16 +04:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
|
1999-02-12 21:41:26 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && shell) {
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
rv = shell->GetDocument(getter_AddRefs(doc));
|
1999-02-12 21:41:26 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && doc) {
|
1998-08-04 03:39:16 +04:00
|
|
|
result = doc->GetDisplaySelection();
|
|
|
|
if (isOkToTurnOn && !result) {
|
|
|
|
doc->SetDisplaySelection(PR_TRUE);
|
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-02-12 20:45:58 +03:00
|
|
|
|
1998-07-27 22:05:35 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-04-10 21:32:22 +04:00
|
|
|
void
|
|
|
|
nsFrame::SetClipRect(nsIRenderingContext& aRenderingContext)
|
|
|
|
{
|
|
|
|
PRBool clipState;
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) display);
|
|
|
|
|
|
|
|
// Start with the auto version of the clip rect. Then overlay on top
|
|
|
|
// of it specific offsets.
|
|
|
|
nscoord top = 0;
|
|
|
|
nscoord right = mRect.width;
|
|
|
|
nscoord bottom = mRect.height;
|
|
|
|
nscoord left = 0;
|
|
|
|
if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) {
|
|
|
|
top += display->mClip.top;
|
|
|
|
}
|
|
|
|
if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) {
|
1999-07-06 00:38:14 +04:00
|
|
|
right -= display->mClip.right;
|
1999-04-10 21:32:22 +04:00
|
|
|
}
|
|
|
|
if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) {
|
1999-07-06 00:38:14 +04:00
|
|
|
bottom -= display->mClip.bottom;
|
1999-04-10 21:32:22 +04:00
|
|
|
}
|
|
|
|
if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) {
|
|
|
|
left += display->mClip.left;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set updated clip-rect into the rendering context
|
1999-07-06 00:38:14 +04:00
|
|
|
nsRect clipRect(left, top, right - left, bottom - top);
|
1999-04-10 21:32:22 +04:00
|
|
|
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
|
|
|
|
}
|
|
|
|
|
1998-12-18 18:54:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
|
|
|
{
|
1999-05-20 04:52:00 +04:00
|
|
|
//if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
1999-05-17 04:21:18 +04:00
|
|
|
/** GetDocument
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
nsresult result;
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
result = aPresContext.GetShell(getter_AddRefs(shell));
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
PRBool displaySelection;
|
1999-08-26 02:19:23 +04:00
|
|
|
//result = shell->GetDisplayNonTextSelection(&displaySelection);
|
|
|
|
//if (NS_FAILED(result))
|
|
|
|
//return result;
|
|
|
|
displaySelection = PR_TRUE;
|
1999-05-17 04:21:18 +04:00
|
|
|
if (!displaySelection)
|
1998-12-18 18:54:23 +03:00
|
|
|
return NS_OK;
|
1999-05-17 04:21:18 +04:00
|
|
|
if (mContent) {
|
|
|
|
result = mContent->GetDocument(*getter_AddRefs(doc));
|
|
|
|
}
|
|
|
|
if (!doc || NS_FAILED(result)) {
|
|
|
|
if (NS_SUCCEEDED(result) && shell) {
|
|
|
|
result = shell->GetDocument(getter_AddRefs(doc));
|
|
|
|
}
|
1998-12-18 18:54:23 +03:00
|
|
|
}
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1999-05-17 04:21:18 +04:00
|
|
|
displaySelection = doc->GetDisplaySelection();
|
1999-04-26 08:02:04 +04:00
|
|
|
nsFrameState frameState;
|
|
|
|
PRBool isSelected;
|
|
|
|
GetFrameState(&frameState);
|
|
|
|
isSelected = (frameState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
1999-07-06 00:38:14 +04:00
|
|
|
// PRInt32 selectionStartOffset = 0;//frame coordinates
|
|
|
|
// PRInt32 selectionEndOffset = 0;//frame coordinates
|
1999-05-17 04:21:18 +04:00
|
|
|
|
|
|
|
if (!displaySelection || !isSelected)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMSelection> selection;
|
|
|
|
nsCOMPtr<nsIFrameSelection> frameSelection;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> newContent;
|
|
|
|
result = mContent->GetParent(*getter_AddRefs(newContent));
|
1999-07-15 22:19:03 +04:00
|
|
|
|
|
|
|
SelectionDetails *details;
|
1999-05-17 04:21:18 +04:00
|
|
|
PRInt32 offset;
|
|
|
|
if (NS_SUCCEEDED(result) && newContent){
|
1999-09-01 05:02:16 +04:00
|
|
|
result = newContent->IndexOf(mContent, offset);
|
1999-05-17 04:21:18 +04:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
{
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
1999-04-26 08:02:04 +04:00
|
|
|
|
1999-05-17 04:21:18 +04:00
|
|
|
if (NS_SUCCEEDED(result) && shell){
|
1999-07-18 06:27:19 +04:00
|
|
|
result = shell->GetFrameSelection(getter_AddRefs(frameSelection));
|
|
|
|
if (NS_SUCCEEDED(result) && frameSelection){
|
|
|
|
result = frameSelection->LookUpSelection(newContent, offset,
|
|
|
|
1, &details);// last param notused
|
1999-05-17 04:21:18 +04:00
|
|
|
}
|
1998-12-18 18:54:23 +03:00
|
|
|
}
|
1999-05-20 04:52:00 +04:00
|
|
|
//}
|
1999-07-15 22:19:03 +04:00
|
|
|
if (details)
|
1999-05-17 04:21:18 +04:00
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
GetRect(rect);
|
|
|
|
rect.width-=2;
|
|
|
|
rect.height-=2;
|
|
|
|
rect.x++;
|
|
|
|
rect.y++;
|
|
|
|
aRenderingContext.SetColor(NS_RGB(0,0,255));
|
|
|
|
nsRect drawrect(1, 1, rect.width, rect.height);
|
|
|
|
aRenderingContext.DrawRect(drawrect );
|
1999-07-15 22:19:03 +04:00
|
|
|
SelectionDetails *deletingDetails = details;
|
1999-09-01 05:02:16 +04:00
|
|
|
while((deletingDetails = details->mNext)){
|
1999-07-15 22:19:03 +04:00
|
|
|
delete details;
|
|
|
|
details = deletingDetails;
|
|
|
|
}
|
|
|
|
delete details;
|
1999-05-17 04:21:18 +04:00
|
|
|
//aRenderingContext.DrawLine(rect.x, rect.y, rect.XMost(), rect.YMost());
|
|
|
|
//aRenderingContext.DrawLine(rect.x, rect.YMost(), rect.XMost(), rect.y);
|
1998-05-08 22:33:42 +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-12-18 18:54:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::HandleEvent(nsIPresContext& aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus& aEventStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-11-18 08:25:26 +03:00
|
|
|
if (nsEventStatus_eConsumeNoDefault == aEventStatus) {
|
|
|
|
return NS_OK;
|
1998-06-24 01:53:02 +04:00
|
|
|
}
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1999-05-08 01:12:59 +04:00
|
|
|
/*i have no idea why this is here keeping incase..
|
1998-08-04 03:39:16 +04:00
|
|
|
if (DisplaySelection(aPresContext) == PR_FALSE) {
|
|
|
|
if (aEvent->message != NS_MOUSE_LEFT_BUTTON_DOWN) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
1999-05-08 01:12:59 +04:00
|
|
|
*/
|
|
|
|
if (aEvent->message == NS_MOUSE_MOVE) {
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
|
|
|
|
if (NS_SUCCEEDED(rv)){
|
1999-07-18 06:27:19 +04:00
|
|
|
nsCOMPtr<nsIFrameSelection> frameselection;
|
|
|
|
if (NS_SUCCEEDED(shell->GetFrameSelection(getter_AddRefs(frameselection))) && frameselection){
|
1999-05-08 01:12:59 +04:00
|
|
|
PRBool mouseDown = PR_FALSE;
|
1999-05-27 01:08:14 +04:00
|
|
|
if (NS_SUCCEEDED(frameselection->GetMouseDownState(&mouseDown)) && mouseDown) {
|
|
|
|
|
|
|
|
#if NORMAL_DRAG_HANDLING
|
1999-05-08 01:12:59 +04:00
|
|
|
HandleDrag(aPresContext, aEvent, aEventStatus);
|
1999-05-27 01:08:14 +04:00
|
|
|
#else
|
|
|
|
nsIDragService* dragService;
|
|
|
|
nsresult rv = nsServiceManager::GetService(kCDragServiceCID,
|
|
|
|
nsIDragService::GetIID(),
|
|
|
|
(nsISupports **)&dragService);
|
|
|
|
if (NS_OK == rv) {
|
|
|
|
nsCOMPtr<nsITransferable> trans;
|
|
|
|
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull,
|
|
|
|
nsITransferable::GetIID(), getter_AddRefs(trans));
|
|
|
|
nsCOMPtr<nsITransferable> trans2;
|
|
|
|
rv = nsComponentManager::CreateInstance(kCTransferableCID, nsnull,
|
|
|
|
nsITransferable::GetIID(), getter_AddRefs(trans2));
|
|
|
|
if ( trans && trans2 ) {
|
1999-06-08 00:43:23 +04:00
|
|
|
nsString textPlainFlavor ( "text/plain" );
|
|
|
|
trans->AddDataFlavor(&textPlainFlavor);
|
1999-05-27 01:08:14 +04:00
|
|
|
nsString dragText = "Drag Text";
|
|
|
|
PRUint32 len = 9;
|
1999-06-22 03:19:54 +04:00
|
|
|
trans->SetTransferData(&textPlainFlavor, dragText.ToNewCString(), len); // transferable consumes the data
|
1999-05-27 01:08:14 +04:00
|
|
|
|
1999-06-08 00:43:23 +04:00
|
|
|
trans2->AddDataFlavor(&textPlainFlavor);
|
1999-05-27 01:08:14 +04:00
|
|
|
nsString dragText2 = "More Drag Text";
|
|
|
|
len = 14;
|
1999-06-22 03:19:54 +04:00
|
|
|
trans2->SetTransferData(&textPlainFlavor, dragText2.ToNewCString(), len); // transferable consumes the data
|
1999-05-27 01:08:14 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsArray> items;
|
|
|
|
NS_NewISupportsArray(getter_AddRefs(items));
|
|
|
|
if ( items ) {
|
|
|
|
items->AppendElement(trans);
|
|
|
|
items->AppendElement(trans2);
|
|
|
|
dragService->InvokeDragSession(items, nsnull, nsIDragService::DRAGDROP_ACTION_COPY | nsIDragService::DRAGDROP_ACTION_MOVE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nsServiceManager::ReleaseService(kCDragServiceCID, dragService);
|
|
|
|
}
|
|
|
|
//---------------------------------------------------
|
|
|
|
#endif
|
|
|
|
|
1999-05-08 01:12:59 +04:00
|
|
|
}
|
1998-06-08 04:57:15 +04:00
|
|
|
}
|
|
|
|
}
|
1999-05-08 01:12:59 +04:00
|
|
|
}
|
|
|
|
else if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {
|
|
|
|
HandlePress(aPresContext, aEvent, aEventStatus);
|
1998-04-27 20:44:52 +04:00
|
|
|
}
|
1999-05-17 04:21:18 +04:00
|
|
|
else if (aEvent->message == NS_MOUSE_LEFT_DOUBLECLICK) {
|
|
|
|
HandleMultiplePress(aPresContext, aEvent, aEventStatus);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::HandlePress(nsIPresContext& aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus& aEventStatus)
|
1998-04-27 20:44:52 +04:00
|
|
|
{
|
1999-04-30 00:24:21 +04:00
|
|
|
if (!DisplaySelection(aPresContext)) {
|
1998-07-27 22:05:35 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
|
1999-02-12 21:41:26 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && shell) {
|
1999-06-08 06:19:26 +04:00
|
|
|
nsInputEvent *inputEvent = (nsInputEvent *)aEvent;
|
|
|
|
PRInt32 startPos = 0;
|
1999-07-06 00:38:14 +04:00
|
|
|
// PRUint32 contentOffset = 0;
|
1999-06-08 06:19:26 +04:00
|
|
|
PRInt32 contentOffsetEnd = 0;
|
|
|
|
nsCOMPtr<nsIContent> newContent;
|
1999-06-11 01:08:17 +04:00
|
|
|
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x, getter_AddRefs(newContent),
|
|
|
|
startPos, contentOffsetEnd))){
|
1999-07-18 06:27:19 +04:00
|
|
|
nsCOMPtr<nsIFrameSelection> frameselection;
|
|
|
|
if (NS_SUCCEEDED(shell->GetFrameSelection(getter_AddRefs(frameselection))) && frameselection){
|
|
|
|
frameselection->SetMouseDownState(PR_TRUE);//not important if it fails here
|
|
|
|
frameselection->TakeFocus(newContent, startPos , contentOffsetEnd , inputEvent->isShift, inputEvent->isControl);
|
1998-12-14 21:34:14 +03:00
|
|
|
}
|
1999-06-08 06:19:26 +04:00
|
|
|
//no release
|
1998-12-14 21:34:14 +03:00
|
|
|
}
|
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-05-17 04:21:18 +04:00
|
|
|
/**
|
|
|
|
* Handles the Multiple Mouse Press Event for the frame
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::HandleMultiplePress(nsIPresContext& aPresContext,
|
|
|
|
nsGUIEvent* aEvent,
|
|
|
|
nsEventStatus& aEventStatus)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
|
1998-04-27 20:44:52 +04:00
|
|
|
nsGUIEvent* aEvent,
|
1998-08-28 19:58:37 +04:00
|
|
|
nsEventStatus& aEventStatus)
|
1998-04-27 20:44:52 +04:00
|
|
|
{
|
1999-04-30 00:24:21 +04:00
|
|
|
if (!DisplaySelection(aPresContext)) {
|
1998-12-14 21:34:14 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-06-22 00:31:30 +04:00
|
|
|
// printf("handledrag %x\n",this);
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
|
1999-02-12 21:41:26 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && shell) {
|
1999-06-08 06:19:26 +04:00
|
|
|
PRInt32 startPos = 0;
|
|
|
|
PRInt32 contentOffsetEnd = 0;
|
|
|
|
nsCOMPtr<nsIContent> newContent;
|
1999-06-11 01:08:17 +04:00
|
|
|
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x, getter_AddRefs(newContent),
|
|
|
|
startPos, contentOffsetEnd))){
|
1999-07-18 06:27:19 +04:00
|
|
|
nsCOMPtr<nsIFrameSelection> frameselection;
|
|
|
|
if (NS_SUCCEEDED(shell->GetFrameSelection(getter_AddRefs(frameselection))) && frameselection){
|
|
|
|
frameselection->TakeFocus(newContent, startPos, contentOffsetEnd , PR_TRUE, PR_FALSE); //TRUE IS THE DIFFERENCE for continue selection
|
1998-12-14 21:34:14 +03:00
|
|
|
}
|
1999-06-08 06:19:26 +04:00
|
|
|
//no release
|
1998-12-14 21:34:14 +03:00
|
|
|
}
|
|
|
|
}
|
1998-04-27 20:44:52 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext& aPresContext,
|
1998-04-27 20:44:52 +04:00
|
|
|
nsGUIEvent* aEvent,
|
1998-08-28 19:58:37 +04:00
|
|
|
nsEventStatus& aEventStatus)
|
1998-04-27 20:44:52 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-05-08 22:33:42 +04:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//-- GetPosition
|
|
|
|
//--------------------------------------------------------------------------
|
1999-06-11 01:08:17 +04:00
|
|
|
NS_IMETHODIMP nsFrame::GetPosition(nsIPresContext& aCX,
|
|
|
|
nscoord aXCoord,
|
|
|
|
nsIContent ** aNewContent,
|
|
|
|
PRInt32& aContentOffset,
|
|
|
|
PRInt32& aContentOffsetEnd)
|
1999-05-17 04:21:18 +04:00
|
|
|
{
|
|
|
|
//default getposition will return parent as newcontent
|
|
|
|
//also aActualContentOffset will be 0
|
|
|
|
// aOffset and aOffsetEnd will be 1 value apart
|
|
|
|
// aNewFrame is not used nor is aEvent, aRendContent, nor aPresContext
|
|
|
|
if (!aNewContent || !mContent)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
nsresult result;
|
1999-08-25 01:51:47 +04:00
|
|
|
|
|
|
|
//traverse through children and look for the best one to give this to
|
|
|
|
//if it fails the getposition call, make it yourself// also only look at primary list
|
|
|
|
nsIFrame *kid;
|
|
|
|
nsIFrame *closestFrame = nsnull;
|
|
|
|
nsresult rv = FirstChild(nsnull, &kid);
|
|
|
|
if (NS_SUCCEEDED(rv) && nsnull != kid) {
|
|
|
|
PRInt32 closestDistance = 999999; //some HUGE number that will always fail first comparison
|
|
|
|
while (nsnull != kid) {
|
|
|
|
nsRect rect;
|
|
|
|
kid->GetRect(rect);
|
|
|
|
nsPoint offsetPoint; //used for offset of result frame
|
|
|
|
nsIView * view; //used for call of get offset from view
|
|
|
|
kid->GetOffsetFromView(offsetPoint, &view);
|
|
|
|
rect.x = offsetPoint.x;
|
|
|
|
rect.y = offsetPoint.y;
|
|
|
|
if (rect.x <= aXCoord && (rect.x+rect.width) >= aXCoord)
|
|
|
|
{
|
|
|
|
closestFrame = kid;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 distance = PR_MIN(abs(rect.x - aXCoord),abs((rect.x + rect.width) - aXCoord));
|
|
|
|
if (distance < closestDistance)
|
|
|
|
{
|
|
|
|
closestDistance = distance;
|
|
|
|
closestFrame = kid;
|
|
|
|
}
|
|
|
|
else if (distance > closestDistance)
|
|
|
|
break;//done
|
|
|
|
|
|
|
|
kid->GetNextSibling(&kid);
|
|
|
|
}
|
|
|
|
if (closestFrame)
|
|
|
|
return closestFrame->GetPosition(aCX,aXCoord,aNewContent,aContentOffset,aContentOffsetEnd);
|
|
|
|
}
|
1999-05-17 04:21:18 +04:00
|
|
|
result = mContent->GetParent(*aNewContent);
|
|
|
|
|
|
|
|
if (*aNewContent){
|
1999-07-06 00:38:14 +04:00
|
|
|
result = (*aNewContent)->IndexOf(mContent, aContentOffset);
|
1999-05-17 04:21:18 +04:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
{
|
|
|
|
return result;
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
1999-06-11 01:08:17 +04:00
|
|
|
aContentOffsetEnd = aContentOffset +1;
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
1999-07-15 22:19:03 +04:00
|
|
|
return result;
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
|
|
|
|
1998-04-27 20:44:52 +04:00
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
1998-11-24 01:20:50 +03:00
|
|
|
nsFrame::GetCursor(nsIPresContext& aPresContext,
|
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-11-18 08:25:26 +03:00
|
|
|
const nsStyleColor* styleColor;
|
|
|
|
GetStyleData(eStyleStruct_Color, (const nsStyleStruct*&)styleColor);
|
|
|
|
aCursor = styleColor->mCursor;
|
|
|
|
|
1999-01-14 08:16:23 +03:00
|
|
|
if ((NS_STYLE_CURSOR_AUTO == aCursor) && (nsnull != mParent)) {
|
|
|
|
mParent->GetCursor(aPresContext, aPoint, aCursor);
|
1998-11-18 05:11:54 +03:00
|
|
|
}
|
1998-11-18 08:25:26 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame)
|
|
|
|
{
|
|
|
|
*aFrame = this;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Resize and incremental reflow
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-10 07:17:06 +03:00
|
|
|
nsFrame::GetFrameState(nsFrameState* aResult)
|
1998-05-14 04:47:32 +04:00
|
|
|
{
|
1999-02-10 07:17:06 +03:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null OUT parameter pointer");
|
|
|
|
*aResult = mState;
|
1998-05-14 04:47:32 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP
|
1998-05-14 04:47:32 +04:00
|
|
|
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
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP
|
1998-05-14 04:47:32 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP
|
1998-05-14 04:47:32 +04:00
|
|
|
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) {
|
1999-07-22 03:47:01 +04:00
|
|
|
mState &= ~(NS_FRAME_IN_REFLOW | NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY);
|
1998-05-29 01:55:13 +04:00
|
|
|
|
1998-10-17 00:09:32 +04:00
|
|
|
// Size and position the view if requested
|
|
|
|
if ((nsnull != mView) && (NS_FRAME_SYNC_FRAME_AND_VIEW & mState)) {
|
1998-05-29 01:55:13 +04:00
|
|
|
// 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;
|
1999-02-10 08:38:18 +03:00
|
|
|
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);
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
// Clip applies to block-level and replaced elements with overflow
|
|
|
|
// set to other than 'visible'
|
|
|
|
const nsStyleDisplay* display =
|
|
|
|
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
if (display->IsBlockLevel()) {
|
|
|
|
if (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN) {
|
|
|
|
nscoord left, top, right, bottom;
|
|
|
|
|
|
|
|
// Start with the 'auto' values and then factor in user
|
|
|
|
// specified values
|
|
|
|
left = top = 0;
|
|
|
|
right = mRect.width;
|
|
|
|
bottom = mRect.height;
|
|
|
|
|
|
|
|
if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) {
|
|
|
|
top += display->mClip.top;
|
|
|
|
}
|
|
|
|
if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) {
|
|
|
|
right -= display->mClip.right;
|
|
|
|
}
|
|
|
|
if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) {
|
|
|
|
bottom -= display->mClip.bottom;
|
|
|
|
}
|
|
|
|
if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) {
|
|
|
|
left += display->mClip.left;
|
|
|
|
}
|
|
|
|
mView->SetClip(left, top, right, bottom);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Make sure no clip is set
|
|
|
|
mView->SetClip(0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
1998-06-03 02:04:54 +04:00
|
|
|
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-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
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-10-01 08:46:11 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::FindTextRuns(nsLineLayout& aLineLayout)
|
|
|
|
{
|
|
|
|
aLineLayout.EndTextRun();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-27 19:51:21 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::AdjustFrameSize(nscoord aExtraSpace, nscoord& aUsedSpace)
|
|
|
|
{
|
|
|
|
aUsedSpace = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-04-20 04:26:32 +04:00
|
|
|
nsFrame::TrimTrailingWhiteSpace(nsIPresContext* aPresContext,
|
1998-10-27 19:51:21 +03:00
|
|
|
nsIRenderingContext& aRC,
|
|
|
|
nscoord& aDeltaWidth)
|
1998-05-08 08:45:37 +04:00
|
|
|
{
|
1998-10-27 19:51:21 +03:00
|
|
|
aDeltaWidth = 0;
|
1998-05-08 08:45:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-31 01:11:47 +03:00
|
|
|
NS_IMETHODIMP
|
1999-04-20 04:26:32 +04:00
|
|
|
nsFrame::MoveInSpaceManager(nsIPresContext* aPresContext,
|
1998-10-31 01:11:47 +03:00
|
|
|
nsISpaceManager* aSpaceManager,
|
|
|
|
nscoord aDeltaX, nscoord aDeltaY)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-27 19:51:21 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::ContentChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
nsISupports* aSubContent)
|
|
|
|
{
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
|
1999-02-12 21:41:26 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && shell) {
|
1999-02-12 20:45:58 +03:00
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, this,
|
|
|
|
nsIReflowCommand::ContentChanged);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
shell->AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
1999-01-23 02:07:09 +03:00
|
|
|
}
|
1999-02-12 20:45:58 +03:00
|
|
|
return rv;
|
1998-10-27 19:51:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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
|
|
|
}
|
|
|
|
|
1999-02-24 07:48:08 +03:00
|
|
|
NS_IMETHODIMP nsFrame::GetPrevInFlow(nsIFrame** aPrevInFlow) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-24 07:48:08 +03:00
|
|
|
*aPrevInFlow = nsnull;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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
|
|
|
}
|
|
|
|
|
1999-02-24 07:48:08 +03:00
|
|
|
NS_IMETHODIMP nsFrame::GetNextInFlow(nsIFrame** aNextInFlow) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-24 07:48:08 +03:00
|
|
|
*aNextInFlow = nsnull;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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
|
1999-02-10 08:38:18 +03:00
|
|
|
NS_IMETHODIMP nsFrame::GetView(nsIView** aView) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-10 08:38:18 +03:00
|
|
|
NS_PRECONDITION(nsnull != aView, "null OUT parameter pointer");
|
|
|
|
*aView = mView;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP 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
|
1999-02-10 08:38:18 +03:00
|
|
|
NS_IMETHODIMP nsFrame::GetParentWithView(nsIFrame** aParent) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-10 08:38:18 +03:00
|
|
|
NS_PRECONDITION(nsnull != aParent, "null OUT parameter pointer");
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-02-10 08:38:18 +03:00
|
|
|
nsIFrame* parent;
|
|
|
|
for (parent = mParent; nsnull != parent; parent->GetParent(&parent)) {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIView* parView;
|
|
|
|
|
1999-02-10 08:38:18 +03:00
|
|
|
parent->GetView(&parView);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull != parView) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-10 08:38:18 +03:00
|
|
|
*aParent = parent;
|
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
|
1999-02-10 08:38:18 +03:00
|
|
|
NS_IMETHODIMP nsFrame::GetOffsetFromView(nsPoint& aOffset, nsIView** aView) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-10 08:38:18 +03:00
|
|
|
NS_PRECONDITION(nsnull != aView, "null OUT parameter pointer");
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* frame = (nsIFrame*)this;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-02-10 08:38:18 +03: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;
|
1999-02-10 04:36:30 +03:00
|
|
|
frame->GetParent(&frame);
|
1998-04-17 05:41:24 +04:00
|
|
|
if (nsnull != frame) {
|
|
|
|
frame->GetView(aView);
|
|
|
|
}
|
1999-02-10 08:38:18 +03:00
|
|
|
} while ((nsnull != frame) && (nsnull == *aView));
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-10 08:38:18 +03:00
|
|
|
NS_IMETHODIMP nsFrame::GetWindow(nsIWidget** aWindow) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-10 08:38:18 +03:00
|
|
|
NS_PRECONDITION(nsnull != aWindow, "null OUT parameter pointer");
|
|
|
|
|
|
|
|
nsIFrame* frame;
|
|
|
|
nsIWidget* window = nsnull;
|
|
|
|
for (frame = (nsIFrame*)this; nsnull != frame; frame->GetParentWithView(&frame)) {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIView* view;
|
|
|
|
|
1999-02-10 08:38:18 +03:00
|
|
|
frame->GetView(&view);
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull != view) {
|
1999-02-10 08:38:18 +03:00
|
|
|
view->GetWidget(window);
|
|
|
|
if (nsnull != window) {
|
1998-04-17 05:41:24 +04:00
|
|
|
break;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-02-10 08:38:18 +03:00
|
|
|
NS_POSTCONDITION(nsnull != window, "no window in frame tree");
|
|
|
|
*aWindow = window;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-09 08:44:13 +03:00
|
|
|
NS_IMETHODIMP
|
1999-02-10 07:17:06 +03:00
|
|
|
nsFrame::GetFrameType(nsIAtom** aType) const
|
1999-02-09 08:44:13 +03:00
|
|
|
{
|
1999-02-10 07:17:06 +03:00
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsnull;
|
1999-02-09 08:44:13 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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;
|
1999-08-19 18:36:47 +04:00
|
|
|
nsRect damageRect(aDamageRect);
|
|
|
|
|
|
|
|
// Checks to see if the damaged rect should be infalted
|
|
|
|
// to include the outline
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
|
|
|
|
nscoord width;
|
|
|
|
spacing->GetOutlineWidth(width);
|
|
|
|
if (width > 0) {
|
|
|
|
damageRect.Inflate(width, width);
|
|
|
|
}
|
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);
|
1999-08-19 18:36:47 +04:00
|
|
|
viewManager->UpdateView(mView, damageRect, flags);
|
1998-06-02 09:28:11 +04:00
|
|
|
|
|
|
|
} else {
|
1999-08-19 18:36:47 +04:00
|
|
|
nsRect rect(damageRect);
|
1998-08-08 08:23:33 +04:00
|
|
|
nsPoint offset;
|
|
|
|
nsIView* view;
|
1998-06-02 09:28:11 +04:00
|
|
|
|
1999-02-10 08:38:18 +03:00
|
|
|
GetOffsetFromView(offset, &view);
|
1998-08-08 08:23:33 +04:00
|
|
|
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
|
|
|
|
1999-08-28 01:48:06 +04:00
|
|
|
#define MAX_REFLOW_DEPTH 500
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsFrame::IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics)
|
|
|
|
{
|
|
|
|
if (aReflowState.mReflowDepth > MAX_REFLOW_DEPTH) {
|
|
|
|
mState |= NS_FRAME_IS_UNFLOWABLE;
|
|
|
|
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
|
|
|
|
aMetrics.width = 0;
|
|
|
|
aMetrics.height = 0;
|
|
|
|
aMetrics.ascent = 0;
|
|
|
|
aMetrics.descent = 0;
|
|
|
|
aMetrics.mCarriedOutBottomMargin = 0;
|
|
|
|
aMetrics.mCombinedArea.x = 0;
|
|
|
|
aMetrics.mCombinedArea.y = 0;
|
|
|
|
aMetrics.mCombinedArea.width = 0;
|
|
|
|
aMetrics.mCombinedArea.height = 0;
|
|
|
|
if (aMetrics.maxElementSize) {
|
|
|
|
aMetrics.maxElementSize->width = 0;
|
|
|
|
aMetrics.maxElementSize->height = 0;
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
mState &= ~NS_FRAME_IS_UNFLOWABLE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-05-14 02:38:09 +04:00
|
|
|
// Style sizing methods
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP nsFrame::IsPercentageBase(PRBool& aBase) const
|
1998-05-14 02:38:09 +04:00
|
|
|
{
|
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) ||
|
1999-01-13 09:37:31 +03:00
|
|
|
(display->mDisplay == NS_STYLE_DISPLAY_LIST_ITEM) ||
|
|
|
|
(display->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL)) {
|
1998-05-14 02:38:09 +04:00
|
|
|
aBase = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aBase = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Sibling pointer used to link together frames
|
|
|
|
|
1999-02-10 09:13:38 +03:00
|
|
|
NS_IMETHODIMP nsFrame::GetNextSibling(nsIFrame** aNextSibling) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-10 09:13:38 +03:00
|
|
|
NS_PRECONDITION(nsnull != aNextSibling, "null OUT parameter pointer");
|
|
|
|
*aNextSibling = mNextSibling;
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP nsFrame::SetNextSibling(nsIFrame* aNextSibling)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-02-01 20:31:10 +03:00
|
|
|
NS_ASSERTION(aNextSibling != this, "attempt to create circular frame list");
|
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-10-10 03:46:02 +04:00
|
|
|
NS_IMETHODIMP nsFrame::Scrolled(nsIView *aView)
|
1998-09-06 00:57:57 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-09 00:35:16 +04:00
|
|
|
PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsIContent* content;
|
|
|
|
PRInt32 result = -1;
|
|
|
|
|
1999-02-10 03:42:56 +03:00
|
|
|
aFrame->GetContent(&content);
|
1998-10-09 00:35:16 +04:00
|
|
|
if (nsnull != content) {
|
|
|
|
nsIContent* parentContent;
|
|
|
|
|
|
|
|
content->GetParent(parentContent);
|
|
|
|
if (nsnull != parentContent) {
|
|
|
|
parentContent->IndexOf(content, result);
|
|
|
|
NS_RELEASE(parentContent);
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Debugging
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
1999-01-16 03:00:50 +03:00
|
|
|
nsFrame::List(FILE* out, PRInt32 aIndent) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-01-16 03:00:50 +03:00
|
|
|
IndentBy(out, aIndent);
|
|
|
|
ListTag(out);
|
|
|
|
if (nsnull != mView) {
|
|
|
|
fprintf(out, " [view=%p]", mView);
|
|
|
|
}
|
1999-03-05 07:22:54 +03:00
|
|
|
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
|
1999-01-16 03:00:50 +03:00
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
1998-05-18 20:53:09 +04:00
|
|
|
}
|
1999-05-04 00:51:30 +04:00
|
|
|
fputs("\n", out);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("Frame", aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFrame::MakeFrameName(const char* aType, nsString& aResult) const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-11-19 20:22:29 +03:00
|
|
|
aResult = aType;
|
1998-11-13 02:03:35 +03:00
|
|
|
if (nsnull != mContent) {
|
|
|
|
nsIAtom* tag;
|
|
|
|
mContent->GetTag(tag);
|
1999-01-23 01:48:00 +03:00
|
|
|
if ((tag != nsnull) && (tag != nsLayoutAtoms::textTagName)) {
|
1998-11-19 21:51:53 +03:00
|
|
|
aResult.Append("(");
|
1998-11-13 02:03:35 +03:00
|
|
|
nsAutoString buf;
|
|
|
|
tag->ToString(buf);
|
1998-11-19 20:22:29 +03:00
|
|
|
aResult.Append(buf);
|
1998-11-13 02:03:35 +03:00
|
|
|
NS_RELEASE(tag);
|
1998-11-19 21:51:53 +03:00
|
|
|
aResult.Append(")");
|
1998-11-13 02:03:35 +03:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-11-19 20:22:29 +03:00
|
|
|
char buf[40];
|
1998-11-19 21:51:53 +03:00
|
|
|
PR_snprintf(buf, sizeof(buf), "(%d)", ContentIndexInContainer(this));
|
1998-11-19 20:22:29 +03:00
|
|
|
aResult.Append(buf);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-19 20:55:22 +03:00
|
|
|
void
|
|
|
|
nsFrame::XMLQuote(nsString& aString)
|
|
|
|
{
|
|
|
|
PRInt32 i, len = aString.Length();
|
|
|
|
for (i = 0; i < len; i++) {
|
1999-04-20 11:20:21 +04:00
|
|
|
PRUnichar ch = aString.CharAt(i);
|
1998-11-19 20:55:22 +03:00
|
|
|
if (ch == '<') {
|
|
|
|
nsAutoString tmp("<");
|
|
|
|
aString.Cut(i, 1);
|
|
|
|
aString.Insert(tmp, i);
|
|
|
|
len += 3;
|
|
|
|
i += 3;
|
|
|
|
}
|
|
|
|
else if (ch == '>') {
|
|
|
|
nsAutoString tmp(">");
|
|
|
|
aString.Cut(i, 1);
|
|
|
|
aString.Insert(tmp, i);
|
|
|
|
len += 3;
|
|
|
|
i += 3;
|
|
|
|
}
|
1999-02-04 19:28:36 +03:00
|
|
|
else if (ch == '\"') {
|
1998-11-19 20:55:22 +03:00
|
|
|
nsAutoString tmp(""");
|
|
|
|
aString.Cut(i, 1);
|
|
|
|
aString.Insert(tmp, i);
|
|
|
|
len += 5;
|
|
|
|
i += 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-02 03:04:13 +04:00
|
|
|
PRBool
|
|
|
|
nsFrame::ParentDisablesSelection() const
|
|
|
|
{
|
|
|
|
PRBool selected;
|
|
|
|
if (NS_FAILED(GetSelected(&selected)))
|
|
|
|
return PR_FALSE;
|
|
|
|
if (selected)
|
|
|
|
return PR_FALSE; //if this frame is selected and no one has overridden the selection from "higher up"
|
|
|
|
//then no one below us will be disabled by this frame.
|
|
|
|
nsIFrame* target;
|
|
|
|
GetParent(&target);
|
|
|
|
if (target)
|
|
|
|
return ((nsFrame *)target)->ParentDisablesSelection();
|
|
|
|
return PR_FALSE; //default this does not happen
|
|
|
|
}
|
|
|
|
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::DumpRegressionData(FILE* out, PRInt32 aIndent)
|
|
|
|
{
|
|
|
|
IndentBy(out, aIndent);
|
1999-02-08 20:56:00 +03:00
|
|
|
fprintf(out, "<frame va=\"%ld\" type=\"", PRUptrdiff(this));
|
1998-11-19 20:22:29 +03:00
|
|
|
nsAutoString name;
|
|
|
|
GetFrameName(name);
|
1998-11-19 20:55:22 +03:00
|
|
|
XMLQuote(name);
|
1998-11-19 20:22:29 +03:00
|
|
|
fputs(name, out);
|
1999-02-08 20:56:00 +03:00
|
|
|
fprintf(out, "\" state=\"%d\" parent=\"%ld\">\n",
|
|
|
|
mState, PRUptrdiff(mParent));
|
1998-11-19 20:22:29 +03:00
|
|
|
|
|
|
|
aIndent++;
|
|
|
|
DumpBaseRegressionData(out, aIndent);
|
|
|
|
aIndent--;
|
|
|
|
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fprintf(out, "</frame>\n");
|
1998-05-06 03:56:50 +04:00
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-11-19 20:22:29 +03:00
|
|
|
void
|
|
|
|
nsFrame::DumpBaseRegressionData(FILE* out, PRInt32 aIndent)
|
|
|
|
{
|
|
|
|
if (nsnull != mNextSibling) {
|
|
|
|
IndentBy(out, aIndent);
|
1999-02-08 20:56:00 +03:00
|
|
|
fprintf(out, "<next-sibling va=\"%ld\"/>\n", PRUptrdiff(mNextSibling));
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != mView) {
|
|
|
|
IndentBy(out, aIndent);
|
1999-02-08 20:56:00 +03:00
|
|
|
fprintf(out, "<view va=\"%ld\">\n", PRUptrdiff(mView));
|
1998-11-19 20:22:29 +03:00
|
|
|
aIndent++;
|
|
|
|
// XXX add in code to dump out view state too...
|
|
|
|
aIndent--;
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fprintf(out, "</view>\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
IndentBy(out, aIndent);
|
1999-02-08 20:56:00 +03:00
|
|
|
fprintf(out, "<bbox x=\"%d\" y=\"%d\" w=\"%d\" h=\"%d\"/>\n",
|
1998-11-19 20:22:29 +03:00
|
|
|
mRect.x, mRect.y, mRect.width, mRect.height);
|
|
|
|
|
|
|
|
// Now dump all of the children on all of the child lists
|
|
|
|
nsIFrame* kid;
|
|
|
|
nsIAtom* list = nsnull;
|
|
|
|
PRInt32 listIndex = 0;
|
|
|
|
do {
|
1999-02-10 05:25:01 +03:00
|
|
|
nsresult rv = FirstChild(list, &kid);
|
1998-11-19 20:22:29 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != kid)) {
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
if (nsnull != list) {
|
|
|
|
nsAutoString listName;
|
|
|
|
list->ToString(listName);
|
|
|
|
fprintf(out, "<child-list name=\"");
|
1998-11-19 20:55:22 +03:00
|
|
|
XMLQuote(listName);
|
1998-11-19 20:22:29 +03:00
|
|
|
fputs(listName, out);
|
|
|
|
fprintf(out, "\">\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(out, "<child-list>\n");
|
|
|
|
}
|
|
|
|
aIndent++;
|
|
|
|
while (nsnull != kid) {
|
|
|
|
kid->DumpRegressionData(out, aIndent);
|
1999-02-10 09:13:38 +03:00
|
|
|
kid->GetNextSibling(&kid);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
|
|
|
aIndent--;
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fprintf(out, "</child-list>\n");
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(list);
|
1999-02-10 05:25:01 +03:00
|
|
|
GetAdditionalChildListName(listIndex++, &list);
|
1998-11-19 20:22:29 +03:00
|
|
|
} while (nsnull != list);
|
|
|
|
}
|
|
|
|
|
1999-08-31 07:09:40 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 05:02:16 +04:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
*aResult = sizeof(*this);
|
|
|
|
#else
|
|
|
|
*aResult = 0;
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
|
|
|
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
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
|
|
|
|
1999-02-16 05:42:08 +03:00
|
|
|
/*this method may.. invalidate if the state was changed or if aForceRedraw is PR_TRUE
|
|
|
|
it will not update immediately.*/
|
1998-12-14 21:34:14 +03:00
|
|
|
NS_IMETHODIMP
|
1999-05-20 04:52:00 +04:00
|
|
|
nsFrame::SetSelected(nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread)
|
|
|
|
{
|
1999-06-02 03:04:13 +04:00
|
|
|
if (aSelected && ParentDisablesSelection())
|
|
|
|
return NS_OK;
|
1999-05-20 04:52:00 +04:00
|
|
|
if (eSpreadDown == aSpread){
|
|
|
|
nsIFrame* kid;
|
|
|
|
nsresult rv = FirstChild(nsnull, &kid);
|
1999-07-06 00:38:14 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
while (nsnull != kid) {
|
|
|
|
kid->SetSelected(nsnull,aSelected,aSpread);
|
|
|
|
kid->GetNextSibling(&kid);
|
|
|
|
}
|
1999-05-20 04:52:00 +04:00
|
|
|
}
|
|
|
|
}
|
1999-04-26 08:02:04 +04:00
|
|
|
nsFrameState frameState;
|
|
|
|
GetFrameState(&frameState);
|
1999-06-03 06:09:03 +04:00
|
|
|
PRBool isSelected = ((frameState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT);
|
|
|
|
if (aSelected == isSelected) //allready set thanks
|
1999-06-02 03:04:13 +04:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-05-20 04:52:00 +04:00
|
|
|
if ( aSelected ){
|
1999-04-26 08:02:04 +04:00
|
|
|
frameState |= NS_FRAME_SELECTED_CONTENT;
|
1999-05-20 04:52:00 +04:00
|
|
|
}
|
1999-04-26 08:02:04 +04:00
|
|
|
else
|
|
|
|
frameState &= ~NS_FRAME_SELECTED_CONTENT;
|
|
|
|
SetFrameState(frameState);
|
|
|
|
nsRect frameRect;
|
|
|
|
GetRect(frameRect);
|
|
|
|
nsRect rect(0, 0, frameRect.width, frameRect.height);
|
1999-05-20 04:52:00 +04:00
|
|
|
Invalidate(rect, PR_FALSE);
|
1998-12-14 21:34:14 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-01-22 21:58:14 +03:00
|
|
|
NS_IMETHODIMP
|
1999-04-26 08:02:04 +04:00
|
|
|
nsFrame::GetSelected(PRBool *aSelected) const
|
1998-12-14 21:34:14 +03:00
|
|
|
{
|
1999-01-22 21:58:14 +03:00
|
|
|
if (!aSelected )
|
1998-12-14 21:34:14 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-04-26 08:02:04 +04:00
|
|
|
*aSelected = (PRBool)(mState & NS_FRAME_SELECTED_CONTENT);
|
1998-12-14 21:34:14 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-12 03:02:31 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::GetPointFromOffset(nsIPresContext* inPresContext, nsIRenderingContext* inRendContext, PRInt32 inOffset, nsPoint* outPoint)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(outPoint != nsnull, "Null parameter");
|
|
|
|
nsPoint bottomLeft(0, 0);
|
|
|
|
*outPoint = bottomLeft;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset, PRInt32* outFrameContentOffset, nsIFrame **outChildFrame)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(outChildFrame && outFrameContentOffset, "Null parameter");
|
|
|
|
*outFrameContentOffset = 0;
|
|
|
|
*outChildFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-01-22 21:58:14 +03:00
|
|
|
|
1999-08-25 01:51:47 +04:00
|
|
|
nsresult
|
1999-07-15 22:19:03 +04:00
|
|
|
nsFrame::GetNextPrevLineFromeBlockFrame(nsIFocusTracker *aTracker,
|
|
|
|
nsDirection aDirection,
|
|
|
|
nsIFrame *aBlockFrame,
|
|
|
|
PRInt32 aLineStart,
|
|
|
|
nscoord aDesiredX,
|
|
|
|
nsIContent **aResultContent,
|
|
|
|
PRInt32 *aContentOffset,
|
1999-08-25 01:51:47 +04:00
|
|
|
PRInt8 aOutSideLimit,
|
|
|
|
nsIFrame **aResultFrame
|
1999-07-15 22:19:03 +04:00
|
|
|
)
|
|
|
|
{
|
|
|
|
//magic numbers aLineStart will be -1 for end of block 0 will be start of block
|
|
|
|
if (!aBlockFrame)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-09-01 05:02:16 +04:00
|
|
|
if (aResultFrame) {
|
|
|
|
*aResultFrame = nsnull;
|
|
|
|
}
|
|
|
|
if (aResultContent) {
|
|
|
|
*aResultContent = nsnull;
|
|
|
|
}
|
|
|
|
|
1999-07-15 22:19:03 +04:00
|
|
|
nsresult result;
|
|
|
|
nsCOMPtr<nsILineIterator> it;
|
|
|
|
result = aBlockFrame->QueryInterface(nsILineIterator::GetIID(),getter_AddRefs(it));
|
|
|
|
if (NS_FAILED(result) || !it)
|
|
|
|
return result;
|
|
|
|
PRInt32 searchingLine = aLineStart;
|
|
|
|
PRInt32 countLines;
|
|
|
|
result = it->GetNumLines(&countLines);
|
|
|
|
if (aOutSideLimit > 0) //start at end
|
|
|
|
searchingLine = countLines;
|
|
|
|
else if (aOutSideLimit <0)//start at begining
|
|
|
|
searchingLine = -1;//"next" will be 0
|
|
|
|
else
|
|
|
|
if ((aDirection == eDirPrevious && aLineStart == 0) ||
|
|
|
|
(aDirection == eDirNext && aLineStart >= (countLines -1) )){
|
|
|
|
//we need to jump to new block frame.
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
PRInt32 lineFrameCount;
|
|
|
|
nsIFrame *resultFrame = nsnull;
|
|
|
|
nsIFrame *farStoppingFrame = nsnull; //we keep searching until we find a "this" frame then we go to next line
|
|
|
|
nsIFrame *nearStoppingFrame = nsnull; //if we are backing up from edge, stop here
|
|
|
|
nsIFrame *firstFrame;
|
|
|
|
nsIFrame *lastFrame;
|
|
|
|
nsRect nonUsedRect;
|
|
|
|
PRBool isBeforeFirstFrame, isAfterLastFrame;
|
|
|
|
PRBool found = PR_FALSE;
|
|
|
|
while (!found)
|
|
|
|
{
|
|
|
|
if (aDirection == eDirPrevious)
|
|
|
|
searchingLine --;
|
|
|
|
else
|
|
|
|
searchingLine ++;
|
|
|
|
result = it->GetLine(searchingLine, &firstFrame, &lineFrameCount,nonUsedRect);
|
|
|
|
if (NS_SUCCEEDED(result)){
|
|
|
|
lastFrame = firstFrame;
|
|
|
|
for (;lineFrameCount > 1;lineFrameCount --){
|
|
|
|
result = lastFrame->GetNextSibling(&lastFrame);
|
|
|
|
if (NS_FAILED(result)){
|
|
|
|
NS_ASSERTION(0,"should not be reached nsFrame\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GetLastLeaf(&lastFrame);
|
|
|
|
|
|
|
|
if (aDirection == eDirNext){
|
|
|
|
nearStoppingFrame = firstFrame;
|
|
|
|
farStoppingFrame = lastFrame;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
nearStoppingFrame = lastFrame;
|
|
|
|
farStoppingFrame = firstFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = it->FindFrameAt(searchingLine, aDesiredX, &resultFrame, &isBeforeFirstFrame, &isAfterLastFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result) && resultFrame)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsILineIterator> newIt;
|
|
|
|
//check to see if this is ANOTHER blockframe inside the other one if so then call into its lines
|
|
|
|
result = resultFrame->QueryInterface(nsILineIterator::GetIID(),getter_AddRefs(newIt));
|
|
|
|
if (NS_SUCCEEDED(result) && newIt)
|
|
|
|
{
|
|
|
|
if (aDirection == eDirPrevious){
|
|
|
|
if (NS_SUCCEEDED(GetNextPrevLineFromeBlockFrame(aTracker,
|
|
|
|
aDirection,
|
|
|
|
resultFrame,
|
|
|
|
0,
|
|
|
|
aDesiredX,
|
|
|
|
aResultContent,
|
|
|
|
aContentOffset,
|
1999-08-25 01:51:47 +04:00
|
|
|
1,//start from end,
|
|
|
|
aResultFrame
|
1999-07-15 22:19:03 +04:00
|
|
|
)))
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (NS_SUCCEEDED(GetNextPrevLineFromeBlockFrame(aTracker,
|
|
|
|
aDirection,
|
|
|
|
resultFrame,
|
|
|
|
0,
|
|
|
|
aDesiredX,
|
|
|
|
aResultContent,
|
|
|
|
aContentOffset,
|
1999-08-25 01:51:47 +04:00
|
|
|
-1,//start from beginning
|
|
|
|
aResultFrame
|
1999-07-15 22:19:03 +04:00
|
|
|
)))
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//resultFrame is not a block frame
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
|
|
|
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,resultFrame);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
nsISupports *isupports = nsnull;
|
|
|
|
nsIFrame *storeOldResultFrame = resultFrame;
|
|
|
|
while ( !found ){
|
|
|
|
nsCOMPtr<nsIPresContext> context;
|
|
|
|
result = aTracker->GetPresContext(getter_AddRefs(context));
|
|
|
|
|
|
|
|
result = resultFrame->GetPosition(*(context.get()),aDesiredX,
|
|
|
|
aResultContent,*aContentOffset, *aContentOffset);
|
|
|
|
if (NS_SUCCEEDED(result))
|
|
|
|
found = PR_TRUE;
|
|
|
|
else {
|
|
|
|
if (aDirection == eDirPrevious && (resultFrame == farStoppingFrame))
|
|
|
|
break;
|
|
|
|
if (aDirection == eDirNext && (resultFrame == nearStoppingFrame))
|
|
|
|
break;
|
|
|
|
//always try previous on THAT line if that fails go the other way
|
|
|
|
result = frameTraversal->Prev();
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
result = frameTraversal->CurrentItem(&isupports);
|
|
|
|
if (NS_FAILED(result) || !isupports)
|
|
|
|
return result;
|
|
|
|
//we must CAST here to an nsIFrame. nsIFrame doesnt really follow the rules
|
|
|
|
resultFrame = (nsIFrame *)isupports;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found){
|
|
|
|
resultFrame = storeOldResultFrame;
|
|
|
|
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,resultFrame);
|
|
|
|
}
|
|
|
|
while ( !found ){
|
|
|
|
nsCOMPtr<nsIPresContext> context;
|
|
|
|
result = aTracker->GetPresContext(getter_AddRefs(context));
|
|
|
|
|
|
|
|
result = resultFrame->GetPosition(*(context.get()),aDesiredX,
|
|
|
|
aResultContent,*aContentOffset, *aContentOffset);
|
|
|
|
if (NS_SUCCEEDED(result))
|
|
|
|
found = PR_TRUE;
|
|
|
|
else {
|
|
|
|
if (aDirection == eDirPrevious && (resultFrame == nearStoppingFrame))
|
|
|
|
break;
|
|
|
|
if (aDirection == eDirNext && (resultFrame == farStoppingFrame))
|
|
|
|
break;
|
|
|
|
//previous didnt work now we try "next"
|
|
|
|
result = frameTraversal->Next();
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
break;
|
|
|
|
result = frameTraversal->CurrentItem(&isupports);
|
|
|
|
if (NS_FAILED(result) || !isupports)
|
|
|
|
return result;
|
|
|
|
//we must CAST here to an nsIFrame. nsIFrame doesnt really follow the rules
|
|
|
|
resultFrame = (nsIFrame *)isupports;
|
|
|
|
}
|
|
|
|
}
|
1999-08-25 01:51:47 +04:00
|
|
|
*aResultFrame = resultFrame;
|
1999-07-15 22:19:03 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
//we need to jump to new block frame.
|
|
|
|
if (aDirection == eDirNext)
|
|
|
|
return aBlockFrame->PeekOffset(aTracker, aDesiredX, eSelectLine, aDirection, 0, aResultContent,
|
1999-08-25 01:51:47 +04:00
|
|
|
aContentOffset, aResultFrame, PR_FALSE);
|
1999-07-15 22:19:03 +04:00
|
|
|
else
|
|
|
|
return aBlockFrame->PeekOffset(aTracker, aDesiredX, eSelectLine, aDirection, -1, aResultContent,
|
1999-08-25 01:51:47 +04:00
|
|
|
aContentOffset, aResultFrame, PR_FALSE);
|
1999-07-15 22:19:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-02 03:23:40 +03:00
|
|
|
NS_IMETHODIMP
|
1999-06-20 00:36:44 +04:00
|
|
|
nsFrame::PeekOffset(nsIFocusTracker *aTracker,
|
|
|
|
nscoord aDesiredX,
|
1999-06-11 01:08:17 +04:00
|
|
|
nsSelectionAmount aAmount,
|
1999-05-13 04:44:23 +04:00
|
|
|
nsDirection aDirection,
|
|
|
|
PRInt32 aStartOffset,
|
|
|
|
nsIContent **aResultContent,
|
|
|
|
PRInt32 *aContentOffset,
|
1999-08-25 01:51:47 +04:00
|
|
|
nsIFrame **aResultFrame,
|
1999-05-13 04:44:23 +04:00
|
|
|
PRBool aEatingWS)
|
|
|
|
{
|
1999-08-25 01:51:47 +04:00
|
|
|
if (!aResultContent || !aContentOffset ||!aTracker || !aResultFrame)
|
1999-02-10 21:55:25 +03:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-07-15 22:19:03 +04:00
|
|
|
nsresult result = NS_ERROR_FAILURE;
|
1999-06-20 00:36:44 +04:00
|
|
|
switch (aAmount){
|
|
|
|
case eSelectLine :
|
|
|
|
{
|
|
|
|
if (!aTracker)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
nsCOMPtr<nsILineIterator> it;
|
|
|
|
nsIFrame *blockFrame = this;
|
|
|
|
nsIFrame *thisBlock = this;
|
1999-07-15 22:19:03 +04:00
|
|
|
PRInt32 thisLine;
|
1999-06-20 00:36:44 +04:00
|
|
|
|
1999-07-15 22:19:03 +04:00
|
|
|
while (NS_FAILED(result)){
|
|
|
|
result = blockFrame->GetParent(&blockFrame);
|
|
|
|
if (NS_FAILED(result) || !blockFrame) //if at line 0 then nothing to do
|
|
|
|
return result;
|
|
|
|
result = blockFrame->QueryInterface(nsILineIterator::GetIID(),getter_AddRefs(it));
|
|
|
|
while (NS_FAILED(result) && blockFrame)
|
1999-06-20 00:36:44 +04:00
|
|
|
{
|
1999-07-15 22:19:03 +04:00
|
|
|
thisBlock = blockFrame;
|
|
|
|
result = blockFrame->GetParent(&blockFrame);
|
|
|
|
if (NS_SUCCEEDED(result) && blockFrame){
|
|
|
|
result = blockFrame->QueryInterface(nsILineIterator::GetIID(),getter_AddRefs(it));
|
1999-06-20 00:36:44 +04:00
|
|
|
}
|
|
|
|
}
|
1999-07-15 22:19:03 +04:00
|
|
|
if (NS_FAILED(result) || !it || !blockFrame)
|
|
|
|
return result;
|
|
|
|
result = it->FindLineContaining(thisBlock, &thisLine);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
result = GetNextPrevLineFromeBlockFrame(aTracker,
|
|
|
|
aDirection,
|
|
|
|
blockFrame,
|
|
|
|
thisLine,
|
|
|
|
aDesiredX,
|
|
|
|
aResultContent,
|
|
|
|
aContentOffset,
|
1999-08-25 01:51:47 +04:00
|
|
|
0, //start from thisLine
|
|
|
|
aResultFrame
|
1999-07-15 22:19:03 +04:00
|
|
|
);
|
|
|
|
thisBlock = blockFrame;
|
|
|
|
|
1999-06-20 00:36:44 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
//this will use the nsFrameTraversal as the default peek method.
|
|
|
|
//this should change to use geometry and also look to ALL the child lists
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
|
|
|
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF,this);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
nsISupports *isupports = nsnull;
|
|
|
|
if (aDirection == eDirNext)
|
|
|
|
result = frameTraversal->Next();
|
|
|
|
else
|
|
|
|
result = frameTraversal->Prev();
|
|
|
|
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
result = frameTraversal->CurrentItem(&isupports);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
if (!isupports)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
//we must CAST here to an nsIFrame. nsIFrame doesnt really follow the rules
|
|
|
|
//for speed reasons
|
|
|
|
nsIFrame *newFrame = (nsIFrame *)isupports;
|
|
|
|
if (aDirection == eDirNext)
|
|
|
|
return newFrame->PeekOffset(aTracker, aDesiredX, aAmount, aDirection, 0, aResultContent,
|
1999-08-25 01:51:47 +04:00
|
|
|
aContentOffset,aResultFrame, aEatingWS);
|
1999-06-20 00:36:44 +04:00
|
|
|
else
|
|
|
|
return newFrame->PeekOffset(aTracker, aDesiredX, aAmount, aDirection, -1, aResultContent,
|
1999-08-25 01:51:47 +04:00
|
|
|
aContentOffset,aResultFrame, aEatingWS);
|
1999-06-20 00:36:44 +04:00
|
|
|
}
|
|
|
|
}
|
1999-07-15 22:19:03 +04:00
|
|
|
return result;
|
1999-02-02 03:23:40 +03:00
|
|
|
}
|
|
|
|
|
1998-04-27 20:44:52 +04:00
|
|
|
//-----------------------------------------------------------------------------------
|
|
|
|
|
1998-08-04 02:22:27 +04:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Refreshes each content's frame
|
|
|
|
*********************************************************/
|
1998-12-18 20:34:34 +03:00
|
|
|
static void RefreshAllContentFrames(nsIFrame * aFrame, nsIContent * aContent)
|
1998-08-04 02:22:27 +04:00
|
|
|
{
|
|
|
|
nsIContent* frameContent;
|
1999-02-10 03:42:56 +03:00
|
|
|
aFrame->GetContent(&frameContent);
|
1998-08-04 02:22:27 +04:00
|
|
|
if (frameContent == aContent) {
|
|
|
|
ForceDrawFrame((nsFrame *)aFrame);
|
|
|
|
}
|
1998-11-13 02:03:35 +03:00
|
|
|
NS_IF_RELEASE(frameContent);
|
1998-08-04 02:22:27 +04:00
|
|
|
|
1999-02-10 05:25:01 +03:00
|
|
|
aFrame->FirstChild(nsnull, &aFrame);
|
1998-08-04 02:22:27 +04:00
|
|
|
while (aFrame) {
|
|
|
|
RefreshAllContentFrames(aFrame, aContent);
|
1999-02-10 09:13:38 +03:00
|
|
|
aFrame->GetNextSibling(&aFrame);
|
1998-08-04 02:22:27 +04:00
|
|
|
}
|
1998-05-08 22:33:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Refreshes each content's frame
|
|
|
|
*********************************************************/
|
1999-02-08 20:56:00 +03:00
|
|
|
#if 0
|
1998-12-18 20:34:34 +03:00
|
|
|
static void RefreshContentFrames(nsIPresContext& aPresContext,
|
1998-05-08 22:33:42 +04:00
|
|
|
nsIContent * aStartContent,
|
|
|
|
nsIContent * aEndContent)
|
|
|
|
{
|
|
|
|
//-------------------------------------
|
|
|
|
// Undraw all the current selected frames
|
|
|
|
// XXX Kludge for now
|
1998-12-29 07:45:18 +03:00
|
|
|
nsIPresShell *shell = aPresContext.GetShell();
|
|
|
|
nsIFrame *rootFrame;
|
|
|
|
|
|
|
|
shell->GetRootFrame(rootFrame);
|
1998-08-04 02:22:27 +04:00
|
|
|
|
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
|
|
|
}
|
1999-02-08 20:56:00 +03:00
|
|
|
#endif
|
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;
|
1999-02-10 08:38:18 +03:00
|
|
|
aFrame->GetOffsetFromView(pnt, &view);
|
1998-05-08 22:33:42 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-09-01 05:02:16 +04:00
|
|
|
static void
|
1999-07-15 22:19:03 +04:00
|
|
|
GetLastLeaf(nsIFrame **aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame || !*aFrame)
|
|
|
|
return;
|
|
|
|
nsIFrame *child = *aFrame;
|
|
|
|
nsresult result;
|
|
|
|
nsIFrame *lookahead = nsnull;
|
|
|
|
while (1){
|
|
|
|
result = child->FirstChild(nsnull, &lookahead);
|
|
|
|
if (NS_FAILED(result) || !lookahead)
|
|
|
|
return;//nothing to do
|
|
|
|
child = lookahead;
|
|
|
|
while (NS_SUCCEEDED(child->GetNextSibling(&lookahead)) && lookahead)
|
|
|
|
child = lookahead;
|
|
|
|
*aFrame = child;
|
|
|
|
}
|
|
|
|
*aFrame = child;
|
|
|
|
}
|
1998-05-08 22:33:42 +04:00
|
|
|
|
1999-09-01 05:02:16 +04:00
|
|
|
#if 0
|
1999-07-15 22:19:03 +04:00
|
|
|
void
|
|
|
|
GetFirstLeaf(nsIFrame **aFrame)
|
|
|
|
{
|
|
|
|
if (!aFrame || !*aFrame)
|
|
|
|
return;
|
|
|
|
nsIFrame *child = *aFrame;
|
|
|
|
nsresult result;
|
|
|
|
nsIFrame *lookahead = nsnull;
|
|
|
|
while (1){
|
|
|
|
result = child->FirstChild(nsnull, &lookahead);
|
|
|
|
if (NS_FAILED(result) || !lookahead)
|
|
|
|
return;//nothing to do
|
|
|
|
child = lookahead;
|
|
|
|
*aFrame = child;
|
|
|
|
}
|
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|
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);
|
|
|
|
}
|
|
|
|
}
|
1999-07-24 06:37:06 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
nsFrame::VerifyDirtyBitSet(nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
for (nsIFrame*f = aFrameList; f; f->GetNextSibling(&f)) {
|
|
|
|
nsFrameState frameState;
|
|
|
|
f->GetFrameState(&frameState);
|
|
|
|
NS_ASSERTION(frameState & NS_FRAME_IS_DIRTY, "dirty bit not set");
|
|
|
|
}
|
|
|
|
}
|
1998-05-20 20:24:13 +04:00
|
|
|
#endif
|