mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Update euclid.
There are a few canvas2d-related dependencies that haven't updated, but they only use euclid internally so that's not blocking landing the rest of the changes. Given the size of this patch, I think it's useful to get this landed as-is.
This commit is contained in:
parent
2ff7cb5a37
commit
3d57c22e9c
133 changed files with 686 additions and 596 deletions
|
@ -49,7 +49,7 @@ backtrace = "0.3"
|
|||
bitflags = "1.0"
|
||||
clipboard = "0.5"
|
||||
crossbeam-channel = "0.3"
|
||||
euclid = "0.19"
|
||||
euclid = "0.20"
|
||||
gleam = "0.6"
|
||||
glutin = "0.21.0"
|
||||
keyboard-types = "0.4.3"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use crate::keyutils::{CMD_OR_ALT, CMD_OR_CONTROL};
|
||||
use crate::window_trait::{WindowPortsMethods, LINE_HEIGHT};
|
||||
use euclid::{TypedPoint2D, TypedVector2D};
|
||||
use euclid::{Point2D, Vector2D};
|
||||
use keyboard_types::{Key, KeyboardEvent, Modifiers, ShortcutMatcher};
|
||||
use servo::compositing::windowing::{WebRenderDebugOption, WindowEvent};
|
||||
use servo::embedder_traits::{EmbedderMsg, FilterPattern};
|
||||
|
@ -222,14 +222,14 @@ where
|
|||
self.event_queue.push(WindowEvent::ResetZoom)
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::PageDown, || {
|
||||
let scroll_location = ScrollLocation::Delta(TypedVector2D::new(
|
||||
let scroll_location = ScrollLocation::Delta(Vector2D::new(
|
||||
0.0,
|
||||
-self.window.page_height() + 2.0 * LINE_HEIGHT,
|
||||
));
|
||||
self.scroll_window_from_key(scroll_location, TouchEventType::Move);
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::PageUp, || {
|
||||
let scroll_location = ScrollLocation::Delta(TypedVector2D::new(
|
||||
let scroll_location = ScrollLocation::Delta(Vector2D::new(
|
||||
0.0,
|
||||
self.window.page_height() - 2.0 * LINE_HEIGHT,
|
||||
));
|
||||
|
@ -243,32 +243,32 @@ where
|
|||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowUp, || {
|
||||
self.scroll_window_from_key(
|
||||
ScrollLocation::Delta(TypedVector2D::new(0.0, 3.0 * LINE_HEIGHT)),
|
||||
ScrollLocation::Delta(Vector2D::new(0.0, 3.0 * LINE_HEIGHT)),
|
||||
TouchEventType::Move,
|
||||
);
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowDown, || {
|
||||
self.scroll_window_from_key(
|
||||
ScrollLocation::Delta(TypedVector2D::new(0.0, -3.0 * LINE_HEIGHT)),
|
||||
ScrollLocation::Delta(Vector2D::new(0.0, -3.0 * LINE_HEIGHT)),
|
||||
TouchEventType::Move,
|
||||
);
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowLeft, || {
|
||||
self.scroll_window_from_key(
|
||||
ScrollLocation::Delta(TypedVector2D::new(LINE_HEIGHT, 0.0)),
|
||||
ScrollLocation::Delta(Vector2D::new(LINE_HEIGHT, 0.0)),
|
||||
TouchEventType::Move,
|
||||
);
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowRight, || {
|
||||
self.scroll_window_from_key(
|
||||
ScrollLocation::Delta(TypedVector2D::new(-LINE_HEIGHT, 0.0)),
|
||||
ScrollLocation::Delta(Vector2D::new(-LINE_HEIGHT, 0.0)),
|
||||
TouchEventType::Move,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
fn scroll_window_from_key(&mut self, scroll_location: ScrollLocation, phase: TouchEventType) {
|
||||
let event = WindowEvent::Scroll(scroll_location, TypedPoint2D::zero(), phase);
|
||||
let event = WindowEvent::Scroll(scroll_location, Point2D::zero(), phase);
|
||||
self.event_queue.push(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::context::GlContext;
|
|||
use crate::events_loop::EventsLoop;
|
||||
use crate::keyutils::keyboard_event_from_winit;
|
||||
use crate::window_trait::{WindowPortsMethods, LINE_HEIGHT};
|
||||
use euclid::{Size2D, TypedPoint2D, TypedScale, TypedSize2D, TypedVector2D};
|
||||
use euclid::{default::Size2D as UntypedSize2D, Point2D, Scale, Size2D, Vector2D};
|
||||
use gleam::gl;
|
||||
use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
||||
#[cfg(target_os = "macos")]
|
||||
|
@ -57,13 +57,13 @@ fn builder_with_platform_options(builder: glutin::WindowBuilder) -> glutin::Wind
|
|||
pub struct Window {
|
||||
gl_context: RefCell<GlContext>,
|
||||
events_loop: Rc<RefCell<EventsLoop>>,
|
||||
screen_size: TypedSize2D<u32, DeviceIndependentPixel>,
|
||||
inner_size: Cell<TypedSize2D<u32, DeviceIndependentPixel>>,
|
||||
screen_size: Size2D<u32, DeviceIndependentPixel>,
|
||||
inner_size: Cell<Size2D<u32, DeviceIndependentPixel>>,
|
||||
mouse_down_button: Cell<Option<glutin::MouseButton>>,
|
||||
mouse_down_point: Cell<TypedPoint2D<i32, DevicePixel>>,
|
||||
mouse_down_point: Cell<Point2D<i32, DevicePixel>>,
|
||||
primary_monitor: glutin::MonitorId,
|
||||
event_queue: RefCell<Vec<WindowEvent>>,
|
||||
mouse_pos: Cell<TypedPoint2D<i32, DevicePixel>>,
|
||||
mouse_pos: Cell<Point2D<i32, DevicePixel>>,
|
||||
last_pressed: Cell<Option<KeyboardEvent>>,
|
||||
animation_state: Cell<AnimationState>,
|
||||
fullscreen: Cell<bool>,
|
||||
|
@ -71,20 +71,20 @@ pub struct Window {
|
|||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn window_creation_scale_factor() -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
TypedScale::new(1.0)
|
||||
fn window_creation_scale_factor() -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
Scale::new(1.0)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn window_creation_scale_factor() -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
fn window_creation_scale_factor() -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
let hdc = unsafe { winapi::um::winuser::GetDC(::std::ptr::null_mut()) };
|
||||
let ppi = unsafe { winapi::um::wingdi::GetDeviceCaps(hdc, winapi::um::wingdi::LOGPIXELSY) };
|
||||
TypedScale::new(ppi as f32 / 96.0)
|
||||
Scale::new(ppi as f32 / 96.0)
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub fn new(
|
||||
win_size: TypedSize2D<u32, DeviceIndependentPixel>,
|
||||
win_size: Size2D<u32, DeviceIndependentPixel>,
|
||||
sharing: Option<&GlContext>,
|
||||
events_loop: Rc<RefCell<EventsLoop>>,
|
||||
) -> Window {
|
||||
|
@ -139,13 +139,13 @@ impl Window {
|
|||
width: screen_width,
|
||||
height: screen_height,
|
||||
} = primary_monitor.get_dimensions();
|
||||
let screen_size = TypedSize2D::new(screen_width as u32, screen_height as u32);
|
||||
let screen_size = Size2D::new(screen_width as u32, screen_height as u32);
|
||||
// TODO(ajeffrey): can this fail?
|
||||
let LogicalSize { width, height } = context
|
||||
.window()
|
||||
.get_inner_size()
|
||||
.expect("Failed to get window inner size.");
|
||||
let inner_size = TypedSize2D::new(width as u32, height as u32);
|
||||
let inner_size = Size2D::new(width as u32, height as u32);
|
||||
|
||||
context.window().show();
|
||||
|
||||
|
@ -172,8 +172,8 @@ impl Window {
|
|||
events_loop,
|
||||
event_queue: RefCell::new(vec![]),
|
||||
mouse_down_button: Cell::new(None),
|
||||
mouse_down_point: Cell::new(TypedPoint2D::new(0, 0)),
|
||||
mouse_pos: Cell::new(TypedPoint2D::new(0, 0)),
|
||||
mouse_down_point: Cell::new(Point2D::new(0, 0)),
|
||||
mouse_pos: Cell::new(Point2D::new(0, 0)),
|
||||
last_pressed: Cell::new(None),
|
||||
gl: gl.clone(),
|
||||
animation_state: Cell::new(AnimationState::Idle),
|
||||
|
@ -233,7 +233,7 @@ impl Window {
|
|||
&self,
|
||||
button: glutin::MouseButton,
|
||||
action: glutin::ElementState,
|
||||
coords: TypedPoint2D<i32, DevicePixel>,
|
||||
coords: Point2D<i32, DevicePixel>,
|
||||
) {
|
||||
use servo::script_traits::MouseButton;
|
||||
|
||||
|
@ -271,15 +271,15 @@ impl Window {
|
|||
.push(WindowEvent::MouseWindowEventClass(event));
|
||||
}
|
||||
|
||||
fn device_hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
TypedScale::new(self.gl_context.borrow().window().get_hidpi_factor() as f32)
|
||||
fn device_hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
Scale::new(self.gl_context.borrow().window().get_hidpi_factor() as f32)
|
||||
}
|
||||
|
||||
fn servo_hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
fn servo_hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
match opts::get().device_pixels_per_px {
|
||||
Some(device_pixels_per_px) => TypedScale::new(device_pixels_per_px),
|
||||
Some(device_pixels_per_px) => Scale::new(device_pixels_per_px),
|
||||
_ => match opts::get().output_file {
|
||||
Some(_) => TypedScale::new(1.0),
|
||||
Some(_) => Scale::new(1.0),
|
||||
None => self.device_hidpi_factor(),
|
||||
},
|
||||
}
|
||||
|
@ -397,10 +397,10 @@ impl WindowPortsMethods for Window {
|
|||
glutin::WindowEvent::CursorMoved { position, .. } => {
|
||||
let pos = position.to_physical(self.device_hidpi_factor().get() as f64);
|
||||
let (x, y): (i32, i32) = pos.into();
|
||||
self.mouse_pos.set(TypedPoint2D::new(x, y));
|
||||
self.mouse_pos.set(Point2D::new(x, y));
|
||||
self.event_queue
|
||||
.borrow_mut()
|
||||
.push(WindowEvent::MouseWindowMoveEventClass(TypedPoint2D::new(
|
||||
.push(WindowEvent::MouseWindowMoveEventClass(Point2D::new(
|
||||
x as f32, y as f32,
|
||||
)));
|
||||
},
|
||||
|
@ -418,7 +418,7 @@ impl WindowPortsMethods for Window {
|
|||
// Create wheel event before snapping to the major axis of movement
|
||||
let wheel_delta = WheelDelta { x: dx, y: dy, z: 0.0, mode };
|
||||
let pos = self.mouse_pos.get();
|
||||
let position = TypedPoint2D::new(pos.x as f32, pos.y as f32);
|
||||
let position = Point2D::new(pos.x as f32, pos.y as f32);
|
||||
let wheel_event = WindowEvent::Wheel(wheel_delta, position);
|
||||
|
||||
// Scroll events snap to the major axis of movement, with vertical
|
||||
|
@ -429,7 +429,7 @@ impl WindowPortsMethods for Window {
|
|||
dy = 0.0;
|
||||
}
|
||||
|
||||
let scroll_location = ScrollLocation::Delta(TypedVector2D::new(dx as f32, dy as f32));
|
||||
let scroll_location = ScrollLocation::Delta(Vector2D::new(dx as f32, dy as f32));
|
||||
let phase = winit_phase_to_touch_event_type(phase);
|
||||
let scroll_event = WindowEvent::Scroll(scroll_location, self.mouse_pos.get(), phase);
|
||||
|
||||
|
@ -445,7 +445,7 @@ impl WindowPortsMethods for Window {
|
|||
let position = touch
|
||||
.location
|
||||
.to_physical(self.device_hidpi_factor().get() as f64);
|
||||
let point = TypedPoint2D::new(position.x as f32, position.y as f32);
|
||||
let point = Point2D::new(position.x as f32, position.y as f32);
|
||||
self.event_queue
|
||||
.borrow_mut()
|
||||
.push(WindowEvent::Touch(phase, id, point));
|
||||
|
@ -461,7 +461,7 @@ impl WindowPortsMethods for Window {
|
|||
self.gl_context.borrow_mut().resize(physical_size);
|
||||
// window.set_inner_size() takes DeviceIndependentPixel.
|
||||
let (width, height) = size.into();
|
||||
let new_size = TypedSize2D::new(width, height);
|
||||
let new_size = Size2D::new(width, height);
|
||||
if self.inner_size.get() != new_size {
|
||||
self.inner_size.set(new_size);
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Resize);
|
||||
|
@ -482,7 +482,7 @@ impl webxr::glwindow::GlWindow for Window {
|
|||
self.gl_context.get_mut().make_not_current();
|
||||
}
|
||||
|
||||
fn size(&self) -> Size2D<gl::GLsizei> {
|
||||
fn size(&self) -> UntypedSize2D<gl::GLsizei> {
|
||||
let dpr = self.device_hidpi_factor().get() as f64;
|
||||
let LogicalSize { width, height } = self
|
||||
.gl_context
|
||||
|
@ -523,8 +523,8 @@ impl WindowMethods for Window {
|
|||
.window()
|
||||
.get_position()
|
||||
.unwrap_or(LogicalPosition::new(0., 0.));
|
||||
let win_size = (TypedSize2D::new(width as f32, height as f32) * dpr).to_i32();
|
||||
let win_origin = (TypedPoint2D::new(x as f32, y as f32) * dpr).to_i32();
|
||||
let win_size = (Size2D::new(width as f32, height as f32) * dpr).to_i32();
|
||||
let win_origin = (Point2D::new(x as f32, y as f32) * dpr).to_i32();
|
||||
let screen = (self.screen_size.to_f32() * dpr).to_i32();
|
||||
|
||||
let LogicalSize { width, height } = self
|
||||
|
@ -533,9 +533,9 @@ impl WindowMethods for Window {
|
|||
.window()
|
||||
.get_inner_size()
|
||||
.expect("Failed to get window inner size.");
|
||||
let inner_size = (TypedSize2D::new(width as f32, height as f32) * dpr).to_i32();
|
||||
let viewport = DeviceIntRect::new(TypedPoint2D::zero(), inner_size);
|
||||
let framebuffer = DeviceIntSize::from_untyped(&viewport.size.to_untyped());
|
||||
let inner_size = (Size2D::new(width as f32, height as f32) * dpr).to_i32();
|
||||
let viewport = DeviceIntRect::new(Point2D::zero(), inner_size);
|
||||
let framebuffer = DeviceIntSize::from_untyped(viewport.size.to_untyped());
|
||||
|
||||
EmbedderCoordinates {
|
||||
viewport,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use crate::window_trait::WindowPortsMethods;
|
||||
use glutin;
|
||||
use euclid::{Size2D, TypedPoint2D, TypedScale, TypedSize2D};
|
||||
use euclid::{default::Size2D as UntypedSize2D, Point2D, Scale, Size2D};
|
||||
use gleam::gl;
|
||||
use servo::compositing::windowing::{AnimationState, WindowEvent};
|
||||
use servo::compositing::windowing::{EmbedderCoordinates, WindowMethods};
|
||||
|
@ -106,7 +106,7 @@ pub struct Window {
|
|||
}
|
||||
|
||||
impl Window {
|
||||
pub fn new(size: TypedSize2D<u32, DeviceIndependentPixel>) -> Rc<dyn WindowPortsMethods> {
|
||||
pub fn new(size: Size2D<u32, DeviceIndependentPixel>) -> Rc<dyn WindowPortsMethods> {
|
||||
let context = HeadlessContext::new(size.width, size.height, None);
|
||||
let gl = unsafe { gl::GlFns::load_with(|s| HeadlessContext::get_proc_address(s)) };
|
||||
|
||||
|
@ -126,10 +126,10 @@ impl Window {
|
|||
Rc::new(window)
|
||||
}
|
||||
|
||||
fn servo_hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
fn servo_hidpi_factor(&self) -> Scale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||
match opts::get().device_pixels_per_px {
|
||||
Some(device_pixels_per_px) => TypedScale::new(device_pixels_per_px),
|
||||
_ => TypedScale::new(1.0),
|
||||
Some(device_pixels_per_px) => Scale::new(device_pixels_per_px),
|
||||
_ => Scale::new(1.0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,13 +177,13 @@ impl WindowMethods for Window {
|
|||
fn get_coordinates(&self) -> EmbedderCoordinates {
|
||||
let dpr = self.servo_hidpi_factor();
|
||||
let size =
|
||||
(TypedSize2D::new(self.context.width, self.context.height).to_f32() * dpr).to_i32();
|
||||
let viewport = DeviceIntRect::new(TypedPoint2D::zero(), size);
|
||||
let framebuffer = DeviceIntSize::from_untyped(&size.to_untyped());
|
||||
(Size2D::new(self.context.width, self.context.height).to_f32() * dpr).to_i32();
|
||||
let viewport = DeviceIntRect::new(Point2D::zero(), size);
|
||||
let framebuffer = DeviceIntSize::from_untyped(size.to_untyped());
|
||||
EmbedderCoordinates {
|
||||
viewport,
|
||||
framebuffer,
|
||||
window: (size, TypedPoint2D::zero()),
|
||||
window: (size, Point2D::zero()),
|
||||
screen: size,
|
||||
screen_avail: size,
|
||||
hidpi_factor: dpr,
|
||||
|
@ -214,7 +214,7 @@ impl WindowMethods for Window {
|
|||
impl webxr::glwindow::GlWindow for Window {
|
||||
fn make_current(&mut self) {}
|
||||
fn swap_buffers(&mut self) {}
|
||||
fn size(&self) -> Size2D<gl::GLsizei> {
|
||||
fn size(&self) -> UntypedSize2D<gl::GLsizei> {
|
||||
let dpr = self.servo_hidpi_factor().get();
|
||||
Size2D::new((self.context.width as f32 * dpr) as gl::GLsizei, (self.context.height as f32 * dpr) as gl::GLsizei)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use libc::{dup2, pipe, read};
|
|||
use log::info;
|
||||
use log::warn;
|
||||
use rust_webvr::api::MagicLeapVRService;
|
||||
use servo::euclid::TypedScale;
|
||||
use servo::euclid::Scale;
|
||||
use servo::keyboard_types::Key;
|
||||
use servo::servo_url::ServoUrl;
|
||||
use servo::webrender_api::units::{DevicePixel, DevicePoint, LayoutPixel};
|
||||
|
@ -176,7 +176,7 @@ pub unsafe extern "C" fn init_servo(
|
|||
|
||||
let result = Box::new(ServoInstance {
|
||||
scroll_state: ScrollState::TriggerUp,
|
||||
scroll_scale: TypedScale::new(SCROLL_SCALE / hidpi),
|
||||
scroll_scale: Scale::new(SCROLL_SCALE / hidpi),
|
||||
shut_down_complete,
|
||||
});
|
||||
Box::into_raw(result)
|
||||
|
@ -389,7 +389,7 @@ impl HostTrait for HostCallbacks {
|
|||
|
||||
pub struct ServoInstance {
|
||||
scroll_state: ScrollState,
|
||||
scroll_scale: TypedScale<f32, DevicePixel, LayoutPixel>,
|
||||
scroll_scale: Scale<f32, DevicePixel, LayoutPixel>,
|
||||
shut_down_complete: Rc<Cell<bool>>,
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ use servo::compositing::windowing::{
|
|||
};
|
||||
use servo::embedder_traits::resources::{self, Resource, ResourceReaderMethods};
|
||||
use servo::embedder_traits::EmbedderMsg;
|
||||
use servo::euclid::{TypedPoint2D, TypedRect, TypedScale, TypedSize2D, TypedVector2D};
|
||||
use servo::euclid::{Point2D, Rect, Scale, Size2D, Vector2D};
|
||||
use servo::keyboard_types::{Key, KeyState, KeyboardEvent};
|
||||
use servo::msg::constellation_msg::TraversalDirection;
|
||||
use servo::script_traits::{TouchEventType, TouchId};
|
||||
|
@ -61,8 +61,8 @@ pub enum VRInitOptions {
|
|||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Coordinates {
|
||||
pub viewport: TypedRect<i32, DevicePixel>,
|
||||
pub framebuffer: TypedSize2D<i32, DevicePixel>,
|
||||
pub viewport: Rect<i32, DevicePixel>,
|
||||
pub framebuffer: Size2D<i32, DevicePixel>,
|
||||
}
|
||||
|
||||
impl Coordinates {
|
||||
|
@ -75,8 +75,8 @@ impl Coordinates {
|
|||
fb_height: i32,
|
||||
) -> Coordinates {
|
||||
Coordinates {
|
||||
viewport: TypedRect::new(TypedPoint2D::new(x, y), TypedSize2D::new(width, height)),
|
||||
framebuffer: TypedSize2D::new(fb_width, fb_height),
|
||||
viewport: Rect::new(Point2D::new(x, y), Size2D::new(width, height)),
|
||||
framebuffer: Size2D::new(fb_width, fb_height),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,13 +324,9 @@ impl ServoGlue {
|
|||
/// x/y are scroll coordinates.
|
||||
/// dx/dy are scroll deltas.
|
||||
pub fn scroll_start(&mut self, dx: f32, dy: f32, x: i32, y: i32) -> Result<(), &'static str> {
|
||||
let delta = TypedVector2D::new(dx, dy);
|
||||
let delta = Vector2D::new(dx, dy);
|
||||
let scroll_location = ScrollLocation::Delta(delta);
|
||||
let event = WindowEvent::Scroll(
|
||||
scroll_location,
|
||||
TypedPoint2D::new(x, y),
|
||||
TouchEventType::Down,
|
||||
);
|
||||
let event = WindowEvent::Scroll(scroll_location, Point2D::new(x, y), TouchEventType::Down);
|
||||
self.process_event(event)
|
||||
}
|
||||
|
||||
|
@ -338,13 +334,9 @@ impl ServoGlue {
|
|||
/// x/y are scroll coordinates.
|
||||
/// dx/dy are scroll deltas.
|
||||
pub fn scroll(&mut self, dx: f32, dy: f32, x: i32, y: i32) -> Result<(), &'static str> {
|
||||
let delta = TypedVector2D::new(dx, dy);
|
||||
let delta = Vector2D::new(dx, dy);
|
||||
let scroll_location = ScrollLocation::Delta(delta);
|
||||
let event = WindowEvent::Scroll(
|
||||
scroll_location,
|
||||
TypedPoint2D::new(x, y),
|
||||
TouchEventType::Move,
|
||||
);
|
||||
let event = WindowEvent::Scroll(scroll_location, Point2D::new(x, y), TouchEventType::Move);
|
||||
self.process_event(event)
|
||||
}
|
||||
|
||||
|
@ -352,10 +344,9 @@ impl ServoGlue {
|
|||
/// x/y are scroll coordinates.
|
||||
/// dx/dy are scroll deltas.
|
||||
pub fn scroll_end(&mut self, dx: f32, dy: f32, x: i32, y: i32) -> Result<(), &'static str> {
|
||||
let delta = TypedVector2D::new(dx, dy);
|
||||
let delta = Vector2D::new(dx, dy);
|
||||
let scroll_location = ScrollLocation::Delta(delta);
|
||||
let event =
|
||||
WindowEvent::Scroll(scroll_location, TypedPoint2D::new(x, y), TouchEventType::Up);
|
||||
let event = WindowEvent::Scroll(scroll_location, Point2D::new(x, y), TouchEventType::Up);
|
||||
self.process_event(event)
|
||||
}
|
||||
|
||||
|
@ -364,7 +355,7 @@ impl ServoGlue {
|
|||
let event = WindowEvent::Touch(
|
||||
TouchEventType::Down,
|
||||
TouchId(pointer_id),
|
||||
TypedPoint2D::new(x as f32, y as f32),
|
||||
Point2D::new(x as f32, y as f32),
|
||||
);
|
||||
self.process_event(event)
|
||||
}
|
||||
|
@ -374,7 +365,7 @@ impl ServoGlue {
|
|||
let event = WindowEvent::Touch(
|
||||
TouchEventType::Move,
|
||||
TouchId(pointer_id),
|
||||
TypedPoint2D::new(x as f32, y as f32),
|
||||
Point2D::new(x as f32, y as f32),
|
||||
);
|
||||
self.process_event(event)
|
||||
}
|
||||
|
@ -384,7 +375,7 @@ impl ServoGlue {
|
|||
let event = WindowEvent::Touch(
|
||||
TouchEventType::Up,
|
||||
TouchId(pointer_id),
|
||||
TypedPoint2D::new(x as f32, y as f32),
|
||||
Point2D::new(x as f32, y as f32),
|
||||
);
|
||||
self.process_event(event)
|
||||
}
|
||||
|
@ -394,28 +385,28 @@ impl ServoGlue {
|
|||
let event = WindowEvent::Touch(
|
||||
TouchEventType::Cancel,
|
||||
TouchId(pointer_id),
|
||||
TypedPoint2D::new(x as f32, y as f32),
|
||||
Point2D::new(x as f32, y as f32),
|
||||
);
|
||||
self.process_event(event)
|
||||
}
|
||||
|
||||
/// Register a mouse movement.
|
||||
pub fn move_mouse(&mut self, x: f32, y: f32) -> Result<(), &'static str> {
|
||||
let point = TypedPoint2D::new(x, y);
|
||||
let point = Point2D::new(x, y);
|
||||
let event = WindowEvent::MouseWindowMoveEventClass(point);
|
||||
self.process_event(event)
|
||||
}
|
||||
|
||||
/// Register a mouse button press.
|
||||
pub fn mouse_down(&mut self, x: f32, y: f32, button: MouseButton) -> Result<(), &'static str> {
|
||||
let point = TypedPoint2D::new(x, y);
|
||||
let point = Point2D::new(x, y);
|
||||
let event = WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseDown(button, point));
|
||||
self.process_event(event)
|
||||
}
|
||||
|
||||
/// Register a mouse button release.
|
||||
pub fn mouse_up(&mut self, x: f32, y: f32, button: MouseButton) -> Result<(), &'static str> {
|
||||
let point = TypedPoint2D::new(x, y);
|
||||
let point = Point2D::new(x, y);
|
||||
let event = WindowEvent::MouseWindowEventClass(MouseWindowEvent::MouseUp(button, point));
|
||||
self.process_event(event)
|
||||
}
|
||||
|
@ -440,7 +431,7 @@ impl ServoGlue {
|
|||
|
||||
/// Perform a click.
|
||||
pub fn click(&mut self, x: f32, y: f32) -> Result<(), &'static str> {
|
||||
let mouse_event = MouseWindowEvent::Click(MouseButton::Left, TypedPoint2D::new(x, y));
|
||||
let mouse_event = MouseWindowEvent::Click(MouseButton::Left, Point2D::new(x, y));
|
||||
let event = WindowEvent::MouseWindowEventClass(mouse_event);
|
||||
self.process_event(event)
|
||||
}
|
||||
|
@ -647,10 +638,10 @@ impl WindowMethods for ServoWindowCallbacks {
|
|||
EmbedderCoordinates {
|
||||
viewport: coords.viewport,
|
||||
framebuffer: coords.framebuffer,
|
||||
window: (coords.viewport.size, TypedPoint2D::new(0, 0)),
|
||||
window: (coords.viewport.size, Point2D::new(0, 0)),
|
||||
screen: coords.viewport.size,
|
||||
screen_avail: coords.viewport.size,
|
||||
hidpi_factor: TypedScale::new(self.density),
|
||||
hidpi_factor: Scale::new(self.density),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue