diff --git a/components/style/author_styles.rs b/components/style/author_styles.rs index 83bd0ad2854..a0223dceccc 100644 --- a/components/style/author_styles.rs +++ b/components/style/author_styles.rs @@ -6,8 +6,6 @@ //! ones used for ShadowRoot. use crate::dom::TElement; -#[cfg(feature = "gecko")] -use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; use crate::invalidation::media_queries::ToMediaListKey; use crate::shared_lock::SharedRwLockReadGuard; use crate::stylesheet_set::AuthorStylesheetSet; @@ -19,7 +17,7 @@ use servo_arc::Arc; /// A set of author stylesheets and their computed representation, such as the /// ones used for ShadowRoot. #[derive(MallocSizeOf)] -pub struct AuthorStyles +pub struct GenericAuthorStyles where S: StylesheetInDocument + PartialEq + 'static, { @@ -31,11 +29,13 @@ where pub data: Arc, } +pub use self::GenericAuthorStyles as AuthorStyles; + lazy_static! { static ref EMPTY_CASCADE_DATA: Arc = Arc::new_leaked(CascadeData::new()); } -impl AuthorStyles +impl GenericAuthorStyles where S: StylesheetInDocument + PartialEq + 'static, { @@ -68,12 +68,3 @@ where } } } - -#[cfg(feature = "gecko")] -unsafe impl HasFFI for AuthorStyles { - type FFIType = crate::gecko_bindings::structs::RawServoAuthorStyles; -} -#[cfg(feature = "gecko")] -unsafe impl HasSimpleFFI for AuthorStyles {} -#[cfg(feature = "gecko")] -unsafe impl HasBoxFFI for AuthorStyles {} diff --git a/components/style/gecko/boxed_types.rs b/components/style/gecko/boxed_types.rs deleted file mode 100644 index 47fc4fe57dc..00000000000 --- a/components/style/gecko/boxed_types.rs +++ /dev/null @@ -1,31 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -//! FFI implementations for types listed in ServoBoxedTypeList.h. - -use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; -use crate::properties::animated_properties::AnimationValueMap; -use to_shmem::SharedMemoryBuilder; - -// TODO(heycam): The FFI impls for most of the types in ServoBoxedTypeList.h are spread across -// various files at the moment, but should probably all move here, and use macros to define -// them more succinctly, like we do in arc_types.rs. - -#[cfg(feature = "gecko")] -unsafe impl HasFFI for AnimationValueMap { - type FFIType = crate::gecko_bindings::bindings::RawServoAnimationValueMap; -} -#[cfg(feature = "gecko")] -unsafe impl HasSimpleFFI for AnimationValueMap {} -#[cfg(feature = "gecko")] -unsafe impl HasBoxFFI for AnimationValueMap {} - -#[cfg(feature = "gecko")] -unsafe impl HasFFI for SharedMemoryBuilder { - type FFIType = crate::gecko_bindings::bindings::RawServoSharedMemoryBuilder; -} -#[cfg(feature = "gecko")] -unsafe impl HasSimpleFFI for SharedMemoryBuilder {} -#[cfg(feature = "gecko")] -unsafe impl HasBoxFFI for SharedMemoryBuilder {} diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index 6e347c59ce7..65c7dc71012 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -6,9 +6,8 @@ use crate::dom::TElement; use crate::gecko_bindings::bindings; -use crate::gecko_bindings::structs::{self, RawServoStyleSet, ServoStyleSetSizes}; -use crate::gecko_bindings::structs::{StyleSheet as DomStyleSheet, StyleSheetInfo}; -use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI}; +use crate::gecko_bindings::structs::{self, ServoStyleSetSizes, StyleSheet as DomStyleSheet, StyleSheetInfo}; +use crate::gecko_bindings::sugar::ownership::HasArcFFI; use crate::invalidation::media_queries::{MediaListKey, ToMediaListKey}; use crate::media_queries::{Device, MediaList}; use crate::properties::ComputedValues; @@ -201,8 +200,5 @@ impl PerDocumentStyleDataImpl { } } -unsafe impl HasFFI for PerDocumentStyleData { - type FFIType = RawServoStyleSet; -} -unsafe impl HasSimpleFFI for PerDocumentStyleData {} -unsafe impl HasBoxFFI for PerDocumentStyleData {} +/// The gecko-specific AuthorStyles instantiation. +pub type AuthorStyles = crate::author_styles::AuthorStyles; diff --git a/components/style/gecko/mod.rs b/components/style/gecko/mod.rs index 7b19810fcf2..c32ded14f33 100644 --- a/components/style/gecko/mod.rs +++ b/components/style/gecko/mod.rs @@ -8,7 +8,6 @@ mod non_ts_pseudo_class_list; pub mod arc_types; -pub mod boxed_types; pub mod conversions; pub mod data; pub mod media_features; diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index 7c182ac8c54..3ec9fbd0c0e 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -5,8 +5,6 @@ //! Gecko-specific bits for selector-parsing. use crate::computed_value_flags::ComputedValueFlags; -use crate::gecko_bindings::structs::RawServoSelectorList; -use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; use crate::invalidation::element::document_state::InvalidationMatchingData; use crate::properties::ComputedValues; use crate::selector_parser::{Direction, HorizontalDirection, SelectorParser}; @@ -17,7 +15,6 @@ use cssparser::{BasicParseError, BasicParseErrorKind, Parser}; use cssparser::{CowRcStr, SourceLocation, ToCss, Token}; use dom::{DocumentState, ElementState}; use selectors::parser::SelectorParseErrorKind; -use selectors::SelectorList; use std::fmt; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss as ToCss_}; use thin_vec::ThinVec; @@ -489,12 +486,6 @@ impl SelectorImpl { } } -unsafe impl HasFFI for SelectorList { - type FFIType = RawServoSelectorList; -} -unsafe impl HasSimpleFFI for SelectorList {} -unsafe impl HasBoxFFI for SelectorList {} - // Selector and component sizes are important for matching performance. size_of_test!(selectors::parser::Selector, 8); size_of_test!(selectors::parser::Component, 24); diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index b5bcaa8242a..f6ae9f69391 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -15,11 +15,9 @@ //! the separation between the style system implementation and everything else. use crate::applicable_declarations::ApplicableDeclarationBlock; -use crate::author_styles::AuthorStyles; use crate::context::{PostAnimationTasks, QuirksMode, SharedStyleContext, UpdateAnimationsTasks}; use crate::data::ElementData; use crate::dom::{LayoutIterator, NodeInfo, OpaqueNode, TDocument, TElement, TNode, TShadowRoot}; -use crate::gecko::data::GeckoStyleSheet; use crate::gecko::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl}; use crate::gecko::snapshot_helpers; use crate::gecko_bindings::bindings; @@ -50,7 +48,7 @@ use crate::gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES; use crate::gecko_bindings::structs::NODE_NEEDS_FRAME; use crate::gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag}; use crate::gecko_bindings::structs::{nsINode as RawGeckoNode, Element as RawGeckoElement}; -use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI}; +use crate::gecko_bindings::sugar::ownership::HasArcFFI; use crate::global_style_data::GLOBAL_STYLE_DATA; use crate::invalidation::element::restyle_hints::RestyleHint; use crate::media_queries::Device; @@ -180,7 +178,6 @@ impl<'lr> TShadowRoot for GeckoShadowRoot<'lr> { Self: 'a, { let author_styles = unsafe { self.0.mServoStyles.mPtr.as_ref()? }; - let author_styles = AuthorStyles::::from_ffi(author_styles); Some(&author_styles.data) } @@ -925,7 +922,7 @@ fn get_animation_rule( Gecko_GetAnimationRule( element.0, cascade_level, - AnimationValueMap::as_ffi_mut(&mut animation_values), + &mut animation_values, ) } { let shared_lock = &GLOBAL_STYLE_DATA.shared_lock; diff --git a/components/style/gecko_bindings/sugar/ownership.rs b/components/style/gecko_bindings/sugar/ownership.rs index 249134169f5..9579e291127 100644 --- a/components/style/gecko_bindings/sugar/ownership.rs +++ b/components/style/gecko_bindings/sugar/ownership.rs @@ -56,26 +56,6 @@ pub unsafe trait HasSimpleFFI: HasFFI { } } -/// Indicates that the given Servo type is passed over FFI -/// as a Box -pub unsafe trait HasBoxFFI: HasSimpleFFI { - #[inline] - /// Converts a borrowed Arc to a borrowed FFI reference. - /// - /// &Arc -> &GeckoType - fn into_ffi(self: Box) -> Owned { - unsafe { transmute(self) } - } - - /// Drops an owned FFI pointer. This conceptually takes the - /// Owned, except it's a bit of a paint to do that without - /// much benefit. - #[inline] - unsafe fn drop_ffi(ptr: *mut Self::FFIType) { - let _ = Box::from_raw(ptr as *mut Self); - } -} - /// Helper trait for conversions between FFI Strong/Borrowed types and Arcs /// /// Should be implemented by types which are passed over FFI as Arcs via Strong @@ -265,75 +245,6 @@ unsafe impl FFIArcHelpers for Arc { } } -#[repr(C)] -#[derive(Debug)] -/// Gecko-FFI-safe owned pointer. -/// -/// Cannot be null, and leaks on drop, so needs to be converted into a rust-side -/// `Box` before. -pub struct Owned { - ptr: *mut GeckoType, - _marker: PhantomData, -} - -impl Owned { - /// Converts this instance to a (non-null) instance of `OwnedOrNull`. - pub fn maybe(self) -> OwnedOrNull { - unsafe { transmute(self) } - } -} - -impl Deref for Owned { - type Target = GeckoType; - fn deref(&self) -> &GeckoType { - unsafe { &*self.ptr } - } -} - -impl DerefMut for Owned { - fn deref_mut(&mut self) -> &mut GeckoType { - unsafe { &mut *self.ptr } - } -} - -#[repr(C)] -/// Gecko-FFI-safe owned pointer. -/// -/// Can be null, and just as `Owned` leaks on `Drop`. -pub struct OwnedOrNull { - ptr: *mut GeckoType, - _marker: PhantomData, -} - -impl OwnedOrNull { - /// Returns a null pointer. - #[inline] - pub fn null() -> Self { - Self { - ptr: ptr::null_mut(), - _marker: PhantomData, - } - } - - /// Returns whether this pointer is null. - #[inline] - pub fn is_null(&self) -> bool { - self.ptr.is_null() - } - - /// Gets a immutable reference to the underlying Gecko type, or `None` if - /// null. - pub fn borrow(&self) -> Option<&GeckoType> { - unsafe { transmute(self) } - } - - /// Gets a mutable reference to the underlying Gecko type, or `None` if - /// null. - pub fn borrow_mut(&self) -> Option<&mut GeckoType> { - unsafe { transmute(self) } - } -} - impl Deref for CopyablePtr { type Target = T; fn deref(&self) -> &Self::Target { diff --git a/components/style/use_counters/mod.rs b/components/style/use_counters/mod.rs index bb8e92594a6..bfa73291ee7 100644 --- a/components/style/use_counters/mod.rs +++ b/components/style/use_counters/mod.rs @@ -4,8 +4,6 @@ //! Various stuff for CSS property use counters. -#[cfg(feature = "gecko")] -use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; use crate::properties::{CountedUnknownProperty, COUNTED_UNKNOWN_PROPERTY_COUNT}; use crate::properties::{NonCustomPropertyId, NON_CUSTOM_PROPERTY_ID_COUNT}; use std::cell::Cell; @@ -96,14 +94,3 @@ impl UseCounters { .merge(&other.counted_unknown_properties); } } - -#[cfg(feature = "gecko")] -unsafe impl HasFFI for UseCounters { - type FFIType = crate::gecko_bindings::structs::StyleUseCounters; -} - -#[cfg(feature = "gecko")] -unsafe impl HasSimpleFFI for UseCounters {} - -#[cfg(feature = "gecko")] -unsafe impl HasBoxFFI for UseCounters {} diff --git a/components/style/values/specified/source_size_list.rs b/components/style/values/specified/source_size_list.rs index faafbb90163..7fa92fe581a 100644 --- a/components/style/values/specified/source_size_list.rs +++ b/components/style/values/specified/source_size_list.rs @@ -4,8 +4,6 @@ //! https://html.spec.whatwg.org/multipage/#source-size-list -#[cfg(feature = "gecko")] -use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; use crate::media_queries::Device; use crate::parser::{Parse, ParserContext}; use crate::queries::{FeatureType, QueryCondition}; @@ -134,12 +132,3 @@ impl SourceSizeList { } } } - -#[cfg(feature = "gecko")] -unsafe impl HasFFI for SourceSizeList { - type FFIType = crate::gecko_bindings::structs::RawServoSourceSizeList; -} -#[cfg(feature = "gecko")] -unsafe impl HasSimpleFFI for SourceSizeList {} -#[cfg(feature = "gecko")] -unsafe impl HasBoxFFI for SourceSizeList {}