From 9207223d59e4af08d385dfd94306ec41b25619ee Mon Sep 17 00:00:00 2001 From: Bas Schouten Date: Thu, 17 Aug 2017 15:45:31 +0200 Subject: [PATCH] Bug 1363922 - Part 2: Estimate scale of frames based on their PresShell resolution. r=mstange MozReview-Commit-ID: 8f6T3PiPkF8 --- layout/generic/nsGfxScrollFrame.cpp | 10 +++++-- layout/painting/FrameLayerBuilder.cpp | 40 --------------------------- layout/painting/FrameLayerBuilder.h | 9 ------ 3 files changed, 7 insertions(+), 52 deletions(-) diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 80ddf51dbbd9..f49d517bfa58 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -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); } diff --git a/layout/painting/FrameLayerBuilder.cpp b/layout/painting/FrameLayerBuilder.cpp index 33b6a3c10e3e..36303c074693 100644 --- a/layout/painting/FrameLayerBuilder.cpp +++ b/layout/painting/FrameLayerBuilder.cpp @@ -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& 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 - (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, diff --git a/layout/painting/FrameLayerBuilder.h b/layout/painting/FrameLayerBuilder.h index 96133dc2d146..c8579f081855 100644 --- a/layout/painting/FrameLayerBuilder.h +++ b/layout/painting/FrameLayerBuilder.h @@ -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. *