1// Copyright 2018 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5module cc.mojom; 6 7import "mojo/public/mojom/base/time.mojom"; 8import "services/viz/public/mojom/compositing/local_surface_id.mojom"; 9import "services/viz/public/mojom/compositing/selection.mojom"; 10import "services/viz/public/mojom/compositing/vertical_scroll_direction.mojom"; 11import "ui/gfx/geometry/mojom/geometry.mojom"; 12 13// See components/viz/service/quads/render_frame_metadata.h 14struct RenderFrameMetadata { 15 // The background color of a CompositorFrame. It can be used for filling the 16 // content area if the primary surface is unavailable and fallback is not 17 // specified. 18 uint32 root_background_color; 19 20 // Scroll offset of the root layer. This optional parameter is only sent 21 // during tests. 22 gfx.mojom.Vector2dF? root_scroll_offset; 23 24 // Indicates whether the scroll offset of the root layer is at top, i.e., 25 // whether scroll_offset.y() == 0. 26 bool is_scroll_offset_at_top; 27 28 // Selection region relative to the current viewport. If the selection is 29 // empty or otherwise unused, the bound types will indicate such. 30 viz.mojom.Selection selection; 31 32 // Determines whether the page is mobile optimized or not, which means at 33 // least one of the following has to be true: 34 // - page has a width=device-width or narrower viewport. 35 // - page prevents zooming in or out (i.e. min and max page scale factors 36 // are the same). 37 bool is_mobile_optimized; 38 39 // Flag used to notify the browser process to start or stop forwarding points 40 // to viz for use in a delegated ink trail. True the entire time points should 41 // be forwarded, and forwarding stops as soon as it is false again. 42 bool has_delegated_ink_metadata; 43 44 // The device scale factor used to generate CompositorFrame. 45 float device_scale_factor; 46 47 // The size of the viewport used to generate a CompositorFrame. 48 gfx.mojom.Size viewport_size_in_pixels; 49 50 // The last viz::LocalSurfaceId used to submit a CompositorFrame. 51 viz.mojom.LocalSurfaceId? local_surface_id; 52 53 // The page scale factor used on the content. 54 float page_scale_factor; 55 56 // The subframe page scale factor used on the content. This value will match 57 // |page_scale_factor|, which is only ever set for the main frame, and it is 58 // only used for setting raster scale in child renderers. 59 float external_page_scale_factor; 60 61 // Used to position the Android location top bar and page content, whose 62 // precise position is computed by the renderer compositor. 63 float top_controls_height; 64 65 float top_controls_shown_ratio; 66 67 viz.mojom.VerticalScrollDirection new_vertical_scroll_direction; 68 69 // Used to position Android bottom bar, whose position is computed by the 70 // renderer compositor. 71 [EnableIf=is_android] 72 float bottom_controls_height; 73 74 [EnableIf=is_android] 75 float bottom_controls_shown_ratio; 76 77 [EnableIf=is_android] 78 float top_controls_min_height_offset; 79 80 [EnableIf=is_android] 81 float bottom_controls_min_height_offset; 82 83 [EnableIf=is_android] 84 float min_page_scale_factor; 85 86 [EnableIf=is_android] 87 float max_page_scale_factor; 88 89 [EnableIf=is_android] 90 bool root_overflow_y_hidden; 91 92 [EnableIf=is_android] 93 gfx.mojom.SizeF scrollable_viewport_size; 94 95 [EnableIf=is_android] 96 gfx.mojom.SizeF root_layer_size; 97 98 [EnableIf=is_android] 99 bool has_transparent_background; 100}; 101 102// This interface is provided by the renderer. It impacts the frequency with 103// which a fully populated RenderFrameMetadata object (above) is delivered to 104// the RenderFrameMetadataObserverClient. 105interface RenderFrameMetadataObserver { 106 // When |enabled| is set to true this notifies the client of any change to the 107 // root scroll offset. The client is notified in two ways: 108 // . OnRenderFrameMetadataChanged(), is sent if the client would normally be 109 // notified of the frame (for example, the viewport changed). 110 // . OnRootScrollOffsetChanged() if the client is not notified of the frame 111 // change, but the root scroll offset has changed. In other words, if this 112 // is sent, *only* the root-scroll-offset has changed and the client is not 113 // sent a OnRenderFrameMetadataChanged() for the frame. 114 // Used on Android for acessibility and GestureListenerManager. 115 [EnableIf=is_android] 116 ReportAllRootScrolls(bool enabled); 117 118 // When |enabled| is set to true, this will send RenderFrameMetadata to 119 // the RenderFrameMetadataObserverClient for all frames. Only used for 120 // tests. 121 ReportAllFrameSubmissionsForTesting(bool enabled); 122}; 123 124// This interface is provided by the browser. It is notified of changes to 125// RenderFrameMetadata. It can be notified of all frame submissions, via 126// RenderFrameMetadataObserver::ReportAllFrameSubmissionsForTesting, or of 127// additional frames with root scroll offset changes via 128// RenderFrameMetadataObserver::ReportAllRootScrolls. 129interface RenderFrameMetadataObserverClient { 130 // Notified when RenderFrameMetadata has changed. 131 OnRenderFrameMetadataChanged(uint32 frame_token, 132 RenderFrameMetadata metadata); 133 134 // Notified on all frame submissions. 135 OnFrameSubmissionForTesting(uint32 frame_token); 136 137 // Only called if ReportAllRootScrolls(true) has been called. See 138 // ReportAllRootScrolls() for details. 139 [EnableIf=is_android] 140 OnRootScrollOffsetChanged(gfx.mojom.Vector2dF root_scroll_offset); 141}; 142