Bug 1518045 - Rustfmt has changed its default style. r=emilio

This cherry-picks the formatting parts of
https://github.com/servo/servo/pull/22385.
This commit is contained in:
Simon Sapin 2018-12-14 08:31:30 +01:00 коммит произвёл Emilio Cobos Álvarez
Родитель 1834c20f36
Коммит 81312a11be
63 изменённых файлов: 232 добавлений и 295 удалений

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

@ -261,10 +261,11 @@ where
let iter = selector.iter_from(selector.len() - from_offset);
debug_assert!(
iter.clone().next().is_some() ||
(from_offset != selector.len() && matches!(
selector.combinator_at_parse_order(from_offset),
Combinator::SlotAssignment | Combinator::PseudoElement
)),
(from_offset != selector.len() &&
matches!(
selector.combinator_at_parse_order(from_offset),
Combinator::SlotAssignment | Combinator::PseudoElement
)),
"Got the math wrong: {:?} | {:?} | {} {}",
selector,
selector.iter_raw_match_order().as_slice(),
@ -454,11 +455,9 @@ where
context.current_host.is_some(),
"Should not be trying to match slotted rules in a non-shadow-tree context"
);
debug_assert!(
element
.assigned_slot()
.map_or(true, |s| s.is_html_slot_element())
);
debug_assert!(element
.assigned_slot()
.map_or(true, |s| s.is_html_slot_element()));
let scope = context.current_host?;
let mut current_slot = element.assigned_slot()?;
while current_slot.containing_shadow_host().unwrap().opaque() != scope {
@ -674,9 +673,9 @@ where
Component::Combinator(_) => unreachable!(),
Component::Slotted(ref selector) => {
// <slots> are never flattened tree slottables.
!element.is_html_slot_element() && element.assigned_slot().is_some() && context
.shared
.nest(|context| {
!element.is_html_slot_element() &&
element.assigned_slot().is_some() &&
context.shared.nest(|context| {
matches_complex_selector(selector.iter(), element, context, flags_setter)
})
},

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

@ -449,9 +449,7 @@ where
ref local_name,
never_matches,
..
}
if !never_matches =>
{
} if !never_matches => {
if !visitor.visit_attribute_selector(
&NamespaceConstraint::Specific(&namespace_empty_string::<Impl>()),
local_name,
@ -459,7 +457,7 @@ where
) {
return false;
}
}
},
AttributeOther(ref attr_selector) if !attr_selector.never_matches => {
let empty_string;
let namespace = match attr_selector.namespace() {
@ -1366,7 +1364,7 @@ where
SelectorParseErrorKind::DanglingCombinator
} else {
SelectorParseErrorKind::EmptySelector
}))
}));
},
};
@ -1634,7 +1632,7 @@ where
OptionalQName::None(t) => {
return Err(input.new_custom_error(
SelectorParseErrorKind::NoQualifiedNameInAttributeSelector(t),
))
));
},
OptionalQName::Some(_, None) => unreachable!(),
OptionalQName::Some(ns, Some(ln)) => {
@ -1691,7 +1689,7 @@ where
Ok(t) => {
return Err(location.new_custom_error(
SelectorParseErrorKind::UnexpectedTokenInAttributeSelector(t.clone()),
))
));
},
};
@ -1768,11 +1766,12 @@ impl AttributeFlags {
AttributeFlags::CaseSensitive => ParsedCaseSensitivity::ExplicitCaseSensitive,
AttributeFlags::AsciiCaseInsensitive => ParsedCaseSensitivity::AsciiCaseInsensitive,
AttributeFlags::CaseSensitivityDependsOnName => {
if !have_namespace && include!(concat!(
env!("OUT_DIR"),
"/ascii_case_insensitive_html_attributes.rs"
))
.contains(local_name)
if !have_namespace &&
include!(concat!(
env!("OUT_DIR"),
"/ascii_case_insensitive_html_attributes.rs"
))
.contains(local_name)
{
ParsedCaseSensitivity::AsciiCaseInsensitiveIfInHtmlElementInHtmlDocument
} else {
@ -1961,7 +1960,7 @@ where
&Token::Ident(ref name) => name.clone(),
t => {
return Err(location
.new_custom_error(SelectorParseErrorKind::NoIdentForPseudo(t.clone())))
.new_custom_error(SelectorParseErrorKind::NoIdentForPseudo(t.clone())));
},
};

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

@ -6,7 +6,6 @@
//!
//! [attr]: https://dom.spec.whatwg.org/#interface-attr
use app_units::Au;
use crate::properties::PropertyDeclarationBlock;
use crate::shared_lock::Locked;
use crate::str::str_join;
@ -14,6 +13,7 @@ use crate::str::{read_exponent, read_fraction, HTML_SPACE_CHARACTERS};
use crate::str::{read_numbers, split_commas, split_html_space_chars};
use crate::values::specified::Length;
use crate::{Atom, LocalName, Namespace, Prefix};
use app_units::Au;
use cssparser::{self, Color, RGBA};
use euclid::num::Zero;
use num_traits::ToPrimitive;

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

@ -7,8 +7,8 @@
#![deny(missing_docs)]
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use crate::dom::{SendElement, TElement};
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use owning_ref::OwningHandle;
use selectors::bloom::BloomFilter;
use servo_arc::Arc;

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

@ -515,8 +515,7 @@ mod bindings {
"pub type nsTArrayBorrowed_{}<'a> = ",
"&'a mut ::gecko_bindings::structs::nsTArray<{}>;"
),
cpp_type,
rust_type
cpp_type, rust_type
))
})
.handle_str_items("servo-immutable-borrow-types", |b, ty| b.borrowed_type(ty))

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

@ -4,7 +4,6 @@
//! The context within which style is calculated.
use app_units::Au;
#[cfg(feature = "servo")]
use crate::animation::Animation;
use crate::bloom::StyleBloom;
@ -29,6 +28,7 @@ use crate::thread_state::{self, ThreadState};
use crate::timer::Timer;
use crate::traversal::DomTraversal;
use crate::traversal_flags::TraversalFlags;
use app_units::Au;
#[cfg(feature = "servo")]
use crossbeam_channel::Sender;
use euclid::Size2D;

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

@ -434,7 +434,7 @@ fn parse_declaration_value_block<'i, 't>(
return Ok((
TokenSerializationType::nothing(),
TokenSerializationType::nothing(),
))
));
},
};
let first_token_type = token.serialization_type();

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

@ -7,7 +7,6 @@
#![allow(unsafe_code)]
#![deny(missing_docs)]
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use crate::applicable_declarations::ApplicableDeclarationBlock;
#[cfg(feature = "gecko")]
use crate::context::PostAnimationTasks;
@ -23,6 +22,7 @@ use crate::shared_lock::Locked;
use crate::stylist::CascadeData;
use crate::traversal_flags::TraversalFlags;
use crate::{Atom, LocalName, Namespace, WeakAtom};
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use selectors::matching::{ElementSelectorFlags, QuirksMode, VisitedHandlingMode};
use selectors::sink::Push;
use selectors::Element as SelectorsElement;
@ -42,10 +42,7 @@ use std::ops::Deref;
/// data structures. Also, layout code tends to be faster when the DOM is not being accessed, for
/// locality reasons. Using `OpaqueNode` enforces this invariant.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[cfg_attr(
feature = "servo",
derive(MallocSizeOf, Deserialize, Serialize)
)]
#[cfg_attr(feature = "servo", derive(MallocSizeOf, Deserialize, Serialize))]
pub struct OpaqueNode(pub usize);
impl OpaqueNode {

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

@ -336,9 +336,10 @@ impl<'a> FontFace<'a> {
// We support only opentype fonts and truetype is an alias for
// that format. Sources without format hints need to be
// downloaded in case we support them.
hints.is_empty() || hints
.iter()
.any(|hint| hint == "truetype" || hint == "opentype" || hint == "woff")
hints.is_empty() ||
hints.iter().any(|hint| {
hint == "truetype" || hint == "opentype" || hint == "woff"
})
} else {
true
}

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

@ -6,12 +6,12 @@
#![deny(missing_docs)]
use app_units::Au;
use crate::context::SharedStyleContext;
use crate::logical_geometry::WritingMode;
use crate::media_queries::Device;
use crate::properties::style_structs::Font;
use crate::Atom;
use app_units::Au;
/// Represents the font metrics that style needs from a font to compute the
/// value of certain CSS units like `ex`.

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

@ -10,7 +10,6 @@
#![allow(unsafe_code)]
use app_units::Au;
use crate::gecko::values::GeckoStyleCoordConvertible;
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs::RawGeckoGfxMatrix4x4;
@ -30,6 +29,7 @@ use crate::values::generics::box_::VerticalAlign;
use crate::values::generics::grid::{TrackListValue, TrackSize};
use crate::values::generics::image::{CompatMode, GradientItem, Image as GenericImage};
use crate::values::generics::rect::Rect;
use app_units::Au;
use std::f32::consts::PI;
impl From<CalcLengthOrPercentage> for nsStyleCoord_CalcValue {

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

@ -4,7 +4,6 @@
//! Data needed to style a Gecko document.
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use crate::context::QuirksMode;
use crate::dom::TElement;
use crate::gecko_bindings::bindings::{self, RawServoStyleSet};
@ -18,6 +17,7 @@ use crate::selector_parser::SnapshotMap;
use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
use crate::stylesheets::{CssRule, Origin, StylesheetContents, StylesheetInDocument};
use crate::stylist::Stylist;
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use malloc_size_of::MallocSizeOfOps;
use servo_arc::Arc;
use std::fmt;

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

@ -4,7 +4,6 @@
//! Gecko's media feature list and evaluator.
use app_units::Au;
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs;
use crate::media_queries::media_feature::{AllowsRanges, ParsingRequirements};
@ -14,6 +13,7 @@ use crate::media_queries::{Device, MediaType};
use crate::values::computed::CSSPixelLength;
use crate::values::computed::Resolution;
use crate::Atom;
use app_units::Au;
use euclid::Size2D;
fn viewport_size(device: &Device) -> Size2D<Au> {

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

@ -4,8 +4,6 @@
//! Gecko's media-query device and expression representation.
use app_units::Au;
use app_units::AU_PER_PX;
use crate::custom_properties::CssEnvironment;
use crate::gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
use crate::gecko_bindings::bindings;
@ -16,6 +14,8 @@ use crate::properties::ComputedValues;
use crate::string_cache::Atom;
use crate::values::computed::font::FontSize;
use crate::values::{CustomIdent, KeyframesName};
use app_units::Au;
use app_units::AU_PER_PX;
use cssparser::RGBA;
use euclid::Size2D;
use euclid::TypedScale;

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

@ -230,33 +230,34 @@ impl NonTSPseudoClass {
/// Returns true if the given pseudoclass should trigger style sharing cache
/// revalidation.
pub fn needs_cache_revalidation(&self) -> bool {
self.state_flag().is_empty() && !matches!(*self,
// :-moz-any is handled by the revalidation visitor walking
// the things inside it; it does not need to cause
// revalidation on its own.
NonTSPseudoClass::MozAny(_) |
// :dir() depends on state only, but doesn't use state_flag
// because its semantics don't quite match. Nevertheless, it
// doesn't need cache revalidation, because we already compare
// states for elements and candidates.
NonTSPseudoClass::Dir(_) |
// :-moz-is-html only depends on the state of the document and
// the namespace of the element; the former is invariant
// across all the elements involved and the latter is already
// checked for by our caching precondtions.
NonTSPseudoClass::MozIsHTML |
// :-moz-placeholder is parsed but never matches.
NonTSPseudoClass::MozPlaceholder |
// :-moz-locale-dir and :-moz-window-inactive depend only on
// the state of the document, which is invariant across all
// the elements involved in a given style cache.
NonTSPseudoClass::MozLocaleDir(_) |
NonTSPseudoClass::MozWindowInactive |
// Similar for the document themes.
NonTSPseudoClass::MozLWTheme |
NonTSPseudoClass::MozLWThemeBrightText |
NonTSPseudoClass::MozLWThemeDarkText
)
self.state_flag().is_empty() &&
!matches!(*self,
// :-moz-any is handled by the revalidation visitor walking
// the things inside it; it does not need to cause
// revalidation on its own.
NonTSPseudoClass::MozAny(_) |
// :dir() depends on state only, but doesn't use state_flag
// because its semantics don't quite match. Nevertheless, it
// doesn't need cache revalidation, because we already compare
// states for elements and candidates.
NonTSPseudoClass::Dir(_) |
// :-moz-is-html only depends on the state of the document and
// the namespace of the element; the former is invariant
// across all the elements involved and the latter is already
// checked for by our caching precondtions.
NonTSPseudoClass::MozIsHTML |
// :-moz-placeholder is parsed but never matches.
NonTSPseudoClass::MozPlaceholder |
// :-moz-locale-dir and :-moz-window-inactive depend only on
// the state of the document, which is invariant across all
// the elements involved in a given style cache.
NonTSPseudoClass::MozLocaleDir(_) |
NonTSPseudoClass::MozWindowInactive |
// Similar for the document themes.
NonTSPseudoClass::MozLWTheme |
NonTSPseudoClass::MozLWThemeBrightText |
NonTSPseudoClass::MozLWThemeDarkText
)
}
/// Returns true if the evaluation of the pseudo-class depends on the

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

@ -6,7 +6,6 @@
//! Different kind of helpers to interact with Gecko values.
use app_units::Au;
use crate::counter_style::{Symbol, Symbols};
use crate::gecko_bindings::structs::{self, nsStyleCoord, CounterStylePtr};
use crate::gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
@ -27,6 +26,7 @@ use crate::values::generics::length::{MaxLength, MozLength};
use crate::values::generics::{CounterStyleOrNone, NonNegative};
use crate::values::{Auto, Either, None_, Normal};
use crate::Atom;
use app_units::Au;
use cssparser::RGBA;
use nsstring::{nsACString, nsCStr};
use std::cmp::max;

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

@ -14,8 +14,6 @@
//! style system it's kind of pointless in the Stylo case, and only Servo forces
//! the separation between the style system implementation and everything else.
use app_units::Au;
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use crate::applicable_declarations::ApplicableDeclarationBlock;
use crate::author_styles::AuthorStyles;
use crate::context::{PostAnimationTasks, QuirksMode, SharedStyleContext, UpdateAnimationsTasks};
@ -72,6 +70,8 @@ use crate::shared_lock::Locked;
use crate::string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
use crate::stylist::CascadeData;
use crate::CaseSensitivityExt;
use app_units::Au;
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator};
use selectors::attr::{CaseSensitivity, NamespaceConstraint};
use selectors::matching::VisitedHandlingMode;
@ -931,13 +931,14 @@ impl<'le> GeckoElement<'le> {
debug_assert_eq!(to.is_some(), from.is_some());
combined_duration > 0.0f32 && from != to && from
.unwrap()
.animate(
to.as_ref().unwrap(),
Procedure::Interpolate { progress: 0.5 },
)
.is_ok()
combined_duration > 0.0f32 &&
from != to &&
from.unwrap()
.animate(
to.as_ref().unwrap(),
Procedure::Interpolate { progress: 0.5 },
)
.is_ok()
}
}
@ -1241,10 +1242,11 @@ impl<'le> TElement for GeckoElement<'le> {
}
fn owner_doc_matches_for_testing(&self, device: &Device) -> bool {
self.as_node().owner_doc().0 as *const structs::Document == device
.pres_context()
.mDocument
.mRawPtr
self.as_node().owner_doc().0 as *const structs::Document ==
device
.pres_context()
.mDocument
.mRawPtr
}
fn style_attribute(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> {
@ -1861,9 +1863,8 @@ impl<'le> TElement for GeckoElement<'le> {
.intersects(NonTSPseudoClass::Active.state_flag());
if active {
let declarations = unsafe { Gecko_GetActiveLinkAttrDeclarationBlock(self.0) };
let declarations: Option<
&RawOffsetArc<Locked<PropertyDeclarationBlock>>,
> = declarations.and_then(|s| s.as_arc_opt());
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
declarations.and_then(|s| s.as_arc_opt());
if let Some(decl) = declarations {
hints.push(ApplicableDeclarationBlock::from_declarations(
decl.clone_arc(),
@ -2078,11 +2079,10 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
return false;
}
debug_assert!(
self.as_node()
.parent_node()
.map_or(false, |p| p.is_document())
);
debug_assert!(self
.as_node()
.parent_node()
.map_or(false, |p| p.is_document()));
unsafe { bindings::Gecko_IsRootElement(self.0) }
}

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

@ -4,12 +4,7 @@
//! Gecko's C++ bindings, along with some rust helpers to ease its use.
#[allow(
dead_code,
improper_ctypes,
non_camel_case_types,
missing_docs
)]
#[allow(dead_code, improper_ctypes, non_camel_case_types, missing_docs)]
pub mod bindings {
include!(concat!(env!("OUT_DIR"), "/gecko/bindings.rs"));
}

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

@ -4,9 +4,9 @@
//! Rust helpers for Gecko's `nsCSSShadowItem`.
use app_units::Au;
use crate::gecko_bindings::structs::nsCSSShadowItem;
use crate::values::computed::effects::{BoxShadow, SimpleShadow};
use app_units::Au;
impl nsCSSShadowItem {
/// Sets this item from the given box shadow.

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

@ -208,10 +208,10 @@ where
// Instead, we use the `visited_handling` to determine if they
// match.
NonTSPseudoClass::Link => {
return self.is_link() && context.visited_handling().matches_unvisited()
return self.is_link() && context.visited_handling().matches_unvisited();
},
NonTSPseudoClass::Visited => {
return self.is_link() && context.visited_handling().matches_visited()
return self.is_link() && context.visited_handling().matches_visited();
},
#[cfg(feature = "gecko")]

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

@ -1221,11 +1221,12 @@ impl<T: Copy + Add<T, Output = T> + Sub<T, Output = T>> LogicalRect<T> {
pub fn translate(&self, offset: &LogicalPoint<T>) -> LogicalRect<T> {
LogicalRect {
start: self.start + LogicalSize {
inline: offset.i,
block: offset.b,
debug_writing_mode: offset.debug_writing_mode,
},
start: self.start +
LogicalSize {
inline: offset.i,
block: offset.b,
debug_writing_mode: offset.debug_writing_mode,
},
size: self.size,
debug_writing_mode: self.debug_writing_mode,
}

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

@ -469,11 +469,9 @@ trait PrivateMatchMethods: TElement {
pseudo: Option<&PseudoElement>,
) -> ChildCascadeRequirement {
debug!("accumulate_damage_for: {:?}", self);
debug_assert!(
!shared_context
.traversal_flags
.contains(TraversalFlags::Forgetful)
);
debug_assert!(!shared_context
.traversal_flags
.contains(TraversalFlags::Forgetful));
let difference = self.compute_style_difference(old_values, new_values, pseudo);

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

@ -30,9 +30,10 @@ type MediaFeatureEvaluator<T> = fn(
pub type KeywordSerializer = fn(KeywordDiscriminant) -> String;
/// Parses a given identifier.
pub type KeywordParser =
for<'a, 'i, 't> fn(context: &'a ParserContext, input: &'a mut Parser<'i, 't>)
-> Result<KeywordDiscriminant, ParseError<'i>>;
pub type KeywordParser = for<'a, 'i, 't> fn(
context: &'a ParserContext,
input: &'a mut Parser<'i, 't>,
) -> Result<KeywordDiscriminant, ParseError<'i>>;
/// An evaluator for a given media feature.
///

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

@ -134,10 +134,11 @@ impl RangeOrOperator {
match range_or_op {
RangeOrOperator::Range(range) => {
cmp == Ordering::Equal || match range {
Range::Min => cmp == Ordering::Greater,
Range::Max => cmp == Ordering::Less,
}
cmp == Ordering::Equal ||
match range {
Range::Min => cmp == Ordering::Greater,
Range::Max => cmp == Ordering::Less,
}
},
RangeOrOperator::Operator(op) => match op {
Operator::Equal => cmp == Ordering::Equal,
@ -344,7 +345,7 @@ impl MediaFeatureExpression {
Err(()) => {
return Err(location.new_custom_error(
StyleParseErrorKind::MediaQueryExpectedFeatureName(ident.clone()),
))
));
},
}

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

@ -74,21 +74,22 @@ impl MediaList {
pub fn evaluate(&self, device: &Device, quirks_mode: QuirksMode) -> bool {
// Check if it is an empty media query list or any queries match.
// https://drafts.csswg.org/mediaqueries-4/#mq-list
self.media_queries.is_empty() || self.media_queries.iter().any(|mq| {
let media_match = mq.media_type.matches(device.media_type());
self.media_queries.is_empty() ||
self.media_queries.iter().any(|mq| {
let media_match = mq.media_type.matches(device.media_type());
// Check if the media condition match.
let query_match = media_match && mq
.condition
.as_ref()
.map_or(true, |c| c.matches(device, quirks_mode));
// Check if the media condition match.
let query_match = media_match &&
mq.condition
.as_ref()
.map_or(true, |c| c.matches(device, quirks_mode));
// Apply the logical NOT qualifier to the result
match mq.qualifier {
Some(Qualifier::Not) => !query_match,
_ => query_match,
}
})
// Apply the logical NOT qualifier to the result
match mq.qualifier {
Some(Qualifier::Not) => !query_match,
_ => query_match,
}
})
}
/// Whether this `MediaList` contains no media queries.

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

@ -22,11 +22,11 @@
#![deny(missing_docs)]
use arrayvec::ArrayVec;
use crate::context::{StyleContext, ThreadLocalStyleContext};
use crate::dom::{OpaqueNode, SendNode, TElement};
use crate::scoped_tls::ScopedTLS;
use crate::traversal::{DomTraversal, PerLevelTraversalData};
use arrayvec::ArrayVec;
use itertools::Itertools;
use rayon;
use smallvec::SmallVec;

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

@ -4,7 +4,6 @@
//! Servo's media-query device and expression representation.
use app_units::Au;
use crate::custom_properties::CssEnvironment;
use crate::media_queries::media_feature::{AllowsRanges, ParsingRequirements};
use crate::media_queries::media_feature::{Evaluator, MediaFeatureDescription};
@ -14,6 +13,7 @@ use crate::properties::ComputedValues;
use crate::values::computed::font::FontSize;
use crate::values::computed::CSSPixelLength;
use crate::values::KeyframesName;
use app_units::Au;
use cssparser::RGBA;
use euclid::{Size2D, TypedScale, TypedSize2D};
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering};

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

@ -457,7 +457,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
parser: &mut CssParser<'i, 't>,
) -> Result<NonTSPseudoClass, ParseError<'i>> {
use self::NonTSPseudoClass::*;
let pseudo_class = match_ignore_ascii_case!{ &name,
let pseudo_class = match_ignore_ascii_case! { &name,
"lang" => {
Lang(parser.expect_ident_or_string()?.as_ref().into())
}

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

@ -4,10 +4,10 @@
//! Different objects protected by the same lock
#[cfg(feature = "gecko")]
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use crate::str::{CssString, CssStringWriter};
use crate::stylesheets::Origin;
#[cfg(feature = "gecko")]
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
#[cfg(feature = "servo")]
use parking_lot::RwLock;
use servo_arc::Arc;

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

@ -64,7 +64,6 @@
//! selectors are effectively stripped off, so that matching them all against
//! elements makes sense.
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use crate::applicable_declarations::ApplicableDeclarationBlock;
use crate::bloom::StyleBloom;
use crate::context::{SelectorFlagsMap, SharedStyleContext, StyleContext};
@ -75,6 +74,7 @@ use crate::rule_tree::StrongRuleNode;
use crate::style_resolver::{PrimaryStyle, ResolvedElementStyles};
use crate::stylist::Stylist;
use crate::Atom;
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
use owning_ref::OwningHandle;
use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode};
use selectors::NthIndexCache;

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

@ -5,7 +5,6 @@
//! A struct to encapsulate all the style fixups and flags propagations
//! a computed style needs in order for it to adhere to the CSS spec.
use app_units::Au;
use crate::dom::TElement;
use crate::properties::computed_value_flags::ComputedValueFlags;
use crate::properties::longhands::display::computed_value::T as Display;
@ -13,6 +12,7 @@ use crate::properties::longhands::float::computed_value::T as Float;
use crate::properties::longhands::overflow_x::computed_value::T as Overflow;
use crate::properties::longhands::position::computed_value::T as Position;
use crate::properties::{self, ComputedValues, StyleBuilder};
use app_units::Au;
/// A struct that implements all the adjustment methods.
///
@ -190,12 +190,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
let is_root = self.style.pseudo.is_none() && element.map_or(false, |e| e.is_root());
blockify_if!(is_root);
if !self.skip_item_display_fixup(element) {
blockify_if!(
layout_parent_style
.get_box()
.clone_display()
.is_item_container()
);
blockify_if!(layout_parent_style
.get_box()
.clone_display()
.is_item_container());
}
let is_item_or_root = blockify;
@ -220,11 +218,12 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
pub fn set_bits(&mut self) {
let display = self.style.get_box().clone_display();
if !display.is_contents() && !self
.style
.get_text()
.clone_text_decoration_line()
.is_empty()
if !display.is_contents() &&
!self
.style
.get_text()
.clone_text_decoration_line()
.is_empty()
{
self.style
.flags
@ -299,10 +298,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
#[cfg(feature = "gecko")]
fn adjust_for_text_in_ruby(&mut self) {
let parent_display = self.style.get_parent_box().clone_display();
if parent_display.is_ruby_type() || self
.style
.get_parent_flags()
.contains(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK)
if parent_display.is_ruby_type() ||
self.style
.get_parent_flags()
.contains(ComputedValueFlags::SHOULD_SUPPRESS_LINEBREAK)
{
self.style
.flags

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

@ -70,11 +70,7 @@ impl Parse for SingleValue {
match *input.next()? {
Token::Number {
int_value: Some(v), ..
}
if v >= 0 =>
{
Ok(SingleValue(v as u32))
},
} if v >= 0 => Ok(SingleValue(v as u32)),
ref t => Err(location.new_unexpected_token_error(t.clone())),
}
}
@ -103,22 +99,14 @@ impl Parse for PairValues {
let first = match *input.next()? {
Token::Number {
int_value: Some(a), ..
}
if a >= 0 =>
{
a as u32
},
} if a >= 0 => a as u32,
ref t => return Err(location.new_unexpected_token_error(t.clone())),
};
let location = input.current_source_location();
match input.next() {
Ok(&Token::Number {
int_value: Some(b), ..
})
if b >= 0 =>
{
Ok(PairValues(first, Some(b as u32)))
},
}) if b >= 0 => Ok(PairValues(first, Some(b as u32))),
// It can't be anything other than number.
Ok(t) => Err(location.new_unexpected_token_error(t.clone())),
// It can be just one value.
@ -157,11 +145,9 @@ impl Parse for VectorValues {
match input.next() {
Ok(&Token::Number {
int_value: Some(a), ..
})
if a >= 0 =>
{
}) if a >= 0 => {
vec.push(a as u32);
}
},
// It can't be anything other than number.
Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
Err(_) => break,

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

@ -141,11 +141,7 @@ impl KeyframePercentage {
Token::Percentage {
unit_value: percentage,
..
}
if percentage >= 0. && percentage <= 1. =>
{
Ok(KeyframePercentage::new(percentage))
},
} if percentage >= 0. && percentage <= 1. => Ok(KeyframePercentage::new(percentage)),
_ => Err(input.new_unexpected_token_error(token)),
}
}
@ -600,7 +596,7 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for KeyframeDeclarationParser<'a, 'b> {
let id = match PropertyId::parse(&name, self.context) {
Ok(id) => id,
Err(()) => {
return Err(input.new_custom_error(StyleParseErrorKind::UnknownProperty(name)))
return Err(input.new_custom_error(StyleParseErrorKind::UnknownProperty(name)));
},
};

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

@ -107,9 +107,10 @@ impl<'b> TopLevelRuleParser<'b> {
// If there's anything that isn't a namespace rule (or import rule, but
// we checked that already at the beginning), reject with a
// StateError.
if new_state == State::Namespaces && ctx.rule_list[ctx.index..]
.iter()
.any(|r| !matches!(*r, CssRule::Namespace(..)))
if new_state == State::Namespaces &&
ctx.rule_list[ctx.index..]
.iter()
.any(|r| !matches!(*r, CssRule::Namespace(..)))
{
self.dom_error = Some(RulesMutateError::InvalidState);
return false;

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

@ -145,7 +145,7 @@ impl SupportsCondition {
function: &str,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
match_ignore_ascii_case!{ function,
match_ignore_ascii_case! { function,
// Although this is an internal syntax, it is not necessary
// to check parsing context as far as we accept any
// unexpected token as future syntax, and evaluate it to
@ -350,9 +350,8 @@ impl RawSelector {
use crate::selector_parser::PseudoElement;
use selectors::parser::Component;
let has_any_unknown_webkit_pseudo = selector.has_pseudo_element() && selector
.iter_raw_match_order()
.any(|component| {
let has_any_unknown_webkit_pseudo = selector.has_pseudo_element() &&
selector.iter_raw_match_order().any(|component| {
matches!(
*component,
Component::PseudoElement(PseudoElement::UnknownWebkit(..))

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

@ -7,7 +7,6 @@
//! [at]: https://drafts.csswg.org/css-device-adapt/#atviewport-rule
//! [meta]: https://drafts.csswg.org/css-device-adapt/#viewport-meta
use app_units::Au;
use crate::context::QuirksMode;
use crate::error_reporting::ContextualParseError;
use crate::font_metrics::get_metrics_provider_for_product;
@ -20,6 +19,7 @@ use crate::str::CssStringWriter;
use crate::stylesheets::{Origin, StylesheetInDocument};
use crate::values::computed::{Context, ToComputedValue};
use crate::values::specified::{LengthOrPercentageOrAuto, NoCalcLength, ViewportPercentageLength};
use app_units::Au;
use cssparser::CowRcStr;
use cssparser::{parse_important, AtRuleParser, DeclarationListParser, DeclarationParser, Parser};
use euclid::TypedSize2D;

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

@ -355,10 +355,7 @@ pub struct Stylist {
stylesheets: StylistStylesheetSet,
/// If true, the quirks-mode stylesheet is applied.
#[cfg_attr(
feature = "servo",
ignore_malloc_size_of = "defined in selectors"
)]
#[cfg_attr(feature = "servo", ignore_malloc_size_of = "defined in selectors")]
quirks_mode: QuirksMode,
/// Selector maps for all of the style sheets in the stylist, after
@ -1572,9 +1569,8 @@ impl<'a> SelectorVisitor for StylistSelectorVisitor<'a> {
// Also, note that this call happens before we visit any of the simple
// selectors in the next ComplexSelector, so we can use this to skip
// looking at them.
self.passed_rightmost_selector =
self.passed_rightmost_selector ||
!matches!(combinator, None | Some(Combinator::PseudoElement));
self.passed_rightmost_selector = self.passed_rightmost_selector ||
!matches!(combinator, None | Some(Combinator::PseudoElement));
true
}
@ -1591,9 +1587,8 @@ impl<'a> SelectorVisitor for StylistSelectorVisitor<'a> {
}
fn visit_simple_selector(&mut self, s: &Component<SelectorImpl>) -> bool {
self.needs_revalidation =
self.needs_revalidation ||
component_needs_revalidation(s, self.passed_rightmost_selector);
self.needs_revalidation = self.needs_revalidation ||
component_needs_revalidation(s, self.passed_rightmost_selector);
match *s {
Component::NonTSPseudoClass(ref p) => {
@ -2026,10 +2021,10 @@ impl CascadeData {
debug!("Found valid keyframes rule: {:?}", *keyframes_rule);
// Don't let a prefixed keyframes animation override a non-prefixed one.
let needs_insertion = keyframes_rule.vendor_prefix.is_none() || self
.animations
.get(keyframes_rule.name.as_atom())
.map_or(true, |rule| rule.vendor_prefix.is_some());
let needs_insertion = keyframes_rule.vendor_prefix.is_none() ||
self.animations
.get(keyframes_rule.name.as_atom())
.map_or(true, |rule| rule.vendor_prefix.is_some());
if needs_insertion {
let animation = KeyframesAnimation::from_keyframes(
&keyframes_rule.keyframes,

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

@ -208,11 +208,11 @@ pub trait DomTraversal<E: TElement>: Sync {
// animation-only restyle hint or recascade.
if traversal_flags.for_animation_only() {
return data.map_or(false, |d| d.has_styles()) &&
(el.has_animation_only_dirty_descendants() || data
.as_ref()
.unwrap()
.hint
.has_animation_hint_or_recascade());
(el.has_animation_only_dirty_descendants() ||
data.as_ref()
.unwrap()
.hint
.has_animation_hint_or_recascade());
}
// Non-incremental layout visits every node.
@ -516,9 +516,8 @@ pub fn recalc_style_at<E, D, F>(
!child_cascade_requirement.can_skip_cascade() ||
is_servo_nonincremental_layout();
traverse_children =
traverse_children &&
!traversal.should_cull_subtree(context, element, &data, is_initial_style);
traverse_children = traverse_children &&
!traversal.should_cull_subtree(context, element, &data, is_initial_style);
// Examine our children, and enqueue the appropriate ones for traversal.
if traverse_children {

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

@ -8,7 +8,6 @@
//! computed values and need yet another intermediate representation. This
//! module's raison d'être is to ultimately contain all these types.
use app_units::Au;
use crate::properties::PropertyId;
use crate::values::computed::length::CalcLengthOrPercentage;
use crate::values::computed::url::ComputedUrl;
@ -16,6 +15,7 @@ use crate::values::computed::Angle as ComputedAngle;
use crate::values::computed::Image;
use crate::values::CSSFloat;
use crate::values::specified::SVGPathData;
use app_units::Au;
use euclid::{Point2D, Size2D};
use smallvec::SmallVec;
use std::cmp;

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

@ -4,7 +4,6 @@
//! Computed types for CSS values related to borders.
use app_units::Au;
use crate::values::generics::NonNegative;
use crate::values::computed::length::{NonNegativeLengthOrPercentage, NonNegativeLength};
use crate::values::computed::{NonNegativeNumber, NonNegativeNumberOrPercentage};
@ -15,6 +14,7 @@ use crate::values::generics::border::BorderRadius as GenericBorderRadius;
use crate::values::generics::border::BorderSpacing as GenericBorderSpacing;
use crate::values::generics::rect::Rect;
use crate::values::generics::size::Size;
use app_units::Au;
pub use crate::values::specified::border::BorderImageRepeat;

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

@ -4,8 +4,6 @@
//! Computed values for font properties
use app_units::Au;
use byteorder::{BigEndian, ByteOrder};
#[cfg(feature = "gecko")]
use crate::gecko_bindings::sugar::refptr::RefPtr;
#[cfg(feature = "gecko")]
@ -19,6 +17,8 @@ use crate::values::specified::font::{self as specified, MAX_FONT_WEIGHT, MIN_FON
use crate::values::specified::length::{FontBaseSize, NoCalcLength};
use crate::values::CSSFloat;
use crate::Atom;
use app_units::Au;
use byteorder::{BigEndian, ByteOrder};
use cssparser::{serialize_identifier, CssStringWriter, Parser};
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};

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

@ -5,7 +5,6 @@
//! `<length>` computed values, and related ones.
use super::{Context, Number, Percentage, ToComputedValue};
use app_units::Au;
use crate::values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
use crate::values::generics::length::MaxLength as GenericMaxLength;
@ -15,6 +14,7 @@ use crate::values::generics::NonNegative;
use crate::values::specified::length::ViewportPercentageLength;
use crate::values::specified::length::{AbsoluteLength, FontBaseSize, FontRelativeLength};
use crate::values::{specified, Auto, CSSFloat, Either, IsAuto, Normal};
use app_units::Au;
use ordered_float::NotNan;
use std::fmt::{self, Write};
use std::ops::{Add, Neg};

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

@ -291,11 +291,7 @@ where
(
&ShapeSource::Shape(ref this, ref this_box),
&ShapeSource::Shape(ref other, ref other_box),
)
if this_box == other_box =>
{
this.compute_squared_distance(other)
},
) if this_box == other_box => this.compute_squared_distance(other),
(&ShapeSource::Path(ref this), &ShapeSource::Path(ref other))
if this.fill == other.fill =>
{

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

@ -4,9 +4,9 @@
//! Generic types for font stuff.
use crate::parser::{Parse, ParserContext};
use app_units::Au;
use byteorder::{BigEndian, ReadBytesExt};
use crate::parser::{Parse, ParserContext};
use cssparser::Parser;
use num_traits::One;
use std::fmt::{self, Write};

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

@ -4,10 +4,10 @@
//! Generic types for text properties.
use app_units::Au;
use crate::parser::ParserContext;
use crate::values::animated::{Animate, Procedure, ToAnimatedZero};
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
use app_units::Au;
use cssparser::Parser;
use style_traits::ParseError;

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

@ -4,13 +4,13 @@
//! Generic types for CSS values that are related to transformations.
use app_units::Au;
use crate::values::computed::length::Length as ComputedLength;
use crate::values::computed::length::LengthOrPercentage as ComputedLengthOrPercentage;
use crate::values::specified::angle::Angle as SpecifiedAngle;
use crate::values::specified::length::Length as SpecifiedLength;
use crate::values::specified::length::LengthOrPercentage as SpecifiedLengthOrPercentage;
use crate::values::{computed, CSSFloat};
use app_units::Au;
use euclid::{self, Rect, Transform3D};
use num_traits::Zero;
use std::fmt::{self, Write};

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

@ -93,10 +93,7 @@ where
}
/// Convenience void type to disable some properties and values through types.
#[cfg_attr(
feature = "servo",
derive(Deserialize, MallocSizeOf, Serialize)
)]
#[cfg_attr(feature = "servo", derive(Deserialize, MallocSizeOf, Serialize))]
#[derive(
Clone, Copy, Debug, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToComputedValue, ToCss,
)]

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

@ -193,7 +193,7 @@ impl Angle {
AllowUnitlessZeroAngle::No => Err(()),
},
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {
return input.parse_nested_block(|i| CalcNode::parse_angle(context, i))
return input.parse_nested_block(|i| CalcNode::parse_angle(context, i));
},
_ => Err(()),
}

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

@ -218,10 +218,7 @@ impl Display {
// Special handling for contents and list-item on the root
// element for Gecko.
#[cfg(feature = "gecko")]
Display::Contents | Display::ListItem if _is_root_element =>
{
Display::Block
},
Display::Contents | Display::ListItem if _is_root_element => Display::Block,
// These are not changed by blockification.
Display::None | Display::Block | Display::Flex | Display::ListItem | Display::Table => {
@ -747,7 +744,9 @@ impl Parse for Contain {
let flag = match flag {
Some(flag) if !result.contains(flag) => flag,
_ => {
return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name)))
return Err(
input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name))
);
},
};
result.insert(flag);
@ -826,7 +825,7 @@ impl Parse for TransitionProperty {
location,
ident,
&["none"],
)?))
)?));
},
};
@ -1309,7 +1308,7 @@ impl BreakBetween {
Ok(v) => v,
Err(()) => {
return Err(location
.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())))
.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(ident.clone())));
},
};
match break_value {

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

@ -180,7 +180,7 @@ impl CalcNode {
) => {
return NoCalcLength::parse_dimension(context, value, unit)
.map(CalcNode::Length)
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
},
(
&Token::Dimension {
@ -204,7 +204,7 @@ impl CalcNode {
},
(&Token::Percentage { unit_value, .. }, CalcUnit::LengthOrPercentage) |
(&Token::Percentage { unit_value, .. }, CalcUnit::Percentage) => {
return Ok(CalcNode::Percentage(unit_value))
return Ok(CalcNode::Percentage(unit_value));
},
(&Token::ParenthesisBlock, _) => {},
(&Token::Function(ref name), _) if name.eq_ignore_ascii_case("calc") => {},

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

@ -181,7 +181,7 @@ impl Parse for Content {
None => {
return Err(input.new_custom_error(
StyleParseErrorKind::UnexpectedFunction(name.clone()),
))
));
},
}
},

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

@ -4,8 +4,6 @@
//! Specified values for font properties
use app_units::Au;
use byteorder::{BigEndian, ByteOrder};
#[cfg(feature = "gecko")]
use crate::gecko_bindings::bindings;
use crate::parser::{Parse, ParserContext};
@ -22,6 +20,8 @@ use crate::values::specified::{AllowQuirks, Angle, Integer, LengthOrPercentage};
use crate::values::specified::{NoCalcLength, Number, Percentage};
use crate::values::CustomIdent;
use crate::Atom;
use app_units::Au;
use byteorder::{BigEndian, ByteOrder};
use cssparser::{Parser, Token};
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};

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

@ -22,11 +22,7 @@ pub fn parse_flex<'i, 't>(input: &mut Parser<'i, 't>) -> Result<CSSFloat, ParseE
match *input.next()? {
Token::Dimension {
value, ref unit, ..
}
if unit.eq_ignore_ascii_case("fr") && value.is_sign_positive() =>
{
Ok(value)
},
} if unit.eq_ignore_ascii_case("fr") && value.is_sign_positive() => Ok(value),
ref t => Err(location.new_unexpected_token_error(t.clone())),
}
}

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

@ -262,7 +262,7 @@ impl Parse for Gradient {
let (shape, repeating, mut compat_mode) = match result {
Some(result) => result,
None => {
return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedFunction(func)))
return Err(input.new_custom_error(StyleParseErrorKind::UnexpectedFunction(func)));
},
};
@ -792,7 +792,7 @@ impl LineDirection {
CompatMode::WebKit if to_ident.is_ok() => {
return Err(
i.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("to".into()))
)
);
},
_ => {},
}

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

@ -7,7 +7,6 @@
//! [length]: https://drafts.csswg.org/css-values/#lengths
use super::{AllowQuirks, Number, Percentage, ToComputedValue};
use app_units::Au;
use crate::font_metrics::FontMetricsQueryResult;
use crate::parser::{Parse, ParserContext};
use crate::values::computed::{self, CSSPixelLength, Context, ExtremumLength};
@ -17,6 +16,7 @@ use crate::values::generics::transform::IsZeroLength;
use crate::values::generics::NonNegative;
use crate::values::specified::calc::CalcNode;
use crate::values::{Auto, CSSFloat, Either, IsAuto, Normal};
use app_units::Au;
use cssparser::{Parser, Token};
use euclid::Size2D;
use std::cmp;
@ -601,12 +601,10 @@ impl Length {
match *token {
Token::Dimension {
value, ref unit, ..
}
if num_context.is_ok(context.parsing_mode, value) =>
{
} if num_context.is_ok(context.parsing_mode, value) => {
return NoCalcLength::parse_dimension(context, value, unit)
.map(Length::NoCalc)
.map_err(|()| location.new_unexpected_token_error(token.clone()))
.map_err(|()| location.new_unexpected_token_error(token.clone()));
},
Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => {
if value != 0. &&
@ -800,20 +798,18 @@ impl LengthOrPercentage {
match *token {
Token::Dimension {
value, ref unit, ..
}
if num_context.is_ok(context.parsing_mode, value) =>
{
} if num_context.is_ok(context.parsing_mode, value) => {
return NoCalcLength::parse_dimension(context, value, unit)
.map(LengthOrPercentage::Length)
.map_err(|()| location.new_unexpected_token_error(token.clone()))
.map_err(|()| location.new_unexpected_token_error(token.clone()));
},
Token::Percentage { unit_value, .. }
if num_context.is_ok(context.parsing_mode, unit_value) =>
{
return Ok(LengthOrPercentage::Percentage(computed::Percentage(
unit_value,
)))
},
)));
}
Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => {
if value != 0. &&
!context.parsing_mode.allows_unitless_lengths() &&
@ -932,20 +928,18 @@ impl LengthOrPercentageOrAuto {
match *token {
Token::Dimension {
value, ref unit, ..
}
if num_context.is_ok(context.parsing_mode, value) =>
{
} if num_context.is_ok(context.parsing_mode, value) => {
return NoCalcLength::parse_dimension(context, value, unit)
.map(LengthOrPercentageOrAuto::Length)
.map_err(|()| location.new_unexpected_token_error(token.clone()))
.map_err(|()| location.new_unexpected_token_error(token.clone()));
},
Token::Percentage { unit_value, .. }
if num_context.is_ok(context.parsing_mode, unit_value) =>
{
return Ok(LengthOrPercentageOrAuto::Percentage(computed::Percentage(
unit_value,
)))
},
)));
}
Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => {
if value != 0. &&
!context.parsing_mode.allows_unitless_lengths() &&
@ -958,7 +952,7 @@ impl LengthOrPercentageOrAuto {
)));
},
Token::Ident(ref value) if value.eq_ignore_ascii_case("auto") => {
return Ok(LengthOrPercentageOrAuto::Auto)
return Ok(LengthOrPercentageOrAuto::Auto);
},
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {},
_ => return Err(location.new_unexpected_token_error(token.clone())),
@ -1098,20 +1092,18 @@ impl LengthOrPercentageOrNone {
match *token {
Token::Dimension {
value, ref unit, ..
}
if num_context.is_ok(context.parsing_mode, value) =>
{
} if num_context.is_ok(context.parsing_mode, value) => {
return NoCalcLength::parse_dimension(context, value, unit)
.map(LengthOrPercentageOrNone::Length)
.map_err(|()| location.new_unexpected_token_error(token.clone()))
.map_err(|()| location.new_unexpected_token_error(token.clone()));
},
Token::Percentage { unit_value, .. }
if num_context.is_ok(context.parsing_mode, unit_value) =>
{
return Ok(LengthOrPercentageOrNone::Percentage(computed::Percentage(
unit_value,
)))
},
)));
}
Token::Number { value, .. } if num_context.is_ok(context.parsing_mode, value) => {
if value != 0. &&
!context.parsing_mode.allows_unitless_lengths() &&
@ -1125,7 +1117,7 @@ impl LengthOrPercentageOrNone {
},
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {},
Token::Ident(ref value) if value.eq_ignore_ascii_case("none") => {
return Ok(LengthOrPercentageOrNone::None)
return Ok(LengthOrPercentageOrNone::None);
},
_ => return Err(location.new_unexpected_token_error(token.clone())),
}

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

@ -138,7 +138,7 @@ fn parse_number_with_clamping_mode<'i, 't>(
return Ok(Number {
value: value.min(f32::MAX).max(f32::MIN),
calc_clamping_mode: None,
})
});
},
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {},
ref t => return Err(location.new_unexpected_token_error(t.clone())),
@ -828,7 +828,7 @@ impl Attr {
Some(ns) => ns,
None => {
return Err(location
.new_custom_error(StyleParseErrorKind::UnspecifiedError))
.new_custom_error(StyleParseErrorKind::UnspecifiedError));
},
};
Some((prefix, ns))

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

@ -4,13 +4,13 @@
//! https://html.spec.whatwg.org/multipage/#source-size-list
use app_units::Au;
#[cfg(feature = "gecko")]
use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use crate::media_queries::{Device, MediaCondition};
use crate::parser::{Parse, ParserContext};
use crate::values::computed::{self, ToComputedValue};
use crate::values::specified::{Length, NoCalcLength, ViewportPercentageLength};
use app_units::Au;
use cssparser::{Delimiter, Parser, Token};
use selectors::context::QuirksMode;
use style_traits::ParseError;
@ -118,7 +118,7 @@ impl SourceSizeList {
return Self {
source_sizes,
value: Some(value),
}
};
},
Ok(SourceSizeOrLength::SourceSize(source_size)) => {
source_sizes.push(source_size);

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

@ -91,8 +91,7 @@ impl Parse for LineHeight {
match ident {
ref ident if ident.eq_ignore_ascii_case("normal") => Ok(GenericLineHeight::Normal),
#[cfg(feature = "gecko")]
ref ident if ident.eq_ignore_ascii_case("-moz-block-height") =>
{
ref ident if ident.eq_ignore_ascii_case("-moz-block-height") => {
Ok(GenericLineHeight::MozBlockHeight)
},
ident => {

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

@ -92,12 +92,10 @@ impl Time {
// ParsingMode::DEFAULT directly.
Ok(&Token::Dimension {
value, ref unit, ..
})
if clamping_mode.is_ok(ParsingMode::DEFAULT, value) =>
{
}) if clamping_mode.is_ok(ParsingMode::DEFAULT, value) => {
return Time::parse_dimension(value, unit, /* from_calc = */ false)
.map_err(|()| location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
},
Ok(&Token::Function(ref name)) if name.eq_ignore_ascii_case("calc") => {},
Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
Err(e) => return Err(e.into()),

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

@ -172,9 +172,7 @@ fn path_to_ident(path: &Path) -> Option<&Ident> {
Path {
leading_colon: None,
ref segments,
}
if segments.len() == 1 =>
{
} if segments.len() == 1 => {
if segments[0].arguments.is_empty() {
Some(&segments[0].ident)
} else {

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

@ -43,7 +43,7 @@ pub fn derive(input: DeriveInput) -> TokenStream {
saw_condition |= parse_attrs.condition.is_some();
let condition = match parse_attrs.condition {
Some(ref p) => quote! { if #p(context) },
None => quote!{},
None => quote! {},
};
let mut body = quote! {

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

@ -48,10 +48,7 @@ pub enum DevicePixel {}
/// Represents a mobile style pinch zoom factor.
/// TODO(gw): Once WR supports pinch zoom, use a type directly from webrender_api.
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(
feature = "servo",
derive(Deserialize, Serialize, MallocSizeOf)
)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, MallocSizeOf))]
pub struct PinchZoomFactor(f32);
impl PinchZoomFactor {

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

@ -28,10 +28,7 @@ define_css_keyword_enum! {
///
/// <https://drafts.csswg.org/css-device-adapt/#viewport-desc>
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(
feature = "servo",
derive(Deserialize, Serialize, MallocSizeOf)
)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, MallocSizeOf))]
pub struct ViewportConstraints {
/// Width and height:
/// * https://drafts.csswg.org/css-device-adapt/#width-desc