From 2bd2fc024d88cbab8566bbfc459f512ecbe4e968 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Fri, 11 Dec 1998 23:01:09 +0000 Subject: [PATCH] Fixing the content model structure and correcting a drawing error in the tree view. git-svn-id: svn://10.0.0.236/trunk@16276 18797224-902f-48f8-a5cc-f745e15eee43 --- .../widget/src/xpwidgets/nsHTDataModel.cpp | 24 ++++++++++++++++++- mozilla/widget/src/xpwidgets/nsHTDataModel.h | 1 + mozilla/widget/src/xpwidgets/nsHTItem.cpp | 22 ----------------- mozilla/widget/src/xpwidgets/nsHTItem.h | 5 ++-- .../src/xpwidgets/nsHTTreeDataModel.cpp | 2 +- mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp | 19 ++++++--------- mozilla/widget/src/xpwidgets/nsTreeView.cpp | 2 +- 7 files changed, 35 insertions(+), 40 deletions(-) diff --git a/mozilla/widget/src/xpwidgets/nsHTDataModel.cpp b/mozilla/widget/src/xpwidgets/nsHTDataModel.cpp index 435b7ef7383..e755d4dd395 100644 --- a/mozilla/widget/src/xpwidgets/nsHTDataModel.cpp +++ b/mozilla/widget/src/xpwidgets/nsHTDataModel.cpp @@ -99,7 +99,7 @@ void nsHTDataModel::AddNodesToArray(nsIContent* pContent, PRUint32 indentLevel) nsHTItem* pItem = NS_STATIC_CAST(nsHTItem*, pDataItem->GetImplData()); - nsIContent* pChildrenNode = pItem->FindChildWithName("children"); + nsIContent* pChildrenNode = nsHTDataModel::FindChildWithName(pItem->GetContentNode(), "children"); if (pChildrenNode) { // If the node is OPEN, then its children need to be added to the visibility array. @@ -159,6 +159,7 @@ void nsHTDataModel::ImageLoaded(nsHierarchicalDataItem* pItem) } } +// Static Helper functions void nsHTDataModel::GetChildTextForNode(nsIContent* pChildNode, nsString& text) { nsIContent* pChild; @@ -176,3 +177,24 @@ static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID); NS_IF_RELEASE(pChild); } + +nsIContent* nsHTDataModel::FindChildWithName(nsIContent* pNode, const nsString& name) +{ + PRInt32 count; + pNode->ChildCount(count); + for (PRInt32 i = 0; i < count; i++) + { + nsIAtom* pAtom = nsnull; + nsIContent* pChild = nsnull; + pNode->ChildAt(i, pChild); + pChild->GetTag(pAtom); + nsString answer; + pAtom->ToString(answer); + NS_IF_RELEASE(pAtom); + if (answer.EqualsIgnoreCase(name)) + return pChild; + else NS_IF_RELEASE(pChild); + } + + return nsnull; +} diff --git a/mozilla/widget/src/xpwidgets/nsHTDataModel.h b/mozilla/widget/src/xpwidgets/nsHTDataModel.h index 5bdfbf48736..e35db932ab6 100644 --- a/mozilla/widget/src/xpwidgets/nsHTDataModel.h +++ b/mozilla/widget/src/xpwidgets/nsHTDataModel.h @@ -60,6 +60,7 @@ public: virtual nsHierarchicalDataItem* CreateDataItemWithContentNode(nsIContent* pContent) = 0; static void GetChildTextForNode(nsIContent* pChildNode, nsString& text); + static nsIContent* FindChildWithName(nsIContent* pNode, const nsString& name); void ImageLoaded(nsHierarchicalDataItem* pItem); nsIImageGroup* GetImageGroup() const { NS_ADDREF(mImageGroup); return mImageGroup; } diff --git a/mozilla/widget/src/xpwidgets/nsHTItem.cpp b/mozilla/widget/src/xpwidgets/nsHTItem.cpp index e72d24d1ffa..80c5043ec4f 100644 --- a/mozilla/widget/src/xpwidgets/nsHTItem.cpp +++ b/mozilla/widget/src/xpwidgets/nsHTItem.cpp @@ -49,25 +49,3 @@ void nsHTItem::SetIndentationLevelDelegate(PRUint32 n) { mIndentationLevel = n; } - -nsIContent* nsHTItem::FindChildWithName(const nsString& name) const -{ - PRInt32 count; - mContentNode->ChildCount(count); - for (PRInt32 i = 0; i < count; i++) - { - nsIAtom* pAtom = nsnull; - nsIContent* pChild = nsnull; - mContentNode->ChildAt(i, pChild); - pChild->GetTag(pAtom); - nsString answer; - pAtom->ToString(answer); - NS_IF_RELEASE(pAtom); - if (answer.EqualsIgnoreCase(name)) - return pChild; - else NS_IF_RELEASE(pChild); - } - - return nsnull; -} - diff --git a/mozilla/widget/src/xpwidgets/nsHTItem.h b/mozilla/widget/src/xpwidgets/nsHTItem.h index 713843dde7b..5952d85cb57 100644 --- a/mozilla/widget/src/xpwidgets/nsHTItem.h +++ b/mozilla/widget/src/xpwidgets/nsHTItem.h @@ -33,9 +33,8 @@ public: virtual PRUint32 GetIndentationLevelDelegate() const; virtual void SetIndentationLevelDelegate(PRUint32 n); -public: - nsIContent* FindChildWithName(const nsString& name) const; // Caller must release the content ptr. - + nsIContent* GetContentNode() const { return mContentNode; }; + protected: nsHierarchicalDataModel* mDataModel; nsIContent* mContentNode; diff --git a/mozilla/widget/src/xpwidgets/nsHTTreeDataModel.cpp b/mozilla/widget/src/xpwidgets/nsHTTreeDataModel.cpp index c2ea3f47d20..778467c16b0 100644 --- a/mozilla/widget/src/xpwidgets/nsHTTreeDataModel.cpp +++ b/mozilla/widget/src/xpwidgets/nsHTTreeDataModel.cpp @@ -92,7 +92,7 @@ void nsHTTreeDataModel::SetContentRoot(nsIContent* pContent) if (mRootNode) { nsHTItem* pItem = (nsHTItem*)(mRootNode->GetImplData()); - nsIContent* pColumnNode = pItem->FindChildWithName("columns"); + nsIContent* pColumnNode = nsHTDataModel::FindChildWithName(pItem->GetContentNode(), "columns"); if (pColumnNode) { PRInt32 numChildren; diff --git a/mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp b/mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp index ff8f8aeaec4..2139de28225 100644 --- a/mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp +++ b/mozilla/widget/src/xpwidgets/nsHTTreeItem.cpp @@ -178,18 +178,13 @@ void nsHTTreeItem::GetTextForColumn(nsTreeColumn* pColumn, nsString& nodeText) c pColumn->GetColumnName(columnName); // Look for a child of the content node that has this name as its tag. -#if defined(SEPARATE_COLUMN_GROUP) - nsIContent* pColumnNode = FindChildWithName("columns"); - if (pColumnNode) { - nsIContent* pChildNode = pColumnNode->FindChildWithName(columnName); - if (pChildNode) - nsHTDataModel::GetChildTextForNode(pChildNode, nodeText); - } -#else - nsIContent* pChildNode = FindChildWithName(columnName); - if (pChildNode) - nsHTDataModel::GetChildTextForNode(pChildNode, nodeText); -#endif + nsIContent* pColumnNode = nsHTDataModel::FindChildWithName(mContentNode, "columns"); + if (pColumnNode) + { + nsIContent* pChildNode = nsHTDataModel::FindChildWithName(pColumnNode, columnName); + if (pChildNode) + nsHTDataModel::GetChildTextForNode(pChildNode, nodeText); + } } // image request observer implementation diff --git a/mozilla/widget/src/xpwidgets/nsTreeView.cpp b/mozilla/widget/src/xpwidgets/nsTreeView.cpp index b0c2de81a75..6bddf32f97f 100644 --- a/mozilla/widget/src/xpwidgets/nsTreeView.cpp +++ b/mozilla/widget/src/xpwidgets/nsTreeView.cpp @@ -649,7 +649,7 @@ void nsTreeView::PaintTreeRows(nsIRenderingContext* drawCtx, nsRect remainderRect(0, yPosition, rect.width, rect.height - yPosition); nscolor viewBGColor = NS_RGB(240,240,240); drawCtx->SetColor(viewBGColor); - drawCtx->FillRect(rect); + drawCtx->FillRect(remainderRect); } }