From 229c0bea7cfa55bd126cbc5394048c92292dc615 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 25 Nov 2009 00:35:55 -0500 Subject: [PATCH] Bug 528134. Hand out the style context with the rulenode. r=dbaron --- layout/inspector/src/inDOMUtils.cpp | 9 +++++++-- layout/inspector/src/inDOMUtils.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/layout/inspector/src/inDOMUtils.cpp b/layout/inspector/src/inDOMUtils.cpp index bee6f8226b8a..abfcbd1b50a0 100644 --- a/layout/inspector/src/inDOMUtils.cpp +++ b/layout/inspector/src/inDOMUtils.cpp @@ -164,7 +164,8 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement, nsRuleNode* ruleNode = nsnull; nsCOMPtr content = do_QueryInterface(aElement); - GetRuleNodeForContent(content, &ruleNode); + nsRefPtr styleContext; + GetRuleNodeForContent(content, getter_AddRefs(styleContext), &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. @@ -271,9 +272,12 @@ inDOMUtils::GetContentState(nsIDOMElement *aElement, PRInt32* aState) } /* static */ nsresult -inDOMUtils::GetRuleNodeForContent(nsIContent* aContent, nsRuleNode** aRuleNode) +inDOMUtils::GetRuleNodeForContent(nsIContent* aContent, + nsStyleContext** aStyleContext, + nsRuleNode** aRuleNode) { *aRuleNode = nsnull; + *aStyleContext = nsnull; nsIDocument* doc = aContent->GetDocument(); NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED); @@ -284,5 +288,6 @@ inDOMUtils::GetRuleNodeForContent(nsIContent* aContent, nsRuleNode** aRuleNode) nsRefPtr sContext = nsComputedDOMStyle::GetStyleContextForContent(aContent, nsnull, presShell); *aRuleNode = sContext->GetRuleNode(); + sContext.forget(aStyleContext); return NS_OK; } diff --git a/layout/inspector/src/inDOMUtils.h b/layout/inspector/src/inDOMUtils.h index de108337c728..27d77949d924 100644 --- a/layout/inspector/src/inDOMUtils.h +++ b/layout/inspector/src/inDOMUtils.h @@ -44,6 +44,7 @@ #include "nsISupportsArray.h" class nsRuleNode; +class nsStyleContext; class inDOMUtils : public inIDOMUtils { @@ -55,7 +56,9 @@ public: virtual ~inDOMUtils(); private: + // aStyleContext must be released by the caller once he's done with aRuleNode. static nsresult GetRuleNodeForContent(nsIContent* aContent, + nsStyleContext** aStyleContext, nsRuleNode** aRuleNode); };