From c5c7fc45e17f43b07bd2241f964c915dcb267141 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Thu, 10 Jun 1999 05:53:01 +0000 Subject: [PATCH] Using DOM calls for setting/removing selection and hover attributes. --- layout/xul/base/src/nsTreeCellFrame.cpp | 52 +++++++++++-------------- layout/xul/base/src/nsTreeFrame.cpp | 3 ++ 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/layout/xul/base/src/nsTreeCellFrame.cpp b/layout/xul/base/src/nsTreeCellFrame.cpp index 81888fae4b78..aa429cf72d57 100644 --- a/layout/xul/base/src/nsTreeCellFrame.cpp +++ b/layout/xul/base/src/nsTreeCellFrame.cpp @@ -264,58 +264,50 @@ nsTreeCellFrame::HandleDoubleClickEvent(nsIPresContext& aPresContext, void nsTreeCellFrame::Select(nsIPresContext& aPresContext, PRBool isSelected, PRBool notifyForReflow) { - nsCOMPtr kSelectedCellAtom(dont_AddRef(NS_NewAtom("selectedcell"))); - nsCOMPtr kSelectedAtom(dont_AddRef(NS_NewAtom("selected"))); + nsCOMPtr parentContent; + nsCOMPtr element; + nsCOMPtr parentElement; - nsIContent* pParentContent = nsnull; - mContent->GetParent(pParentContent); + mContent->GetParent(*getter_AddRefs(parentContent)); + element = do_QueryInterface(mContent); + parentElement = do_QueryInterface(parentContent); if (isSelected) { // We're selecting the node. - mContent->SetAttribute(kNameSpaceID_None, kSelectedCellAtom, "true", notifyForReflow); - if(pParentContent) { - pParentContent->SetAttribute(kNameSpaceID_None, kSelectedAtom, "true", notifyForReflow); - } + element->SetAttribute("selectedcell", "true"); + parentElement->SetAttribute("selected", "true"); } else { // We're deselecting the node. - mContent->UnsetAttribute(kNameSpaceID_None, kSelectedCellAtom, notifyForReflow); - if(pParentContent) { - pParentContent->UnsetAttribute(kNameSpaceID_None, kSelectedAtom, notifyForReflow); - } + element->RemoveAttribute("selectedcell"); + parentElement->RemoveAttribute("selected"); } - - 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 parentContent; + nsCOMPtr element; + nsCOMPtr parentElement; - nsIContent* pParentContent = nsnull; - mContent->GetParent(pParentContent); + mContent->GetParent(*getter_AddRefs(parentContent)); + element = do_QueryInterface(mContent); + parentElement = do_QueryInterface(parentContent); if (isHover) { - // We're hovering over the node. - mContent->SetAttribute(kNameSpaceID_None, kHoverCellAtom, "true", notifyForReflow); - if(pParentContent) { - pParentContent->SetAttribute(kNameSpaceID_None, kHoverAtom, "true", notifyForReflow); - } + // We're selecting the node. + element->SetAttribute("hovercell", "true"); + parentElement->SetAttribute("hover", "true"); } else { // We're deselecting the node. - mContent->UnsetAttribute(kNameSpaceID_None, kHoverCellAtom, notifyForReflow); - if(pParentContent) { - pParentContent->UnsetAttribute(kNameSpaceID_None, kHoverAtom, notifyForReflow); - } - } - - NS_IF_RELEASE(pParentContent); + element->RemoveAttribute("hovercell"); + parentElement->RemoveAttribute("hover"); + } } // XXX This method will go away. I think it can diff --git a/layout/xul/base/src/nsTreeFrame.cpp b/layout/xul/base/src/nsTreeFrame.cpp index ada1d692723e..1a26373a6660 100644 --- a/layout/xul/base/src/nsTreeFrame.cpp +++ b/layout/xul/base/src/nsTreeFrame.cpp @@ -261,6 +261,9 @@ void nsTreeFrame::FireChangeHandler(nsIPresContext& aPresContext) event.message = NS_FORM_CHANGE; if (nsnull != mContent) { + + // Set up the target by doing a PreHandleEvent + mContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status); } }