static bool
IsRectZoomedIn(const CSSRect& aRect, const CSSRect& aCompositedArea)
{
  // This functions checks to see if the area of the rect visible in the
  // composition bounds (i.e. the overlapArea variable below) is approximately
  // the max area of the rect we can show.
  CSSRect overlap = aCompositedArea.Intersect(aRect);
  float overlapArea = overlap.width * overlap.height;
  float availHeight = std::min(aRect.width * aCompositedArea.height / aCompositedArea.width,
                               aRect.height);
  float showing = overlapArea / (aRect.width * availHeight);
  float ratioW = aRect.width / aCompositedArea.width;
  float ratioH = aRect.height / aCompositedArea.height;

  return showing > 0.9 && (ratioW > 0.9 || ratioH > 0.9);
}
示例#2
0
static void
MaybeAlignAndClampDisplayPort(mozilla::layers::FrameMetrics& aFrameMetrics,
                              const CSSPoint& aActualScrollOffset)
{
  // Correct the display-port by the difference between the requested scroll
  // offset and the resulting scroll offset after setting the requested value.
  CSSRect& displayPort = aFrameMetrics.mDisplayPort;
  displayPort += aFrameMetrics.mScrollOffset - aActualScrollOffset;

  // Expand the display port to the next tile boundaries, if tiled thebes layers
  // are enabled.
  if (gfxPlatform::GetPrefLayersEnableTiles()) {
    displayPort =
      ExpandDisplayPortToTileBoundaries(displayPort + aActualScrollOffset,
                                        aFrameMetrics.LayersPixelsPerCSSPixel())
      - aActualScrollOffset;
  }

  // Finally, clamp the display port to the expanded scrollable rect.
  CSSRect scrollableRect = aFrameMetrics.GetExpandedScrollableRect();
  displayPort = scrollableRect.Intersect(displayPort + aActualScrollOffset)
    - aActualScrollOffset;
}