1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-13 20:24:54 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:40:37 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-02-02 22:24:56 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
1999-02-12 17:45:58 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsFrame.h"
|
1999-02-01 17:31:10 +00:00
|
|
|
#include "nsFrameList.h"
|
1998-10-09 23:46:02 +00:00
|
|
|
#include "nsLineLayout.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIAtom.h"
|
1999-12-04 23:49:50 +00:00
|
|
|
#include "nsIArena.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsGUIEvent.h"
|
1998-07-23 02:55:33 +00:00
|
|
|
#include "nsDOMEvent.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsStyleConsts.h"
|
1998-05-08 16:33:07 +00:00
|
|
|
#include "nsIPresShell.h"
|
1998-05-20 16:24:13 +00:00
|
|
|
#include "prlog.h"
|
|
|
|
#include "prprf.h"
|
|
|
|
#include <stdarg.h>
|
1998-06-02 05:28:11 +00:00
|
|
|
#include "nsIPtr.h"
|
1998-06-05 21:06:24 +00:00
|
|
|
#include "nsISizeOfHandler.h"
|
1999-10-27 03:56:14 +00:00
|
|
|
#include "nsIFrameManager.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-27 16:44:52 +00:00
|
|
|
#include "nsIDOMText.h"
|
1998-05-08 18:33:42 +00:00
|
|
|
#include "nsDocument.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
1998-10-01 04:46:11 +00:00
|
|
|
#include "nsHTMLIIDs.h"
|
1998-11-18 05:25:26 +00:00
|
|
|
#include "nsIEventStateManager.h"
|
1999-02-11 23:12:28 +00:00
|
|
|
#include "nsIDOMSelection.h"
|
|
|
|
#include "nsIFrameSelection.h"
|
1999-01-15 01:29:15 +00:00
|
|
|
#include "nsHTMLParts.h"
|
1999-01-22 22:48:00 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
1998-05-08 18:33:42 +00:00
|
|
|
|
1999-02-10 18:55:25 +00:00
|
|
|
#include "nsFrameTraversal.h"
|
|
|
|
#include "nsCOMPtr.h"
|
1999-03-25 06:43:38 +00:00
|
|
|
#include "nsStyleChangeList.h"
|
1999-09-20 21:47:37 +00:00
|
|
|
#include "nsIDOMRange.h"
|
2000-03-16 23:45:39 +00:00
|
|
|
#include "nsITableLayout.h" //selection neccesity
|
|
|
|
#include "nsITableCellLayout.h"// "
|
2000-05-11 04:25:43 +00:00
|
|
|
#include "nsIGfxTextControlFrame.h"
|
|
|
|
|
1999-09-20 21:47:37 +00:00
|
|
|
|
1999-02-10 18:55:25 +00:00
|
|
|
|
1998-07-18 18:18:20 +00:00
|
|
|
// Some Misc #defines
|
1998-07-22 22:01:46 +00:00
|
|
|
#define SELECTION_DEBUG 0
|
1998-07-18 18:18:20 +00:00
|
|
|
#define FORCE_SELECTION_UPDATE 1
|
|
|
|
#define CALC_DEBUG 0
|
|
|
|
|
1998-07-17 23:00:54 +00:00
|
|
|
|
1999-06-19 20:36:44 +00:00
|
|
|
#include "nsICaret.h"
|
|
|
|
#include "nsILineIterator.h"
|
1998-04-27 16:44:52 +00:00
|
|
|
// [HACK] Foward Declarations
|
1999-10-26 04:44:41 +00:00
|
|
|
void ForceDrawFrame(nsIPresContext* aPresContext, nsFrame * aFrame);
|
2000-04-12 05:43:42 +00:00
|
|
|
static PRBool IsSelectable(nsIFrame *aFrame); //checks style to see if we can selected
|
2000-04-12 03:04:11 +00:00
|
|
|
|
1999-07-15 18:19:03 +00:00
|
|
|
//non Hack prototypes
|
1999-02-08 17:56:00 +00:00
|
|
|
#if 0
|
1999-11-24 06:03:41 +00:00
|
|
|
static void RefreshContentFrames(nsIPresContext* aPresContext, nsIContent * aStartContent, nsIContent * aEndContent);
|
1999-02-08 17:56:00 +00:00
|
|
|
#endif
|
1998-05-08 18:33:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
1998-05-20 16:24:13 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef NS_DEBUG
|
1998-05-20 16:24:13 +00:00
|
|
|
static PRBool gShowFrameBorders = PR_FALSE;
|
1998-05-08 18:33:42 +00:00
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
NS_LAYOUT void nsIFrameDebug::ShowFrameBorders(PRBool aEnable)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
gShowFrameBorders = aEnable;
|
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
NS_LAYOUT PRBool nsIFrameDebug::GetShowFrameBorders()
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
return gShowFrameBorders;
|
|
|
|
}
|
|
|
|
|
2000-02-03 02:49:58 +00:00
|
|
|
static PRBool gShowEventTargetFrameBorder = PR_FALSE;
|
|
|
|
|
|
|
|
NS_LAYOUT void nsIFrameDebug::ShowEventTargetFrameBorder(PRBool aEnable)
|
|
|
|
{
|
|
|
|
gShowEventTargetFrameBorder = aEnable;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_LAYOUT PRBool nsIFrameDebug::GetShowEventTargetFrameBorder()
|
|
|
|
{
|
|
|
|
return gShowEventTargetFrameBorder;
|
|
|
|
}
|
|
|
|
|
1998-05-20 16:24:13 +00:00
|
|
|
/**
|
|
|
|
* Note: the log module is created during library initialization which
|
|
|
|
* means that you cannot perform logging before then.
|
|
|
|
*/
|
1999-02-26 17:05:20 +00:00
|
|
|
static PRLogModuleInfo* gLogModule;
|
1998-05-20 16:24:13 +00:00
|
|
|
|
|
|
|
static PRLogModuleInfo* gFrameVerifyTreeLogModuleInfo;
|
|
|
|
|
|
|
|
static PRBool gFrameVerifyTreeEnable = PRBool(0x55);
|
|
|
|
|
|
|
|
NS_LAYOUT PRBool
|
1999-11-01 22:12:45 +00:00
|
|
|
nsIFrameDebug::GetVerifyTreeEnable()
|
1998-05-20 16:24:13 +00:00
|
|
|
{
|
|
|
|
if (gFrameVerifyTreeEnable == PRBool(0x55)) {
|
|
|
|
if (nsnull == gFrameVerifyTreeLogModuleInfo) {
|
|
|
|
gFrameVerifyTreeLogModuleInfo = PR_NewLogModule("frameverifytree");
|
|
|
|
gFrameVerifyTreeEnable = 0 != gFrameVerifyTreeLogModuleInfo->level;
|
|
|
|
printf("Note: frameverifytree is %sabled\n",
|
|
|
|
gFrameVerifyTreeEnable ? "en" : "dis");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gFrameVerifyTreeEnable;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_LAYOUT void
|
1999-11-01 22:12:45 +00:00
|
|
|
nsIFrameDebug::SetVerifyTreeEnable(PRBool aEnabled)
|
1998-05-20 16:24:13 +00:00
|
|
|
{
|
|
|
|
gFrameVerifyTreeEnable = aEnabled;
|
|
|
|
}
|
|
|
|
|
1999-09-21 07:51:52 +00:00
|
|
|
static PRLogModuleInfo* gStyleVerifyTreeLogModuleInfo;
|
|
|
|
|
|
|
|
static PRBool gStyleVerifyTreeEnable = PRBool(0x55);
|
|
|
|
|
|
|
|
NS_LAYOUT PRBool
|
1999-11-01 22:12:45 +00:00
|
|
|
nsIFrameDebug::GetVerifyStyleTreeEnable()
|
1999-09-21 07:51:52 +00:00
|
|
|
{
|
|
|
|
if (gStyleVerifyTreeEnable == PRBool(0x55)) {
|
|
|
|
if (nsnull == gStyleVerifyTreeLogModuleInfo) {
|
|
|
|
gStyleVerifyTreeLogModuleInfo = PR_NewLogModule("styleverifytree");
|
|
|
|
gStyleVerifyTreeEnable = 0 != gStyleVerifyTreeLogModuleInfo->level;
|
|
|
|
printf("Note: styleverifytree is %sabled\n",
|
|
|
|
gStyleVerifyTreeEnable ? "en" : "dis");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return gStyleVerifyTreeEnable;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_LAYOUT void
|
1999-11-01 22:12:45 +00:00
|
|
|
nsIFrameDebug::SetVerifyStyleTreeEnable(PRBool aEnabled)
|
1999-09-21 07:51:52 +00:00
|
|
|
{
|
|
|
|
gStyleVerifyTreeEnable = aEnabled;
|
|
|
|
}
|
|
|
|
|
1998-05-20 16:24:13 +00:00
|
|
|
NS_LAYOUT PRLogModuleInfo*
|
1999-11-01 22:12:45 +00:00
|
|
|
nsIFrameDebug::GetLogModuleInfo()
|
1998-05-20 16:24:13 +00:00
|
|
|
{
|
1999-02-26 17:05:20 +00:00
|
|
|
if (nsnull == gLogModule) {
|
|
|
|
gLogModule = PR_NewLogModule("frame");
|
|
|
|
}
|
1998-05-20 16:24:13 +00:00
|
|
|
return gLogModule;
|
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-05-20 16:24:13 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
static NS_DEFINE_IID(kIFrameIID, NS_IFRAME_IID);
|
1999-02-11 23:12:28 +00:00
|
|
|
static NS_DEFINE_IID(kIFrameSelection, NS_IFRAMESELECTION_IID);
|
1998-04-13 20:24:54 +00:00
|
|
|
nsresult
|
1999-12-04 23:49:50 +00:00
|
|
|
NS_NewEmptyFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
1998-04-13 20:24:54 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-04 23:49:50 +00:00
|
|
|
nsFrame* it = new (aPresShell) nsFrame;
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-11 22:03:29 +00:00
|
|
|
*aNewFrame = it;
|
1998-04-13 20:24:54 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-10-05 14:51:12 +00:00
|
|
|
MOZ_DECL_CTOR_COUNTER(nsFrame);
|
|
|
|
|
1999-12-04 23:49:50 +00:00
|
|
|
// Overloaded new operator. Initializes the memory to 0 and relies on an arena
|
|
|
|
// (which comes from the presShell) to perform the allocation.
|
|
|
|
void*
|
|
|
|
nsFrame::operator new(size_t sz, nsIPresShell* aPresShell)
|
|
|
|
{
|
|
|
|
// Check the recycle list first.
|
|
|
|
void* result = nsnull;
|
|
|
|
aPresShell->AllocateFrame(sz, &result);
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
nsCRT::zero(result, sz);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Overridden to prevent the global delete from being called, since the memory
|
|
|
|
// came out of an nsIArena instead of the global delete operator's heap.
|
|
|
|
void
|
|
|
|
nsFrame::operator delete(void* aPtr, size_t sz)
|
|
|
|
{
|
|
|
|
// Don't let the memory be freed, since it will be recycled
|
|
|
|
// instead. Don't call the global operator delete.
|
|
|
|
|
|
|
|
// Stash the size of the object in the first four bytes of the
|
|
|
|
// freed up memory. The Destroy method can then use this information
|
|
|
|
// to recycle the object.
|
|
|
|
size_t* szPtr = (size_t*)aPtr;
|
|
|
|
*szPtr = sz;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-03 06:31:43 +00:00
|
|
|
nsFrame::nsFrame()
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-10-05 14:51:12 +00:00
|
|
|
MOZ_COUNT_CTOR(nsFrame);
|
|
|
|
|
|
|
|
mState = NS_FRAME_FIRST_REFLOW | NS_FRAME_SYNC_FRAME_AND_VIEW |
|
|
|
|
NS_FRAME_IS_DIRTY;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsFrame::~nsFrame()
|
|
|
|
{
|
1999-10-05 14:51:12 +00:00
|
|
|
MOZ_COUNT_DTOR(nsFrame);
|
|
|
|
|
1998-08-04 18:19:51 +00:00
|
|
|
NS_IF_RELEASE(mContent);
|
1998-04-13 20:24:54 +00:00
|
|
|
NS_IF_RELEASE(mStyleContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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);
|
1999-11-02 05:49:11 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2000-02-02 22:24:56 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIFrameDebug))) {
|
1999-11-02 05:49:11 +00:00
|
|
|
*aInstancePtr = (void*)(nsIFrameDebug*)this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-10-30 02:52:11 +00:00
|
|
|
if (aIID.Equals(kClassIID) || aIID.Equals(kISupportsIID)) {
|
1998-04-13 20:24:54 +00:00
|
|
|
*aInstancePtr = (void*)this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsFrame::AddRef(void)
|
|
|
|
{
|
1998-09-24 01:50:16 +00:00
|
|
|
NS_WARNING("not supported for frames");
|
|
|
|
return 1;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsFrame::Release(void)
|
|
|
|
{
|
1998-09-24 01:50:16 +00:00
|
|
|
NS_WARNING("not supported for frames");
|
|
|
|
return 1;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIFrame
|
|
|
|
|
1998-12-03 06:31:43 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::Init(nsIPresContext* aPresContext,
|
1998-12-03 06:31:43 +00:00
|
|
|
nsIContent* aContent,
|
1999-01-14 05:16:23 +00:00
|
|
|
nsIFrame* aParent,
|
1999-02-25 03:27:57 +00:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1998-12-03 06:31:43 +00:00
|
|
|
{
|
|
|
|
mContent = aContent;
|
|
|
|
NS_IF_ADDREF(mContent);
|
1999-01-14 05:16:23 +00:00
|
|
|
mParent = aParent;
|
2000-05-04 08:35:42 +00:00
|
|
|
nsFrameState state;
|
1999-10-23 23:19:14 +00:00
|
|
|
|
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Make sure the general flags bits are the same
|
|
|
|
aPrevInFlow->GetFrameState(&state);
|
|
|
|
if ((state & NS_FRAME_SYNC_FRAME_AND_VIEW) == 0) {
|
|
|
|
mState &= ~NS_FRAME_SYNC_FRAME_AND_VIEW;
|
|
|
|
}
|
|
|
|
if (state & NS_FRAME_REPLACED_ELEMENT) {
|
|
|
|
mState |= NS_FRAME_REPLACED_ELEMENT;
|
|
|
|
}
|
|
|
|
if (state & NS_FRAME_SELECTED_CONTENT) {
|
|
|
|
mState |= NS_FRAME_SELECTED_CONTENT;
|
|
|
|
}
|
2000-05-04 08:35:42 +00:00
|
|
|
if (state & NS_FRAME_INDEPENDENT_SELECTION) {
|
|
|
|
mState |= NS_FRAME_INDEPENDENT_SELECTION;
|
|
|
|
}
|
1999-10-23 23:19:14 +00:00
|
|
|
}
|
2000-05-04 08:35:42 +00:00
|
|
|
if(mParent)
|
|
|
|
{
|
|
|
|
mParent->GetFrameState(&state);
|
|
|
|
if (state & NS_FRAME_INDEPENDENT_SELECTION) {
|
|
|
|
mState |= NS_FRAME_INDEPENDENT_SELECTION;
|
|
|
|
}
|
1999-10-23 23:19:14 +00:00
|
|
|
|
2000-05-04 08:35:42 +00:00
|
|
|
}
|
1999-11-24 06:03:41 +00:00
|
|
|
return SetStyleContext(aPresContext, aContext);
|
1998-12-03 06:31:43 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
1998-11-10 06:05:32 +00:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-09-10 19:32:14 +00:00
|
|
|
{
|
1998-11-10 06:05:32 +00: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 19:32:14 +00:00
|
|
|
return NS_OK;
|
1998-11-10 06:05:32 +00:00
|
|
|
#endif
|
1998-09-10 19:32:14 +00:00
|
|
|
}
|
|
|
|
|
1999-01-15 01:29:15 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-01-15 01:29:15 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
1999-08-19 03:51:25 +00:00
|
|
|
NS_PRECONDITION(PR_FALSE, "not a container");
|
1999-01-15 01:29:15 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-01-15 01:29:15 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
1999-08-19 03:51:25 +00:00
|
|
|
NS_PRECONDITION(PR_FALSE, "not a container");
|
1999-01-15 01:29:15 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-01-15 01:29:15 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
1999-08-19 03:51:25 +00:00
|
|
|
NS_PRECONDITION(PR_FALSE, "not a container");
|
1999-01-15 01:29:15 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
1999-07-22 04:32:31 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::ReplaceFrame(nsIPresContext* aPresContext,
|
1999-07-22 04:32:31 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame,
|
|
|
|
nsIFrame* aNewFrame)
|
|
|
|
{
|
1999-08-19 03:51:25 +00:00
|
|
|
NS_PRECONDITION(PR_FALSE, "not a container");
|
1999-07-22 04:32:31 +00:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
1999-01-15 01:29:15 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::Destroy(nsIPresContext* aPresContext)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-06-25 04:22:15 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
1999-11-24 06:03:41 +00:00
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
1999-10-27 03:56:14 +00:00
|
|
|
|
|
|
|
// Get the view pointer now before the frame properties disappear
|
|
|
|
// when we call NotifyDestroyingFrame()
|
|
|
|
nsIView* view;
|
1999-11-24 06:03:41 +00:00
|
|
|
GetView(aPresContext, &view);
|
1999-06-25 04:22:15 +00:00
|
|
|
|
1999-07-16 23:25:15 +00:00
|
|
|
// XXX Rather than always doing this it would be better if it was part of
|
1999-06-25 04:22:15 +00: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-16 23:25:15 +00:00
|
|
|
shell->NotifyDestroyingFrame(this);
|
1999-06-25 04:22:15 +00:00
|
|
|
}
|
|
|
|
|
1999-05-03 20:51:30 +00:00
|
|
|
if ((mState & NS_FRAME_EXTERNAL_REFERENCE) ||
|
|
|
|
(mState & NS_FRAME_SELECTED_CONTENT)) {
|
1999-06-25 04:22:15 +00:00
|
|
|
if (shell) {
|
1998-11-19 00:43:36 +00:00
|
|
|
shell->ClearFrameRefs(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-28 02:52:54 +00:00
|
|
|
//XXX Why is this done in nsFrame instead of some frame class
|
1998-08-08 04:23:33 +00:00
|
|
|
// that actually loads images?
|
1999-11-24 06:03:41 +00:00
|
|
|
aPresContext->StopAllLoadImagesFor(this);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-10-27 03:56:14 +00:00
|
|
|
if (view) {
|
|
|
|
// Break association between view and frame
|
|
|
|
view->SetClientData(nsnull);
|
|
|
|
|
|
|
|
// Destroy the view
|
|
|
|
view->Destroy();
|
1998-08-10 02:28:23 +00:00
|
|
|
}
|
|
|
|
|
1999-12-04 23:49:50 +00:00
|
|
|
// Deleting the frame doesn't really free the memory, since we're using an
|
|
|
|
// nsIArena for allocation, but we will get our destructors called.
|
1998-04-13 20:24:54 +00:00
|
|
|
delete this;
|
1999-12-04 23:49:50 +00:00
|
|
|
|
|
|
|
// Now that we're totally cleaned out, we need to add ourselves to the presshell's
|
|
|
|
// recycler.
|
|
|
|
size_t* sz = (size_t*)this;
|
|
|
|
shell->FreeFrame(*sz, (void*)this);
|
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-06-05 21:06:24 +00:00
|
|
|
NS_IMETHODIMP
|
1999-02-10 00:42:56 +00:00
|
|
|
nsFrame::GetContent(nsIContent** aContent) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-10 00:42:56 +00:00
|
|
|
NS_PRECONDITION(nsnull != aContent, "null OUT parameter pointer");
|
|
|
|
*aContent = mContent;
|
2000-02-17 23:19:18 +00:00
|
|
|
NS_IF_ADDREF(*aContent);
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-01-22 18:58:14 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::GetOffsets(PRInt32 &aStart, PRInt32 &aEnd) const
|
|
|
|
{
|
|
|
|
aStart = 0;
|
|
|
|
aEnd = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-01-16 00:00:50 +00:00
|
|
|
NS_IMETHODIMP
|
1999-02-10 00:42:56 +00:00
|
|
|
nsFrame::GetStyleContext(nsIStyleContext** aStyleContext) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-10 00:42:56 +00:00
|
|
|
NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer");
|
1998-11-03 20:23:15 +00:00
|
|
|
NS_ASSERTION(nsnull != mStyleContext, "frame should always have style context");
|
1998-04-13 20:24:54 +00:00
|
|
|
NS_IF_ADDREF(mStyleContext);
|
1999-02-10 00:42:56 +00:00
|
|
|
*aStyleContext = mStyleContext;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetStyleContext(nsIPresContext* aPresContext,nsIStyleContext* aContext)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-04-10 17:32:22 +00:00
|
|
|
// NS_PRECONDITION(0 == (mState & NS_FRAME_IN_REFLOW), "Shouldn't set style context during reflow");
|
1998-04-13 20:24:54 +00:00
|
|
|
NS_PRECONDITION(nsnull != aContext, "null ptr");
|
|
|
|
if (aContext != mStyleContext) {
|
|
|
|
NS_IF_RELEASE(mStyleContext);
|
|
|
|
if (nsnull != aContext) {
|
|
|
|
mStyleContext = aContext;
|
|
|
|
NS_ADDREF(aContext);
|
1998-05-01 20:43:02 +00:00
|
|
|
DidSetStyleContext(aPresContext);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
1998-04-17 01:41:24 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-28 23:25:07 +00:00
|
|
|
// Subclass hook for style post processing
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::DidSetStyleContext(nsIPresContext* aPresContext)
|
1998-04-28 23:25:07 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetStyleData(nsStyleStructID aSID, const nsStyleStruct*& aStyleStruct) const
|
1998-04-17 01:41:24 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mStyleContext!=nsnull,"null style context");
|
|
|
|
if (mStyleContext) {
|
1998-06-05 06:09:09 +00:00
|
|
|
aStyleStruct = mStyleContext->GetStyleData(aSID);
|
1998-04-17 01:41:24 +00:00
|
|
|
} else {
|
|
|
|
aStyleStruct = nsnull;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-09-03 23:35:14 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::GetAdditionalStyleContext(PRInt32 aIndex,
|
|
|
|
nsIStyleContext** aStyleContext) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aIndex >= 0, "invalid index number");
|
|
|
|
NS_ASSERTION(aStyleContext, "null ptr");
|
|
|
|
if (! aStyleContext) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
*aStyleContext = nsnull;
|
1999-09-21 07:51:52 +00:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
1999-09-03 23:35:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::SetAdditionalStyleContext(PRInt32 aIndex,
|
|
|
|
nsIStyleContext* aStyleContext)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aIndex >= 0, "invalid index number");
|
|
|
|
return ((aIndex < 0) ? NS_ERROR_INVALID_ARG : NS_OK);
|
|
|
|
}
|
|
|
|
|
1999-01-14 05:16:23 +00:00
|
|
|
// Geometric parent member functions
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-02-10 01:36:30 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetParent(nsIFrame** aParent) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-10 01:36:30 +00:00
|
|
|
NS_PRECONDITION(nsnull != aParent, "null OUT parameter pointer");
|
|
|
|
*aParent = mParent;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-01-14 05:16:23 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetParent(const nsIFrame* aParent)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-01-14 05:16:23 +00:00
|
|
|
mParent = (nsIFrame*)aParent;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bounding rect member functions
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetRect(nsRect& aRect) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
aRect = mRect;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetOrigin(nsPoint& aPoint) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
aPoint.x = mRect.x;
|
|
|
|
aPoint.y = mRect.y;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetSize(nsSize& aSize) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-04-17 01:41:24 +00:00
|
|
|
aSize.width = mRect.width;
|
|
|
|
aSize.height = mRect.height;
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetRect(nsIPresContext* aPresContext,
|
|
|
|
const nsRect& aRect)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-10-26 04:44:41 +00:00
|
|
|
MoveTo(aPresContext, aRect.x, aRect.y);
|
|
|
|
SizeTo(aPresContext, aRect.width, aRect.height);
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::MoveTo(nsIPresContext* aPresContext, nscoord aX, nscoord aY)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-06-26 00:31:44 +00:00
|
|
|
mRect.x = aX;
|
|
|
|
mRect.y = aY;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SizeTo(nsIPresContext* aPresContext, nscoord aWidth, nscoord aHeight)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-05-07 16:13:09 +00:00
|
|
|
mRect.width = aWidth;
|
|
|
|
mRect.height = aHeight;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Child frame enumeration
|
|
|
|
|
1998-11-09 19:59:33 +00:00
|
|
|
NS_IMETHODIMP
|
1999-02-10 02:25:01 +00:00
|
|
|
nsFrame::GetAdditionalChildListName(PRInt32 aIndex, nsIAtom** aListName) const
|
1998-11-09 19:59:33 +00:00
|
|
|
{
|
1999-02-10 02:25:01 +00:00
|
|
|
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
|
1998-11-09 19:59:33 +00:00
|
|
|
NS_PRECONDITION(aIndex >= 0, "invalid index number");
|
1999-02-10 02:25:01 +00:00
|
|
|
*aListName = nsnull;
|
1998-11-09 19:59:33 +00:00
|
|
|
return aIndex < 0 ? NS_ERROR_INVALID_ARG : NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-22 01:16:50 +00:00
|
|
|
NS_IMETHODIMP nsFrame::FirstChild(nsIPresContext* aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame** aFirstChild) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-10 02:25:01 +00:00
|
|
|
*aFirstChild = nsnull;
|
1998-11-09 19:40:27 +00:00
|
|
|
return nsnull == aListName ? NS_OK : NS_ERROR_INVALID_ARG;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-04-30 18:56:26 +00:00
|
|
|
PRInt16
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::DisplaySelection(nsIPresContext* aPresContext, PRBool isOkToTurnOn)
|
1998-08-03 23:39:16 +00:00
|
|
|
{
|
2000-04-30 18:56:26 +00:00
|
|
|
PRInt16 result = nsISelectionController::SELECTION_OFF;
|
1998-08-03 23:39:16 +00:00
|
|
|
|
2000-05-04 08:35:42 +00:00
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
|
|
|
result = GetSelectionController(aPresContext, getter_AddRefs(selCon));
|
|
|
|
if (NS_SUCCEEDED(result) && selCon) {
|
|
|
|
selCon->GetDisplaySelection(&result);
|
|
|
|
if (result) {
|
|
|
|
// check whether style allows selection
|
|
|
|
const nsStyleUserInterface* userinterface;
|
|
|
|
GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct*&)userinterface);
|
|
|
|
if (userinterface) {
|
|
|
|
if (userinterface->mUserSelect == NS_STYLE_USER_SELECT_AUTO) {
|
|
|
|
// if 'user-select' isn't set for this frame, use the parent's
|
|
|
|
if (mParent) {
|
|
|
|
mParent->GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct*&)userinterface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (userinterface->mUserSelect == NS_STYLE_USER_SELECT_NONE) {
|
|
|
|
result = nsISelectionController::SELECTION_OFF;
|
|
|
|
isOkToTurnOn = PR_FALSE;
|
1999-11-23 01:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
2000-05-04 08:35:42 +00:00
|
|
|
}
|
|
|
|
if (isOkToTurnOn && !result) {
|
|
|
|
selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
|
|
|
|
result = nsISelectionController::SELECTION_ON;
|
1998-08-03 23:39:16 +00:00
|
|
|
}
|
|
|
|
}
|
1998-07-27 18:05:35 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-04-10 17:32:22 +00:00
|
|
|
void
|
2000-04-25 04:43:11 +00:00
|
|
|
nsFrame::SetOverflowClipRect(nsIRenderingContext& aRenderingContext)
|
1999-04-10 17:32:22 +00:00
|
|
|
{
|
2000-04-25 04:43:11 +00:00
|
|
|
// 'overflow-clip' only applies to block-level elements and replaced
|
|
|
|
// elements that have 'overflow' set to 'hidden', and it is relative
|
|
|
|
// to the content area and applies to content only (not border or background)
|
|
|
|
const nsStyleSpacing* spacing;
|
|
|
|
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)spacing);
|
|
|
|
|
|
|
|
// Start with the 'auto' values and then factor in user specified values
|
|
|
|
nsRect clipRect(0, 0, mRect.width, mRect.height);
|
|
|
|
|
|
|
|
// XXX We don't support the 'overflow-clip' property yet, so just use the
|
|
|
|
// content area (which is the default value) as the clip shape
|
|
|
|
nsMargin border, padding;
|
|
|
|
|
|
|
|
spacing->GetBorder(border);
|
|
|
|
clipRect.Deflate(border);
|
|
|
|
// XXX We need to handle percentage padding
|
|
|
|
if (spacing->GetPadding(padding)) {
|
|
|
|
clipRect.Deflate(padding);
|
1999-04-10 17:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set updated clip-rect into the rendering context
|
2000-04-25 04:43:11 +00:00
|
|
|
PRBool clipState;
|
1999-04-10 17:32:22 +00:00
|
|
|
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);
|
|
|
|
}
|
|
|
|
|
1998-12-18 15:54:23 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::Paint(nsIPresContext* aPresContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
|
|
|
{
|
2000-05-11 04:25:43 +00:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
nsresult result;
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
result = aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
1999-05-17 00:21:18 +00:00
|
|
|
|
2000-05-11 04:25:43 +00:00
|
|
|
PRBool displaySelection = PR_TRUE;
|
|
|
|
result = shell->GetDisplayNonTextSelection(&displaySelection);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
if (!displaySelection)
|
|
|
|
return NS_OK;
|
|
|
|
if (mContent) {
|
|
|
|
result = mContent->GetDocument(*getter_AddRefs(doc));
|
|
|
|
}
|
1998-05-08 18:33:42 +00:00
|
|
|
|
2000-05-11 04:25:43 +00:00
|
|
|
//check frame selection state
|
|
|
|
PRBool isSelected;
|
|
|
|
nsFrameState frameState;
|
|
|
|
GetFrameState(&frameState);
|
|
|
|
isSelected = (frameState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
|
|
|
|
//if not selected then return
|
|
|
|
if (!isSelected)
|
|
|
|
return NS_OK; //nothing to do
|
1999-05-17 00:21:18 +00:00
|
|
|
|
2000-05-11 04:25:43 +00:00
|
|
|
//get the selection controller
|
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
|
|
|
result = GetSelectionController(aPresContext, getter_AddRefs(selCon));
|
|
|
|
PRInt16 selectionValue;
|
|
|
|
selCon->GetDisplaySelection(&selectionValue);
|
|
|
|
displaySelection = selectionValue > nsISelectionController::SELECTION_HIDDEN;
|
|
|
|
//check display selection state.
|
|
|
|
if (!displaySelection)
|
|
|
|
return NS_OK; //if frame does not allow selection. do nothing
|
1999-05-17 00:21:18 +00:00
|
|
|
|
1999-07-15 18:19:03 +00:00
|
|
|
|
2000-05-11 04:25:43 +00:00
|
|
|
nsCOMPtr<nsIContent> newContent;
|
|
|
|
result = mContent->GetParent(*getter_AddRefs(newContent));
|
|
|
|
|
|
|
|
//check to see if we are anonymouse content
|
|
|
|
PRInt32 offset;
|
|
|
|
if (NS_SUCCEEDED(result) && newContent){
|
|
|
|
result = newContent->IndexOf(mContent, offset);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
{
|
|
|
|
return result;
|
1999-05-17 00:21:18 +00:00
|
|
|
}
|
2000-05-11 04:25:43 +00:00
|
|
|
}
|
1999-04-26 04:02:04 +00:00
|
|
|
|
2000-05-11 04:25:43 +00:00
|
|
|
SelectionDetails *details;
|
|
|
|
if (NS_SUCCEEDED(result) && shell){
|
2000-05-08 03:59:53 +00:00
|
|
|
|
2000-05-11 04:25:43 +00:00
|
|
|
nsCOMPtr<nsIFrameSelection> frameSelection;
|
|
|
|
if (NS_SUCCEEDED(result) && selCon)
|
|
|
|
{
|
|
|
|
frameSelection = do_QueryInterface(selCon); //this MAY implement
|
|
|
|
}
|
|
|
|
if (!frameSelection)
|
|
|
|
result = shell->GetFrameSelection(getter_AddRefs(frameSelection));
|
|
|
|
if (NS_SUCCEEDED(result) && frameSelection){
|
|
|
|
result = frameSelection->LookUpSelection(newContent, offset,
|
|
|
|
1, &details, PR_FALSE);//look up to see what selection(s) are on this frame
|
1998-12-18 15:54:23 +00:00
|
|
|
}
|
2000-05-11 04:25:43 +00:00
|
|
|
}
|
1999-07-15 18:19:03 +00:00
|
|
|
if (details)
|
1999-05-17 00:21:18 +00: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 18:19:03 +00:00
|
|
|
SelectionDetails *deletingDetails = details;
|
1999-09-14 23:41:49 +00:00
|
|
|
while((deletingDetails = details->mNext) != nsnull) {
|
1999-07-15 18:19:03 +00:00
|
|
|
delete details;
|
|
|
|
details = deletingDetails;
|
|
|
|
}
|
|
|
|
delete details;
|
1998-05-08 18:33:42 +00:00
|
|
|
}
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-02-11 01:24:59 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::GetContentForEvent(nsIPresContext* aPresContext,
|
|
|
|
nsEvent* aEvent,
|
|
|
|
nsIContent** aContent)
|
|
|
|
{
|
|
|
|
return GetContent(aContent);
|
|
|
|
}
|
|
|
|
|
1998-04-27 16:44:52 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
1998-12-18 15:54:23 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::HandleEvent(nsIPresContext* aPresContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
|
|
|
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
|
1998-11-18 05:25:26 +00:00
|
|
|
return NS_OK;
|
1998-06-23 21:53:02 +00:00
|
|
|
}
|
1998-04-27 16:44:52 +00:00
|
|
|
|
1999-05-07 21:12:59 +00:00
|
|
|
/*i have no idea why this is here keeping incase..
|
1998-08-03 23:39:16 +00:00
|
|
|
if (DisplaySelection(aPresContext) == PR_FALSE) {
|
|
|
|
if (aEvent->message != NS_MOUSE_LEFT_BUTTON_DOWN) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
1999-05-07 21:12:59 +00:00
|
|
|
*/
|
1999-09-25 23:33:02 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
1999-11-24 06:03:41 +00:00
|
|
|
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
|
1999-09-25 23:33:02 +00:00
|
|
|
switch (aEvent->message)
|
|
|
|
{
|
|
|
|
case NS_MOUSE_MOVE:
|
|
|
|
{
|
1999-05-07 21:12:59 +00:00
|
|
|
if (NS_SUCCEEDED(rv)){
|
1999-07-18 02:27:19 +00:00
|
|
|
nsCOMPtr<nsIFrameSelection> frameselection;
|
2000-05-08 03:59:53 +00:00
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
|
|
|
rv = GetSelectionController(aPresContext, getter_AddRefs(selCon));
|
|
|
|
if (NS_SUCCEEDED(rv) && selCon)
|
|
|
|
{
|
|
|
|
frameselection = do_QueryInterface(selCon); //this MAY implement
|
|
|
|
}
|
|
|
|
if (!frameselection)
|
|
|
|
rv = shell->GetFrameSelection(getter_AddRefs(frameselection));
|
|
|
|
if (NS_SUCCEEDED(rv) && frameselection){
|
1999-05-07 21:12:59 +00:00
|
|
|
PRBool mouseDown = PR_FALSE;
|
2000-02-15 07:13:21 +00:00
|
|
|
if (NS_SUCCEEDED(frameselection->GetMouseDownState(&mouseDown)) && mouseDown)
|
|
|
|
HandleDrag(aPresContext, aEvent, aEventStatus);
|
1999-05-07 21:12:59 +00:00
|
|
|
}
|
1998-06-08 00:57:15 +00:00
|
|
|
}
|
1999-09-25 23:33:02 +00:00
|
|
|
}break;
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
|
|
|
{
|
2000-05-13 08:09:03 +00:00
|
|
|
nsFrameState state;
|
|
|
|
GetFrameState(&state);
|
1999-09-25 23:33:02 +00:00
|
|
|
nsCOMPtr<nsIFrameSelection> frameselection;
|
2000-05-08 03:59:53 +00:00
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
|
|
|
rv = GetSelectionController(aPresContext, getter_AddRefs(selCon));
|
|
|
|
if (NS_SUCCEEDED(rv) && selCon)
|
|
|
|
{
|
2000-05-13 08:09:03 +00:00
|
|
|
if (state & NS_FRAME_INDEPENDENT_SELECTION)
|
|
|
|
frameselection = do_QueryInterface(selCon); //this MAY implement
|
|
|
|
else
|
|
|
|
rv = shell->GetFrameSelection(getter_AddRefs(frameselection));
|
2000-04-12 03:04:11 +00:00
|
|
|
}
|
2000-05-13 08:09:03 +00:00
|
|
|
NS_ENSURE_TRUE(frameselection, NS_ERROR_FAILURE);
|
|
|
|
frameselection->SetMouseDownState( PR_TRUE );//redandant in normal cases but we MUST tell this selection by hand here
|
1999-09-22 02:29:33 +00:00
|
|
|
HandlePress(aPresContext, aEvent, aEventStatus);
|
1999-09-25 23:33:02 +00:00
|
|
|
}break;
|
1999-09-29 20:04:05 +00:00
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
2000-05-08 03:59:53 +00:00
|
|
|
{
|
|
|
|
nsFrameState state;
|
|
|
|
GetFrameState(&state);
|
2000-05-13 08:09:03 +00:00
|
|
|
nsCOMPtr<nsIFrameSelection> frameselection;
|
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
|
|
|
rv = GetSelectionController(aPresContext, getter_AddRefs(selCon));
|
|
|
|
if (NS_SUCCEEDED(rv) && selCon)
|
2000-05-08 03:59:53 +00:00
|
|
|
{
|
2000-05-13 08:09:03 +00:00
|
|
|
if (state & NS_FRAME_INDEPENDENT_SELECTION)
|
2000-05-08 03:59:53 +00:00
|
|
|
frameselection = do_QueryInterface(selCon); //this MAY implement
|
2000-05-13 08:09:03 +00:00
|
|
|
else
|
|
|
|
rv = shell->GetFrameSelection(getter_AddRefs(frameselection));
|
2000-05-08 03:59:53 +00:00
|
|
|
}
|
2000-05-13 08:09:03 +00:00
|
|
|
NS_ENSURE_TRUE(frameselection, NS_ERROR_FAILURE);
|
|
|
|
frameselection->SetMouseDownState( PR_FALSE );//redandant in normal cases but we MUST tell this selection by hand here
|
2000-05-08 03:59:53 +00:00
|
|
|
HandleRelease(aPresContext, aEvent, aEventStatus);
|
|
|
|
}
|
1999-09-29 20:04:05 +00:00
|
|
|
break;
|
1999-09-25 23:33:02 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}//end switch
|
1998-04-27 16:44:52 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-16 23:45:39 +00:00
|
|
|
NS_IMETHODIMP
|
2000-03-21 06:04:02 +00:00
|
|
|
nsFrame::GetDataForTableSelection(nsMouseEvent *aMouseEvent, nsIContent **aParentContent,
|
|
|
|
PRInt32 *aContentOffset, PRUint32 *aTarget)
|
2000-03-16 23:45:39 +00:00
|
|
|
{
|
|
|
|
if (!aMouseEvent || !aParentContent || !aContentOffset || !aTarget)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*aParentContent = nsnull;
|
|
|
|
*aContentOffset = 0;
|
|
|
|
*aTarget = 0;
|
|
|
|
|
|
|
|
// Test if special 'table selection' key is pressed
|
|
|
|
PRBool doTableSelection;
|
|
|
|
|
|
|
|
#ifdef XP_MAC
|
|
|
|
doTableSelection = aMouseEvent->isMeta;
|
|
|
|
#else
|
|
|
|
doTableSelection = aMouseEvent->isControl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!doTableSelection) return NS_OK;
|
|
|
|
|
|
|
|
// Get the cell frame or table frame (or parent) of the current content node
|
|
|
|
nsIFrame *frame = this;
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
PRBool foundCell = PR_FALSE;
|
|
|
|
PRBool foundTable = PR_FALSE;
|
|
|
|
|
|
|
|
while (frame && NS_SUCCEEDED(result))
|
|
|
|
{
|
|
|
|
// Check for a table cell by querying to a known CellFrame interface
|
|
|
|
nsITableCellLayout *cellElement;
|
|
|
|
result = (frame)->QueryInterface(nsITableCellLayout::GetIID(), (void **)&cellElement);
|
|
|
|
if (NS_SUCCEEDED(result) && cellElement)
|
|
|
|
{
|
|
|
|
foundCell = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If not a cell, check for table
|
|
|
|
// This will happen when starting frame is the table or child of a table,
|
|
|
|
// such as a row (we were inbetween cells or in table border)
|
|
|
|
nsITableLayout *tableElement;
|
|
|
|
result = (frame)->QueryInterface(nsITableLayout::GetIID(), (void **)&tableElement);
|
|
|
|
if (NS_SUCCEEDED(result) && tableElement)
|
|
|
|
{
|
|
|
|
foundTable = PR_TRUE;
|
|
|
|
break;
|
2000-03-21 06:04:02 +00:00
|
|
|
} else {
|
|
|
|
result = frame->GetParent(&frame);
|
2000-03-16 23:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// We aren't in a cell or table
|
|
|
|
if (!foundCell && !foundTable) return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> tableOrCellContent;
|
|
|
|
result = frame->GetContent(getter_AddRefs(tableOrCellContent));
|
|
|
|
if (NS_FAILED(result)) return result;
|
|
|
|
if (!tableOrCellContent) return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> parentContent;
|
|
|
|
result = tableOrCellContent->GetParent(*getter_AddRefs(parentContent));
|
|
|
|
if (NS_FAILED(result)) return result;
|
|
|
|
if (!parentContent) return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
PRInt32 offset;
|
|
|
|
result = parentContent->IndexOf(tableOrCellContent, offset);
|
|
|
|
if (NS_FAILED(result)) return result;
|
|
|
|
// Not likely?
|
|
|
|
if (offset < 0) return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// Everything is OK -- set the return values
|
|
|
|
*aParentContent = parentContent;
|
|
|
|
NS_ADDREF(*aParentContent);
|
|
|
|
|
|
|
|
*aContentOffset = offset;
|
|
|
|
|
|
|
|
if (foundCell)
|
|
|
|
*aTarget = TABLESELECTION_CELL;
|
|
|
|
|
|
|
|
if (foundTable)
|
|
|
|
{
|
|
|
|
//TODO: Put logic to find "hit" spots for selecting column or row here
|
|
|
|
*aTarget = TABLESELECTION_TABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-04-12 05:48:03 +00:00
|
|
|
static PRBool IsSelectable(nsIFrame *aFrame) //checks style to see if we can selected
|
2000-04-12 03:04:11 +00:00
|
|
|
{
|
|
|
|
if (!aFrame)
|
|
|
|
return PR_FALSE;
|
|
|
|
nsIFrame *parent;
|
|
|
|
if (NS_FAILED(aFrame->GetParent(&parent)))
|
|
|
|
return PR_FALSE;
|
|
|
|
const nsStyleUserInterface* userinterface;
|
|
|
|
aFrame->GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct*&)userinterface);
|
|
|
|
if (userinterface) {
|
|
|
|
if (userinterface->mUserSelect == NS_STYLE_USER_SELECT_AUTO) {
|
|
|
|
// if 'user-select' isn't set for this frame, use the parent's
|
|
|
|
if (parent) {
|
|
|
|
parent->GetStyleData(eStyleStruct_UserInterface, (const nsStyleStruct*&)userinterface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (userinterface->mUserSelect == NS_STYLE_USER_SELECT_NONE) {
|
|
|
|
return PR_FALSE;//do not continue no selection for this frame.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_TRUE;//default to true.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-08 18:33:42 +00:00
|
|
|
/**
|
|
|
|
* Handles the Mouse Press Event for the frame
|
|
|
|
*/
|
1999-02-12 17:45:58 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::HandlePress(nsIPresContext* aPresContext,
|
1999-02-12 17:45:58 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-04-27 16:44:52 +00:00
|
|
|
{
|
2000-04-13 00:15:02 +00:00
|
|
|
if (!IsMouseCaptured(aPresContext))
|
|
|
|
CaptureMouse(aPresContext, PR_TRUE);
|
2000-05-11 04:25:43 +00:00
|
|
|
|
|
|
|
PRInt16 displayresult = nsISelectionController::SELECTION_OFF;
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
|
|
|
rv = GetSelectionController(aPresContext, getter_AddRefs(selCon));
|
2000-05-13 20:47:42 +00:00
|
|
|
//get the selection controller
|
|
|
|
if (NS_SUCCEEDED(rv) && selCon)
|
|
|
|
{
|
2000-05-11 04:25:43 +00:00
|
|
|
selCon->GetDisplaySelection(&displayresult);
|
|
|
|
if (displayresult == nsISelectionController::SELECTION_OFF)
|
|
|
|
return NS_OK;//nothing to do we cannot affect selection from here
|
1998-07-27 18:05:35 +00:00
|
|
|
}
|
2000-04-12 03:04:11 +00:00
|
|
|
|
2000-05-11 04:25:43 +00:00
|
|
|
|
1999-09-11 00:18:02 +00:00
|
|
|
nsMouseEvent *me = (nsMouseEvent *)aEvent;
|
1999-09-25 23:33:02 +00:00
|
|
|
if (me->clickCount >1 )
|
|
|
|
return HandleMultiplePress(aPresContext,aEvent,aEventStatus);
|
1998-07-27 18:05:35 +00:00
|
|
|
|
2000-03-25 01:14:39 +00:00
|
|
|
|
|
|
|
// check whether style allows selection
|
|
|
|
// if not dont tell selection the mouse event even occured.
|
2000-04-12 03:04:11 +00:00
|
|
|
if (!IsSelectable(this))
|
|
|
|
return NS_OK;
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
2000-05-11 04:25:43 +00:00
|
|
|
rv = aPresContext->GetShell(getter_AddRefs(shell));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && shell) {
|
1999-06-08 02:19:26 +00:00
|
|
|
PRInt32 startPos = 0;
|
1999-07-05 20:38:14 +00:00
|
|
|
// PRUint32 contentOffset = 0;
|
1999-06-08 02:19:26 +00:00
|
|
|
PRInt32 contentOffsetEnd = 0;
|
|
|
|
nsCOMPtr<nsIContent> newContent;
|
1999-10-13 01:15:26 +00:00
|
|
|
PRBool beginContent;
|
1999-09-29 20:04:05 +00:00
|
|
|
if (NS_SUCCEEDED(GetContentAndOffsetsFromPoint(aPresContext, aEvent->point,
|
1999-09-15 20:38:42 +00:00
|
|
|
getter_AddRefs(newContent),
|
2000-03-16 23:45:39 +00:00
|
|
|
startPos, contentOffsetEnd, beginContent)))
|
|
|
|
{
|
2000-05-13 20:47:42 +00:00
|
|
|
//get the frame selection from sel controller
|
1999-07-18 02:27:19 +00:00
|
|
|
nsCOMPtr<nsIFrameSelection> frameselection;
|
2000-05-13 20:47:42 +00:00
|
|
|
frameselection = do_QueryInterface(selCon); //this MAY implement
|
|
|
|
if (!frameselection)//if we must get it from the pres shell's
|
2000-05-08 03:59:53 +00:00
|
|
|
rv = shell->GetFrameSelection(getter_AddRefs(frameselection));
|
|
|
|
if (NS_SUCCEEDED(rv) && frameselection)
|
2000-03-16 23:45:39 +00:00
|
|
|
{
|
1999-07-18 02:27:19 +00:00
|
|
|
frameselection->SetMouseDownState(PR_TRUE);//not important if it fails here
|
2000-02-10 04:35:51 +00:00
|
|
|
|
2000-03-16 23:45:39 +00:00
|
|
|
nsCOMPtr<nsIContent>parentContent;
|
|
|
|
PRInt32 contentOffset;
|
|
|
|
PRUint32 target;
|
|
|
|
nsresult result = GetDataForTableSelection(me, getter_AddRefs(parentContent), &contentOffset, &target);
|
|
|
|
if (NS_SUCCEEDED(result) && parentContent)
|
2000-03-21 06:04:02 +00:00
|
|
|
frameselection->HandleTableSelection(parentContent, contentOffset, target, me);
|
2000-02-10 04:35:51 +00:00
|
|
|
else
|
2000-03-16 23:45:39 +00:00
|
|
|
frameselection->HandleClick(newContent, startPos , contentOffsetEnd , me->isShift, PR_FALSE, beginContent);
|
1998-12-14 18:34:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-27 16:44:52 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1999-09-10 18:29:37 +00:00
|
|
|
|
1999-05-17 00:21:18 +00:00
|
|
|
/**
|
|
|
|
* Handles the Multiple Mouse Press Event for the frame
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::HandleMultiplePress(nsIPresContext* aPresContext,
|
1999-09-15 20:38:42 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-05-17 00:21:18 +00:00
|
|
|
{
|
2000-04-30 18:56:26 +00:00
|
|
|
if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF) {
|
1999-09-11 00:18:02 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
nsMouseEvent *me = (nsMouseEvent *)aEvent;
|
|
|
|
if (me->clickCount <3 )
|
|
|
|
return NS_OK;
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
1999-11-24 06:03:41 +00:00
|
|
|
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
|
2000-05-04 08:35:42 +00:00
|
|
|
nsCOMPtr<nsISelectionController> selcon;
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
{
|
|
|
|
rv = GetSelectionController(aPresContext, getter_AddRefs(selcon));
|
|
|
|
}
|
1999-09-25 23:33:02 +00:00
|
|
|
|
2000-04-27 07:37:12 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && shell && selcon) {
|
1999-09-11 00:18:02 +00:00
|
|
|
nsCOMPtr<nsIRenderingContext> acx;
|
|
|
|
nsCOMPtr<nsIFocusTracker> tracker;
|
|
|
|
tracker = do_QueryInterface(shell, &rv);
|
|
|
|
if (NS_FAILED(rv) || !tracker)
|
|
|
|
return rv;
|
|
|
|
rv = shell->CreateRenderingContext(this, getter_AddRefs(acx));
|
|
|
|
if (NS_SUCCEEDED(rv)){
|
|
|
|
PRInt32 startPos = 0;
|
|
|
|
PRInt32 contentOffsetEnd = 0;
|
|
|
|
nsCOMPtr<nsIContent> newContent;
|
1999-10-13 01:15:26 +00:00
|
|
|
PRBool beginContent = PR_FALSE;
|
1999-09-29 20:04:05 +00:00
|
|
|
if (NS_SUCCEEDED(GetContentAndOffsetsFromPoint(aPresContext, aEvent->point,
|
1999-09-15 20:38:42 +00:00
|
|
|
getter_AddRefs(newContent),
|
1999-10-13 01:15:26 +00:00
|
|
|
startPos, contentOffsetEnd,beginContent))) {
|
1999-09-15 20:38:42 +00:00
|
|
|
// find which word needs to be selected! use peek offset one
|
|
|
|
// way then the other
|
1999-09-11 00:18:02 +00:00
|
|
|
nsCOMPtr<nsIContent> startContent;
|
|
|
|
nsCOMPtr<nsIDOMNode> startNode;
|
|
|
|
nsCOMPtr<nsIContent> endContent;
|
|
|
|
nsCOMPtr<nsIDOMNode> endNode;
|
|
|
|
//peeks{}
|
|
|
|
nsPeekOffsetStruct startpos;
|
|
|
|
startpos.SetData(tracker,
|
|
|
|
0,
|
|
|
|
eSelectBeginLine,
|
|
|
|
eDirPrevious,
|
|
|
|
startPos,
|
|
|
|
PR_FALSE,
|
1999-10-22 00:19:18 +00:00
|
|
|
PR_TRUE,
|
1999-09-11 00:18:02 +00:00
|
|
|
PR_TRUE);
|
1999-11-24 06:03:41 +00:00
|
|
|
rv = PeekOffset(aPresContext, &startpos);
|
1999-09-11 00:18:02 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
nsPeekOffsetStruct endpos;
|
|
|
|
endpos.SetData(tracker,
|
|
|
|
0,
|
|
|
|
eSelectEndLine,
|
|
|
|
eDirNext,
|
|
|
|
startPos,
|
|
|
|
PR_FALSE,
|
1999-10-22 00:19:18 +00:00
|
|
|
PR_FALSE,
|
|
|
|
PR_TRUE);
|
1999-11-24 06:03:41 +00:00
|
|
|
rv = PeekOffset(aPresContext, &endpos);
|
1999-09-11 00:18:02 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
endNode = do_QueryInterface(endpos.mResultContent,&rv);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
startNode = do_QueryInterface(startpos.mResultContent,&rv);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMSelection> selection;
|
2000-04-27 07:37:12 +00:00
|
|
|
if (NS_SUCCEEDED(selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)))){
|
1999-09-11 00:18:02 +00:00
|
|
|
rv = selection->Collapse(startNode,startpos.mContentOffset);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
rv = selection->Extend(endNode,endpos.mContentOffset);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
//no release
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-05-17 00:21:18 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext* aPresContext,
|
1999-09-15 20:38:42 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-04-27 16:44:52 +00:00
|
|
|
{
|
2000-04-30 18:56:26 +00:00
|
|
|
if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF) {
|
1998-12-14 18:34:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-29 20:04:05 +00:00
|
|
|
nsresult result;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
result = aPresContext->GetShell(getter_AddRefs(presShell));
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFrameSelection> frameselection;
|
2000-05-08 03:59:53 +00:00
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
|
|
|
result = GetSelectionController(aPresContext, getter_AddRefs(selCon));
|
|
|
|
if (NS_SUCCEEDED(result) && selCon)
|
|
|
|
{
|
|
|
|
frameselection = do_QueryInterface(selCon); //this MAY implement
|
|
|
|
}
|
|
|
|
if (!frameselection)
|
|
|
|
result = presShell->GetFrameSelection(getter_AddRefs(frameselection));
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result) && frameselection)
|
|
|
|
{
|
|
|
|
frameselection->StopAutoScrollTimer();
|
2000-03-16 23:45:39 +00:00
|
|
|
|
|
|
|
// Check if we are dragging in a table cell
|
|
|
|
nsCOMPtr<nsIContent> parentContent;
|
|
|
|
PRInt32 contentOffset;
|
|
|
|
PRUint32 target;
|
|
|
|
nsMouseEvent *me = (nsMouseEvent *)aEvent;
|
|
|
|
result = GetDataForTableSelection(me, getter_AddRefs(parentContent), &contentOffset, &target);
|
|
|
|
if (NS_SUCCEEDED(result) && parentContent)
|
2000-03-21 06:04:02 +00:00
|
|
|
frameselection->HandleTableSelection(parentContent, contentOffset, target, me);
|
2000-03-16 23:45:39 +00:00
|
|
|
else
|
|
|
|
frameselection->HandleDrag(aPresContext, this, aEvent->point);
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
frameselection->StartAutoScrollTimer(aPresContext, this, aEvent->point, 30);
|
1998-12-14 18:34:14 +00:00
|
|
|
}
|
1999-09-29 20:04:05 +00:00
|
|
|
|
1998-04-27 16:44:52 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::HandleRelease(nsIPresContext* aPresContext,
|
1999-09-15 20:38:42 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-04-27 16:44:52 +00:00
|
|
|
{
|
2000-04-13 00:15:02 +00:00
|
|
|
if (IsMouseCaptured(aPresContext))
|
|
|
|
CaptureMouse(aPresContext, PR_FALSE);
|
|
|
|
|
2000-04-30 18:56:26 +00:00
|
|
|
if (DisplaySelection(aPresContext) == nsISelectionController::SELECTION_OFF)
|
1999-09-29 20:04:05 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsresult result;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
result = aPresContext->GetShell(getter_AddRefs(presShell));
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result))
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIFrameSelection> frameselection;
|
2000-05-08 03:59:53 +00:00
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
|
|
|
result = GetSelectionController(aPresContext, getter_AddRefs(selCon));
|
|
|
|
if (NS_SUCCEEDED(result) && selCon)
|
|
|
|
{
|
|
|
|
frameselection = do_QueryInterface(selCon); //this MAY implement
|
|
|
|
}
|
|
|
|
if (!frameselection)
|
|
|
|
result = presShell->GetFrameSelection(getter_AddRefs(frameselection));
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result) && frameselection)
|
|
|
|
frameselection->StopAutoScrollTimer();
|
|
|
|
}
|
|
|
|
|
1998-04-27 16:44:52 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-29 20:04:05 +00:00
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
nsresult nsFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
|
1999-09-29 20:04:05 +00:00
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsIContent ** aNewContent,
|
|
|
|
PRInt32& aContentOffset,
|
1999-10-13 01:15:26 +00:00
|
|
|
PRInt32& aContentOffsetEnd,
|
|
|
|
PRBool& aBeginFrameContent)
|
1999-09-29 20:04:05 +00:00
|
|
|
{
|
|
|
|
nsresult result = NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if (!aNewContent)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
nsIView *view = nsnull;
|
|
|
|
nsIFrame *kid = nsnull;
|
|
|
|
nsIFrame *closestFrame = nsnull;
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
result = GetClosestViewForFrame(aCX, this, &view);
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
2000-01-22 01:16:50 +00:00
|
|
|
result = FirstChild(aCX, nsnull, &kid);
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result) && nsnull != kid) {
|
|
|
|
|
|
|
|
#define HUGE_DISTANCE 999999 //some HUGE number that will always fail first comparison
|
|
|
|
|
|
|
|
PRInt32 closestXDistance = HUGE_DISTANCE;
|
|
|
|
PRInt32 closestYDistance = HUGE_DISTANCE;
|
|
|
|
|
|
|
|
while (nsnull != kid) {
|
1999-11-18 19:40:52 +00:00
|
|
|
|
|
|
|
// Skip over generated content kid frames, or frames
|
|
|
|
// that don't have a proper parent-child relationship!
|
|
|
|
|
|
|
|
PRBool skipThisKid = PR_FALSE;
|
|
|
|
nsFrameState frameState;
|
|
|
|
result = kid->GetFrameState(&frameState);
|
|
|
|
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
if (frameState & NS_FRAME_GENERATED_CONTENT) {
|
|
|
|
// It's generated content, so skip it!
|
|
|
|
skipThisKid = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// The frame's content is not generated. Now check
|
|
|
|
// if it is anonymous content!
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> kidContent;
|
|
|
|
|
|
|
|
result = kid->GetContent(getter_AddRefs(kidContent));
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result) && kidContent) {
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
|
|
|
|
result = kidContent->GetParent(*getter_AddRefs(content));
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result) && content) {
|
|
|
|
PRInt32 kidCount = 0;
|
|
|
|
|
|
|
|
result = content->ChildCount(kidCount);
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
|
|
|
|
PRInt32 kidIndex = 0;
|
|
|
|
result = content->IndexOf(kidContent, kidIndex);
|
|
|
|
|
|
|
|
// IndexOf() should return -1 for the index if it doesn't
|
|
|
|
// find kidContent in it's child list.
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result) && (kidIndex < 0 || kidIndex >= kidCount)) {
|
|
|
|
// Must be anonymous content! So skip it!
|
|
|
|
skipThisKid = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skipThisKid) {
|
|
|
|
kid->GetNextSibling(&kid);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Kid frame has content that has a proper parent-child
|
|
|
|
// relationship. Now see if the aPoint inside it's bounding
|
|
|
|
// rect or close by.
|
|
|
|
|
1999-09-29 20:04:05 +00:00
|
|
|
nsRect rect;
|
|
|
|
nsPoint offsetPoint(0,0);
|
|
|
|
nsIView * kidView = nsnull;
|
|
|
|
|
|
|
|
kid->GetRect(rect);
|
1999-11-24 06:03:41 +00:00
|
|
|
kid->GetOffsetFromView(aCX, offsetPoint, &kidView);
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
rect.x = offsetPoint.x;
|
|
|
|
rect.y = offsetPoint.y;
|
|
|
|
|
1999-10-12 23:25:19 +00:00
|
|
|
nscoord ya = rect.y;
|
|
|
|
nscoord yb = rect.y + rect.height;
|
1999-09-29 20:04:05 +00:00
|
|
|
|
1999-10-12 23:25:19 +00:00
|
|
|
PRInt32 yDistance = PR_MIN(abs(ya - aPoint.y),abs(yb - aPoint.y));
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
if (yDistance <= closestYDistance && rect.width > 0 && rect.height > 0)
|
|
|
|
{
|
|
|
|
if (yDistance < closestYDistance)
|
|
|
|
closestXDistance = HUGE_DISTANCE;
|
|
|
|
|
1999-10-12 23:25:19 +00:00
|
|
|
nscoord xa = rect.x;
|
|
|
|
nscoord xb = rect.x + rect.width;
|
1999-09-29 20:04:05 +00:00
|
|
|
|
1999-10-12 23:25:19 +00:00
|
|
|
if (xa <= aPoint.x && xb >= aPoint.x && ya <= aPoint.y && yb >= aPoint.y)
|
1999-09-29 20:04:05 +00:00
|
|
|
{
|
|
|
|
closestFrame = kid;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-10-12 23:25:19 +00:00
|
|
|
PRInt32 xDistance = PR_MIN(abs(xa - aPoint.x),abs(xb - aPoint.x));
|
1999-09-29 20:04:05 +00:00
|
|
|
|
1999-11-18 19:40:52 +00:00
|
|
|
if (xDistance < closestXDistance || (xDistance == closestXDistance && rect.x <= aPoint.x))
|
1999-09-29 20:04:05 +00:00
|
|
|
{
|
|
|
|
closestXDistance = xDistance;
|
|
|
|
closestYDistance = yDistance;
|
|
|
|
closestFrame = kid;
|
|
|
|
}
|
|
|
|
// else if (xDistance > closestXDistance)
|
|
|
|
// break;//done
|
|
|
|
}
|
|
|
|
|
|
|
|
kid->GetNextSibling(&kid);
|
|
|
|
}
|
|
|
|
if (closestFrame) {
|
|
|
|
|
|
|
|
// If we cross a view boundary, we need to adjust
|
|
|
|
// the coordinates because GetPosition() expects
|
|
|
|
// them to be relative to the closest view.
|
|
|
|
|
|
|
|
nsPoint newPoint = aPoint;
|
|
|
|
nsIView *closestView = nsnull;
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
result = GetClosestViewForFrame(aCX, closestFrame, &closestView);
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
if (closestView && view != closestView)
|
|
|
|
{
|
|
|
|
nscoord vX = 0, vY = 0;
|
|
|
|
result = closestView->GetPosition(&vX, &vY);
|
|
|
|
if (NS_SUCCEEDED(result))
|
|
|
|
{
|
|
|
|
newPoint.x -= vX;
|
|
|
|
newPoint.y -= vY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// printf(" 0x%.8x 0x%.8x %4d %4d\n",
|
|
|
|
// closestFrame, closestView, closestXDistance, closestYDistance);
|
|
|
|
|
|
|
|
return closestFrame->GetContentAndOffsetsFromPoint(aCX, newPoint, aNewContent,
|
1999-10-13 01:15:26 +00:00
|
|
|
aContentOffset, aContentOffsetEnd,aBeginFrameContent);
|
1999-09-29 20:04:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mContent)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-10-22 00:19:18 +00:00
|
|
|
nsRect thisRect;
|
|
|
|
result = GetRect(thisRect);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
nsPoint offsetPoint;
|
1999-11-24 06:03:41 +00:00
|
|
|
GetOffsetFromView(aCX, offsetPoint, &view);
|
1999-10-22 00:19:18 +00:00
|
|
|
thisRect.x = offsetPoint.x;
|
|
|
|
thisRect.y = offsetPoint.y;
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
result = mContent->GetParent(*aNewContent);
|
|
|
|
if (*aNewContent){
|
|
|
|
result = (*aNewContent)->IndexOf(mContent, aContentOffset);
|
2000-01-12 21:39:36 +00:00
|
|
|
if (NS_FAILED(result) || aContentOffset < 0)
|
1999-09-29 20:04:05 +00:00
|
|
|
{
|
2000-01-12 21:39:36 +00:00
|
|
|
return (result?result:NS_ERROR_FAILURE);
|
1999-09-29 20:04:05 +00:00
|
|
|
}
|
1999-10-22 00:19:18 +00:00
|
|
|
aBeginFrameContent = PR_TRUE;
|
|
|
|
if (thisRect.Contains(aPoint))
|
|
|
|
aContentOffsetEnd = aContentOffset +1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((thisRect.x + thisRect.width) < aPoint.x || thisRect.y > aPoint.y)
|
|
|
|
{
|
|
|
|
aBeginFrameContent = PR_FALSE;
|
|
|
|
aContentOffset++;
|
|
|
|
}
|
|
|
|
aContentOffsetEnd = aContentOffset;
|
|
|
|
}
|
1999-09-29 20:04:05 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-05-08 18:33:42 +00:00
|
|
|
|
1998-04-27 16:44:52 +00:00
|
|
|
|
1998-11-18 05:25:26 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::GetCursor(nsIPresContext* aPresContext,
|
1998-11-23 22:20:50 +00:00
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-11-18 05:25:26 +00:00
|
|
|
const nsStyleColor* styleColor;
|
|
|
|
GetStyleData(eStyleStruct_Color, (const nsStyleStruct*&)styleColor);
|
|
|
|
aCursor = styleColor->mCursor;
|
|
|
|
|
1999-01-14 05:16:23 +00:00
|
|
|
if ((NS_STYLE_CURSOR_AUTO == aCursor) && (nsnull != mParent)) {
|
|
|
|
mParent->GetCursor(aPresContext, aPoint, aCursor);
|
1998-11-18 02:11:54 +00:00
|
|
|
}
|
1998-11-18 05:25:26 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 02:43:08 +00:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
1999-10-26 04:44:41 +00:00
|
|
|
nsIFrame** aFrame)
|
1998-11-18 05:25:26 +00:00
|
|
|
{
|
2000-03-22 02:43:08 +00:00
|
|
|
if ((aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) &&
|
|
|
|
(mRect.Contains(aPoint))) {
|
|
|
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
if (disp->IsVisible()) {
|
|
|
|
*aFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Resize and incremental reflow
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP
|
1999-02-10 04:17:06 +00:00
|
|
|
nsFrame::GetFrameState(nsFrameState* aResult)
|
1998-05-14 00:47:32 +00:00
|
|
|
{
|
1999-02-10 04:17:06 +00:00
|
|
|
NS_PRECONDITION(nsnull != aResult, "null OUT parameter pointer");
|
|
|
|
*aResult = mState;
|
1998-05-14 00:47:32 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP
|
1998-05-14 00:47:32 +00:00
|
|
|
nsFrame::SetFrameState(nsFrameState aNewState)
|
|
|
|
{
|
|
|
|
mState = aNewState;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-01 04:46:11 +00:00
|
|
|
// nsIHTMLReflow member functions
|
1998-05-14 00:47:32 +00:00
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::WillReflow(nsIPresContext* aPresContext)
|
1998-05-14 00:47:32 +00:00
|
|
|
{
|
1998-06-25 16:33:10 +00:00
|
|
|
NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("WillReflow: oldState=%x", mState));
|
1998-05-14 00:47:32 +00:00
|
|
|
mState |= NS_FRAME_IN_REFLOW;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::DidReflow(nsIPresContext* aPresContext,
|
1998-05-14 00:47:32 +00:00
|
|
|
nsDidReflowStatus aStatus)
|
|
|
|
{
|
1998-06-25 16:33:10 +00:00
|
|
|
NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
|
|
|
|
("nsFrame::DidReflow: aStatus=%d", aStatus));
|
1998-05-14 00:47:32 +00:00
|
|
|
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
|
2000-01-12 08:28:24 +00:00
|
|
|
mState &= ~(NS_FRAME_IN_REFLOW | NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-12-01 04:13:19 +00:00
|
|
|
}
|
1998-05-28 21:55:13 +00:00
|
|
|
|
1998-05-14 00:47:32 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-09 23:46:02 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-04-21 14:59:47 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsFrame", aReflowState.reason);
|
1998-04-13 20:24:54 +00:00
|
|
|
aDesiredSize.width = 0;
|
|
|
|
aDesiredSize.height = 0;
|
|
|
|
aDesiredSize.ascent = 0;
|
|
|
|
aDesiredSize.descent = 0;
|
1998-05-25 17:31:49 +00:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-05-12 04:17:56 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-10-01 04:46:11 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::FindTextRuns(nsLineLayout& aLineLayout)
|
|
|
|
{
|
|
|
|
aLineLayout.EndTextRun();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-27 16:51:21 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::AdjustFrameSize(nscoord aExtraSpace, nscoord& aUsedSpace)
|
|
|
|
{
|
|
|
|
aUsedSpace = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-04-20 00:26:32 +00:00
|
|
|
nsFrame::TrimTrailingWhiteSpace(nsIPresContext* aPresContext,
|
1998-10-27 16:51:21 +00:00
|
|
|
nsIRenderingContext& aRC,
|
|
|
|
nscoord& aDeltaWidth)
|
1998-05-08 04:45:37 +00:00
|
|
|
{
|
1998-10-27 16:51:21 +00:00
|
|
|
aDeltaWidth = 0;
|
1998-05-08 04:45:37 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-27 16:51:21 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::ContentChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
nsISupports* aSubContent)
|
|
|
|
{
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && shell) {
|
1999-02-12 17:45:58 +00:00
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, this,
|
|
|
|
nsIReflowCommand::ContentChanged);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
shell->AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
1999-01-22 23:07:09 +00:00
|
|
|
}
|
1999-02-12 17:45:58 +00:00
|
|
|
return rv;
|
1998-10-27 16:51:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
1999-10-15 23:16:45 +00:00
|
|
|
PRInt32 aNameSpaceID,
|
1998-10-27 16:51:21 +00:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aHint)
|
1998-09-18 19:53:27 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-10 05:52:23 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::ContentStateChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aHint)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Flow member functions
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::IsSplittable(nsSplittableType& aIsSplittable) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-05-22 04:54:11 +00:00
|
|
|
aIsSplittable = NS_FRAME_NOT_SPLITTABLE;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-02-24 04:48:08 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetPrevInFlow(nsIFrame** aPrevInFlow) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-24 04:48:08 +00:00
|
|
|
*aPrevInFlow = nsnull;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-10-27 00:53:15 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetPrevInFlow(nsIFrame* aPrevInFlow)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-10-27 00:53:15 +00:00
|
|
|
// Ignore harmless requests to set it to NULL
|
|
|
|
if (aPrevInFlow) {
|
|
|
|
NS_ERROR("not splittable");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-02-24 04:48:08 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetNextInFlow(nsIFrame** aNextInFlow) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-24 04:48:08 +00:00
|
|
|
*aNextInFlow = nsnull;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetNextInFlow(nsIFrame*)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
NS_ERROR("not splittable");
|
1998-05-08 17:02:35 +00:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Associated view object
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetView(nsIPresContext* aPresContext, nsIView** aView) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-10-27 03:56:14 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aView);
|
|
|
|
|
|
|
|
// Initialize OUT parameter
|
|
|
|
*aView = nsnull;
|
|
|
|
|
2000-02-03 00:51:37 +00:00
|
|
|
// Check the frame state bit and see if the frame has a view
|
|
|
|
if (mState & NS_FRAME_HAS_VIEW) {
|
|
|
|
// Check for a property on the frame
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
1999-10-27 03:56:14 +00:00
|
|
|
|
2000-02-03 00:51:37 +00:00
|
|
|
if (presShell) {
|
|
|
|
nsCOMPtr<nsIFrameManager> frameManager;
|
|
|
|
presShell->GetFrameManager(getter_AddRefs(frameManager));
|
|
|
|
|
|
|
|
if (frameManager) {
|
|
|
|
void* value;
|
|
|
|
frameManager->GetFrameProperty((nsIFrame*)this, nsLayoutAtoms::viewProperty, 0, &value);
|
|
|
|
*aView = (nsIView*)value;
|
|
|
|
NS_ASSERTION(value != 0, "frame state bit was set but frame has no view");
|
|
|
|
}
|
1999-10-27 03:56:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetView(nsIPresContext* aPresContext, nsIView* aView)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-10-27 03:56:14 +00:00
|
|
|
if (aView) {
|
1998-08-28 02:52:54 +00:00
|
|
|
aView->SetClientData(this);
|
1999-10-27 03:56:14 +00:00
|
|
|
|
|
|
|
// Set a property on the frame
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
|
|
|
|
if (presShell) {
|
|
|
|
nsCOMPtr<nsIFrameManager> frameManager;
|
|
|
|
presShell->GetFrameManager(getter_AddRefs(frameManager));
|
|
|
|
|
|
|
|
if (frameManager) {
|
|
|
|
frameManager->SetFrameProperty(this, nsLayoutAtoms::viewProperty,
|
|
|
|
aView, nsnull);
|
|
|
|
}
|
|
|
|
}
|
2000-02-03 00:51:37 +00:00
|
|
|
|
|
|
|
// Set the frame state bit that says the frame has a view
|
|
|
|
mState |= NS_FRAME_HAS_VIEW;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-08-28 02:52:54 +00:00
|
|
|
|
1999-10-27 03:56:14 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Find the first geometric parent that has a view
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetParentWithView(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame** aParent) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-10 05:38:18 +00:00
|
|
|
NS_PRECONDITION(nsnull != aParent, "null OUT parameter pointer");
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-02-10 05:38:18 +00:00
|
|
|
nsIFrame* parent;
|
|
|
|
for (parent = mParent; nsnull != parent; parent->GetParent(&parent)) {
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIView* parView;
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
parent->GetView(aPresContext, &parView);
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull != parView) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-10 05:38:18 +00:00
|
|
|
*aParent = parent;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00: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-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetOffsetFromView(nsIPresContext* aPresContext,
|
|
|
|
nsPoint& aOffset,
|
|
|
|
nsIView** aView) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-10 05:38:18 +00:00
|
|
|
NS_PRECONDITION(nsnull != aView, "null OUT parameter pointer");
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIFrame* frame = (nsIFrame*)this;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-02-10 05:38:18 +00:00
|
|
|
*aView = nsnull;
|
1998-04-13 20:24:54 +00:00
|
|
|
aOffset.MoveTo(0, 0);
|
|
|
|
do {
|
1998-04-17 01:41:24 +00:00
|
|
|
nsPoint origin;
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
frame->GetOrigin(origin);
|
|
|
|
aOffset += origin;
|
1999-02-10 01:36:30 +00:00
|
|
|
frame->GetParent(&frame);
|
1998-04-17 01:41:24 +00:00
|
|
|
if (nsnull != frame) {
|
1999-10-26 04:44:41 +00:00
|
|
|
frame->GetView(aPresContext, aView);
|
1998-04-17 01:41:24 +00:00
|
|
|
}
|
1999-02-10 05:38:18 +00:00
|
|
|
} while ((nsnull != frame) && (nsnull == *aView));
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetWindow(nsIPresContext* aPresContext,
|
|
|
|
nsIWidget** aWindow) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-10 05:38:18 +00:00
|
|
|
NS_PRECONDITION(nsnull != aWindow, "null OUT parameter pointer");
|
|
|
|
|
|
|
|
nsIFrame* frame;
|
|
|
|
nsIWidget* window = nsnull;
|
1999-10-26 04:44:41 +00:00
|
|
|
for (frame = (nsIFrame*)this; nsnull != frame; frame->GetParentWithView(aPresContext, &frame)) {
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIView* view;
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
frame->GetView(aPresContext, &view);
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull != view) {
|
1999-02-10 05:38:18 +00:00
|
|
|
view->GetWidget(window);
|
|
|
|
if (nsnull != window) {
|
1998-04-17 01:41:24 +00:00
|
|
|
break;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-01-26 23:04:40 +00:00
|
|
|
|
|
|
|
if (nsnull == window) {
|
|
|
|
// Ask the view manager for the widget
|
|
|
|
|
|
|
|
// First we have to get to a frame with a view
|
|
|
|
nsIView* view;
|
|
|
|
GetView(aPresContext, &view);
|
|
|
|
if (nsnull == view) {
|
|
|
|
GetParentWithView(aPresContext, &frame);
|
|
|
|
if (nsnull != frame) {
|
|
|
|
GetView(aPresContext, &view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// From the view get the view manager
|
|
|
|
if (nsnull != view) {
|
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
view->GetViewManager(*getter_AddRefs(vm));
|
|
|
|
vm->GetWidget(&window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-10 05:38:18 +00:00
|
|
|
NS_POSTCONDITION(nsnull != window, "no window in frame tree");
|
|
|
|
*aWindow = window;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1999-02-09 05:44:13 +00:00
|
|
|
NS_IMETHODIMP
|
1999-02-10 04:17:06 +00:00
|
|
|
nsFrame::GetFrameType(nsIAtom** aType) const
|
1999-02-09 05:44:13 +00:00
|
|
|
{
|
1999-02-10 04:17:06 +00:00
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsnull;
|
1999-02-09 05:44:13 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-24 23:56:15 +00:00
|
|
|
void
|
1999-10-26 04:44:41 +00:00
|
|
|
nsFrame::Invalidate(nsIPresContext* aPresContext,
|
|
|
|
const nsRect& aDamageRect,
|
|
|
|
PRBool aImmediate) const
|
1998-06-02 05:28:11 +00:00
|
|
|
{
|
1998-08-30 19:16:11 +00:00
|
|
|
nsIViewManager* viewManager = nsnull;
|
1999-08-19 14:36:47 +00: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 05:28:11 +00:00
|
|
|
|
1998-09-24 23:56:15 +00:00
|
|
|
PRUint32 flags = aImmediate ? NS_VMREFRESH_IMMEDIATE : NS_VMREFRESH_NO_SYNC;
|
1999-10-27 03:56:14 +00:00
|
|
|
nsIView* view;
|
|
|
|
|
|
|
|
GetView(aPresContext, &view);
|
|
|
|
if (view) {
|
|
|
|
view->GetViewManager(viewManager);
|
|
|
|
viewManager->UpdateView(view, damageRect, flags);
|
1998-06-02 05:28:11 +00:00
|
|
|
|
|
|
|
} else {
|
1999-08-19 14:36:47 +00:00
|
|
|
nsRect rect(damageRect);
|
1998-08-08 04:23:33 +00:00
|
|
|
nsPoint offset;
|
1998-06-02 05:28:11 +00:00
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
GetOffsetFromView(aPresContext, offset, &view);
|
1998-08-08 04:23:33 +00:00
|
|
|
NS_ASSERTION(nsnull != view, "no view");
|
1998-06-02 05:28:11 +00:00
|
|
|
rect += offset;
|
1998-08-30 19:16:11 +00:00
|
|
|
view->GetViewManager(viewManager);
|
1998-09-24 23:56:15 +00:00
|
|
|
viewManager->UpdateView(view, rect, flags);
|
1998-06-02 05:28:11 +00:00
|
|
|
}
|
1998-08-30 19:16:11 +00:00
|
|
|
|
|
|
|
NS_IF_RELEASE(viewManager);
|
1998-06-02 05:28:11 +00:00
|
|
|
}
|
1998-05-13 22:38:09 +00:00
|
|
|
|
1999-08-27 21:48:06 +00: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;
|
1999-12-06 15:49:53 +00:00
|
|
|
aMetrics.mOverflowArea.x = 0;
|
|
|
|
aMetrics.mOverflowArea.y = 0;
|
|
|
|
aMetrics.mOverflowArea.width = 0;
|
|
|
|
aMetrics.mOverflowArea.height = 0;
|
1999-08-27 21:48:06 +00:00
|
|
|
if (aMetrics.maxElementSize) {
|
|
|
|
aMetrics.maxElementSize->width = 0;
|
|
|
|
aMetrics.maxElementSize->height = 0;
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
mState &= ~NS_FRAME_IS_UNFLOWABLE;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-05-13 22:38:09 +00:00
|
|
|
// Style sizing methods
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::IsPercentageBase(PRBool& aBase) const
|
1998-05-13 22:38:09 +00:00
|
|
|
{
|
1998-06-05 06:09:09 +00:00
|
|
|
const nsStylePosition* position;
|
|
|
|
GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)position);
|
1998-05-13 22:38:09 +00:00
|
|
|
if (position->mPosition != NS_STYLE_POSITION_NORMAL) {
|
|
|
|
aBase = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
1998-06-05 06:09:09 +00:00
|
|
|
const nsStyleDisplay* display;
|
|
|
|
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display);
|
1998-05-13 22:38:09 +00:00
|
|
|
if ((display->mDisplay == NS_STYLE_DISPLAY_BLOCK) ||
|
1999-01-13 06:37:31 +00:00
|
|
|
(display->mDisplay == NS_STYLE_DISPLAY_LIST_ITEM) ||
|
|
|
|
(display->mDisplay == NS_STYLE_DISPLAY_TABLE_CELL)) {
|
1998-05-13 22:38:09 +00:00
|
|
|
aBase = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aBase = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
// Sibling pointer used to link together frames
|
|
|
|
|
1999-02-10 06:13:38 +00:00
|
|
|
NS_IMETHODIMP nsFrame::GetNextSibling(nsIFrame** aNextSibling) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-10 06:13:38 +00:00
|
|
|
NS_PRECONDITION(nsnull != aNextSibling, "null OUT parameter pointer");
|
|
|
|
*aNextSibling = mNextSibling;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::SetNextSibling(nsIFrame* aNextSibling)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-02-01 17:31:10 +00:00
|
|
|
NS_ASSERTION(aNextSibling != this, "attempt to create circular frame list");
|
1998-04-13 20:24:54 +00:00
|
|
|
mNextSibling = aNextSibling;
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-10-09 23:46:02 +00:00
|
|
|
NS_IMETHODIMP nsFrame::Scrolled(nsIView *aView)
|
1998-09-05 20:57:57 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-08 20:35:16 +00:00
|
|
|
PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsIContent* content;
|
|
|
|
PRInt32 result = -1;
|
|
|
|
|
1999-02-10 00:42:56 +00:00
|
|
|
aFrame->GetContent(&content);
|
1998-10-08 20:35:16 +00:00
|
|
|
if (nsnull != content) {
|
|
|
|
nsIContent* parentContent;
|
|
|
|
|
|
|
|
content->GetParent(parentContent);
|
|
|
|
if (nsnull != parentContent) {
|
|
|
|
parentContent->IndexOf(content, result);
|
|
|
|
NS_RELEASE(parentContent);
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef NS_DEBUG
|
1998-04-13 20:24:54 +00:00
|
|
|
// Debugging
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-01-16 00:00:50 +00:00
|
|
|
IndentBy(out, aIndent);
|
|
|
|
ListTag(out);
|
1999-10-27 03:56:14 +00:00
|
|
|
|
|
|
|
nsIView* view;
|
|
|
|
GetView(aPresContext, &view);
|
|
|
|
if (view) {
|
|
|
|
fprintf(out, " [view=%p]", view);
|
1999-01-16 00:00:50 +00:00
|
|
|
}
|
1999-03-05 04:22:54 +00:00
|
|
|
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
|
1999-01-16 00:00:50 +00:00
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
1998-05-18 16:53:09 +00:00
|
|
|
}
|
1999-05-03 20:51:30 +00:00
|
|
|
fputs("\n", out);
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::GetFrameName(nsString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName("Frame", aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFrame::MakeFrameName(const char* aType, nsString& aResult) const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-04-03 11:39:09 +00:00
|
|
|
aResult.AssignWithConversion(aType);
|
1998-11-12 23:03:35 +00:00
|
|
|
if (nsnull != mContent) {
|
|
|
|
nsIAtom* tag;
|
|
|
|
mContent->GetTag(tag);
|
1999-01-22 22:48:00 +00:00
|
|
|
if ((tag != nsnull) && (tag != nsLayoutAtoms::textTagName)) {
|
2000-04-03 11:39:09 +00:00
|
|
|
aResult.AppendWithConversion("(");
|
1998-11-12 23:03:35 +00:00
|
|
|
nsAutoString buf;
|
|
|
|
tag->ToString(buf);
|
1998-11-19 17:22:29 +00:00
|
|
|
aResult.Append(buf);
|
1998-11-12 23:03:35 +00:00
|
|
|
NS_RELEASE(tag);
|
2000-04-03 11:39:09 +00:00
|
|
|
aResult.AppendWithConversion(")");
|
1998-11-12 23:03:35 +00:00
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-11-19 17:22:29 +00:00
|
|
|
char buf[40];
|
1998-11-19 18:51:53 +00:00
|
|
|
PR_snprintf(buf, sizeof(buf), "(%d)", ContentIndexInContainer(this));
|
2000-04-03 11:39:09 +00:00
|
|
|
aResult.AppendWithConversion(buf);
|
1998-11-19 17:22:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-11-19 17:22:29 +00:00
|
|
|
|
1998-11-19 17:55:22 +00:00
|
|
|
void
|
|
|
|
nsFrame::XMLQuote(nsString& aString)
|
|
|
|
{
|
|
|
|
PRInt32 i, len = aString.Length();
|
|
|
|
for (i = 0; i < len; i++) {
|
1999-04-20 07:20:21 +00:00
|
|
|
PRUnichar ch = aString.CharAt(i);
|
1998-11-19 17:55:22 +00:00
|
|
|
if (ch == '<') {
|
2000-04-03 11:39:09 +00:00
|
|
|
nsAutoString tmp; tmp.AssignWithConversion("<");
|
1998-11-19 17:55:22 +00:00
|
|
|
aString.Cut(i, 1);
|
|
|
|
aString.Insert(tmp, i);
|
|
|
|
len += 3;
|
|
|
|
i += 3;
|
|
|
|
}
|
|
|
|
else if (ch == '>') {
|
2000-04-03 11:39:09 +00:00
|
|
|
nsAutoString tmp; tmp.AssignWithConversion(">");
|
1998-11-19 17:55:22 +00:00
|
|
|
aString.Cut(i, 1);
|
|
|
|
aString.Insert(tmp, i);
|
|
|
|
len += 3;
|
|
|
|
i += 3;
|
|
|
|
}
|
1999-02-04 16:28:36 +00:00
|
|
|
else if (ch == '\"') {
|
2000-04-03 11:39:09 +00:00
|
|
|
nsAutoString tmp; tmp.AssignWithConversion(""");
|
1998-11-19 17:55:22 +00:00
|
|
|
aString.Cut(i, 1);
|
|
|
|
aString.Insert(tmp, i);
|
|
|
|
len += 5;
|
|
|
|
i += 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-01 23:04:13 +00:00
|
|
|
PRBool
|
|
|
|
nsFrame::ParentDisablesSelection() const
|
|
|
|
{
|
1999-09-20 21:47:37 +00:00
|
|
|
return PR_FALSE;//depricating method perhaps.
|
|
|
|
/*
|
1999-06-01 23:04:13 +00:00
|
|
|
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
|
1999-09-20 21:47:37 +00:00
|
|
|
*/
|
1999-06-01 23:04:13 +00:00
|
|
|
}
|
|
|
|
|
2000-05-04 08:35:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFrame::GetSelectionController(nsIPresContext *aPresContext, nsISelectionController **aSelCon)
|
|
|
|
{
|
|
|
|
if (!aPresContext || !aSelCon)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
nsFrameState state;
|
|
|
|
GetFrameState(&state);
|
|
|
|
if (state & NS_FRAME_INDEPENDENT_SELECTION)
|
|
|
|
{
|
|
|
|
nsIFrame *tmp = this;
|
2000-05-05 02:38:03 +00:00
|
|
|
while ( NS_SUCCEEDED(tmp->GetParent(&tmp)) && tmp)
|
2000-05-04 08:35:42 +00:00
|
|
|
{
|
2000-05-11 04:25:43 +00:00
|
|
|
nsIGfxTextControlFrame2 *tcf;
|
|
|
|
if (NS_SUCCEEDED(tmp->QueryInterface(nsIGfxTextControlFrame2::GetIID(),(void**)&tcf)))
|
2000-05-04 08:35:42 +00:00
|
|
|
{
|
2000-05-11 04:25:43 +00:00
|
|
|
return tcf->GetSelectionController(aSelCon);
|
2000-05-04 08:35:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-05-11 04:25:43 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
if (NS_SUCCEEDED(aPresContext->GetShell(getter_AddRefs(shell))) && shell)
|
2000-05-04 08:35:42 +00:00
|
|
|
{
|
2000-05-11 04:25:43 +00:00
|
|
|
nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(shell);
|
|
|
|
NS_IF_ADDREF(*aSelCon = selCon);
|
|
|
|
return NS_OK;
|
2000-05-04 08:35:42 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef NS_DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
1999-10-27 03:56:14 +00:00
|
|
|
nsFrame::DumpRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
|
|
|
IndentBy(out, aIndent);
|
1999-02-08 17:56:00 +00:00
|
|
|
fprintf(out, "<frame va=\"%ld\" type=\"", PRUptrdiff(this));
|
1998-11-19 17:22:29 +00:00
|
|
|
nsAutoString name;
|
|
|
|
GetFrameName(name);
|
1998-11-19 17:55:22 +00:00
|
|
|
XMLQuote(name);
|
1998-11-19 17:22:29 +00:00
|
|
|
fputs(name, out);
|
1999-02-08 17:56:00 +00:00
|
|
|
fprintf(out, "\" state=\"%d\" parent=\"%ld\">\n",
|
|
|
|
mState, PRUptrdiff(mParent));
|
1998-11-19 17:22:29 +00:00
|
|
|
|
|
|
|
aIndent++;
|
1999-10-27 03:56:14 +00:00
|
|
|
DumpBaseRegressionData(aPresContext, out, aIndent);
|
1998-11-19 17:22:29 +00:00
|
|
|
aIndent--;
|
|
|
|
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fprintf(out, "</frame>\n");
|
1998-05-05 23:56:50 +00:00
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
void
|
1999-10-27 03:56:14 +00:00
|
|
|
nsFrame::DumpBaseRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mNextSibling) {
|
|
|
|
IndentBy(out, aIndent);
|
1999-02-08 17:56:00 +00:00
|
|
|
fprintf(out, "<next-sibling va=\"%ld\"/>\n", PRUptrdiff(mNextSibling));
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
|
|
|
|
1999-10-27 03:56:14 +00:00
|
|
|
nsIView* view;
|
|
|
|
GetView(aPresContext, &view);
|
|
|
|
if (view) {
|
1998-11-19 17:22:29 +00:00
|
|
|
IndentBy(out, aIndent);
|
1999-10-27 03:56:14 +00:00
|
|
|
fprintf(out, "<view va=\"%ld\">\n", PRUptrdiff(view));
|
1998-11-19 17:22:29 +00: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 17:56:00 +00:00
|
|
|
fprintf(out, "<bbox x=\"%d\" y=\"%d\" w=\"%d\" h=\"%d\"/>\n",
|
1998-11-19 17:22:29 +00: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 {
|
2000-01-22 01:16:50 +00:00
|
|
|
nsresult rv = FirstChild(aPresContext, list, &kid);
|
1998-11-19 17:22:29 +00: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 17:55:22 +00:00
|
|
|
XMLQuote(listName);
|
1998-11-19 17:22:29 +00:00
|
|
|
fputs(listName, out);
|
|
|
|
fprintf(out, "\">\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(out, "<child-list>\n");
|
|
|
|
}
|
|
|
|
aIndent++;
|
|
|
|
while (nsnull != kid) {
|
1999-11-01 22:12:45 +00:00
|
|
|
nsIFrameDebug* frameDebug;
|
|
|
|
|
2000-02-02 22:24:56 +00:00
|
|
|
if (NS_SUCCEEDED(kid->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) {
|
1999-11-01 22:12:45 +00:00
|
|
|
frameDebug->DumpRegressionData(aPresContext, out, aIndent);
|
|
|
|
}
|
1999-02-10 06:13:38 +00:00
|
|
|
kid->GetNextSibling(&kid);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
|
|
|
aIndent--;
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fprintf(out, "</child-list>\n");
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(list);
|
1999-02-10 02:25:01 +00:00
|
|
|
GetAdditionalChildListName(listIndex++, &list);
|
1998-11-19 17:22:29 +00:00
|
|
|
} while (nsnull != list);
|
|
|
|
}
|
|
|
|
|
1999-08-31 03:09:40 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 01:02:16 +00:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 03:09:40 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
*aResult = sizeof(*this);
|
|
|
|
#else
|
|
|
|
*aResult = 0;
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
1999-08-31 03:09:40 +00:00
|
|
|
}
|
|
|
|
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::VerifyTree() const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-05-28 19:00:31 +00:00
|
|
|
NS_ASSERTION(0 == (mState & NS_FRAME_IN_REFLOW), "frame is in reflow");
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-04-27 16:44:52 +00:00
|
|
|
|
1999-02-16 02:42:08 +00:00
|
|
|
/*this method may.. invalidate if the state was changed or if aForceRedraw is PR_TRUE
|
|
|
|
it will not update immediately.*/
|
1998-12-14 18:34:14 +00:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsFrame::SetSelected(nsIPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread)
|
1999-05-20 00:52:00 +00:00
|
|
|
{
|
1999-06-01 23:04:13 +00:00
|
|
|
if (aSelected && ParentDisablesSelection())
|
|
|
|
return NS_OK;
|
2000-01-11 19:44:59 +00:00
|
|
|
// check whether style allows selection
|
2000-04-12 03:04:11 +00:00
|
|
|
if (!IsSelectable(this))
|
|
|
|
return NS_OK;
|
2000-01-11 19:44:59 +00:00
|
|
|
|
1999-09-21 22:58:14 +00:00
|
|
|
/* nsresult rv;
|
|
|
|
|
1999-05-20 00:52:00 +00:00
|
|
|
if (eSpreadDown == aSpread){
|
|
|
|
nsIFrame* kid;
|
1999-09-20 21:47:37 +00:00
|
|
|
rv = FirstChild(nsnull, &kid);
|
1999-07-05 20:38:14 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
while (nsnull != kid) {
|
|
|
|
kid->SetSelected(nsnull,aSelected,aSpread);
|
|
|
|
kid->GetNextSibling(&kid);
|
|
|
|
}
|
1999-05-20 00:52:00 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-21 22:58:14 +00:00
|
|
|
*/
|
1999-04-26 04:02:04 +00:00
|
|
|
nsFrameState frameState;
|
|
|
|
GetFrameState(&frameState);
|
1999-06-03 02:09:03 +00:00
|
|
|
PRBool isSelected = ((frameState & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT);
|
|
|
|
if (aSelected == isSelected) //allready set thanks
|
1999-06-01 23:04:13 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-05-20 00:52:00 +00:00
|
|
|
if ( aSelected ){
|
1999-04-26 04:02:04 +00:00
|
|
|
frameState |= NS_FRAME_SELECTED_CONTENT;
|
1999-05-20 00:52:00 +00:00
|
|
|
}
|
1999-04-26 04:02:04 +00:00
|
|
|
else
|
|
|
|
frameState &= ~NS_FRAME_SELECTED_CONTENT;
|
|
|
|
SetFrameState(frameState);
|
|
|
|
nsRect frameRect;
|
|
|
|
GetRect(frameRect);
|
|
|
|
nsRect rect(0, 0, frameRect.width, frameRect.height);
|
1999-10-26 04:44:41 +00:00
|
|
|
Invalidate(aPresContext, rect, PR_FALSE);
|
1999-09-21 22:58:14 +00:00
|
|
|
#if 0
|
1999-09-20 21:47:37 +00:00
|
|
|
if (aRange) {
|
|
|
|
//lets see if the range contains us, if so we must redraw!
|
|
|
|
nsCOMPtr<nsIDOMNode> endNode;
|
|
|
|
nsCOMPtr<nsIDOMNode> startNode;
|
|
|
|
aRange->GetEndParent(getter_AddRefs(endNode));
|
|
|
|
aRange->GetStartParent(getter_AddRefs(startNode));
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
rv = GetContent(getter_AddRefs(content));
|
|
|
|
nsCOMPtr<nsIDOMNode> thisNode;
|
|
|
|
thisNode = do_QueryInterface(content);
|
|
|
|
|
|
|
|
//we must tell the siblings about the set selected call
|
|
|
|
//since the getprimaryframe call is done with this content node.
|
|
|
|
if (thisNode != startNode && thisNode != endNode)
|
|
|
|
{ //whole node selected
|
|
|
|
nsIFrame *frame;
|
|
|
|
rv = GetNextSibling(&frame);
|
|
|
|
while (NS_SUCCEEDED(rv) && frame)
|
|
|
|
{
|
|
|
|
frame->SetSelected(aRange,aSelected,eSpreadDown);
|
|
|
|
rv = frame->GetNextSibling(&frame);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-09-21 22:58:14 +00:00
|
|
|
#endif
|
1998-12-14 18:34:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-01-22 18:58:14 +00:00
|
|
|
NS_IMETHODIMP
|
1999-04-26 04:02:04 +00:00
|
|
|
nsFrame::GetSelected(PRBool *aSelected) const
|
1998-12-14 18:34:14 +00:00
|
|
|
{
|
1999-01-22 18:58:14 +00:00
|
|
|
if (!aSelected )
|
1998-12-14 18:34:14 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-04-26 04:02:04 +00:00
|
|
|
*aSelected = (PRBool)(mState & NS_FRAME_SELECTED_CONTENT);
|
1998-12-14 18:34:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-12 00:02:31 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::GetPointFromOffset(nsIPresContext* inPresContext, nsIRenderingContext* inRendContext, PRInt32 inOffset, nsPoint* outPoint)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(outPoint != nsnull, "Null parameter");
|
|
|
|
nsPoint bottomLeft(0, 0);
|
1999-10-22 00:19:18 +00:00
|
|
|
if (mContent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> newContent;
|
|
|
|
PRInt32 newOffset;
|
|
|
|
nsresult result = mContent->GetParent(*getter_AddRefs(newContent));
|
|
|
|
if (newContent){
|
|
|
|
result = newContent->IndexOf(mContent, newOffset);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
{
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
nsRect rect;
|
|
|
|
result = GetRect(rect);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
{
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if (inOffset > newOffset)
|
|
|
|
bottomLeft.x = rect.width;
|
|
|
|
}
|
|
|
|
}
|
1999-02-12 00:02:31 +00:00
|
|
|
*outPoint = bottomLeft;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-09-11 00:18:02 +00:00
|
|
|
nsFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset, PRBool inHint, PRInt32* outFrameContentOffset, nsIFrame **outChildFrame)
|
1999-02-12 00:02:31 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(outChildFrame && outFrameContentOffset, "Null parameter");
|
1999-09-11 00:18:02 +00:00
|
|
|
*outFrameContentOffset = (PRInt32)inHint;
|
1999-02-12 00:02:31 +00:00
|
|
|
*outChildFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-01-22 18:58:14 +00:00
|
|
|
|
1999-08-24 21:51:47 +00:00
|
|
|
nsresult
|
1999-10-26 04:44:41 +00:00
|
|
|
nsFrame::GetNextPrevLineFromeBlockFrame(nsIPresContext* aPresContext,
|
|
|
|
nsPeekOffsetStruct *aPos,
|
1999-07-15 18:19:03 +00:00
|
|
|
nsIFrame *aBlockFrame,
|
|
|
|
PRInt32 aLineStart,
|
1999-10-13 01:15:26 +00:00
|
|
|
PRInt8 aOutSideLimit
|
1999-07-15 18:19:03 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
//magic numbers aLineStart will be -1 for end of block 0 will be start of block
|
1999-10-13 01:15:26 +00:00
|
|
|
if (!aBlockFrame || !aPos)
|
1999-07-15 18:19:03 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-09-01 01:02:16 +00:00
|
|
|
|
1999-10-13 01:15:26 +00:00
|
|
|
aPos->mResultFrame = nsnull;
|
|
|
|
aPos->mResultContent = nsnull;
|
|
|
|
aPos->mPreferLeft = (aPos->mDirection == eDirNext);
|
|
|
|
|
|
|
|
nsresult result;
|
1999-07-15 18:19:03 +00:00
|
|
|
nsCOMPtr<nsILineIterator> it;
|
2000-02-02 22:24:56 +00:00
|
|
|
result = aBlockFrame->QueryInterface(NS_GET_IID(nsILineIterator),getter_AddRefs(it));
|
1999-07-15 18:19:03 +00:00
|
|
|
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
|
2000-05-11 01:04:39 +00:00
|
|
|
searchingLine = -1;//"next" will be 0
|
1999-07-15 18:19:03 +00:00
|
|
|
else
|
2000-05-11 01:04:39 +00:00
|
|
|
if ((aPos->mDirection == eDirPrevious && searchingLine == 0) ||
|
|
|
|
(aPos->mDirection == eDirNext && searchingLine >= (countLines -1) )){
|
1999-07-15 18:19:03 +00:00
|
|
|
//we need to jump to new block frame.
|
2000-05-11 01:04:39 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-07-15 18:19:03 +00:00
|
|
|
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)
|
|
|
|
{
|
1999-10-13 01:15:26 +00:00
|
|
|
if (aPos->mDirection == eDirPrevious)
|
1999-07-15 18:19:03 +00:00
|
|
|
searchingLine --;
|
|
|
|
else
|
|
|
|
searchingLine ++;
|
1999-10-13 01:15:26 +00:00
|
|
|
if ((aPos->mDirection == eDirPrevious && searchingLine < 0) ||
|
|
|
|
(aPos->mDirection == eDirNext && searchingLine >= countLines ))
|
1999-09-10 18:29:37 +00:00
|
|
|
{
|
2000-05-11 01:04:39 +00:00
|
|
|
//we need to jump to new block frame.
|
1999-09-10 18:29:37 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-10-12 23:25:19 +00:00
|
|
|
PRUint32 lineFlags;
|
|
|
|
result = it->GetLine(searchingLine, &firstFrame, &lineFrameCount,
|
|
|
|
nonUsedRect, &lineFlags);
|
1999-09-10 18:29:37 +00:00
|
|
|
if (!lineFrameCount)
|
|
|
|
continue;
|
1999-07-15 18:19:03 +00:00
|
|
|
if (NS_SUCCEEDED(result)){
|
|
|
|
lastFrame = firstFrame;
|
2000-05-11 01:04:39 +00:00
|
|
|
if(!lastFrame)
|
|
|
|
return NS_ERROR_FAILURE;//XXX this is temporary, to avoid crashing
|
1999-07-15 18:19:03 +00:00
|
|
|
for (;lineFrameCount > 1;lineFrameCount --){
|
2000-05-11 01:04:39 +00:00
|
|
|
//result = lastFrame->GetNextSibling(&lastFrame, searchingLine);
|
|
|
|
result = it->GetNextSibling(lastFrame, searchingLine);
|
1999-07-15 18:19:03 +00:00
|
|
|
if (NS_FAILED(result)){
|
|
|
|
NS_ASSERTION(0,"should not be reached nsFrame\n");
|
|
|
|
continue;
|
|
|
|
}
|
2000-05-11 01:04:39 +00:00
|
|
|
if(!lastFrame)
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
2000-01-22 01:16:50 +00:00
|
|
|
GetLastLeaf(aPresContext, &lastFrame);
|
1999-07-15 18:19:03 +00:00
|
|
|
|
1999-10-13 01:15:26 +00:00
|
|
|
if (aPos->mDirection == eDirNext){
|
1999-07-15 18:19:03 +00:00
|
|
|
nearStoppingFrame = firstFrame;
|
|
|
|
farStoppingFrame = lastFrame;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
nearStoppingFrame = lastFrame;
|
|
|
|
farStoppingFrame = firstFrame;
|
|
|
|
}
|
1999-09-10 18:29:37 +00:00
|
|
|
nsPoint offset;
|
|
|
|
nsIView * view; //used for call of get offset from view
|
1999-10-26 04:44:41 +00:00
|
|
|
aBlockFrame->GetOffsetFromView(aPresContext, offset,&view);
|
1999-10-13 01:15:26 +00:00
|
|
|
nscoord newDesiredX = aPos->mDesiredX - offset.x;//get desired x into blockframe coordinates!
|
1999-09-10 18:29:37 +00:00
|
|
|
result = it->FindFrameAt(searchingLine, newDesiredX, &resultFrame, &isBeforeFirstFrame, &isAfterLastFrame);
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2000-02-02 22:24:56 +00:00
|
|
|
result = resultFrame->QueryInterface(NS_GET_IID(nsILineIterator),getter_AddRefs(newIt));
|
1999-07-15 18:19:03 +00:00
|
|
|
if (NS_SUCCEEDED(result) && newIt)
|
|
|
|
{
|
1999-10-13 01:15:26 +00:00
|
|
|
aPos->mResultFrame = resultFrame;
|
1999-09-01 21:40:16 +00:00
|
|
|
return NS_OK;
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
//resultFrame is not a block frame
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
1999-09-15 20:38:42 +00:00
|
|
|
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal), LEAF,
|
2000-01-22 01:16:50 +00:00
|
|
|
aPresContext, resultFrame);
|
1999-07-15 18:19:03 +00:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
nsISupports *isupports = nsnull;
|
|
|
|
nsIFrame *storeOldResultFrame = resultFrame;
|
|
|
|
while ( !found ){
|
|
|
|
nsCOMPtr<nsIPresContext> context;
|
1999-10-13 01:15:26 +00:00
|
|
|
result = aPos->mTracker->GetPresContext(getter_AddRefs(context));
|
|
|
|
nsPoint point;
|
|
|
|
point.x = aPos->mDesiredX;
|
2000-05-11 01:04:39 +00:00
|
|
|
if(aPos->mDirection == eDirPrevious)
|
|
|
|
{
|
|
|
|
nsRect tempRect;
|
|
|
|
nsRect& tempRectRef = tempRect;
|
|
|
|
resultFrame->GetRect(tempRectRef);
|
|
|
|
nsPoint offset;
|
|
|
|
nsIView * view; //used for call of get offset from view
|
|
|
|
resultFrame->GetOffsetFromView(aPresContext, offset,&view);
|
|
|
|
point.y = tempRect.height + offset.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
point.y = 0;
|
|
|
|
|
2000-04-12 03:04:11 +00:00
|
|
|
result = NS_ERROR_FAILURE;
|
|
|
|
nsIView* view;//if frame has a view. then stop. no doubleclicking into views
|
|
|
|
if (NS_FAILED(resultFrame->GetView(aPresContext, &view)) || !view)
|
|
|
|
{
|
|
|
|
result = resultFrame->GetContentAndOffsetsFromPoint(context,point,
|
1999-10-13 01:15:26 +00:00
|
|
|
getter_AddRefs(aPos->mResultContent),
|
|
|
|
aPos->mContentOffset,
|
|
|
|
aPos->mContentOffsetEnd,
|
|
|
|
aPos->mPreferLeft);
|
2000-04-12 03:04:11 +00:00
|
|
|
}
|
1999-07-15 18:19:03 +00:00
|
|
|
if (NS_SUCCEEDED(result))
|
1999-10-13 01:15:26 +00:00
|
|
|
{
|
1999-07-15 18:19:03 +00:00
|
|
|
found = PR_TRUE;
|
1999-10-13 01:15:26 +00:00
|
|
|
}
|
1999-07-15 18:19:03 +00:00
|
|
|
else {
|
1999-10-13 01:15:26 +00:00
|
|
|
if (aPos->mDirection == eDirPrevious && (resultFrame == farStoppingFrame))
|
1999-07-15 18:19:03 +00:00
|
|
|
break;
|
1999-10-13 01:15:26 +00:00
|
|
|
if (aPos->mDirection == eDirNext && (resultFrame == nearStoppingFrame))
|
1999-07-15 18:19:03 +00:00
|
|
|
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;
|
1999-09-15 20:38:42 +00:00
|
|
|
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal), LEAF,
|
2000-01-22 01:16:50 +00:00
|
|
|
aPresContext, resultFrame);
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
while ( !found ){
|
|
|
|
nsCOMPtr<nsIPresContext> context;
|
1999-10-13 01:15:26 +00:00
|
|
|
result = aPos->mTracker->GetPresContext(getter_AddRefs(context));
|
|
|
|
|
|
|
|
nsPoint point;
|
|
|
|
point.x = aPos->mDesiredX;
|
|
|
|
point.y = 0;
|
1999-07-15 18:19:03 +00:00
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
result = resultFrame->GetContentAndOffsetsFromPoint(context,point,
|
1999-10-13 01:15:26 +00:00
|
|
|
getter_AddRefs(aPos->mResultContent), aPos->mContentOffset,
|
|
|
|
aPos->mContentOffsetEnd, aPos->mPreferLeft);
|
2000-04-12 03:04:11 +00:00
|
|
|
if (!IsSelectable(resultFrame))
|
|
|
|
return NS_ERROR_FAILURE;//cant go to unselectable frame
|
1999-07-15 18:19:03 +00:00
|
|
|
if (NS_SUCCEEDED(result))
|
1999-10-13 01:15:26 +00:00
|
|
|
{
|
1999-07-15 18:19:03 +00:00
|
|
|
found = PR_TRUE;
|
1999-10-13 01:15:26 +00:00
|
|
|
if (resultFrame == farStoppingFrame)
|
|
|
|
aPos->mPreferLeft = PR_FALSE;
|
|
|
|
else
|
|
|
|
aPos->mPreferLeft = PR_TRUE;
|
|
|
|
}
|
1999-07-15 18:19:03 +00:00
|
|
|
else {
|
1999-10-13 01:15:26 +00:00
|
|
|
if (aPos->mDirection == eDirPrevious && (resultFrame == nearStoppingFrame))
|
1999-07-15 18:19:03 +00:00
|
|
|
break;
|
1999-10-13 01:15:26 +00:00
|
|
|
if (aPos->mDirection == eDirNext && (resultFrame == farStoppingFrame))
|
1999-07-15 18:19:03 +00:00
|
|
|
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-10-13 01:15:26 +00:00
|
|
|
aPos->mResultFrame = resultFrame;
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
//we need to jump to new block frame.
|
1999-10-13 01:15:26 +00:00
|
|
|
aPos->mAmount = eSelectLine;
|
|
|
|
aPos->mStartOffset = 0;
|
|
|
|
aPos->mEatingWS = PR_FALSE;
|
|
|
|
aPos->mPreferLeft = !(aPos->mDirection == eDirNext);
|
|
|
|
if (aPos->mDirection == eDirPrevious)
|
|
|
|
aPos->mStartOffset = -1;//start from end
|
1999-10-26 04:44:41 +00:00
|
|
|
return aBlockFrame->PeekOffset(aPresContext, aPos);
|
1999-07-15 18:19:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-02 00:23:40 +00:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsFrame::PeekOffset(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
1999-09-10 18:29:37 +00:00
|
|
|
{
|
|
|
|
if (!aPos || !aPos->mTracker )
|
1999-02-10 18:55:25 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-09-07 18:47:01 +00:00
|
|
|
nsresult result = NS_ERROR_FAILURE;
|
1999-09-25 23:33:02 +00:00
|
|
|
PRInt32 endoffset;
|
1999-10-22 00:19:18 +00:00
|
|
|
nsPoint point;
|
|
|
|
point.x = aPos->mDesiredX;
|
|
|
|
point.y = 0;
|
1999-09-10 18:29:37 +00:00
|
|
|
switch (aPos->mAmount){
|
1999-10-22 00:19:18 +00:00
|
|
|
case eSelectCharacter : case eSelectWord:
|
|
|
|
{
|
|
|
|
if (mContent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContent> newContent;
|
|
|
|
PRInt32 newOffset;
|
|
|
|
result = mContent->GetParent(*getter_AddRefs(newContent));
|
|
|
|
if (newContent){
|
|
|
|
aPos->mResultContent = newContent;
|
|
|
|
result = newContent->IndexOf(mContent, newOffset);
|
|
|
|
if (aPos->mStartOffset < 0)//start at "end"
|
|
|
|
aPos->mStartOffset = newOffset + 1;
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
{
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if ((aPos->mDirection == eDirNext && newOffset < aPos->mStartOffset) || //need to go to next one
|
|
|
|
(aPos->mDirection == eDirPrevious && newOffset >= aPos->mStartOffset))
|
|
|
|
{
|
2000-01-22 01:16:50 +00:00
|
|
|
result = GetFrameFromDirection(aPresContext, aPos);
|
2000-04-12 03:04:11 +00:00
|
|
|
if (NS_FAILED(result) || !aPos->mResultFrame || !IsSelectable(aPos->mResultFrame))
|
1999-10-22 00:19:18 +00:00
|
|
|
{
|
|
|
|
return result?result:NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-10-26 04:44:41 +00:00
|
|
|
return aPos->mResultFrame->PeekOffset(aPresContext, aPos);
|
1999-10-22 00:19:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (aPos->mDirection == eDirNext)
|
|
|
|
aPos->mContentOffset = newOffset +1;
|
|
|
|
else
|
|
|
|
aPos->mContentOffset = newOffset;//to beginning of frame
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}//drop into no amount
|
1999-09-25 23:33:02 +00:00
|
|
|
case eSelectNoAmount:
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPresContext> context;
|
|
|
|
result = aPos->mTracker->GetPresContext(getter_AddRefs(context));
|
|
|
|
if (NS_FAILED(result) || !context)
|
|
|
|
return result;
|
1999-11-24 06:03:41 +00:00
|
|
|
result = GetContentAndOffsetsFromPoint(context,point,
|
1999-09-25 23:33:02 +00:00
|
|
|
getter_AddRefs(aPos->mResultContent),
|
|
|
|
aPos->mContentOffset,
|
1999-10-13 01:15:26 +00:00
|
|
|
endoffset,
|
|
|
|
aPos->mPreferLeft);
|
1999-09-25 23:33:02 +00:00
|
|
|
}break;
|
1999-06-19 20:36:44 +00:00
|
|
|
case eSelectLine :
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsILineIterator> it;
|
|
|
|
nsIFrame *blockFrame = this;
|
|
|
|
nsIFrame *thisBlock = this;
|
1999-07-15 18:19:03 +00:00
|
|
|
PRInt32 thisLine;
|
1999-06-19 20:36:44 +00:00
|
|
|
|
1999-07-15 18:19:03 +00:00
|
|
|
while (NS_FAILED(result)){
|
1999-09-07 18:47:01 +00:00
|
|
|
thisBlock = blockFrame;
|
1999-07-15 18:19:03 +00:00
|
|
|
result = blockFrame->GetParent(&blockFrame);
|
|
|
|
if (NS_FAILED(result) || !blockFrame) //if at line 0 then nothing to do
|
|
|
|
return result;
|
2000-02-02 22:24:56 +00:00
|
|
|
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator),getter_AddRefs(it));
|
1999-07-15 18:19:03 +00:00
|
|
|
while (NS_FAILED(result) && blockFrame)
|
1999-06-19 20:36:44 +00:00
|
|
|
{
|
1999-07-15 18:19:03 +00:00
|
|
|
thisBlock = blockFrame;
|
|
|
|
result = blockFrame->GetParent(&blockFrame);
|
|
|
|
if (NS_SUCCEEDED(result) && blockFrame){
|
2000-02-02 22:24:56 +00:00
|
|
|
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator),getter_AddRefs(it));
|
1999-06-19 20:36:44 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-01 21:40:16 +00:00
|
|
|
//this block is now one child down from blockframe
|
|
|
|
if (NS_FAILED(result) || !it || !blockFrame || !thisBlock)
|
2000-01-08 00:31:32 +00:00
|
|
|
return ((result) ? result : NS_ERROR_FAILURE);
|
1999-07-15 18:19:03 +00:00
|
|
|
result = it->FindLineContaining(thisBlock, &thisLine);
|
1999-09-07 18:47:01 +00:00
|
|
|
if (NS_FAILED(result) || thisLine <0)
|
1999-07-15 18:19:03 +00:00
|
|
|
return result;
|
1999-09-01 21:40:16 +00:00
|
|
|
int edgeCase = 0;//no edge case. this should look at thisLine
|
|
|
|
PRBool doneLooping = PR_FALSE;//tells us when no more block frames hit.
|
|
|
|
//this part will find a frame or a block frame. if its a block frame
|
|
|
|
//it will "drill down" to find a viable frame or it will return an error.
|
|
|
|
do {
|
1999-09-10 18:29:37 +00:00
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
result = GetNextPrevLineFromeBlockFrame(aPresContext,
|
|
|
|
aPos,
|
1999-07-15 18:19:03 +00:00
|
|
|
blockFrame,
|
|
|
|
thisLine,
|
1999-10-13 01:15:26 +00:00
|
|
|
edgeCase //start from thisLine
|
1999-07-15 18:19:03 +00:00
|
|
|
);
|
1999-09-22 06:12:44 +00:00
|
|
|
if (aPos->mResultFrame == this)//we came back to same spot! keep going
|
|
|
|
{
|
|
|
|
aPos->mResultFrame = nsnull;
|
|
|
|
if (aPos->mDirection == eDirPrevious)
|
|
|
|
thisLine--;
|
|
|
|
else
|
|
|
|
thisLine++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
doneLooping = PR_TRUE; //do not continue with while loop
|
1999-09-10 18:29:37 +00:00
|
|
|
if (NS_SUCCEEDED(result) && aPos->mResultFrame){
|
2000-02-02 22:24:56 +00:00
|
|
|
result = aPos->mResultFrame->QueryInterface(NS_GET_IID(nsILineIterator),getter_AddRefs(it));
|
1999-09-01 21:40:16 +00:00
|
|
|
if (NS_SUCCEEDED(result) && it)//we have struck another block element!
|
|
|
|
{
|
|
|
|
doneLooping = PR_FALSE;
|
1999-09-10 18:29:37 +00:00
|
|
|
if (aPos->mDirection == eDirPrevious)
|
1999-09-01 21:40:16 +00:00
|
|
|
edgeCase = 1;//far edge, search from end backwards
|
|
|
|
else
|
|
|
|
edgeCase = -1;//near edge search from beginning onwards
|
|
|
|
thisLine=0;//this line means nothing now.
|
|
|
|
//everything else means something so keep looking "inside" the block
|
1999-09-10 18:29:37 +00:00
|
|
|
blockFrame = aPos->mResultFrame;
|
1999-09-01 21:40:16 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = NS_OK;//THIS is to mean that everything is ok to the containing while loop
|
|
|
|
}
|
|
|
|
}while(!doneLooping);
|
1999-07-15 18:19:03 +00:00
|
|
|
|
1999-06-19 20:36:44 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1999-09-07 23:40:17 +00:00
|
|
|
case eSelectBeginLine:
|
|
|
|
case eSelectEndLine:
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsILineIterator> it;
|
|
|
|
nsIFrame *blockFrame = this;
|
|
|
|
nsIFrame *thisBlock = this;
|
|
|
|
PRInt32 thisLine;
|
|
|
|
result = blockFrame->GetParent(&blockFrame);
|
|
|
|
if (NS_FAILED(result) || !blockFrame) //if at line 0 then nothing to do
|
|
|
|
return result;
|
2000-02-02 22:24:56 +00:00
|
|
|
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator),getter_AddRefs(it));
|
1999-09-07 23:40:17 +00:00
|
|
|
while (NS_FAILED(result) && blockFrame)
|
|
|
|
{
|
|
|
|
thisBlock = blockFrame;
|
|
|
|
result = blockFrame->GetParent(&blockFrame);
|
|
|
|
if (NS_SUCCEEDED(result) && blockFrame){
|
2000-02-02 22:24:56 +00:00
|
|
|
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator),getter_AddRefs(it));
|
1999-09-07 23:40:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//this block is now one child down from blockframe
|
|
|
|
if (NS_FAILED(result) || !it || !blockFrame || !thisBlock)
|
|
|
|
return result;
|
|
|
|
result = it->FindLineContaining(thisBlock, &thisLine);
|
|
|
|
if (NS_FAILED(result) || thisLine < 0 )
|
|
|
|
return result;
|
|
|
|
nsCOMPtr<nsIPresContext> context;
|
1999-09-10 18:29:37 +00:00
|
|
|
result = aPos->mTracker->GetPresContext(getter_AddRefs(context));
|
1999-09-07 23:40:17 +00:00
|
|
|
if (NS_FAILED(result) || !context)
|
|
|
|
return result;
|
|
|
|
PRInt32 lineFrameCount;
|
|
|
|
nsIFrame *firstFrame;
|
|
|
|
nsRect usedRect;
|
1999-10-12 23:25:19 +00:00
|
|
|
PRUint32 lineFlags;
|
|
|
|
result = it->GetLine(thisLine, &firstFrame, &lineFrameCount,usedRect,
|
|
|
|
&lineFlags);
|
1999-09-10 18:29:37 +00:00
|
|
|
if (eSelectBeginLine == aPos->mAmount)
|
1999-09-07 23:40:17 +00:00
|
|
|
{
|
|
|
|
if (firstFrame)
|
|
|
|
{
|
1999-10-22 00:19:18 +00:00
|
|
|
nsPoint offsetPoint; //used for offset of result frame
|
|
|
|
nsIView * view; //used for call of get offset from view
|
1999-10-26 04:44:41 +00:00
|
|
|
firstFrame->GetOffsetFromView(aPresContext, offsetPoint, &view);
|
1999-10-22 00:19:18 +00:00
|
|
|
|
1999-10-22 14:51:41 +00:00
|
|
|
offsetPoint.x = 0;//all the way to the left
|
1999-11-24 06:03:41 +00:00
|
|
|
result = firstFrame->GetContentAndOffsetsFromPoint(context,
|
1999-10-22 14:51:41 +00:00
|
|
|
offsetPoint,
|
1999-09-15 20:38:42 +00:00
|
|
|
getter_AddRefs(aPos->mResultContent),
|
|
|
|
aPos->mContentOffset,
|
1999-10-13 01:15:26 +00:00
|
|
|
endoffset,
|
|
|
|
aPos->mPreferLeft);
|
1999-09-07 23:40:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (firstFrame)
|
|
|
|
{
|
1999-09-15 01:57:50 +00:00
|
|
|
PRBool found = PR_FALSE;
|
|
|
|
while(!found)
|
|
|
|
{
|
|
|
|
nsIFrame *nextFrame = firstFrame;;
|
|
|
|
for (PRInt32 i=1;i<lineFrameCount;i++)//allready have 1st frame
|
|
|
|
nextFrame->GetNextSibling(&nextFrame);
|
|
|
|
|
|
|
|
nsPoint offsetPoint; //used for offset of result frame
|
|
|
|
nsIView * view; //used for call of get offset from view
|
1999-10-26 04:44:41 +00:00
|
|
|
nextFrame->GetOffsetFromView(aPresContext, offsetPoint, &view);
|
1999-09-15 01:57:50 +00:00
|
|
|
|
2000-04-12 03:04:11 +00:00
|
|
|
offsetPoint.x += 2* usedRect.width; //2* just to be sure we are off the edge
|
1999-10-13 01:15:26 +00:00
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
result = nextFrame->GetContentAndOffsetsFromPoint(context,
|
1999-10-22 14:51:41 +00:00
|
|
|
offsetPoint,
|
1999-09-15 20:38:42 +00:00
|
|
|
getter_AddRefs(aPos->mResultContent),
|
|
|
|
aPos->mContentOffset,
|
1999-10-13 01:15:26 +00:00
|
|
|
endoffset,
|
|
|
|
aPos->mPreferLeft);
|
1999-09-15 01:57:50 +00:00
|
|
|
if (NS_SUCCEEDED(result))
|
|
|
|
found = PR_TRUE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lineFrameCount--;
|
|
|
|
if (lineFrameCount == 0)
|
|
|
|
break;//just fail out
|
|
|
|
}
|
|
|
|
}
|
1999-09-07 23:40:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}break;
|
1999-10-22 00:19:18 +00:00
|
|
|
|
1999-06-19 20:36:44 +00:00
|
|
|
default:
|
|
|
|
{
|
1999-10-22 00:19:18 +00:00
|
|
|
if (NS_SUCCEEDED(result))
|
1999-10-26 04:44:41 +00:00
|
|
|
result = aPos->mResultFrame->PeekOffset(aPresContext, aPos);
|
1999-10-22 00:19:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
1999-09-22 04:12:23 +00:00
|
|
|
|
1999-10-22 00:19:18 +00:00
|
|
|
PRInt32
|
|
|
|
nsFrame::GetLineNumber(nsIFrame *aFrame)
|
|
|
|
{
|
|
|
|
nsIFrame *blockFrame = aFrame;
|
|
|
|
nsIFrame *thisBlock;
|
|
|
|
PRInt32 thisLine;
|
|
|
|
nsCOMPtr<nsILineIterator> it;
|
|
|
|
nsresult result = NS_ERROR_FAILURE;
|
|
|
|
while (NS_FAILED(result) && blockFrame)
|
|
|
|
{
|
|
|
|
thisBlock = blockFrame;
|
|
|
|
result = blockFrame->GetParent(&blockFrame);
|
|
|
|
if (NS_SUCCEEDED(result) && blockFrame){
|
2000-02-02 22:24:56 +00:00
|
|
|
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator),getter_AddRefs(it));
|
1999-10-22 00:19:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
blockFrame = nsnull;
|
|
|
|
}
|
|
|
|
if (!blockFrame || !it)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
result = it->FindLineContaining(thisBlock, &thisLine);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return -1;
|
|
|
|
return thisLine;
|
|
|
|
}
|
1999-09-22 04:12:23 +00:00
|
|
|
|
|
|
|
|
1999-10-22 00:19:18 +00:00
|
|
|
//this will use the nsFrameTraversal as the default peek method.
|
|
|
|
//this should change to use geometry and also look to ALL the child lists
|
|
|
|
//we need to set up line information to make sure we dont jump across line boundaries
|
|
|
|
NS_IMETHODIMP
|
2000-01-22 01:16:50 +00:00
|
|
|
nsFrame::GetFrameFromDirection(nsIPresContext* aPresContext, nsPeekOffsetStruct *aPos)
|
1999-10-22 00:19:18 +00:00
|
|
|
{
|
|
|
|
nsIFrame *blockFrame = this;
|
|
|
|
nsIFrame *thisBlock;
|
|
|
|
PRInt32 thisLine;
|
|
|
|
nsCOMPtr<nsILineIterator> it;
|
|
|
|
nsresult result = NS_ERROR_FAILURE;
|
|
|
|
while (NS_FAILED(result) && blockFrame)
|
|
|
|
{
|
|
|
|
thisBlock = blockFrame;
|
|
|
|
result = blockFrame->GetParent(&blockFrame);
|
|
|
|
if (NS_SUCCEEDED(result) && blockFrame){
|
2000-02-02 22:24:56 +00:00
|
|
|
result = blockFrame->QueryInterface(NS_GET_IID(nsILineIterator),getter_AddRefs(it));
|
1999-10-22 00:19:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
blockFrame = nsnull;
|
|
|
|
}
|
|
|
|
if (!blockFrame || !it)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
result = it->FindLineContaining(thisBlock, &thisLine);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
1999-09-22 04:12:23 +00:00
|
|
|
|
1999-10-22 00:19:18 +00:00
|
|
|
nsIFrame *firstFrame;
|
|
|
|
nsIFrame *lastFrame;
|
|
|
|
nsRect nonUsedRect;
|
|
|
|
PRInt32 lineFrameCount;
|
|
|
|
PRUint32 lineFlags;
|
1999-09-22 04:12:23 +00:00
|
|
|
|
1999-10-22 00:19:18 +00:00
|
|
|
result = it->GetLine(thisLine, &firstFrame, &lineFrameCount,nonUsedRect,
|
|
|
|
&lineFlags);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
1999-06-19 20:36:44 +00:00
|
|
|
|
1999-10-22 00:19:18 +00:00
|
|
|
lastFrame = firstFrame;
|
|
|
|
for (;lineFrameCount > 1;lineFrameCount --){
|
|
|
|
result = lastFrame->GetNextSibling(&lastFrame);
|
|
|
|
if (NS_FAILED(result)){
|
|
|
|
NS_ASSERTION(0,"should not be reached nsFrame\n");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-22 01:16:50 +00:00
|
|
|
GetFirstLeaf(aPresContext, &firstFrame);
|
|
|
|
GetLastLeaf(aPresContext, &lastFrame);
|
1999-10-22 00:19:18 +00:00
|
|
|
//END LINE DATA CODE
|
|
|
|
if ((aPos->mDirection == eDirNext && lastFrame == this)
|
|
|
|
||(aPos->mDirection == eDirPrevious && firstFrame == this))
|
|
|
|
{
|
|
|
|
if (aPos->mJumpLines != PR_TRUE)
|
|
|
|
return NS_ERROR_FAILURE;//we are done. cannot jump lines
|
|
|
|
if (aPos->mAmount != eSelectWord)
|
|
|
|
{
|
|
|
|
aPos->mPreferLeft = (PRBool)!(aPos->mPreferLeft);//drift to other side
|
|
|
|
aPos->mAmount = eSelectNoAmount;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if (aPos->mEatingWS)//done finding what we wanted
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
if (aPos->mDirection == eDirNext)
|
1999-09-22 04:12:23 +00:00
|
|
|
{
|
1999-10-22 00:19:18 +00:00
|
|
|
aPos->mPreferLeft = (PRBool)!(aPos->mPreferLeft);//drift to other side
|
|
|
|
aPos->mAmount = eSelectNoAmount;
|
1999-09-22 04:12:23 +00:00
|
|
|
}
|
1999-06-19 20:36:44 +00:00
|
|
|
}
|
1999-10-22 00:19:18 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
if (aPos->mAmount == eSelectDir)
|
|
|
|
aPos->mAmount = eSelectNoAmount;//just get to next frame.
|
|
|
|
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
|
2000-01-22 01:16:50 +00:00
|
|
|
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),LEAF, aPresContext, this);
|
1999-10-22 00:19:18 +00:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
nsISupports *isupports = nsnull;
|
|
|
|
if (aPos->mDirection == 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;
|
2000-04-12 03:04:11 +00:00
|
|
|
if (!IsSelectable(newFrame))
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-10-22 00:19:18 +00:00
|
|
|
if (aPos->mDirection == eDirNext)
|
|
|
|
aPos->mStartOffset = 0;
|
|
|
|
else
|
|
|
|
aPos->mStartOffset = -1;
|
|
|
|
aPos->mResultFrame = newFrame;
|
|
|
|
return NS_OK;
|
1999-02-02 00:23:40 +00:00
|
|
|
}
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
nsresult nsFrame::GetClosestViewForFrame(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame *aFrame,
|
|
|
|
nsIView **aView)
|
1999-09-29 20:04:05 +00:00
|
|
|
{
|
|
|
|
if (!aView)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
|
|
|
|
*aView = 0;
|
|
|
|
|
|
|
|
nsIFrame *parent = aFrame;
|
|
|
|
|
|
|
|
while (parent && !*aView)
|
|
|
|
{
|
1999-10-26 04:44:41 +00:00
|
|
|
result = parent->GetView(aPresContext, aView);
|
1999-09-29 20:04:05 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
if (!*aView)
|
|
|
|
{
|
|
|
|
result = parent->GetParent(&parent);
|
|
|
|
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-01-12 08:28:24 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0, "nsFrame::ReflowDirtyChild() should never be called.");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
1998-04-27 16:44:52 +00:00
|
|
|
//-----------------------------------------------------------------------------------
|
|
|
|
|
1998-08-03 22:22:27 +00:00
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Refreshes each content's frame
|
|
|
|
*********************************************************/
|
1999-10-26 04:44:41 +00:00
|
|
|
static void RefreshAllContentFrames(nsIPresContext* aPresContext, nsIFrame * aFrame, nsIContent * aContent)
|
1998-08-03 22:22:27 +00:00
|
|
|
{
|
|
|
|
nsIContent* frameContent;
|
1999-02-10 00:42:56 +00:00
|
|
|
aFrame->GetContent(&frameContent);
|
1998-08-03 22:22:27 +00:00
|
|
|
if (frameContent == aContent) {
|
1999-10-26 04:44:41 +00:00
|
|
|
ForceDrawFrame(aPresContext, (nsFrame *)aFrame);
|
1998-08-03 22:22:27 +00:00
|
|
|
}
|
1998-11-12 23:03:35 +00:00
|
|
|
NS_IF_RELEASE(frameContent);
|
1998-08-03 22:22:27 +00:00
|
|
|
|
2000-01-22 01:16:50 +00:00
|
|
|
aFrame->FirstChild(aPresContext, nsnull, &aFrame);
|
1998-08-03 22:22:27 +00:00
|
|
|
while (aFrame) {
|
1999-10-26 04:44:41 +00:00
|
|
|
RefreshAllContentFrames(aPresContext, aFrame, aContent);
|
1999-02-10 06:13:38 +00:00
|
|
|
aFrame->GetNextSibling(&aFrame);
|
1998-08-03 22:22:27 +00:00
|
|
|
}
|
1998-05-08 18:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************
|
|
|
|
* Refreshes each content's frame
|
|
|
|
*********************************************************/
|
1998-04-27 16:44:52 +00:00
|
|
|
|
1998-05-08 18:33:42 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
1999-10-26 04:44:41 +00:00
|
|
|
void ForceDrawFrame(nsIPresContext* aPresContext, nsFrame * aFrame)//, PRBool)
|
1998-05-08 18:33:42 +00:00
|
|
|
{
|
|
|
|
if (aFrame == nsnull) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsRect rect;
|
|
|
|
nsIView * view;
|
|
|
|
nsPoint pnt;
|
1999-10-26 04:44:41 +00:00
|
|
|
aFrame->GetOffsetFromView(aPresContext, pnt, &view);
|
1998-05-08 18:33:42 +00:00
|
|
|
aFrame->GetRect(rect);
|
|
|
|
rect.x = pnt.x;
|
|
|
|
rect.y = pnt.y;
|
|
|
|
if (view != nsnull) {
|
1998-08-30 19:16:11 +00:00
|
|
|
nsIViewManager * viewMgr;
|
|
|
|
view->GetViewManager(viewMgr);
|
1998-05-08 18:33:42 +00:00
|
|
|
if (viewMgr != nsnull) {
|
|
|
|
viewMgr->UpdateView(view, rect, 0);
|
1998-08-03 22:22:27 +00:00
|
|
|
NS_RELEASE(viewMgr);
|
1998-05-08 18:33:42 +00:00
|
|
|
}
|
1998-08-03 22:22:27 +00:00
|
|
|
//viewMgr->UpdateView(view, rect, NS_VMREFRESH_DOUBLE_BUFFER | NS_VMREFRESH_IMMEDIATE);
|
1998-05-08 18:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-10-22 00:19:18 +00:00
|
|
|
void
|
2000-01-22 01:16:50 +00:00
|
|
|
nsFrame::GetLastLeaf(nsIPresContext* aPresContext, nsIFrame **aFrame)
|
1999-07-15 18:19:03 +00:00
|
|
|
{
|
|
|
|
if (!aFrame || !*aFrame)
|
|
|
|
return;
|
|
|
|
nsIFrame *child = *aFrame;
|
|
|
|
nsresult result;
|
|
|
|
nsIFrame *lookahead = nsnull;
|
|
|
|
while (1){
|
2000-01-22 01:16:50 +00:00
|
|
|
result = child->FirstChild(aPresContext, nsnull, &lookahead);
|
1999-07-15 18:19:03 +00:00
|
|
|
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 18:33:42 +00:00
|
|
|
|
1999-10-22 00:19:18 +00:00
|
|
|
void
|
2000-01-22 01:16:50 +00:00
|
|
|
nsFrame::GetFirstLeaf(nsIPresContext* aPresContext, nsIFrame **aFrame)
|
1999-10-22 00:19:18 +00:00
|
|
|
{
|
|
|
|
if (!aFrame || !*aFrame)
|
|
|
|
return;
|
|
|
|
nsIFrame *child = *aFrame;
|
|
|
|
nsIFrame *lookahead;
|
|
|
|
nsresult result;
|
|
|
|
while (1){
|
2000-01-22 01:16:50 +00:00
|
|
|
result = child->FirstChild(aPresContext, nsnull, &lookahead);
|
1999-10-22 00:19:18 +00:00
|
|
|
if (NS_FAILED(result) || !lookahead)
|
|
|
|
return;//nothing to do
|
|
|
|
child = lookahead;
|
|
|
|
*aFrame = child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-12 17:20:16 +00:00
|
|
|
nsresult nsFrame::CreateAndPostReflowCommand(nsIPresShell* aPresShell,
|
|
|
|
nsIFrame* aTargetFrame,
|
|
|
|
nsIReflowCommand::ReflowType aReflowType,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
nsIAtom* aListName)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
if (!aPresShell || !aTargetFrame) {
|
|
|
|
rv = NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsCOMPtr<nsIReflowCommand> reflowCmd;
|
|
|
|
rv = NS_NewHTMLReflowCommand(getter_AddRefs(reflowCmd), aTargetFrame,
|
|
|
|
aReflowType, aChildFrame,
|
|
|
|
aAttribute);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
if (nsnull != aListName) {
|
|
|
|
reflowCmd->SetChildListName(aListName);
|
|
|
|
}
|
|
|
|
aPresShell->AppendReflowCommand(reflowCmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1999-10-22 00:19:18 +00:00
|
|
|
|
2000-04-12 03:04:11 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFrame::CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
|
|
|
|
{
|
|
|
|
// get its view
|
|
|
|
nsIView* view = nsnull;
|
|
|
|
nsIFrame *parent;//might be THIS frame thats ok
|
|
|
|
nsresult rv = GetParentWithView(aPresContext, &parent);
|
|
|
|
if (!parent || NS_FAILED(rv))
|
|
|
|
return rv?rv:NS_ERROR_FAILURE;
|
|
|
|
parent->GetView(aPresContext,&view);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
|
|
|
PRBool result;
|
|
|
|
|
|
|
|
if (view) {
|
|
|
|
view->GetViewManager(*getter_AddRefs(viewMan));
|
|
|
|
if (viewMan) {
|
|
|
|
if (aGrabMouseEvents) {
|
|
|
|
viewMan->GrabMouseEvents(view,result);
|
|
|
|
} else {
|
|
|
|
viewMan->GrabMouseEvents(nsnull,result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsFrame::IsMouseCaptured(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
// get its view
|
|
|
|
nsIView* view = nsnull;
|
|
|
|
|
|
|
|
nsIFrame *parent;//might be THIS frame thats ok
|
|
|
|
nsresult rv = GetParentWithView(aPresContext, &parent);
|
|
|
|
if (!parent || NS_FAILED(rv))
|
|
|
|
return rv?rv:NS_ERROR_FAILURE;
|
|
|
|
parent->GetView(aPresContext,&view);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
|
|
|
|
|
|
|
if (view) {
|
|
|
|
view->GetViewManager(*getter_AddRefs(viewMan));
|
|
|
|
|
|
|
|
if (viewMan) {
|
|
|
|
nsIView* grabbingView;
|
|
|
|
viewMan->GetMouseEventGrabber(grabbingView);
|
|
|
|
if (grabbingView == view)
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-05-20 16:24:13 +00: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-29 20:20:38 +00:00
|
|
|
nsIAtom* tag;
|
|
|
|
aContent->GetTag(tag);
|
1998-05-20 16:24:13 +00: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 02:37:06 +00: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");
|
|
|
|
}
|
|
|
|
}
|
2000-01-12 08:28:24 +00:00
|
|
|
|
2000-04-12 03:04:11 +00:00
|
|
|
|
1998-05-20 16:24:13 +00:00
|
|
|
#endif
|