mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Minor cleanup of the fix for bug 122557. r=dbaron, sr=jst.
This commit is contained in:
parent
8e44c55296
commit
5a0969e2e5
@ -79,9 +79,8 @@ public:
|
||||
NS_IMETHOD AdjustRectForMargins(nsIFrame* aFrame, nsRect& aRect) = 0;
|
||||
|
||||
// Hooks to methods that need layout atoms (static vars in layout)
|
||||
NS_IMETHOD GetStyleContextForContent(nsIPresShell* aPresShell,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext** aStyleContext) = 0;
|
||||
NS_IMETHOD GetStyleContextForFrame(nsIFrame* aFrame,
|
||||
nsIStyleContext** aStyleContext) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIInspectorCSSUtils_h___ */
|
||||
|
@ -113,31 +113,32 @@ nsInspectorCSSUtils::AdjustRectForMargins(nsIFrame* aFrame, nsRect& aRect)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInspectorCSSUtils::GetStyleContextForContent(nsIPresShell* aPresShell,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext** aStyleContext)
|
||||
nsInspectorCSSUtils::GetStyleContextForFrame(nsIFrame* aFrame,
|
||||
nsIStyleContext** aStyleContext)
|
||||
{
|
||||
NS_PRECONDITION(aPresShell, "Null pres shell");
|
||||
NS_PRECONDITION(aFrame, "We'd better have a frame!");
|
||||
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
aFrame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
if (!styleContext) {
|
||||
// Caller returns rv on through, and this does not seem
|
||||
// exception-worthy.
|
||||
*aStyleContext = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFrame* frame = nsnull;
|
||||
nsresult rv = aPresShell->GetPrimaryFrameFor(aContent, &frame);
|
||||
if (NS_FAILED(rv) || !frame) return rv;
|
||||
|
||||
/* For tables the primary frame is the "outer frame" but the style
|
||||
* rules are applied to the "inner frame". Luckily, the "outer
|
||||
* frame" actually inherits style from the "inner frame" so we can
|
||||
* just move one level up in the style hierarchy....
|
||||
* just move one level up in the style context hierarchy....
|
||||
*/
|
||||
nsCOMPtr<nsIAtom> frameType;
|
||||
frame->GetFrameType(getter_AddRefs(frameType));
|
||||
aFrame->GetFrameType(getter_AddRefs(frameType));
|
||||
if (frameType == nsLayoutAtoms::tableOuterFrame) {
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
rv = aPresShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (! presContext)
|
||||
return rv;
|
||||
PRBool isChild;
|
||||
rv = frame->GetParentStyleContextFrame(presContext, &frame, &isChild);
|
||||
if (NS_FAILED(rv) || !frame) return rv;
|
||||
*aStyleContext = styleContext->GetParent();
|
||||
} else {
|
||||
*aStyleContext = styleContext;
|
||||
NS_ADDREF(*aStyleContext);
|
||||
}
|
||||
return aPresShell->GetStyleContextFor(frame, aStyleContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -57,9 +57,8 @@ public:
|
||||
NS_IMETHOD GetRuleNodeRule(nsRuleNode *aNode, nsIStyleRule **aRule);
|
||||
NS_IMETHOD IsRuleNodeRoot(nsRuleNode *aNode, PRBool *aIsRoot);
|
||||
NS_IMETHOD AdjustRectForMargins(nsIFrame* aFrame, nsRect& aRect);
|
||||
NS_IMETHOD GetStyleContextForContent(nsIPresShell* aPresShell,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext** aStyleContext);
|
||||
NS_IMETHOD GetStyleContextForFrame(nsIFrame* aFrame,
|
||||
nsIStyleContext** aStyleContext);
|
||||
};
|
||||
|
||||
#endif /* nsInspectorCSSUtils_h___ */
|
||||
|
@ -76,6 +76,8 @@ NS_IMPL_ISUPPORTS1(inDOMUtils, inIDOMUtils);
|
||||
NS_IMETHODIMP
|
||||
inDOMUtils::GetStyleRules(nsIDOMElement *aElement, nsISupportsArray **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> rules;
|
||||
NS_NewISupportsArray(getter_AddRefs(rules));
|
||||
if (!rules) return NS_OK;
|
||||
@ -88,8 +90,13 @@ inDOMUtils::GetStyleRules(nsIDOMElement *aElement, nsISupportsArray **_retval)
|
||||
content = do_QueryInterface(aElement);
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
|
||||
nsresult rv = mCSSUtils->GetStyleContextForContent(shell, content,
|
||||
getter_AddRefs(styleContext));
|
||||
nsIFrame* frame;
|
||||
shell->GetPrimaryFrameFor(content, &frame);
|
||||
if (!frame)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = mCSSUtils->GetStyleContextForFrame(frame,
|
||||
getter_AddRefs(styleContext));
|
||||
|
||||
if (NS_FAILED(rv) || !styleContext) return rv;
|
||||
|
||||
|
@ -79,9 +79,8 @@ public:
|
||||
NS_IMETHOD AdjustRectForMargins(nsIFrame* aFrame, nsRect& aRect) = 0;
|
||||
|
||||
// Hooks to methods that need layout atoms (static vars in layout)
|
||||
NS_IMETHOD GetStyleContextForContent(nsIPresShell* aPresShell,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext** aStyleContext) = 0;
|
||||
NS_IMETHOD GetStyleContextForFrame(nsIFrame* aFrame,
|
||||
nsIStyleContext** aStyleContext) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIInspectorCSSUtils_h___ */
|
||||
|
@ -113,31 +113,32 @@ nsInspectorCSSUtils::AdjustRectForMargins(nsIFrame* aFrame, nsRect& aRect)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInspectorCSSUtils::GetStyleContextForContent(nsIPresShell* aPresShell,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext** aStyleContext)
|
||||
nsInspectorCSSUtils::GetStyleContextForFrame(nsIFrame* aFrame,
|
||||
nsIStyleContext** aStyleContext)
|
||||
{
|
||||
NS_PRECONDITION(aPresShell, "Null pres shell");
|
||||
NS_PRECONDITION(aFrame, "We'd better have a frame!");
|
||||
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
aFrame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
if (!styleContext) {
|
||||
// Caller returns rv on through, and this does not seem
|
||||
// exception-worthy.
|
||||
*aStyleContext = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFrame* frame = nsnull;
|
||||
nsresult rv = aPresShell->GetPrimaryFrameFor(aContent, &frame);
|
||||
if (NS_FAILED(rv) || !frame) return rv;
|
||||
|
||||
/* For tables the primary frame is the "outer frame" but the style
|
||||
* rules are applied to the "inner frame". Luckily, the "outer
|
||||
* frame" actually inherits style from the "inner frame" so we can
|
||||
* just move one level up in the style hierarchy....
|
||||
* just move one level up in the style context hierarchy....
|
||||
*/
|
||||
nsCOMPtr<nsIAtom> frameType;
|
||||
frame->GetFrameType(getter_AddRefs(frameType));
|
||||
aFrame->GetFrameType(getter_AddRefs(frameType));
|
||||
if (frameType == nsLayoutAtoms::tableOuterFrame) {
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
rv = aPresShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (! presContext)
|
||||
return rv;
|
||||
PRBool isChild;
|
||||
rv = frame->GetParentStyleContextFrame(presContext, &frame, &isChild);
|
||||
if (NS_FAILED(rv) || !frame) return rv;
|
||||
*aStyleContext = styleContext->GetParent();
|
||||
} else {
|
||||
*aStyleContext = styleContext;
|
||||
NS_ADDREF(*aStyleContext);
|
||||
}
|
||||
return aPresShell->GetStyleContextFor(frame, aStyleContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -57,9 +57,8 @@ public:
|
||||
NS_IMETHOD GetRuleNodeRule(nsRuleNode *aNode, nsIStyleRule **aRule);
|
||||
NS_IMETHOD IsRuleNodeRoot(nsRuleNode *aNode, PRBool *aIsRoot);
|
||||
NS_IMETHOD AdjustRectForMargins(nsIFrame* aFrame, nsRect& aRect);
|
||||
NS_IMETHOD GetStyleContextForContent(nsIPresShell* aPresShell,
|
||||
nsIContent* aContent,
|
||||
nsIStyleContext** aStyleContext);
|
||||
NS_IMETHOD GetStyleContextForFrame(nsIFrame* aFrame,
|
||||
nsIStyleContext** aStyleContext);
|
||||
};
|
||||
|
||||
#endif /* nsInspectorCSSUtils_h___ */
|
||||
|
Loading…
Reference in New Issue
Block a user