Fix for 42867. r=evaughan

This commit is contained in:
hyatt%netscape.com 2000-06-20 00:52:57 +00:00
parent b4a13cb700
commit 1e8e0acdcc
10 changed files with 74 additions and 17 deletions

View File

@ -301,7 +301,6 @@ nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsIAtom> tag;
while (PR_TRUE) {
content = do_QueryInterface(currentItem);
content->GetTag(*getter_AddRefs(tag));
@ -336,16 +335,30 @@ nsXULTreeElement::SelectAll()
if (childCount == 0)
return NS_OK;
nsCOMPtr<nsIContent> startContent;
content->ChildAt(0, *getter_AddRefs(startContent));
nsCOMPtr<nsIContent> endContent;
content->ChildAt(childCount-1, *getter_AddRefs(endContent));
// Get the total row count.
nsCOMPtr<nsIBoxObject> boxObject;
mOuter->GetBoxObject(getter_AddRefs(boxObject));
nsCOMPtr<nsITreeBoxObject> treebox = do_QueryInterface(boxObject);
PRInt32 rowCount;
treebox->GetRowCount(&rowCount);
if (rowCount == 0)
return NS_OK;
nsCOMPtr<nsIDOMXULElement> startElement = do_QueryInterface(startContent);
nsCOMPtr<nsIDOMXULElement> endElement = do_QueryInterface(endContent);
// Get the item at index 0
nsCOMPtr<nsIDOMXULElement> startContent;
nsCOMPtr<nsIDOMElement> startElement;
treebox->GetItemAtIndex(0, getter_AddRefs(startElement));
startContent = do_QueryInterface(startElement);
// Get the item at index rowCount-1
nsCOMPtr<nsIDOMXULElement> endContent;
nsCOMPtr<nsIDOMElement> endElement;
treebox->GetItemAtIndex(rowCount-1, getter_AddRefs(endElement));
endContent = do_QueryInterface(endElement);
// Select the whole range.
SelectItemRange(startElement, endElement);
SelectItemRange(startContent, endContent);
// We shouldn't move the active item.
mCurrentItem = oldItem;

View File

@ -37,6 +37,7 @@ interface nsITreeBoxObject : nsISupports
long getIndexOfItem(in nsIDOMElement item);
long getNumberOfVisibleRows();
long getIndexOfFirstVisibleRow();
long getRowCount();
};
%{C++

View File

@ -45,6 +45,7 @@ public:
NS_IMETHOD GetIndexOfItem(nsIPresContext* aPresContext, nsIDOMElement* aElement, PRInt32* aResult) = 0;
NS_IMETHOD GetNumberOfVisibleRows(PRInt32* aResult) = 0;
NS_IMETHOD GetIndexOfFirstVisibleRow(PRInt32* aResult) = 0;
NS_IMETHOD GetRowCount(PRInt32* aResult) = 0;
};
#endif

View File

@ -198,6 +198,16 @@ NS_IMETHODIMP nsTreeBoxObject::GetIndexOfFirstVisibleRow(PRInt32 *aResult)
return treeFrame->GetIndexOfFirstVisibleRow(aResult);
}
NS_IMETHODIMP nsTreeBoxObject::GetRowCount(PRInt32 *aResult)
{
nsIFrame* frame = GetFrame();
if (!frame)
return NS_OK;
nsCOMPtr<nsITreeFrame> treeFrame(do_QueryInterface(frame));
return treeFrame->GetRowCount(aResult);
}
// Creation Routine ///////////////////////////////////////////////////////////////////////
nsresult

View File

@ -106,6 +106,7 @@ public:
NS_IMETHOD GetIndexOfItem(nsIPresContext* aPresContext, nsIDOMElement* aElement, PRInt32* aResult);
NS_IMETHOD GetNumberOfVisibleRows(PRInt32* aResult);
NS_IMETHOD GetIndexOfFirstVisibleRow(PRInt32* aResult);
NS_IMETHOD GetRowCount(PRInt32* aResult) { return NS_OK; }
PRInt32 GetFixedRowSize() { return mFixedRows; };

View File

@ -267,6 +267,17 @@ nsXULTreeFrame::GetIndexOfFirstVisibleRow(PRInt32 *aResult)
return XULTreeOuterGroup->GetIndexOfFirstVisibleRow(aResult);
}
NS_IMETHODIMP
nsXULTreeFrame::GetRowCount(PRInt32 *aResult)
{
// Get our treechildren child frame.
nsXULTreeOuterGroupFrame* XULTreeOuterGroup = nsnull;
GetTreeBody(&XULTreeOuterGroup);
if (!XULTreeOuterGroup) return NS_OK;
return XULTreeOuterGroup->GetRowCount(aResult);
}
void
nsXULTreeFrame::GetTreeBody(nsXULTreeOuterGroupFrame** aResult)

View File

@ -48,6 +48,7 @@ public:
NS_IMETHOD GetIndexOfItem(nsIPresContext* aPresContext, nsIDOMElement* aElement, PRInt32* aResult);
NS_IMETHOD GetNumberOfVisibleRows(PRInt32 *aResult);
NS_IMETHOD GetIndexOfFirstVisibleRow(PRInt32 *aResult);
NS_IMETHOD GetRowCount(PRInt32* aResult);
protected:
nsXULTreeFrame(nsIPresShell* aPresShell, PRBool aIsRoot = nsnull, nsIBoxLayout* aLayoutManager = nsnull, PRBool aDefaultHorizontal = PR_TRUE);

View File

@ -581,7 +581,11 @@ nsXULTreeOuterGroupFrame::FindRowContentAtIndex(PRInt32& aIndex,
}
PRInt32 delta = (PRInt32)(point-aIndex);
FindPreviousRowContent(delta, startContent, nsnull, aResult);
if (delta == 0) {
*aResult = startContent;
NS_IF_ADDREF(*aResult);
}
else FindPreviousRowContent(delta, startContent, nsnull, aResult);
}
void

View File

@ -106,6 +106,8 @@ public:
NS_IMETHOD GetIndexOfFirstVisibleRow(PRInt32 *aResult) {
*aResult=mCurrentIndex; return NS_OK;
}
NS_IMETHOD GetRowCount(PRInt32* aResult) { *aResult = GetRowCount(); return NS_OK; }
NS_IMETHOD PositionChanged(PRInt32 aOldIndex, PRInt32 aNewIndex);
NS_IMETHOD ScrollbarButtonPressed(PRInt32 aOldIndex, PRInt32 aNewIndex);

View File

@ -301,7 +301,6 @@ nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement
nsCOMPtr<nsIContent> content;
nsCOMPtr<nsIAtom> tag;
while (PR_TRUE) {
content = do_QueryInterface(currentItem);
content->GetTag(*getter_AddRefs(tag));
@ -336,16 +335,30 @@ nsXULTreeElement::SelectAll()
if (childCount == 0)
return NS_OK;
nsCOMPtr<nsIContent> startContent;
content->ChildAt(0, *getter_AddRefs(startContent));
nsCOMPtr<nsIContent> endContent;
content->ChildAt(childCount-1, *getter_AddRefs(endContent));
// Get the total row count.
nsCOMPtr<nsIBoxObject> boxObject;
mOuter->GetBoxObject(getter_AddRefs(boxObject));
nsCOMPtr<nsITreeBoxObject> treebox = do_QueryInterface(boxObject);
PRInt32 rowCount;
treebox->GetRowCount(&rowCount);
if (rowCount == 0)
return NS_OK;
nsCOMPtr<nsIDOMXULElement> startElement = do_QueryInterface(startContent);
nsCOMPtr<nsIDOMXULElement> endElement = do_QueryInterface(endContent);
// Get the item at index 0
nsCOMPtr<nsIDOMXULElement> startContent;
nsCOMPtr<nsIDOMElement> startElement;
treebox->GetItemAtIndex(0, getter_AddRefs(startElement));
startContent = do_QueryInterface(startElement);
// Get the item at index rowCount-1
nsCOMPtr<nsIDOMXULElement> endContent;
nsCOMPtr<nsIDOMElement> endElement;
treebox->GetItemAtIndex(rowCount-1, getter_AddRefs(endElement));
endContent = do_QueryInterface(endElement);
// Select the whole range.
SelectItemRange(startElement, endElement);
SelectItemRange(startContent, endContent);
// We shouldn't move the active item.
mCurrentItem = oldItem;