Skip to content

Commit

Permalink
Rustfmt recent changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Jan 8, 2019
1 parent c7f30ad commit 2a6cdaa
Show file tree
Hide file tree
Showing 22 changed files with 141 additions and 172 deletions.
17 changes: 10 additions & 7 deletions components/layout/block.rs
Expand Up @@ -431,8 +431,11 @@ impl CandidateBSizeIterator {
},
};

let min_block_size =
fragment.style.min_block_size().maybe_to_used_value(block_container_block_size).unwrap_or(Au(0));
let min_block_size = fragment
.style
.min_block_size()
.maybe_to_used_value(block_container_block_size)
.unwrap_or(Au(0));

// If the style includes `box-sizing: border-box`, subtract the border and padding.
let adjustment_for_box_sizing = match fragment.style.get_position().box_sizing {
Expand Down Expand Up @@ -2154,7 +2157,9 @@ impl Flow for BlockFlow {
// rather than bubbling up children inline width.
let consult_children = match self.fragment.style().get_position().width {
LengthPercentageOrAuto::Auto => true,
LengthPercentageOrAuto::LengthPercentage(ref lp) => lp.maybe_to_used_value(None).is_none(),
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
lp.maybe_to_used_value(None).is_none()
},
};
self.bubble_inline_sizes_for_block(consult_children);
self.fragment
Expand Down Expand Up @@ -2540,8 +2545,7 @@ impl Flow for BlockFlow {
.base
.flags
.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) &&
self.fragment.style().logical_position().inline_start ==
LengthPercentageOrAuto::Auto &&
self.fragment.style().logical_position().inline_start == LengthPercentageOrAuto::Auto &&
self.fragment.style().logical_position().inline_end == LengthPercentageOrAuto::Auto
{
self.base.position.start.i = inline_position
Expand All @@ -2553,8 +2557,7 @@ impl Flow for BlockFlow {
.base
.flags
.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) &&
self.fragment.style().logical_position().block_start ==
LengthPercentageOrAuto::Auto &&
self.fragment.style().logical_position().block_start == LengthPercentageOrAuto::Auto &&
self.fragment.style().logical_position().block_end == LengthPercentageOrAuto::Auto
{
self.base.position.start.b = block_position
Expand Down
22 changes: 9 additions & 13 deletions components/layout/flex.rs
Expand Up @@ -28,9 +28,7 @@ use style::logical_geometry::{Direction, LogicalSize};
use style::properties::ComputedValues;
use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::computed::flex::FlexBasis;
use style::values::computed::{
LengthPercentage, LengthPercentageOrAuto, LengthPercentageOrNone,
};
use style::values::computed::{LengthPercentage, LengthPercentageOrAuto, LengthPercentageOrNone};
use style::values::generics::flex::FlexBasis as GenericFlexBasis;

/// The size of an axis. May be a specified size, a min/max
Expand All @@ -54,13 +52,13 @@ impl AxisSize {
match size {
LengthPercentageOrAuto::Auto => {
AxisSize::MinMax(SizeConstraint::new(content_size, min, max, None))
}
},
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
match lp.maybe_to_used_value(content_size) {
Some(length) => AxisSize::Definite(length),
None => AxisSize::Infinite,
}
}
},
}
}
}
Expand Down Expand Up @@ -459,10 +457,9 @@ impl FlexFlow {
// stripped out, and max replaced with union_nonbreaking_inline.
fn inline_mode_bubble_inline_sizes(&mut self) {
// FIXME(emilio): This doesn't handle at all writing-modes.
let fixed_width = !model::style_length(
self.block_flow.fragment.style().get_position().width,
None,
).is_auto();
let fixed_width =
!model::style_length(self.block_flow.fragment.style().get_position().width, None)
.is_auto();

let mut computation = self.block_flow.fragment.compute_intrinsic_inline_sizes();
if !fixed_width {
Expand All @@ -486,10 +483,9 @@ impl FlexFlow {
// Currently, this is the core of BlockFlow::bubble_inline_sizes() with all float logic
// stripped out.
fn block_mode_bubble_inline_sizes(&mut self) {
let fixed_width = !model::style_length(
self.block_flow.fragment.style().get_position().width,
None,
).is_auto();
let fixed_width =
!model::style_length(self.block_flow.fragment.style().get_position().width, None)
.is_auto();

let mut computation = self.block_flow.fragment.compute_intrinsic_inline_sizes();
if !fixed_width {
Expand Down
5 changes: 2 additions & 3 deletions components/layout/floats.rs
Expand Up @@ -547,13 +547,12 @@ impl SpeculatedFloatPlacement {
// nonzero value (in this case, 1px) so that the layout
// traversal logic will know that objects later in the document
// might flow around this float.
let inline_size =
flow.as_block().fragment.style.content_inline_size();
let inline_size = flow.as_block().fragment.style.content_inline_size();
let fixed = match inline_size {
LengthPercentageOrAuto::Auto => false,
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
lp.is_definitely_zero() || lp.maybe_to_used_value(None).is_some()
}
},
};
if !fixed {
float_inline_size = Au::from_px(1)
Expand Down
5 changes: 2 additions & 3 deletions components/layout/fragment.rs
Expand Up @@ -1614,16 +1614,15 @@ impl Fragment {
LengthPercentageOrAuto::Auto => None,
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
lp.maybe_to_used_value(None)
}
},
};

let mut inline_size = inline_size.unwrap_or_else(|| {
// We have to initialize the `border_padding` field first to make
// the size constraints work properly.
// TODO(stshine): Find a cleaner way to do this.
let padding = self.style.logical_padding();
self.border_padding.inline_start =
padding.inline_start.to_used_value(Au(0));
self.border_padding.inline_start = padding.inline_start.to_used_value(Au(0));
self.border_padding.inline_end = padding.inline_end.to_used_value(Au(0));
self.border_padding.block_start = padding.block_start.to_used_value(Au(0));
self.border_padding.block_end = padding.block_end.to_used_value(Au(0));
Expand Down
13 changes: 5 additions & 8 deletions components/layout/model.rs
Expand Up @@ -481,7 +481,6 @@ impl MaybeAuto {
}
}


#[inline]
pub fn map<F>(&self, mapper: F) -> MaybeAuto
where
Expand All @@ -497,15 +496,12 @@ impl MaybeAuto {
/// Receive an optional container size and return used value for width or height.
///
/// `style_length`: content size as given in the CSS.
pub fn style_length(
style_length: LengthPercentageOrAuto,
container_size: Option<Au>,
) -> MaybeAuto {
pub fn style_length(style_length: LengthPercentageOrAuto, container_size: Option<Au>) -> MaybeAuto {
match style_length {
LengthPercentageOrAuto::Auto => MaybeAuto::Auto,
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
MaybeAuto::from_option(lp.maybe_to_used_value(container_size))
}
},
}
}

Expand Down Expand Up @@ -574,8 +570,9 @@ impl SizeConstraint {
max_size: LengthPercentageOrNone,
border: Option<Au>,
) -> SizeConstraint {
let mut min_size =
min_size.maybe_to_used_value(container_size).unwrap_or(Au(0));
let mut min_size = min_size
.maybe_to_used_value(container_size)
.unwrap_or(Au(0));

let mut max_size = match max_size {
LengthPercentageOrNone::None => None,
Expand Down
14 changes: 6 additions & 8 deletions components/layout/multicol.rs
Expand Up @@ -158,15 +158,13 @@ impl Flow for MulticolFlow {
LengthPercentageOrAuto::Auto => None,
LengthPercentageOrAuto::LengthPercentage(ref lp) => {
lp.maybe_to_used_value(None)
}
},
};
let size = size.or_else(|| {
match style.max_block_size() {
LengthPercentageOrNone::None => None,
LengthPercentageOrNone::LengthPercentage(ref lp) => {
lp.maybe_to_used_value(None)
}
}
let size = size.or_else(|| match style.max_block_size() {
LengthPercentageOrNone::None => None,
LengthPercentageOrNone::LengthPercentage(ref lp) => {
lp.maybe_to_used_value(None)
},
});

size.unwrap_or_else(|| {
Expand Down
40 changes: 15 additions & 25 deletions components/script/dom/element.rs
Expand Up @@ -719,7 +719,7 @@ impl LayoutElementHelpers for LayoutDom<Element> {
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::Width(specified::LengthPercentageOrAuto::LengthPercentage(
specified::LengthPercentage::Length(value)
specified::LengthPercentage::Length(value),
)),
));
}
Expand All @@ -746,24 +746,19 @@ impl LayoutElementHelpers for LayoutDom<Element> {
LengthOrPercentageOrAuto::Auto => {},
LengthOrPercentageOrAuto::Percentage(percentage) => {
let width_value = specified::LengthPercentageOrAuto::LengthPercentage(
specified::LengthPercentage::Percentage(
computed::Percentage(percentage),
),
specified::LengthPercentage::Percentage(computed::Percentage(percentage)),
);
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::Width(width_value),
));
},
LengthOrPercentageOrAuto::Length(length) => {
let width_value =
specified::LengthPercentageOrAuto::LengthPercentage(
specified::LengthPercentage::Length(
specified::NoCalcLength::Absolute(
specified::AbsoluteLength::Px(length.to_f32_px()),
),
),
);
let width_value = specified::LengthPercentageOrAuto::LengthPercentage(
specified::LengthPercentage::Length(specified::NoCalcLength::Absolute(
specified::AbsoluteLength::Px(length.to_f32_px()),
)),
);
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::Width(width_value),
Expand All @@ -785,24 +780,19 @@ impl LayoutElementHelpers for LayoutDom<Element> {
LengthOrPercentageOrAuto::Auto => {},
LengthOrPercentageOrAuto::Percentage(percentage) => {
let height_value = specified::LengthPercentageOrAuto::LengthPercentage(
specified::LengthPercentage::Percentage(
computed::Percentage(percentage),
)
specified::LengthPercentage::Percentage(computed::Percentage(percentage)),
);
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::Height(height_value),
));
},
LengthOrPercentageOrAuto::Length(length) => {
let height_value =
specified::LengthPercentageOrAuto::LengthPercentage(
specified::LengthPercentage::Length(
specified::NoCalcLength::Absolute(
specified::AbsoluteLength::Px(length.to_f32_px()),
)
)
);
let height_value = specified::LengthPercentageOrAuto::LengthPercentage(
specified::LengthPercentage::Length(specified::NoCalcLength::Absolute(
specified::AbsoluteLength::Px(length.to_f32_px()),
)),
);
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::Height(height_value),
Expand Down Expand Up @@ -830,7 +820,7 @@ impl LayoutElementHelpers for LayoutDom<Element> {
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::Width(specified::LengthPercentageOrAuto::LengthPercentage(
specified::LengthPercentage::Length(value)
specified::LengthPercentage::Length(value),
)),
));
}
Expand All @@ -854,7 +844,7 @@ impl LayoutElementHelpers for LayoutDom<Element> {
hints.push(from_declaration(
shared_lock,
PropertyDeclaration::Height(specified::LengthPercentageOrAuto::LengthPercentage(
specified::LengthPercentage::Length(value)
specified::LengthPercentage::Length(value),
)),
));
}
Expand Down
29 changes: 13 additions & 16 deletions components/style/gecko/conversions.rs
Expand Up @@ -80,8 +80,8 @@ impl From<nsStyleCoord_CalcValue> for LengthPercentageOrAuto {
// disappear as we move more stuff to cbindgen.
impl From<nsStyleCoord_CalcValue> for NonNegativeLengthPercentageOrAuto {
fn from(other: nsStyleCoord_CalcValue) -> Self {
NonNegative(
LengthPercentageOrAuto::LengthPercentage(LengthPercentage::with_clamping_mode(
NonNegative(LengthPercentageOrAuto::LengthPercentage(
LengthPercentage::with_clamping_mode(
Au(other.mLength).into(),
if other.mHasPercent {
Some(Percentage(other.mPercent))
Expand All @@ -90,8 +90,8 @@ impl From<nsStyleCoord_CalcValue> for NonNegativeLengthPercentageOrAuto {
},
AllowedNumericType::NonNegative,
/* was_calc = */ true,
))
)
),
))
}
}

Expand Down Expand Up @@ -529,17 +529,15 @@ impl nsStyleImage {
structs::NS_STYLE_GRADIENT_SHAPE_ELLIPTICAL => {
let length_percentage_keyword = match gecko_gradient.mSize as u32 {
structs::NS_STYLE_GRADIENT_SIZE_EXPLICIT_SIZE => match (
LengthPercentage::from_gecko_style_coord(
&gecko_gradient.mRadiusX,
),
LengthPercentage::from_gecko_style_coord(
&gecko_gradient.mRadiusY,
),
LengthPercentage::from_gecko_style_coord(&gecko_gradient.mRadiusX),
LengthPercentage::from_gecko_style_coord(&gecko_gradient.mRadiusY),
) {
(Some(x), Some(y)) => Ellipse::Radii(x, y),
_ => {
debug_assert!(false,
"mRadiusX, mRadiusY could not convert to LengthPercentage");
debug_assert!(
false,
"mRadiusX, mRadiusY could not convert to LengthPercentage"
);
Ellipse::Radii(
LengthPercentage::zero(),
LengthPercentage::zero(),
Expand Down Expand Up @@ -802,10 +800,9 @@ pub mod basic_shape {
),
),
NonNegative(
LengthPercentage::from_gecko_style_coord(&other.data_at(index + 1))
.expect(
"<border-radius> should be a length, percentage, or calc value",
),
LengthPercentage::from_gecko_style_coord(&other.data_at(index + 1)).expect(
"<border-radius> should be a length, percentage, or calc value",
),
),
)
};
Expand Down
12 changes: 8 additions & 4 deletions components/style/gecko/values.rs
Expand Up @@ -149,7 +149,7 @@ impl GeckoStyleCoordConvertible for NumberOrPercentage {
impl GeckoStyleCoordConvertible for LengthPercentage {
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
if self.was_calc {
return coord.set_value(CoordDataValue::Calc((*self).into()))
return coord.set_value(CoordDataValue::Calc((*self).into()));
}
debug_assert!(self.percentage.is_none() || self.unclamped_length() == Length::zero());
if let Some(p) = self.percentage {
Expand All @@ -161,7 +161,9 @@ impl GeckoStyleCoordConvertible for LengthPercentage {
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
match coord.as_value() {
CoordDataValue::Coord(coord) => Some(LengthPercentage::new(Au(coord).into(), None)),
CoordDataValue::Percent(p) => Some(LengthPercentage::new(Au(0).into(), Some(Percentage(p)))),
CoordDataValue::Percent(p) => {
Some(LengthPercentage::new(Au(0).into(), Some(Percentage(p))))
},
CoordDataValue::Calc(calc) => Some(calc.into()),
_ => None,
}
Expand Down Expand Up @@ -192,7 +194,8 @@ impl GeckoStyleCoordConvertible for LengthPercentageOrAuto {
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
match coord.as_value() {
CoordDataValue::Auto => Some(LengthPercentageOrAuto::Auto),
_ => LengthPercentage::from_gecko_style_coord(coord).map(LengthPercentageOrAuto::LengthPercentage),
_ => LengthPercentage::from_gecko_style_coord(coord)
.map(LengthPercentageOrAuto::LengthPercentage),
}
}
}
Expand All @@ -208,7 +211,8 @@ impl GeckoStyleCoordConvertible for LengthPercentageOrNone {
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
match coord.as_value() {
CoordDataValue::None => Some(LengthPercentageOrNone::None),
_ => LengthPercentage::from_gecko_style_coord(coord).map(LengthPercentageOrNone::LengthPercentage),
_ => LengthPercentage::from_gecko_style_coord(coord)
.map(LengthPercentageOrNone::LengthPercentage),
}
}
}
Expand Down

0 comments on commit 2a6cdaa

Please sign in to comment.