Move non-gfx things out of gfx_traits and create a base crate (#32296)

For a long time, `gfx_traits` has held a lot of things unrelated to graphics
and also unrelated to the `gfx` crate (which is mostly about fonts).
This is a cleanup which does a few things:

1. Move non `gfx` crate things out of `gfx_traits`. This is important in
   order to prevent dependency cycles with a different integration between
   layout, script, and fonts.
2. Rename the `msg` crate to `base`. It didn't really contain anything
   to do with messages and instead mostly holds ids, which are used
   across many different crates in Servo. This new crate will hold the
   *rare* data types that are widely used.

Details:

 - All BackgroundHangMonitor-related things from base to a new
   `background_hang_monitor_api` crate.
 - Moved `TraversalDirection` to `script_traits`
 - Moved `Epoch`-related things from `gfx_traits` to `base`.
 - Moved `PrintTree` to base. This should be widely useful in Servo.
 - Moved `WebrenderApi` from `base` to `webrender_traits` and renamed it
   to `WebRenderFontApi`.
This commit is contained in:
Martin Robinson 2024-05-17 14:28:58 +02:00 committed by GitHub
parent 1017533297
commit 3398fc017b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
163 changed files with 709 additions and 632 deletions

View file

@ -4,9 +4,9 @@
use std::rc::Rc;
use base::id::PipelineId;
use dom_struct::dom_struct;
use js::rust::HandleObject;
use msg::constellation_msg::PipelineId;
use servo_media::audio::context::{LatencyCategory, ProcessingState, RealTimeAudioContextOptions};
use crate::dom::baseaudiocontext::{BaseAudioContext, BaseAudioContextOptions};

View file

@ -8,10 +8,10 @@ use std::collections::{HashMap, VecDeque};
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use base::id::PipelineId;
use dom_struct::dom_struct;
use js::rust::CustomAutoRooterGuard;
use js::typedarray::ArrayBuffer;
use msg::constellation_msg::PipelineId;
use servo_media::audio::context::{
AudioContext, AudioContextOptions, OfflineAudioContextOptions, ProcessingState,
RealTimeAudioContextOptions,

View file

@ -8,6 +8,7 @@ use std::collections::HashMap;
use std::os::raw;
use std::ptr;
use base::id::{BlobId, MessagePortId};
use js::glue::{
CopyJSStructuredCloneData, DeleteJSAutoStructuredCloneBuffer, GetLengthOfJSStructuredCloneData,
NewJSAutoStructuredCloneBuffer, WriteBytesToJSStructuredCloneData,
@ -22,7 +23,6 @@ use js::jsapi::{
use js::jsval::UndefinedValue;
use js::rust::wrappers::{JS_ReadStructuredClone, JS_WriteStructuredClone};
use js::rust::{CustomAutoRooterGuard, HandleValue, MutableHandleValue};
use msg::constellation_msg::{BlobId, MessagePortId};
use script_traits::serializable::BlobImpl;
use script_traits::transferable::MessagePortImpl;
use script_traits::StructuredSerializedData;

View file

@ -7,11 +7,11 @@ use std::num::NonZeroU32;
use std::ptr::NonNull;
use std::rc::Rc;
use base::id::{BlobId, BlobIndex, PipelineNamespaceId};
use dom_struct::dom_struct;
use encoding_rs::UTF_8;
use js::jsapi::JSObject;
use js::rust::HandleObject;
use msg::constellation_msg::{BlobId, BlobIndex, PipelineNamespaceId};
use net_traits::filemanager_thread::RelativePos;
use script_traits::serializable::BlobImpl;
use uuid::Uuid;

View file

@ -7,6 +7,7 @@ use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::thread::{self, JoinHandle};
use base::id::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId};
use crossbeam_channel::{unbounded, Receiver, Sender};
use devtools_traits::DevtoolScriptControlMsg;
use dom_struct::dom_struct;
@ -15,7 +16,6 @@ use ipc_channel::router::ROUTER;
use js::jsapi::{Heap, JSContext, JSObject, JS_AddInterruptCallback};
use js::jsval::UndefinedValue;
use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue};
use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId};
use net_traits::image_cache::ImageCache;
use net_traits::request::{
CredentialsMode, Destination, ParserMetadata, Referrer, RequestBuilder, RequestMode,

View file

@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use base::id::PipelineId;
use dom_struct::dom_struct;
use js::jsapi::{Heap, JSObject};
use js::jsval::{JSVal, UndefinedValue};
use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue};
use msg::constellation_msg::PipelineId;
use script_traits::{ScriptMsg, StructuredSerializedData};
use servo_url::ServoUrl;

View file

@ -13,6 +13,7 @@ use std::rc::Rc;
use std::slice::from_ref;
use std::time::{Duration, Instant};
use base::id::BrowsingContextId;
use canvas_traits::webgl::{self, WebGLContextId, WebGLMsg};
use content_security_policy::{self as csp, CspList};
use cookie::Cookie;
@ -33,7 +34,6 @@ use metrics::{
ProgressiveWebMetric,
};
use mime::{self, Mime};
use msg::constellation_msg::BrowsingContextId;
use net_traits::pub_domains::is_pub_domain;
use net_traits::request::RequestBuilder;
use net_traits::response::HttpsState;

View file

@ -15,6 +15,7 @@ use std::{fmt, mem};
use cssparser::match_ignore_ascii_case;
use devtools_traits::AttrInfo;
use dom_struct::dom_struct;
use embedder_traits::InputMethodType;
use euclid::default::{Rect, Size2D};
use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode};
use html5ever::serialize::{SerializeOpts, TraversalScope};
@ -25,7 +26,6 @@ use html5ever::{
use js::jsapi::Heap;
use js::jsval::JSVal;
use js::rust::HandleObject;
use msg::constellation_msg::InputMethodType;
use net_traits::request::CorsSettings;
use net_traits::ReferrerPolicy;
use script_layout_interface::ReflowGoal;

View file

@ -14,6 +14,10 @@ use std::thread::JoinHandle;
use std::time::Instant;
use std::{mem, ptr};
use base::id::{
BlobId, BroadcastChannelRouterId, MessagePortId, MessagePortRouterId, PipelineId,
ServiceWorkerId, ServiceWorkerRegistrationId,
};
use content_security_policy::CspList;
use crossbeam_channel::Sender;
use devtools_traits::{PageError, ScriptToDevtoolsControlMsg};
@ -34,10 +38,6 @@ use js::rust::{
MutableHandleValue, ParentRuntime, Runtime,
};
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
use msg::constellation_msg::{
BlobId, BroadcastChannelRouterId, MessagePortId, MessagePortRouterId, PipelineId,
ServiceWorkerId, ServiceWorkerRegistrationId,
};
use net_traits::blob_url_store::{get_blob_origin, BlobBuf};
use net_traits::filemanager_thread::{
FileManagerResult, FileManagerThreadMsg, ReadFileProgress, RelativePos,

View file

@ -5,15 +5,15 @@
use std::cell::Cell;
use std::cmp::Ordering;
use base::id::HistoryStateId;
use dom_struct::dom_struct;
use js::jsapi::Heap;
use js::jsval::{JSVal, NullValue, UndefinedValue};
use js::rust::HandleValue;
use msg::constellation_msg::{HistoryStateId, TraversalDirection};
use net_traits::{CoreResourceMsg, IpcSend};
use profile_traits::ipc;
use profile_traits::ipc::channel;
use script_traits::{ScriptMsg, StructuredSerializedData};
use script_traits::{ScriptMsg, StructuredSerializedData, TraversalDirection};
use servo_url::ServoUrl;
use crate::dom::bindings::codegen::Bindings::HistoryBinding::HistoryMethods;

View file

@ -4,11 +4,11 @@
use std::cell::Cell;
use base::id::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId};
use bitflags::bitflags;
use dom_struct::dom_struct;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::rust::HandleObject;
use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId};
use profile_traits::ipc as ProfiledIpc;
use script_layout_interface::ReflowGoal;
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};

View file

@ -9,6 +9,7 @@ use std::sync::{Arc, Mutex};
use std::{char, i32, mem};
use app_units::{Au, AU_PER_PX};
use base::id::PipelineId;
use cssparser::{Parser, ParserInput};
use dom_struct::dom_struct;
use euclid::Point2D;
@ -19,7 +20,6 @@ use ipc_channel::router::ROUTER;
use js::jsapi::JSAutoRealm;
use js::rust::HandleObject;
use mime::{self, Mime};
use msg::constellation_msg::PipelineId;
use net_traits::image::base::{Image, ImageMetadata};
use net_traits::image_cache::{
CorsStatus, ImageCache, ImageCacheResult, ImageOrMetadataAvailable, ImageResponse,

View file

@ -11,7 +11,7 @@ use std::{f64, ptr};
use chrono::naive::{NaiveDate, NaiveDateTime};
use chrono::{DateTime, Datelike, Weekday};
use dom_struct::dom_struct;
use embedder_traits::FilterPattern;
use embedder_traits::{FilterPattern, InputMethodType};
use encoding_rs::Encoding;
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
use js::jsapi::{
@ -21,7 +21,6 @@ use js::jsapi::{
use js::jsval::UndefinedValue;
use js::rust::jsapi_wrapped::{ExecuteRegExpNoStatics, ObjectIsRegExp};
use js::rust::{HandleObject, MutableHandleObject};
use msg::constellation_msg::InputMethodType;
use net_traits::blob_url_store::get_blob_origin;
use net_traits::filemanager_thread::FileManagerThreadMsg;
use net_traits::{CoreResourceMsg, IpcSend};

View file

@ -12,6 +12,7 @@ use std::ptr;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use base::id::PipelineId;
use content_security_policy as csp;
use dom_struct::dom_struct;
use encoding_rs::Encoding;
@ -24,7 +25,6 @@ use js::rust::{
transform_str_to_source_text, CompileOptionsWrapper, FinishOffThreadStencil, HandleObject,
Stencil,
};
use msg::constellation_msg::PipelineId;
use net_traits::request::{
CorsSettings, CredentialsMode, Destination, ParserMetadata, RequestBuilder,
};

View file

@ -8,10 +8,10 @@ use std::convert::TryInto;
use std::num::NonZeroU32;
use std::rc::Rc;
use base::id::{MessagePortId, MessagePortIndex, PipelineNamespaceId};
use dom_struct::dom_struct;
use js::jsapi::{Heap, JSObject, MutableHandleObject};
use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue};
use msg::constellation_msg::{MessagePortId, MessagePortIndex, PipelineNamespaceId};
use script_traits::PortMessageTask;
use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;

View file

@ -13,6 +13,7 @@ use std::sync::Arc as StdArc;
use std::{cmp, iter};
use app_units::Au;
use base::id::{BrowsingContextId, PipelineId};
use bitflags::bitflags;
use devtools_traits::NodeInfo;
use dom_struct::dom_struct;
@ -22,7 +23,6 @@ use js::jsapi::JSObject;
use js::rust::HandleObject;
use libc::{self, c_void, uintptr_t};
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use msg::constellation_msg::{BrowsingContextId, PipelineId};
use net_traits::image::base::{Image, ImageMetadata};
use script_layout_interface::{
GenericLayoutData, HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType, QueryMsg,

View file

@ -7,9 +7,9 @@ use std::rc::Rc;
use std::sync::{mpsc, Arc, Mutex};
use std::thread::Builder;
use base::id::PipelineId;
use dom_struct::dom_struct;
use js::rust::HandleObject;
use msg::constellation_msg::PipelineId;
use servo_media::audio::context::OfflineAudioContextOptions as ServoMediaOfflineAudioContextOptions;
use crate::dom::audiobuffer::{AudioBuffer, MAX_SAMPLE_RATE, MIN_SAMPLE_RATE};

View file

@ -10,6 +10,7 @@ use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use base::id::PipelineId;
use crossbeam_channel::{unbounded, Sender};
use dom_struct::dom_struct;
use euclid::{Scale, Size2D};
@ -20,7 +21,6 @@ use js::jsapi::{
use js::jsval::{JSVal, ObjectValue, UndefinedValue};
use js::rust::wrappers::{Call, Construct1};
use js::rust::{HandleValue, Runtime};
use msg::constellation_msg::PipelineId;
use net_traits::image_cache::ImageCache;
use pixels::PixelFormat;
use profile_traits::ipc;

View file

@ -4,10 +4,10 @@
use std::cell::Cell;
use base::id::ServiceWorkerId;
use dom_struct::dom_struct;
use js::jsapi::{Heap, JSObject};
use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue};
use msg::constellation_msg::ServiceWorkerId;
use script_traits::{DOMMessage, ScriptMsg};
use servo_url::ServoUrl;

View file

@ -7,6 +7,7 @@ use std::sync::Arc;
use std::thread::{self, JoinHandle};
use std::time::{Duration, Instant};
use base::id::PipelineId;
use crossbeam_channel::{after, unbounded, Receiver, Sender};
use devtools_traits::DevtoolScriptControlMsg;
use dom_struct::dom_struct;
@ -14,7 +15,6 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
use js::jsapi::{JSContext, JS_AddInterruptCallback};
use js::jsval::UndefinedValue;
use msg::constellation_msg::PipelineId;
use net_traits::request::{CredentialsMode, Destination, ParserMetadata, Referrer, RequestBuilder};
use net_traits::{CustomResponseMediator, IpcSend};
use parking_lot::Mutex;

View file

@ -4,9 +4,9 @@
use std::cell::Cell;
use base::id::ServiceWorkerRegistrationId;
use devtools_traits::WorkerId;
use dom_struct::dom_struct;
use msg::constellation_msg::ServiceWorkerRegistrationId;
use script_traits::{ScopeThings, WorkerScriptLoadOrigin};
use servo_url::ServoUrl;
use uuid::Uuid;

View file

@ -6,6 +6,7 @@ use std::borrow::Cow;
use std::cell::Cell;
use std::mem;
use base::id::PipelineId;
use base64::engine::general_purpose;
use base64::Engine as _;
use content_security_policy::{self as csp, CspList};
@ -20,7 +21,6 @@ use html5ever::tree_builder::{ElementFlags, NextParserState, NodeOrText, QuirksM
use html5ever::{local_name, namespace_url, ns, Attribute, ExpandedName, LocalName, QualName};
use hyper_serde::Serde;
use mime::{self, Mime};
use msg::constellation_msg::PipelineId;
use net_traits::{
FetchMetadata, FetchResponseListener, Metadata, NetworkError, ResourceFetchTiming,
ResourceTimingType,

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use base::id::PipelineId;
use html5ever::buffer_queue::BufferQueue;
use html5ever::tokenizer::states::RawKind;
use html5ever::tokenizer::{
@ -9,7 +10,6 @@ use html5ever::tokenizer::{
};
use html5ever::{local_name, Attribute, LocalName};
use js::jsapi::JSTracer;
use msg::constellation_msg::PipelineId;
use net_traits::request::{CorsSettings, CredentialsMode, ParserMetadata, Referrer};
use net_traits::{CoreResourceMsg, FetchChannels, IpcSend, ReferrerPolicy, ResourceThreads};
use servo_url::{ImmutableOrigin, ServoUrl};

View file

@ -4,10 +4,10 @@
use std::collections::HashMap;
use base::id::PipelineId;
use crossbeam_channel::Sender;
use dom_struct::dom_struct;
use js::rust::Runtime;
use msg::constellation_msg::PipelineId;
use servo_url::ServoUrl;
use crate::dom::bindings::cell::DomRefCell;

View file

@ -16,6 +16,7 @@ use std::{cmp, env, mem};
use app_units::Au;
use backtrace::Backtrace;
use base::id::{BrowsingContextId, PipelineId};
use base64::Engine;
use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLChan;
@ -26,7 +27,6 @@ use dom_struct::dom_struct;
use embedder_traits::{EmbedderMsg, PromptDefinition, PromptOrigin, PromptResult};
use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect};
use euclid::{Point2D, Rect, Scale, Size2D, Vector2D};
use gfx_traits::combine_id_with_fragment_type;
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use js::conversions::ToJSValConvertible;
@ -38,7 +38,6 @@ use js::rust::{
};
use malloc_size_of::MallocSizeOf;
use media::WindowGLContext;
use msg::constellation_msg::{BrowsingContextId, PipelineId};
use net_traits::image_cache::{
ImageCache, ImageResponder, ImageResponse, PendingImageId, PendingImageResponse,
};
@ -50,7 +49,8 @@ use profile_traits::ipc as ProfiledIpc;
use profile_traits::mem::ProfilerChan as MemProfilerChan;
use profile_traits::time::ProfilerChan as TimeProfilerChan;
use script_layout_interface::{
Layout, PendingImageState, QueryMsg, Reflow, ReflowGoal, ScriptReflow, TrustedNodeAddress,
combine_id_with_fragment_type, FragmentType, Layout, PendingImageState, QueryMsg, Reflow,
ReflowGoal, ScriptReflow, TrustedNodeAddress,
};
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use script_traits::{
@ -2110,10 +2110,7 @@ impl Window {
.borrow_mut()
.insert(node.to_opaque(), Vector2D::new(x_ as f32, y_ as f32));
let scroll_id = ExternalScrollId(
combine_id_with_fragment_type(
node.to_opaque().id(),
gfx_traits::FragmentType::FragmentBody,
),
combine_id_with_fragment_type(node.to_opaque().id(), FragmentType::FragmentBody),
self.pipeline_id().into(),
);

View file

@ -5,6 +5,7 @@
use std::cell::Cell;
use std::ptr;
use base::id::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId};
use dom_struct::dom_struct;
use embedder_traits::EmbedderMsg;
use html5ever::local_name;
@ -27,7 +28,6 @@ use js::jsval::{JSVal, NullValue, PrivateValue, UndefinedValue};
use js::rust::wrappers::{JS_TransplantObject, NewWindowProxy, SetWindowProxy};
use js::rust::{get_object_class, Handle, MutableHandle};
use js::JSCLASS_IS_GLOBAL;
use msg::constellation_msg::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId};
use net_traits::request::Referrer;
use script_traits::{
AuxiliaryBrowsingContextLoadInfo, HistoryEntryReplacement, LoadData, LoadOrigin, NewLayoutInfo,

View file

@ -7,6 +7,7 @@ use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use base::id::{PipelineId, PipelineNamespace};
use crossbeam_channel::Receiver;
use devtools_traits::{DevtoolScriptControlMsg, WorkerId};
use dom_struct::dom_struct;
@ -14,7 +15,6 @@ use ipc_channel::ipc::IpcSender;
use js::jsval::UndefinedValue;
use js::panic::maybe_resume_unwind;
use js::rust::{HandleValue, ParentRuntime};
use msg::constellation_msg::{PipelineId, PipelineNamespace};
use net_traits::request::{
CredentialsMode, Destination, ParserMetadata, RequestBuilder as NetRequestInit,
};

View file

@ -18,11 +18,11 @@ use std::sync::atomic::{AtomicIsize, Ordering};
use std::sync::Arc;
use std::thread;
use base::id::PipelineId;
use crossbeam_channel::{unbounded, Receiver, Sender};
use dom_struct::dom_struct;
use js::jsapi::{GCReason, JSGCParamKey, JSTracer, JS_GetGCParameter, JS_GC};
use malloc_size_of::malloc_size_of_is_0;
use msg::constellation_msg::PipelineId;
use net_traits::request::{Destination, RequestBuilder, RequestMode};
use net_traits::IpcSend;
use servo_url::{ImmutableOrigin, ServoUrl};

View file

@ -5,13 +5,13 @@
use std::borrow::Cow;
use std::sync::Arc;
use base::id::PipelineId;
use crossbeam_channel::Sender;
use devtools_traits::ScriptToDevtoolsControlMsg;
use dom_struct::dom_struct;
use ipc_channel::ipc::IpcSender;
use js::jsval::UndefinedValue;
use js::rust::Runtime;
use msg::constellation_msg::PipelineId;
use net_traits::image_cache::ImageCache;
use net_traits::ResourceThreads;
use parking_lot::Mutex;

View file

@ -5,10 +5,10 @@
use std::cell::Cell;
use std::rc::Rc;
use base::id::PipelineId;
use dom_struct::dom_struct;
use ipc_channel::ipc::{self as ipc_crate, IpcReceiver};
use ipc_channel::router::ROUTER;
use msg::constellation_msg::PipelineId;
use profile_traits::ipc;
use servo_config::pref;
use webxr_api::{Error as XRError, Frame, Session, SessionInit, SessionMode};