forcetouch events support

This enables Apple forcetouch DOM events. It requires the preference dom.forcetouch.enabled.

The DOM events are described here:
- https://developer.apple.com/library/mac/documentation/AppleApplications/Conceptual/SafariJSProgTopics/RespondingtoForceTouchEventsfromJavaScript.html

The Cocoa mechanism is documented here:
- https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSEvent_Class/#//apple_ref/doc/uid/20000016-SW274
This commit is contained in:
Paul Rouget 2016-03-18 08:57:20 +01:00
parent 05a4dcdc3b
commit df6e7394d4
13 changed files with 245 additions and 8 deletions

View file

@ -14,9 +14,10 @@ use layers::geometry::LayerPixel;
use layers::layers::{Layer, LayerBufferSet};
use msg::constellation_msg::PipelineId;
use script_traits::CompositorEvent;
use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent};
use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent, TouchpadPressureEvent};
use script_traits::ConstellationControlMsg;
use script_traits::MouseEventType;
use script_traits::TouchpadPressurePhase;
use std::rc::Rc;
use windowing::{MouseWindowEvent, WindowMethods};
@ -139,6 +140,13 @@ pub trait CompositorLayer {
event: CompositorEvent)
where Window: WindowMethods;
fn send_touchpad_pressure_event<Window>(&self,
compositor: &IOCompositor<Window>,
cursor: TypedPoint2D<LayerPixel, f32>,
pressure: f32,
phase: TouchpadPressurePhase)
where Window: WindowMethods;
fn clamp_scroll_offset_and_scroll_layer(&self,
new_offset: TypedPoint2D<LayerPixel, f32>)
-> ScrollEventResult;
@ -399,6 +407,18 @@ impl CompositorLayer for Layer<CompositorData> {
}
}
fn send_touchpad_pressure_event<Window>(&self,
compositor: &IOCompositor<Window>,
cursor: TypedPoint2D<LayerPixel, f32>,
pressure: f32,
phase: TouchpadPressurePhase)
where Window: WindowMethods {
if let Some(pipeline) = compositor.pipeline(self.pipeline_id()) {
let message = TouchpadPressureEvent(cursor.to_untyped(), pressure, phase);
let _ = pipeline.script_chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
}
}
fn scroll_layer_and_all_child_layers(&self, new_offset: TypedPoint2D<LayerPixel, f32>)
-> bool {
let mut result = false;