mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Revert changes to servo_arc, style_derive, and style_traits (#31387)
This reverts the Rust edition updates to these three traits as well as incorporates https://phabricator.services.mozilla.com/D117887. The purpose of this change is to reduce the diff with upstream stylo. Finally, formatting is disabled for these crates as well.
This commit is contained in:
parent
d4212dca0b
commit
1c2de6dd1d
22 changed files with 85 additions and 106 deletions
|
@ -5,7 +5,6 @@ authors = ["The Servo Project Developers"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/servo/servo"
|
repository = "https://github.com/servo/servo"
|
||||||
description = "A fork of std::sync::Arc with some extra functionality and without weak references"
|
description = "A fork of std::sync::Arc with some extra functionality and without weak references"
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "servo_arc"
|
name = "servo_arc"
|
||||||
|
|
|
@ -25,23 +25,30 @@
|
||||||
// duplicate those here.
|
// duplicate those here.
|
||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
extern crate serde;
|
||||||
|
extern crate stable_deref_trait;
|
||||||
|
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use stable_deref_trait::{CloneStableDeref, StableDeref};
|
||||||
use std::alloc::{self, Layout};
|
use std::alloc::{self, Layout};
|
||||||
|
use std::borrow;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
|
use std::fmt;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::iter::{ExactSizeIterator, Iterator};
|
use std::iter::{ExactSizeIterator, Iterator};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem::{self, align_of, size_of};
|
use std::mem::{self, align_of, size_of};
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
use std::process;
|
||||||
|
use std::ptr;
|
||||||
|
use std::slice;
|
||||||
use std::sync::atomic;
|
use std::sync::atomic;
|
||||||
use std::sync::atomic::Ordering::{Acquire, Relaxed, Release};
|
use std::sync::atomic::Ordering::{Acquire, Relaxed, Release};
|
||||||
use std::{borrow, fmt, isize, process, ptr, slice, usize};
|
use std::{isize, usize};
|
||||||
|
|
||||||
use nodrop::NoDrop;
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use stable_deref_trait::{CloneStableDeref, StableDeref};
|
|
||||||
|
|
||||||
/// A soft limit on the amount of references that may be made to an `Arc`.
|
/// A soft limit on the amount of references that may be made to an `Arc`.
|
||||||
///
|
///
|
||||||
|
@ -811,6 +818,7 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
|
||||||
|
|
||||||
/// Creates an Arc for a HeaderSlice using the given header struct and
|
/// Creates an Arc for a HeaderSlice using the given header struct and
|
||||||
/// iterator to generate the slice. The resulting Arc will be fat.
|
/// iterator to generate the slice. The resulting Arc will be fat.
|
||||||
|
#[inline]
|
||||||
pub fn from_header_and_iter<I>(header: H, items: I) -> Self
|
pub fn from_header_and_iter<I>(header: H, items: I) -> Self
|
||||||
where
|
where
|
||||||
I: Iterator<Item = T> + ExactSizeIterator,
|
I: Iterator<Item = T> + ExactSizeIterator,
|
||||||
|
@ -904,7 +912,7 @@ impl<H, T> ThinArc<H, T> {
|
||||||
{
|
{
|
||||||
// Synthesize transient Arc, which never touches the refcount of the ArcInner.
|
// Synthesize transient Arc, which never touches the refcount of the ArcInner.
|
||||||
let transient = unsafe {
|
let transient = unsafe {
|
||||||
NoDrop::new(Arc {
|
mem::ManuallyDrop::new(Arc {
|
||||||
p: ptr::NonNull::new_unchecked(thin_to_thick(self.ptr.as_ptr())),
|
p: ptr::NonNull::new_unchecked(thin_to_thick(self.ptr.as_ptr())),
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
|
@ -913,11 +921,6 @@ impl<H, T> ThinArc<H, T> {
|
||||||
// Expose the transient Arc to the callback, which may clone it if it wants.
|
// Expose the transient Arc to the callback, which may clone it if it wants.
|
||||||
let result = f(&transient);
|
let result = f(&transient);
|
||||||
|
|
||||||
// Forget the transient Arc to leave the refcount untouched.
|
|
||||||
// XXXManishearth this can be removed when unions stabilize,
|
|
||||||
// since then NoDrop becomes zero overhead
|
|
||||||
mem::forget(transient);
|
|
||||||
|
|
||||||
// Forward the result.
|
// Forward the result.
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
@ -1129,7 +1132,7 @@ impl<'a, T> ArcBorrow<'a, T> {
|
||||||
/// Compare two `ArcBorrow`s via pointer equality. Will only return
|
/// Compare two `ArcBorrow`s via pointer equality. Will only return
|
||||||
/// true if they come from the same allocation
|
/// true if they come from the same allocation
|
||||||
pub fn ptr_eq(this: &Self, other: &Self) -> bool {
|
pub fn ptr_eq(this: &Self, other: &Self) -> bool {
|
||||||
std::ptr::eq(this.0, other.0)
|
this.0 as *const T == other.0 as *const T
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Temporarily converts |self| into a bonafide Arc and exposes it to the
|
/// Temporarily converts |self| into a bonafide Arc and exposes it to the
|
||||||
|
@ -1141,16 +1144,11 @@ impl<'a, T> ArcBorrow<'a, T> {
|
||||||
T: 'static,
|
T: 'static,
|
||||||
{
|
{
|
||||||
// Synthesize transient Arc, which never touches the refcount.
|
// Synthesize transient Arc, which never touches the refcount.
|
||||||
let transient = unsafe { NoDrop::new(Arc::from_raw(self.0)) };
|
let transient = unsafe { mem::ManuallyDrop::new(Arc::from_raw(self.0)) };
|
||||||
|
|
||||||
// Expose the transient Arc to the callback, which may clone it if it wants.
|
// Expose the transient Arc to the callback, which may clone it if it wants.
|
||||||
let result = f(&transient);
|
let result = f(&transient);
|
||||||
|
|
||||||
// Forget the transient Arc to leave the refcount untouched.
|
|
||||||
// XXXManishearth this can be removed when unions stabilize,
|
|
||||||
// since then NoDrop becomes zero overhead
|
|
||||||
mem::forget(transient);
|
|
||||||
|
|
||||||
// Forward the result.
|
// Forward the result.
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
@ -1309,13 +1307,12 @@ impl<A: fmt::Debug, B: fmt::Debug> fmt::Debug for ArcUnion<A, B> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use super::{Arc, HeaderWithLength, ThinArc};
|
||||||
use std::clone::Clone;
|
use std::clone::Clone;
|
||||||
use std::ops::Drop;
|
use std::ops::Drop;
|
||||||
use std::sync::atomic;
|
use std::sync::atomic;
|
||||||
use std::sync::atomic::Ordering::{Acquire, SeqCst};
|
use std::sync::atomic::Ordering::{Acquire, SeqCst};
|
||||||
|
|
||||||
use super::{Arc, HeaderWithLength, ThinArc};
|
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
struct Canary(*mut atomic::AtomicUsize);
|
struct Canary(*mut atomic::AtomicUsize);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ name = "style_derive"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = ["The Servo Project Developers"]
|
authors = ["The Servo Project Developers"]
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
edition = "2018"
|
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|
|
@ -3,14 +3,10 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use darling::util::PathList;
|
use darling::util::PathList;
|
||||||
use darling::FromDeriveInput;
|
|
||||||
use darling::FromField;
|
|
||||||
use darling::FromVariant;
|
|
||||||
use derive_common::cg;
|
use derive_common::cg;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
|
||||||
use quote::TokenStreamExt;
|
use quote::TokenStreamExt;
|
||||||
use syn::{parse_quote, DeriveInput, WhereClause};
|
use syn::{DeriveInput, WhereClause};
|
||||||
use synstructure::{Structure, VariantInfo};
|
use synstructure::{Structure, VariantInfo};
|
||||||
|
|
||||||
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs};
|
use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs};
|
||||||
use darling::FromField;
|
|
||||||
use derive_common::cg;
|
use derive_common::cg;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
|
||||||
use quote::TokenStreamExt;
|
use quote::TokenStreamExt;
|
||||||
use syn::{parse_quote, DeriveInput, WhereClause};
|
use syn::{DeriveInput, WhereClause};
|
||||||
use synstructure;
|
use synstructure;
|
||||||
|
|
||||||
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
|
|
|
@ -4,6 +4,17 @@
|
||||||
|
|
||||||
#![recursion_limit = "128"]
|
#![recursion_limit = "128"]
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate darling;
|
||||||
|
extern crate derive_common;
|
||||||
|
extern crate proc_macro;
|
||||||
|
extern crate proc_macro2;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate quote;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate syn;
|
||||||
|
extern crate synstructure;
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
|
|
||||||
mod animate;
|
mod animate;
|
||||||
|
|
|
@ -3,12 +3,9 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::to_css::{CssBitflagAttrs, CssVariantAttrs};
|
use crate::to_css::{CssBitflagAttrs, CssVariantAttrs};
|
||||||
use darling::FromField;
|
|
||||||
use darling::FromVariant;
|
|
||||||
use derive_common::cg;
|
use derive_common::cg;
|
||||||
use proc_macro2::{Span, TokenStream};
|
use proc_macro2::{Span, TokenStream};
|
||||||
use quote::{quote, TokenStreamExt};
|
use quote::TokenStreamExt;
|
||||||
use syn::parse_quote;
|
|
||||||
use syn::{self, DeriveInput, Ident, Path};
|
use syn::{self, DeriveInput, Ident, Path};
|
||||||
use synstructure::{Structure, VariantInfo};
|
use synstructure::{Structure, VariantInfo};
|
||||||
|
|
||||||
|
@ -132,7 +129,7 @@ fn parse_non_keyword_variant(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quote! {
|
quote! {
|
||||||
if let Ok(v) = input.r#try(|i| <#ty as crate::parser::Parse>::parse(context, i)) {
|
if let Ok(v) = input.try(|i| <#ty as crate::parser::Parse>::parse(context, i)) {
|
||||||
return Ok(#name::#variant_name(v));
|
return Ok(#name::#variant_name(v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,10 @@
|
||||||
|
|
||||||
use crate::parse::ParseVariantAttrs;
|
use crate::parse::ParseVariantAttrs;
|
||||||
use crate::to_css::{CssFieldAttrs, CssInputAttrs, CssVariantAttrs};
|
use crate::to_css::{CssFieldAttrs, CssInputAttrs, CssVariantAttrs};
|
||||||
use darling::FromDeriveInput;
|
|
||||||
use darling::FromField;
|
|
||||||
use darling::FromVariant;
|
|
||||||
use derive_common::cg;
|
use derive_common::cg;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
|
||||||
use quote::TokenStreamExt;
|
use quote::TokenStreamExt;
|
||||||
use syn::{parse_quote, Data, DeriveInput, Fields, Ident, Type};
|
use syn::{Data, DeriveInput, Fields, Ident, Type};
|
||||||
|
|
||||||
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
let css_attrs = cg::parse_input_attrs::<CssInputAttrs>(&input);
|
let css_attrs = cg::parse_input_attrs::<CssInputAttrs>(&input);
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::to_computed_value;
|
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
use syn::DeriveInput;
|
||||||
use syn::{parse_quote, DeriveInput};
|
|
||||||
use synstructure::BindStyle;
|
use synstructure::BindStyle;
|
||||||
|
use to_computed_value;
|
||||||
|
|
||||||
pub fn derive(input: DeriveInput) -> TokenStream {
|
pub fn derive(input: DeriveInput) -> TokenStream {
|
||||||
let trait_impl = |from_body, to_body| {
|
let trait_impl = |from_body, to_body| {
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs};
|
use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs};
|
||||||
use derive_common::cg;
|
use derive_common::cg;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
|
||||||
use quote::TokenStreamExt;
|
use quote::TokenStreamExt;
|
||||||
use syn::{self, parse_quote};
|
use syn;
|
||||||
use synstructure;
|
use synstructure;
|
||||||
|
|
||||||
pub fn derive(mut input: syn::DeriveInput) -> TokenStream {
|
pub fn derive(mut input: syn::DeriveInput) -> TokenStream {
|
||||||
|
|
|
@ -2,11 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use darling::FromField;
|
|
||||||
use derive_common::cg;
|
use derive_common::cg;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
|
||||||
use syn::parse_quote;
|
|
||||||
use syn::{DeriveInput, Ident, Path};
|
use syn::{DeriveInput, Ident, Path};
|
||||||
use synstructure::{BindStyle, BindingInfo};
|
use synstructure::{BindStyle, BindingInfo};
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,9 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use darling::util::Override;
|
use darling::util::Override;
|
||||||
use darling::FromDeriveInput;
|
|
||||||
use darling::FromField;
|
|
||||||
use darling::FromMeta;
|
|
||||||
use darling::FromVariant;
|
|
||||||
use derive_common::cg;
|
use derive_common::cg;
|
||||||
use proc_macro2::{Span, TokenStream};
|
use proc_macro2::{Span, TokenStream};
|
||||||
use quote::quote;
|
|
||||||
use quote::{ToTokens, TokenStreamExt};
|
use quote::{ToTokens, TokenStreamExt};
|
||||||
use syn::parse_quote;
|
|
||||||
use syn::{self, Data, Ident, Path, WhereClause};
|
use syn::{self, Data, Ident, Path, WhereClause};
|
||||||
use synstructure::{BindingInfo, Structure, VariantInfo};
|
use synstructure::{BindingInfo, Structure, VariantInfo};
|
||||||
|
|
||||||
|
@ -209,7 +203,7 @@ fn derive_variant_fields_expr(
|
||||||
let mut iter = bindings
|
let mut iter = bindings
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|binding| {
|
.filter_map(|binding| {
|
||||||
let attrs = cg::parse_field_attrs::<CssFieldAttrs>(binding.ast());
|
let attrs = cg::parse_field_attrs::<CssFieldAttrs>(&binding.ast());
|
||||||
if attrs.skip {
|
if attrs.skip {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use crate::to_computed_value;
|
|
||||||
use darling::FromField;
|
|
||||||
use derive_common::cg;
|
use derive_common::cg;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
use syn::DeriveInput;
|
||||||
use syn::{parse_quote, DeriveInput};
|
|
||||||
use synstructure::BindStyle;
|
use synstructure::BindStyle;
|
||||||
|
use to_computed_value;
|
||||||
|
|
||||||
pub fn derive(input: DeriveInput) -> TokenStream {
|
pub fn derive(input: DeriveInput) -> TokenStream {
|
||||||
let trait_impl = |from_body, to_body| {
|
let trait_impl = |from_body, to_body| {
|
||||||
|
|
|
@ -3,7 +3,6 @@ name = "style_traits"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
authors = ["The Servo Project Developers"]
|
authors = ["The Servo Project Developers"]
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
edition = "2018"
|
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
@ -22,7 +21,7 @@ euclid = "0.22"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
malloc_size_of = { path = "../malloc_size_of" }
|
malloc_size_of = { path = "../malloc_size_of" }
|
||||||
malloc_size_of_derive = "0.1"
|
malloc_size_of_derive = "0.1"
|
||||||
selectors = { path = "../selectors", features = ["shmem"] }
|
selectors = { path = "../selectors" }
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
servo_arc = { path = "../servo_arc" }
|
servo_arc = { path = "../servo_arc" }
|
||||||
servo_atoms = { path = "../atoms", optional = true }
|
servo_atoms = { path = "../atoms", optional = true }
|
||||||
|
|
|
@ -4,16 +4,14 @@
|
||||||
|
|
||||||
//! A thin atomically-reference-counted slice.
|
//! A thin atomically-reference-counted slice.
|
||||||
|
|
||||||
|
use serde::de::{Deserialize, Deserializer};
|
||||||
|
use serde::ser::{Serialize, Serializer};
|
||||||
|
use servo_arc::ThinArc;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::{iter, mem};
|
use std::{iter, mem};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps, MallocUnconditionalSizeOf};
|
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps, MallocUnconditionalSizeOf};
|
||||||
use serde::de::{Deserialize, Deserializer};
|
|
||||||
use serde::ser::{Serialize, Serializer};
|
|
||||||
use servo_arc::ThinArc;
|
|
||||||
use to_shmem_derive::ToShmem;
|
|
||||||
|
|
||||||
/// A canary that we stash in ArcSlices.
|
/// A canary that we stash in ArcSlices.
|
||||||
///
|
///
|
||||||
|
|
|
@ -4,10 +4,7 @@
|
||||||
|
|
||||||
//! Types used to access the DOM from style calculation.
|
//! Types used to access the DOM from style calculation.
|
||||||
|
|
||||||
use bitflags::bitflags;
|
|
||||||
use malloc_size_of::malloc_size_of_is_0;
|
use malloc_size_of::malloc_size_of_is_0;
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
/// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed
|
/// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed
|
||||||
/// back into a non-opaque representation. The only safe operation that can be
|
/// back into a non-opaque representation. The only safe operation that can be
|
||||||
|
|
|
@ -9,17 +9,37 @@
|
||||||
#![crate_name = "style_traits"]
|
#![crate_name = "style_traits"]
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
|
|
||||||
use bitflags::bitflags;
|
extern crate app_units;
|
||||||
use cssparser::{CowRcStr, Token};
|
#[macro_use]
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
extern crate bitflags;
|
||||||
use selectors::parser::SelectorParseErrorKind;
|
extern crate cssparser;
|
||||||
use serde::{Deserialize, Serialize};
|
extern crate euclid;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate lazy_static;
|
||||||
|
extern crate malloc_size_of;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate malloc_size_of_derive;
|
||||||
|
extern crate selectors;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate serde;
|
||||||
|
extern crate servo_arc;
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
use servo_atoms::Atom;
|
extern crate servo_atoms;
|
||||||
use size_of_test::size_of_test;
|
extern crate to_shmem;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate to_shmem_derive;
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
extern crate webrender_api;
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
extern crate url;
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
pub use webrender_api::units::DevicePixel;
|
pub use webrender_api::units::DevicePixel;
|
||||||
|
|
||||||
|
use cssparser::{CowRcStr, Token};
|
||||||
|
use selectors::parser::SelectorParseErrorKind;
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
use servo_atoms::Atom;
|
||||||
|
|
||||||
/// One hardware pixel.
|
/// One hardware pixel.
|
||||||
///
|
///
|
||||||
/// This unit corresponds to the smallest addressable element of the display hardware.
|
/// This unit corresponds to the smallest addressable element of the display hardware.
|
||||||
|
@ -78,11 +98,9 @@ pub use crate::values::{
|
||||||
|
|
||||||
/// The error type for all CSS parsing routines.
|
/// The error type for all CSS parsing routines.
|
||||||
pub type ParseError<'i> = cssparser::ParseError<'i, StyleParseErrorKind<'i>>;
|
pub type ParseError<'i> = cssparser::ParseError<'i, StyleParseErrorKind<'i>>;
|
||||||
size_of_test!(ParseError, 64);
|
|
||||||
|
|
||||||
/// Error in property value parsing
|
/// Error in property value parsing
|
||||||
pub type ValueParseError<'i> = cssparser::ParseError<'i, ValueParseErrorKind<'i>>;
|
pub type ValueParseError<'i> = cssparser::ParseError<'i, ValueParseErrorKind<'i>>;
|
||||||
size_of_test!(ValueParseError, 48);
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
/// Errors that can be encountered while parsing CSS values.
|
/// Errors that can be encountered while parsing CSS values.
|
||||||
|
@ -149,7 +167,6 @@ pub enum StyleParseErrorKind<'i> {
|
||||||
/// The property is not allowed within a page rule.
|
/// The property is not allowed within a page rule.
|
||||||
NotAllowedInPageRule,
|
NotAllowedInPageRule,
|
||||||
}
|
}
|
||||||
size_of_test!(StyleParseErrorKind, 56);
|
|
||||||
|
|
||||||
impl<'i> From<ValueParseErrorKind<'i>> for StyleParseErrorKind<'i> {
|
impl<'i> From<ValueParseErrorKind<'i>> for StyleParseErrorKind<'i> {
|
||||||
fn from(this: ValueParseErrorKind<'i>) -> Self {
|
fn from(this: ValueParseErrorKind<'i>) -> Self {
|
||||||
|
@ -171,7 +188,6 @@ pub enum ValueParseErrorKind<'i> {
|
||||||
/// An invalid filter value was encountered.
|
/// An invalid filter value was encountered.
|
||||||
InvalidFilter(Token<'i>),
|
InvalidFilter(Token<'i>),
|
||||||
}
|
}
|
||||||
size_of_test!(ValueParseErrorKind, 40);
|
|
||||||
|
|
||||||
impl<'i> StyleParseErrorKind<'i> {
|
impl<'i> StyleParseErrorKind<'i> {
|
||||||
/// Create an InvalidValue parse error
|
/// Create an InvalidValue parse error
|
||||||
|
|
|
@ -6,14 +6,13 @@
|
||||||
|
|
||||||
//! A replacement for `Box<[T]>` that cbindgen can understand.
|
//! A replacement for `Box<[T]>` that cbindgen can understand.
|
||||||
|
|
||||||
|
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps};
|
||||||
|
use serde::de::{Deserialize, Deserializer};
|
||||||
|
use serde::ser::{Serialize, Serializer};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::{fmt, iter, mem, slice};
|
use std::{fmt, iter, mem, slice};
|
||||||
|
|
||||||
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps};
|
|
||||||
use serde::de::{Deserialize, Deserializer};
|
|
||||||
use serde::ser::{Serialize, Serializer};
|
|
||||||
use to_shmem::{self, SharedMemoryBuilder, ToShmem};
|
use to_shmem::{self, SharedMemoryBuilder, ToShmem};
|
||||||
|
|
||||||
/// A struct that basically replaces a `Box<[T]>`, but which cbindgen can
|
/// A struct that basically replaces a `Box<[T]>`, but which cbindgen can
|
||||||
|
|
|
@ -6,14 +6,10 @@
|
||||||
|
|
||||||
//! A replacement for `Box<str>` that has a defined layout for FFI.
|
//! A replacement for `Box<str>` that has a defined layout for FFI.
|
||||||
|
|
||||||
|
use crate::owned_slice::OwnedSlice;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
|
||||||
use to_shmem_derive::ToShmem;
|
|
||||||
|
|
||||||
use crate::owned_slice::OwnedSlice;
|
|
||||||
|
|
||||||
/// A struct that basically replaces a Box<str>, but with a defined layout,
|
/// A struct that basically replaces a Box<str>, but with a defined layout,
|
||||||
/// suitable for FFI.
|
/// suitable for FFI.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
1
components/style_traits/rustfmt.toml
Normal file
1
components/style_traits/rustfmt.toml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
disable_all_formatting = true
|
|
@ -4,13 +4,11 @@
|
||||||
|
|
||||||
//! Value information for devtools.
|
//! Value information for devtools.
|
||||||
|
|
||||||
use std::ops::Range;
|
|
||||||
use std::sync::Arc as StdArc;
|
|
||||||
|
|
||||||
use servo_arc::Arc;
|
|
||||||
|
|
||||||
use crate::arc_slice::ArcSlice;
|
use crate::arc_slice::ArcSlice;
|
||||||
use crate::owned_slice::OwnedSlice;
|
use crate::owned_slice::OwnedSlice;
|
||||||
|
use servo_arc::Arc;
|
||||||
|
use std::ops::Range;
|
||||||
|
use std::sync::Arc as StdArc;
|
||||||
|
|
||||||
/// Type of value that a property supports. This is used by Gecko's
|
/// Type of value that a property supports. This is used by Gecko's
|
||||||
/// devtools to make sense about value it parses, and types listed
|
/// devtools to make sense about value it parses, and types listed
|
||||||
|
|
|
@ -4,13 +4,11 @@
|
||||||
|
|
||||||
//! Helper types and traits for the handling of CSS values.
|
//! Helper types and traits for the handling of CSS values.
|
||||||
|
|
||||||
use std::fmt::{self, Write};
|
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::{
|
use cssparser::ToCss as CssparserToCss;
|
||||||
serialize_string, ParseError, Parser, ToCss as CssparserToCss, Token, UnicodeRange,
|
use cssparser::{serialize_string, ParseError, Parser, Token, UnicodeRange};
|
||||||
};
|
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
|
use std::fmt::{self, Write};
|
||||||
|
|
||||||
/// Serialises a value according to its CSS representation.
|
/// Serialises a value according to its CSS representation.
|
||||||
///
|
///
|
||||||
|
@ -380,7 +378,7 @@ impl Separator for Space {
|
||||||
let mut results = vec![parse_one(input)?];
|
let mut results = vec![parse_one(input)?];
|
||||||
loop {
|
loop {
|
||||||
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
|
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
|
||||||
if let Ok(item) = input.r#try(&mut parse_one) {
|
if let Ok(item) = input.try(&mut parse_one) {
|
||||||
results.push(item);
|
results.push(item);
|
||||||
} else {
|
} else {
|
||||||
return Ok(results);
|
return Ok(results);
|
||||||
|
@ -406,9 +404,9 @@ impl Separator for CommaWithSpace {
|
||||||
loop {
|
loop {
|
||||||
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
|
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
|
||||||
let comma_location = input.current_source_location();
|
let comma_location = input.current_source_location();
|
||||||
let comma = input.r#try(|i| i.expect_comma()).is_ok();
|
let comma = input.try(|i| i.expect_comma()).is_ok();
|
||||||
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
|
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
|
||||||
if let Ok(item) = input.r#try(&mut parse_one) {
|
if let Ok(item) = input.try(&mut parse_one) {
|
||||||
results.push(item);
|
results.push(item);
|
||||||
} else if comma {
|
} else if comma {
|
||||||
return Err(comma_location.new_unexpected_token_error(Token::Comma));
|
return Err(comma_location.new_unexpected_token_error(Token::Comma));
|
||||||
|
@ -506,9 +504,6 @@ impl_to_css_for_predefined_type!(::cssparser::UnicodeRange);
|
||||||
|
|
||||||
/// Helper types for the handling of specified values.
|
/// Helper types for the handling of specified values.
|
||||||
pub mod specified {
|
pub mod specified {
|
||||||
use malloc_size_of_derive::MallocSizeOf;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use crate::ParsingMode;
|
use crate::ParsingMode;
|
||||||
|
|
||||||
/// Whether to allow negative lengths or not.
|
/// Whether to allow negative lengths or not.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue