mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 531371. Correctly propagate the backround from a <body style="display: table"> to the viewport as needed. r=bzbarsky
This commit is contained in:
parent
92426ad0f4
commit
0ee624eeb2
@ -1132,9 +1132,7 @@ nsIFrame*
|
||||
nsGenericElement::GetStyledFrame()
|
||||
{
|
||||
nsIFrame *frame = GetPrimaryFrame(Flush_Layout);
|
||||
|
||||
return (frame && frame->GetType() == nsGkAtoms::tableOuterFrame) ?
|
||||
frame->GetFirstChild(nsnull) : frame;
|
||||
return frame ? nsLayoutUtils::GetStyleFrame(frame) : nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -962,7 +962,7 @@ nsCSSRendering::IsCanvasFrame(nsIFrame* aFrame)
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
nsCSSRendering::FindRootFrame(nsIFrame* aForFrame)
|
||||
nsCSSRendering::FindBackgroundStyleFrame(nsIFrame* aForFrame)
|
||||
{
|
||||
const nsStyleBackground* result = aForFrame->GetStyleBackground();
|
||||
|
||||
@ -990,7 +990,7 @@ nsCSSRendering::FindRootFrame(nsIFrame* aForFrame)
|
||||
nsIFrame *bodyFrame = aForFrame->PresContext()->GetPresShell()->
|
||||
GetPrimaryFrameFor(bodyContent);
|
||||
if (bodyFrame) {
|
||||
return bodyFrame;
|
||||
return nsLayoutUtils::GetStyleFrame(bodyFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1030,7 +1030,7 @@ nsCSSRendering::FindRootFrame(nsIFrame* aForFrame)
|
||||
const nsStyleBackground*
|
||||
nsCSSRendering::FindRootFrameBackground(nsIFrame* aForFrame)
|
||||
{
|
||||
return FindRootFrame(aForFrame)->GetStyleBackground();
|
||||
return FindBackgroundStyleFrame(aForFrame)->GetStyleBackground();
|
||||
}
|
||||
|
||||
inline PRBool
|
||||
|
@ -138,9 +138,13 @@ struct nsCSSRendering {
|
||||
const nsRect& aFillArea);
|
||||
|
||||
/**
|
||||
* Gets the root frame for the frame
|
||||
* Find the frame whose background style should be used to draw the
|
||||
* canvas background. aForFrame must be the frame for the root element
|
||||
* whose background style should be used. This function will return
|
||||
* aForFrame unless the <body> background should be propagated, in
|
||||
* which case we return the frame associated with the <body>'s background.
|
||||
*/
|
||||
static nsIFrame* FindRootFrame(nsIFrame* aForFrame);
|
||||
static nsIFrame* FindBackgroundStyleFrame(nsIFrame* aForFrame);
|
||||
|
||||
/**
|
||||
* @return PR_TRUE if |aFrame| is a canvas frame, in the CSS sense.
|
||||
|
@ -227,6 +227,19 @@ nsLayoutUtils::GetClosestFrameOfType(nsIFrame* aFrame, nsIAtom* aFrameType)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// static
|
||||
nsIFrame*
|
||||
nsLayoutUtils::GetStyleFrame(nsIFrame* aFrame)
|
||||
{
|
||||
if (aFrame->GetType() == nsGkAtoms::tableOuterFrame) {
|
||||
nsIFrame* inner = aFrame->GetFirstChild(nsnull);
|
||||
NS_ASSERTION(inner, "Outer table must have an inner");
|
||||
return inner;
|
||||
}
|
||||
|
||||
return aFrame;
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
nsLayoutUtils::GetFloatFromPlaceholder(nsIFrame* aFrame) {
|
||||
NS_ASSERTION(nsGkAtoms::placeholderFrame == aFrame->GetType(),
|
||||
@ -2790,7 +2803,7 @@ nsLayoutUtils::GetGraphicsFilterForFrame(nsIFrame* aForFrame)
|
||||
{
|
||||
#ifdef MOZ_SVG
|
||||
nsIFrame *frame = nsCSSRendering::IsCanvasFrame(aForFrame) ?
|
||||
nsCSSRendering::FindRootFrame(aForFrame) : aForFrame;
|
||||
nsCSSRendering::FindBackgroundStyleFrame(aForFrame) : aForFrame;
|
||||
|
||||
switch (frame->GetStyleSVG()->mImageRendering) {
|
||||
case NS_STYLE_IMAGE_RENDERING_OPTIMIZESPEED:
|
||||
|
@ -121,6 +121,14 @@ public:
|
||||
return GetClosestFrameOfType(aFrame, nsGkAtoms::pageFrame);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a frame which is the primary frame for an element,
|
||||
* return the frame that has the non-psuedoelement style context for
|
||||
* the content.
|
||||
* This is aPrimaryFrame itself except for tableOuter frames.
|
||||
*/
|
||||
static nsIFrame* GetStyleFrame(nsIFrame* aPrimaryFrame);
|
||||
|
||||
/**
|
||||
* IsGeneratedContentFor returns PR_TRUE if aFrame is the outermost
|
||||
* frame for generated content of type aPseudoElement for aContent.
|
||||
|
3
layout/reftests/bugs/531371-1-ref.html
Normal file
3
layout/reftests/bugs/531371-1-ref.html
Normal file
@ -0,0 +1,3 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html style="display:table; background:lime;">
|
||||
</html>
|
5
layout/reftests/bugs/531371-1.html
Normal file
5
layout/reftests/bugs/531371-1.html
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body style="display:table; background:lime;">
|
||||
</body>
|
||||
</html>
|
@ -1347,4 +1347,5 @@ fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") == 488692-1.html 488692-1-ref.html # needs
|
||||
== 528038-1e.html 528038-1-ref.html
|
||||
== 528038-1f.html 528038-1-ref.html
|
||||
== 528038-2.html 528038-2-ref.html
|
||||
== 531371-1.html 531371-1-ref.html
|
||||
== 530686-1.html 530686-1-ref.html
|
||||
|
@ -317,22 +317,6 @@ nsComputedDOMStyle::GetPropertyValue(const nsAString& aPropertyName,
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsStyleContext*
|
||||
GetStyleContextForFrame(nsIFrame* aFrame)
|
||||
{
|
||||
nsStyleContext* styleContext = aFrame->GetStyleContext();
|
||||
|
||||
/* 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 context hierarchy....
|
||||
*/
|
||||
if (aFrame->GetType() == nsGkAtoms::tableOuterFrame)
|
||||
return styleContext->GetParent();
|
||||
|
||||
return styleContext;
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsStyleContext>
|
||||
nsComputedDOMStyle::GetStyleContextForContent(nsIContent* aContent,
|
||||
@ -373,7 +357,8 @@ nsComputedDOMStyle::GetStyleContextForContentNoFlush(nsIContent* aContent,
|
||||
if (!aPseudo) {
|
||||
nsIFrame* frame = aPresShell->GetPrimaryFrameFor(aContent);
|
||||
if (frame) {
|
||||
nsStyleContext* result = GetStyleContextForFrame(frame);
|
||||
nsStyleContext* result =
|
||||
nsLayoutUtils::GetStyleFrame(frame)->GetStyleContext();
|
||||
// Don't use the style context if it was influenced by
|
||||
// pseudo-elements, since then it's not the primary style
|
||||
// for this element.
|
||||
|
Loading…
Reference in New Issue
Block a user