style: Reformat recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2020-04-16 17:01:24 +02:00
parent 7c96aed31d
commit f76acc84c6
30 changed files with 330 additions and 191 deletions

View file

@ -2043,7 +2043,10 @@ where
// given selector is allowed to match a featureless element, // given selector is allowed to match a featureless element,
// it must do so while ignoring the default namespace. // it must do so while ignoring the default namespace.
// //
if !matches!(result, SimpleSelectorParseResult::SimpleSelector(Component::Host(..))) { if !matches!(
result,
SimpleSelectorParseResult::SimpleSelector(Component::Host(..))
) {
builder.push_simple_selector(Component::DefaultNamespace(url)); builder.push_simple_selector(Component::DefaultNamespace(url));
} }
} }

View file

@ -408,7 +408,9 @@ impl ToCss for System {
} }
/// <https://drafts.csswg.org/css-counter-styles/#typedef-symbol> /// <https://drafts.csswg.org/css-counter-styles/#typedef-symbol>
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToCss, ToShmem)] #[derive(
Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToCss, ToShmem,
)]
#[repr(u8)] #[repr(u8)]
pub enum Symbol { pub enum Symbol {
/// <string> /// <string>
@ -554,7 +556,9 @@ impl Parse for Fallback {
} }
/// <https://drafts.csswg.org/css-counter-styles/#descdef-counter-style-symbols> /// <https://drafts.csswg.org/css-counter-styles/#descdef-counter-style-symbols>
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToCss, ToShmem)] #[derive(
Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToCss, ToShmem,
)]
#[repr(C)] #[repr(C)]
pub struct Symbols(#[css(iterable)] pub crate::OwnedSlice<Symbol>); pub struct Symbols(#[css(iterable)] pub crate::OwnedSlice<Symbol>);

View file

@ -582,7 +582,7 @@ impl<'a> CustomPropertiesBuilder<'a> {
// Don't touch the map, this has the same effect as // Don't touch the map, this has the same effect as
// making it compute to the inherited one. // making it compute to the inherited one.
return; return;
} },
} }
} else { } else {
(*unparsed_value).clone() (*unparsed_value).clone()
@ -848,7 +848,7 @@ fn substitute_all(
match result { match result {
Ok(computed_value) => { Ok(computed_value) => {
context.map.insert(name, Arc::new(computed_value)); context.map.insert(name, Arc::new(computed_value));
} },
Err(..) => { Err(..) => {
// This is invalid, reset it to the unset (inherited) value. // This is invalid, reset it to the unset (inherited) value.
let inherited = context.inherited.and_then(|m| m.get(&name)).cloned(); let inherited = context.inherited.and_then(|m| m.get(&name)).cloned();
@ -860,7 +860,7 @@ fn substitute_all(
context.map.remove(&name); context.map.remove(&name);
}, },
}; };
} },
} }
// All resolved, so return the signal value. // All resolved, so return the signal value.

View file

@ -10,7 +10,7 @@
#![allow(unsafe_code)] #![allow(unsafe_code)]
use crate::gecko_bindings::structs::{Matrix4x4Components, nsresult}; use crate::gecko_bindings::structs::{nsresult, Matrix4x4Components};
use crate::stylesheets::RulesMutateError; use crate::stylesheets::RulesMutateError;
use crate::values::computed::transform::Matrix3D; use crate::values::computed::transform::Matrix3D;

View file

@ -318,7 +318,9 @@ impl Device {
let mut right = 0.0; let mut right = 0.0;
let mut bottom = 0.0; let mut bottom = 0.0;
let mut left = 0.0; let mut left = 0.0;
unsafe { bindings::Gecko_GetSafeAreaInsets(pc, &mut top, &mut right, &mut bottom, &mut left) }; unsafe {
bindings::Gecko_GetSafeAreaInsets(pc, &mut top, &mut right, &mut bottom, &mut left)
};
SideOffsets2D::new(top, right, bottom, left) SideOffsets2D::new(top, right, bottom, left)
} }
} }

View file

@ -173,7 +173,7 @@ impl NonTSPseudoClass {
#[inline] #[inline]
fn is_enabled_in_content(&self) -> bool { fn is_enabled_in_content(&self) -> bool {
if matches!(*self, NonTSPseudoClass::FocusVisible) { if matches!(*self, NonTSPseudoClass::FocusVisible) {
return static_prefs::pref!("layout.css.focus-visible.enabled") return static_prefs::pref!("layout.css.focus-visible.enabled");
} }
!self.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME) !self.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME)
} }

View file

@ -93,13 +93,7 @@ pub(super) fn each_exported_part(
None => return, None => return,
}; };
let mut length = 0; let mut length = 0;
let atoms = unsafe { let atoms = unsafe { bindings::Gecko_Element_ExportedParts(attr, name.as_ptr(), &mut length) };
bindings::Gecko_Element_ExportedParts(
attr,
name.as_ptr(),
&mut length,
)
};
if atoms.is_null() { if atoms.is_null() {
return; return;
} }

View file

@ -24,7 +24,18 @@ macro_rules! ns {
} }
/// A Gecko namespace is just a wrapped atom. /// A Gecko namespace is just a wrapped atom.
#[derive(Clone, Debug, Default, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)] #[derive(
Clone,
Debug,
Default,
Eq,
Hash,
MallocSizeOf,
PartialEq,
ToComputedValue,
ToResolvedValue,
ToShmem,
)]
#[repr(transparent)] #[repr(transparent)]
pub struct Namespace(pub Atom); pub struct Namespace(pub Atom);

View file

@ -148,7 +148,8 @@ where
self.context.current_host = host.map(|e| e.opaque()); self.context.current_host = host.map(|e| e.opaque());
f(self); f(self);
if start != self.rules.len() { if start != self.rules.len() {
self.rules[start..].sort_unstable_by_key(|block| (block.specificity, block.source_order())); self.rules[start..]
.sort_unstable_by_key(|block| (block.specificity, block.source_order()));
} }
self.context.current_host = old_host; self.context.current_host = old_host;
self.in_sort_scope = false; self.in_sort_scope = false;
@ -214,11 +215,7 @@ where
} }
#[inline] #[inline]
fn collect_rules_in_list( fn collect_rules_in_list(&mut self, part_rules: &[Rule], cascade_level: CascadeLevel) {
&mut self,
part_rules: &[Rule],
cascade_level: CascadeLevel,
) {
debug_assert!(self.in_sort_scope, "Rules gotta be sorted"); debug_assert!(self.in_sort_scope, "Rules gotta be sorted");
SelectorMap::get_matching_rules( SelectorMap::get_matching_rules(
self.element, self.element,
@ -231,11 +228,7 @@ where
} }
#[inline] #[inline]
fn collect_rules_in_map( fn collect_rules_in_map(&mut self, map: &SelectorMap<Rule>, cascade_level: CascadeLevel) {
&mut self,
map: &SelectorMap<Rule>,
cascade_level: CascadeLevel,
) {
debug_assert!(self.in_sort_scope, "Rules gotta be sorted"); debug_assert!(self.in_sort_scope, "Rules gotta be sorted");
map.get_all_matching_rules( map.get_all_matching_rules(
self.element, self.element,
@ -413,10 +406,7 @@ where
self.in_tree(containing_host, |collector| { self.in_tree(containing_host, |collector| {
for p in &parts { for p in &parts {
if let Some(part_rules) = part_rules.get(p) { if let Some(part_rules) = part_rules.get(p) {
collector.collect_rules_in_list( collector.collect_rules_in_list(part_rules, cascade_level);
part_rules,
cascade_level,
);
} }
} }
}); });

View file

@ -58,8 +58,8 @@ pub use self::rule_parser::{InsertRuleContext, State, TopLevelRuleParser};
pub use self::rules_iterator::{AllRules, EffectiveRules}; pub use self::rules_iterator::{AllRules, EffectiveRules};
pub use self::rules_iterator::{NestedRuleIterationCondition, RulesIterator}; pub use self::rules_iterator::{NestedRuleIterationCondition, RulesIterator};
pub use self::style_rule::StyleRule; pub use self::style_rule::StyleRule;
pub use self::stylesheet::{AllowImportRules, SanitizationData, SanitizationKind};
pub use self::stylesheet::{DocumentStyleSheet, Namespaces, Stylesheet}; pub use self::stylesheet::{DocumentStyleSheet, Namespaces, Stylesheet};
pub use self::stylesheet::{SanitizationData, SanitizationKind, AllowImportRules};
pub use self::stylesheet::{StylesheetContents, StylesheetInDocument, UserAgentStylesheets}; pub use self::stylesheet::{StylesheetContents, StylesheetInDocument, UserAgentStylesheets};
pub use self::supports_rule::SupportsRule; pub use self::supports_rule::SupportsRule;
pub use self::viewport_rule::ViewportRule; pub use self::viewport_rule::ViewportRule;

View file

@ -10,7 +10,7 @@ use crate::str::CssStringWriter;
use crate::stylesheets::loader::StylesheetLoader; use crate::stylesheets::loader::StylesheetLoader;
use crate::stylesheets::rule_parser::{InsertRuleContext, State}; use crate::stylesheets::rule_parser::{InsertRuleContext, State};
use crate::stylesheets::stylesheet::StylesheetContents; use crate::stylesheets::stylesheet::StylesheetContents;
use crate::stylesheets::{CssRule, RulesMutateError, AllowImportRules}; use crate::stylesheets::{AllowImportRules, CssRule, RulesMutateError};
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps}; use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps};
use servo_arc::{Arc, RawOffsetArc}; use servo_arc::{Arc, RawOffsetArc};

View file

@ -694,9 +694,7 @@ where
if let Some(ref values) = data.styles.primary { if let Some(ref values) = data.styles.primary {
for image in &values.get_background().background_image.0 { for image in &values.get_background().background_image.0 {
let (name, arguments) = match *image { let (name, arguments) = match *image {
Image::PaintWorklet(ref worklet) => { Image::PaintWorklet(ref worklet) => (&worklet.name, &worklet.arguments),
(&worklet.name, &worklet.arguments)
},
_ => continue, _ => continue,
}; };
let painter = match context.shared.registered_speculative_painters.get(name) { let painter = match context.shared.registered_speculative_painters.get(name) {

View file

@ -227,7 +227,9 @@ impl ToCss for FontFamily {
} }
} }
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)] #[derive(
Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem,
)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
/// The name of a font family of choice /// The name of a font family of choice
pub struct FamilyName { pub struct FamilyName {
@ -270,7 +272,9 @@ impl ToCss for FamilyName {
} }
} }
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)] #[derive(
Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem,
)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
/// Font family names must either be given quoted as strings, /// Font family names must either be given quoted as strings,
/// or unquoted as a sequence of one or more identifiers. /// or unquoted as a sequence of one or more identifiers.
@ -285,7 +289,9 @@ pub enum FontFamilyNameSyntax {
Identifiers, Identifiers,
} }
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToComputedValue, ToResolvedValue, ToShmem)] #[derive(
Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToComputedValue, ToResolvedValue, ToShmem,
)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, Hash))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize, Hash))]
/// A set of faces that vary in weight, width or slope. /// A set of faces that vary in weight, width or slope.
pub enum SingleFontFamily { pub enum SingleFontFamily {
@ -301,7 +307,18 @@ pub enum SingleFontFamily {
/// `gfxPlatformFontList.h`s ranged array and `gfxFontFamilyList`'s /// `gfxPlatformFontList.h`s ranged array and `gfxFontFamilyList`'s
/// sSingleGenerics are updated as well. /// sSingleGenerics are updated as well.
#[derive( #[derive(
Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, Parse, ToCss, ToComputedValue, ToResolvedValue, ToShmem, Clone,
Copy,
Debug,
Eq,
Hash,
MallocSizeOf,
PartialEq,
Parse,
ToCss,
ToComputedValue,
ToResolvedValue,
ToShmem,
)] )]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[repr(u8)] #[repr(u8)]
@ -427,7 +444,9 @@ impl SingleFontFamily {
} }
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)] #[derive(
Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem,
)]
/// A list of SingleFontFamily /// A list of SingleFontFamily
pub struct FontFamilyList(Box<[SingleFontFamily]>); pub struct FontFamilyList(Box<[SingleFontFamily]>);

View file

@ -13,7 +13,8 @@ use crate::values::computed::url::ComputedImageUrl;
use crate::values::computed::NumberOrPercentage; use crate::values::computed::NumberOrPercentage;
use crate::values::computed::{Angle, Color, Context}; use crate::values::computed::{Angle, Color, Context};
use crate::values::computed::{ use crate::values::computed::{
AngleOrPercentage, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage, ToComputedValue, AngleOrPercentage, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage,
ToComputedValue,
}; };
use crate::values::generics::image::{self as generic, GradientCompatMode}; use crate::values::generics::image::{self as generic, GradientCompatMode};
use crate::values::specified::image::LineDirection as SpecifiedLineDirection; use crate::values::specified::image::LineDirection as SpecifiedLineDirection;

View file

@ -34,8 +34,8 @@ use crate::Zero;
use app_units::Au; use app_units::Au;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::fmt::{self, Write};
use std::borrow::Cow; use std::borrow::Cow;
use std::fmt::{self, Write};
use style_traits::values::specified::AllowedNumericType; use style_traits::values::specified::AllowedNumericType;
use style_traits::{CssWriter, ToCss}; use style_traits::{CssWriter, ToCss};
@ -202,7 +202,9 @@ impl LengthPercentage {
fn to_calc_node(&self) -> Cow<CalcNode> { fn to_calc_node(&self) -> Cow<CalcNode> {
match self.unpack() { match self.unpack() {
Unpacked::Length(l) => Cow::Owned(CalcNode::Leaf(CalcLengthPercentageLeaf::Length(l))), Unpacked::Length(l) => Cow::Owned(CalcNode::Leaf(CalcLengthPercentageLeaf::Length(l))),
Unpacked::Percentage(p) => Cow::Owned(CalcNode::Leaf(CalcLengthPercentageLeaf::Percentage(p))), Unpacked::Percentage(p) => {
Cow::Owned(CalcNode::Leaf(CalcLengthPercentageLeaf::Percentage(p)))
},
Unpacked::Calc(p) => Cow::Borrowed(&p.node), Unpacked::Calc(p) => Cow::Borrowed(&p.node),
} }
} }
@ -241,20 +243,20 @@ impl LengthPercentage {
let mut node = v.to_calc_node().into_owned(); let mut node = v.to_calc_node().into_owned();
node.negate(); node.negate();
let new_node = CalcNode::Sum(vec![ let new_node = CalcNode::Sum(
vec![
CalcNode::Leaf(CalcLengthPercentageLeaf::Percentage(Percentage::hundred())), CalcNode::Leaf(CalcLengthPercentageLeaf::Percentage(Percentage::hundred())),
node, node,
].into()); ]
.into(),
);
Self::new_calc(new_node, clamping_mode) Self::new_calc(new_node, clamping_mode)
} }
/// Constructs a `calc()` value. /// Constructs a `calc()` value.
#[inline] #[inline]
pub fn new_calc( pub fn new_calc(mut node: CalcNode, clamping_mode: AllowedNumericType) -> Self {
mut node: CalcNode,
clamping_mode: AllowedNumericType,
) -> Self {
node.simplify_and_sort(); node.simplify_and_sort();
match node { match node {
@ -267,13 +269,11 @@ impl LengthPercentage {
Self::new_percent(Percentage(clamping_mode.clamp(p.0))) Self::new_percent(Percentage(clamping_mode.clamp(p.0)))
}, },
} }
} },
_ => { _ => Self::new_calc_unchecked(Box::new(CalcLengthPercentage {
Self::new_calc_unchecked(Box::new(CalcLengthPercentage {
clamping_mode, clamping_mode,
node, node,
})) })),
}
} }
} }
@ -456,7 +456,7 @@ impl LengthPercentage {
UnpackedMut::Calc(ref mut c) => { UnpackedMut::Calc(ref mut c) => {
c.clamping_mode = AllowedNumericType::NonNegative; c.clamping_mode = AllowedNumericType::NonNegative;
self self
} },
} }
} }
} }
@ -577,7 +577,17 @@ impl<'de> Deserialize<'de> for LengthPercentage {
} }
/// The leaves of a `<length-percentage>` calc expression. /// The leaves of a `<length-percentage>` calc expression.
#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize, ToAnimatedZero, ToCss, ToResolvedValue)] #[derive(
Clone,
Debug,
Deserialize,
MallocSizeOf,
PartialEq,
Serialize,
ToAnimatedZero,
ToCss,
ToResolvedValue,
)]
#[allow(missing_docs)] #[allow(missing_docs)]
#[repr(u8)] #[repr(u8)]
pub enum CalcLengthPercentageLeaf { pub enum CalcLengthPercentageLeaf {
@ -609,8 +619,10 @@ impl PartialOrd for CalcLengthPercentageLeaf {
match *self { match *self {
Length(..) | Percentage(..) => {}, Length(..) | Percentage(..) => {},
} }
unsafe { debug_unreachable!("Forgot a branch?"); } unsafe {
debug_unreachable!("Forgot a branch?");
} }
},
} }
} }
} }
@ -670,7 +682,9 @@ impl calc::CalcNodeLeaf for CalcLengthPercentageLeaf {
pub type CalcNode = calc::GenericCalcNode<CalcLengthPercentageLeaf>; pub type CalcNode = calc::GenericCalcNode<CalcLengthPercentageLeaf>;
/// The representation of a calc() function with mixed lengths and percentages. /// The representation of a calc() function with mixed lengths and percentages.
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize, ToAnimatedZero, ToResolvedValue, ToCss)] #[derive(
Clone, Debug, Deserialize, MallocSizeOf, Serialize, ToAnimatedZero, ToResolvedValue, ToCss,
)]
#[repr(C)] #[repr(C)]
pub struct CalcLengthPercentage { pub struct CalcLengthPercentage {
#[animation(constant)] #[animation(constant)]
@ -684,12 +698,15 @@ impl CalcLengthPercentage {
#[inline] #[inline]
fn resolve(&self, basis: Length) -> Length { fn resolve(&self, basis: Length) -> Length {
// unwrap() is fine because the conversion below is infallible. // unwrap() is fine because the conversion below is infallible.
let px = self.node.resolve(|l| { let px = self
.node
.resolve(|l| {
Ok(match *l { Ok(match *l {
CalcLengthPercentageLeaf::Length(l) => l.px(), CalcLengthPercentageLeaf::Length(l) => l.px(),
CalcLengthPercentageLeaf::Percentage(ref p) => basis.px() * p.0, CalcLengthPercentageLeaf::Percentage(ref p) => basis.px() * p.0,
}) })
}).unwrap(); })
.unwrap();
Length::new(self.clamping_mode.clamp(px)) Length::new(self.clamping_mode.clamp(px))
} }
} }
@ -726,24 +743,16 @@ impl specified::CalcLengthPercentage {
use crate::values::specified::calc::Leaf; use crate::values::specified::calc::Leaf;
use crate::values::specified::length::NoCalcLength; use crate::values::specified::length::NoCalcLength;
let node = self.node.map_leaves(|leaf| { let node = self.node.map_leaves(|leaf| match *leaf {
match *leaf {
Leaf::Percentage(p) => CalcLengthPercentageLeaf::Percentage(Percentage(p)), Leaf::Percentage(p) => CalcLengthPercentageLeaf::Percentage(Percentage(p)),
Leaf::Length(l) => { Leaf::Length(l) => CalcLengthPercentageLeaf::Length(match l {
CalcLengthPercentageLeaf::Length(match l { NoCalcLength::Absolute(ref abs) => zoom_fn(abs.to_computed_value(context)),
NoCalcLength::Absolute(ref abs) => { NoCalcLength::FontRelative(ref fr) => fr.to_computed_value(context, base_size),
zoom_fn(abs.to_computed_value(context))
},
NoCalcLength::FontRelative(ref fr) => {
fr.to_computed_value(context, base_size)
},
other => other.to_computed_value(context), other => other.to_computed_value(context),
}) }),
Leaf::Number(..) | Leaf::Angle(..) | Leaf::Time(..) => {
unreachable!("Shouldn't have parsed")
}, },
Leaf::Number(..) |
Leaf::Angle(..) |
Leaf::Time(..) => unreachable!("Shouldn't have parsed"),
}
}); });
LengthPercentage::new_calc(node, self.clamping_mode) LengthPercentage::new_calc(node, self.clamping_mode)
@ -788,12 +797,12 @@ impl specified::CalcLengthPercentage {
specified::CalcLengthPercentage { specified::CalcLengthPercentage {
clamping_mode: computed.clamping_mode, clamping_mode: computed.clamping_mode,
node: computed.node.map_leaves(|l| { node: computed.node.map_leaves(|l| match l {
match l { CalcLengthPercentageLeaf::Length(ref l) => {
CalcLengthPercentageLeaf::Length(ref l) => Leaf::Length(NoCalcLength::from_px(l.px())), Leaf::Length(NoCalcLength::from_px(l.px()))
},
CalcLengthPercentageLeaf::Percentage(ref p) => Leaf::Percentage(p.0), CalcLengthPercentageLeaf::Percentage(ref p) => Leaf::Percentage(p.0),
} }),
})
} }
} }
} }
@ -819,7 +828,10 @@ impl Animate for LengthPercentage {
one.mul_by(l as f32); one.mul_by(l as f32);
other.mul_by(r as f32); other.mul_by(r as f32);
Self::new_calc(CalcNode::Sum(vec![one, other].into()), AllowedNumericType::All) Self::new_calc(
CalcNode::Sum(vec![one, other].into()),
AllowedNumericType::All,
)
}, },
}) })
} }

View file

@ -21,9 +21,9 @@ use crate::media_queries::Device;
use crate::properties; use crate::properties;
use crate::properties::{ComputedValues, LonghandId, StyleBuilder}; use crate::properties::{ComputedValues, LonghandId, StyleBuilder};
use crate::rule_cache::RuleCacheConditions; use crate::rule_cache::RuleCacheConditions;
use crate::{ArcSlice, Atom};
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use crate::Prefix; use crate::Prefix;
use crate::{ArcSlice, Atom};
use euclid::default::Size2D; use euclid::default::Size2D;
use servo_arc::Arc; use servo_arc::Arc;
use std::cell::RefCell; use std::cell::RefCell;

View file

@ -61,7 +61,7 @@ impl GenericPositionComponent for LengthPercentage {
fn is_center(&self) -> bool { fn is_center(&self) -> bool {
match self.to_percentage() { match self.to_percentage() {
Some(Percentage(per)) => per == 0.5, Some(Percentage(per)) => per == 0.5,
_ => false _ => false,
} }
} }
} }

View file

@ -114,7 +114,10 @@ pub enum GenericClipPath<BasicShape, U> {
Url(U), Url(U),
#[css(function)] #[css(function)]
Path(Path), Path(Path),
Shape(Box<BasicShape>, #[css(skip_if = "is_default")] ShapeGeometryBox), Shape(
Box<BasicShape>,
#[css(skip_if = "is_default")] ShapeGeometryBox,
),
#[animation(error)] #[animation(error)]
Box(ShapeGeometryBox), Box(ShapeGeometryBox),
} }

View file

@ -7,14 +7,25 @@
//! [calc]: https://drafts.csswg.org/css-values/#calc-notation //! [calc]: https://drafts.csswg.org/css-values/#calc-notation
use crate::Zero; use crate::Zero;
use style_traits::{CssWriter, ToCss};
use std::fmt::{self, Write};
use std::{cmp, mem};
use std::ops::Add;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::fmt::{self, Write};
use std::ops::Add;
use std::{cmp, mem};
use style_traits::{CssWriter, ToCss};
/// Whether we're a `min` or `max` function. /// Whether we're a `min` or `max` function.
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize, ToAnimatedZero, ToResolvedValue, ToShmem)] #[derive(
Clone,
Copy,
Debug,
Deserialize,
MallocSizeOf,
PartialEq,
Serialize,
ToAnimatedZero,
ToResolvedValue,
ToShmem,
)]
#[repr(u8)] #[repr(u8)]
pub enum MinMaxOp { pub enum MinMaxOp {
/// `min()` /// `min()`
@ -50,7 +61,17 @@ pub enum SortKey {
/// FIXME: This would be much more elegant if we used `Self` in the types below, /// FIXME: This would be much more elegant if we used `Self` in the types below,
/// but we can't because of https://github.com/serde-rs/serde/issues/1565. /// but we can't because of https://github.com/serde-rs/serde/issues/1565.
#[repr(u8)] #[repr(u8)]
#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize, ToAnimatedZero, ToResolvedValue, ToShmem)] #[derive(
Clone,
Debug,
Deserialize,
MallocSizeOf,
PartialEq,
Serialize,
ToAnimatedZero,
ToResolvedValue,
ToShmem,
)]
pub enum GenericCalcNode<L> { pub enum GenericCalcNode<L> {
/// A leaf node. /// A leaf node.
Leaf(L), Leaf(L),
@ -111,7 +132,9 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
/// Tries to merge one sum to another, that is, perform `x` + `y`. /// Tries to merge one sum to another, that is, perform `x` + `y`.
fn try_sum_in_place(&mut self, other: &Self) -> Result<(), ()> { fn try_sum_in_place(&mut self, other: &Self) -> Result<(), ()> {
match (self, other) { match (self, other) {
(&mut CalcNode::Leaf(ref mut one), &CalcNode::Leaf(ref other)) => one.try_sum_in_place(other), (&mut CalcNode::Leaf(ref mut one), &CalcNode::Leaf(ref other)) => {
one.try_sum_in_place(other)
},
_ => Err(()), _ => Err(()),
} }
} }
@ -139,25 +162,35 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
O: CalcNodeLeaf, O: CalcNodeLeaf,
F: FnMut(&L) -> O, F: FnMut(&L) -> O,
{ {
children.iter().map(|c| c.map_leaves_internal(map)).collect() children
.iter()
.map(|c| c.map_leaves_internal(map))
.collect()
} }
match *self { match *self {
Self::Leaf(ref l) => CalcNode::Leaf(map(l)), Self::Leaf(ref l) => CalcNode::Leaf(map(l)),
Self::Sum(ref c) => CalcNode::Sum(map_children(c, map)), Self::Sum(ref c) => CalcNode::Sum(map_children(c, map)),
Self::MinMax(ref c, op) => CalcNode::MinMax(map_children(c, map), op), Self::MinMax(ref c, op) => CalcNode::MinMax(map_children(c, map), op),
Self::Clamp { ref min, ref center, ref max } => { Self::Clamp {
ref min,
ref center,
ref max,
} => {
let min = Box::new(min.map_leaves_internal(map)); let min = Box::new(min.map_leaves_internal(map));
let center = Box::new(center.map_leaves_internal(map)); let center = Box::new(center.map_leaves_internal(map));
let max = Box::new(max.map_leaves_internal(map)); let max = Box::new(max.map_leaves_internal(map));
CalcNode::Clamp { min, center, max } CalcNode::Clamp { min, center, max }
} },
} }
} }
/// Resolves the expression returning a value of `O`, given a function to /// Resolves the expression returning a value of `O`, given a function to
/// turn a leaf into the relevant value. /// turn a leaf into the relevant value.
pub fn resolve<O>(&self, mut leaf_to_output_fn: impl FnMut(&L) -> Result<O, ()>) -> Result<O, ()> pub fn resolve<O>(
&self,
mut leaf_to_output_fn: impl FnMut(&L) -> Result<O, ()>,
) -> Result<O, ()>
where where
O: PartialOrd + PartialEq + Add<Output = O> + Zero, O: PartialOrd + PartialEq + Add<Output = O> + Zero,
{ {
@ -192,7 +225,11 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
} }
result result
}, },
Self::Clamp { ref min, ref center, ref max } => { Self::Clamp {
ref min,
ref center,
ref max,
} => {
let min = min.resolve_internal(leaf_to_output_fn)?; let min = min.resolve_internal(leaf_to_output_fn)?;
let center = center.resolve_internal(leaf_to_output_fn)?; let center = center.resolve_internal(leaf_to_output_fn)?;
let max = max.resolve_internal(leaf_to_output_fn)?; let max = max.resolve_internal(leaf_to_output_fn)?;
@ -432,7 +469,7 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
}, },
Self::Leaf(ref mut l) => { Self::Leaf(ref mut l) => {
l.simplify(); l.simplify();
} },
} }
} }

View file

@ -341,8 +341,16 @@ where
W: Write, W: Write,
{ {
let (compat_mode, repeating) = match *self { let (compat_mode, repeating) = match *self {
Gradient::Linear { compat_mode, repeating, .. } => (compat_mode, repeating), Gradient::Linear {
Gradient::Radial { compat_mode, repeating, .. } => (compat_mode, repeating), compat_mode,
repeating,
..
} => (compat_mode, repeating),
Gradient::Radial {
compat_mode,
repeating,
..
} => (compat_mode, repeating),
Gradient::Conic { repeating, .. } => (GradientCompatMode::Modern, repeating), Gradient::Conic { repeating, .. } => (GradientCompatMode::Modern, repeating),
}; };
@ -357,7 +365,12 @@ where
} }
match *self { match *self {
Gradient::Linear { ref direction, ref items, compat_mode, .. } => { Gradient::Linear {
ref direction,
ref items,
compat_mode,
..
} => {
dest.write_str("linear-gradient(")?; dest.write_str("linear-gradient(")?;
let mut skip_comma = if !direction.points_downwards(compat_mode) { let mut skip_comma = if !direction.points_downwards(compat_mode) {
direction.to_css(dest, compat_mode)?; direction.to_css(dest, compat_mode)?;
@ -373,7 +386,13 @@ where
item.to_css(dest)?; item.to_css(dest)?;
} }
}, },
Gradient::Radial { ref shape, ref position, ref items, compat_mode, .. } => { Gradient::Radial {
ref shape,
ref position,
ref items,
compat_mode,
..
} => {
dest.write_str("radial-gradient(")?; dest.write_str("radial-gradient(")?;
let omit_shape = match *shape { let omit_shape = match *shape {
EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::Cover)) | EndingShape::Ellipse(Ellipse::Extent(ShapeExtent::Cover)) |
@ -412,7 +431,12 @@ where
item.to_css(dest)?; item.to_css(dest)?;
} }
}, },
Gradient::Conic { ref angle, ref position, ref items, .. } => { Gradient::Conic {
ref angle,
ref position,
ref items,
..
} => {
dest.write_str("conic-gradient(")?; dest.write_str("conic-gradient(")?;
let omit_angle = angle.is_zero(); let omit_angle = angle.is_zero();
let omit_position = position.is_center(); let omit_position = position.is_center();

View file

@ -126,12 +126,7 @@ impl Parse for ClipPath {
return Ok(ClipPath::Url(url)); return Ok(ClipPath::Url(url));
} }
parse_shape_or_box( parse_shape_or_box(context, input, ClipPath::Shape, ClipPath::Box)
context,
input,
ClipPath::Shape,
ClipPath::Box,
)
} }
} }
@ -152,12 +147,7 @@ impl Parse for ShapeOutside {
return Ok(ShapeOutside::Image(image)); return Ok(ShapeOutside::Image(image));
} }
parse_shape_or_box( parse_shape_or_box(context, input, ShapeOutside::Shape, ShapeOutside::Box)
context,
input,
ShapeOutside::Shape,
ShapeOutside::Box,
)
} }
} }

View file

@ -15,8 +15,8 @@ use crate::values::specified::{self, Angle, Time};
use crate::values::{CSSFloat, CSSInteger}; use crate::values::{CSSFloat, CSSInteger};
use cssparser::{AngleOrNumber, CowRcStr, NumberOrPercentage, Parser, Token}; use cssparser::{AngleOrNumber, CowRcStr, NumberOrPercentage, Parser, Token};
use smallvec::SmallVec; use smallvec::SmallVec;
use std::fmt::{self, Write};
use std::cmp; use std::cmp;
use std::fmt::{self, Write};
use style_traits::values::specified::AllowedNumericType; use style_traits::values::specified::AllowedNumericType;
use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss};
@ -116,8 +116,10 @@ impl PartialOrd for Leaf {
match *self { match *self {
Length(..) | Percentage(..) | Angle(..) | Time(..) | Number(..) => {}, Length(..) | Percentage(..) | Angle(..) | Time(..) | Number(..) => {},
} }
unsafe { debug_unreachable!("Forgot a branch?"); } unsafe {
debug_unreachable!("Forgot a branch?");
} }
},
} }
} }
} }
@ -126,8 +128,7 @@ impl generic::CalcNodeLeaf for Leaf {
fn is_negative(&self) -> bool { fn is_negative(&self) -> bool {
match *self { match *self {
Self::Length(ref l) => l.is_negative(), Self::Length(ref l) => l.is_negative(),
Self::Percentage(n) | Self::Percentage(n) | Self::Number(n) => n < 0.,
Self::Number(n) => n < 0.,
Self::Angle(ref a) => a.degrees() < 0., Self::Angle(ref a) => a.degrees() < 0.,
Self::Time(ref t) => t.seconds() < 0., Self::Time(ref t) => t.seconds() < 0.,
} }
@ -215,8 +216,10 @@ impl generic::CalcNodeLeaf for Leaf {
match *other { match *other {
Number(..) | Percentage(..) | Angle(..) | Time(..) | Length(..) => {}, Number(..) | Percentage(..) | Angle(..) | Time(..) | Length(..) => {},
} }
unsafe { debug_unreachable!(); } unsafe {
debug_unreachable!();
} }
},
} }
Ok(()) Ok(())
@ -252,11 +255,9 @@ impl CalcNode {
value, ref unit, .. value, ref unit, ..
}, },
CalcUnit::LengthPercentage, CalcUnit::LengthPercentage,
) => { ) => match NoCalcLength::parse_dimension(context, value, unit) {
match NoCalcLength::parse_dimension(context, value, unit) {
Ok(l) => Ok(CalcNode::Leaf(Leaf::Length(l))), Ok(l) => Ok(CalcNode::Leaf(Leaf::Length(l))),
Err(()) => Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)), Err(()) => Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
}
}, },
( (
&Token::Dimension { &Token::Dimension {
@ -266,7 +267,9 @@ impl CalcNode {
) => { ) => {
match Angle::parse_dimension(value, unit, /* from_calc = */ true) { match Angle::parse_dimension(value, unit, /* from_calc = */ true) {
Ok(a) => Ok(CalcNode::Leaf(Leaf::Angle(a))), Ok(a) => Ok(CalcNode::Leaf(Leaf::Angle(a))),
Err(()) => Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)), Err(()) => {
Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
},
} }
}, },
( (
@ -277,7 +280,9 @@ impl CalcNode {
) => { ) => {
match Time::parse_dimension(value, unit, /* from_calc = */ true) { match Time::parse_dimension(value, unit, /* from_calc = */ true) {
Ok(t) => Ok(CalcNode::Leaf(Leaf::Time(t))), Ok(t) => Ok(CalcNode::Leaf(Leaf::Time(t))),
Err(()) => Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)), Err(()) => {
Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
},
} }
}, },
(&Token::Percentage { unit_value, .. }, CalcUnit::LengthPercentage) | (&Token::Percentage { unit_value, .. }, CalcUnit::LengthPercentage) |
@ -328,8 +333,7 @@ impl CalcNode {
// //
// Consider adding an API to cssparser to specify the // Consider adding an API to cssparser to specify the
// initial vector capacity? // initial vector capacity?
let arguments = input let arguments = input.parse_comma_separated(|input| {
.parse_comma_separated(|input| {
Self::parse_argument(context, input, expected_unit) Self::parse_argument(context, input, expected_unit)
})?; })?;
@ -474,43 +478,35 @@ impl CalcNode {
/// Tries to simplify this expression into a `<time>` value. /// Tries to simplify this expression into a `<time>` value.
fn to_time(&self) -> Result<Time, ()> { fn to_time(&self) -> Result<Time, ()> {
let seconds = self.resolve(|leaf| { let seconds = self.resolve(|leaf| match *leaf {
match *leaf {
Leaf::Time(ref t) => Ok(t.seconds()), Leaf::Time(ref t) => Ok(t.seconds()),
_ => Err(()), _ => Err(()),
}
})?; })?;
Ok(Time::from_calc(seconds)) Ok(Time::from_calc(seconds))
} }
/// Tries to simplify this expression into an `Angle` value. /// Tries to simplify this expression into an `Angle` value.
fn to_angle(&self) -> Result<Angle, ()> { fn to_angle(&self) -> Result<Angle, ()> {
let degrees = self.resolve(|leaf| { let degrees = self.resolve(|leaf| match *leaf {
match *leaf {
Leaf::Angle(ref angle) => Ok(angle.degrees()), Leaf::Angle(ref angle) => Ok(angle.degrees()),
_ => Err(()), _ => Err(()),
}
})?; })?;
Ok(Angle::from_calc(degrees)) Ok(Angle::from_calc(degrees))
} }
/// Tries to simplify this expression into a `<number>` value. /// Tries to simplify this expression into a `<number>` value.
fn to_number(&self) -> Result<CSSFloat, ()> { fn to_number(&self) -> Result<CSSFloat, ()> {
self.resolve(|leaf| { self.resolve(|leaf| match *leaf {
match *leaf {
Leaf::Number(n) => Ok(n), Leaf::Number(n) => Ok(n),
_ => Err(()), _ => Err(()),
}
}) })
} }
/// Tries to simplify this expression into a `<percentage>` value. /// Tries to simplify this expression into a `<percentage>` value.
fn to_percentage(&self) -> Result<CSSFloat, ()> { fn to_percentage(&self) -> Result<CSSFloat, ()> {
self.resolve(|leaf| { self.resolve(|leaf| match *leaf {
match *leaf {
Leaf::Percentage(p) => Ok(p), Leaf::Percentage(p) => Ok(p),
_ => Err(()), _ => Err(()),
}
}) })
} }

View file

@ -19,7 +19,8 @@ use crate::values::specified::position::{HorizontalPositionKeyword, VerticalPosi
use crate::values::specified::position::{Position, PositionComponent, Side}; use crate::values::specified::position::{Position, PositionComponent, Side};
use crate::values::specified::url::SpecifiedImageUrl; use crate::values::specified::url::SpecifiedImageUrl;
use crate::values::specified::{ use crate::values::specified::{
Angle, AngleOrPercentage, Color, Length, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage, Angle, AngleOrPercentage, Color, Length, LengthPercentage, NonNegativeLength,
NonNegativeLengthPercentage,
}; };
use crate::values::specified::{Number, NumberOrPercentage, Percentage}; use crate::values::specified::{Number, NumberOrPercentage, Percentage};
use crate::Atom; use crate::Atom;
@ -73,10 +74,7 @@ impl SpecifiedValueInfo for Gradient {
]); ]);
if static_prefs::pref!("layout.css.conic-gradient.enabled") { if static_prefs::pref!("layout.css.conic-gradient.enabled") {
f(&[ f(&["conic-gradient", "repeating-conic-gradient"]);
"conic-gradient",
"repeating-conic-gradient",
]);
} }
} }
} }
@ -527,7 +525,8 @@ impl Gradient {
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<LengthPercentageItemList, ParseError<'i>> { ) -> Result<LengthPercentageItemList, ParseError<'i>> {
let items = generic::GradientItem::parse_comma_separated(context, input, LengthPercentage::parse)?; let items =
generic::GradientItem::parse_comma_separated(context, input, LengthPercentage::parse)?;
if items.len() < 2 { if items.len() < 2 {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)); return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
} }
@ -633,7 +632,11 @@ impl Gradient {
let angle = angle.unwrap_or(Angle::zero()); let angle = angle.unwrap_or(Angle::zero());
let position = position.unwrap_or(Position::center()); let position = position.unwrap_or(Position::center());
let items = generic::GradientItem::parse_comma_separated(context, input, AngleOrPercentage::parse_with_unitless)?; let items = generic::GradientItem::parse_comma_separated(
context,
input,
AngleOrPercentage::parse_with_unitless,
)?;
if items.len() < 2 { if items.len() < 2 {
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)); return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
@ -853,7 +856,8 @@ impl<T> generic::GradientItem<Color, T> {
fn parse_comma_separated<'i, 't>( fn parse_comma_separated<'i, 't>(
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
parse_position: impl for<'i1, 't1> Fn(&ParserContext, &mut Parser<'i1, 't1>) -> Result<T, ParseError<'i1>> + Copy, parse_position: impl for<'i1, 't1> Fn(&ParserContext, &mut Parser<'i1, 't1>) -> Result<T, ParseError<'i1>>
+ Copy,
) -> Result<crate::OwnedSlice<Self>, ParseError<'i>> { ) -> Result<crate::OwnedSlice<Self>, ParseError<'i>> {
let mut items = Vec::new(); let mut items = Vec::new();
let mut seen_stop = false; let mut seen_stop = false;
@ -906,7 +910,10 @@ impl<T> generic::ColorStop<Color, T> {
fn parse<'i, 't>( fn parse<'i, 't>(
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
parse_position: impl for<'i1, 't1> Fn(&ParserContext, &mut Parser<'i1, 't1>) -> Result<T, ParseError<'i1>>, parse_position: impl for<'i1, 't1> Fn(
&ParserContext,
&mut Parser<'i1, 't1>,
) -> Result<T, ParseError<'i1>>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
Ok(generic::ColorStop { Ok(generic::ColorStop {
color: Color::parse(context, input)?, color: Color::parse(context, input)?,

View file

@ -28,8 +28,8 @@ use std::ops::{Add, Mul};
use style_traits::values::specified::AllowedNumericType; use style_traits::values::specified::AllowedNumericType;
use style_traits::{ParseError, SpecifiedValueInfo, StyleParseErrorKind}; use style_traits::{ParseError, SpecifiedValueInfo, StyleParseErrorKind};
pub use super::image::{EndingShape as GradientEndingShape, Gradient};
pub use super::image::Image; pub use super::image::Image;
pub use super::image::{EndingShape as GradientEndingShape, Gradient};
pub use crate::values::specified::calc::CalcLengthPercentage; pub use crate::values::specified::calc::CalcLengthPercentage;
/// Number of app units per pixel /// Number of app units per pixel

View file

@ -80,12 +80,12 @@ pub use self::svg::MozContextProperties;
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint}; pub use self::svg::{SVGLength, SVGOpacity, SVGPaint};
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth}; pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
pub use self::svg_path::SVGPathData; pub use self::svg_path::SVGPathData;
pub use self::text::TextAlignLast;
pub use self::text::TextUnderlinePosition; pub use self::text::TextUnderlinePosition;
pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight, TextAlign}; pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight, TextAlign};
pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak}; pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak};
pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing}; pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing};
pub use self::text::{TextDecorationLength, TextDecorationSkipInk, TextTransform}; pub use self::text::{TextDecorationLength, TextDecorationSkipInk, TextTransform};
pub use self::text::TextAlignLast;
pub use self::time::Time; pub use self::time::Time;
pub use self::transform::{Rotate, Scale, Transform}; pub use self::transform::{Rotate, Scale, Transform};
pub use self::transform::{TransformOrigin, TransformStyle, Translate}; pub use self::transform::{TransformOrigin, TransformStyle, Translate};

View file

@ -35,8 +35,7 @@ use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
pub struct SVGPathData( pub struct SVGPathData(
// TODO(emilio): Should probably measure this somehow only from the // TODO(emilio): Should probably measure this somehow only from the
// specified values. // specified values.
#[ignore_malloc_size_of = "Arc"] #[ignore_malloc_size_of = "Arc"] pub crate::ArcSlice<PathCommand>,
pub crate::ArcSlice<PathCommand>,
); );
impl SVGPathData { impl SVGPathData {
@ -541,7 +540,17 @@ impl CoordPair {
/// The EllipticalArc flag type. /// The EllipticalArc flag type.
#[derive( #[derive(
Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, Clone,
Copy,
Debug,
Deserialize,
MallocSizeOf,
PartialEq,
Serialize,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
)] )]
#[repr(C)] #[repr(C)]
pub struct ArcFlag(bool); pub struct ArcFlag(bool);

View file

@ -122,7 +122,18 @@ impl ToComputedValue for LineHeight {
} }
/// A generic value for the `text-overflow` property. /// A generic value for the `text-overflow` property.
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] #[derive(
Clone,
Debug,
Eq,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(C, u8)] #[repr(C, u8)]
pub enum TextOverflowSide { pub enum TextOverflowSide {
/// Clip inline content. /// Clip inline content.
@ -687,7 +698,19 @@ pub enum TextEmphasisStyle {
} }
/// Fill mode for the text-emphasis-style property /// Fill mode for the text-emphasis-style property
#[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToComputedValue, ToResolvedValue, ToShmem)] #[derive(
Clone,
Copy,
Debug,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToCss,
ToComputedValue,
ToResolvedValue,
ToShmem,
)]
#[repr(u8)] #[repr(u8)]
pub enum TextEmphasisFillMode { pub enum TextEmphasisFillMode {
/// `filled` /// `filled`

View file

@ -58,7 +58,12 @@ impl Parse for CursorImage {
hotspot_y = Number::parse(context, input)?; hotspot_y = Number::parse(context, input)?;
} }
Ok(Self { url, has_hotspot, hotspot_x, hotspot_y }) Ok(Self {
url,
has_hotspot,
hotspot_x,
hotspot_y,
})
} }
} }

View file

@ -102,7 +102,10 @@ pub fn derive_to_value(
} else { } else {
let to_body = cg::fmap_match(&input, bind_style, |binding| { let to_body = cg::fmap_match(&input, bind_style, |binding| {
let attrs = binding_attrs(&binding); let attrs = binding_attrs(&binding);
assert!(!attrs.no_field_bound, "It doesn't make sense on a generic implementation"); assert!(
!attrs.no_field_bound,
"It doesn't make sense on a generic implementation"
);
if attrs.field_bound { if attrs.field_bound {
add_field_bound(&binding); add_field_bound(&binding);
} }
@ -111,8 +114,16 @@ pub fn derive_to_value(
let from_body = cg::fmap_match(&input, bind_style, |binding| call_from(&binding)); let from_body = cg::fmap_match(&input, bind_style, |binding| call_from(&binding));
let self_ = if moves { quote! { self } } else { quote! { *self } }; let self_ = if moves {
let from_ = if moves { quote! { from } } else { quote! { *from } }; quote! { self }
} else {
quote! { *self }
};
let from_ = if moves {
quote! { from }
} else {
quote! { *from }
};
let to_body = quote! { let to_body = quote! {
match #self_ { match #self_ {