style: Rustfmt recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-10-09 12:54:35 +02:00
parent 112a68723e
commit 33d39d37a2
9 changed files with 61 additions and 50 deletions

View file

@ -42,7 +42,7 @@ impl nsStyleImage {
image_rect.left, image_rect.left,
); );
} }
} },
GenericImage::Element(ref element) => unsafe { GenericImage::Element(ref element) => unsafe {
bindings::Gecko_SetImageElement(self, element.as_ptr()); bindings::Gecko_SetImageElement(self, element.as_ptr());
}, },
@ -76,16 +76,16 @@ impl nsStyleImage {
left: rect.3, left: rect.3,
}))) })))
} }
} },
nsStyleImageType::eStyleImageType_Gradient => { nsStyleImageType::eStyleImageType_Gradient => {
let gradient: &Gradient = &**self.__bindgen_anon_1.mGradient.as_ref(); let gradient: &Gradient = &**self.__bindgen_anon_1.mGradient.as_ref();
Some(GenericImage::Gradient(Box::new(gradient.clone()))) Some(GenericImage::Gradient(Box::new(gradient.clone())))
} },
nsStyleImageType::eStyleImageType_Element => { nsStyleImageType::eStyleImageType_Element => {
use crate::gecko_string_cache::Atom; use crate::gecko_string_cache::Atom;
let atom = bindings::Gecko_GetImageElement(self); let atom = bindings::Gecko_GetImageElement(self);
Some(GenericImage::Element(Atom::from_raw(atom))) Some(GenericImage::Element(Atom::from_raw(atom)))
} },
} }
} }
@ -128,13 +128,13 @@ pub mod basic_shape {
Some(self.mReferenceBox.into()) Some(self.mReferenceBox.into())
}; };
Some(ShapeSource::Shape(shape, reference_box)) Some(ShapeSource::Shape(shape, reference_box))
} },
StyleShapeSourceType::Image => None, StyleShapeSourceType::Image => None,
StyleShapeSourceType::Path => { StyleShapeSourceType::Path => {
let path = self.to_svg_path().expect("expect an SVGPathData"); let path = self.to_svg_path().expect("expect an SVGPathData");
let fill = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr }.mFillRule; let fill = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr }.mFillRule;
Some(ShapeSource::Path(Path { fill, path })) Some(ShapeSource::Path(Path { fill, path }))
} },
} }
} }
@ -144,7 +144,7 @@ pub mod basic_shape {
StyleShapeSourceType::Path => { StyleShapeSourceType::Path => {
let gecko_path = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr }; let gecko_path = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr };
Some(SVGPathData(gecko_path.mPath.clone())) Some(SVGPathData(gecko_path.mPath.clone()))
} },
_ => None, _ => None,
} }
} }
@ -193,9 +193,9 @@ pub mod basic_shape {
other.to_svg_path().expect("Cannot convert to SVGPathData"), other.to_svg_path().expect("Cannot convert to SVGPathData"),
), ),
StyleShapeSourceType::None => OffsetPath::none(), StyleShapeSourceType::None => OffsetPath::none(),
StyleShapeSourceType::Shape StyleShapeSourceType::Shape |
| StyleShapeSourceType::Box StyleShapeSourceType::Box |
| StyleShapeSourceType::Image => unreachable!("Unsupported offset-path type"), StyleShapeSourceType::Image => unreachable!("Unsupported offset-path type"),
} }
} }
} }

View file

@ -44,6 +44,8 @@ use crate::gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWThe
use crate::gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags}; use crate::gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
use crate::gecko_bindings::structs; use crate::gecko_bindings::structs;
use crate::gecko_bindings::structs::nsChangeHint; use crate::gecko_bindings::structs::nsChangeHint;
#[cfg(feature = "moz_xbl")]
use crate::gecko_bindings::structs::nsXBLBinding as RawGeckoXBLBinding;
use crate::gecko_bindings::structs::Document_DocumentTheme as DocumentTheme; use crate::gecko_bindings::structs::Document_DocumentTheme as DocumentTheme;
use crate::gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel; use crate::gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel;
use crate::gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT; use crate::gecko_bindings::structs::ELEMENT_HANDLED_SNAPSHOT;
@ -53,13 +55,7 @@ use crate::gecko_bindings::structs::ELEMENT_HAS_SNAPSHOT;
use crate::gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES; use crate::gecko_bindings::structs::NODE_DESCENDANTS_NEED_FRAMES;
use crate::gecko_bindings::structs::NODE_NEEDS_FRAME; use crate::gecko_bindings::structs::NODE_NEEDS_FRAME;
use crate::gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag}; use crate::gecko_bindings::structs::{nsAtom, nsIContent, nsINode_BooleanFlag};
use crate::gecko_bindings::structs::{ use crate::gecko_bindings::structs::{nsINode as RawGeckoNode, Element as RawGeckoElement};
nsINode as RawGeckoNode, Element as RawGeckoElement,
};
#[cfg(feature = "moz_xbl")]
use crate::gecko_bindings::structs::nsXBLBinding as RawGeckoXBLBinding;
#[cfg(not(feature = "moz_xbl"))]
use values::Impossible;
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI}; use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
use crate::global_style_data::GLOBAL_STYLE_DATA; use crate::global_style_data::GLOBAL_STYLE_DATA;
use crate::hash::FxHashMap; use crate::hash::FxHashMap;
@ -90,6 +86,8 @@ use std::fmt;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use std::mem; use std::mem;
use std::ptr; use std::ptr;
#[cfg(not(feature = "moz_xbl"))]
use values::Impossible;
#[inline] #[inline]
fn elements_with_id<'a, 'le>( fn elements_with_id<'a, 'le>(
@ -568,7 +566,6 @@ pub struct GeckoXBLBinding<'lb>(&'lb Impossible);
#[cfg(not(feature = "moz_xbl"))] #[cfg(not(feature = "moz_xbl"))]
impl<'lb> GeckoXBLBinding<'lb> { impl<'lb> GeckoXBLBinding<'lb> {
#[inline] #[inline]
fn anon_content(&self) -> *const nsIContent { fn anon_content(&self) -> *const nsIContent {
match *self.0 {} match *self.0 {}

View file

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

View file

@ -124,11 +124,7 @@ impl LengthPercentage {
/// Returns a new `LengthPercentage`. /// Returns a new `LengthPercentage`.
#[inline] #[inline]
pub fn new(length: Length, percentage: Option<Percentage>) -> Self { pub fn new(length: Length, percentage: Option<Percentage>) -> Self {
Self::with_clamping_mode( Self::with_clamping_mode(length, percentage, AllowedNumericType::All)
length,
percentage,
AllowedNumericType::All,
)
} }
/// Returns a new `LengthPercentage` with zero length and some percentage. /// Returns a new `LengthPercentage` with zero length and some percentage.
@ -384,11 +380,7 @@ impl LengthPercentage {
); );
} }
return Self::with_clamping_mode( return Self::with_clamping_mode(self.length, Some(p), AllowedNumericType::NonNegative);
self.length,
Some(p),
AllowedNumericType::NonNegative,
)
} }
Self::with_clamping_mode( Self::with_clamping_mode(

View file

@ -82,7 +82,12 @@ pub struct GenericGradient<
Color, Color,
> { > {
/// Gradients can be linear or radial. /// Gradients can be linear or radial.
pub kind: GenericGradientKind<LineDirection, NonNegativeLength, NonNegativeLengthPercentage, Position>, pub kind: GenericGradientKind<
LineDirection,
NonNegativeLength,
NonNegativeLengthPercentage,
Position,
>,
/// The color stops and interpolation hints. /// The color stops and interpolation hints.
pub items: crate::OwnedSlice<GenericGradientItem<Color, LengthPercentage>>, pub items: crate::OwnedSlice<GenericGradientItem<Color, LengthPercentage>>,
/// True if this is a repeating gradient. /// True if this is a repeating gradient.
@ -108,11 +113,19 @@ pub enum GradientCompatMode {
/// A gradient kind. /// A gradient kind.
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)] #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)]
#[repr(C, u8)] #[repr(C, u8)]
pub enum GenericGradientKind<LineDirection, NonNegativeLength, NonNegativeLengthPercentage, Position> { pub enum GenericGradientKind<
LineDirection,
NonNegativeLength,
NonNegativeLengthPercentage,
Position,
> {
/// A linear gradient. /// A linear gradient.
Linear(LineDirection), Linear(LineDirection),
/// A radial gradient. /// A radial gradient.
Radial(GenericEndingShape<NonNegativeLength, NonNegativeLengthPercentage>, Position), Radial(
GenericEndingShape<NonNegativeLength, NonNegativeLengthPercentage>,
Position,
),
} }
pub use self::GenericGradientKind as GradientKind; pub use self::GenericGradientKind as GradientKind;

View file

@ -398,7 +398,9 @@ impl Display {
// blockify both to "block". // blockify both to "block".
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
DisplayOutside::XUL => { DisplayOutside::XUL => {
if static_prefs::pref!("layout.css.xul-box-display-values.survive-blockification.enabled") { if static_prefs::pref!(
"layout.css.xul-box-display-values.survive-blockification.enabled"
) {
match self.inside() { match self.inside() {
DisplayInside::MozInlineBox | DisplayInside::MozBox => Display::MozBox, DisplayInside::MozInlineBox | DisplayInside::MozBox => Display::MozBox,
_ => Display::Block, _ => Display::Block,
@ -1155,7 +1157,7 @@ fn change_bits_for_longhand(longhand: LonghandId) -> WillChangeBits {
LonghandId::Opacity => WillChangeBits::OPACITY, LonghandId::Opacity => WillChangeBits::OPACITY,
LonghandId::Transform | LonghandId::Translate | LonghandId::Rotate | LonghandId::Scale => { LonghandId::Transform | LonghandId::Translate | LonghandId::Rotate | LonghandId::Scale => {
WillChangeBits::TRANSFORM WillChangeBits::TRANSFORM
} },
_ => WillChangeBits::empty(), _ => WillChangeBits::empty(),
}; };

View file

@ -10,16 +10,18 @@
use crate::custom_properties::SpecifiedValue; use crate::custom_properties::SpecifiedValue;
use crate::parser::{Parse, ParserContext}; use crate::parser::{Parse, ParserContext};
use crate::stylesheets::CorsMode; use crate::stylesheets::CorsMode;
use crate::values::generics::NonNegative;
use crate::values::generics::image::PaintWorklet; use crate::values::generics::image::PaintWorklet;
use crate::values::generics::image::{ use crate::values::generics::image::{
self as generic, Circle, Ellipse, GradientCompatMode, ShapeExtent, self as generic, Circle, Ellipse, GradientCompatMode, ShapeExtent,
}; };
use crate::values::generics::position::Position as GenericPosition; use crate::values::generics::position::Position as GenericPosition;
use crate::values::generics::NonNegative;
use crate::values::specified::position::{HorizontalPositionKeyword, VerticalPositionKeyword}; use crate::values::specified::position::{HorizontalPositionKeyword, VerticalPositionKeyword};
use crate::values::specified::position::{Position, PositionComponent, Side}; use crate::values::specified::position::{Position, PositionComponent, Side};
use crate::values::specified::url::SpecifiedImageUrl; use crate::values::specified::url::SpecifiedImageUrl;
use crate::values::specified::{Angle, Color, Length, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage}; use crate::values::specified::{
Angle, Color, Length, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage,
};
use crate::values::specified::{Number, NumberOrPercentage, Percentage}; use crate::values::specified::{Number, NumberOrPercentage, Percentage};
use crate::Atom; use crate::Atom;
use cssparser::{Delimiter, Parser, Token}; use cssparser::{Delimiter, Parser, Token};
@ -88,7 +90,8 @@ impl SpecifiedValueInfo for Gradient {
} }
/// A specified gradient kind. /// A specified gradient kind.
pub type GradientKind = generic::GradientKind<LineDirection, NonNegativeLength, NonNegativeLengthPercentage, Position>; pub type GradientKind =
generic::GradientKind<LineDirection, NonNegativeLength, NonNegativeLengthPercentage, Position>;
/// A specified gradient line direction. /// A specified gradient line direction.
/// ///
@ -751,7 +754,10 @@ impl EndingShape {
} }
NonNegativeLengthPercentage::parse(context, i)? NonNegativeLengthPercentage::parse(context, i)?
}; };
Ok(generic::EndingShape::Ellipse(Ellipse::Radii(NonNegative(LengthPercentage::from(x)), y))) Ok(generic::EndingShape::Ellipse(Ellipse::Radii(
NonNegative(LengthPercentage::from(x)),
y,
)))
}) })
} }
} }

View file

@ -62,7 +62,9 @@ pub use self::length::{FontRelativeLength, Length, LengthOrNumber, NonNegativeLe
pub use self::length::{LengthOrAuto, LengthPercentage, LengthPercentageOrAuto}; pub use self::length::{LengthOrAuto, LengthPercentage, LengthPercentageOrAuto};
pub use self::length::{MaxSize, Size}; pub use self::length::{MaxSize, Size};
pub use self::length::{NoCalcLength, ViewportPercentageLength}; pub use self::length::{NoCalcLength, ViewportPercentageLength};
pub use self::length::{NonNegativeLength, NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto}; pub use self::length::{
NonNegativeLength, NonNegativeLengthPercentage, NonNegativeLengthPercentageOrAuto,
};
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use self::list::ListStyleType; pub use self::list::ListStyleType;
pub use self::list::MozListReversed; pub use self::list::MozListReversed;

View file

@ -297,11 +297,7 @@ impl<S: Side> ToComputedValue for PositionComponent<S> {
let p = Percentage(1. - length.percentage()); let p = Percentage(1. - length.percentage());
let l = -length.unclamped_length(); let l = -length.unclamped_length();
// We represent `<end-side> <length>` as `calc(100% - <length>)`. // We represent `<end-side> <length>` as `calc(100% - <length>)`.
ComputedLengthPercentage::with_clamping_mode( ComputedLengthPercentage::with_clamping_mode(l, Some(p), length.clamping_mode)
l,
Some(p),
length.clamping_mode,
)
}, },
PositionComponent::Side(_, Some(ref length)) | PositionComponent::Side(_, Some(ref length)) |
PositionComponent::Length(ref length) => length.to_computed_value(context), PositionComponent::Length(ref length) => length.to_computed_value(context),