From e6e615f9f5cb6184f41e8edb988d67cc25e54526 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 16 Dec 2009 02:10:50 +0000 Subject: [PATCH] Bug 528134. Hand out the style context with the rulenode. r=dbaron, a=dveditz git-svn-id: svn://10.0.0.236/trunk@259235 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/inspector/src/inDOMUtils.cpp | 4 +++- mozilla/layout/inspector/src/inDOMUtils.h | 2 +- mozilla/layout/style/nsIInspectorCSSUtils.h | 21 +++++++++++++++++++- mozilla/layout/style/nsInspectorCSSUtils.cpp | 14 ++++++++++++- mozilla/layout/style/nsInspectorCSSUtils.h | 7 ++++++- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/mozilla/layout/inspector/src/inDOMUtils.cpp b/mozilla/layout/inspector/src/inDOMUtils.cpp index 74e2815157b..e39e38f2996 100644 --- a/mozilla/layout/inspector/src/inDOMUtils.cpp +++ b/mozilla/layout/inspector/src/inDOMUtils.cpp @@ -157,7 +157,9 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement, nsRuleNode* ruleNode = nsnull; nsCOMPtr content = do_QueryInterface(aElement); - mCSSUtils->GetRuleNodeForContent(content, &ruleNode); + nsRefPtr styleContext; + mCSSUtils->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. diff --git a/mozilla/layout/inspector/src/inDOMUtils.h b/mozilla/layout/inspector/src/inDOMUtils.h index fd73e3347c5..3c3b78a23da 100644 --- a/mozilla/layout/inspector/src/inDOMUtils.h +++ b/mozilla/layout/inspector/src/inDOMUtils.h @@ -54,7 +54,7 @@ public: virtual ~inDOMUtils(); protected: - nsCOMPtr mCSSUtils; + nsCOMPtr mCSSUtils; }; diff --git a/mozilla/layout/style/nsIInspectorCSSUtils.h b/mozilla/layout/style/nsIInspectorCSSUtils.h index a0302f1783a..8f13a7330a7 100644 --- a/mozilla/layout/style/nsIInspectorCSSUtils.h +++ b/mozilla/layout/style/nsIInspectorCSSUtils.h @@ -51,6 +51,7 @@ struct nsRect; class nsIContent; class nsIDOMElement; class nsIArray; +class nsStyleContext; // 35dfc2a6-b069-4014-ad4b-01927e77d828 #define NS_IINSPECTORCSSUTILS_IID \ @@ -77,7 +78,8 @@ public: NS_IMETHOD GetRuleNodeRule(nsRuleNode *aNode, nsIStyleRule **aRule) = 0; NS_IMETHOD IsRuleNodeRoot(nsRuleNode *aNode, PRBool *aIsRoot) = 0; - // Hooks to methods that need nsStyleContext + // Hooks to methods that need nsStyleContext. Don't call this. + // Use nsIInspectorCSSUtils_MOZILLA_1_9_BRANCH instead. NS_IMETHOD GetRuleNodeForContent(nsIContent* aContent, nsRuleNode** aParent) = 0; @@ -87,4 +89,21 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(nsIInspectorCSSUtils, NS_IINSPECTORCSSUTILS_IID) + +#define NS_IINSPECTORCSSUTILS_MOZILLA_1_9_BRANCH_IID \ +{ 0x0a03de47, 0x0b6d, 0x4cdb, \ + { 0xaa, 0xe3, 0xf4, 0x7f, 0x16, 0x1e, 0x54, 0x2a } } + +class nsIInspectorCSSUtils_MOZILLA_1_9_BRANCH : public nsIInspectorCSSUtils { +public: + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IINSPECTORCSSUTILS_MOZILLA_1_9_BRANCH_IID) + + NS_IMETHOD GetRuleNodeForContent(nsIContent* aContent, + nsStyleContext** aStyleContext, + nsRuleNode** aRuleNode) = 0; +}; + +NS_DEFINE_STATIC_IID_ACCESSOR(nsIInspectorCSSUtils_MOZILLA_1_9_BRANCH, + NS_IINSPECTORCSSUTILS_MOZILLA_1_9_BRANCH_IID) + #endif /* nsIInspectorCSSUtils_h___ */ diff --git a/mozilla/layout/style/nsInspectorCSSUtils.cpp b/mozilla/layout/style/nsInspectorCSSUtils.cpp index 0e38d7f8d38..ed496c23035 100644 --- a/mozilla/layout/style/nsInspectorCSSUtils.cpp +++ b/mozilla/layout/style/nsInspectorCSSUtils.cpp @@ -65,7 +65,8 @@ nsInspectorCSSUtils::~nsInspectorCSSUtils() nsCSSProps::ReleaseTable(); } -NS_IMPL_ISUPPORTS1(nsInspectorCSSUtils, nsIInspectorCSSUtils) +NS_IMPL_ISUPPORTS2(nsInspectorCSSUtils, nsIInspectorCSSUtils, + nsIInspectorCSSUtils_MOZILLA_1_9_BRANCH) NS_IMETHODIMP nsInspectorCSSUtils::LookupCSSProperty(const nsAString& aName, nsCSSProperty *aProp) @@ -161,6 +162,16 @@ nsInspectorCSSUtils::GetStyleContextForContent(nsIContent* aContent, NS_IMETHODIMP nsInspectorCSSUtils::GetRuleNodeForContent(nsIContent* aContent, nsRuleNode** aRuleNode) +{ + nsRefPtr styleContext; + return GetRuleNodeForContent(aContent, getter_AddRefs(styleContext), + aRuleNode); +} + +NS_IMETHODIMP +nsInspectorCSSUtils::GetRuleNodeForContent(nsIContent* aContent, + nsStyleContext** aStyleContext, + nsRuleNode** aRuleNode) { *aRuleNode = nsnull; @@ -173,6 +184,7 @@ nsInspectorCSSUtils::GetRuleNodeForContent(nsIContent* aContent, nsRefPtr sContext = GetStyleContextForContent(aContent, nsnull, presShell); *aRuleNode = sContext->GetRuleNode(); + sContext.forget(aStyleContext); return NS_OK; } diff --git a/mozilla/layout/style/nsInspectorCSSUtils.h b/mozilla/layout/style/nsInspectorCSSUtils.h index 37258bcd01a..9be7b25835d 100644 --- a/mozilla/layout/style/nsInspectorCSSUtils.h +++ b/mozilla/layout/style/nsInspectorCSSUtils.h @@ -48,7 +48,7 @@ class nsIPresShell; -class nsInspectorCSSUtils : public nsIInspectorCSSUtils { +class nsInspectorCSSUtils : public nsIInspectorCSSUtils_MOZILLA_1_9_BRANCH { public: @@ -70,6 +70,11 @@ public: GetStyleContextForContent(nsIContent* aContent, nsIAtom* aPseudo, nsIPresShell* aPresShell); + // nsIInspectorCSSUtils_MOZILLA_1_9_BRANCH + NS_IMETHOD GetRuleNodeForContent(nsIContent* aContent, + nsStyleContext** aStyleContext, + nsRuleNode** aRuleNode); + private: static nsStyleContext* GetStyleContextForFrame(nsIFrame* aFrame); };