Create a constellation_traits crate (#36088)

This change creates a `constellation_traits` crate. Previously messages
to the `Constellation` were in the `compositing_traits` crate, which
came about organically. This change moves these to a new crate which
also contains data types that are used in both compositing/libservo and
script (ie types that cross the process boundary). The idea is similar
to `embedding_traits`, but this is meant for types not exposed to the
API.

This change allows deduplicating `UntrustedNodeAddress`, which
previously had two versions to avoid circular dependencies.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-03-22 16:49:08 +01:00 committed by GitHub
parent 02375809b0
commit 7c574141c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 399 additions and 270 deletions

View file

@ -45,6 +45,7 @@ bincode = { workspace = true }
bitflags = { workspace = true }
bluetooth_traits = { workspace = true, optional = true }
canvas_traits = { workspace = true }
constellation_traits = { workspace = true }
cbc = { workspace = true }
cipher = { workspace = true }
chrono = { workspace = true }

View file

@ -7,10 +7,11 @@
use std::cell::Cell;
use base::id::PipelineId;
use constellation_traits::UntrustedNodeAddress;
use cssparser::ToCss;
use fxhash::{FxHashMap, FxHashSet};
use libc::c_void;
use script_traits::{AnimationState as AnimationsPresentState, ScriptMsg, UntrustedNodeAddress};
use script_traits::{AnimationState as AnimationsPresentState, ScriptMsg};
use serde::{Deserialize, Serialize};
use style::animation::{
Animation, AnimationSetKey, AnimationState, DocumentAnimationSet, ElementAnimationSet,

View file

@ -19,6 +19,7 @@ use base::cross_process_instant::CrossProcessInstant;
use base::id::WebViewId;
use canvas_traits::webgl::{self, WebGLContextId, WebGLMsg};
use chrono::Local;
use constellation_traits::{AnimationTickType, CompositorHitTestResult};
use content_security_policy::{self as csp, CspList, PolicyDisposition};
use cookie::Cookie;
use cssparser::match_ignore_ascii_case;
@ -51,8 +52,7 @@ use profile_traits::ipc as profile_ipc;
use profile_traits::time::TimerMetadataFrameType;
use script_layout_interface::{PendingRestyle, TrustedNodeAddress};
use script_traits::{
AnimationState, AnimationTickType, ConstellationInputEvent, DocumentActivity,
ProgressiveWebMetricType, ScriptMsg,
AnimationState, ConstellationInputEvent, DocumentActivity, ProgressiveWebMetricType, ScriptMsg,
};
use servo_arc::Arc;
use servo_config::pref;
@ -72,7 +72,6 @@ use uuid::Uuid;
#[cfg(feature = "webgpu")]
use webgpu::swapchain::WebGPUContextId;
use webrender_api::units::DeviceIntRect;
use webrender_traits::CompositorHitTestResult;
use super::bindings::codegen::Bindings::XPathEvaluatorBinding::XPathEvaluatorMethods;
use super::clipboardevent::ClipboardEventType;

View file

@ -4,9 +4,9 @@
use std::fmt;
use constellation_traits::UntrustedNodeAddress;
use euclid::default::Point2D;
use script_layout_interface::{NodesFromPointQueryType, QueryMsg};
use script_traits::UntrustedNodeAddress;
use servo_arc::Arc;
use style::invalidation::media_queries::{MediaListKey, ToMediaListKey};
use style::media_queries::MediaList;

View file

@ -6,8 +6,8 @@ use std::cell::Cell;
use std::cmp::Ordering;
use base::id::HistoryStateId;
use constellation_traits::TraversalDirection;
use dom_struct::dom_struct;
use embedder_traits::TraversalDirection;
use js::jsapi::Heap;
use js::jsval::{JSVal, NullValue, UndefinedValue};
use js::rust::{HandleValue, MutableHandleValue};

View file

@ -6,6 +6,7 @@ use std::cell::Cell;
use base::id::{BrowsingContextId, PipelineId, WebViewId};
use bitflags::bitflags;
use constellation_traits::WindowSizeData;
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix, local_name, namespace_url, ns};
use js::rust::HandleObject;
@ -14,7 +15,7 @@ use profile_traits::ipc as ProfiledIpc;
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
use script_traits::{
IFrameLoadInfo, IFrameLoadInfoWithData, JsEvalResult, LoadData, LoadOrigin,
NavigationHistoryBehavior, NewLayoutInfo, ScriptMsg, UpdatePipelineIdReason, WindowSizeData,
NavigationHistoryBehavior, NewLayoutInfo, ScriptMsg, UpdatePipelineIdReason,
};
use servo_url::ServoUrl;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};

View file

@ -5,11 +5,11 @@
use std::cell::Cell;
use std::default::Default;
use constellation_traits::CompositorHitTestResult;
use dom_struct::dom_struct;
use euclid::default::Point2D;
use js::rust::HandleObject;
use servo_config::pref;
use webrender_traits::CompositorHitTestResult;
use crate::dom::bindings::codegen::Bindings::EventBinding::Event_Binding::EventMethods;
use crate::dom::bindings::codegen::Bindings::MouseEventBinding;

View file

@ -15,6 +15,9 @@ use std::{cmp, fmt, iter};
use app_units::Au;
use base::id::{BrowsingContextId, PipelineId};
use bitflags::bitflags;
use constellation_traits::{
UntrustedNodeAddress, UntrustedNodeAddress as CompositorUntrustedNodeAddress,
};
use devtools_traits::NodeInfo;
use dom_struct::dom_struct;
use euclid::default::{Rect, Size2D, Vector2D};
@ -28,7 +31,7 @@ use script_layout_interface::{
GenericLayoutData, HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType, QueryMsg,
SVGSVGData, StyleData, TrustedNodeAddress,
};
use script_traits::{DocumentActivity, UntrustedNodeAddress};
use script_traits::DocumentActivity;
use selectors::matching::{
MatchingContext, MatchingForInvalidation, MatchingMode, NeedsSelectorFlags,
matches_selector_list,
@ -44,7 +47,6 @@ 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;

View file

@ -21,6 +21,7 @@ use base64::Engine;
#[cfg(feature = "bluetooth")]
use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLChan;
use constellation_traits::{ScrollState, WindowSizeData, WindowSizeType};
use crossbeam_channel::{Sender, unbounded};
use cssparser::{Parser, ParserInput, SourceLocation};
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
@ -61,7 +62,7 @@ use script_layout_interface::{
};
use script_traits::{
DocumentState, LoadData, LoadOrigin, NavigationHistoryBehavior, ScriptMsg, ScriptThreadMessage,
ScriptToConstellationChan, StructuredSerializedData, WindowSizeData, WindowSizeType,
ScriptToConstellationChan, StructuredSerializedData,
};
use selectors::attr::CaseSensitivity;
use servo_arc::Arc as ServoArc;
@ -83,7 +84,7 @@ use stylo_atoms::Atom;
use url::Position;
use webrender_api::units::{DevicePixel, LayoutPixel};
use webrender_api::{DocumentId, ExternalScrollId};
use webrender_traits::{CrossProcessCompositorApi, ScrollState};
use webrender_traits::CrossProcessCompositorApi;
use super::bindings::codegen::Bindings::MessagePortBinding::StructuredSerializeOptions;
use super::bindings::trace::HashMapTracedValues;

View file

@ -6,10 +6,11 @@ use std::cell::Cell;
use std::default::Default;
use base::id::BrowsingContextId;
use constellation_traits::{WindowSizeData, WindowSizeType};
use euclid::{Scale, Size2D};
use fnv::FnvHashMap;
use script_layout_interface::IFrameSizes;
use script_traits::{IFrameSizeMsg, WindowSizeData, WindowSizeType};
use script_traits::IFrameSizeMsg;
use style_traits::CSSPixel;
use webrender_api::units::DevicePixel;

View file

@ -7,13 +7,13 @@ use std::sync::atomic::Ordering;
use std::{fmt, slice};
use atomic_refcell::{AtomicRef, AtomicRefMut};
use constellation_traits::UntrustedNodeAddress;
use html5ever::{LocalName, Namespace, local_name, namespace_url, ns};
use js::jsapi::JSObject;
use script_layout_interface::wrapper_traits::{
LayoutNode, PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
};
use script_layout_interface::{LayoutNodeType, StyleData};
use script_traits::UntrustedNodeAddress;
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
use selectors::bloom::{BLOOM_HASH_MASK, BloomFilter};
use selectors::matching::{ElementSelectorFlags, MatchingContext, VisitedHandlingMode};

View file

@ -10,6 +10,7 @@ use std::cell::Cell;
use base::cross_process_instant::CrossProcessInstant;
use base::id::{BrowsingContextId, PipelineId, WebViewId};
use constellation_traits::WindowSizeData;
use content_security_policy::Destination;
use crossbeam_channel::Sender;
use http::header;
@ -21,7 +22,7 @@ use net_traits::{
BoxedFetchCallback, CoreResourceThread, DOCUMENT_ACCEPT_HEADER_VALUE, FetchResponseMsg,
Metadata, fetch_async, set_default_accept_language,
};
use script_traits::{DocumentActivity, LoadData, WindowSizeData};
use script_traits::{DocumentActivity, LoadData};
use servo_url::{MutableOrigin, ServoUrl};
use crate::fetch::FetchCanceller;

View file

@ -37,6 +37,7 @@ use base::cross_process_instant::CrossProcessInstant;
use base::id::{BrowsingContextId, HistoryStateId, PipelineId, PipelineNamespace, WebViewId};
use canvas_traits::webgl::WebGLPipeline;
use chrono::{DateTime, Local};
use constellation_traits::{CompositorHitTestResult, ScrollState, WindowSizeData, WindowSizeType};
use crossbeam_channel::unbounded;
use devtools_traits::{
CSSError, DevtoolScriptControlMsg, DevtoolsPageInfo, NavigationState,
@ -80,7 +81,7 @@ use script_traits::{
ConstellationInputEvent, DiscardBrowsingContext, DocumentActivity, InitialScriptState,
JsEvalResult, LoadData, LoadOrigin, NavigationHistoryBehavior, NewLayoutInfo, Painter,
ProgressiveWebMetricType, ScriptMsg, ScriptThreadMessage, ScriptToConstellationChan,
StructuredSerializedData, UpdatePipelineIdReason, WindowSizeData, WindowSizeType,
StructuredSerializedData, UpdatePipelineIdReason,
};
use servo_config::opts;
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
@ -92,7 +93,7 @@ use url::Position;
#[cfg(feature = "webgpu")]
use webgpu::{WebGPUDevice, WebGPUMsg};
use webrender_api::DocumentId;
use webrender_traits::{CompositorHitTestResult, CrossProcessCompositorApi, ScrollState};
use webrender_traits::CrossProcessCompositorApi;
use crate::document_collection::DocumentCollection;
use crate::document_loader::DocumentLoader;