diff --git a/components/script/dom/document_event_handler.rs b/components/script/dom/document_event_handler.rs index 734a081a1fd..40a1bd52b0e 100644 --- a/components/script/dom/document_event_handler.rs +++ b/components/script/dom/document_event_handler.rs @@ -1472,4 +1472,13 @@ impl DocumentEventHandler { document.handle_element_scroll_event(&element); } } + + pub(crate) fn run_default_keyboard_event_handler(&self, event: &KeyboardEvent, can_gc: CanGc) { + if event.upcast::().type_() != atom!("keydown") { + return; + } + + // keydown + dbg!(event.upcast::().type_()); + } } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 85fc7a8ec19..e9d8d8a20bb 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -121,6 +121,7 @@ use crate::dom::shadowroot::{IsUserAgentWidget, LayoutShadowRootHelpers, ShadowR use crate::dom::stylesheetlist::StyleSheetListOwner; use crate::dom::svgsvgelement::{LayoutSVGSVGElementHelpers, SVGSVGElement}; use crate::dom::text::Text; +use crate::dom::types::KeyboardEvent; use crate::dom::virtualmethods::{VirtualMethods, vtable_for}; use crate::dom::window::Window; use crate::script_runtime::CanGc; @@ -4084,6 +4085,12 @@ impl VirtualMethods for Node { self.ranges().drain_to_parent(context, self); } } + + fn handle_event(&self, event: &Event, can_gc: CanGc) { + if let Some(event) = event.downcast::() { + self.owner_document().event_handler().run_default_keyboard_event_handler(event, can_gc); + } + } } /// A summary of the changes that happened to a node. diff --git a/ports/servoshell/desktop/app_state.rs b/ports/servoshell/desktop/app_state.rs index 84174159bfc..cc098513781 100644 --- a/ports/servoshell/desktop/app_state.rs +++ b/ports/servoshell/desktop/app_state.rs @@ -455,6 +455,7 @@ impl RunningAppState { .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowDown), || { let location = ScrollLocation::Delta(Vector2D::new(0.0, LINE_HEIGHT)); webview.notify_scroll_event(location, origin); + dbg!("here"); }) .shortcut(Modifiers::empty(), Key::Named(NamedKey::ArrowLeft), || { let location = ScrollLocation::Delta(Vector2D::new(-LINE_WIDTH, 0.0));