mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
remove forcetouch support
This commit is contained in:
parent
019fdaa1bd
commit
e7c754fb64
12 changed files with 7 additions and 240 deletions
|
@ -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);
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue