Don't crash if we're asked for the style rules for a node in a document with no

presentation at all.  Bug 240767, r=caillon, sr=bryner.
This commit is contained in:
bzbarsky%mit.edu 2006-05-17 02:38:34 +00:00
Родитель ccc522d8b0
Коммит e466ed9cea
1 изменённых файлов: 9 добавлений и 4 удалений

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

@ -158,13 +158,18 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
*_retval = nsnull;
nsCOMPtr<nsISupportsArray> rules;
NS_NewISupportsArray(getter_AddRefs(rules));
if (!rules) return NS_ERROR_OUT_OF_MEMORY;
nsRuleNode* ruleNode = nsnull;
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
mCSSUtils->GetRuleNodeForContent(content, &ruleNode);
if (!ruleNode) {
// This can fail for content nodes that are not in the document or
// if the document they're in doesn't have a presshell. Bail out.
return NS_OK;
}
nsCOMPtr<nsISupportsArray> rules;
NS_NewISupportsArray(getter_AddRefs(rules));
if (!rules) return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIStyleRule> srule;
nsCOMPtr<nsICSSStyleRule> cssRule;