From ac62853b71e9b6ea2da7669448a0cf43f6df656b Mon Sep 17 00:00:00 2001 From: "shaver%mozilla.org" Date: Wed, 3 Oct 2001 02:48:00 +0000 Subject: [PATCH] Bug 101234: crash when calling focus() or blur() on not-yet-appended XUL Element. r=sicking(!), sr=blizzard git-svn-id: svn://10.0.0.236/trunk@104513 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/xul/content/src/nsXULElement.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 7967c6b7bb8..66a7c4cf1b5 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -22,7 +22,7 @@ * Pierre Phaneuf * Peter Annema * Brendan Eich - * + * Mike Shaver * * This Original Code has been modified by IBM Corporation. * Modifications made by IBM described herein are @@ -4890,6 +4890,10 @@ nsXULElement::IsAncestor(nsIDOMNode* aParentNode, nsIDOMNode* aChildNode) NS_IMETHODIMP nsXULElement::Focus() { + // What kind of crazy tries to focus an element without a doc? + if (!mDocument) + return NS_OK; + // Obtain a presentation context and then call SetFocus. PRInt32 count = mDocument->GetNumberOfShells(); if (count == 0) @@ -4909,6 +4913,10 @@ nsXULElement::Focus() NS_IMETHODIMP nsXULElement::Blur() { + // What kind of crazy tries to blur an element without a doc? + if (!mDocument) + return NS_OK; + // Obtain a presentation context and then call SetFocus. PRInt32 count = mDocument->GetNumberOfShells(); if (count == 0)