mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
clippy: Fix assorted warnings in components/
(#31628)
* clippy: fix assorted warnings in `components/` * fix: new and default * fix: review comments
This commit is contained in:
parent
0fda14263a
commit
03d64d0675
14 changed files with 87 additions and 98 deletions
|
@ -114,6 +114,7 @@ pub trait GenericPathBuilder {
|
||||||
control_point3: &Point2D<f32>,
|
control_point3: &Point2D<f32>,
|
||||||
);
|
);
|
||||||
fn close(&mut self);
|
fn close(&mut self);
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn ellipse(
|
fn ellipse(
|
||||||
&mut self,
|
&mut self,
|
||||||
origin: Point2D<f32>,
|
origin: Point2D<f32>,
|
||||||
|
@ -195,6 +196,7 @@ impl<'a> PathBuilderRef<'a> {
|
||||||
.arc(center, radius, start_angle, end_angle, ccw);
|
.arc(center, radius, start_angle, end_angle, ccw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn ellipse(
|
pub fn ellipse(
|
||||||
&mut self,
|
&mut self,
|
||||||
center: &Point2D<f32>,
|
center: &Point2D<f32>,
|
||||||
|
@ -978,6 +980,7 @@ impl<'a> CanvasData<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn ellipse(
|
pub fn ellipse(
|
||||||
&mut self,
|
&mut self,
|
||||||
center: &Point2D<f32>,
|
center: &Point2D<f32>,
|
||||||
|
|
|
@ -670,7 +670,7 @@ impl GenericDrawTarget for raqote::DrawTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Filter {
|
impl Filter {
|
||||||
fn to_raqote(&self) -> raqote::FilterMode {
|
fn to_raqote(self) -> raqote::FilterMode {
|
||||||
match self {
|
match self {
|
||||||
Filter::Bilinear => raqote::FilterMode::Bilinear,
|
Filter::Bilinear => raqote::FilterMode::Bilinear,
|
||||||
Filter::Nearest => raqote::FilterMode::Nearest,
|
Filter::Nearest => raqote::FilterMode::Nearest,
|
||||||
|
@ -847,7 +847,7 @@ pub trait ToRaqotePattern<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ToRaqoteGradientStop {
|
pub trait ToRaqoteGradientStop {
|
||||||
fn to_raqote(&self) -> raqote::GradientStop;
|
fn to_raqote(self) -> raqote::GradientStop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clamp a 0..1 number to a 0..255 range to u8.
|
/// Clamp a 0..1 number to a 0..255 range to u8.
|
||||||
|
@ -878,7 +878,7 @@ pub fn clamp_floor_256_f32(val: f32) -> u8 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToRaqoteGradientStop for CanvasGradientStop {
|
impl ToRaqoteGradientStop for CanvasGradientStop {
|
||||||
fn to_raqote(&self) -> raqote::GradientStop {
|
fn to_raqote(self) -> raqote::GradientStop {
|
||||||
let color = raqote::Color::new(
|
let color = raqote::Color::new(
|
||||||
self.color.alpha.map(clamp_unit_f32).unwrap_or(0),
|
self.color.alpha.map(clamp_unit_f32).unwrap_or(0),
|
||||||
self.color.red.unwrap_or(0),
|
self.color.red.unwrap_or(0),
|
||||||
|
@ -890,7 +890,7 @@ impl ToRaqoteGradientStop for CanvasGradientStop {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ToRaqotePattern<'_> for FillOrStrokeStyle {
|
impl ToRaqotePattern<'_> for FillOrStrokeStyle {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn to_raqote_pattern(self) -> Option<Pattern<'static>> {
|
fn to_raqote_pattern(self) -> Option<Pattern<'static>> {
|
||||||
use canvas_traits::canvas::FillOrStrokeStyle::*;
|
use canvas_traits::canvas::FillOrStrokeStyle::*;
|
||||||
|
|
|
@ -2514,8 +2514,8 @@ fn to_name_in_compiled_shader(s: &str) -> String {
|
||||||
|
|
||||||
fn from_name_in_compiled_shader(s: &str) -> String {
|
fn from_name_in_compiled_shader(s: &str) -> String {
|
||||||
map_dot_separated(s, |s, mapped| {
|
map_dot_separated(s, |s, mapped| {
|
||||||
mapped.push_str(if s.starts_with(ANGLE_NAME_PREFIX) {
|
mapped.push_str(if let Some(stripped) = s.strip_prefix(ANGLE_NAME_PREFIX) {
|
||||||
&s[ANGLE_NAME_PREFIX.len()..]
|
stripped
|
||||||
} else {
|
} else {
|
||||||
s
|
s
|
||||||
})
|
})
|
||||||
|
@ -2533,6 +2533,7 @@ fn map_dot_separated<F: Fn(&str, &mut String)>(s: &str, f: F) -> String {
|
||||||
mapped
|
mapped
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn prepare_pixels(
|
fn prepare_pixels(
|
||||||
internal_format: TexFormat,
|
internal_format: TexFormat,
|
||||||
data_type: TexDataType,
|
data_type: TexDataType,
|
||||||
|
@ -3100,7 +3101,8 @@ impl WebXRBridge {
|
||||||
contexts: &mut dyn WebXRContexts<WebXRSurfman>,
|
contexts: &mut dyn WebXRContexts<WebXRSurfman>,
|
||||||
context_id: WebXRContextId,
|
context_id: WebXRContextId,
|
||||||
) {
|
) {
|
||||||
for (_, manager) in &mut self.managers {
|
for manager in self.managers.values_mut() {
|
||||||
|
#[allow(clippy::unnecessary_to_owned)] // Needs mutable borrow later in destroy
|
||||||
for (other_id, layer_id) in manager.layers().to_vec() {
|
for (other_id, layer_id) in manager.layers().to_vec() {
|
||||||
if other_id == context_id {
|
if other_id == context_id {
|
||||||
manager.destroy_layer(device, contexts, context_id, layer_id);
|
manager.destroy_layer(device, contexts, context_id, layer_id);
|
||||||
|
|
|
@ -42,7 +42,6 @@ use script_traits::{
|
||||||
};
|
};
|
||||||
use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength};
|
use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength};
|
||||||
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
|
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
|
||||||
use webrender;
|
|
||||||
use webrender::{CaptureBits, RenderApi, Transaction};
|
use webrender::{CaptureBits, RenderApi, Transaction};
|
||||||
use webrender_api::units::{
|
use webrender_api::units::{
|
||||||
DeviceIntPoint, DeviceIntSize, DevicePoint, LayoutPoint, LayoutRect, LayoutSize,
|
DeviceIntPoint, DeviceIntSize, DevicePoint, LayoutPoint, LayoutRect, LayoutSize,
|
||||||
|
@ -79,6 +78,7 @@ const MAX_ZOOM: f32 = 8.0;
|
||||||
const MIN_ZOOM: f32 = 0.1;
|
const MIN_ZOOM: f32 = 0.1;
|
||||||
|
|
||||||
trait ConvertPipelineIdFromWebRender {
|
trait ConvertPipelineIdFromWebRender {
|
||||||
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_webrender(&self) -> PipelineId;
|
fn from_webrender(&self) -> PipelineId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,10 +919,9 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pipeline_details(&mut self, pipeline_id: PipelineId) -> &mut PipelineDetails {
|
fn pipeline_details(&mut self, pipeline_id: PipelineId) -> &mut PipelineDetails {
|
||||||
if !self.pipeline_details.contains_key(&pipeline_id) {
|
|
||||||
self.pipeline_details
|
self.pipeline_details
|
||||||
.insert(pipeline_id, PipelineDetails::new());
|
.entry(pipeline_id)
|
||||||
}
|
.or_insert_with(PipelineDetails::new);
|
||||||
self.pipeline_details
|
self.pipeline_details
|
||||||
.get_mut(&pipeline_id)
|
.get_mut(&pipeline_id)
|
||||||
.expect("Insert then get failed!")
|
.expect("Insert then get failed!")
|
||||||
|
@ -930,7 +929,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
|
|
||||||
pub fn pipeline(&self, pipeline_id: PipelineId) -> Option<&CompositionPipeline> {
|
pub fn pipeline(&self, pipeline_id: PipelineId) -> Option<&CompositionPipeline> {
|
||||||
match self.pipeline_details.get(&pipeline_id) {
|
match self.pipeline_details.get(&pipeline_id) {
|
||||||
Some(ref details) => details.pipeline.as_ref(),
|
Some(details) => details.pipeline.as_ref(),
|
||||||
None => {
|
None => {
|
||||||
warn!(
|
warn!(
|
||||||
"Compositor layer has an unknown pipeline ({:?}).",
|
"Compositor layer has an unknown pipeline ({:?}).",
|
||||||
|
@ -1021,8 +1020,8 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
self.webrender_api
|
self.webrender_api
|
||||||
.send_transaction(self.webrender_document, txn);
|
.send_transaction(self.webrender_document, txn);
|
||||||
|
|
||||||
self.create_pipeline_details_for_frame_tree(&frame_tree);
|
self.create_pipeline_details_for_frame_tree(frame_tree);
|
||||||
self.reset_scroll_tree_for_unattached_pipelines(&frame_tree);
|
self.reset_scroll_tree_for_unattached_pipelines(frame_tree);
|
||||||
|
|
||||||
self.frame_tree_id.next();
|
self.frame_tree_id.next();
|
||||||
}
|
}
|
||||||
|
@ -1081,7 +1080,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
|
|
||||||
let data = WindowSizeData {
|
let data = WindowSizeData {
|
||||||
device_pixel_ratio: dppx,
|
device_pixel_ratio: dppx,
|
||||||
initial_viewport: initial_viewport,
|
initial_viewport,
|
||||||
};
|
};
|
||||||
|
|
||||||
let top_level_browsing_context_id =
|
let top_level_browsing_context_id =
|
||||||
|
@ -1118,7 +1117,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
|
|
||||||
self.send_window_size(WindowSizeType::Resize);
|
self.send_window_size(WindowSizeType::Resize);
|
||||||
self.composite_if_necessary(CompositingReason::Resize);
|
self.composite_if_necessary(CompositingReason::Resize);
|
||||||
return true;
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_mouse_window_event_class(&mut self, mouse_window_event: MouseWindowEvent) {
|
pub fn on_mouse_window_event_class(&mut self, mouse_window_event: MouseWindowEvent) {
|
||||||
|
@ -1171,7 +1170,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
let dppx = self.page_zoom * self.hidpi_factor();
|
let dppx = self.page_zoom * self.hidpi_factor();
|
||||||
let scaled_point = (point / dppx).to_untyped();
|
let scaled_point = (point / dppx).to_untyped();
|
||||||
let world_point = WorldPoint::from_untyped(scaled_point);
|
let world_point = WorldPoint::from_untyped(scaled_point);
|
||||||
return self.hit_test_at_point(world_point);
|
self.hit_test_at_point(world_point)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hit_test_at_point(&self, point: WorldPoint) -> Option<CompositorHitTestResult> {
|
fn hit_test_at_point(&self, point: WorldPoint) -> Option<CompositorHitTestResult> {
|
||||||
|
@ -1320,7 +1319,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
scroll_location: ScrollLocation::Delta(LayoutVector2D::from_untyped(
|
scroll_location: ScrollLocation::Delta(LayoutVector2D::from_untyped(
|
||||||
scroll_delta.to_untyped(),
|
scroll_delta.to_untyped(),
|
||||||
)),
|
)),
|
||||||
cursor: cursor,
|
cursor,
|
||||||
event_count: 1,
|
event_count: 1,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
@ -1378,7 +1377,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
fn on_scroll_window_event(&mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint) {
|
fn on_scroll_window_event(&mut self, scroll_location: ScrollLocation, cursor: DeviceIntPoint) {
|
||||||
self.pending_scroll_zoom_events
|
self.pending_scroll_zoom_events
|
||||||
.push(ScrollZoomEvent::Scroll(ScrollEvent {
|
.push(ScrollZoomEvent::Scroll(ScrollEvent {
|
||||||
scroll_location: scroll_location,
|
scroll_location,
|
||||||
cursor,
|
cursor,
|
||||||
event_count: 1,
|
event_count: 1,
|
||||||
}));
|
}));
|
||||||
|
@ -1603,21 +1602,18 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_scroll_positions_to_layout_for_pipeline(&self, pipeline_id: &PipelineId) {
|
fn send_scroll_positions_to_layout_for_pipeline(&self, pipeline_id: &PipelineId) {
|
||||||
let details = match self.pipeline_details.get(&pipeline_id) {
|
let details = match self.pipeline_details.get(pipeline_id) {
|
||||||
Some(details) => details,
|
Some(details) => details,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut scroll_states = Vec::new();
|
let mut scroll_states = Vec::new();
|
||||||
details.scroll_tree.nodes.iter().for_each(|node| {
|
details.scroll_tree.nodes.iter().for_each(|node| {
|
||||||
match (node.external_id(), node.offset()) {
|
if let (Some(scroll_id), Some(scroll_offset)) = (node.external_id(), node.offset()) {
|
||||||
(Some(scroll_id), Some(scroll_offset)) => {
|
|
||||||
scroll_states.push(ScrollState {
|
scroll_states.push(ScrollState {
|
||||||
scroll_id,
|
scroll_id,
|
||||||
scroll_offset,
|
scroll_offset,
|
||||||
});
|
});
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1632,7 +1628,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
|
|
||||||
// Check if any pipelines currently have active animations or animation callbacks.
|
// Check if any pipelines currently have active animations or animation callbacks.
|
||||||
fn animations_active(&self) -> bool {
|
fn animations_active(&self) -> bool {
|
||||||
for (_, details) in &self.pipeline_details {
|
for details in self.pipeline_details.values() {
|
||||||
// If animations are currently running, then don't bother checking
|
// If animations are currently running, then don't bother checking
|
||||||
// with the constellation if the output image is stable.
|
// with the constellation if the output image is stable.
|
||||||
if details.animations_running {
|
if details.animations_running {
|
||||||
|
@ -1666,7 +1662,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
// This gets sent to the constellation for comparison with the current
|
// This gets sent to the constellation for comparison with the current
|
||||||
// frame tree.
|
// frame tree.
|
||||||
let mut pipeline_epochs = HashMap::new();
|
let mut pipeline_epochs = HashMap::new();
|
||||||
for (id, _) in &self.pipeline_details {
|
for id in self.pipeline_details.keys() {
|
||||||
let webrender_pipeline_id = id.to_webrender();
|
let webrender_pipeline_id = id.to_webrender();
|
||||||
if let Some(WebRenderEpoch(epoch)) = self
|
if let Some(WebRenderEpoch(epoch)) = self
|
||||||
.webrender
|
.webrender
|
||||||
|
@ -1830,7 +1826,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// in which case, we remove it from the list of pending metrics,
|
// in which case, we remove it from the list of pending metrics,
|
||||||
to_remove.push(id.clone());
|
to_remove.push(*id);
|
||||||
if let Some(pipeline) = self.pipeline(*id) {
|
if let Some(pipeline) = self.pipeline(*id) {
|
||||||
// and inform layout with the measured paint time.
|
// and inform layout with the measured paint time.
|
||||||
let message = LayoutControlMsg::PaintMetric(epoch, paint_time);
|
let message = LayoutControlMsg::PaintMetric(epoch, paint_time);
|
||||||
|
@ -1897,7 +1893,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
width: img.width(),
|
width: img.width(),
|
||||||
height: img.height(),
|
height: img.height(),
|
||||||
format: PixelFormat::RGB8,
|
format: PixelFormat::RGB8,
|
||||||
bytes: ipc::IpcSharedMemory::from_bytes(&*img),
|
bytes: ipc::IpcSharedMemory::from_bytes(&img),
|
||||||
id: None,
|
id: None,
|
||||||
cors_status: CorsStatus::Safe,
|
cors_status: CorsStatus::Safe,
|
||||||
})
|
})
|
||||||
|
@ -2078,10 +2074,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
pub fn repaint_synchronously(&mut self) {
|
pub fn repaint_synchronously(&mut self) {
|
||||||
while self.shutdown_state != ShutdownState::ShuttingDown {
|
while self.shutdown_state != ShutdownState::ShuttingDown {
|
||||||
let msg = self.port.recv_compositor_msg();
|
let msg = self.port.recv_compositor_msg();
|
||||||
let need_recomposite = match msg {
|
let need_recomposite = matches!(msg, CompositorMsg::NewWebRenderFrameReady(_));
|
||||||
CompositorMsg::NewWebRenderFrameReady(_) => true,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
let keep_going = self.handle_browser_message(msg);
|
let keep_going = self.handle_browser_message(msg);
|
||||||
if need_recomposite {
|
if need_recomposite {
|
||||||
self.composite();
|
self.composite();
|
||||||
|
@ -2142,7 +2135,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
.map(|dir| dir.join("capture_webrender").join(&capture_id))
|
.map(|dir| dir.join("capture_webrender").join(&capture_id))
|
||||||
.ok()
|
.ok()
|
||||||
})
|
})
|
||||||
.find(|val| match create_dir_all(&val) {
|
.find(|val| match create_dir_all(val) {
|
||||||
Ok(_) => true,
|
Ok(_) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Unable to create path '{:?}' for capture: {:?}", &val, err);
|
eprintln!("Unable to create path '{:?}' for capture: {:?}", &val, err);
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl RenderTargetInfo {
|
||||||
let dst_start = y * stride;
|
let dst_start = y * stride;
|
||||||
let src_start = (height - y - 1) * stride;
|
let src_start = (height - y - 1) * stride;
|
||||||
let src_slice = &orig_pixels[src_start..src_start + stride];
|
let src_slice = &orig_pixels[src_start..src_start + stride];
|
||||||
(&mut pixels[dst_start..dst_start + stride]).clone_from_slice(&src_slice[..stride]);
|
pixels[dst_start..dst_start + stride].clone_from_slice(&src_slice[..stride]);
|
||||||
}
|
}
|
||||||
|
|
||||||
RgbImage::from_raw(width as u32, height as u32, pixels).expect("Flipping image failed!")
|
RgbImage::from_raw(width as u32, height as u32, pixels).expect("Flipping image failed!")
|
||||||
|
|
|
@ -25,10 +25,7 @@ pub struct TouchPoint {
|
||||||
|
|
||||||
impl TouchPoint {
|
impl TouchPoint {
|
||||||
pub fn new(id: TouchId, point: Point2D<f32, DevicePixel>) -> Self {
|
pub fn new(id: TouchId, point: Point2D<f32, DevicePixel>) -> Self {
|
||||||
TouchPoint {
|
TouchPoint { id, point }
|
||||||
id: id,
|
|
||||||
point: point,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,7 @@ impl EmbedderCoordinates {
|
||||||
/// to the framebuffer with OpenGL commands.
|
/// to the framebuffer with OpenGL commands.
|
||||||
pub fn get_flipped_viewport(&self) -> DeviceIntRect {
|
pub fn get_flipped_viewport(&self) -> DeviceIntRect {
|
||||||
let fb_height = self.framebuffer.height;
|
let fb_height = self.framebuffer.height;
|
||||||
let mut view = self.viewport.clone();
|
let mut view = self.viewport;
|
||||||
view.origin.y = fb_height - view.origin.y - view.size.height;
|
view.origin.y = fb_height - view.origin.y - view.size.height;
|
||||||
DeviceIntRect::from_untyped(&view.to_untyped())
|
DeviceIntRect::from_untyped(&view.to_untyped())
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ use crate::pipeline::UnprivilegedPipelineContent;
|
||||||
use crate::serviceworker::ServiceWorkerUnprivilegedContent;
|
use crate::serviceworker::ServiceWorkerUnprivilegedContent;
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum UnprivilegedContent {
|
pub enum UnprivilegedContent {
|
||||||
Pipeline(UnprivilegedPipelineContent),
|
Pipeline(UnprivilegedPipelineContent),
|
||||||
ServiceWorker(ServiceWorkerUnprivilegedContent),
|
ServiceWorker(ServiceWorkerUnprivilegedContent),
|
||||||
|
|
|
@ -521,7 +521,7 @@ impl FontCacheThread {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut number_loading = 0;
|
let mut number_loading = 0;
|
||||||
stylesheet.effective_font_face_rules(&device, guard, |rule| {
|
stylesheet.effective_font_face_rules(device, guard, |rule| {
|
||||||
let font_face = match rule.font_face() {
|
let font_face = match rule.font_face() {
|
||||||
Some(font_face) => font_face,
|
Some(font_face) => font_face,
|
||||||
None => return,
|
None => return,
|
||||||
|
|
|
@ -75,13 +75,7 @@ fn set_metric<U: ProgressiveWebMetric>(
|
||||||
pwm.send_queued_constellation_msg(metric_type, time);
|
pwm.send_queued_constellation_msg(metric_type, time);
|
||||||
|
|
||||||
// Send the metric to the time profiler.
|
// Send the metric to the time profiler.
|
||||||
send_profile_data(
|
send_profile_data(category, metadata, pwm.get_time_profiler_chan(), time, time);
|
||||||
category,
|
|
||||||
metadata,
|
|
||||||
&pwm.get_time_profiler_chan(),
|
|
||||||
time,
|
|
||||||
time,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Print the metric to console if the print-pwm option was given.
|
// Print the metric to console if the print-pwm option was given.
|
||||||
if opts::get().print_pwm {
|
if opts::get().print_pwm {
|
||||||
|
@ -119,13 +113,15 @@ pub struct InteractiveWindow {
|
||||||
start: SystemTime,
|
start: SystemTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InteractiveWindow {
|
impl Default for InteractiveWindow {
|
||||||
pub fn new() -> InteractiveWindow {
|
fn default() -> Self {
|
||||||
InteractiveWindow {
|
Self {
|
||||||
start: SystemTime::now(),
|
start: SystemTime::now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl InteractiveWindow {
|
||||||
// We need to either start or restart the 10s window
|
// We need to either start or restart the 10s window
|
||||||
// start: we've added a new document
|
// start: we've added a new document
|
||||||
// restart: there was a task > 50ms
|
// restart: there was a task > 50ms
|
||||||
|
@ -163,7 +159,7 @@ impl InteractiveMetrics {
|
||||||
dom_content_loaded: Cell::new(None),
|
dom_content_loaded: Cell::new(None),
|
||||||
main_thread_available: Cell::new(None),
|
main_thread_available: Cell::new(None),
|
||||||
time_to_interactive: Cell::new(None),
|
time_to_interactive: Cell::new(None),
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan,
|
||||||
url,
|
url,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3200,7 +3200,7 @@ impl Document {
|
||||||
fullscreen_element: MutNullableDom::new(None),
|
fullscreen_element: MutNullableDom::new(None),
|
||||||
form_id_listener_map: Default::default(),
|
form_id_listener_map: Default::default(),
|
||||||
interactive_time: DomRefCell::new(interactive_time),
|
interactive_time: DomRefCell::new(interactive_time),
|
||||||
tti_window: DomRefCell::new(InteractiveWindow::new()),
|
tti_window: DomRefCell::new(InteractiveWindow::default()),
|
||||||
canceller: canceller,
|
canceller: canceller,
|
||||||
throw_on_dynamic_markup_insertion_counter: Cell::new(0),
|
throw_on_dynamic_markup_insertion_counter: Cell::new(0),
|
||||||
page_showing: Cell::new(false),
|
page_showing: Cell::new(false),
|
||||||
|
|
|
@ -101,8 +101,8 @@ impl Handler {
|
||||||
actions_by_tick: &[ActionSequence],
|
actions_by_tick: &[ActionSequence],
|
||||||
) -> Result<(), ErrorStatus> {
|
) -> Result<(), ErrorStatus> {
|
||||||
for tick_actions in actions_by_tick.iter() {
|
for tick_actions in actions_by_tick.iter() {
|
||||||
let tick_duration = compute_tick_duration(&tick_actions);
|
let tick_duration = compute_tick_duration(tick_actions);
|
||||||
self.dispatch_tick_actions(&tick_actions, tick_duration)?;
|
self.dispatch_tick_actions(tick_actions, tick_duration)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -144,10 +144,10 @@ impl Handler {
|
||||||
.or_insert(InputSourceState::Key(KeyInputState::new()));
|
.or_insert(InputSourceState::Key(KeyInputState::new()));
|
||||||
match action {
|
match action {
|
||||||
KeyAction::Down(action) => {
|
KeyAction::Down(action) => {
|
||||||
self.dispatch_keydown_action(&source_id, &action)
|
self.dispatch_keydown_action(source_id, action)
|
||||||
},
|
},
|
||||||
KeyAction::Up(action) => {
|
KeyAction::Up(action) => {
|
||||||
self.dispatch_keyup_action(&source_id, &action)
|
self.dispatch_keyup_action(source_id, action)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -174,15 +174,15 @@ impl Handler {
|
||||||
match action {
|
match action {
|
||||||
PointerAction::Cancel => (),
|
PointerAction::Cancel => (),
|
||||||
PointerAction::Down(action) => {
|
PointerAction::Down(action) => {
|
||||||
self.dispatch_pointerdown_action(&source_id, &action)
|
self.dispatch_pointerdown_action(source_id, action)
|
||||||
},
|
},
|
||||||
PointerAction::Move(action) => self.dispatch_pointermove_action(
|
PointerAction::Move(action) => self.dispatch_pointermove_action(
|
||||||
&source_id,
|
source_id,
|
||||||
&action,
|
action,
|
||||||
tick_duration,
|
tick_duration,
|
||||||
)?,
|
)?,
|
||||||
PointerAction::Up(action) => {
|
PointerAction::Up(action) => {
|
||||||
self.dispatch_pointerup_action(&source_id, &action)
|
self.dispatch_pointerup_action(source_id, action)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -435,6 +435,7 @@ impl Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/webdriver/#dfn-perform-a-pointer-move
|
// https://w3c.github.io/webdriver/#dfn-perform-a-pointer-move
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn perform_pointer_move(
|
fn perform_pointer_move(
|
||||||
&mut self,
|
&mut self,
|
||||||
source_id: &str,
|
source_id: &str,
|
||||||
|
@ -470,11 +471,7 @@ impl Handler {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
let last = if 1.0 - duration_ratio < 0.001 {
|
let last = 1.0 - duration_ratio < 0.001;
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
let (x, y) = if last {
|
let (x, y) = if last {
|
||||||
|
|
|
@ -67,7 +67,7 @@ use webdriver::server::{self, Session, SessionTeardownKind, WebDriverHandler};
|
||||||
use crate::actions::{InputSourceState, PointerInputState};
|
use crate::actions::{InputSourceState, PointerInputState};
|
||||||
|
|
||||||
fn extension_routes() -> Vec<(Method, &'static str, ServoExtensionRoute)> {
|
fn extension_routes() -> Vec<(Method, &'static str, ServoExtensionRoute)> {
|
||||||
return vec![
|
vec![
|
||||||
(
|
(
|
||||||
Method::POST,
|
Method::POST,
|
||||||
"/session/{sessionId}/servo/prefs/get",
|
"/session/{sessionId}/servo/prefs/get",
|
||||||
|
@ -83,7 +83,7 @@ fn extension_routes() -> Vec<(Method, &'static str, ServoExtensionRoute)> {
|
||||||
"/session/{sessionId}/servo/prefs/reset",
|
"/session/{sessionId}/servo/prefs/reset",
|
||||||
ServoExtensionRoute::ResetPrefs,
|
ServoExtensionRoute::ResetPrefs,
|
||||||
),
|
),
|
||||||
];
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cookie_msg_to_cookie(cookie: cookie::Cookie) -> Cookie {
|
fn cookie_msg_to_cookie(cookie: cookie::Cookie) -> Cookie {
|
||||||
|
@ -157,8 +157,8 @@ impl WebDriverSession {
|
||||||
) -> WebDriverSession {
|
) -> WebDriverSession {
|
||||||
WebDriverSession {
|
WebDriverSession {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
browsing_context_id: browsing_context_id,
|
browsing_context_id,
|
||||||
top_level_browsing_context_id: top_level_browsing_context_id,
|
top_level_browsing_context_id,
|
||||||
|
|
||||||
script_timeout: Some(30_000),
|
script_timeout: Some(30_000),
|
||||||
load_timeout: 300_000,
|
load_timeout: 300_000,
|
||||||
|
@ -189,6 +189,7 @@ struct Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
enum ServoExtensionRoute {
|
enum ServoExtensionRoute {
|
||||||
GetPrefs,
|
GetPrefs,
|
||||||
SetPrefs,
|
SetPrefs,
|
||||||
|
@ -222,6 +223,7 @@ impl WebDriverExtensionRoute for ServoExtensionRoute {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
enum ServoExtensionCommand {
|
enum ServoExtensionCommand {
|
||||||
GetPrefs(GetPrefsParameters),
|
GetPrefs(GetPrefsParameters),
|
||||||
SetPrefs(SetPrefsParameters),
|
SetPrefs(SetPrefsParameters),
|
||||||
|
@ -251,7 +253,7 @@ impl Serialize for SendableWebDriverJSValue {
|
||||||
WebDriverJSValue::Null => serializer.serialize_unit(),
|
WebDriverJSValue::Null => serializer.serialize_unit(),
|
||||||
WebDriverJSValue::Boolean(x) => serializer.serialize_bool(x),
|
WebDriverJSValue::Boolean(x) => serializer.serialize_bool(x),
|
||||||
WebDriverJSValue::Number(x) => serializer.serialize_f64(x),
|
WebDriverJSValue::Number(x) => serializer.serialize_f64(x),
|
||||||
WebDriverJSValue::String(ref x) => serializer.serialize_str(&x),
|
WebDriverJSValue::String(ref x) => serializer.serialize_str(x),
|
||||||
WebDriverJSValue::Element(ref x) => x.serialize(serializer),
|
WebDriverJSValue::Element(ref x) => x.serialize(serializer),
|
||||||
WebDriverJSValue::Frame(ref x) => x.serialize(serializer),
|
WebDriverJSValue::Frame(ref x) => x.serialize(serializer),
|
||||||
WebDriverJSValue::Window(ref x) => x.serialize(serializer),
|
WebDriverJSValue::Window(ref x) => x.serialize(serializer),
|
||||||
|
@ -279,7 +281,7 @@ impl Serialize for WebDriverPrefValue {
|
||||||
{
|
{
|
||||||
match self.0 {
|
match self.0 {
|
||||||
PrefValue::Bool(b) => serializer.serialize_bool(b),
|
PrefValue::Bool(b) => serializer.serialize_bool(b),
|
||||||
PrefValue::Str(ref s) => serializer.serialize_str(&s),
|
PrefValue::Str(ref s) => serializer.serialize_str(s),
|
||||||
PrefValue::Float(f) => serializer.serialize_f64(f),
|
PrefValue::Float(f) => serializer.serialize_f64(f),
|
||||||
PrefValue::Int(i) => serializer.serialize_i64(i),
|
PrefValue::Int(i) => serializer.serialize_i64(i),
|
||||||
PrefValue::Missing => serializer.serialize_unit(),
|
PrefValue::Missing => serializer.serialize_unit(),
|
||||||
|
@ -407,7 +409,7 @@ impl Handler {
|
||||||
load_status_sender,
|
load_status_sender,
|
||||||
load_status_receiver,
|
load_status_receiver,
|
||||||
session: None,
|
session: None,
|
||||||
constellation_chan: constellation_chan,
|
constellation_chan,
|
||||||
resize_timeout: 500,
|
resize_timeout: 500,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -713,14 +715,8 @@ impl Handler {
|
||||||
params: &WindowRectParameters,
|
params: &WindowRectParameters,
|
||||||
) -> WebDriverResult<WebDriverResponse> {
|
) -> WebDriverResult<WebDriverResponse> {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
let width = match params.width {
|
let width = params.width.unwrap_or(0);
|
||||||
Some(v) => v,
|
let height = params.height.unwrap_or(0);
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
let height = match params.height {
|
|
||||||
Some(v) => v,
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
let size = Size2D::new(width as u32, height as u32);
|
let size = Size2D::new(width as u32, height as u32);
|
||||||
let top_level_browsing_context_id = self.session()?.top_level_browsing_context_id;
|
let top_level_browsing_context_id = self.session()?.top_level_browsing_context_id;
|
||||||
let cmd_msg = WebDriverCommandMsg::SetWindowSize(
|
let cmd_msg = WebDriverCommandMsg::SetWindowSize(
|
||||||
|
@ -1368,7 +1364,7 @@ impl Handler {
|
||||||
let input_cancel_list = {
|
let input_cancel_list = {
|
||||||
let session = self.session_mut()?;
|
let session = self.session_mut()?;
|
||||||
session.input_cancel_list.reverse();
|
session.input_cancel_list.reverse();
|
||||||
mem::replace(&mut session.input_cancel_list, Vec::new())
|
mem::take(&mut session.input_cancel_list)
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(error) = self.dispatch_actions(&input_cancel_list) {
|
if let Err(error) = self.dispatch_actions(&input_cancel_list) {
|
||||||
|
@ -1471,7 +1467,7 @@ impl Handler {
|
||||||
receiver
|
receiver
|
||||||
.recv()
|
.recv()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.or_else(|error| Err(WebDriverError::new(error, "")))?;
|
.map_err(|error| WebDriverError::new(error, ""))?;
|
||||||
|
|
||||||
let input_events = send_keys(&keys.text);
|
let input_events = send_keys(&keys.text);
|
||||||
|
|
||||||
|
@ -1629,12 +1625,10 @@ impl Handler {
|
||||||
serde_json::to_value(encoded)?,
|
serde_json::to_value(encoded)?,
|
||||||
)))
|
)))
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => Err(WebDriverError::new(
|
||||||
return Err(WebDriverError::new(
|
|
||||||
ErrorStatus::StaleElementReference,
|
ErrorStatus::StaleElementReference,
|
||||||
"Element not found",
|
"Element not found",
|
||||||
));
|
)),
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1662,7 +1656,7 @@ impl Handler {
|
||||||
&self,
|
&self,
|
||||||
parameters: &SetPrefsParameters,
|
parameters: &SetPrefsParameters,
|
||||||
) -> WebDriverResult<WebDriverResponse> {
|
) -> WebDriverResult<WebDriverResponse> {
|
||||||
for &(ref key, ref value) in parameters.prefs.iter() {
|
for (key, value) in parameters.prefs.iter() {
|
||||||
prefs::pref_map()
|
prefs::pref_map()
|
||||||
.set(key, value.0.clone())
|
.set(key, value.0.clone())
|
||||||
.expect("Failed to set preference");
|
.expect("Failed to set preference");
|
||||||
|
@ -1674,7 +1668,7 @@ impl Handler {
|
||||||
&self,
|
&self,
|
||||||
parameters: &GetPrefsParameters,
|
parameters: &GetPrefsParameters,
|
||||||
) -> WebDriverResult<WebDriverResponse> {
|
) -> WebDriverResult<WebDriverResponse> {
|
||||||
let prefs = if parameters.prefs.len() == 0 {
|
let prefs = if parameters.prefs.is_empty() {
|
||||||
prefs::pref_map().reset_all();
|
prefs::pref_map().reset_all();
|
||||||
BTreeMap::new()
|
BTreeMap::new()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -54,6 +54,7 @@ const DEVICE_POLL_INTERVAL: u64 = 100;
|
||||||
pub const PRESENTATION_BUFFER_COUNT: usize = 10;
|
pub const PRESENTATION_BUFFER_COUNT: usize = 10;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum WebGPUResponse {
|
pub enum WebGPUResponse {
|
||||||
RequestAdapter {
|
RequestAdapter {
|
||||||
adapter_info: wgt::AdapterInfo,
|
adapter_info: wgt::AdapterInfo,
|
||||||
|
@ -330,6 +331,12 @@ impl WebGPU {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WebGPUBufferMaps<'a> =
|
||||||
|
HashMap<id::BufferId, Rc<BufferMapInfo<'a, Option<WebGPUResponseResult>>>>;
|
||||||
|
type WebGPUPresentBufferMaps<'a> =
|
||||||
|
HashMap<id::BufferId, Rc<BufferMapInfo<'a, (Option<ErrorScopeId>, WebGPURequest)>>>;
|
||||||
|
|
||||||
|
#[allow(clippy::upper_case_acronyms)] // Name of the library
|
||||||
struct WGPU<'a> {
|
struct WGPU<'a> {
|
||||||
receiver: IpcReceiver<(Option<ErrorScopeId>, WebGPURequest)>,
|
receiver: IpcReceiver<(Option<ErrorScopeId>, WebGPURequest)>,
|
||||||
sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
|
sender: IpcSender<(Option<ErrorScopeId>, WebGPURequest)>,
|
||||||
|
@ -340,10 +347,9 @@ struct WGPU<'a> {
|
||||||
// Track invalid adapters https://gpuweb.github.io/gpuweb/#invalid
|
// Track invalid adapters https://gpuweb.github.io/gpuweb/#invalid
|
||||||
_invalid_adapters: Vec<WebGPUAdapter>,
|
_invalid_adapters: Vec<WebGPUAdapter>,
|
||||||
// Buffers with pending mapping
|
// Buffers with pending mapping
|
||||||
buffer_maps: HashMap<id::BufferId, Rc<BufferMapInfo<'a, Option<WebGPUResponseResult>>>>,
|
buffer_maps: WebGPUBufferMaps<'a>,
|
||||||
// Presentation Buffers with pending mapping
|
// Presentation Buffers with pending mapping
|
||||||
present_buffer_maps:
|
present_buffer_maps: WebGPUPresentBufferMaps<'a>,
|
||||||
HashMap<id::BufferId, Rc<BufferMapInfo<'a, (Option<ErrorScopeId>, WebGPURequest)>>>,
|
|
||||||
//TODO: Remove this (https://github.com/gfx-rs/wgpu/issues/867)
|
//TODO: Remove this (https://github.com/gfx-rs/wgpu/issues/867)
|
||||||
error_command_encoders: RefCell<HashMap<id::CommandEncoderId, String>>,
|
error_command_encoders: RefCell<HashMap<id::CommandEncoderId, String>>,
|
||||||
webrender_api: RenderApi,
|
webrender_api: RenderApi,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue