mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
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.
This commit is contained in:
parent
8f11b52d9a
commit
35bca991ad
16 changed files with 347 additions and 146 deletions
|
@ -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).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue