mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Add comment and rename epoch_not_synchronized
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
parent
afa3f4bba2
commit
3d7ced5048
2 changed files with 20 additions and 16 deletions
|
@ -671,7 +671,7 @@ impl IOCompositor {
|
||||||
};
|
};
|
||||||
let dppx = webview_renderer.device_pixels_per_page_pixel();
|
let dppx = webview_renderer.device_pixels_per_page_pixel();
|
||||||
let point = dppx.transform_point(Point2D::new(x, y));
|
let point = dppx.transform_point(Point2D::new(x, y));
|
||||||
webview_renderer.dispatch_input_event(
|
webview_renderer.dispatch_point_input_event(
|
||||||
InputEvent::MouseButton(MouseButtonEvent::new(action, button, point))
|
InputEvent::MouseButton(MouseButtonEvent::new(action, button, point))
|
||||||
.with_webdriver_message_id(Some(message_id)),
|
.with_webdriver_message_id(Some(message_id)),
|
||||||
);
|
);
|
||||||
|
@ -684,7 +684,7 @@ impl IOCompositor {
|
||||||
};
|
};
|
||||||
let dppx = webview_renderer.device_pixels_per_page_pixel();
|
let dppx = webview_renderer.device_pixels_per_page_pixel();
|
||||||
let point = dppx.transform_point(Point2D::new(x, y));
|
let point = dppx.transform_point(Point2D::new(x, y));
|
||||||
webview_renderer.dispatch_input_event(
|
webview_renderer.dispatch_point_input_event(
|
||||||
InputEvent::MouseMove(MouseMoveEvent::new(point))
|
InputEvent::MouseMove(MouseMoveEvent::new(point))
|
||||||
.with_webdriver_message_id(Some(message_id)),
|
.with_webdriver_message_id(Some(message_id)),
|
||||||
);
|
);
|
||||||
|
@ -706,7 +706,7 @@ impl IOCompositor {
|
||||||
let scroll_delta =
|
let scroll_delta =
|
||||||
dppx.transform_vector(Vector2D::new(delta_x as f32, delta_y as f32));
|
dppx.transform_vector(Vector2D::new(delta_x as f32, delta_y as f32));
|
||||||
webview_renderer
|
webview_renderer
|
||||||
.dispatch_input_event(InputEvent::Wheel(WheelEvent { delta, point }));
|
.dispatch_point_input_event(InputEvent::Wheel(WheelEvent { delta, point }));
|
||||||
webview_renderer.on_webdriver_wheel_action(scroll_delta, point);
|
webview_renderer.on_webdriver_wheel_action(scroll_delta, point);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -815,7 +815,7 @@ impl IOCompositor {
|
||||||
return warn!("Could not find WebView for incoming display list");
|
return warn!("Could not find WebView for incoming display list");
|
||||||
};
|
};
|
||||||
// epoch is outdated until we receive "NewWebRenderFrameReady" message.
|
// epoch is outdated until we receive "NewWebRenderFrameReady" message.
|
||||||
webview_renderer.epoch_not_synchronized.set(true);
|
webview_renderer.webrender_frame_ready.set(false);
|
||||||
|
|
||||||
let pipeline_id = display_list_info.pipeline_id;
|
let pipeline_id = display_list_info.pipeline_id;
|
||||||
let details = webview_renderer.ensure_pipeline_details(pipeline_id.into());
|
let details = webview_renderer.ensure_pipeline_details(pipeline_id.into());
|
||||||
|
@ -1664,7 +1664,7 @@ impl IOCompositor {
|
||||||
// Process all pending events
|
// Process all pending events
|
||||||
self.webview_renderers.iter().for_each(|webview| {
|
self.webview_renderers.iter().for_each(|webview| {
|
||||||
webview.dispatch_pending_point_input_events();
|
webview.dispatch_pending_point_input_events();
|
||||||
webview.epoch_not_synchronized.set(false);
|
webview.webrender_frame_ready.set(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ pub(crate) struct WebViewRenderer {
|
||||||
/// Pending input events queue. Priavte and only this thread pushes events to it.
|
/// Pending input events queue. Priavte and only this thread pushes events to it.
|
||||||
pending_point_input_events: RefCell<VecDeque<InputEvent>>,
|
pending_point_input_events: RefCell<VecDeque<InputEvent>>,
|
||||||
/// Flag to indicate that the epoch has been not synchronized yet.
|
/// Flag to indicate that the epoch has been not synchronized yet.
|
||||||
pub epoch_not_synchronized: Cell<bool>,
|
pub webrender_frame_ready: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for WebViewRenderer {
|
impl Drop for WebViewRenderer {
|
||||||
|
@ -137,7 +137,7 @@ impl WebViewRenderer {
|
||||||
hidpi_scale_factor: Scale::new(hidpi_scale_factor.0),
|
hidpi_scale_factor: Scale::new(hidpi_scale_factor.0),
|
||||||
animating: false,
|
animating: false,
|
||||||
pending_point_input_events: Default::default(),
|
pending_point_input_events: Default::default(),
|
||||||
epoch_not_synchronized: Cell::default(),
|
webrender_frame_ready: Cell::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,14 +315,17 @@ impl WebViewRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn dispatch_input_event(&mut self, event: InputEvent) {
|
pub(crate) fn dispatch_point_input_event(&mut self, event: InputEvent) {
|
||||||
// Events that do not need to do hit testing are sent directly to the
|
// Events that do not need to do hit testing are sent directly to the
|
||||||
// constellation to filter down.
|
// constellation to filter down.
|
||||||
let Some(point) = event.point() else {
|
let Some(point) = event.point() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.epoch_not_synchronized.get() {
|
// Delay the event if the epoch is not synchronized yet (new frame is not ready),
|
||||||
|
// or hit test result would fail and the event is rejected anyway.
|
||||||
|
if !self.webrender_frame_ready.get() || !self.pending_point_input_events.borrow().is_empty()
|
||||||
|
{
|
||||||
self.pending_point_input_events
|
self.pending_point_input_events
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push_back(event);
|
.push_back(event);
|
||||||
|
@ -453,13 +456,14 @@ impl WebViewRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.dispatch_input_event(event);
|
self.dispatch_point_input_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_touch_event(&self, mut event: TouchEvent) -> bool {
|
fn send_touch_event(&self, mut event: TouchEvent) -> bool {
|
||||||
if self.epoch_not_synchronized.get() {
|
// Delay the event if the epoch is not synchronized yet (new frame is not ready),
|
||||||
// If the epoch is not synchronized, we cannot send the event.
|
// or hit test result would fail and the event is rejected anyway.
|
||||||
// We will try again later.
|
if !self.webrender_frame_ready.get() || !self.pending_point_input_events.borrow().is_empty()
|
||||||
|
{
|
||||||
self.pending_point_input_events
|
self.pending_point_input_events
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push_back(InputEvent::Touch(event));
|
.push_back(InputEvent::Touch(event));
|
||||||
|
@ -759,13 +763,13 @@ impl WebViewRenderer {
|
||||||
/// <http://w3c.github.io/touch-events/#mouse-events>
|
/// <http://w3c.github.io/touch-events/#mouse-events>
|
||||||
fn simulate_mouse_click(&mut self, point: DevicePoint) {
|
fn simulate_mouse_click(&mut self, point: DevicePoint) {
|
||||||
let button = MouseButton::Left;
|
let button = MouseButton::Left;
|
||||||
self.dispatch_input_event(InputEvent::MouseMove(MouseMoveEvent::new(point)));
|
self.dispatch_point_input_event(InputEvent::MouseMove(MouseMoveEvent::new(point)));
|
||||||
self.dispatch_input_event(InputEvent::MouseButton(MouseButtonEvent::new(
|
self.dispatch_point_input_event(InputEvent::MouseButton(MouseButtonEvent::new(
|
||||||
MouseButtonAction::Down,
|
MouseButtonAction::Down,
|
||||||
button,
|
button,
|
||||||
point,
|
point,
|
||||||
)));
|
)));
|
||||||
self.dispatch_input_event(InputEvent::MouseButton(MouseButtonEvent::new(
|
self.dispatch_point_input_event(InputEvent::MouseButton(MouseButtonEvent::new(
|
||||||
MouseButtonAction::Up,
|
MouseButtonAction::Up,
|
||||||
button,
|
button,
|
||||||
point,
|
point,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue