зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1341102 - Revendor rust deps; r=bustage
MozReview-Commit-ID: 2EcVsnJ5VFN
This commit is contained in:
Родитель
d7485b7e2f
Коммит
1e3217e804
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"6b96b2c6bfd7e1acef4b825a2813fc4277859eb9400a16800db8835c25e4087d","Cargo.toml":"1648e6342e3879aaf3add2a9341915ca1650037df830907dc1e2b768aa087036","README.md":"9f048d969f9f8333cdcdb892744cd0816e4f2922c8817fa5e9e07f9472fe1050","src/app_unit.rs":"7e75ca0ad78d26c6538029c7ddae650f7b76c2f7210735e6da6e52920494fdb4","src/lib.rs":"2df7d863c47d8b22f9af66caeafa87e6a206ee713a8aeaa55c5a80a42a92513b"},"package":"7ff4f3fe57393a150b39b026b6f6f4b9a6c4f49b52d0a4e2d61d08d926358438"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"6b96b2c6bfd7e1acef4b825a2813fc4277859eb9400a16800db8835c25e4087d","Cargo.toml":"41d47153a6043d3e4599f827888e1ac43c204e52ed5f6998b1e275fcae21a3cc","README.md":"9f048d969f9f8333cdcdb892744cd0816e4f2922c8817fa5e9e07f9472fe1050","src/app_unit.rs":"0f4fde2c0481b6dd021f48c8ef548090e7c577c02c429c41626c2b5e7a006949","src/lib.rs":"2df7d863c47d8b22f9af66caeafa87e6a206ee713a8aeaa55c5a80a42a92513b"},"package":"ed0a4de09a3b8449515e649f3bb84f72ea15fc2d10639beb0776a09b7d308074"}
|
|
@ -12,20 +12,20 @@
|
|||
|
||||
[package]
|
||||
name = "app_units"
|
||||
version = "0.5.3"
|
||||
version = "0.5.6"
|
||||
authors = ["The Servo Project Developers"]
|
||||
description = "Servo app units type (Au)"
|
||||
documentation = "http://doc.servo.org/app_units/"
|
||||
license = "MPL-2.0"
|
||||
repository = "https://github.com/servo/app_units"
|
||||
[dependencies.serde]
|
||||
version = "1.0"
|
||||
[dependencies.rustc-serialize]
|
||||
version = "0.3"
|
||||
|
||||
[dependencies.num-traits]
|
||||
version = "0.1.32"
|
||||
|
||||
[dependencies.rustc-serialize]
|
||||
version = "0.3"
|
||||
|
||||
[dependencies.heapsize]
|
||||
version = ">=0.3, < 0.5"
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0"
|
||||
|
|
|
@ -189,17 +189,24 @@ impl Au {
|
|||
|
||||
#[inline]
|
||||
fn clamp_self(&mut self) {
|
||||
*self = self.clamp()
|
||||
*self = Au::clamp(*self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scale_by(self, factor: f32) -> Au {
|
||||
let new_float = ((self.0 as f64) * factor as f64).round();
|
||||
Au::clamp_from_f64_au(new_float)
|
||||
Au::from_f64_au(new_float)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn clamp_from_f64_au(float: f64) -> Self {
|
||||
/// Scale, but truncate (useful for viewport-relative units)
|
||||
pub fn scale_by_trunc(self, factor: f32) -> Au {
|
||||
let new_float = ((self.0 as f64) * factor as f64).trunc();
|
||||
Au::from_f64_au(new_float)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_f64_au(float: f64) -> Self {
|
||||
// We *must* operate in f64. f32 isn't precise enough
|
||||
// to handle MAX_AU
|
||||
Au(float.min(MAX_AU.0 as f64)
|
||||
|
@ -247,13 +254,13 @@ impl Au {
|
|||
#[inline]
|
||||
pub fn from_f32_px(px: f32) -> Au {
|
||||
let float = (px * AU_PER_PX as f32).round();
|
||||
Au::clamp_from_f64_au(float as f64)
|
||||
Au::from_f64_au(float as f64)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_f64_px(px: f64) -> Au {
|
||||
let float = (px * AU_PER_PX as f64).round();
|
||||
Au::clamp_from_f64_au(float)
|
||||
Au::from_f64_au(float)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -303,6 +310,7 @@ fn scale() {
|
|||
assert_eq!(Au(12).scale_by(1.5), Au(18));
|
||||
assert_eq!(Au(12).scale_by(1.7), Au(20));
|
||||
assert_eq!(Au(12).scale_by(1.8), Au(22));
|
||||
assert_eq!(Au(12).scale_by_trunc(1.8), Au(21));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Загрузка…
Ссылка в новой задаче