diff options
author | Robert Snakard <robert.snakard@gmail.com> | 2019-02-24 21:24:36 +0000 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2019-06-09 13:25:01 -0400 |
commit | 35bca991ad4db3fe52ff6dd30bb3f7c567ba26e9 (patch) | |
tree | 4e7682b0903234354e4a82fbcbe51f1e2dbeb0fa /components/script/script_thread.rs | |
parent | 8f11b52d9a80a51ddf80212817b87efc20bef8d6 (diff) | |
download | servo-35bca991ad4db3fe52ff6dd30bb3f7c567ba26e9.tar.gz servo-35bca991ad4db3fe52ff6dd30bb3f7c567ba26e9.zip |
Implement WheelEvent Interface
Note: The WheelEvent interface supports rotation in all 3 spatial
dimensions. This implementation only supports two due to limitations
in the Glutin compositor.
The wheelevent interface is a dom interface that triggers for any
attached device that can rotate in one or more spatial dimensions.
Traditionally this is the mouse wheel though other devices could be
used as well. E.g. the trackball on a trackball mouse.
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index f284e14dd0c..d0dad1cd9ba 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -125,6 +125,7 @@ use script_layout_interface::message::{self, LayoutThreadInit, Msg, ReflowGoal}; use script_traits::webdriver_msg::WebDriverScriptCommand; use script_traits::CompositorEvent::{ CompositionEvent, KeyboardEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent, TouchEvent, + WheelEvent, }; use script_traits::{CompositorEvent, ConstellationControlMsg}; use script_traits::{DiscardBrowsingContext, DocumentActivity, EventResult}; @@ -132,7 +133,7 @@ use script_traits::{InitialScriptState, JsEvalResult, LayoutMsg, LoadData}; use script_traits::{MouseButton, MouseEventType, NewLayoutInfo}; use script_traits::{Painter, ProgressiveWebMetricType, ScriptMsg, ScriptThreadFactory}; use script_traits::{ScriptToConstellationChan, TimerEvent, TimerSchedulerMsg}; -use script_traits::{TimerSource, TouchEventType, TouchId, UntrustedNodeAddress}; +use script_traits::{TimerSource, TouchEventType, TouchId, UntrustedNodeAddress, WheelDelta}; use script_traits::{UpdatePipelineIdReason, WindowSizeData, WindowSizeType}; use servo_atoms::Atom; use servo_config::opts; @@ -3162,6 +3163,10 @@ impl ScriptThread { } }, + WheelEvent(delta, point, node_address) => { + self.handle_wheel_event(pipeline_id, delta, point, node_address); + }, + KeyboardEvent(key_event) => { let document = match { self.documents.borrow().find_document(pipeline_id) } { Some(document) => document, @@ -3229,6 +3234,20 @@ impl ScriptThread { ) } + fn handle_wheel_event( + &self, + pipeline_id: PipelineId, + wheel_delta: WheelDelta, + point: Point2D<f32>, + node_address: Option<UntrustedNodeAddress>, + ) { + let document = match { self.documents.borrow().find_document(pipeline_id) } { + Some(document) => document, + None => return warn!("Message sent to closed pipeline {}.", pipeline_id), + }; + document.handle_wheel_event(self.js_runtime.rt(), wheel_delta, point, node_address); + } + /// <https://html.spec.whatwg.org/multipage/#navigating-across-documents> /// The entry point for content to notify that a new load has been requested /// for the given pipeline (specifically the "navigate" algorithm). |