chromium/third_party/blink/renderer/core/paint/line_relative_rect.h

// 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_CORE_PAINT_LINE_RELATIVE_RECT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_LINE_RELATIVE_RECT_H_

#include <optional>

#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/geometry/logical_size.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_size.h"
#include "third_party/blink/renderer/platform/geometry/layout_unit.h"
#include "third_party/blink/renderer/platform/transforms/affine_transform.h"
#include "ui/gfx/geometry/rect_f.h"

namespace blink {

class FragmentItem;

// Type-safe geometry for line-relative coordinate spaces.
//
// When painting text fragments in a vertical writing mode (where ‘writing-mode’
// is vertical or sideways), we rotate the canvas into a line-relative
// coordinate space, where +x is line-right and +y is line-under.
//
// Paint ops done while rotated (like text and text decorations) need
// coordinates in this rotated space, but ops done outside of these rotations
// (like selection backgrounds) need coordinates in the original physical space.
//
// Note that the bi-orientational transform for upright typesetting (see
// ‘text-orientation’) is handled by the lower-level text painting code with a
// nested rotation (CanvasRotationInVertical), which can be ignored at the
// painter level.

// 2D point or vector in line-relative space (physical space rotated for
// ‘writing-mode’), like gfx::PointF or gfx::Vector2dF but in fixed-point
// coordinates (LayoutUnit).
struct CORE_EXPORT LineRelativeOffset {};

// TODO(crbug.com/962299): These functions should upgraded to force correct
// pixel snapping in a type-safe way.
inline gfx::Point ToRoundedPoint(const LineRelativeOffset& o) {}

// 2D rect in line-relative space (physical space rotated for ‘writing-mode’),
// like gfx::RectF but in fixed-point coordinates (LayoutUnit).
struct CORE_EXPORT LineRelativeRect {};

// TODO(crbug.com/962299): These functions should upgraded to force correct
// pixel snapping in a type-safe way.
inline gfx::Rect ToPixelSnappedRect(const LineRelativeRect& r) {}

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_LINE_RELATIVE_RECT_H_