mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
style: Fix servo build, and appease tidy / fmt.
This commit is contained in:
parent
8c004c0858
commit
49842f5031
23 changed files with 165 additions and 53 deletions
45
Cargo.lock
generated
45
Cargo.lock
generated
|
@ -942,6 +942,17 @@ dependencies = [
|
|||
"deny_public_fields 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_common"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"darling 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "0.13.0"
|
||||
|
@ -3646,6 +3657,8 @@ dependencies = [
|
|||
"servo_arc 0.1.1",
|
||||
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thin-slice 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"to_shmem 0.0.1",
|
||||
"to_shmem_derive 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3992,6 +4005,8 @@ dependencies = [
|
|||
"malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo_rand 0.0.1",
|
||||
"to_shmem 0.0.1",
|
||||
"to_shmem_derive 0.0.1",
|
||||
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4240,6 +4255,8 @@ dependencies = [
|
|||
"style_traits 0.0.1",
|
||||
"thin-slice 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"to_shmem 0.0.1",
|
||||
"to_shmem_derive 0.0.1",
|
||||
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uluru 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-bidi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4253,6 +4270,7 @@ name = "style_derive"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"darling 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"derive_common 0.0.1",
|
||||
"proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -4297,6 +4315,8 @@ dependencies = [
|
|||
"servo_arc 0.1.1",
|
||||
"servo_atoms 0.0.1",
|
||||
"servo_url 0.0.1",
|
||||
"to_shmem 0.0.1",
|
||||
"to_shmem_derive 0.0.1",
|
||||
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
|
||||
]
|
||||
|
||||
|
@ -4435,6 +4455,31 @@ dependencies = [
|
|||
"libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "to_shmem"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"cssparser 0.25.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"servo_arc 0.1.1",
|
||||
"smallbitvec 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thin-slice 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "to_shmem_derive"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"darling 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"derive_common 0.0.1",
|
||||
"proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "0.1.8"
|
||||
|
|
|
@ -26,7 +26,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
|
|||
use std::sync::Arc;
|
||||
use style::computed_values::{font_stretch, font_style, font_variant_caps, font_weight};
|
||||
use style::properties::style_structs::Font as FontStyleStruct;
|
||||
use style::values::computed::font::SingleFontFamily;
|
||||
use style::values::computed::font::{GenericFontFamily, SingleFontFamily};
|
||||
use unicode_script::Script;
|
||||
|
||||
macro_rules! ot_tag {
|
||||
|
@ -564,9 +564,14 @@ impl<'a> From<&'a SingleFontFamily> for FontFamilyName {
|
|||
FontFamilyName::Specific(family_name.name.clone())
|
||||
},
|
||||
|
||||
SingleFontFamily::Generic(ref generic_name) => {
|
||||
FontFamilyName::Generic(generic_name.clone())
|
||||
},
|
||||
SingleFontFamily::Generic(generic) => FontFamilyName::Generic(match generic {
|
||||
GenericFontFamily::None => panic!("Shouldn't appear in style"),
|
||||
GenericFontFamily::Serif => atom!("serif"),
|
||||
GenericFontFamily::SansSerif => atom!("sans-serif"),
|
||||
GenericFontFamily::Monospace => atom!("monospace"),
|
||||
GenericFontFamily::Cursive => atom!("cursive"),
|
||||
GenericFontFamily::Fantasy => atom!("fantasy"),
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,10 @@ use std::fmt;
|
|||
use std::sync::Arc;
|
||||
use style::logical_geometry::LogicalSize;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::length::{MaxSize, NonNegativeLengthOrAuto, Size};
|
||||
use style::values::computed::length::{
|
||||
MaxSize, NonNegativeLengthOrAuto, NonNegativeLengthPercentageOrNormal, Size,
|
||||
};
|
||||
use style::values::generics::column::ColumnCount;
|
||||
use style::values::Either;
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe impl crate::flow::HasBaseFlow for MulticolFlow {}
|
||||
|
@ -106,8 +107,10 @@ impl Flow for MulticolFlow {
|
|||
{
|
||||
let style = &self.block_flow.fragment.style;
|
||||
let column_gap = match style.get_position().column_gap {
|
||||
Either::First(len) => len.0.to_pixel_length(content_inline_size).into(),
|
||||
Either::Second(_normal) => {
|
||||
NonNegativeLengthPercentageOrNormal::LengthPercentage(len) => {
|
||||
len.0.to_pixel_length(content_inline_size).into()
|
||||
},
|
||||
NonNegativeLengthPercentageOrNormal::Normal => {
|
||||
self.block_flow.fragment.style.get_font().font_size.size()
|
||||
},
|
||||
};
|
||||
|
|
|
@ -643,6 +643,7 @@ impl LayoutElementHelpers for LayoutDom<Element> {
|
|||
};
|
||||
|
||||
if let Some(font_family) = font_family {
|
||||
// FIXME(emilio): This in Gecko parses a whole family list.
|
||||
hints.push(from_declaration(
|
||||
shared_lock,
|
||||
PropertyDeclaration::FontFamily(font_family::SpecifiedValue::Values(
|
||||
|
|
|
@ -20,7 +20,7 @@ gecko = ["style_traits/gecko", "fallible/known_system_malloc"]
|
|||
use_bindgen = ["bindgen", "regex", "toml"]
|
||||
servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever",
|
||||
"cssparser/serde", "encoding_rs", "malloc_size_of/servo", "arrayvec/use_union",
|
||||
"servo_url", "string_cache", "crossbeam-channel"]
|
||||
"servo_url", "string_cache", "crossbeam-channel", "to_shmem/servo", "servo_arc/servo"]
|
||||
gecko_debug = []
|
||||
|
||||
[dependencies]
|
||||
|
|
|
@ -70,7 +70,7 @@ impl FontMetricsProvider for ServoMetricsProvider {
|
|||
ServoMetricsProvider
|
||||
}
|
||||
|
||||
fn get_size(&self, _font_name: &Atom, _font_family: u8) -> Au {
|
||||
fn get_size(&self, _: &Atom, _: crate::values::computed::font::GenericFontFamily) -> Au {
|
||||
unreachable!("Dummy provider should never be used to compute font size")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ impl MallocSizeOf for CssUrl {
|
|||
}
|
||||
|
||||
/// A key type for URL_VALUE_TABLE.
|
||||
#[derive(Hash, PartialEq, Eq)]
|
||||
#[derive(Eq, Hash, PartialEq)]
|
||||
struct CssUrlDataKey(*const CssUrlData);
|
||||
|
||||
unsafe impl Sync for CssUrlDataKey {}
|
||||
|
|
|
@ -25,7 +25,7 @@ use style_traits::{CssWriter, ParseError, ParsingMode, StyleParseErrorKind, ToCs
|
|||
use crate::stylesheets::{CssRuleType, Origin, UrlExtraData};
|
||||
use super::*;
|
||||
use crate::values::computed::Context;
|
||||
use crate::selector_parser::{SelectorImpl};
|
||||
use crate::selector_parser::SelectorImpl;
|
||||
use selectors::SelectorList;
|
||||
|
||||
/// The animation rules.
|
||||
|
|
|
@ -495,8 +495,7 @@ ${helpers.predefined_type(
|
|||
// a lot of code with `if product == gecko` conditionals, we have a
|
||||
// dummy system font module that does nothing
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, SpecifiedValueInfo, ToCss)]
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
|
||||
/// void enum for system font, can never exist
|
||||
pub enum SystemFont {}
|
||||
impl SystemFont {
|
||||
|
|
|
@ -29,8 +29,7 @@ use style_traits::{ParseError, StyleParseErrorKind};
|
|||
/// A pseudo-element, both public and private.
|
||||
///
|
||||
/// NB: If you add to this list, be sure to update `each_simple_pseudo_element` too.
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToShmem)]
|
||||
#[allow(missing_docs)]
|
||||
#[repr(usize)]
|
||||
pub enum PseudoElement {
|
||||
|
@ -265,8 +264,7 @@ pub type Lang = Box<str>;
|
|||
|
||||
/// A non tree-structural pseudo-class.
|
||||
/// See https://drafts.csswg.org/selectors-4/#structural-pseudos
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToShmem)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum NonTSPseudoClass {
|
||||
Active,
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::fmt::{self, Write};
|
|||
// nonzero optimization is important in keeping the size of SpecifiedUrl below
|
||||
// the threshold.
|
||||
use crate::values::computed::{Context, ToComputedValue};
|
||||
use std::sync::Arc;
|
||||
use servo_arc::Arc;
|
||||
use style_traits::{CssWriter, ParseError, ToCss};
|
||||
|
||||
/// A CSS url() value for servo.
|
||||
|
@ -26,7 +26,7 @@ use style_traits::{CssWriter, ParseError, ToCss};
|
|||
///
|
||||
/// TODO(emilio): This should be shrunk by making CssUrl a wrapper type of an
|
||||
/// arc, and keep the serialization in that Arc. See gecko/url.rs for example.
|
||||
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize, SpecifiedValueInfo)]
|
||||
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize, SpecifiedValueInfo, ToShmem)]
|
||||
pub struct CssUrl {
|
||||
/// The original URI. This might be optional since we may insert computed
|
||||
/// values of images into the cascade directly, and we don't bother to
|
||||
|
|
|
@ -15,7 +15,6 @@ use std::cell::UnsafeCell;
|
|||
use std::fmt;
|
||||
#[cfg(feature = "servo")]
|
||||
use std::mem;
|
||||
#[cfg(feature = "gecko")]
|
||||
use std::mem::ManuallyDrop;
|
||||
#[cfg(feature = "gecko")]
|
||||
use std::ptr;
|
||||
|
@ -124,11 +123,7 @@ impl<'a> Drop for SharedRwLockReadGuard<'a> {
|
|||
fn drop(&mut self) {
|
||||
// Unsafe: self.lock is private to this module, only ever set after `read()`,
|
||||
// and never copied or cloned (see `compile_time_assert` below).
|
||||
if let Some(arc) = self.0.arc {
|
||||
unsafe {
|
||||
arc.force_unlock_read();
|
||||
}
|
||||
}
|
||||
unsafe { self.0.arc.force_unlock_read() }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,12 +161,6 @@ impl<T: fmt::Debug> fmt::Debug for Locked<T> {
|
|||
}
|
||||
|
||||
impl<T> Locked<T> {
|
||||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
fn is_read_only_lock(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
#[inline]
|
||||
fn is_read_only_lock(&self) -> bool {
|
||||
|
@ -199,10 +188,14 @@ impl<T> Locked<T> {
|
|||
|
||||
/// Access the data for reading.
|
||||
pub fn read_with<'a>(&'a self, guard: &'a SharedRwLockReadGuard) -> &'a T {
|
||||
#[cfg(feature = "gecko")]
|
||||
assert!(
|
||||
self.is_read_only_lock() || self.same_lock_as(guard.0.as_ref().map(|r| &**r)),
|
||||
"Locked::read_with called with a guard from an unrelated SharedRwLock"
|
||||
);
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
assert!(self.same_lock_as(&guard.0));
|
||||
|
||||
let ptr = self.data.get();
|
||||
|
||||
// Unsafe:
|
||||
|
@ -223,10 +216,14 @@ impl<T> Locked<T> {
|
|||
|
||||
/// Access the data for writing.
|
||||
pub fn write_with<'a>(&'a self, guard: &'a mut SharedRwLockWriteGuard) -> &'a mut T {
|
||||
#[cfg(feature = "gecko")]
|
||||
assert!(
|
||||
!self.is_read_only_lock() && self.same_lock_as(Some(&guard.0)),
|
||||
"Locked::write_with called with a guard from a read only or unrelated SharedRwLock"
|
||||
);
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
assert!(self.same_lock_as(&guard.0));
|
||||
|
||||
let ptr = self.data.get();
|
||||
|
||||
// Unsafe:
|
||||
|
|
|
@ -39,6 +39,7 @@ use std::fmt;
|
|||
#[cfg(feature = "gecko")]
|
||||
use std::mem::{self, ManuallyDrop};
|
||||
use style_traits::ParsingMode;
|
||||
#[cfg(feature = "gecko")]
|
||||
use to_shmem::{SharedMemoryBuilder, ToShmem};
|
||||
|
||||
pub use self::counter_style_rule::CounterStyleRule;
|
||||
|
|
|
@ -29,6 +29,7 @@ use std::mem::{self, ManuallyDrop};
|
|||
#[cfg(feature = "servo")]
|
||||
use std::slice;
|
||||
use style_traits::{CssWriter, ParseError, ToCss};
|
||||
#[cfg(feature = "gecko")]
|
||||
use to_shmem::{SharedMemoryBuilder, ToShmem};
|
||||
|
||||
pub use crate::values::computed::Length as MozScriptMinSize;
|
||||
|
@ -284,7 +285,7 @@ pub enum FontFamilyNameSyntax {
|
|||
Identifiers,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)]
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToResolvedValue, ToShmem)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, Hash))]
|
||||
/// A set of faces that vary in weight, width or slope.
|
||||
pub enum SingleFontFamily {
|
||||
|
@ -299,7 +300,10 @@ pub enum SingleFontFamily {
|
|||
/// The order here is important, if you change it make sure that
|
||||
/// `gfxPlatformFontList.h`s ranged array and `gfxFontFamilyList`'s
|
||||
/// sSingleGenerics are updated as well.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, Parse, ToCss, ToResolvedValue)]
|
||||
#[derive(
|
||||
Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, Parse, ToCss, ToResolvedValue, ToShmem,
|
||||
)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[repr(u8)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum GenericFontFamily {
|
||||
|
@ -373,6 +377,35 @@ impl SingleFontFamily {
|
|||
}))
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
/// Get the corresponding font-family with Atom
|
||||
pub fn from_atom(input: Atom) -> SingleFontFamily {
|
||||
match input {
|
||||
atom!("serif") => return SingleFontFamily::Generic(GenericFontFamily::Serif),
|
||||
atom!("sans-serif") => return SingleFontFamily::Generic(GenericFontFamily::SansSerif),
|
||||
atom!("cursive") => return SingleFontFamily::Generic(GenericFontFamily::Cursive),
|
||||
atom!("fantasy") => return SingleFontFamily::Generic(GenericFontFamily::Fantasy),
|
||||
atom!("monospace") => return SingleFontFamily::Generic(GenericFontFamily::Monospace),
|
||||
_ => {},
|
||||
}
|
||||
|
||||
match_ignore_ascii_case! { &input,
|
||||
"serif" => return SingleFontFamily::Generic(GenericFontFamily::Serif),
|
||||
"sans-serif" => return SingleFontFamily::Generic(GenericFontFamily::SansSerif),
|
||||
"cursive" => return SingleFontFamily::Generic(GenericFontFamily::Cursive),
|
||||
"fantasy" => return SingleFontFamily::Generic(GenericFontFamily::Fantasy),
|
||||
"monospace" => return SingleFontFamily::Generic(GenericFontFamily::Monospace),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// We don't know if it's quoted or not. So we set it to
|
||||
// quoted by default.
|
||||
SingleFontFamily::FamilyName(FamilyName {
|
||||
name: input,
|
||||
syntax: FontFamilyNameSyntax::Quoted,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
/// Get the corresponding font-family with family name
|
||||
fn from_font_family_name(family: &structs::FontFamilyName) -> SingleFontFamily {
|
||||
|
@ -389,7 +422,7 @@ impl SingleFontFamily {
|
|||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToResolvedValue)]
|
||||
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToResolvedValue, ToShmem)]
|
||||
/// A list of SingleFontFamily
|
||||
pub struct FontFamilyList(Box<[SingleFontFamily]>);
|
||||
|
||||
|
@ -501,7 +534,7 @@ impl FontFamilyList {
|
|||
let mut iter = self.iter();
|
||||
if let Some(SingleFontFamily::Generic(f)) = iter.next() {
|
||||
if iter.next().is_none() {
|
||||
return Some(f);
|
||||
return Some(f.clone());
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
|
@ -557,7 +557,7 @@ pub enum TrackListType {
|
|||
/// A grid `<track-list>` type.
|
||||
///
|
||||
/// <https://drafts.csswg.org/css-grid/#typedef-track-list>
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToShmem, ToResolvedValue)]
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToResolvedValue, ToShmem)]
|
||||
pub struct TrackList<LengthPercentage, Integer> {
|
||||
/// The type of this `<track-list>` (auto, explicit or general).
|
||||
///
|
||||
|
|
|
@ -157,7 +157,7 @@ pub struct ColorStop<Color, LengthPercentage> {
|
|||
/// Specified values for a paint worklet.
|
||||
/// <https://drafts.css-houdini.org/css-paint-api/>
|
||||
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
|
||||
#[derive(Clone, Debug, PartialEq, ToComputedValue)]
|
||||
#[derive(Clone, Debug, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)]
|
||||
pub struct PaintWorklet {
|
||||
/// The name the worklet was registered with.
|
||||
pub name: Atom,
|
||||
|
|
|
@ -65,15 +65,16 @@ trivial_to_resolved_value!(u8);
|
|||
trivial_to_resolved_value!(i8);
|
||||
trivial_to_resolved_value!(u16);
|
||||
trivial_to_resolved_value!(u32);
|
||||
#[cfg(feature = "servo")]
|
||||
trivial_to_resolved_value!(Prefix);
|
||||
trivial_to_resolved_value!(String);
|
||||
trivial_to_resolved_value!(Box<str>);
|
||||
trivial_to_resolved_value!(cssparser::RGBA);
|
||||
trivial_to_resolved_value!(crate::Atom);
|
||||
trivial_to_resolved_value!(app_units::Au);
|
||||
trivial_to_resolved_value!(computed::url::ComputedUrl);
|
||||
#[cfg(feature = "gecko")]
|
||||
trivial_to_resolved_value!(computed::url::ComputedImageUrl);
|
||||
#[cfg(feature = "servo")]
|
||||
trivial_to_resolved_value!(html5ever::Prefix);
|
||||
|
||||
impl<A, B> ToResolvedValue for (A, B)
|
||||
where
|
||||
|
|
|
@ -1192,7 +1192,7 @@ macro_rules! impl_variant_east_asian {
|
|||
)+
|
||||
} => {
|
||||
bitflags! {
|
||||
#[derive(MallocSizeOf, ToShmem, ToResolvedValue)]
|
||||
#[derive(MallocSizeOf, ToResolvedValue, ToShmem)]
|
||||
/// Vairants for east asian variant
|
||||
pub struct VariantEastAsian: u16 {
|
||||
/// None of the features
|
||||
|
|
|
@ -10,13 +10,14 @@ name = "to_shmem"
|
|||
path = "lib.rs"
|
||||
|
||||
[features]
|
||||
servo = ["serde", "cssparser/serde"]
|
||||
servo = ["serde", "cssparser/serde", "string_cache"]
|
||||
gecko = []
|
||||
|
||||
[dependencies]
|
||||
cssparser = "0.25"
|
||||
serde = {version = "1.0", optional = true}
|
||||
serde = { version = "1.0", optional = true }
|
||||
servo_arc = { path = "../servo_arc" }
|
||||
smallbitvec = "2.1.1"
|
||||
smallvec = "0.6.6"
|
||||
string_cache = { version = "0.7", optional = true }
|
||||
thin-slice = "0.1.0"
|
||||
|
|
|
@ -16,6 +16,8 @@ extern crate cssparser;
|
|||
extern crate servo_arc;
|
||||
extern crate smallbitvec;
|
||||
extern crate smallvec;
|
||||
#[cfg(feature = "string_cache")]
|
||||
extern crate string_cache;
|
||||
extern crate thin_slice;
|
||||
|
||||
use servo_arc::{Arc, ThinArc};
|
||||
|
@ -193,16 +195,18 @@ pub trait ToShmem: Sized {
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! impl_trivial_to_shmem {
|
||||
($($ty:ty),*) => {$(
|
||||
impl $crate::ToShmem for $ty {
|
||||
fn to_shmem(
|
||||
&self,
|
||||
_builder: &mut $crate::SharedMemoryBuilder,
|
||||
) -> ::std::mem::ManuallyDrop<Self> {
|
||||
::std::mem::ManuallyDrop::new(*self)
|
||||
($($ty:ty),*) => {
|
||||
$(
|
||||
impl $crate::ToShmem for $ty {
|
||||
fn to_shmem(
|
||||
&self,
|
||||
_builder: &mut $crate::SharedMemoryBuilder,
|
||||
) -> ::std::mem::ManuallyDrop<Self> {
|
||||
::std::mem::ManuallyDrop::new(*self)
|
||||
}
|
||||
}
|
||||
}
|
||||
)*};
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
impl_trivial_to_shmem!(
|
||||
|
@ -522,3 +526,17 @@ impl ToShmem for SmallBitVec {
|
|||
ManuallyDrop::new(unsafe { SmallBitVec::from_storage(storage) })
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "string_cache")]
|
||||
impl<Static: string_cache::StaticAtomSet> ToShmem for string_cache::Atom<Static> {
|
||||
fn to_shmem(&self, _: &mut SharedMemoryBuilder) -> ManuallyDrop<Self> {
|
||||
// NOTE(emilio): In practice, this can be implemented trivially if
|
||||
// string_cache could expose the implementation detail of static atoms
|
||||
// being an index into the static table (and panicking in the
|
||||
// non-static, non-inline cases).
|
||||
unimplemented!(
|
||||
"If servo wants to share stylesheets across processes, \
|
||||
then ToShmem for Atom needs to be implemented"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ pub fn derive(mut input: syn::DeriveInput) -> TokenStream {
|
|||
|
||||
quote! {
|
||||
impl #impl_generics ::to_shmem::ToShmem for #name #ty_generics #where_clause {
|
||||
#[allow(unused_variables)]
|
||||
#[allow(unused_variables, unreachable_code)]
|
||||
fn to_shmem(
|
||||
&self,
|
||||
builder: &mut ::to_shmem::SharedMemoryBuilder,
|
||||
|
|
|
@ -13,6 +13,8 @@ path = "lib.rs"
|
|||
[dependencies]
|
||||
malloc_size_of = { path = "../malloc_size_of", features = ["servo"] }
|
||||
malloc_size_of_derive = "0.1"
|
||||
to_shmem = { path = "../to_shmem" }
|
||||
to_shmem_derive = { path = "../to_shmem_derive" }
|
||||
serde = {version = "1.0", features = ["derive"]}
|
||||
servo_rand = {path = "../rand"}
|
||||
url = "1.2"
|
||||
|
|
|
@ -20,10 +20,12 @@ pub use crate::origin::{ImmutableOrigin, MutableOrigin, OpaqueOrigin};
|
|||
use std::collections::hash_map::DefaultHasher;
|
||||
use std::fmt;
|
||||
use std::hash::Hasher;
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::net::IpAddr;
|
||||
use std::ops::{Index, Range, RangeFrom, RangeFull, RangeTo};
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use to_shmem::{SharedMemoryBuilder, ToShmem};
|
||||
use url::{Position, Url};
|
||||
|
||||
pub use url::Host;
|
||||
|
@ -31,6 +33,12 @@ pub use url::Host;
|
|||
#[derive(Clone, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd)]
|
||||
pub struct ServoUrl(#[ignore_malloc_size_of = "Arc"] Arc<Url>);
|
||||
|
||||
impl ToShmem for ServoUrl {
|
||||
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> ManuallyDrop<Self> {
|
||||
unimplemented!("If servo wants to share stylesheets across processes, ToShmem for Url must be implemented")
|
||||
}
|
||||
}
|
||||
|
||||
impl ServoUrl {
|
||||
pub fn from_url(url: Url) -> Self {
|
||||
ServoUrl(Arc::new(url))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue