Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
Daniel Libby | adeca89 | 2020-06-05 20:03:40 | [diff] [blame] | 2 | // 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 Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 8 | #include <optional> |
Anton Bikineev | 9662571 | 2021-05-13 19:17:50 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
Daniel Libby | adeca89 | 2020-06-05 20:03:40 | [diff] [blame] | 11 | #include "build/build_config.h" |
| 12 | #include "content/common/content_export.h" |
Songtao Xia | 27891f21 | 2020-07-09 21:39:17 | [diff] [blame] | 13 | #include "ui/gfx/geometry/rect.h" |
Daniel Libby | adeca89 | 2020-06-05 20:03:40 | [diff] [blame] | 14 | |
| 15 | namespace 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. |
| 38 | struct CONTENT_EXPORT DisplayFeature { |
| 39 | enum class Orientation { kVertical, kHorizontal, kMaxValue = kHorizontal }; |
Songtao Xia | 27891f21 | 2020-07-09 21:39:17 | [diff] [blame] | 40 | enum class ParamErrorEnum { |
| 41 | kDisplayFeatureWithZeroScreenSize = 1, |
| 42 | kNegativeDisplayFeatureParams, |
| 43 | kOutsideScreenWidth, |
| 44 | kOutsideScreenHeight |
| 45 | }; |
Daniel Libby | adeca89 | 2020-06-05 20:03:40 | [diff] [blame] | 46 | |
| 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 Keitel | 2f61db6 | 2025-05-20 08:26:02 | [diff] [blame] | 59 | friend bool operator==(const DisplayFeature&, |
| 60 | const DisplayFeature&) = default; |
Songtao Xia | 27891f21 | 2020-07-09 21:39:17 | [diff] [blame] | 61 | |
| 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 Menard | fb62ecc | 2024-02-26 21:25:19 | [diff] [blame] | 65 | std::vector<gfx::Rect> ComputeViewportSegments( |
Menard, Alexis | 91b2a32 | 2024-02-23 21:41:11 | [diff] [blame] | 66 | const gfx::Size& visible_viewport_size, |
| 67 | int root_view_offset_from_origin = 0) const; |
Songtao Xia | 27891f21 | 2020-07-09 21:39:17 | [diff] [blame] | 68 | |
Arthur Sonzogni | c686e8f | 2024-01-11 08:36:37 | [diff] [blame] | 69 | static std::optional<DisplayFeature> Create( |
Songtao Xia | 27891f21 | 2020-07-09 21:39:17 | [diff] [blame] | 70 | Orientation orientation, |
| 71 | int offset, |
| 72 | int mask_length, |
| 73 | int screen_width, |
| 74 | int screen_height, |
| 75 | DisplayFeature::ParamErrorEnum* error); |
Daniel Libby | adeca89 | 2020-06-05 20:03:40 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | } // namespace content |
| 79 | |
| 80 | #endif // CONTENT_BROWSER_RENDERER_HOST_DISPLAY_FEATURE_H_ |