Bug 914825 - Compute FrameMetrics::mCompositionBounds correctly for the root scroll frame. r=tn

This commit is contained in:
Botond Ballo 2013-09-10 17:47:14 -04:00
parent b03cdbbbf8
commit 9a202d2a4e

View File

@ -614,6 +614,15 @@ static void UnmarkFrameForDisplay(nsIFrame* aFrame) {
}
}
static void AdjustForScrollBars(ScreenIntRect& aToAdjust, nsIScrollableFrame* aScrollableFrame) {
if (aScrollableFrame && !LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars)) {
nsMargin sizes = aScrollableFrame->GetActualScrollbarSizes();
// Scrollbars are not subject to scaling, so CSS pixels = screen pixels for them.
ScreenIntMargin boundMargins = RoundedToInt(CSSMargin::FromAppUnits(sizes) * CSSToScreenScale(1.0f));
aToAdjust.Deflate(boundMargins);
}
}
static void RecordFrameMetrics(nsIFrame* aForFrame,
nsIFrame* aScrollFrame,
const nsIFrame* aReferenceFrame,
@ -712,12 +721,30 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
* metrics.mCumulativeResolution
* layerToScreenScale);
// For the root scroll frame of the root content document, clamp the
// composition bounds to the widget bounds. This is necessary because, if
// the page is zoomed in, the frame's size might be larger than the widget
// bounds, but we don't want the composition bounds to be.
bool useWidgetBounds = false;
bool isRootContentDocRootScrollFrame = aForFrame->GetParent() == nullptr
&& presContext->IsRootContentDocument();
if (isRootContentDocRootScrollFrame) {
if (nsIWidget* widget = aForFrame->GetNearestWidget()) {
nsIntRect bounds;
widget->GetBounds(bounds);
ScreenIntRect screenBounds = ScreenIntRect::FromUnknownRect(mozilla::gfx::IntRect(
bounds.x, bounds.y, bounds.width, bounds.height));
AdjustForScrollBars(screenBounds, scrollableFrame);
metrics.mCompositionBounds = screenBounds.ClampRect(metrics.mCompositionBounds);
useWidgetBounds = true;
}
}
// Adjust composition bounds for the size of scroll bars.
if (scrollableFrame && !LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars)) {
nsMargin sizes = scrollableFrame->GetActualScrollbarSizes();
// Scrollbars are not subject to scaling, so CSS pixels = screen pixels for them.
ScreenIntMargin boundMargins = RoundedToInt(CSSMargin::FromAppUnits(sizes) * CSSToScreenScale(1.0f));
metrics.mCompositionBounds.Deflate(boundMargins);
// If the widget bounds were used to clamp the composition bounds,
// this adjustment was already made to the widget bounds.
if (!useWidgetBounds) {
AdjustForScrollBars(metrics.mCompositionBounds, scrollableFrame);
}
metrics.mPresShellId = presShell->GetPresShellId();