Turning on the new tree widget. Bug#30511, r=evaughan

This commit is contained in:
hyatt%netscape.com 2000-06-19 22:57:39 +00:00
Родитель 3b592d2c82
Коммит 4cfbe9e471
17 изменённых файлов: 180 добавлений и 88 удалений

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

@ -1294,7 +1294,8 @@ nsXBLBinding::BuildInsertionTable()
PRUint32 count;
childrenElements->Count(&count);
for (PRUint32 i = 0; i < count; i++) {
PRUint32 i;
for (i = 0; i < count; i++) {
nsCOMPtr<nsISupports> supp;
childrenElements->GetElementAt(i, getter_AddRefs(supp));
nsCOMPtr<nsIContent> child(do_QueryInterface(supp));
@ -1332,6 +1333,20 @@ nsXBLBinding::BuildInsertionTable()
}
}
}
// Now remove the <children> elements.
for (i = 0; i < count; i++) {
nsCOMPtr<nsISupports> supp;
childrenElements->GetElementAt(i, getter_AddRefs(supp));
nsCOMPtr<nsIContent> child(do_QueryInterface(supp));
if (child) {
nsCOMPtr<nsIContent> parent;
child->GetParent(*getter_AddRefs(parent));
PRInt32 index;
parent->IndexOf(child, index);
parent->RemoveChildAt(index, PR_FALSE);
}
}
}
PRBool

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

@ -152,7 +152,7 @@ static PRBool gReallyNoisyContentUpdates = PR_FALSE;
static PRBool gNoisyInlineConstruction = PR_FALSE;
#endif
//#define XULTREE
#define XULTREE
#ifdef XULTREE
#include "nsXULTreeFrame.h"
#include "nsXULTreeOuterGroupFrame.h"
@ -9050,8 +9050,8 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
nsBoxLayoutState state(aPresContext);
treeRowGroup->MarkDirtyChildren(state);
treeRowGroup->ClearRowGroupInfo();
return NS_OK;
}
return NS_OK;
#else
nsTreeRowGroupFrame* treeRowGroup = (nsTreeRowGroupFrame*)parentFrame;
if (treeRowGroup) {

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

@ -1450,7 +1450,7 @@ nsGfxTextControlFrame2::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
if (!aReflowState)
return NS_OK;
if (eReflowReason_Initial == aReflowState->reason)
if (mState & NS_FRAME_FIRST_REFLOW)
{
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
nsFormFrame::AddFormControlFrame(aPresContext, *NS_STATIC_CAST(nsIFrame*, this));

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

@ -152,7 +152,7 @@ static PRBool gReallyNoisyContentUpdates = PR_FALSE;
static PRBool gNoisyInlineConstruction = PR_FALSE;
#endif
//#define XULTREE
#define XULTREE
#ifdef XULTREE
#include "nsXULTreeFrame.h"
#include "nsXULTreeOuterGroupFrame.h"
@ -9050,8 +9050,8 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
nsBoxLayoutState state(aPresContext);
treeRowGroup->MarkDirtyChildren(state);
treeRowGroup->ClearRowGroupInfo();
return NS_OK;
}
return NS_OK;
#else
nsTreeRowGroupFrame* treeRowGroup = (nsTreeRowGroupFrame*)parentFrame;
if (treeRowGroup) {

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

@ -1294,7 +1294,8 @@ nsXBLBinding::BuildInsertionTable()
PRUint32 count;
childrenElements->Count(&count);
for (PRUint32 i = 0; i < count; i++) {
PRUint32 i;
for (i = 0; i < count; i++) {
nsCOMPtr<nsISupports> supp;
childrenElements->GetElementAt(i, getter_AddRefs(supp));
nsCOMPtr<nsIContent> child(do_QueryInterface(supp));
@ -1332,6 +1333,20 @@ nsXBLBinding::BuildInsertionTable()
}
}
}
// Now remove the <children> elements.
for (i = 0; i < count; i++) {
nsCOMPtr<nsISupports> supp;
childrenElements->GetElementAt(i, getter_AddRefs(supp));
nsCOMPtr<nsIContent> child(do_QueryInterface(supp));
if (child) {
nsCOMPtr<nsIContent> parent;
child->GetParent(*getter_AddRefs(parent));
PRInt32 index;
parent->IndexOf(child, index);
parent->RemoveChildAt(index, PR_FALSE);
}
}
}
PRBool

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

@ -33,6 +33,7 @@ class nsBoxLayout : public nsIBoxLayout {
public:
nsBoxLayout();
virtual ~nsBoxLayout() {};
NS_DECL_ISUPPORTS

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

@ -74,6 +74,10 @@ nsContainerBox::nsContainerBox(nsIPresShell* aShell):nsBox(aShell)
mChildCount = 0;
}
nsContainerBox::~nsContainerBox()
{
}
void
nsContainerBox::GetBoxName(nsAutoString& aName)
{

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

@ -39,6 +39,7 @@ public:
NS_IMETHOD GetChildBox(nsIBox** aBox);
nsContainerBox(nsIPresShell* aShell);
virtual ~nsContainerBox();
NS_IMETHOD SetLayoutManager(nsIBoxLayout* aLayout);
NS_IMETHOD GetLayoutManager(nsIBoxLayout** aLayout);
@ -65,8 +66,6 @@ public:
virtual void SanityCheck(nsFrameList& aFrameList);
virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIBox* aChild, PRBool aDebug);
virtual ~nsContainerBox() {}
static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect);

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

@ -87,8 +87,8 @@ nsGridLayout::GetOtherTemple(nsIBox* aBox, nsTempleLayout** aTemple, nsIBox** aT
child = b;
}
nsIBoxLayout* layout = nsnull;
child->GetLayoutManager(&layout);
nsCOMPtr<nsIBoxLayout> layout;
child->GetLayoutManager(getter_AddRefs(layout));
// must find a temple that is not our requestor and is a monument.
if (layout != aRequestor) {
@ -186,7 +186,6 @@ nsGridLayout::EnscriptionChanged(nsBoxLayoutState& aState, PRInt32 aIndex)
NS_IMETHODIMP
nsGridLayout::DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState)
{
NS_ERROR("Should Never be Called!");
return NS_OK;
}

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

@ -72,7 +72,8 @@ public:
virtual PRInt32 GetRefCount()=0;
virtual PRBool SetListener(nsIBox* aBox, nsBoxSizeListener& aListener)=0;
virtual void RemoveListener()=0;
virtual void SetAdjacent(nsBoxLayoutState& aState, nsBoxSizeList* aList)=0;
virtual nsBoxSizeList* GetAdjacent()=0;
};
// {AF0C1603-06C3-11d4-BA07-001083023C1E}

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

@ -179,16 +179,15 @@ nsMonumentIterator::GetNextObelisk(nsObeliskLayout** aObelisk, PRBool aSearchChi
//------ nsInfoListNodeImpl ----
nsBoxSizeListNodeImpl::~nsBoxSizeListNodeImpl()
{
}
void
nsBoxSizeListNodeImpl::Release(nsBoxLayoutState& aState)
{
mRefCount--;
if (mRefCount == 0) {
Clear(aState);
if (mNext)
mNext->Release(aState);
delete this;
}
delete this;
}
void
@ -201,18 +200,18 @@ nsBoxSizeListNodeImpl::Desecrate(nsBoxLayoutState& aState)
void
nsBoxSizeListNodeImpl::MarkDirty(nsBoxLayoutState& aState)
{
mBox->MarkDirty(aState);
if (mBox)
mBox->MarkDirty(aState);
}
void nsBoxSizeListNodeImpl::SetNext(nsBoxLayoutState& aState, nsBoxSizeList* aNext)
{
if (mNext) {
mNext->Release(aState);
}
mNext = aNext;
if (mNext)
aNext->AddRef();
}
void nsBoxSizeListNodeImpl::SetAdjacent(nsBoxLayoutState& aState, nsBoxSizeList* aNext)
{
mAdjacent = aNext;
}
void
@ -223,6 +222,7 @@ nsBoxSizeListNodeImpl::Append(nsBoxLayoutState& aState, nsBoxSizeList* aChild)
nsBoxSizeListNodeImpl::nsBoxSizeListNodeImpl(nsIBox* aBox):mNext(nsnull),
mParent(nsnull),
mAdjacent(nsnull),
mBox(aBox),
mRefCount(0),
mIsSet(PR_FALSE)
@ -239,7 +239,7 @@ nsBoxSizeListNodeImpl::GetAt(PRInt32 aIndex)
if (count == aIndex)
return node;
node = node->GetNext();
node = node->GetAdjacent();
count++;
}
@ -272,15 +272,29 @@ nsBoxSizeListImpl::nsBoxSizeListImpl(nsIBox* aBox):nsBoxSizeListNodeImpl(aBox),
{
}
nsBoxSizeListImpl::~nsBoxSizeListImpl()
{
}
void
nsBoxSizeListImpl::Release(nsBoxLayoutState& aState)
{
if (mRefCount == 1) {
if (mListener)
mListener->WillBeDestroyed(mListenerBox, aState, *this);
}
if (mListener) {
mListener->WillBeDestroyed(mListenerBox, aState, *this);
}
nsBoxSizeListNodeImpl::Release(aState);
nsBoxSizeList* list = mFirst;
while(list)
{
nsBoxSizeList* toRelease = list;
list = list->GetNext();
toRelease->SetParent(nsnull);
}
if (mAdjacent)
mAdjacent->Release(aState);
delete this;
}
void
@ -308,7 +322,6 @@ nsBoxSizeListImpl::Append(nsBoxLayoutState& aState, nsBoxSizeList* aChild)
mLast = aChild;
aChild->SetParent(this);
aChild->AddRef();
}
void
@ -401,6 +414,9 @@ nsBoxSizeListNodeImpl::GetBoxSize(nsBoxLayoutState& aState, PRBool aIsHorizontal
nscoord ascent = 0;
nscoord flex = 0;
if (!mBox)
return size;
mBox->GetPrefSize(aState, pref);
mBox->GetMinSize(aState, min);
mBox->GetMaxSize(aState, max);
@ -502,8 +518,8 @@ nsMonumentLayout::GetOtherMonumentsAt(nsIBox* aBox, PRInt32 aIndexOfObelisk, nsB
childBox = do_QueryInterface(childFrame);
}
nsIBoxLayout* layout = nsnull;
childBox->GetLayoutManager(&layout);
nsCOMPtr<nsIBoxLayout> layout;
childBox->GetLayoutManager(getter_AddRefs(layout));
// only all monuments
nsCOMPtr<nsIMonument> monument = do_QueryInterface(layout, &rv);
@ -556,7 +572,7 @@ nsMonumentLayout::GetMonumentsAt(nsIBox* aBox, PRInt32 aMonumentIndex, nsBoxSize
*aList = list;
return NS_OK;
}
list = list->GetNext();
list = list->GetAdjacent();
count++;
}
@ -607,7 +623,7 @@ nsMonumentLayout::GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxS
if (*aList == nsnull)
*aList = last = newOne;
else {
last->SetNext(aState, newOne);
last->SetAdjacent(aState, newOne);
last = newOne;
}
child->GetNextBox(&child);

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

@ -88,10 +88,15 @@ public:
virtual PRBool IsSet() { return mIsSet; }
virtual nsIBox* GetBox() { return mBox; }
virtual void SetAdjacent(nsBoxLayoutState& aState, nsBoxSizeList* aAdjacent);
virtual nsBoxSizeList* GetAdjacent() { return mAdjacent; }
nsBoxSizeListNodeImpl(nsIBox* aBox);
virtual ~nsBoxSizeListNodeImpl();
nsBoxSizeList* mNext;
nsBoxSizeList* mParent;
nsBoxSizeList* mAdjacent;
nsIBox* mBox;
PRInt32 mRefCount;
PRBool mIsSet;
@ -113,6 +118,7 @@ public:
virtual void Release(nsBoxLayoutState& aState);
nsBoxSizeListImpl(nsIBox* aBox);
virtual ~nsBoxSizeListImpl();
nsBoxSizeList* mFirst;
nsBoxSizeList* mLast;

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

@ -73,52 +73,42 @@ nsTempleLayout::GetMonumentList(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSiz
return NS_OK;
}
*aList = nsnull;
// run through our children.
// ask each child for its monument list
// append the list to our list
nsIBox* box = nsnull;
aBox->GetChildBox(&box);
nsIBox* firstChild = nsnull;
aBox->GetChildBox(&firstChild);
nsBoxSizeList* current = nsnull;
nsCOMPtr<nsIMonument> monument;
nsMonumentIterator it(firstChild);
nsMonumentIterator it(box);
nsIBox* box = nsnull;
while(it.GetNextMonument(getter_AddRefs(monument))) {
it.GetBox(&box);
if (!mMonuments) {
mMonuments = new nsBoxSizeListImpl(box);
mMonuments->AddRef();
}
current = mMonuments;
nsBoxSizeList* node = nsnull;
monument->GetMonumentList(box, aState, &node);
if (node)
node->AddRef();
while(node)
{
if (!mMonuments) {
mMonuments = new nsBoxSizeListImpl(firstChild);
current = mMonuments;
}
current->Append(aState, node);
node->Release(aState);
nsBoxSizeList* tmp = node->GetNext();
if (tmp)
tmp->AddRef();
node->SetNext(aState, nsnull);
node = tmp;
if (node && !current->GetNext()) {
node = node->GetAdjacent();
if (node && !current->GetAdjacent()) {
nsBoxSizeList* newOne = new nsBoxSizeListImpl(box);
current->SetNext(aState, newOne);
current->SetAdjacent(aState, newOne);
current = newOne;
} else {
current = current->GetNext();
current = current->GetAdjacent();
}
}
}
@ -225,10 +215,16 @@ nsTempleLayout::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox*
NS_IMETHODIMP
nsTempleLayout::DesecrateMonuments(nsIBox* aBox, nsBoxLayoutState& aState)
{
nsCOMPtr<nsIMonument> parent;
nsCOMPtr<nsIBox> parentBox;
GetParentMonument(aBox, parentBox, getter_AddRefs(parent));
if (parent)
parent->DesecrateMonuments(parentBox, aState);
if (mMonuments) {
nsBoxSizeList* tmp = mMonuments;
mMonuments->Release(aState);
mMonuments = nsnull;
tmp->Release(aState);
}
return NS_OK;

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

@ -33,7 +33,7 @@
#include "nsIPresContext.h"
#include "nsIFrame.h"
//#define XULTREE
#define XULTREE
// XXX Hack
#include "nsTreeOuterFrame.h"

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

@ -94,7 +94,7 @@ nsTreeLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSiz
aSize.height = frame->GetRowCount() * rowheight;
// Pad the height.
nscoord y = frame->GetAvailableHeight();
if (y > 0 && rowheight > 0) {
if (aSize.height > y && y > 0 && rowheight > 0) {
nscoord m = (aSize.height-y)%rowheight;
nscoord remainder = m == 0 ? 0 : rowheight - m;
aSize.height += remainder;
@ -113,7 +113,7 @@ nsTreeLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize
aSize.height = frame->GetRowCount() * rowheight;
// Pad the height.
nscoord y = frame->GetAvailableHeight();
if (y > 0 && rowheight > 0) {
if (aSize.height > y && y > 0 && rowheight > 0) {
nscoord m = (aSize.height-y)%rowheight;
nscoord remainder = m == 0 ? 0 : rowheight - m;
aSize.height += remainder;
@ -132,7 +132,7 @@ nsTreeLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize
aSize.height = frame->GetRowCount() * rowheight;
// Pad the height.
nscoord y = frame->GetAvailableHeight();
if (y > 0 && rowheight > 0) {
if (aSize.height > y && y > 0 && rowheight > 0) {
nscoord m = (aSize.height-y)%rowheight;
nscoord remainder = m == 0 ? 0 : rowheight - m;
aSize.height += remainder;

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

@ -25,6 +25,7 @@
#include "nsCOMPtr.h"
#include "nsXULTreeOuterGroupFrame.h"
#include "nsXULAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsIContent.h"
#include "nsINameSpaceManager.h"
#include "nsIScrollableFrame.h"
@ -63,7 +64,7 @@ NS_NewXULTreeOuterGroupFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRB
// Constructor
nsXULTreeOuterGroupFrame::nsXULTreeOuterGroupFrame(nsIPresShell* aPresShell, PRBool aIsRoot, nsIBoxLayout* aLayoutManager, PRBool aIsHorizontal)
:nsXULTreeGroupFrame(aPresShell, aIsRoot, aLayoutManager, aIsHorizontal),
mRowGroupInfo(nsnull), mRowHeight(TREE_LINE_HEIGHT), mCurrentIndex(0), mTwipIndex(0)
mRowGroupInfo(nsnull), mRowHeight(0), mCurrentIndex(0), mTwipIndex(0)
{}
// Destructor
@ -124,6 +125,42 @@ nsXULTreeOuterGroupFrame::Init(nsIPresContext* aPresContext, nsIContent* aConten
} // Init
PRBool
nsXULTreeOuterGroupFrame::IsFixedRowSize()
{
nsCOMPtr<nsIContent> parent;
mContent->GetParent(*getter_AddRefs(parent));
nsAutoString rows;
parent->GetAttribute(kNameSpaceID_None, nsXULAtoms::rows, rows);
if (!rows.IsEmpty())
return PR_TRUE;
return PR_FALSE;
}
void
nsXULTreeOuterGroupFrame::SetRowHeight(nscoord aRowHeight)
{
if (mRowHeight == 0) {
mRowHeight = aRowHeight;
nsCOMPtr<nsIContent> parent;
mContent->GetParent(*getter_AddRefs(parent));
nsAutoString rows;
parent->GetAttribute(kNameSpaceID_None, nsXULAtoms::rows, rows);
if (!rows.IsEmpty()) {
PRInt32 dummy;
PRInt32 count = rows.ToInteger(&dummy);
float t2p;
mPresContext->GetTwipsToPixels(&t2p);
PRInt32 rowHeight = NSTwipsToIntPixels(aRowHeight, t2p);
nsAutoString value;
value.AppendInt(rowHeight*count);
parent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::height, value, PR_FALSE);
}
nsBoxLayoutState state(mPresContext);
MarkDirtyChildren(state);
}
}
nscoord
nsXULTreeOuterGroupFrame::GetYPosition()
{
@ -337,7 +374,7 @@ nsXULTreeOuterGroupFrame::InternalPositionChanged(PRBool aUp, PRInt32 aDelta)
}
nsBoxLayoutState state(mPresContext);
mFirstChild = mLastChild = nsnull;
ClearChildren(state);
mFrames.DestroyFrames(mPresContext);
nsCOMPtr<nsIContent> topRowContent;
@ -715,19 +752,28 @@ nsXULTreeOuterGroupFrame::EnsureRowIsVisible(PRInt32 aRowIndex)
{
PRInt32 rows = GetAvailableHeight()/mRowHeight;
PRInt32 bottomIndex = mCurrentIndex + rows - 1;
if (IsFixedRowSize())
bottomIndex++;
// if row is visible, ignore
if (mCurrentIndex <= aRowIndex && aRowIndex <= bottomIndex)
return;
// Try to center the new index.
PRInt32 newIndex = aRowIndex - rows/2;
if (newIndex < 0)
newIndex = 0;
PRInt32 newIndex = aRowIndex;
PRInt32 delta = mCurrentIndex > newIndex ? mCurrentIndex - newIndex : newIndex - mCurrentIndex;
PRInt32 up = newIndex < mCurrentIndex;
mCurrentIndex = newIndex;
PRBool up = newIndex < mCurrentIndex;
if (up)
mCurrentIndex = newIndex;
else {
// Scroll just enough to bring the newIndex into view.
PRInt32 adjustment = newIndex - rows;
if (!IsFixedRowSize())
adjustment++;
delta = adjustment - mCurrentIndex;
mCurrentIndex = adjustment;
}
InternalPositionChanged(up, delta);
// This change has to happen immediately.
@ -742,7 +788,7 @@ nsXULTreeOuterGroupFrame::ScrollToIndex(PRInt32 aRowIndex)
{
PRInt32 newIndex = aRowIndex;
PRInt32 delta = mCurrentIndex > newIndex ? mCurrentIndex - newIndex : newIndex - mCurrentIndex;
PRInt32 up = newIndex < mCurrentIndex;
PRBool up = newIndex < mCurrentIndex;
mCurrentIndex = newIndex;
InternalPositionChanged(up, delta);

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

@ -95,14 +95,8 @@ public:
void ClearRowGroupInfo() { if (mRowGroupInfo) mRowGroupInfo->Clear(); NeedsRecalc(); };
void SetRowHeight(PRInt32 aRowHeight)
{
if (mRowHeight != aRowHeight) {
mRowHeight = aRowHeight;
nsBoxLayoutState state(mPresContext);
MarkDirtyChildren(state);
}
};
void SetRowHeight(PRInt32 aRowHeight);
PRBool IsFixedRowSize();
nscoord GetYPosition();
nscoord GetAvailableHeight();