From 69ff4afa580c1bc551807349f3495658d13b2d41 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Fri, 20 Jun 2025 19:13:05 +0200 Subject: [PATCH] Rename `script_layout_interface` to `layout_api` (#37591) Now that we are standardizing on the `_traits` crates becoming `_api` and exposing the API of the crate that they get their name from [^1], `script_layout_interface` becomes `layout_api` as it exposes the API for `layout` that is used by `script` This brings the crate in line with the naming of the other ones in `shared`. [^1]: https://servo.zulipchat.com/#narrow/channel/263398-general/topic/Organizing.20*_traits.20crates/with/396893711 Testing: This should not change any behavior and thus is covered by existing tests. Signed-off-by: Martin Robinson --- Cargo.lock | 74 +++++++++---------- Cargo.toml | 2 +- components/constellation/Cargo.toml | 2 +- components/constellation/constellation.rs | 2 +- components/constellation/pipeline.rs | 2 +- components/layout/Cargo.toml | 2 +- components/layout/context.rs | 6 +- components/layout/dom.rs | 12 +-- components/layout/dom_traversal.rs | 6 +- components/layout/flow/inline/inline_box.rs | 2 +- components/layout/flow/inline/mod.rs | 2 +- components/layout/flow/root.rs | 6 +- .../layout/fragment_tree/base_fragment.rs | 2 +- components/layout/layout_impl.rs | 13 ++-- components/layout/query.rs | 6 +- components/layout/replaced.rs | 2 +- components/layout/table/construct.rs | 2 +- components/layout/traversal.rs | 2 +- components/script/Cargo.toml | 2 +- components/script/canvas_context.rs | 2 +- components/script/dom/bindings/root.rs | 2 +- components/script/dom/document.rs | 2 +- components/script/dom/documentorshadowroot.rs | 2 +- components/script/dom/htmlcanvaselement.rs | 2 +- components/script/dom/htmlelement.rs | 2 +- components/script/dom/htmlmediaelement.rs | 2 +- components/script/dom/htmlvideoelement.rs | 2 +- components/script/dom/node.rs | 8 +- components/script/dom/svgsvgelement.rs | 2 +- components/script/dom/window.rs | 8 +- components/script/iframe_collection.rs | 2 +- components/script/image_animation.rs | 2 +- components/script/layout_dom/element.rs | 6 +- components/script/layout_dom/node.rs | 10 +-- components/script/script_thread.rs | 2 +- components/servo/Cargo.toml | 2 +- components/servo/lib.rs | 2 +- .../{script_layout => layout}/Cargo.toml | 4 +- .../shared/{script_layout => layout}/lib.rs | 2 +- .../wrapper_traits.rs | 0 python/servo/testing_commands.py | 2 +- 41 files changed, 102 insertions(+), 113 deletions(-) rename components/shared/{script_layout => layout}/Cargo.toml (94%) rename components/shared/{script_layout => layout}/lib.rs (99%) rename components/shared/{script_layout => layout}/wrapper_traits.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index e8ab5d560a0..5a2d074ef80 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1175,6 +1175,7 @@ dependencies = [ "gaol", "ipc-channel", "keyboard-types", + "layout_api", "log", "media", "net", @@ -1182,7 +1183,6 @@ dependencies = [ "parking_lot", "profile", "profile_traits", - "script_layout_interface", "script_traits", "serde", "servo-tracing", @@ -4314,6 +4314,7 @@ dependencies = [ "icu_segmenter", "ipc-channel", "itertools 0.14.0", + "layout_api", "log", "malloc_size_of_derive", "net_traits", @@ -4325,7 +4326,6 @@ dependencies = [ "range", "rayon", "script", - "script_layout_interface", "script_traits", "selectors", "servo-tracing", @@ -4346,6 +4346,39 @@ dependencies = [ "xi-unicode", ] +[[package]] +name = "layout_api" +version = "0.0.1" +dependencies = [ + "app_units", + "atomic_refcell", + "base", + "compositing_traits", + "constellation_traits", + "embedder_traits", + "euclid", + "fnv", + "fonts", + "fonts_traits", + "fxhash", + "html5ever", + "ipc-channel", + "libc", + "malloc_size_of_derive", + "net_traits", + "pixels", + "profile_traits", + "range", + "script_traits", + "selectors", + "serde", + "servo_arc", + "servo_malloc_size_of", + "servo_url", + "stylo", + "webrender_api", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -4453,6 +4486,7 @@ dependencies = [ "ipc-channel", "keyboard-types", "layout", + "layout_api", "libservo", "log", "media", @@ -4465,7 +4499,6 @@ dependencies = [ "rayon", "rustls", "script", - "script_layout_interface", "script_traits", "serde", "servo-media", @@ -6613,6 +6646,7 @@ dependencies = [ "itertools 0.14.0", "jstraceable_derive", "keyboard-types", + "layout_api", "libc", "log", "malloc_size_of_derive", @@ -6634,7 +6668,6 @@ dependencies = [ "range", "regex", "script_bindings", - "script_layout_interface", "script_traits", "selectors", "serde", @@ -6713,39 +6746,6 @@ dependencies = [ "xml5ever", ] -[[package]] -name = "script_layout_interface" -version = "0.0.1" -dependencies = [ - "app_units", - "atomic_refcell", - "base", - "compositing_traits", - "constellation_traits", - "embedder_traits", - "euclid", - "fnv", - "fonts", - "fonts_traits", - "fxhash", - "html5ever", - "ipc-channel", - "libc", - "malloc_size_of_derive", - "net_traits", - "pixels", - "profile_traits", - "range", - "script_traits", - "selectors", - "serde", - "servo_arc", - "servo_malloc_size_of", - "servo_url", - "stylo", - "webrender_api", -] - [[package]] name = "script_tests" version = "0.0.1" diff --git a/Cargo.toml b/Cargo.toml index f74964ed07b..56f0d36ccf7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -118,7 +118,7 @@ resvg = "0.45.0" rustls = { version = "0.23", default-features = false, features = ["logging", "std", "tls12"] } rustls-pemfile = "2.0" rustls-pki-types = "1.12" -script_layout_interface = { path = "components/shared/script_layout" } +layout_api = { path = "components/shared/layout" } script_traits = { path = "components/shared/script" } selectors = { git = "https://github.com/servo/stylo", branch = "2025-06-03" } serde = "1.0.219" diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml index dd1e407b3c2..c1a0249828a 100644 --- a/components/constellation/Cargo.toml +++ b/components/constellation/Cargo.toml @@ -33,6 +33,7 @@ euclid = { workspace = true } fonts = { path = "../fonts" } ipc-channel = { workspace = true } keyboard-types = { workspace = true } +layout_api = { workspace = true } log = { workspace = true } media = { path = "../media" } net = { path = "../net" } @@ -40,7 +41,6 @@ net_traits = { workspace = true } parking_lot = { workspace = true } profile = { path = "../profile" } profile_traits = { workspace = true } -script_layout_interface = { workspace = true } script_traits = { workspace = true } serde = { workspace = true } servo_config = { path = "../config" } diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 6a07bbcb60e..957bf6a9247 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -142,6 +142,7 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use keyboard_types::webdriver::Event as WebDriverInputEvent; use keyboard_types::{Key, KeyState, Modifiers}; +use layout_api::{LayoutFactory, ScriptThreadFactory}; use log::{debug, error, info, trace, warn}; use media::WindowGLContext; use net_traits::pub_domains::reg_host; @@ -150,7 +151,6 @@ use net_traits::storage_thread::{StorageThreadMsg, StorageType}; use net_traits::{self, IpcSend, ReferrerPolicy, ResourceThreads}; use profile_traits::mem::ProfilerMsg; use profile_traits::{mem, time}; -use script_layout_interface::{LayoutFactory, ScriptThreadFactory}; use script_traits::{ ConstellationInputEvent, DiscardBrowsingContext, DocumentActivity, ProgressiveWebMetricType, ScriptThreadMessage, UpdatePipelineIdReason, diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs index 53a7560ed1f..b49d8d1c927 100644 --- a/components/constellation/pipeline.rs +++ b/components/constellation/pipeline.rs @@ -30,6 +30,7 @@ use fonts::{SystemFontServiceProxy, SystemFontServiceProxySender}; use ipc_channel::Error; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; +use layout_api::{LayoutFactory, ScriptThreadFactory}; use log::{debug, error, warn}; use media::WindowGLContext; use net::image_cache::ImageCacheImpl; @@ -38,7 +39,6 @@ use net_traits::image_cache::ImageCache; use profile::system_reporter; use profile_traits::mem::{ProfilerMsg, Reporter}; use profile_traits::{mem as profile_mem, time}; -use script_layout_interface::{LayoutFactory, ScriptThreadFactory}; use script_traits::{ DiscardBrowsingContext, DocumentActivity, InitialScriptState, NewLayoutInfo, ScriptThreadMessage, diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index 72ed7e4aa25..bb500d6f98c 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -35,6 +35,7 @@ icu_locid = { workspace = true } icu_segmenter = { workspace = true } ipc-channel = { workspace = true } itertools = { workspace = true } +layout_api = { workspace = true } log = { workspace = true } malloc_size_of = { workspace = true } malloc_size_of_derive = { workspace = true } @@ -45,7 +46,6 @@ profile_traits = { workspace = true } range = { path = "../range" } rayon = { workspace = true } script = { path = "../script" } -script_layout_interface = { workspace = true } script_traits = { workspace = true } selectors = { workspace = true } servo_arc = { workspace = true } diff --git a/components/layout/context.rs b/components/layout/context.rs index 5360c24ae9f..a1aac631fbc 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -9,15 +9,15 @@ use euclid::Size2D; use fnv::FnvHashMap; use fonts::FontContext; use fxhash::FxHashMap; +use layout_api::{ + IFrameSizes, ImageAnimationState, PendingImage, PendingImageState, PendingRasterizationImage, +}; use net_traits::image_cache::{ Image as CachedImage, ImageCache, ImageCacheResult, ImageOrMetadataAvailable, PendingImageId, UsePlaceholder, }; use parking_lot::{Mutex, RwLock}; use pixels::RasterImage; -use script_layout_interface::{ - IFrameSizes, ImageAnimationState, PendingImage, PendingImageState, PendingRasterizationImage, -}; use servo_url::{ImmutableOrigin, ServoUrl}; use style::context::SharedStyleContext; use style::dom::OpaqueNode; diff --git a/components/layout/dom.rs b/components/layout/dom.rs index 129f1338ffe..87ce8a03a1e 100644 --- a/components/layout/dom.rs +++ b/components/layout/dom.rs @@ -8,15 +8,15 @@ use std::marker::PhantomData; use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut}; use base::id::{BrowsingContextId, PipelineId}; use html5ever::{local_name, ns}; +use layout_api::wrapper_traits::{ + LayoutDataTrait, LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode, +}; +use layout_api::{ + GenericLayoutDataTrait, LayoutElementType, LayoutNodeType as ScriptLayoutNodeType, +}; use malloc_size_of_derive::MallocSizeOf; use net_traits::image_cache::Image; use script::layout_dom::ServoLayoutNode; -use script_layout_interface::wrapper_traits::{ - LayoutDataTrait, LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode, -}; -use script_layout_interface::{ - GenericLayoutDataTrait, LayoutElementType, LayoutNodeType as ScriptLayoutNodeType, -}; use servo_arc::Arc as ServoArc; use style::context::SharedStyleContext; use style::properties::ComputedValues; diff --git a/components/layout/dom_traversal.rs b/components/layout/dom_traversal.rs index 8bf6d919fa3..f27672b8c9f 100644 --- a/components/layout/dom_traversal.rs +++ b/components/layout/dom_traversal.rs @@ -7,12 +7,10 @@ use std::iter::FusedIterator; use fonts::ByteIndex; use html5ever::{LocalName, local_name}; +use layout_api::wrapper_traits::{LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; +use layout_api::{LayoutElementType, LayoutNodeType}; use range::Range; use script::layout_dom::ServoLayoutNode; -use script_layout_interface::wrapper_traits::{ - LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode, -}; -use script_layout_interface::{LayoutElementType, LayoutNodeType}; use selectors::Element as SelectorsElement; use servo_arc::Arc as ServoArc; use style::dom::{NodeInfo, TElement, TNode, TShadowRoot}; diff --git a/components/layout/flow/inline/inline_box.rs b/components/layout/flow/inline/inline_box.rs index a9642d3b222..0db6dd72d59 100644 --- a/components/layout/flow/inline/inline_box.rs +++ b/components/layout/flow/inline/inline_box.rs @@ -6,9 +6,9 @@ use std::vec::IntoIter; use app_units::Au; use fonts::FontMetrics; +use layout_api::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode}; use malloc_size_of_derive::MallocSizeOf; use script::layout_dom::ServoLayoutNode; -use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode}; use servo_arc::Arc as ServoArc; use style::properties::ComputedValues; diff --git a/components/layout/flow/inline/mod.rs b/components/layout/flow/inline/mod.rs index 8a3df569822..06cc7f2acad 100644 --- a/components/layout/flow/inline/mod.rs +++ b/components/layout/flow/inline/mod.rs @@ -83,6 +83,7 @@ use bitflags::bitflags; use construct::InlineFormattingContextBuilder; use fonts::{ByteIndex, FontMetrics, GlyphStore}; use inline_box::{InlineBox, InlineBoxContainerState, InlineBoxIdentifier, InlineBoxes}; +use layout_api::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode}; use line::{ AbsolutelyPositionedLineItem, AtomicLineItem, FloatLineItem, LineItem, LineItemLayout, TextRunLineItem, @@ -91,7 +92,6 @@ use line_breaker::LineBreaker; use malloc_size_of_derive::MallocSizeOf; use range::Range; use script::layout_dom::ServoLayoutNode; -use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode}; use servo_arc::Arc; use style::Zero; use style::computed_values::text_wrap_mode::T as TextWrapMode; diff --git a/components/layout/flow/root.rs b/components/layout/flow/root.rs index 84b832d4b62..ad52da593e4 100644 --- a/components/layout/flow/root.rs +++ b/components/layout/flow/root.rs @@ -7,12 +7,10 @@ use atomic_refcell::AtomicRef; use compositing_traits::display_list::AxesScrollSensitivity; use euclid::Rect; use euclid::default::Size2D as UntypedSize2D; +use layout_api::wrapper_traits::{LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; +use layout_api::{LayoutElementType, LayoutNodeType}; use malloc_size_of_derive::MallocSizeOf; use script::layout_dom::ServoLayoutNode; -use script_layout_interface::wrapper_traits::{ - LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode, -}; -use script_layout_interface::{LayoutElementType, LayoutNodeType}; use servo_arc::Arc; use style::dom::{NodeInfo, TNode}; use style::properties::ComputedValues; diff --git a/components/layout/fragment_tree/base_fragment.rs b/components/layout/fragment_tree/base_fragment.rs index ff5df44c225..8009135c17d 100644 --- a/components/layout/fragment_tree/base_fragment.rs +++ b/components/layout/fragment_tree/base_fragment.rs @@ -3,9 +3,9 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use bitflags::bitflags; +use layout_api::combine_id_with_fragment_type; use malloc_size_of::malloc_size_of_is_0; use malloc_size_of_derive::MallocSizeOf; -use script_layout_interface::combine_id_with_fragment_type; use style::dom::OpaqueNode; use style::selector_parser::PseudoElement; diff --git a/components/layout/layout_impl.rs b/components/layout/layout_impl.rs index 5cfd23351c7..8730902549f 100644 --- a/components/layout/layout_impl.rs +++ b/components/layout/layout_impl.rs @@ -24,6 +24,10 @@ use fonts::{FontContext, FontContextWebFontMethods}; use fonts_traits::StylesheetWebFontLoadFinishedCallback; use fxhash::FxHashMap; use ipc_channel::ipc::IpcSender; +use layout_api::{ + Layout, LayoutConfig, LayoutFactory, NodesFromPointQueryType, OffsetParentResponse, ReflowGoal, + ReflowRequest, ReflowResult, TrustedNodeAddress, +}; use log::{debug, error, warn}; use malloc_size_of::{MallocConditionalSizeOf, MallocSizeOf, MallocSizeOfOps}; use net_traits::image_cache::{ImageCache, UsePlaceholder}; @@ -35,10 +39,6 @@ use profile_traits::time::{ use profile_traits::{path, time_profile}; use rayon::ThreadPool; use script::layout_dom::{ServoLayoutDocument, ServoLayoutElement, ServoLayoutNode}; -use script_layout_interface::{ - Layout, LayoutConfig, LayoutFactory, NodesFromPointQueryType, OffsetParentResponse, ReflowGoal, - ReflowRequest, ReflowResult, TrustedNodeAddress, -}; use script_traits::{DrawAPaintImageResult, PaintWorkletError, Painter, ScriptThreadMessage}; use servo_arc::Arc as ServoArc; use servo_config::opts::{self, DebugOptions}; @@ -271,10 +271,7 @@ impl Layout for LayoutThread { } #[servo_tracing::instrument(skip_all)] - fn query_element_inner_outer_text( - &self, - node: script_layout_interface::TrustedNodeAddress, - ) -> String { + fn query_element_inner_outer_text(&self, node: layout_api::TrustedNodeAddress) -> String { let node = unsafe { ServoLayoutNode::new(&node) }; get_the_text_steps(node) } diff --git a/components/layout/query.rs b/components/layout/query.rs index 21f43a34fd7..1761faed012 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -9,11 +9,9 @@ use app_units::Au; use euclid::default::{Point2D, Rect}; use euclid::{SideOffsets2D, Size2D}; use itertools::Itertools; +use layout_api::wrapper_traits::{LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; +use layout_api::{LayoutElementType, LayoutNodeType, OffsetParentResponse}; use script::layout_dom::ServoLayoutNode; -use script_layout_interface::wrapper_traits::{ - LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode, -}; -use script_layout_interface::{LayoutElementType, LayoutNodeType, OffsetParentResponse}; use servo_arc::Arc as ServoArc; use servo_url::ServoUrl; use style::computed_values::display::T as Display; diff --git a/components/layout/replaced.rs b/components/layout/replaced.rs index 46c179c6c14..1f2f55502f6 100644 --- a/components/layout/replaced.rs +++ b/components/layout/replaced.rs @@ -9,10 +9,10 @@ use base::id::{BrowsingContextId, PipelineId}; use data_url::DataUrl; use embedder_traits::ViewportDetails; use euclid::{Scale, Size2D}; +use layout_api::IFrameSize; use malloc_size_of_derive::MallocSizeOf; use net_traits::image_cache::{Image, ImageOrMetadataAvailable, UsePlaceholder}; use script::layout_dom::ServoLayoutNode; -use script_layout_interface::IFrameSize; use servo_arc::Arc as ServoArc; use style::Zero; use style::computed_values::object_fit::T as ObjectFit; diff --git a/components/layout/table/construct.rs b/components/layout/table/construct.rs index 0b22ea1c13a..191faaa77c5 100644 --- a/components/layout/table/construct.rs +++ b/components/layout/table/construct.rs @@ -7,8 +7,8 @@ use std::convert::{TryFrom, TryInto}; use std::iter::repeat; use atomic_refcell::AtomicRef; +use layout_api::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode}; use log::warn; -use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode}; use servo_arc::Arc; use style::properties::ComputedValues; use style::properties::style_structs::Font; diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index 22faa4b1191..f8d24dfb489 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -2,8 +2,8 @@ * 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 layout_api::wrapper_traits::LayoutNode; use script::layout_dom::ServoLayoutNode; -use script_layout_interface::wrapper_traits::LayoutNode; use style::context::{SharedStyleContext, StyleContext}; use style::data::ElementData; use style::dom::{NodeInfo, TElement, TNode}; diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 1cbf7c47e01..ae1a74bd1a4 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -81,6 +81,7 @@ itertools = { workspace = true } js = { workspace = true } jstraceable_derive = { path = "../jstraceable_derive" } keyboard-types = { workspace = true } +layout_api = { workspace = true } libc = { workspace = true } log = { workspace = true } malloc_size_of = { workspace = true } @@ -101,7 +102,6 @@ profile_traits = { workspace = true } range = { path = "../range" } regex = { workspace = true } script_bindings = { path = "../script_bindings" } -script_layout_interface = { workspace = true } script_traits = { workspace = true } selectors = { workspace = true } serde = { workspace = true, features = ["derive"] } diff --git a/components/script/canvas_context.rs b/components/script/canvas_context.rs index a4db133673e..7570a5691af 100644 --- a/components/script/canvas_context.rs +++ b/components/script/canvas_context.rs @@ -5,9 +5,9 @@ //! Common interfaces for Canvas Contexts use euclid::default::Size2D; +use layout_api::HTMLCanvasData; use pixels::Snapshot; use script_bindings::root::Dom; -use script_layout_interface::HTMLCanvasData; use webrender_api::ImageKey; use crate::dom::bindings::codegen::UnionTypes::HTMLCanvasElementOrOffscreenCanvas; diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index 923aa51351d..ab999cab6ba 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -31,9 +31,9 @@ use std::marker::PhantomData; use std::{mem, ptr}; use js::jsapi::{JSObject, JSTracer}; +use layout_api::TrustedNodeAddress; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; pub(crate) use script_bindings::root::*; -use script_layout_interface::TrustedNodeAddress; use style::thread_state; use crate::dom::bindings::conversions::DerivedFrom; diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 9253cc79463..0e7992799da 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -41,6 +41,7 @@ use hyper_serde::Serde; use ipc_channel::ipc; use js::rust::{HandleObject, HandleValue}; use keyboard_types::{Code, Key, KeyState, Modifiers}; +use layout_api::{PendingRestyle, TrustedNodeAddress, node_id_from_scroll_id}; use metrics::{InteractiveFlag, InteractiveWindow, ProgressiveWebMetrics}; use net_traits::CookieSource::NonHTTP; use net_traits::CoreResourceMsg::{GetCookiesForUrl, SetCookiesForUrl}; @@ -55,7 +56,6 @@ use profile_traits::ipc as profile_ipc; use profile_traits::time::TimerMetadataFrameType; use regex::bytes::Regex; use script_bindings::interfaces::DocumentHelpers; -use script_layout_interface::{PendingRestyle, TrustedNodeAddress, node_id_from_scroll_id}; use script_traits::{ConstellationInputEvent, DocumentActivity, ProgressiveWebMetricType}; use servo_arc::Arc; use servo_config::pref; diff --git a/components/script/dom/documentorshadowroot.rs b/components/script/dom/documentorshadowroot.rs index 5672282f921..d46cfacd76d 100644 --- a/components/script/dom/documentorshadowroot.rs +++ b/components/script/dom/documentorshadowroot.rs @@ -6,7 +6,7 @@ use std::fmt; use embedder_traits::UntrustedNodeAddress; use euclid::default::Point2D; -use script_layout_interface::{NodesFromPointQueryType, QueryMsg}; +use layout_api::{NodesFromPointQueryType, QueryMsg}; use servo_arc::Arc; use style::invalidation::media_queries::{MediaListKey, ToMediaListKey}; use style::media_queries::MediaList; diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index a783a8794e4..8539bca6183 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -21,8 +21,8 @@ use image::{ColorType, ImageEncoder, ImageError}; use ipc_channel::ipc::{self as ipcchan}; use js::error::throw_type_error; use js::rust::{HandleObject, HandleValue}; +use layout_api::HTMLCanvasData; use pixels::{Snapshot, SnapshotAlphaMode, SnapshotPixelFormat}; -use script_layout_interface::HTMLCanvasData; use servo_media::streams::MediaStreamType; use servo_media::streams::registry::MediaStreamId; use style::attr::AttrValue; diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index c85fc85d000..d3a6d2d5dc9 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -9,7 +9,7 @@ use std::rc::Rc; use dom_struct::dom_struct; use html5ever::{LocalName, Prefix, local_name, ns}; use js::rust::HandleObject; -use script_layout_interface::QueryMsg; +use layout_api::QueryMsg; use style::attr::AttrValue; use stylo_dom::ElementState; diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 060b5358a8c..484493f3003 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -21,6 +21,7 @@ use http::header::{self, HeaderMap, HeaderValue}; use ipc_channel::ipc::{self, IpcSharedMemory, channel}; use ipc_channel::router::ROUTER; use js::jsapi::JSAutoRealm; +use layout_api::MediaFrame; use media::{GLPlayerMsg, GLPlayerMsgForward, WindowGLContext}; use net_traits::request::{Destination, RequestId}; use net_traits::{ @@ -32,7 +33,6 @@ use script_bindings::codegen::GenericBindings::TimeRangesBinding::TimeRangesMeth use script_bindings::codegen::InheritTypes::{ ElementTypeId, HTMLElementTypeId, HTMLMediaElementTypeId, NodeTypeId, }; -use script_layout_interface::MediaFrame; use servo_config::pref; use servo_media::player::audio::AudioRenderer; use servo_media::player::video::{VideoFrame, VideoFrameRenderer}; diff --git a/components/script/dom/htmlvideoelement.rs b/components/script/dom/htmlvideoelement.rs index 5ab58fab15b..b59960606a3 100644 --- a/components/script/dom/htmlvideoelement.rs +++ b/components/script/dom/htmlvideoelement.rs @@ -10,6 +10,7 @@ use dom_struct::dom_struct; use euclid::default::Size2D; use html5ever::{LocalName, Prefix, local_name, ns}; use js::rust::HandleObject; +use layout_api::{HTMLMediaData, MediaMetadata}; use net_traits::image_cache::{ ImageCache, ImageCacheResult, ImageLoadListener, ImageOrMetadataAvailable, ImageResponse, PendingImageId, UsePlaceholder, @@ -20,7 +21,6 @@ use net_traits::{ ResourceTimingType, }; use pixels::{Snapshot, SnapshotAlphaMode, SnapshotPixelFormat}; -use script_layout_interface::{HTMLMediaData, MediaMetadata}; use servo_media::player::video::VideoFrame; use servo_url::ServoUrl; use style::attr::{AttrValue, LengthOrPercentageOrAuto}; diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index bb16082d310..4e06bc1909b 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -23,15 +23,15 @@ use html5ever::serialize::HtmlSerializer; use html5ever::{Namespace, Prefix, QualName, ns, serialize as html_serialize}; use js::jsapi::JSObject; use js::rust::HandleObject; +use layout_api::{ + GenericLayoutData, HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType, QueryMsg, + SVGSVGData, StyleData, TrustedNodeAddress, +}; use libc::{self, c_void, uintptr_t}; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use net_traits::image_cache::Image; use pixels::ImageMetadata; use script_bindings::codegen::InheritTypes::DocumentFragmentTypeId; -use script_layout_interface::{ - GenericLayoutData, HTMLCanvasData, HTMLMediaData, LayoutElementType, LayoutNodeType, QueryMsg, - SVGSVGData, StyleData, TrustedNodeAddress, -}; use script_traits::DocumentActivity; use selectors::matching::{ MatchingContext, MatchingForInvalidation, MatchingMode, NeedsSelectorFlags, diff --git a/components/script/dom/svgsvgelement.rs b/components/script/dom/svgsvgelement.rs index 12b7fa6bc71..1229ed4e29d 100644 --- a/components/script/dom/svgsvgelement.rs +++ b/components/script/dom/svgsvgelement.rs @@ -5,7 +5,7 @@ use dom_struct::dom_struct; use html5ever::{LocalName, Prefix, local_name, ns}; use js::rust::HandleObject; -use script_layout_interface::SVGSVGData; +use layout_api::SVGSVGData; use style::attr::AttrValue; use crate::dom::attr::Attr; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index c4c4cfe71c0..46709366478 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -51,6 +51,10 @@ use js::rust::{ CustomAutoRooter, CustomAutoRooterGuard, HandleObject, HandleValue, MutableHandleObject, MutableHandleValue, }; +use layout_api::{ + FragmentType, Layout, PendingImageState, QueryMsg, ReflowGoal, ReflowRequest, + TrustedNodeAddress, combine_id_with_fragment_type, +}; use malloc_size_of::MallocSizeOf; use media::WindowGLContext; use net_traits::ResourceThreads; @@ -67,10 +71,6 @@ use script_bindings::codegen::GenericBindings::NavigatorBinding::NavigatorMethod use script_bindings::codegen::GenericBindings::PerformanceBinding::PerformanceMethods; use script_bindings::interfaces::WindowHelpers; use script_bindings::root::Root; -use script_layout_interface::{ - FragmentType, Layout, PendingImageState, QueryMsg, ReflowGoal, ReflowRequest, - TrustedNodeAddress, combine_id_with_fragment_type, -}; use script_traits::ScriptThreadMessage; use selectors::attr::CaseSensitivity; use servo_arc::Arc as ServoArc; diff --git a/components/script/iframe_collection.rs b/components/script/iframe_collection.rs index be0fd22e4ac..e52ccc8f49c 100644 --- a/components/script/iframe_collection.rs +++ b/components/script/iframe_collection.rs @@ -9,7 +9,7 @@ use base::id::BrowsingContextId; use constellation_traits::{IFrameSizeMsg, WindowSizeType}; use embedder_traits::ViewportDetails; use fnv::FnvHashMap; -use script_layout_interface::IFrameSizes; +use layout_api::IFrameSizes; use crate::dom::bindings::inheritance::Castable; use crate::dom::bindings::root::{Dom, DomRoot}; diff --git a/components/script/image_animation.rs b/components/script/image_animation.rs index 096b37900a6..d7e14c110d8 100644 --- a/components/script/image_animation.rs +++ b/components/script/image_animation.rs @@ -6,9 +6,9 @@ use compositing_traits::{ImageUpdate, SerializableImageData}; use embedder_traits::UntrustedNodeAddress; use fxhash::{FxHashMap, FxHashSet}; use ipc_channel::ipc::IpcSharedMemory; +use layout_api::ImageAnimationState; use libc::c_void; use script_bindings::root::Dom; -use script_layout_interface::ImageAnimationState; use style::dom::OpaqueNode; use webrender_api::units::DeviceIntSize; use webrender_api::{ImageDescriptor, ImageDescriptorFlags, ImageFormat}; diff --git a/components/script/layout_dom/element.rs b/components/script/layout_dom/element.rs index 62cfb5b9313..738975d9631 100644 --- a/components/script/layout_dom/element.rs +++ b/components/script/layout_dom/element.rs @@ -10,10 +10,8 @@ use atomic_refcell::{AtomicRef, AtomicRefMut}; use embedder_traits::UntrustedNodeAddress; use html5ever::{LocalName, Namespace, local_name, ns}; use js::jsapi::JSObject; -use script_layout_interface::wrapper_traits::{ - LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode, -}; -use script_layout_interface::{LayoutNodeType, StyleData}; +use layout_api::wrapper_traits::{LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; +use layout_api::{LayoutNodeType, StyleData}; use selectors::Element as _; use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; use selectors::bloom::{BLOOM_HASH_MASK, BloomFilter}; diff --git a/components/script/layout_dom/node.rs b/components/script/layout_dom/node.rs index 85b75f0b15f..1ab47737dfd 100644 --- a/components/script/layout_dom/node.rs +++ b/components/script/layout_dom/node.rs @@ -10,14 +10,14 @@ use std::fmt; use base::id::{BrowsingContextId, PipelineId}; use fonts_traits::ByteIndex; use html5ever::{local_name, ns}; -use net_traits::image_cache::Image; -use pixels::ImageMetadata; -use range::Range; -use script_layout_interface::wrapper_traits::{LayoutDataTrait, LayoutNode, ThreadSafeLayoutNode}; -use script_layout_interface::{ +use layout_api::wrapper_traits::{LayoutDataTrait, LayoutNode, ThreadSafeLayoutNode}; +use layout_api::{ GenericLayoutData, HTMLCanvasData, HTMLMediaData, LayoutNodeType, SVGSVGData, StyleData, TrustedNodeAddress, }; +use net_traits::image_cache::Image; +use pixels::ImageMetadata; +use range::Range; use servo_arc::Arc; use servo_url::ServoUrl; use style; diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 41d037f5993..748be207296 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -69,6 +69,7 @@ use js::jsapi::{ }; use js::jsval::UndefinedValue; use js::rust::ParentRuntime; +use layout_api::{LayoutConfig, LayoutFactory, ReflowGoal, ScriptThreadFactory}; use media::WindowGLContext; use metrics::MAX_TASK_NS; use net_traits::image_cache::{ImageCache, ImageCacheResponseMessage}; @@ -83,7 +84,6 @@ use percent_encoding::percent_decode; use profile_traits::mem::{ProcessReports, ReportsChan, perform_memory_report}; use profile_traits::time::ProfilerCategory; use profile_traits::time_profile; -use script_layout_interface::{LayoutConfig, LayoutFactory, ReflowGoal, ScriptThreadFactory}; use script_traits::{ ConstellationInputEvent, DiscardBrowsingContext, DocumentActivity, InitialScriptState, NewLayoutInfo, Painter, ProgressiveWebMetricType, ScriptThreadMessage, UpdatePipelineIdReason, diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 5988dbdc4b9..db9864ff9b0 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -89,6 +89,7 @@ gstreamer = { workspace = true, optional = true } ipc-channel = { workspace = true } keyboard-types = { workspace = true } layout = { path = "../layout" } +layout_api = { workspace = true } log = { workspace = true } media = { path = "../media" } mozangle = { workspace = true } @@ -99,7 +100,6 @@ profile = { path = "../profile" } profile_traits = { workspace = true } rayon = { workspace = true } script = { path = "../script" } -script_layout_interface = { workspace = true } script_traits = { workspace = true } serde = { workspace = true } servo-media = { workspace = true } diff --git a/components/servo/lib.rs b/components/servo/lib.rs index ce552eda963..1512aa3ed0b 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -116,7 +116,7 @@ use webview::WebViewInner; pub use webxr; pub use { background_hang_monitor, base, canvas, canvas_traits, devtools, devtools_traits, euclid, fonts, - ipc_channel, media, net, net_traits, profile, profile_traits, script, script_layout_interface, + ipc_channel, layout_api, media, net, net_traits, profile, profile_traits, script, script_traits, servo_config as config, servo_config, servo_geometry, servo_url, style, style_traits, webrender_api, }; diff --git a/components/shared/script_layout/Cargo.toml b/components/shared/layout/Cargo.toml similarity index 94% rename from components/shared/script_layout/Cargo.toml rename to components/shared/layout/Cargo.toml index 167606f7247..3874757066e 100644 --- a/components/shared/script_layout/Cargo.toml +++ b/components/shared/layout/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "script_layout_interface" +name = "layout_api" version.workspace = true authors.workspace = true license.workspace = true @@ -8,7 +8,7 @@ publish.workspace = true rust-version.workspace = true [lib] -name = "script_layout_interface" +name = "layout_api" path = "lib.rs" [dependencies] diff --git a/components/shared/script_layout/lib.rs b/components/shared/layout/lib.rs similarity index 99% rename from components/shared/script_layout/lib.rs rename to components/shared/layout/lib.rs index d1e3d8332b2..ed4178647d8 100644 --- a/components/shared/script_layout/lib.rs +++ b/components/shared/layout/lib.rs @@ -284,7 +284,7 @@ pub trait Layout { fn query_text_indext(&self, node: OpaqueNode, point: Point2D) -> Option; } -/// This trait is part of `script_layout_interface` because it depends on both `script_traits` +/// This trait is part of `layout_api` because it depends on both `script_traits` /// and also `LayoutFactory` from this crate. If it was in `script_traits` there would be a /// circular dependency. pub trait ScriptThreadFactory { diff --git a/components/shared/script_layout/wrapper_traits.rs b/components/shared/layout/wrapper_traits.rs similarity index 100% rename from components/shared/script_layout/wrapper_traits.rs rename to components/shared/layout/wrapper_traits.rs diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index d0e87e34295..ed717e26f74 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -185,12 +185,12 @@ class MachCommands(CommandBase): "fonts", "hyper_serde", "layout", + "layout_api", "libservo", "metrics", "net", "net_traits", "pixels", - "script_layout_interface", "script_traits", "selectors", "servo_config",