pub(crate) struct WebViewRenderer {Show 13 fields
pub id: WebViewId,
pub webview: Box<dyn WebViewTrait>,
pub root_pipeline_id: Option<PipelineId>,
pub rect: DeviceRect,
pub pipelines: HashMap<PipelineId, PipelineDetails>,
pub(crate) global: Rc<RefCell<ServoRenderer>>,
pending_scroll_zoom_events: Vec<ScrollZoomEvent>,
touch_handler: TouchHandler,
pub page_zoom: Scale<f32, CSSPixel, DeviceIndependentPixel>,
pinch_zoom: PinchZoomFactor,
hidpi_scale_factor: Scale<f32, DeviceIndependentPixel, DevicePixel>,
animating: bool,
viewport_description: Option<ViewportDescription>,
}
Expand description
A renderer for a libservo WebView
. This is essentially the ServoRenderer
’s interface to a
libservo WebView
, but the code here cannot depend on libservo in order to prevent circular
dependencies, which is why we store a dyn WebViewTrait
here instead of the WebView
itself.
Fields§
§id: WebViewId
The WebViewId
of the WebView
associated with this [WebViewDetails
].
webview: Box<dyn WebViewTrait>
The renderer’s view of the embedding layer WebView
as a trait implementation,
so that the renderer doesn’t need to depend on the embedding layer. This avoids
a dependency cycle.
root_pipeline_id: Option<PipelineId>
The root PipelineId
of the currently displayed page in this WebView.
rect: DeviceRect
The rectangle of the [WebView
] in device pixels, which is the viewport.
pipelines: HashMap<PipelineId, PipelineDetails>
Tracks details about each active pipeline that the compositor knows about.
global: Rc<RefCell<ServoRenderer>>
Data that is shared by all WebView renderers.
pending_scroll_zoom_events: Vec<ScrollZoomEvent>
Pending scroll/zoom events.
touch_handler: TouchHandler
Touch input state machine
page_zoom: Scale<f32, CSSPixel, DeviceIndependentPixel>
“Desktop-style” zoom that resizes the viewport to fit the window.
pinch_zoom: PinchZoomFactor
“Mobile-style” zoom that does not reflow the page.
hidpi_scale_factor: Scale<f32, DeviceIndependentPixel, DevicePixel>
The HiDPI scale factor for the WebView
associated with this renderer. This is controlled
by the embedding layer.
animating: bool
Whether or not this WebViewRenderer
isn’t throttled and has a pipeline with
active animations or animation frame callbacks.
viewport_description: Option<ViewportDescription>
A ViewportDescription
for this WebViewRenderer
, which contains the limitations
and initial values for zoom derived from the viewport
meta tag in web content.
Implementations§
Source§impl WebViewRenderer
impl WebViewRenderer
pub(crate) fn new( global: Rc<RefCell<ServoRenderer>>, renderer_webview: Box<dyn WebViewTrait>, viewport_details: ViewportDetails, ) -> Self
pub(crate) fn animation_callbacks_running(&self) -> bool
pub(crate) fn pipeline_ids(&self) -> Keys<'_, PipelineId, PipelineDetails>
pub(crate) fn animating(&self) -> bool
Sourcepub(crate) fn ensure_pipeline_details(
&mut self,
pipeline_id: PipelineId,
) -> &mut PipelineDetails
pub(crate) fn ensure_pipeline_details( &mut self, pipeline_id: PipelineId, ) -> &mut PipelineDetails
Returns the PipelineDetails
for the given PipelineId
, creating it if needed.
pub(crate) fn pipeline_exited( &mut self, pipeline_id: PipelineId, source: PipelineExitSource, )
pub(crate) fn set_frame_tree(&mut self, frame_tree: &SendableFrameTree)
pub(crate) fn send_scroll_positions_to_layout_for_pipeline( &self, pipeline_id: PipelineId, )
pub(crate) fn set_frame_tree_on_pipeline_details( &mut self, frame_tree: &SendableFrameTree, parent_pipeline_id: Option<PipelineId>, )
pub(crate) fn reset_scroll_tree_for_unattached_pipelines( &mut self, frame_tree: &SendableFrameTree, )
Sourcepub(crate) fn change_pipeline_running_animations_state(
&mut self,
pipeline_id: PipelineId,
animation_state: AnimationState,
) -> bool
pub(crate) fn change_pipeline_running_animations_state( &mut self, pipeline_id: PipelineId, animation_state: AnimationState, ) -> bool
Sets or unsets the animations-running flag for the given pipeline. Returns true if the pipeline has started animating.
Sourcepub(crate) fn set_throttled(
&mut self,
pipeline_id: PipelineId,
throttled: bool,
) -> bool
pub(crate) fn set_throttled( &mut self, pipeline_id: PipelineId, throttled: bool, ) -> bool
Sets or unsets the throttled flag for the given pipeline. Returns true if the pipeline has started animating.
fn update_animation_state(&mut self)
pub(crate) fn dispatch_input_event_with_hit_testing( &self, event: InputEvent, ) -> bool
pub(crate) fn notify_input_event(&mut self, event: InputEvent)
fn send_touch_event(&mut self, event: TouchEvent) -> bool
pub(crate) fn on_touch_event(&mut self, event: TouchEvent)
fn on_touch_down(&mut self, event: TouchEvent)
fn on_touch_move(&mut self, event: TouchEvent)
fn on_touch_up(&mut self, event: TouchEvent)
fn on_touch_cancel(&mut self, event: TouchEvent)
pub(crate) fn on_touch_event_processed(&mut self, result: TouchEventResult)
Sourcefn simulate_mouse_click(&mut self, point: DevicePoint)
fn simulate_mouse_click(&mut self, point: DevicePoint)
pub(crate) fn notify_scroll_event( &mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint, )
fn on_scroll_window_event( &mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint, )
Sourcepub(crate) fn process_pending_scroll_and_pinch_zoom_events(
&mut self,
) -> (PinchZoomResult, Option<ScrollResult>)
pub(crate) fn process_pending_scroll_and_pinch_zoom_events( &mut self, ) -> (PinchZoomResult, Option<ScrollResult>)
Process pending scroll events for this WebViewRenderer
. Returns a tuple containing:
- A boolean that is true if a zoom occurred.
- An optional
ScrollResult
if a scroll occurred.
It is up to the caller to ensure that these events update the rendering appropriately.
Sourcefn scroll_node_at_device_point(
&mut self,
cursor: DevicePoint,
scroll_location: ScrollLocation,
) -> Option<ScrollResult>
fn scroll_node_at_device_point( &mut self, cursor: DevicePoint, scroll_location: ScrollLocation, ) -> Option<ScrollResult>
Perform a hit test at the given DevicePoint
and apply the ScrollLocation
scrolling to the applicable scroll node under that point. If a scroll was
performed, returns the hit test result contains PipelineId
of the node
scrolled, the id, and the final scroll delta.
fn dispatch_scroll_event( &self, external_id: ExternalScrollId, hit_test_result: CompositorHitTestResult, )
pub(crate) fn pinch_zoom_level(&self) -> Scale<f32, DevicePixel, DevicePixel>
fn set_pinch_zoom_level(&mut self, zoom: f32) -> bool
pub(crate) fn page_zoom( &mut self, ) -> Scale<f32, CSSPixel, DeviceIndependentPixel>
pub(crate) fn set_page_zoom( &mut self, new_page_zoom: Scale<f32, CSSPixel, DeviceIndependentPixel>, )
Sourcepub(crate) fn device_pixels_per_page_pixel(
&self,
) -> Scale<f32, CSSPixel, DevicePixel>
pub(crate) fn device_pixels_per_page_pixel( &self, ) -> Scale<f32, CSSPixel, DevicePixel>
The scale to use when displaying this WebViewRenderer
in WebRender
including both viewport scale (page zoom and hidpi scale) as well as any
pinch zoom applied. This is based on the latest display list received,
as page zoom changes are applied asynchronously and the rendered view
should reflect the latest display list.
Sourcepub(crate) fn device_pixels_per_page_pixel_not_including_pinch_zoom(
&self,
) -> Scale<f32, CSSPixel, DevicePixel>
pub(crate) fn device_pixels_per_page_pixel_not_including_pinch_zoom( &self, ) -> Scale<f32, CSSPixel, DevicePixel>
The current viewport scale (hidpi scale and page zoom and not pinch zoom) based on the current setting of the WebView. Note that this may not be the rendered viewport zoom as that is based on the latest display list and zoom changes are applied asynchronously.
Sourcepub(crate) fn set_pinch_zoom(&mut self, magnification: f32)
pub(crate) fn set_pinch_zoom(&mut self, magnification: f32)
Simulate a pinch zoom
fn send_window_size_message(&self)
Sourcepub(crate) fn set_hidpi_scale_factor(
&mut self,
new_scale: Scale<f32, DeviceIndependentPixel, DevicePixel>,
) -> bool
pub(crate) fn set_hidpi_scale_factor( &mut self, new_scale: Scale<f32, DeviceIndependentPixel, DevicePixel>, ) -> bool
Set the hidpi_scale_factor
for this renderer, returning true
if the value actually changed.
Sourcepub(crate) fn set_rect(&mut self, new_rect: DeviceRect) -> bool
pub(crate) fn set_rect(&mut self, new_rect: DeviceRect) -> bool
Set the rect
for this renderer, returning true
if the value actually changed.
pub fn set_viewport_description( &mut self, viewport_description: ViewportDescription, )
pub(crate) fn scroll_trees_memory_usage( &self, ops: &mut MallocSizeOfOps, ) -> usize
Auto Trait Implementations§
impl Freeze for WebViewRenderer
impl !RefUnwindSafe for WebViewRenderer
impl !Send for WebViewRenderer
impl !Sync for WebViewRenderer
impl Unpin for WebViewRenderer
impl !UnwindSafe for WebViewRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more