mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 923251 - Part f: Pass an Element to inDOMUtils::GetRuleNodeForContent and rename it to reflect that; r=heycam
This commit is contained in:
parent
35a65686e8
commit
893c7a0744
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user