Improving trees.

This commit is contained in:
hyatt%netscape.com 2000-01-10 03:04:05 +00:00
parent 542c0cc4fe
commit 0e8c3d1636
13 changed files with 173 additions and 17 deletions

View File

@ -584,6 +584,17 @@ nsresult nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresCont
nscoord tableMaxWidth = PR_MAX(aReflowState.reflowState.availableWidth, mMinCaptionWidth);
nsHTMLReflowState innerReflowState(aPresContext, aReflowState.reflowState, mInnerTableFrame,
nsSize(tableMaxWidth, aReflowState.reflowState.availableHeight));
// Tables are completely screwed up. They do not really obey mComputedWidth and mComputedHeight,
// and when the innerReflowState is constructed, they attempt to set it themselves by looking
// for their styled width and height. This is totally bogus, since there's no reason to
// believe that those #s are always accurate now that the notion of flex has been
// introduced.
// The following function will at least make trees behave properly inside boxes. Maybe one
// day we'll be able to make tables behave too.
FixBadReflowState(aReflowState.reflowState, innerReflowState);
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState,
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
mInnerTableFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);

View File

@ -228,6 +228,12 @@ protected:
// end Incremental Reflow methods
// The following function at least lets the tree widget work
// inside boxes. It repairs the reflow state after it's been
// screwed up by the nsHTMLReflowState code.
NS_IMETHOD FixBadReflowState(const nsHTMLReflowState& aParentReflowState,
nsHTMLReflowState& aChildReflowState) { return NS_OK; };
private:
/** used to keep track of this frame's children */
nsIFrame *mInnerTableFrame;

View File

@ -584,6 +584,17 @@ nsresult nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresCont
nscoord tableMaxWidth = PR_MAX(aReflowState.reflowState.availableWidth, mMinCaptionWidth);
nsHTMLReflowState innerReflowState(aPresContext, aReflowState.reflowState, mInnerTableFrame,
nsSize(tableMaxWidth, aReflowState.reflowState.availableHeight));
// Tables are completely screwed up. They do not really obey mComputedWidth and mComputedHeight,
// and when the innerReflowState is constructed, they attempt to set it themselves by looking
// for their styled width and height. This is totally bogus, since there's no reason to
// believe that those #s are always accurate now that the notion of flex has been
// introduced.
// The following function will at least make trees behave properly inside boxes. Maybe one
// day we'll be able to make tables behave too.
FixBadReflowState(aReflowState.reflowState, innerReflowState);
rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState,
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
mInnerTableFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);

View File

@ -228,6 +228,12 @@ protected:
// end Incremental Reflow methods
// The following function at least lets the tree widget work
// inside boxes. It repairs the reflow state after it's been
// screwed up by the nsHTMLReflowState code.
NS_IMETHOD FixBadReflowState(const nsHTMLReflowState& aParentReflowState,
nsHTMLReflowState& aChildReflowState) { return NS_OK; };
private:
/** used to keep track of this frame's children */
nsIFrame *mInnerTableFrame;

View File

@ -142,11 +142,13 @@ nsTableFrame* nsTreeCellFrame::GetTreeFrame()
return mTreeFrame;
}
NS_METHOD nsTreeCellFrame::Reflow(nsIPresContext* aPresContext,
NS_IMETHODIMP nsTreeCellFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
//printf("Tree Cell Width: %d, Tree Cell Height: %d\n", aReflowState.mComputedWidth, aReflowState.mComputedHeight);
nsresult rv = nsTableCellFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
return rv;

View File

@ -451,6 +451,14 @@ nsTreeFrame::Reflow(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_ASSERTION(aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE,
"Reflowing tree with unconstrained width!!!!");
NS_ASSERTION(aReflowState.mComputedHeight != NS_UNCONSTRAINEDSIZE,
"Reflowing tree with unconstrained height!!!!");
//printf("Tree Width: %d, Tree Height: %d\n", aReflowState.mComputedWidth, aReflowState.mComputedHeight);
nsresult rv = NS_OK;
mSlatedForReflow = PR_FALSE;
@ -477,11 +485,11 @@ nsTreeFrame::Reflow(nsIPresContext* aPresContext,
if (aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE)
aDesiredSize.width = aReflowState.mComputedWidth +
aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
if (aReflowState.mComputedHeight != NS_UNCONSTRAINEDSIZE)
aDesiredSize.height = aReflowState.mComputedHeight +
aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
aDesiredSize.ascent = aDesiredSize.height;

View File

@ -30,6 +30,7 @@
#include "nsIDOMXULTreeElement.h"
#include "nsINameSpaceManager.h"
#include "nsXULAtoms.h"
#include "nsBoxFrame.h"
//
// NS_NewTreeOuterFrame
@ -90,3 +91,94 @@ nsTreeOuterFrame::HandleEvent(nsIPresContext* aPresContext,
return NS_OK;
}
NS_IMETHODIMP
nsTreeOuterFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
NS_ASSERTION(aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE,
"Reflowing outer tree frame with unconstrained width!!!!");
NS_ASSERTION(aReflowState.mComputedHeight != NS_UNCONSTRAINEDSIZE,
"Reflowing outer tree frame with unconstrained height!!!!");
//printf("TOF Width: %d, TOF Height: %d\n", aReflowState.mComputedWidth, aReflowState.mComputedHeight);
return nsTableOuterFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
}
/**
* Ok return our dimensions
*/
NS_IMETHODIMP
nsTreeOuterFrame::GetBoxInfo(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize)
{
aSize.minSize.width = 0;
aSize.minSize.height = 0;
aSize.prefSize.width = 100;
aSize.prefSize.height = 100;
((nsCalculatedBoxInfo&)aSize).prefWidthIntrinsic = PR_FALSE;
((nsCalculatedBoxInfo&)aSize).prefHeightIntrinsic = PR_FALSE;
return NS_OK;
}
/**
* We can be a nsIBox
*/
NS_IMETHODIMP
nsTreeOuterFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
if (aIID.Equals(NS_GET_IID(nsIBox))) {
*aInstancePtr = (void*)(nsIBox*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsTableOuterFrame::QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP
nsTreeOuterFrame::Dirty(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild)
{
incrementalChild = this;
return NS_OK;
}
/*
* We are a frame and we do not maintain a ref count
*/
NS_IMETHODIMP_(nsrefcnt)
nsTreeOuterFrame::AddRef(void)
{
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsTreeOuterFrame::Release(void)
{
return NS_OK;
}
NS_IMETHODIMP
nsTreeOuterFrame::FixBadReflowState(const nsHTMLReflowState& aParentReflowState,
nsHTMLReflowState& aChildReflowState)
{
if (aParentReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE) {
aChildReflowState.mComputedWidth = aParentReflowState.mComputedWidth;
}
if (aParentReflowState.mComputedHeight != NS_UNCONSTRAINEDSIZE) {
aChildReflowState.mComputedHeight = aParentReflowState.mComputedHeight;
}
return NS_OK;
}

View File

@ -21,8 +21,9 @@
*/
#include "nsTableOuterFrame.h"
#include "nsIBox.h"
class nsTreeOuterFrame : public nsTableOuterFrame
class nsTreeOuterFrame : public nsTableOuterFrame, nsIBox
{
public:
friend nsresult NS_NewTreeOuterFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
@ -31,6 +32,19 @@ public:
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_DECL_ISUPPORTS
NS_IMETHOD GetBoxInfo(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize);
NS_IMETHOD Dirty(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild);
NS_IMETHOD FixBadReflowState(const nsHTMLReflowState& aParentReflowState,
nsHTMLReflowState& aChildReflowState);
protected:
nsTreeOuterFrame();
virtual ~nsTreeOuterFrame();

View File

@ -201,6 +201,13 @@ nsTreeRowFrame::Reflow(nsIPresContext* aPresContext,
i++;
printf("Full row reflow! Number %d\n", i);
*/
// Debugging info.
NS_ASSERTION(aReflowState.mComputedWidth != NS_UNCONSTRAINEDSIZE,
"Reflowing tree row frame with unconstrained width!!!!");
//printf("Tree Row Width: %d, Tree Row Height: %d\n", aReflowState.mComputedWidth, aReflowState.mComputedHeight);
if (mState & NS_FRAME_FIRST_REFLOW) {
// Newly inserted frame
((nsHTMLReflowState&)aReflowState).reason = eReflowReason_Initial;

View File

@ -973,6 +973,16 @@ nsTreeRowGroupFrame::ReflowBeforeRowLayout(nsIPresContext* aPresContext,
nsReflowStatus& aStatus,
nsReflowReason aReason)
{
NS_ASSERTION(!aReflowState.unconstrainedWidth,
"Reflowing tree row group with unconstrained width!!!!");
NS_ASSERTION(!aReflowState.unconstrainedHeight,
"Reflowing tree row group with unconstrained height!!!!");
//if (mScrollbar)
// printf("TRG Width: %d, TRG Height: %d\n", aReflowState.availSize.width,
// aReflowState.availSize.height);
nsresult rv = NS_OK;
mRowGroupHeight = aReflowState.availSize.height;
return rv;

View File

@ -571,9 +571,7 @@ Rights Reserved.
<box align="vertical" flex="1">
<html:div id="results_box" style="width:100px;height:0px" flex="2" >
<tree id="threadTree"/>
</html:div>
<tree id="threadTree" flex="2" style="height:0px"/>
<!-- if you change this id, please change GetThreadAndMessagePaneSplitter() -->
<splitter id="gray_horizontal_splitter" collapse="after" persist="state"

View File

@ -34,7 +34,7 @@ Rights Reserved.
<html:script src="chrome://global/content/treePopups.js"/>
<html:script src="chrome://messenger/content/messengerdnd.js"/>
<tree datasources="rdf:null" id="threadTree" style="width: 100%; height: 100%"
<tree datasources="rdf:null" id="threadTree"
onselect="top.ThreadPaneSelectionChange(); document.commandDispatcher.updateCommands('tree-select');"
onblur="goOnEvent(this,'blur')"
containment="http://home.netscape.com/NC-rdf#MessageChild">

View File

@ -23,19 +23,10 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to HTML */
@namespace html url("http://www.w3.org/TR/REC-html40"); /* namespace for XUL elements */
[hide] {
 display: none;
}
tree {
border-left: 1px solid transparent;
}
tree:focus {
border-left: 1px solid #336699;
}
treeitem[selected="true"] > treerow {
color: black;
background-color: #CCCCCC;