From caf60434405f007c08a5533550dbc1d7cbc59bfc Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Fri, 30 Sep 2005 22:58:37 +0000 Subject: [PATCH] Bug 307158. Account for scrollbars reducing the padding-edge when calculating the geometry of absolutely-positioned children of scrolled elements. r+sr=dbaron --- layout/generic/nsBlockFrame.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 00f5444e821b..16da4d44d768 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -75,6 +75,7 @@ #include "nsLayoutErrors.h" #include "nsAutoPtr.h" #include "nsIServiceManager.h" +#include "nsIScrollableFrame.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #endif @@ -610,13 +611,23 @@ CalculateContainingBlockSizeForAbsolutes(const nsHTMLReflowState& aReflowState, // heck did it end up wrapping this block frame? NS_ASSERTION(aLastRS->frame->GetStyleDisplay()->IsBlockLevel(), "Wrapping frame should be block-level"); + // Scrollbars need to be specifically excluded, if present, because they are outside the + // padding-edge. We need better APIs for getting the various boxes from a frame. + nsIScrollableFrame* scrollFrame; + CallQueryInterface(aLastRS->frame, &scrollFrame); + nsMargin scrollbars(0,0,0,0); + if (scrollFrame) { + scrollbars = scrollFrame->GetActualScrollbarSizes(); + } // We found a reflow state for the outermost wrapping frame, so use // its computed metrics if available if (aLastRS->mComputedWidth != NS_UNCONSTRAINEDSIZE) { - cbSize.width = aLastRS->mComputedWidth + aLastRS->mComputedPadding.LeftRight(); + cbSize.width = PR_MAX(0, + aLastRS->mComputedWidth + aLastRS->mComputedPadding.LeftRight() - scrollbars.LeftRight()); } if (aLastRS->mComputedHeight != NS_UNCONSTRAINEDSIZE) { - cbSize.height = aLastRS->mComputedHeight + aLastRS->mComputedPadding.TopBottom(); + cbSize.height = PR_MAX(0, + aLastRS->mComputedHeight + aLastRS->mComputedPadding.TopBottom() - scrollbars.TopBottom()); } } }