aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2025-02-12 18:07:15 +0100
committerGitHub <noreply@github.com>2025-02-12 17:07:15 +0000
commit0908a477802ed67b6f8bd939416b7fbc62040c18 (patch)
tree7d95f340b57fd31a33ae3ba6df3e1978d2a142ef /components/script/dom/node.rs
parentb7b8619e875a5a11611fd9f9bc874805b2319901 (diff)
downloadservo-0908a477802ed67b6f8bd939416b7fbc62040c18.tar.gz
servo-0908a477802ed67b6f8bd939416b7fbc62040c18.zip
libservo: Expose a single `InputEvent` type and pass it to script (#35430)
This change exposes a single `InputEvent` type and now there is only a single delegate method for this `WebViewDelegate::notify_input_event`. - Clipboard events are now handled as `EditingAction` inpute events. In the future this can include things like "Select All", etc. In addition, many parts of the dance to pass these events can now be simplified due to this abstraction. - All forwarded events are handled the same way in the `Constellation`, though they may carry an optional hit test (for events that have a `point`) which affects which `Pipeline` they are sent to. - In the `ScriptThread` we now accept these `InputEvents` and use them everywhere. Now all "compositor events" are "input events". - This allows removing several data structures which are no longer necessary. - We no longer inform the embedder when an event was handled by a WebView as that was only important for a MDI feature that will no longer be so important the full-featured `WebView` API. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index b623ae18973..225334c2710 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -43,6 +43,7 @@ use style::properties::ComputedValues;
use style::selector_parser::{SelectorImpl, SelectorParser};
use style::stylesheets::{Stylesheet, UrlExtraData};
use uuid::Uuid;
+use webrender_traits::UntrustedNodeAddress as CompositorUntrustedNodeAddress;
use xml5ever::serialize as xml_serialize;
use super::globalscope::GlobalScope;
@@ -1420,6 +1421,15 @@ pub(crate) unsafe fn from_untrusted_node_address(candidate: UntrustedNodeAddress
DomRoot::from_ref(Node::from_untrusted_node_address(candidate))
}
+/// If the given untrusted node address represents a valid DOM node in the given runtime,
+/// returns it.
+#[allow(unsafe_code)]
+pub(crate) unsafe fn from_untrusted_compositor_node_address(
+ candidate: CompositorUntrustedNodeAddress,
+) -> DomRoot<Node> {
+ DomRoot::from_ref(Node::from_untrusted_compositor_node_address(candidate))
+}
+
#[allow(unsafe_code)]
pub(crate) trait LayoutNodeHelpers<'dom> {
fn type_id_for_layout(self) -> NodeTypeId;
@@ -2747,6 +2757,26 @@ impl Node {
&*(conversions::private_from_object(object) as *const Self)
}
+ /// If the given untrusted node address represents a valid DOM node in the given runtime,
+ /// returns it.
+ ///
+ /// # Safety
+ ///
+ /// Callers should ensure they pass a [`CompositorUntrustedNodeAddress`] that points
+ /// to a valid [`JSObject`] in memory that represents a [`Node`].
+ #[allow(unsafe_code)]
+ pub(crate) unsafe fn from_untrusted_compositor_node_address(
+ candidate: CompositorUntrustedNodeAddress,
+ ) -> &'static Self {
+ // https://github.com/servo/servo/issues/6383
+ let candidate = candidate.0 as usize;
+ let object = candidate as *mut JSObject;
+ if object.is_null() {
+ panic!("Attempted to create a `Node` from an invalid pointer!")
+ }
+ &*(conversions::private_from_object(object) as *const Self)
+ }
+
pub(crate) fn html_serialize(
&self,
traversal_scope: html_serialize::TraversalScope,