mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 19:37:15 +00:00
Fixing the content model structure and correcting a drawing error
in the tree view.
This commit is contained in:
parent
58fef6676e
commit
d22b37ac06
@ -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;
|
||||
}
|
||||
|
@ -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; }
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user