diff --git a/mozilla/content/shared/public/nsXULAtoms.h b/mozilla/content/shared/public/nsXULAtoms.h index 05aad215d41..bc7230df3da 100644 --- a/mozilla/content/shared/public/nsXULAtoms.h +++ b/mozilla/content/shared/public/nsXULAtoms.h @@ -58,7 +58,7 @@ public: static nsIAtom* tree; // The start of a tree view static nsIAtom* treecaption; // The caption of a tree view static nsIAtom* treehead; // The header of the tree view - static nsIAtom* treebody; // The body of the tree view + static nsIAtom* treerow; // A row in the tree view static nsIAtom* treeitem; // An item in the tree view static nsIAtom* treecell; // A cell in the tree view static nsIAtom* treechildren; // The children of an item in the tree viw diff --git a/mozilla/content/shared/src/nsXULAtoms.cpp b/mozilla/content/shared/src/nsXULAtoms.cpp index 68c30d84aea..beaa4a0c0a1 100644 --- a/mozilla/content/shared/src/nsXULAtoms.cpp +++ b/mozilla/content/shared/src/nsXULAtoms.cpp @@ -40,7 +40,7 @@ nsIAtom* nsXULAtoms::toolbox; nsIAtom* nsXULAtoms::tree; nsIAtom* nsXULAtoms::treecaption; nsIAtom* nsXULAtoms::treehead; -nsIAtom* nsXULAtoms::treebody; +nsIAtom* nsXULAtoms::treerow; nsIAtom* nsXULAtoms::treeitem; nsIAtom* nsXULAtoms::treecell; nsIAtom* nsXULAtoms::treechildren; @@ -105,7 +105,7 @@ void nsXULAtoms::AddrefAtoms() { tree = NS_NewAtom("tree"); treecaption = NS_NewAtom("treecaption"); treehead = NS_NewAtom("treehead"); - treebody = NS_NewAtom("treebody"); + treerow = NS_NewAtom("treerow"); treecell = NS_NewAtom("treecell"); treeitem = NS_NewAtom("treeitem"); treechildren = NS_NewAtom("treechildren"); @@ -161,7 +161,7 @@ void nsXULAtoms::ReleaseAtoms() { NS_RELEASE(tree); NS_RELEASE(treecaption); NS_RELEASE(treehead); - NS_RELEASE(treebody); + NS_RELEASE(treerow); NS_RELEASE(treecell); NS_RELEASE(treeitem); NS_RELEASE(treechildren); diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 1f714b0b34d..d77a3e5ede4 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -1732,8 +1732,8 @@ nsCSSFrameConstructor::TableIsValidCellContent(nsIPresContext* aPresContext, (nsXULAtoms::widget == tag.get()) || (nsXULAtoms::tree == tag.get()) || (nsXULAtoms::treechildren == tag.get()) || - (nsXULAtoms::treebody == tag.get()) || (nsXULAtoms::treeitem == tag.get()) || + (nsXULAtoms::treerow == tag.get()) || (nsXULAtoms::treecell == tag.get()) || (nsXULAtoms::treeindentation == tag.get()) || (nsXULAtoms::toolbox == tag.get()) || @@ -2714,9 +2714,9 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, // TREE CONSTRUCTION // The following code is used to construct a tree view from the XUL content - // model. It has to take the hierarchical tree content structure and build a flattened - // table row frame structure. - else if (aTag == nsXULAtoms::treebody) { + // model. + else if (aTag == nsXULAtoms::treeitem || + aTag == nsXULAtoms::treechildren) { nsIFrame* newTopFrame; rv = ConstructTableGroupFrame(aPresContext, aState, aContent, aParentFrame, aStyleContext, PR_TRUE, newTopFrame, newFrame, treeCreator, nsnull); @@ -2760,12 +2760,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, } return rv; } - else if (aTag == nsXULAtoms::treechildren) - { - haltProcessing = PR_TRUE; - return rv; // This is actually handled by the treeitem node. - } - else if (aTag == nsXULAtoms::treeitem) + else if (aTag == nsXULAtoms::treerow) { // A tree item causes a table row to be constructed that is always // slaved to the nearest enclosing table row group (regardless of how @@ -2773,60 +2768,29 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresContext* aPresContext, rv = ConstructTableRowFrame(aPresContext, aState, aContent, aParentFrame, aStyleContext, newFrame, ignore, treeCreator); aFrameItems.AddChild(newFrame); - - // We need to find the treechildren node that is a child of this node - // and we need to construct new rows. - PRInt32 aChildCount; - aContent->ChildCount(aChildCount); - for (PRInt32 i = 0; i < aChildCount; i++) - { - nsCOMPtr childContent; - - if (NS_SUCCEEDED(aContent->ChildAt(i, *getter_AddRefs(childContent)))) - { - // Construct a child frame - nsCOMPtr pTag; - childContent->GetTag(*getter_AddRefs(pTag)); - if (pTag.get() == nsXULAtoms::treechildren) - { - // Always build rows. Rely on style rules to hide frames. - // Rely on RDF trickery to hide synthetic content from the content model. - nsFrameConstructorSaveState floaterSaveState; - - aState.PushFloaterContainingBlock(nsnull, floaterSaveState); - rv = ProcessChildren(aPresContext, aState, childContent, aParentFrame, - PR_FALSE, aFrameItems); - NS_ASSERTION(!aState.mFloatedItems.childList, "floater in odd spot"); - } - } - } return rv; - - // Note: See later in this method. More processing has to be done after the - // tree item has constructed its children and after this frame has been added - // to our list. - } - else if (aTag == nsXULAtoms::treecell) - { - // We make a tree cell frame and process the children. - // Find out what the attribute value for event allowance is. - nsString attrValue; - nsresult result = aContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::treeallowevents, attrValue); - attrValue.ToLowerCase(); - PRBool allowEvents = (result == NS_CONTENT_ATTR_NO_VALUE || - (result == NS_CONTENT_ATTR_HAS_VALUE && attrValue=="true")); - nsIFrame* ignore2; - rv = ConstructTableCellFrame(aPresContext, aState, aContent, aParentFrame, aStyleContext, - newFrame, ignore, ignore2, treeCreator); - aFrameItems.AddChild(newFrame); - ((nsTreeCellFrame*)newFrame)->SetAllowEvents(allowEvents); - return rv; - } - else if (aTag == nsXULAtoms::treeindentation) - { - rv = NS_NewTreeIndentationFrame(&newFrame); - } - // End of TREE CONSTRUCTION code here (there's more later on in the function) + } + else if (aTag == nsXULAtoms::treecell) + { + // We make a tree cell frame and process the children. + // Find out what the attribute value for event allowance is. + nsString attrValue; + nsresult result = aContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::treeallowevents, attrValue); + attrValue.ToLowerCase(); + PRBool allowEvents = (result == NS_CONTENT_ATTR_NO_VALUE || + (result == NS_CONTENT_ATTR_HAS_VALUE && attrValue=="true")); + nsIFrame* ignore2; + rv = ConstructTableCellFrame(aPresContext, aState, aContent, aParentFrame, aStyleContext, + newFrame, ignore, ignore2, treeCreator); + aFrameItems.AddChild(newFrame); + ((nsTreeCellFrame*)newFrame)->SetAllowEvents(allowEvents); + return rv; + } + else if (aTag == nsXULAtoms::treeindentation) + { + rv = NS_NewTreeIndentationFrame(&newFrame); + } + // End of TREE CONSTRUCTION code here (there's more later on in the function) // TOOLBAR CONSTRUCTION else if (aTag == nsXULAtoms::toolbox) { @@ -4166,47 +4130,9 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, nsIFrame* parentFrame; if ((nsnull == prevSibling) && (nsnull == nextSibling)) { -#ifdef INCLUDE_XUL - // Need to (for XUL only) do a special check for the treechildren tag - PRInt32 nameSpaceID; - if (NS_SUCCEEDED(aContainer->GetNameSpaceID(nameSpaceID)) && - nameSpaceID == nsXULAtoms::nameSpaceID) { - // See if we're the treechildren tag. This tag is treated differently, - // since it has no corresponding frame, but may have children that have - // frames (the whole hierarchical content model vs. flat table frame model - // problem). - nsIAtom* tag; - aContainer->GetTag(tag); - nsString tagName; - tag->ToString(tagName); - if (tagName == "treechildren") - { - // Retrieve the parent treeitem, and then obtain its frame. This is - // the prevSibling frame that we should use. - nsCOMPtr parentItem; - aContainer->GetParent(*getter_AddRefs(parentItem)); - - shell->GetPrimaryFrameFor(parentItem, &prevSibling); - prevSibling->GetParent(&parentFrame); - // XXX: Optimize for the lazy frame instantiation case. Need to bail - // if our frame isn't visible - } - else - { - // No previous or next sibling so treat this like an appended frame. - isAppend = PR_TRUE; - shell->GetPrimaryFrameFor(aContainer, &parentFrame); - } - } - else { -#endif // INCLUDE_XUL - // No previous or next sibling so treat this like an appended frame. isAppend = PR_TRUE; shell->GetPrimaryFrameFor(aContainer, &parentFrame); -#ifdef INCLUDE_XUL - } -#endif } else { // Use the prev sibling if we have it; otherwise use the next sibling if (nsnull != prevSibling) { @@ -4460,41 +4386,6 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, nsIFrame* parentFrame; childFrame->GetParent(&parentFrame); rv = parentFrame->RemoveFrame(*aPresContext, *shell, nsnull, childFrame); - -#ifdef INCLUDE_XUL - // Need to (for XUL only) do a special check for the treeitem tag - PRInt32 nameSpaceID; - if (aContainer && - NS_SUCCEEDED(aContainer->GetNameSpaceID(nameSpaceID)) && - nameSpaceID == nsXULAtoms::nameSpaceID) { - // See if we're the treeitem tag. This tag is treated differently, - // since the children of the content node are actually SIBLING frames. - // We've only removed the parent frame. Now we have to remove all of - // its children. - nsCOMPtr tag; - aContainer->GetTag(*getter_AddRefs(tag)); - nsString tagName; - tag->ToString(tagName); - if (tagName == "treeitem") - { - // Calling content removed on each of our content node children - // should do the trick. - PRInt32 count = 0; - aContainer->ChildCount(count); - for (PRInt32 i = 0; i < count; i++) - { - nsCOMPtr childContent; - aContainer->ChildAt(i, *getter_AddRefs(childContent)); - if (childContent) - { - // Call ContentRemoved. - ContentRemoved(aPresContext, aContainer, - childContent, i); - } - } - } - } -#endif // INCLUDE_XUL } } diff --git a/mozilla/layout/xul/base/src/nsTreeCellFrame.cpp b/mozilla/layout/xul/base/src/nsTreeCellFrame.cpp index 81888fae4b7..6dd019d5840 100644 --- a/mozilla/layout/xul/base/src/nsTreeCellFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTreeCellFrame.cpp @@ -96,13 +96,13 @@ nsTreeCellFrame::Init(nsIPresContext& aPresContext, // Determine if we're a column header or not. // Get row group frame - nsIFrame* pRowGroupFrame = nsnull; - aParent->GetParent(&pRowGroupFrame); - if (pRowGroupFrame != nsnull) + nsIFrame* rowGroupFrame = nsnull; + aParent->GetParent(&rowGroupFrame); + if (rowGroupFrame != nsnull) { // Get the display type of the row group frame and see if it's a header or body nsCOMPtr parentContext; - pRowGroupFrame->GetStyleContext(getter_AddRefs(parentContext)); + rowGroupFrame->GetStyleContext(getter_AddRefs(parentContext)); if (parentContext) { const nsStyleDisplay* display = (const nsStyleDisplay*) @@ -114,7 +114,12 @@ nsTreeCellFrame::Init(nsIPresContext& aPresContext, else mIsHeader = PR_FALSE; // Get the table frame. - pRowGroupFrame->GetParent((nsIFrame**) &mTreeFrame); + nsTableFrame* tableFrame = nsnull; + nsresult rv = nsTableFrame::GetTableFrame(rowGroupFrame, tableFrame); + if (NS_FAILED(rv) || (nsnull == tableFrame)) { + return rv; + } + mTreeFrame = (nsTreeFrame*)tableFrame; } } @@ -235,27 +240,30 @@ nsTreeCellFrame::HandleDoubleClickEvent(nsIPresContext& aPresContext, { // Perform an expand/collapse // Iterate up the chain to the row and then to the item. - nsCOMPtr pTreeItemContent; - mContent->GetParent(*getter_AddRefs(pTreeItemContent)); - nsCOMPtr pTreeItem( do_QueryInterface(pTreeItemContent) ); - NS_ASSERTION(pTreeItem, "not a DOM element"); - if (! pTreeItem) + nsCOMPtr treeItemContent; + nsCOMPtr treeRowContent; + mContent->GetParent(*getter_AddRefs(treeRowContent)); + treeRowContent->GetParent(*getter_AddRefs(treeItemContent)); + + nsCOMPtr treeItem( do_QueryInterface(treeItemContent) ); + NS_ASSERTION(treeItem, "not a DOM element"); + if (! treeItem) return NS_ERROR_UNEXPECTED; // Take the tree item content and toggle the value of its open attribute. nsAutoString attrValue; - nsresult result = pTreeItem->GetAttribute("open", attrValue); + nsresult result = treeItem->GetAttribute("open", attrValue); attrValue.ToLowerCase(); PRBool isExpanded = (attrValue=="true"); if (isExpanded) { // We're collapsing and need to remove frames from the flow. - pTreeItem->RemoveAttribute("open"); + treeItem->RemoveAttribute("open"); } else { // We're expanding and need to add frames to the flow. - pTreeItem->SetAttribute("open", "true"); + treeItem->SetAttribute("open", "true"); } } return NS_OK; @@ -265,74 +273,55 @@ nsTreeCellFrame::HandleDoubleClickEvent(nsIPresContext& aPresContext, void nsTreeCellFrame::Select(nsIPresContext& aPresContext, PRBool isSelected, PRBool notifyForReflow) { nsCOMPtr kSelectedCellAtom(dont_AddRef(NS_NewAtom("selectedcell"))); + nsCOMPtr kSelectedRowAtom(dont_AddRef(NS_NewAtom("selectedrow"))); nsCOMPtr kSelectedAtom(dont_AddRef(NS_NewAtom("selected"))); - nsIContent* pParentContent = nsnull; - mContent->GetParent(pParentContent); + nsCOMPtr rowContent; + nsCOMPtr itemContent; + mContent->GetParent(*getter_AddRefs(rowContent)); + rowContent->GetParent(*getter_AddRefs(itemContent)); if (isSelected) { // We're selecting the node. mContent->SetAttribute(kNameSpaceID_None, kSelectedCellAtom, "true", notifyForReflow); - if(pParentContent) { - pParentContent->SetAttribute(kNameSpaceID_None, kSelectedAtom, "true", notifyForReflow); - } + rowContent->SetAttribute(kNameSpaceID_None, kSelectedRowAtom, "true", notifyForReflow); + itemContent->SetAttribute(kNameSpaceID_None, kSelectedAtom, "true", notifyForReflow); } else { // We're deselecting the node. - mContent->UnsetAttribute(kNameSpaceID_None, kSelectedCellAtom, notifyForReflow); - if(pParentContent) { - pParentContent->UnsetAttribute(kNameSpaceID_None, kSelectedAtom, notifyForReflow); - } + mContent->UnsetAttribute(kNameSpaceID_None, kSelectedCellAtom, notifyForReflow); + rowContent->UnsetAttribute(kNameSpaceID_None, kSelectedRowAtom, notifyForReflow); + itemContent->UnsetAttribute(kNameSpaceID_None, kSelectedAtom, notifyForReflow); } - - NS_IF_RELEASE(pParentContent); } void nsTreeCellFrame::Hover(nsIPresContext& aPresContext, PRBool isHover, PRBool notifyForReflow) { - nsCOMPtr kHoverCellAtom(dont_AddRef(NS_NewAtom("hovercell"))); - nsCOMPtr kHoverAtom(dont_AddRef(NS_NewAtom("hover"))); + nsCOMPtr kHoverCellAtom(dont_AddRef(NS_NewAtom("Hovercell"))); + nsCOMPtr kHoverRowAtom(dont_AddRef(NS_NewAtom("Hoverrow"))); + nsCOMPtr kHoverAtom(dont_AddRef(NS_NewAtom("Hover"))); - nsIContent* pParentContent = nsnull; - mContent->GetParent(pParentContent); + nsCOMPtr rowContent; + nsCOMPtr itemContent; + mContent->GetParent(*getter_AddRefs(rowContent)); + rowContent->GetParent(*getter_AddRefs(itemContent)); if (isHover) { - // We're hovering over the node. + // We're selecting the node. mContent->SetAttribute(kNameSpaceID_None, kHoverCellAtom, "true", notifyForReflow); - if(pParentContent) { - pParentContent->SetAttribute(kNameSpaceID_None, kHoverAtom, "true", notifyForReflow); - } + rowContent->SetAttribute(kNameSpaceID_None, kHoverRowAtom, "true", notifyForReflow); + itemContent->SetAttribute(kNameSpaceID_None, kHoverAtom, "true", notifyForReflow); } else { // We're deselecting the node. - mContent->UnsetAttribute(kNameSpaceID_None, kHoverCellAtom, notifyForReflow); - if(pParentContent) { - pParentContent->UnsetAttribute(kNameSpaceID_None, kHoverAtom, notifyForReflow); - } - } - - NS_IF_RELEASE(pParentContent); -} - -// XXX This method will go away. I think it can -// actually go away now... ? -NS_IMETHODIMP -nsTreeCellFrame::AttributeChanged(nsIPresContext* aPresContext, - nsIContent* aChild, - nsIAtom* aAttribute, - PRInt32 aHint) -{ - // redraw - nsRect frameRect; - GetRect(frameRect); - nsRect rect(0, 0, frameRect.width, frameRect.height); - Invalidate(rect, PR_TRUE); - - return NS_OK; + mContent->UnsetAttribute(kNameSpaceID_None, kHoverCellAtom, notifyForReflow); + rowContent->UnsetAttribute(kNameSpaceID_None, kHoverRowAtom, notifyForReflow); + itemContent->UnsetAttribute(kNameSpaceID_None, kHoverAtom, notifyForReflow); + } } NS_IMETHODIMP diff --git a/mozilla/layout/xul/base/src/nsTreeCellFrame.h b/mozilla/layout/xul/base/src/nsTreeCellFrame.h index 2eec3e2f7f8..3b6117b8a40 100644 --- a/mozilla/layout/xul/base/src/nsTreeCellFrame.h +++ b/mozilla/layout/xul/base/src/nsTreeCellFrame.h @@ -46,12 +46,6 @@ public: NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext); - NS_IMETHOD - AttributeChanged(nsIPresContext* aPresContext, - nsIContent* aChild, - nsIAtom* aAttribute, - PRInt32 aHint); - void Select(nsIPresContext& presContext, PRBool isSelected, PRBool notifyForReflow = PR_TRUE); void Hover(nsIPresContext& presContext, PRBool isHover, PRBool notifyForReflow = PR_TRUE); diff --git a/mozilla/layout/xul/base/src/nsTreeIndentationFrame.cpp b/mozilla/layout/xul/base/src/nsTreeIndentationFrame.cpp index 3f37f47e43a..f9050ff6aab 100644 --- a/mozilla/layout/xul/base/src/nsTreeIndentationFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTreeIndentationFrame.cpp @@ -77,7 +77,7 @@ nsTreeIndentationFrame::Reflow(nsIPresContext& aPresContext, { nscoord level = 0; - // First climb out to the tree row level. + // First climb out to the tree item level. nsIFrame* aFrame = this; nsCOMPtr pContent; aFrame->GetContent(getter_AddRefs(pContent)); @@ -96,7 +96,7 @@ nsTreeIndentationFrame::Reflow(nsIPresContext& aPresContext, // We now have a tree row content node. Start counting our level of nesting. nsCOMPtr pParentContent; - while (pTag.get() != nsXULAtoms::treebody && pTag.get() != nsXULAtoms::treehead) + while (pTag.get() != nsXULAtoms::tree && pTag.get() != nsXULAtoms::treehead) { pContent->GetParent(*getter_AddRefs(pParentContent)); @@ -106,7 +106,8 @@ nsTreeIndentationFrame::Reflow(nsIPresContext& aPresContext, ++level; } - level = (level-1)/2; + level = (level/2) - 1; + if (level < 0) level = 0; width = level*16; // Hardcode an indentation of 16 pixels for now. TODO: Make this a parameter or something } diff --git a/mozilla/layout/xul/content/src/nsXULAtoms.cpp b/mozilla/layout/xul/content/src/nsXULAtoms.cpp index 68c30d84aea..beaa4a0c0a1 100644 --- a/mozilla/layout/xul/content/src/nsXULAtoms.cpp +++ b/mozilla/layout/xul/content/src/nsXULAtoms.cpp @@ -40,7 +40,7 @@ nsIAtom* nsXULAtoms::toolbox; nsIAtom* nsXULAtoms::tree; nsIAtom* nsXULAtoms::treecaption; nsIAtom* nsXULAtoms::treehead; -nsIAtom* nsXULAtoms::treebody; +nsIAtom* nsXULAtoms::treerow; nsIAtom* nsXULAtoms::treeitem; nsIAtom* nsXULAtoms::treecell; nsIAtom* nsXULAtoms::treechildren; @@ -105,7 +105,7 @@ void nsXULAtoms::AddrefAtoms() { tree = NS_NewAtom("tree"); treecaption = NS_NewAtom("treecaption"); treehead = NS_NewAtom("treehead"); - treebody = NS_NewAtom("treebody"); + treerow = NS_NewAtom("treerow"); treecell = NS_NewAtom("treecell"); treeitem = NS_NewAtom("treeitem"); treechildren = NS_NewAtom("treechildren"); @@ -161,7 +161,7 @@ void nsXULAtoms::ReleaseAtoms() { NS_RELEASE(tree); NS_RELEASE(treecaption); NS_RELEASE(treehead); - NS_RELEASE(treebody); + NS_RELEASE(treerow); NS_RELEASE(treecell); NS_RELEASE(treeitem); NS_RELEASE(treechildren); diff --git a/mozilla/layout/xul/content/src/nsXULAtoms.h b/mozilla/layout/xul/content/src/nsXULAtoms.h index 05aad215d41..bc7230df3da 100644 --- a/mozilla/layout/xul/content/src/nsXULAtoms.h +++ b/mozilla/layout/xul/content/src/nsXULAtoms.h @@ -58,7 +58,7 @@ public: static nsIAtom* tree; // The start of a tree view static nsIAtom* treecaption; // The caption of a tree view static nsIAtom* treehead; // The header of the tree view - static nsIAtom* treebody; // The body of the tree view + static nsIAtom* treerow; // A row in the tree view static nsIAtom* treeitem; // An item in the tree view static nsIAtom* treecell; // A cell in the tree view static nsIAtom* treechildren; // The children of an item in the tree viw