diff --git a/layout/xul/base/src/outliner/public/nsIOutlinerView.idl b/layout/xul/base/src/outliner/public/nsIOutlinerView.idl index 5c9e98c2ee74..0dd09878b16e 100644 --- a/layout/xul/base/src/outliner/public/nsIOutlinerView.idl +++ b/layout/xul/base/src/outliner/public/nsIOutlinerView.idl @@ -52,6 +52,11 @@ interface nsIOutlinerView : nsISupports // to be matched on the ::moz-outliner-cell pseudoelement. void getCellProperties(in long row, in wstring colID, in nsISupportsArray properties); + // Methods that can be used to test whether or not a twisty should be drawn, + // and if so, whether an open or closed twisty should be used. + boolean isContainer(in long index); + boolean isContainerOpen(in long index); + // The text for a given cell. If a column consists only of an image, then // the empty string is returned. The level is an integer value that represents // the level of indentation. It is multiplied by the width specified in the diff --git a/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp b/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp index 943fd9f781df..8c62dea3a520 100644 --- a/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp +++ b/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp @@ -29,6 +29,9 @@ #include "nsXULAtoms.h" #include "nsIContent.h" #include "nsIStyleContext.h" +#include "nsIDOMElement.h" +#include "nsIDOMNodeList.h" +#include "nsIContent.h" // The style context cache impl nsresult @@ -267,7 +270,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::Paint(nsIPresContext* aPresContext, mView->GetRowCount(&rowCount); // Ensure our column info is built. - EnsureColumns(); + EnsureColumns(aPresContext); // Loop through our onscreen rows. for (PRInt32 i = mTopRowIndex; i < rowCount && i < mTopRowIndex+mPageCount+1; i++) { @@ -307,10 +310,39 @@ nsOutlinerBodyFrame::GetPseudoStyleContext(nsIPresContext* aPresContext, nsIStyl } void -nsOutlinerBodyFrame::EnsureColumns() +nsOutlinerBodyFrame::EnsureColumns(nsIPresContext* aPresContext) { if (!mColumns) { + nsCOMPtr parent; + mContent->GetParent(*getter_AddRefs(parent)); + nsCOMPtr elt(do_QueryInterface(parent)); + nsCOMPtr cols; + elt->GetElementsByTagName(NS_LITERAL_STRING("outlinercol"), getter_AddRefs(cols)); + + nsCOMPtr shell; + aPresContext->GetShell(getter_AddRefs(shell)); + + PRUint32 count; + cols->GetLength(&count); + + nsOutlinerColumn* currCol = nsnull; + for (PRUint32 i = 0; i < count; i++) { + nsCOMPtr node; + cols->Item(i, getter_AddRefs(node)); + nsCOMPtr child(do_QueryInterface(node)); + + // Get the frame for this column. + nsIFrame* frame; + shell->GetPrimaryFrameFor(child, &frame); + + // Create a new column structure. + nsOutlinerColumn* col = new nsOutlinerColumn(child, frame); + if (currCol) + currCol->SetNext(col); + else mColumns = col; + currCol = col; + } } } diff --git a/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.h b/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.h index 4ece88d28ec2..c691dac86fb8 100644 --- a/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.h +++ b/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.h @@ -122,7 +122,7 @@ class nsOutlinerColumn { nsIFrame* mColFrame; public: - nsOutlinerColumn(nsIContent* aColElement); + nsOutlinerColumn(nsIContent* aColElement, nsIFrame* aFrame); virtual ~nsOutlinerColumn(); void SetNext(nsOutlinerColumn* aNext) { mNext = aNext; }; @@ -178,7 +178,7 @@ protected: nsresult GetPseudoStyleContext(nsIPresContext* aPresContext, nsIStyleContext** aResult); // Builds our cache of column info. - void EnsureColumns(); + void EnsureColumns(nsIPresContext* aContext); protected: // Data Members // The current view for this outliner widget. We get all of our row and cell data diff --git a/layout/xul/base/src/tree/public/nsITreeView.idl b/layout/xul/base/src/tree/public/nsITreeView.idl index 5c9e98c2ee74..0dd09878b16e 100644 --- a/layout/xul/base/src/tree/public/nsITreeView.idl +++ b/layout/xul/base/src/tree/public/nsITreeView.idl @@ -52,6 +52,11 @@ interface nsIOutlinerView : nsISupports // to be matched on the ::moz-outliner-cell pseudoelement. void getCellProperties(in long row, in wstring colID, in nsISupportsArray properties); + // Methods that can be used to test whether or not a twisty should be drawn, + // and if so, whether an open or closed twisty should be used. + boolean isContainer(in long index); + boolean isContainerOpen(in long index); + // The text for a given cell. If a column consists only of an image, then // the empty string is returned. The level is an integer value that represents // the level of indentation. It is multiplied by the width specified in the diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 943fd9f781df..8c62dea3a520 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -29,6 +29,9 @@ #include "nsXULAtoms.h" #include "nsIContent.h" #include "nsIStyleContext.h" +#include "nsIDOMElement.h" +#include "nsIDOMNodeList.h" +#include "nsIContent.h" // The style context cache impl nsresult @@ -267,7 +270,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::Paint(nsIPresContext* aPresContext, mView->GetRowCount(&rowCount); // Ensure our column info is built. - EnsureColumns(); + EnsureColumns(aPresContext); // Loop through our onscreen rows. for (PRInt32 i = mTopRowIndex; i < rowCount && i < mTopRowIndex+mPageCount+1; i++) { @@ -307,10 +310,39 @@ nsOutlinerBodyFrame::GetPseudoStyleContext(nsIPresContext* aPresContext, nsIStyl } void -nsOutlinerBodyFrame::EnsureColumns() +nsOutlinerBodyFrame::EnsureColumns(nsIPresContext* aPresContext) { if (!mColumns) { + nsCOMPtr parent; + mContent->GetParent(*getter_AddRefs(parent)); + nsCOMPtr elt(do_QueryInterface(parent)); + nsCOMPtr cols; + elt->GetElementsByTagName(NS_LITERAL_STRING("outlinercol"), getter_AddRefs(cols)); + + nsCOMPtr shell; + aPresContext->GetShell(getter_AddRefs(shell)); + + PRUint32 count; + cols->GetLength(&count); + + nsOutlinerColumn* currCol = nsnull; + for (PRUint32 i = 0; i < count; i++) { + nsCOMPtr node; + cols->Item(i, getter_AddRefs(node)); + nsCOMPtr child(do_QueryInterface(node)); + + // Get the frame for this column. + nsIFrame* frame; + shell->GetPrimaryFrameFor(child, &frame); + + // Create a new column structure. + nsOutlinerColumn* col = new nsOutlinerColumn(child, frame); + if (currCol) + currCol->SetNext(col); + else mColumns = col; + currCol = col; + } } }