diff --git a/Cargo.lock b/Cargo.lock index 876215a9010..f1aee44e64c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3129,7 +3129,6 @@ dependencies = [ "lazy_static", "libc", "log", - "mitochondria", "msg", "net_traits", "parking_lot", @@ -3735,12 +3734,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "mitochondria" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de3eca27871df31c33b807f834b94ef7d000956f57aa25c5aed9c5f0aae8f6f" - [[package]] name = "mozangle" version = "0.3.5" @@ -4991,7 +4984,6 @@ dependencies = [ "metrics", "mime", "mime_guess", - "mitochondria", "mozangle", "mozjs", "msg", diff --git a/Cargo.toml b/Cargo.toml index 4bf050387a6..31cf7f46a30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,6 @@ log = "0.4" malloc_size_of_derive = "0.1" mime = "0.3.13" mime_guess = "2.0.3" -mitochondria = "1.1.2" mozangle = "0.3" num-traits = "0.2" parking_lot = "0.12" diff --git a/components/layout_2020/Cargo.toml b/components/layout_2020/Cargo.toml index bad6c59b0c4..c44c8ef635d 100644 --- a/components/layout_2020/Cargo.toml +++ b/components/layout_2020/Cargo.toml @@ -28,7 +28,6 @@ html5ever = { workspace = true } ipc-channel = { workspace = true } libc = { workspace = true } log = { workspace = true } -mitochondria = { workspace = true } msg = { path = "../msg" } net_traits = { path = "../net_traits" } parking_lot = { workspace = true } diff --git a/components/layout_2020/display_list/mod.rs b/components/layout_2020/display_list/mod.rs index c2c7713df13..4fce61406d1 100644 --- a/components/layout_2020/display_list/mod.rs +++ b/components/layout_2020/display_list/mod.rs @@ -13,10 +13,10 @@ use embedder_traits::Cursor; use euclid::{Point2D, SideOffsets2D, Size2D}; use fnv::FnvHashMap; use gfx::text::glyph::GlyphStore; -use mitochondria::OnceCell; use msg::constellation_msg::BrowsingContextId; use net_traits::image_cache::UsePlaceholder; use script_traits::compositor::{CompositorDisplayListInfo, ScrollTreeNodeId}; +use std::cell::OnceCell; use std::sync::Arc; use style::computed_values::text_decoration_style::T as ComputedTextDecorationStyle; use style::dom::OpaqueNode; @@ -440,7 +440,7 @@ impl<'a> BuilderForBoxFragment<'a> { } fn content_rect(&self) -> &units::LayoutRect { - self.content_rect.init_once(|| { + self.content_rect.get_or_init(|| { self.fragment .content_rect .to_physical(self.fragment.style.writing_mode, self.containing_block) @@ -450,7 +450,7 @@ impl<'a> BuilderForBoxFragment<'a> { } fn padding_rect(&self) -> &units::LayoutRect { - self.padding_rect.init_once(|| { + self.padding_rect.get_or_init(|| { self.fragment .padding_rect() .to_physical(self.fragment.style.writing_mode, self.containing_block) @@ -462,11 +462,11 @@ impl<'a> BuilderForBoxFragment<'a> { fn border_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option { *self .border_edge_clip_id - .init_once(|| clip_for_radii(self.border_radius, self.border_rect, builder)) + .get_or_init(|| clip_for_radii(self.border_radius, self.border_rect, builder)) } fn padding_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option { - *self.padding_edge_clip_id.init_once(|| { + *self.padding_edge_clip_id.get_or_init(|| { clip_for_radii( inner_radii( self.border_radius, @@ -482,7 +482,7 @@ impl<'a> BuilderForBoxFragment<'a> { } fn content_edge_clip(&self, builder: &mut DisplayListBuilder) -> Option { - *self.content_edge_clip_id.init_once(|| { + *self.content_edge_clip_id.get_or_init(|| { clip_for_radii( inner_radii( self.border_radius, diff --git a/components/layout_2020/lib.rs b/components/layout_2020/lib.rs index 91f4bf5ffc9..ca23f264c14 100644 --- a/components/layout_2020/lib.rs +++ b/components/layout_2020/lib.rs @@ -3,6 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] +#![feature(once_cell)] #[macro_use] extern crate log; diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 0a8b713ce9d..e4f84658730 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -76,7 +76,6 @@ media = { path = "../media" } metrics = { path = "../metrics" } mime = { workspace = true } mime_guess = { workspace = true } -mitochondria = { workspace = true } msg = { path = "../msg" } net_traits = { path = "../net_traits" } num-traits = { workspace = true } diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index b0b7eeb146d..b51730848b6 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -33,9 +33,8 @@ use crate::dom::node::Node; use js::jsapi::{Heap, JSObject, JSTracer}; use js::rust::GCMethods; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; -use mitochondria::OnceCell; use script_layout_interface::TrustedNodeAddress; -use std::cell::{Cell, UnsafeCell}; +use std::cell::{Cell, OnceCell, UnsafeCell}; use std::default::Default; use std::hash::{Hash, Hasher}; use std::marker::PhantomData; @@ -718,7 +717,7 @@ where F: FnOnce() -> DomRoot, { assert_in_script(); - &self.ptr.init_once(|| Dom::from_ref(&cb())) + &self.ptr.get_or_init(|| Dom::from_ref(&cb())) } } @@ -742,7 +741,7 @@ impl MallocSizeOf for DomOnceCell { #[allow(unrooted_must_root)] unsafe impl JSTraceable for DomOnceCell { unsafe fn trace(&self, trc: *mut JSTracer) { - if let Some(ptr) = self.ptr.as_ref() { + if let Some(ptr) = self.ptr.get() { ptr.trace(trc); } } diff --git a/components/script/lib.rs b/components/script/lib.rs index 3d46f4f797c..ecb4bf8a853 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -4,6 +4,7 @@ #![feature(core_intrinsics)] #![feature(drain_filter)] +#![feature(once_cell)] #![feature(plugin)] #![feature(register_tool)] #![deny(unsafe_code)]