Remove usage of the deprecated std::num::Zero trait.

This commit is contained in:
Simon Sapin 2014-12-18 11:16:47 +00:00
parent 32c721e640
commit 084a63df45
10 changed files with 42 additions and 51 deletions

View file

@ -6,11 +6,12 @@ use geom::length::Length;
use geom::point::Point2D;
use geom::rect::Rect;
use geom::size::Size2D;
use geom::num::Zero;
use serialize::{Encodable, Encoder};
use std::default::Default;
use std::i32;
use std::num::{Float, NumCast, Zero};
use std::num::{Float, NumCast};
use std::fmt;
// Units for use with geom::length and geom::scale_factor.
@ -64,7 +65,7 @@ pub enum PagePx {}
// See https://bugzilla.mozilla.org/show_bug.cgi?id=177805 for more info.
//
// FIXME: Implement Au using Length and ScaleFactor instead of a custom type.
#[deriving(Clone, Hash, PartialEq, PartialOrd, Eq, Ord, Zero)]
#[deriving(Clone, Hash, PartialEq, PartialOrd, Eq, Ord)]
pub struct Au(pub i32);
impl Default for Au {
@ -74,6 +75,13 @@ impl Default for Au {
}
}
impl Zero for Au {
#[inline]
fn zero() -> Au {
Au(0)
}
}
pub static ZERO_POINT: Point2D<Au> = Point2D {
x: Au(0),
y: Au(0),

View file

@ -5,9 +5,9 @@
//! Geometry in flow-relative space.
use geom::{Size2D, Point2D, SideOffsets2D, Rect};
use geom::num::Zero;
use std::cmp::{min, max};
use std::fmt::{Show, Formatter, FormatError};
use std::num::Zero;
bitflags!(
#[deriving(Encodable)]
@ -158,11 +158,6 @@ impl<T: Zero> LogicalSize<T> {
debug_writing_mode: DebugWritingMode::new(mode),
}
}
#[inline]
pub fn is_zero(&self) -> bool {
self.inline.is_zero() && self.block.is_zero()
}
}
impl<T: Copy> LogicalSize<T> {
@ -295,11 +290,6 @@ impl<T: Zero> LogicalPoint<T> {
debug_writing_mode: DebugWritingMode::new(mode),
}
}
#[inline]
pub fn is_zero(&self) -> bool {
self.i.is_zero() && self.b.is_zero()
}
}
impl<T: Copy> LogicalPoint<T> {
@ -476,14 +466,6 @@ impl<T: Zero> LogicalMargin<T> {
debug_writing_mode: DebugWritingMode::new(mode),
}
}
#[inline]
pub fn is_zero(&self) -> bool {
self.block_start.is_zero() &&
self.inline_end.is_zero() &&
self.block_end.is_zero() &&
self.inline_start.is_zero()
}
}
impl<T: Copy> LogicalMargin<T> {
@ -666,6 +648,14 @@ impl<T: Copy> LogicalMargin<T> {
}
}
impl<T: PartialEq + Zero> LogicalMargin<T> {
#[inline]
pub fn is_zero(&self) -> bool {
self.block_start == Zero::zero() && self.inline_end == Zero::zero() &&
self.block_end == Zero::zero() && self.inline_start == Zero::zero()
}
}
impl<T: Add<T, T>> LogicalMargin<T> {
#[inline]
pub fn inline_start_end(&self) -> T {
@ -756,11 +746,6 @@ impl<T: Zero> LogicalRect<T> {
debug_writing_mode: DebugWritingMode::new(mode),
}
}
#[inline]
pub fn is_zero(&self) -> bool {
self.start.is_zero() && self.size.is_zero()
}
}
impl<T: Copy> LogicalRect<T> {