Bug 480345. Handle painting of background images on pages which have no in-flow content. r+sr=dbaron
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -1720,17 +1720,17 @@ PaintBackgroundLayer(nsPresContext* aPre
nsSize imageSize;
imageSize.width = nsPresContext::CSSPixelsToAppUnits(imageIntSize.width);
imageSize.height = nsPresContext::CSSPixelsToAppUnits(imageIntSize.height);
req = nsnull;
// relative to aBorderArea
- nsRect bgOriginRect;
+ nsRect bgOriginRect(0, 0, 0, 0);
nsIAtom* frameType = aForFrame->GetType();
nsIFrame* geometryFrame = aForFrame;
if (frameType == nsGkAtoms::inlineFrame ||
frameType == nsGkAtoms::positionedInlineFrame) {
switch (aBackground.mBackgroundInlinePolicy) {
case NS_STYLE_BG_INLINE_POLICY_EACH_BOX:
bgOriginRect = nsRect(nsPoint(0,0), aBorderArea.Size());
@@ -1742,28 +1742,30 @@ PaintBackgroundLayer(nsPresContext* aPre
NS_ERROR("Unknown background-inline-policy value! "
"Please, teach me what to do.");
case NS_STYLE_BG_INLINE_POLICY_CONTINUOUS:
bgOriginRect = gInlineBGData->GetContinuousRect(aForFrame);
break;
}
} else if (frameType == nsGkAtoms::canvasFrame) {
geometryFrame = aForFrame->GetFirstChild(nsnull);
- NS_ASSERTION(geometryFrame, "A canvas with a background "
- "image had no child frame, which is impossible according to CSS. "
- "Make sure there isn't a background image specified on the "
- "|:viewport| pseudo-element in |html.css|.");
- bgOriginRect = geometryFrame->GetRect();
+ // geometryFrame might be null if this canvas is a page created
+ // as an overflow container (e.g. the in-flow content has already
+ // finished and this page only displays the continuations of
+ // absolutely positioned content).
+ if (geometryFrame) {
+ bgOriginRect = geometryFrame->GetRect();
+ }
} else {
bgOriginRect = nsRect(nsPoint(0,0), aBorderArea.Size());
}
// Background images are tiled over the 'background-clip' area
// but the origin of the tiling is based on the 'background-origin' area
- if (aLayer.mOrigin != NS_STYLE_BG_ORIGIN_BORDER) {
+ if (aLayer.mOrigin != NS_STYLE_BG_ORIGIN_BORDER && geometryFrame) {
nsMargin border = geometryFrame->GetUsedBorder();
geometryFrame->ApplySkipSides(border);
bgOriginRect.Deflate(border);
if (aLayer.mOrigin != NS_STYLE_BG_ORIGIN_PADDING) {
nsMargin padding = geometryFrame->GetUsedPadding();
geometryFrame->ApplySkipSides(padding);
bgOriginRect.Deflate(padding);
NS_ASSERTION(aLayer.mOrigin == NS_STYLE_BG_ORIGIN_CONTENT,
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -222,18 +222,16 @@ nsPresContext::nsPresContext(nsIDocument
mFocusTextColor = mDefaultColor;
mFocusBackgroundColor = mBackgroundColor;
mFocusRingWidth = 1;
if (aType == eContext_Galley) {
mMedium = nsGkAtoms::screen;
} else {
- SetBackgroundImageDraw(PR_FALSE);
- SetBackgroundColorDraw(PR_FALSE);
mMedium = nsGkAtoms::print;
mPaginated = PR_TRUE;
}
if (!IsDynamic()) {
mImageAnimationMode = imgIContainer::kDontAnimMode;
mNeverAnimate = PR_TRUE;
} else {
new file mode 100644
--- /dev/null
+++ b/layout/generic/crashtests/480345-1.html
@@ -0,0 +1,5 @@
+<!DOCTYPE HTML>
+<html class="reftest-print">
+<body style="background:url(solidblue.png); position:absolute; height:40in;">
+</body>
+</html>
--- a/layout/generic/crashtests/crashtests.list
+++ b/layout/generic/crashtests/crashtests.list
@@ -197,8 +197,9 @@ load 455171-3.html
load 457375.html
load 463741-1.html
load 465651-1.html
load 467487-1.html
load 468207-1.html
load 472776-1.html
load 472950-1.html
load 477928.html
+load 480345-1.html
new file mode 100644
index 0000000000000000000000000000000000000000..a64b6a4255c9f99fd7bb87449a6d798a3c7f039d
GIT binary patch
literal 135
zc%17D@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6-MC9V-A
z!TD(=<%vb93;~Imc_n&&t|1C##(D;ZGV4@afoh~YT^vI!PA8`btowi7fiXeGG~r4^
dAah$cBg3=Pl8P(8`~sQG;OXk;vd$@?2>@O)C0qai