From 981f7414ec4820a7c48ce43f2260040d93110c04 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Tue, 22 Jan 2019 13:41:21 -0500 Subject: [PATCH] Remove unnecessary layers of casting from embedding event API. --- ports/libsimpleservo/api/src/lib.rs | 22 +++++++++++----------- ports/libsimpleservo/capi/src/lib.rs | 8 ++++---- ports/libsimpleservo/jniapi/src/lib.rs | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ports/libsimpleservo/api/src/lib.rs b/ports/libsimpleservo/api/src/lib.rs index 5dc19e98329..84bb431b43f 100644 --- a/ports/libsimpleservo/api/src/lib.rs +++ b/ports/libsimpleservo/api/src/lib.rs @@ -277,12 +277,12 @@ impl ServoGlue { /// Start scrolling. /// x/y are scroll coordinates. /// dx/dy are scroll deltas. - pub fn scroll_start(&mut self, dx: i32, dy: i32, x: u32, y: u32) -> Result<(), &'static str> { - let delta = TypedVector2D::new(dx as f32, dy as f32); + pub fn scroll_start(&mut self, dx: f32, dy: f32, x: i32, y: i32) -> Result<(), &'static str> { + let delta = TypedVector2D::new(dx, dy); let scroll_location = webrender_api::ScrollLocation::Delta(delta); let event = WindowEvent::Scroll( scroll_location, - TypedPoint2D::new(x as i32, y as i32), + TypedPoint2D::new(x, y), TouchEventType::Down, ); self.process_event(event) @@ -291,12 +291,12 @@ impl ServoGlue { /// Scroll. /// x/y are scroll coordinates. /// dx/dy are scroll deltas. - pub fn scroll(&mut self, dx: i32, dy: i32, x: u32, y: u32) -> Result<(), &'static str> { - let delta = TypedVector2D::new(dx as f32, dy as f32); + pub fn scroll(&mut self, dx: f32, dy: f32, x: i32, y: i32) -> Result<(), &'static str> { + let delta = TypedVector2D::new(dx, dy); let scroll_location = webrender_api::ScrollLocation::Delta(delta); let event = WindowEvent::Scroll( scroll_location, - TypedPoint2D::new(x as i32, y as i32), + TypedPoint2D::new(x, y), TouchEventType::Move, ); self.process_event(event) @@ -305,12 +305,12 @@ impl ServoGlue { /// End scrolling. /// x/y are scroll coordinates. /// dx/dy are scroll deltas. - pub fn scroll_end(&mut self, dx: i32, dy: i32, x: u32, y: u32) -> Result<(), &'static str> { - let delta = TypedVector2D::new(dx as f32, dy as f32); + pub fn scroll_end(&mut self, dx: f32, dy: f32, x: i32, y: i32) -> Result<(), &'static str> { + let delta = TypedVector2D::new(dx, dy); let scroll_location = webrender_api::ScrollLocation::Delta(delta); let event = WindowEvent::Scroll( scroll_location, - TypedPoint2D::new(x as i32, y as i32), + TypedPoint2D::new(x, y), TouchEventType::Up, ); self.process_event(event) @@ -375,9 +375,9 @@ impl ServoGlue { } /// Perform a click. - pub fn click(&mut self, x: u32, y: u32) -> Result<(), &'static str> { + pub fn click(&mut self, x: f32, y: f32) -> Result<(), &'static str> { let mouse_event = - MouseWindowEvent::Click(MouseButton::Left, TypedPoint2D::new(x as f32, y as f32)); + MouseWindowEvent::Click(MouseButton::Left, TypedPoint2D::new(x, y)); let event = WindowEvent::MouseWindowEventClass(mouse_event); self.process_event(event) } diff --git a/ports/libsimpleservo/capi/src/lib.rs b/ports/libsimpleservo/capi/src/lib.rs index 0785f336e40..acbf2b0c440 100644 --- a/ports/libsimpleservo/capi/src/lib.rs +++ b/ports/libsimpleservo/capi/src/lib.rs @@ -192,19 +192,19 @@ pub extern "C" fn go_forward() { #[no_mangle] pub extern "C" fn scroll_start(dx: i32, dy: i32, x: i32, y: i32) { debug!("scroll_start"); - call(|s| s.scroll_start(dx as i32, dy as i32, x as u32, y as u32)); + call(|s| s.scroll_start(dx as f32, dy as f32, x, y)); } #[no_mangle] pub extern "C" fn scroll_end(dx: i32, dy: i32, x: i32, y: i32) { debug!("scroll_end"); - call(|s| s.scroll_end(dx as i32, dy as i32, x as u32, y as u32)); + call(|s| s.scroll_end(dx as f32, dy as f32, x, y)); } #[no_mangle] pub extern "C" fn scroll(dx: i32, dy: i32, x: i32, y: i32) { debug!("scroll"); - call(|s| s.scroll(dx as i32, dy as i32, x as u32, y as u32)); + call(|s| s.scroll(dx as f32, dy as f32, x, y)); } #[no_mangle] @@ -252,7 +252,7 @@ pub extern "C" fn pinchzoom_end(factor: f32, x: i32, y: i32) { #[no_mangle] pub extern "C" fn click(x: i32, y: i32) { debug!("click"); - call(|s| s.click(x as u32, y as u32)); + call(|s| s.click(x as f32, y as f32)); } pub struct WakeupCallback(extern "C" fn()); diff --git a/ports/libsimpleservo/jniapi/src/lib.rs b/ports/libsimpleservo/jniapi/src/lib.rs index b1b400b1443..aa52cfe49dd 100644 --- a/ports/libsimpleservo/jniapi/src/lib.rs +++ b/ports/libsimpleservo/jniapi/src/lib.rs @@ -200,7 +200,7 @@ pub fn Java_org_mozilla_servoview_JNIServo_scrollStart( ) { debug!("scrollStart"); call(&env, |s| { - s.scroll_start(dx as i32, dy as i32, x as u32, y as u32) + s.scroll_start(dx as f32, dy as f32, x as i32, y as i32) }); } @@ -215,7 +215,7 @@ pub fn Java_org_mozilla_servoview_JNIServo_scrollEnd( ) { debug!("scrollEnd"); call(&env, |s| { - s.scroll_end(dx as i32, dy as i32, x as u32, y as u32) + s.scroll_end(dx as f32, dy as f32, x as i32, y as i32) }); } @@ -229,7 +229,7 @@ pub fn Java_org_mozilla_servoview_JNIServo_scroll( y: jint, ) { debug!("scroll"); - call(&env, |s| s.scroll(dx as i32, dy as i32, x as u32, y as u32)); + call(&env, |s| s.scroll(dx as f32, dy as f32, x as i32, y as i32)); } #[no_mangle] @@ -321,7 +321,7 @@ pub fn Java_org_mozilla_servoview_JNIServo_pinchZoomEnd( #[no_mangle] pub fn Java_org_mozilla_servoview_JNIServo_click(env: JNIEnv, _: JClass, x: jint, y: jint) { debug!("click"); - call(&env, |s| s.click(x as u32, y as u32)); + call(&env, |s| s.click(x as f32, y as f32)); } pub struct WakeupCallback {