Upgrade to rustc 551a74dddd84cf01440ee84148ebd18bc68bd7c8.

This commit is contained in:
Simon Sapin 2015-04-23 00:14:02 +02:00 committed by Josh Matthews
parent 7b87085c18
commit ef8edd4e87
168 changed files with 2247 additions and 2408 deletions

View file

@ -43,9 +43,6 @@ path = "../profile_traits"
[dependencies.util]
path = "../util"
[dependencies.cssparser]
git = "https://github.com/servo/rust-cssparser"
[dependencies.selectors]
git = "https://github.com/servo/rust-selectors"
@ -70,4 +67,4 @@ url = "0.2.16"
bitflags = "*"
rustc-serialize = "0.3"
libc = "*"
cssparser = "0.3.1"

View file

@ -31,7 +31,7 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation>
property_animation.update(new_style, 0.0);
// Kick off the animation.
let now = clock_ticks::precise_time_s();
let now = clock_ticks::precise_time_s() as f32;
let animation_style = new_style.get_animation();
let start_time = now + animation_style.transition_delay.0.get_mod(i).seconds();
new_animations_sender.send(Animation {
@ -66,7 +66,7 @@ pub fn recalc_style_for_animation(flow: &mut Flow, animation: &Animation) {
return
}
let now = clock_ticks::precise_time_s();
let now = clock_ticks::precise_time_s() as f32;
let mut progress = (now - animation.start_time) / animation.duration();
if progress > 1.0 {
progress = 1.0
@ -91,7 +91,7 @@ pub fn recalc_style_for_animation(flow: &mut Flow, animation: &Animation) {
/// Handles animation updates.
pub fn tick_all_animations(layout_task: &LayoutTask, rw_data: &mut LayoutTaskData) {
let running_animations = mem::replace(&mut rw_data.running_animations, Vec::new());
let now = clock_ticks::precise_time_s();
let now = clock_ticks::precise_time_s() as f32;
for running_animation in running_animations.into_iter() {
layout_task.tick_animation(&running_animation, rw_data);

View file

@ -1480,13 +1480,12 @@ impl FlowConstructionUtils for FlowRef {
///
/// This must not be public because only the layout constructor can do this.
fn add_new_child(&mut self, mut new_child: FlowRef) {
let base = flow::mut_base(&mut **self);
{
let kid_base = flow::mut_base(&mut *new_child);
kid_base.parallel.parent = parallel::mut_owned_flow_to_unsafe_flow(self);
}
let base = flow::mut_base(&mut **self);
base.children.push_back(new_child);
let _ = base.parallel.children_count.fetch_add(1, Ordering::Relaxed);
}

View file

@ -34,7 +34,7 @@ use style::selector_matching::{Stylist, DeclarationBlock};
use util::arc_ptr_eq;
use util::cache::{LRUCache, SimpleHashCache};
use util::opts;
use util::smallvec::{SmallVec, SmallVec16};
use util::smallvec::SmallVec16;
use util::vec::ForgetfulSink;
pub struct ApplicableDeclarations {
@ -689,7 +689,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
let mut damage = self.cascade_node_pseudo_element(
layout_context,
parent_style,
applicable_declarations.normal.as_slice(),
&applicable_declarations.normal,
&mut layout_data.shared_data.style,
applicable_declarations_cache,
new_animations_sender,

View file

@ -39,8 +39,6 @@ use png::{self, PixelsByColorType};
use std::cmp;
use std::default::Default;
use std::iter::repeat;
use std::num::Float;
use std::num::ToPrimitive;
use std::sync::Arc;
use std::sync::mpsc::channel;
use style::computed_values::filter::Filter;
@ -247,13 +245,13 @@ pub trait FragmentDisplayListBuilding {
fn handle_overlapping_radii(size: &Size2D<Au>, radii: &BorderRadii<Au>) -> BorderRadii<Au> {
// No two corners' border radii may add up to more than the length of the edge
// between them. To prevent that, all radii are scaled down uniformly.
fn scale_factor(radius_a: Au, radius_b: Au, edge_length: Au) -> f64 {
fn scale_factor(radius_a: Au, radius_b: Au, edge_length: Au) -> f32 {
let required = radius_a + radius_b;
if required <= edge_length {
1.0
} else {
to_frac_px(edge_length) / to_frac_px(required)
edge_length.to_frac32_px() / required.to_frac32_px()
}
}
@ -503,10 +501,10 @@ impl FragmentDisplayListBuilding for Fragment {
// between the starting point and the ending point.
let delta = match gradient.angle_or_corner {
AngleOrCorner::Angle(angle) => {
Point2D(Au((angle.radians().sin() *
absolute_bounds.size.width.to_f64().unwrap() / 2.0) as i32),
Au((-angle.radians().cos() *
absolute_bounds.size.height.to_f64().unwrap() / 2.0) as i32))
Point2D(Au::from_frac32_px(angle.radians().sin() *
absolute_bounds.size.width.to_frac32_px() / 2.0),
Au::from_frac32_px(-angle.radians().cos() *
absolute_bounds.size.height.to_frac32_px() / 2.0))
}
AngleOrCorner::Corner(horizontal, vertical) => {
let x_factor = match horizontal {
@ -517,14 +515,14 @@ impl FragmentDisplayListBuilding for Fragment {
VerticalDirection::Top => -1,
VerticalDirection::Bottom => 1,
};
Point2D(Au(x_factor * absolute_bounds.size.width.to_i32().unwrap() / 2),
Au(y_factor * absolute_bounds.size.height.to_i32().unwrap() / 2))
Point2D(absolute_bounds.size.width * x_factor / 2,
absolute_bounds.size.height * y_factor / 2)
}
};
// This is the length of the gradient line.
let length = Au((delta.x.to_f64().unwrap() * 2.0).hypot(delta.y.to_f64().unwrap() * 2.0)
as i32);
let length = Au::from_frac32_px(
(delta.x.to_frac32_px() * 2.0).hypot(delta.y.to_frac32_px() * 2.0));
// Determine the position of each stop per CSS-IMAGES § 3.4.
//

View file

@ -55,7 +55,6 @@ use rustc_serialize::{Encoder, Encodable};
use std::fmt;
use std::iter::Zip;
use std::mem;
use std::num::FromPrimitive;
use std::raw;
use std::slice::IterMut;
use std::sync::Arc;
@ -582,13 +581,13 @@ impl FlowFlags {
#[inline]
pub fn text_align(self) -> text_align::T {
FromPrimitive::from_u32((self & TEXT_ALIGN).bits() >> TEXT_ALIGN_SHIFT).unwrap()
text_align::T::from_u32((self & TEXT_ALIGN).bits() >> TEXT_ALIGN_SHIFT).unwrap()
}
#[inline]
pub fn set_text_align(&mut self, value: text_align::T) {
*self = (*self & !TEXT_ALIGN) |
FlowFlags::from_bits((value as u32) << TEXT_ALIGN_SHIFT).unwrap();
FlowFlags::from_bits(value.to_u32() << TEXT_ALIGN_SHIFT).unwrap();
}
#[inline]
@ -876,7 +875,6 @@ impl Encodable for BaseFlow {
}
}
#[unsafe_destructor]
impl Drop for BaseFlow {
fn drop(&mut self) {
if self.strong_ref_count.load(Ordering::SeqCst) != 0 &&

View file

@ -78,7 +78,8 @@ impl DerefMut for FlowRef {
impl Drop for FlowRef {
fn drop(&mut self) {
unsafe {
if self.object.vtable.is_null() {
if self.object.vtable.is_null() ||
self.object.vtable as usize == mem::POST_DROP_USIZE {
return
}
if flow::base(&**self).strong_ref_count().fetch_sub(1, Ordering::Release) != 1 {
@ -102,7 +103,7 @@ impl Drop for FlowRef {
let object_align = vtable[2];
let fake_data = heap::allocate(object_size, object_align);
ptr::copy(fake_data, flow_ref.object.data as *const u8, object_size);
ptr::copy(flow_ref.object.data as *const u8, fake_data, object_size);
let fake_box = raw::TraitObject { vtable: flow_ref.object.vtable, data: fake_data as *mut () };
let fake_flow = mem::transmute::<raw::TraitObject, Box<Flow>>(fake_box);
@ -181,7 +182,8 @@ impl Clone for WeakFlowRef {
impl Drop for WeakFlowRef {
fn drop(&mut self) {
unsafe {
if self.object.vtable.is_null() {
if self.object.vtable.is_null() ||
self.object.vtable as usize == mem::POST_DROP_USIZE {
return
}

View file

@ -34,7 +34,6 @@ use std::borrow::ToOwned;
use std::cmp::{max, min};
use std::collections::LinkedList;
use std::fmt;
use std::num::ToPrimitive;
use std::str::FromStr;
use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex};
@ -51,7 +50,6 @@ use url::Url;
use util::geometry::{self, Au, ZERO_POINT};
use util::logical_geometry::{LogicalRect, LogicalSize, LogicalMargin, WritingMode};
use util::range::*;
use util::smallvec::SmallVec;
use util::str::is_whitespace;
use util;
@ -453,8 +451,8 @@ impl ReplacedImageFragmentInfo {
if intrinsic_height == Au(0) {
intrinsic_width
} else {
let ratio = intrinsic_width.to_f32().unwrap() /
intrinsic_height.to_f32().unwrap();
let ratio = intrinsic_width.to_frac32_px() /
intrinsic_height.to_frac32_px();
let specified_height = ReplacedImageFragmentInfo::style_length(
style_block_size,
@ -468,7 +466,7 @@ impl ReplacedImageFragmentInfo {
style_min_block_size,
style_max_block_size,
Au(0));
Au((specified_height.to_f32().unwrap() * ratio) as i32)
Au::from_frac32_px(specified_height.to_frac32_px() * ratio)
}
},
MaybeAuto::Specified(w) => w,
@ -505,8 +503,8 @@ impl ReplacedImageFragmentInfo {
MaybeAuto::Auto => {
let intrinsic_width = fragment_inline_size;
let intrinsic_height = fragment_block_size;
let scale = intrinsic_width.to_f32().unwrap() / inline_size.to_f32().unwrap();
Au((intrinsic_height.to_f32().unwrap() / scale) as i32)
let scale = intrinsic_width.to_frac32_px() / inline_size.to_frac32_px();
Au::from_frac32_px(intrinsic_height.to_frac32_px() / scale)
},
MaybeAuto::Specified(h) => {
h

View file

@ -21,7 +21,7 @@ use std::sync::Arc;
use style::computed_values::content::ContentItem;
use style::computed_values::{display, list_style_type};
use style::properties::ComputedValues;
use util::smallvec::{SmallVec, SmallVec8};
use util::smallvec::SmallVec8;
// Decimal styles per CSS-COUNTER-STYLES § 6.1:
static DECIMAL: [char; 10] = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ];
@ -530,9 +530,7 @@ fn push_alphabetic_representation(mut value: i32, system: &[char], accumulator:
value = ((value as usize) / system.len()) as i32;
}
for i in (0..string.len()).rev() {
accumulator.push(*string.get(i))
}
accumulator.extend(string.iter().cloned().rev())
}
/// Pushes the string that represents the value rendered using the given *numeric system* onto the
@ -554,8 +552,6 @@ fn push_numeric_representation(mut value: i32, system: &[char], accumulator: &mu
}
// Step 3.
for &ch in string.iter().rev() {
accumulator.push(ch)
}
accumulator.extend(string.iter().cloned().rev())
}

View file

@ -210,7 +210,10 @@ impl<'a> LayoutDamageComputation for &'a mut (Flow + 'a) {
.insert(self_base.restyle_damage.damage_for_child(
is_absolutely_positioned,
child_is_absolutely_positioned));
special_damage.insert(kid.compute_layout_damage());
{
let kid: &mut Flow = kid;
special_damage.insert(kid.compute_layout_damage());
}
self_base.restyle_damage
.insert(flow::base(kid).restyle_damage.damage_for_parent(
child_is_absolutely_positioned));

View file

@ -25,8 +25,6 @@ use gfx::text::text_run::TextRun;
use std::cmp::max;
use std::fmt;
use std::mem;
use std::num::ToPrimitive;
use std::ops::{Add, Sub, Mul, Div, Rem, Neg, Shl, Shr, Not, BitOr, BitAnd, BitXor};
use std::sync::Arc;
use std::u16;
use style::computed_values::{display, overflow_x, text_align, text_justify, text_overflow};
@ -38,8 +36,8 @@ use util::range::{Range, RangeIndex};
use util;
// From gfxFontConstants.h in Firefox
static FONT_SUBSCRIPT_OFFSET_RATIO: f64 = 0.20;
static FONT_SUPERSCRIPT_OFFSET_RATIO: f64 = 0.34;
static FONT_SUBSCRIPT_OFFSET_RATIO: f32 = 0.20;
static FONT_SUPERSCRIPT_OFFSET_RATIO: f32 = 0.34;
/// `Line`s are represented as offsets into the child list, rather than
/// as an object that "owns" fragments. Choosing a different set of line
@ -928,7 +926,7 @@ impl InlineFlow {
text_align::T::left | text_align::T::right => unreachable!()
}
for fragment_index in line.range.begin()..line.range.end() {
for fragment_index in line.range.each_index() {
let fragment = fragments.get_mut(fragment_index.to_usize());
let size = fragment.border_box.size;
fragment.border_box = LogicalRect::new(fragment.style.writing_mode,
@ -1017,7 +1015,7 @@ impl InlineFlow {
line_distance_from_flow_block_start: Au,
baseline_distance_from_block_start: Au,
largest_depth_below_baseline: Au) {
for fragment_index in line.range.begin()..line.range.end() {
for fragment_index in line.range.each_index() {
// If any of the inline styles say `top` or `bottom`, adjust the vertical align
// appropriately.
//
@ -1295,7 +1293,7 @@ impl Flow for InlineFlow {
let (mut largest_block_size_for_top_fragments,
mut largest_block_size_for_bottom_fragments) = (Au(0), Au(0));
for fragment_index in line.range.begin()..line.range.end() {
for fragment_index in line.range.each_index() {
let fragment = &mut self.fragments.fragments[fragment_index.to_usize()];
let InlineMetrics {

View file

@ -73,7 +73,6 @@ use util::geometry::{Au, MAX_RECT};
use util::logical_geometry::LogicalPoint;
use util::mem::HeapSizeOf;
use util::opts;
use util::smallvec::SmallVec;
use util::task::spawn_named_with_send_on_failure;
use util::task_state;
use util::workqueue::WorkQueue;
@ -1097,7 +1096,7 @@ impl LayoutRPC for LayoutRPCImpl {
/// Requests the node containing the point of interest.
fn hit_test(&self, _: TrustedNodeAddress, point: Point2D<f32>) -> Result<HitTestResponse, ()> {
let point = Point2D(Au::from_frac_px(point.x as f64), Au::from_frac_px(point.y as f64));
let point = Point2D(Au::from_frac32_px(point.x), Au::from_frac32_px(point.y));
let resp = {
let &LayoutRPCImpl(ref rw_data) = self;
let rw_data = rw_data.lock().unwrap();
@ -1124,7 +1123,7 @@ impl LayoutRPC for LayoutRPCImpl {
fn mouse_over(&self, _: TrustedNodeAddress, point: Point2D<f32>)
-> Result<MouseOverResponse, ()> {
let mut mouse_over_list: Vec<DisplayItemMetadata> = vec!();
let point = Point2D(Au::from_frac_px(point.x as f64), Au::from_frac_px(point.y as f64));
let point = Point2D(Au::from_frac32_px(point.x), Au::from_frac32_px(point.y));
{
let &LayoutRPCImpl(ref rw_data) = self;
let rw_data = rw_data.lock().unwrap();

View file

@ -6,13 +6,12 @@
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#![feature(io)]
#![feature(filling_drop)]
#![feature(plugin)]
#![feature(rustc_private)]
#![feature(std_misc)]
#![feature(str_char)]
#![feature(thread_local)]
#![feature(unicode)]
#![feature(unsafe_destructor)]
#![feature(unsafe_no_drop_flag)]
#![deny(unsafe_code)]
@ -29,7 +28,7 @@ extern crate bitflags;
#[macro_use]
#[no_link]
extern crate "plugins" as servo_plugins;
extern crate plugins as servo_plugins;
extern crate net_traits;
#[macro_use]
extern crate profile_traits;
@ -37,7 +36,7 @@ extern crate profile_traits;
#[macro_use]
extern crate util;
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize;
extern crate alloc;
extern crate azure;
extern crate canvas;

View file

@ -434,8 +434,8 @@ impl ToGfxMatrix for ComputedMatrix {
self.m12 as f32,
self.m21 as f32,
self.m22 as f32,
self.m31.to_au(containing_size.width).to_subpx() as f32,
self.m32.to_au(containing_size.height).to_subpx() as f32)
self.m31.to_au(containing_size.width).to_frac32_px(),
self.m32.to_au(containing_size.height).to_frac32_px())
}
}
@ -446,7 +446,7 @@ trait ToAu {
impl ToAu for LengthAndPercentage {
#[inline]
fn to_au(&self, containing_size: Au) -> Au {
self.length + Au::from_frac_px(self.percentage * containing_size.to_subpx())
self.length + Au::from_frac32_px(self.percentage * containing_size.to_frac32_px())
}
}

View file

@ -82,7 +82,10 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
if opts::get().bubble_inline_sizes_separately {
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
root.traverse_postorder(&bubble_inline_sizes);
{
let root: &mut Flow = root;
root.traverse_postorder(&bubble_inline_sizes);
}
}
let assign_inline_sizes = AssignISizes { layout_context: &layout_context };

View file

@ -430,8 +430,8 @@ impl Flow for TableFlow {
// if there are any, or among all the columns if all are specified.
self.column_computed_inline_sizes.clear();
if num_unspecified_inline_sizes == 0 {
let ratio = content_inline_size.to_subpx() /
total_column_inline_size.to_subpx();
let ratio = content_inline_size.to_frac32_px() /
total_column_inline_size.to_frac32_px();
for column_inline_size in self.column_intrinsic_inline_sizes.iter() {
self.column_computed_inline_sizes.push(ColumnComputedInlineSize {
size: column_inline_size.minimum_length.scale_by(ratio),

View file

@ -590,7 +590,7 @@ impl SelectedAutoLayoutCandidateGuess {
/// Computes the weight needed to linearly interpolate `middle` between two guesses `low` and
/// `high` as specified by INTRINSIC § 4.3.
fn weight(low: Au, middle: Au, high: Au) -> CSSFloat {
(middle - low).to_subpx() / (high - low).to_subpx()
(middle - low).to_frac32_px() / (high - low).to_frac32_px()
}
/// Linearly interpolates between two guesses, as specified by INTRINSIC § 4.3.
@ -653,9 +653,9 @@ impl ExcessInlineSizeDistributionInfo {
// do?
if !column_intrinsic_inline_size.constrained &&
column_intrinsic_inline_size.percentage == 0.0 {
column_intrinsic_inline_size.preferred.to_subpx() /
column_intrinsic_inline_size.preferred.to_frac32_px() /
self.preferred_inline_size_of_nonconstrained_columns_with_no_percentage
.to_subpx()
.to_frac32_px()
} else {
0.0
}
@ -663,8 +663,8 @@ impl ExcessInlineSizeDistributionInfo {
1.0 / (self.count_of_nonconstrained_columns_with_no_percentage as CSSFloat)
} else if self.preferred_inline_size_of_constrained_columns_with_no_percentage >
Au(0) {
column_intrinsic_inline_size.preferred.to_subpx() /
self.preferred_inline_size_of_constrained_columns_with_no_percentage.to_subpx()
column_intrinsic_inline_size.preferred.to_frac32_px() /
self.preferred_inline_size_of_constrained_columns_with_no_percentage.to_frac32_px()
} else if self.total_percentage > 0.0 {
column_intrinsic_inline_size.percentage / self.total_percentage
} else {
@ -684,7 +684,7 @@ impl ExcessInlineSizeDistributionInfo {
/// An intermediate column size assignment.
struct IntermediateColumnInlineSize {
size: Au,
percentage: f64,
percentage: f32,
}
fn initial_computed_inline_size(block: &mut BlockFlow,

View file

@ -27,7 +27,7 @@ use util::geometry::Au;
use util::linked_list::split_off_head;
use util::logical_geometry::{LogicalSize, WritingMode};
use util::range::{Range, RangeIndex};
use util::smallvec::{SmallVec, SmallVec1};
use util::smallvec::SmallVec1;
/// A stack-allocated object for scanning an inline flow into `TextRun`-containing `TextFragment`s.
pub struct TextRunScanner {
@ -185,7 +185,7 @@ impl TextRunScanner {
};
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let mut font = fontgroup.fonts.get(0).borrow_mut();
let mut font = fontgroup.fonts[0].borrow_mut();
Arc::new(box TextRun::new(&mut *font, run_text, &options))
};
@ -193,7 +193,7 @@ impl TextRunScanner {
debug!("TextRunScanner: pushing {} fragment(s)", self.clump.len());
for (logical_offset, old_fragment) in
mem::replace(&mut self.clump, LinkedList::new()).into_iter().enumerate() {
let mut range = *new_ranges.get(logical_offset);
let mut range = new_ranges[logical_offset];
if range.is_empty() {
debug!("Elided an `SpecificFragmentInfo::UnscannedText` because it was \
zero-length after compression");
@ -238,14 +238,14 @@ impl TextRunScanner {
let length = string.len();
let original = mem::replace(string, String::with_capacity(length));
for character in original.chars() {
string.push(character.to_uppercase())
string.extend(character.to_uppercase())
}
}
text_transform::T::lowercase => {
let length = string.len();
let original = mem::replace(string, String::with_capacity(length));
for character in original.chars() {
string.push(character.to_lowercase())
string.extend(character.to_lowercase())
}
}
text_transform::T::capitalize => {
@ -258,7 +258,7 @@ impl TextRunScanner {
//
// http://dev.w3.org/csswg/css-text/#typographic-letter-unit
if capitalize_next_letter && character.is_alphabetic() {
string.push(character.to_uppercase());
string.extend(character.to_uppercase());
capitalize_next_letter = false;
continue
}
@ -308,7 +308,7 @@ pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<Fo
-> FontMetrics {
let fontgroup = font_context.get_layout_font_group_for_style(font_style);
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let font = fontgroup.fonts.get(0).borrow();
let font = fontgroup.fonts[0].borrow();
font.metrics.clone()
}

View file

@ -71,11 +71,11 @@ use style::computed_values::content::ContentItem;
use style::computed_values::{content, display, white_space};
use selectors::matching::DeclarationBlock;
use selectors::parser::{NamespaceConstraint, AttrSelector};
use selectors::smallvec::VecLike;
use style::legacy::{IntegerAttribute, LengthAttribute};
use style::legacy::{UnsignedIntegerAttribute};
use style::node::{TElement, TElementAttributes, TNode};
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
use util::smallvec::VecLike;
use url::Url;
/// Allows some convenience methods on generic layout nodes.