Fix for bug 243203. Crash removing address line in message compose window [@ nsCSSFrameConstructor::AttributeChanged] r=neil, sr=bryner

This commit is contained in:
varga%nixcorp.com 2004-05-14 13:58:00 +00:00
Родитель d3a014761e
Коммит b7408dd75e
2 изменённых файлов: 36 добавлений и 55 удалений

Просмотреть файл

@ -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<nsITreeColumns> 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<nsITreeColumns> 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<nsITreeBoxObject> tree;
mColumns->GetTree(getter_AddRefs(tree));
if (tree)
tree->Invalidate();
}
}
else if (aAttribute == nsXULAtoms::ordinal || aAttribute == nsXULAtoms::primary) {
EnsureTree();
if (mTree) {
nsCOMPtr<nsITreeColumns> 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<nsIDOMNSDocument> nsDoc(do_QueryInterface(mContent->GetDocument()));
nsCOMPtr<nsIDOMElement> elt(do_QueryInterface(grandParent));
nsCOMPtr<nsIBoxObject> boxObject;
nsDoc->GetBoxObjectFor(elt, getter_AddRefs(boxObject));
mTree = do_QueryInterface(boxObject);
if (grandParent) {
nsCOMPtr<nsIDOMXULTreeElement> treeElement = do_QueryInterface(grandParent);
if (treeElement)
treeElement->GetColumns(getter_AddRefs(mColumns));
}
}
}
}

Просмотреть файл

@ -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<nsITreeBoxObject> mTree;
}; // class nsTreeColFrame
nsCOMPtr<nsITreeColumns> mColumns;
};