Bug 1363922 - Part 2: Estimate scale of frames based on their PresShell resolution. r=mstange

MozReview-Commit-ID: 8f6T3PiPkF8
This commit is contained in:
Bas Schouten 2017-08-17 15:45:31 +02:00
Родитель fe49d64a98
Коммит 9207223d59
3 изменённых файлов: 7 добавлений и 52 удалений

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

@ -2762,7 +2762,8 @@ ScrollFrameHelper::ScrollToImpl(nsPoint aPt, const nsRect& aRange, nsIAtom* aOri
nscoord appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
// 'scale' is our estimate of the scale factor that will be applied
// when rendering the scrolled content to its own PaintedLayer.
gfxSize scale = FrameLayerBuilder::GetPaintedLayerScaleForFrame(mScrolledFrame);
float presShellResolution = mScrolledFrame->PresContext()->PresShell()->GetResolution();
gfxSize scale(presShellResolution, presShellResolution);
nsPoint curPos = GetScrollPosition();
nsPoint alignWithPos = mScrollPosForLayerPixelAlignment == nsPoint(-1,-1)
? curPos : mScrollPosForLayerPixelAlignment;
@ -5879,9 +5880,12 @@ ScrollFrameHelper::GetScrolledRect() const
}
// Now, snap the bottom right corner of both of these rects.
// We snap to layer pixels, so we need to respect the layer's scale.
// We ignore the CSS transforms here because we don't have a cheap way of accessing layer resolution of
// the layer that this frame is going to be painted to. Using the presShell resolution is good enough
// for most situations and simpler.
nscoord appUnitsPerDevPixel = mScrolledFrame->PresContext()->AppUnitsPerDevPixel();
gfxSize scale = FrameLayerBuilder::GetPaintedLayerScaleForFrame(mScrolledFrame);
float presShellResolution = mScrolledFrame->PresContext()->PresShell()->GetResolution();
gfxSize scale(presShellResolution, presShellResolution);
if (scale.IsEmpty()) {
scale = gfxSize(1.0f, 1.0f);
}

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

@ -5875,46 +5875,6 @@ PredictScaleForContent(nsIFrame* aFrame, nsIFrame* aAncestorWithScale,
return gfxSize(1.0, 1.0);
}
gfxSize
FrameLayerBuilder::GetPaintedLayerScaleForFrame(nsIFrame* aFrame)
{
MOZ_ASSERT(aFrame, "need a frame");
nsIFrame* last = nullptr;
for (nsIFrame* f = aFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
last = f;
if (nsLayoutUtils::IsPopup(f)) {
// Don't examine ancestors of a popup. It won't make sense to check
// the transform from some content inside the popup to some content
// which is an ancestor of the popup.
break;
}
const SmallPointerArray<DisplayItemData>& array = aFrame->DisplayItemData();
for (uint32_t i = 0; i < array.Length(); i++) {
Layer* layer = DisplayItemData::AssertDisplayItemData(array.ElementAt(i))->mLayer;
ContainerLayer* container = layer->AsContainerLayer();
if (!container ||
!layer->Manager()->IsWidgetLayerManager()) {
continue;
}
for (Layer* l = container->GetFirstChild(); l; l = l->GetNextSibling()) {
PaintedDisplayItemLayerUserData* data =
static_cast<PaintedDisplayItemLayerUserData*>
(l->GetUserData(&gPaintedDisplayItemLayerUserData));
if (data) {
return PredictScaleForContent(aFrame, f, gfxSize(data->mXScale, data->mYScale));
}
}
}
}
float presShellResolution = last->PresContext()->PresShell()->GetResolution();
return PredictScaleForContent(aFrame, last,
gfxSize(presShellResolution, presShellResolution));
}
#ifdef MOZ_DUMP_PAINTING
static void DebugPaintItem(DrawTarget& aDrawTarget,
nsPresContext* aPresContext,

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

@ -568,15 +568,6 @@ public:
*/
nsIntPoint GetLastPaintOffset(PaintedLayer* aLayer);
/**
* Return the resolution at which we expect to render aFrame's contents,
* assuming they are being painted to retained layers. This takes into account
* the resolution the contents of the ContainerLayer containing aFrame are
* being rendered at, as well as any currently-inactive transforms between
* aFrame and that container layer.
*/
static gfxSize GetPaintedLayerScaleForFrame(nsIFrame* aFrame);
/**
* Stores a Layer as the dedicated layer in the DisplayItemData for a given frame/key pair.
*