Commit 35ae7c50 authored by Botond Ballo's avatar Botond Ballo
Browse files

Bug 1818967 - Use the correct scale in DisplayPortMargins::GetRelativeToLayoutViewport(). r=hiro

mScale is the zoom at the time the displayport margins were set, but
the resulting ScreenMargin will be interpreted in the context of the
scale at which we're about to paint, which may be different.

Note that mMargins themselves are not affected by these two scales
being potentially different, since we want the magnitude of the
margins to the constant in Screen pixels (i.e. a constant fraction
of the viewport size).

Differential Revision: https://phabricator.services.mozilla.com/D173577
parent 6543182f
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -96,8 +96,8 @@ DisplayPortMargins DisplayPortMargins::ForContent(
}

ScreenMargin DisplayPortMargins::GetRelativeToLayoutViewport(
    ContentGeometryType aGeometryType,
    nsIScrollableFrame* aScrollableFrame) const {
    ContentGeometryType aGeometryType, nsIScrollableFrame* aScrollableFrame,
    const CSSToScreenScale2D& aDisplayportScale) const {
  // APZ wants |mMargins| applied relative to the visual viewport.
  // The main-thread painting code applies margins relative to
  // the layout viewport. To get the main thread to paint the
@@ -106,7 +106,7 @@ ScreenMargin DisplayPortMargins::GetRelativeToLayoutViewport(
  // applying the displayport to scrolled or fixed content.
  CSSPoint scrollDeltaCss =
      ComputeAsyncTranslation(aGeometryType, aScrollableFrame);
  ScreenPoint scrollDelta = scrollDeltaCss * mScale;
  ScreenPoint scrollDelta = scrollDeltaCss * aDisplayportScale;
  ScreenMargin margins = mMargins;
  margins.left -= scrollDelta.x;
  margins.right += scrollDelta.x;
@@ -275,7 +275,8 @@ static nsRect GetDisplayPortFromMarginsData(
  MOZ_ASSERT(presShell);

  ScreenMargin margins = aMarginsData->mMargins.GetRelativeToLayoutViewport(
      aOptions.mGeometryType, scrollableFrame);
      aOptions.mGeometryType, scrollableFrame,
      presContext->CSSToDevPixelScale() * res);

  if (presShell->IsDisplayportSuppressed() ||
      aContent->GetProperty(nsGkAtoms::MinimalDisplayPort)) {
+2 −2
Original line number Diff line number Diff line
@@ -107,8 +107,8 @@ struct DisplayPortMargins {
  // applied to (or, in the case of fixed content), the scroll frame wrt. which
  // the content is fixed.
  ScreenMargin GetRelativeToLayoutViewport(
      ContentGeometryType aGeometryType,
      nsIScrollableFrame* aScrollableFrame) const;
      ContentGeometryType aGeometryType, nsIScrollableFrame* aScrollableFrame,
      const CSSToScreenScale2D& aDisplayportScale) const;

  friend std::ostream& operator<<(std::ostream& aOs,
                                  const DisplayPortMargins& aMargins);