mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Implement Document.createTouch
This commit is contained in:
parent
817eed22d1
commit
316802e206
6 changed files with 73 additions and 11 deletions
|
@ -594,7 +594,7 @@ impl Document {
|
|||
EventCancelable::Cancelable,
|
||||
Some(&self.window),
|
||||
clickCount,
|
||||
x, y, x, y,
|
||||
x, y, x, y, // TODO: Get real screen coordinates?
|
||||
false, false, false, false,
|
||||
0i16,
|
||||
None);
|
||||
|
@ -723,13 +723,18 @@ impl Document {
|
|||
},
|
||||
};
|
||||
let target = el.upcast::<EventTarget>();
|
||||
|
||||
let x = Finite::wrap(point.x as f64);
|
||||
let y = Finite::wrap(point.y as f64);
|
||||
|
||||
let window = self.window.root();
|
||||
|
||||
let touch = Touch::new(window.r(), identifier, target, x, y, x, y);
|
||||
let client_x = Finite::wrap(point.x as f64);
|
||||
let client_y = Finite::wrap(point.y as f64);
|
||||
let page_x = Finite::wrap(point.x as f64 + window.PageXOffset() as f64);
|
||||
let page_y = Finite::wrap(point.y as f64 + window.PageYOffset() as f64);
|
||||
|
||||
let touch = Touch::new(window.r(), identifier, target,
|
||||
client_x, client_y, // TODO: Get real screen coordinates?
|
||||
client_x, client_y,
|
||||
page_x, page_y);
|
||||
|
||||
let mut touches = RootedVec::new();
|
||||
touches.push(JS::from_rooted(&touch));
|
||||
let touches = TouchList::new(window.r(), touches.r());
|
||||
|
@ -1414,6 +1419,21 @@ impl DocumentMethods for Document {
|
|||
NodeIterator::new(self, root, whatToShow, filter)
|
||||
}
|
||||
|
||||
// https://w3c.github.io/touch-events/#idl-def-Document
|
||||
fn CreateTouch(&self,
|
||||
window: &Window,
|
||||
target: &EventTarget,
|
||||
identifier: i32,
|
||||
pageX: Finite<f64>,
|
||||
pageY: Finite<f64>,
|
||||
screenX: Finite<f64>,
|
||||
screenY: Finite<f64>)
|
||||
-> Root<Touch> {
|
||||
let clientX = Finite::wrap(*pageX - window.PageXOffset() as f64);
|
||||
let clientY = Finite::wrap(*pageY - window.PageYOffset() as f64);
|
||||
Touch::new(window, identifier, target, screenX, screenY, clientX, clientY, pageX, pageY)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createtreewalker
|
||||
fn CreateTreeWalker(&self, root: &Node, whatToShow: u32, filter: Option<Rc<NodeFilter>>)
|
||||
-> Root<TreeWalker> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue