Skip to content

Commit

Permalink
Remove unnecessary layers of casting from embedding event API.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdm committed Mar 4, 2019
1 parent 256011a commit 981f741
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
22 changes: 11 additions & 11 deletions ports/libsimpleservo/api/src/lib.rs
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions ports/libsimpleservo/capi/src/lib.rs
Expand Up @@ -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]
Expand Down Expand Up @@ -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());
Expand Down
8 changes: 4 additions & 4 deletions ports/libsimpleservo/jniapi/src/lib.rs
Expand Up @@ -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)
});
}

Expand All @@ -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)
});
}

Expand All @@ -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]
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 981f741

Please sign in to comment.