Skip to content

Commit

Permalink
style: Rustfmt recent changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Jan 6, 2019
1 parent 152ef2e commit 5f173c4
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 43 deletions.
19 changes: 13 additions & 6 deletions components/style/gecko/conversions.rs
Expand Up @@ -24,11 +24,11 @@ use crate::values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
use crate::values::computed::{Integer, LengthOrPercentage};
use crate::values::computed::{LengthOrPercentageOrAuto, NonNegativeLengthOrPercentageOrAuto};
use crate::values::computed::{Percentage, TextAlign};
use crate::values::generics::NonNegative;
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 crate::values::generics::NonNegative;
use app_units::Au;
use std::f32::consts::PI;

Expand Down Expand Up @@ -677,11 +677,11 @@ pub mod basic_shape {
use crate::values::generics::basic_shape::{
BasicShape as GenericBasicShape, InsetRect, Polygon,
};
use crate::values::generics::NonNegative;
use crate::values::generics::basic_shape::{Circle, Ellipse, Path, PolygonCoord};
use crate::values::generics::basic_shape::{GeometryBox, ShapeBox, ShapeSource};
use crate::values::generics::border::BorderRadius as GenericBorderRadius;
use crate::values::generics::rect::Rect;
use crate::values::generics::NonNegative;
use crate::values::specified::SVGPathData;
use std::borrow::Borrow;

Expand Down Expand Up @@ -841,10 +841,17 @@ pub mod basic_shape {
fn from(other: &'a nsStyleCorners) -> Self {
let get_corner = |index| {
BorderCornerRadius::new(
NonNegative(LengthOrPercentage::from_gecko_style_coord(&other.data_at(index))
.expect("<border-radius> should be a length, percentage, or calc value")),
NonNegative(LengthOrPercentage::from_gecko_style_coord(&other.data_at(index + 1))
.expect("<border-radius> should be a length, percentage, or calc value")),
NonNegative(
LengthOrPercentage::from_gecko_style_coord(&other.data_at(index)).expect(
"<border-radius> should be a length, percentage, or calc value",
),
),
NonNegative(
LengthOrPercentage::from_gecko_style_coord(&other.data_at(index + 1))
.expect(
"<border-radius> should be a length, percentage, or calc value",
),
),
)
};

Expand Down
12 changes: 3 additions & 9 deletions components/style/gecko/data.rs
Expand Up @@ -7,8 +7,8 @@
use crate::context::QuirksMode;
use crate::dom::TElement;
use crate::gecko_bindings::bindings::{self, RawServoStyleSet};
use crate::gecko_bindings::structs::{StyleSheet as DomStyleSheet, StyleSheetInfo};
use crate::gecko_bindings::structs::{RawGeckoPresContextBorrowed, ServoStyleSetSizes};
use crate::gecko_bindings::structs::{StyleSheet as DomStyleSheet, StyleSheetInfo};
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
use crate::invalidation::media_queries::{MediaListKey, ToMediaListKey};
use crate::media_queries::{Device, MediaList};
Expand Down Expand Up @@ -150,8 +150,7 @@ impl PerDocumentStyleData {
// right now not always honored, see bug 1405543...
//
// Should we just force XBL Stylists to be NoQuirks?
let quirks_mode =
unsafe { (*device.pres_context().mDocument.mRawPtr).mCompatMode };
let quirks_mode = unsafe { (*device.pres_context().mDocument.mRawPtr).mCompatMode };

PerDocumentStyleData(AtomicRefCell::new(PerDocumentStyleDataImpl {
stylist: Stylist::new(device, quirks_mode.into()),
Expand Down Expand Up @@ -192,12 +191,7 @@ impl PerDocumentStyleDataImpl {
/// Returns whether visited styles are enabled.
#[inline]
pub fn visited_styles_enabled(&self) -> bool {
let doc = self
.stylist
.device()
.pres_context()
.mDocument
.mRawPtr;
let doc = self.stylist.device().pres_context().mDocument.mRawPtr;
unsafe { bindings::Gecko_VisitedStylesEnabled(doc) }
}

Expand Down
3 changes: 1 addition & 2 deletions components/style/gecko/media_features.rs
Expand Up @@ -320,8 +320,7 @@ fn eval_overflow_block(device: &Device, query_value: Option<OverflowBlock>) -> b
};

match query_value {
OverflowBlock::None |
OverflowBlock::OptionalPaged => false,
OverflowBlock::None | OverflowBlock::OptionalPaged => false,
OverflowBlock::Scroll => scrolling,
OverflowBlock::Paged => !scrolling,
}
Expand Down
4 changes: 1 addition & 3 deletions components/style/gecko/values.rs
Expand Up @@ -286,9 +286,7 @@ impl GeckoStyleCoordConvertible for ComputedShapeRadius {
None
}
},
_ => {
GeckoStyleCoordConvertible::from_gecko_style_coord(coord).map(ShapeRadius::Length)
},
_ => GeckoStyleCoordConvertible::from_gecko_style_coord(coord).map(ShapeRadius::Length),
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions components/style/gecko/wrapper.rs
Expand Up @@ -45,8 +45,8 @@ use crate::gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWThe
use crate::gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
use crate::gecko_bindings::structs;
use crate::gecko_bindings::structs::nsChangeHint;
use crate::gecko_bindings::structs::Document_DocumentTheme as DocumentTheme;
use crate::gecko_bindings::structs::nsRestyleHint;
use crate::gecko_bindings::structs::Document_DocumentTheme as DocumentTheme;
use crate::gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel;
use crate::gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT;
use crate::gecko_bindings::structs::ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO;
Expand Down Expand Up @@ -1243,10 +1243,7 @@ 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
device.pres_context().mDocument.mRawPtr
}

fn style_attribute(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> {
Expand Down
5 changes: 4 additions & 1 deletion components/style/gecko_bindings/sugar/origin_flags.rs
Expand Up @@ -10,7 +10,10 @@ use crate::stylesheets::OriginSet;
/// Checks that the values for OriginFlags are the ones we expect.
pub fn assert_flags_match() {
use crate::stylesheets::origin::*;
debug_assert_eq!(OriginFlags::UserAgent.0, OriginSet::ORIGIN_USER_AGENT.bits());
debug_assert_eq!(
OriginFlags::UserAgent.0,
OriginSet::ORIGIN_USER_AGENT.bits()
);
debug_assert_eq!(OriginFlags::Author.0, OriginSet::ORIGIN_AUTHOR.bits());
debug_assert_eq!(OriginFlags::User.0, OriginSet::ORIGIN_USER.bits());
}
Expand Down
8 changes: 6 additions & 2 deletions components/style/invalidation/element/restyle_hints.rs
Expand Up @@ -205,13 +205,17 @@ impl From<nsRestyleHint> for RestyleHint {
hint.insert(RestyleHint::RESTYLE_SELF);
}

if (raw.0 & (nsRestyleHint::eRestyle_Subtree.0 | nsRestyleHint::eRestyle_SomeDescendants.0)) != 0 {
if (raw.0 & (nsRestyleHint::eRestyle_Subtree.0 | nsRestyleHint::eRestyle_SomeDescendants.0)) !=
0
{
raw.0 &= !nsRestyleHint::eRestyle_Subtree.0;
raw.0 &= !nsRestyleHint::eRestyle_SomeDescendants.0;
hint.insert(RestyleHint::RESTYLE_DESCENDANTS);
}

if (raw.0 & (nsRestyleHint::eRestyle_ForceDescendants.0 | nsRestyleHint::eRestyle_Force.0)) != 0 {
if (raw.0 & (nsRestyleHint::eRestyle_ForceDescendants.0 | nsRestyleHint::eRestyle_Force.0)) !=
0
{
raw.0 &= !nsRestyleHint::eRestyle_Force.0;
hint.insert(RestyleHint::RECASCADE_SELF);
}
Expand Down
3 changes: 1 addition & 2 deletions components/style/rule_collector.rs
Expand Up @@ -260,8 +260,7 @@ where

let cascade_data = containing_shadow.style_data();
let host = containing_shadow.host();
if let Some(map) = cascade_data.and_then(|data| data.normal_rules(self.pseudo_element))
{
if let Some(map) = cascade_data.and_then(|data| data.normal_rules(self.pseudo_element)) {
self.collect_rules_in_shadow_tree(host, map, CascadeLevel::SameTreeAuthorNormal);
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/style/stylist.rs
Expand Up @@ -17,7 +17,7 @@ use crate::media_queries::Device;
use crate::properties::{self, CascadeMode, ComputedValues};
use crate::properties::{AnimationRules, PropertyDeclarationBlock};
use crate::rule_cache::{RuleCache, RuleCacheConditions};
use crate::rule_collector::{RuleCollector, containing_shadow_ignoring_svg_use};
use crate::rule_collector::{containing_shadow_ignoring_svg_use, RuleCollector};
use crate::rule_tree::{CascadeLevel, RuleTree, ShadowCascadeOrder, StrongRuleNode, StyleSource};
use crate::selector_map::{PrecomputedHashMap, PrecomputedHashSet, SelectorMap, SelectorMapEntry};
use crate::selector_parser::{PerPseudoElementMap, PseudoElement, SelectorImpl, SnapshotMap};
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/animated/mod.rs
Expand Up @@ -13,8 +13,8 @@ use crate::values::computed::length::CalcLengthOrPercentage;
use crate::values::computed::url::ComputedUrl;
use crate::values::computed::Angle as ComputedAngle;
use crate::values::computed::Image;
use crate::values::CSSFloat;
use crate::values::specified::SVGPathData;
use crate::values::CSSFloat;
use app_units::Au;
use euclid::{Point2D, Size2D};
use smallvec::SmallVec;
Expand Down
7 changes: 4 additions & 3 deletions components/style/values/computed/border.rs
Expand Up @@ -4,8 +4,7 @@

//! Computed types for CSS values related to borders.

use crate::values::generics::NonNegative;
use crate::values::computed::length::{NonNegativeLengthOrPercentage, NonNegativeLength};
use crate::values::computed::length::{NonNegativeLength, NonNegativeLengthOrPercentage};
use crate::values::computed::{NonNegativeNumber, NonNegativeNumberOrPercentage};
use crate::values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
use crate::values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth;
Expand All @@ -14,6 +13,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 crate::values::generics::NonNegative;
use app_units::Au;

pub use crate::values::specified::border::BorderImageRepeat;
Expand All @@ -22,7 +22,8 @@ pub use crate::values::specified::border::BorderImageRepeat;
pub type BorderImageWidth = Rect<BorderImageSideWidth>;

/// A computed value for a single side of a `border-image-width` property.
pub type BorderImageSideWidth = GenericBorderImageSideWidth<NonNegativeLengthOrPercentage, NonNegativeNumber>;
pub type BorderImageSideWidth =
GenericBorderImageSideWidth<NonNegativeLengthOrPercentage, NonNegativeNumber>;

/// A computed value for the `border-image-slice` property.
pub type BorderImageSlice = GenericBorderImageSlice<NonNegativeNumberOrPercentage>;
Expand Down
4 changes: 3 additions & 1 deletion components/style/values/computed/mod.rs
Expand Up @@ -546,7 +546,9 @@ pub enum NumberOrPercentage {
impl NumberOrPercentage {
fn clamp_to_non_negative(self) -> Self {
match self {
NumberOrPercentage::Percentage(p) => NumberOrPercentage::Percentage(p.clamp_to_non_negative()),
NumberOrPercentage::Percentage(p) => {
NumberOrPercentage::Percentage(p.clamp_to_non_negative())
},
NumberOrPercentage::Number(n) => NumberOrPercentage::Number(n.max(0.)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/specified/basic_shape.rs
Expand Up @@ -16,8 +16,8 @@ use crate::values::specified::border::BorderRadius;
use crate::values::specified::image::Image;
use crate::values::specified::position::{HorizontalPosition, Position, VerticalPosition};
use crate::values::specified::url::SpecifiedUrl;
use crate::values::specified::{LengthOrPercentage, NonNegativeLengthOrPercentage};
use crate::values::specified::SVGPathData;
use crate::values::specified::{LengthOrPercentage, NonNegativeLengthOrPercentage};
use cssparser::Parser;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
Expand Down
8 changes: 4 additions & 4 deletions components/style/values/specified/border.rs
Expand Up @@ -13,7 +13,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 crate::values::specified::length::{NonNegativeLengthOrPercentage, NonNegativeLength};
use crate::values::specified::length::{NonNegativeLength, NonNegativeLengthOrPercentage};
use crate::values::specified::{AllowQuirks, NonNegativeNumber, NonNegativeNumberOrPercentage};
use cssparser::Parser;
use std::fmt::{self, Write};
Expand Down Expand Up @@ -78,7 +78,8 @@ pub enum BorderSideWidth {
pub type BorderImageWidth = Rect<BorderImageSideWidth>;

/// A specified value for a single side of a `border-image-width` property.
pub type BorderImageSideWidth = GenericBorderImageSideWidth<NonNegativeLengthOrPercentage, NonNegativeNumber>;
pub type BorderImageSideWidth =
GenericBorderImageSideWidth<NonNegativeLengthOrPercentage, NonNegativeNumber>;

/// A specified value for the `border-image-slice` property.
pub type BorderImageSlice = GenericBorderImageSlice<NonNegativeNumberOrPercentage>;
Expand Down Expand Up @@ -116,8 +117,7 @@ impl BorderSideWidth {
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {
if let Ok(length) =
input.try(|i| NonNegativeLength::parse_quirky(context, i, allow_quirks))
if let Ok(length) = input.try(|i| NonNegativeLength::parse_quirky(context, i, allow_quirks))
{
return Ok(BorderSideWidth::Length(length));
}
Expand Down
6 changes: 5 additions & 1 deletion components/style/values/specified/length.rs
Expand Up @@ -725,7 +725,11 @@ impl NonNegativeLength {
input: &mut Parser<'i, 't>,
allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> {
Ok(NonNegative(Length::parse_non_negative_quirky(context, input, allow_quirks)?))
Ok(NonNegative(Length::parse_non_negative_quirky(
context,
input,
allow_quirks,
)?))
}
}

Expand Down
4 changes: 3 additions & 1 deletion components/style/values/specified/mod.rs
Expand Up @@ -375,7 +375,9 @@ impl Parse for NonNegativeNumberOrPercentage {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
Ok(NonNegative(NumberOrPercentage::parse_non_negative(context, input)?))
Ok(NonNegative(NumberOrPercentage::parse_non_negative(
context, input,
)?))
}
}

Expand Down

0 comments on commit 5f173c4

Please sign in to comment.