Replace Au::zero_* with generic methods

This commit is contained in:
Matt Brubeck 2014-05-01 17:13:03 -07:00
parent 8af9ce07f8
commit 4821df6216
8 changed files with 15 additions and 39 deletions

View file

@ -7,6 +7,7 @@ use azure::azure_hl::{BackendType, ColorPattern};
use azure::scaled_font::ScaledFont; use azure::scaled_font::ScaledFont;
use geom::{Point2D, Rect, Size2D}; use geom::{Point2D, Rect, Size2D};
use std::cast; use std::cast;
use std::num::Zero;
use std::ptr; use std::ptr;
use std::str; use std::str;
use std::rc::Rc; use std::rc::Rc;
@ -366,7 +367,7 @@ impl Font {
for (glyphs, _offset, slice_range) in run.iter_slices_for_range(range) { for (glyphs, _offset, slice_range) in run.iter_slices_for_range(range) {
for (_i, glyph) in glyphs.iter_glyphs_for_char_range(&slice_range) { for (_i, glyph) in 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(Au::zero_point()); let glyph_offset = glyph.offset().unwrap_or(Zero::zero());
let azglyph = struct__AzGlyph { let azglyph = struct__AzGlyph {
mIndex: glyph.index() as uint32_t, mIndex: glyph.index() as uint32_t,

View file

@ -5,10 +5,9 @@
use servo_util::vec::*; use servo_util::vec::*;
use servo_util::range::Range; use servo_util::range::Range;
use servo_util::geometry::Au; use servo_util::geometry::Au;
use servo_util::geometry;
use std::cmp::{Ord, Eq}; use std::cmp::{Ord, Eq};
use std::num::NumCast; use std::num::{NumCast, Zero};
use std::mem; use std::mem;
use std::u16; use std::u16;
use std::slice; use std::slice;
@ -441,7 +440,7 @@ impl GlyphData {
ligature_start: bool) ligature_start: bool)
-> GlyphData { -> GlyphData {
let offset = match offset { let offset = match offset {
None => geometry::zero_point(), None => Zero::zero(),
Some(o) => o Some(o) => o
}; };
@ -536,7 +535,7 @@ impl<'a> GlyphStore {
fn glyph_is_compressible(data: &GlyphData) -> bool { fn glyph_is_compressible(data: &GlyphData) -> bool {
is_simple_glyph_id(data.index) is_simple_glyph_id(data.index)
&& is_simple_advance(data.advance) && is_simple_advance(data.advance)
&& data.offset == geometry::zero_point() && data.offset.is_zero()
&& data.cluster_start // others are stored in detail buffer && data.cluster_start // others are stored in detail buffer
} }

View file

@ -36,6 +36,7 @@ use servo_msg::compositor_msg::{FixedPosition, LayerId, Scrollable};
use servo_util::geometry::Au; use servo_util::geometry::Au;
use servo_util::geometry; use servo_util::geometry;
use servo_util::smallvec::{SmallVec, SmallVec0}; use servo_util::smallvec::{SmallVec, SmallVec0};
use std::num::Zero;
use style::computed_values::{LPA_Auto, LPA_Length, LPA_Percentage, LPN_Length, LPN_None}; use style::computed_values::{LPA_Auto, LPA_Length, LPA_Percentage, LPN_Length, LPN_None};
use style::computed_values::{LPN_Percentage, LP_Length, LP_Percentage}; use style::computed_values::{LPN_Percentage, LP_Length, LP_Percentage};
use sync::Arc; use sync::Arc;
@ -1548,7 +1549,7 @@ impl Flow for BlockFlow {
if self.is_root() { if self.is_root() {
debug!("Setting root position"); debug!("Setting root position");
self.base.position.origin = Au::zero_point(); self.base.position.origin = Zero::zero();
self.base.position.size.width = ctx.screen_size.width; self.base.position.size.width = ctx.screen_size.width;
self.base.floats = Floats::new(); self.base.floats = Floats::new();
// Root element is not floated // Root element is not floated

View file

@ -430,7 +430,7 @@ impl Box {
Box { Box {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node), node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
style: node.style().clone(), style: node.style().clone(),
border_box: RefCell::new(Au::zero_rect()), border_box: RefCell::new(Rect::zero()),
border: RefCell::new(Zero::zero()), border: RefCell::new(Zero::zero()),
padding: RefCell::new(Zero::zero()), padding: RefCell::new(Zero::zero()),
margin: RefCell::new(Zero::zero()), margin: RefCell::new(Zero::zero()),
@ -446,7 +446,7 @@ impl Box {
Box { Box {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node), node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
style: node.style().clone(), style: node.style().clone(),
border_box: RefCell::new(Au::zero_rect()), border_box: RefCell::new(Rect::zero()),
border: RefCell::new(Zero::zero()), border: RefCell::new(Zero::zero()),
padding: RefCell::new(Zero::zero()), padding: RefCell::new(Zero::zero()),
margin: RefCell::new(Zero::zero()), margin: RefCell::new(Zero::zero()),
@ -473,7 +473,7 @@ impl Box {
Box { Box {
node: OpaqueNodeMethods::from_thread_safe_layout_node(node), node: OpaqueNodeMethods::from_thread_safe_layout_node(node),
style: Arc::new(node_style), style: Arc::new(node_style),
border_box: RefCell::new(Au::zero_rect()), border_box: RefCell::new(Rect::zero()),
border: RefCell::new(Zero::zero()), border: RefCell::new(Zero::zero()),
padding: RefCell::new(Zero::zero()), padding: RefCell::new(Zero::zero()),
margin: RefCell::new(Zero::zero()), margin: RefCell::new(Zero::zero()),
@ -492,7 +492,7 @@ impl Box {
Box { Box {
node: node, node: node,
style: style, style: style,
border_box: RefCell::new(Au::zero_rect()), border_box: RefCell::new(Rect::zero()),
border: RefCell::new(Zero::zero()), border: RefCell::new(Zero::zero()),
padding: RefCell::new(Zero::zero()), padding: RefCell::new(Zero::zero()),
margin: RefCell::new(Zero::zero()), margin: RefCell::new(Zero::zero()),

View file

@ -818,8 +818,8 @@ impl BaseFlow {
prev_sibling: Rawlink::none(), prev_sibling: Rawlink::none(),
intrinsic_widths: IntrinsicWidths::new(), intrinsic_widths: IntrinsicWidths::new(),
position: Au::zero_rect(), position: Rect::zero(),
overflow: Au::zero_rect(), overflow: Rect::zero(),
parallel: FlowParallelInfo::new(), parallel: FlowParallelInfo::new(),

View file

@ -749,7 +749,7 @@ impl LayoutTask {
union_boxes_for_node(&mut rect, display_list.iter(), node) union_boxes_for_node(&mut rect, display_list.iter(), node)
} }
} }
reply_chan.send(ContentBoxResponse(rect.unwrap_or(Au::zero_rect()))) reply_chan.send(ContentBoxResponse(rect.unwrap_or(Rect::zero())))
} }
ContentBoxesQuery(node, reply_chan) => { ContentBoxesQuery(node, reply_chan) => {
let node: OpaqueNode = OpaqueNodeMethods::from_script_node(node); let node: OpaqueNode = OpaqueNodeMethods::from_script_node(node);

View file

@ -4,7 +4,6 @@
use geom::point::Point2D; use geom::point::Point2D;
use geom::rect::Rect; use geom::rect::Rect;
use geom::size::Size2D;
use std::num::{NumCast, One, Zero}; use std::num::{NumCast, One, Zero};
use std::fmt; use std::fmt;
@ -152,17 +151,6 @@ impl Au {
else { return Au(s - res) }; else { return Au(s - res) };
} }
#[inline]
pub fn zero_point() -> Point2D<Au> {
Point2D(Au(0), Au(0))
}
#[inline]
pub fn zero_rect() -> Rect<Au> {
let z = Au(0);
Rect(Point2D(z, z), Size2D(z, z))
}
#[inline] #[inline]
pub fn from_pt(pt: f64) -> Au { pub fn from_pt(pt: f64) -> Au {
from_px(pt_to_px(pt) as int) from_px(pt_to_px(pt) as int)
@ -198,19 +186,6 @@ pub fn px_to_pt(px: f64) -> f64 {
px / 96f64 * 72f64 px / 96f64 * 72f64
} }
pub fn zero_rect() -> Rect<Au> {
let z = Au(0);
Rect(Point2D(z, z), Size2D(z, z))
}
pub fn zero_point() -> Point2D<Au> {
Point2D(Au(0), Au(0))
}
pub fn zero_size() -> Size2D<Au> {
Size2D(Au(0), Au(0))
}
pub fn from_frac_px(px: f64) -> Au { pub fn from_frac_px(px: f64) -> Au {
Au((px * 60f64) as i32) Au((px * 60f64) as i32)
} }

@ -1 +1 @@
Subproject commit 8d67075e4affa75fc0872ebfdcc9b3ec8c6fe69b Subproject commit ab55c3f4f6edab87fe5802c58866d1e4455232ab