Backed out changeset affcc1c08bc0 (deCOM frame enumerator) due to regression from it or bug 461410.

This commit is contained in:
Benjamin Smedberg 2008-10-28 02:47:40 -04:00
Родитель 2127dcfc13
Коммит 555c5a8f1c
7 изменённых файлов: 104 добавлений и 85 удалений

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

@ -4362,7 +4362,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent,
nsresult rv;
nsCOMPtr<nsIFrameTraversal> trav(do_CreateInstance(kFrameTraversalCID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFrameEnumerator> frameTraversal;
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
// --- Get frame to start with ---
if (!aStartFrame) {
@ -4381,7 +4381,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent,
);
NS_ENSURE_SUCCESS(rv, rv);
if (!forward) {
frameTraversal->Last();
rv = frameTraversal->Last();
}
}
else {
@ -4397,16 +4397,15 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent,
!aStartContent->IsNodeOfType(nsINode::eHTML)) {
// Need to do special check in case we're in an imagemap which has multiple
// content per frame, so don't skip over the starting frame.
if (forward)
frameTraversal->Next();
else
frameTraversal->Prev();
rv = forward ? frameTraversal->Next() : frameTraversal->Prev();
}
}
// -- Walk frames to find something tabbable matching mCurrentTabIndex --
while (1) {
*aResultFrame = frameTraversal->CurrentItem();
while (NS_SUCCEEDED(rv)) {
nsISupports* currentItem;
frameTraversal->CurrentItem(&currentItem);
*aResultFrame = (nsIFrame*)currentItem;
if (!*aResultFrame) {
break;
}
@ -4438,10 +4437,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent,
return NS_OK;
}
}
if (forward)
frameTraversal->Next();
else
frameTraversal->Prev();
rv = forward ? frameTraversal->Next() : frameTraversal->Prev();
}
// -- Reached end or beginning of document --
@ -5548,7 +5544,7 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent,
if (nodeValue.Length() == *aStartOffset && !isFormControl &&
startContent != mDocument->GetRootContent()) {
// Yes, indeed we were at the end of the last node
nsCOMPtr<nsIFrameEnumerator> frameTraversal;
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
nsCOMPtr<nsIFrameTraversal> trav(do_CreateInstance(kFrameTraversalCID,
&rv));
@ -5570,8 +5566,9 @@ nsEventStateManager::GetDocSelectionLocation(nsIContent **aStartContent,
// Continue getting the next frame until the primary content for the frame
// we are on changes - we don't want to be stuck in the same place
frameTraversal->Next();
newCaretFrame = frameTraversal->CurrentItem();
if (nsnull == newCaretFrame) {
nsISupports* currentItem;
frameTraversal->CurrentItem(&currentItem);
if (nsnull == (newCaretFrame = static_cast<nsIFrame*>(currentItem))) {
break;
}
newCaretContent = newCaretFrame->GetContent();

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

@ -42,18 +42,22 @@
#include "nsPlaceholderFrame.h"
class nsFrameIterator : public nsIFrameEnumerator
class nsFrameIterator: public nsIBidirectionalEnumerator
{
public:
NS_DECL_ISUPPORTS
virtual void First();
virtual void Next();
virtual nsIFrame* CurrentItem();
virtual PRBool IsDone();
NS_IMETHOD First();
virtual void Last();
virtual void Prev();
NS_IMETHOD Last();
NS_IMETHOD Next();
NS_IMETHOD Prev();
NS_IMETHOD CurrentItem(nsISupports **aItem);
NS_IMETHOD IsDone();//what does this mean??off edge? yes
nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart,
nsIteratorType aType, PRBool aLockScroll, PRBool aFollowOOFs);
@ -161,7 +165,7 @@ nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult)
}
nsresult
NS_NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
nsPresContext* aPresContext,
nsIFrame *aStart,
nsIteratorType aType,
@ -171,7 +175,7 @@ NS_NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
{
if (!aEnumerator || !aStart)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIFrameIterator> trav;
nsFrameIterator *trav;
if (aVisual) {
trav = new nsVisualIterator(aPresContext, aStart, aType,
aLockInScrollView, aFollowOOFs);
@ -181,7 +185,7 @@ NS_NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
}
if (!trav)
return NS_ERROR_OUT_OF_MEMORY;
*aEnumerator = trav;
*aEnumerator = static_cast<nsIBidirectionalEnumerator*>(trav);
NS_ADDREF(trav);
return NS_OK;
}
@ -198,7 +202,7 @@ nsFrameTraversal::~nsFrameTraversal()
NS_IMPL_ISUPPORTS1(nsFrameTraversal,nsIFrameTraversal)
NS_IMETHODIMP
nsFrameTraversal::NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
nsFrameTraversal::NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
nsPresContext* aPresContext,
nsIFrame *aStart,
PRInt32 aType,
@ -213,7 +217,7 @@ NS_IMETHODIMP
// nsFrameIterator implementation
NS_IMPL_ISUPPORTS1(nsFrameIterator, nsIFrameEnumerator)
NS_IMPL_ISUPPORTS2(nsFrameIterator, nsIEnumerator, nsIBidirectionalEnumerator)
nsFrameIterator::nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart,
nsIteratorType aType, PRBool aLockInScrollView,
@ -233,27 +237,34 @@ nsFrameIterator::nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart,
nsIFrame*
nsFrameIterator::CurrentItem()
NS_IMETHODIMP
nsFrameIterator::CurrentItem(nsISupports **aItem)
{
if (!aItem)
return NS_ERROR_NULL_POINTER;
*aItem = mCurrent;
if (mOffEdge)
return nsnull;
return mCurrent;
return NS_ENUMERATOR_FALSE;
return NS_OK;
}
PRBool
nsFrameIterator::IsDone()
NS_IMETHODIMP
nsFrameIterator::IsDone()//what does this mean??off edge? yes
{
return mOffEdge != 0;
if (mOffEdge != 0)
return NS_OK;
return NS_ENUMERATOR_FALSE;
}
void
NS_IMETHODIMP
nsFrameIterator::First()
{
mCurrent = mStart;
return NS_OK;
}
static PRBool
@ -264,7 +275,7 @@ IsRootFrame(nsIFrame* aFrame)
(atom == nsGkAtoms::rootFrame);
}
void
NS_IMETHODIMP
nsFrameIterator::Last()
{
nsIFrame* result;
@ -283,9 +294,10 @@ nsFrameIterator::Last()
setCurrent(parent);
if (!parent)
setOffEdge(1);
return NS_OK;
}
void
NS_IMETHODIMP
nsFrameIterator::Next()
{
// recursive-oid method to get next frame
@ -339,9 +351,10 @@ nsFrameIterator::Next()
setOffEdge(1);
setLast(parent);
}
return NS_OK;
}
void
NS_IMETHODIMP
nsFrameIterator::Prev()
{
// recursive-oid method to get prev frame
@ -394,6 +407,7 @@ nsFrameIterator::Prev()
setOffEdge(-1);
setLast(parent);
}
return NS_OK;
}
nsIFrame*

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

@ -37,10 +37,11 @@
#ifndef NSFRAMETRAVERSAL_H
#define NSFRAMETRAVERSAL_H
#include "nsIEnumerator.h"
#include "nsIFrame.h"
#include "nsIFrameTraversal.h"
nsresult NS_NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
nsresult NS_NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
nsPresContext* aPresContext,
nsIFrame *aStart,
nsIteratorType aType,
@ -58,7 +59,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
NS_IMETHOD NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
nsPresContext* aPresContext,
nsIFrame *aStart,
PRInt32 aType,

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

@ -38,28 +38,9 @@
#define NSIFRAMETRAVERSAL_H
#include "nsISupports.h"
#include "nsIEnumerator.h"
#include "nsIFrame.h"
#define NS_IFRAMEENUMERATOR_IID \
{ 0x7c633f5d, 0x91eb, 0x494e, \
{ 0xa1, 0x40, 0x17, 0x46, 0x17, 0x4c, 0x23, 0xd3 } }
class nsIFrameEnumerator : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFRAMEENUMERATOR_IID)
virtual void First() = 0;
virtual void Next() = 0;
virtual nsIFrame* CurrentItem() = 0;
virtual PRBool IsDone() = 0;
virtual void Last() = 0;
virtual void Prev() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIFrameEnumerator, NS_IFRAMEENUMERATOR_IID)
enum nsIteratorType {
eLeaf,
ePreOrder,
@ -90,7 +71,7 @@ public:
* the real frame. Going back up will go on past the placeholder,
* so the placeholders are logically part of the frame tree.
*/
NS_IMETHOD NewFrameTraversal(nsIFrameEnumerator **aEnumerator,
NS_IMETHOD NewFrameTraversal(nsIBidirectionalEnumerator **aEnumerator,
nsPresContext* aPresContext,
nsIFrame *aStart,
PRInt32 aType,

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

@ -4651,7 +4651,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
}
//resultFrame is not a block frame
nsCOMPtr<nsIFrameEnumerator> frameTraversal;
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
aPresContext, resultFrame,
ePostOrder,
@ -4661,6 +4661,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
);
if (NS_FAILED(result))
return result;
nsISupports *isupports = nsnull;
nsIFrame *storeOldResultFrame = resultFrame;
while ( !found ){
nsPoint point;
@ -4738,10 +4739,14 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
if (aPos->mDirection == eDirNext && (resultFrame == nearStoppingFrame))
break;
//always try previous on THAT line if that fails go the other way
frameTraversal->Prev();
resultFrame = frameTraversal->CurrentItem();
if (!resultFrame)
return NS_ERROR_FAILURE;
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){
@ -4783,11 +4788,14 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
if (aPos->mDirection == eDirNext && (resultFrame == farStoppingFrame))
break;
//previous didnt work now we try "next"
frameTraversal->Next();
nsIFrame *tempFrame = frameTraversal->CurrentItem();
if (!tempFrame)
result = frameTraversal->Next();
if (NS_FAILED(result))
break;
resultFrame = tempFrame;
result = frameTraversal->CurrentItem(&isupports);
if (NS_FAILED(result) || !isupports)
break;
//we must CAST here to an nsIFrame. nsIFrame doesnt really follow the rules
resultFrame = (nsIFrame *)isupports;
}
aPos->mResultFrame = resultFrame;
}
@ -5474,7 +5482,7 @@ nsIFrame::GetFrameFromDirection(nsDirection aDirection, PRBool aVisual,
return NS_ERROR_FAILURE; //we are done. cannot jump lines
}
nsCOMPtr<nsIFrameEnumerator> frameTraversal;
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
result = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
presContext, traversedFrame,
eLeaf,
@ -5486,13 +5494,21 @@ nsIFrame::GetFrameFromDirection(nsDirection aDirection, PRBool aVisual,
return result;
if (aDirection == eDirNext)
frameTraversal->Next();
result = frameTraversal->Next();
else
frameTraversal->Prev();
result = frameTraversal->Prev();
if (NS_FAILED(result))
return result;
traversedFrame = frameTraversal->CurrentItem();
if (!traversedFrame)
return NS_ERROR_FAILURE;
nsISupports *isupports = nsnull;
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 doesn't really follow the rules
//for speed reasons
traversedFrame = (nsIFrame *)isupports;
traversedFrame->IsSelectable(&selectable, nsnull);
} // while (!selectable)

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

@ -1583,7 +1583,7 @@ nsFrameSelection::GetFrameFromLevel(nsIFrame *aFrameIn,
PRUint8 foundLevel = 0;
nsIFrame *foundFrame = aFrameIn;
nsCOMPtr<nsIFrameEnumerator> frameTraversal;
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
nsresult result;
nsCOMPtr<nsIFrameTraversal> trav(do_CreateInstance(kFrameTraversalCID,&result));
if (NS_FAILED(result))
@ -1598,17 +1598,25 @@ nsFrameSelection::GetFrameFromLevel(nsIFrame *aFrameIn,
);
if (NS_FAILED(result))
return result;
nsISupports *isupports = nsnull;
do {
*aFrameOut = foundFrame;
if (aDirection == eDirNext)
frameTraversal->Next();
result = frameTraversal->Next();
else
frameTraversal->Prev();
result = frameTraversal->Prev();
foundFrame = frameTraversal->CurrentItem();
if (!foundFrame)
return NS_ERROR_FAILURE;
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 doesn't really follow the rules
//for speed reasons
foundFrame = (nsIFrame *)isupports;
foundLevel = NS_GET_EMBEDDING_LEVEL(foundFrame);
} while (foundLevel > aBidiLevel);

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

@ -1175,7 +1175,7 @@ nsTypeAheadFind::IsRangeVisible(nsIPresShell *aPresShell,
// We know that the target range isn't usable because it's not in the
// view port. Move range forward to first visible point,
// this speeds us up a lot in long documents
nsCOMPtr<nsIFrameEnumerator> frameTraversal;
nsCOMPtr<nsIBidirectionalEnumerator> frameTraversal;
nsCOMPtr<nsIFrameTraversal> trav(do_CreateInstance(kFrameTraversalCID));
if (trav)
trav->NewFrameTraversal(getter_AddRefs(frameTraversal),
@ -1191,7 +1191,9 @@ nsTypeAheadFind::IsRangeVisible(nsIPresShell *aPresShell,
while (rectVisibility == nsRectVisibility_kAboveViewport || rectVisibility == nsRectVisibility_kZeroAreaRect) {
frameTraversal->Next();
frame = frameTraversal->CurrentItem();
nsISupports* currentItem;
frameTraversal->CurrentItem(&currentItem);
frame = static_cast<nsIFrame*>(currentItem);
if (!frame)
return PR_FALSE;