Skip to content
Permalink
Browse files

Remove unnecessary layers of casting from embedding event API.

  • Loading branch information...
jdm committed Jan 22, 2019
1 parent 256011a commit 981f7414ec4820a7c48ce43f2260040d93110c04
@@ -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)
}
@@ -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());
@@ -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 {

0 comments on commit 981f741

Please sign in to comment.
You can’t perform that action at this time.