auto merge of #4708 : Ms2ger/servo/rustup-prepare, r=SimonSapin

This commit is contained in:
bors-servo 2015-01-22 08:06:50 -07:00
commit 55fbf1f2b6
33 changed files with 136 additions and 343 deletions

View file

@ -157,7 +157,7 @@ impl Font {
Some(glyphs) => return (*glyphs).clone(),
}
let mut glyphs = GlyphStore::new(text.char_len() as int,
let mut glyphs = GlyphStore::new(text.chars().count() as int,
options.flags.contains(IS_WHITESPACE_SHAPING_FLAG));
shaper.as_ref().unwrap().shape_text(text, options, &mut glyphs);

View file

@ -7,7 +7,7 @@ use servo_util::range;
use servo_util::range::{Range, RangeIndex, EachIndex};
use servo_util::geometry::Au;
use std::cmp::PartialOrd;
use std::cmp::{Ordering, PartialOrd};
use std::iter::repeat;
use std::num::NumCast;
use std::mem;
@ -398,9 +398,9 @@ impl<'a> DetailedGlyphStore {
let mut mut_records : Vec<DetailedGlyphRecord> = unsorted_records;
mut_records.sort_by(|a, b| {
if a < b {
Less
Ordering::Less
} else {
Greater
Ordering::Greater
}
});
let mut sorted_records = mut_records;

View file

@ -274,7 +274,7 @@ impl Shaper {
let glyph_data = ShapedGlyphData::new(buffer);
let glyph_count = glyph_data.len();
let byte_max = text.len() as int;
let char_max = text.char_len() as int;
let char_max = text.chars().count() as int;
// GlyphStore records are indexed by character, not byte offset.
// so, we must be careful to increment this when saving glyph entries.

View file

@ -8,6 +8,7 @@ use platform::font_template::FontTemplateData;
use servo_util::geometry::Au;
use servo_util::range::Range;
use servo_util::vec::{Comparator, FullBinarySearchMethods};
use std::cmp::Ordering;
use std::slice::Items;
use std::sync::Arc;
use text::glyph::{CharIndex, GlyphStore};
@ -42,11 +43,11 @@ struct CharIndexComparator;
impl Comparator<CharIndex,GlyphRun> for CharIndexComparator {
fn compare(&self, key: &CharIndex, value: &GlyphRun) -> Ordering {
if *key < value.range.begin() {
Less
Ordering::Less
} else if *key >= value.range.end() {
Greater
Ordering::Greater
} else {
Equal
Ordering::Equal
}
}
}

View file

@ -53,7 +53,7 @@ use servo_util::opts;
use std::borrow::ToOwned;
use std::collections::DList;
use std::mem;
use std::sync::atomic::Relaxed;
use std::sync::atomic::Ordering;
use style::computed_values::{caption_side, display, empty_cells, float, list_style_position};
use style::computed_values::{position};
use style::{mod, ComputedValues};
@ -90,7 +90,7 @@ impl ConstructionResult {
match self {
&ConstructionResult::None => 0u,
&ConstructionResult::ConstructionItem(_) => 0u,
&ConstructionResult::Flow(ref flow_ref, _) => flow::base(flow_ref.deref()).debug_id(),
&ConstructionResult::Flow(ref flow_ref, _) => flow::base(&**flow_ref).debug_id(),
}
}
}
@ -376,7 +376,7 @@ impl<'a> FlowConstructor<'a> {
ConstructionResult::Flow(kid_flow, kid_abs_descendants) => {
// If kid_flow is TableCaptionFlow, kid_flow should be added under
// TableWrapperFlow.
if flow.is_table() && kid_flow.deref().is_table_caption() {
if flow.is_table() && kid_flow.is_table_caption() {
kid.set_flow_construction_result(ConstructionResult::Flow(kid_flow,
Descendants::new()))
} else if flow.need_anonymous_flow(&*kid_flow) {
@ -815,7 +815,7 @@ impl<'a> FlowConstructor<'a> {
for kid in node.children() {
match kid.swap_out_construction_result() {
ConstructionResult::Flow(mut kid_flow, _) => {
if kid_flow.deref().is_table_caption() &&
if kid_flow.is_table_caption() &&
kid_flow.as_block()
.fragment
.style()
@ -1377,15 +1377,15 @@ 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(self.deref_mut());
let base = flow::mut_base(&mut **self);
{
let kid_base = flow::mut_base(new_child.deref_mut());
let kid_base = flow::mut_base(&mut *new_child);
kid_base.parallel.parent = parallel::mut_owned_flow_to_unsafe_flow(self);
}
base.children.push_back(new_child);
let _ = base.parallel.children_count.fetch_add(1, Relaxed);
let _ = base.parallel.children_count.fetch_add(1, Ordering::Relaxed);
}
/// Finishes a flow. Once a flow is finished, no more child flows or fragments may be added to

View file

@ -879,7 +879,7 @@ impl FragmentDisplayListBuilding for Fragment {
let (sender, receiver) = channel::<Vec<u8>>();
let canvas_data = match canvas_fragment_info.renderer {
Some(ref renderer) => {
renderer.deref().lock().send(SendPixelContents(sender));
renderer.lock().send(SendPixelContents(sender));
receiver.recv()
},
None => repeat(0xFFu8).take(width * height * 4).collect(),
@ -1226,12 +1226,12 @@ impl InlineFlowDisplayListBuilding for InlineFlow {
&self.base.clip);
match fragment.specific {
SpecificFragmentInfo::InlineBlock(ref mut block_flow) => {
let block_flow = block_flow.flow_ref.deref_mut();
let block_flow = &mut *block_flow.flow_ref;
flow::mut_base(block_flow).display_list_building_result
.add_to(&mut *display_list)
}
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut block_flow) => {
let block_flow = block_flow.flow_ref.deref_mut();
let block_flow = &mut *block_flow.flow_ref;
flow::mut_base(block_flow).display_list_building_result
.add_to(&mut *display_list)
}

View file

@ -56,7 +56,7 @@ use std::mem;
use std::fmt;
use std::iter::Zip;
use std::raw;
use std::sync::atomic::{AtomicUint, SeqCst};
use std::sync::atomic::{AtomicUint, Ordering};
use std::slice::MutItems;
use style::computed_values::{clear, empty_cells, float, position, text_align};
use style::ComputedValues;
@ -781,7 +781,7 @@ impl fmt::Show for BaseFlow {
write!(f,
"@ {}, CC {}, ADC {}",
self.position,
self.parallel.children_count.load(SeqCst),
self.parallel.children_count.load(Ordering::SeqCst),
self.abs_descendants.len())
}
}
@ -830,7 +830,7 @@ impl<E, S: Encoder<E>> Encodable<S, E> for BaseFlow {
#[unsafe_destructor]
impl Drop for BaseFlow {
fn drop(&mut self) {
if self.ref_count.load(SeqCst) != 0 {
if self.ref_count.load(Ordering::SeqCst) != 0 {
panic!("Flow destroyed before its ref count hit zero—this is unsafe!")
}
}

View file

@ -26,25 +26,25 @@ impl FlowList {
/// Provide a reference to the front element, or None if the list is empty
#[inline]
pub fn front<'a>(&'a self) -> Option<&'a Flow> {
self.flows.front().map(|head| head.deref())
self.flows.front().map(|head| &**head)
}
/// Provide a mutable reference to the front element, or None if the list is empty
#[inline]
pub unsafe fn front_mut<'a>(&'a mut self) -> Option<&'a mut Flow> {
self.flows.front_mut().map(|head| head.deref_mut())
self.flows.front_mut().map(|head| &mut **head)
}
/// Provide a reference to the back element, or None if the list is empty
#[inline]
pub fn back<'a>(&'a self) -> Option<&'a Flow> {
self.flows.back().map(|tail| tail.deref())
self.flows.back().map(|tail| &**tail)
}
/// Provide a mutable reference to the back element, or None if the list is empty
#[inline]
pub unsafe fn back_mut<'a>(&'a mut self) -> Option<&'a mut Flow> {
self.flows.back_mut().map(|tail| tail.deref_mut())
self.flows.back_mut().map(|tail| &mut **tail)
}
/// Add an element first in the list
@ -108,7 +108,7 @@ impl FlowList {
impl<'a> Iterator<&'a (Flow + 'a)> for FlowListIterator<'a> {
#[inline]
fn next(&mut self) -> Option<&'a (Flow + 'a)> {
self.it.next().map(|x| x.deref())
self.it.next().map(|x| &**x)
}
#[inline]
@ -120,7 +120,7 @@ impl<'a> Iterator<&'a (Flow + 'a)> for FlowListIterator<'a> {
impl<'a> Iterator<&'a mut (Flow + 'a)> for MutFlowListIterator<'a> {
#[inline]
fn next(&mut self) -> Option<&'a mut (Flow + 'a)> {
self.it.next().map(|x| x.deref_mut())
self.it.next().map(|x| &mut **x)
}
#[inline]

View file

@ -12,7 +12,7 @@ use flow;
use std::mem;
use std::ptr;
use std::raw;
use std::sync::atomic::SeqCst;
use std::sync::atomic::Ordering;
#[unsafe_no_drop_flag]
pub struct FlowRef {
@ -55,7 +55,7 @@ impl Drop for FlowRef {
if self.object.vtable.is_null() {
return
}
if flow::base(&**self).ref_count().fetch_sub(1, SeqCst) > 1 {
if flow::base(&**self).ref_count().fetch_sub(1, Ordering::SeqCst) > 1 {
return
}
let flow_ref: FlowRef = mem::replace(self, FlowRef {
@ -75,7 +75,7 @@ impl Drop for FlowRef {
impl Clone for FlowRef {
fn clone(&self) -> FlowRef {
unsafe {
drop(flow::base(self.deref()).ref_count().fetch_add(1, SeqCst));
drop(flow::base(&**self).ref_count().fetch_add(1, Ordering::SeqCst));
FlowRef {
object: raw::TraitObject {
vtable: self.object.vtable,

View file

@ -164,7 +164,7 @@ impl SpecificFragmentInfo {
SpecificFragmentInfo::InlineBlock(ref info) => &info.flow_ref,
};
flow::base(flow.deref()).restyle_damage
flow::base(&**flow).restyle_damage
}
pub fn get_type(&self) -> &'static str {
@ -1610,7 +1610,7 @@ impl Fragment {
}
SpecificFragmentInfo::InlineBlock(ref info) => {
// See CSS 2.1 § 10.8.1.
let block_flow = info.flow_ref.deref().as_immutable_block();
let block_flow = info.flow_ref.as_immutable_block();
let font_style = self.style.get_font_arc();
let font_metrics = text::font_metrics_for_style(layout_context.font_context(),
font_style);

View file

@ -1194,14 +1194,14 @@ impl Flow for InlineFlow {
&stacking_relative_border_box);
match fragment.specific {
SpecificFragmentInfo::InlineBlock(ref mut info) => {
flow::mut_base(info.flow_ref.deref_mut()).clip = clip;
flow::mut_base(&mut *info.flow_ref).clip = clip;
let block_flow = info.flow_ref.as_block();
block_flow.base.absolute_position_info = self.base.absolute_position_info;
block_flow.base.stacking_relative_position =
stacking_relative_border_box.origin;
}
SpecificFragmentInfo::InlineAbsoluteHypothetical(ref mut info) => {
flow::mut_base(info.flow_ref.deref_mut()).clip = clip;
flow::mut_base(&mut *info.flow_ref).clip = clip;
let block_flow = info.flow_ref.as_block();
block_flow.base.absolute_position_info = self.base.absolute_position_info;
block_flow.base.stacking_relative_position =

View file

@ -14,7 +14,7 @@ use serialize::json;
use std::borrow::ToOwned;
use std::cell::RefCell;
use std::io::File;
use std::sync::atomic::{AtomicUint, SeqCst, INIT_ATOMIC_UINT};
use std::sync::atomic::{AtomicUint, Ordering, INIT_ATOMIC_UINT};
thread_local!(static STATE_KEY: RefCell<Option<State>> = RefCell::new(None))
@ -64,7 +64,7 @@ impl Scope {
STATE_KEY.with(|ref r| {
match &mut *r.borrow_mut() {
&Some(ref mut state) => {
let flow_trace = json::encode(&flow::base(state.flow_root.deref()));
let flow_trace = json::encode(&flow::base(&*state.flow_root));
let data = box ScopeData::new(name.clone(), flow_trace);
state.scope_stack.push(data);
}
@ -82,7 +82,7 @@ impl Drop for Scope {
match &mut *r.borrow_mut() {
&Some(ref mut state) => {
let mut current_scope = state.scope_stack.pop().unwrap();
current_scope.post = json::encode(&flow::base(state.flow_root.deref()));
current_scope.post = json::encode(&flow::base(&*state.flow_root));
let previous_scope = state.scope_stack.last_mut().unwrap();
previous_scope.children.push(current_scope);
}
@ -96,7 +96,7 @@ impl Drop for Scope {
/// which are often reallocated but represent essentially the
/// same data.
pub fn generate_unique_debug_id() -> u16 {
unsafe { DEBUG_ID_COUNTER.fetch_add(1, SeqCst) as u16 }
unsafe { DEBUG_ID_COUNTER.fetch_add(1, Ordering::SeqCst) as u16 }
}
/// Begin a layout debug trace. If this has not been called,
@ -105,7 +105,7 @@ pub fn begin_trace(flow_root: FlowRef) {
assert!(STATE_KEY.with(|ref r| r.borrow().is_none()));
STATE_KEY.with(|ref r| {
let flow_trace = json::encode(&flow::base(flow_root.deref()));
let flow_trace = json::encode(&flow::base(&*flow_root));
let state = State {
scope_stack: vec![box ScopeData::new("root".to_owned(), flow_trace)],
flow_root: flow_root.clone(),
@ -121,7 +121,7 @@ pub fn end_trace() {
let mut task_state = STATE_KEY.with(|ref r| r.borrow_mut().take().unwrap());
assert!(task_state.scope_stack.len() == 1);
let mut root_scope = task_state.scope_stack.pop().unwrap();
root_scope.post = json::encode(&flow::base(task_state.flow_root.deref()));
root_scope.post = json::encode(&flow::base(&*task_state.flow_root));
let result = json::encode(&root_scope);
let path = Path::new("layout_trace.json");

View file

@ -222,8 +222,8 @@ enum RWGuard<'a> {
impl<'a> Deref<LayoutTaskData> for RWGuard<'a> {
fn deref(&self) -> &LayoutTaskData {
match *self {
RWGuard::Held(ref x) => x.deref(),
RWGuard::Used(ref x) => x.deref(),
RWGuard::Held(ref x) => &**x,
RWGuard::Used(ref x) => &**x,
}
}
}
@ -231,8 +231,8 @@ impl<'a> Deref<LayoutTaskData> for RWGuard<'a> {
impl<'a> DerefMut<LayoutTaskData> for RWGuard<'a> {
fn deref_mut(&mut self) -> &mut LayoutTaskData {
match *self {
RWGuard::Held(ref mut x) => x.deref_mut(),
RWGuard::Used(ref mut x) => x.deref_mut(),
RWGuard::Held(ref mut x) => &mut **x,
RWGuard::Used(ref mut x) => &mut **x,
}
}
}
@ -462,7 +462,7 @@ impl LayoutTask {
{
let mut rw_data = self.lock_rw_data(possibly_locked_rw_data);
match rw_data.deref_mut().parallel_traversal {
match (&mut *rw_data).parallel_traversal {
None => {}
Some(ref mut traversal) => traversal.shutdown(),
}
@ -644,7 +644,7 @@ impl LayoutTask {
flow::mut_base(&mut **layout_root).clip =
ClippingRegion::from_rect(&data.page_clip_rect);
let rw_data = rw_data.deref_mut();
let rw_data = &mut **rw_data;
match rw_data.parallel_traversal {
None => {
sequential::build_display_list_for_subtree(layout_root, shared_layout_context);
@ -688,8 +688,8 @@ impl LayoutTask {
root_flow.position.size.to_physical(root_flow.writing_mode)
};
let mut display_list = box DisplayList::new();
flow::mut_base(layout_root.deref_mut()).display_list_building_result
.add_to(&mut *display_list);
flow::mut_base(&mut **layout_root).display_list_building_result
.add_to(&mut *display_list);
let paint_layer = Arc::new(PaintLayer::new(layout_root.layer_id(0),
color,
ScrollPolicy::Scrollable));
@ -748,7 +748,7 @@ impl LayoutTask {
rw_data.screen_size = current_screen_size;
// Create a layout context for use throughout the following passes.
let mut shared_layout_context = self.build_shared_layout_context(rw_data.deref(),
let mut shared_layout_context = self.build_shared_layout_context(&*rw_data,
node,
&data.url);
@ -773,7 +773,7 @@ impl LayoutTask {
if needs_reflow {
self.try_get_layout_root(*node).map(
|mut flow| LayoutTask::reflow_all_nodes(flow.deref_mut()));
|mut flow| LayoutTask::reflow_all_nodes(&mut *flow));
}
let mut layout_root = profile(TimeProfilerCategory::LayoutStyleRecalc,
@ -781,7 +781,7 @@ impl LayoutTask {
self.time_profiler_chan.clone(),
|| {
// Perform CSS selector matching and flow construction.
let rw_data = rw_data.deref_mut();
let rw_data = &mut *rw_data;
match rw_data.parallel_traversal {
None => {
sequential::traverse_dom_preorder(*node, &shared_layout_context);
@ -798,10 +798,9 @@ impl LayoutTask {
self.profiler_metadata(data),
self.time_profiler_chan.clone(),
|| {
if opts::get().nonincremental_layout || layout_root.deref_mut()
.compute_layout_damage()
if opts::get().nonincremental_layout || layout_root.compute_layout_damage()
.contains(REFLOW_ENTIRE_DOCUMENT) {
layout_root.deref_mut().reflow_entire_document()
layout_root.reflow_entire_document()
}
});
@ -820,7 +819,7 @@ impl LayoutTask {
self.profiler_metadata(data),
self.time_profiler_chan.clone(),
|| {
let rw_data = rw_data.deref_mut();
let rw_data = &mut *rw_data;
match rw_data.parallel_traversal {
None => {
// Sequential mode.

View file

@ -23,7 +23,7 @@ use servo_util::time::{TimeProfilerCategory, ProfilerMetadata, TimeProfilerChan,
use servo_util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
use std::mem;
use std::ptr;
use std::sync::atomic::{AtomicInt, Relaxed, SeqCst};
use std::sync::atomic::{AtomicInt, Ordering};
#[allow(dead_code)]
fn static_assertion(node: UnsafeLayoutNode) {
@ -108,7 +108,7 @@ pub trait ParallelPreorderDomTraversal : PreorderDomTraversal {
{
let mut layout_data_ref = node.mutate_layout_data();
let layout_data = layout_data_ref.as_mut().expect("no layout data");
layout_data.data.parallel.children_count.store(child_count as int, Relaxed);
layout_data.data.parallel.children_count.store(child_count as int, Ordering::Relaxed);
}
// Possibly enqueue the children.
@ -173,7 +173,7 @@ trait ParallelPostorderDomTraversal : PostorderDomTraversal {
.data
.parallel
.children_count
.fetch_sub(1, SeqCst) == 1 {
.fetch_sub(1, Ordering::SeqCst) == 1 {
// We were the last child of our parent. Construct flows for our parent.
} else {
// Get out of here and find another node to work on.
@ -223,15 +223,15 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
let flow: &mut FlowRef = mem::transmute(&unsafe_flow);
// Perform the appropriate traversal.
if self.should_process(flow.deref_mut()) {
self.process(flow.deref_mut());
if self.should_process(&mut **flow) {
self.process(&mut **flow);
}
let base = flow::mut_base(flow.deref_mut());
let base = flow::mut_base(&mut **flow);
// Reset the count of children for the next layout traversal.
base.parallel.children_count.store(base.children.len() as int, Relaxed);
base.parallel.children_count.store(base.children.len() as int, Ordering::Relaxed);
// Possibly enqueue the parent.
let unsafe_parent = base.parallel.parent;
@ -244,8 +244,8 @@ trait ParallelPostorderFlowTraversal : PostorderFlowTraversal {
// of our parent to finish processing? If so, we can continue
// on with our parent; otherwise, we've gotta wait.
let parent: &mut FlowRef = mem::transmute(&unsafe_parent);
let parent_base = flow::mut_base(parent.deref_mut());
if parent_base.parallel.children_count.fetch_sub(1, SeqCst) == 1 {
let parent_base = flow::mut_base(&mut **parent);
if parent_base.parallel.children_count.fetch_sub(1, Ordering::SeqCst) == 1 {
// We were the last child of our parent. Reflow our parent.
unsafe_flow = unsafe_parent
} else {
@ -278,13 +278,13 @@ trait ParallelPreorderFlowTraversal : PreorderFlowTraversal {
// Get a real flow.
let flow: &mut FlowRef = mem::transmute(&unsafe_flow);
if self.should_process(flow.deref_mut()) {
if self.should_process(&mut **flow) {
// Perform the appropriate traversal.
self.process(flow.deref_mut());
self.process(&mut **flow);
}
// Possibly enqueue the children.
for kid in flow::child_iter(flow.deref_mut()) {
for kid in flow::child_iter(&mut **flow) {
had_children = true;
proxy.push(WorkUnit {
fun: top_down_func,
@ -427,7 +427,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
if opts::get().bubble_inline_sizes_separately {
let layout_context = LayoutContext::new(shared_layout_context);
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
root.deref_mut().traverse_postorder(&bubble_inline_sizes);
root.traverse_postorder(&bubble_inline_sizes);
}
queue.data = shared_layout_context as *const _;

View file

@ -59,7 +59,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
let layout_context = LayoutContext::new(shared_layout_context);
let root = root.deref_mut();
let root = &mut **root;
if opts::get().bubble_inline_sizes_separately {
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
@ -94,7 +94,7 @@ pub fn build_display_list_for_subtree(root: &mut FlowRef,
let compute_absolute_positions = ComputeAbsolutePositions { layout_context: &layout_context };
let build_display_list = BuildDisplayList { layout_context: &layout_context };
doit(root.deref_mut(), compute_absolute_positions, build_display_list);
doit(&mut **root, compute_absolute_positions, build_display_list);
}
pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut FlowRef,
@ -117,5 +117,5 @@ pub fn iterate_through_flow_tree_fragment_border_boxes(root: &mut FlowRef,
}
}
doit(root.deref_mut(), iterator, &ZERO_POINT);
doit(&mut **root, iterator, &ZERO_POINT);
}

View file

@ -138,7 +138,7 @@ impl TextRunScanner {
};
let mut new_line_pos = Vec::new();
let old_length = CharIndex(run_text.as_slice().char_len() as int);
let old_length = CharIndex(run_text.chars().count() as int);
last_whitespace = util::transform_text(in_fragment.as_slice(),
compression,
last_whitespace,
@ -146,7 +146,7 @@ impl TextRunScanner {
&mut new_line_pos);
new_line_positions.push(NewLinePositions(new_line_pos));
let added_chars = CharIndex(run_text.as_slice().char_len() as int) - old_length;
let added_chars = CharIndex(run_text.chars().count() as int) - old_length;
new_ranges.push(Range::new(char_total, added_chars));
char_total = char_total + added_chars;
}

View file

@ -634,7 +634,7 @@ impl<'a, T: Reflectable> JSRef<'a, T> {
impl<'a, T: Reflectable> Reflectable for JSRef<'a, T> {
fn reflector<'a>(&'a self) -> &'a Reflector {
self.deref().reflector()
(**self).reflector()
}
}

View file

@ -505,7 +505,7 @@ impl<'a> ElementHelpers<'a> for JSRef<'a, Element> {
fn update_inline_style(self, property_decl: style::PropertyDeclaration, style_priority: StylePriority) {
let mut inline_declarations = self.style_attribute().borrow_mut();
if let Some(ref mut declarations) = *inline_declarations.deref_mut() {
if let &Some(ref mut declarations) = &mut *inline_declarations {
let existing_declarations = if style_priority == StylePriority::Important {
declarations.important.make_unique()
} else {

View file

@ -161,7 +161,7 @@ impl LayoutHTMLInputElementHelpers for JS<HTMLInputElement> {
InputType::InputReset => get_raw_attr_value(self).unwrap_or_else(|| DEFAULT_RESET_VALUE.to_owned()),
InputType::InputPassword => {
let raw = get_raw_textinput_value(self);
String::from_char(raw.char_len(), '●')
raw.chars().map(|_| '●').collect()
}
_ => get_raw_textinput_value(self),
}

View file

@ -515,7 +515,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
}
fn is_in_doc(self) -> bool {
self.deref().flags.get().contains(IS_IN_DOC)
self.flags.get().contains(IS_IN_DOC)
}
/// Returns the type ID of this node. Fails if this node is borrowed mutably.
@ -728,7 +728,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
}
fn to_trusted_node_address(self) -> TrustedNodeAddress {
TrustedNodeAddress(self.deref() as *const Node as *const libc::c_void)
TrustedNodeAddress(&*self as *const Node as *const libc::c_void)
}
fn get_bounding_content_box(self) -> Rect<Au> {
@ -1019,7 +1019,7 @@ pub struct NodeChildrenIterator<'a> {
impl<'a> Iterator<JSRef<'a, Node>> for NodeChildrenIterator<'a> {
fn next(&mut self) -> Option<JSRef<'a, Node>> {
let node = self.current;
self.current = node.and_then(|node| node.next_sibling().map(|node| *node.root().deref()));
self.current = node.and_then(|node| node.next_sibling().map(|node| *node.root()));
node
}
}
@ -1043,7 +1043,7 @@ pub struct AncestorIterator<'a> {
impl<'a> Iterator<JSRef<'a, Node>> for AncestorIterator<'a> {
fn next(&mut self) -> Option<JSRef<'a, Node>> {
let node = self.current;
self.current = node.and_then(|node| node.parent_node().map(|node| *node.root().deref()));
self.current = node.and_then(|node| node.parent_node().map(|node| *node.root()));
node
}
}

View file

@ -135,7 +135,7 @@ impl TextInput {
let new_lines = {
let prefix = self.lines[begin.line].slice_chars(0, begin.index);
let suffix = self.lines[end.line].slice_chars(end.index, self.lines[end.line].char_len());
let suffix = self.lines[end.line].slice_chars(end.index, self.lines[end.line].chars().count());
let lines_prefix = self.lines.slice(0, begin.line);
let lines_suffix = self.lines.slice(end.line + 1, self.lines.len());
@ -150,7 +150,7 @@ impl TextInput {
insert_lines[0] = new_line;
let last_insert_lines_index = insert_lines.len() - 1;
self.edit_point.index = insert_lines[last_insert_lines_index].char_len();
self.edit_point.index = insert_lines[last_insert_lines_index].chars().count();
self.edit_point.line = begin.line + last_insert_lines_index;
insert_lines[last_insert_lines_index].push_str(suffix);
@ -167,7 +167,7 @@ impl TextInput {
/// Return the length of the current line under the editing point.
fn current_line_length(&self) -> uint {
self.lines[self.edit_point.line].char_len()
self.lines[self.edit_point.line].chars().count()
}
/// Adjust the editing point position by a given of lines. The resulting column is
@ -260,7 +260,7 @@ impl TextInput {
});
let last_line = self.lines.len() - 1;
self.edit_point.line = last_line;
self.edit_point.index = self.lines[last_line].char_len();
self.edit_point.index = self.lines[last_line].chars().count();
}
/// Remove the current selection.

View file

@ -32,10 +32,6 @@ use libc::c_int;
#[cfg(not(test))]
use servo_util::opts;
// FIXME: Find replacement for this post-runtime removal
//#[cfg(not(test))]
//use servo_util::rtinstrument;
#[cfg(not(test))]
use servo::Browser;
#[cfg(not(test))]
@ -161,8 +157,6 @@ fn main() {
browser
} = browser;
browser.shutdown();
//rtinstrument::teardown();
}
}

View file

@ -1161,6 +1161,7 @@ impl<K: Eq + Hash, V> FindPush<K, V> for HashMap<K, Vec<V>> {
#[cfg(test)]
mod tests {
use std::cmp::Ordering;
use std::sync::Arc;
use super::{DeclarationBlock, Rule, SelectorMap};
use selectors::LocalName;
@ -1201,7 +1202,7 @@ mod tests {
let rules_list = get_mock_rules(&["a.intro", "img.sidebar"]);
let a = &rules_list[0][0].declarations;
let b = &rules_list[1][0].declarations;
assert!((a.specificity, a.source_order).cmp(&(b.specificity, b.source_order)) == Less,
assert!((a.specificity, a.source_order).cmp(&(b.specificity, b.source_order)) == Ordering::Less,
"The rule that comes later should win.");
}

View file

@ -51,8 +51,6 @@ pub mod opts;
pub mod persistent_list;
pub mod range;
pub mod resource_files;
// FIXME: Find replacement for this post-runtime removal
// pub mod rtinstrument;
pub mod smallvec;
pub mod sort;
pub mod str;
@ -71,7 +69,7 @@ pub fn breakpoint() {
// Workaround for lack of `ptr_eq` on Arcs...
#[inline]
pub fn arc_ptr_eq<T: 'static + Send + Sync>(a: &Arc<T>, b: &Arc<T>) -> bool {
let a: &T = a.deref();
let b: &T = b.deref();
let a: &T = &**a;
let b: &T = &**b;
(a as *const T) == (b as *const T)
}

View file

@ -1,198 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use opts;
use std::any::Any;
use std::borrow::ToOwned;
#[cfg(not(test))]
use std::io::File;
//use std::mem;
//use std::raw;
use std::rt::Runtime;
use std::rt::local::Local;
//use std::rt::rtio;
use std::rt::task::{Task, TaskOpts, BlockedTask};
use std_time;
use std::sync::Mutex;
#[cfg(not(test))]
use serialize::json;
#[deriving(Encodable)]
pub enum Event {
Spawn,
Schedule,
Unschedule,
Death,
}
#[deriving(Encodable)]
pub struct Message {
timestamp: u64,
event: Event,
}
#[deriving(Encodable)]
pub struct TaskStats {
pub name: String,
pub messages: Vec<Message>,
pub task_id: uint,
}
struct InstrumentedRuntime {
inner: Option<Box<Runtime + Send>>,
messages: Vec<Message>,
}
#[deriving(Encodable)]
pub struct GlobalState {
task_stats: Vec<TaskStats>,
}
#[cfg(not(test))]
pub fn teardown() {
if opts::get().profile_tasks {
let state = GLOBAL_STATE.lock();
let result = json::encode(&*state);
let path = Path::new("thread_trace.json");
let mut file = File::create(&path).unwrap();
file.write_str(result.as_slice()).unwrap();
}
}
impl GlobalState {
fn new() -> GlobalState {
GlobalState {
task_stats: vec!(),
}
}
}
lazy_static! {
pub static ref GLOBAL_STATE: Mutex<GlobalState> = Mutex::new(GlobalState::new());
}
/// Instrument all code run inside the specific block, returning a vector of all
/// messages which occurred.
pub fn instrument(f: proc()) {
if opts::get().profile_tasks {
install();
f();
let rt = uninstall();
let task_id = rt.task_id();
let name = {
let task = Local::borrow(None::<Task>);
match task.name {
Some(ref name) => name.to_string(),
None => "unknown".to_owned(),
}
};
let stats = TaskStats {
name: name,
messages: rt.messages,
task_id: task_id,
};
let mut state = GLOBAL_STATE.lock();
state.task_stats.push(stats);
} else {
f();
}
}
/// Installs an instrumented runtime which will append to the given vector of
/// messages.
///
/// The instrumented runtime is installed into the current task.
fn install() {
let mut task = Local::borrow(None::<Task>);
let rt = task.take_runtime();
let mut new_rt = box InstrumentedRuntime {
inner: Some(rt),
messages: vec!(),
};
new_rt.log(Event::Spawn);
task.put_runtime(new_rt);
}
/// Uninstalls the runtime from the current task, returning the instrumented
/// runtime.
fn uninstall() -> InstrumentedRuntime {
let mut task = Local::borrow(None::<Task>);
let mut rt = task.maybe_take_runtime::<InstrumentedRuntime>().unwrap();
rt.log(Event::Death);
task.put_runtime(rt.inner.take().unwrap());
*rt
}
impl InstrumentedRuntime {
/// Puts this runtime back into the local task
fn put(mut self: Box<InstrumentedRuntime>, event: Option<Event>) {
assert!(self.inner.is_none());
let mut task: Box<Task> = Local::take();
let rt = task.take_runtime();
self.inner = Some(rt);
match event {
Some(event) => self.log(event),
None => {}
}
task.put_runtime(self);
Local::put(task);
}
/// Logs a message into this runtime
fn log(&mut self, event: Event) {
self.messages.push(Message {
timestamp: std_time::precise_time_ns(),
event: event,
});
}
fn task_id(&self) -> uint { self as *const _ as uint }
}
impl Runtime for InstrumentedRuntime {
fn stack_guard(&self) -> Option<uint> {
self.inner.as_ref().unwrap().stack_guard()
}
fn yield_now(mut self: Box<InstrumentedRuntime>, cur_task: Box<Task>) {
self.inner.take().unwrap().yield_now(cur_task);
self.put(None)
}
fn maybe_yield(mut self: Box<InstrumentedRuntime>, cur_task: Box<Task>) {
self.inner.take().unwrap().maybe_yield(cur_task);
self.put(None)
}
fn deschedule(mut self: Box<InstrumentedRuntime>, times: uint, cur_task: Box<Task>,
f: |BlockedTask| -> Result<(), BlockedTask>) {
self.log(Event::Unschedule);
self.inner.take().unwrap().deschedule(times, cur_task, f);
self.put(Some(Event::Schedule));
}
fn reawaken(mut self: Box<InstrumentedRuntime>, to_wake: Box<Task>) {
self.inner.take().unwrap().reawaken(to_wake);
self.put(None);
}
fn spawn_sibling(mut self: Box<InstrumentedRuntime>,
cur_task: Box<Task>,
opts: TaskOpts,
f: proc():Send) {
// Be sure to install an instrumented runtime for the spawned sibling by
// specifying a new runtime.
self.inner.take().unwrap().spawn_sibling(cur_task, opts, proc() {
install();
f();
drop(uninstall());
});
self.put(None)
}
fn stack_bounds(&self) -> (uint, uint) { self.inner.as_ref().unwrap().stack_bounds() }
fn can_block(&self) -> bool { self.inner.as_ref().unwrap().can_block() }
fn wrap(self: Box<InstrumentedRuntime>) -> Box<Any+'static> { self as Box<Any> }
}

View file

@ -4,6 +4,8 @@
//! In-place sorting.
use std::cmp::Ordering;
fn quicksort_helper<T>(arr: &mut [T], left: int, right: int, compare: fn(&T, &T) -> Ordering) {
if right <= left {
return
@ -17,11 +19,11 @@ fn quicksort_helper<T>(arr: &mut [T], left: int, right: int, compare: fn(&T, &T)
let v: *mut T = &mut arr[right as uint];
loop {
i += 1;
while compare(&arr[i as uint], &*v) == Less {
while compare(&arr[i as uint], &*v) == Ordering::Less {
i += 1
}
j -= 1;
while compare(&*v, &arr[j as uint]) == Less {
while compare(&*v, &arr[j as uint]) == Ordering::Less {
if j == left {
break
}
@ -31,11 +33,11 @@ fn quicksort_helper<T>(arr: &mut [T], left: int, right: int, compare: fn(&T, &T)
break
}
arr.swap(i as uint, j as uint);
if compare(&arr[i as uint], &*v) == Equal {
if compare(&arr[i as uint], &*v) == Ordering::Equal {
p += 1;
arr.swap(p as uint, i as uint)
}
if compare(&*v, &arr[j as uint]) == Equal {
if compare(&*v, &arr[j as uint]) == Ordering::Equal {
q -= 1;
arr.swap(j as uint, q as uint)
}

View file

@ -6,13 +6,11 @@ use std::borrow::ToOwned;
use std::task;
use std::comm::Sender;
use std::task::TaskBuilder;
// use rtinstrument;
use task_state;
pub fn spawn_named(name: String, f: proc():Send) {
let builder = task::TaskBuilder::new().named(name);
builder.spawn(proc() {
// rtinstrument::instrument(f);
f();
});
}
@ -25,22 +23,18 @@ pub fn spawn_named_with_send_on_failure<T: Send>(name: &'static str,
dest: Sender<T>) {
let future_result = TaskBuilder::new().named(name).try_future(proc() {
task_state::initialize(state);
// FIXME: Find replacement for this post-runtime removal
// rtinstrument::instrument(f);
f();
});
let watched_name = name.to_owned();
let watcher_name = format!("{}Watcher", watched_name);
TaskBuilder::new().named(watcher_name).spawn(proc() {
//rtinstrument::instrument(proc() {
match future_result.into_inner() {
Ok(()) => (),
Err(..) => {
debug!("{} failed, notifying constellation", name);
dest.send(msg);
}
match future_result.into_inner() {
Ok(()) => (),
Err(..) => {
debug!("{} failed, notifying constellation", name);
dest.send(msg);
}
//});
}
});
}

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, SeqCst};
use std::sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, Ordering};
use std::rc::Rc;
use std::cell::RefCell;
@ -15,7 +15,7 @@ pub fn tid() -> uint {
TASK_LOCAL_TID.with(|ref k| {
let ret =
match *k.borrow() {
None => unsafe { next_tid.fetch_add(1, SeqCst) },
None => unsafe { next_tid.fetch_add(1, Ordering::SeqCst) },
Some(x) => x,
};

View file

@ -6,6 +6,7 @@
use collections::TreeMap;
use std::borrow::ToOwned;
use std::cmp::Ordering;
use std::comm::{Sender, channel, Receiver};
use std::f64;
use std::io::timer::sleep;
@ -228,9 +229,9 @@ impl TimeProfiler {
for (&(ref category, ref meta), ref mut data) in self.buckets.iter_mut() {
data.sort_by(|a, b| {
if a < b {
Less
Ordering::Less
} else {
Greater
Ordering::Greater
}
});
let data_len = data.len();

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::cmp::{PartialOrd, PartialEq};
use std::cmp::{PartialOrd, PartialEq, Ordering};
#[cfg(test)]
use std::fmt::Show;
@ -47,9 +47,9 @@ impl<'a, T> FullBinarySearchMethods<T> for &'a [T] {
let midv = &self[mid];
match cmp.compare(key, midv) {
Greater => low = (mid as int) + 1,
Less => high = (mid as int) - 1,
Equal => return Some(mid),
Ordering::Greater => low = (mid as int) + 1,
Ordering::Less => high = (mid as int) - 1,
Ordering::Equal => return Some(mid),
}
}
return None;

View file

@ -14,7 +14,7 @@ use libc::funcs::posix88::unistd::usleep;
use rand::{Rng, XorShiftRng};
use std::mem;
use std::rand::weak_rng;
use std::sync::atomic::{AtomicUint, SeqCst};
use std::sync::atomic::{AtomicUint, Ordering};
use deque::{Abort, BufferPool, Data, Empty, Stealer, Worker};
/// A unit of work.
@ -157,7 +157,7 @@ impl<QueueData: Send, WorkData: Send> WorkerThread<QueueData, WorkData> {
// The work is done. Now decrement the count of outstanding work items. If this was
// the last work unit in the queue, then send a message on the channel.
unsafe {
if (*ref_count).fetch_sub(1, SeqCst) == 1 {
if (*ref_count).fetch_sub(1, Ordering::SeqCst) == 1 {
self.chan.send(SupervisorMsg::Finished)
}
}
@ -181,7 +181,7 @@ impl<'a, QueueData: 'static, WorkData: Send> WorkerProxy<'a, QueueData, WorkData
#[inline]
pub fn push(&mut self, work_unit: WorkUnit<QueueData, WorkData>) {
unsafe {
drop((*self.ref_count).fetch_add(1, SeqCst));
drop((*self.ref_count).fetch_add(1, Ordering::SeqCst));
}
self.worker.push(work_unit);
}

View file

@ -18,7 +18,7 @@ use libc::c_int;
use servo_util::opts;
use std::borrow::ToOwned;
use std::cell::{Cell, RefCell};
use std::sync::atomic::{AtomicInt, SeqCst};
use std::sync::atomic::{AtomicInt, Ordering};
thread_local!(pub static ID_COUNTER: AtomicInt = AtomicInt::new(0))
thread_local!(pub static BROWSERS: RefCell<Vec<CefBrowser>> = RefCell::new(vec!()))
@ -105,7 +105,7 @@ impl ServoCefBrowser {
};
let id = ID_COUNTER.with(|counter| {
counter.fetch_add(1, SeqCst)
counter.fetch_add(1, Ordering::SeqCst)
});
ServoCefBrowser {

View file

@ -7,6 +7,7 @@ use eutil::slice_to_str;
use libc::{mod, size_t, c_int, c_ushort, c_void};
use libc::types::os::arch::c95::wchar_t;
use std::char;
use std::cmp::Ordering;
use std::mem;
use std::ptr;
use std::slice;
@ -106,15 +107,15 @@ pub extern "C" fn cef_string_utf8_set(src: *const u8, src_len: size_t, output: *
#[no_mangle]
pub extern "C" fn cef_string_utf8_cmp(a: *const cef_string_utf8_t, b: *const cef_string_utf8_t) -> c_int {
unsafe {
slice::raw::buf_as_slice((*a).str as *const u8, (*a).length as uint, |astr:&[u8]| {
slice::raw::buf_as_slice((*a).str as *const u8, (*a).length as uint, |astr:&[u8]| {
slice::raw::buf_as_slice((*b).str as *const u8, (*b).length as uint, |bstr:&[u8]| {
match astr.cmp(bstr) {
Less => -1,
Equal => 0,
Greater => 1
}
match astr.cmp(bstr) {
Ordering::Less => -1,
Ordering::Equal => 0,
Ordering::Greater => 1
}
})
})
})
}
}
@ -188,15 +189,15 @@ pub extern "C" fn cef_string_utf16_set(src: *const c_ushort, src_len: size_t, ou
#[no_mangle]
pub extern "C" fn cef_string_utf16_cmp(a: *const cef_string_utf16_t, b: *const cef_string_utf16_t) -> c_int {
unsafe {
slice::raw::buf_as_slice(mem::transmute((*a).str), (*a).length as uint, |astr:&[u16]| {
slice::raw::buf_as_slice(mem::transmute((*a).str), (*a).length as uint, |astr:&[u16]| {
slice::raw::buf_as_slice(mem::transmute((*b).str), (*b).length as uint, |bstr:&[u16]| {
match astr.cmp(bstr) {
Less => -1,
Equal => 0,
Greater => 1
}
match astr.cmp(bstr) {
Ordering::Less => -1,
Ordering::Equal => 0,
Ordering::Greater => 1
}
})
})
})
}
}
@ -246,15 +247,15 @@ pub extern "C" fn cef_string_wide_set(src: *const wchar_t, src_len: size_t, outp
#[no_mangle]
pub extern "C" fn cef_string_wide_cmp(a: *const cef_string_wide_t, b: *const cef_string_wide_t) -> c_int {
unsafe {
slice::raw::buf_as_slice((*a).str as *const wchar_t, (*a).length as uint, |astr:&[wchar_t]| {
slice::raw::buf_as_slice((*a).str as *const wchar_t, (*a).length as uint, |astr:&[wchar_t]| {
slice::raw::buf_as_slice((*b).str as *const wchar_t, (*b).length as uint, |bstr:&[wchar_t]| {
match astr.cmp(bstr) {
Less => -1,
Equal => 0,
Greater => 1
}
match astr.cmp(bstr) {
Ordering::Less => -1,
Ordering::Equal => 0,
Ordering::Greater => 1
}
})
})
})
}
}