Bug 1521392 - Fix servo build and rustfmt recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-01-20 15:38:14 +01:00
Родитель 2bc0dd1099
Коммит ea73c6b7e9
7 изменённых файлов: 45 добавлений и 36 удалений

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

@ -36,9 +36,7 @@ use style_traits::values::specified::AllowedNumericType;
impl From<LengthPercentage> for nsStyleCoord_CalcValue {
fn from(other: LengthPercentage) -> nsStyleCoord_CalcValue {
debug_assert!(
other.was_calc ||
!other.has_percentage ||
other.unclamped_length() == Length::zero()
other.was_calc || !other.has_percentage || other.unclamped_length() == Length::zero()
);
nsStyleCoord_CalcValue {
mLength: other.unclamped_length().to_i32_au(),

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

@ -172,17 +172,22 @@ impl WritingMode {
}
#[inline]
fn physical_sides_to_corner(block_side: PhysicalSide, inline_side: PhysicalSide) -> PhysicalCorner {
fn physical_sides_to_corner(
block_side: PhysicalSide,
inline_side: PhysicalSide,
) -> PhysicalCorner {
match (block_side, inline_side) {
(PhysicalSide::Top, PhysicalSide::Left) |
(PhysicalSide::Left, PhysicalSide::Top) => PhysicalCorner::TopLeft,
(PhysicalSide::Top, PhysicalSide::Right) |
(PhysicalSide::Right, PhysicalSide::Top) => PhysicalCorner::TopRight,
(PhysicalSide::Top, PhysicalSide::Left) | (PhysicalSide::Left, PhysicalSide::Top) => {
PhysicalCorner::TopLeft
},
(PhysicalSide::Top, PhysicalSide::Right) | (PhysicalSide::Right, PhysicalSide::Top) => {
PhysicalCorner::TopRight
},
(PhysicalSide::Bottom, PhysicalSide::Right) |
(PhysicalSide::Right, PhysicalSide::Bottom) => PhysicalCorner::BottomRight,
(PhysicalSide::Bottom, PhysicalSide::Left) |
(PhysicalSide::Left, PhysicalSide::Bottom) => PhysicalCorner::BottomLeft,
_ => unreachable!("block and inline sides must be orthogonal")
_ => unreachable!("block and inline sides must be orthogonal"),
}
}
@ -190,28 +195,32 @@ impl WritingMode {
pub fn start_start_physical_corner(&self) -> PhysicalCorner {
WritingMode::physical_sides_to_corner(
self.block_start_physical_side(),
self.inline_start_physical_side())
self.inline_start_physical_side(),
)
}
#[inline]
pub fn start_end_physical_corner(&self) -> PhysicalCorner {
WritingMode::physical_sides_to_corner(
self.block_start_physical_side(),
self.inline_end_physical_side())
self.inline_end_physical_side(),
)
}
#[inline]
pub fn end_start_physical_corner(&self) -> PhysicalCorner {
WritingMode::physical_sides_to_corner(
self.block_end_physical_side(),
self.inline_start_physical_side())
self.inline_start_physical_side(),
)
}
#[inline]
pub fn end_end_physical_corner(&self) -> PhysicalCorner {
WritingMode::physical_sides_to_corner(
self.block_end_physical_side(),
self.inline_end_physical_side())
self.inline_end_physical_side(),
)
}
#[inline]

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

@ -26,13 +26,10 @@ impl Animate for LengthPercentage {
let length = self
.unclamped_length()
.animate(&other.unclamped_length(), procedure)?;
let percentage = animate_percentage_half(
self.specified_percentage(),
other.specified_percentage(),
)?;
let is_calc = self.was_calc ||
other.was_calc ||
self.has_percentage != other.has_percentage;
let percentage =
animate_percentage_half(self.specified_percentage(), other.specified_percentage())?;
let is_calc =
self.was_calc || other.was_calc || self.has_percentage != other.has_percentage;
Ok(Self::with_clamping_mode(
length,
percentage,

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

@ -32,16 +32,14 @@ fn to_number_or_percentage(
value: &SvgLengthPercentageOrNumber<LengthPercentage, Number>,
) -> Result<NumberOrPercentage, ()> {
Ok(match *value {
SvgLengthPercentageOrNumber::LengthPercentage(ref l) => {
match l.specified_percentage() {
Some(p) => {
if l.unclamped_length().px() != 0. {
return Err(());
}
NumberOrPercentage::Percentage(p)
},
None => NumberOrPercentage::Number(l.length().px()),
}
SvgLengthPercentageOrNumber::LengthPercentage(ref l) => match l.specified_percentage() {
Some(p) => {
if l.unclamped_length().px() != 0. {
return Err(());
}
NumberOrPercentage::Percentage(p)
},
None => NumberOrPercentage::Number(l.length().px()),
},
SvgLengthPercentageOrNumber::Number(ref n) => NumberOrPercentage::Number(*n),
})

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

@ -102,7 +102,8 @@ pub struct LengthPercentage {
// like calc(0px + 5%) and such.
impl PartialEq for LengthPercentage {
fn eq(&self, other: &Self) -> bool {
self.length == other.length && self.percentage == other.percentage &&
self.length == other.length &&
self.percentage == other.percentage &&
self.has_percentage == other.has_percentage
}
}
@ -115,7 +116,8 @@ impl ComputeSquaredDistance for LengthPercentage {
Ok(self
.unclamped_length()
.compute_squared_distance(&other.unclamped_length())? +
self.percentage.compute_squared_distance(&other.percentage)?)
self.percentage
.compute_squared_distance(&other.percentage)?)
}
}
@ -216,7 +218,8 @@ impl LengthPercentage {
/// percentages.
pub fn maybe_to_pixel_length(&self, container_len: Option<Au>) -> Option<Length> {
if self.has_percentage {
let length = self.unclamped_length().px() + container_len?.scale_by(self.percentage.0).to_f32_px();
let length = self.unclamped_length().px() +
container_len?.scale_by(self.percentage.0).to_f32_px();
return Some(Length::new(self.clamping_mode.clamp(length)));
}
Some(self.length())
@ -431,8 +434,7 @@ impl ToComputedValue for specified::LengthPercentage {
return specified::LengthPercentage::Percentage(p);
}
if !computed.has_percentage &&
computed.clamping_mode.clamp(length.px()) == length.px() {
if !computed.has_percentage && computed.clamping_mode.clamp(length.px()) == length.px() {
return specified::LengthPercentage::Length(ToComputedValue::from_computed_value(
&length,
));

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

@ -5,8 +5,8 @@
//! Generic values for UI properties.
use std::fmt::{self, Write};
use values::specified::ui::CursorKind;
use style_traits::{CssWriter, ToCss};
use values::specified::ui::CursorKind;
/// A generic value for the `cursor` property.
///

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

@ -163,6 +163,7 @@ pub enum UserSelect {
Copy,
Debug,
Eq,
FromPrimitive,
MallocSizeOf,
Parse,
PartialEq,
@ -208,8 +209,12 @@ pub enum CursorKind {
ZoomIn,
ZoomOut,
Auto,
#[cfg(feature = "gecko")]
MozGrab,
#[cfg(feature = "gecko")]
MozGrabbing,
#[cfg(feature = "gecko")]
MozZoomIn,
#[cfg(feature = "gecko")]
MozZoomOut,
}