Commit dc9473c8 authored by Botond Ballo's avatar Botond Ballo
Browse files

Bug 1493976 - Define OutOfFlowDisplayData::ComputeVisibleRectForFrame() out of line. r=kats

Differential Revision: https://phabricator.services.mozilla.com/D9442

--HG--
extra : moz-landing-system : lando
parent 9405cbcc
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
@@ -958,6 +958,59 @@ nsDisplayListBuilder::AutoCurrentActiveScrolledRootSetter::InsertScrollFrame(
  mUsed = true;
}

/* static */ nsRect
nsDisplayListBuilder::OutOfFlowDisplayData::ComputeVisibleRectForFrame(
    nsDisplayListBuilder* aBuilder,
    nsIFrame* aFrame,
    const nsRect& aVisibleRect,
    const nsRect& aDirtyRect,
    nsRect* aOutDirtyRect)
{
  nsRect visible = aVisibleRect;
  nsRect dirtyRectRelativeToDirtyFrame = aDirtyRect;

#ifdef MOZ_WIDGET_ANDROID
  if (nsLayoutUtils::IsFixedPosFrameInDisplayPort(aFrame) &&
      aBuilder->IsPaintingToWindow()) {
    // We want to ensure that fixed position elements are visible when
    // being async scrolled, so we paint them at the size of the larger
    // viewport.
    dirtyRectRelativeToDirtyFrame =
      nsRect(nsPoint(0, 0), aFrame->GetParent()->GetSize());

    nsIPresShell* ps = aFrame->PresShell();
    if (ps->IsVisualViewportSizeSet() &&
        dirtyRectRelativeToDirtyFrame.Size() <
          ps->GetVisualViewportSize()) {
      dirtyRectRelativeToDirtyFrame.SizeTo(ps->GetVisualViewportSize());
    }

    visible = dirtyRectRelativeToDirtyFrame;
  }
#endif

  *aOutDirtyRect = dirtyRectRelativeToDirtyFrame - aFrame->GetPosition();
  visible -= aFrame->GetPosition();

  nsRect overflowRect = aFrame->GetVisualOverflowRect();

  if (aFrame->IsTransformed() &&
      mozilla::EffectCompositor::HasAnimationsForCompositor(
        aFrame, eCSSProperty_transform)) {
    /**
     * Add a fuzz factor to the overflow rectangle so that elements only
     * just out of view are pulled into the display list, so they can be
     * prerendered if necessary.
     */
    overflowRect.Inflate(nsPresContext::CSSPixelsToAppUnits(32));
  }

  visible.IntersectRect(visible, overflowRect);
  aOutDirtyRect->IntersectRect(*aOutDirtyRect, overflowRect);

  return visible;
}

nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
                                           nsDisplayListBuilderMode aMode,
                                           bool aBuildCaret,
+1 −46
Original line number Diff line number Diff line
@@ -1629,52 +1629,7 @@ public:
                                             nsIFrame* aFrame,
                                             const nsRect& aVisibleRect,
                                             const nsRect& aDirtyRect,
                                             nsRect* aOutDirtyRect)
    {
      nsRect visible = aVisibleRect;
      nsRect dirtyRectRelativeToDirtyFrame = aDirtyRect;

#ifdef MOZ_WIDGET_ANDROID
      if (nsLayoutUtils::IsFixedPosFrameInDisplayPort(aFrame) &&
          aBuilder->IsPaintingToWindow()) {
        // We want to ensure that fixed position elements are visible when
        // being async scrolled, so we paint them at the size of the larger
        // viewport.
        dirtyRectRelativeToDirtyFrame =
          nsRect(nsPoint(0, 0), aFrame->GetParent()->GetSize());

        nsIPresShell* ps = aFrame->PresShell();
        if (ps->IsVisualViewportSizeSet() &&
            dirtyRectRelativeToDirtyFrame.Size() <
              ps->GetVisualViewportSize()) {
          dirtyRectRelativeToDirtyFrame.SizeTo(ps->GetVisualViewportSize());
        }

        visible = dirtyRectRelativeToDirtyFrame;
      }
#endif

      *aOutDirtyRect = dirtyRectRelativeToDirtyFrame - aFrame->GetPosition();
      visible -= aFrame->GetPosition();

      nsRect overflowRect = aFrame->GetVisualOverflowRect();

      if (aFrame->IsTransformed() &&
          mozilla::EffectCompositor::HasAnimationsForCompositor(
            aFrame, eCSSProperty_transform)) {
        /**
         * Add a fuzz factor to the overflow rectangle so that elements only
         * just out of view are pulled into the display list, so they can be
         * prerendered if necessary.
         */
        overflowRect.Inflate(nsPresContext::CSSPixelsToAppUnits(32));
      }

      visible.IntersectRect(visible, overflowRect);
      aOutDirtyRect->IntersectRect(*aOutDirtyRect, overflowRect);

      return visible;
    }
                                             nsRect* aOutDirtyRect);

    nsRect GetVisibleRectForFrame(nsDisplayListBuilder* aBuilder,
                                  nsIFrame* aFrame,