auto merge of #4420 : servo/servo/fix-warnings, r=Ms2ger

This commit is contained in:
bors-servo 2014-12-18 04:42:50 -07:00
commit eea49ee1d9
16 changed files with 95 additions and 118 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

@ -7,11 +7,11 @@ use self::GlyphInfo::*;
use servo_util::vec::*; use servo_util::vec::*;
use servo_util::range; use servo_util::range;
use servo_util::range::{Range, RangeIndex, IntRangeIndex, EachIndex}; use servo_util::range::{Range, RangeIndex, 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

@ -28,12 +28,11 @@ use gfx::text::glyph::CharIndex;
use servo_util::geometry::Au; use servo_util::geometry::Au;
use servo_util::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use servo_util::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use servo_util::opts; use servo_util::opts;
use servo_util::range::{IntRangeIndex, Range, RangeIndex}; use servo_util::range::{Range, RangeIndex};
use servo_util::arc_ptr_eq; 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

@ -78,7 +78,7 @@ fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) | ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning), ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning),
ast::TyPath(_, _, id) => { ast::TyPath(_, _, id) => {
match cx.tcx.def_map.borrow().get_copy(&id) { match cx.tcx.def_map.borrow()[id].clone() {
def::DefTy(def_id, _) => { def::DefTy(def_id, _) => {
if ty::has_attr(cx.tcx, def_id, "must_root") { if ty::has_attr(cx.tcx, def_id, "must_root") {
cx.span_lint(UNROOTED_MUST_ROOT, ty.span, warning); cx.span_lint(UNROOTED_MUST_ROOT, ty.span, warning);

View file

@ -104,8 +104,8 @@ class CastableObjectUnwrapper():
self.substitution = { self.substitution = {
"type": descriptor.nativeType, "type": descriptor.nativeType,
"depth": descriptor.interface.inheritanceDepth(), "depth": descriptor.interface.inheritanceDepth(),
"prototype": "PrototypeList::id::" + descriptor.name, "prototype": "PrototypeList::ID::" + descriptor.name,
"protoID": "PrototypeList::id::" + descriptor.name + " as uint", "protoID": "PrototypeList::ID::" + descriptor.name + " as uint",
"source": source, "source": source,
"codeOnFailure": CGIndenter(CGGeneric(codeOnFailure), 4).define(), "codeOnFailure": CGIndenter(CGGeneric(codeOnFailure), 4).define(),
} }
@ -1418,12 +1418,12 @@ class CGNamespace(CGWrapper):
return CGNamespace(namespaces[0], inner, public=public) return CGNamespace(namespaces[0], inner, public=public)
def DOMClass(descriptor): def DOMClass(descriptor):
protoList = ['PrototypeList::id::' + proto for proto in descriptor.prototypeChain] protoList = ['PrototypeList::ID::' + proto for proto in descriptor.prototypeChain]
# Pad out the list to the right length with id::Count so we # Pad out the list to the right length with ID::Count so we
# guarantee that all the lists are the same length. id::Count # guarantee that all the lists are the same length. id::Count
# is never the ID of any prototype, so it's safe to use as # is never the ID of any prototype, so it's safe to use as
# padding. # padding.
protoList.extend(['PrototypeList::id::Count'] * (descriptor.config.maxProtoChainLength - len(protoList))) protoList.extend(['PrototypeList::ID::Count'] * (descriptor.config.maxProtoChainLength - len(protoList)))
prototypeChainString = ', '.join(protoList) prototypeChainString = ', '.join(protoList)
return """DOMClass { return """DOMClass {
interface_chain: [ %s ], interface_chain: [ %s ],
@ -1801,7 +1801,7 @@ def CreateBindingJSObject(descriptor, parent=None):
if descriptor.proxy: if descriptor.proxy:
assert not descriptor.isGlobal() assert not descriptor.isGlobal()
create += """ create += """
let handler = RegisterBindings::proxy_handlers[PrototypeList::proxies::%s as uint]; let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as uint];
let mut private = PrivateValue(squirrel_away_unique(aObject) as *const libc::c_void); let mut private = PrivateValue(squirrel_away_unique(aObject) as *const libc::c_void);
let obj = with_compartment(aCx, proto, || { let obj = with_compartment(aCx, proto, || {
NewProxyObject(aCx, handler, NewProxyObject(aCx, handler,
@ -1887,8 +1887,8 @@ class CGIDLInterface(CGThing):
} }
return string.Template(""" return string.Template("""
impl IDLInterface for ${type} { impl IDLInterface for ${type} {
fn get_prototype_id(_: Option<${type}>) -> PrototypeList::id { fn get_prototype_id(_: Option<${type}>) -> PrototypeList::ID {
PrototypeList::id::${type} PrototypeList::ID::${type}
} }
fn get_prototype_depth(_: Option<${type}>) -> uint { fn get_prototype_depth(_: Option<${type}>) -> uint {
${depth} ${depth}
@ -2023,7 +2023,7 @@ class CGGetPerInterfaceObject(CGAbstractMethod):
Argument('*mut JSObject', 'aReceiver')] Argument('*mut JSObject', 'aReceiver')]
CGAbstractMethod.__init__(self, descriptor, name, CGAbstractMethod.__init__(self, descriptor, name,
'*mut JSObject', args, pub=pub) '*mut JSObject', args, pub=pub)
self.id = idPrefix + "id::" + self.descriptor.name self.id = idPrefix + "ID::" + self.descriptor.name
def definition_body(self): def definition_body(self):
return CGGeneric(""" return CGGeneric("""
@ -2682,7 +2682,7 @@ class CGMemberJITInfo(CGThing):
self.descriptor = descriptor self.descriptor = descriptor
def defineJitInfo(self, infoName, opName, infallible): def defineJitInfo(self, infoName, opName, infallible):
protoID = "PrototypeList::id::%s as u32" % self.descriptor.name protoID = "PrototypeList::ID::%s as u32" % self.descriptor.name
depth = self.descriptor.interface.inheritanceDepth() depth = self.descriptor.interface.inheritanceDepth()
failstr = "true" if infallible else "false" failstr = "true" if infallible else "false"
return ("\n" return ("\n"
@ -4397,7 +4397,7 @@ class CGRegisterProxyHandlersMethod(CGAbstractMethod):
def definition_body(self): def definition_body(self):
return CGList([ return CGList([
CGGeneric("proxy_handlers[proxies::%s as uint] = codegen::Bindings::%sBinding::DefineProxyHandler();" % (desc.name, desc.name)) CGGeneric("proxy_handlers[Proxies::%s as uint] = codegen::Bindings::%sBinding::DefineProxyHandler();" % (desc.name, desc.name))
for desc in self.descriptors for desc in self.descriptors
], "\n") ], "\n")
@ -5135,8 +5135,8 @@ class GlobalGenRoots():
return CGList([ return CGList([
CGGeneric(AUTOGENERATED_WARNING_COMMENT), CGGeneric(AUTOGENERATED_WARNING_COMMENT),
CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength), CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength),
CGNonNamespacedEnum('id', protos, [0], deriving="PartialEq"), CGNonNamespacedEnum('ID', protos, [0], deriving="PartialEq"),
CGNonNamespacedEnum('proxies', proxies, [0], deriving="PartialEq"), CGNonNamespacedEnum('Proxies', proxies, [0], deriving="PartialEq"),
]) ])
@ -5150,7 +5150,7 @@ class GlobalGenRoots():
return CGImports(code, [], [ return CGImports(code, [], [
'dom::bindings::codegen', 'dom::bindings::codegen',
'dom::bindings::codegen::PrototypeList::proxies', 'dom::bindings::codegen::PrototypeList::Proxies',
'js::jsapi::JSContext', 'js::jsapi::JSContext',
'js::jsapi::JSObject', 'js::jsapi::JSObject',
'libc', 'libc',

View file

@ -6,6 +6,7 @@
//! Conversions of Rust values to and from `JSVal`. //! Conversions of Rust values to and from `JSVal`.
use dom::bindings::codegen::PrototypeList;
use dom::bindings::js::{JS, JSRef, Root}; use dom::bindings::js::{JS, JSRef, Root};
use dom::bindings::str::ByteString; use dom::bindings::str::ByteString;
use dom::bindings::utils::{Reflectable, Reflector}; use dom::bindings::utils::{Reflectable, Reflector};
@ -29,15 +30,13 @@ use libc;
use std::default; use std::default;
use std::slice; use std::slice;
use dom::bindings::codegen::PrototypeList;
/// A trait to retrieve the constants necessary to check if a `JSObject` /// A trait to retrieve the constants necessary to check if a `JSObject`
/// implements a given interface. /// implements a given interface.
// FIXME (https://github.com/rust-lang/rfcs/pull/4) // FIXME (https://github.com/rust-lang/rfcs/pull/4)
// remove Option<Self> arguments. // remove Option<Self> arguments.
pub trait IDLInterface { pub trait IDLInterface {
/// Returns the prototype ID. /// Returns the prototype ID.
fn get_prototype_id(_: Option<Self>) -> PrototypeList::id; fn get_prototype_id(_: Option<Self>) -> PrototypeList::ID;
/// Returns the prototype depth, i.e., the number of interfaces this /// Returns the prototype depth, i.e., the number of interfaces this
/// interface inherits from. /// interface inherits from.
fn get_prototype_depth(_: Option<Self>) -> uint; fn get_prototype_depth(_: Option<Self>) -> uint;

View file

@ -124,7 +124,7 @@ pub unsafe fn get_dom_class(obj: *mut JSObject) -> Result<DOMClass, ()> {
/// not a reflector for a DOM object of the given type (as defined by the /// not a reflector for a DOM object of the given type (as defined by the
/// proto_id and proto_depth). /// proto_id and proto_depth).
pub fn unwrap_jsmanaged<T: Reflectable>(mut obj: *mut JSObject, pub fn unwrap_jsmanaged<T: Reflectable>(mut obj: *mut JSObject,
proto_id: PrototypeList::id, proto_id: PrototypeList::ID,
proto_depth: uint) -> Result<JS<T>, ()> { proto_depth: uint) -> Result<JS<T>, ()> {
unsafe { unsafe {
let dom_class = get_dom_class(obj).or_else(|_| { let dom_class = get_dom_class(obj).or_else(|_| {
@ -234,7 +234,7 @@ pub struct NativePropertyHooks {
pub struct DOMClass { pub struct DOMClass {
/// A list of interfaces that this object implements, in order of decreasing /// A list of interfaces that this object implements, in order of decreasing
/// derivedness. /// derivedness.
pub interface_chain: [PrototypeList::id, ..MAX_PROTO_CHAIN_LENGTH], pub interface_chain: [PrototypeList::ID, ..MAX_PROTO_CHAIN_LENGTH],
/// The NativePropertyHooks for the interface associated with this class. /// The NativePropertyHooks for the interface associated with this class.
pub native_hooks: &'static NativePropertyHooks, pub native_hooks: &'static NativePropertyHooks,
@ -421,7 +421,7 @@ pub unsafe extern fn ThrowingConstructor(cx: *mut JSContext, _argc: c_uint, _vp:
/// Construct and cache the ProtoOrIfaceArray for the given global. /// Construct and cache the ProtoOrIfaceArray for the given global.
/// Fails if the argument is not a DOM global. /// Fails if the argument is not a DOM global.
pub fn initialize_global(global: *mut JSObject) { pub fn initialize_global(global: *mut JSObject) {
let protoArray = box () ([0 as *mut JSObject, ..PrototypeList::id::Count as uint]); let protoArray = box () ([0 as *mut JSObject, ..PrototypeList::ID::Count as uint]);
unsafe { unsafe {
assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0); assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0);
let box_ = squirrel_away_unique(protoArray); let box_ = squirrel_away_unique(protoArray);

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> {

View file

@ -6,29 +6,15 @@ use std::cmp::{max, min};
use std::iter; use std::iter;
use std::fmt; use std::fmt;
use std::num; use std::num;
use std::num::{Int, Bounded, Zero}; use std::num::Int;
/// An index type to be used by a `Range` /// An index type to be used by a `Range`
pub trait RangeIndex: Copy pub trait RangeIndex<T>: Int + fmt::Show {
+ Clone
+ fmt::Show
+ PartialEq
+ PartialOrd
+ Eq
+ Ord
+ Add<Self, Self>
+ Sub<Self, Self>
+ Neg<Self>
+ Zero {}
pub trait IntRangeIndex<T>: RangeIndex + Copy {
fn new(x: T) -> Self; fn new(x: T) -> Self;
fn get(self) -> T; fn get(self) -> T;
} }
impl RangeIndex for int {} impl RangeIndex<int> for int {
impl IntRangeIndex<int> for int {
#[inline] #[inline]
fn new(x: int) -> int { x } fn new(x: int) -> int { x }
@ -40,7 +26,7 @@ impl IntRangeIndex<int> for int {
#[macro_export] #[macro_export]
macro_rules! int_range_index { macro_rules! int_range_index {
($(#[$attr:meta])* struct $Self:ident($T:ty)) => ( ($(#[$attr:meta])* struct $Self:ident($T:ty)) => (
#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show, Zero)] #[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show)]
$(#[$attr])* $(#[$attr])*
pub struct $Self(pub $T); pub struct $Self(pub $T);
@ -51,7 +37,18 @@ macro_rules! int_range_index {
} }
} }
impl RangeIndex for $Self {} impl RangeIndex<$T> for $Self {
#[inline]
fn new(x: $T) -> $Self {
$Self(x)
}
#[inline]
fn get(self) -> $T {
match self { $Self(x) => x }
}
}
impl ::std::num::Int for $Self { impl ::std::num::Int for $Self {
fn zero() -> $Self { $Self(0) } fn zero() -> $Self { $Self(0) }
fn one() -> $Self { $Self(1) } fn one() -> $Self { $Self(1) }
@ -77,18 +74,6 @@ macro_rules! int_range_index {
} }
} }
impl IntRangeIndex<$T> for $Self {
#[inline]
fn new(x: $T) -> $Self {
$Self(x)
}
#[inline]
fn get(self) -> $T {
match self { $Self(x) => x }
}
}
impl Add<$Self, $Self> for $Self { impl Add<$Self, $Self> for $Self {
#[inline] #[inline]
fn add(&self, other: &$Self) -> $Self { fn add(&self, other: &$Self) -> $Self {
@ -196,7 +181,7 @@ pub struct Range<I> {
length: I, length: I,
} }
impl<I: RangeIndex> fmt::Show for Range<I> { impl<I: RangeIndex<T>, T> fmt::Show for Range<I> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "[{} .. {})", self.begin(), self.end()) write!(f, "[{} .. {})", self.begin(), self.end())
} }
@ -207,14 +192,14 @@ pub struct EachIndex<T, I> {
it: iter::Range<T>, it: iter::Range<T>,
} }
pub fn each_index<T: Int, I: IntRangeIndex<T>>(start: I, stop: I) -> EachIndex<T, I> { pub fn each_index<T: Int, I: RangeIndex<T>>(start: I, stop: I) -> EachIndex<T, I> {
EachIndex { it: iter::range(start.get(), stop.get()) } EachIndex { it: iter::range(start.get(), stop.get()) }
} }
impl<T: Int, I: IntRangeIndex<T>> Iterator<I> for EachIndex<T, I> { impl<T: Int, I: RangeIndex<T>> Iterator<I> for EachIndex<T, I> {
#[inline] #[inline]
fn next(&mut self) -> Option<I> { fn next(&mut self) -> Option<I> {
self.it.next().map(|i| IntRangeIndex::new(i)) self.it.next().map(|i| RangeIndex::new(i))
} }
#[inline] #[inline]
@ -223,7 +208,7 @@ impl<T: Int, I: IntRangeIndex<T>> Iterator<I> for EachIndex<T, I> {
} }
} }
impl<I: RangeIndex> Range<I> { impl<I: RangeIndex<T>, T> Range<I> {
/// Create a new range from beginning and length offsets. This could be /// Create a new range from beginning and length offsets. This could be
/// denoted as `[begin, begin + length)`. /// denoted as `[begin, begin + length)`.
/// ///
@ -239,7 +224,7 @@ impl<I: RangeIndex> Range<I> {
#[inline] #[inline]
pub fn empty() -> Range<I> { pub fn empty() -> Range<I> {
Range::new(num::zero(), num::zero()) Range::new(Int::zero(), Int::zero())
} }
/// The index offset to the beginning of the range. /// The index offset to the beginning of the range.
@ -287,7 +272,7 @@ impl<I: RangeIndex> Range<I> {
/// `true` if the offset from the beginning to the end of the range is zero. /// `true` if the offset from the beginning to the end of the range is zero.
#[inline] #[inline]
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.length().is_zero() self.length() == Int::zero()
} }
/// Shift the entire range by the supplied index delta. /// Shift the entire range by the supplied index delta.
@ -360,7 +345,7 @@ impl<I: RangeIndex> Range<I> {
} }
/// Methods for `Range`s with indices based on integer values /// Methods for `Range`s with indices based on integer values
impl<T: Int+Bounded, I: IntRangeIndex<T>> Range<I> { impl<T: Int, I: RangeIndex<T>> Range<I> {
/// Returns an iterater that increments over `[begin, end)`. /// Returns an iterater that increments over `[begin, end)`.
#[inline] #[inline]
pub fn each_index(&self) -> EachIndex<T, I> { pub fn each_index(&self) -> EachIndex<T, I> {
@ -372,7 +357,7 @@ impl<T: Int+Bounded, I: IntRangeIndex<T>> Range<I> {
let s_len = s.len(); let s_len = s.len();
match num::cast::<uint, T>(s_len) { match num::cast::<uint, T>(s_len) {
Some(len) => { Some(len) => {
let len = IntRangeIndex::new(len); let len = RangeIndex::new(len);
self.begin() < len self.begin() < len
&& self.end() <= len && self.end() <= len
&& self.length() <= len && self.length() <= len
@ -381,8 +366,8 @@ impl<T: Int+Bounded, I: IntRangeIndex<T>> Range<I> {
debug!("Range<T>::is_valid_for_string: string length (len={}) is longer than the \ debug!("Range<T>::is_valid_for_string: string length (len={}) is longer than the \
max value for the range index (max={})", s_len, max value for the range index (max={})", s_len,
{ {
let max: T = Bounded::max_value(); let max: T = Int::max_value();
let val: I = IntRangeIndex::new(max); let val: I = RangeIndex::new(max);
val val
}); });
false false

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",
] ]

View file

@ -38,14 +38,16 @@ class MachCommands(CommandBase):
@CommandArgument('--verbose', '-v', @CommandArgument('--verbose', '-v',
action='store_true', action='store_true',
help='Print verbose output') help='Print verbose output')
@CommandArgument('params', nargs='...',
help="Command-line arguments to be passed through to Cargo")
def build(self, target=None, release=False, jobs=None, android=None, def build(self, target=None, release=False, jobs=None, android=None,
verbose=False, debug_mozjs=False): verbose=False, debug_mozjs=False, params=None):
self.ensure_bootstrapped() self.ensure_bootstrapped()
if android is None: if android is None:
android = self.config["build"]["android"] android = self.config["build"]["android"]
opts = [] opts = params or []
features = [] features = []
if release: if release: