From 1ab4c2fd23ca8a2f95d1ea6fcae60857ea3a6db9 Mon Sep 17 00:00:00 2001 From: "varga%nixcorp.com" Date: Fri, 14 May 2004 13:58:00 +0000 Subject: [PATCH] Fix for bug 243203. Crash removing address line in message compose window [@ nsCSSFrameConstructor::AttributeChanged] r=neil, sr=bryner git-svn-id: svn://10.0.0.236/trunk@156410 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xul/base/src/tree/src/nsTreeColFrame.cpp | 63 ++++++++----------- .../xul/base/src/tree/src/nsTreeColFrame.h | 28 ++++----- 2 files changed, 36 insertions(+), 55 deletions(-) diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp index 45bea2b65f8..1b22adc1252 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.cpp @@ -47,7 +47,8 @@ #include "nsIDocument.h" #include "nsIBoxObject.h" #include "nsIDOMElement.h" -#include "nsITreeColumns.h" +#include "nsITreeBoxObject.h" +#include "nsIDOMXULTreeElement.h" // // NS_NewTreeColFrame @@ -108,26 +109,17 @@ nsTreeColFrame::Init(nsIPresContext* aPresContext, nsIFrame* aPrevInFlow) { nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); - EnsureTree(); - if (mTree) { - nsCOMPtr cols; - mTree->GetColumns(getter_AddRefs(cols)); - if (cols) - cols->InvalidateColumns(); - } + EnsureColumns(); + if (mColumns) + mColumns->InvalidateColumns(); return rv; } NS_IMETHODIMP nsTreeColFrame::Destroy(nsIPresContext* aPresContext) { - EnsureTree(); - if (mTree) { - nsCOMPtr cols; - mTree->GetColumns(getter_AddRefs(cols)); - if (cols) - cols->InvalidateColumns(); - } + if (mColumns) + mColumns->InvalidateColumns(); return nsBoxFrame::Destroy(aPresContext); } @@ -137,10 +129,8 @@ nsTreeColFrame::GetFrameForPoint(nsIPresContext* aPresContext, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame) { - if (! ( mRect.Contains(aPoint) || ( mState & NS_FRAME_OUTSIDE_CHILDREN)) ) - { + if (!(mRect.Contains(aPoint) || (mState & NS_FRAME_OUTSIDE_CHILDREN))) return NS_ERROR_FAILURE; - } // If we are in either the first 2 pixels or the last 2 pixels, we're going to // do something really strange. Check for an adjacent splitter. @@ -201,39 +191,36 @@ nsTreeColFrame::AttributeChanged(nsIPresContext* aPresContext, aModType); if (aAttribute == nsHTMLAtoms::width || aAttribute == nsHTMLAtoms::hidden) { - // Invalidate the tree. - EnsureTree(); - if (mTree) - mTree->Invalidate(); + EnsureColumns(); + if (mColumns) { + nsCOMPtr tree; + mColumns->GetTree(getter_AddRefs(tree)); + if (tree) + tree->Invalidate(); + } } else if (aAttribute == nsXULAtoms::ordinal || aAttribute == nsXULAtoms::primary) { - EnsureTree(); - if (mTree) { - nsCOMPtr cols; - mTree->GetColumns(getter_AddRefs(cols)); - if (cols) - cols->InvalidateColumns(); - } + EnsureColumns(); + if (mColumns) + mColumns->InvalidateColumns(); } return rv; } void -nsTreeColFrame::EnsureTree() +nsTreeColFrame::EnsureColumns() { - if (!mTree && mContent) { + if (!mColumns) { // Get our parent node. nsIContent* parent = mContent->GetParent(); if (parent) { nsIContent* grandParent = parent->GetParent(); - nsCOMPtr nsDoc(do_QueryInterface(mContent->GetDocument())); - nsCOMPtr elt(do_QueryInterface(grandParent)); - - nsCOMPtr boxObject; - nsDoc->GetBoxObjectFor(elt, getter_AddRefs(boxObject)); - - mTree = do_QueryInterface(boxObject); + if (grandParent) { + nsCOMPtr treeElement = do_QueryInterface(grandParent); + if (treeElement) + treeElement->GetColumns(getter_AddRefs(mColumns)); + } } } } diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.h b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.h index d1703658953..1aa89f79846 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.h +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeColFrame.h @@ -37,26 +37,18 @@ * ***** END LICENSE BLOCK ***** */ #include "nsBoxFrame.h" -#include "nsITreeBoxObject.h" - -class nsSupportsHashtable; +#include "nsITreeColumns.h" nsresult NS_NewTreeColFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRBool aIsRoot = PR_FALSE, nsIBoxLayout* aLayoutManager = nsnull); -// The actual frame that paints the cells and rows. class nsTreeColFrame : public nsBoxFrame { public: NS_DECL_ISUPPORTS - friend nsresult NS_NewTreeColFrame(nsIPresShell* aPresShell, - nsIFrame** aNewFrame, - PRBool aIsRoot, - nsIBoxLayout* aLayoutManager); - NS_IMETHOD Init(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, @@ -64,9 +56,10 @@ public: nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsIPresContext* aPresContext); - + + // Overridden to capture events. NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext, - const nsPoint& aPoint, // Overridden to capture events + const nsPoint& aPoint, nsFramePaintLayer aWhichLayer, nsIFrame** aFrame); @@ -76,15 +69,16 @@ public: nsIAtom* aAttribute, PRInt32 aModType); + friend nsresult NS_NewTreeColFrame(nsIPresShell* aPresShell, + nsIFrame** aNewFrame, + PRBool aIsRoot, + nsIBoxLayout* aLayoutManager); protected: nsTreeColFrame(nsIPresShell* aPresShell, PRBool aIsRoot = nsnull, nsIBoxLayout* aLayoutManager = nsnull); virtual ~nsTreeColFrame(); -protected: - // Members. + void EnsureColumns(); - void EnsureTree(); - - nsCOMPtr mTree; -}; // class nsTreeColFrame + nsCOMPtr mColumns; +};