mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01: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
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue