style: Rustfmt recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-11-30 14:34:45 +01:00
parent 59eef57eb7
commit 006417e40a
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
22 changed files with 249 additions and 248 deletions

View file

@ -36,12 +36,15 @@ const CASCADE_LEVEL_SHIFT: usize = SOURCE_ORDER_BITS;
/// Stores the source order of a block, the cascade level it belongs to, and the /// Stores the source order of a block, the cascade level it belongs to, and the
/// counter needed to handle Shadow DOM cascade order properly. /// counter needed to handle Shadow DOM cascade order properly.
#[derive(Clone, Copy, Eq, MallocSizeOf, PartialEq, Debug)] #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq)]
struct ApplicableDeclarationBits(u32); struct ApplicableDeclarationBits(u32);
impl ApplicableDeclarationBits { impl ApplicableDeclarationBits {
fn new(source_order: u32, cascade_level: CascadeLevel) -> Self { fn new(source_order: u32, cascade_level: CascadeLevel) -> Self {
Self((source_order & SOURCE_ORDER_MASK) | ((cascade_level.to_byte_lossy() as u32) << CASCADE_LEVEL_SHIFT)) Self(
(source_order & SOURCE_ORDER_MASK) |
((cascade_level.to_byte_lossy() as u32) << CASCADE_LEVEL_SHIFT),
)
} }
fn source_order(&self) -> u32 { fn source_order(&self) -> u32 {
@ -87,12 +90,7 @@ impl ApplicableDeclarationBlock {
/// Constructs an applicable declaration block from the given components /// Constructs an applicable declaration block from the given components
#[inline] #[inline]
pub fn new( pub fn new(source: StyleSource, order: u32, level: CascadeLevel, specificity: u32) -> Self {
source: StyleSource,
order: u32,
level: CascadeLevel,
specificity: u32,
) -> Self {
ApplicableDeclarationBlock { ApplicableDeclarationBlock {
source, source,
bits: ApplicableDeclarationBits::new(order, level), bits: ApplicableDeclarationBits::new(order, level),

View file

@ -83,7 +83,10 @@ pub fn get_id(attrs: &[structs::AttrArray_InternalAttr]) -> Option<&WeakAtom> {
} }
#[inline(always)] #[inline(always)]
pub(super) fn exported_part(attrs: &[structs::AttrArray_InternalAttr], name: &Atom) -> Option<Atom> { pub(super) fn exported_part(
attrs: &[structs::AttrArray_InternalAttr],
name: &Atom,
) -> Option<Atom> {
let attr = find_attr(attrs, &atom!("exportparts"))?; let attr = find_attr(attrs, &atom!("exportparts"))?;
let atom = unsafe { bindings::Gecko_Element_ExportedPart(attr, name.as_ptr()) }; let atom = unsafe { bindings::Gecko_Element_ExportedPart(attr, name.as_ptr()) };
if atom.is_null() { if atom.is_null() {
@ -93,7 +96,10 @@ pub(super) fn exported_part(attrs: &[structs::AttrArray_InternalAttr], name: &At
} }
#[inline(always)] #[inline(always)]
pub(super) fn imported_part(attrs: &[structs::AttrArray_InternalAttr], name: &Atom) -> Option<Atom> { pub(super) fn imported_part(
attrs: &[structs::AttrArray_InternalAttr],
name: &Atom,
) -> Option<Atom> {
let attr = find_attr(attrs, &atom!("exportparts"))?; let attr = find_attr(attrs, &atom!("exportparts"))?;
let atom = unsafe { bindings::Gecko_Element_ImportedPart(attr, name.as_ptr()) }; let atom = unsafe { bindings::Gecko_Element_ImportedPart(attr, name.as_ptr()) };
if atom.is_null() { if atom.is_null() {

View file

@ -1244,7 +1244,8 @@ impl<'le> TElement for GeckoElement<'le> {
#[inline] #[inline]
fn has_part_attr(&self) -> bool { fn has_part_attr(&self) -> bool {
self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasPart) self.as_node()
.get_bool_flag(nsINode_BooleanFlag::ElementHasPart)
} }
#[inline] #[inline]
@ -2193,7 +2194,8 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
#[inline] #[inline]
fn is_link(&self) -> bool { fn is_link(&self) -> bool {
self.state().intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE) self.state()
.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE)
} }
#[inline] #[inline]

View file

@ -392,7 +392,8 @@ impl Atom {
// though. // though.
// //
// debug_assert!((index as usize) < STATIC_ATOM_COUNT); // debug_assert!((index as usize) < STATIC_ATOM_COUNT);
let offset = (index as usize) * std::mem::size_of::<nsStaticAtom>() + kGkAtomsArrayOffset as usize; let offset =
(index as usize) * std::mem::size_of::<nsStaticAtom>() + kGkAtomsArrayOffset as usize;
Atom(NonZeroUsize::new_unchecked((offset << 1) | 1)) Atom(NonZeroUsize::new_unchecked((offset << 1) | 1))
} }

View file

@ -8,10 +8,10 @@
use crate::context::StackLimitChecker; use crate::context::StackLimitChecker;
use crate::dom::{TElement, TNode, TShadowRoot}; use crate::dom::{TElement, TNode, TShadowRoot};
use crate::selector_parser::SelectorImpl; use crate::selector_parser::SelectorImpl;
use selectors::OpaqueElement;
use selectors::matching::matches_compound_selector_from; use selectors::matching::matches_compound_selector_from;
use selectors::matching::{CompoundSelectorMatchingResult, MatchingContext}; use selectors::matching::{CompoundSelectorMatchingResult, MatchingContext};
use selectors::parser::{Combinator, Component, Selector}; use selectors::parser::{Combinator, Component, Selector};
use selectors::OpaqueElement;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::fmt; use std::fmt;

View file

@ -4,7 +4,6 @@
//! Collects a series of applicable rules for a given element. //! Collects a series of applicable rules for a given element.
use crate::Atom;
use crate::applicable_declarations::{ApplicableDeclarationBlock, ApplicableDeclarationList}; use crate::applicable_declarations::{ApplicableDeclarationBlock, ApplicableDeclarationList};
use crate::dom::{TElement, TNode, TShadowRoot}; use crate::dom::{TElement, TNode, TShadowRoot};
use crate::properties::{AnimationRules, PropertyDeclarationBlock}; use crate::properties::{AnimationRules, PropertyDeclarationBlock};
@ -14,6 +13,7 @@ use crate::selector_parser::PseudoElement;
use crate::shared_lock::Locked; use crate::shared_lock::Locked;
use crate::stylesheets::Origin; use crate::stylesheets::Origin;
use crate::stylist::{AuthorStylesEnabled, Rule, RuleInclusion, Stylist}; use crate::stylist::{AuthorStylesEnabled, Rule, RuleInclusion, Stylist};
use crate::Atom;
use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode}; use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode};
use servo_arc::ArcBorrow; use servo_arc::ArcBorrow;
use smallvec::SmallVec; use smallvec::SmallVec;
@ -261,7 +261,9 @@ where
self.collect_rules_in_shadow_tree( self.collect_rules_in_shadow_tree(
shadow.host(), shadow.host(),
slotted_rules, slotted_rules,
CascadeLevel::AuthorNormal { shadow_cascade_order }, CascadeLevel::AuthorNormal {
shadow_cascade_order,
},
); );
} }
} }
@ -312,7 +314,9 @@ where
self.collect_rules_in_shadow_tree( self.collect_rules_in_shadow_tree(
rule_hash_target, rule_hash_target,
host_rules, host_rules,
CascadeLevel::AuthorNormal { shadow_cascade_order }, CascadeLevel::AuthorNormal {
shadow_cascade_order,
},
); );
} }

View file

@ -283,7 +283,9 @@ impl RuleTree {
if any_important { if any_important {
found_important = true; found_important = true;
match level { match level {
AuthorNormal { shadow_cascade_order } => { AuthorNormal {
shadow_cascade_order,
} => {
important_author.push((source.clone(), shadow_cascade_order)); important_author.push((source.clone(), shadow_cascade_order));
}, },
UANormal => important_ua.push(source.clone()), UANormal => important_ua.push(source.clone()),
@ -344,9 +346,13 @@ impl RuleTree {
} }
for (source, shadow_cascade_order) in important_author.drain() { for (source, shadow_cascade_order) in important_author.drain() {
current = current.ensure_child(self.root.downgrade(), source, AuthorImportant { current = current.ensure_child(
shadow_cascade_order: -shadow_cascade_order, self.root.downgrade(),
}); source,
AuthorImportant {
shadow_cascade_order: -shadow_cascade_order,
},
);
} }
for source in important_user.drain() { for source in important_user.drain() {
@ -496,12 +502,7 @@ impl RuleTree {
if current.get().level == level { if current.get().level == level {
*important_rules_changed |= level.is_important(); *important_rules_changed |= level.is_important();
let current_decls = current let current_decls = current.get().source.as_ref().unwrap().as_declarations();
.get()
.source
.as_ref()
.unwrap()
.as_declarations();
// If the only rule at the level we're replacing is exactly the // If the only rule at the level we're replacing is exactly the
// same as `pdb`, we're done, and `path` is still valid. // same as `pdb`, we're done, and `path` is still valid.
@ -701,10 +702,14 @@ impl CascadeLevel {
Self::UANormal => (0, 0), Self::UANormal => (0, 0),
Self::UserNormal => (1, 0), Self::UserNormal => (1, 0),
Self::PresHints => (2, 0), Self::PresHints => (2, 0),
Self::AuthorNormal { shadow_cascade_order } => (3, shadow_cascade_order.0), Self::AuthorNormal {
shadow_cascade_order,
} => (3, shadow_cascade_order.0),
Self::SMILOverride => (4, 0), Self::SMILOverride => (4, 0),
Self::Animations => (5, 0), Self::Animations => (5, 0),
Self::AuthorImportant { shadow_cascade_order } => (6, shadow_cascade_order.0), Self::AuthorImportant {
shadow_cascade_order,
} => (6, shadow_cascade_order.0),
Self::UserImportant => (7, 0), Self::UserImportant => (7, 0),
Self::UAImportant => (8, 0), Self::UAImportant => (8, 0),
Self::Transitions => (9, 0), Self::Transitions => (9, 0),
@ -727,20 +732,28 @@ impl CascadeLevel {
let order = { let order = {
let abs = ((b & 0b01110000) >> 4) as i8; let abs = ((b & 0b01110000) >> 4) as i8;
let negative = b & 0b10000000 != 0; let negative = b & 0b10000000 != 0;
if negative { -abs } else { abs } if negative {
-abs
} else {
abs
}
}; };
let discriminant = b & 0xf; let discriminant = b & 0xf;
let level = match discriminant { let level = match discriminant {
0 => Self::UANormal, 0 => Self::UANormal,
1 => Self::UserNormal, 1 => Self::UserNormal,
2 => Self::PresHints, 2 => Self::PresHints,
3 => return Self::AuthorNormal { 3 => {
shadow_cascade_order: ShadowCascadeOrder(order), return Self::AuthorNormal {
shadow_cascade_order: ShadowCascadeOrder(order),
}
}, },
4 => Self::SMILOverride, 4 => Self::SMILOverride,
5 => Self::Animations, 5 => Self::Animations,
6 => return Self::AuthorImportant { 6 => {
shadow_cascade_order: ShadowCascadeOrder(order), return Self::AuthorImportant {
shadow_cascade_order: ShadowCascadeOrder(order),
}
}, },
7 => Self::UserImportant, 7 => Self::UserImportant,
8 => Self::UAImportant, 8 => Self::UAImportant,
@ -1550,9 +1563,7 @@ impl StrongRuleNode {
// FIXME(emilio): this looks wrong, this should // FIXME(emilio): this looks wrong, this should
// do: if color is not transparent, then return // do: if color is not transparent, then return
// true, or something. // true, or something.
if let PropertyDeclaration::BackgroundColor(ref color) = if let PropertyDeclaration::BackgroundColor(ref color) = *declaration {
*declaration
{
return *color == Color::transparent(); return *color == Color::transparent();
} }
} }
@ -1567,9 +1578,7 @@ impl StrongRuleNode {
// However, if it is inherited, then it might be // However, if it is inherited, then it might be
// inherited from an author rule from an // inherited from an author rule from an
// ancestor element's rule nodes. // ancestor element's rule nodes.
if declaration.get_css_wide_keyword() == if declaration.get_css_wide_keyword() == Some(CSSWideKeyword::Inherit) {
Some(CSSWideKeyword::Inherit)
{
have_explicit_ua_inherit = true; have_explicit_ua_inherit = true;
inherited_properties.insert(id); inherited_properties.insert(id);
} }

View file

@ -271,9 +271,7 @@ impl SelectorMap<Rule> {
context, context,
flags_setter, flags_setter,
) { ) {
matching_rules.push( matching_rules.push(rule.to_applicable_declaration_block(cascade_level));
rule.to_applicable_declaration_block(cascade_level),
);
} }
} }
} }

View file

@ -2325,12 +2325,7 @@ impl Rule {
level: CascadeLevel, level: CascadeLevel,
) -> ApplicableDeclarationBlock { ) -> ApplicableDeclarationBlock {
let source = StyleSource::from_rule(self.style_rule.clone()); let source = StyleSource::from_rule(self.style_rule.clone());
ApplicableDeclarationBlock::new( ApplicableDeclarationBlock::new(source, self.source_order, level, self.specificity())
source,
self.source_order,
level,
self.specificity(),
)
} }
/// Creates a new Rule. /// Creates a new Rule.

View file

@ -139,10 +139,10 @@ impl ComputeSquaredDistance for MatrixDecomposed2D {
const RAD_PER_DEG: f64 = std::f64::consts::PI / 180.0; const RAD_PER_DEG: f64 = std::f64::consts::PI / 180.0;
let angle1 = self.angle as f64 * RAD_PER_DEG; let angle1 = self.angle as f64 * RAD_PER_DEG;
let angle2 = other.angle as f64 * RAD_PER_DEG; let angle2 = other.angle as f64 * RAD_PER_DEG;
Ok(self.translate.compute_squared_distance(&other.translate)? Ok(self.translate.compute_squared_distance(&other.translate)? +
+ self.scale.compute_squared_distance(&other.scale)? self.scale.compute_squared_distance(&other.scale)? +
+ angle1.compute_squared_distance(&angle2)? angle1.compute_squared_distance(&angle2)? +
+ self.matrix.compute_squared_distance(&other.matrix)?) self.matrix.compute_squared_distance(&other.matrix)?)
} }
} }
@ -316,9 +316,9 @@ impl ComputeSquaredDistance for Skew {
// ComputeSquaredDistance manually. // ComputeSquaredDistance manually.
#[inline] #[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
Ok(self.0.atan().compute_squared_distance(&other.0.atan())? Ok(self.0.atan().compute_squared_distance(&other.0.atan())? +
+ self.1.atan().compute_squared_distance(&other.1.atan())? self.1.atan().compute_squared_distance(&other.1.atan())? +
+ self.2.atan().compute_squared_distance(&other.2.atan())?) self.2.atan().compute_squared_distance(&other.2.atan())?)
} }
} }
@ -394,9 +394,9 @@ impl Animate for Quaternion {
debug_assert!( debug_assert!(
// Doule EPSILON since both this_weight and other_weght have calculation errors // Doule EPSILON since both this_weight and other_weght have calculation errors
// which are approximately equal to EPSILON. // which are approximately equal to EPSILON.
(this_weight + other_weight - 1.0f64).abs() <= f64::EPSILON * 2.0 (this_weight + other_weight - 1.0f64).abs() <= f64::EPSILON * 2.0 ||
|| other_weight == 1.0f64 other_weight == 1.0f64 ||
|| other_weight == 0.0f64, other_weight == 0.0f64,
"animate should only be used for interpolating or accumulating transforms" "animate should only be used for interpolating or accumulating transforms"
); );
@ -830,17 +830,17 @@ fn is_matched_operation(
second: &ComputedTransformOperation, second: &ComputedTransformOperation,
) -> bool { ) -> bool {
match (first, second) { match (first, second) {
(&TransformOperation::Matrix(..), &TransformOperation::Matrix(..)) (&TransformOperation::Matrix(..), &TransformOperation::Matrix(..)) |
| (&TransformOperation::Matrix3D(..), &TransformOperation::Matrix3D(..)) (&TransformOperation::Matrix3D(..), &TransformOperation::Matrix3D(..)) |
| (&TransformOperation::Skew(..), &TransformOperation::Skew(..)) (&TransformOperation::Skew(..), &TransformOperation::Skew(..)) |
| (&TransformOperation::SkewX(..), &TransformOperation::SkewX(..)) (&TransformOperation::SkewX(..), &TransformOperation::SkewX(..)) |
| (&TransformOperation::SkewY(..), &TransformOperation::SkewY(..)) (&TransformOperation::SkewY(..), &TransformOperation::SkewY(..)) |
| (&TransformOperation::Rotate(..), &TransformOperation::Rotate(..)) (&TransformOperation::Rotate(..), &TransformOperation::Rotate(..)) |
| (&TransformOperation::Rotate3D(..), &TransformOperation::Rotate3D(..)) (&TransformOperation::Rotate3D(..), &TransformOperation::Rotate3D(..)) |
| (&TransformOperation::RotateX(..), &TransformOperation::RotateX(..)) (&TransformOperation::RotateX(..), &TransformOperation::RotateX(..)) |
| (&TransformOperation::RotateY(..), &TransformOperation::RotateY(..)) (&TransformOperation::RotateY(..), &TransformOperation::RotateY(..)) |
| (&TransformOperation::RotateZ(..), &TransformOperation::RotateZ(..)) (&TransformOperation::RotateZ(..), &TransformOperation::RotateZ(..)) |
| (&TransformOperation::Perspective(..), &TransformOperation::Perspective(..)) => true, (&TransformOperation::Perspective(..), &TransformOperation::Perspective(..)) => true,
// Match functions that have the same primitive transform function // Match functions that have the same primitive transform function
(a, b) if a.is_translate() && b.is_translate() => true, (a, b) if a.is_translate() && b.is_translate() => true,
(a, b) if a.is_scale() && b.is_scale() => true, (a, b) if a.is_scale() && b.is_scale() => true,
@ -895,21 +895,21 @@ impl Animate for ComputedTransform {
Procedure::Add => { Procedure::Add => {
debug_assert!(false, "Should have already dealt with add by the point"); debug_assert!(false, "Should have already dealt with add by the point");
return Err(()); return Err(());
} },
Procedure::Interpolate { progress } => { Procedure::Interpolate { progress } => {
result.push(TransformOperation::InterpolateMatrix { result.push(TransformOperation::InterpolateMatrix {
from_list: Transform(this_remainder.to_vec().into()), from_list: Transform(this_remainder.to_vec().into()),
to_list: Transform(other_remainder.to_vec().into()), to_list: Transform(other_remainder.to_vec().into()),
progress: Percentage(progress as f32), progress: Percentage(progress as f32),
}); });
} },
Procedure::Accumulate { count } => { Procedure::Accumulate { count } => {
result.push(TransformOperation::AccumulateMatrix { result.push(TransformOperation::AccumulateMatrix {
from_list: Transform(this_remainder.to_vec().into()), from_list: Transform(this_remainder.to_vec().into()),
to_list: Transform(other_remainder.to_vec().into()), to_list: Transform(other_remainder.to_vec().into()),
count: cmp::min(count, i32::max_value() as u64) as i32, count: cmp::min(count, i32::max_value() as u64) as i32,
}); });
} },
}, },
// If there is a remainder from just one list, then one list must be shorter but // If there is a remainder from just one list, then one list must be shorter but
// completely match the type of the corresponding functions in the longer list. // completely match the type of the corresponding functions in the longer list.
@ -925,8 +925,8 @@ impl Animate for ComputedTransform {
match transform { match transform {
// We can't interpolate/accumulate ___Matrix types directly with a // We can't interpolate/accumulate ___Matrix types directly with a
// matrix. Instead we need to wrap it in another ___Matrix type. // matrix. Instead we need to wrap it in another ___Matrix type.
TransformOperation::AccumulateMatrix { .. } TransformOperation::AccumulateMatrix { .. } |
| TransformOperation::InterpolateMatrix { .. } => { TransformOperation::InterpolateMatrix { .. } => {
let transform_list = Transform(vec![transform.clone()].into()); let transform_list = Transform(vec![transform.clone()].into());
let identity_list = Transform(vec![identity].into()); let identity_list = Transform(vec![identity].into());
let (from_list, to_list) = if fill_right { let (from_list, to_list) = if fill_right {
@ -943,7 +943,7 @@ impl Animate for ComputedTransform {
to_list, to_list,
progress: Percentage(progress as f32), progress: Percentage(progress as f32),
}) })
} },
Procedure::Accumulate { count } => { Procedure::Accumulate { count } => {
Ok(TransformOperation::AccumulateMatrix { Ok(TransformOperation::AccumulateMatrix {
from_list, from_list,
@ -951,9 +951,9 @@ impl Animate for ComputedTransform {
count: cmp::min(count, i32::max_value() as u64) count: cmp::min(count, i32::max_value() as u64)
as i32, as i32,
}) })
} },
} }
} },
_ => { _ => {
let (lhs, rhs) = if fill_right { let (lhs, rhs) = if fill_right {
(transform, &identity) (transform, &identity)
@ -961,13 +961,13 @@ impl Animate for ComputedTransform {
(&identity, transform) (&identity, transform)
}; };
lhs.animate(rhs, procedure) lhs.animate(rhs, procedure)
} },
} }
}) })
.collect::<Result<Vec<_>, _>>()?, .collect::<Result<Vec<_>, _>>()?,
); );
} },
(None, None) => {} (None, None) => {},
} }
Ok(Transform(result.into())) Ok(Transform(result.into()))
@ -999,10 +999,10 @@ impl Animate for ComputedTransformOperation {
Ok(TransformOperation::Matrix3D( Ok(TransformOperation::Matrix3D(
this.animate(other, procedure)?, this.animate(other, procedure)?,
)) ))
} },
(&TransformOperation::Matrix(ref this), &TransformOperation::Matrix(ref other)) => { (&TransformOperation::Matrix(ref this), &TransformOperation::Matrix(ref other)) => {
Ok(TransformOperation::Matrix(this.animate(other, procedure)?)) Ok(TransformOperation::Matrix(this.animate(other, procedure)?))
} },
( (
&TransformOperation::Skew(ref fx, ref fy), &TransformOperation::Skew(ref fx, ref fy),
&TransformOperation::Skew(ref tx, ref ty), &TransformOperation::Skew(ref tx, ref ty),
@ -1012,10 +1012,10 @@ impl Animate for ComputedTransformOperation {
)), )),
(&TransformOperation::SkewX(ref f), &TransformOperation::SkewX(ref t)) => { (&TransformOperation::SkewX(ref f), &TransformOperation::SkewX(ref t)) => {
Ok(TransformOperation::SkewX(f.animate(t, procedure)?)) Ok(TransformOperation::SkewX(f.animate(t, procedure)?))
} },
(&TransformOperation::SkewY(ref f), &TransformOperation::SkewY(ref t)) => { (&TransformOperation::SkewY(ref f), &TransformOperation::SkewY(ref t)) => {
Ok(TransformOperation::SkewY(f.animate(t, procedure)?)) Ok(TransformOperation::SkewY(f.animate(t, procedure)?))
} },
( (
&TransformOperation::Translate3D(ref fx, ref fy, ref fz), &TransformOperation::Translate3D(ref fx, ref fy, ref fz),
&TransformOperation::Translate3D(ref tx, ref ty, ref tz), &TransformOperation::Translate3D(ref tx, ref ty, ref tz),
@ -1033,13 +1033,13 @@ impl Animate for ComputedTransformOperation {
)), )),
(&TransformOperation::TranslateX(ref f), &TransformOperation::TranslateX(ref t)) => { (&TransformOperation::TranslateX(ref f), &TransformOperation::TranslateX(ref t)) => {
Ok(TransformOperation::TranslateX(f.animate(t, procedure)?)) Ok(TransformOperation::TranslateX(f.animate(t, procedure)?))
} },
(&TransformOperation::TranslateY(ref f), &TransformOperation::TranslateY(ref t)) => { (&TransformOperation::TranslateY(ref f), &TransformOperation::TranslateY(ref t)) => {
Ok(TransformOperation::TranslateY(f.animate(t, procedure)?)) Ok(TransformOperation::TranslateY(f.animate(t, procedure)?))
} },
(&TransformOperation::TranslateZ(ref f), &TransformOperation::TranslateZ(ref t)) => { (&TransformOperation::TranslateZ(ref f), &TransformOperation::TranslateZ(ref t)) => {
Ok(TransformOperation::TranslateZ(f.animate(t, procedure)?)) Ok(TransformOperation::TranslateZ(f.animate(t, procedure)?))
} },
( (
&TransformOperation::Scale3D(ref fx, ref fy, ref fz), &TransformOperation::Scale3D(ref fx, ref fy, ref fz),
&TransformOperation::Scale3D(ref tx, ref ty, ref tz), &TransformOperation::Scale3D(ref tx, ref ty, ref tz),
@ -1072,25 +1072,25 @@ impl Animate for ComputedTransformOperation {
.animate(&Rotate::Rotate3D(tx, ty, tz, ta), procedure)?; .animate(&Rotate::Rotate3D(tx, ty, tz, ta), procedure)?;
let (fx, fy, fz, fa) = ComputedRotate::resolve(&animated); let (fx, fy, fz, fa) = ComputedRotate::resolve(&animated);
Ok(TransformOperation::Rotate3D(fx, fy, fz, fa)) Ok(TransformOperation::Rotate3D(fx, fy, fz, fa))
} },
(&TransformOperation::RotateX(fa), &TransformOperation::RotateX(ta)) => { (&TransformOperation::RotateX(fa), &TransformOperation::RotateX(ta)) => {
Ok(TransformOperation::RotateX(fa.animate(&ta, procedure)?)) Ok(TransformOperation::RotateX(fa.animate(&ta, procedure)?))
} },
(&TransformOperation::RotateY(fa), &TransformOperation::RotateY(ta)) => { (&TransformOperation::RotateY(fa), &TransformOperation::RotateY(ta)) => {
Ok(TransformOperation::RotateY(fa.animate(&ta, procedure)?)) Ok(TransformOperation::RotateY(fa.animate(&ta, procedure)?))
} },
(&TransformOperation::RotateZ(fa), &TransformOperation::RotateZ(ta)) => { (&TransformOperation::RotateZ(fa), &TransformOperation::RotateZ(ta)) => {
Ok(TransformOperation::RotateZ(fa.animate(&ta, procedure)?)) Ok(TransformOperation::RotateZ(fa.animate(&ta, procedure)?))
} },
(&TransformOperation::Rotate(fa), &TransformOperation::Rotate(ta)) => { (&TransformOperation::Rotate(fa), &TransformOperation::Rotate(ta)) => {
Ok(TransformOperation::Rotate(fa.animate(&ta, procedure)?)) Ok(TransformOperation::Rotate(fa.animate(&ta, procedure)?))
} },
(&TransformOperation::Rotate(fa), &TransformOperation::RotateZ(ta)) => { (&TransformOperation::Rotate(fa), &TransformOperation::RotateZ(ta)) => {
Ok(TransformOperation::Rotate(fa.animate(&ta, procedure)?)) Ok(TransformOperation::Rotate(fa.animate(&ta, procedure)?))
} },
(&TransformOperation::RotateZ(fa), &TransformOperation::Rotate(ta)) => { (&TransformOperation::RotateZ(fa), &TransformOperation::Rotate(ta)) => {
Ok(TransformOperation::Rotate(fa.animate(&ta, procedure)?)) Ok(TransformOperation::Rotate(fa.animate(&ta, procedure)?))
} },
( (
&TransformOperation::Perspective(ref fd), &TransformOperation::Perspective(ref fd),
&TransformOperation::Perspective(ref td), &TransformOperation::Perspective(ref td),
@ -1120,13 +1120,13 @@ impl Animate for ComputedTransformOperation {
Ok(TransformOperation::Perspective(CSSPixelLength::new( Ok(TransformOperation::Perspective(CSSPixelLength::new(
used_value, used_value,
))) )))
} },
_ if self.is_translate() && other.is_translate() => self _ if self.is_translate() && other.is_translate() => self
.to_translate_3d() .to_translate_3d()
.animate(&other.to_translate_3d(), procedure), .animate(&other.to_translate_3d(), procedure),
_ if self.is_scale() && other.is_scale() => { _ if self.is_scale() && other.is_scale() => {
self.to_scale_3d().animate(&other.to_scale_3d(), procedure) self.to_scale_3d().animate(&other.to_scale_3d(), procedure)
} },
_ if self.is_rotate() && other.is_rotate() => self _ if self.is_rotate() && other.is_rotate() => self
.to_rotate_3d() .to_rotate_3d()
.animate(&other.to_rotate_3d(), procedure), .animate(&other.to_rotate_3d(), procedure),
@ -1144,20 +1144,20 @@ impl ComputeSquaredDistance for ComputedTransformOperation {
match (self, other) { match (self, other) {
(&TransformOperation::Matrix3D(ref this), &TransformOperation::Matrix3D(ref other)) => { (&TransformOperation::Matrix3D(ref this), &TransformOperation::Matrix3D(ref other)) => {
this.compute_squared_distance(other) this.compute_squared_distance(other)
} },
(&TransformOperation::Matrix(ref this), &TransformOperation::Matrix(ref other)) => { (&TransformOperation::Matrix(ref this), &TransformOperation::Matrix(ref other)) => {
let this: Matrix3D = (*this).into(); let this: Matrix3D = (*this).into();
let other: Matrix3D = (*other).into(); let other: Matrix3D = (*other).into();
this.compute_squared_distance(&other) this.compute_squared_distance(&other)
} },
( (
&TransformOperation::Skew(ref fx, ref fy), &TransformOperation::Skew(ref fx, ref fy),
&TransformOperation::Skew(ref tx, ref ty), &TransformOperation::Skew(ref tx, ref ty),
) => Ok(fx.compute_squared_distance(&tx)? + fy.compute_squared_distance(&ty)?), ) => Ok(fx.compute_squared_distance(&tx)? + fy.compute_squared_distance(&ty)?),
(&TransformOperation::SkewX(ref f), &TransformOperation::SkewX(ref t)) (&TransformOperation::SkewX(ref f), &TransformOperation::SkewX(ref t)) |
| (&TransformOperation::SkewY(ref f), &TransformOperation::SkewY(ref t)) => { (&TransformOperation::SkewY(ref f), &TransformOperation::SkewY(ref t)) => {
f.compute_squared_distance(&t) f.compute_squared_distance(&t)
} },
( (
&TransformOperation::Translate3D(ref fx, ref fy, ref fz), &TransformOperation::Translate3D(ref fx, ref fy, ref fz),
&TransformOperation::Translate3D(ref tx, ref ty, ref tz), &TransformOperation::Translate3D(ref tx, ref ty, ref tz),
@ -1173,33 +1173,33 @@ impl ComputeSquaredDistance for ComputedTransformOperation {
let tx = tx.length_component().px(); let tx = tx.length_component().px();
let ty = ty.length_component().px(); let ty = ty.length_component().px();
Ok(fx.compute_squared_distance(&tx)? Ok(fx.compute_squared_distance(&tx)? +
+ fy.compute_squared_distance(&ty)? fy.compute_squared_distance(&ty)? +
+ fz.compute_squared_distance(&tz)?) fz.compute_squared_distance(&tz)?)
} },
( (
&TransformOperation::Scale3D(ref fx, ref fy, ref fz), &TransformOperation::Scale3D(ref fx, ref fy, ref fz),
&TransformOperation::Scale3D(ref tx, ref ty, ref tz), &TransformOperation::Scale3D(ref tx, ref ty, ref tz),
) => Ok(fx.compute_squared_distance(&tx)? ) => Ok(fx.compute_squared_distance(&tx)? +
+ fy.compute_squared_distance(&ty)? fy.compute_squared_distance(&ty)? +
+ fz.compute_squared_distance(&tz)?), fz.compute_squared_distance(&tz)?),
( (
&TransformOperation::Rotate3D(fx, fy, fz, fa), &TransformOperation::Rotate3D(fx, fy, fz, fa),
&TransformOperation::Rotate3D(tx, ty, tz, ta), &TransformOperation::Rotate3D(tx, ty, tz, ta),
) => Rotate::Rotate3D(fx, fy, fz, fa) ) => Rotate::Rotate3D(fx, fy, fz, fa)
.compute_squared_distance(&Rotate::Rotate3D(tx, ty, tz, ta)), .compute_squared_distance(&Rotate::Rotate3D(tx, ty, tz, ta)),
(&TransformOperation::RotateX(fa), &TransformOperation::RotateX(ta)) (&TransformOperation::RotateX(fa), &TransformOperation::RotateX(ta)) |
| (&TransformOperation::RotateY(fa), &TransformOperation::RotateY(ta)) (&TransformOperation::RotateY(fa), &TransformOperation::RotateY(ta)) |
| (&TransformOperation::RotateZ(fa), &TransformOperation::RotateZ(ta)) (&TransformOperation::RotateZ(fa), &TransformOperation::RotateZ(ta)) |
| (&TransformOperation::Rotate(fa), &TransformOperation::Rotate(ta)) => { (&TransformOperation::Rotate(fa), &TransformOperation::Rotate(ta)) => {
fa.compute_squared_distance(&ta) fa.compute_squared_distance(&ta)
} },
( (
&TransformOperation::Perspective(ref fd), &TransformOperation::Perspective(ref fd),
&TransformOperation::Perspective(ref td), &TransformOperation::Perspective(ref td),
) => fd.compute_squared_distance(td), ) => fd.compute_squared_distance(td),
(&TransformOperation::Perspective(ref p), &TransformOperation::Matrix3D(ref m)) (&TransformOperation::Perspective(ref p), &TransformOperation::Matrix3D(ref m)) |
| (&TransformOperation::Matrix3D(ref m), &TransformOperation::Perspective(ref p)) => { (&TransformOperation::Matrix3D(ref m), &TransformOperation::Perspective(ref p)) => {
// FIXME(emilio): Is this right? Why interpolating this with // FIXME(emilio): Is this right? Why interpolating this with
// Perspective but not with anything else? // Perspective but not with anything else?
let mut p_matrix = Matrix3D::identity(); let mut p_matrix = Matrix3D::identity();
@ -1207,7 +1207,7 @@ impl ComputeSquaredDistance for ComputedTransformOperation {
p_matrix.m34 = -1. / p.px(); p_matrix.m34 = -1. / p.px();
} }
p_matrix.compute_squared_distance(&m) p_matrix.compute_squared_distance(&m)
} },
// Gecko cross-interpolates amongst all translate and all scale // Gecko cross-interpolates amongst all translate and all scale
// functions (See ToPrimitive in layout/style/StyleAnimationValue.cpp) // functions (See ToPrimitive in layout/style/StyleAnimationValue.cpp)
// without falling back to InterpolateMatrix // without falling back to InterpolateMatrix
@ -1260,7 +1260,7 @@ impl Animate for ComputedRotate {
fz, fz,
fa.animate(&Angle::zero(), procedure)?, fa.animate(&Angle::zero(), procedure)?,
)) ))
} },
(&Rotate::None, &Rotate::Rotate3D(tx, ty, tz, ta)) => { (&Rotate::None, &Rotate::Rotate3D(tx, ty, tz, ta)) => {
// Normalize direction vector first. // Normalize direction vector first.
let (tx, ty, tz, ta) = transform::get_normalized_vector_and_angle(tx, ty, tz, ta); let (tx, ty, tz, ta) = transform::get_normalized_vector_and_angle(tx, ty, tz, ta);
@ -1270,7 +1270,7 @@ impl Animate for ComputedRotate {
tz, tz,
Angle::zero().animate(&ta, procedure)?, Angle::zero().animate(&ta, procedure)?,
)) ))
} },
(&Rotate::Rotate3D(_, ..), _) | (_, &Rotate::Rotate3D(_, ..)) => { (&Rotate::Rotate3D(_, ..), _) | (_, &Rotate::Rotate3D(_, ..)) => {
let (from, to) = (self.resolve(), other.resolve()); let (from, to) = (self.resolve(), other.resolve());
let (mut fx, mut fy, mut fz, fa) = let (mut fx, mut fy, mut fz, fa) =
@ -1306,12 +1306,12 @@ impl Animate for ComputedRotate {
); );
Ok(Rotate::Rotate3D(x, y, z, Angle::from_radians(angle))) Ok(Rotate::Rotate3D(x, y, z, Angle::from_radians(angle)))
} },
(&Rotate::Rotate(_), _) | (_, &Rotate::Rotate(_)) => { (&Rotate::Rotate(_), _) | (_, &Rotate::Rotate(_)) => {
// If this is a 2D rotation, we just animate the <angle> // If this is a 2D rotation, we just animate the <angle>
let (from, to) = (self.resolve().3, other.resolve().3); let (from, to) = (self.resolve().3, other.resolve().3);
Ok(Rotate::Rotate(from.animate(&to, procedure)?)) Ok(Rotate::Rotate(from.animate(&to, procedure)?))
} },
} }
} }
} }
@ -1321,10 +1321,10 @@ impl ComputeSquaredDistance for ComputedRotate {
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
match (self, other) { match (self, other) {
(&Rotate::None, &Rotate::None) => Ok(SquaredDistance::from_sqrt(0.)), (&Rotate::None, &Rotate::None) => Ok(SquaredDistance::from_sqrt(0.)),
(&Rotate::Rotate3D(_, _, _, a), &Rotate::None) (&Rotate::Rotate3D(_, _, _, a), &Rotate::None) |
| (&Rotate::None, &Rotate::Rotate3D(_, _, _, a)) => { (&Rotate::None, &Rotate::Rotate3D(_, _, _, a)) => {
a.compute_squared_distance(&Angle::zero()) a.compute_squared_distance(&Angle::zero())
} },
(&Rotate::Rotate3D(_, ..), _) | (_, &Rotate::Rotate3D(_, ..)) => { (&Rotate::Rotate3D(_, ..), _) | (_, &Rotate::Rotate3D(_, ..)) => {
let (from, to) = (self.resolve(), other.resolve()); let (from, to) = (self.resolve(), other.resolve());
let (mut fx, mut fy, mut fz, angle1) = let (mut fx, mut fy, mut fz, angle1) =
@ -1351,7 +1351,7 @@ impl ComputeSquaredDistance for ComputedRotate {
let q2 = Quaternion::from_direction_and_angle(&v2, angle2.radians64()); let q2 = Quaternion::from_direction_and_angle(&v2, angle2.radians64());
q1.compute_squared_distance(&q2) q1.compute_squared_distance(&q2)
} }
} },
(&Rotate::Rotate(_), _) | (_, &Rotate::Rotate(_)) => self (&Rotate::Rotate(_), _) | (_, &Rotate::Rotate(_)) => self
.resolve() .resolve()
.3 .3
@ -1390,7 +1390,7 @@ impl Animate for ComputedTranslate {
from.1.animate(&to.1, procedure)?, from.1.animate(&to.1, procedure)?,
from.2.animate(&to.2, procedure)?, from.2.animate(&to.2, procedure)?,
)) ))
} },
} }
} }
} }
@ -1399,9 +1399,9 @@ impl ComputeSquaredDistance for ComputedTranslate {
#[inline] #[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
let (from, to) = (self.resolve(), other.resolve()); let (from, to) = (self.resolve(), other.resolve());
Ok(from.0.compute_squared_distance(&to.0)? Ok(from.0.compute_squared_distance(&to.0)? +
+ from.1.compute_squared_distance(&to.1)? from.1.compute_squared_distance(&to.1)? +
+ from.2.compute_squared_distance(&to.2)?) from.2.compute_squared_distance(&to.2)?)
} }
} }
@ -1439,7 +1439,7 @@ impl Animate for ComputedScale {
animate_multiplicative_factor(from.1, to.1, procedure)?, animate_multiplicative_factor(from.1, to.1, procedure)?,
animate_multiplicative_factor(from.2, to.2, procedure)?, animate_multiplicative_factor(from.2, to.2, procedure)?,
)) ))
} },
} }
} }
} }
@ -1448,8 +1448,8 @@ impl ComputeSquaredDistance for ComputedScale {
#[inline] #[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> { fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
let (from, to) = (self.resolve(), other.resolve()); let (from, to) = (self.resolve(), other.resolve());
Ok(from.0.compute_squared_distance(&to.0)? Ok(from.0.compute_squared_distance(&to.0)? +
+ from.1.compute_squared_distance(&to.1)? from.1.compute_squared_distance(&to.1)? +
+ from.2.compute_squared_distance(&to.2)?) from.2.compute_squared_distance(&to.2)?)
} }
} }

View file

@ -543,7 +543,10 @@ impl<L, I> TrackListValue<L, I> {
/// Returns true if `self` is the initial value. /// Returns true if `self` is the initial value.
pub fn is_initial(&self) -> bool { pub fn is_initial(&self) -> bool {
matches!(*self, TrackListValue::TrackSize(TrackSize::Breadth(TrackBreadth::Auto))) // FIXME: can't use Self::INITIAL_VALUE here yet: https://github.com/rust-lang/rust/issues/66585 matches!(
*self,
TrackListValue::TrackSize(TrackSize::Breadth(TrackBreadth::Auto))
) // FIXME: can't use Self::INITIAL_VALUE here yet: https://github.com/rust-lang/rust/issues/66585
} }
} }

View file

@ -303,7 +303,7 @@ where
match *self { match *self {
Translate(..) | Translate3D(..) | TranslateX(..) | TranslateY(..) | TranslateZ(..) => { Translate(..) | Translate3D(..) | TranslateX(..) | TranslateY(..) | TranslateZ(..) => {
true true
} },
_ => false, _ => false,
} }
} }
@ -415,8 +415,8 @@ where
fn is_3d(&self) -> bool { fn is_3d(&self) -> bool {
use self::TransformOperation::*; use self::TransformOperation::*;
match *self { match *self {
Translate3D(..) | TranslateZ(..) | Rotate3D(..) | RotateX(..) | RotateY(..) Translate3D(..) | TranslateZ(..) | Rotate3D(..) | RotateX(..) | RotateY(..) |
| RotateZ(..) | Scale3D(..) | ScaleZ(..) | Perspective(..) | Matrix3D(..) => true, RotateZ(..) | Scale3D(..) | ScaleZ(..) | Perspective(..) | Matrix3D(..) => true,
_ => false, _ => false,
} }
} }
@ -444,23 +444,23 @@ where
az as f64, az as f64,
euclid::Angle::radians(theta), euclid::Angle::radians(theta),
) )
} },
RotateX(theta) => { RotateX(theta) => {
let theta = euclid::Angle::radians(TWO_PI - theta.radians64()); let theta = euclid::Angle::radians(TWO_PI - theta.radians64());
Transform3D::create_rotation(1., 0., 0., theta) Transform3D::create_rotation(1., 0., 0., theta)
} },
RotateY(theta) => { RotateY(theta) => {
let theta = euclid::Angle::radians(TWO_PI - theta.radians64()); let theta = euclid::Angle::radians(TWO_PI - theta.radians64());
Transform3D::create_rotation(0., 1., 0., theta) Transform3D::create_rotation(0., 1., 0., theta)
} },
RotateZ(theta) | Rotate(theta) => { RotateZ(theta) | Rotate(theta) => {
let theta = euclid::Angle::radians(TWO_PI - theta.radians64()); let theta = euclid::Angle::radians(TWO_PI - theta.radians64());
Transform3D::create_rotation(0., 0., 1., theta) Transform3D::create_rotation(0., 0., 1., theta)
} },
Perspective(ref d) => { Perspective(ref d) => {
let m = create_perspective_matrix(d.to_pixel_length(None)?); let m = create_perspective_matrix(d.to_pixel_length(None)?);
m.cast() m.cast()
} },
Scale3D(sx, sy, sz) => Transform3D::create_scale(sx.into(), sy.into(), sz.into()), Scale3D(sx, sy, sz) => Transform3D::create_scale(sx.into(), sy.into(), sz.into()),
Scale(sx, sy) => Transform3D::create_scale(sx.into(), sy.into(), 1.), Scale(sx, sy) => Transform3D::create_scale(sx.into(), sy.into(), 1.),
ScaleX(s) => Transform3D::create_scale(s.into(), 1., 1.), ScaleX(s) => Transform3D::create_scale(s.into(), 1., 1.),
@ -470,23 +470,23 @@ where
let tx = tx.to_pixel_length(reference_width)? as f64; let tx = tx.to_pixel_length(reference_width)? as f64;
let ty = ty.to_pixel_length(reference_height)? as f64; let ty = ty.to_pixel_length(reference_height)? as f64;
Transform3D::create_translation(tx, ty, tz.to_pixel_length(None)? as f64) Transform3D::create_translation(tx, ty, tz.to_pixel_length(None)? as f64)
} },
Translate(ref tx, ref ty) => { Translate(ref tx, ref ty) => {
let tx = tx.to_pixel_length(reference_width)? as f64; let tx = tx.to_pixel_length(reference_width)? as f64;
let ty = ty.to_pixel_length(reference_height)? as f64; let ty = ty.to_pixel_length(reference_height)? as f64;
Transform3D::create_translation(tx, ty, 0.) Transform3D::create_translation(tx, ty, 0.)
} },
TranslateX(ref t) => { TranslateX(ref t) => {
let t = t.to_pixel_length(reference_width)? as f64; let t = t.to_pixel_length(reference_width)? as f64;
Transform3D::create_translation(t, 0., 0.) Transform3D::create_translation(t, 0., 0.)
} },
TranslateY(ref t) => { TranslateY(ref t) => {
let t = t.to_pixel_length(reference_height)? as f64; let t = t.to_pixel_length(reference_height)? as f64;
Transform3D::create_translation(0., t, 0.) Transform3D::create_translation(0., t, 0.)
} },
TranslateZ(ref z) => { TranslateZ(ref z) => {
Transform3D::create_translation(0., 0., z.to_pixel_length(None)? as f64) Transform3D::create_translation(0., 0., z.to_pixel_length(None)? as f64)
} },
Skew(theta_x, theta_y) => Transform3D::create_skew( Skew(theta_x, theta_y) => Transform3D::create_skew(
euclid::Angle::radians(theta_x.radians64()), euclid::Angle::radians(theta_x.radians64()),
euclid::Angle::radians(theta_y.radians64()), euclid::Angle::radians(theta_y.radians64()),
@ -509,7 +509,7 @@ where
// return an identity matrix. // return an identity matrix.
// Note: DOMMatrix doesn't go into this arm. // Note: DOMMatrix doesn't go into this arm.
Transform3D::identity() Transform3D::identity()
} },
}; };
Ok(matrix) Ok(matrix)
} }
@ -676,7 +676,7 @@ where
} }
dest.write_char(' ')?; dest.write_char(' ')?;
angle.to_css(dest) angle.to_css(dest)
} },
} }
} }
} }
@ -732,7 +732,7 @@ where
z.to_css(dest)?; z.to_css(dest)?;
} }
Ok(()) Ok(())
} },
} }
} }
} }

View file

@ -218,7 +218,7 @@ impl Angle {
Err(()) => { Err(()) => {
let t = t.clone(); let t = t.clone();
Err(input.new_unexpected_token_error(t)) Err(input.new_unexpected_token_error(t))
} },
} }
}, },
Token::Number { value, .. } if value == 0. => match allow_unitless_zero { Token::Number { value, .. } if value == 0. => match allow_unitless_zero {
@ -234,7 +234,7 @@ impl Angle {
ref t => { ref t => {
let t = t.clone(); let t = t.clone();
Err(input.new_unexpected_token_error(t)) Err(input.new_unexpected_token_error(t))
} },
} }
} }
} }

View file

@ -1153,7 +1153,7 @@ fn change_bits_for_longhand(longhand: LonghandId) -> WillChangeBits {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
LonghandId::Translate | LonghandId::Rotate | LonghandId::Scale | LonghandId::OffsetPath => { LonghandId::Translate | LonghandId::Rotate | LonghandId::Scale | LonghandId::OffsetPath => {
WillChangeBits::TRANSFORM WillChangeBits::TRANSFORM
} },
_ => WillChangeBits::empty(), _ => WillChangeBits::empty(),
}; };

View file

@ -176,13 +176,9 @@ impl CalcNode {
value, ref unit, .. value, ref unit, ..
}, },
CalcUnit::LengthPercentage, CalcUnit::LengthPercentage,
) => { ) => NoCalcLength::parse_dimension(context, value, unit)
NoCalcLength::parse_dimension(context, value, unit) .map(CalcNode::Length)
.map(CalcNode::Length) .map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
.map_err(|()| {
location.new_custom_error(StyleParseErrorKind::UnspecifiedError)
})
},
( (
&Token::Dimension { &Token::Dimension {
value, ref unit, .. value, ref unit, ..
@ -191,9 +187,7 @@ impl CalcNode {
) => { ) => {
Angle::parse_dimension(value, unit, /* from_calc = */ true) Angle::parse_dimension(value, unit, /* from_calc = */ true)
.map(CalcNode::Angle) .map(CalcNode::Angle)
.map_err(|()| { .map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
location.new_custom_error(StyleParseErrorKind::UnspecifiedError)
})
}, },
( (
&Token::Dimension { &Token::Dimension {
@ -203,9 +197,7 @@ impl CalcNode {
) => { ) => {
Time::parse_dimension(value, unit, /* from_calc = */ true) Time::parse_dimension(value, unit, /* from_calc = */ true)
.map(CalcNode::Time) .map(CalcNode::Time)
.map_err(|()| { .map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
location.new_custom_error(StyleParseErrorKind::UnspecifiedError)
})
}, },
(&Token::Percentage { unit_value, .. }, CalcUnit::LengthPercentage) | (&Token::Percentage { unit_value, .. }, CalcUnit::LengthPercentage) |
(&Token::Percentage { unit_value, .. }, CalcUnit::Percentage) => { (&Token::Percentage { unit_value, .. }, CalcUnit::Percentage) => {
@ -252,7 +244,7 @@ impl CalcNode {
ref t => { ref t => {
let t = t.clone(); let t = t.clone();
return Err(input.new_unexpected_token_error(t)); return Err(input.new_unexpected_token_error(t));
} },
} }
}, },
_ => { _ => {

View file

@ -260,13 +260,9 @@ impl SystemColor {
SystemColor::MozVisitedhyperlinktext => prefs.mVisitedLinkColor, SystemColor::MozVisitedhyperlinktext => prefs.mVisitedLinkColor,
_ => unsafe { _ => unsafe {
bindings::Gecko_GetLookAndFeelSystemColor( bindings::Gecko_GetLookAndFeelSystemColor(*self as i32, cx.device().document())
*self as i32, },
cx.device().document()
)
}
}) })
} }
} }

View file

@ -203,7 +203,7 @@ impl Parse for Content {
Ok(t) => { Ok(t) => {
let t = t.clone(); let t = t.clone();
return Err(input.new_unexpected_token_error(t)); return Err(input.new_unexpected_token_error(t));
} },
} }
} }
if content.is_empty() { if content.is_empty() {

View file

@ -1212,69 +1212,67 @@ impl Parse for FontVariantAlternates {
parsed_alternates |= $flag; parsed_alternates |= $flag;
) )
); );
while let Ok(_) = input.try(|input| { while let Ok(_) = input.try(|input| match *input.next()? {
match *input.next()? { Token::Ident(ref value) if value.eq_ignore_ascii_case("historical-forms") => {
Token::Ident(ref value) if value.eq_ignore_ascii_case("historical-forms") => { check_if_parsed!(input, VariantAlternatesParsingFlags::HISTORICAL_FORMS);
check_if_parsed!(input, VariantAlternatesParsingFlags::HISTORICAL_FORMS); alternates.push(VariantAlternates::HistoricalForms);
alternates.push(VariantAlternates::HistoricalForms); Ok(())
Ok(()) },
}, Token::Function(ref name) => {
Token::Function(ref name) => { let name = name.clone();
let name = name.clone(); input.parse_nested_block(|i| {
input.parse_nested_block(|i| { match_ignore_ascii_case! { &name,
match_ignore_ascii_case! { &name, "swash" => {
"swash" => { check_if_parsed!(i, VariantAlternatesParsingFlags::SWASH);
check_if_parsed!(i, VariantAlternatesParsingFlags::SWASH); let location = i.current_source_location();
let ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?;
alternates.push(VariantAlternates::Swash(ident));
Ok(())
},
"stylistic" => {
check_if_parsed!(i, VariantAlternatesParsingFlags::STYLISTIC);
let location = i.current_source_location();
let ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?;
alternates.push(VariantAlternates::Stylistic(ident));
Ok(())
},
"ornaments" => {
check_if_parsed!(i, VariantAlternatesParsingFlags::ORNAMENTS);
let location = i.current_source_location();
let ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?;
alternates.push(VariantAlternates::Ornaments(ident));
Ok(())
},
"annotation" => {
check_if_parsed!(i, VariantAlternatesParsingFlags::ANNOTATION);
let location = i.current_source_location();
let ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?;
alternates.push(VariantAlternates::Annotation(ident));
Ok(())
},
"styleset" => {
check_if_parsed!(i, VariantAlternatesParsingFlags::STYLESET);
let idents = i.parse_comma_separated(|i| {
let location = i.current_source_location(); let location = i.current_source_location();
let ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?; CustomIdent::from_ident(location, i.expect_ident()?, &[])
alternates.push(VariantAlternates::Swash(ident)); })?;
Ok(()) alternates.push(VariantAlternates::Styleset(idents.into()));
}, Ok(())
"stylistic" => { },
check_if_parsed!(i, VariantAlternatesParsingFlags::STYLISTIC); "character-variant" => {
check_if_parsed!(i, VariantAlternatesParsingFlags::CHARACTER_VARIANT);
let idents = i.parse_comma_separated(|i| {
let location = i.current_source_location(); let location = i.current_source_location();
let ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?; CustomIdent::from_ident(location, i.expect_ident()?, &[])
alternates.push(VariantAlternates::Stylistic(ident)); })?;
Ok(()) alternates.push(VariantAlternates::CharacterVariant(idents.into()));
}, Ok(())
"ornaments" => { },
check_if_parsed!(i, VariantAlternatesParsingFlags::ORNAMENTS); _ => return Err(i.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
let location = i.current_source_location(); }
let ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?; })
alternates.push(VariantAlternates::Ornaments(ident)); },
Ok(()) _ => Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
},
"annotation" => {
check_if_parsed!(i, VariantAlternatesParsingFlags::ANNOTATION);
let location = i.current_source_location();
let ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?;
alternates.push(VariantAlternates::Annotation(ident));
Ok(())
},
"styleset" => {
check_if_parsed!(i, VariantAlternatesParsingFlags::STYLESET);
let idents = i.parse_comma_separated(|i| {
let location = i.current_source_location();
CustomIdent::from_ident(location, i.expect_ident()?, &[])
})?;
alternates.push(VariantAlternates::Styleset(idents.into()));
Ok(())
},
"character-variant" => {
check_if_parsed!(i, VariantAlternatesParsingFlags::CHARACTER_VARIANT);
let idents = i.parse_comma_separated(|i| {
let location = i.current_source_location();
CustomIdent::from_ident(location, i.expect_ident()?, &[])
})?;
alternates.push(VariantAlternates::CharacterVariant(idents.into()));
Ok(())
},
_ => return Err(i.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
}
})
},
_ => Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
}
}) {} }) {}
if parsed_alternates.is_empty() { if parsed_alternates.is_empty() {

View file

@ -602,20 +602,17 @@ impl Length {
!context.parsing_mode.allows_unitless_lengths() && !context.parsing_mode.allows_unitless_lengths() &&
!allow_quirks.allowed(context.quirks_mode) !allow_quirks.allowed(context.quirks_mode)
{ {
return Err( return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
location.new_custom_error(StyleParseErrorKind::UnspecifiedError)
);
} }
Ok(Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px( Ok(Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(
value, value,
)))) ))))
}, },
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => { Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => input
input.parse_nested_block(|input| { .parse_nested_block(|input| {
CalcNode::parse_length(context, input, num_context) CalcNode::parse_length(context, input, num_context)
.map(|calc| Length::Calc(Box::new(calc))) .map(|calc| Length::Calc(Box::new(calc)))
}) }),
},
ref token => return Err(location.new_unexpected_token_error(token.clone())), ref token => return Err(location.new_unexpected_token_error(token.clone())),
} }
} }

View file

@ -116,9 +116,10 @@ impl Percentage {
if num_context.is_ok(context.parsing_mode, unit_value) => if num_context.is_ok(context.parsing_mode, unit_value) =>
{ {
Ok(Percentage::new(unit_value)) Ok(Percentage::new(unit_value))
} },
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => { Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {
let result = input.parse_nested_block(|i| CalcNode::parse_percentage(context, i))?; let result =
input.parse_nested_block(|i| CalcNode::parse_percentage(context, i))?;
// TODO(emilio): -moz-image-rect is the only thing that uses // TODO(emilio): -moz-image-rect is the only thing that uses
// the clamping mode... I guess we could disallow it... // the clamping mode... I guess we could disallow it...

View file

@ -92,9 +92,8 @@ impl Time {
Token::Dimension { Token::Dimension {
value, ref unit, .. value, ref unit, ..
} if clamping_mode.is_ok(ParsingMode::DEFAULT, value) => { } if clamping_mode.is_ok(ParsingMode::DEFAULT, value) => {
Time::parse_dimension(value, unit, /* from_calc = */ false).map_err(|()| { Time::parse_dimension(value, unit, /* from_calc = */ false)
location.new_custom_error(StyleParseErrorKind::UnspecifiedError) .map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
})
}, },
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => { Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {
match input.parse_nested_block(|i| CalcNode::parse_time(context, i)) { match input.parse_nested_block(|i| CalcNode::parse_time(context, i)) {

View file

@ -12,7 +12,9 @@ use crate::values::generics::transform::{Matrix, Matrix3D};
use crate::values::specified::position::{ use crate::values::specified::position::{
HorizontalPositionKeyword, Side, VerticalPositionKeyword, HorizontalPositionKeyword, Side, VerticalPositionKeyword,
}; };
use crate::values::specified::{self, Angle, Integer, Length, LengthPercentage, Number, NumberOrPercentage}; use crate::values::specified::{
self, Angle, Integer, Length, LengthPercentage, Number, NumberOrPercentage,
};
use crate::Zero; use crate::Zero;
use cssparser::Parser; use cssparser::Parser;
use style_traits::{ParseError, StyleParseErrorKind}; use style_traits::{ParseError, StyleParseErrorKind};