diff --git a/layout/xul/base/src/nsTreeCellFrame.cpp b/layout/xul/base/src/nsTreeCellFrame.cpp index 703d66e2c29a..81888fae4b78 100644 --- a/layout/xul/base/src/nsTreeCellFrame.cpp +++ b/layout/xul/base/src/nsTreeCellFrame.cpp @@ -338,6 +338,6 @@ nsTreeCellFrame::AttributeChanged(nsIPresContext* aPresContext, NS_IMETHODIMP nsTreeCellFrame::DeleteFrame(nsIPresContext& aPresContext) { - mTreeFrame->RemoveFromSelection(this); + mTreeFrame->RemoveFromSelection(aPresContext, this); return nsTableCellFrame::DeleteFrame(aPresContext); } diff --git a/layout/xul/base/src/nsTreeFrame.cpp b/layout/xul/base/src/nsTreeFrame.cpp index c19caf3200c9..c9a490a035ce 100644 --- a/layout/xul/base/src/nsTreeFrame.cpp +++ b/layout/xul/base/src/nsTreeFrame.cpp @@ -19,6 +19,7 @@ #include "nsTreeFrame.h" #include "nsIStyleContext.h" +#include "nsIContent.h" #include "nsCSSRendering.h" #include "nsTreeCellFrame.h" #include "nsCellMap.h" @@ -59,6 +60,8 @@ void nsTreeFrame::SetSelection(nsIPresContext& aPresContext, nsTreeCellFrame* pF ClearSelection(aPresContext); mSelectedItems.AppendElement(pFrame); pFrame->Select(aPresContext, PR_TRUE); + + FireChangeHandler(aPresContext); } void nsTreeFrame::ToggleSelection(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame) @@ -105,6 +108,8 @@ void nsTreeFrame::ToggleSelection(nsIPresContext& aPresContext, nsTreeCellFrame* mSelectedItems.RemoveElementAt(inArray); pFrame->Select(aPresContext, PR_FALSE); } + + FireChangeHandler(aPresContext); } void nsTreeFrame::RangedSelection(nsIPresContext& aPresContext, nsTreeCellFrame* pEndFrame) @@ -145,6 +150,8 @@ void nsTreeFrame::RangedSelection(nsIPresContext& aPresContext, nsTreeCellFrame* mSelectedItems.AppendElement(pTreeCell); pTreeCell->Select(aPresContext, PR_TRUE); } + + FireChangeHandler(aPresContext); } void nsTreeFrame::ClearSelection(nsIPresContext& aPresContext) @@ -161,7 +168,7 @@ void nsTreeFrame::ClearSelection(nsIPresContext& aPresContext) } void -nsTreeFrame::RemoveFromSelection(nsTreeCellFrame* frame) +nsTreeFrame::RemoveFromSelection(nsIPresContext& aPresContext, nsTreeCellFrame* frame) { PRInt32 count = mSelectedItems.Count(); for (PRInt32 i = 0; i < count; i++) @@ -173,6 +180,8 @@ nsTreeFrame::RemoveFromSelection(nsTreeCellFrame* frame) break; } } + + FireChangeHandler(aPresContext); } void nsTreeFrame::MoveUp(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame) @@ -240,4 +249,19 @@ void nsTreeFrame::MoveToRowCol(nsIPresContext& aPresContext, PRInt32 row, PRInt3 // We now have the cell that should be selected. nsTreeCellFrame* pTreeCell = NS_STATIC_CAST(nsTreeCellFrame*, cellFrame); SetSelection(aPresContext, pTreeCell); + + FireChangeHandler(aPresContext); } + +void nsTreeFrame::FireChangeHandler(nsIPresContext& aPresContext) +{ + nsEventStatus status = nsEventStatus_eIgnore; + nsEvent event; + event.eventStructType = NS_EVENT; + + event.message = NS_FORM_CHANGE; + if (nsnull != mContent) { + mContent->HandleDOMEvent(aPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, status); + } +} + diff --git a/layout/xul/base/src/nsTreeFrame.h b/layout/xul/base/src/nsTreeFrame.h index 3eb9b362bccc..1dac8c5b6678 100644 --- a/layout/xul/base/src/nsTreeFrame.h +++ b/layout/xul/base/src/nsTreeFrame.h @@ -31,17 +31,16 @@ public: void ClearSelection(nsIPresContext& presContext); void ToggleSelection(nsIPresContext& presContext, nsTreeCellFrame* pFrame); void RangedSelection(nsIPresContext& aPresContext, nsTreeCellFrame* pEndFrame); - void RemoveFromSelection(nsTreeCellFrame* frame); + void RemoveFromSelection(nsIPresContext& aPresContext, nsTreeCellFrame* frame); void MoveUp(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame); void MoveDown(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame); void MoveLeft(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame); void MoveRight(nsIPresContext& aPresContext, nsTreeCellFrame* pFrame); -// using nsTableFrame::MoveTo; // don't hide inherited::Move void MoveToRowCol(nsIPresContext& aPresContext, PRInt32 row, PRInt32 col, nsTreeCellFrame* pFrame); - // NOTE: CWPro4 still reports a warning about hiding inherited virtual functions. - // Compiler bug, ignore it. - + + void FireChangeHandler(nsIPresContext& aPresContext); + protected: nsTreeFrame(); virtual ~nsTreeFrame();