// Copyright 2023 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_RENDERER_PLATFORM_GRAPHICS_VISUAL_RECT_FLAGS_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_VISUAL_RECT_FLAGS_H_

#include "base/containers/enum_set.h"

namespace blink {

enum class VisualRectFlag {
  kMinValue,

  // The following flags are used in both
  // LayoutObject::MapToVisualRectInAncestorSpace() and
  // GeometryMapper::LocalToAncestorVisualRect().

  // Use gfx::RectF::InclusiveIntersect instead of gfx::RectF::Intersect for
  // intersection.
  kEdgeInclusive = kMinValue,
  // Don't expand visual rect for pixel-moving filters.
  kIgnoreFilters,

  // The following flags are used in
  // LayoutObject::MapToVisualRectInAncestorSpace() only.

  // Use the GeometryMapper fast-path, if possible.
  kUseGeometryMapper,
  // When mapping to absolute coordinates and the main frame is remote, don't
  // apply the main frame root scroller's overflow clip.
  kDontApplyMainFrameOverflowClip,
  kIgnoreLocalClipPath,

  // If the local root frame has a remote frame parent, apply the transformation
  // from the local root frame to the viewport, i.e., (0, 0) maps to the origin
  // of the window rendering the remote main Document.
  //
  // NOTE: This is guaranteed to provide a correct value only if the iframe is
  // onscreen. This is because we don't sync scroll updates from the main
  // frame's root scroller. See kSkipUnnecessaryRemoteFrameGeometryPropagation.
  kApplyRemoteViewportTransform,

  // Use the real clip-path bounding rect, ignoring any large clip path bounding
  // rect designed to facilitate painting of composited clip path animations.
  // Used for intersection observers.
  kUsePreciseClipPath,

  // Skip all ancestor clips, including the viewport clip. Callers that need to
  // derive both the unclipped and clipped rects can map once with this flag to
  // obtain the unclipped geometry and once without it for the fully clipped
  // rect, ensuring identical transform and scroll offset logic.
  kSkipAncestorAndViewportClips,
  kMaxValue = kSkipAncestorAndViewportClips,
};

using VisualRectFlags = base::EnumSet<VisualRectFlag>;

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_VISUAL_RECT_FLAGS_H_
