diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-03-18 16:28:09 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-03-18 16:28:09 -0600 |
commit | 2346c9b94055f84a536808e40ad0b596ee21fbf4 (patch) | |
tree | e9216526445ac4400992acbb8cb1aa88f8ecb655 | |
parent | 124a78fb2e4d324a7d0ed54da1cca17839d406b7 (diff) | |
parent | 6ef9cb4e18cd262ff051500249076c8979e12525 (diff) | |
download | servo-2346c9b94055f84a536808e40ad0b596ee21fbf4.tar.gz servo-2346c9b94055f84a536808e40ad0b596ee21fbf4.zip |
auto merge of #5266 : mbrubeck/servo/linked_list, r=metajack
Fixes deprecation warnings. Also removes a workaround for a fixed bug in Rust.
-rw-r--r-- | components/gfx/display_list/mod.rs | 38 | ||||
-rw-r--r-- | components/gfx/display_list/optimizer.rs | 6 | ||||
-rw-r--r-- | components/layout/text.rs | 6 | ||||
-rw-r--r-- | components/util/lib.rs | 2 | ||||
-rw-r--r-- | components/util/linked_list.rs (renamed from components/util/dlist.rs) | 4 | ||||
-rw-r--r-- | components/util/memory.rs | 30 |
6 files changed, 41 insertions, 45 deletions
diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 74c0792fdcd..2fdf6c071cd 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -26,7 +26,7 @@ use text::TextRun; use azure::azure::AzFloat; use azure::azure_hl::{Color}; -use collections::dlist::{self, DList}; +use collections::linked_list::{self, LinkedList}; use geom::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D}; use geom::approxeq::ApproxEq; use geom::num::Zero; @@ -35,7 +35,7 @@ use paint_task::PaintLayer; use msg::compositor_msg::LayerId; use net::image::base::Image; use util::cursor::Cursor; -use util::dlist as servo_dlist; +use util::linked_list::prepend_from; use util::geometry::{self, Au, MAX_RECT, ZERO_RECT}; use util::memory::SizeOf; use util::range::Range; @@ -81,17 +81,17 @@ impl OpaqueNode { /// structure, omitting several pointers and lengths. pub struct DisplayList { /// The border and backgrounds for the root of this stacking context: steps 1 and 2. - pub background_and_borders: DList<DisplayItem>, + pub background_and_borders: LinkedList<DisplayItem>, /// Borders and backgrounds for block-level descendants: step 4. - pub block_backgrounds_and_borders: DList<DisplayItem>, + pub block_backgrounds_and_borders: LinkedList<DisplayItem>, /// Floats: step 5. These are treated as pseudo-stacking contexts. - pub floats: DList<DisplayItem>, + pub floats: LinkedList<DisplayItem>, /// All other content. - pub content: DList<DisplayItem>, + pub content: LinkedList<DisplayItem>, /// Outlines: step 10. - pub outlines: DList<DisplayItem>, + pub outlines: LinkedList<DisplayItem>, /// Child stacking contexts. - pub children: DList<Arc<StackingContext>>, + pub children: LinkedList<Arc<StackingContext>>, } impl DisplayList { @@ -99,12 +99,12 @@ impl DisplayList { #[inline] pub fn new() -> DisplayList { DisplayList { - background_and_borders: DList::new(), - block_backgrounds_and_borders: DList::new(), - floats: DList::new(), - content: DList::new(), - outlines: DList::new(), - children: DList::new(), + background_and_borders: LinkedList::new(), + block_backgrounds_and_borders: LinkedList::new(), + floats: LinkedList::new(), + content: LinkedList::new(), + outlines: LinkedList::new(), + children: LinkedList::new(), } } @@ -123,10 +123,10 @@ impl DisplayList { /// Merges all display items from all non-float stacking levels to the `float` stacking level. #[inline] pub fn form_float_pseudo_stacking_context(&mut self) { - servo_dlist::prepend_from(&mut self.floats, &mut self.outlines); - servo_dlist::prepend_from(&mut self.floats, &mut self.content); - servo_dlist::prepend_from(&mut self.floats, &mut self.block_backgrounds_and_borders); - servo_dlist::prepend_from(&mut self.floats, &mut self.background_and_borders); + prepend_from(&mut self.floats, &mut self.outlines); + prepend_from(&mut self.floats, &mut self.content); + prepend_from(&mut self.floats, &mut self.block_backgrounds_and_borders); + prepend_from(&mut self.floats, &mut self.background_and_borders); } /// Returns a list of all items in this display list concatenated together. This is extremely @@ -1002,7 +1002,7 @@ pub enum BoxShadowClipMode { pub enum DisplayItemIterator<'a> { Empty, - Parent(dlist::Iter<'a,DisplayItem>), + Parent(linked_list::Iter<'a,DisplayItem>), } impl<'a> Iterator for DisplayItemIterator<'a> { diff --git a/components/gfx/display_list/optimizer.rs b/components/gfx/display_list/optimizer.rs index f14ff8a74a8..9306d81bbac 100644 --- a/components/gfx/display_list/optimizer.rs +++ b/components/gfx/display_list/optimizer.rs @@ -6,7 +6,7 @@ use display_list::{DisplayItem, DisplayList, StackingContext}; -use collections::dlist::DList; +use collections::linked_list::LinkedList; use geom::rect::Rect; use util::geometry::{self, Au}; use std::sync::Arc; @@ -42,7 +42,7 @@ impl DisplayListOptimizer { /// Adds display items that intersect the visible rect to `result_list`. fn add_in_bounds_display_items<'a,I>(&self, - result_list: &mut DList<DisplayItem>, + result_list: &mut LinkedList<DisplayItem>, display_items: I) where I: Iterator<Item=&'a DisplayItem> { for display_item in display_items { @@ -55,7 +55,7 @@ impl DisplayListOptimizer { /// Adds child stacking contexts whose boundaries intersect the visible rect to `result_list`. fn add_in_bounds_stacking_contexts<'a,I>(&self, - result_list: &mut DList<Arc<StackingContext>>, + result_list: &mut LinkedList<Arc<StackingContext>>, stacking_contexts: I) where I: Iterator<Item=&'a Arc<StackingContext>> { for stacking_context in stacking_contexts { diff --git a/components/layout/text.rs b/components/layout/text.rs index 9c25dbccf02..9ac4d9b1174 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -15,7 +15,7 @@ use gfx::font_context::FontContext; use gfx::text::glyph::CharIndex; use gfx::text::text_run::TextRun; use gfx::text::util::{self, CompressionMode}; -use util::dlist; +use util::linked_list::split_off_head; use util::geometry::Au; use util::logical_geometry::{LogicalSize, WritingMode}; use util::range::Range; @@ -50,13 +50,13 @@ impl TextRunScanner { let mut last_whitespace = true; while !fragments.is_empty() { // Create a clump. - self.clump.append(&mut dlist::split_off_head(&mut fragments)); + self.clump.append(&mut split_off_head(&mut fragments)); while !fragments.is_empty() && self.clump .back() .unwrap() .can_merge_with_fragment(fragments.front() .unwrap()) { - self.clump.append(&mut dlist::split_off_head(&mut fragments)); + self.clump.append(&mut split_off_head(&mut fragments)); } // Flush that clump to the list of fragments we're building up. diff --git a/components/util/lib.rs b/components/util/lib.rs index 094bd292897..05d0c4058f9 100644 --- a/components/util/lib.rs +++ b/components/util/lib.rs @@ -59,7 +59,7 @@ pub mod cache; pub mod cursor; pub mod debug_utils; pub mod deque; -pub mod dlist; +pub mod linked_list; pub mod fnv; pub mod geometry; pub mod logical_geometry; diff --git a/components/util/dlist.rs b/components/util/linked_list.rs index 95cadd025c1..5114f02c0e4 100644 --- a/components/util/dlist.rs +++ b/components/util/linked_list.rs @@ -9,10 +9,6 @@ use std::mem; /// Splits the head off a list in O(1) time, and returns the head. pub fn split_off_head<T>(list: &mut LinkedList<T>) -> LinkedList<T> { - // FIXME: Work around https://github.com/rust-lang/rust/issues/22244 - if list.len() == 1 { - return mem::replace(list, LinkedList::new()); - } let tail = list.split_off(1); mem::replace(list, tail) } diff --git a/components/util/memory.rs b/components/util/memory.rs index 4bc44b332c3..487d22aab86 100644 --- a/components/util/memory.rs +++ b/components/util/memory.rs @@ -7,7 +7,7 @@ use libc::{c_char,c_int,c_void,size_t}; use std::borrow::ToOwned; use std::collections::HashMap; -use std::collections::LinkedList as DList; +use std::collections::LinkedList; use std::ffi::CString; #[cfg(target_os = "linux")] use std::iter::AdditiveIterator; @@ -109,18 +109,18 @@ impl<T: SizeOf> SizeOf for Vec<T> { } } -// FIXME(njn): We can't implement SizeOf accurately for DList because it requires access to the +// FIXME(njn): We can't implement SizeOf accurately for LinkedList because it requires access to the // private Node type. Eventually we'll want to add SizeOf (or equivalent) to Rust itself. In the -// meantime, we use the dirty hack of transmuting DList into an identical type (DList2) and +// meantime, we use the dirty hack of transmuting LinkedList into an identical type (LinkedList2) and // measuring that. -impl<T: SizeOf> SizeOf for DList<T> { +impl<T: SizeOf> SizeOf for LinkedList<T> { fn size_of_excluding_self(&self) -> usize { - let list2: &DList2<T> = unsafe { transmute(self) }; + let list2: &LinkedList2<T> = unsafe { transmute(self) }; list2.size_of_excluding_self() } } -struct DList2<T> { +struct LinkedList2<T> { _length: usize, list_head: Link<T>, _list_tail: Rawlink<Node<T>>, @@ -140,14 +140,14 @@ struct Node<T> { impl<T: SizeOf> SizeOf for Node<T> { // Unlike most size_of_excluding_self() functions, this one does *not* measure descendents. - // Instead, DList2<T>::size_of_excluding_self() handles that, so that it can use iteration + // Instead, LinkedList2<T>::size_of_excluding_self() handles that, so that it can use iteration // instead of recursion, which avoids potentially blowing the stack. fn size_of_excluding_self(&self) -> usize { self.value.size_of_excluding_self() } } -impl<T: SizeOf> SizeOf for DList2<T> { +impl<T: SizeOf> SizeOf for LinkedList2<T> { fn size_of_excluding_self(&self) -> usize { let mut size = 0; let mut curr: &Link<T> = &self.list_head; @@ -159,17 +159,17 @@ impl<T: SizeOf> SizeOf for DList2<T> { } } -// This is a basic sanity check. If the representation of DList changes such that it becomes a -// different size to DList2, this will fail at compile-time. +// This is a basic sanity check. If the representation of LinkedList changes such that it becomes a +// different size to LinkedList2, this will fail at compile-time. #[allow(dead_code)] -unsafe fn dlist2_check() { - transmute::<DList<i32>, DList2<i32>>(panic!()); +unsafe fn linked_list2_check() { + transmute::<LinkedList<i32>, LinkedList2<i32>>(panic!()); } -// Currently, types that implement the Drop type are larger than those that don't. Because DList -// implements Drop, DList2 must also so that dlist2_check() doesn't fail. +// Currently, types that implement the Drop type are larger than those that don't. Because +// LinkedList implements Drop, LinkedList2 must also so that linked_list2_check() doesn't fail. #[unsafe_destructor] -impl<T> Drop for DList2<T> { +impl<T> Drop for LinkedList2<T> { fn drop(&mut self) {} } |