diff options
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/block.rs | 77 | ||||
-rw-r--r-- | components/layout/construct.rs | 8 | ||||
-rw-r--r-- | components/layout/css/matching.rs | 6 | ||||
-rw-r--r-- | components/layout/css/node_util.rs | 4 | ||||
-rw-r--r-- | components/layout/flow.rs | 38 | ||||
-rw-r--r-- | components/layout/flow_list.rs | 223 | ||||
-rw-r--r-- | components/layout/flow_ref.rs | 10 | ||||
-rw-r--r-- | components/layout/fragment.rs | 2 | ||||
-rw-r--r-- | components/layout/inline.rs | 18 | ||||
-rw-r--r-- | components/layout/layout_debug.rs | 2 | ||||
-rw-r--r-- | components/layout/layout_task.rs | 2 | ||||
-rw-r--r-- | components/layout/lib.rs | 8 | ||||
-rw-r--r-- | components/layout/model.rs | 2 | ||||
-rw-r--r-- | components/layout/table.rs | 8 | ||||
-rw-r--r-- | components/layout/text.rs | 2 | ||||
-rw-r--r-- | components/layout/util.rs | 2 | ||||
-rw-r--r-- | components/layout/wrapper.rs | 20 |
17 files changed, 137 insertions, 295 deletions
diff --git a/components/layout/block.rs b/components/layout/block.rs index ba8dfda8751..fedca650919 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -753,7 +753,7 @@ impl BlockFlow { // Avoid copying the offset vector. let offsets = mem::replace(&mut kid_base.abs_descendants.static_b_offsets, Vec::new()); // Consume all the static y-offsets bubbled up by kid. - for y_offset in offsets.move_iter() { + for y_offset in offsets.into_iter() { // The offsets are wrt the kid flow box. Translate them to current flow. abs_descendant_y_offsets.push(y_offset + kid_base.position.start.b); } @@ -977,10 +977,16 @@ impl BlockFlow { let mut candidate_block_size_iterator = CandidateBSizeIterator::new( self.fragment.style(), self.base.block_container_explicit_block_size); - for candidate_block_size in candidate_block_size_iterator { - candidate_block_size_iterator.candidate_value = match candidate_block_size { - Auto => block_size, - Specified(value) => value + // Can't use `for` because we assign to candidate_block_size_iterator.candidate_value + loop { + match candidate_block_size_iterator.next() { + Some(candidate_block_size) => { + candidate_block_size_iterator.candidate_value = match candidate_block_size { + Auto => block_size, + Specified(value) => value + } + } + None => break, } } @@ -1040,15 +1046,15 @@ impl BlockFlow { self.fragment.border_padding.inline_start_end(), block_size + margin_block_size), ceiling: clearance + self.base.position.start.b, - max_inline_size: self.float.get_ref().containing_inline_size, - kind: self.float.get_ref().float_kind, + max_inline_size: self.float.as_ref().unwrap().containing_inline_size, + kind: self.float.as_ref().unwrap().float_kind, }; // Place the float and return the `Floats` back to the parent flow. // After, grab the position and use that to set our position. self.base.floats.add_float(&info); - self.float.get_mut_ref().rel_pos = self.base.floats.last_float_pos().unwrap(); + self.float.as_mut().unwrap().rel_pos = self.base.floats.last_float_pos().unwrap(); } /// Assign block-size for current flow. @@ -1097,10 +1103,16 @@ impl BlockFlow { let mut candidate_block_size_iterator = CandidateBSizeIterator::new(self.fragment.style(), self.base.block_container_explicit_block_size); - for candidate_block_size in candidate_block_size_iterator { - candidate_block_size_iterator.candidate_value = match candidate_block_size { - Auto => content_block_size, - Specified(value) => value, + // Can't use `for` because we assign to candidate_block_size_iterator.candidate_value + loop { + match candidate_block_size_iterator.next() { + Some(candidate_block_size) => { + candidate_block_size_iterator.candidate_value = match candidate_block_size { + Auto => content_block_size, + Specified(value) => value, + } + } + None => break, } } @@ -1173,7 +1185,7 @@ impl BlockFlow { } pub fn build_display_list_float(&mut self, layout_context: &LayoutContext) { - let float_offset = self.float.get_ref().rel_pos; + let float_offset = self.float.as_ref().unwrap().rel_pos; self.build_display_list_block_common(layout_context, float_offset, RootOfStackingContextLevel); @@ -1241,19 +1253,26 @@ impl BlockFlow { let mut candidate_block_size_iterator = CandidateBSizeIterator::new(style, Some(containing_block_block_size)); - for block_size_used_val in candidate_block_size_iterator { - solution = - Some(BSizeConstraintSolution::solve_vertical_constraints_abs_nonreplaced( - block_size_used_val, - margin_block_start, - margin_block_end, - block_start, - block_end, - content_block_size, - available_block_size, - static_b_offset)); - - candidate_block_size_iterator.candidate_value = solution.unwrap().block_size + // Can't use `for` because we assign to candidate_block_size_iterator.candidate_value + loop { + match candidate_block_size_iterator.next() { + Some(block_size_used_val) => { + solution = + Some(BSizeConstraintSolution::solve_vertical_constraints_abs_nonreplaced( + block_size_used_val, + margin_block_start, + margin_block_end, + block_start, + block_end, + content_block_size, + available_block_size, + static_b_offset)); + + candidate_block_size_iterator.candidate_value + = solution.unwrap().block_size; + } + None => break, + } } } } @@ -1580,7 +1599,7 @@ impl Flow for BlockFlow { let containing_block_inline_size = self.base.position.size.inline; self.compute_used_inline_size(layout_context, containing_block_inline_size); if self.is_float() { - self.float.get_mut_ref().containing_inline_size = containing_block_inline_size; + self.float.as_mut().unwrap().containing_inline_size = containing_block_inline_size; } // Formatting contexts are never impacted by floats. @@ -1701,7 +1720,7 @@ impl Flow for BlockFlow { } let float_offset = if self.is_float() { - self.float.get_ref().rel_pos + self.float.as_ref().unwrap().rel_pos } else { LogicalPoint::zero(self.base.writing_mode) }; @@ -1773,7 +1792,7 @@ impl Flow for BlockFlow { // FIXME(#2010, pcwalton): This is a hack and is totally bogus in the presence of pseudo- // elements. But until we have incremental reflow we can't do better--we recreate the flow // for every DOM node so otherwise we nuke layers on every reflow. - LayerId(self.fragment.node.id(), fragment_index) + LayerId(self.fragment.node.id() as uint, fragment_index) } fn is_absolute_containing_block(&self) -> bool { diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 0cf5adf3254..12747c71377 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -173,7 +173,7 @@ impl InlineFragmentsAccumulator { match enclosing_style { Some(enclosing_style) => { - for frag in fragments.fragments.mut_iter() { + for frag in fragments.fragments.iter_mut() { frag.add_inline_context_style(enclosing_style.clone()); } } @@ -372,7 +372,7 @@ impl<'a> FlowConstructor<'a> { abs_descendants: kid_abs_descendants, })) => { // Add any {ib} splits. - for split in splits.move_iter() { + for split in splits.into_iter() { // Pull apart the {ib} split object and push its predecessor fragments // onto the list. let InlineBlockSplit { @@ -556,7 +556,7 @@ impl<'a> FlowConstructor<'a> { })) => { // Bubble up {ib} splits. - for split in splits.move_iter() { + for split in splits.into_iter() { let InlineBlockSplit { predecessors: predecessors, flow: kid_flow @@ -709,7 +709,7 @@ impl<'a> FlowConstructor<'a> { node: &ThreadSafeLayoutNode) { let mut anonymous_flow = flow.get().generate_missing_child_flow(node); let mut consecutive_siblings = vec!(); - for kid_flow in child_flows.move_iter() { + for kid_flow in child_flows.into_iter() { if anonymous_flow.get().need_anonymous_flow(kid_flow.get()) { consecutive_siblings.push(kid_flow); continue; diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index 039e176e843..6913b43bfc4 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -464,7 +464,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> { Some(shared_style) => { // Yay, cache hit. Share the style. let mut layout_data_ref = self.mutate_layout_data(); - layout_data_ref.get_mut_ref().shared_data.style = Some(shared_style); + layout_data_ref.as_mut().unwrap().shared_data.style = Some(shared_style); return StyleWasShared(i) } None => {} @@ -622,14 +622,14 @@ impl<'ln> MatchMethods for LayoutNode<'ln> { applicable_declarations_cache, applicable_declarations.normal_shareable); if applicable_declarations.before.len() > 0 { - self.cascade_node_pseudo_element(Some(layout_data.shared_data.style.get_ref()), + self.cascade_node_pseudo_element(Some(layout_data.shared_data.style.as_ref().unwrap()), applicable_declarations.before.as_slice(), &mut layout_data.data.before_style, applicable_declarations_cache, false); } if applicable_declarations.after.len() > 0 { - self.cascade_node_pseudo_element(Some(layout_data.shared_data.style.get_ref()), + self.cascade_node_pseudo_element(Some(layout_data.shared_data.style.as_ref().unwrap()), applicable_declarations.after.as_slice(), &mut layout_data.data.after_style, applicable_declarations_cache, diff --git a/components/layout/css/node_util.rs b/components/layout/css/node_util.rs index 150995428ea..dcf1019440e 100644 --- a/components/layout/css/node_util.rs +++ b/components/layout/css/node_util.rs @@ -57,7 +57,7 @@ impl<'ln> NodeUtil for ThreadSafeLayoutNode<'ln> { /// Does this node have a computed style yet? fn have_css_select_results(&self) -> bool { let layout_data_ref = self.borrow_layout_data(); - layout_data_ref.get_ref().shared_data.style.is_some() + layout_data_ref.as_ref().unwrap().shared_data.style.is_some() } /// Get the description of how to account for recent style changes. @@ -73,7 +73,7 @@ impl<'ln> NodeUtil for ThreadSafeLayoutNode<'ln> { let layout_data_ref = self.borrow_layout_data(); layout_data_ref - .get_ref() + .as_ref().unwrap() .data .restyle_damage .unwrap_or(default) diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 5559dff4cbf..8c49eae6357 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -29,7 +29,7 @@ use css::node_style::StyledNode; use block::BlockFlow; use context::LayoutContext; use floats::Floats; -use flow_list::{FlowList, Link, FlowListIterator, MutFlowListIterator}; +use flow_list::{FlowList, FlowListIterator, MutFlowListIterator}; use flow_ref::FlowRef; use fragment::{Fragment, TableRowFragment, TableCellFragment}; use incremental::RestyleDamage; @@ -67,7 +67,7 @@ use style::computed_values::{clear, float, position, text_align}; /// /// Note that virtual methods have a cost; we should not overuse them in Servo. Consider adding /// methods to `ImmutableFlowUtils` or `MutableFlowUtils` before adding more methods here. -pub trait Flow: fmt::Show + ToString + Share { +pub trait Flow: fmt::Show + ToString + Sync { // RTTI // // TODO(pcwalton): Use Rust's RTTI, once that works. @@ -310,7 +310,7 @@ pub trait Flow: fmt::Show + ToString + Share { } } -impl<'a, E, S: Encoder<E>> Encodable<S, E> for &'a Flow { +impl<'a, E, S: Encoder<E>> Encodable<S, E> for &'a Flow + 'a { fn encode(&self, e: &mut S) -> Result<(), E> { e.emit_struct("flow", 0, |e| { try!(e.emit_struct_field("class", 0, |e| self.class().encode(e))) @@ -355,7 +355,7 @@ pub fn mut_base<'a>(this: &'a mut Flow) -> &'a mut BaseFlow { /// Iterates over the children of this flow. pub fn child_iter<'a>(flow: &'a mut Flow) -> MutFlowListIterator<'a> { - mut_base(flow).children.mut_iter() + mut_base(flow).children.iter_mut() } pub trait ImmutableFlowUtils { @@ -610,7 +610,7 @@ impl Descendants { /// /// Ignore any static y offsets, because they are None before layout. pub fn push_descendants(&mut self, given_descendants: Descendants) { - for elem in given_descendants.descendant_links.move_iter() { + for elem in given_descendants.descendant_links.into_iter() { self.descendant_links.push(elem); } } @@ -618,16 +618,16 @@ impl Descendants { /// Return an iterator over the descendant flows. pub fn iter<'a>(&'a mut self) -> DescendantIter<'a> { DescendantIter { - iter: self.descendant_links.mut_slice_from(0).mut_iter(), + iter: self.descendant_links.slice_from_mut(0).iter_mut(), } } /// Return an iterator over (descendant, static y offset). pub fn iter_with_offset<'a>(&'a mut self) -> DescendantOffsetIter<'a> { let descendant_iter = DescendantIter { - iter: self.descendant_links.mut_slice_from(0).mut_iter(), + iter: self.descendant_links.slice_from_mut(0).iter_mut(), }; - descendant_iter.zip(self.static_b_offsets.mut_slice_from(0).mut_iter()) + descendant_iter.zip(self.static_b_offsets.slice_from_mut(0).iter_mut()) } } @@ -637,8 +637,8 @@ pub struct DescendantIter<'a> { iter: MutItems<'a, FlowRef>, } -impl<'a> Iterator<&'a mut Flow> for DescendantIter<'a> { - fn next(&mut self) -> Option<&'a mut Flow> { +impl<'a> Iterator<&'a mut Flow + 'a> for DescendantIter<'a> { + fn next(&mut self) -> Option<&'a mut Flow + 'a> { match self.iter.next() { None => None, Some(ref mut flow) => { @@ -691,16 +691,6 @@ pub struct BaseFlow { /// The children of this flow. pub children: FlowList, - /// The flow's next sibling. - /// - /// FIXME(pcwalton): Make this private. Misuse of this can lead to data races. - pub next_sibling: Link, - - /// The flow's previous sibling. - /// - /// FIXME(pcwalton): Make this private. Misuse of this can lead to data races. - pub prev_sibling: Link, - /* layout computations */ // TODO: min/pref and position are used during disjoint phases of // layout; maybe combine into a single enum to save space. @@ -809,8 +799,6 @@ impl BaseFlow { restyle_damage: node.restyle_damage(), children: FlowList::new(), - next_sibling: None, - prev_sibling: None, intrinsic_inline_sizes: IntrinsicISizes::new(), position: LogicalRect::zero(writing_mode), @@ -836,7 +824,7 @@ impl BaseFlow { } pub fn child_iter<'a>(&'a mut self) -> MutFlowListIterator<'a> { - self.children.mut_iter() + self.children.iter_mut() } pub unsafe fn ref_count<'a>(&'a self) -> &'a AtomicUint { @@ -848,7 +836,7 @@ impl BaseFlow { } } -impl<'a> ImmutableFlowUtils for &'a Flow { +impl<'a> ImmutableFlowUtils for &'a Flow + 'a { /// Returns true if this flow is a block or a float flow. fn is_block_like(self) -> bool { match self.class() { @@ -1016,7 +1004,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow { } } -impl<'a> MutableFlowUtils for &'a mut Flow { +impl<'a> MutableFlowUtils for &'a mut Flow + 'a { /// Traverses the tree in preorder. fn traverse_preorder<T:PreorderFlowTraversal>(self, traversal: &mut T) -> bool { if traversal.should_prune(self) { diff --git a/components/layout/flow_list.rs b/components/layout/flow_list.rs index 4277326a624..59259078963 100644 --- a/components/layout/flow_list.rs +++ b/components/layout/flow_list.rs @@ -2,198 +2,90 @@ * 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/. */ -//! A variant of `DList` specialized to store `Flow`s without an extra -//! indirection. - -use flow::{Flow, base, mut_base}; +use flow::Flow; use flow_ref::FlowRef; -use std::kinds::marker::ContravariantLifetime; -use std::mem; -use std::ptr; -use std::raw; - -pub type Link = Option<FlowRef>; +use std::collections::{Deque, dlist, DList}; +// This needs to be reworked now that we have dynamically-sized types in Rust. +// Until then, it's just a wrapper around DList. -#[allow(raw_pointer_deriving)] -pub struct Rawlink<'a> { - object: raw::TraitObject, - marker: ContravariantLifetime<'a>, -} - -/// Doubly-linked list of Flows. -/// -/// The forward links are strong references. -/// The backward links are weak references. pub struct FlowList { - length: uint, - list_head: Link, - list_tail: Link, + flows: DList<FlowRef>, } -/// Double-ended FlowList iterator pub struct FlowListIterator<'a> { - head: &'a Link, - nelem: uint, + it: dlist::Items<'a, FlowRef>, } -/// Double-ended mutable FlowList iterator pub struct MutFlowListIterator<'a> { - head: Rawlink<'a>, - nelem: uint, -} - -impl<'a> Rawlink<'a> { - /// Like Option::None for Rawlink - pub fn none() -> Rawlink<'static> { - Rawlink { - object: raw::TraitObject { - vtable: ptr::mut_null(), - data: ptr::mut_null(), - }, - marker: ContravariantLifetime, - } - } - - /// Like Option::Some for Rawlink - pub fn some(n: &Flow) -> Rawlink { - unsafe { - Rawlink { - object: mem::transmute::<&Flow, raw::TraitObject>(n), - marker: ContravariantLifetime, - } - } - } - - pub unsafe fn resolve_mut(&self) -> Option<&'a mut Flow> { - if self.object.data.is_null() { - None - } else { - Some(mem::transmute_copy::<raw::TraitObject, &mut Flow>(&self.object)) - } - } -} - -/// Set the .prev field on `next`, then return `Some(next)` -unsafe fn link_with_prev(mut next: FlowRef, prev: Option<FlowRef>) -> Link { - mut_base(next.get_mut()).prev_sibling = prev; - Some(next) + it: dlist::MutItems<'a, FlowRef>, } impl Collection for FlowList { /// O(1) #[inline] fn is_empty(&self) -> bool { - self.list_head.is_none() + self.flows.is_empty() } /// O(1) #[inline] fn len(&self) -> uint { - self.length + self.flows.len() } } -// This doesn't quite fit the Deque trait because of the need to switch between -// &Flow and ~Flow. 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.list_head.as_ref().map(|head| head.get()) + self.flows.front().map(|head| head.get()) } /// 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.list_head.as_mut().map(|head| head.get_mut()) + self.flows.front_mut().map(|head| head.get_mut()) } /// Provide a reference to the back element, or None if the list is empty #[inline] pub fn back<'a>(&'a self) -> Option<&'a Flow> { - match self.list_tail { - None => None, - Some(ref list_tail) => Some(list_tail.get()) - } + self.flows.back().map(|tail| tail.get()) } /// 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> { - // Can't use map() due to error: - // lifetime of `tail` is too short to guarantee its contents can be safely reborrowed - match self.list_tail { - None => None, - Some(ref mut tail) => { - let x: &mut Flow = tail.get_mut(); - Some(mem::transmute_copy(&x)) - } - } + self.flows.back_mut().map(|tail| tail.get_mut()) } /// Add an element first in the list /// /// O(1) - pub fn push_front(&mut self, mut new_head: FlowRef) { - unsafe { - match self.list_head { - None => { - self.list_tail = Some(new_head.clone()); - self.list_head = link_with_prev(new_head, None); - } - Some(ref mut head) => { - mut_base(new_head.get_mut()).prev_sibling = None; - mut_base(head.get_mut()).prev_sibling = Some(new_head.clone()); - mem::swap(head, &mut new_head); - mut_base(head.get_mut()).next_sibling = Some(new_head); - } - } - self.length += 1; - } + pub fn push_front(&mut self, new_head: FlowRef) { + self.flows.push_front(new_head); } /// Remove the first element and return it, or None if the list is empty /// /// O(1) pub fn pop_front(&mut self) -> Option<FlowRef> { - self.list_head.take().map(|mut front_node| { - self.length -= 1; - unsafe { - match mut_base(front_node.get_mut()).next_sibling.take() { - Some(node) => self.list_head = link_with_prev(node, None), - None => self.list_tail = None, - } - } - front_node - }) + self.flows.pop_front() } /// Add an element last in the list /// /// O(1) pub fn push_back(&mut self, new_tail: FlowRef) { - if self.list_tail.is_none() { - return self.push_front(new_tail); - } - - let old_tail = self.list_tail.clone(); - self.list_tail = Some(new_tail.clone()); - let mut tail = (*old_tail.as_ref().unwrap()).clone(); - let tail_clone = Some(tail.clone()); - unsafe { - mut_base(tail.get_mut()).next_sibling = link_with_prev(new_tail, tail_clone); - } - self.length += 1; + self.flows.push(new_tail); } /// Create an empty list #[inline] pub fn new() -> FlowList { FlowList { - list_head: None, - list_tail: None, - length: 0, + flows: DList::new(), } } @@ -201,96 +93,39 @@ impl FlowList { #[inline] pub fn iter<'a>(&'a self) -> FlowListIterator<'a> { FlowListIterator { - nelem: self.len(), - head: &self.list_head, + it: self.flows.iter(), } } /// Provide a forward iterator with mutable references #[inline] - pub fn mut_iter<'a>(&'a mut self) -> MutFlowListIterator<'a> { - let len = self.len(); - let head_raw = match self.list_head { - Some(ref mut h) => Rawlink::some(h.get()), - None => Rawlink::none(), - }; + pub fn iter_mut<'a>(&'a mut self) -> MutFlowListIterator<'a> { MutFlowListIterator { - nelem: len, - head: head_raw, + it: self.flows.iter_mut(), } } } -#[unsafe_destructor] -impl Drop for FlowList { - fn drop(&mut self) { - // Dissolve the list in backwards direction - // Just dropping the list_head can lead to stack exhaustion - // when length is >> 1_000_000 - let mut tail = mem::replace(&mut self.list_tail, None); - loop { - let new_tail = match tail { - None => break, - Some(ref mut prev) => { - let prev_base = mut_base(prev.get_mut()); - prev_base.next_sibling.take(); - prev_base.prev_sibling.clone() - } - }; - tail = new_tail - } - self.length = 0; - self.list_head = None; - } -} - -impl<'a> Iterator<&'a Flow> for FlowListIterator<'a> { +impl<'a> Iterator<&'a Flow + 'a> for FlowListIterator<'a> { #[inline] - fn next(&mut self) -> Option<&'a Flow> { - if self.nelem == 0 { - return None; - } - self.head.as_ref().map(|head| { - let head_base = base(head.get()); - self.nelem -= 1; - self.head = &head_base.next_sibling; - let ret: &Flow = head.get(); - ret - }) + fn next(&mut self) -> Option<&'a Flow + 'a> { + self.it.next().map(|x| x.get()) } #[inline] fn size_hint(&self) -> (uint, Option<uint>) { - (self.nelem, Some(self.nelem)) + self.it.size_hint() } } -impl<'a> Iterator<&'a mut Flow> for MutFlowListIterator<'a> { +impl<'a> Iterator<&'a mut Flow + 'a> for MutFlowListIterator<'a> { #[inline] - fn next(&mut self) -> Option<&'a mut Flow> { - if self.nelem == 0 { - return None; - } - unsafe { - self.head.resolve_mut().map(|next| { - self.nelem -= 1; - self.head = match mut_base(next).next_sibling { - Some(ref mut node) => { - let x: &mut Flow = node.get_mut(); - // NOTE: transmute needed here to break the link - // between x and next so that it is no longer - // borrowed. - mem::transmute(Rawlink::some(x)) - } - None => Rawlink::none(), - }; - next - }) - } + fn next(&mut self) -> Option<&'a mut Flow + 'a> { + self.it.next().map(|x| x.get_mut()) } #[inline] fn size_hint(&self) -> (uint, Option<uint>) { - (self.nelem, Some(self.nelem)) + self.it.size_hint() } } diff --git a/components/layout/flow_ref.rs b/components/layout/flow_ref.rs index d90d9ac4cc0..628981e7033 100644 --- a/components/layout/flow_ref.rs +++ b/components/layout/flow_ref.rs @@ -23,7 +23,7 @@ impl FlowRef { pub fn new(mut flow: Box<Flow>) -> FlowRef { unsafe { let result = { - let flow_ref: &mut Flow = flow; + let flow_ref: &mut Flow = &mut *flow; let object = mem::transmute::<&mut Flow, raw::TraitObject>(flow_ref); FlowRef { object: object } }; @@ -56,14 +56,14 @@ impl Drop for FlowRef { } let flow_ref: FlowRef = mem::replace(self, FlowRef { object: raw::TraitObject { - vtable: ptr::mut_null(), - data: ptr::mut_null(), + vtable: ptr::null_mut(), + data: ptr::null_mut(), } }); drop(mem::transmute::<raw::TraitObject, Box<Flow>>(flow_ref.object)); mem::forget(flow_ref); - self.object.vtable = ptr::mut_null(); - self.object.data = ptr::mut_null(); + self.object.vtable = ptr::null_mut(); + self.object.data = ptr::null_mut(); } } } diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 61c7bb2a61b..c695c038c8a 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -467,7 +467,7 @@ impl Fragment { if self.inline_context.is_none() { self.inline_context = Some(InlineFragmentContext::new()); } - self.inline_context.get_mut_ref().styles.push(style.clone()); + self.inline_context.as_mut().unwrap().styles.push(style.clone()); } /// Uses the style only to estimate the intrinsic inline-sizes. These may be modified for text or diff --git a/components/layout/inline.rs b/components/layout/inline.rs index ae47937a037..bdae0326323 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -495,7 +495,7 @@ impl LineBreaker { inline_start.new_line_pos = vec![]; self.push_fragment_to_line(inline_start); - for inline_end in inline_end.move_iter() { + for inline_end in inline_end.into_iter() { debug!("LineBreaker: Deferring the fragment to the inline_end of the new-line \ character to the line."); let mut inline_end = split_fragment(inline_end); @@ -680,7 +680,7 @@ impl InlineFragments { // FIXME (rust#16151): This can be reverted back to using skip_while once // the upstream bug is fixed. - let mut fragments = mem::replace(&mut self.fragments, vec![]).move_iter(); + let mut fragments = mem::replace(&mut self.fragments, vec![]).into_iter(); let mut new_fragments = Vec::new(); let mut skipping = true; for fragment in fragments { @@ -703,7 +703,7 @@ impl InlineFragments { } let mut new_fragments = self.fragments.clone(); - while new_fragments.len() > 0 && new_fragments.as_slice().last().get_ref().is_whitespace_only() { + while new_fragments.len() > 0 && new_fragments.as_slice().last().as_ref().unwrap().is_whitespace_only() { debug!("stripping ignorable whitespace from end"); drop(new_fragments.pop()); } @@ -757,7 +757,7 @@ impl InlineFlow { // not recurse on a line if nothing in it can intersect the dirty region. debug!("Flow: building display list for {:u} inline fragments", self.fragments.len()); - for fragment in self.fragments.fragments.mut_iter() { + for fragment in self.fragments.fragments.iter_mut() { let rel_offset = fragment.relative_position(&self.base .absolute_position_info .relative_containing_block_size); @@ -923,7 +923,7 @@ impl Flow for InlineFlow { } let mut intrinsic_inline_sizes = IntrinsicISizes::new(); - for fragment in self.fragments.fragments.mut_iter() { + for fragment in self.fragments.fragments.iter_mut() { debug!("Flow: measuring {}", *fragment); let fragment_intrinsic_inline_sizes = @@ -953,7 +953,7 @@ impl Flow for InlineFlow { { let inline_size = self.base.position.size.inline; let this = &mut *self; - for fragment in this.fragments.fragments.mut_iter() { + for fragment in this.fragments.fragments.iter_mut() { fragment.assign_replaced_inline_size_if_necessary(inline_size); } } @@ -982,7 +982,7 @@ impl Flow for InlineFlow { debug!("assign_block_size_inline: floats in: {:?}", self.base.floats); // assign block-size for inline fragments - for fragment in self.fragments.fragments.mut_iter() { + for fragment in self.fragments.fragments.iter_mut() { fragment.assign_replaced_block_size_if_necessary(); } @@ -995,7 +995,7 @@ impl Flow for InlineFlow { // Now, go through each line and lay out the fragments inside. let mut line_distance_from_flow_block_start = Au(0); - for line in self.lines.mut_iter() { + for line in self.lines.iter_mut() { // Lay out fragments horizontally. InlineFlow::set_horizontal_fragment_positions(&mut self.fragments, line, text_align); @@ -1124,7 +1124,7 @@ impl Flow for InlineFlow { } fn compute_absolute_position(&mut self) { - for f in self.fragments.fragments.mut_iter() { + for f in self.fragments.fragments.iter_mut() { match f.specific { InlineBlockFragment(ref mut info) => { let block_flow = info.flow_ref.get_mut().as_block(); diff --git a/components/layout/layout_debug.rs b/components/layout/layout_debug.rs index 58db599c9e2..1c998e2bc4a 100644 --- a/components/layout/layout_debug.rs +++ b/components/layout/layout_debug.rs @@ -81,7 +81,7 @@ impl Drop for Scope { let mut state = refcell.borrow_mut(); let mut current_scope = state.scope_stack.pop().unwrap(); current_scope.post = json::encode(&state.flow_root.get()); - let previous_scope = state.scope_stack.mut_last().unwrap(); + let previous_scope = state.scope_stack.last_mut().unwrap(); previous_scope.children.push(current_scope); } None => {} diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index d535e1c247a..e974b1287fc 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -909,7 +909,7 @@ impl LayoutTask { let mut layers = SmallVec1::new(); layers.push(render_layer); for layer in mem::replace(&mut flow::mut_base(layout_root.get_mut()).layers, - DList::new()).move_iter() { + DList::new()).into_iter() { layers.push(layer) } diff --git a/components/layout/lib.rs b/components/layout/lib.rs index 3bc8b828771..a613a5dec1e 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -23,11 +23,11 @@ extern crate script_traits; extern crate serialize; extern crate style; #[phase(plugin)] -extern crate servo_macros = "macros"; -extern crate servo_net = "net"; -extern crate servo_msg = "msg"; +extern crate "macros" as servo_macros; +extern crate "net" as servo_net; +extern crate "msg" as servo_msg; #[phase(plugin, link)] -extern crate servo_util = "util"; +extern crate "util" as servo_util; extern crate collections; extern crate encoding; diff --git a/components/layout/model.rs b/components/layout/model.rs index 1642f0e7ee1..34cb231ba51 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -8,7 +8,7 @@ use fragment::Fragment; -use computed = style::computed_values; +use style::computed_values as computed; use geom::SideOffsets2D; use style::computed_values::{LPA_Auto, LPA_Length, LPA_Percentage, LP_Length, LP_Percentage}; use style::ComputedValues; diff --git a/components/layout/table.rs b/components/layout/table.rs index 744e031fdfa..e3f9ae3667a 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -107,7 +107,7 @@ impl TableFlow { pub fn update_col_inline_sizes(self_inline_sizes: &mut Vec<Au>, kid_inline_sizes: &Vec<Au>) -> Au { let mut sum_inline_sizes = Au(0); let mut kid_inline_sizes_it = kid_inline_sizes.iter(); - for self_inline_size in self_inline_sizes.mut_iter() { + for self_inline_size in self_inline_sizes.iter_mut() { match kid_inline_sizes_it.next() { Some(kid_inline_size) => { if *self_inline_size < *kid_inline_size { @@ -197,7 +197,7 @@ impl Flow for TableFlow { if !did_first_row { did_first_row = true; let mut child_inline_sizes = kid_col_inline_sizes.iter(); - for col_inline_size in self.col_inline_sizes.mut_iter() { + for col_inline_size in self.col_inline_sizes.iter_mut() { match child_inline_sizes.next() { Some(child_inline_size) => { if *col_inline_size == Au::new(0) { @@ -280,12 +280,12 @@ impl Flow for TableFlow { // any, or among all the columns if all are specified. if (total_column_inline_size < content_inline_size) && (num_unspecified_inline_sizes == 0) { let ratio = content_inline_size.to_f64().unwrap() / total_column_inline_size.to_f64().unwrap(); - for col_inline_size in self.col_inline_sizes.mut_iter() { + for col_inline_size in self.col_inline_sizes.iter_mut() { *col_inline_size = (*col_inline_size).scale_by(ratio); } } else if num_unspecified_inline_sizes != 0 { let extra_column_inline_size = (content_inline_size - total_column_inline_size) / num_unspecified_inline_sizes; - for col_inline_size in self.col_inline_sizes.mut_iter() { + for col_inline_size in self.col_inline_sizes.iter_mut() { if *col_inline_size == Au(0) { *col_inline_size = extra_column_inline_size; } diff --git a/components/layout/text.rs b/components/layout/text.rs index e90272e218a..e2ab1d545d5 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -231,7 +231,7 @@ impl TextRunScanner { continue } - let new_text_fragment_info = ScannedTextFragmentInfo::new(run.get_ref().clone(), range); + let new_text_fragment_info = ScannedTextFragmentInfo::new(run.as_ref().unwrap().clone(), range); let old_fragment = &in_fragments[i.to_uint()]; let new_metrics = new_text_fragment_info.run.metrics_for_range(&range); let bounding_box_size = bounding_box_for_run_metrics( diff --git a/components/layout/util.rs b/components/layout/util.rs index fd8cb10cd09..98a2b8d440e 100644 --- a/components/layout/util.rs +++ b/components/layout/util.rs @@ -123,7 +123,7 @@ impl OpaqueNodeMethods for OpaqueNode { fn from_thread_safe_layout_node(node: &ThreadSafeLayoutNode) -> OpaqueNode { unsafe { let abstract_node = node.get_jsmanaged(); - let ptr: uintptr_t = abstract_node.reflector().get_jsobject() as uint; + let ptr: uintptr_t = abstract_node.reflector().get_jsobject() as uintptr_t; OpaqueNode(ptr) } } diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 36bebcaf760..eb1eedfeaa2 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -452,7 +452,7 @@ impl<'le> TElement for LayoutElement<'le> { fn get_content(content_list: &content::T) -> String { match *content_list { content::Content(ref value) => { - let iter = &mut value.clone().move_iter().peekable(); + let iter = &mut value.clone().into_iter().peekable(); match iter.next() { Some(content::StringContent(content)) => content, _ => "".to_string(), @@ -533,13 +533,13 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> { fn text(&self) -> String { if self.pseudo != Normal { let layout_data_ref = self.borrow_layout_data(); - let node_layout_data_wrapper = layout_data_ref.get_ref(); + let node_layout_data_wrapper = layout_data_ref.as_ref().unwrap(); if self.pseudo == Before || self.pseudo == BeforeBlock { - let before_style = node_layout_data_wrapper.data.before_style.get_ref(); + let before_style = node_layout_data_wrapper.data.before_style.as_ref().unwrap(); return get_content(&before_style.get_box().content) } else { - let after_style = node_layout_data_wrapper.data.after_style.get_ref(); + let after_style = node_layout_data_wrapper.data.after_style.as_ref().unwrap(); return get_content(&after_style.get_box().content) } } @@ -610,19 +610,19 @@ impl<'ln> ThreadSafeLayoutNode<'ln> { pub fn is_block(&self, kind: PseudoElementType) -> bool { let mut layout_data_ref = self.mutate_layout_data(); - let node_layout_data_wrapper = layout_data_ref.get_mut_ref(); + let node_layout_data_wrapper = layout_data_ref.as_mut().unwrap(); let display = match kind { Before | BeforeBlock => { - let before_style = node_layout_data_wrapper.data.before_style.get_ref(); + let before_style = node_layout_data_wrapper.data.before_style.as_ref().unwrap(); before_style.get_box().display } After | AfterBlock => { - let after_style = node_layout_data_wrapper.data.after_style.get_ref(); + let after_style = node_layout_data_wrapper.data.after_style.as_ref().unwrap(); after_style.get_box().display } Normal => { - let after_style = node_layout_data_wrapper.shared_data.style.get_ref(); + let after_style = node_layout_data_wrapper.shared_data.style.as_ref().unwrap(); after_style.get_box().display } }; @@ -632,13 +632,13 @@ impl<'ln> ThreadSafeLayoutNode<'ln> { pub fn has_before_pseudo(&self) -> bool { let layout_data_wrapper = self.borrow_layout_data(); - let layout_data_wrapper_ref = layout_data_wrapper.get_ref(); + let layout_data_wrapper_ref = layout_data_wrapper.as_ref().unwrap(); layout_data_wrapper_ref.data.before_style.is_some() } pub fn has_after_pseudo(&self) -> bool { let layout_data_wrapper = self.borrow_layout_data(); - let layout_data_wrapper_ref = layout_data_wrapper.get_ref(); + let layout_data_wrapper_ref = layout_data_wrapper.as_ref().unwrap(); layout_data_wrapper_ref.data.after_style.is_some() } |