blob: 1f8fd7040952327e0113a353504a3c48e2934239 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2020 The Chromium Authors
Daniel Libbyadeca892020-06-05 20:03:402// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_RENDERER_HOST_DISPLAY_FEATURE_H_
6#define CONTENT_BROWSER_RENDERER_HOST_DISPLAY_FEATURE_H_
7
Arthur Sonzognic686e8f2024-01-11 08:36:378#include <optional>
Anton Bikineev96625712021-05-13 19:17:509#include <vector>
10
Daniel Libbyadeca892020-06-05 20:03:4011#include "build/build_config.h"
12#include "content/common/content_export.h"
Songtao Xia27891f212020-07-09 21:39:1713#include "ui/gfx/geometry/rect.h"
Daniel Libbyadeca892020-06-05 20:03:4014
15namespace content {
16
17// Information about a physical attribute of the screen which that creates a
18// Logical separator or divider (e.g. a fold or mask).
19// This is a visual example of a vertically oriented display feature that masks
20// content underneath
21//
22// Orientation: vertical
23//
24// offset
25// |
26// +---------|===|---------+
27// | | | |
28// | | | |
29// | | | |
30// | | | |
31// | | | |
32// +---------|===|---------+
33// \
34// mask_length
35//
36// Note that the implicit height of the display feature is the entire height of
37// the screen on which it exists.
38struct CONTENT_EXPORT DisplayFeature {
39 enum class Orientation { kVertical, kHorizontal, kMaxValue = kHorizontal };
Songtao Xia27891f212020-07-09 21:39:1740 enum class ParamErrorEnum {
41 kDisplayFeatureWithZeroScreenSize = 1,
42 kNegativeDisplayFeatureParams,
43 kOutsideScreenWidth,
44 kOutsideScreenHeight
45 };
Daniel Libbyadeca892020-06-05 20:03:4046
47 // The orientation of the display feature in relation to the screen.
48 Orientation orientation = Orientation::kVertical;
49
50 // The offset from the screen origin in either the x (for vertical
51 // orientation) or y (for horizontal orientation) direction.
52 int offset = 0;
53
54 // A display feature may mask content such that it is not physically
55 // displayed - this length along with the offset describes this area.
56 // A display feature that only splits content will have a 0 |mask_length|.
57 int mask_length = 0;
58
Jan Keitel2f61db62025-05-20 08:26:0259 friend bool operator==(const DisplayFeature&,
60 const DisplayFeature&) = default;
Songtao Xia27891f212020-07-09 21:39:1761
62 // Computes logical segments of the |visible_viewport_size|, based on
63 // this display feature. These segments are in DIPs relative to the widget
64 // origin.
Alexis Menardfb62ecc2024-02-26 21:25:1965 std::vector<gfx::Rect> ComputeViewportSegments(
Menard, Alexis91b2a322024-02-23 21:41:1166 const gfx::Size& visible_viewport_size,
67 int root_view_offset_from_origin = 0) const;
Songtao Xia27891f212020-07-09 21:39:1768
Arthur Sonzognic686e8f2024-01-11 08:36:3769 static std::optional<DisplayFeature> Create(
Songtao Xia27891f212020-07-09 21:39:1770 Orientation orientation,
71 int offset,
72 int mask_length,
73 int screen_width,
74 int screen_height,
75 DisplayFeature::ParamErrorEnum* error);
Daniel Libbyadeca892020-06-05 20:03:4076};
77
78} // namespace content
79
80#endif // CONTENT_BROWSER_RENDERER_HOST_DISPLAY_FEATURE_H_