remove forcetouch support

This commit is contained in:
Paul Rouget 2018-02-07 10:10:58 +01:00
parent 019fdaa1bd
commit e7c754fb64
12 changed files with 7 additions and 240 deletions

View file

@ -18,8 +18,8 @@ use nonzero::NonZero;
use profile_traits::time::{self, ProfilerCategory, profile};
use script_traits::{AnimationState, AnimationTickType, ConstellationMsg, LayoutControlMsg};
use script_traits::{MouseButton, MouseEventType, ScrollState, TouchEventType, TouchId};
use script_traits::{TouchpadPressurePhase, UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use script_traits::CompositorEvent::{MouseMoveEvent, MouseButtonEvent, TouchEvent, TouchpadPressureEvent};
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use script_traits::CompositorEvent::{MouseMoveEvent, MouseButtonEvent, TouchEvent};
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_geometry::DeviceIndependentPixel;
@ -864,31 +864,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.send_touch_event(TouchEventType::Cancel, identifier, point);
}
pub fn on_touchpad_pressure_event(&self,
point: TypedPoint2D<f32, DevicePixel>,
pressure: f32,
phase: TouchpadPressurePhase) {
match PREFS.get("dom.forcetouch.enabled").as_boolean() {
Some(true) => {},
_ => return,
}
let results = self.hit_test_at_point(point);
if let Some(item) = results.items.first() {
let event = TouchpadPressureEvent(
item.point_in_viewport.to_untyped(),
pressure,
phase,
Some(UntrustedNodeAddress(item.tag.0 as *const c_void)),
);
let pipeline_id = PipelineId::from_webrender(item.pipeline);
let msg = ConstellationMsg::ForwardEvent(pipeline_id, event);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending event to constellation failed ({}).", e);
}
}
}
/// <http://w3c.github.io/touch-events/#mouse-events>
fn simulate_mouse_click(&mut self, p: TypedPoint2D<f32, DevicePixel>) {
let button = MouseButton::Left;

View file

@ -11,7 +11,7 @@ use gleam::gl;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::{Key, KeyModifiers, KeyState, TopLevelBrowsingContextId, TraversalDirection};
use net_traits::net_error_list::NetError;
use script_traits::{LoadData, MouseButton, TouchEventType, TouchId, TouchpadPressurePhase};
use script_traits::{LoadData, MouseButton, TouchEventType, TouchId};
use servo_geometry::DeviceIndependentPixel;
use servo_url::ServoUrl;
use std::fmt::{Debug, Error, Formatter};
@ -50,8 +50,6 @@ pub enum WindowEvent {
Refresh,
/// Sent when the window is resized.
Resize,
/// Touchpad Pressure
TouchpadPressure(TypedPoint2D<f32, DevicePixel>, f32, TouchpadPressurePhase),
/// Sent when a new URL is to be loaded.
LoadUrl(TopLevelBrowsingContextId, ServoUrl),
/// Sent when a mouse hit test is to be performed.
@ -94,7 +92,6 @@ impl Debug for WindowEvent {
WindowEvent::Idle => write!(f, "Idle"),
WindowEvent::Refresh => write!(f, "Refresh"),
WindowEvent::Resize => write!(f, "Resize"),
WindowEvent::TouchpadPressure(..) => write!(f, "TouchpadPressure"),
WindowEvent::KeyEvent(..) => write!(f, "Key"),
WindowEvent::LoadUrl(..) => write!(f, "LoadUrl"),
WindowEvent::MouseWindowEventClass(..) => write!(f, "Mouse"),

View file

@ -79,7 +79,7 @@ use profile_traits::time::ProfilerChan as TimeProfilerChan;
use script_layout_interface::OpaqueStyleAndLayoutData;
use script_layout_interface::reporter::CSSErrorReporter;
use script_layout_interface::rpc::LayoutRPC;
use script_traits::{DocumentActivity, ScriptToConstellationChan, TimerEventId, TimerSource, TouchpadPressurePhase};
use script_traits::{DocumentActivity, ScriptToConstellationChan, TimerEventId, TimerSource};
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
use script_traits::DrawAPaintImageResult;
use selectors::matching::ElementSelectorFlags;
@ -385,7 +385,6 @@ unsafe_no_jsmanaged_fields!(Request);
unsafe_no_jsmanaged_fields!(RequestInit);
unsafe_no_jsmanaged_fields!(SharedRt);
unsafe_no_jsmanaged_fields!(StyleSharedRwLock);
unsafe_no_jsmanaged_fields!(TouchpadPressurePhase);
unsafe_no_jsmanaged_fields!(USVString);
unsafe_no_jsmanaged_fields!(ReferrerPolicy);
unsafe_no_jsmanaged_fields!(Response);

View file

@ -42,7 +42,6 @@ use dom::errorevent::ErrorEvent;
use dom::event::{Event, EventBubbles, EventCancelable, EventDefault, EventStatus};
use dom::eventtarget::EventTarget;
use dom::focusevent::FocusEvent;
use dom::forcetouchevent::ForceTouchEvent;
use dom::globalscope::GlobalScope;
use dom::hashchangeevent::HashChangeEvent;
use dom::htmlanchorelement::HTMLAnchorElement;
@ -112,8 +111,7 @@ use script_layout_interface::message::{Msg, NodesFromPointQueryType, ReflowGoal}
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
use script_thread::{MainThreadScriptMsg, ScriptThread};
use script_traits::{AnimationState, DocumentActivity, MouseButton, MouseEventType};
use script_traits::{MozBrowserEvent, MsDuration, ScriptMsg, TouchEventType, TouchId};
use script_traits::{TouchpadPressurePhase, UntrustedNodeAddress};
use script_traits::{MozBrowserEvent, MsDuration, ScriptMsg, TouchEventType, TouchId, UntrustedNodeAddress};
use servo_arc::Arc;
use servo_atoms::Atom;
use servo_config::prefs::PREFS;
@ -328,7 +326,6 @@ pub struct Document {
load_event_end: Cell<u64>,
/// <https://html.spec.whatwg.org/multipage/#concept-document-https-state>
https_state: Cell<HttpsState>,
touchpad_pressure_phase: Cell<TouchpadPressurePhase>,
/// The document's origin.
origin: MutableOrigin,
/// https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-states
@ -998,65 +995,6 @@ impl Document {
*self.last_click_info.borrow_mut() = Some((now, click_pos));
}
#[allow(unsafe_code)]
pub fn handle_touchpad_pressure_event(
&self,
js_runtime: *mut JSRuntime,
pressure: f32,
phase_now: TouchpadPressurePhase,
node_address: Option<UntrustedNodeAddress>
) {
let el = node_address.and_then(|address| {
let node = unsafe { node::from_untrusted_node_address(js_runtime, address) };
node.inclusive_ancestors()
.filter_map(DomRoot::downcast::<Element>)
.next()
});
let el = match el {
Some(el) => el,
None => return,
};
let phase_before = self.touchpad_pressure_phase.get();
self.touchpad_pressure_phase.set(phase_now);
if phase_before == TouchpadPressurePhase::BeforeClick &&
phase_now == TouchpadPressurePhase::BeforeClick {
return;
}
let node = el.upcast::<Node>();
let target = node.upcast();
let force = match phase_now {
TouchpadPressurePhase::BeforeClick => pressure,
TouchpadPressurePhase::AfterFirstClick => 1. + pressure,
TouchpadPressurePhase::AfterSecondClick => 2. + pressure,
};
if phase_now != TouchpadPressurePhase::BeforeClick {
self.fire_forcetouch_event("servomouseforcechanged".to_owned(), target, force);
}
if phase_before != TouchpadPressurePhase::AfterSecondClick &&
phase_now == TouchpadPressurePhase::AfterSecondClick {
self.fire_forcetouch_event("servomouseforcedown".to_owned(), target, force);
}
if phase_before == TouchpadPressurePhase::AfterSecondClick &&
phase_now != TouchpadPressurePhase::AfterSecondClick {
self.fire_forcetouch_event("servomouseforceup".to_owned(), target, force);
}
}
fn fire_forcetouch_event(&self, event_name: String, target: &EventTarget, force: f32) {
let force_event = ForceTouchEvent::new(&self.window,
DOMString::from(event_name),
force);
let event = force_event.upcast::<Event>();
event.fire(target);
}
pub fn fire_mouse_event(&self, client_point: Point2D<f32>, target: &EventTarget, event_name: FireMouseEventType) {
let client_x = client_point.x.to_i32().unwrap_or(0);
let client_y = client_point.y.to_i32().unwrap_or(0);
@ -2297,7 +2235,6 @@ impl Document {
load_event_start: Cell::new(Default::default()),
load_event_end: Cell::new(Default::default()),
https_state: Cell::new(HttpsState::None),
touchpad_pressure_phase: Cell::new(TouchpadPressurePhase::BeforeClick),
origin: origin,
referrer: referrer,
referrer_policy: Cell::new(referrer_policy),

View file

@ -1,58 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::ForceTouchEventBinding;
use dom::bindings::codegen::Bindings::ForceTouchEventBinding::ForceTouchEventMethods;
use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::num::Finite;
use dom::bindings::reflector::reflect_dom_object;
use dom::bindings::root::DomRoot;
use dom::bindings::str::DOMString;
use dom::uievent::UIEvent;
use dom::window::Window;
use dom_struct::dom_struct;
#[dom_struct]
pub struct ForceTouchEvent {
uievent: UIEvent,
force: f32,
}
impl ForceTouchEvent {
fn new_inherited(force: f32) -> ForceTouchEvent {
ForceTouchEvent {
uievent: UIEvent::new_inherited(),
force: force,
}
}
pub fn new(window: &Window,
type_: DOMString,
force: f32) -> DomRoot<ForceTouchEvent> {
let event = Box::new(ForceTouchEvent::new_inherited(force));
let ev = reflect_dom_object(event, window, ForceTouchEventBinding::Wrap);
ev.upcast::<UIEvent>().InitUIEvent(type_, true, true, Some(window), 0);
ev
}
}
impl<'a> ForceTouchEventMethods for &'a ForceTouchEvent {
fn ServoForce(&self) -> Finite<f32> {
Finite::wrap(self.force)
}
fn SERVO_FORCE_AT_MOUSE_DOWN(&self) -> Finite<f32> {
Finite::wrap(1.0)
}
fn SERVO_FORCE_AT_FORCE_MOUSE_DOWN(&self) -> Finite<f32> {
Finite::wrap(2.0)
}
// https://dom.spec.whatwg.org/#dom-event-istrusted
fn IsTrusted(&self) -> bool {
self.uievent.IsTrusted()
}
}

View file

@ -289,7 +289,6 @@ pub mod filelist;
pub mod filereader;
pub mod filereadersync;
pub mod focusevent;
pub mod forcetouchevent;
pub mod formdata;
pub mod gamepad;
pub mod gamepadbutton;

View file

@ -1,34 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://developer.apple.com/library/mac/documentation/AppleApplications/Conceptual/SafariJSProgTopics/RespondingtoForceTouchEventsfromJavaScript.html
/**
* Events: (copy/paste from apple.com)
*
* webkitmouseforcewillbegin: This event occurs immediately before the mousedown event. It allows you to
* prevent the default system behavior, such as displaying a dictionary window when force clicking on a
* word, in order to perform a custom action instead. To prevent the default system behavior, call the
* preventDefault() method on the event.
* webkitmouseforcedown: This event occurs after the mousedown event, once enough force has been applied
* to register as a force click. The user receives haptic feedback representing the force click when this
* event occurs.
* webkitmouseforceup: This event occurs after a webkitmouseforcedown event, once enough force has been
* released to exit the force click operation. The user receives haptic feedback representing the exit
* from force click when this event occurs.
* webkitmouseforcechanged: This event occurs whenever a change in trackpad force is detected between the
* mousedown and mouseup events.
*
*/
[Pref="dom.forcetouch.enabled"]
interface ForceTouchEvent : UIEvent {
// Represents the amount of force required to perform a regular click.
readonly attribute float SERVO_FORCE_AT_MOUSE_DOWN;
// Represents the force required to perform a force click.
readonly attribute float SERVO_FORCE_AT_FORCE_MOUSE_DOWN;
// force level
readonly attribute float servoForce;
};

View file

@ -96,8 +96,7 @@ use script_traits::{ProgressiveWebMetricType, Painter, ScriptMsg, ScriptThreadFa
use script_traits::{ScriptToConstellationChan, TimerEvent, TimerSchedulerMsg};
use script_traits::{TimerSource, TouchEventType, TouchId, UntrustedNodeAddress};
use script_traits::{UpdatePipelineIdReason, WindowSizeData, WindowSizeType};
use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent};
use script_traits::CompositorEvent::{TouchEvent, TouchpadPressureEvent};
use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent, TouchEvent};
use script_traits::webdriver_msg::WebDriverScriptCommand;
use serviceworkerjob::{Job, JobQueue};
use servo_atoms::Atom;
@ -2378,19 +2377,6 @@ impl ScriptThread {
}
}
TouchpadPressureEvent(_point, pressure, phase, node_address) => {
let doc = match { self.documents.borrow().find_document(pipeline_id) } {
Some(doc) => doc,
None => return warn!("Message sent to closed pipeline {}.", pipeline_id),
};
doc.handle_touchpad_pressure_event(
self.js_runtime.rt(),
pressure,
phase,
node_address
);
}
KeyEvent(ch, key, state, modifiers) => {
let document = match { self.documents.borrow().find_document(pipeline_id) } {
Some(document) => document,

View file

@ -445,23 +445,10 @@ pub enum CompositorEvent {
MouseMoveEvent(Option<Point2D<f32>>, Option<UntrustedNodeAddress>),
/// A touch event was generated with a touch ID and location.
TouchEvent(TouchEventType, TouchId, Point2D<f32>, Option<UntrustedNodeAddress>),
/// Touchpad pressure event
TouchpadPressureEvent(Point2D<f32>, f32, TouchpadPressurePhase, Option<UntrustedNodeAddress>),
/// A key was pressed.
KeyEvent(Option<char>, Key, KeyState, KeyModifiers),
}
/// Touchpad pressure phase for `TouchpadPressureEvent`.
#[derive(Clone, Copy, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub enum TouchpadPressurePhase {
/// Pressure before a regular click.
BeforeClick,
/// Pressure after a regular click.
AfterFirstClick,
/// Pressure after a "forceTouch" click
AfterSecondClick,
}
/// Requests a TimerEvent-Message be sent after the given duration.
#[derive(Deserialize, Serialize)]
pub struct TimerEventRequest(pub IpcSender<TimerEvent>, pub TimerSource, pub TimerEventId, pub MsDuration);

View file

@ -311,10 +311,6 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
}
}
WindowEvent::TouchpadPressure(cursor, pressure, stage) => {
self.compositor.on_touchpad_pressure_event(cursor, pressure, stage);
}
WindowEvent::KeyEvent(ch, key, state, modifiers) => {
let msg = ConstellationMsg::KeyEvent(ch, key, state, modifiers);
if let Err(e) = self.constellation_chan.send(msg) {

View file

@ -23,7 +23,7 @@ use msg::constellation_msg::{KeyModifiers, KeyState, TraversalDirection};
use net_traits::net_error_list::NetError;
#[cfg(any(target_os = "linux", target_os = "macos"))]
use osmesa_sys;
use script_traits::{LoadData, TouchEventType, TouchpadPressurePhase};
use script_traits::{LoadData, TouchEventType};
use servo::ipc_channel::ipc::IpcSender;
use servo_config::opts;
use servo_config::prefs::PREFS;
@ -518,12 +518,6 @@ impl Window {
let point = TypedPoint2D::new(touch.location.0 as f32, touch.location.1 as f32);
self.event_queue.borrow_mut().push(WindowEvent::Touch(phase, id, point));
}
Event::TouchpadPressure(pressure, stage) => {
let m = self.mouse_pos.get();
let point = TypedPoint2D::new(m.x as f32, m.y as f32);
let phase = glutin_pressure_stage_to_touchpad_pressure_phase(stage);
self.event_queue.borrow_mut().push(WindowEvent::TouchpadPressure(point, pressure, phase));
}
Event::Refresh => {
self.event_queue.borrow_mut().push(WindowEvent::Refresh);
}
@ -1371,16 +1365,6 @@ fn glutin_phase_to_touch_event_type(phase: TouchPhase) -> TouchEventType {
}
}
fn glutin_pressure_stage_to_touchpad_pressure_phase(stage: i64) -> TouchpadPressurePhase {
if stage < 1 {
TouchpadPressurePhase::BeforeClick
} else if stage < 2 {
TouchpadPressurePhase::AfterFirstClick
} else {
TouchpadPressurePhase::AfterSecondClick
}
}
fn is_printable(key_code: VirtualKeyCode) -> bool {
use glutin::VirtualKeyCode::*;
match key_code {

View file

@ -54,7 +54,6 @@ files = [
"./components/style/gecko/generated/atom_macro.rs",
"./resources/hsts_preload.json",
"./tests/wpt/metadata/MANIFEST.json",
"./components/script/dom/webidls/ForceTouchEvent.webidl",
"./support/android/openssl.sh",
# Upstream code from Khronos/WebGL uses tabs for indentation
"./tests/wpt/mozilla/tests/webgl",