Bug 923251 - Part f: Pass an Element to inDOMUtils::GetRuleNodeForContent and rename it to reflect that; r=heycam

This commit is contained in:
Ms2ger 2013-11-11 09:00:41 +01:00
parent 35a65686e8
commit 893c7a0744
2 changed files with 16 additions and 13 deletions

View File

@ -203,12 +203,12 @@ inDOMUtils::GetCSSStyleRules(nsIDOMElement *aElement,
}
nsRuleNode* ruleNode = nullptr;
nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
NS_ENSURE_STATE(content);
nsCOMPtr<Element> element = do_QueryInterface(aElement);
NS_ENSURE_STATE(element);
nsRefPtr<nsStyleContext> styleContext;
GetRuleNodeForContent(content, pseudoElt, getter_AddRefs(styleContext), &ruleNode);
GetRuleNodeForElement(element, pseudoElt, getter_AddRefs(styleContext), &ruleNode);
if (!ruleNode) {
// This can fail for content nodes that are not in the document or
// This can fail for elements that are not in the document or
// if the document they're in doesn't have a presshell. Bail out.
return NS_OK;
}
@ -699,19 +699,17 @@ inDOMUtils::GetContentState(nsIDOMElement *aElement, nsEventStates::InternalType
}
/* static */ nsresult
inDOMUtils::GetRuleNodeForContent(nsIContent* aContent,
inDOMUtils::GetRuleNodeForElement(dom::Element* aElement,
nsIAtom* aPseudo,
nsStyleContext** aStyleContext,
nsRuleNode** aRuleNode)
{
MOZ_ASSERT(aElement);
*aRuleNode = nullptr;
*aStyleContext = nullptr;
if (!aContent->IsElement()) {
return NS_ERROR_UNEXPECTED;
}
nsIDocument* doc = aContent->GetDocument();
nsIDocument* doc = aElement->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
nsIPresShell *presShell = doc->GetShell();
@ -723,7 +721,7 @@ inDOMUtils::GetRuleNodeForContent(nsIContent* aContent,
presContext->EnsureSafeToHandOutCSSRules();
nsRefPtr<nsStyleContext> sContext =
nsComputedDOMStyle::GetStyleContextForElement(aContent->AsElement(), aPseudo, presShell);
nsComputedDOMStyle::GetStyleContextForElement(aElement, aPseudo, presShell);
if (sContext) {
*aRuleNode = sContext->RuleNode();
sContext.forget(aStyleContext);

View File

@ -10,7 +10,12 @@
class nsRuleNode;
class nsStyleContext;
class nsIAtom;
class nsIContent;
namespace mozilla {
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
class inDOMUtils : public inIDOMUtils
{
@ -23,7 +28,7 @@ public:
private:
// aStyleContext must be released by the caller once he's done with aRuleNode.
static nsresult GetRuleNodeForContent(nsIContent* aContent,
static nsresult GetRuleNodeForElement(mozilla::dom::Element* aElement,
nsIAtom* aPseudo,
nsStyleContext** aStyleContext,
nsRuleNode** aRuleNode);