Upgrade to rustc 551a74dddd84cf01440ee84148ebd18bc68bd7c8.

This commit is contained in:
Simon Sapin 2015-04-23 00:14:02 +02:00 committed by Josh Matthews
parent 7b87085c18
commit ef8edd4e87
168 changed files with 2247 additions and 2408 deletions

View file

@ -21,10 +21,8 @@ use values::computed::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, Lengt
use values::CSSFloat;
use cssparser::{RGBA, Color};
use std::num::Float;
use std::cmp::Ordering;
use std::iter::repeat;
use std::num::FromPrimitive;
use util::bezier::Bezier;
use util::geometry::Au;
@ -155,7 +153,7 @@ impl PropertyAnimation {
}
}
pub fn update(&self, style: &mut ComputedValues, time: f64) {
pub fn update(&self, style: &mut ComputedValues, time: f32) {
let progress = match self.timing_function {
TransitionTimingFunction::CubicBezier(p1, p2) => {
// See `WebCore::AnimationBase::solveEpsilon(double)` in WebKit.
@ -163,10 +161,10 @@ impl PropertyAnimation {
Bezier::new(p1, p2).solve(time, epsilon)
}
TransitionTimingFunction::Steps(steps, StartEnd::Start) => {
(time * (steps as f64)).ceil() / (steps as f64)
(time * (steps as f32)).ceil() / (steps as f32)
}
TransitionTimingFunction::Steps(steps, StartEnd::End) => {
(time * (steps as f64)).floor() / (steps as f64)
(time * (steps as f32)).floor() / (steps as f32)
}
};
@ -336,19 +334,19 @@ impl AnimatedProperty {
}
trait Interpolate {
fn interpolate(&self, other: &Self, time: f64) -> Option<Self>;
fn interpolate(&self, other: &Self, time: f32) -> Option<Self>;
}
impl Interpolate for Au {
#[inline]
fn interpolate(&self, other: &Au, time: f64) -> Option<Au> {
Some(Au((self.0 as f64 + (other.0 as f64 - self.0 as f64) * time).round() as i32))
fn interpolate(&self, other: &Au, time: f32) -> Option<Au> {
Some(Au((self.0 as f32 + (other.0 as f32 - self.0 as f32) * time).round() as i32))
}
}
impl <T> Interpolate for Option<T> where T:Interpolate {
#[inline]
fn interpolate(&self, other: &Option<T>, time: f64) -> Option<Option<T>> {
fn interpolate(&self, other: &Option<T>, time: f32) -> Option<Option<T>> {
match (self, other) {
(&Some(ref this), &Some(ref other)) => {
this.interpolate(other, time).and_then(|value| {
@ -360,32 +358,32 @@ impl <T> Interpolate for Option<T> where T:Interpolate {
}
}
impl Interpolate for f64 {
impl Interpolate for f32 {
#[inline]
fn interpolate(&self, other: &f64, time: f64) -> Option<f64> {
fn interpolate(&self, other: &f32, time: f32) -> Option<f32> {
Some(*self + (*other - *self) * time)
}
}
impl Interpolate for f32 {
impl Interpolate for f64 {
#[inline]
fn interpolate(&self, other: &f32, time: f64) -> Option<f32> {
Some(*self + (*other - *self) * (time as f32))
fn interpolate(&self, other: &f64, time: f32) -> Option<f64> {
Some(*self + (*other - *self) * (time as f64))
}
}
impl Interpolate for i32 {
#[inline]
fn interpolate(&self, other: &i32, time: f64) -> Option<i32> {
let a = *self as f64;
let b = *other as f64;
fn interpolate(&self, other: &i32, time: f32) -> Option<i32> {
let a = *self as f32;
let b = *other as f32;
Some((a + (b - a) * time).round() as i32)
}
}
impl Interpolate for Visibility {
#[inline]
fn interpolate(&self, other: &Visibility, time: f64)
fn interpolate(&self, other: &Visibility, time: f32)
-> Option<Visibility> {
match (*self, *other) {
(Visibility::visible, _) | (_, Visibility::visible) => {
@ -404,7 +402,7 @@ impl Interpolate for Visibility {
impl Interpolate for ZIndex {
#[inline]
fn interpolate(&self, other: &ZIndex, time: f64)
fn interpolate(&self, other: &ZIndex, time: f32)
-> Option<ZIndex> {
match (*self, *other) {
(ZIndex::Number(ref this),
@ -420,7 +418,7 @@ impl Interpolate for ZIndex {
impl Interpolate for VerticalAlign {
#[inline]
fn interpolate(&self, other: &VerticalAlign, time: f64)
fn interpolate(&self, other: &VerticalAlign, time: f32)
-> Option<VerticalAlign> {
match (*self, *other) {
(VerticalAlign::Length(ref this),
@ -436,7 +434,7 @@ impl Interpolate for VerticalAlign {
impl Interpolate for BorderSpacing {
#[inline]
fn interpolate(&self, other: &BorderSpacing, time: f64)
fn interpolate(&self, other: &BorderSpacing, time: f32)
-> Option<BorderSpacing> {
self.horizontal.interpolate(&other.horizontal, time).and_then(|horizontal| {
self.vertical.interpolate(&other.vertical, time).and_then(|vertical| {
@ -448,7 +446,7 @@ impl Interpolate for BorderSpacing {
impl Interpolate for RGBA {
#[inline]
fn interpolate(&self, other: &RGBA, time: f64) -> Option<RGBA> {
fn interpolate(&self, other: &RGBA, time: f32) -> Option<RGBA> {
match (self.red.interpolate(&other.red, time),
self.green.interpolate(&other.green, time),
self.blue.interpolate(&other.blue, time),
@ -463,7 +461,7 @@ impl Interpolate for RGBA {
impl Interpolate for Color {
#[inline]
fn interpolate(&self, other: &Color, time: f64) -> Option<Color> {
fn interpolate(&self, other: &Color, time: f32) -> Option<Color> {
match (*self, *other) {
(Color::RGBA(ref this), Color::RGBA(ref other)) => {
this.interpolate(other, time).and_then(|value| {
@ -477,7 +475,7 @@ impl Interpolate for Color {
impl Interpolate for LengthOrPercentage {
#[inline]
fn interpolate(&self, other: &LengthOrPercentage, time: f64)
fn interpolate(&self, other: &LengthOrPercentage, time: f32)
-> Option<LengthOrPercentage> {
match (*self, *other) {
(LengthOrPercentage::Length(ref this),
@ -499,7 +497,7 @@ impl Interpolate for LengthOrPercentage {
impl Interpolate for LengthOrPercentageOrAuto {
#[inline]
fn interpolate(&self, other: &LengthOrPercentageOrAuto, time: f64)
fn interpolate(&self, other: &LengthOrPercentageOrAuto, time: f32)
-> Option<LengthOrPercentageOrAuto> {
match (*self, *other) {
(LengthOrPercentageOrAuto::Length(ref this),
@ -524,7 +522,7 @@ impl Interpolate for LengthOrPercentageOrAuto {
impl Interpolate for LengthOrPercentageOrNone {
#[inline]
fn interpolate(&self, other: &LengthOrPercentageOrNone, time: f64)
fn interpolate(&self, other: &LengthOrPercentageOrNone, time: f32)
-> Option<LengthOrPercentageOrNone> {
match (*self, *other) {
(LengthOrPercentageOrNone::Length(ref this),
@ -549,7 +547,7 @@ impl Interpolate for LengthOrPercentageOrNone {
impl Interpolate for LineHeight {
#[inline]
fn interpolate(&self, other: &LineHeight, time: f64)
fn interpolate(&self, other: &LineHeight, time: f32)
-> Option<LineHeight> {
match (*self, *other) {
(LineHeight::Length(ref this),
@ -572,20 +570,39 @@ impl Interpolate for LineHeight {
}
}
/// http://dev.w3.org/csswg/css-transitions/#animtype-font-weight
impl Interpolate for FontWeight {
#[inline]
fn interpolate(&self, other: &FontWeight, time: f64)
fn interpolate(&self, other: &FontWeight, time: f32)
-> Option<FontWeight> {
let a = (*self as isize) as f64;
let b = (*other as isize) as f64;
let weight: Option<FontWeight> = FromPrimitive::from_isize((a + (b - a) * time).round() as isize);
weight
let a = (*self as u32) as f32;
let b = (*other as u32) as f32;
let weight = a + (b - a) * time;
Some(if weight < 150. {
FontWeight::Weight100
} else if weight < 250. {
FontWeight::Weight200
} else if weight < 350. {
FontWeight::Weight300
} else if weight < 450. {
FontWeight::Weight400
} else if weight < 550. {
FontWeight::Weight500
} else if weight < 650. {
FontWeight::Weight600
} else if weight < 750. {
FontWeight::Weight700
} else if weight < 850. {
FontWeight::Weight800
} else {
FontWeight::Weight900
})
}
}
impl Interpolate for ClipRect {
#[inline]
fn interpolate(&self, other: &ClipRect, time: f64)
fn interpolate(&self, other: &ClipRect, time: f32)
-> Option<ClipRect> {
match (self.top.interpolate(&other.top, time),
self.right.interpolate(&other.right, time),
@ -601,7 +618,7 @@ impl Interpolate for ClipRect {
impl Interpolate for BackgroundPosition {
#[inline]
fn interpolate(&self, other: &BackgroundPosition, time: f64)
fn interpolate(&self, other: &BackgroundPosition, time: f32)
-> Option<BackgroundPosition> {
match (self.horizontal.interpolate(&other.horizontal, time),
self.vertical.interpolate(&other.vertical, time)) {
@ -615,7 +632,7 @@ impl Interpolate for BackgroundPosition {
impl Interpolate for TextShadow {
#[inline]
fn interpolate(&self, other: &TextShadow, time: f64)
fn interpolate(&self, other: &TextShadow, time: f32)
-> Option<TextShadow> {
match (self.offset_x.interpolate(&other.offset_x, time),
self.offset_y.interpolate(&other.offset_y, time),
@ -631,7 +648,7 @@ impl Interpolate for TextShadow {
impl Interpolate for TextShadowList {
#[inline]
fn interpolate(&self, other: &TextShadowList, time: f64)
fn interpolate(&self, other: &TextShadowList, time: f32)
-> Option<TextShadowList> {
let zero = TextShadow {
offset_x: Au(0),