From 35bca991ad4db3fe52ff6dd30bb3f7c567ba26e9 Mon Sep 17 00:00:00 2001 From: Robert Snakard Date: Sun, 24 Feb 2019 21:24:36 +0000 Subject: 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. --- components/script/script_thread.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'components/script/script_thread.rs') 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, + node_address: Option, + ) { + 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); + } + /// /// The entry point for content to notify that a new load has been requested /// for the given pipeline (specifically the "navigate" algorithm). -- cgit v1.2.3