// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_FRAME_FRAME_VISUAL_PROPERTIES_H_
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_FRAME_FRAME_VISUAL_PROPERTIES_H_

#include "components/viz/common/surfaces/local_surface_id.h"
#include "third_party/blink/public/common/common_export.h"
#include "ui/display/screen_infos.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"

namespace blink {

// TODO(fsamuel): We might want to unify this with content::ResizeParams.
struct BLINK_COMMON_EXPORT FrameVisualProperties {
  FrameVisualProperties();
  FrameVisualProperties(const FrameVisualProperties& other);
  ~FrameVisualProperties();

  FrameVisualProperties& operator=(const FrameVisualProperties& other);

  static double MaxChildFrameScreenRectMovement();
  static int MinScreenRectStableTimeMs();

  // MaxChildFrameScreenRectMovement and MinScreenRectStableTimeMs are
  // initialized according to the field trial parameters, but once
  // initialized, they will never be updated. This causes flaky failure
  // of EventHandlerSimTest.DiscardEventsToRecentlyMovedIframe.
  static void ResetForTesting();

  // TODO(szager): These values override the above two values for frames that
  // utilize IntersectionObserver V2 (i.e. occlusion detection). The purpose of
  // this specialization is to preserve existing behavior while the above two
  // parameters are experimentally dialed in.
  // See kTargetFrameMovedRecentlyForIOv2 in web_input_event.h.
  static int MaxChildFrameScreenRectMovementForIOv2();
  static int MinScreenRectStableTimeMsForIOv2();

  // These fields are values from VisualProperties, see comments there for
  // descriptions. They exist here to propagate from each RenderWidget to its
  // child RenderWidgets. Here they are flowing from RenderWidget in a parent
  // renderer process up to the RenderWidgetHost for a child RenderWidget in
  // another renderer process. That RenderWidgetHost would then be responsible
  // for passing it along to the child RenderWidget.
  display::ScreenInfos screen_infos;
  bool auto_resize_enabled = false;
  bool is_pinch_gesture_active = false;
  double zoom_level = 0;
  double css_zoom_factor = 1.f;
  float page_scale_factor = 1.f;
  float compositing_scale_factor = 1.f;
  float cursor_accessibility_scale_factor = 1.f;
  gfx::Size visible_viewport_size;
  gfx::Size min_size_for_auto_resize;
  gfx::Size max_size_for_auto_resize;
  std::vector<gfx::Rect> root_widget_viewport_segments;

  // The size of the compositor viewport, to match the sub-frame's surface.
  gfx::Rect compositor_viewport;

  // The frame's rect relative to the first ancestor local root frame.
  gfx::Rect rect_in_local_root;

  // The size of the frame in its parent's coordinate space.
  gfx::Size local_frame_size;

  // The LocalSurfaceId of the frame. This id is generated by the parent frame.
  viz::LocalSurfaceId local_surface_id;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_FRAME_FRAME_VISUAL_PROPERTIES_H_
