Bug 1600436 - Rustfmt recent changes.

Differential Revision: https://phabricator.services.mozilla.com/D55357

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-11-30 14:13:04 +00:00
Родитель 91bdbdf2ed
Коммит f628d09be6
21 изменённых файлов: 247 добавлений и 247 удалений

Просмотреть файл

@ -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
/// 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);
impl ApplicableDeclarationBits {
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 {
@ -87,12 +90,7 @@ impl ApplicableDeclarationBlock {
/// Constructs an applicable declaration block from the given components
#[inline]
pub fn new(
source: StyleSource,
order: u32,
level: CascadeLevel,
specificity: u32,
) -> Self {
pub fn new(source: StyleSource, order: u32, level: CascadeLevel, specificity: u32) -> Self {
ApplicableDeclarationBlock {
source,
bits: ApplicableDeclarationBits::new(order, level),

Просмотреть файл

@ -83,7 +83,10 @@ pub fn get_id(attrs: &[structs::AttrArray_InternalAttr]) -> Option<&WeakAtom> {
}
#[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 atom = unsafe { bindings::Gecko_Element_ExportedPart(attr, name.as_ptr()) };
if atom.is_null() {
@ -93,7 +96,10 @@ pub(super) fn exported_part(attrs: &[structs::AttrArray_InternalAttr], name: &At
}
#[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 atom = unsafe { bindings::Gecko_Element_ImportedPart(attr, name.as_ptr()) };
if atom.is_null() {

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -543,7 +543,10 @@ impl<L, I> TrackListValue<L, I> {
/// Returns true if `self` is the initial value.
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
}
}

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -1212,69 +1212,67 @@ impl Parse for FontVariantAlternates {
parsed_alternates |= $flag;
)
);
while let Ok(_) = input.try(|input| {
match *input.next()? {
Token::Ident(ref value) if value.eq_ignore_ascii_case("historical-forms") => {
check_if_parsed!(input, VariantAlternatesParsingFlags::HISTORICAL_FORMS);
alternates.push(VariantAlternates::HistoricalForms);
Ok(())
},
Token::Function(ref name) => {
let name = name.clone();
input.parse_nested_block(|i| {
match_ignore_ascii_case! { &name,
"swash" => {
check_if_parsed!(i, VariantAlternatesParsingFlags::SWASH);
while let Ok(_) = input.try(|input| match *input.next()? {
Token::Ident(ref value) if value.eq_ignore_ascii_case("historical-forms") => {
check_if_parsed!(input, VariantAlternatesParsingFlags::HISTORICAL_FORMS);
alternates.push(VariantAlternates::HistoricalForms);
Ok(())
},
Token::Function(ref name) => {
let name = name.clone();
input.parse_nested_block(|i| {
match_ignore_ascii_case! { &name,
"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 ident = CustomIdent::from_ident(location, i.expect_ident()?, &[])?;
alternates.push(VariantAlternates::Swash(ident));
Ok(())
},
"stylistic" => {
check_if_parsed!(i, VariantAlternatesParsingFlags::STYLISTIC);
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();
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();
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)),
}
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() {

Просмотреть файл

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

Просмотреть файл

@ -116,9 +116,10 @@ impl Percentage {
if num_context.is_ok(context.parsing_mode, unit_value) =>
{
Ok(Percentage::new(unit_value))
}
},
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
// the clamping mode... I guess we could disallow it...

Просмотреть файл

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

Просмотреть файл

@ -12,7 +12,9 @@ use crate::values::generics::transform::{Matrix, Matrix3D};
use crate::values::specified::position::{
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 cssparser::Parser;
use style_traits::{ParseError, StyleParseErrorKind};