1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 import "services/viz/public/mojom/compositing/local_surface_id.mojom";
8 import "services/viz/public/mojom/compositing/selection.mojom";
9 import "services/viz/public/mojom/compositing/vertical_scroll_direction.mojom";
10 import "skia/public/mojom/skcolor4f.mojom";
11 import "ui/gfx/geometry/mojom/geometry.mojom";
13 // Contains information to assist in making a decision about forwarding
14 // pointerevents to viz for use in a delegated ink trail.
15 struct DelegatedInkBrowserMetadata {
16 // Flag used to indicate the state of the hovering on the pointerevent that
17 // the delegated ink metadata was created from. If this state does not match
18 // the point under consideration to send to viz, it won't be sent. As soon
19 // as it matches again the point will be sent, regardless of if the renderer
20 // has processed the point that didn't match yet or not. It is true when
21 // hovering, false otherwise.
22 bool delegated_ink_is_hovering;
25 // See components/viz/service/quads/render_frame_metadata.h
26 struct RenderFrameMetadata {
27 // The background color of a CompositorFrame. It can be used for filling the
28 // content area if the primary surface is unavailable and fallback is not
30 skia.mojom.SkColor4f root_background_color;
32 // Scroll offset of the root layer. This optional parameter is only sent
34 gfx.mojom.PointF? root_scroll_offset;
36 // Indicates whether the scroll offset of the root layer is at top, i.e.,
37 // whether scroll_offset.y() == 0.
38 bool is_scroll_offset_at_top;
40 // Selection region relative to the current viewport. If the selection is
41 // empty or otherwise unused, the bound types will indicate such.
42 viz.mojom.Selection selection;
44 // Determines whether the page is mobile optimized or not, which means at
45 // least one of the following has to be true:
46 // - page has a width=device-width or narrower viewport.
47 // - page prevents zooming in or out (i.e. min and max page scale factors
49 bool is_mobile_optimized;
51 // Existence of this flag informs the browser process to start forwarding
52 // points to viz for use in a delegated ink trail. It contains more
53 // information to be used in making the forwarding decision. It exists the
54 // entire time points could be forwarded, and forwarding must stop as soon as
56 DelegatedInkBrowserMetadata? delegated_ink_metadata;
58 // The device scale factor used to generate CompositorFrame.
59 float device_scale_factor;
61 // The size of the viewport used to generate a CompositorFrame.
62 gfx.mojom.Size viewport_size_in_pixels;
64 // The last viz::LocalSurfaceId used to submit a CompositorFrame.
65 viz.mojom.LocalSurfaceId? local_surface_id;
67 // The page scale factor used on the content.
68 float page_scale_factor;
70 // The subframe page scale factor used on the content. This value will match
71 // |page_scale_factor|, which is only ever set for the main frame, and it is
72 // only used for setting raster scale in child renderers.
73 float external_page_scale_factor;
75 // Used to position the Android location top bar and page content, whose
76 // precise position is computed by the renderer compositor.
77 float top_controls_height;
79 float top_controls_shown_ratio;
81 viz.mojom.VerticalScrollDirection new_vertical_scroll_direction;
83 // Used to position Android/iOS bottom bar, whose position is computed by the
84 // renderer compositor.
85 [EnableIf=is_android_or_ios]
86 float bottom_controls_height;
88 [EnableIf=is_android_or_ios]
89 float bottom_controls_shown_ratio;
91 [EnableIf=is_android_or_ios]
92 float top_controls_min_height_offset;
94 [EnableIf=is_android_or_ios]
95 float bottom_controls_min_height_offset;
97 [EnableIf=is_android_or_ios]
98 float min_page_scale_factor;
100 [EnableIf=is_android_or_ios]
101 float max_page_scale_factor;
103 [EnableIf=is_android_or_ios]
104 bool root_overflow_y_hidden;
106 [EnableIf=is_android_or_ios]
107 gfx.mojom.SizeF scrollable_viewport_size;
109 [EnableIf=is_android_or_ios]
110 gfx.mojom.SizeF root_layer_size;
112 [EnableIf=is_android_or_ios]
113 bool has_transparent_background;
116 [EnableIf=is_android]
117 enum RootScrollOffsetUpdateFrequency {
118 // The client will only be notified of root scroll offsets via the regular
119 // RenderFrameMetadata updates. This is the default behavior. See
120 // `RenderFrameMetadataObserverImpl::ShouldSendRenderFrameMetadata()` for
121 // details on when the RenderFrameMetadata updates occur.
123 // The client will also be notified with an updated root scroll offset when a
124 // scroll ends in addition to offset updates sent via RenderFrameMetadata
127 // The client will be notified of any change to the root scroll offset.
131 // This interface is provided by the renderer. It impacts the frequency with
132 // which a fully populated RenderFrameMetadata object (above) is delivered to
133 // the RenderFrameMetadataObserverClient.
134 interface RenderFrameMetadataObserver {
135 // When `frequency` is set to a value other than `kNone`, this notifies the
136 // client of changes to the root scroll offset. The client is notified in
138 // . OnRenderFrameMetadataChanged(), is sent if the client would normally be
139 // notified of the frame (for example, the viewport changed). If `frequency`
140 // is `kNone`, the client is not sent `OnRootScrollOffsetChanged()`.
141 // . OnRootScrollOffsetChanged() if the client is not notified of the frame
143 // - but `frequency` is `kOnScrollEnd` and a scroll has just ended.
144 // - but `frequency` is `kAllUpdates` and the scroll offset has changed.
146 // In other words, if this is sent, *only* the root-scroll-offset has changed
147 // and the client is not sent a OnRenderFrameMetadataChanged() for the frame.
148 // Used on Android for acessibility and GestureListenerManager.
149 [EnableIf=is_android]
150 UpdateRootScrollOffsetUpdateFrequency(
151 RootScrollOffsetUpdateFrequency frequency);
153 // When |enabled| is set to true, this will send RenderFrameMetadata to
154 // the RenderFrameMetadataObserverClient for all frames. Only used for
156 ReportAllFrameSubmissionsForTesting(bool enabled);
159 // This interface is provided by the browser. It is notified of changes to
160 // RenderFrameMetadata. It can be notified of all frame submissions, via
161 // RenderFrameMetadataObserver::ReportAllFrameSubmissionsForTesting, or of
162 // additional frames with root scroll offset changes via
163 // RenderFrameMetadataObserver::UpdateRootScrollOffsetUpdateFrequency.
164 interface RenderFrameMetadataObserverClient {
165 // Notified when RenderFrameMetadata has changed.
166 OnRenderFrameMetadataChanged(uint32 frame_token,
167 RenderFrameMetadata metadata);
169 // Notified on all frame submissions.
170 OnFrameSubmissionForTesting(uint32 frame_token);
172 // Only called if UpdateRootScrollOffsetUpdateFrequency() has been called.
173 [EnableIf=is_android]
174 OnRootScrollOffsetChanged(gfx.mojom.PointF root_scroll_offset);