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

@ -14,7 +14,6 @@ use windowing::{MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg}
use azure::azure_hl; use azure::azure_hl;
use std::cmp; use std::cmp;
use std::mem; use std::mem;
use std::num::Zero;
use geom::point::{Point2D, TypedPoint2D}; use geom::point::{Point2D, TypedPoint2D};
use geom::rect::{Rect, TypedRect}; use geom::rect::{Rect, TypedRect};
use geom::size::TypedSize2D; use geom::size::TypedSize2D;
@ -176,7 +175,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
context: None, context: None,
root_pipeline: None, root_pipeline: None,
scene: Scene::new(Rect { scene: Scene::new(Rect {
origin: Zero::zero(), origin: Point2D::zero(),
size: window_size.as_f32(), size: window_size.as_f32(),
}), }),
window_size: window_size, window_size: window_size,
@ -1027,7 +1026,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
debug!("compositor: compositing"); debug!("compositor: compositing");
// Adjust the layer dimensions as necessary to correspond to the size of the window. // Adjust the layer dimensions as necessary to correspond to the size of the window.
self.scene.viewport = Rect { self.scene.viewport = Rect {
origin: Zero::zero(), origin: Point2D::zero(),
size: self.window_size.as_f32(), size: self.window_size.as_f32(),
}; };
// paint the scene. // paint the scene.
@ -1121,7 +1120,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}; };
let clip_rect_for_children = if masks_to_bounds { let clip_rect_for_children = if masks_to_bounds {
Rect(Zero::zero(), clipped_layer_bounds.size) Rect(Point2D::zero(), clipped_layer_bounds.size)
} else { } else {
clipped_layer_bounds.translate(&clip_rect.origin) clipped_layer_bounds.translate(&clip_rect.origin)
}; };

View file

@ -29,7 +29,7 @@ use servo_util::geometry::{Au, MAX_RECT};
use servo_util::opts; use servo_util::opts;
use servo_util::range::Range; use servo_util::range::Range;
use std::default::Default; use std::default::Default;
use std::num::{Float, FloatMath, Zero}; use std::num::{Float, FloatMath};
use std::ptr; use std::ptr;
use style::computed_values::border_style; use style::computed_values::border_style;
use sync::Arc; use sync::Arc;
@ -666,7 +666,7 @@ impl<'a> PaintContext<'a> {
self.draw_target.set_transform(&current_transform.mul(&Matrix2D::new(0., -1., self.draw_target.set_transform(&current_transform.mul(&Matrix2D::new(0., -1.,
1., 0., 1., 0.,
x, y))); x, y)));
Zero::zero() Point2D::zero()
} }
SidewaysRight => { SidewaysRight => {
let x = text.baseline_origin.x.to_subpx() as AzFloat; let x = text.baseline_origin.x.to_subpx() as AzFloat;
@ -674,7 +674,7 @@ impl<'a> PaintContext<'a> {
self.draw_target.set_transform(&current_transform.mul(&Matrix2D::new(0., 1., self.draw_target.set_transform(&current_transform.mul(&Matrix2D::new(0., 1.,
-1., 0., -1., 0.,
x, y))); x, y)));
Zero::zero() Point2D::zero()
} }
}; };
@ -988,7 +988,7 @@ impl ScaledFontExtensionMethods for ScaledFont {
for slice in run.natural_word_slices_in_range(range) { for slice in run.natural_word_slices_in_range(range) {
for (_i, glyph) in slice.glyphs.iter_glyphs_for_char_range(&slice.range) { for (_i, glyph) in slice.glyphs.iter_glyphs_for_char_range(&slice.range) {
let glyph_advance = glyph.advance(); let glyph_advance = glyph.advance();
let glyph_offset = glyph.offset().unwrap_or(Zero::zero()); let glyph_offset = glyph.offset().unwrap_or(Point2D::zero());
let azglyph = struct__AzGlyph { let azglyph = struct__AzGlyph {
mIndex: glyph.id() as uint32_t, mIndex: glyph.id() as uint32_t,
mPosition: struct__AzPoint { mPosition: struct__AzPoint {

View file

@ -11,7 +11,7 @@ use servo_util::range::{Range, RangeIndex, IntRangeIndex, EachIndex};
use servo_util::geometry::Au; use servo_util::geometry::Au;
use std::cmp::PartialOrd; use std::cmp::PartialOrd;
use std::num::{NumCast, Zero}; use std::num::NumCast;
use std::mem; use std::mem;
use std::u16; use std::u16;
use std::vec::Vec; use std::vec::Vec;
@ -434,7 +434,7 @@ impl GlyphData {
GlyphData { GlyphData {
id: id, id: id,
advance: advance, advance: advance,
offset: offset.unwrap_or(Zero::zero()), offset: offset.unwrap_or(Point2D::zero()),
is_missing: is_missing, is_missing: is_missing,
cluster_start: cluster_start, cluster_start: cluster_start,
ligature_start: ligature_start, ligature_start: ligature_start,
@ -549,7 +549,7 @@ impl<'a> GlyphStore {
fn glyph_is_compressible(data: &GlyphData) -> bool { fn glyph_is_compressible(data: &GlyphData) -> bool {
is_simple_glyph_id(data.id) is_simple_glyph_id(data.id)
&& is_simple_advance(data.advance) && is_simple_advance(data.advance)
&& data.offset.is_zero() && data.offset == Point2D::zero()
&& data.cluster_start // others are stored in detail buffer && data.cluster_start // others are stored in detail buffer
} }

View file

@ -53,7 +53,6 @@ use servo_util::geometry::Au;
use servo_util::logical_geometry::WritingMode; use servo_util::logical_geometry::WritingMode;
use servo_util::logical_geometry::{LogicalRect, LogicalSize}; use servo_util::logical_geometry::{LogicalRect, LogicalSize};
use std::mem; use std::mem;
use std::num::Zero;
use std::fmt; use std::fmt;
use std::iter::Zip; use std::iter::Zip;
use std::raw; use std::raw;
@ -686,7 +685,7 @@ impl AbsolutePositionInfo {
// of the root layer. // of the root layer.
AbsolutePositionInfo { AbsolutePositionInfo {
relative_containing_block_size: LogicalSize::zero(writing_mode), relative_containing_block_size: LogicalSize::zero(writing_mode),
stacking_relative_position_of_absolute_containing_block: Zero::zero(), stacking_relative_position_of_absolute_containing_block: Point2D::zero(),
layers_needed_for_positioned_flows: false, layers_needed_for_positioned_flows: false,
} }
} }
@ -902,7 +901,7 @@ impl BaseFlow {
parallel: FlowParallelInfo::new(), parallel: FlowParallelInfo::new(),
floats: Floats::new(writing_mode), floats: Floats::new(writing_mode),
collapsible_margins: CollapsibleMargins::new(), collapsible_margins: CollapsibleMargins::new(),
stacking_relative_position: Zero::zero(), stacking_relative_position: Point2D::zero(),
abs_descendants: Descendants::new(), abs_descendants: Descendants::new(),
absolute_static_i_offset: Au(0), absolute_static_i_offset: Au(0),
fixed_static_i_offset: Au(0), fixed_static_i_offset: Au(0),
@ -911,7 +910,7 @@ impl BaseFlow {
absolute_cb: ContainingBlockLink::new(), absolute_cb: ContainingBlockLink::new(),
display_list_building_result: DisplayListBuildingResult::None, display_list_building_result: DisplayListBuildingResult::None,
absolute_position_info: AbsolutePositionInfo::new(writing_mode), absolute_position_info: AbsolutePositionInfo::new(writing_mode),
clip_rect: Rect(Zero::zero(), Size2D(Au(0), Au(0))), clip_rect: Rect(Point2D::zero(), Size2D::zero()),
flags: flags, flags: flags,
writing_mode: writing_mode, writing_mode: writing_mode,
} }

View file

@ -33,7 +33,6 @@ use servo_util::arc_ptr_eq;
use std::cmp::max; use std::cmp::max;
use std::fmt; use std::fmt;
use std::mem; use std::mem;
use std::num;
use std::u16; use std::u16;
use style::computed_values::{text_align, vertical_align, white_space}; use style::computed_values::{text_align, vertical_align, white_space};
use style::ComputedValues; use style::ComputedValues;
@ -211,7 +210,7 @@ impl LineBreaker {
/// Reinitializes the pending line to blank data. /// Reinitializes the pending line to blank data.
fn reset_line(&mut self) { fn reset_line(&mut self) {
self.pending_line.range.reset(num::zero(), num::zero()); self.pending_line.range.reset(FragmentIndex(0), FragmentIndex(0));
self.pending_line.bounds = LogicalRect::new(self.floats.writing_mode, self.pending_line.bounds = LogicalRect::new(self.floats.writing_mode,
Au(0), Au(0),
self.cur_b, self.cur_b,
@ -632,7 +631,7 @@ impl LineBreaker {
if self.pending_line_is_empty() { if self.pending_line_is_empty() {
assert!(self.new_fragments.len() <= (u16::MAX as uint)); assert!(self.new_fragments.len() <= (u16::MAX as uint));
self.pending_line.range.reset(FragmentIndex(self.new_fragments.len() as int), self.pending_line.range.reset(FragmentIndex(self.new_fragments.len() as int),
num::zero()); FragmentIndex(0));
} }
self.pending_line.range.extend_by(FragmentIndex(1)); self.pending_line.range.extend_by(FragmentIndex(1));
@ -655,7 +654,7 @@ impl LineBreaker {
/// Returns true if the pending line is empty and false otherwise. /// Returns true if the pending line is empty and false otherwise.
fn pending_line_is_empty(&self) -> bool { fn pending_line_is_empty(&self) -> bool {
self.pending_line.range.length() == num::zero() self.pending_line.range.length() == FragmentIndex(0)
} }
} }

View file

@ -247,7 +247,7 @@ source = "git+https://github.com/alexcrichton/gcc-rs#903e8f8a2e3766ad3d514404d45
[[package]] [[package]]
name = "geom" name = "geom"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-geom#95e746133b4a35b53eb259304668b63ee8de42b8" source = "git+https://github.com/servo/rust-geom#5e52790076fc238a395d1777c4280fa46a1555fa"
[[package]] [[package]]
name = "gfx" name = "gfx"
@ -425,7 +425,7 @@ source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb7
[[package]] [[package]]
name = "layers" name = "layers"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#5fbdc521b82296e325d2df13fce8026c727c01d2" source = "git+https://github.com/servo/rust-layers#21798aac4de6bfd800836f419dd5b6a308edcaa4"
dependencies = [ dependencies = [
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",

View file

@ -6,11 +6,12 @@ use geom::length::Length;
use geom::point::Point2D; use geom::point::Point2D;
use geom::rect::Rect; use geom::rect::Rect;
use geom::size::Size2D; use geom::size::Size2D;
use geom::num::Zero;
use serialize::{Encodable, Encoder}; use serialize::{Encodable, Encoder};
use std::default::Default; use std::default::Default;
use std::i32; use std::i32;
use std::num::{Float, NumCast, Zero}; use std::num::{Float, NumCast};
use std::fmt; use std::fmt;
// Units for use with geom::length and geom::scale_factor. // 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. // 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. // 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); pub struct Au(pub i32);
impl Default for Au { 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 { pub static ZERO_POINT: Point2D<Au> = Point2D {
x: Au(0), x: Au(0),
y: Au(0), y: Au(0),

View file

@ -5,9 +5,9 @@
//! Geometry in flow-relative space. //! Geometry in flow-relative space.
use geom::{Size2D, Point2D, SideOffsets2D, Rect}; use geom::{Size2D, Point2D, SideOffsets2D, Rect};
use geom::num::Zero;
use std::cmp::{min, max}; use std::cmp::{min, max};
use std::fmt::{Show, Formatter, FormatError}; use std::fmt::{Show, Formatter, FormatError};
use std::num::Zero;
bitflags!( bitflags!(
#[deriving(Encodable)] #[deriving(Encodable)]
@ -158,11 +158,6 @@ impl<T: Zero> LogicalSize<T> {
debug_writing_mode: DebugWritingMode::new(mode), 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> { impl<T: Copy> LogicalSize<T> {
@ -295,11 +290,6 @@ impl<T: Zero> LogicalPoint<T> {
debug_writing_mode: DebugWritingMode::new(mode), 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> { impl<T: Copy> LogicalPoint<T> {
@ -476,14 +466,6 @@ impl<T: Zero> LogicalMargin<T> {
debug_writing_mode: DebugWritingMode::new(mode), 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> { 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> { impl<T: Add<T, T>> LogicalMargin<T> {
#[inline] #[inline]
pub fn inline_start_end(&self) -> T { pub fn inline_start_end(&self) -> T {
@ -756,11 +746,6 @@ impl<T: Zero> LogicalRect<T> {
debug_writing_mode: DebugWritingMode::new(mode), 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> { impl<T: Copy> LogicalRect<T> {

4
ports/cef/Cargo.lock generated
View file

@ -243,7 +243,7 @@ source = "git+https://github.com/alexcrichton/gcc-rs#903e8f8a2e3766ad3d514404d45
[[package]] [[package]]
name = "geom" name = "geom"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-geom#95e746133b4a35b53eb259304668b63ee8de42b8" source = "git+https://github.com/servo/rust-geom#5e52790076fc238a395d1777c4280fa46a1555fa"
[[package]] [[package]]
name = "gfx" name = "gfx"
@ -393,7 +393,7 @@ source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb7
[[package]] [[package]]
name = "layers" name = "layers"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#5fbdc521b82296e325d2df13fce8026c727c01d2" source = "git+https://github.com/servo/rust-layers#21798aac4de6bfd800836f419dd5b6a308edcaa4"
dependencies = [ dependencies = [
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",

5
ports/gonk/Cargo.lock generated
View file

@ -207,7 +207,7 @@ source = "git+https://github.com/alexcrichton/gcc-rs#d35c34c871dd75f97fadf04cb0e
[[package]] [[package]]
name = "geom" name = "geom"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-geom#e5e74911ac6d3201009879b72499d6c681302611" source = "git+https://github.com/servo/rust-geom#5e52790076fc238a395d1777c4280fa46a1555fa"
[[package]] [[package]]
name = "gfx" name = "gfx"
@ -329,7 +329,7 @@ source = "git+https://github.com/bjz/gl-rs.git#79cd3b3f9f19aa0e39f6af572fc8673a6
[[package]] [[package]]
name = "layers" name = "layers"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#b068d2a96d54bf173b548aece36f5ea4ef9353cf" source = "git+https://github.com/servo/rust-layers#21798aac4de6bfd800836f419dd5b6a308edcaa4"
dependencies = [ dependencies = [
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
@ -410,6 +410,7 @@ dependencies = [
"hyper 0.0.1 (git+https://github.com/servo/hyper?ref=servo)", "hyper 0.0.1 (git+https://github.com/servo/hyper?ref=servo)",
"io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface)", "io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface)",
"layers 0.1.0 (git+https://github.com/servo/rust-layers)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)",
"style 0.0.1",
"url 0.1.0 (git+https://github.com/servo/rust-url)", "url 0.1.0 (git+https://github.com/servo/rust-url)",
"util 0.0.1", "util 0.0.1",
] ]