1999-02-22 06:19:24 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03: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/
|
1999-02-22 06:19:24 +03:00
|
|
|
*
|
1999-11-06 06:40:37 +03: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.
|
1999-02-22 06:19:24 +03:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-02-22 06:19:24 +03:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-02-22 06:19:24 +03:00
|
|
|
*/
|
2000-04-12 07:04:11 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsLayoutAtoms.h"
|
|
|
|
|
1999-02-19 03:21:22 +03:00
|
|
|
#include "nsFrameTraversal.h"
|
|
|
|
#include "nsFrameList.h"
|
|
|
|
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
class nsFrameIterator: public nsIBidirectionalEnumerator
|
1999-02-19 03:21:22 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHOD First();
|
1999-02-19 03:21:22 +03:00
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHOD Last();
|
1999-02-19 03:21:22 +03:00
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHOD Next()=0;
|
1999-02-19 03:21:22 +03:00
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHOD Prev()=0;
|
1999-02-19 03:21:22 +03:00
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHOD CurrentItem(nsISupports **aItem);
|
1999-02-19 03:21:22 +03:00
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHOD IsDone();//what does this mean??off edge? yes
|
1999-02-19 03:21:22 +03:00
|
|
|
|
|
|
|
nsFrameIterator();
|
1999-10-09 00:41:19 +04:00
|
|
|
|
1999-02-19 03:21:22 +03:00
|
|
|
protected:
|
|
|
|
void setCurrent(nsIFrame *aFrame){mCurrent = aFrame;}
|
|
|
|
nsIFrame *getCurrent(){return mCurrent;}
|
|
|
|
void setStart(nsIFrame *aFrame){mStart = aFrame;}
|
|
|
|
nsIFrame *getStart(){return mStart;}
|
|
|
|
nsIFrame *getLast(){return mLast;}
|
|
|
|
void setLast(nsIFrame *aFrame){mLast = aFrame;}
|
|
|
|
PRInt8 getOffEdge(){return mOffEdge;}
|
|
|
|
void setOffEdge(PRInt8 aOffEdge){mOffEdge = aOffEdge;}
|
|
|
|
private:
|
|
|
|
nsIFrame *mStart;
|
|
|
|
nsIFrame *mCurrent;
|
|
|
|
nsIFrame *mLast; //the last one that was in current;
|
|
|
|
PRInt8 mOffEdge; //0= no -1 to far prev, 1 to far next;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
class nsFastFrameIterator: public nsFrameIterator
|
|
|
|
{
|
|
|
|
nsFastFrameIterator(nsIFrame *start);
|
|
|
|
private :
|
|
|
|
|
|
|
|
virtual nsresult Next();
|
|
|
|
|
|
|
|
virtual nsresult Prev();
|
|
|
|
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsLeafIterator: public nsFrameIterator
|
|
|
|
{
|
|
|
|
public:
|
2000-01-22 04:16:50 +03:00
|
|
|
nsLeafIterator(nsIPresContext* aPresContext, nsIFrame *start);
|
2000-04-05 03:55:31 +04:00
|
|
|
void SetExtensive(PRBool aExtensive) {mExtensive = aExtensive;}
|
|
|
|
PRBool GetExtensive(){return mExtensive;}
|
2001-08-14 04:46:32 +04:00
|
|
|
void SetPreOrder(PRBool aPreOrder) { mPreOrder = aPreOrder; }
|
|
|
|
PRBool GetPreOrder() { return mPreOrder; }
|
|
|
|
|
1999-02-19 03:21:22 +03:00
|
|
|
private :
|
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHOD Next();
|
1999-02-19 03:21:22 +03:00
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHOD Prev();
|
1999-02-19 03:21:22 +03:00
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
nsIPresContext* mPresContext;
|
2001-08-14 04:46:32 +04:00
|
|
|
PRPackedBool mExtensive;
|
|
|
|
PRPackedBool mPreOrder;
|
1999-02-19 03:21:22 +03:00
|
|
|
};
|
|
|
|
|
2001-03-21 04:16:22 +03:00
|
|
|
#ifdef IBMBIDI // Simon
|
|
|
|
|
|
|
|
class nsVisualIterator: public nsFrameIterator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsVisualIterator(nsIPresContext* aPresContext, nsIFrame *start);
|
|
|
|
private :
|
|
|
|
|
|
|
|
NS_IMETHOD Next();
|
|
|
|
|
|
|
|
NS_IMETHOD Prev();
|
|
|
|
|
|
|
|
nsIPresContext* mPresContext;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1999-02-19 03:21:22 +03:00
|
|
|
/************IMPLEMENTATIONS**************/
|
|
|
|
|
2001-02-20 00:50:04 +03:00
|
|
|
nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
*aResult = nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFrameTraversal> t(new nsFrameTraversal());
|
|
|
|
if (!t)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
*aResult = t;
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-19 03:21:22 +03:00
|
|
|
nsresult
|
2000-01-22 04:16:50 +03:00
|
|
|
NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
|
|
|
|
nsTraversalType aType,
|
|
|
|
nsIPresContext* aPresContext,
|
|
|
|
nsIFrame *aStart)
|
1999-02-19 03:21:22 +03:00
|
|
|
{
|
|
|
|
if (!aEnumerator || !aStart)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
switch(aType)
|
|
|
|
{
|
|
|
|
case LEAF: {
|
2000-01-22 04:16:50 +03:00
|
|
|
nsLeafIterator *trav = new nsLeafIterator(aPresContext, aStart);
|
1999-02-19 03:21:22 +03:00
|
|
|
if (!trav)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1999-02-23 11:10:24 +03:00
|
|
|
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
1999-02-19 03:21:22 +03:00
|
|
|
NS_ADDREF(trav);
|
2000-04-05 03:55:31 +04:00
|
|
|
trav->SetExtensive(PR_FALSE);
|
2001-08-14 04:46:32 +04:00
|
|
|
trav->SetPreOrder(PR_FALSE);
|
|
|
|
}
|
|
|
|
break;
|
1999-02-19 03:21:22 +03:00
|
|
|
case EXTENSIVE:{
|
2000-04-05 03:55:31 +04:00
|
|
|
nsLeafIterator *trav = new nsLeafIterator(aPresContext, aStart);
|
1999-02-19 03:21:22 +03:00
|
|
|
if (!trav)
|
2000-04-05 03:55:31 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1999-02-23 11:10:24 +03:00
|
|
|
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
1999-02-19 03:21:22 +03:00
|
|
|
NS_ADDREF(trav);
|
2000-04-05 03:55:31 +04:00
|
|
|
trav->SetExtensive(PR_TRUE);
|
2001-08-14 04:46:32 +04:00
|
|
|
trav->SetPreOrder(PR_FALSE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EXTENSIVE_PREORDER: {
|
|
|
|
nsLeafIterator *trav = new nsLeafIterator(aPresContext, aStart);
|
|
|
|
if (!trav)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
|
|
|
NS_ADDREF(trav);
|
|
|
|
trav->SetExtensive(PR_TRUE);
|
|
|
|
trav->SetPreOrder(PR_TRUE);
|
|
|
|
}
|
|
|
|
break;
|
2001-03-21 04:16:22 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
case VISUAL:{
|
|
|
|
nsVisualIterator *trav = new nsVisualIterator(aPresContext, aStart);
|
|
|
|
if (!trav)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
|
|
|
NS_ADDREF(trav);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2000-04-05 03:55:31 +04:00
|
|
|
#if 0
|
1999-02-19 03:21:22 +03:00
|
|
|
case FASTEST:{
|
|
|
|
nsFastestTraversal *trav = new nsFastestTraversal(aStart);
|
|
|
|
if (!trav)
|
|
|
|
return NS_ERROR_NOMEMORY;
|
1999-02-23 11:10:24 +03:00
|
|
|
*aEnumerator = NS_STATIC_CAST(nsIBidirectionalEnumerator*, trav);
|
1999-02-19 03:21:22 +03:00
|
|
|
NS_ADDREF(trav);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-20 00:50:04 +03:00
|
|
|
nsFrameTraversal::nsFrameTraversal()
|
|
|
|
{
|
|
|
|
NS_INIT_ISUPPORTS();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameTraversal::~nsFrameTraversal()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsFrameTraversal,nsIFrameTraversal);
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFrameTraversal::NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
|
|
|
|
PRUint32 aType,
|
|
|
|
nsIPresContext* aPresContext,
|
|
|
|
nsIFrame *aStart)
|
|
|
|
{
|
|
|
|
return NS_NewFrameTraversal(aEnumerator, NS_STATIC_CAST(nsTraversalType,
|
|
|
|
aType),
|
|
|
|
aPresContext, aStart);
|
|
|
|
}
|
1999-02-19 03:21:22 +03:00
|
|
|
|
|
|
|
/*********nsFrameIterator************/
|
2000-01-29 22:59:53 +03:00
|
|
|
NS_IMPL_ISUPPORTS2(nsFrameIterator, nsIEnumerator, nsIBidirectionalEnumerator)
|
1999-02-19 03:21:22 +03:00
|
|
|
|
|
|
|
nsFrameIterator::nsFrameIterator()
|
|
|
|
{
|
|
|
|
mOffEdge = 0;
|
|
|
|
mLast = nsnull;
|
|
|
|
mCurrent = nsnull;
|
|
|
|
mStart = nsnull;
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHODIMP
|
1999-02-19 03:21:22 +03:00
|
|
|
nsFrameIterator::CurrentItem(nsISupports **aItem)
|
|
|
|
{
|
|
|
|
if (!aItem)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
*aItem = mCurrent;
|
1999-03-03 04:51:21 +03:00
|
|
|
if (mOffEdge)
|
1999-10-28 07:16:48 +04:00
|
|
|
return NS_ENUMERATOR_FALSE;
|
1999-02-19 03:21:22 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHODIMP
|
1999-02-19 03:21:22 +03:00
|
|
|
nsFrameIterator::IsDone()//what does this mean??off edge? yes
|
|
|
|
{
|
|
|
|
if (mOffEdge != 0)
|
|
|
|
return NS_OK;
|
1999-10-28 07:16:48 +04:00
|
|
|
return NS_ENUMERATOR_FALSE;
|
1999-02-19 03:21:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHODIMP
|
1999-02-19 03:21:22 +03:00
|
|
|
nsFrameIterator::First()
|
|
|
|
{
|
|
|
|
mCurrent = mStart;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHODIMP
|
1999-02-19 03:21:22 +03:00
|
|
|
nsFrameIterator::Last()
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********LEAFITERATOR**********/
|
|
|
|
|
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
nsLeafIterator::nsLeafIterator(nsIPresContext* aPresContext, nsIFrame *aStart)
|
|
|
|
: mPresContext(aPresContext)
|
1999-02-19 03:21:22 +03:00
|
|
|
{
|
|
|
|
setStart(aStart);
|
|
|
|
setCurrent(aStart);
|
|
|
|
setLast(aStart);
|
|
|
|
}
|
|
|
|
|
2000-04-19 06:13:43 +04:00
|
|
|
static PRBool
|
|
|
|
IsRootFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAtom>atom;
|
|
|
|
|
|
|
|
aFrame->GetFrameType(getter_AddRefs(atom));
|
|
|
|
return (atom.get() == nsLayoutAtoms::canvasFrame) ||
|
|
|
|
(atom.get() == nsLayoutAtoms::rootFrame);
|
|
|
|
}
|
1999-02-19 03:21:22 +03:00
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHODIMP
|
1999-02-19 03:21:22 +03:00
|
|
|
nsLeafIterator::Next()
|
|
|
|
{
|
|
|
|
//recursive-oid method to get next frame
|
2000-04-12 07:04:11 +04:00
|
|
|
nsIFrame *result = nsnull;
|
1999-02-19 03:21:22 +03:00
|
|
|
nsIFrame *parent = getCurrent();
|
|
|
|
if (!parent)
|
|
|
|
parent = getLast();
|
2001-08-14 04:46:32 +04:00
|
|
|
if (!mExtensive && !mPreOrder)
|
1999-02-19 03:21:22 +03:00
|
|
|
{
|
2000-04-05 03:55:31 +04:00
|
|
|
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result)
|
|
|
|
{
|
|
|
|
parent = result;
|
|
|
|
}
|
2001-08-14 04:46:32 +04:00
|
|
|
} else if (mPreOrder) {
|
|
|
|
if (NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull, &result)) && result)
|
|
|
|
parent = result;
|
1999-02-19 03:21:22 +03:00
|
|
|
}
|
|
|
|
if (parent != getCurrent())
|
|
|
|
{
|
|
|
|
result = parent;
|
|
|
|
}
|
|
|
|
else {
|
2000-04-19 06:13:43 +04:00
|
|
|
while(parent && !IsRootFrame(parent)) {
|
2001-08-14 04:46:32 +04:00
|
|
|
if (NS_SUCCEEDED(parent->GetNextSibling(&result)) && result) {
|
|
|
|
if (!mPreOrder) {
|
1999-02-19 03:21:22 +03:00
|
|
|
parent = result;
|
2001-08-14 04:46:32 +04:00
|
|
|
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result)
|
|
|
|
{
|
|
|
|
parent = result;
|
|
|
|
}
|
|
|
|
result = parent;
|
1999-02-19 03:21:22 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
2000-04-19 06:13:43 +04:00
|
|
|
{
|
|
|
|
parent->GetParent(&result);
|
|
|
|
if (!result || IsRootFrame(result)) {
|
1999-02-19 03:21:22 +03:00
|
|
|
result = nsnull;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
2000-04-05 03:55:31 +04:00
|
|
|
{
|
1999-02-19 03:21:22 +03:00
|
|
|
parent = result;
|
2001-08-14 04:46:32 +04:00
|
|
|
if (mExtensive && !mPreOrder)
|
2000-04-05 03:55:31 +04:00
|
|
|
break;
|
|
|
|
}
|
2000-04-19 06:13:43 +04:00
|
|
|
}
|
1999-02-19 03:21:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
setCurrent(result);
|
|
|
|
if (!result)
|
|
|
|
setOffEdge(1);
|
1999-03-03 04:51:21 +03:00
|
|
|
return NS_OK;
|
1999-02-19 03:21:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-02-20 02:47:36 +03:00
|
|
|
NS_IMETHODIMP
|
1999-02-19 03:21:22 +03:00
|
|
|
nsLeafIterator::Prev()
|
|
|
|
{
|
|
|
|
//recursive-oid method to get prev frame
|
|
|
|
nsIFrame *result;
|
|
|
|
nsIFrame *parent = getCurrent();
|
|
|
|
if (!parent)
|
1999-03-03 04:51:21 +03:00
|
|
|
parent = getLast();
|
1999-02-19 03:21:22 +03:00
|
|
|
while(parent){
|
1999-03-03 04:51:21 +03:00
|
|
|
nsIFrame *grandParent;
|
|
|
|
if (NS_SUCCEEDED(parent->GetParent(&grandParent)) && grandParent &&
|
2000-01-22 04:16:50 +03:00
|
|
|
NS_SUCCEEDED(grandParent->FirstChild(mPresContext, nsnull,&result))){
|
1999-03-03 04:51:21 +03:00
|
|
|
nsFrameList list(result);
|
1999-07-15 22:19:03 +04:00
|
|
|
result = list.GetPrevSiblingFor(parent);
|
|
|
|
if (result){
|
1999-03-03 04:51:21 +03:00
|
|
|
parent = result;
|
2000-01-22 04:16:50 +03:00
|
|
|
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result){
|
1999-03-03 04:51:21 +03:00
|
|
|
parent = result;
|
|
|
|
while(NS_SUCCEEDED(parent->GetNextSibling(&result)) && result){
|
|
|
|
parent = result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = parent;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (NS_FAILED(parent->GetParent(&result)) || !result){
|
|
|
|
result = nsnull;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
2000-04-05 03:55:31 +04:00
|
|
|
{
|
1999-03-03 04:51:21 +03:00
|
|
|
parent = result;
|
2000-04-05 03:55:31 +04:00
|
|
|
if (mExtensive)
|
|
|
|
break;
|
|
|
|
}
|
1999-03-03 04:51:21 +03:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
setLast(parent);
|
|
|
|
result = nsnull;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-19 03:21:22 +03:00
|
|
|
setCurrent(result);
|
|
|
|
if (!result)
|
|
|
|
setOffEdge(-1);
|
1999-03-03 04:51:21 +03:00
|
|
|
return NS_OK;
|
1999-02-19 03:21:22 +03:00
|
|
|
}
|
2001-03-21 04:16:22 +03:00
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
|
|
|
|
/*********VISUALITERATOR**********/
|
|
|
|
|
|
|
|
nsVisualIterator::nsVisualIterator(nsIPresContext* aPresContext, nsIFrame *aStart)
|
|
|
|
: mPresContext(aPresContext)
|
|
|
|
{
|
|
|
|
setStart(aStart);
|
|
|
|
setCurrent(aStart);
|
|
|
|
setLast(aStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsVisualIterator::Next()
|
|
|
|
{
|
|
|
|
//recursive-oid method to get next frame
|
|
|
|
nsIFrame *result = nsnull;
|
|
|
|
nsIFrame *parent = getCurrent();
|
|
|
|
if (!parent)
|
|
|
|
parent = getLast();
|
|
|
|
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result)
|
|
|
|
{
|
|
|
|
parent = result;
|
|
|
|
}
|
|
|
|
if (parent != getCurrent())
|
|
|
|
{
|
|
|
|
result = parent;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
while(parent && !IsRootFrame(parent)) {
|
|
|
|
nsIFrame *grandParent;
|
|
|
|
if (NS_SUCCEEDED(parent->GetParent(&grandParent)) && grandParent &&
|
|
|
|
NS_SUCCEEDED(grandParent->FirstChild(mPresContext, nsnull,&result))){
|
|
|
|
nsFrameList list(result);
|
|
|
|
result = list.GetNextVisualFor(parent);
|
|
|
|
if (result){
|
|
|
|
parent = result;
|
|
|
|
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result) {
|
|
|
|
parent = result;
|
|
|
|
}
|
|
|
|
result = parent;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (NS_FAILED(parent->GetParent(&result)) || !result || IsRootFrame(result)){
|
|
|
|
result = nsnull;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parent = result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
setLast(parent);
|
|
|
|
result = nsnull;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setCurrent(result);
|
|
|
|
if (!result)
|
|
|
|
setOffEdge(-1);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsVisualIterator::Prev()
|
|
|
|
{
|
|
|
|
//recursive-oid method to get prev frame
|
|
|
|
nsIFrame *result;
|
|
|
|
nsIFrame *parent = getCurrent();
|
|
|
|
if (!parent)
|
|
|
|
parent = getLast();
|
|
|
|
while(parent){
|
|
|
|
nsIFrame *grandParent;
|
|
|
|
if (NS_SUCCEEDED(parent->GetParent(&grandParent)) && grandParent &&
|
|
|
|
NS_SUCCEEDED(grandParent->FirstChild(mPresContext, nsnull,&result))){
|
|
|
|
nsFrameList list(result);
|
|
|
|
result = list.GetPrevVisualFor(parent);
|
|
|
|
if (result){
|
|
|
|
parent = result;
|
|
|
|
while(NS_SUCCEEDED(parent->FirstChild(mPresContext, nsnull,&result)) && result){
|
|
|
|
parent = result;
|
|
|
|
while(NS_SUCCEEDED(parent->GetNextSibling(&result)) && result){
|
|
|
|
parent = result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = parent;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (NS_FAILED(parent->GetParent(&result)) || !result){
|
|
|
|
result = nsnull;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parent = result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
setLast(parent);
|
|
|
|
result = nsnull;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setCurrent(result);
|
|
|
|
if (!result)
|
|
|
|
setOffEdge(-1);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|