Position fixed backgrounds with respect to the viewport, not "nearest

scrollframe or viewport".  Bug 235768, r+sr=roc


git-svn-id: svn://10.0.0.236/trunk@153320 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2004-02-27 05:40:16 +00:00
parent 0e7b3c1f95
commit 3dddb6f9bc
2 changed files with 36 additions and 100 deletions

View File

@@ -2454,20 +2454,6 @@ ComputeBackgroundAnchorPoint(const nsStyleBackground& aColor,
aResult.y = y;
}
// Returns the nearest scroll frame ancestor
static nsIFrame*
GetNearestScrollFrame(nsIFrame* aFrame)
{
for (nsIFrame* f = aFrame; f; f = f->GetParent()) {
// Is it a scroll frame?
if (nsLayoutAtoms::scrollFrame == f->GetType()) {
return f;
}
}
return nsnull;
}
// Returns the root scrollable frame, which is the first child of the root
// frame.
static nsIScrollableFrame*
@@ -3011,48 +2997,30 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
nsPoint anchor;
if (NS_STYLE_BG_ATTACHMENT_FIXED == aColor.mBackgroundAttachment) {
// If it's a fixed background attachment, then the image is placed
// relative to the nearest scrolling ancestor, or the viewport if
// the frame doesn't have a scrolling ancestor
nsIFrame* scrolledFrame = nsnull;
// relative to the viewport
nsIView* viewportView = nsnull;
nsRect viewportArea;
// get the nsIScrollableFrame interface from the scrollFrame
nsIScrollableFrame* scrollableFrame;
nsIFrame* scrollFrame = GetNearestScrollFrame(aForFrame);
if (scrollFrame) {
CallQueryInterface(scrollFrame, &scrollableFrame);
if (scrollableFrame) {
scrollableFrame->GetScrolledFrame(aPresContext, scrolledFrame);
}
nsIFrame* rootFrame;
aPresContext->PresShell()->GetRootFrame(&rootFrame);
NS_ASSERTION(rootFrame, "no root frame");
PRBool isPaginated = PR_FALSE;
aPresContext->IsPaginated(&isPaginated);
if (isPaginated) {
nsIFrame* page = nsLayoutUtils::GetPageFrame(aForFrame);
NS_ASSERTION(page, "no page");
rootFrame = page;
}
if (scrolledFrame) {
viewportArea = scrolledFrame->GetRect();
viewportView = scrolledFrame->GetView();
}
else {
// The viewport isn't scrollable, so use the root frame's view
nsIFrame* rootFrame;
aPresContext->PresShell()->GetRootFrame(&rootFrame);
NS_ASSERTION(rootFrame, "no root frame");
viewportView = rootFrame->GetView();
NS_ASSERTION(viewportView, "no viewport view");
viewportArea = viewportView->GetBounds();
viewportArea.x = 0;
viewportArea.y = 0;
PRBool isPaginated = PR_FALSE;
aPresContext->IsPaginated(&isPaginated);
if (isPaginated) {
nsIFrame* page = nsLayoutUtils::GetPageFrame(aForFrame);
NS_ASSERTION(page, "no page");
rootFrame = page;
}
viewportView = rootFrame->GetView();
NS_ASSERTION(viewportView, "no viewport view");
viewportArea = viewportView->GetBounds();
viewportArea.x = 0;
viewportArea.y = 0;
scrollableFrame = GetRootScrollableFrame(aPresContext, rootFrame);
}
nsIScrollableFrame* scrollableFrame =
GetRootScrollableFrame(aPresContext, rootFrame);
if (scrollableFrame) {
nsMargin scrollbars = scrollableFrame->GetActualScrollbarSizes();

View File

@@ -2454,20 +2454,6 @@ ComputeBackgroundAnchorPoint(const nsStyleBackground& aColor,
aResult.y = y;
}
// Returns the nearest scroll frame ancestor
static nsIFrame*
GetNearestScrollFrame(nsIFrame* aFrame)
{
for (nsIFrame* f = aFrame; f; f = f->GetParent()) {
// Is it a scroll frame?
if (nsLayoutAtoms::scrollFrame == f->GetType()) {
return f;
}
}
return nsnull;
}
// Returns the root scrollable frame, which is the first child of the root
// frame.
static nsIScrollableFrame*
@@ -3011,48 +2997,30 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
nsPoint anchor;
if (NS_STYLE_BG_ATTACHMENT_FIXED == aColor.mBackgroundAttachment) {
// If it's a fixed background attachment, then the image is placed
// relative to the nearest scrolling ancestor, or the viewport if
// the frame doesn't have a scrolling ancestor
nsIFrame* scrolledFrame = nsnull;
// relative to the viewport
nsIView* viewportView = nsnull;
nsRect viewportArea;
// get the nsIScrollableFrame interface from the scrollFrame
nsIScrollableFrame* scrollableFrame;
nsIFrame* scrollFrame = GetNearestScrollFrame(aForFrame);
if (scrollFrame) {
CallQueryInterface(scrollFrame, &scrollableFrame);
if (scrollableFrame) {
scrollableFrame->GetScrolledFrame(aPresContext, scrolledFrame);
}
nsIFrame* rootFrame;
aPresContext->PresShell()->GetRootFrame(&rootFrame);
NS_ASSERTION(rootFrame, "no root frame");
PRBool isPaginated = PR_FALSE;
aPresContext->IsPaginated(&isPaginated);
if (isPaginated) {
nsIFrame* page = nsLayoutUtils::GetPageFrame(aForFrame);
NS_ASSERTION(page, "no page");
rootFrame = page;
}
if (scrolledFrame) {
viewportArea = scrolledFrame->GetRect();
viewportView = scrolledFrame->GetView();
}
else {
// The viewport isn't scrollable, so use the root frame's view
nsIFrame* rootFrame;
aPresContext->PresShell()->GetRootFrame(&rootFrame);
NS_ASSERTION(rootFrame, "no root frame");
viewportView = rootFrame->GetView();
NS_ASSERTION(viewportView, "no viewport view");
viewportArea = viewportView->GetBounds();
viewportArea.x = 0;
viewportArea.y = 0;
PRBool isPaginated = PR_FALSE;
aPresContext->IsPaginated(&isPaginated);
if (isPaginated) {
nsIFrame* page = nsLayoutUtils::GetPageFrame(aForFrame);
NS_ASSERTION(page, "no page");
rootFrame = page;
}
viewportView = rootFrame->GetView();
NS_ASSERTION(viewportView, "no viewport view");
viewportArea = viewportView->GetBounds();
viewportArea.x = 0;
viewportArea.y = 0;
scrollableFrame = GetRootScrollableFrame(aPresContext, rootFrame);
}
nsIScrollableFrame* scrollableFrame =
GetRootScrollableFrame(aPresContext, rootFrame);
if (scrollableFrame) {
nsMargin scrollbars = scrollableFrame->GetActualScrollbarSizes();