Bug 982141 - Calculate frame metrics for a display port calculation. r=kats,tn

--HG--
extra : rebase_source : bbb27a00dfc190c9c78563b149ca10aa6bfb41d5
This commit is contained in:
Botond Ballo 2014-03-19 13:15:54 -04:00
Родитель 43b071d67b
Коммит 77d4189994
1 изменённых файлов: 46 добавлений и 0 удалений

Просмотреть файл

@ -2408,6 +2408,52 @@ nsLayoutUtils::GetFramesForArea(nsIFrame* aFrame, const nsRect& aRect,
return NS_OK;
}
// This function is only used on B2G, and some compilers complain about
// unused static functions, so we need to #ifdef it.
#ifdef MOZ_WIDGET_GONK
// aScrollFrame and aScrollFrameAsScrollable must be non-nullptr
static FrameMetrics
CalculateFrameMetricsForDisplayPort(nsIFrame* aScrollFrame,
nsIScrollableFrame* aScrollFrameAsScrollable) {
// Calculate the metrics necessary for calculating the displayport.
// This code has a lot in common with the code in RecordFrameMetrics();
// we may want to refactor this at some point.
FrameMetrics metrics;
nsPresContext* presContext = aScrollFrame->PresContext();
nsIPresShell* presShell = presContext->PresShell();
CSSToLayoutDeviceScale deviceScale(float(nsPresContext::AppUnitsPerCSSPixel())
/ presContext->AppUnitsPerDevPixel());
ParentLayerToLayerScale resolution(presShell->GetResolution().width);
LayoutDeviceToLayerScale cumulativeResolution(presShell->GetCumulativeResolution().width);
metrics.mDevPixelsPerCSSPixel = deviceScale;
metrics.mResolution = resolution;
metrics.mCumulativeResolution = cumulativeResolution;
metrics.SetZoom(deviceScale * cumulativeResolution * LayerToScreenScale(1));
// Only the size of the composition bounds is relevant to the
// displayport calculation, not its origin.
nsSize compositionSize = nsLayoutUtils::CalculateCompositionSizeForFrame(aScrollFrame);
metrics.mCompositionBounds
= RoundedToInt(LayoutDeviceRect::FromAppUnits(nsRect(nsPoint(0, 0), compositionSize),
presContext->AppUnitsPerDevPixel())
* (cumulativeResolution / resolution));
// This function is used for setting a display port for subframes, so
// aScrollFrame will not be the root content document's root scroll frame.
metrics.SetRootCompositionSize(
nsLayoutUtils::CalculateRootCompositionSize(aScrollFrame, false, metrics));
metrics.SetScrollOffset(CSSPoint::FromAppUnits(
aScrollFrameAsScrollable->GetScrollPosition()));
metrics.mScrollableRect = CSSRect::FromAppUnits(
nsLayoutUtils::CalculateScrollableRectForFrame(aScrollFrameAsScrollable, nullptr));
return metrics;
}
#endif
nsresult
nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFrame,
const nsRegion& aDirtyRegion, nscolor aBackstop,