From 902e7c0207db30b0c5d3b993070f3f84979508f7 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Wed, 27 Jan 1999 12:42:21 +0000 Subject: [PATCH] Making events for arbitrary HTML still work in tree cells. --- content/shared/public/nsXULAtoms.h | 1 + content/shared/src/nsXULAtoms.cpp | 3 +++ layout/xul/base/src/nsTreeCellFrame.cpp | 19 +++++++++++++------ layout/xul/base/src/nsTreeCellFrame.h | 5 +++-- layout/xul/content/src/nsXULAtoms.cpp | 3 +++ layout/xul/content/src/nsXULAtoms.h | 1 + 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/content/shared/public/nsXULAtoms.h b/content/shared/public/nsXULAtoms.h index 33e0247b3aad..c3b11084a1d4 100644 --- a/content/shared/public/nsXULAtoms.h +++ b/content/shared/public/nsXULAtoms.h @@ -59,6 +59,7 @@ public: static nsIAtom* treecell; // A cell in the tree view static nsIAtom* treechildren; // The children of an item in the tree viw static nsIAtom* treeindentation; // Specifies that the indentation for the level should occur here. + static nsIAtom* treeallowevents; // Lets events be handled on the cell contents. static nsIAtom* widget; static nsIAtom* window; diff --git a/content/shared/src/nsXULAtoms.cpp b/content/shared/src/nsXULAtoms.cpp index a3a773429e24..e0e50eaaf9b0 100644 --- a/content/shared/src/nsXULAtoms.cpp +++ b/content/shared/src/nsXULAtoms.cpp @@ -41,6 +41,7 @@ nsIAtom* nsXULAtoms::treerow; nsIAtom* nsXULAtoms::treecell; nsIAtom* nsXULAtoms::treechildren; nsIAtom* nsXULAtoms::treeindentation; +nsIAtom* nsXULAtoms::treeallowevents; nsIAtom* nsXULAtoms::widget; nsIAtom* nsXULAtoms::window; @@ -77,6 +78,7 @@ void nsXULAtoms::AddrefAtoms() { treeitem = NS_NewAtom("treeitem"); treechildren = NS_NewAtom("treechildren"); treeindentation = NS_NewAtom("treeindentation"); + treeallowevents = NS_NewAtom("treeallowevents"); widget = NS_NewAtom("widget"); window = NS_NewAtom("window"); @@ -104,6 +106,7 @@ void nsXULAtoms::ReleaseAtoms() { NS_RELEASE(treeitem); NS_RELEASE(treechildren); NS_RELEASE(treeindentation); + NS_RELEASE(treeallowevents); NS_RELEASE(widget); NS_RELEASE(window); diff --git a/layout/xul/base/src/nsTreeCellFrame.cpp b/layout/xul/base/src/nsTreeCellFrame.cpp index ce34add84cf9..ea476c3fb8df 100644 --- a/layout/xul/base/src/nsTreeCellFrame.cpp +++ b/layout/xul/base/src/nsTreeCellFrame.cpp @@ -65,9 +65,9 @@ static void ForceDrawFrame(nsIFrame * aFrame) // Creates a new tree cell frame // nsresult -NS_NewTreeCellFrame (nsIFrame*& aNewFrame) +NS_NewTreeCellFrame (nsIFrame*& aNewFrame, PRBool allowEvents) { - nsTreeCellFrame* theFrame = new nsTreeCellFrame; + nsTreeCellFrame* theFrame = new nsTreeCellFrame(allowEvents); if (theFrame == nsnull) return NS_ERROR_OUT_OF_MEMORY; @@ -78,8 +78,8 @@ NS_NewTreeCellFrame (nsIFrame*& aNewFrame) // Constructor -nsTreeCellFrame::nsTreeCellFrame() -:nsTableCellFrame() { mIsHeader = PR_FALSE; mBeenReflowed = PR_FALSE; } +nsTreeCellFrame::nsTreeCellFrame(PRBool allowEvents) +:nsTableCellFrame() { mAllowEvents = allowEvents; mIsHeader = PR_FALSE; mBeenReflowed = PR_FALSE; } // Destructor nsTreeCellFrame::~nsTreeCellFrame() @@ -165,8 +165,15 @@ NS_IMETHODIMP nsTreeCellFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame) { - *aFrame = this; // Capture all events so that we can perform selection and expand/collapse. - return NS_OK; + if (mAllowEvents) + { + return nsTableCellFrame::GetFrameForPoint(aPoint, aFrame); + } + else + { + *aFrame = this; // Capture all events so that we can perform selection and expand/collapse. + return NS_OK; + } } NS_IMETHODIMP diff --git a/layout/xul/base/src/nsTreeCellFrame.h b/layout/xul/base/src/nsTreeCellFrame.h index 825e94d5464f..8a647005cc54 100644 --- a/layout/xul/base/src/nsTreeCellFrame.h +++ b/layout/xul/base/src/nsTreeCellFrame.h @@ -24,7 +24,7 @@ class nsTreeFrame; class nsTreeCellFrame : public nsTableCellFrame { public: - friend nsresult NS_NewTreeCellFrame(nsIFrame*& aNewFrame); + friend nsresult NS_NewTreeCellFrame(nsIFrame*& aNewFrame, PRBool allowEvents); NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, // Overridden to capture events nsIFrame** aFrame); @@ -46,7 +46,7 @@ public: void Select(nsIPresContext& presContext, PRBool isSelected); protected: - nsTreeCellFrame(); + nsTreeCellFrame(PRBool allowEvents); virtual ~nsTreeCellFrame(); nsresult HandleMouseDownEvent(nsIPresContext& aPresContext, @@ -64,6 +64,7 @@ protected: nsIStyleContext* mSelectedContext; // The style context to use when the tree item is selected nsIStyleContext* mNormalContext; // The style context to use normally. nsTreeFrame* mTreeFrame; // Our parent tree frame. + PRBool mAllowEvents; // Whether we let events go through. PRBool mBeenReflowed; // Hack for now. }; // class nsTableCellFrame diff --git a/layout/xul/content/src/nsXULAtoms.cpp b/layout/xul/content/src/nsXULAtoms.cpp index a3a773429e24..e0e50eaaf9b0 100644 --- a/layout/xul/content/src/nsXULAtoms.cpp +++ b/layout/xul/content/src/nsXULAtoms.cpp @@ -41,6 +41,7 @@ nsIAtom* nsXULAtoms::treerow; nsIAtom* nsXULAtoms::treecell; nsIAtom* nsXULAtoms::treechildren; nsIAtom* nsXULAtoms::treeindentation; +nsIAtom* nsXULAtoms::treeallowevents; nsIAtom* nsXULAtoms::widget; nsIAtom* nsXULAtoms::window; @@ -77,6 +78,7 @@ void nsXULAtoms::AddrefAtoms() { treeitem = NS_NewAtom("treeitem"); treechildren = NS_NewAtom("treechildren"); treeindentation = NS_NewAtom("treeindentation"); + treeallowevents = NS_NewAtom("treeallowevents"); widget = NS_NewAtom("widget"); window = NS_NewAtom("window"); @@ -104,6 +106,7 @@ void nsXULAtoms::ReleaseAtoms() { NS_RELEASE(treeitem); NS_RELEASE(treechildren); NS_RELEASE(treeindentation); + NS_RELEASE(treeallowevents); NS_RELEASE(widget); NS_RELEASE(window); diff --git a/layout/xul/content/src/nsXULAtoms.h b/layout/xul/content/src/nsXULAtoms.h index 33e0247b3aad..c3b11084a1d4 100644 --- a/layout/xul/content/src/nsXULAtoms.h +++ b/layout/xul/content/src/nsXULAtoms.h @@ -59,6 +59,7 @@ public: static nsIAtom* treecell; // A cell in the tree view static nsIAtom* treechildren; // The children of an item in the tree viw static nsIAtom* treeindentation; // Specifies that the indentation for the level should occur here. + static nsIAtom* treeallowevents; // Lets events be handled on the cell contents. static nsIAtom* widget; static nsIAtom* window;