diff options
153 files changed, 2093 insertions, 1296 deletions
diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs index 637d73b40b5..0e4ee649a5b 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_task.rs @@ -10,6 +10,7 @@ use servo_util::task::spawn_named; use std::comm; +#[deriving(Copy)] pub enum CanvasMsg { FillRect(Rect<f32>), ClearRect(Rect<f32>), diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 40d0f56dfa7..134b7ee0af1 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -29,9 +29,9 @@ use png; use gleam::gl::types::{GLint, GLsizei}; use gleam::gl; use script_traits::{ConstellationControlMsg, ScriptControlChan}; -use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, LayerId}; -use servo_msg::compositor_msg::{ReadyState, PaintState, Scrollable}; -use servo_msg::constellation_msg::{mod, ConstellationChan}; +use servo_msg::compositor_msg::{Epoch, LayerId}; +use servo_msg::compositor_msg::{ReadyState, PaintState, ScrollPolicy}; +use servo_msg::constellation_msg::{ConstellationChan, NavigationDirection}; use servo_msg::constellation_msg::Msg as ConstellationMsg; use servo_msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData}; use servo_msg::constellation_msg::{PipelineId, WindowSizeData}; @@ -147,7 +147,7 @@ enum CompositionRequest { CompositeNow, } -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] enum ShutdownState { NotShuttingDown, ShuttingDown, @@ -380,9 +380,10 @@ impl<Window: WindowMethods> IOCompositor<Window> { fn get_earliest_pipeline_ready_state(&self) -> ReadyState { if self.ready_states.len() == 0 { - return Blank; + return ReadyState::Blank; } - return self.ready_states.values().fold(FinishedLoading, |a, &b| cmp::min(a, b)); + return self.ready_states.values().fold(ReadyState::FinishedLoading, + |a, &b| cmp::min(a, b)); } @@ -477,7 +478,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { id: LayerId::null(), rect: Rect::zero(), background_color: azure_hl::Color::new(0., 0., 0., 0.), - scroll_policy: Scrollable, + scroll_policy: ScrollPolicy::Scrollable, }; let root_layer = CompositorData::new_layer(pipeline.clone(), @@ -504,7 +505,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { frame_rect: Option<TypedRect<PagePx, f32>>) -> Rc<Layer<CompositorData>> { // Initialize the ReadyState and PaintState for this pipeline. - self.ready_states.insert(frame_tree.pipeline.id, Blank); + self.ready_states.insert(frame_tree.pipeline.id, ReadyState::Blank); self.paint_states.insert(frame_tree.pipeline.id, PaintState::Painting); let root_layer = self.create_root_layer_for_pipeline_and_rect(&frame_tree.pipeline, @@ -907,8 +908,8 @@ impl<Window: WindowMethods> IOCompositor<Window> { fn on_navigation_window_event(&self, direction: WindowNavigateMsg) { let direction = match direction { - windowing::WindowNavigateMsg::Forward => constellation_msg::Forward, - windowing::WindowNavigateMsg::Back => constellation_msg::Back, + windowing::WindowNavigateMsg::Forward => NavigationDirection::Forward, + windowing::WindowNavigateMsg::Back => NavigationDirection::Back, }; let ConstellationChan(ref chan) = self.constellation_chan; chan.send(ConstellationMsg::Navigate(direction)) @@ -916,7 +917,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { fn on_key_event(&self, key: Key, state: KeyState, modifiers: KeyModifiers) { let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(constellation_msg::KeyEvent(key, state, modifiers)) + chan.send(ConstellationMsg::KeyEvent(key, state, modifiers)) } fn convert_buffer_requests_to_pipeline_requests_map(&self, @@ -1025,7 +1026,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { return false; } - if self.get_earliest_pipeline_ready_state() != FinishedLoading { + if self.get_earliest_pipeline_ready_state() != ReadyState::FinishedLoading { return false; } @@ -1123,7 +1124,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { let mut img = png::Image { width: width as u32, height: height as u32, - pixels: png::RGB8(pixels), + pixels: png::PixelsByColorType::RGB8(pixels), }; let res = png::store_png(&mut img, &path); assert!(res.is_ok()); diff --git a/components/compositing/compositor_layer.rs b/components/compositing/compositor_layer.rs index 665e786d262..ba6d969c0e1 100644 --- a/components/compositing/compositor_layer.rs +++ b/components/compositing/compositor_layer.rs @@ -17,9 +17,9 @@ use layers::color::Color; use layers::geometry::LayerPixel; use layers::layers::{Layer, LayerBufferSet}; use layers::platform::surface::NativeSurfaceMethods; -use script_traits::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent}; +use script_traits::CompositorEvent::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent}; use script_traits::{ScriptControlChan, ConstellationControlMsg}; -use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId, ScrollPolicy}; +use servo_msg::compositor_msg::{Epoch, LayerId, ScrollPolicy}; use std::num::Float; use std::num::FloatMath; use std::rc::Rc; @@ -122,7 +122,7 @@ pub trait CompositorLayer { fn wants_scroll_events(&self) -> WantsScrollEventsFlag; } -#[deriving(PartialEq, Clone)] +#[deriving(Copy, PartialEq, Clone)] pub enum WantsScrollEventsFlag { WantsScrollEvents, DoesntWantScrollEvents, @@ -343,7 +343,7 @@ impl CompositorLayer for Layer<CompositorData> { let mut result = false; // Only scroll this layer if it's not fixed-positioned. - if self.extra_data.borrow().scroll_policy != FixedPosition { + if self.extra_data.borrow().scroll_policy != ScrollPolicy::FixedPosition { let new_offset = new_offset.to_untyped(); *self.transform.borrow_mut() = identity().translate(new_offset.x, new_offset.y, 0.0); *self.content_offset.borrow_mut() = Point2D::from_untyped(&new_offset); diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index 147bbe4b211..0c1fed90ece 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -20,12 +20,12 @@ use layers::layers::LayerBufferSet; use servo_msg::compositor_msg::{Epoch, LayerId, LayerMetadata, ReadyState}; use servo_msg::compositor_msg::{PaintListener, PaintState, ScriptListener, ScrollPolicy}; use servo_msg::constellation_msg::{ConstellationChan, LoadData, PipelineId}; -use servo_msg::constellation_msg::{Key, KeyState, KeyModifiers, Pressed}; +use servo_msg::constellation_msg::{Key, KeyState, KeyModifiers}; use servo_util::cursor::Cursor; use servo_util::memory::MemoryProfilerChan; use servo_util::time::TimeProfilerChan; use std::comm::{channel, Sender, Receiver}; -use std::fmt::{FormatError, Formatter, Show}; +use std::fmt::{Error, Formatter, Show}; use std::rc::Rc; /// Sends messages to the compositor. This is a trait supplied by the port because the method used @@ -89,13 +89,14 @@ impl ScriptListener for Box<CompositorProxy+'static+Send> { } fn send_key_event(&mut self, key: Key, state: KeyState, modifiers: KeyModifiers) { - if state == Pressed { + if state == KeyState::Pressed { self.send(Msg::KeyEvent(key, modifiers)); } } } /// Information about each layer that the compositor keeps. +#[deriving(Copy)] pub struct LayerProperties { pub pipeline_id: PipelineId, pub epoch: Epoch, @@ -221,7 +222,7 @@ pub enum Msg { } impl Show for Msg { - fn fmt(&self, f: &mut Formatter) -> Result<(),FormatError> { + fn fmt(&self, f: &mut Formatter) -> Result<(),Error> { match *self { Msg::Exit(..) => write!(f, "Exit"), Msg::ShutdownComplete(..) => write!(f, "ShutdownComplete"), diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 9ec8fb9aaa6..06f0289f338 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -14,12 +14,12 @@ use gfx::font_cache_task::FontCacheTask; use layers::geometry::DevicePixel; use layout_traits::LayoutTaskFactory; use libc; -use script_traits::{mod, ConstellationControlMsg}; +use script_traits::{CompositorEvent, ConstellationControlMsg}; use script_traits::{ScriptControlChan, ScriptTaskFactory}; use servo_msg::compositor_msg::LayerId; use servo_msg::constellation_msg::{mod, ConstellationChan, Failure}; -use servo_msg::constellation_msg::{IFrameSandboxState, IFrameUnsandboxed}; -use servo_msg::constellation_msg::{KeyEvent, Key, KeyState, KeyModifiers}; +use servo_msg::constellation_msg::{IFrameSandboxState, NavigationDirection}; +use servo_msg::constellation_msg::{Key, KeyState, KeyModifiers}; use servo_msg::constellation_msg::{LoadData, NavigationType}; use servo_msg::constellation_msg::{PipelineExitType, PipelineId}; use servo_msg::constellation_msg::{SubpageId, WindowSizeData}; @@ -27,8 +27,7 @@ use servo_msg::constellation_msg::Msg as ConstellationMsg; use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient}; use servo_net::resource_task::ResourceTask; use servo_net::resource_task; -use servo_net::storage_task::StorageTask; -use servo_net::storage_task; +use servo_net::storage_task::{StorageTask, StorageTaskMsg}; use servo_util::cursor::Cursor; use servo_util::geometry::{PagePx, ViewportPx}; use servo_util::opts; @@ -91,6 +90,7 @@ pub struct Constellation<LTF, STF> { } /// A unique ID used to identify a frame. +#[deriving(Copy)] pub struct FrameId(u32); /// One frame in the hierarchy. @@ -515,11 +515,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { pipeline.exit(PipelineExitType::Complete); } self.image_cache_task.exit(); - self.resource_task.send(resource_task::Exit); + self.resource_task.send(resource_task::ControlMsg::Exit); self.devtools_chan.as_ref().map(|chan| { chan.send(devtools_traits::ServerExitMsg); }); - self.storage_task.send(storage_task::Exit); + self.storage_task.send(StorageTaskMsg::Exit); self.font_cache_task.exit(); self.compositor_proxy.send(CompositorMsg::ShutdownComplete); } @@ -571,7 +571,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { self.browse(Some(pipeline_id), Rc::new(FrameTree::new(new_frame_id, pipeline.clone(), None)), - constellation_msg::Load); + NavigationType::Load); self.pipelines.insert(new_id, pipeline); } @@ -596,7 +596,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { let pipeline = self.new_pipeline(next_pipeline_id, None, None, LoadData::new(url)); self.browse(None, Rc::new(FrameTree::new(next_frame_id, pipeline.clone(), None)), - constellation_msg::Load); + NavigationType::Load); self.pipelines.insert(pipeline.id, pipeline); } @@ -718,7 +718,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { let source_url = source_pipeline.load_data.url.clone(); let same_script = (source_url.host() == url.host() && - source_url.port() == url.port()) && sandbox == IFrameUnsandboxed; + source_url.port() == url.port()) && + sandbox == IFrameSandboxState::IFrameUnsandboxed; // FIXME(tkuehn): Need to follow the standardized spec for checking same-origin // Reuse the script task if the URL is same-origin let script_pipeline = if same_script { @@ -785,7 +786,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { Rc::new(FrameTree::new(next_frame_id, pipeline.clone(), parent.borrow().clone())), - constellation_msg::Load); + NavigationType::Load); self.pipelines.insert(pipeline.id, pipeline); } @@ -797,7 +798,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { // navigation always has navigation priority, and after that new page loading is // first come, first served. let destination_frame = match direction { - constellation_msg::Forward => { + NavigationDirection::Forward => { if self.navigation_context.next.is_empty() { debug!("no next page to navigate to"); return; @@ -809,7 +810,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { } self.navigation_context.forward(&mut *self.compositor_proxy) } - constellation_msg::Back => { + NavigationDirection::Back => { if self.navigation_context.previous.is_empty() { debug!("no previous page to navigate to"); return; @@ -826,7 +827,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { for frame in destination_frame.iter() { frame.pipeline.load(); } - self.grant_paint_permission(destination_frame, constellation_msg::Navigate); + self.grant_paint_permission(destination_frame, NavigationType::Navigate); } @@ -838,7 +839,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { fn handle_key_msg(&self, key: Key, state: KeyState, mods: KeyModifiers) { self.current_frame().as_ref().map(|frame| { let ScriptControlChan(ref chan) = frame.pipeline.script_chan; - chan.send(ConstellationControlMsg::SendEvent(frame.pipeline.id, script_traits::KeyEvent(key, state, mods))); + chan.send(ConstellationControlMsg::SendEvent( + frame.pipeline.id, CompositorEvent::KeyEvent(key, state, mods))); }); } @@ -1005,7 +1007,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { // Don't call navigation_context.load() on a Navigate type (or None, as in the case of // parsed iframes that finish loading) match navigation_type { - constellation_msg::Load => { + NavigationType::Load => { debug!("evicting old frames due to load"); let evicted = self.navigation_context.load(frame_tree, &mut *self.compositor_proxy); diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index 8c22d7c9ea4..c8a054d16ef 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -3,13 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use CompositorProxy; -use layout_traits::{ExitNowMsg, LayoutTaskFactory, LayoutControlChan}; +use layout_traits::{LayoutControlMsg, LayoutTaskFactory, LayoutControlChan}; use script_traits::{ScriptControlChan, ScriptTaskFactory}; use script_traits::{NewLayoutInfo, ConstellationControlMsg}; use devtools_traits::DevtoolsControlChan; use gfx::paint_task::Msg as PaintMsg; -use gfx::paint_task::{PaintPermissionGranted, PaintPermissionRevoked}; use gfx::paint_task::{PaintChan, PaintTask}; use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineId, SubpageId}; use servo_msg::constellation_msg::{LoadData, WindowSizeData, PipelineExitType}; @@ -166,12 +165,12 @@ impl Pipeline { } pub fn grant_paint_permission(&self) { - let _ = self.paint_chan.send_opt(PaintPermissionGranted); + let _ = self.paint_chan.send_opt(PaintMsg::PaintPermissionGranted); } pub fn revoke_paint_permission(&self) { debug!("pipeline revoking paint channel paint permission"); - let _ = self.paint_chan.send_opt(PaintPermissionRevoked); + let _ = self.paint_chan.send_opt(PaintMsg::PaintPermissionRevoked); } pub fn exit(&self, exit_type: PipelineExitType) { @@ -196,7 +195,7 @@ impl Pipeline { PipelineExitType::PipelineOnly)); let _ = self.paint_chan.send_opt(PaintMsg::Exit(None, PipelineExitType::PipelineOnly)); let LayoutControlChan(ref layout_channel) = self.layout_chan; - let _ = layout_channel.send_opt(ExitNowMsg(PipelineExitType::PipelineOnly)); + let _ = layout_channel.send_opt(LayoutControlMsg::ExitNowMsg(PipelineExitType::PipelineOnly)); } pub fn to_sendable(&self) -> CompositionPipeline { diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index 08a99aa2e03..eae46c2d5fb 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -15,21 +15,24 @@ use servo_msg::compositor_msg::{PaintState, ReadyState}; use servo_msg::constellation_msg::{Key, KeyState, KeyModifiers, LoadData}; use servo_util::cursor::Cursor; use servo_util::geometry::ScreenPx; -use std::fmt::{FormatError, Formatter, Show}; +use std::fmt::{Error, Formatter, Show}; use std::rc::Rc; +#[deriving(Clone)] pub enum MouseWindowEvent { Click(uint, TypedPoint2D<DevicePixel, f32>), MouseDown(uint, TypedPoint2D<DevicePixel, f32>), MouseUp(uint, TypedPoint2D<DevicePixel, f32>), } +#[deriving(Clone)] pub enum WindowNavigateMsg { Forward, Back, } /// Events that the windowing system sends to Servo. +#[deriving(Clone)] pub enum WindowEvent { /// Sent when no message has arrived, but the event loop was kicked for some reason (perhaps /// by another Servo subsystem). @@ -68,7 +71,7 @@ pub enum WindowEvent { } impl Show for WindowEvent { - fn fmt(&self, f: &mut Formatter) -> Result<(),FormatError> { + fn fmt(&self, f: &mut Formatter) -> Result<(),Error> { match *self { WindowEvent::Idle => write!(f, "Idle"), WindowEvent::Refresh => write!(f, "Refresh"), diff --git a/components/devtools/actor.rs b/components/devtools/actor.rs index 47d0c30761d..87c3d45f139 100644 --- a/components/devtools/actor.rs +++ b/components/devtools/actor.rs @@ -20,7 +20,7 @@ pub trait Actor : Any { fn handle_message(&self, registry: &ActorRegistry, msg_type: &String, - msg: &json::JsonObject, + msg: &json::Object, stream: &mut TcpStream) -> Result<bool, ()>; fn name(&self) -> String; } @@ -149,14 +149,14 @@ impl ActorRegistry { /// Attempt to process a message as directed by its `to` property. If the actor is not /// found or does not indicate that it knew how to process the message, ignore the failure. pub fn handle_message(&mut self, - msg: &json::JsonObject, + msg: &json::Object, stream: &mut TcpStream) -> Result<(), ()> { - let to = msg.get(&"to".to_string()).unwrap().as_string().unwrap(); + let to = msg.get("to").unwrap().as_string().unwrap(); match self.actors.get(&to.to_string()) { None => println!("message received for unknown actor \"{}\"", to), Some(actor) => { - let msg_type = msg.get(&"type".to_string()).unwrap().as_string().unwrap(); + let msg_type = msg.get("type").unwrap().as_string().unwrap(); if !try!(actor.handle_message(self, &msg_type.to_string(), msg, stream)) { println!("unexpected message type \"{}\" found for actor \"{}\"", msg_type, to); diff --git a/components/devtools/actors/console.rs b/components/devtools/actors/console.rs index 8839e6f8a34..5628506d5af 100644 --- a/components/devtools/actors/console.rs +++ b/components/devtools/actors/console.rs @@ -15,8 +15,7 @@ use servo_msg::constellation_msg::PipelineId; use collections::TreeMap; use core::cell::RefCell; -use serialize::json; -use serialize::json::ToJson; +use serialize::json::{mod, Json, ToJson}; use std::io::TcpStream; use std::num::Float; @@ -76,7 +75,7 @@ enum ConsoleMessageType { #[deriving(Encodable)] struct GetCachedMessagesReply { from: String, - messages: Vec<json::JsonObject>, + messages: Vec<json::Object>, } #[deriving(Encodable)] @@ -96,11 +95,11 @@ struct AutocompleteReply { struct EvaluateJSReply { from: String, input: String, - result: json::Json, + result: Json, timestamp: uint, - exception: json::Json, + exception: Json, exceptionMessage: String, - helperResult: json::Json, + helperResult: Json, } pub struct ConsoleActor { @@ -118,11 +117,11 @@ impl Actor for ConsoleActor { fn handle_message(&self, _registry: &ActorRegistry, msg_type: &String, - msg: &json::JsonObject, + msg: &json::Object, stream: &mut TcpStream) -> Result<bool, ()> { Ok(match msg_type.as_slice() { "getCachedMessages" => { - let types = msg.get(&"messageTypes".to_string()).unwrap().as_list().unwrap(); + let types = msg.get(&"messageTypes".to_string()).unwrap().as_array().unwrap(); let /*mut*/ messages = vec!(); for msg_type in types.iter() { let msg_type = msg_type.as_string().unwrap(); @@ -196,7 +195,7 @@ impl Actor for ConsoleActor { from: self.name(), stoppedListeners: msg.get(&"listeners".to_string()) .unwrap() - .as_list() + .as_array() .unwrap_or(&vec!()) .iter() .map(|listener| listener.as_string().unwrap().to_string()) @@ -228,19 +227,19 @@ impl Actor for ConsoleActor { VoidValue => { let mut m = TreeMap::new(); m.insert("type".to_string(), "undefined".to_string().to_json()); - json::Object(m) + Json::Object(m) } NullValue => { let mut m = TreeMap::new(); m.insert("type".to_string(), "null".to_string().to_json()); - json::Object(m) + Json::Object(m) } BooleanValue(val) => val.to_json(), NumberValue(val) => { if val.is_nan() { let mut m = TreeMap::new(); m.insert("type".to_string(), "NaN".to_string().to_json()); - json::Object(m) + Json::Object(m) } else if val.is_infinite() { let mut m = TreeMap::new(); if val < 0. { @@ -248,11 +247,11 @@ impl Actor for ConsoleActor { } else { m.insert("type".to_string(), "Infinity".to_string().to_json()); } - json::Object(m) + Json::Object(m) } else if val == Float::neg_zero() { let mut m = TreeMap::new(); m.insert("type".to_string(), "-0".to_string().to_json()); - json::Object(m) + Json::Object(m) } else { val.to_json() } @@ -267,7 +266,7 @@ impl Actor for ConsoleActor { m.insert("extensible".to_string(), true.to_json()); m.insert("frozen".to_string(), false.to_json()); m.insert("sealed".to_string(), false.to_json()); - json::Object(m) + Json::Object(m) } }; @@ -277,9 +276,9 @@ impl Actor for ConsoleActor { input: input, result: result, timestamp: 0, - exception: json::Object(TreeMap::new()), + exception: Json::Object(TreeMap::new()), exceptionMessage: "".to_string(), - helperResult: json::Object(TreeMap::new()), + helperResult: Json::Object(TreeMap::new()), }; stream.write_json_packet(&msg); true diff --git a/components/devtools/actors/inspector.rs b/components/devtools/actors/inspector.rs index f35ae3d9f40..ac3b51cf34f 100644 --- a/components/devtools/actors/inspector.rs +++ b/components/devtools/actors/inspector.rs @@ -12,8 +12,7 @@ use protocol::JsonPacketStream; use collections::TreeMap; use servo_msg::constellation_msg::PipelineId; -use serialize::json; -use serialize::json::ToJson; +use serialize::json::{mod, Json, ToJson}; use std::cell::RefCell; use std::io::TcpStream; use std::num::Float; @@ -66,7 +65,7 @@ impl Actor for HighlighterActor { fn handle_message(&self, _registry: &ActorRegistry, msg_type: &String, - _msg: &json::JsonObject, + _msg: &json::Object, stream: &mut TcpStream) -> Result<bool, ()> { Ok(match msg_type.as_slice() { "showBoxModel" => { @@ -103,12 +102,12 @@ impl Actor for NodeActor { fn handle_message(&self, registry: &ActorRegistry, msg_type: &String, - msg: &json::JsonObject, + msg: &json::Object, stream: &mut TcpStream) -> Result<bool, ()> { Ok(match msg_type.as_slice() { "modifyAttributes" => { let target = msg.get(&"to".to_string()).unwrap().as_string().unwrap(); - let mods = msg.get(&"modifications".to_string()).unwrap().as_list().unwrap(); + let mods = msg.get(&"modifications".to_string()).unwrap().as_array().unwrap(); let modifications = mods.iter().map(|json_mod| { json::decode(json_mod.to_string().as_slice()).unwrap() }).collect(); @@ -276,7 +275,7 @@ impl Actor for WalkerActor { fn handle_message(&self, registry: &ActorRegistry, msg_type: &String, - msg: &json::JsonObject, + msg: &json::Object, stream: &mut TcpStream) -> Result<bool, ()> { Ok(match msg_type.as_slice() { "querySelector" => { @@ -368,7 +367,7 @@ struct GetComputedReply { #[deriving(Encodable)] struct AppliedEntry { rule: String, - pseudoElement: json::Json, + pseudoElement: Json, isSystem: bool, matchedSelectors: Vec<String>, } @@ -400,7 +399,7 @@ struct AppliedSheet { struct GetLayoutReply { width: int, height: int, - autoMargins: json::Json, + autoMargins: Json, from: String, } @@ -421,7 +420,7 @@ impl Actor for PageStyleActor { fn handle_message(&self, registry: &ActorRegistry, msg_type: &String, - msg: &json::JsonObject, + msg: &json::Object, stream: &mut TcpStream) -> Result<bool, ()> { Ok(match msg_type.as_slice() { "getApplied" => { @@ -469,9 +468,9 @@ impl Actor for PageStyleActor { m.insert("bottom".to_string(), "auto".to_string().to_json()); m.insert("left".to_string(), "auto".to_string().to_json()); m.insert("right".to_string(), "auto".to_string().to_json()); - json::Object(m) + Json::Object(m) } else { - json::Null + Json::Null }, from: self.name(), }; @@ -492,7 +491,7 @@ impl Actor for InspectorActor { fn handle_message(&self, registry: &ActorRegistry, msg_type: &String, - _msg: &json::JsonObject, + _msg: &json::Object, stream: &mut TcpStream) -> Result<bool, ()> { Ok(match msg_type.as_slice() { "getWalker" => { diff --git a/components/devtools/actors/root.rs b/components/devtools/actors/root.rs index 50d0e314bd2..da0e33d7c7d 100644 --- a/components/devtools/actors/root.rs +++ b/components/devtools/actors/root.rs @@ -53,7 +53,7 @@ impl Actor for RootActor { fn handle_message(&self, registry: &ActorRegistry, msg_type: &String, - _msg: &json::JsonObject, + _msg: &json::Object, stream: &mut TcpStream) -> Result<bool, ()> { Ok(match msg_type.as_slice() { "listAddons" => { diff --git a/components/devtools/actors/tab.rs b/components/devtools/actors/tab.rs index f185f4ab5a9..519e3e48128 100644 --- a/components/devtools/actors/tab.rs +++ b/components/devtools/actors/tab.rs @@ -77,7 +77,7 @@ impl Actor for TabActor { fn handle_message(&self, registry: &ActorRegistry, msg_type: &String, - _msg: &json::JsonObject, + _msg: &json::Object, stream: &mut TcpStream) -> Result<bool, ()> { Ok(match msg_type.as_slice() { "reconfigure" => { diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index 3552fa9948a..62ab676e3b7 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -21,7 +21,6 @@ extern crate collections; extern crate core; extern crate devtools_traits; extern crate serialize; -extern crate sync; extern crate "msg" as servo_msg; extern crate "util" as servo_util; @@ -42,7 +41,7 @@ use std::comm; use std::comm::{Disconnected, Empty}; use std::io::{TcpListener, TcpStream}; use std::io::{Acceptor, Listener, TimedOut}; -use sync::{Arc, Mutex}; +use std::sync::{Arc, Mutex}; mod actor; /// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/ diff --git a/components/devtools/protocol.rs b/components/devtools/protocol.rs index e657741b9e3..be27eed2ec1 100644 --- a/components/devtools/protocol.rs +++ b/components/devtools/protocol.rs @@ -5,12 +5,13 @@ /// Low-level wire protocol implementation. Currently only supports [JSON packets](https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport#JSON_Packets). use serialize::{json, Encodable}; +use serialize::json::Json; use std::io::{IoError, OtherIoError, EndOfFile, TcpStream, IoResult}; use std::num; pub trait JsonPacketStream { fn write_json_packet<'a, T: Encodable<json::Encoder<'a>,IoError>>(&mut self, obj: &T); - fn read_json_packet(&mut self) -> IoResult<json::Json>; + fn read_json_packet(&mut self) -> IoResult<Json>; } impl JsonPacketStream for TcpStream { @@ -22,7 +23,7 @@ impl JsonPacketStream for TcpStream { self.write_str(s.as_slice()).unwrap(); } - fn read_json_packet<'a>(&mut self) -> IoResult<json::Json> { + fn read_json_packet<'a>(&mut self) -> IoResult<Json> { // https://wiki.mozilla.org/Remote_Debugging_Protocol_Stream_Transport // In short, each JSON packet is [ascii length]:[JSON data of given length] let mut buffer = vec!(); diff --git a/components/gfx/buffer_map.rs b/components/gfx/buffer_map.rs index fab6ffc2f5e..9c1197ec8b2 100644 --- a/components/gfx/buffer_map.rs +++ b/components/gfx/buffer_map.rs @@ -27,7 +27,7 @@ pub struct BufferMap { } /// A key with which to store buffers. It is based on the size of the buffer. -#[deriving(Eq)] +#[deriving(Eq, Copy)] struct BufferKey([uint, ..2]); impl Hash for BufferKey { diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 1905f73885c..469d4121f6a 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -42,7 +42,7 @@ use std::slice::Items; use style::ComputedValues; use style::computed_values::border_style; use style::computed_values::cursor; -use sync::Arc; +use std::sync::Arc; // It seems cleaner to have layout code not mention Azure directly, so let's just reexport this for // layout to use. @@ -61,7 +61,7 @@ pub static BOX_SHADOW_INFLATION_FACTOR: i32 = 3; /// Because the script task's GC does not trace layout, node data cannot be safely stored in layout /// data structures. Also, layout code tends to be faster when the DOM is not being accessed, for /// locality reasons. Using `OpaqueNode` enforces this invariant. -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Copy)] pub struct OpaqueNode(pub uintptr_t); impl OpaqueNode { @@ -628,7 +628,7 @@ impl ClippingRegion { /// Metadata attached to each display item. This is useful for performing auxiliary tasks with /// the display list involving hit testing: finding the originating DOM node and determining the /// cursor to use when the element is hovered over. -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub struct DisplayItemMetadata { /// The DOM node from which this display item originated. pub node: OpaqueNode, @@ -739,7 +739,7 @@ pub struct BorderDisplayItem { /// Information about the border radii. /// /// TODO(pcwalton): Elliptical radii. -#[deriving(Clone, Default, PartialEq, Show)] +#[deriving(Clone, Default, PartialEq, Show, Copy)] pub struct BorderRadii<T> { pub top_left: T, pub top_right: T, diff --git a/components/gfx/display_list/optimizer.rs b/components/gfx/display_list/optimizer.rs index 1b7998f86c9..f9b738a1d73 100644 --- a/components/gfx/display_list/optimizer.rs +++ b/components/gfx/display_list/optimizer.rs @@ -9,7 +9,7 @@ use display_list::{DisplayItem, DisplayList, StackingContext}; use collections::dlist::DList; use geom::rect::Rect; use servo_util::geometry::{mod, Au}; -use sync::Arc; +use std::sync::Arc; /// Transforms a display list to produce a visually-equivalent, but cheaper-to-paint, one. pub struct DisplayListOptimizer { diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 1e01e78a21f..270e0447ed1 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -4,14 +4,14 @@ use geom::{Point2D, Rect, Size2D}; use std::mem; -use std::string; +use std::slice; use std::rc::Rc; use std::cell::RefCell; use servo_util::cache::{Cache, HashCache}; use servo_util::smallvec::{SmallVec, SmallVec8}; use style::computed_values::{font_variant, font_weight}; use style::style_structs::Font as FontStyle; -use sync::Arc; +use std::sync::Arc; use collections::hash::Hash; use platform::font_context::FontContextHandle; @@ -56,11 +56,10 @@ pub trait FontTableTagConversions { impl FontTableTagConversions for FontTableTag { fn tag_to_str(&self) -> String { unsafe { - let reversed = string::raw::from_buf_len(mem::transmute(self), 4); - return String::from_chars([reversed.as_slice().char_at(3), - reversed.as_slice().char_at(2), - reversed.as_slice().char_at(1), - reversed.as_slice().char_at(0)]); + let pointer = mem::transmute::<&u32, *const u8>(self); + let mut bytes = slice::from_raw_buf(&pointer, 4).to_vec(); + bytes.reverse(); + String::from_utf8_unchecked(bytes) } } } @@ -101,6 +100,7 @@ pub struct Font { } bitflags! { + #[deriving(Copy)] flags ShapingFlags: u8 { #[doc="Set if the text is entirely whitespace."] const IS_WHITESPACE_SHAPING_FLAG = 0x01, @@ -110,7 +110,7 @@ bitflags! { } /// Various options that control text shaping. -#[deriving(Clone, Eq, PartialEq, Hash)] +#[deriving(Clone, Eq, PartialEq, Hash, Copy)] pub struct ShapingOptions { /// Spacing to add between each letter. Corresponds to the CSS 2.1 `letter-spacing` property. /// NB: You will probably want to set the `IGNORE_LIGATURES_SHAPING_FLAG` if this is non-null. diff --git a/components/gfx/font_cache_task.rs b/components/gfx/font_cache_task.rs index 0b1ba4c9083..4321cd5e613 100644 --- a/components/gfx/font_cache_task.rs +++ b/components/gfx/font_cache_task.rs @@ -10,7 +10,7 @@ use platform::font_context::FontContextHandle; use collections::str::Str; use std::collections::HashMap; -use sync::Arc; +use std::sync::Arc; use font_template::{FontTemplate, FontTemplateDescriptor}; use platform::font_template::FontTemplateData; use servo_net::resource_task::{ResourceTask, load_whole_resource}; diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index a18a801b4e1..f6d715be693 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -19,7 +19,7 @@ use servo_util::arc_ptr_eq; use std::rc::Rc; use std::cell::RefCell; -use sync::Arc; +use std::sync::Arc; use azure::AzFloat; use azure::azure_hl::BackendType; diff --git a/components/gfx/font_template.rs b/components/gfx/font_template.rs index 78d83f17a32..2ee658009f8 100644 --- a/components/gfx/font_template.rs +++ b/components/gfx/font_template.rs @@ -7,14 +7,14 @@ use platform::font_context::FontContextHandle; use platform::font::FontHandle; use platform::font_template::FontTemplateData; -use sync::{Arc, Weak}; +use std::sync::{Arc, Weak}; use font::FontHandleMethods; /// Describes how to select a font from a given family. /// This is very basic at the moment and needs to be /// expanded or refactored when we support more of the /// font styling parameters. -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub struct FontTemplateDescriptor { pub weight: font_weight::T, pub italic: bool, diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index e7ad3c65a4c..df136969dec 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -29,7 +29,6 @@ extern crate "net" as servo_net; extern crate "util" as servo_util; extern crate "msg" as servo_msg; extern crate style; -extern crate sync; extern crate time; extern crate url; diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index 2f277de6a84..22f2dbbde03 100644 --- a/components/gfx/paint_context.rs +++ b/components/gfx/paint_context.rs @@ -33,7 +33,7 @@ use std::mem; use std::num::{Float, FloatMath}; use std::ptr; use style::computed_values::border_style; -use sync::Arc; +use std::sync::Arc; use text::TextRun; use text::glyph::CharIndex; @@ -52,6 +52,7 @@ pub struct PaintContext<'a> { pub transient_clip: Option<ClippingRegion>, } +#[deriving(Copy)] enum Direction { Top, Left, @@ -59,6 +60,7 @@ enum Direction { Bottom } +#[deriving(Copy)] enum DashSize { DottedBorder = 1, DashedBorder = 3 diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index 99e1454e945..dd288fc07e1 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -35,7 +35,7 @@ use servo_util::time::{TimeProfilerChan, TimeProfilerCategory, profile}; use std::comm::{Receiver, Sender, channel}; use std::mem; use std::task::TaskBuilder; -use sync::Arc; +use std::sync::Arc; /// Information about a hardware graphics layer that layout sends to the painting task. #[deriving(Clone)] diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs index a68e443183d..26676830fbc 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/gfx/platform/freetype/font.rs @@ -30,7 +30,7 @@ use std::num::Float; use std::ptr; use std::string; -use sync::Arc; +use std::sync::Arc; fn float_to_fixed_ft(f: f64) -> i32 { float_to_fixed(6, f) diff --git a/components/gfx/platform/macos/font.rs b/components/gfx/platform/macos/font.rs index d73a22d7d41..2e3aae29dc7 100644 --- a/components/gfx/platform/macos/font.rs +++ b/components/gfx/platform/macos/font.rs @@ -29,7 +29,7 @@ use core_text::font_descriptor::{kCTFontDefaultOrientation}; use std::num::Float; use std::ptr; -use sync::Arc; +use std::sync::Arc; pub struct FontTable { data: CFData, @@ -100,15 +100,15 @@ impl FontHandleMethods for FontHandle { let normalized = self.ctfont.all_traits().normalized_weight(); // 0.0 to 9.0 let normalized = (normalized + 1.0) / 2.0 * 9.0; - if normalized < 1.0 { return font_weight::Weight100; } - if normalized < 2.0 { return font_weight::Weight200; } - if normalized < 3.0 { return font_weight::Weight300; } - if normalized < 4.0 { return font_weight::Weight400; } - if normalized < 5.0 { return font_weight::Weight500; } - if normalized < 6.0 { return font_weight::Weight600; } - if normalized < 7.0 { return font_weight::Weight700; } - if normalized < 8.0 { return font_weight::Weight800; } - return font_weight::Weight900; + if normalized < 1.0 { return font_weight::T::Weight100; } + if normalized < 2.0 { return font_weight::T::Weight200; } + if normalized < 3.0 { return font_weight::T::Weight300; } + if normalized < 4.0 { return font_weight::T::Weight400; } + if normalized < 5.0 { return font_weight::T::Weight500; } + if normalized < 6.0 { return font_weight::T::Weight600; } + if normalized < 7.0 { return font_weight::T::Weight700; } + if normalized < 8.0 { return font_weight::T::Weight800; } + return font_weight::T::Weight900; } fn glyph_index(&self, codepoint: char) -> Option<GlyphId> { @@ -179,7 +179,7 @@ impl FontHandleMethods for FontHandle { average_advance: average_advance, line_gap: Au::from_frac_px(line_gap), }; - debug!("Font metrics (@{:f} pt): {}", self.ctfont.pt_size() as f64, metrics); + debug!("Font metrics (@{} pt): {}", self.ctfont.pt_size() as f64, metrics); return metrics; } diff --git a/components/gfx/platform/macos/font_context.rs b/components/gfx/platform/macos/font_context.rs index 94730641c3d..e65381c3bbc 100644 --- a/components/gfx/platform/macos/font_context.rs +++ b/components/gfx/platform/macos/font_context.rs @@ -7,7 +7,6 @@ pub struct FontContextHandle { ctx: () } -#[deriving(Clone)] impl FontContextHandle { // this is a placeholder until NSFontManager or whatever is bound in here. pub fn new() -> FontContextHandle { diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index 1a36f8c4cbb..a991f147bed 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -22,7 +22,7 @@ use geom::point::Point2D; /// In the uncommon case (multiple glyphs per unicode character, large glyph index/advance, or /// glyph offsets), we pack the glyph count into GlyphEntry, and store the other glyph information /// in DetailedGlyphStore. -#[deriving(Clone, Show)] +#[deriving(Clone, Show, Copy)] struct GlyphEntry { value: u32, } @@ -87,7 +87,7 @@ impl GlyphEntry { pub type GlyphId = u32; // TODO: unify with bit flags? -#[deriving(PartialEq)] +#[deriving(PartialEq, Copy)] pub enum BreakType { None, Normal, @@ -251,7 +251,7 @@ impl GlyphEntry { // Stores data for a detailed glyph, in the case that several glyphs // correspond to one character, or the glyph's data couldn't be packed. -#[deriving(Clone, Show)] +#[deriving(Clone, Show, Copy)] struct DetailedGlyph { id: GlyphId, // glyph's advance, in the text's direction (RTL or RTL) @@ -270,7 +270,7 @@ impl DetailedGlyph { } } -#[deriving(PartialEq, Clone, Eq, Show)] +#[deriving(PartialEq, Clone, Eq, Show, Copy)] struct DetailedGlyphRecord { // source string offset/GlyphEntry offset in the TextRun entry_offset: CharIndex, @@ -411,6 +411,7 @@ impl<'a> DetailedGlyphStore { // This struct is used by GlyphStore clients to provide new glyph data. // It should be allocated on the stack and passed by reference to GlyphStore. +#[deriving(Copy)] pub struct GlyphData { id: GlyphId, advance: Au, @@ -443,6 +444,7 @@ impl GlyphData { // through glyphs (either for a particular TextRun offset, or all glyphs). // Rather than eagerly assembling and copying glyph data, it only retrieves // values as they are needed from the GlyphStore, using provided offsets. +#[deriving(Copy)] pub enum GlyphInfo<'a> { Simple(&'a GlyphStore, CharIndex), Detail(&'a GlyphStore, CharIndex, u16), diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index 6e10384615b..11c01a65948 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -503,7 +503,7 @@ impl Shaper { // space (U+00A0) left in the text after the white space processing rules have been // applied. The effect of the property on other word-separator characters is undefined." // We elect to only space the two required code points. - if character == ' ' || character == '\u00a0' { + if character == ' ' || character == '\u{a0}' { advance = advance + options.word_spacing } diff --git a/components/gfx/text/text_run.rs b/components/gfx/text/text_run.rs index 68031657157..8b8230a94cc 100644 --- a/components/gfx/text/text_run.rs +++ b/components/gfx/text/text_run.rs @@ -9,7 +9,7 @@ use servo_util::geometry::Au; use servo_util::range::Range; use servo_util::vec::{Comparator, FullBinarySearchMethods}; use std::slice::Items; -use sync::Arc; +use std::sync::Arc; use text::glyph::{CharIndex, GlyphStore}; /// A single "paragraph" of text in one font size and style. diff --git a/components/gfx/text/util.rs b/components/gfx/text/util.rs index 9fc60084d5c..c8d082c405a 100644 --- a/components/gfx/text/util.rs +++ b/components/gfx/text/util.rs @@ -4,7 +4,7 @@ use text::glyph::CharIndex; -#[deriving(PartialEq)] +#[deriving(PartialEq, Eq, Copy)] pub enum CompressionMode { CompressNone, CompressWhitespace, diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index ca77107965b..d24261495e1 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -34,9 +34,6 @@ path = "../util" [dependencies.cssparser] git = "https://github.com/servo/rust-cssparser" -[dependencies.encoding] -git = "https://github.com/lifthrasiir/rust-encoding" - [dependencies.geom] git = "https://github.com/servo/rust-geom" @@ -48,3 +45,6 @@ git = "https://github.com/servo/string-cache" [dependencies.string_cache_macros] git = "https://github.com/servo/string-cache" + +[dependencies] +encoding = "0.2" diff --git a/components/layout/block.rs b/components/layout/block.rs index 3f7fd4be823..f91f079f6bf 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -61,7 +61,7 @@ use style::ComputedValues; use style::computed_values::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone}; use style::computed_values::{LengthOrPercentage, box_sizing, display, float}; use style::computed_values::{overflow, position}; -use sync::Arc; +use std::sync::Arc; /// Information specific to floated blocks. #[deriving(Clone, Encodable)] @@ -92,6 +92,7 @@ impl FloatedBlockInfo { } /// The solutions for the block-size-and-margins constraint equation. +#[deriving(Copy)] struct BSizeConstraintSolution { block_start: Au, _block_end: Au, @@ -347,8 +348,8 @@ impl CandidateBSizeIterator { // If the style includes `box-sizing: border-box`, subtract the border and padding. let adjustment_for_box_sizing = match fragment.style.get_box().box_sizing { - box_sizing::border_box => fragment.border_padding.block_start_end(), - box_sizing::content_box => Au(0), + box_sizing::T::border_box => fragment.border_padding.block_start_end(), + box_sizing::T::content_box => Au(0), }; return CandidateBSizeIterator { @@ -1323,12 +1324,12 @@ impl BlockFlow { } match flow::base(kid).flags.float_kind() { - float::none => {} - float::left => { + float::T::none => {} + float::T::left => { inline_size_of_preceding_left_floats = inline_size_of_preceding_left_floats + flow::base(kid).intrinsic_inline_sizes.preferred_inline_size; } - float::right => { + float::T::right => { inline_size_of_preceding_right_floats = inline_size_of_preceding_right_floats + flow::base(kid).intrinsic_inline_sizes.preferred_inline_size; } @@ -1408,14 +1409,16 @@ impl BlockFlow { /// `FormattingContextType`. fn formatting_context_type(&self) -> FormattingContextType { let style = self.fragment.style(); - if style.get_box().float != float::none { + if style.get_box().float != float::T::none { return FormattingContextType::Other } match style.get_box().display { - display::table_cell | display::table_caption | display::inline_block => { + display::T::table_cell | + display::T::table_caption | + display::T::inline_block => { FormattingContextType::Other } - _ if style.get_box().overflow != overflow::visible => FormattingContextType::Block, + _ if style.get_box().overflow != overflow::T::visible => FormattingContextType::Block, _ => FormattingContextType::None, } } @@ -1462,7 +1465,7 @@ impl BlockFlow { } fn is_inline_block(&self) -> bool { - self.fragment.style().get_box().display == display::inline_block + self.fragment.style().get_box().display == display::T::inline_block } /// Computes the content portion (only) of the intrinsic inline sizes of this flow. This is @@ -1527,16 +1530,16 @@ impl Flow for BlockFlow { child_base.intrinsic_inline_sizes.minimum_inline_size); match float_kind { - float::none => { + float::T::none => { computation.content_intrinsic_sizes.preferred_inline_size = max(computation.content_intrinsic_sizes.preferred_inline_size, child_base.intrinsic_inline_sizes.preferred_inline_size); } - float::left => { + float::T::left => { left_float_width = left_float_width + child_base.intrinsic_inline_sizes.preferred_inline_size; } - float::right => { + float::T::right => { right_float_width = right_float_width + child_base.intrinsic_inline_sizes.preferred_inline_size; } @@ -1556,9 +1559,9 @@ impl Flow for BlockFlow { self.base.intrinsic_inline_sizes = computation.finish(); match self.fragment.style().get_box().float { - float::none => {} - float::left => flags.insert(HAS_LEFT_FLOATED_DESCENDANTS), - float::right => flags.insert(HAS_RIGHT_FLOATED_DESCENDANTS), + float::T::none => {} + float::T::left => flags.insert(HAS_LEFT_FLOATED_DESCENDANTS), + float::T::right => flags.insert(HAS_RIGHT_FLOATED_DESCENDANTS), } self.base.flags = flags } @@ -1911,7 +1914,7 @@ impl fmt::Show for BlockFlow { } /// The inputs for the inline-sizes-and-margins constraint equation. -#[deriving(Show)] +#[deriving(Show, Copy)] pub struct ISizeConstraintInput { pub computed_inline_size: MaybeAuto, pub inline_start_margin: MaybeAuto, @@ -1944,7 +1947,7 @@ impl ISizeConstraintInput { } /// The solutions for the inline-size-and-margins constraint equation. -#[deriving(Show)] +#[deriving(Copy, Show)] pub struct ISizeConstraintSolution { pub inline_start: Au, pub inline_end: Au, @@ -2006,11 +2009,12 @@ pub trait ISizeAndMarginsComputer { let style = block.fragment.style(); match (computed_inline_size, style.get_box().box_sizing) { - (MaybeAuto::Specified(size), box_sizing::border_box) => { + (MaybeAuto::Specified(size), box_sizing::T::border_box) => { computed_inline_size = MaybeAuto::Specified(size - block.fragment.border_padding.inline_start_end()) } - (MaybeAuto::Auto, box_sizing::border_box) | (_, box_sizing::content_box) => {} + (MaybeAuto::Auto, box_sizing::T::border_box) | + (_, box_sizing::T::content_box) => {} } // The text alignment of a block flow is the text alignment of its box's style. diff --git a/components/layout/construct.rs b/components/layout/construct.rs index c2911b13640..7db6466d48b 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -55,7 +55,7 @@ use std::sync::atomic::Relaxed; use style::computed_values::{caption_side, display, empty_cells, float, list_style_position}; use style::computed_values::{position}; use style::{mod, ComputedValues}; -use sync::Arc; +use std::sync::Arc; use url::Url; /// The results of flow construction for a DOM node. @@ -701,7 +701,7 @@ impl<'a> FlowConstructor<'a> { // `<div style="position:absolute">foo bar baz</div>`. The fragments for `foo`, `bar`, and // `baz` had better not be absolutely positioned! let mut style = (*node.style()).clone(); - if style.get_box().display != display::inline { + if style.get_box().display != display::T::inline { style = Arc::new(style::make_inline(&*style)) } @@ -859,7 +859,7 @@ impl<'a> FlowConstructor<'a> { float_value: float::T) -> ConstructionResult { let fragment = Fragment::new_from_specific_info(node, SpecificFragmentInfo::TableWrapper); let wrapper_flow = match float_value { - float::none => box TableWrapperFlow::from_node_and_fragment(node, fragment), + float::T::none => box TableWrapperFlow::from_node_and_fragment(node, fragment), _ => { let float_kind = FloatKind::from_property(float_value); box TableWrapperFlow::float_from_node_and_fragment(node, fragment, float_kind) @@ -882,7 +882,7 @@ impl<'a> FlowConstructor<'a> { // value of `caption-side`. self.place_table_caption_under_table_wrapper_on_side(&mut wrapper_flow, node, - caption_side::top); + caption_side::T::top); match construction_result { ConstructionResult::Flow(table_flow, table_abs_descendants) => { @@ -895,7 +895,7 @@ impl<'a> FlowConstructor<'a> { // If the value of `caption-side` is `bottom`, place it now. self.place_table_caption_under_table_wrapper_on_side(&mut wrapper_flow, node, - caption_side::bottom); + caption_side::T::bottom); // The flow is done. wrapper_flow.finish(); @@ -954,10 +954,12 @@ impl<'a> FlowConstructor<'a> { // Determine if the table cell should be hidden. Per CSS 2.1 § 17.6.1.1, this will be true // if the cell has any in-flow elements (even empty ones!) and has `empty-cells` set to // `hide`. - let hide = node.style().get_inheritedtable().empty_cells == empty_cells::hide && + let hide = node.style().get_inheritedtable().empty_cells == empty_cells::T::hide && node.children().all(|kid| { let position = kid.style().get_box().position; - !kid.is_content() || position == position::absolute || position == position::fixed + !kid.is_content() || + position == position::T::absolute || + position == position::T::fixed }); let flow = box TableCellFlow::from_node_fragment_and_visibility_flag(node, fragment, !hide) @@ -1003,11 +1005,11 @@ impl<'a> FlowConstructor<'a> { let flow; let initial_fragment; match node.style().get_list().list_style_position { - list_style_position::outside => { + list_style_position::T::outside => { flow = box ListItemFlow::from_node_and_marker(self, node, marker_fragment); initial_fragment = None; } - list_style_position::inside => { + list_style_position::T::inside => { flow = box ListItemFlow::from_node_and_marker(self, node, None); initial_fragment = marker_fragment; } @@ -1117,7 +1119,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> { // Pseudo-element. let style = node.style(); let display = match node.get_pseudo_element_type() { - PseudoElementType::Normal => display::inline, + PseudoElementType::Normal => display::T::inline, PseudoElementType::Before(display) => display, PseudoElementType::After(display) => display, }; @@ -1126,20 +1128,20 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> { Some(NodeTypeId::Element(_)) => { let style = node.style(); let munged_display = if style.get_box()._servo_display_for_hypothetical_box == - display::inline { - display::inline + display::T::inline { + display::T::inline } else { style.get_box().display }; (munged_display, style.get_box().float, style.get_box().position) } - Some(NodeTypeId::Text) => (display::inline, float::none, position::static_), + Some(NodeTypeId::Text) => (display::T::inline, float::T::none, position::T::static_), Some(NodeTypeId::Comment) | Some(NodeTypeId::DocumentType) | Some(NodeTypeId::DocumentFragment) | Some(NodeTypeId::Document) | Some(NodeTypeId::ProcessingInstruction) => { - (display::none, float::none, position::static_) + (display::T::none, float::T::none, position::T::static_) } }; @@ -1149,14 +1151,14 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> { match (display, float, positioning) { // `display: none` contributes no flow construction result. Nuke the flow construction // results of children. - (display::none, _, _) => { + (display::T::none, _, _) => { for child in node.children() { drop(child.swap_out_construction_result()) } } // Table items contribute table flow construction results. - (display::table, float_value, _) => { + (display::T::table, float_value, _) => { let construction_result = self.build_flow_for_table_wrapper(node, float_value); node.set_flow_construction_result(construction_result) } @@ -1167,18 +1169,19 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> { // positioned, but inline we shouldn't try to construct a block // flow here - instead, let it match the inline case // below. - (display::block, _, position::absolute) | (_, _, position::fixed) => { + (display::T::block, _, position::T::absolute) | + (_, _, position::T::fixed) => { node.set_flow_construction_result(self.build_flow_for_nonfloated_block(node)) } // List items contribute their own special flows. - (display::list_item, _, _) => { + (display::T::list_item, _, _) => { node.set_flow_construction_result(self.build_flow_for_list_item(node)) } // Inline items that are absolutely-positioned contribute inline fragment construction // results with a hypothetical fragment. - (display::inline, _, position::absolute) => { + (display::T::inline, _, position::T::absolute) => { let construction_result = self.build_fragment_for_absolutely_positioned_inline(node); node.set_flow_construction_result(construction_result) @@ -1187,50 +1190,51 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> { // Inline items contribute inline fragment construction results. // // FIXME(pcwalton, #3307): This is not sufficient to handle floated generated content. - (display::inline, float::none, _) => { + (display::T::inline, float::T::none, _) => { let construction_result = self.build_fragments_for_inline(node); node.set_flow_construction_result(construction_result) } // Inline-block items contribute inline fragment construction results. - (display::inline_block, float::none, _) => { + (display::T::inline_block, float::T::none, _) => { let construction_result = self.build_fragment_for_inline_block(node); node.set_flow_construction_result(construction_result) } // Table items contribute table flow construction results. - (display::table_caption, _, _) => { + (display::T::table_caption, _, _) => { let construction_result = self.build_flow_for_table_caption(node); node.set_flow_construction_result(construction_result) } // Table items contribute table flow construction results. - (display::table_column_group, _, _) => { + (display::T::table_column_group, _, _) => { let construction_result = self.build_flow_for_table_colgroup(node); node.set_flow_construction_result(construction_result) } // Table items contribute table flow construction results. - (display::table_column, _, _) => { + (display::T::table_column, _, _) => { let construction_result = self.build_fragments_for_table_column(node); node.set_flow_construction_result(construction_result) } // Table items contribute table flow construction results. - (display::table_row_group, _, _) | (display::table_header_group, _, _) | - (display::table_footer_group, _, _) => { + (display::T::table_row_group, _, _) | + (display::T::table_header_group, _, _) | + (display::T::table_footer_group, _, _) => { let construction_result = self.build_flow_for_table_rowgroup(node); node.set_flow_construction_result(construction_result) } // Table items contribute table flow construction results. - (display::table_row, _, _) => { + (display::T::table_row, _, _) => { let construction_result = self.build_flow_for_table_row(node); node.set_flow_construction_result(construction_result) } // Table items contribute table flow construction results. - (display::table_cell, _, _) => { + (display::T::table_cell, _, _) => { let construction_result = self.build_flow_for_table_cell(node); node.set_flow_construction_result(construction_result) } @@ -1240,7 +1244,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> { // TODO(pcwalton): Make this only trigger for blocks and handle the other `display` // properties separately. - (_, float::none, _) => { + (_, float::T::none, _) => { node.set_flow_construction_result(self.build_flow_for_nonfloated_block(node)) } diff --git a/components/layout/context.rs b/components/layout/context.rs index 6d04c131b85..7a5b0454ab8 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -15,8 +15,10 @@ use script_traits::UntrustedNodeAddress; use servo_msg::constellation_msg::ConstellationChan; use servo_net::local_image_cache::LocalImageCache; use servo_util::geometry::Au; -use sync::{Arc, Mutex}; +use std::cell::Cell; use std::mem; +use std::ptr; +use std::sync::{Arc, Mutex}; use style::Stylist; use url::Url; @@ -26,25 +28,21 @@ struct LocalLayoutContext { style_sharing_candidate_cache: StyleSharingCandidateCache, } -local_data_key!(local_context_key: *mut LocalLayoutContext) +thread_local!(static local_context_key: Cell<*mut LocalLayoutContext> = Cell::new(ptr::null_mut())) fn create_or_get_local_context(shared_layout_context: &SharedLayoutContext) -> *mut LocalLayoutContext { - let maybe_context = local_context_key.get(); - - let context = match maybe_context { - None => { + local_context_key.with(|ref r| { + if r.get().is_null() { let context = box LocalLayoutContext { font_context: FontContext::new(shared_layout_context.font_cache_task.clone()), applicable_declarations_cache: ApplicableDeclarationsCache::new(), style_sharing_candidate_cache: StyleSharingCandidateCache::new(), }; - local_context_key.replace(Some(unsafe { mem::transmute(context) })); - local_context_key.get().unwrap() - }, - Some(context) => context - }; + r.set(unsafe { mem::transmute(context) }); + } - *context + r.get() + }) } pub struct SharedLayoutContext { diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index e4d6b767c34..e453d36f7ae 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -20,7 +20,7 @@ use std::slice::Items; use string_cache::{Atom, Namespace}; use style::{mod, PseudoElement, ComputedValues, DeclarationBlock, Stylist, TElement, TNode}; use style::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes, cascade}; -use sync::Arc; +use std::sync::Arc; pub struct ApplicableDeclarations { pub normal: SmallVec16<DeclarationBlock>, diff --git a/components/layout/css/node_style.rs b/components/layout/css/node_style.rs index 8b4e1aa08a4..d2cbf029b1a 100644 --- a/components/layout/css/node_style.rs +++ b/components/layout/css/node_style.rs @@ -8,7 +8,7 @@ use wrapper::{PseudoElementType, ThreadSafeLayoutNode}; use std::mem; use style::ComputedValues; -use sync::Arc; +use std::sync::Arc; /// Node mixin providing `style` method that returns a `NodeStyle` pub trait StyledNode { diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 80877ffaaf9..326a688e5df 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -28,15 +28,15 @@ use gfx::display_list::{BorderRadii, BoxShadowDisplayItem, ClippingRegion}; use gfx::display_list::{DisplayItem, DisplayList, DisplayItemMetadata}; use gfx::display_list::{GradientDisplayItem}; use gfx::display_list::{GradientStop, ImageDisplayItem, LineDisplayItem}; -use gfx::display_list::{SidewaysLeft}; -use gfx::display_list::{SidewaysRight, SolidColorDisplayItem}; -use gfx::display_list::{StackingContext, TextDisplayItem, Upright}; +use gfx::display_list::TextOrientation; +use gfx::display_list::{SolidColorDisplayItem}; +use gfx::display_list::{StackingContext, TextDisplayItem}; use gfx::paint_task::PaintLayer; -use servo_msg::compositor_msg::{FixedPosition, Scrollable}; +use servo_msg::compositor_msg::ScrollPolicy; use servo_msg::constellation_msg::Msg as ConstellationMsg; use servo_msg::constellation_msg::ConstellationChan; use servo_net::image::holder::ImageHolder; -use servo_util::cursor::{DefaultCursor, TextCursor, VerticalTextCursor}; +use servo_util::cursor::Cursor; use servo_util::geometry::{mod, Au}; use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize}; use servo_util::opts; @@ -48,7 +48,7 @@ use style::computed_values::{background_attachment, background_repeat, border_st use style::computed_values::{position, visibility}; use style::style_structs::Border; use style::{ComputedValues, RGBA}; -use sync::Arc; +use std::sync::Arc; use url::Url; /// The results of display list building for a single flow. @@ -253,7 +253,7 @@ impl FragmentDisplayListBuilding for Fragment { base: BaseDisplayItem::new(*absolute_bounds, DisplayItemMetadata::new(self.node, style, - DefaultCursor), + Cursor::DefaultCursor), clip.clone()), color: background_color.to_gfx_color(), }), level); @@ -319,10 +319,10 @@ impl FragmentDisplayListBuilding for Fragment { // Use background-attachment to get the initial virtual origin let (virtual_origin_x, virtual_origin_y) = match background.background_attachment { - background_attachment::scroll => { + background_attachment::T::scroll => { (absolute_bounds.origin.x, absolute_bounds.origin.y) } - background_attachment::fixed => { + background_attachment::T::fixed => { (Au(0), Au(0)) } }; @@ -338,25 +338,25 @@ impl FragmentDisplayListBuilding for Fragment { // Adjust origin and size based on background-repeat match background.background_repeat { - background_repeat::no_repeat => { + background_repeat::T::no_repeat => { bounds.origin.x = abs_x; bounds.origin.y = abs_y; bounds.size.width = image_width; bounds.size.height = image_height; } - background_repeat::repeat_x => { + background_repeat::T::repeat_x => { bounds.origin.y = abs_y; bounds.size.height = image_height; ImageFragmentInfo::tile_image(&mut bounds.origin.x, &mut bounds.size.width, abs_x, image.width); } - background_repeat::repeat_y => { + background_repeat::T::repeat_y => { bounds.origin.x = abs_x; bounds.size.width = image_width; ImageFragmentInfo::tile_image(&mut bounds.origin.y, &mut bounds.size.height, abs_y, image.height); } - background_repeat::repeat => { + background_repeat::T::repeat => { ImageFragmentInfo::tile_image(&mut bounds.origin.x, &mut bounds.size.width, abs_x, image.width); ImageFragmentInfo::tile_image(&mut bounds.origin.y, &mut bounds.size.height, @@ -367,7 +367,7 @@ impl FragmentDisplayListBuilding for Fragment { // Create the image display item. display_list.push(DisplayItem::ImageClass(box ImageDisplayItem { base: BaseDisplayItem::new(bounds, - DisplayItemMetadata::new(self.node, style, DefaultCursor), + DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor), clip), image: image.clone(), stretch_size: Size2D(Au::from_px(image.width as int), @@ -477,7 +477,7 @@ impl FragmentDisplayListBuilding for Fragment { let gradient_display_item = DisplayItem::GradientClass(box GradientDisplayItem { base: BaseDisplayItem::new(*absolute_bounds, - DisplayItemMetadata::new(self.node, style, DefaultCursor), + DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor), clip), start_point: center - delta, end_point: center + delta, @@ -505,7 +505,7 @@ impl FragmentDisplayListBuilding for Fragment { base: BaseDisplayItem::new(bounds, DisplayItemMetadata::new(self.node, style, - DefaultCursor), + Cursor::DefaultCursor), (*clip).clone()), box_bounds: *absolute_bounds, color: style.resolve_color(box_shadow.color).to_gfx_color(), @@ -536,7 +536,7 @@ impl FragmentDisplayListBuilding for Fragment { // Append the border to the display list. display_list.push(DisplayItem::BorderClass(box BorderDisplayItem { base: BaseDisplayItem::new(*abs_bounds, - DisplayItemMetadata::new(self.node, style, DefaultCursor), + DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor), (*clip).clone()), border_widths: border.to_physical(style.writing_mode), color: SideOffsets2D::new(top_color.to_gfx_color(), @@ -562,7 +562,7 @@ impl FragmentDisplayListBuilding for Fragment { } let outline_style = style.get_outline().outline_style; - if outline_style == border_style::none { + if outline_style == border_style::T::none { return } @@ -578,7 +578,7 @@ impl FragmentDisplayListBuilding for Fragment { let color = style.resolve_color(style.get_outline().outline_color).to_gfx_color(); display_list.outlines.push_back(DisplayItem::BorderClass(box BorderDisplayItem { base: BaseDisplayItem::new(bounds, - DisplayItemMetadata::new(self.node, style, DefaultCursor), + DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor), (*clip).clone()), border_widths: SideOffsets2D::new_all_same(width), color: SideOffsets2D::new_all_same(color), @@ -600,11 +600,11 @@ impl FragmentDisplayListBuilding for Fragment { // Compute the text fragment bounds and draw a border surrounding them. display_list.content.push_back(DisplayItem::BorderClass(box BorderDisplayItem { base: BaseDisplayItem::new(*stacking_relative_border_box, - DisplayItemMetadata::new(self.node, style, DefaultCursor), + DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor), (*clip).clone()), border_widths: SideOffsets2D::new_all_same(Au::from_px(1)), color: SideOffsets2D::new_all_same(color::rgb(0, 0, 200)), - style: SideOffsets2D::new_all_same(border_style::solid), + style: SideOffsets2D::new_all_same(border_style::T::solid), radius: Default::default(), })); @@ -618,10 +618,10 @@ impl FragmentDisplayListBuilding for Fragment { let line_display_item = box LineDisplayItem { base: BaseDisplayItem::new(baseline, - DisplayItemMetadata::new(self.node, style, DefaultCursor), + DisplayItemMetadata::new(self.node, style, Cursor::DefaultCursor), (*clip).clone()), color: color::rgb(0, 200, 0), - style: border_style::dashed, + style: border_style::T::dashed, }; display_list.content.push_back(DisplayItem::LineClass(line_display_item)); } @@ -635,11 +635,11 @@ impl FragmentDisplayListBuilding for Fragment { base: BaseDisplayItem::new(*stacking_relative_border_box, DisplayItemMetadata::new(self.node, &*self.style, - DefaultCursor), + Cursor::DefaultCursor), (*clip).clone()), border_widths: SideOffsets2D::new_all_same(Au::from_px(1)), color: SideOffsets2D::new_all_same(color::rgb(0, 0, 200)), - style: SideOffsets2D::new_all_same(border_style::solid), + style: SideOffsets2D::new_all_same(border_style::T::solid), radius: Default::default(), })); } @@ -651,7 +651,7 @@ impl FragmentDisplayListBuilding for Fragment { // Account for `clip` per CSS 2.1 § 11.1.2. let style_clip_rect = match (self.style().get_box().position, self.style().get_effects().clip) { - (position::absolute, Some(style_clip_rect)) => style_clip_rect, + (position::T::absolute, Some(style_clip_rect)) => style_clip_rect, _ => return (*parent_clip).clone(), }; @@ -686,7 +686,7 @@ impl FragmentDisplayListBuilding for Fragment { stacking_relative_flow_origin, self); - if self.style().get_inheritedbox().visibility != visibility::visible { + if self.style().get_inheritedbox().visibility != visibility::T::visible { return } @@ -848,7 +848,7 @@ impl FragmentDisplayListBuilding for Fragment { base: BaseDisplayItem::new(stacking_relative_content_box, DisplayItemMetadata::new(self.node, &*self.style, - DefaultCursor), + Cursor::DefaultCursor), (*clip).clone()), image: image.clone(), stretch_size: stacking_relative_content_box.size, @@ -899,7 +899,7 @@ impl FragmentDisplayListBuilding for Fragment { // Only clip if `overflow` tells us to. match self.style.get_box().overflow { - overflow::hidden | overflow::auto | overflow::scroll => { + overflow::T::hidden | overflow::T::auto | overflow::T::scroll => { // Create a new clip rect. current_clip.intersect_rect(stacking_relative_border_box) } @@ -916,12 +916,12 @@ impl FragmentDisplayListBuilding for Fragment { // Determine the orientation and cursor to use. let (orientation, cursor) = if self.style.writing_mode.is_vertical() { if self.style.writing_mode.is_sideways_left() { - (SidewaysLeft, VerticalTextCursor) + (TextOrientation::SidewaysLeft, Cursor::VerticalTextCursor) } else { - (SidewaysRight, VerticalTextCursor) + (TextOrientation::SidewaysRight, Cursor::VerticalTextCursor) } } else { - (Upright, TextCursor) + (TextOrientation::Upright, Cursor::TextCursor) }; // Compute location of the baseline. @@ -995,7 +995,7 @@ impl FragmentDisplayListBuilding for Fragment { let stacking_relative_box = stacking_relative_box.to_physical(self.style.writing_mode, container_size); - let metadata = DisplayItemMetadata::new(self.node, &*self.style, DefaultCursor); + let metadata = DisplayItemMetadata::new(self.node, &*self.style, Cursor::DefaultCursor); display_list.content.push_back(DisplayItem::SolidColorClass(box SolidColorDisplayItem { base: BaseDisplayItem::new(stacking_relative_box, metadata, (*clip).clone()), color: color.to_gfx_color(), @@ -1083,9 +1083,9 @@ impl BlockFlowDisplayListBuilding for BlockFlow { // If we got here, then we need a new layer. let scroll_policy = if self.is_fixed() { - FixedPosition + ScrollPolicy::FixedPosition } else { - Scrollable + ScrollPolicy::Scrollable }; let transparent = color::rgba(1.0, 1.0, 1.0, 0.0); @@ -1163,7 +1163,7 @@ impl InlineFlowDisplayListBuilding for InlineFlow { fn build_display_list_for_inline(&mut self, layout_context: &LayoutContext) { // TODO(#228): Once we form lines and have their cached bounds, we can be smarter and // 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()); + debug!("Flow: building display list for {} inline fragments", self.fragments.len()); let mut display_list = box DisplayList::new(); for fragment in self.fragments.fragments.iter_mut() { @@ -1227,6 +1227,7 @@ impl ListItemFlowDisplayListBuilding for ListItemFlow { } // A helper data structure for gradients. +#[deriving(Copy)] struct StopRun { start_offset: f32, end_offset: f32, @@ -1250,7 +1251,7 @@ fn position_to_offset(position: LengthOrPercentage, Au(total_length): Au) -> f32 } /// "Steps" as defined by CSS 2.1 § E.2. -#[deriving(Clone, PartialEq, Show)] +#[deriving(Clone, PartialEq, Show, Copy)] pub enum StackingLevel { /// The border and backgrounds for the root of this stacking context: steps 1 and 2. BackgroundAndBorders, diff --git a/components/layout/floats.rs b/components/layout/floats.rs index ca840bc5374..5d82014f779 100644 --- a/components/layout/floats.rs +++ b/components/layout/floats.rs @@ -12,7 +12,7 @@ use std::fmt; use style::computed_values::float; /// The kind of float: left or right. -#[deriving(Clone, Encodable, Show)] +#[deriving(Clone, Encodable, Show, Copy)] pub enum FloatKind { Left, Right @@ -21,14 +21,15 @@ pub enum FloatKind { impl FloatKind { pub fn from_property(property: float::T) -> FloatKind { match property { - float::none => panic!("can't create a float type from an unfloated property"), - float::left => FloatKind::Left, - float::right => FloatKind::Right, + float::T::none => panic!("can't create a float type from an unfloated property"), + float::T::left => FloatKind::Left, + float::T::right => FloatKind::Right, } } } /// The kind of clearance: left, right, or both. +#[deriving(Copy)] pub enum ClearType { Left, Right, @@ -36,7 +37,7 @@ pub enum ClearType { } /// Information about a single float. -#[deriving(Clone)] +#[deriving(Clone, Copy)] struct Float { /// The boundaries of this float. bounds: LogicalRect<Au>, diff --git a/components/layout/flow.rs b/components/layout/flow.rs index d252a93269b..bffdb756505 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -60,7 +60,7 @@ use std::sync::atomic::{AtomicUint, SeqCst}; use std::slice::MutItems; use style::computed_values::{clear, empty_cells, float, position, text_align}; use style::ComputedValues; -use sync::Arc; +use std::sync::Arc; /// Virtual methods that make up a float context. /// @@ -255,12 +255,12 @@ pub trait Flow: fmt::Show + ToString + Sync { /// The 'position' property of this flow. fn positioning(&self) -> position::T { - position::static_ + position::T::static_ } /// Return true if this flow has position 'fixed'. fn is_fixed(&self) -> bool { - self.positioning() == position::fixed + self.positioning() == position::T::fixed } fn is_positioned(&self) -> bool { @@ -268,7 +268,7 @@ pub trait Flow: fmt::Show + ToString + Sync { } fn is_relatively_positioned(&self) -> bool { - self.positioning() == position::relative + self.positioning() == position::T::relative } /// Return true if this is the root of an absolute flow tree. @@ -471,6 +471,7 @@ pub trait PostorderFlowTraversal { bitflags! { #[doc = "Flags used in flows."] + #[deriving(Copy)] flags FlowFlags: u16 { // floated descendants flags #[doc = "Whether this flow has descendants that float left in the same block formatting"] @@ -575,11 +576,11 @@ impl FlowFlags { #[inline] pub fn float_kind(&self) -> float::T { if self.contains(FLOATS_LEFT) { - float::left + float::T::left } else if self.contains(FLOATS_RIGHT) { - float::right + float::T::right } else { - float::none + float::T::none } } @@ -658,8 +659,8 @@ pub struct DescendantIter<'a> { iter: MutItems<'a, FlowRef>, } -impl<'a> Iterator<&'a mut Flow + 'a> for DescendantIter<'a> { - fn next(&mut self) -> Option<&'a mut Flow + 'a> { +impl<'a> Iterator<&'a mut (Flow + 'a)> for DescendantIter<'a> { + fn next(&mut self) -> Option<&'a mut (Flow + 'a)> { self.iter.next().map(|flow| &mut **flow) } } @@ -668,7 +669,7 @@ pub type DescendantOffsetIter<'a> = Zip<DescendantIter<'a>, MutItems<'a, Au>>; /// Information needed to compute absolute (i.e. viewport-relative) flow positions (not to be /// confused with absolutely-positioned flows). -#[deriving(Encodable)] +#[deriving(Encodable, Copy)] pub struct AbsolutePositionInfo { /// The size of the containing block for relatively-positioned descendants. pub relative_containing_block_size: LogicalSize<Au>, @@ -863,7 +864,7 @@ impl BaseFlow { Some(node) => { let node_style = node.style(); match node_style.get_box().position { - position::absolute | position::fixed => { + position::T::absolute | position::T::fixed => { flags.insert(IS_ABSOLUTELY_POSITIONED) } _ => {} @@ -871,17 +872,17 @@ impl BaseFlow { if force_nonfloated == ForceNonfloatedFlag::FloatIfNecessary { match node_style.get_box().float { - float::none => {} - float::left => flags.insert(FLOATS_LEFT), - float::right => flags.insert(FLOATS_RIGHT), + float::T::none => {} + float::T::left => flags.insert(FLOATS_LEFT), + float::T::right => flags.insert(FLOATS_RIGHT), } } match node_style.get_box().clear { - clear::none => {} - clear::left => flags.insert(CLEARS_LEFT), - clear::right => flags.insert(CLEARS_RIGHT), - clear::both => { + clear::T::none => {} + clear::T::left => flags.insert(CLEARS_LEFT), + clear::T::right => flags.insert(CLEARS_RIGHT), + clear::T::both => { flags.insert(CLEARS_LEFT); flags.insert(CLEARS_RIGHT); } @@ -962,7 +963,7 @@ impl BaseFlow { } } -impl<'a> ImmutableFlowUtils for &'a Flow + 'a { +impl<'a> ImmutableFlowUtils for &'a (Flow + 'a) { /// Returns true if this flow is a block flow. fn is_block_like(self) -> bool { match self.class() { @@ -1064,7 +1065,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow + 'a { let fragment = Fragment::new_anonymous_from_specific_info(node, SpecificFragmentInfo::TableCell); - let hide = node.style().get_inheritedtable().empty_cells == empty_cells::hide; + let hide = node.style().get_inheritedtable().empty_cells == empty_cells::T::hide; box TableCellFlow::from_node_fragment_and_visibility_flag(node, fragment, !hide) as Box<Flow> }, @@ -1138,7 +1139,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow + 'a { } } -impl<'a> MutableFlowUtils for &'a mut Flow + 'a { +impl<'a> MutableFlowUtils for &'a mut (Flow + 'a) { /// Traverses the tree in preorder. fn traverse_preorder<T:PreorderFlowTraversal>(self, traversal: &T) { if traversal.should_process(self) { diff --git a/components/layout/flow_list.rs b/components/layout/flow_list.rs index a4b2abe0eb3..c3300e6ab79 100644 --- a/components/layout/flow_list.rs +++ b/components/layout/flow_list.rs @@ -105,9 +105,9 @@ impl FlowList { } } -impl<'a> Iterator<&'a Flow + 'a> for FlowListIterator<'a> { +impl<'a> Iterator<&'a (Flow + 'a)> for FlowListIterator<'a> { #[inline] - fn next(&mut self) -> Option<&'a Flow + 'a> { + fn next(&mut self) -> Option<&'a (Flow + 'a)> { self.it.next().map(|x| x.deref()) } @@ -117,9 +117,9 @@ impl<'a> Iterator<&'a Flow + 'a> for FlowListIterator<'a> { } } -impl<'a> Iterator<&'a mut Flow + 'a> for MutFlowListIterator<'a> { +impl<'a> Iterator<&'a mut (Flow + 'a)> for MutFlowListIterator<'a> { #[inline] - fn next(&mut self) -> Option<&'a mut Flow + 'a> { + fn next(&mut self) -> Option<&'a mut (Flow + 'a)> { self.it.next().map(|x| x.deref_mut()) } diff --git a/components/layout/flow_ref.rs b/components/layout/flow_ref.rs index e46c42d4844..67f306d4508 100644 --- a/components/layout/flow_ref.rs +++ b/components/layout/flow_ref.rs @@ -34,17 +34,17 @@ impl FlowRef { } impl<'a> Deref<Flow + 'a> for FlowRef { - fn deref(&self) -> &Flow + 'a { + fn deref(&self) -> &(Flow + 'a) { unsafe { - mem::transmute_copy::<raw::TraitObject, &Flow + 'a>(&self.object) + mem::transmute_copy::<raw::TraitObject, &(Flow + 'a)>(&self.object) } } } impl<'a> DerefMut<Flow + 'a> for FlowRef { - fn deref_mut<'a>(&mut self) -> &mut Flow + 'a { + fn deref_mut<'a>(&mut self) -> &mut (Flow + 'a) { unsafe { - mem::transmute_copy::<raw::TraitObject, &mut Flow + 'a>(&self.object) + mem::transmute_copy::<raw::TraitObject, &mut (Flow + 'a)>(&self.object) } } } diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index cfc2ab8b1a5..bf8ae12c10f 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -45,7 +45,7 @@ use style::computed_values::{LengthOrPercentage, LengthOrPercentageOrAuto}; use style::computed_values::{LengthOrPercentageOrNone}; use style::computed_values::{clear, overflow_wrap, position, text_align}; use style::computed_values::{text_decoration, vertical_align, white_space}; -use sync::{Arc, Mutex}; +use std::sync::{Arc, Mutex}; use url::Url; /// Fragments (`struct Fragment`) are the leaves of the layout tree. They cannot position @@ -398,7 +398,7 @@ impl ScannedTextFragmentInfo { /// Describes how to split a fragment. This is used during line breaking as part of the return /// value of `find_split_info_for_inline_size()`. -#[deriving(Show)] +#[deriving(Show, Clone)] pub struct SplitInfo { // TODO(bjz): this should only need to be a single character index, but both values are // currently needed for splitting in the `inline::try_append_*` functions. @@ -455,7 +455,7 @@ impl UnscannedTextFragmentInfo { } /// A fragment that represents a table column. -#[deriving(Clone)] +#[deriving(Copy, Clone)] pub struct TableColumnFragmentInfo { /// the number of columns a <col> element should span pub span: int, @@ -877,7 +877,7 @@ impl Fragment { } // Go over the ancestor fragments and add all relative offsets (if any). - let mut rel_pos = if self.style().get_box().position == position::relative { + let mut rel_pos = if self.style().get_box().position == position::T::relative { from_style(self.style(), containing_block_size) } else { LogicalSize::zero(self.style.writing_mode) @@ -887,7 +887,7 @@ impl Fragment { None => {} Some(ref inline_fragment_context) => { for style in inline_fragment_context.styles.iter() { - if style.get_box().position == position::relative { + if style.get_box().position == position::T::relative { rel_pos = rel_pos + from_style(&**style, containing_block_size); } } @@ -903,10 +903,10 @@ impl Fragment { pub fn clear(&self) -> Option<ClearType> { let style = self.style(); match style.get_box().clear { - clear::none => None, - clear::left => Some(ClearType::Left), - clear::right => Some(ClearType::Right), - clear::both => Some(ClearType::Both), + clear::T::none => None, + clear::T::left => Some(ClearType::Left), + clear::T::right => Some(ClearType::Right), + clear::T::both => Some(ClearType::Both), } } @@ -1152,7 +1152,7 @@ impl Fragment { let mut flags = SplitOptions::empty(); if starts_line { flags.insert(STARTS_LINE); - if self.style().get_inheritedtext().overflow_wrap == overflow_wrap::break_word { + if self.style().get_inheritedtext().overflow_wrap == overflow_wrap::T::break_word { flags.insert(RETRY_AT_CHARACTER_BOUNDARIES) } } @@ -1279,8 +1279,8 @@ impl Fragment { /// whitespace that should be stripped. pub fn is_ignorable_whitespace(&self) -> bool { match self.white_space() { - white_space::pre => return false, - white_space::normal | white_space::nowrap => {} + white_space::T::pre => return false, + white_space::T::normal | white_space::T::nowrap => {} } match self.specific { SpecificFragmentInfo::UnscannedText(ref text_fragment_info) => { @@ -1616,12 +1616,12 @@ impl Fragment { return true } match self.style().get_box().position { - position::absolute | position::fixed => { + position::T::absolute | position::T::fixed => { // FIXME(pcwalton): This should only establish a new stacking context when // `z-index` is not `auto`. But this matches what we did before. true } - position::relative | position::static_ => { + position::T::relative | position::T::static_ => { // FIXME(pcwalton): `position: relative` establishes a new stacking context if // `z-index` is not `auto`. But this matches what we did before. false diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs index bf2fcacf66d..6949063d41b 100644 --- a/components/layout/incremental.rs +++ b/components/layout/incremental.rs @@ -12,6 +12,7 @@ use style::ComputedValues; bitflags! { #[doc = "Individual layout actions that may be necessary after restyling."] + #[deriving(Copy)] flags RestyleDamage: u8 { #[doc = "Repaint the node itself."] #[doc = "Currently unused; need to decide how this propagates."] @@ -87,7 +88,7 @@ impl RestyleDamage { } impl fmt::Show for RestyleDamage { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::FormatError> { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { let mut first_elem = true; let to_iter = @@ -181,7 +182,7 @@ pub trait LayoutDamageComputation { fn reflow_entire_document(self); } -impl<'a> LayoutDamageComputation for &'a mut Flow+'a { +impl<'a> LayoutDamageComputation for &'a mut (Flow + 'a) { fn compute_layout_damage(self) -> SpecialRestyleDamage { let mut special_damage = SpecialRestyleDamage::empty(); let is_absolutely_positioned = flow::base(self).flags.contains(IS_ABSOLUTELY_POSITIONED); @@ -203,7 +204,7 @@ impl<'a> LayoutDamageComputation for &'a mut Flow+'a { } let self_base = flow::base(self); - if self_base.flags.float_kind() != float::none && + if self_base.flags.float_kind() != float::T::none && self_base.restyle_damage.intersects(REFLOW) { special_damage.insert(REFLOW_ENTIRE_DOCUMENT); } diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 0a2234bfa8b..67fc65b21e7 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -34,7 +34,7 @@ use std::mem; use std::u16; use style::computed_values::{text_align, vertical_align, white_space}; use style::ComputedValues; -use sync::Arc; +use std::sync::Arc; // From gfxFontConstants.h in Firefox static FONT_SUBSCRIPT_OFFSET_RATIO: f64 = 0.20; @@ -65,7 +65,7 @@ static FONT_SUPERSCRIPT_OFFSET_RATIO: f64 = 0.34; /// with a float or a horizontal wall of the containing block. The block-start /// inline-start corner of the green zone is the same as that of the line, but /// the green zone can be taller and wider than the line itself. -#[deriving(Encodable, Show)] +#[deriving(Encodable, Show, Copy)] pub struct Line { /// A range of line indices that describe line breaks. /// @@ -267,14 +267,14 @@ impl LineBreaker { // Set up our reflow flags. let flags = match fragment.style().get_inheritedtext().white_space { - white_space::normal => InlineReflowFlags::empty(), - white_space::pre | white_space::nowrap => NO_WRAP_INLINE_REFLOW_FLAG, + white_space::T::normal => InlineReflowFlags::empty(), + white_space::T::pre | white_space::T::nowrap => NO_WRAP_INLINE_REFLOW_FLAG, }; // Try to append the fragment, and commit the line (so we can try again with the next // line) if we couldn't. match fragment.style().get_inheritedtext().white_space { - white_space::normal | white_space::nowrap => { + white_space::T::normal | white_space::T::nowrap => { if !self.append_fragment_to_line_if_possible(fragment, flow, layout_context, @@ -282,7 +282,7 @@ impl LineBreaker { self.flush_current_line() } } - white_space::pre => { + white_space::T::pre => { // FIXME(pcwalton): Surely we can unify // `append_fragment_to_line_if_possible` and // `try_append_to_line_by_new_line` by adding another bit in the reflow @@ -602,8 +602,8 @@ impl LineBreaker { fragment.border_box.size.block); fragment.transform(size, info) }; - (split_result.inline_start.map(|x| split_fragment(x)), - split_result.inline_end.map(|x| split_fragment(x))) + (split_result.inline_start.as_ref().map(|x| split_fragment(x.clone())), + split_result.inline_end.as_ref().map(|x| split_fragment(x.clone()))) } }; @@ -769,53 +769,53 @@ impl InlineFlow { layout_context: &LayoutContext) -> (Au, bool) { match fragment.vertical_align() { - vertical_align::baseline => (-ascent, false), - vertical_align::middle => { + vertical_align::T::baseline => (-ascent, false), + vertical_align::T::middle => { // TODO: x-height value should be used from font info. // TODO: The code below passes our current reftests but doesn't work in all // situations. Add vertical align reftests and fix this. (-ascent, false) }, - vertical_align::sub => { + vertical_align::T::sub => { let sub_offset = (parent_text_block_start + parent_text_block_end) .scale_by(FONT_SUBSCRIPT_OFFSET_RATIO); (sub_offset - ascent, false) }, - vertical_align::super_ => { + vertical_align::T::super_ => { let super_offset = (parent_text_block_start + parent_text_block_end) .scale_by(FONT_SUPERSCRIPT_OFFSET_RATIO); (-super_offset - ascent, false) }, - vertical_align::text_top => { + vertical_align::T::text_top => { let fragment_block_size = *block_size_above_baseline + *depth_below_baseline; let prev_depth_below_baseline = *depth_below_baseline; *block_size_above_baseline = parent_text_block_start; *depth_below_baseline = fragment_block_size - *block_size_above_baseline; (*depth_below_baseline - prev_depth_below_baseline - ascent, false) }, - vertical_align::text_bottom => { + vertical_align::T::text_bottom => { let fragment_block_size = *block_size_above_baseline + *depth_below_baseline; let prev_depth_below_baseline = *depth_below_baseline; *depth_below_baseline = parent_text_block_end; *block_size_above_baseline = fragment_block_size - *depth_below_baseline; (*depth_below_baseline - prev_depth_below_baseline - ascent, false) }, - vertical_align::top => { + vertical_align::T::top => { *largest_block_size_for_top_fragments = max(*largest_block_size_for_top_fragments, *block_size_above_baseline + *depth_below_baseline); let offset_top = *block_size_above_baseline - ascent; (offset_top, true) }, - vertical_align::bottom => { + vertical_align::T::bottom => { *largest_block_size_for_bottom_fragments = max(*largest_block_size_for_bottom_fragments, *block_size_above_baseline + *depth_below_baseline); let offset_bottom = -(*depth_below_baseline + ascent); (offset_bottom, true) }, - vertical_align::Length(length) => (-(length + ascent), false), - vertical_align::Percentage(p) => { + vertical_align::T::Length(length) => (-(length + ascent), false), + vertical_align::T::Percentage(p) => { let line_height = fragment.calculate_line_height(layout_context); let percent_offset = line_height.scale_by(p); (-(percent_offset + ascent), false) @@ -838,9 +838,9 @@ impl InlineFlow { // coordinates. // // TODO(burg, issue #213): Implement `text-align: justify`. - text_align::left | text_align::justify => Au(0), - text_align::center => slack_inline_size.scale_by(0.5), - text_align::right => slack_inline_size, + text_align::T::left | text_align::T::justify => Au(0), + text_align::T::center => slack_inline_size.scale_by(0.5), + text_align::T::right => slack_inline_size, }; for fragment_index in range(line.range.begin(), line.range.end()) { @@ -866,11 +866,11 @@ impl InlineFlow { for fragment_index in range(line.range.begin(), line.range.end()) { let fragment = fragments.get_mut(fragment_index.to_uint()); match fragment.vertical_align() { - vertical_align::top => { + vertical_align::T::top => { fragment.border_box.start.b = fragment.border_box.start.b + line_distance_from_flow_block_start } - vertical_align::bottom => { + vertical_align::T::bottom => { fragment.border_box.start.b = fragment.border_box.start.b + line_distance_from_flow_block_start + baseline_distance_from_block_start + largest_depth_below_baseline diff --git a/components/layout/layout_debug.rs b/components/layout/layout_debug.rs index a70dca58840..f16a18e1dfb 100644 --- a/components/layout/layout_debug.rs +++ b/components/layout/layout_debug.rs @@ -14,7 +14,7 @@ use std::cell::RefCell; use std::io::File; use std::sync::atomic::{AtomicUint, SeqCst, INIT_ATOMIC_UINT}; -local_data_key!(state_key: RefCell<State>) +thread_local!(static state_key: RefCell<Option<State>> = RefCell::new(None)) static mut DEBUG_ID_COUNTER: AtomicUint = INIT_ATOMIC_UINT; @@ -59,16 +59,16 @@ struct State { /// will be output at the beginning and end of this scope. impl Scope { pub fn new(name: String) -> Scope { - let maybe_refcell = state_key.get(); - match maybe_refcell { - Some(refcell) => { - let mut state = refcell.borrow_mut(); - let flow_trace = json::encode(&flow::base(state.flow_root.deref())); - let data = box ScopeData::new(name, flow_trace); - state.scope_stack.push(data); + 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 data = box ScopeData::new(name.clone(), flow_trace); + state.scope_stack.push(data); + } + &None => {} } - None => {} - } + }); Scope } } @@ -76,17 +76,17 @@ impl Scope { #[cfg(not(ndebug))] impl Drop for Scope { fn drop(&mut self) { - let maybe_refcell = state_key.get(); - match maybe_refcell { - Some(refcell) => { - let mut state = refcell.borrow_mut(); - let mut current_scope = state.scope_stack.pop().unwrap(); - current_scope.post = json::encode(&flow::base(state.flow_root.deref())); - let previous_scope = state.scope_stack.last_mut().unwrap(); - previous_scope.children.push(current_scope); + state_key.with(|ref r| { + 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())); + let previous_scope = state.scope_stack.last_mut().unwrap(); + previous_scope.children.push(current_scope); + } + &None => {} } - None => {} - } + }); } } @@ -100,22 +100,23 @@ pub fn generate_unique_debug_id() -> u16 { /// Begin a layout debug trace. If this has not been called, /// creating debug scopes has no effect. pub fn begin_trace(flow_root: FlowRef) { - assert!(state_key.get().is_none()); - - let flow_trace = json::encode(&flow::base(flow_root.deref())); - let state = State { - scope_stack: vec![box ScopeData::new("root".into_string(), flow_trace)], - flow_root: flow_root, - }; - state_key.replace(Some(RefCell::new(state))); + 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 state = State { + scope_stack: vec![box ScopeData::new("root".into_string(), flow_trace)], + flow_root: flow_root.clone(), + }; + *r.borrow_mut() = Some(state); + }); } /// End the debug layout trace. This will write the layout /// trace to disk in the current directory. The output /// file can then be viewed with an external tool. pub fn end_trace() { - let task_state_cell = state_key.replace(None).unwrap(); - let mut task_state = task_state_cell.borrow_mut(); + 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())); diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index e64ea0f1d22..48c1bb10496 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -30,27 +30,27 @@ use gfx::display_list::{StackingContext}; use gfx::font_cache_task::FontCacheTask; use gfx::paint_task::{PaintChan, PaintLayer}; use gfx::paint_task::Msg as PaintMsg; -use layout_traits::{mod, LayoutControlMsg, LayoutTaskFactory}; +use layout_traits::{LayoutControlMsg, LayoutTaskFactory}; use log; use script::dom::bindings::js::JS; use script::dom::node::{LayoutDataRef, Node, NodeTypeId}; use script::dom::element::ElementTypeId; use script::dom::htmlelement::HTMLElementTypeId; use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse}; -use script::layout_interface::{ContentBoxesQuery, ContentBoxQuery}; +use script::layout_interface::ReflowQueryType; use script::layout_interface::{HitTestResponse, LayoutChan, LayoutRPC}; -use script::layout_interface::{MouseOverResponse, Msg, NoQuery}; +use script::layout_interface::{MouseOverResponse, Msg}; use script::layout_interface::{Reflow, ReflowGoal, ScriptLayoutChan, TrustedNodeAddress}; -use script_traits::{ConstellationControlMsg, ReflowEvent, OpaqueScriptLayoutChannel}; +use script_traits::{ConstellationControlMsg, CompositorEvent, OpaqueScriptLayoutChannel}; use script_traits::{ScriptControlChan, UntrustedNodeAddress}; -use servo_msg::compositor_msg::Scrollable; +use servo_msg::compositor_msg::ScrollPolicy; use servo_msg::constellation_msg::Msg as ConstellationMsg; use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineExitType}; use servo_msg::constellation_msg::PipelineId; use servo_net::image_cache_task::{ImageCacheTask, ImageResponseMsg}; use servo_net::local_image_cache::{ImageResponder, LocalImageCache}; use servo_net::resource_task::{ResourceTask, load_bytes_iter}; -use servo_util::cursor::DefaultCursor; +use servo_util::cursor::Cursor; use servo_util::geometry::Au; use servo_util::logical_geometry::LogicalPoint; use servo_util::opts; @@ -66,7 +66,7 @@ use std::mem; use std::ptr; use style::{StylesheetOrigin, Stylesheet, Stylist, TNode, iter_font_face_rules}; use style::{MediaType, Device}; -use sync::{Arc, Mutex, MutexGuard}; +use std::sync::{Arc, Mutex, MutexGuard}; use url::Url; /// Mutable data belonging to the LayoutTask. @@ -161,7 +161,8 @@ impl ImageResponder<UntrustedNodeAddress> for LayoutImageResponder { debug!("Dirtying {:x}", node_address as uint); let mut nodes = SmallVec1::new(); nodes.vec_push(node_address); - drop(chan.send_opt(ConstellationControlMsg::SendEvent(id.clone(), ReflowEvent(nodes)))) + drop(chan.send_opt(ConstellationControlMsg::SendEvent( + id.clone(), CompositorEvent::ReflowEvent(nodes)))) }; f } @@ -346,7 +347,7 @@ impl LayoutTask { match port_to_read { PortToRead::Pipeline => { match self.pipeline_port.recv() { - layout_traits::ExitNowMsg(exit_type) => { + LayoutControlMsg::ExitNowMsg(exit_type) => { self.handle_script_request(Msg::ExitNow(exit_type), possibly_locked_rw_data) } } @@ -690,7 +691,7 @@ impl LayoutTask { .add_to(&mut *display_list); let paint_layer = Arc::new(PaintLayer::new(layout_root.layer_id(0), color, - Scrollable)); + ScrollPolicy::Scrollable)); let origin = Rect(Point2D(Au(0), Au(0)), root_size); let stacking_context = Arc::new(StackingContext::new(display_list, &origin, @@ -846,13 +847,13 @@ impl LayoutTask { } match data.query_type { - ContentBoxQuery(node) => { + ReflowQueryType::ContentBoxQuery(node) => { self.process_content_box_request(node, &mut layout_root, &mut rw_data) } - ContentBoxesQuery(node) => { + ReflowQueryType::ContentBoxesQuery(node) => { self.process_content_boxes_request(node, &mut layout_root, &mut rw_data) } - NoQuery => {} + ReflowQueryType::NoQuery => {} } self.first_reflow.set(false); @@ -999,7 +1000,7 @@ impl LayoutRPC for LayoutRPCImpl { let cursor = if !mouse_over_list.is_empty() { mouse_over_list[0].cursor } else { - DefaultCursor + Cursor::DefaultCursor }; let ConstellationChan(ref constellation_chan) = rw_data.constellation_chan; constellation_chan.send(ConstellationMsg::SetCursor(cursor)); diff --git a/components/layout/lib.rs b/components/layout/lib.rs index 7691a051afc..1da38b4eee8 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -33,7 +33,6 @@ extern crate string_cache; extern crate collections; extern crate encoding; extern crate libc; -extern crate sync; extern crate url; // Listed first because of macro definitions diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index b13630496c5..296a73454ca 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -21,7 +21,7 @@ use servo_util::geometry::Au; use servo_util::opts; use style::ComputedValues; use style::computed_values::list_style_type; -use sync::Arc; +use std::sync::Arc; /// A block with the CSS `display` property equal to `list-item`. #[deriving(Show)] @@ -131,12 +131,12 @@ pub fn static_text_for_list_style_type(list_style_type: list_style_type::T) // Just to keep things simple, use a nonbreaking space (Unicode 0xa0) to provide the marker // separation. match list_style_type { - list_style_type::none => None, - list_style_type::disc => Some("•\u00a0"), - list_style_type::circle => Some("◦\u00a0"), - list_style_type::square => Some("▪\u00a0"), - list_style_type::disclosure_open => Some("▾\u00a0"), - list_style_type::disclosure_closed => Some("‣\u00a0"), + list_style_type::T::none => None, + list_style_type::T::disc => Some("•\u{a0}"), + list_style_type::T::circle => Some("◦\u{a0}"), + list_style_type::T::square => Some("▪\u{a0}"), + list_style_type::T::disclosure_open => Some("▾\u{a0}"), + list_style_type::T::disclosure_closed => Some("‣\u{a0}"), } } diff --git a/components/layout/model.rs b/components/layout/model.rs index 4e4e5cad399..a031a5b0537 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -18,6 +18,7 @@ use std::cmp::{max, min}; use std::fmt; /// A collapsible margin. See CSS 2.1 § 8.3.1. +#[deriving(Copy)] pub struct AdjoiningMargins { /// The value of the greatest positive margin. pub most_positive: Au, @@ -60,6 +61,7 @@ impl AdjoiningMargins { } /// Represents the block-start and block-end margins of a flow with collapsible margins. See CSS 2.1 § 8.3.1. +#[deriving(Copy)] pub enum CollapsibleMargins { /// Margins may not collapse with this flow. None(Au, Au), @@ -237,6 +239,7 @@ impl MarginCollapseInfo { } } +#[deriving(Copy)] pub enum MarginCollapseState { AccumulatingCollapsibleTopMargin, AccumulatingMarginIn, @@ -322,7 +325,7 @@ impl IntrinsicISizesContribution { } /// Useful helper data type when computing values for blocks and positioned elements. -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] pub enum MaybeAuto { Auto, Specified(Au), diff --git a/components/layout/table.rs b/components/layout/table.rs index e05abd4d67e..0dd9f9caa08 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -27,7 +27,7 @@ use std::cmp::max; use std::fmt; use style::{ComputedValues, CSSFloat}; use style::computed_values::{LengthOrPercentageOrAuto, table_layout}; -use sync::Arc; +use std::sync::Arc; /// A table flow corresponded to the table's internal table fragment under a table wrapper flow. /// The properties `position`, `float`, and `margin-*` are used on the table wrapper fragment, @@ -54,7 +54,7 @@ impl TableFlow { -> TableFlow { let mut block_flow = BlockFlow::from_node_and_fragment(node, fragment); let table_layout = if block_flow.fragment().style().get_table().table_layout == - table_layout::fixed { + table_layout::T::fixed { TableLayout::Fixed } else { TableLayout::Auto @@ -72,7 +72,7 @@ impl TableFlow { -> TableFlow { let mut block_flow = BlockFlow::from_node(constructor, node); let table_layout = if block_flow.fragment().style().get_table().table_layout == - table_layout::fixed { + table_layout::T::fixed { TableLayout::Fixed } else { TableLayout::Auto @@ -91,7 +91,7 @@ impl TableFlow { -> TableFlow { let mut block_flow = BlockFlow::float_from_node(constructor, node, float_kind); let table_layout = if block_flow.fragment().style().get_table().table_layout == - table_layout::fixed { + table_layout::T::fixed { TableLayout::Fixed } else { TableLayout::Auto @@ -441,7 +441,7 @@ impl ISizeAndMarginsComputer for InternalTable { /// maximum of 100 pixels and 20% of the table), the preceding constraint means that we must /// potentially store both a specified width *and* a specified percentage, so that the inline-size /// assignment phase of layout will know which one to pick. -#[deriving(Clone, Encodable, Show)] +#[deriving(Clone, Encodable, Show, Copy)] pub struct ColumnIntrinsicInlineSize { /// The preferred intrinsic inline size. pub preferred: Au, @@ -485,7 +485,7 @@ impl ColumnIntrinsicInlineSize { /// /// TODO(pcwalton): There will probably be some `border-collapse`-related info in here too /// eventually. -#[deriving(Encodable)] +#[deriving(Encodable, Copy)] pub struct ColumnComputedInlineSize { /// The computed size of this inline column. pub size: Au, diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs index 1a77cde7092..938bfa0e0d2 100644 --- a/components/layout/table_caption.rs +++ b/components/layout/table_caption.rs @@ -17,7 +17,7 @@ use geom::{Point2D, Rect}; use servo_util::geometry::Au; use std::fmt; use style::ComputedValues; -use sync::Arc; +use std::sync::Arc; /// A table formatting context. pub struct TableCaptionFlow { diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index b97a12e143d..89eea551c73 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -19,7 +19,7 @@ use geom::{Point2D, Rect}; use servo_util::geometry::Au; use std::fmt; use style::{UnsignedIntegerAttribute, ComputedValues}; -use sync::Arc; +use std::sync::Arc; /// A table formatting context. #[deriving(Encodable)] diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index 5e7b066d206..648c1ae125c 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -19,7 +19,7 @@ use std::cmp::max; use std::fmt; use style::computed_values::LengthOrPercentageOrAuto; use style::ComputedValues; -use sync::Arc; +use std::sync::Arc; /// A table formatting context. pub struct TableColGroupFlow { diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index b3e9e1ae7f6..55bc3634efa 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -24,7 +24,7 @@ use std::cmp::max; use std::fmt; use style::ComputedValues; use style::computed_values::LengthOrPercentageOrAuto; -use sync::Arc; +use std::sync::Arc; /// A single row of a table. #[deriving(Encodable)] @@ -39,7 +39,7 @@ pub struct TableRowFlow { } /// Information about the column inline size and span for each cell. -#[deriving(Encodable)] +#[deriving(Encodable, Copy)] pub struct CellIntrinsicInlineSize { /// Inline sizes that this cell contributes to the column. pub column_size: ColumnIntrinsicInlineSize, diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index 2c2847565c7..80647a01a77 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -19,7 +19,7 @@ use geom::{Point2D, Rect}; use servo_util::geometry::Au; use std::fmt; use style::ComputedValues; -use sync::Arc; +use std::sync::Arc; /// A table formatting context. #[deriving(Encodable)] diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 1c68b7fa924..5a856db7334 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -29,9 +29,9 @@ use std::cmp::{max, min}; use std::fmt; use style::{ComputedValues, CSSFloat}; use style::computed_values::table_layout; -use sync::Arc; +use std::sync::Arc; -#[deriving(Encodable, Show)] +#[deriving(Copy, Encodable, Show)] pub enum TableLayout { Fixed, Auto @@ -55,7 +55,7 @@ impl TableWrapperFlow { -> TableWrapperFlow { let mut block_flow = BlockFlow::from_node_and_fragment(node, fragment); let table_layout = if block_flow.fragment().style().get_table().table_layout == - table_layout::fixed { + table_layout::T::fixed { TableLayout::Fixed } else { TableLayout::Auto @@ -72,7 +72,7 @@ impl TableWrapperFlow { -> TableWrapperFlow { let mut block_flow = BlockFlow::from_node(constructor, node); let table_layout = if block_flow.fragment().style().get_table().table_layout == - table_layout::fixed { + table_layout::T::fixed { TableLayout::Fixed } else { TableLayout::Auto @@ -90,7 +90,7 @@ impl TableWrapperFlow { -> TableWrapperFlow { let mut block_flow = BlockFlow::float_from_node_and_fragment(node, fragment, float_kind); let table_layout = if block_flow.fragment().style().get_table().table_layout == - table_layout::fixed { + table_layout::T::fixed { TableLayout::Fixed } else { TableLayout::Auto @@ -487,7 +487,7 @@ impl Add<AutoLayoutCandidateGuess,AutoLayoutCandidateGuess> for AutoLayoutCandid /// The `CSSFloat` member specifies the weight of the smaller of the two guesses, on a scale from /// 0.0 to 1.0. -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] enum SelectedAutoLayoutCandidateGuess { UseMinimumGuess, InterpolateBetweenMinimumGuessAndMinimumPercentageGuess(CSSFloat), diff --git a/components/layout/text.rs b/components/layout/text.rs index ea79541bde0..e92197b7257 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -14,7 +14,7 @@ use gfx::font::{ShapingOptions}; use gfx::font_context::FontContext; use gfx::text::glyph::CharIndex; use gfx::text::text_run::TextRun; -use gfx::text::util::{mod, CompressWhitespaceNewline, CompressNone}; +use gfx::text::util::{mod, CompressionMode}; use servo_util::dlist; use servo_util::geometry::Au; use servo_util::logical_geometry::{LogicalSize, WritingMode}; @@ -25,7 +25,7 @@ use std::mem; use style::ComputedValues; use style::computed_values::{line_height, text_orientation, text_transform, white_space}; use style::style_structs::Font as FontStyle; -use sync::Arc; +use std::sync::Arc; /// A stack-allocated object for scanning an inline flow into `TextRun`-containing `TextFragment`s. pub struct TextRunScanner { @@ -114,8 +114,8 @@ impl TextRunScanner { let inherited_text_style = in_fragment.style().get_inheritedtext(); fontgroup = font_context.get_layout_font_group_for_style(font_style); compression = match in_fragment.white_space() { - white_space::normal | white_space::nowrap => CompressWhitespaceNewline, - white_space::pre => CompressNone, + white_space::T::normal | white_space::T::nowrap => CompressionMode::CompressWhitespaceNewline, + white_space::T::pre => CompressionMode::CompressNone, }; text_transform = inherited_text_style.text_transform; letter_spacing = inherited_text_style.letter_spacing; @@ -213,22 +213,22 @@ impl TextRunScanner { string: &mut String, text_transform: text_transform::T) { match text_transform { - text_transform::none => {} - text_transform::uppercase => { + text_transform::T::none => {} + text_transform::T::uppercase => { let length = string.len(); let original = mem::replace(string, String::with_capacity(length)); for character in original.chars() { string.push(character.to_uppercase()) } } - text_transform::lowercase => { + 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()) } } - text_transform::capitalize => { + text_transform::T::capitalize => { let length = string.len(); let original = mem::replace(string, String::with_capacity(length)); let mut capitalize_next_letter = true; @@ -266,9 +266,9 @@ fn bounding_box_for_run_metrics(metrics: &RunMetrics, writing_mode: WritingMode) // This will be a reminder to update the code below. let dummy: Option<text_orientation::T> = None; match dummy { - Some(text_orientation::sideways_right) | - Some(text_orientation::sideways_left) | - Some(text_orientation::sideways) | + Some(text_orientation::T::sideways_right) | + Some(text_orientation::T::sideways_left) | + Some(text_orientation::T::sideways) | None => {} } @@ -296,8 +296,8 @@ pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<Fo pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> Au { let font_size = style.get_font().font_size; match style.get_inheritedbox().line_height { - line_height::Normal => metrics.line_gap, - line_height::Number(l) => font_size.scale_by(l), - line_height::Length(l) => l + line_height::T::Normal => metrics.line_gap, + line_height::T::Number(l) => font_size.scale_by(l), + line_height::T::Length(l) => l } } diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index df56254c066..bafd242fc31 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -21,6 +21,9 @@ use servo_util::opts; use servo_util::tid::tid; use style::TNode; +use std::cell::RefCell; +use std::mem; + /// Every time we do another layout, the old bloom filters are invalid. This is /// detected by ticking a generation number every layout. type Generation = uint; @@ -45,7 +48,7 @@ type Generation = uint; /// Since a work-stealing queue is used for styling, sometimes, the bloom filter /// will no longer be the for the parent of the node we're currently on. When /// this happens, the task local bloom filter will be thrown away and rebuilt. -local_data_key!(style_bloom: (Box<BloomFilter>, UnsafeLayoutNode, Generation)) +thread_local!(static STYLE_BLOOM: RefCell<Option<(Box<BloomFilter>, UnsafeLayoutNode, Generation)>> = RefCell::new(None)) /// Returns the task local bloom filter. /// @@ -53,43 +56,48 @@ local_data_key!(style_bloom: (Box<BloomFilter>, UnsafeLayoutNode, Generation)) /// it will be thrown out and a new one will be made for you. fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>, layout_context: &LayoutContext) -> Box<BloomFilter> { - match (parent_node, style_bloom.replace(None)) { - // Root node. Needs new bloom filter. - (None, _ ) => { - debug!("[{}] No parent, but new bloom filter!", tid()); - box BloomFilter::new() - } - // No bloom filter for this thread yet. - (Some(parent), None) => { - let mut bloom_filter = box BloomFilter::new(); - insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, layout_context); - bloom_filter - } - // Found cached bloom filter. - (Some(parent), Some((mut bloom_filter, old_node, old_generation))) => { - // Hey, the cached parent is our parent! We can reuse the bloom filter. - if old_node == layout_node_to_unsafe_layout_node(&parent) && - old_generation == layout_context.shared.generation { - debug!("[{}] Parent matches (={}). Reusing bloom filter.", tid(), old_node.val0()); - bloom_filter - } else { - // Oh no. the cached parent is stale. I guess we need a new one. Reuse the existing - // allocation to avoid malloc churn. - *bloom_filter = BloomFilter::new(); + STYLE_BLOOM.with(|style_bloom| { + match (parent_node, style_bloom.borrow_mut().take()) { + // Root node. Needs new bloom filter. + (None, _ ) => { + debug!("[{}] No parent, but new bloom filter!", tid()); + box BloomFilter::new() + } + // No bloom filter for this thread yet. + (Some(parent), None) => { + let mut bloom_filter = box BloomFilter::new(); insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, layout_context); bloom_filter } - }, - } + // Found cached bloom filter. + (Some(parent), Some((mut bloom_filter, old_node, old_generation))) => { + // Hey, the cached parent is our parent! We can reuse the bloom filter. + if old_node == layout_node_to_unsafe_layout_node(&parent) && + old_generation == layout_context.shared.generation { + debug!("[{}] Parent matches (={}). Reusing bloom filter.", tid(), old_node.val0()); + bloom_filter.clone() + } else { + // Oh no. the cached parent is stale. I guess we need a new one. Reuse the existing + // allocation to avoid malloc churn. + *bloom_filter = BloomFilter::new(); + insert_ancestors_into_bloom_filter(&mut bloom_filter, parent, layout_context); + bloom_filter + } + }, + } + }) } fn put_task_local_bloom_filter(bf: Box<BloomFilter>, unsafe_node: &UnsafeLayoutNode, layout_context: &LayoutContext) { - match style_bloom.replace(Some((bf, *unsafe_node, layout_context.shared.generation))) { - None => {}, - Some(_) => panic!("Putting into a never-taken task-local bloom filter"), - } + let bf: *mut BloomFilter = unsafe { mem::transmute(bf) }; + STYLE_BLOOM.with(|style_bloom| { + assert!(style_bloom.borrow().is_none(), + "Putting into a never-taken task-local bloom filter"); + let bf: Box<BloomFilter> = unsafe { mem::transmute(bf) }; + *style_bloom.borrow_mut() = Some((bf, *unsafe_node, layout_context.shared.generation)); + }) } /// "Ancestors" in this context is inclusive of ourselves. @@ -112,6 +120,7 @@ fn insert_ancestors_into_bloom_filter(bf: &mut Box<BloomFilter>, /// The recalc-style-for-node traversal, which styles each node and must run before /// layout computation. This computes the styles applied to each node. +#[deriving(Copy)] pub struct RecalcStyleForNode<'a> { pub layout_context: &'a LayoutContext<'a>, } @@ -200,6 +209,7 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> { } /// The flow construction traversal, which builds flows for styled nodes. +#[deriving(Copy)] pub struct ConstructFlows<'a> { pub layout_context: &'a LayoutContext<'a>, } @@ -238,9 +248,10 @@ impl<'a> PostorderDomTraversal for ConstructFlows<'a> { let unsafe_layout_node = layout_node_to_unsafe_layout_node(&node); let (mut bf, old_node, old_generation) = - style_bloom - .replace(None) - .expect("The bloom filter should have been set by style recalc."); + STYLE_BLOOM.with(|style_bloom| { + mem::replace(&mut *style_bloom.borrow_mut(), None) + .expect("The bloom filter should have been set by style recalc.") + }); assert_eq!(old_node, unsafe_layout_node); assert_eq!(old_generation, self.layout_context.shared.generation); @@ -297,6 +308,7 @@ impl<'a> PostorderFlowTraversal for BubbleISizes<'a> { } /// The assign-inline-sizes traversal. In Gecko this corresponds to `Reflow`. +#[deriving(Copy)] pub struct AssignISizes<'a> { pub layout_context: &'a LayoutContext<'a>, } @@ -317,6 +329,7 @@ impl<'a> PreorderFlowTraversal for AssignISizes<'a> { /// layout computation. Determines the final block-sizes for all layout objects, computes /// positions, and computes overflow regions. In Gecko this corresponds to `Reflow` and /// `FinishAndStoreOverflow`. +#[deriving(Copy)] pub struct AssignBSizesAndStoreOverflow<'a> { pub layout_context: &'a LayoutContext<'a>, } @@ -341,6 +354,7 @@ impl<'a> PostorderFlowTraversal for AssignBSizesAndStoreOverflow<'a> { } } +#[deriving(Copy)] pub struct ComputeAbsolutePositions<'a> { pub layout_context: &'a LayoutContext<'a>, } @@ -352,6 +366,7 @@ impl<'a> PreorderFlowTraversal for ComputeAbsolutePositions<'a> { } } +#[deriving(Copy)] pub struct BuildDisplayList<'a> { pub layout_context: &'a LayoutContext<'a>, } diff --git a/components/layout/util.rs b/components/layout/util.rs index 368182e6c9e..0ba105f20fa 100644 --- a/components/layout/util.rs +++ b/components/layout/util.rs @@ -19,7 +19,7 @@ use std::mem; use std::cell::{Ref, RefMut}; use style::ComputedValues; use style; -use sync::Arc; +use std::sync::Arc; /// Data that layout associates with a node. pub struct PrivateLayoutData { @@ -64,6 +64,7 @@ impl PrivateLayoutData { } bitflags! { + #[deriving(Copy)] flags LayoutDataFlags: u8 { #[doc="Whether a flow has been newly constructed."] const HAS_NEWLY_CONSTRUCTED_FLOW = 0x01 diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index aca02bdbb4e..c22bb367b60 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -137,6 +137,7 @@ pub trait TLayoutNode { /// A wrapper so that layout can access only the methods that it should have access to. Layout must /// only ever see these and must never see instances of `JS`. +#[deriving(Copy)] pub struct LayoutNode<'a> { /// The wrapped node. node: JS<Node>, @@ -476,6 +477,7 @@ impl<'a> Iterator<LayoutNode<'a>> for LayoutTreeIterator<'a> { } /// A wrapper around elements that ensures layout can only ever access safe properties. +#[deriving(Copy)] pub struct LayoutElement<'le> { element: &'le Element, } @@ -631,10 +633,10 @@ impl<'le> TElementAttributes for LayoutElement<'le> { fn get_content(content_list: &content::T) -> String { match *content_list { - content::Content(ref value) => { + content::T::Content(ref value) => { let iter = &mut value.clone().into_iter().peekable(); match iter.next() { - Some(content::StringContent(content)) => content, + Some(content::ContentItem::StringContent(content)) => content, _ => "".into_string(), } } @@ -642,7 +644,7 @@ fn get_content(content_list: &content::T) -> String { } } -#[deriving(PartialEq, Clone)] +#[deriving(Copy, PartialEq, Clone)] pub enum PseudoElementType { Normal, Before(display::T), @@ -667,7 +669,7 @@ impl PseudoElementType { /// A thread-safe version of `LayoutNode`, used during flow construction. This type of layout /// node does not allow any parents or siblings of nodes to be accessed, to avoid races. -#[deriving(Clone)] +#[deriving(Copy, Clone)] pub struct ThreadSafeLayoutNode<'ln> { /// The wrapped node. node: LayoutNode<'ln>, @@ -716,9 +718,9 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> { let pseudo_before_node = self.with_pseudo(PseudoElementType::Before(self.get_before_display())); return Some(pseudo_before_node) } - PseudoElementType::Before(display::inline) => {} + PseudoElementType::Before(display::T::inline) => {} PseudoElementType::Before(_) => { - let pseudo_before_node = self.with_pseudo(PseudoElementType::Before(display::inline)); + let pseudo_before_node = self.with_pseudo(PseudoElementType::Before(display::T::inline)); return Some(pseudo_before_node) } _ => {} @@ -922,7 +924,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> { // If you implement other values for this property, you will almost certainly // want to update this check. match self.style().get_inheritedtext().white_space { - white_space::normal => true, + white_space::T::normal => true, _ => false, } } diff --git a/components/msg/compositor_msg.rs b/components/msg/compositor_msg.rs index 9d280cef673..2b220652a03 100644 --- a/components/msg/compositor_msg.rs +++ b/components/msg/compositor_msg.rs @@ -14,13 +14,13 @@ use std::fmt; use constellation_msg::PipelineId; /// The status of the painter. -#[deriving(PartialEq, Clone)] +#[deriving(PartialEq, Eq, Clone, Copy)] pub enum PaintState { Idle, Painting, } -#[deriving(Eq, Ord, PartialEq, PartialOrd, Clone, Show)] +#[deriving(Eq, Ord, PartialEq, PartialOrd, Clone, Show, Copy)] pub enum ReadyState { /// Informs the compositor that nothing has been done yet. Used for setting status Blank, @@ -33,7 +33,7 @@ pub enum ReadyState { } /// A newtype struct for denoting the age of messages; prevents race conditions. -#[deriving(PartialEq, Show)] +#[deriving(PartialEq, Eq, Show, Copy)] pub struct Epoch(pub uint); impl Epoch { @@ -43,7 +43,7 @@ impl Epoch { } } -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Eq, Copy)] pub struct LayerId(pub uint, pub uint); impl Show for LayerId { @@ -61,7 +61,7 @@ impl LayerId { } /// The scrolling policy of a layer. -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Eq, Copy)] pub enum ScrollPolicy { /// These layers scroll when the parent receives a scrolling message. Scrollable, @@ -71,6 +71,7 @@ pub enum ScrollPolicy { /// All layer-specific information that the painting task sends to the compositor other than the /// buffer contents of the layer itself. +#[deriving(Copy)] pub struct LayerMetadata { /// An opaque ID. This is usually the address of the flow and index of the box within it. pub id: LayerId, diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 023df2ccae0..cbd6062f724 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -26,19 +26,20 @@ impl ConstellationChan { } } -#[deriving(PartialEq)] +#[deriving(PartialEq, Eq, Copy)] pub enum IFrameSandboxState { IFrameSandboxed, IFrameUnsandboxed } // We pass this info to various tasks, so it lives in a separate, cloneable struct. -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub struct Failure { pub pipeline_id: PipelineId, pub subpage_id: Option<SubpageId>, } +#[deriving(Copy)] pub struct WindowSizeData { /// The size of the initial layout viewport, before parsing an /// http://www.w3.org/TR/css-device-adapt/#initial-viewport @@ -51,7 +52,7 @@ pub struct WindowSizeData { pub device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>, } -#[deriving(PartialEq)] +#[deriving(PartialEq, Eq, Copy, Clone)] pub enum KeyState { Pressed, Released, @@ -59,7 +60,7 @@ pub enum KeyState { } //N.B. Straight up copied from glfw-rs -#[deriving(Show)] +#[deriving(Show, PartialEq, Eq, Copy, Clone)] pub enum Key { Space, Apostrophe, @@ -185,6 +186,7 @@ pub enum Key { } bitflags! { + #[deriving(Copy)] flags KeyModifiers: u8 { const SHIFT = 0x01, const CONTROL = 0x02, @@ -236,26 +238,27 @@ impl LoadData { } /// Represents the two different ways to which a page can be navigated -#[deriving(Clone, PartialEq, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, Copy, Hash, Show)] pub enum NavigationType { Load, // entered or clicked on a url Navigate, // browser forward/back buttons } -#[deriving(Clone, PartialEq, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, Copy, Hash, Show)] pub enum NavigationDirection { Forward, Back, } -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, Copy, Hash, Show)] pub struct PipelineId(pub uint); -#[deriving(Clone, PartialEq, Eq, Hash, Show)] +#[deriving(Clone, PartialEq, Eq, Copy, Hash, Show)] pub struct SubpageId(pub uint); // The type of pipeline exit. During complete shutdowns, pipelines do not have to // release resources automatically released on process termination. +#[deriving(Copy)] pub enum PipelineExitType { PipelineOnly, Complete, diff --git a/components/net/about_loader.rs b/components/net/about_loader.rs index 0a5f2c30ada..bedb21b573e 100644 --- a/components/net/about_loader.rs +++ b/components/net/about_loader.rs @@ -11,7 +11,6 @@ use hyper::http::RawStatus; use servo_util::resource_files::resources_dir_path; use std::io::fs::PathExtensions; -use std::str::Slice; pub fn factory(mut load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) { let senders = ResponseSenders { @@ -25,7 +24,7 @@ pub fn factory(mut load_data: LoadData, start_chan: Sender<TargetedLoadResponse> content_type: Some(("text".to_string(), "html".to_string())), charset: Some("utf-8".to_string()), headers: None, - status: Some(RawStatus(200, Slice("OK"))) + status: Some(RawStatus(200, "OK".into_string())) }); chan.send(Done(Ok(()))); return diff --git a/components/net/fetch/request.rs b/components/net/fetch/request.rs index f4dd62971f8..050ed9b892b 100644 --- a/components/net/fetch/request.rs +++ b/components/net/fetch/request.rs @@ -11,6 +11,7 @@ use fetch::cors_cache::CORSCache; use fetch::response::Response; /// A [request context](http://fetch.spec.whatwg.org/#concept-request-context) +#[deriving(Copy)] pub enum Context { Audio, Beacon, CSPreport, Download, Embed, Eventsource, Favicon, Fetch, Font, Form, Frame, Hyperlink, IFrame, Image, @@ -20,6 +21,7 @@ pub enum Context { } /// A [request context frame type](http://fetch.spec.whatwg.org/#concept-request-context-frame-type) +#[deriving(Copy)] pub enum ContextFrameType { Auxiliary, TopLevel, @@ -35,6 +37,7 @@ pub enum Referer { } /// A [request mode](http://fetch.spec.whatwg.org/#concept-request-mode) +#[deriving(Copy)] pub enum RequestMode { SameOrigin, NoCORS, @@ -43,6 +46,7 @@ pub enum RequestMode { } /// Request [credentials mode](http://fetch.spec.whatwg.org/#concept-request-credentials-mode) +#[deriving(Copy)] pub enum CredentialsMode { Omit, CredentialsSameOrigin, @@ -50,6 +54,7 @@ pub enum CredentialsMode { } /// [Response tainting](http://fetch.spec.whatwg.org/#concept-request-response-tainting) +#[deriving(Copy)] pub enum ResponseTainting { Basic, CORSTainting, diff --git a/components/net/fetch/response.rs b/components/net/fetch/response.rs index f2ee213560d..2c1817de338 100644 --- a/components/net/fetch/response.rs +++ b/components/net/fetch/response.rs @@ -9,7 +9,7 @@ use std::ascii::AsciiExt; use std::comm::Receiver; /// [Response type](http://fetch.spec.whatwg.org/#concept-response-type) -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Copy)] pub enum ResponseType { Basic, CORS, @@ -19,7 +19,7 @@ pub enum ResponseType { } /// [Response termination reason](http://fetch.spec.whatwg.org/#concept-response-termination-reason) -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub enum TerminationReason { EndUserAbort, Fatal, diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index ccfca4deb26..d8b909f88f3 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -85,7 +85,7 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) { // FIXME(seanmonstar): use AcceptEncoding from Hyper once available //if !req.headers.has::<AcceptEncoding>() { // We currently don't support HTTP Compression (FIXME #2587) - req.headers_mut().set_raw("Accept-Encoding", vec![b"identity".to_vec()]); + req.headers_mut().set_raw("Accept-Encoding".into_string(), vec![b"identity".to_vec()]); //} let writer = match load_data.data { Some(ref data) => { diff --git a/components/net/image/holder.rs b/components/net/image/holder.rs index 2ca86d8af99..216f362328a 100644 --- a/components/net/image/holder.rs +++ b/components/net/image/holder.rs @@ -7,7 +7,7 @@ use image_cache_task::ImageResponseMsg; use local_image_cache::LocalImageCache; use geom::size::Size2D; -use sync::{Arc, Mutex}; +use std::sync::{Arc, Mutex}; use url::Url; // FIXME: Nasty coupling here This will be a problem if we want to factor out image handling from diff --git a/components/net/image_cache_task.rs b/components/net/image_cache_task.rs index aa0097cd86b..46f238b0a00 100644 --- a/components/net/image_cache_task.rs +++ b/components/net/image_cache_task.rs @@ -13,7 +13,7 @@ use std::comm::{channel, Receiver, Sender}; use std::collections::HashMap; use std::collections::hash_map::{Occupied, Vacant}; use std::mem::replace; -use sync::{Arc, Mutex}; +use std::sync::{Arc, Mutex}; use serialize::{Encoder, Encodable}; use url::Url; diff --git a/components/net/lib.rs b/components/net/lib.rs index 1954802b2aa..0b579dd5e0d 100644 --- a/components/net/lib.rs +++ b/components/net/lib.rs @@ -16,7 +16,6 @@ extern crate log; extern crate serialize; extern crate "util" as servo_util; extern crate stb_image; -extern crate sync; extern crate time; extern crate url; diff --git a/components/net/resource_task.rs b/components/net/resource_task.rs index d7bd8f2e40f..9b541455a03 100644 --- a/components/net/resource_task.rs +++ b/components/net/resource_task.rs @@ -21,7 +21,6 @@ use hyper::mime::{Mime, Attr}; use url::Url; use std::comm::{channel, Receiver, Sender}; -use std::str::Slice; pub enum ControlMsg { /// Request the data associated with a particular URL @@ -86,7 +85,8 @@ impl Metadata { content_type: None, charset: None, headers: None, - status: Some(RawStatus(200, Slice("OK"))) // http://fetch.spec.whatwg.org/#concept-response-status-message + // http://fetch.spec.whatwg.org/#concept-response-status-message + status: Some(RawStatus(200, "OK".into_string())) } } diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs index 5a4a7554a8e..53995abfab9 100644 --- a/components/plugins/lib.rs +++ b/components/plugins/lib.rs @@ -21,8 +21,6 @@ extern crate syntax; #[phase(plugin, link)] extern crate rustc; -#[cfg(test)] -extern crate sync; use rustc::lint::LintPassObject; use rustc::plugin::Registry; diff --git a/components/plugins/lints/inheritance_integrity.rs b/components/plugins/lints/inheritance_integrity.rs index d3ea6ee280d..fa3f42770f0 100644 --- a/components/plugins/lints/inheritance_integrity.rs +++ b/components/plugins/lints/inheritance_integrity.rs @@ -5,7 +5,6 @@ use syntax::{ast, ast_util}; use rustc::lint::{Context, LintPass, LintArray, Level}; use rustc::middle::{ty, def}; -use rustc::middle::typeck::astconv::AstConv; use utils::match_lang_ty; @@ -42,7 +41,7 @@ impl LintPass for InheritancePass { .map(|(_, f)| f.span); // Find all #[dom_struct] fields let dom_spans: Vec<_> = def.fields.iter().enumerate().filter_map(|(ctr, f)| { - if let ast::TyPath(_, _, ty_id) = f.node.ty.node { + if let ast::TyPath(_, ty_id) = f.node.ty.node { if let Some(def::DefTy(def_id, _)) = cx.tcx.def_map.borrow().get(&ty_id).cloned() { if ty::has_attr(cx.tcx, def_id, "_dom_struct_marker") { // If the field is not the first, it's probably diff --git a/components/plugins/lints/privatize.rs b/components/plugins/lints/privatize.rs index 07e7ca594da..379fa946b43 100644 --- a/components/plugins/lints/privatize.rs +++ b/components/plugins/lints/privatize.rs @@ -7,7 +7,6 @@ use syntax::ast::Public; use syntax::attr::AttrMetaMethods; use rustc::lint::{Context, LintPass, LintArray}; use rustc::middle::ty; -use rustc::middle::typeck::astconv::AstConv; declare_lint!(PRIVATIZE, Deny, "Allows to enforce private fields for struct definitions") diff --git a/components/plugins/lints/str_to_string.rs b/components/plugins/lints/str_to_string.rs index 79c2d917139..d02e0d9bfde 100644 --- a/components/plugins/lints/str_to_string.rs +++ b/components/plugins/lints/str_to_string.rs @@ -6,7 +6,6 @@ use syntax::ast; use rustc::lint::{Context, LintPass, LintArray}; use rustc::middle::ty::expr_ty; use rustc::middle::ty; -use rustc::middle::typeck::astconv::AstConv; declare_lint!(STR_TO_STRING, Deny, "Warn when a String could use into_string() instead of to_string()") @@ -33,13 +32,13 @@ impl LintPass for StrToStringPass { } fn is_str(cx: &Context, expr: &ast::Expr) -> bool { - fn walk_ty<'t>(ty: ty::t) -> ty::t { - match ty::get(ty).sty { + fn walk_ty<'t>(ty: ty::Ty<'t>) -> ty::Ty<'t> { + match ty.sty { ty::ty_ptr(ref tm) | ty::ty_rptr(_, ref tm) => walk_ty(tm.ty), _ => ty } } - match ty::get(walk_ty(expr_ty(cx.tcx, expr))).sty { + match walk_ty(expr_ty(cx.tcx, expr)).sty { ty::ty_str => true, _ => false } diff --git a/components/plugins/lints/transmute_type.rs b/components/plugins/lints/transmute_type.rs index a5d6ec55ba3..674f14c3c7d 100644 --- a/components/plugins/lints/transmute_type.rs +++ b/components/plugins/lints/transmute_type.rs @@ -6,7 +6,6 @@ use syntax::ast; use syntax::attr::AttrMetaMethods; use rustc::lint::{Context, LintPass, LintArray}; use rustc::middle::ty::expr_ty; -use rustc::middle::typeck::astconv::AstConv; use rustc::util::ppaux::Repr; declare_lint!(TRANSMUTE_TYPE_LINT, Allow, @@ -31,7 +30,7 @@ impl LintPass for TransmutePass { if path.segments.last() .map_or(false, |ref segment| segment.identifier.name.as_str() == "transmute") && args.len() == 1 { - let tcx = cx.tcx(); + let tcx = cx.tcx; cx.span_lint(TRANSMUTE_TYPE_LINT, ex.span, format!("Transmute to {} from {} detected", expr_ty(tcx, ex).repr(tcx), diff --git a/components/plugins/lints/unrooted_must_root.rs b/components/plugins/lints/unrooted_must_root.rs index 582d1502fa3..636ff472fff 100644 --- a/components/plugins/lints/unrooted_must_root.rs +++ b/components/plugins/lints/unrooted_must_root.rs @@ -7,7 +7,6 @@ use syntax::attr::AttrMetaMethods; use rustc::lint::{Context, LintPass, LintArray}; use rustc::middle::ty::expr_ty; use rustc::middle::{ty, def}; -use rustc::middle::typeck::astconv::AstConv; use rustc::util::ppaux::Repr; use utils::unsafe_context; @@ -24,6 +23,7 @@ declare_lint!(UNROOTED_MUST_ROOT, Deny, /// - Not being bound locally in a `let` statement, assignment, `for` loop, or `match` statement. /// /// This helps catch most situations where pointers like `JS<T>` are used in a way that they can be invalidated by a GC pass. +#[allow(missing_copy_implementations)] pub struct UnrootedPass; // Checks if a type has the #[must_root] annotation. @@ -33,7 +33,7 @@ fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) { match ty.node { ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) | ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning), - ast::TyPath(_, _, id) => { + ast::TyPath(_, id) => { match cx.tcx.def_map.borrow()[id].clone() { def::DefTy(def_id, _) => { if ty::has_attr(cx.tcx, def_id, "must_root") { @@ -146,7 +146,7 @@ impl LintPass for UnrootedPass { }; let t = expr_ty(cx.tcx, &*expr); - match ty::get(t).sty { + match t.sty { ty::ty_struct(did, _) | ty::ty_enum(did, _) => { if ty::has_attr(cx.tcx, did, "must_root") { diff --git a/components/plugins/utils.rs b/components/plugins/utils.rs index 132d7afaaa8..6f7f00f9109 100644 --- a/components/plugins/utils.rs +++ b/components/plugins/utils.rs @@ -4,7 +4,6 @@ use rustc::lint::Context; use rustc::middle::{ty, def}; -use rustc::middle::typeck::astconv::AstConv; use syntax::ptr::P; use syntax::{ast, ast_map}; @@ -17,7 +16,7 @@ use syntax::attr::mark_used; /// Try not to use this for types defined in crates you own, use match_lang_ty instead (for lint passes) pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> { match ty.node { - TyPath(Path {segments: ref seg, ..}, _, _) => { + TyPath(Path {segments: ref seg, ..}, _) => { // So ast::Path isn't the full path, just the tokens that were provided. // I could muck around with the maps and find the full path // however the more efficient way is to simply reverse the iterators and zip them @@ -40,7 +39,7 @@ pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> /// Checks if a type has a #[servo_lang = "str"] attribute pub fn match_lang_ty(cx: &Context, ty: &Ty, value: &str) -> bool { let mut found = false; - if let TyPath(_, _, ty_id) = ty.node { + if let TyPath(_, ty_id) = ty.node { if let Some(def::DefTy(def_id, _)) = cx.tcx.def_map.borrow().get(&ty_id).cloned() { // Iterating through attributes is hard because of cross-crate defs ty::each_attr(cx.tcx, def_id, |attr| { diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 88074db8320..2a211eb52d5 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -48,9 +48,6 @@ git = "https://github.com/servo/rust-geom" [dependencies.html5ever] git = "https://github.com/servo/html5ever" -[dependencies.encoding] -git = "https://github.com/lifthrasiir/rust-encoding" - [dependencies.hyper] git = "https://github.com/servo/hyper" branch = "servo" @@ -72,3 +69,6 @@ git = "https://github.com/servo/string-cache" [dependencies.time] git = "https://github.com/rust-lang/time" + +[dependencies] +encoding = "0.2" diff --git a/components/script/cors.rs b/components/script/cors.rs index 24900e1daa1..e7fd20d866c 100644 --- a/components/script/cors.rs +++ b/components/script/cors.rs @@ -40,7 +40,7 @@ pub struct CORSRequest { /// http://fetch.spec.whatwg.org/#concept-request-mode /// This only covers some of the request modes. The /// `same-origin` and `no CORS` modes are unnecessary for XHR. -#[deriving(PartialEq, Clone)] +#[deriving(PartialEq, Copy, Clone)] pub enum RequestMode { CORS, // CORS ForcedPreflight // CORS-with-forced-preflight diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs index ec6071e0700..29741117383 100644 --- a/components/script/dom/bindings/callback.rs +++ b/components/script/dom/bindings/callback.rs @@ -16,6 +16,7 @@ use js::jsval::{JSVal, UndefinedValue}; use std::ptr; /// The exception handling used for a call. +#[deriving(Copy)] pub enum ExceptionHandling { /// Report any exception and don't throw it to the caller code. ReportExceptions, @@ -28,7 +29,7 @@ pub enum ExceptionHandling { } /// A common base class for representing IDL callback function types. -#[deriving(Clone,PartialEq)] +#[deriving(Copy, Clone,PartialEq)] #[jstraceable] pub struct CallbackFunction { object: CallbackObject @@ -46,7 +47,7 @@ impl CallbackFunction { } /// A common base class for representing IDL callback interface types. -#[deriving(Clone,PartialEq)] +#[deriving(Copy, Clone,PartialEq)] #[jstraceable] pub struct CallbackInterface { object: CallbackObject @@ -55,7 +56,7 @@ pub struct CallbackInterface { /// A common base class for representing IDL callback function and /// callback interface types. #[allow(raw_pointer_deriving)] -#[deriving(Clone,PartialEq)] +#[deriving(Copy, Clone,PartialEq)] #[jstraceable] struct CallbackObject { /// The underlying `JSObject`. diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 82b79eb1971..4d8dd7599c5 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2763,7 +2763,7 @@ class CGEnum(CGThing): decl = """\ #[repr(uint)] -#[deriving(PartialEq)] +#[deriving(PartialEq, Copy)] #[jstraceable] pub enum %s { %s @@ -4693,7 +4693,7 @@ class CGCallback(CGClass): bases=[ClassBase(baseName)], constructors=self.getConstructors(), methods=realMethods+getters+setters, - decorators="#[deriving(PartialEq,Clone)]#[jstraceable]") + decorators="#[deriving(PartialEq,Copy,Clone)]#[jstraceable]") def getConstructors(self): return [ClassConstructor( @@ -5189,8 +5189,8 @@ class GlobalGenRoots(): return CGList([ CGGeneric(AUTOGENERATED_WARNING_COMMENT), CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength), - CGNonNamespacedEnum('ID', protos, [0], deriving="PartialEq"), - CGNonNamespacedEnum('Proxies', proxies, [0], deriving="PartialEq"), + CGNonNamespacedEnum('ID', protos, [0], deriving="PartialEq, Copy"), + CGNonNamespacedEnum('Proxies', proxies, [0], deriving="PartialEq, Copy"), ]) diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs index 8079c796094..0b65fabfec0 100644 --- a/components/script/dom/bindings/global.rs +++ b/components/script/dom/bindings/global.rs @@ -26,6 +26,7 @@ use url::Url; use std::ptr; /// A freely-copyable reference to a rooted global object. +#[deriving(Copy)] pub enum GlobalRef<'a> { Window(JSRef<'a, window::Window>), Worker(JSRef<'a, WorkerGlobalScope>), diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index f7208237cc1..a0c099769f0 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -70,6 +70,15 @@ pub struct Temporary<T> { _js_ptr: *mut JSObject, } +impl<T> Clone for Temporary<T> { + fn clone(&self) -> Temporary<T> { + Temporary { + inner: self.inner, + _js_ptr: self._js_ptr, + } + } +} + impl<T> PartialEq for Temporary<T> { fn eq(&self, other: &Temporary<T>) -> bool { self.inner == other.inner @@ -92,10 +101,12 @@ impl<T: Reflectable> Temporary<T> { /// Create a stack-bounded root for this value. pub fn root(self) -> Root<T> { - let collection = StackRoots.get().unwrap(); - unsafe { - Root::new(&**collection, &self.inner) - } + StackRoots.with(|ref collection| { + let RootCollectionPtr(collection) = collection.get().unwrap(); + unsafe { + Root::new(&*collection, &self.inner) + } + }) } unsafe fn inner(&self) -> JS<T> { @@ -114,6 +125,8 @@ pub struct JS<T> { ptr: *const T } +impl<T> Copy for JS<T> {} + impl<T> PartialEq for JS<T> { #[allow(unrooted_must_root)] fn eq(&self, other: &JS<T>) -> bool { @@ -151,10 +164,12 @@ impl<T: Reflectable> JS<T> { /// Root this JS-owned value to prevent its collection as garbage. pub fn root(&self) -> Root<T> { - let collection = StackRoots.get().unwrap(); - unsafe { - Root::new(&**collection, self) - } + StackRoots.with(|ref collection| { + let RootCollectionPtr(collection) = collection.get().unwrap(); + unsafe { + Root::new(&*collection, self) + } + }) } } @@ -270,7 +285,7 @@ impl<T: Reflectable> MutNullableJS<T> { Some(inner) => inner, None => { let inner = cb(); - self.assign(Some(inner)); + self.assign(Some(inner.clone())); inner }, } @@ -450,6 +465,10 @@ pub struct RootCollection { roots: UnsafeCell<SmallVec16<*mut JSObject>>, } +pub struct RootCollectionPtr(pub *const RootCollection); + +impl Copy for RootCollectionPtr {} + impl RootCollection { /// Create an empty collection of roots pub fn new() -> RootCollection { @@ -548,6 +567,8 @@ pub struct JSRef<'a, T> { chain: ContravariantLifetime<'a>, } +impl<'a, T> Copy for JSRef<'a, T> {} + impl<'a, T> Clone for JSRef<'a, T> { fn clone(&self) -> JSRef<'a, T> { JSRef { diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index 7bffda2153d..1f6149394f2 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -33,9 +33,11 @@ use js::jsapi::{JS_AddObjectRoot, JS_RemoveObjectRoot, JSContext}; use libc; use std::cell::RefCell; use std::collections::hash_map::{HashMap, Vacant, Occupied}; +use std::rc::Rc; use std::sync::{Arc, Mutex}; -local_data_key!(pub LiveReferences: LiveDOMReferences) +thread_local!(pub static LiveReferences: Rc<RefCell<Option<LiveDOMReferences>>> = Rc::new(RefCell::new(None))) + /// A safe wrapper around a raw pointer to a DOM object that can be /// shared among tasks for use in asynchronous operations. The underlying @@ -55,24 +57,28 @@ impl<T: Reflectable> Trusted<T> { /// be prevented from being GCed for the duration of the resulting `Trusted<T>` object's /// lifetime. pub fn new(cx: *mut JSContext, ptr: JSRef<T>, script_chan: Box<ScriptChan + Send>) -> Trusted<T> { - let live_references = LiveReferences.get().unwrap(); - let refcount = live_references.addref(cx, &*ptr as *const T); - Trusted { - ptr: &*ptr as *const T as *const libc::c_void, - refcount: refcount, - script_chan: script_chan, - owner_thread: (&*live_references) as *const _ as *const libc::c_void, - } + LiveReferences.with(|ref r| { + let r = r.borrow(); + let live_references = r.as_ref().unwrap(); + let refcount = live_references.addref(cx, &*ptr as *const T); + Trusted { + ptr: &*ptr as *const T as *const libc::c_void, + refcount: refcount, + script_chan: script_chan.clone(), + owner_thread: (&*live_references) as *const _ as *const libc::c_void, + } + }) } /// Obtain a usable DOM pointer from a pinned `Trusted<T>` value. Fails if used on /// a different thread than the original value from which this `Trusted<T>` was /// obtained. pub fn to_temporary(&self) -> Temporary<T> { - assert!({ - let live_references = LiveReferences.get().unwrap(); + assert!(LiveReferences.with(|ref r| { + let r = r.borrow(); + let live_references = r.as_ref().unwrap(); self.owner_thread == (&*live_references) as *const _ as *const libc::c_void - }); + })); unsafe { Temporary::new(JS::from_raw(self.ptr as *const T)) } @@ -117,9 +123,11 @@ pub struct LiveDOMReferences { impl LiveDOMReferences { /// Set up the task-local data required for storing the outstanding DOM references. pub fn initialize() { - LiveReferences.replace(Some(LiveDOMReferences { - table: RefCell::new(HashMap::new()), - })); + LiveReferences.with(|ref r| { + *r.borrow_mut() = Some(LiveDOMReferences { + table: RefCell::new(HashMap::new()), + }) + }); } fn addref<T: Reflectable>(&self, cx: *mut JSContext, ptr: *const T) -> Arc<Mutex<uint>> { @@ -144,30 +152,33 @@ impl LiveDOMReferences { /// Unpin the given DOM object if its refcount is 0. pub fn cleanup(cx: *mut JSContext, raw_reflectable: *const libc::c_void) { - let live_references = LiveReferences.get().unwrap(); - let reflectable = raw_reflectable as *const Reflector; - let mut table = live_references.table.borrow_mut(); - match table.entry(raw_reflectable) { - Occupied(entry) => { - if *entry.get().lock() != 0 { - // there could have been a new reference taken since - // this message was dispatched. - return; + LiveReferences.with(|ref r| { + let r = r.borrow(); + let live_references = r.as_ref().unwrap(); + let reflectable = raw_reflectable as *const Reflector; + let mut table = live_references.table.borrow_mut(); + match table.entry(raw_reflectable) { + Occupied(entry) => { + if *entry.get().lock() != 0 { + // there could have been a new reference taken since + // this message was dispatched. + return; + } + + unsafe { + JS_RemoveObjectRoot(cx, (*reflectable).rootable()); + } + let _ = entry.take(); } - - unsafe { - JS_RemoveObjectRoot(cx, (*reflectable).rootable()); + Vacant(_) => { + // there could be a cleanup message dispatched, then a new + // pinned reference obtained and released before the message + // is processed, at which point there would be no matching + // hashtable entry. + info!("attempt to cleanup an unrecognized reflector"); } - let _ = entry.take(); - } - Vacant(_) => { - // there could be a cleanup message dispatched, then a new - // pinned reference obtained and released before the message - // is processed, at which point there would be no matching - // hashtable entry. - info!("attempt to cleanup an unrecognized reflector"); } - } + }) } } diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index ec809144374..6986ddaf344 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -129,6 +129,7 @@ pub struct NativePropertyHooks { } /// The struct that holds inheritance information for DOM object reflectors. +#[deriving(Copy)] pub struct DOMClass { /// A list of interfaces that this object implements, in order of decreasing /// derivedness. @@ -139,6 +140,7 @@ pub struct DOMClass { } /// The JSClass used for DOM object reflectors. +#[deriving(Copy)] pub struct DOMJSClass { /// The actual JSClass. pub base: js::Class, @@ -586,18 +588,18 @@ pub fn xml_name_type(name: &str) -> XMLName { 'A' ... 'Z' | '_' | 'a' ... 'z' | - '\u00C0' ... '\u00D6' | - '\u00D8' ... '\u00F6' | - '\u00F8' ... '\u02FF' | - '\u0370' ... '\u037D' | - '\u037F' ... '\u1FFF' | - '\u200C' ... '\u200D' | - '\u2070' ... '\u218F' | - '\u2C00' ... '\u2FEF' | - '\u3001' ... '\uD7FF' | - '\uF900' ... '\uFDCF' | - '\uFDF0' ... '\uFFFD' | - '\U00010000' ... '\U000EFFFF' => true, + '\u{C0}' ... '\u{D6}' | + '\u{D8}' ... '\u{F6}' | + '\u{F8}' ... '\u{2FF}' | + '\u{370}' ... '\u{37D}' | + '\u{37F}' ... '\u{1FFF}' | + '\u{200C}' ... '\u{200D}' | + '\u{2070}' ... '\u{218F}' | + '\u{2C00}' ... '\u{2FEF}' | + '\u{3001}' ... '\u{D7FF}' | + '\u{F900}' ... '\u{FDCF}' | + '\u{FDF0}' ... '\u{FFFD}' | + '\u{10000}' ... '\u{EFFFF}' => true, _ => false, } } @@ -607,9 +609,9 @@ pub fn xml_name_type(name: &str) -> XMLName { '-' | '.' | '0' ... '9' | - '\u00B7' | - '\u0300' ... '\u036F' | - '\u203F' ... '\u2040' => true, + '\u{B7}' | + '\u{300}' ... '\u{36F}' | + '\u{203F}' ... '\u{2040}' => true, _ => false, } } diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index 1361d388ebe..0af98e21e81 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -12,7 +12,7 @@ use dom::bindings::utils::{Reflector, reflect_dom_object}; use servo_util::str::DOMString; #[repr(uint)] -#[deriving(Show)] +#[deriving(Copy, Show)] #[jstraceable] pub enum DOMErrorName { IndexSizeError = DOMExceptionConstants::INDEX_SIZE_ERR as uint, diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 7730b657215..ec43612be70 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -86,7 +86,7 @@ impl ElementDerived for EventTarget { } } -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[jstraceable] pub enum ElementTypeId { HTMLElement(HTMLElementTypeId), @@ -591,7 +591,7 @@ pub trait AttributeHandlers { impl<'a> AttributeHandlers for JSRef<'a, Element> { fn get_attribute(self, namespace: Namespace, local_name: &Atom) -> Option<Temporary<Attr>> { - self.get_attributes(local_name).iter().map(|attr| attr.root()) + self.get_attributes(local_name).into_iter().map(|attr| attr.root()) .find(|attr| *attr.r().namespace() == namespace) .map(|x| Temporary::from_rooted(x.r())) } @@ -841,9 +841,9 @@ impl<'a> ElementMethods for JSRef<'a, Element> { Some(ref prefix) => { (format!("{}:{}", prefix.as_slice(), - self.local_name.as_slice())).into_maybe_owned() + self.local_name.as_slice())).into_cow() }, - None => self.local_name.as_slice().into_maybe_owned() + None => self.local_name.as_slice().into_cow() }; if self.html_element_in_html_document() { qualified_name.as_slice().to_ascii_upper() @@ -1290,7 +1290,7 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> { }) } fn get_attrs(self, attr: &Atom) -> Vec<&'a str> { - self.get_attributes(attr).iter().map(|attr| attr.root()).map(|attr| { + self.get_attributes(attr).into_iter().map(|attr| attr.root()).map(|attr| { // This transmute is used to cheat the lifetime restriction. unsafe { mem::transmute(attr.r().value().as_slice()) } }).collect() diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index 0bfdb15336d..deba266ee23 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -17,6 +17,7 @@ use std::default::Default; use time; #[jstraceable] +#[deriving(Copy)] pub enum EventPhase { None = EventConstants::NONE as int, Capturing = EventConstants::CAPTURING_PHASE as int, diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 4ea2807b8c7..bc78affcc6c 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -28,14 +28,14 @@ use url::Url; use std::collections::HashMap; -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] pub enum ListenerPhase { Capturing, Bubbling, } -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] pub enum EventTargetTypeId { Node(NodeTypeId), @@ -46,7 +46,7 @@ pub enum EventTargetTypeId { XMLHttpRequestEventTarget(XMLHttpRequestEventTargetTypeId) } -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] pub enum EventListenerType { Additive(EventListener), @@ -62,7 +62,7 @@ impl EventListenerType { } } -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] #[privatize] pub struct EventListenerEntry { diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 2c889dcb1de..472ed51c081 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -119,7 +119,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> { if recreate { let (w, h) = (self.width.get() as i32, self.height.get() as i32); match self.context.get() { - Some(ref context) => context.root().r().recreate(Size2D(w, h)), + Some(context) => context.root().r().recreate(Size2D(w, h)), None => () } } @@ -147,7 +147,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> { if recreate { let (w, h) = (self.width.get() as i32, self.height.get() as i32); match self.context.get() { - Some(ref context) => context.root().r().recreate(Size2D(w, h)), + Some(context) => context.root().r().recreate(Size2D(w, h)), None => () } } diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 0d5f610965c..d60591bb390 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -156,7 +156,7 @@ fn to_snake_case(name: DOMString) -> DOMString { impl<'a> HTMLElementCustomAttributeHelpers for JSRef<'a, HTMLElement> { fn set_custom_attr(self, name: DOMString, value: DOMString) -> ErrorResult { if name.as_slice().chars() - .skip_while(|&ch| ch != '\u002d') + .skip_while(|&ch| ch != '\u{2d}') .nth(1).map_or(false, |ch| ch as u8 - b'a' < 26) { return Err(Syntax); } @@ -204,7 +204,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> { } } -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[jstraceable] pub enum HTMLElementTypeId { HTMLElement, diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 3720e107179..33313116161 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -129,11 +129,13 @@ impl<'a> HTMLFormElementMethods for JSRef<'a, HTMLFormElement> { } } +#[deriving(Copy)] pub enum SubmittedFrom { FromFormSubmitMethod, NotFromFormSubmitMethod } +#[deriving(Copy)] pub enum ResetFrom { FromFormResetMethod, NotFromFormResetMethod @@ -396,18 +398,21 @@ pub struct FormDatum { pub value: DOMString } +#[deriving(Copy)] pub enum FormEncType { TextPlainEncoded, UrlEncoded, FormDataEncoded } +#[deriving(Copy)] pub enum FormMethod { FormGet, FormPost, FormDialog } +#[deriving(Copy)] pub enum FormSubmitter<'a> { FormElement(JSRef<'a, HTMLFormElement>), InputElement(JSRef<'a, HTMLInputElement>) diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index ab50117b776..aeb480bdfbf 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -56,6 +56,7 @@ impl HTMLIFrameElementDerived for EventTarget { #[jstraceable] #[privatize] +#[deriving(Copy)] pub struct IFrameSize { pipeline_id: PipelineId, subpage_id: SubpageId, diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 81302d02c57..85e1a214666 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -45,7 +45,7 @@ const DEFAULT_SUBMIT_VALUE: &'static str = "Submit"; const DEFAULT_RESET_VALUE: &'static str = "Reset"; #[jstraceable] -#[deriving(PartialEq)] +#[deriving(PartialEq, Copy)] #[allow(dead_code)] enum InputType { InputSubmit, diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 9346436eeb7..ea8dcfa4041 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -38,7 +38,7 @@ impl HTMLMediaElement { } } -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[jstraceable] pub enum HTMLMediaElementTypeId { HTMLAudioElement, diff --git a/components/script/dom/htmlserializer.rs b/components/script/dom/htmlserializer.rs index 0ff300f97f1..b4c3662fd30 100644 --- a/components/script/dom/htmlserializer.rs +++ b/components/script/dom/htmlserializer.rs @@ -156,7 +156,7 @@ fn escape(string: &str, attr_mode: bool, html: &mut String) { for c in string.chars() { match c { '&' => html.push_str("&"), - '\u00A0' => html.push_str(" "), + '\u{A0}' => html.push_str(" "), '"' if attr_mode => html.push_str("""), '<' if !attr_mode => html.push_str("<"), '>' if !attr_mode => html.push_str(">"), diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index 15f19561bb6..24450399f77 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -16,7 +16,7 @@ use cssparser::RGBA; use servo_util::str::{mod, DOMString, LengthOrPercentageOrAuto}; use std::cell::Cell; -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[jstraceable] pub enum HTMLTableCellElementTypeId { HTMLTableDataCellElement, diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index a47c7617066..155e3cb0fa8 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -59,7 +59,7 @@ use std::default::Default; use std::iter::{FilterMap, Peekable}; use std::mem; use style::{mod, ComputedValues}; -use sync::Arc; +use std::sync::Arc; use uuid; use string_cache::QualName; @@ -121,6 +121,7 @@ impl NodeDerived for EventTarget { bitflags! { #[doc = "Flags for node items."] #[jstraceable] + #[deriving(Copy)] flags NodeFlags: u16 { #[doc = "Specifies whether this node is in a document."] const IS_IN_DOC = 0x01, @@ -180,6 +181,7 @@ impl Drop for Node { /// suppress observers flag /// http://dom.spec.whatwg.org/#concept-node-insert /// http://dom.spec.whatwg.org/#concept-node-remove +#[deriving(Copy)] enum SuppressObserver { Suppressed, Unsuppressed @@ -252,7 +254,7 @@ impl LayoutDataRef { } /// The different types of nodes. -#[deriving(PartialEq, Show)] +#[deriving(Copy, PartialEq, Show)] #[jstraceable] pub enum NodeTypeId { DocumentType, @@ -1146,7 +1148,7 @@ impl<'a> Iterator<JSRef<'a, Node>> for NodeIterator { } /// Specifies whether children must be recursively cloned or not. -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] pub enum CloneChildrenFlag { CloneChildren, DoNotCloneChildren @@ -2175,7 +2177,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { /// and are also used in the HTML parser interface. #[allow(raw_pointer_deriving)] -#[deriving(Clone, PartialEq, Eq)] +#[deriving(Clone, PartialEq, Eq, Copy)] pub struct TrustedNodeAddress(pub *const c_void); pub fn document_from_node<T: NodeBase+Reflectable>(derived: JSRef<T>) -> Temporary<Document> { @@ -2284,7 +2286,7 @@ impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> { .map_or(false, |attr| test(attr.r().value().as_slice())) }, style::NamespaceConstraint::Any => { - self.as_element().get_attributes(name).iter() + self.as_element().get_attributes(name).into_iter() .map(|attr| attr.root()) .any(|attr| test(attr.r().value().as_slice())) } @@ -2357,7 +2359,7 @@ impl<'a> DisabledStateHelpers for JSRef<'a, Node> { } /// A summary of the changes that happened to a node. -#[deriving(Clone, PartialEq)] +#[deriving(Copy, Clone, PartialEq)] pub enum NodeDamage { /// The node's `style` attribute changed. NodeStyleDamaged, diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index 252d82acbe9..8cae9d08269 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -256,9 +256,9 @@ impl<'a> PrivateTreeWalkerHelpers<'a> for JSRef<'a, TreeWalker> { // "5. If result is FILTER_REJECT or sibling is null, // then set sibling to node's next sibling if type is next, // and node's previous sibling if type is previous." - match (result, sibling_op) { + match (result, &sibling_op) { (Ok(NodeFilterConstants::FILTER_REJECT), _) - | (_, None) => sibling_op = next_sibling(node), + | (_, &None) => sibling_op = next_sibling(node), _ => {} } } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 5f4517aff3f..b237f12593b 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -114,7 +114,7 @@ pub fn base64_btoa(btoa: DOMString) -> Fallible<DOMString> { // "The btoa() method must throw an InvalidCharacterError exception if // the method's first argument contains any character whose code point // is greater than U+00FF." - if input.chars().any(|c: char| c > '\u00FF') { + if input.chars().any(|c: char| c > '\u{FF}') { Err(InvalidCharacter) } else { // "Otherwise, the user agent must convert that argument to a diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 3cec2779de9..592ead2c083 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -30,7 +30,7 @@ use std::default::Default; use std::rc::Rc; use url::{Url, UrlParser}; -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] pub enum WorkerGlobalScopeTypeId { DedicatedGlobalScope, diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 2dc5b91b691..d2721cc7463 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -63,7 +63,7 @@ use dom::bindings::codegen::UnionTypes::StringOrURLSearchParams; use dom::bindings::codegen::UnionTypes::StringOrURLSearchParams::{eString, eURLSearchParams}; pub type SendParam = StringOrURLSearchParams; -#[deriving(PartialEq)] +#[deriving(PartialEq, Copy)] #[jstraceable] enum XMLHttpRequestState { Unsent = 0, @@ -90,7 +90,7 @@ impl Runnable for XHRProgressHandler { } } -#[deriving(PartialEq, Clone)] +#[deriving(PartialEq, Clone, Copy)] #[jstraceable] pub struct GenerationId(uint); @@ -560,10 +560,10 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { let n = "content-type"; match data { Some(eString(_)) => - request_headers.set_raw(n, vec![join_raw("text/plain", params)]), + request_headers.set_raw(n.into_string(), vec![join_raw("text/plain", params)]), Some(eURLSearchParams(_)) => request_headers.set_raw( - n, vec![join_raw("application/x-www-form-urlencoded", params)]), + n.into_string(), vec![join_raw("application/x-www-form-urlencoded", params)]), None => () } } @@ -813,7 +813,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { // Substep 2 status.map(|RawStatus(code, reason)| { self.status.set(code); - *self.status_text.borrow_mut() = ByteString::new(format!("{}", reason).into_bytes()); + *self.status_text.borrow_mut() = ByteString::new(reason.into_bytes()); }); headers.as_ref().map(|h| *self.response_headers.borrow_mut() = h.clone()); diff --git a/components/script/dom/xmlhttprequesteventtarget.rs b/components/script/dom/xmlhttprequesteventtarget.rs index 430dd158371..f596fe8419b 100644 --- a/components/script/dom/xmlhttprequesteventtarget.rs +++ b/components/script/dom/xmlhttprequesteventtarget.rs @@ -9,7 +9,7 @@ use dom::bindings::codegen::InheritTypes::XMLHttpRequestEventTargetDerived; use dom::bindings::js::JSRef; use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId}; -#[deriving(PartialEq)] +#[deriving(Copy, PartialEq)] #[jstraceable] pub enum XMLHttpRequestEventTargetTypeId { XMLHttpRequest, diff --git a/components/script/lib.rs b/components/script/lib.rs index 490acb01c08..e83b120b4eb 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -34,7 +34,6 @@ extern crate "plugins" as servo_plugins; extern crate "net" as servo_net; extern crate "util" as servo_util; extern crate style; -extern crate sync; extern crate "msg" as servo_msg; extern crate url; extern crate uuid; diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs index d8aba1090b0..8b8fc52ca19 100644 --- a/components/script/parse/html.rs +++ b/components/script/parse/html.rs @@ -25,7 +25,7 @@ use servo_net::resource_task::{ProgressMsg, LoadResponse}; use servo_util::task_state; use servo_util::task_state::IN_HTML_PARSER; use std::ascii::AsciiExt; -use std::str::MaybeOwned; +use std::str::CowString; use url::Url; use html5ever::Attribute; use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText, AppendNode, AppendText}; @@ -110,7 +110,7 @@ impl<'a> TreeSink<TrustedNodeAddress> for servohtmlparser::Sink { Ok(()) } - fn parse_error(&mut self, msg: MaybeOwned<'static>) { + fn parse_error(&mut self, msg: CowString<'static>) { debug!("Parse error: {}", msg); } diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 88e6ed860a5..9a38f96ffbb 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -14,7 +14,8 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, EventTargetCast, NodeCas use dom::bindings::conversions::FromJSValConvertible; use dom::bindings::conversions::StringificationBehavior; use dom::bindings::global::GlobalRef; -use dom::bindings::js::{JS, JSRef, RootCollection, Temporary, OptionalRootable}; +use dom::bindings::js::{JS, JSRef, Temporary, OptionalRootable}; +use dom::bindings::js::{RootCollection, RootCollectionPtr}; use dom::bindings::refcounted::LiveDOMReferences; use dom::bindings::trace::JSTraceable; use dom::bindings::utils::{wrap_for_same_compartment, pre_wrap}; @@ -76,6 +77,7 @@ use url::Url; use libc; use libc::size_t; use std::any::{Any, AnyRefExt}; +use std::cell::Cell; use std::comm::{channel, Sender, Receiver, Select}; use std::fmt::{mod, Show}; use std::mem::replace; @@ -83,8 +85,9 @@ use std::rc::Rc; use std::u32; use time::{Tm, strptime}; -local_data_key!(pub StackRoots: *const RootCollection) +thread_local!(pub static StackRoots: Cell<Option<RootCollectionPtr>> = Cell::new(None)) +#[deriving(Copy)] pub enum TimerSource { FromWindow(PipelineId), FromWorker @@ -158,14 +161,16 @@ pub struct StackRootTLS; impl StackRootTLS { pub fn new(roots: &RootCollection) -> StackRootTLS { - StackRoots.replace(Some(roots as *const RootCollection)); + StackRoots.with(|ref r| { + r.set(Some(RootCollectionPtr(roots as *const _))) + }); StackRootTLS } } impl Drop for StackRootTLS { fn drop(&mut self) { - let _ = StackRoots.replace(None); + StackRoots.with(|ref r| r.set(None)); } } diff --git a/components/script/tests.rs b/components/script/tests.rs index e4636c5b5ad..28710e23647 100644 --- a/components/script/tests.rs +++ b/components/script/tests.rs @@ -38,11 +38,11 @@ macro_rules! sizeof_checker ( ) // Update the sizes here -sizeof_checker!(size_event_target, EventTarget, 56) -sizeof_checker!(size_node, Node, 304) -sizeof_checker!(size_element, Element, 448) -sizeof_checker!(size_htmlelement, HTMLElement, 480) -sizeof_checker!(size_div, HTMLDivElement, 480) -sizeof_checker!(size_span, HTMLSpanElement, 480) -sizeof_checker!(size_text, Text, 336) -sizeof_checker!(size_characterdata, CharacterData, 336) +sizeof_checker!(size_event_target, EventTarget, 48) +sizeof_checker!(size_node, Node, 288) +sizeof_checker!(size_element, Element, 432) +sizeof_checker!(size_htmlelement, HTMLElement, 464) +sizeof_checker!(size_div, HTMLDivElement, 464) +sizeof_checker!(size_span, HTMLSpanElement, 464) +sizeof_checker!(size_text, Text, 320) +sizeof_checker!(size_characterdata, CharacterData, 320) diff --git a/components/script/textinput.rs b/components/script/textinput.rs index a80a9915557..066dbd10e39 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -14,6 +14,7 @@ use std::default::Default; use std::num::SignedInt; #[jstraceable] +#[deriving(Copy)] struct TextPoint { /// 0-based line number line: uint, diff --git a/components/script/timers.rs b/components/script/timers.rs index 0502bdfcd38..f449fa81507 100644 --- a/components/script/timers.rs +++ b/components/script/timers.rs @@ -25,6 +25,7 @@ use std::time::duration::Duration; #[deriving(PartialEq, Eq)] #[jstraceable] +#[deriving(Copy)] pub struct TimerId(i32); #[jstraceable] @@ -67,7 +68,7 @@ impl Drop for TimerManager { // Enum allowing more descriptive values for the is_interval field #[jstraceable] -#[deriving(PartialEq, Clone)] +#[deriving(PartialEq, Copy, Clone)] pub enum IsInterval { Interval, NonInterval, diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index c9e98390961..9e9c8231efd 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -11,14 +11,14 @@ dependencies = [ "net 0.0.1", "script 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "android_glue" version = "0.0.1" -source = "git+https://github.com/servo/android-rs-glue?ref=servo#de9f604bfc71e07f4e968d5dd393de5442dbb2c8" +source = "git+https://github.com/servo/android-rs-glue?ref=servo#122bc28545b5e59a923c466a484c403fa691bd55" dependencies = [ "compile_msg 0.1.1 (git+https://github.com/huonw/compile_msg)", ] @@ -26,7 +26,7 @@ dependencies = [ [[package]] name = "azure" version = "0.1.0" -source = "git+https://github.com/servo/rust-azure#fe95551ca22f2a75b0dd690a72841df39b33885d" +source = "git+https://github.com/servo/rust-azure#6884d442052becfcafccc82b17ab316c7831d8d2" dependencies = [ "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)", @@ -85,24 +85,24 @@ dependencies = [ "png 0.1.0 (git+https://github.com/servo/rust-png)", "script_traits 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "cookie" -version = "0.0.1" -source = "git+https://github.com/servo/cookie-rs#f82090b19c2738b90528167ef873d8eac0353294" +version = "0.1.0" +source = "git+https://github.com/alexcrichton/cookie-rs#8d1b4bb8d5ed06e58c162eb235a4ccd210b68108" dependencies = [ - "openssl 0.0.2 (git+https://github.com/servo/rust-openssl)", + "openssl 0.2.4 (git+https://github.com/sfackler/rust-openssl)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", ] [[package]] name = "core_foundation" version = "0.1.0" -source = "git+https://github.com/servo/rust-core-foundation#d2dbe4fb6f6892521a37735cd7a97098d1b64808" +source = "git+https://github.com/servo/rust-core-foundation#81db9ab15f67e16d7a3e9705a06cad65192014fd" [[package]] name = "core_graphics" @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "core_text" version = "0.1.0" -source = "git+https://github.com/servo/rust-core-text#85784007b6fa1b8f9614059edcd0429b2bd69a11" +source = "git+https://github.com/servo/rust-core-text#cb369a26a0eb4e83c2128ceb3c685a191113417a" dependencies = [ "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)", @@ -123,11 +123,11 @@ dependencies = [ [[package]] name = "cssparser" -version = "0.1.0" -source = "git+https://github.com/servo/rust-cssparser#a2b0b6b00ad84dc3a4b4faf77ddd63611c8ce58a" +version = "0.1.1" +source = "git+https://github.com/servo/rust-cssparser#110bf3052d016bf6eda0689fb21cf971e2c23dc8" dependencies = [ - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", - "text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "text_writer 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -153,60 +153,60 @@ source = "git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c [[package]] name = "encoding" -version = "0.2.3" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding-index-japanese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-korean 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-simpchinese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-singlebyte 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-tradchinese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding-index-japanese 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-korean 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-simpchinese 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-singlebyte 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-tradchinese 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-japanese" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-korean" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-simpchinese" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-singlebyte" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-tradchinese" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding_index_tests" version = "0.1.0" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "expat-sys" @@ -246,9 +246,14 @@ version = "0.0.2" source = "git+https://github.com/alexcrichton/gcc-rs#903e8f8a2e3766ad3d514404d452dbaa1d3b2d79" [[package]] +name = "gcc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "geom" version = "0.1.0" -source = "git+https://github.com/servo/rust-geom#0f77c6ad116748b7e6bedbf2414d4ceea17debc2" +source = "git+https://github.com/servo/rust-geom#05f2d5494355adc78ad7d17286912f0d128f503b" [[package]] name = "gfx" @@ -271,23 +276,23 @@ dependencies = [ "stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)", "style 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "gl_common" version = "0.0.1" -source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb726f242d" +source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa4f67c6e" [[package]] name = "gl_generator" version = "0.0.1" -source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb726f242d" +source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa4f67c6e" dependencies = [ "gl_common 0.0.1 (git+https://github.com/bjz/gl-rs.git)", "khronos_api 0.0.2 (git+https://github.com/bjz/gl-rs.git)", - "rust-xml 0.1.2-pre (git+https://github.com/netvl/rust-xml)", + "xml-rs 0.1.3 (git+https://github.com/netvl/xml-rs)", ] [[package]] @@ -301,10 +306,10 @@ dependencies = [ [[package]] name = "glfw" version = "0.0.1" -source = "git+https://github.com/servo/glfw-rs?ref=servo#1b05fdc7eab45e1d462758ab991065ee78593b7f" +source = "git+https://github.com/servo/glfw-rs?ref=servo#b186cb444e349a36b992445dc5cb2c99d38f2a42" dependencies = [ "glfw-sys 3.0.4 (git+https://github.com/servo/glfw?ref=cargo-3.0.4)", - "semver 0.1.3 (git+https://github.com/rust-lang/semver)", + "semver 0.1.4 (git+https://github.com/rust-lang/semver)", ] [[package]] @@ -371,11 +376,11 @@ source = "git+https://github.com/servo/rust-harfbuzz#8aab215463214647b7a81f66011 [[package]] name = "html5ever" version = "0.0.0" -source = "git+https://github.com/servo/html5ever#e6f8d83de9fffe63a825d95d957ba6bcbc3e1632" +source = "git+https://github.com/servo/html5ever#0abe5e30cc03f9e73bfd4fdc018192d149c21fb3" dependencies = [ "html5ever_macros 0.0.0 (git+https://github.com/servo/html5ever)", - "phf 0.0.0 (git+https://github.com/sfackler/rust-phf)", - "phf_mac 0.0.0 (git+https://github.com/sfackler/rust-phf)", + "phf 0.0.1 (git+https://github.com/sfackler/rust-phf)", + "phf_mac 0.0.1 (git+https://github.com/sfackler/rust-phf)", "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "time 0.1.0 (git+https://github.com/rust-lang/time)", @@ -384,19 +389,20 @@ dependencies = [ [[package]] name = "html5ever_macros" version = "0.0.0" -source = "git+https://github.com/servo/html5ever#e6f8d83de9fffe63a825d95d957ba6bcbc3e1632" +source = "git+https://github.com/servo/html5ever#0abe5e30cc03f9e73bfd4fdc018192d149c21fb3" [[package]] name = "hyper" version = "0.0.1" -source = "git+https://github.com/servo/hyper?ref=servo#4a2c82c75013f8ee55d2017876319b48d656dcb3" +source = "git+https://github.com/servo/hyper?ref=servo#43becc919c24939b8b84fe541b0e0898a4827836" dependencies = [ - "cookie 0.0.1 (git+https://github.com/servo/cookie-rs)", + "cookie 0.1.0 (git+https://github.com/alexcrichton/cookie-rs)", "mime 0.0.1 (git+https://github.com/hyperium/mime.rs)", - "openssl 0.0.2 (git+https://github.com/servo/rust-openssl)", + "mucell 0.1.2 (git+https://github.com/chris-morgan/mucell)", + "openssl 0.2.4 (git+https://github.com/sfackler/rust-openssl)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "unsafe-any 0.1.0 (git+https://github.com/reem/rust-unsafe-any)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "unsafe-any 0.1.1 (git+https://github.com/reem/rust-unsafe-any)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", ] [[package]] @@ -413,7 +419,7 @@ dependencies = [ [[package]] name = "js" version = "0.1.0" -source = "git+https://github.com/servo/rust-mozjs#2d86d6fb7ece49ff2f469c391e15e13f2b02af42" +source = "git+https://github.com/servo/rust-mozjs#e01a846241bd98ac424878e3f8d3e9b989c79242" dependencies = [ "mozjs-sys 0.0.0 (git+https://github.com/servo/mozjs)", ] @@ -421,12 +427,12 @@ dependencies = [ [[package]] name = "khronos_api" version = "0.0.2" -source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb726f242d" +source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa4f67c6e" [[package]] name = "layers" version = "0.1.0" -source = "git+https://github.com/servo/rust-layers#21798aac4de6bfd800836f419dd5b6a308edcaa4" +source = "git+https://github.com/servo/rust-layers#574df7e1c1dd464af930d1cc735ca8d6af46bb90" dependencies = [ "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", @@ -442,8 +448,8 @@ dependencies = [ name = "layout" version = "0.0.1" dependencies = [ - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "gfx 0.0.1", "layout_traits 0.0.1", @@ -454,7 +460,7 @@ dependencies = [ "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "style 0.0.1", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] @@ -472,7 +478,7 @@ dependencies = [ [[package]] name = "lazy_static" version = "0.1.0" -source = "git+https://github.com/Kimundi/lazy-static.rs#62976cb611c5396e11315ae64c9c389576240eb7" +source = "git+https://github.com/Kimundi/lazy-static.rs#76f06e4fa7bc8c92f11d1def19bd4ddfd8017cd8" [[package]] name = "libressl-pnacl-sys" @@ -503,11 +509,16 @@ dependencies = [ "io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "style 0.0.1", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] +name = "mucell" +version = "0.1.2" +source = "git+https://github.com/chris-morgan/mucell#d198c6605b3e688719db168db0939051c803b1ea" + +[[package]] name = "net" version = "0.0.1" dependencies = [ @@ -516,42 +527,42 @@ dependencies = [ "png 0.1.0 (git+https://github.com/servo/rust-png)", "stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "openssl" -version = "0.0.2" -source = "git+https://github.com/servo/rust-openssl#aed5df1036d6f4b5f7b8be6457d10f8a0379b39f" +version = "0.2.4" +source = "git+https://github.com/sfackler/rust-openssl#f299e336d06a85438c3ee90aa06235510f3f5dbe" dependencies = [ - "libressl-pnacl-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.0.2 (git+https://github.com/servo/rust-openssl)", + "openssl-sys 0.2.4 (git+https://github.com/sfackler/rust-openssl)", ] [[package]] name = "openssl-sys" -version = "0.0.2" -source = "git+https://github.com/servo/rust-openssl#aed5df1036d6f4b5f7b8be6457d10f8a0379b39f" +version = "0.2.4" +source = "git+https://github.com/sfackler/rust-openssl#f299e336d06a85438c3ee90aa06235510f3f5dbe" dependencies = [ + "libressl-pnacl-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "phf" -version = "0.0.0" -source = "git+https://github.com/sfackler/rust-phf#aa3e2d0aedea4d55c2e4cea1bdf6e89418dc1206" +version = "0.0.1" +source = "git+https://github.com/sfackler/rust-phf#6a7cc6eb9ec08b103b6b62fa39bdb3229f3cdbe4" dependencies = [ - "xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)", + "xxhash 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "phf_mac" -version = "0.0.0" -source = "git+https://github.com/sfackler/rust-phf#aa3e2d0aedea4d55c2e4cea1bdf6e89418dc1206" +version = "0.0.1" +source = "git+https://github.com/sfackler/rust-phf#6a7cc6eb9ec08b103b6b62fa39bdb3229f3cdbe4" dependencies = [ - "time 0.1.0 (git+https://github.com/rust-lang/time)", - "xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)", + "time 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "xxhash 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -582,18 +593,13 @@ version = "1.6.3" source = "git+https://github.com/servo/libpng?ref=servo#d01f32b4eb86904695efe7fc02b574f902e21a98" [[package]] -name = "rust-xml" -version = "0.1.2-pre" -source = "git+https://github.com/netvl/rust-xml#2d9df3267aeaa4d442e1e19a4dfed733cb1397ed" - -[[package]] name = "script" version = "0.0.1" dependencies = [ "canvas 0.0.1", - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", "devtools_traits 0.0.1", - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "gfx 0.0.1", "html5ever 0.0.0 (git+https://github.com/servo/html5ever)", @@ -607,9 +613,9 @@ dependencies = [ "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "style 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", - "uuid 0.0.2 (git+https://github.com/rust-lang/uuid)", + "uuid 0.1.1 (git+https://github.com/rust-lang/uuid)", ] [[package]] @@ -620,14 +626,14 @@ dependencies = [ "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "msg 0.0.1", "net 0.0.1", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "semver" -version = "0.1.3" -source = "git+https://github.com/rust-lang/semver#29212953f839337c672d185dde74e14b5dfb1f46" +version = "0.1.4" +source = "git+https://github.com/rust-lang/semver#58dc6b1999d345ca925a2f12a6a84676e823e179" [[package]] name = "skia-sys" @@ -646,19 +652,19 @@ source = "git+https://github.com/servo/rust-stb-image#97d7e440e80e41a304647363c3 [[package]] name = "string_cache" version = "0.0.0" -source = "git+https://github.com/servo/string-cache#a18a432fd274e816fc41876536f70e5380abb677" +source = "git+https://github.com/servo/string-cache#661c537b85f19ac81dfcd84e28557d480b6b7a9f" dependencies = [ "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)", - "phf 0.0.0 (git+https://github.com/sfackler/rust-phf)", - "phf_mac 0.0.0 (git+https://github.com/sfackler/rust-phf)", + "phf 0.0.1 (git+https://github.com/sfackler/rust-phf)", + "phf_mac 0.0.1 (git+https://github.com/sfackler/rust-phf)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", - "xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)", + "xxhash 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "string_cache_macros" version = "0.0.0" -source = "git+https://github.com/servo/string-cache#a18a432fd274e816fc41876536f70e5380abb677" +source = "git+https://github.com/servo/string-cache#661c537b85f19ac81dfcd84e28557d480b6b7a9f" dependencies = [ "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)", ] @@ -667,15 +673,15 @@ dependencies = [ name = "style" version = "0.0.1" dependencies = [ - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)", "plugins 0.0.1", "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", - "text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "text_writer 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] @@ -685,7 +691,7 @@ version = "0.0.1" [[package]] name = "text_writer" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -697,35 +703,43 @@ dependencies = [ ] [[package]] +name = "time" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "unsafe-any" -version = "0.1.0" -source = "git+https://github.com/reem/rust-unsafe-any#2863af363bbd83079b6773920bba5b736408db33" +version = "0.1.1" +source = "git+https://github.com/reem/rust-unsafe-any#eb3fe87bea85f375b8fcefa0cdecfd131fae9624" [[package]] name = "url" -version = "0.1.0" -source = "git+https://github.com/servo/rust-url#46458f80e48c542b2f175e36e5b7d30782ca7dc5" +version = "0.2.4" +source = "git+https://github.com/servo/rust-url#79f8034a8e1815ffa1f49204572ddbf6eb747c75" [[package]] name = "util" version = "0.0.1" dependencies = [ - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "plugins 0.0.1", "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "task_info 0.0.1", - "text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "text_writer 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", ] [[package]] name = "uuid" -version = "0.0.2" -source = "git+https://github.com/rust-lang/uuid#f5d94d0043a615756edefaf9c6041f11e52b8370" +version = "0.1.1" +source = "git+https://github.com/rust-lang/uuid#fc793c974a25c126c5cf5daa3b18973512a7a6a0" [[package]] name = "winapi" @@ -738,7 +752,12 @@ version = "0.1.0" source = "git+https://github.com/servo/rust-xlib#58ec3847b592aeabdcfeb6a2d02033d3a2c7f427" [[package]] +name = "xml-rs" +version = "0.1.3" +source = "git+https://github.com/netvl/xml-rs#1a812d3ba720afd768bd75d29a5b5f10ddcdfbeb" + +[[package]] name = "xxhash" -version = "0.0.1" -source = "git+https://github.com/Jurily/rust-xxhash#64f8d02314735f511cb4272563d0f703d575c159" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 8d64a1d73bc..ff3a6b9e626 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -111,7 +111,7 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static { storage_task); // Send the URL command to the constellation. - let cwd = os::getcwd(); + let cwd = os::getcwd().unwrap(); for url in opts.urls.iter() { let url = match url::Url::parse(url.as_slice()) { Ok(url) => url, diff --git a/components/servo/main.rs b/components/servo/main.rs index be8dc7e7f03..235b455ab32 100644 --- a/components/servo/main.rs +++ b/components/servo/main.rs @@ -32,8 +32,9 @@ use libc::c_int; #[cfg(not(test))] use servo_util::opts; -#[cfg(not(test))] -use servo_util::rtinstrument; +// FIXME: Find replacement for this post-runtime removal +//#[cfg(not(test))] +//use servo_util::rtinstrument; #[cfg(not(test))] use servo::Browser; @@ -158,7 +159,7 @@ fn main() { } = browser; browser.shutdown(); - rtinstrument::teardown(); + //rtinstrument::teardown(); } } diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index db2cbe9ffc4..ec0a3fcc2bb 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -24,9 +24,6 @@ git = "https://github.com/servo/rust-url" [dependencies.cssparser] git = "https://github.com/servo/rust-cssparser" -[dependencies.encoding] -git = "https://github.com/lifthrasiir/rust-encoding" - [dependencies.lazy_static] git = "https://github.com/Kimundi/lazy-static.rs" @@ -38,3 +35,4 @@ git = "https://github.com/servo/string-cache" [dependencies] text_writer = "0.1.1" +encoding = "0.2" diff --git a/components/style/legacy.rs b/components/style/legacy.rs index e668b1203ad..19381ebf2e7 100644 --- a/components/style/legacy.rs +++ b/components/style/legacy.rs @@ -18,12 +18,14 @@ use servo_util::smallvec::VecLike; use servo_util::str::LengthOrPercentageOrAuto; /// Legacy presentational attributes that take a length as defined in HTML5 § 2.4.4.4. +#[deriving(Copy, PartialEq, Eq)] pub enum LengthAttribute { /// `<td width>` Width, } /// Legacy presentational attributes that take an integer as defined in HTML5 § 2.4.4.2. +#[deriving(Copy, PartialEq, Eq)] pub enum IntegerAttribute { /// `<input size>` Size, @@ -32,6 +34,7 @@ pub enum IntegerAttribute { } /// Legacy presentational attributes that take a nonnegative integer as defined in HTML5 § 2.4.4.2. +#[deriving(Copy, PartialEq, Eq)] pub enum UnsignedIntegerAttribute { /// `<td border>` Border, @@ -40,6 +43,7 @@ pub enum UnsignedIntegerAttribute { } /// Legacy presentational attributes that take a simple color as defined in HTML5 § 2.4.6. +#[deriving(Copy, PartialEq, Eq)] pub enum SimpleColorAttribute { /// `<body bgcolor>` BgColor, diff --git a/components/style/lib.rs b/components/style/lib.rs index 4c8efd3a3aa..cddd491161e 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -14,7 +14,6 @@ extern crate collections; extern crate geom; extern crate serialize; -extern crate sync; extern crate text_writer; extern crate url; diff --git a/components/style/media_queries.rs b/components/style/media_queries.rs index 60a6ed5fc59..cf9facf8dcf 100644 --- a/components/style/media_queries.rs +++ b/components/style/media_queries.rs @@ -27,6 +27,7 @@ pub struct MediaQueryList { media_queries: Vec<MediaQuery> } +#[deriving(PartialEq, Eq, Copy)] pub enum Range<T> { Min(T), Max(T), @@ -43,11 +44,12 @@ impl<T: Ord> Range<T> { } } +#[deriving(PartialEq, Eq, Copy)] pub enum Expression { Width(Range<Au>), } -#[deriving(PartialEq)] +#[deriving(PartialEq, Eq, Copy)] pub enum Qualifier { Only, Not, @@ -70,13 +72,13 @@ impl MediaQuery { } } -#[deriving(PartialEq)] +#[deriving(PartialEq, Eq, Copy)] pub enum MediaQueryType { All, // Always true MediaType(MediaType), } -#[deriving(PartialEq)] +#[deriving(PartialEq, Eq, Copy)] pub enum MediaType { Screen, Print, diff --git a/components/style/properties/common_types.rs b/components/style/properties/common_types.rs index 5a5f1a95f20..723cf36a73f 100644 --- a/components/style/properties/common_types.rs +++ b/components/style/properties/common_types.rs @@ -16,7 +16,7 @@ macro_rules! define_css_keyword_enum { }; ($name: ident: $( $css: expr => $variant: ident ),+) => { #[allow(non_camel_case_types)] - #[deriving(Clone, Eq, PartialEq, FromPrimitive)] + #[deriving(Clone, Eq, PartialEq, FromPrimitive, Copy)] pub enum $name { $( $variant ),+ } @@ -138,7 +138,7 @@ pub mod specified { } } - #[deriving(Clone, PartialEq)] + #[deriving(Clone, PartialEq, Copy)] pub enum Length { Au(Au), // application units Em(CSSFloat), @@ -219,7 +219,7 @@ pub mod specified { } } - #[deriving(Clone, PartialEq)] + #[deriving(Clone, PartialEq, Copy)] pub enum LengthOrPercentage { Length(Length), Percentage(CSSFloat), // [0 .. 100%] maps to [0.0 .. 1.0] @@ -263,7 +263,7 @@ pub mod specified { } } - #[deriving(Clone)] + #[deriving(Clone, PartialEq, Copy)] pub enum LengthOrPercentageOrAuto { Length(Length), Percentage(CSSFloat), // [0 .. 100%] maps to [0.0 .. 1.0] @@ -309,7 +309,7 @@ pub mod specified { } } - #[deriving(Clone)] + #[deriving(Clone, PartialEq, Copy)] pub enum LengthOrPercentageOrNone { Length(Length), Percentage(CSSFloat), // [0 .. 100%] maps to [0.0 .. 1.0] @@ -355,7 +355,7 @@ pub mod specified { } // http://dev.w3.org/csswg/css2/colors.html#propdef-background-position - #[deriving(Clone)] + #[deriving(Clone, PartialEq, Copy)] pub enum PositionComponent { Length(Length), Percentage(CSSFloat), // [0 .. 100%] maps to [0.0 .. 1.0] @@ -395,7 +395,7 @@ pub mod specified { } } - #[deriving(Clone, PartialEq, PartialOrd)] + #[deriving(Clone, PartialEq, PartialOrd, Copy)] pub struct Angle(pub CSSFloat); impl fmt::Show for Angle { @@ -452,7 +452,7 @@ pub mod specified { match self { &Image::Url(ref url) => { try!(dest.write_str("url(\"")); - try!(write!(CssStringWriter::new(dest), "{}", url)); + try!(write!(&mut CssStringWriter::new(dest), "{}", url)); try!(dest.write_str("\")")); Ok(()) } @@ -522,7 +522,7 @@ pub mod specified { } /// Specified values for an angle or a corner in a linear gradient. - #[deriving(Clone, PartialEq)] + #[deriving(Clone, PartialEq, Copy)] pub enum AngleOrCorner { Angle(Angle), Corner(HorizontalDirection, VerticalDirection), @@ -718,6 +718,7 @@ pub mod computed { use std::fmt; use url::Url; + #[allow(missing_copy_implementations)] // It’s kinda big pub struct Context { pub inherited_font_weight: longhands::font_weight::computed_value::T, pub inherited_font_size: longhands::font_size::computed_value::T, @@ -774,7 +775,7 @@ pub mod computed { } } - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Clone, Copy)] pub enum LengthOrPercentage { Length(Au), Percentage(CSSFloat), @@ -799,7 +800,7 @@ pub mod computed { } } - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Clone, Copy)] pub enum LengthOrPercentageOrAuto { Length(Au), Percentage(CSSFloat), @@ -827,7 +828,7 @@ pub mod computed { } } - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Clone, Copy)] pub enum LengthOrPercentageOrNone { Length(Au), Percentage(CSSFloat), @@ -892,7 +893,7 @@ pub mod computed { } /// Computed values for one color stop in a linear gradient. - #[deriving(Clone, PartialEq)] + #[deriving(Clone, PartialEq, Copy)] pub struct ColorStop { /// The color of this stop. pub color: CSSColor, diff --git a/components/style/properties/mod.rs.mako b/components/style/properties/mod.rs.mako index 47db730d0f1..18c947f3dff 100644 --- a/components/style/properties/mod.rs.mako +++ b/components/style/properties/mod.rs.mako @@ -7,9 +7,9 @@ pub use std::ascii::AsciiExt; use std::fmt; use std::fmt::Show; +use std::sync::Arc; use servo_util::logical_geometry::{WritingMode, LogicalMargin}; -use sync::Arc; pub use url::Url; pub use cssparser::*; @@ -279,7 +279,7 @@ pub mod longhands { % endfor <%self:longhand name="border-top-left-radius"> - #[deriving(Clone, Show)] + #[deriving(Clone, Show, PartialEq, Copy)] pub struct SpecifiedValue { pub radius: specified::LengthOrPercentage, } @@ -287,7 +287,7 @@ pub mod longhands { pub mod computed_value { use super::super::computed; - #[deriving(Clone, PartialEq, Show)] + #[deriving(Clone, PartialEq, Copy, Show)] pub struct T { pub radius: computed::LengthOrPercentage, } @@ -451,7 +451,7 @@ pub mod longhands { pub mod computed_value { use std::fmt; - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Clone, Eq, Copy)] pub enum T { Auto, Number(i32), @@ -543,7 +543,7 @@ pub mod longhands { <%self:single_component_value name="line-height"> use std::fmt; - #[deriving(Clone)] + #[deriving(Clone, PartialEq, Copy)] pub enum SpecifiedValue { Normal, Length(specified::Length), @@ -579,7 +579,7 @@ pub mod longhands { pub mod computed_value { use super::super::{Au, CSSFloat}; use std::fmt; - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Copy, Clone)] pub enum T { Normal, Length(Au), @@ -616,7 +616,7 @@ pub mod longhands { <% vertical_align_keywords = ( "baseline sub super top text-top middle bottom text-bottom".split()) %> #[allow(non_camel_case_types)] - #[deriving(Clone)] + #[deriving(Clone, PartialEq, Copy)] pub enum SpecifiedValue { % for keyword in vertical_align_keywords: ${to_rust_ident(keyword)}, @@ -654,7 +654,7 @@ pub mod longhands { use super::super::{Au, CSSFloat}; use std::fmt; #[allow(non_camel_case_types)] - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Copy, Clone)] pub enum T { % for keyword in vertical_align_keywords: ${to_rust_ident(keyword)}, @@ -710,7 +710,7 @@ pub mod longhands { pub use super::computed_as_specified as to_computed_value; pub mod computed_value { use std::fmt; - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Eq, Clone)] pub enum ContentItem { StringContent(String), } @@ -722,7 +722,7 @@ pub mod longhands { } } #[allow(non_camel_case_types)] - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Eq, Clone)] pub enum T { normal, none, @@ -859,7 +859,7 @@ pub mod longhands { use super::super::super::common_types::computed::LengthOrPercentage; use std::fmt; - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Copy, Clone)] pub struct T { pub horizontal: LengthOrPercentage, pub vertical: LengthOrPercentage, @@ -871,7 +871,7 @@ pub mod longhands { } } - #[deriving(Clone)] + #[deriving(Clone, PartialEq, Copy)] pub struct SpecifiedValue { pub horizontal: specified::LengthOrPercentage, pub vertical: specified::LengthOrPercentage, @@ -1023,7 +1023,7 @@ pub mod longhands { pub use super::computed_as_specified as to_computed_value; pub mod computed_value { use std::fmt; - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Eq, Clone)] pub enum FontFamily { FamilyName(String), // Generic @@ -1110,7 +1110,7 @@ pub mod longhands { <%self:single_component_value name="font-weight"> use std::fmt; - #[deriving(Clone)] + #[deriving(Clone, PartialEq, Eq, Copy)] pub enum SpecifiedValue { Bolder, Lighter, @@ -1159,7 +1159,7 @@ pub mod longhands { } pub mod computed_value { use std::fmt; - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Eq, Copy, Clone)] pub enum T { % for weight in range(100, 901, 100): Weight${weight}, @@ -1327,7 +1327,7 @@ pub mod longhands { <%self:longhand name="text-decoration"> pub use super::computed_as_specified as to_computed_value; use std::fmt; - #[deriving(PartialEq, Clone)] + #[deriving(PartialEq, Eq, Copy, Clone)] pub struct SpecifiedValue { pub underline: bool, pub overline: bool, @@ -1404,7 +1404,7 @@ pub mod longhands { derived_from="display text-decoration"> pub use super::computed_as_specified as to_computed_value; - #[deriving(Clone, PartialEq)] + #[deriving(Clone, PartialEq, Copy)] pub struct SpecifiedValue { pub underline: Option<RGBA>, pub overline: Option<RGBA>, @@ -1516,7 +1516,7 @@ pub mod longhands { pub mod computed_value { use servo_util::cursor::Cursor; - #[deriving(Clone, PartialEq, Show)] + #[deriving(Clone, PartialEq, Eq, Copy, Show)] pub enum T { AutoCursor, SpecifiedCursor(Cursor), @@ -1581,7 +1581,7 @@ pub mod longhands { pub type SpecifiedValue = Vec<SpecifiedBoxShadow>; - #[deriving(Clone)] + #[deriving(Clone, PartialEq)] pub struct SpecifiedBoxShadow { pub offset_x: specified::Length, pub offset_y: specified::Length, @@ -1612,7 +1612,7 @@ pub mod longhands { pub type T = Vec<BoxShadow>; - #[deriving(Clone, PartialEq)] + #[deriving(Clone, PartialEq, Copy)] pub struct BoxShadow { pub offset_x: Au, pub offset_y: Au, @@ -1750,7 +1750,7 @@ pub mod longhands { pub mod computed_value { use super::super::Au; - #[deriving(Clone, PartialEq, Show)] + #[deriving(Clone, PartialEq, Eq, Copy, Show)] pub struct ClipRect { pub top: Au, pub right: Option<Au>, @@ -1761,7 +1761,7 @@ pub mod longhands { pub type T = Option<ClipRect>; } - #[deriving(Clone, Show)] + #[deriving(Clone, Show, PartialEq, Copy)] pub struct SpecifiedClipRect { pub top: specified::Length, pub right: Option<specified::Length>, @@ -2468,7 +2468,7 @@ impl CSSWideKeyword { } -#[deriving(Clone)] +#[deriving(Clone, PartialEq, Eq, Copy)] pub enum DeclaredValue<T> { SpecifiedValue(T), Initial, @@ -2496,6 +2496,7 @@ pub enum PropertyDeclaration { } +#[deriving(Eq, PartialEq, Copy)] pub enum PropertyDeclarationParseResult { UnknownProperty, ExperimentalProperty, @@ -2645,6 +2646,7 @@ pub mod style_structs { use super::longhands; % for style_struct in STYLE_STRUCTS: + #[allow(missing_copy_implementations)] #[deriving(PartialEq, Clone)] pub struct ${style_struct.name} { % for longhand in style_struct.longhands: diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index a5a1f556d16..0870d99711a 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -5,7 +5,7 @@ use std::ascii::AsciiExt; use std::collections::HashMap; use std::hash::Hash; -use sync::Arc; +use std::sync::Arc; use url::Url; @@ -24,7 +24,7 @@ use selectors::{PseudoElement, SelectorList, SimpleSelector}; use selectors::{get_selector_list_selectors}; use stylesheets::{Stylesheet, iter_stylesheet_media_rules, iter_stylesheet_style_rules}; -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Eq, Copy)] pub enum StylesheetOrigin { UserAgent, Author, @@ -624,6 +624,7 @@ fn matches_compound_selector<'a,E,N>(selector: &CompoundSelector, /// However since the selector "c1" raises /// NotMatchedAndRestartFromClosestDescendant. So the selector /// "b1 + c1 > b2 ~ " doesn't match and restart matching from "d1". +#[deriving(PartialEq, Eq, Copy)] enum SelectorMatchingResult { Matched, NotMatchedAndRestartFromClosestLaterSibling, @@ -763,6 +764,7 @@ fn matches_compound_selector_internal<'a,E,N>(selector: &CompoundSelector, } bitflags! { + #[deriving(Copy)] flags CommonStyleAffectingAttributes: u8 { const HIDDEN_ATTRIBUTE = 0x01, const NO_WRAP_ATTRIBUTE = 0x02, @@ -777,6 +779,7 @@ pub struct CommonStyleAffectingAttributeInfo { pub mode: CommonStyleAffectingAttributeMode, } +#[deriving(Copy)] pub enum CommonStyleAffectingAttributeMode { IsPresent(CommonStyleAffectingAttributes), IsEqual(&'static str, CommonStyleAffectingAttributes), @@ -1164,7 +1167,7 @@ impl<K: Eq + Hash, V> FindPush<K, V> for HashMap<K, Vec<V>> { #[cfg(test)] mod tests { - use sync::Arc; + use std::sync::Arc; use super::{DeclarationBlock, Rule, SelectorMap}; use selectors::LocalName; use string_cache::Atom; @@ -1198,7 +1201,7 @@ mod tests { #[test] fn test_rule_ordering_same_specificity(){ - let rules_list = get_mock_rules(["a.intro", "img.sidebar"]); + 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, @@ -1207,21 +1210,21 @@ mod tests { #[test] fn test_get_id_name(){ - let rules_list = get_mock_rules([".intro", "#top"]); + let rules_list = get_mock_rules(&[".intro", "#top"]); assert_eq!(SelectorMap::get_id_name(&rules_list[0][0]), None); assert_eq!(SelectorMap::get_id_name(&rules_list[1][0]), Some(atom!("top"))); } #[test] fn test_get_class_name(){ - let rules_list = get_mock_rules([".intro.foo", "#top"]); + let rules_list = get_mock_rules(&[".intro.foo", "#top"]); assert_eq!(SelectorMap::get_class_name(&rules_list[0][0]), Some(Atom::from_slice("intro"))); assert_eq!(SelectorMap::get_class_name(&rules_list[1][0]), None); } #[test] fn test_get_local_name(){ - let rules_list = get_mock_rules(["img.foo", "#top", "IMG", "ImG"]); + let rules_list = get_mock_rules(&["img.foo", "#top", "IMG", "ImG"]); let check = |i, names: Option<(&str, &str)>| { assert!(SelectorMap::get_local_name(&rules_list[i][0]) == names.map(|(name, lower_name)| LocalName { @@ -1236,7 +1239,7 @@ mod tests { #[test] fn test_insert(){ - let rules_list = get_mock_rules([".intro.foo", "#top"]); + let rules_list = get_mock_rules(&[".intro.foo", "#top"]); let mut selector_map = SelectorMap::new(); selector_map.insert(rules_list[1][0].clone()); assert_eq!(1, selector_map.id_hash.get(&atom!("top")).unwrap()[0].declarations.source_order); diff --git a/components/style/selectors.rs b/components/style/selectors.rs index 5b5833d308d..92570409552 100644 --- a/components/style/selectors.rs +++ b/components/style/selectors.rs @@ -4,7 +4,7 @@ use std::{cmp, iter}; use std::ascii::{AsciiExt, OwnedAsciiExt}; -use sync::Arc; +use std::sync::Arc; use cssparser::ast::*; use cssparser::ast::ComponentValue::*; @@ -16,6 +16,7 @@ use string_cache::{Atom, Namespace}; use namespaces::NamespaceMap; /// Ambient data used by the parser. +#[deriving(Copy)] pub struct ParserContext { /// The origin of this stylesheet. pub origin: StylesheetOrigin, @@ -28,7 +29,7 @@ pub struct Selector { pub specificity: u32, } -#[deriving(Eq, PartialEq, Clone, Hash)] +#[deriving(Eq, PartialEq, Clone, Hash, Copy)] pub enum PseudoElement { Before, After, @@ -43,7 +44,7 @@ pub struct CompoundSelector { pub next: Option<(Box<CompoundSelector>, Combinator)>, // c.next is left of c } -#[deriving(PartialEq, Clone)] +#[deriving(PartialEq, Clone, Copy)] pub enum Combinator { Child, // > Descendant, // space @@ -93,7 +94,7 @@ pub enum SimpleSelector { } -#[deriving(Eq, PartialEq, Clone, Hash)] +#[deriving(Eq, PartialEq, Clone, Hash, Copy)] pub enum CaseSensitivity { CaseSensitive, // Selectors spec says language-defined, but HTML says sensitive. CaseInsensitive, @@ -667,7 +668,7 @@ fn skip_whitespace<I: Iterator<ComponentValue>>(iter: &mut Iter<I>) -> bool { #[cfg(test)] mod tests { - use sync::Arc; + use std::sync::Arc; use cssparser; use namespaces::NamespaceMap; use selector_matching::StylesheetOrigin; diff --git a/components/util/cache.rs b/components/util/cache.rs index 2797bc4e6d6..03bd649f777 100644 --- a/components/util/cache.rs +++ b/components/util/cache.rs @@ -69,14 +69,12 @@ impl<K,V> HashCache<K,V> where K: Clone + PartialEq + Eq + Hash, V: Clone { #[test] fn test_hashcache() { let mut cache: HashCache<uint, Cell<&str>> = HashCache::new(); - let one = Cell::new("one"); - let two = Cell::new("two"); - cache.insert(1, one); + cache.insert(1, Cell::new("one")); assert!(cache.find(&1).is_some()); assert!(cache.find(&2).is_none()); - cache.find_or_create(&2, |_v| { two }); + cache.find_or_create(&2, |_v| { Cell::new("two") }); assert!(cache.find(&1).is_some()); assert!(cache.find(&2).is_some()); } @@ -233,7 +231,7 @@ fn test_lru_cache() { assert!(cache.find(&4).is_some()); // (2, 4) (no change) // Test find_or_create. - cache.find_or_create(&1, |_| { one }); // (4, 1) + cache.find_or_create(&1, |_| { Cell::new("one") }); // (4, 1) assert!(cache.find(&1).is_some()); // (4, 1) (no change) assert!(cache.find(&2).is_none()); // (4, 1) (no change) diff --git a/components/util/cursor.rs b/components/util/cursor.rs index 0a094ce117d..23ca2c0af4a 100644 --- a/components/util/cursor.rs +++ b/components/util/cursor.rs @@ -11,7 +11,7 @@ use text_writer::TextWriter; macro_rules! define_cursor { ($( $css: expr => $variant: ident = $value: expr, )+) => { - #[deriving(Clone, PartialEq, Eq, FromPrimitive, Show)] + #[deriving(Clone, Copy, PartialEq, Eq, FromPrimitive, Show)] #[repr(u8)] pub enum Cursor { $( $variant = $value ),+ diff --git a/components/util/deque/mod.rs b/components/util/deque/mod.rs new file mode 100644 index 00000000000..bf0a82693bd --- /dev/null +++ b/components/util/deque/mod.rs @@ -0,0 +1,660 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A (mostly) lock-free concurrent work-stealing deque +//! +//! This module contains an implementation of the Chase-Lev work stealing deque +//! described in "Dynamic Circular Work-Stealing Deque". The implementation is +//! heavily based on the pseudocode found in the paper. +//! +//! This implementation does not want to have the restriction of a garbage +//! collector for reclamation of buffers, and instead it uses a shared pool of +//! buffers. This shared pool is required for correctness in this +//! implementation. +//! +//! The only lock-synchronized portions of this deque are the buffer allocation +//! and deallocation portions. Otherwise all operations are lock-free. +//! +//! # Example +//! +//! use util::deque::BufferPool; +//! +//! let mut pool = BufferPool::new(); +//! let (mut worker, mut stealer) = pool.deque(); +//! +//! // Only the worker may push/pop +//! worker.push(1i); +//! worker.pop(); +//! +//! // Stealers take data from the other end of the deque +//! worker.push(1i); +//! stealer.steal(); +//! +//! // Stealers can be cloned to have many stealers stealing in parallel +//! worker.push(1i); +//! let mut stealer2 = stealer.clone(); +//! stealer2.steal(); + +#![experimental] + +// NB: the "buffer pool" strategy is not done for speed, but rather for +// correctness. For more info, see the comment on `swap_buffer` + +// FIXME: all atomic operations in this module use a SeqCst ordering. That is +// probably overkill + +pub use self::Stolen::{Empty, Abort, Data}; + +use alloc::arc::Arc; +use alloc::heap::{allocate, deallocate}; +use std::kinds::marker; +use std::mem::{forget, min_align_of, size_of, transmute}; +use std::ptr; + +use std::sync::Mutex; +use std::sync::atomic::{AtomicInt, AtomicPtr, SeqCst}; + +// Once the queue is less than 1/K full, then it will be downsized. Note that +// the deque requires that this number be less than 2. +static K: int = 4; + +// Minimum number of bits that a buffer size should be. No buffer will resize to +// under this value, and all deques will initially contain a buffer of this +// size. +// +// The size in question is 1 << MIN_BITS +static MIN_BITS: uint = 7; + +struct Deque<T> { + bottom: AtomicInt, + top: AtomicInt, + array: AtomicPtr<Buffer<T>>, + pool: BufferPool<T>, +} + +/// Worker half of the work-stealing deque. This worker has exclusive access to +/// one side of the deque, and uses `push` and `pop` method to manipulate it. +/// +/// There may only be one worker per deque. +pub struct Worker<T> { + deque: Arc<Deque<T>>, + _noshare: marker::NoSync, +} + +/// The stealing half of the work-stealing deque. Stealers have access to the +/// opposite end of the deque from the worker, and they only have access to the +/// `steal` method. +pub struct Stealer<T> { + deque: Arc<Deque<T>>, + _noshare: marker::NoSync, +} + +/// When stealing some data, this is an enumeration of the possible outcomes. +#[deriving(PartialEq, Show)] +pub enum Stolen<T> { + /// The deque was empty at the time of stealing + Empty, + /// The stealer lost the race for stealing data, and a retry may return more + /// data. + Abort, + /// The stealer has successfully stolen some data. + Data(T), +} + +/// The allocation pool for buffers used by work-stealing deques. Right now this +/// structure is used for reclamation of memory after it is no longer in use by +/// deques. +/// +/// This data structure is protected by a mutex, but it is rarely used. Deques +/// will only use this structure when allocating a new buffer or deallocating a +/// previous one. +pub struct BufferPool<T> { + // FIXME: This entire file was copied from std::sync::deque before it was removed, + // I converted `Exclusive` to `Mutex` here, but that might not be ideal + pool: Arc<Mutex<Vec<Box<Buffer<T>>>>>, +} + +/// An internal buffer used by the chase-lev deque. This structure is actually +/// implemented as a circular buffer, and is used as the intermediate storage of +/// the data in the deque. +/// +/// This type is implemented with *T instead of Vec<T> for two reasons: +/// +/// 1. There is nothing safe about using this buffer. This easily allows the +/// same value to be read twice in to rust, and there is nothing to +/// prevent this. The usage by the deque must ensure that one of the +/// values is forgotten. Furthermore, we only ever want to manually run +/// destructors for values in this buffer (on drop) because the bounds +/// are defined by the deque it's owned by. +/// +/// 2. We can certainly avoid bounds checks using *T instead of Vec<T>, although +/// LLVM is probably pretty good at doing this already. +struct Buffer<T> { + storage: *const T, + log_size: uint, +} + +impl<T: Send> BufferPool<T> { + /// Allocates a new buffer pool which in turn can be used to allocate new + /// deques. + pub fn new() -> BufferPool<T> { + BufferPool { pool: Arc::new(Mutex::new(Vec::new())) } + } + + /// Allocates a new work-stealing deque which will send/receiving memory to + /// and from this buffer pool. + pub fn deque(&self) -> (Worker<T>, Stealer<T>) { + let a = Arc::new(Deque::new(self.clone())); + let b = a.clone(); + (Worker { deque: a, _noshare: marker::NoSync }, + Stealer { deque: b, _noshare: marker::NoSync }) + } + + fn alloc(&mut self, bits: uint) -> Box<Buffer<T>> { + unsafe { + let mut pool = self.pool.lock(); + match pool.iter().position(|x| x.size() >= (1 << bits)) { + Some(i) => pool.remove(i).unwrap(), + None => box Buffer::new(bits) + } + } + } + + fn free(&self, buf: Box<Buffer<T>>) { + unsafe { + let mut pool = self.pool.lock(); + match pool.iter().position(|v| v.size() > buf.size()) { + Some(i) => pool.insert(i, buf), + None => pool.push(buf), + } + } + } +} + +impl<T: Send> Clone for BufferPool<T> { + fn clone(&self) -> BufferPool<T> { BufferPool { pool: self.pool.clone() } } +} + +impl<T: Send> Worker<T> { + /// Pushes data onto the front of this work queue. + pub fn push(&self, t: T) { + unsafe { self.deque.push(t) } + } + /// Pops data off the front of the work queue, returning `None` on an empty + /// queue. + pub fn pop(&self) -> Option<T> { + unsafe { self.deque.pop() } + } + + /// Gets access to the buffer pool that this worker is attached to. This can + /// be used to create more deques which share the same buffer pool as this + /// deque. + pub fn pool<'a>(&'a self) -> &'a BufferPool<T> { + &self.deque.pool + } +} + +impl<T: Send> Stealer<T> { + /// Steals work off the end of the queue (opposite of the worker's end) + pub fn steal(&self) -> Stolen<T> { + unsafe { self.deque.steal() } + } + + /// Gets access to the buffer pool that this stealer is attached to. This + /// can be used to create more deques which share the same buffer pool as + /// this deque. + pub fn pool<'a>(&'a self) -> &'a BufferPool<T> { + &self.deque.pool + } +} + +impl<T: Send> Clone for Stealer<T> { + fn clone(&self) -> Stealer<T> { + Stealer { deque: self.deque.clone(), _noshare: marker::NoSync } + } +} + +// Almost all of this code can be found directly in the paper so I'm not +// personally going to heavily comment what's going on here. + +impl<T: Send> Deque<T> { + fn new(mut pool: BufferPool<T>) -> Deque<T> { + let buf = pool.alloc(MIN_BITS); + Deque { + bottom: AtomicInt::new(0), + top: AtomicInt::new(0), + array: AtomicPtr::new(unsafe { transmute(buf) }), + pool: pool, + } + } + + unsafe fn push(&self, data: T) { + let mut b = self.bottom.load(SeqCst); + let t = self.top.load(SeqCst); + let mut a = self.array.load(SeqCst); + let size = b - t; + if size >= (*a).size() - 1 { + // You won't find this code in the chase-lev deque paper. This is + // alluded to in a small footnote, however. We always free a buffer + // when growing in order to prevent leaks. + a = self.swap_buffer(b, a, (*a).resize(b, t, 1)); + b = self.bottom.load(SeqCst); + } + (*a).put(b, data); + self.bottom.store(b + 1, SeqCst); + } + + unsafe fn pop(&self) -> Option<T> { + let b = self.bottom.load(SeqCst); + let a = self.array.load(SeqCst); + let b = b - 1; + self.bottom.store(b, SeqCst); + let t = self.top.load(SeqCst); + let size = b - t; + if size < 0 { + self.bottom.store(t, SeqCst); + return None; + } + let data = (*a).get(b); + if size > 0 { + self.maybe_shrink(b, t); + return Some(data); + } + if self.top.compare_and_swap(t, t + 1, SeqCst) == t { + self.bottom.store(t + 1, SeqCst); + return Some(data); + } else { + self.bottom.store(t + 1, SeqCst); + forget(data); // someone else stole this value + return None; + } + } + + unsafe fn steal(&self) -> Stolen<T> { + let t = self.top.load(SeqCst); + let old = self.array.load(SeqCst); + let b = self.bottom.load(SeqCst); + let a = self.array.load(SeqCst); + let size = b - t; + if size <= 0 { return Empty } + if size % (*a).size() == 0 { + if a == old && t == self.top.load(SeqCst) { + return Empty + } + return Abort + } + let data = (*a).get(t); + if self.top.compare_and_swap(t, t + 1, SeqCst) == t { + Data(data) + } else { + forget(data); // someone else stole this value + Abort + } + } + + unsafe fn maybe_shrink(&self, b: int, t: int) { + let a = self.array.load(SeqCst); + if b - t < (*a).size() / K && b - t > (1 << MIN_BITS) { + self.swap_buffer(b, a, (*a).resize(b, t, -1)); + } + } + + // Helper routine not mentioned in the paper which is used in growing and + // shrinking buffers to swap in a new buffer into place. As a bit of a + // recap, the whole point that we need a buffer pool rather than just + // calling malloc/free directly is that stealers can continue using buffers + // after this method has called 'free' on it. The continued usage is simply + // a read followed by a forget, but we must make sure that the memory can + // continue to be read after we flag this buffer for reclamation. + unsafe fn swap_buffer(&self, b: int, old: *mut Buffer<T>, + buf: Buffer<T>) -> *mut Buffer<T> { + let newbuf: *mut Buffer<T> = transmute(box buf); + self.array.store(newbuf, SeqCst); + let ss = (*newbuf).size(); + self.bottom.store(b + ss, SeqCst); + let t = self.top.load(SeqCst); + if self.top.compare_and_swap(t, t + ss, SeqCst) != t { + self.bottom.store(b, SeqCst); + } + self.pool.free(transmute(old)); + return newbuf; + } +} + + +#[unsafe_destructor] +impl<T: Send> Drop for Deque<T> { + fn drop(&mut self) { + let t = self.top.load(SeqCst); + let b = self.bottom.load(SeqCst); + let a = self.array.load(SeqCst); + // Free whatever is leftover in the dequeue, and then move the buffer + // back into the pool. + for i in range(t, b) { + let _: T = unsafe { (*a).get(i) }; + } + self.pool.free(unsafe { transmute(a) }); + } +} + +#[inline] +fn buffer_alloc_size<T>(log_size: uint) -> uint { + (1 << log_size) * size_of::<T>() +} + +impl<T: Send> Buffer<T> { + unsafe fn new(log_size: uint) -> Buffer<T> { + let size = buffer_alloc_size::<T>(log_size); + let buffer = allocate(size, min_align_of::<T>()); + if buffer.is_null() { ::alloc::oom() } + Buffer { + storage: buffer as *const T, + log_size: log_size, + } + } + + fn size(&self) -> int { 1 << self.log_size } + + // Apparently LLVM cannot optimize (foo % (1 << bar)) into this implicitly + fn mask(&self) -> int { (1 << self.log_size) - 1 } + + unsafe fn elem(&self, i: int) -> *const T { + self.storage.offset(i & self.mask()) + } + + // This does not protect against loading duplicate values of the same cell, + // nor does this clear out the contents contained within. Hence, this is a + // very unsafe method which the caller needs to treat specially in case a + // race is lost. + unsafe fn get(&self, i: int) -> T { + ptr::read(self.elem(i)) + } + + // Unsafe because this unsafely overwrites possibly uninitialized or + // initialized data. + unsafe fn put(&self, i: int, t: T) { + ptr::write(self.elem(i) as *mut T, t); + } + + // Again, unsafe because this has incredibly dubious ownership violations. + // It is assumed that this buffer is immediately dropped. + unsafe fn resize(&self, b: int, t: int, delta: int) -> Buffer<T> { + // NB: not entirely obvious, but thanks to 2's complement, + // casting delta to uint and then adding gives the desired + // effect. + let buf = Buffer::new(self.log_size + delta as uint); + for i in range(t, b) { + buf.put(i, self.get(i)); + } + return buf; + } +} + +#[unsafe_destructor] +impl<T: Send> Drop for Buffer<T> { + fn drop(&mut self) { + // It is assumed that all buffers are empty on drop. + let size = buffer_alloc_size::<T>(self.log_size); + unsafe { deallocate(self.storage as *mut u8, size, min_align_of::<T>()) } + } +} + +#[cfg(test)] +mod tests { + use super::{Data, BufferPool, Abort, Empty, Worker, Stealer}; + + use std::mem; + use rustrt::thread::Thread; + use std::rand; + use std::rand::Rng; + use std::sync::atomic::{AtomicBool, INIT_ATOMIC_BOOL, SeqCst, + AtomicUint, INIT_ATOMIC_UINT}; + use std::vec; + + #[test] + fn smoke() { + let pool = BufferPool::new(); + let (w, s) = pool.deque(); + assert_eq!(w.pop(), None); + assert_eq!(s.steal(), Empty); + w.push(1i); + assert_eq!(w.pop(), Some(1)); + w.push(1); + assert_eq!(s.steal(), Data(1)); + w.push(1); + assert_eq!(s.clone().steal(), Data(1)); + } + + #[test] + fn stealpush() { + static AMT: int = 100000; + let pool = BufferPool::<int>::new(); + let (w, s) = pool.deque(); + let t = Thread::start(proc() { + let mut left = AMT; + while left > 0 { + match s.steal() { + Data(i) => { + assert_eq!(i, 1); + left -= 1; + } + Abort | Empty => {} + } + } + }); + + for _ in range(0, AMT) { + w.push(1); + } + + t.join(); + } + + #[test] + fn stealpush_large() { + static AMT: int = 100000; + let pool = BufferPool::<(int, int)>::new(); + let (w, s) = pool.deque(); + let t = Thread::start(proc() { + let mut left = AMT; + while left > 0 { + match s.steal() { + Data((1, 10)) => { left -= 1; } + Data(..) => panic!(), + Abort | Empty => {} + } + } + }); + + for _ in range(0, AMT) { + w.push((1, 10)); + } + + t.join(); + } + + fn stampede(w: Worker<Box<int>>, s: Stealer<Box<int>>, + nthreads: int, amt: uint) { + for _ in range(0, amt) { + w.push(box 20); + } + let mut remaining = AtomicUint::new(amt); + let unsafe_remaining: *mut AtomicUint = &mut remaining; + + let threads = range(0, nthreads).map(|_| { + let s = s.clone(); + Thread::start(proc() { + unsafe { + while (*unsafe_remaining).load(SeqCst) > 0 { + match s.steal() { + Data(box 20) => { + (*unsafe_remaining).fetch_sub(1, SeqCst); + } + Data(..) => panic!(), + Abort | Empty => {} + } + } + } + }) + }).collect::<Vec<Thread<()>>>(); + + while remaining.load(SeqCst) > 0 { + match w.pop() { + Some(box 20) => { remaining.fetch_sub(1, SeqCst); } + Some(..) => panic!(), + None => {} + } + } + + for thread in threads.into_iter() { + thread.join(); + } + } + + #[test] + fn run_stampede() { + let pool = BufferPool::<Box<int>>::new(); + let (w, s) = pool.deque(); + stampede(w, s, 8, 10000); + } + + #[test] + fn many_stampede() { + static AMT: uint = 4; + let pool = BufferPool::<Box<int>>::new(); + let threads = range(0, AMT).map(|_| { + let (w, s) = pool.deque(); + Thread::start(proc() { + stampede(w, s, 4, 10000); + }) + }).collect::<Vec<Thread<()>>>(); + + for thread in threads.into_iter() { + thread.join(); + } + } + + #[test] + fn stress() { + static AMT: int = 100000; + static NTHREADS: int = 8; + static DONE: AtomicBool = INIT_ATOMIC_BOOL; + static HITS: AtomicUint = INIT_ATOMIC_UINT; + let pool = BufferPool::<int>::new(); + let (w, s) = pool.deque(); + + let threads = range(0, NTHREADS).map(|_| { + let s = s.clone(); + Thread::start(proc() { + loop { + match s.steal() { + Data(2) => { HITS.fetch_add(1, SeqCst); } + Data(..) => panic!(), + _ if DONE.load(SeqCst) => break, + _ => {} + } + } + }) + }).collect::<Vec<Thread<()>>>(); + + let mut rng = rand::task_rng(); + let mut expected = 0; + while expected < AMT { + if rng.gen_range(0i, 3) == 2 { + match w.pop() { + None => {} + Some(2) => { HITS.fetch_add(1, SeqCst); }, + Some(_) => panic!(), + } + } else { + expected += 1; + w.push(2); + } + } + + while HITS.load(SeqCst) < AMT as uint { + match w.pop() { + None => {} + Some(2) => { HITS.fetch_add(1, SeqCst); }, + Some(_) => panic!(), + } + } + DONE.store(true, SeqCst); + + for thread in threads.into_iter() { + thread.join(); + } + + assert_eq!(HITS.load(SeqCst), expected as uint); + } + + #[test] + #[cfg_attr(windows, ignore)] // apparently windows scheduling is weird? + fn no_starvation() { + static AMT: int = 10000; + static NTHREADS: int = 4; + static DONE: AtomicBool = INIT_ATOMIC_BOOL; + let pool = BufferPool::<(int, uint)>::new(); + let (w, s) = pool.deque(); + + let (threads, hits) = vec::unzip(range(0, NTHREADS).map(|_| { + let s = s.clone(); + let unique_box = box AtomicUint::new(0); + let thread_box = unsafe { + *mem::transmute::<&Box<AtomicUint>, + *const *mut AtomicUint>(&unique_box) + }; + (Thread::start(proc() { + unsafe { + loop { + match s.steal() { + Data((1, 2)) => { + (*thread_box).fetch_add(1, SeqCst); + } + Data(..) => panic!(), + _ if DONE.load(SeqCst) => break, + _ => {} + } + } + } + }), unique_box) + })); + + let mut rng = rand::task_rng(); + let mut myhit = false; + 'outer: loop { + for _ in range(0, rng.gen_range(0, AMT)) { + if !myhit && rng.gen_range(0i, 3) == 2 { + match w.pop() { + None => {} + Some((1, 2)) => myhit = true, + Some(_) => panic!(), + } + } else { + w.push((1, 2)); + } + } + + for slot in hits.iter() { + let amt = slot.load(SeqCst); + if amt == 0 { continue 'outer; } + } + if myhit { + break + } + } + + DONE.store(true, SeqCst); + + for thread in threads.into_iter() { + thread.join(); + } + } +} diff --git a/components/util/geometry.rs b/components/util/geometry.rs index 1191edba02a..5c3ee808b43 100644 --- a/components/util/geometry.rs +++ b/components/util/geometry.rs @@ -29,7 +29,7 @@ use std::fmt; /// /// The ratio between ScreenPx and DevicePixel for a given display be found by calling /// `servo::windowing::WindowMethods::hidpi_factor`. -#[deriving(Show)] +#[deriving(Show, Copy)] pub enum ScreenPx {} /// One CSS "px" in the coordinate system of the "initial viewport": @@ -41,7 +41,7 @@ pub enum ScreenPx {} /// /// At the default zoom level of 100%, one PagePx is equal to one ScreenPx. However, if the /// document is zoomed in or out then this scale may be larger or smaller. -#[deriving(Encodable, Show)] +#[deriving(Encodable, Show, Copy)] pub enum ViewportPx {} /// One CSS "px" in the root coordinate system for the content document. @@ -50,7 +50,7 @@ pub enum ViewportPx {} /// This is the mobile-style "pinch zoom" that enlarges content without reflowing it. When the /// viewport zoom is not equal to 1.0, then the layout viewport is no longer the same physical size /// as the viewable area. -#[deriving(Encodable, Show)] +#[deriving(Encodable, Show, Copy)] pub enum PagePx {} // In summary, the hierarchy of pixel units and the factors to convert from one to the next: @@ -65,7 +65,7 @@ pub enum PagePx {} // See https://bugzilla.mozilla.org/show_bug.cgi?id=177805 for more info. // // FIXME: Implement Au using Length and ScaleFactor instead of a custom type. -#[deriving(Clone, Hash, PartialEq, PartialOrd, Eq, Ord, Zero)] +#[deriving(Clone, Copy, Hash, PartialEq, PartialOrd, Eq, Ord)] pub struct Au(pub i32); impl Default for Au { diff --git a/components/util/lib.rs b/components/util/lib.rs index a1d31be4298..5d438fd0597 100644 --- a/components/util/lib.rs +++ b/components/util/lib.rs @@ -21,7 +21,6 @@ extern crate libc; extern crate rand; extern crate rustrt; extern crate serialize; -extern crate sync; #[cfg(target_os="macos")] extern crate task_info; extern crate "time" as std_time; @@ -40,6 +39,7 @@ pub mod bloom; pub mod cache; pub mod cursor; pub mod debug_utils; +pub mod deque; pub mod dlist; pub mod fnv; pub mod geometry; @@ -50,7 +50,8 @@ pub mod opts; pub mod persistent_list; pub mod range; pub mod resource_files; -pub mod rtinstrument; +// FIXME: Find replacement for this post-runtime removal +// pub mod rtinstrument; pub mod smallvec; pub mod sort; pub mod str; diff --git a/components/util/logical_geometry.rs b/components/util/logical_geometry.rs index e21039ce758..eebd0735b81 100644 --- a/components/util/logical_geometry.rs +++ b/components/util/logical_geometry.rs @@ -7,10 +7,10 @@ use geom::{Size2D, Point2D, SideOffsets2D, Rect}; use geom::num::Zero; use std::cmp::{min, max}; -use std::fmt::{Show, Formatter, FormatError}; +use std::fmt::{Show, Formatter, Error}; bitflags!( - #[deriving(Encodable)] + #[deriving(Encodable, Copy)] flags WritingMode: u8 { const FLAG_RTL = 1 << 0, const FLAG_VERTICAL = 1 << 1, @@ -49,7 +49,7 @@ impl WritingMode { } impl Show for WritingMode { - fn fmt(&self, formatter: &mut Formatter) -> Result<(), FormatError> { + fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { if self.is_vertical() { try!(write!(formatter, "V")); if self.is_vertical_lr() { @@ -79,11 +79,11 @@ impl Show for WritingMode { /// (in addition to taking it as a parameter to methods) and check it. /// In non-debug builds, make this storage zero-size and the checks no-ops. #[cfg(ndebug)] -#[deriving(Encodable, PartialEq, Eq, Clone)] +#[deriving(Encodable, PartialEq, Eq, Clone, Copy)] struct DebugWritingMode; #[cfg(not(ndebug))] -#[deriving(Encodable, PartialEq, Eq, Clone)] +#[deriving(Encodable, PartialEq, Eq, Clone, Copy)] struct DebugWritingMode { mode: WritingMode } @@ -122,19 +122,19 @@ impl DebugWritingMode { impl Show for DebugWritingMode { #[cfg(ndebug)] - fn fmt(&self, formatter: &mut Formatter) -> Result<(), FormatError> { + fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { write!(formatter, "?") } #[cfg(not(ndebug))] - fn fmt(&self, formatter: &mut Formatter) -> Result<(), FormatError> { + fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { self.mode.fmt(formatter) } } /// A 2D size in flow-relative dimensions -#[deriving(Encodable, PartialEq, Eq, Clone)] +#[deriving(Encodable, PartialEq, Eq, Clone, Copy)] pub struct LogicalSize<T> { pub inline: T, // inline-size, a.k.a. logical width, a.k.a. measure pub block: T, // block-size, a.k.a. logical height, a.k.a. extent @@ -142,7 +142,7 @@ pub struct LogicalSize<T> { } impl<T: Show> Show for LogicalSize<T> { - fn fmt(&self, formatter: &mut Formatter) -> Result<(), FormatError> { + fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { write!(formatter, "LogicalSize({}, i{}×b{})", self.debug_writing_mode, self.inline, self.block) } @@ -266,7 +266,7 @@ impl<T: Sub<T, T>> Sub<LogicalSize<T>, LogicalSize<T>> for LogicalSize<T> { /// A 2D point in flow-relative dimensions -#[deriving(PartialEq, Encodable, Eq, Clone)] +#[deriving(PartialEq, Encodable, Eq, Clone, Copy)] pub struct LogicalPoint<T> { pub i: T, /// inline-axis coordinate pub b: T, /// block-axis coordinate @@ -274,7 +274,7 @@ pub struct LogicalPoint<T> { } impl<T: Show> Show for LogicalPoint<T> { - fn fmt(&self, formatter: &mut Formatter) -> Result<(), FormatError> { + fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { write!(formatter, "LogicalPoint({} (i{}, b{}))", self.debug_writing_mode, self.i, self.b) } @@ -434,7 +434,7 @@ impl<T: Sub<T,T>> Sub<LogicalSize<T>, LogicalPoint<T>> for LogicalPoint<T> { /// Represents the four sides of the margins, borders, or padding of a CSS box, /// or a combination of those. /// A positive "margin" can be added to a rectangle to obtain a bigger rectangle. -#[deriving(Encodable, PartialEq, Eq, Clone)] +#[deriving(Encodable, PartialEq, Eq, Clone, Copy)] pub struct LogicalMargin<T> { pub block_start: T, pub inline_end: T, @@ -444,7 +444,7 @@ pub struct LogicalMargin<T> { } impl<T: Show> Show for LogicalMargin<T> { - fn fmt(&self, formatter: &mut Formatter) -> Result<(), FormatError> { + fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { write!(formatter, "LogicalMargin({}, inline: {}..{} block: {}..{})", self.debug_writing_mode, @@ -718,7 +718,7 @@ impl<T: Sub<T, T>> Sub<LogicalMargin<T>, LogicalMargin<T>> for LogicalMargin<T> /// A rectangle in flow-relative dimensions -#[deriving(Encodable, PartialEq, Eq, Clone)] +#[deriving(Encodable, PartialEq, Eq, Clone, Copy)] pub struct LogicalRect<T> { pub start: LogicalPoint<T>, pub size: LogicalSize<T>, @@ -726,7 +726,7 @@ pub struct LogicalRect<T> { } impl<T: Show> Show for LogicalRect<T> { - fn fmt(&self, formatter: &mut Formatter) -> Result<(), FormatError> { + fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { write!(formatter, "LogicalRect({}, i{}×b{}, @ (i{},b{}))", self.debug_writing_mode, diff --git a/components/util/opts.rs b/components/util/opts.rs index 6bd1882b94e..59642a43b81 100644 --- a/components/util/opts.rs +++ b/components/util/opts.rs @@ -19,7 +19,7 @@ use std::os; use std::ptr; use std::rt; -#[deriving(Clone)] +#[deriving(Clone, Copy)] pub enum RenderApi { OpenGL, Mesa, diff --git a/components/util/persistent_list.rs b/components/util/persistent_list.rs index 7aae2bf030c..458c4c96a2a 100644 --- a/components/util/persistent_list.rs +++ b/components/util/persistent_list.rs @@ -5,7 +5,7 @@ //! A persistent, thread-safe singly-linked list. use std::mem; -use sync::Arc; +use std::sync::Arc; pub struct PersistentList<T> { head: PersistentListLink<T>, diff --git a/components/util/range.rs b/components/util/range.rs index 103f6d3c91d..ef6e7e0ff47 100644 --- a/components/util/range.rs +++ b/components/util/range.rs @@ -26,7 +26,7 @@ impl RangeIndex<int> for int { #[macro_export] macro_rules! int_range_index { ($(#[$attr:meta])* struct $Self:ident($T:ty)) => ( - #[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show)] + #[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show, Copy)] $(#[$attr])* pub struct $Self(pub $T); @@ -175,7 +175,7 @@ macro_rules! int_range_index { } /// A range of indices -#[deriving(Clone, Encodable)] +#[deriving(Clone, Encodable, Copy)] pub struct Range<I> { begin: I, length: I, diff --git a/components/util/rtinstrument.rs b/components/util/rtinstrument.rs index 0cd075c0545..ea9a5ecef32 100644 --- a/components/util/rtinstrument.rs +++ b/components/util/rtinstrument.rs @@ -13,7 +13,7 @@ use std::rt::local::Local; //use std::rt::rtio; use std::rt::task::{Task, TaskOpts, BlockedTask}; use std_time; -use sync::Mutex; +use std::sync::Mutex; #[cfg(not(test))] use serialize::json; diff --git a/components/util/str.rs b/components/util/str.rs index 2344c8655d4..5721770c494 100644 --- a/components/util/str.rs +++ b/components/util/str.rs @@ -57,11 +57,11 @@ pub fn is_whitespace(s: &str) -> bool { /// /// http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#space-character pub static HTML_SPACE_CHARACTERS: StaticCharVec = &[ - '\u0020', - '\u0009', - '\u000a', - '\u000c', - '\u000d', + '\u{0020}', + '\u{0009}', + '\u{000a}', + '\u{000c}', + '\u{000d}', ]; pub fn split_html_space_chars<'a>(s: &'a str) @@ -131,6 +131,7 @@ pub fn parse_unsigned_integer<T: Iterator<char>>(input: T) -> Option<u32> { }) } +#[deriving(Copy)] pub enum LengthOrPercentageOrAuto { Auto, Percentage(f64), diff --git a/components/util/task.rs b/components/util/task.rs index 5de066d5823..384e045fb38 100644 --- a/components/util/task.rs +++ b/components/util/task.rs @@ -2,17 +2,17 @@ * 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::str::IntoMaybeOwned; use std::task; use std::comm::Sender; use std::task::TaskBuilder; -use rtinstrument; +// use rtinstrument; use task_state; -pub fn spawn_named<S: IntoMaybeOwned<'static>>(name: S, f: proc():Send) { +pub fn spawn_named<S: IntoCow<'static, String, str>>(name: S, f: proc():Send) { let builder = task::TaskBuilder::new().named(name); builder.spawn(proc() { - rtinstrument::instrument(f); + // rtinstrument::instrument(f); + f(); }); } @@ -24,13 +24,15 @@ 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); - rtinstrument::instrument(f); + // FIXME: Find replacement for this post-runtime removal + // rtinstrument::instrument(f); + f(); }); let watched_name = name.into_string(); let watcher_name = format!("{}Watcher", watched_name); TaskBuilder::new().named(watcher_name).spawn(proc() { - rtinstrument::instrument(proc() { + //rtinstrument::instrument(proc() { match future_result.unwrap() { Ok(()) => (), Err(..) => { @@ -38,6 +40,6 @@ pub fn spawn_named_with_send_on_failure<T: Send>(name: &'static str, dest.send(msg); } } - }); + //}); }); } diff --git a/components/util/task_state.rs b/components/util/task_state.rs index cd64bb40e2c..3915eeb3059 100644 --- a/components/util/task_state.rs +++ b/components/util/task_state.rs @@ -11,7 +11,7 @@ pub use self::imp::{initialize, get, enter, exit}; bitflags! { - #[deriving(Show)] + #[deriving(Show, Copy)] flags TaskState: u32 { const SCRIPT = 0x01, const LAYOUT = 0x02, @@ -46,22 +46,28 @@ task_types! { #[cfg(not(ndebug))] mod imp { use super::{TaskState, TYPES}; + use std::cell::RefCell; - local_data_key!(STATE: TaskState) + thread_local!(static STATE: RefCell<Option<TaskState>> = RefCell::new(None)) pub fn initialize(x: TaskState) { - match STATE.replace(Some(x)) { - None => (), - Some(s) => panic!("Task state already initialized as {}", s), - }; + STATE.with(|ref k| { + match *k.borrow() { + Some(s) => panic!("Task state already initialized as {}", s), + None => () + }; + *k.borrow_mut() = Some(x); + }); get(); // check the assertion below } pub fn get() -> TaskState { - let state = match STATE.get() { - None => panic!("Task state not initialized"), - Some(s) => *s, - }; + let state = STATE.with(|ref k| { + match *k.borrow() { + None => panic!("Task state not initialized"), + Some(s) => s, + } + }); // Exactly one of the task type flags should be set. assert_eq!(1, TYPES.iter().filter(|&&ty| state.contains(ty)).count()); @@ -71,13 +77,17 @@ mod imp { pub fn enter(x: TaskState) { let state = get(); assert!(!state.intersects(x)); - STATE.replace(Some(state | x)); + STATE.with(|ref k| { + *k.borrow_mut() = Some(state | x); + }) } pub fn exit(x: TaskState) { let state = get(); assert!(state.contains(x)); - STATE.replace(Some(state & !x)); + STATE.with(|ref k| { + *k.borrow_mut() = Some(state & !x); + }) } } diff --git a/components/util/tid.rs b/components/util/tid.rs index 1e569731ff2..a1e24147019 100644 --- a/components/util/tid.rs +++ b/components/util/tid.rs @@ -3,20 +3,24 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, SeqCst}; +use std::rc::Rc; +use std::cell::RefCell; static mut next_tid: AtomicUint = INIT_ATOMIC_UINT; -local_data_key!(task_local_tid: uint) +thread_local!(static task_local_tid: Rc<RefCell<Option<uint>>> = Rc::new(RefCell::new(None))) /// Every task gets one, that's unique. pub fn tid() -> uint { - let ret = - match task_local_tid.replace(None) { - None => unsafe { next_tid.fetch_add(1, SeqCst) }, - Some(x) => x, - }; + task_local_tid.with(|ref k| { + let ret = + match *k.borrow() { + None => unsafe { next_tid.fetch_add(1, SeqCst) }, + Some(x) => x, + }; - task_local_tid.replace(Some(ret)); + *k.borrow_mut() = Some(ret); - ret + ret + }) } diff --git a/components/util/vec.rs b/components/util/vec.rs index c627448f0fc..b9a67b6760b 100644 --- a/components/util/vec.rs +++ b/components/util/vec.rs @@ -101,12 +101,12 @@ fn should_find_all_elements() { let arr_two = [3044u32, 8393]; let arr_three = [12u32, 23, 34]; - test_find_all_elems(arr_odd); - test_find_all_elems(arr_even); - test_find_all_elems(arr_double); - test_find_all_elems(arr_one); - test_find_all_elems(arr_two); - test_find_all_elems(arr_three); + test_find_all_elems(&arr_odd); + test_find_all_elems(&arr_even); + test_find_all_elems(&arr_double); + test_find_all_elems(&arr_one); + test_find_all_elems(&arr_two); + test_find_all_elems(&arr_three); } #[test] @@ -118,10 +118,10 @@ fn should_not_find_missing_elements() { let arr_two = [3044u32, 8393]; let arr_three = [12u32, 23, 34]; - test_miss_all_elems(arr_odd, [-22, 0, 3, 5, 34938, 10, 11, 12]); - test_miss_all_elems(arr_even, [-1, 0, 3, 34938, 10, 11, 12]); - test_miss_all_elems(arr_double, [-1, 0, 3, 4, 34938, 10, 11, 12, 234, 234, 33]); - test_miss_all_elems(arr_one, [-1, 0, 3, 34938, 10, 11, 12, 234, 234, 33]); - test_miss_all_elems(arr_two, [-1, 0, 3, 34938, 10, 11, 12, 234, 234, 33]); - test_miss_all_elems(arr_three, [-2, 0, 1, 2, 3, 34938, 10, 11, 234, 234, 33]); + test_miss_all_elems(&arr_odd, &[-22, 0, 3, 5, 34938, 10, 11, 12]); + test_miss_all_elems(&arr_even, &[-1, 0, 3, 34938, 10, 11, 12]); + test_miss_all_elems(&arr_double, &[-1, 0, 3, 4, 34938, 10, 11, 12, 234, 234, 33]); + test_miss_all_elems(&arr_one, &[-1, 0, 3, 34938, 10, 11, 12, 234, 234, 33]); + test_miss_all_elems(&arr_two, &[-1, 0, 3, 34938, 10, 11, 12, 234, 234, 33]); + test_miss_all_elems(&arr_three, &[-2, 0, 1, 2, 3, 34938, 10, 11, 234, 234, 33]); } diff --git a/components/util/workqueue.rs b/components/util/workqueue.rs index 291ff40ca57..9fef7ac2a81 100644 --- a/components/util/workqueue.rs +++ b/components/util/workqueue.rs @@ -15,7 +15,7 @@ use rand::{Rng, XorShiftRng}; use std::mem; use std::rand::weak_rng; use std::sync::atomic::{AtomicUint, SeqCst}; -use std::sync::deque::{Abort, BufferPool, Data, Empty, Stealer, Worker}; +use deque::{Abort, BufferPool, Data, Empty, Stealer, Worker}; /// A unit of work. /// diff --git a/ports/cef/.cargo/config b/ports/cef/.cargo/config new file mode 100644 index 00000000000..92ac197ce5d --- /dev/null +++ b/ports/cef/.cargo/config @@ -0,0 +1,7 @@ +# FIXME: Remove this next rustup. This is a temporary +# hack to allow android cross compilation to work. When +# this is removed, the support/time submodule can also +# be removed! +paths = [ + "../../support/time" +] diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 2f75cd5447f..af738e810a0 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -27,7 +27,7 @@ dependencies = [ [[package]] name = "azure" version = "0.1.0" -source = "git+https://github.com/servo/rust-azure#fe95551ca22f2a75b0dd690a72841df39b33885d" +source = "git+https://github.com/servo/rust-azure#6884d442052becfcafccc82b17ab316c7831d8d2" dependencies = [ "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)", @@ -81,24 +81,24 @@ dependencies = [ "png 0.1.0 (git+https://github.com/servo/rust-png)", "script_traits 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "cookie" -version = "0.0.1" -source = "git+https://github.com/servo/cookie-rs#f82090b19c2738b90528167ef873d8eac0353294" +version = "0.1.0" +source = "git+https://github.com/alexcrichton/cookie-rs#8d1b4bb8d5ed06e58c162eb235a4ccd210b68108" dependencies = [ - "openssl 0.0.2 (git+https://github.com/servo/rust-openssl)", + "openssl 0.2.4 (git+https://github.com/sfackler/rust-openssl)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", ] [[package]] name = "core_foundation" version = "0.1.0" -source = "git+https://github.com/servo/rust-core-foundation#d2dbe4fb6f6892521a37735cd7a97098d1b64808" +source = "git+https://github.com/servo/rust-core-foundation#81db9ab15f67e16d7a3e9705a06cad65192014fd" [[package]] name = "core_graphics" @@ -111,7 +111,7 @@ dependencies = [ [[package]] name = "core_text" version = "0.1.0" -source = "git+https://github.com/servo/rust-core-text#85784007b6fa1b8f9614059edcd0429b2bd69a11" +source = "git+https://github.com/servo/rust-core-text#cb369a26a0eb4e83c2128ceb3c685a191113417a" dependencies = [ "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)", @@ -119,11 +119,11 @@ dependencies = [ [[package]] name = "cssparser" -version = "0.1.0" -source = "git+https://github.com/servo/rust-cssparser#a2b0b6b00ad84dc3a4b4faf77ddd63611c8ce58a" +version = "0.1.1" +source = "git+https://github.com/servo/rust-cssparser#110bf3052d016bf6eda0689fb21cf971e2c23dc8" dependencies = [ - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", - "text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "text_writer 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -149,60 +149,60 @@ source = "git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c [[package]] name = "encoding" -version = "0.2.3" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding-index-japanese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-korean 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-simpchinese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-singlebyte 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-tradchinese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding-index-japanese 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-korean 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-simpchinese 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-singlebyte 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-tradchinese 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-japanese" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-korean" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-simpchinese" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-singlebyte" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-tradchinese" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding_index_tests" version = "0.1.0" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "expat-sys" @@ -242,9 +242,14 @@ version = "0.0.2" source = "git+https://github.com/alexcrichton/gcc-rs#903e8f8a2e3766ad3d514404d452dbaa1d3b2d79" [[package]] +name = "gcc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "geom" version = "0.1.0" -source = "git+https://github.com/servo/rust-geom#0f77c6ad116748b7e6bedbf2414d4ceea17debc2" +source = "git+https://github.com/servo/rust-geom#05f2d5494355adc78ad7d17286912f0d128f503b" [[package]] name = "gfx" @@ -267,23 +272,23 @@ dependencies = [ "stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)", "style 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "gl_common" version = "0.0.1" -source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb726f242d" +source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa4f67c6e" [[package]] name = "gl_generator" version = "0.0.1" -source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb726f242d" +source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa4f67c6e" dependencies = [ "gl_common 0.0.1 (git+https://github.com/bjz/gl-rs.git)", "khronos_api 0.0.2 (git+https://github.com/bjz/gl-rs.git)", - "rust-xml 0.1.2-pre (git+https://github.com/netvl/rust-xml)", + "xml-rs 0.1.3 (git+https://github.com/netvl/xml-rs)", ] [[package]] @@ -297,10 +302,10 @@ dependencies = [ [[package]] name = "glfw" version = "0.0.1" -source = "git+https://github.com/servo/glfw-rs?ref=servo#1b05fdc7eab45e1d462758ab991065ee78593b7f" +source = "git+https://github.com/servo/glfw-rs?ref=servo#b186cb444e349a36b992445dc5cb2c99d38f2a42" dependencies = [ "glfw-sys 3.0.4 (git+https://github.com/servo/glfw?ref=cargo-3.0.4)", - "semver 0.1.3 (git+https://github.com/rust-lang/semver)", + "semver 0.1.4 (git+https://github.com/rust-lang/semver)", ] [[package]] @@ -339,11 +344,11 @@ source = "git+https://github.com/servo/rust-harfbuzz#8aab215463214647b7a81f66011 [[package]] name = "html5ever" version = "0.0.0" -source = "git+https://github.com/servo/html5ever#e6f8d83de9fffe63a825d95d957ba6bcbc3e1632" +source = "git+https://github.com/servo/html5ever#0abe5e30cc03f9e73bfd4fdc018192d149c21fb3" dependencies = [ "html5ever_macros 0.0.0 (git+https://github.com/servo/html5ever)", - "phf 0.0.0 (git+https://github.com/sfackler/rust-phf)", - "phf_mac 0.0.0 (git+https://github.com/sfackler/rust-phf)", + "phf 0.0.1 (git+https://github.com/sfackler/rust-phf)", + "phf_mac 0.0.1 (git+https://github.com/sfackler/rust-phf)", "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "time 0.1.0 (git+https://github.com/rust-lang/time)", @@ -352,19 +357,20 @@ dependencies = [ [[package]] name = "html5ever_macros" version = "0.0.0" -source = "git+https://github.com/servo/html5ever#e6f8d83de9fffe63a825d95d957ba6bcbc3e1632" +source = "git+https://github.com/servo/html5ever#0abe5e30cc03f9e73bfd4fdc018192d149c21fb3" [[package]] name = "hyper" version = "0.0.1" -source = "git+https://github.com/servo/hyper?ref=servo#4a2c82c75013f8ee55d2017876319b48d656dcb3" +source = "git+https://github.com/servo/hyper?ref=servo#43becc919c24939b8b84fe541b0e0898a4827836" dependencies = [ - "cookie 0.0.1 (git+https://github.com/servo/cookie-rs)", + "cookie 0.1.0 (git+https://github.com/alexcrichton/cookie-rs)", "mime 0.0.1 (git+https://github.com/hyperium/mime.rs)", - "openssl 0.0.2 (git+https://github.com/servo/rust-openssl)", + "mucell 0.1.2 (git+https://github.com/chris-morgan/mucell)", + "openssl 0.2.4 (git+https://github.com/sfackler/rust-openssl)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "unsafe-any 0.1.0 (git+https://github.com/reem/rust-unsafe-any)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "unsafe-any 0.1.1 (git+https://github.com/reem/rust-unsafe-any)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", ] [[package]] @@ -381,7 +387,7 @@ dependencies = [ [[package]] name = "js" version = "0.1.0" -source = "git+https://github.com/servo/rust-mozjs#2d86d6fb7ece49ff2f469c391e15e13f2b02af42" +source = "git+https://github.com/servo/rust-mozjs#e01a846241bd98ac424878e3f8d3e9b989c79242" dependencies = [ "mozjs-sys 0.0.0 (git+https://github.com/servo/mozjs)", ] @@ -389,12 +395,12 @@ dependencies = [ [[package]] name = "khronos_api" version = "0.0.2" -source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb726f242d" +source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa4f67c6e" [[package]] name = "layers" version = "0.1.0" -source = "git+https://github.com/servo/rust-layers#21798aac4de6bfd800836f419dd5b6a308edcaa4" +source = "git+https://github.com/servo/rust-layers#574df7e1c1dd464af930d1cc735ca8d6af46bb90" dependencies = [ "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", @@ -410,8 +416,8 @@ dependencies = [ name = "layout" version = "0.0.1" dependencies = [ - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "gfx 0.0.1", "layout_traits 0.0.1", @@ -422,7 +428,7 @@ dependencies = [ "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "style 0.0.1", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] @@ -440,7 +446,7 @@ dependencies = [ [[package]] name = "lazy_static" version = "0.1.0" -source = "git+https://github.com/Kimundi/lazy-static.rs#62976cb611c5396e11315ae64c9c389576240eb7" +source = "git+https://github.com/Kimundi/lazy-static.rs#76f06e4fa7bc8c92f11d1def19bd4ddfd8017cd8" [[package]] name = "libressl-pnacl-sys" @@ -471,11 +477,16 @@ dependencies = [ "io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "style 0.0.1", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] +name = "mucell" +version = "0.1.2" +source = "git+https://github.com/chris-morgan/mucell#d198c6605b3e688719db168db0939051c803b1ea" + +[[package]] name = "net" version = "0.0.1" dependencies = [ @@ -484,42 +495,42 @@ dependencies = [ "png 0.1.0 (git+https://github.com/servo/rust-png)", "stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "openssl" -version = "0.0.2" -source = "git+https://github.com/servo/rust-openssl#aed5df1036d6f4b5f7b8be6457d10f8a0379b39f" +version = "0.2.4" +source = "git+https://github.com/sfackler/rust-openssl#f299e336d06a85438c3ee90aa06235510f3f5dbe" dependencies = [ - "libressl-pnacl-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.0.2 (git+https://github.com/servo/rust-openssl)", + "openssl-sys 0.2.4 (git+https://github.com/sfackler/rust-openssl)", ] [[package]] name = "openssl-sys" -version = "0.0.2" -source = "git+https://github.com/servo/rust-openssl#aed5df1036d6f4b5f7b8be6457d10f8a0379b39f" +version = "0.2.4" +source = "git+https://github.com/sfackler/rust-openssl#f299e336d06a85438c3ee90aa06235510f3f5dbe" dependencies = [ + "libressl-pnacl-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "phf" -version = "0.0.0" -source = "git+https://github.com/sfackler/rust-phf#aa3e2d0aedea4d55c2e4cea1bdf6e89418dc1206" +version = "0.0.1" +source = "git+https://github.com/sfackler/rust-phf#6a7cc6eb9ec08b103b6b62fa39bdb3229f3cdbe4" dependencies = [ - "xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)", + "xxhash 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "phf_mac" -version = "0.0.0" -source = "git+https://github.com/sfackler/rust-phf#aa3e2d0aedea4d55c2e4cea1bdf6e89418dc1206" +version = "0.0.1" +source = "git+https://github.com/sfackler/rust-phf#6a7cc6eb9ec08b103b6b62fa39bdb3229f3cdbe4" dependencies = [ - "time 0.1.0 (git+https://github.com/rust-lang/time)", - "xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)", + "time 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "xxhash 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -550,18 +561,13 @@ version = "1.6.3" source = "git+https://github.com/servo/libpng?ref=servo#d01f32b4eb86904695efe7fc02b574f902e21a98" [[package]] -name = "rust-xml" -version = "0.1.2-pre" -source = "git+https://github.com/netvl/rust-xml#2d9df3267aeaa4d442e1e19a4dfed733cb1397ed" - -[[package]] name = "script" version = "0.0.1" dependencies = [ "canvas 0.0.1", - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", "devtools_traits 0.0.1", - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "gfx 0.0.1", "html5ever 0.0.0 (git+https://github.com/servo/html5ever)", @@ -575,9 +581,9 @@ dependencies = [ "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "style 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", - "uuid 0.0.2 (git+https://github.com/rust-lang/uuid)", + "uuid 0.1.1 (git+https://github.com/rust-lang/uuid)", ] [[package]] @@ -588,14 +594,14 @@ dependencies = [ "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "msg 0.0.1", "net 0.0.1", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "semver" -version = "0.1.3" -source = "git+https://github.com/rust-lang/semver#29212953f839337c672d185dde74e14b5dfb1f46" +version = "0.1.4" +source = "git+https://github.com/rust-lang/semver#58dc6b1999d345ca925a2f12a6a84676e823e179" [[package]] name = "servo" @@ -609,7 +615,7 @@ dependencies = [ "net 0.0.1", "script 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] @@ -630,19 +636,19 @@ source = "git+https://github.com/servo/rust-stb-image#97d7e440e80e41a304647363c3 [[package]] name = "string_cache" version = "0.0.0" -source = "git+https://github.com/servo/string-cache#a18a432fd274e816fc41876536f70e5380abb677" +source = "git+https://github.com/servo/string-cache#661c537b85f19ac81dfcd84e28557d480b6b7a9f" dependencies = [ "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)", - "phf 0.0.0 (git+https://github.com/sfackler/rust-phf)", - "phf_mac 0.0.0 (git+https://github.com/sfackler/rust-phf)", + "phf 0.0.1 (git+https://github.com/sfackler/rust-phf)", + "phf_mac 0.0.1 (git+https://github.com/sfackler/rust-phf)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", - "xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)", + "xxhash 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "string_cache_macros" version = "0.0.0" -source = "git+https://github.com/servo/string-cache#a18a432fd274e816fc41876536f70e5380abb677" +source = "git+https://github.com/servo/string-cache#661c537b85f19ac81dfcd84e28557d480b6b7a9f" dependencies = [ "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)", ] @@ -651,15 +657,15 @@ dependencies = [ name = "style" version = "0.0.1" dependencies = [ - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)", "plugins 0.0.1", "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", - "text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "text_writer 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] @@ -669,7 +675,7 @@ version = "0.0.1" [[package]] name = "text_writer" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -681,35 +687,43 @@ dependencies = [ ] [[package]] +name = "time" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "unsafe-any" -version = "0.1.0" -source = "git+https://github.com/reem/rust-unsafe-any#2863af363bbd83079b6773920bba5b736408db33" +version = "0.1.1" +source = "git+https://github.com/reem/rust-unsafe-any#eb3fe87bea85f375b8fcefa0cdecfd131fae9624" [[package]] name = "url" -version = "0.1.0" -source = "git+https://github.com/servo/rust-url#46458f80e48c542b2f175e36e5b7d30782ca7dc5" +version = "0.2.4" +source = "git+https://github.com/servo/rust-url#79f8034a8e1815ffa1f49204572ddbf6eb747c75" [[package]] name = "util" version = "0.0.1" dependencies = [ - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "plugins 0.0.1", "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "task_info 0.0.1", - "text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "text_writer 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", ] [[package]] name = "uuid" -version = "0.0.2" -source = "git+https://github.com/rust-lang/uuid#f5d94d0043a615756edefaf9c6041f11e52b8370" +version = "0.1.1" +source = "git+https://github.com/rust-lang/uuid#fc793c974a25c126c5cf5daa3b18973512a7a6a0" [[package]] name = "xlib" @@ -717,7 +731,12 @@ version = "0.1.0" source = "git+https://github.com/servo/rust-xlib#58ec3847b592aeabdcfeb6a2d02033d3a2c7f427" [[package]] +name = "xml-rs" +version = "0.1.3" +source = "git+https://github.com/netvl/xml-rs#1a812d3ba720afd768bd75d29a5b5f10ddcdfbeb" + +[[package]] name = "xxhash" -version = "0.0.1" -source = "git+https://github.com/Jurily/rust-xxhash#64f8d02314735f511cb4272563d0f703d575c159" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/ports/cef/browser.rs b/ports/cef/browser.rs index 98993532df6..a0d0032d430 100644 --- a/ports/cef/browser.rs +++ b/ports/cef/browser.rs @@ -13,7 +13,7 @@ use servo::Browser; use types::{cef_browser_settings_t, cef_string_t, cef_window_info_t}; use window; -use compositing::windowing::{Back, Forward, WindowEvent}; +use compositing::windowing::{WindowNavigateMsg, WindowEvent}; use glfw_app; use libc::c_int; use servo_util::opts; @@ -26,11 +26,11 @@ cef_class_impl! { } fn go_back(&_this) -> () { - core::send_window_event(WindowEvent::Navigation(Back)); + core::send_window_event(WindowEvent::Navigation(WindowNavigateMsg::Back)); } fn go_forward(&_this) -> () { - core::send_window_event(WindowEvent::Navigation(Forward)); + core::send_window_event(WindowEvent::Navigation(WindowNavigateMsg::Forward)); } // Returns the main (top-level) frame for the browser window. @@ -56,9 +56,12 @@ impl ServoCefBrowser { let frame = ServoCefFrame::new().as_cef_interface(); let host = ServoCefBrowserHost::new(client.clone()).as_cef_interface(); if window_info.windowless_rendering_enabled == 0 { - let glfw_window = glfw_app::create_window(); - globals.replace(Some(ServoCefGlobals::OnScreenGlobals(RefCell::new(glfw_window.clone()), - RefCell::new(Browser::new(Some(glfw_window)))))); + globals.with(|ref r| { + let glfw_window = glfw_app::create_window(); + *r.borrow_mut() = Some(ServoCefGlobals::OnScreenGlobals( + RefCell::new(glfw_window.clone()), + RefCell::new(Browser::new(Some(glfw_window))))); + }); } ServoCefBrowser { @@ -77,18 +80,22 @@ trait ServoCefBrowserExtensions { impl ServoCefBrowserExtensions for CefBrowser { fn init(&self, window_info: &cef_window_info_t) { if window_info.windowless_rendering_enabled != 0 { - let window = window::Window::new(); - let servo_browser = Browser::new(Some(window.clone())); - window.set_browser(self.clone()); - globals.replace(Some(ServoCefGlobals::OffScreenGlobals(RefCell::new(window), - RefCell::new(servo_browser)))); + globals.with(|ref r| { + let window = window::Window::new(); + let servo_browser = Browser::new(Some(window.clone())); + window.set_browser(self.clone()); + + *r.borrow_mut() = Some(ServoCefGlobals::OffScreenGlobals( + RefCell::new(window), + RefCell::new(servo_browser))); + }); } self.downcast().host.set_browser((*self).clone()); } } -local_data_key!(pub GLOBAL_BROWSERS: RefCell<Vec<CefBrowser>>) +thread_local!(pub static GLOBAL_BROWSERS: RefCell<Vec<CefBrowser>> = RefCell::new(vec!())) pub fn browser_callback_after_created(browser: CefBrowser) { if browser.downcast().client.is_null_cef_object() { @@ -115,16 +122,7 @@ fn browser_host_create(window_info: &cef_window_info_t, if callback_executed { browser_callback_after_created(browser.clone()); } - match GLOBAL_BROWSERS.replace(None) { - Some(brs) => { - brs.borrow_mut().push(browser.clone()); - GLOBAL_BROWSERS.replace(Some(brs)); - }, - None => { - let brs = RefCell::new(vec!(browser.clone())); - GLOBAL_BROWSERS.replace(Some(brs)); - } - } + GLOBAL_BROWSERS.with(|ref r| r.borrow_mut().push(browser.clone())); browser } diff --git a/ports/cef/browser_host.rs b/ports/cef/browser_host.rs index 69010e483b7..403090bd424 100644 --- a/ports/cef/browser_host.rs +++ b/ports/cef/browser_host.rs @@ -8,11 +8,11 @@ use interfaces::{CefBrowser, CefBrowserHost, CefClient, cef_browser_host_t, cef_ use types::{cef_mouse_button_type_t, cef_mouse_event, cef_rect_t, cef_key_event}; use types::cef_key_event_type_t::{KEYEVENT_CHAR, KEYEVENT_KEYDOWN, KEYEVENT_KEYUP, KEYEVENT_RAWKEYDOWN}; -use compositing::windowing::{WindowEvent, KeyEvent, MouseWindowEvent}; +use compositing::windowing::{WindowEvent, MouseWindowEvent}; use geom::point::TypedPoint2D; use geom::size::TypedSize2D; use libc::{c_double, c_int}; -use servo_msg::constellation_msg::{mod, KeyModifiers, Pressed, Released, Repeated}; +use servo_msg::constellation_msg::{mod, KeyModifiers, KeyState}; use std::cell::RefCell; pub struct ServoCefBrowserHost { @@ -83,12 +83,12 @@ cef_class_impl! { _ => constellation_msg::Key::Space, }; let key_state = match (*event).t { - KEYEVENT_RAWKEYDOWN => Pressed, - KEYEVENT_KEYDOWN | KEYEVENT_CHAR => Repeated, - KEYEVENT_KEYUP => Released, + KEYEVENT_RAWKEYDOWN => KeyState::Pressed, + KEYEVENT_KEYDOWN | KEYEVENT_CHAR => KeyState::Repeated, + KEYEVENT_KEYUP => KeyState::Released, }; let key_modifiers = KeyModifiers::empty(); // TODO(pcwalton) - core::send_window_event(KeyEvent(key, key_state, key_modifiers)) + core::send_window_event(WindowEvent::KeyEvent(key, key_state, key_modifiers)) } fn send_mouse_click_event(&_this, diff --git a/ports/cef/core.rs b/ports/cef/core.rs index c405bde596c..5f1f76bab74 100644 --- a/ports/cef/core.rs +++ b/ports/cef/core.rs @@ -11,11 +11,9 @@ use compositing::windowing::WindowEvent; use geom::size::TypedSize2D; use glfw_app; use libc::{c_char, c_int, c_void}; -use native; -use rustrt::local::Local; use servo::Browser; use servo_util::opts; -use servo_util::opts::OpenGL; +use servo_util::opts::RenderApi; use std::c_str::CString; use std::cell::RefCell; use std::rc::Rc; @@ -33,12 +31,9 @@ pub enum ServoCefGlobals { OffScreenGlobals(RefCell<Rc<window::Window>>, RefCell<Browser<window::Window>>), } -local_data_key!(pub globals: ServoCefGlobals) +thread_local!(pub static globals: Rc<RefCell<Option<ServoCefGlobals>>> = Rc::new(RefCell::new(None))) -local_data_key!(pub message_queue: RefCell<Vec<WindowEvent>>) - -// Copied from `libnative/lib.rs`. -static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20); +thread_local!(pub static message_queue: Rc<RefCell<Vec<WindowEvent>>> = Rc::new(RefCell::new(vec!()))) static CEF_API_HASH_UNIVERSAL: &'static [u8] = b"8efd129f4afc344bd04b2feb7f73a149b6c4e27f\0"; #[cfg(target_os="windows")] @@ -72,10 +67,6 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t, } } - create_rust_task(); - - message_queue.replace(Some(RefCell::new(Vec::new()))); - let urls = vec![HOME_URL.into_string()]; opts::set_opts(opts::Opts { urls: urls, @@ -110,44 +101,29 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t, user_agent: None, dump_flow_tree: false, validate_display_list_geometry: false, - render_api: OpenGL, + render_api: RenderApi::OpenGL, }); return 1 } -// Copied from `libnative/lib.rs`. -fn create_rust_task() { - let something_around_the_top_of_the_stack = 1; - let addr = &something_around_the_top_of_the_stack as *const int; - let my_stack_top = addr as uint; - - // FIXME #11359 we just assume that this thread has a stack of a - // certain size, and estimate that there's at most 20KB of stack - // frames above our current position. - - let my_stack_bottom = my_stack_top + 20000 - OS_DEFAULT_STACK_ESTIMATE; - - let task = native::task::new((my_stack_bottom, my_stack_top), rt::thread::main_guard_page()); - Local::put(task); -} - #[no_mangle] pub extern "C" fn cef_shutdown() { } #[no_mangle] pub extern "C" fn cef_run_message_loop() { - let mut the_globals = globals.get(); - let the_globals = the_globals.as_mut().unwrap(); - match **the_globals { - ServoCefGlobals::OnScreenGlobals(ref window, ref browser) => { - while browser.borrow_mut().handle_event(window.borrow_mut().wait_events()) {} - } - ServoCefGlobals::OffScreenGlobals(ref window, ref browser) => { - while browser.borrow_mut().handle_event(window.borrow_mut().wait_events()) {} + globals.with(|ref r| { + let mut the_globals = r.borrow_mut(); + match *the_globals.as_mut().unwrap() { + ServoCefGlobals::OnScreenGlobals(ref window, ref browser) => { + while browser.borrow_mut().handle_event(window.borrow_mut().wait_events()) {} + } + ServoCefGlobals::OffScreenGlobals(ref window, ref browser) => { + while browser.borrow_mut().handle_event(window.borrow_mut().wait_events()) {} + } } - } + }); } #[no_mangle] @@ -168,74 +144,67 @@ pub extern "C" fn cef_execute_process(_args: *const cef_main_args_t, } pub fn send_window_event(event: WindowEvent) { - message_queue.get().as_mut().unwrap().borrow_mut().push(event); - - let mut the_globals = globals.get(); - let the_globals = match the_globals.as_mut() { - None => return, - Some(the_globals) => the_globals, - }; - loop { - match **the_globals { - ServoCefGlobals::OnScreenGlobals(_, ref browser) => { - match browser.try_borrow_mut() { - None => { - // We're trying to send an event while processing another one. This will - // cause general badness, so queue up that event instead of immediately - // processing it. - break + message_queue.with(|ref r| r.borrow_mut().push(event.clone())); + + globals.with(|ref r| { + let mut the_globals = r.borrow_mut(); + match &mut *the_globals { + &None => return, + &Some(ref mut the_globals) => loop { + match *the_globals { + ServoCefGlobals::OnScreenGlobals(_, ref browser) => { + match browser.try_borrow_mut() { + None => { + // We're trying to send an event while processing another one. This will + // cause general badness, so queue up that event instead of immediately + // processing it. + break + } + Some(ref mut browser) => { + let event = match message_queue.with(|ref r| r.borrow_mut().pop()) { + None => return, + Some(event) => event, + }; + browser.handle_event(event); + } + } } - Some(ref mut browser) => { - let event = match message_queue.get() - .as_mut() - .unwrap() - .borrow_mut() - .pop() { - None => return, - Some(event) => event, - }; - browser.handle_event(event); - } - } - } - ServoCefGlobals::OffScreenGlobals(_, ref browser) => { - match browser.try_borrow_mut() { - None => { - // We're trying to send an event while processing another one. This will - // cause general badness, so queue up that event instead of immediately - // processing it. - break - } - Some(ref mut browser) => { - let event = match message_queue.get() - .as_mut() - .unwrap() - .borrow_mut() - .pop() { - None => return, - Some(event) => event, - }; - browser.handle_event(event); + ServoCefGlobals::OffScreenGlobals(_, ref browser) => { + match browser.try_borrow_mut() { + None => { + // We're trying to send an event while processing another one. This will + // cause general badness, so queue up that event instead of immediately + // processing it. + break + } + Some(ref mut browser) => { + let event = match message_queue.with(|ref r| r.borrow_mut().pop()) { + None => return, + Some(event) => event, + }; + browser.handle_event(event); + } + } } } } } - } + }); } macro_rules! browser_method_delegate( ( $( fn $method:ident ( ) -> $return_type:ty ; )* ) => ( $( pub fn $method() -> $return_type { - let mut the_globals = globals.get(); - let the_globals = match the_globals.as_mut() { - None => panic!("{}: no globals created", stringify!($method)), - Some(the_globals) => the_globals, - }; - match **the_globals { - ServoCefGlobals::OnScreenGlobals(_, ref browser) => browser.borrow_mut().$method(), - ServoCefGlobals::OffScreenGlobals(_, ref browser) => browser.borrow_mut().$method(), - } + globals.with(|ref r| { + match r.borrow_mut().as_mut() { + None => panic!("{}: no globals created", stringify!($method)), + Some(&ServoCefGlobals::OnScreenGlobals(_, ref browser)) => + browser.borrow_mut().$method(), + Some(&ServoCefGlobals::OffScreenGlobals(_, ref browser)) => + browser.borrow_mut().$method(), + } + }) } )* ) diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index 68f323af0bb..3fac5abb456 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -33,7 +33,6 @@ extern crate "util" as servo_util; extern crate style; extern crate stb_image; -extern crate native; extern crate rustrt; extern crate libc; extern crate "url" as std_url; diff --git a/ports/cef/string.rs b/ports/cef/string.rs index 9a817e97674..d0a0e4ba4e3 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -276,7 +276,7 @@ pub extern "C" fn cef_string_wide_to_utf8(src: *const wchar_t, src_len: size_t, } unsafe { slice::raw::buf_as_slice(src, src_len as uint, |ustr| { - let conv = ustr.iter().map(|&c| char::from_u32(c as u32).unwrap_or('\uFFFD')).collect::<String>(); + let conv = ustr.iter().map(|&c| char::from_u32(c as u32).unwrap_or('\u{FFFD}')).collect::<String>(); cef_string_utf8_set(conv.as_bytes().as_ptr(), conv.len() as size_t, output, 1) }) } diff --git a/ports/cef/window.rs b/ports/cef/window.rs index 807b72b83cd..25901c95ebf 100644 --- a/ports/cef/window.rs +++ b/ports/cef/window.rs @@ -22,8 +22,7 @@ use layers::geometry::DevicePixel; use layers::platform::surface::NativeGraphicsMetadata; use libc::{c_char, c_void}; use servo_msg::constellation_msg::{Key, KeyModifiers}; -use servo_msg::compositor_msg::{Blank, FinishedLoading, Loading, PerformingLayout, PaintState}; -use servo_msg::compositor_msg::{ReadyState}; +use servo_msg::compositor_msg::{ReadyState, PaintState}; use servo_msg::constellation_msg::LoadData; use servo_util::cursor::Cursor; use servo_util::geometry::ScreenPx; @@ -31,17 +30,6 @@ use std::cell::RefCell; use std::rc::Rc; #[cfg(target_os="macos")] -use servo_util::cursor::{AliasCursor, AllScrollCursor, ColResizeCursor, ContextMenuCursor}; -#[cfg(target_os="macos")] -use servo_util::cursor::{CopyCursor, CrosshairCursor, EResizeCursor, EwResizeCursor}; -#[cfg(target_os="macos")] -use servo_util::cursor::{GrabCursor, GrabbingCursor, NResizeCursor, NoCursor, NoDropCursor}; -#[cfg(target_os="macos")] -use servo_util::cursor::{NsResizeCursor, NotAllowedCursor, PointerCursor, RowResizeCursor}; -#[cfg(target_os="macos")] -use servo_util::cursor::{SResizeCursor, TextCursor, VerticalTextCursor, WResizeCursor}; - -#[cfg(target_os="macos")] use std::ptr; /// The type of an off-screen window. @@ -107,23 +95,23 @@ impl Window { use cocoa::base::{class, msg_send, selector}; let cocoa_name = match cursor { - NoCursor => return 0 as cef_cursor_handle_t, - ContextMenuCursor => "contextualMenuCursor", - GrabbingCursor => "closedHandCursor", - CrosshairCursor => "crosshairCursor", - CopyCursor => "dragCopyCursor", - AliasCursor => "dragLinkCursor", - TextCursor => "IBeamCursor", - GrabCursor | AllScrollCursor => "openHandCursor", - NoDropCursor | NotAllowedCursor => "operationNotAllowedCursor", - PointerCursor => "pointingHandCursor", - SResizeCursor => "resizeDownCursor", - WResizeCursor => "resizeLeftCursor", - EwResizeCursor | ColResizeCursor => "resizeLeftRightCursor", - EResizeCursor => "resizeRightCursor", - NResizeCursor => "resizeUpCursor", - NsResizeCursor | RowResizeCursor => "resizeUpDownCursor", - VerticalTextCursor => "IBeamCursorForVerticalLayout", + Cursor::NoCursor => return 0 as cef_cursor_handle_t, + Cursor::ContextMenuCursor => "contextualMenuCursor", + Cursor::GrabbingCursor => "closedHandCursor", + Cursor::CrosshairCursor => "crosshairCursor", + Cursor::CopyCursor => "dragCopyCursor", + Cursor::AliasCursor => "dragLinkCursor", + Cursor::TextCursor => "IBeamCursor", + Cursor::GrabCursor | Cursor::AllScrollCursor => "openHandCursor", + Cursor::NoDropCursor | Cursor::NotAllowedCursor => "operationNotAllowedCursor", + Cursor::PointerCursor => "pointingHandCursor", + Cursor::SResizeCursor => "resizeDownCursor", + Cursor::WResizeCursor => "resizeLeftCursor", + Cursor::EwResizeCursor | Cursor::ColResizeCursor => "resizeLeftRightCursor", + Cursor::EResizeCursor => "resizeRightCursor", + Cursor::NResizeCursor => "resizeUpCursor", + Cursor::NsResizeCursor | Cursor::RowResizeCursor => "resizeUpDownCursor", + Cursor::VerticalTextCursor => "IBeamCursorForVerticalLayout", _ => "arrowCursor", }; unsafe { @@ -185,8 +173,8 @@ impl WindowMethods for Window { Some(ref browser) => browser, }; let is_loading = match ready_state { - Blank | FinishedLoading => 0, - Loading | PerformingLayout => 1, + ReadyState::Blank | ReadyState::FinishedLoading => 0, + ReadyState::Loading | ReadyState::PerformingLayout => 1, }; browser.get_host() .get_client() diff --git a/ports/glfw/window.rs b/ports/glfw/window.rs index 090d10203ca..258bef206e4 100644 --- a/ports/glfw/window.rs +++ b/ports/glfw/window.rs @@ -7,14 +7,8 @@ use NestedEventLoopListener; use compositing::compositor_task::{mod, CompositorProxy, CompositorReceiver}; -use compositing::windowing::{Forward, Back}; -use compositing::windowing::{Idle, Resize}; -use compositing::windowing::{KeyEvent, MouseWindowEvent}; -use compositing::windowing::{MouseWindowEventClass, MouseWindowMoveEventClass}; -use compositing::windowing::Refresh; -use compositing::windowing::{Navigation, Scroll, Zoom}; -use compositing::windowing::{PinchZoom, Quit}; -use compositing::windowing::{WindowEvent, WindowMethods}; +use compositing::windowing::WindowNavigateMsg; +use compositing::windowing::{MouseWindowEvent, WindowEvent, WindowMethods}; use geom::point::{Point2D, TypedPoint2D}; use geom::scale_factor::ScaleFactor; use geom::size::TypedSize2D; @@ -23,10 +17,10 @@ use gleam::gl; use layers::geometry::DevicePixel; use layers::platform::surface::NativeGraphicsMetadata; use libc::c_int; -use msg::compositor_msg::{Blank, FinishedLoading, Loading, PaintState}; -use msg::compositor_msg::{PerformingLayout, ReadyState}; -use msg::constellation_msg::{mod, LoadData}; -use msg::constellation_msg::{Key, KeyModifiers, CONTROL, SHIFT}; +use msg::compositor_msg::{PaintState, ReadyState}; +use msg::constellation_msg::{KeyState, LoadData}; +use msg::constellation_msg::{Key, KeyModifiers}; +use msg::constellation_msg::{SHIFT, ALT, CONTROL, SUPER}; use std::cell::{Cell, RefCell}; use std::comm::Receiver; use std::num::Float; @@ -59,10 +53,11 @@ impl Window { -> Rc<Window> { // Create the GLFW window. let window_size = size.to_untyped(); - glfw.window_hint(glfw::Visible(is_foreground)); + glfw.window_hint(glfw::WindowHint::Visible(is_foreground)); let (glfw_window, events) = glfw.create_window(window_size.width as u32, window_size.height as u32, - "Servo", glfw::Windowed) + "Servo", + glfw::WindowMode::Windowed) .expect("Failed to create GLFW window"); glfw_window.make_current(); @@ -80,7 +75,7 @@ impl Window { mouse_down_button: Cell::new(None), mouse_down_point: Cell::new(Point2D(0 as c_int, 0)), - ready_state: Cell::new(Blank), + ready_state: Cell::new(ReadyState::Blank), paint_state: Cell::new(PaintState::Idle), last_title_set_time: Cell::new(Timespec::new(0, 0)), @@ -94,7 +89,7 @@ impl Window { window.glfw_window.set_cursor_pos_polling(true); window.glfw_window.set_scroll_polling(true); - glfw.set_swap_interval(1); + window.glfw.set_swap_interval(1); Rc::new(window) } @@ -122,15 +117,15 @@ impl Window { } if self.glfw_window.should_close() { - Quit + WindowEvent::Quit } else { - self.event_queue.borrow_mut().remove(0).unwrap_or(Idle) + self.event_queue.borrow_mut().remove(0).unwrap_or(WindowEvent::Idle) } } pub unsafe fn set_nested_event_loop_listener( &self, - listener: *mut NestedEventLoopListener + 'static) { + listener: *mut (NestedEventLoopListener + 'static)) { self.glfw_window.set_refresh_polling(false); glfw::ffi::glfwSetWindowRefreshCallback(self.glfw_window.ptr, Some(on_refresh)); glfw::ffi::glfwSetFramebufferSizeCallback(self.glfw_window.ptr, Some(on_framebuffer_size)); @@ -145,7 +140,7 @@ impl Window { } } -static mut g_nested_event_loop_listener: Option<*mut NestedEventLoopListener + 'static> = None; +static mut g_nested_event_loop_listener: Option<*mut (NestedEventLoopListener + 'static)> = None; impl WindowMethods for Window { /// Returns the size of the window in hardware pixels. @@ -215,16 +210,16 @@ impl WindowMethods for Window { match key { Key::Escape => self.glfw_window.set_should_close(true), Key::Equal if mods.contains(CONTROL) => { // Ctrl-+ - self.event_queue.borrow_mut().push(Zoom(1.1)); + self.event_queue.borrow_mut().push(WindowEvent::Zoom(1.1)); } Key::Minus if mods.contains(CONTROL) => { // Ctrl-- - self.event_queue.borrow_mut().push(Zoom(1.0/1.1)); + self.event_queue.borrow_mut().push(WindowEvent::Zoom(1.0/1.1)); } Key::Backspace if mods.contains(SHIFT) => { // Shift-Backspace - self.event_queue.borrow_mut().push(Navigation(Forward)); + self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Forward)); } Key::Backspace => { // Backspace - self.event_queue.borrow_mut().push(Navigation(Back)); + self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Back)); } Key::PageDown => { let (_, height) = self.glfw_window.get_size(); @@ -258,31 +253,31 @@ impl WindowMethods for Window { impl Window { fn handle_window_event(&self, window: &glfw::Window, event: glfw::WindowEvent) { match event { - glfw::KeyEvent(key, _, action, mods) => { + glfw::WindowEvent::Key(key, _, action, mods) => { let key = glfw_key_to_script_key(key); let state = match action { - glfw::Press => constellation_msg::Pressed, - glfw::Release => constellation_msg::Released, - glfw::Repeat => constellation_msg::Repeated, + glfw::Action::Press => KeyState::Pressed, + glfw::Action::Release => KeyState::Released, + glfw::Action::Repeat => KeyState::Repeated, }; let modifiers = glfw_mods_to_script_mods(mods); - self.event_queue.borrow_mut().push(KeyEvent(key, state, modifiers)); + self.event_queue.borrow_mut().push(WindowEvent::KeyEvent(key, state, modifiers)); }, - glfw::FramebufferSizeEvent(width, height) => { + glfw::WindowEvent::FramebufferSize(width, height) => { self.event_queue.borrow_mut().push( - Resize(TypedSize2D(width as uint, height as uint))); + WindowEvent::Resize(TypedSize2D(width as uint, height as uint))); }, - glfw::RefreshEvent => { - self.event_queue.borrow_mut().push(Refresh); + glfw::WindowEvent::Refresh => { + self.event_queue.borrow_mut().push(WindowEvent::Refresh); }, - glfw::MouseButtonEvent(button, action, _mods) => { + glfw::WindowEvent::MouseButton(button, action, _mods) => { let cursor_position = self.cursor_position(); match button { glfw::MouseButton::Button5 => { // Back button (might be different per platform) - self.event_queue.borrow_mut().push(Navigation(Back)); + self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Back)); }, glfw::MouseButton::Button6 => { // Forward - self.event_queue.borrow_mut().push(Navigation(Forward)); + self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Forward)); }, glfw::MouseButtonLeft | glfw::MouseButtonRight => { self.handle_mouse(button, @@ -293,20 +288,20 @@ impl Window { _ => {} } }, - glfw::CursorPosEvent(..) => { + glfw::WindowEvent::CursorPos(..) => { self.event_queue .borrow_mut() - .push(MouseWindowMoveEventClass(self.cursor_position())); + .push(WindowEvent::MouseWindowMoveEventClass(self.cursor_position())); }, - glfw::ScrollEvent(xpos, ypos) => { + glfw::WindowEvent::Scroll(xpos, ypos) => { match (window.get_key(glfw::Key::LeftControl), window.get_key(glfw::Key::RightControl)) { - (glfw::Press, _) | (_, glfw::Press) => { + (glfw::Action::Press, _) | (_, glfw::Action::Press) => { // Ctrl-Scrollwheel simulates a "pinch zoom" gesture. if ypos < 0.0 { - self.event_queue.borrow_mut().push(PinchZoom(1.0/1.1)); + self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(1.0/1.1)); } else if ypos > 0.0 { - self.event_queue.borrow_mut().push(PinchZoom(1.1)); + self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(1.1)); } }, _ => { @@ -323,7 +318,7 @@ impl Window { /// Helper function to send a scroll event. fn scroll_window(&self, dx: f32, dy: f32) { let cursor_pos = self.cursor_position().cast().unwrap(); - self.event_queue.borrow_mut().push(Scroll(TypedPoint2D(dx, dy), cursor_pos)); + self.event_queue.borrow_mut().push(WindowEvent::Scroll(TypedPoint2D(dx, dy), cursor_pos)); } /// Helper function to set the window title in accordance with the ready state. @@ -335,16 +330,16 @@ impl Window { self.last_title_set_time.set(now); match self.ready_state.get() { - Blank => { + ReadyState::Blank => { self.glfw_window.set_title("blank — Servo [GLFW]") } - Loading => { + ReadyState::Loading => { self.glfw_window.set_title("Loading — Servo [GLFW]") } - PerformingLayout => { + ReadyState::PerformingLayout => { self.glfw_window.set_title("Performing Layout — Servo [GLFW]") } - FinishedLoading => { + ReadyState::FinishedLoading => { match self.paint_state.get() { PaintState::Painting => { self.glfw_window.set_title("Rendering — Servo [GLFW]") @@ -362,12 +357,12 @@ impl Window { // FIXME(tkuehn): max pixel dist should be based on pixel density let max_pixel_dist = 10f64; let event = match action { - glfw::Press => { + glfw::Action::Press => { self.mouse_down_point.set(Point2D(x, y)); self.mouse_down_button.set(Some(button)); MouseWindowEvent::MouseDown(button as uint, TypedPoint2D(x as f32, y as f32)) } - glfw::Release => { + glfw::Action::Release => { match self.mouse_down_button.get() { None => (), Some(but) if button == but => { @@ -377,7 +372,7 @@ impl Window { if pixel_dist < max_pixel_dist { let click_event = MouseWindowEvent::Click( button as uint, TypedPoint2D(x as f32, y as f32)); - self.event_queue.borrow_mut().push(MouseWindowEventClass(click_event)); + self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(click_event)); } } Some(_) => (), @@ -386,7 +381,7 @@ impl Window { } _ => panic!("I cannot recognize the type of mouse action that occured. :-(") }; - self.event_queue.borrow_mut().push(MouseWindowEventClass(event)); + self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(event)); } /// Returns the cursor position, properly accounting for HiDPI. @@ -420,7 +415,7 @@ extern "C" fn on_refresh(_glfw_window: *mut glfw::ffi::GLFWwindow) { match g_nested_event_loop_listener { None => {} Some(listener) => { - (*listener).handle_event_from_nested_event_loop(Refresh); + (*listener).handle_event_from_nested_event_loop(WindowEvent::Refresh); } } } @@ -434,25 +429,25 @@ extern "C" fn on_framebuffer_size(_glfw_window: *mut glfw::ffi::GLFWwindow, None => {} Some(listener) => { let size = TypedSize2D(width as uint, height as uint); - (*listener).handle_event_from_nested_event_loop(Resize(size)); + (*listener).handle_event_from_nested_event_loop(WindowEvent::Resize(size)); } } } } -fn glfw_mods_to_script_mods(mods: glfw::Modifiers) -> constellation_msg::KeyModifiers { - let mut result = constellation_msg::KeyModifiers::from_bits(0).unwrap(); +fn glfw_mods_to_script_mods(mods: glfw::Modifiers) -> KeyModifiers { + let mut result = KeyModifiers::from_bits(0).unwrap(); if mods.contains(glfw::Shift) { - result.insert(constellation_msg::SHIFT); + result.insert(SHIFT); } if mods.contains(glfw::Alt) { - result.insert(constellation_msg::ALT); + result.insert(ALT); } if mods.contains(glfw::Control) { - result.insert(constellation_msg::CONTROL); + result.insert(CONTROL); } if mods.contains(glfw::Super) { - result.insert(constellation_msg::SUPER); + result.insert(SUPER); } result } @@ -460,12 +455,12 @@ fn glfw_mods_to_script_mods(mods: glfw::Modifiers) -> constellation_msg::KeyModi macro_rules! glfw_keys_to_script_keys( ($key:expr, $($name:ident),+) => ( match $key { - $(glfw::Key::$name => constellation_msg::Key::$name,)+ + $(glfw::Key::$name => Key::$name,)+ } ); ) -fn glfw_key_to_script_key(key: glfw::Key) -> constellation_msg::Key { +fn glfw_key_to_script_key(key: glfw::Key) -> Key { glfw_keys_to_script_keys!(key, Space, Apostrophe, diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index a5156f6d714..ea0e80cbfe9 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -5,21 +5,16 @@ //! A windowing implementation using glutin. use compositing::compositor_task::{mod, CompositorProxy, CompositorReceiver}; -use compositing::windowing::{WindowEvent, WindowMethods, KeyEvent}; -use compositing::windowing::{Idle, Resize}; -use compositing::windowing::{MouseWindowEventClass, MouseWindowMoveEventClass, Scroll}; -use compositing::windowing::{Zoom, PinchZoom, Navigation}; -use compositing::windowing::{Quit, MouseWindowEvent}; -use compositing::windowing::{Forward, Back}; +use compositing::windowing::WindowNavigateMsg; +use compositing::windowing::{MouseWindowEvent, WindowEvent, WindowMethods}; use geom::point::{Point2D, TypedPoint2D}; use geom::scale_factor::ScaleFactor; use geom::size::TypedSize2D; use layers::geometry::DevicePixel; use layers::platform::surface::NativeGraphicsMetadata; use msg::constellation_msg; -use msg::constellation_msg::{Key, CONTROL, SHIFT, ALT}; -use msg::compositor_msg::{PaintState, FinishedLoading, Blank, Loading}; -use msg::compositor_msg::{PerformingLayout, ReadyState}; +use msg::constellation_msg::{Key, KeyState, CONTROL, SHIFT, ALT}; +use msg::compositor_msg::{PaintState, ReadyState}; use msg::constellation_msg::LoadData; use std::cell::{Cell, RefCell}; use std::num::Float; @@ -27,7 +22,7 @@ use std::rc::Rc; use time::{mod, Timespec}; use util::geometry::ScreenPx; use util::opts; -use util::opts::{RenderApi, Mesa, OpenGL}; +use util::opts::RenderApi; use gleam::gl; use glutin; use glutin::{ElementState, Event, MouseButton, VirtualKeyCode}; @@ -47,21 +42,21 @@ enum WindowHandle { Headless(HeadlessContext), } -static mut g_nested_event_loop_listener: Option<*mut NestedEventLoopListener + 'static> = None; +static mut g_nested_event_loop_listener: Option<*mut (NestedEventLoopListener + 'static)> = None; fn nested_window_resize(width: uint, height: uint) { unsafe { match g_nested_event_loop_listener { None => {} Some(listener) => { - (*listener).handle_event_from_nested_event_loop(Resize(TypedSize2D(width, height))); + (*listener).handle_event_from_nested_event_loop(WindowEvent::Resize(TypedSize2D(width, height))); } } } } bitflags!( - #[deriving(Show)] + #[deriving(Show, Copy)] flags KeyModifiers: u8 { const LEFT_CONTROL = 1, const RIGHT_CONTROL = 2, @@ -119,7 +114,7 @@ impl Window { let window_size = size.to_untyped(); let glutin = match render_api { - OpenGL => { + RenderApi::OpenGL => { let mut glutin_window = glutin::WindowBuilder::new() .with_title("Servo [glutin]".to_string()) .with_dimensions(window_size.width, window_size.height) @@ -132,7 +127,7 @@ impl Window { glutin_window.set_window_resize_callback(Some(nested_window_resize)); WindowHandle::Windowed(glutin_window) } - Mesa => { + RenderApi::Mesa => { let headless_builder = glutin::HeadlessRendererBuilder::new(window_size.width, window_size.height); let headless_context = headless_builder.build().unwrap(); @@ -154,7 +149,7 @@ impl Window { mouse_down_point: Cell::new(Point2D(0, 0)), mouse_pos: Cell::new(Point2D(0, 0)), - ready_state: Cell::new(Blank), + ready_state: Cell::new(ReadyState::Blank), paint_state: Cell::new(PaintState::Idle), key_modifiers: Cell::new(KeyModifiers::empty()), @@ -298,16 +293,16 @@ impl WindowMethods for Window { fn handle_key(&self, key: Key, mods: constellation_msg::KeyModifiers) { match key { Key::Equal if mods.contains(CONTROL) => { // Ctrl-+ - self.event_queue.borrow_mut().push(Zoom(1.1)); + self.event_queue.borrow_mut().push(WindowEvent::Zoom(1.1)); } Key::Minus if mods.contains(CONTROL) => { // Ctrl-- - self.event_queue.borrow_mut().push(Zoom(1.0/1.1)); + self.event_queue.borrow_mut().push(WindowEvent::Zoom(1.0/1.1)); } Key::Backspace if mods.contains(SHIFT) => { // Shift-Backspace - self.event_queue.borrow_mut().push(Navigation(Forward)); + self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Forward)); } Key::Backspace => { // Backspace - self.event_queue.borrow_mut().push(Navigation(Back)); + self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Back)); } Key::PageDown => { self.scroll_window(0.0, -self.framebuffer_size().as_f32().to_untyped().height); @@ -332,16 +327,16 @@ impl Window { self.last_title_set_time.set(now); match self.ready_state.get() { - Blank => { + ReadyState::Blank => { window.set_title("blank - Servo [glutin]") } - Loading => { + ReadyState::Loading => { window.set_title("Loading - Servo [glutin]") } - PerformingLayout => { + ReadyState::PerformingLayout => { window.set_title("Performing Layout - Servo [glutin]") } - FinishedLoading => { + ReadyState::FinishedLoading => { match self.paint_state.get() { PaintState::Painting => { window.set_title("Rendering - Servo [glutin]") @@ -403,9 +398,9 @@ impl Window { (ElementState::Pressed, key_code) => { match glutin_key_to_script_key(key_code) { Ok(key) => { - let state = constellation_msg::Pressed; + let state = KeyState::Pressed; let modifiers = glutin_mods_to_script_mods(self.key_modifiers.get()); - self.event_queue.borrow_mut().push(KeyEvent(key, state, modifiers)); + self.event_queue.borrow_mut().push(WindowEvent::KeyEvent(key, state, modifiers)); } _ => {} } @@ -415,7 +410,7 @@ impl Window { } } Event::Resized(width, height) => { - self.event_queue.borrow_mut().push(Resize(TypedSize2D(width, height))); + self.event_queue.borrow_mut().push(WindowEvent::Resize(TypedSize2D(width, height))); } Event::MouseInput(element_state, mouse_button) => { if mouse_button == MouseButton::LeftMouseButton || @@ -427,15 +422,15 @@ impl Window { Event::MouseMoved((x, y)) => { self.mouse_pos.set(Point2D(x, y)); self.event_queue.borrow_mut().push( - MouseWindowMoveEventClass(TypedPoint2D(x as f32, y as f32))); + WindowEvent::MouseWindowMoveEventClass(TypedPoint2D(x as f32, y as f32))); } Event::MouseWheel(delta) => { if self.ctrl_pressed() { // Ctrl-Scrollwheel simulates a "pinch zoom" gesture. if delta < 0 { - self.event_queue.borrow_mut().push(PinchZoom(1.0/1.1)); + self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(1.0/1.1)); } else if delta > 0 { - self.event_queue.borrow_mut().push(PinchZoom(1.1)); + self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(1.1)); } } else { let dx = 0.0; @@ -463,8 +458,8 @@ impl Window { /// Helper function to send a scroll event. fn scroll_window(&self, dx: f32, dy: f32) { let mouse_pos = self.mouse_pos.get(); - let event = Scroll(TypedPoint2D(dx as f32, dy as f32), - TypedPoint2D(mouse_pos.x as i32, mouse_pos.y as i32)); + let event = WindowEvent::Scroll(TypedPoint2D(dx as f32, dy as f32), + TypedPoint2D(mouse_pos.x as i32, mouse_pos.y as i32)); self.event_queue.borrow_mut().push(event); } @@ -488,7 +483,7 @@ impl Window { if pixel_dist < max_pixel_dist { let click_event = MouseWindowEvent::Click( 0, TypedPoint2D(x as f32, y as f32)); - self.event_queue.borrow_mut().push(MouseWindowEventClass(click_event)); + self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(click_event)); } } Some(_) => (), @@ -496,12 +491,12 @@ impl Window { MouseWindowEvent::MouseUp(0, TypedPoint2D(x as f32, y as f32)) } }; - self.event_queue.borrow_mut().push(MouseWindowEventClass(event)); + self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(event)); } pub unsafe fn set_nested_event_loop_listener( &self, - listener: *mut NestedEventLoopListener + 'static) { + listener: *mut (NestedEventLoopListener + 'static)) { g_nested_event_loop_listener = Some(listener) } @@ -541,13 +536,13 @@ impl Window { } if close_event || window.is_closed() { - Quit + WindowEvent::Quit } else { - self.event_queue.borrow_mut().remove(0).unwrap_or(Idle) + self.event_queue.borrow_mut().remove(0).unwrap_or(WindowEvent::Idle) } } WindowHandle::Headless(_) => { - self.event_queue.borrow_mut().remove(0).unwrap_or(Idle) + self.event_queue.borrow_mut().remove(0).unwrap_or(WindowEvent::Idle) } } } diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 6be4f9e4535..db5159c4bc6 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "azure" version = "0.1.0" -source = "git+https://github.com/servo/rust-azure#fe95551ca22f2a75b0dd690a72841df39b33885d" +source = "git+https://github.com/servo/rust-azure#6884d442052becfcafccc82b17ab316c7831d8d2" dependencies = [ "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)", @@ -64,24 +64,24 @@ dependencies = [ "png 0.1.0 (git+https://github.com/servo/rust-png)", "script_traits 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "cookie" -version = "0.0.1" -source = "git+https://github.com/servo/cookie-rs#f82090b19c2738b90528167ef873d8eac0353294" +version = "0.1.0" +source = "git+https://github.com/alexcrichton/cookie-rs#8d1b4bb8d5ed06e58c162eb235a4ccd210b68108" dependencies = [ - "openssl 0.0.2 (git+https://github.com/servo/rust-openssl)", + "openssl 0.2.4 (git+https://github.com/sfackler/rust-openssl)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", ] [[package]] name = "core_foundation" version = "0.1.0" -source = "git+https://github.com/servo/rust-core-foundation#d2dbe4fb6f6892521a37735cd7a97098d1b64808" +source = "git+https://github.com/servo/rust-core-foundation#81db9ab15f67e16d7a3e9705a06cad65192014fd" [[package]] name = "core_graphics" @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "core_text" version = "0.1.0" -source = "git+https://github.com/servo/rust-core-text#85784007b6fa1b8f9614059edcd0429b2bd69a11" +source = "git+https://github.com/servo/rust-core-text#cb369a26a0eb4e83c2128ceb3c685a191113417a" dependencies = [ "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", "core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)", @@ -102,11 +102,11 @@ dependencies = [ [[package]] name = "cssparser" -version = "0.1.0" -source = "git+https://github.com/servo/rust-cssparser#a2b0b6b00ad84dc3a4b4faf77ddd63611c8ce58a" +version = "0.1.1" +source = "git+https://github.com/servo/rust-cssparser#110bf3052d016bf6eda0689fb21cf971e2c23dc8" dependencies = [ - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", - "text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "text_writer 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -132,60 +132,60 @@ source = "git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c [[package]] name = "encoding" -version = "0.2.3" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding-index-japanese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-korean 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-simpchinese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-singlebyte 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", - "encoding-index-tradchinese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding-index-japanese 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-korean 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-simpchinese 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-singlebyte 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding-index-tradchinese 1.0.20140915 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-japanese" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-korean" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-simpchinese" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-singlebyte" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding-index-tradchinese" version = "1.0.20140915" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "encoding_index_tests 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding_index_tests 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "encoding_index_tests" version = "0.1.0" -source = "git+https://github.com/lifthrasiir/rust-encoding#15ac0ded3ca592c31ded5b9ff6f9fe2fa4b73fc4" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "expat-sys" @@ -225,9 +225,14 @@ version = "0.0.2" source = "git+https://github.com/alexcrichton/gcc-rs#903e8f8a2e3766ad3d514404d452dbaa1d3b2d79" [[package]] +name = "gcc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "geom" version = "0.1.0" -source = "git+https://github.com/servo/rust-geom#0f77c6ad116748b7e6bedbf2414d4ceea17debc2" +source = "git+https://github.com/servo/rust-geom#05f2d5494355adc78ad7d17286912f0d128f503b" [[package]] name = "gfx" @@ -250,23 +255,23 @@ dependencies = [ "stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)", "style 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "gl_common" version = "0.0.1" -source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb726f242d" +source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa4f67c6e" [[package]] name = "gl_generator" version = "0.0.1" -source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb726f242d" +source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa4f67c6e" dependencies = [ "gl_common 0.0.1 (git+https://github.com/bjz/gl-rs.git)", "khronos_api 0.0.2 (git+https://github.com/bjz/gl-rs.git)", - "rust-xml 0.1.2-pre (git+https://github.com/netvl/rust-xml)", + "xml-rs 0.1.3 (git+https://github.com/netvl/xml-rs)", ] [[package]] @@ -293,11 +298,11 @@ source = "git+https://github.com/servo/rust-harfbuzz#8aab215463214647b7a81f66011 [[package]] name = "html5ever" version = "0.0.0" -source = "git+https://github.com/servo/html5ever#e6f8d83de9fffe63a825d95d957ba6bcbc3e1632" +source = "git+https://github.com/servo/html5ever#0abe5e30cc03f9e73bfd4fdc018192d149c21fb3" dependencies = [ "html5ever_macros 0.0.0 (git+https://github.com/servo/html5ever)", - "phf 0.0.0 (git+https://github.com/sfackler/rust-phf)", - "phf_mac 0.0.0 (git+https://github.com/sfackler/rust-phf)", + "phf 0.0.1 (git+https://github.com/sfackler/rust-phf)", + "phf_mac 0.0.1 (git+https://github.com/sfackler/rust-phf)", "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "time 0.1.0 (git+https://github.com/rust-lang/time)", @@ -306,19 +311,20 @@ dependencies = [ [[package]] name = "html5ever_macros" version = "0.0.0" -source = "git+https://github.com/servo/html5ever#e6f8d83de9fffe63a825d95d957ba6bcbc3e1632" +source = "git+https://github.com/servo/html5ever#0abe5e30cc03f9e73bfd4fdc018192d149c21fb3" [[package]] name = "hyper" version = "0.0.1" -source = "git+https://github.com/servo/hyper?ref=servo#4a2c82c75013f8ee55d2017876319b48d656dcb3" +source = "git+https://github.com/servo/hyper?ref=servo#43becc919c24939b8b84fe541b0e0898a4827836" dependencies = [ - "cookie 0.0.1 (git+https://github.com/servo/cookie-rs)", + "cookie 0.1.0 (git+https://github.com/alexcrichton/cookie-rs)", "mime 0.0.1 (git+https://github.com/hyperium/mime.rs)", - "openssl 0.0.2 (git+https://github.com/servo/rust-openssl)", + "mucell 0.1.2 (git+https://github.com/chris-morgan/mucell)", + "openssl 0.2.4 (git+https://github.com/sfackler/rust-openssl)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "unsafe-any 0.1.0 (git+https://github.com/reem/rust-unsafe-any)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "unsafe-any 0.1.1 (git+https://github.com/reem/rust-unsafe-any)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", ] [[package]] @@ -335,7 +341,7 @@ dependencies = [ [[package]] name = "js" version = "0.1.0" -source = "git+https://github.com/servo/rust-mozjs#2d86d6fb7ece49ff2f469c391e15e13f2b02af42" +source = "git+https://github.com/servo/rust-mozjs#e01a846241bd98ac424878e3f8d3e9b989c79242" dependencies = [ "mozjs-sys 0.0.0 (git+https://github.com/servo/mozjs)", ] @@ -343,12 +349,12 @@ dependencies = [ [[package]] name = "khronos_api" version = "0.0.2" -source = "git+https://github.com/bjz/gl-rs.git#c76c23fc9a0dae824b45550d4b823cdb726f242d" +source = "git+https://github.com/bjz/gl-rs.git#b5e3f4f76c31bc1b459d5e4c10d879ffa4f67c6e" [[package]] name = "layers" version = "0.1.0" -source = "git+https://github.com/servo/rust-layers#21798aac4de6bfd800836f419dd5b6a308edcaa4" +source = "git+https://github.com/servo/rust-layers#574df7e1c1dd464af930d1cc735ca8d6af46bb90" dependencies = [ "cgl 0.0.1 (git+https://github.com/servo/rust-cgl)", "core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)", @@ -364,8 +370,8 @@ dependencies = [ name = "layout" version = "0.0.1" dependencies = [ - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "gfx 0.0.1", "layout_traits 0.0.1", @@ -376,7 +382,7 @@ dependencies = [ "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "style 0.0.1", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] @@ -394,7 +400,7 @@ dependencies = [ [[package]] name = "lazy_static" version = "0.1.0" -source = "git+https://github.com/Kimundi/lazy-static.rs#62976cb611c5396e11315ae64c9c389576240eb7" +source = "git+https://github.com/Kimundi/lazy-static.rs#76f06e4fa7bc8c92f11d1def19bd4ddfd8017cd8" [[package]] name = "libressl-pnacl-sys" @@ -425,11 +431,16 @@ dependencies = [ "io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", "style 0.0.1", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] +name = "mucell" +version = "0.1.2" +source = "git+https://github.com/chris-morgan/mucell#d198c6605b3e688719db168db0939051c803b1ea" + +[[package]] name = "net" version = "0.0.1" dependencies = [ @@ -438,42 +449,42 @@ dependencies = [ "png 0.1.0 (git+https://github.com/servo/rust-png)", "stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] [[package]] name = "openssl" -version = "0.0.2" -source = "git+https://github.com/servo/rust-openssl#aed5df1036d6f4b5f7b8be6457d10f8a0379b39f" +version = "0.2.4" +source = "git+https://github.com/sfackler/rust-openssl#f299e336d06a85438c3ee90aa06235510f3f5dbe" dependencies = [ - "libressl-pnacl-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.0.2 (git+https://github.com/servo/rust-openssl)", + "openssl-sys 0.2.4 (git+https://github.com/sfackler/rust-openssl)", ] [[package]] name = "openssl-sys" -version = "0.0.2" -source = "git+https://github.com/servo/rust-openssl#aed5df1036d6f4b5f7b8be6457d10f8a0379b39f" +version = "0.2.4" +source = "git+https://github.com/sfackler/rust-openssl#f299e336d06a85438c3ee90aa06235510f3f5dbe" dependencies = [ + "libressl-pnacl-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "phf" -version = "0.0.0" -source = "git+https://github.com/sfackler/rust-phf#aa3e2d0aedea4d55c2e4cea1bdf6e89418dc1206" +version = "0.0.1" +source = "git+https://github.com/sfackler/rust-phf#6a7cc6eb9ec08b103b6b62fa39bdb3229f3cdbe4" dependencies = [ - "xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)", + "xxhash 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "phf_mac" -version = "0.0.0" -source = "git+https://github.com/sfackler/rust-phf#aa3e2d0aedea4d55c2e4cea1bdf6e89418dc1206" +version = "0.0.1" +source = "git+https://github.com/sfackler/rust-phf#6a7cc6eb9ec08b103b6b62fa39bdb3229f3cdbe4" dependencies = [ - "time 0.1.0 (git+https://github.com/rust-lang/time)", - "xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)", + "time 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "xxhash 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -504,18 +515,13 @@ version = "1.6.3" source = "git+https://github.com/servo/libpng?ref=servo#d01f32b4eb86904695efe7fc02b574f902e21a98" [[package]] -name = "rust-xml" -version = "0.1.2-pre" -source = "git+https://github.com/netvl/rust-xml#2d9df3267aeaa4d442e1e19a4dfed733cb1397ed" - -[[package]] name = "script" version = "0.0.1" dependencies = [ "canvas 0.0.1", - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", "devtools_traits 0.0.1", - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "gfx 0.0.1", "html5ever 0.0.0 (git+https://github.com/servo/html5ever)", @@ -529,9 +535,9 @@ dependencies = [ "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "style 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", - "uuid 0.0.2 (git+https://github.com/rust-lang/uuid)", + "uuid 0.1.1 (git+https://github.com/rust-lang/uuid)", ] [[package]] @@ -542,7 +548,7 @@ dependencies = [ "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "msg 0.0.1", "net 0.0.1", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] @@ -557,7 +563,7 @@ dependencies = [ "net 0.0.1", "script 0.0.1", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] @@ -578,19 +584,19 @@ source = "git+https://github.com/servo/rust-stb-image#97d7e440e80e41a304647363c3 [[package]] name = "string_cache" version = "0.0.0" -source = "git+https://github.com/servo/string-cache#a18a432fd274e816fc41876536f70e5380abb677" +source = "git+https://github.com/servo/string-cache#661c537b85f19ac81dfcd84e28557d480b6b7a9f" dependencies = [ "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)", - "phf 0.0.0 (git+https://github.com/sfackler/rust-phf)", - "phf_mac 0.0.0 (git+https://github.com/sfackler/rust-phf)", + "phf 0.0.1 (git+https://github.com/sfackler/rust-phf)", + "phf_mac 0.0.1 (git+https://github.com/sfackler/rust-phf)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", - "xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)", + "xxhash 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "string_cache_macros" version = "0.0.0" -source = "git+https://github.com/servo/string-cache#a18a432fd274e816fc41876536f70e5380abb677" +source = "git+https://github.com/servo/string-cache#661c537b85f19ac81dfcd84e28557d480b6b7a9f" dependencies = [ "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)", ] @@ -599,15 +605,15 @@ dependencies = [ name = "style" version = "0.0.1" dependencies = [ - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", - "encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", + "encoding 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)", "plugins 0.0.1", "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", - "text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "text_writer 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", "util 0.0.1", ] @@ -617,7 +623,7 @@ version = "0.0.1" [[package]] name = "text_writer" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -629,34 +635,43 @@ dependencies = [ ] [[package]] +name = "time" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "unsafe-any" -version = "0.1.0" -source = "git+https://github.com/reem/rust-unsafe-any#2863af363bbd83079b6773920bba5b736408db33" +version = "0.1.1" +source = "git+https://github.com/reem/rust-unsafe-any#eb3fe87bea85f375b8fcefa0cdecfd131fae9624" [[package]] name = "url" -version = "0.1.0" -source = "git+https://github.com/servo/rust-url#46458f80e48c542b2f175e36e5b7d30782ca7dc5" +version = "0.2.4" +source = "git+https://github.com/servo/rust-url#79f8034a8e1815ffa1f49204572ddbf6eb747c75" [[package]] name = "util" version = "0.0.1" dependencies = [ - "cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)", + "cssparser 0.1.1 (git+https://github.com/servo/rust-cssparser)", "geom 0.1.0 (git+https://github.com/servo/rust-geom)", "layers 0.1.0 (git+https://github.com/servo/rust-layers)", + "plugins 0.0.1", "string_cache 0.0.0 (git+https://github.com/servo/string-cache)", "string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)", "task_info 0.0.1", - "text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "text_writer 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.0 (git+https://github.com/rust-lang/time)", - "url 0.1.0 (git+https://github.com/servo/rust-url)", + "url 0.2.4 (git+https://github.com/servo/rust-url)", ] [[package]] name = "uuid" -version = "0.0.2" -source = "git+https://github.com/rust-lang/uuid#f5d94d0043a615756edefaf9c6041f11e52b8370" +version = "0.1.1" +source = "git+https://github.com/rust-lang/uuid#fc793c974a25c126c5cf5daa3b18973512a7a6a0" [[package]] name = "xlib" @@ -664,7 +679,12 @@ version = "0.1.0" source = "git+https://github.com/servo/rust-xlib#58ec3847b592aeabdcfeb6a2d02033d3a2c7f427" [[package]] +name = "xml-rs" +version = "0.1.3" +source = "git+https://github.com/netvl/xml-rs#1a812d3ba720afd768bd75d29a5b5f10ddcdfbeb" + +[[package]] name = "xxhash" -version = "0.0.1" -source = "git+https://github.com/Jurily/rust-xxhash#64f8d02314735f511cb4272563d0f703d575c159" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/python/tidy.py b/python/tidy.py index 54901fd9b02..da930eea333 100644 --- a/python/tidy.py +++ b/python/tidy.py @@ -25,6 +25,9 @@ ignored_files = [ "components/script/dom/bindings/codegen/*", "components/style/properties/mod.rs", "components/servo/target/*", + + # MIT license + "components/util/deque/mod.rs", ] diff --git a/rust-snapshot-hash b/rust-snapshot-hash index 784693ecb7f..82317dbea35 100644 --- a/rust-snapshot-hash +++ b/rust-snapshot-hash @@ -1 +1 @@ -3dcd2157403163789aaf21a9ab3c4d30a7c6494d/rust-0.13.0-dev +2cfb5acb5a2751c759627377e602bac4f88f2d19/rust-0.13.0-dev diff --git a/support/android-rs-glue b/support/android-rs-glue -Subproject e59b03e0d74e78852f8658aa038e1ae54758ba6 +Subproject 122bc28545b5e59a923c466a484c403fa691bd5 diff --git a/tests/contenttest.rs b/tests/contenttest.rs index 438f8b5fccf..3214b3d9025 100644 --- a/tests/contenttest.rs +++ b/tests/contenttest.rs @@ -15,6 +15,7 @@ extern crate regex; extern crate test; use test::{AutoColor, TestOpts, run_tests_console, TestDesc, TestDescAndFn, DynTestFn, DynTestName}; +use test::ShouldFail; use getopts::{getopts, reqopt}; use std::{os, str}; use std::io::fs; @@ -66,7 +67,10 @@ fn test_options(config: Config) -> TestOpts { test_shard: None, logfile: None, nocapture: false, - color: AutoColor + color: AutoColor, + show_boxplot: false, + boxplot_width: 0, + show_all_stats: false, } } @@ -85,14 +89,14 @@ fn make_test(file: String) -> TestDescAndFn { desc: TestDesc { name: DynTestName(file.clone()), ignore: false, - should_fail: false + should_fail: ShouldFail::No, }, testfn: DynTestFn(proc() { run_test(file) }) } } fn run_test(file: String) { - let path = os::make_absolute(&Path::new(file)); + let path = os::make_absolute(&Path::new(file)).unwrap(); // FIXME (#1094): not the right way to transform a path let infile = format!("file://{}", path.display()); let stdout = CreatePipe(false, true); @@ -100,7 +104,7 @@ fn run_test(file: String) { let args = ["-z", "-f", infile.as_slice()]; let mut prc = match Command::new(os::self_exe_path().unwrap().join("servo")) - .args(args) + .args(args.as_slice()) .stdin(Ignored) .stdout(stdout) .stderr(stderr) diff --git a/tests/reftest.rs b/tests/reftest.rs index fcb47e16ac4..92c84b28b55 100644 --- a/tests/reftest.rs +++ b/tests/reftest.rs @@ -22,13 +22,14 @@ use std::io::process::ExitStatus; use std::io::fs::PathExtensions; use std::os; use std::path::Path; -use test::{AutoColor, DynTestName, DynTestFn, TestDesc, TestOpts, TestDescAndFn}; +use test::{AutoColor, DynTestName, DynTestFn, TestDesc, TestOpts, TestDescAndFn, ShouldFail}; use test::run_tests_console; use regex::Regex; use url::Url; bitflags!( + #[deriving(Copy)] flags RenderMode: u32 { const CPU_RENDERING = 0x00000001, const GPU_RENDERING = 0x00000010, @@ -95,7 +96,10 @@ fn main() { save_metrics: None, test_shard: None, nocapture: false, - color: AutoColor + color: AutoColor, + show_boxplot: false, + boxplot_width: 0, + show_all_stats: false, }; match run(test_opts, @@ -191,7 +195,7 @@ fn parse_lists(file: &Path, servo_args: &[String], render_mode: RenderMode, id_o // If we're running this directly, file.dir_path() might be relative. // (see issue #3521) let base = match file.dir_path().is_relative() { - true => os::getcwd().join(file.dir_path()), + true => os::getcwd().unwrap().join(file.dir_path()), false => file.dir_path() }; @@ -239,7 +243,7 @@ fn make_test(reftest: Reftest) -> TestDescAndFn { desc: TestDesc { name: DynTestName(name), ignore: false, - should_fail: false, + should_fail: ShouldFail::No, }, testfn: DynTestFn(proc() { check_reftest(reftest); @@ -255,7 +259,7 @@ fn capture(reftest: &Reftest, side: uint) -> (u32, u32, Vec<u8>) { // Allows pixel perfect rendering of Ahem font for reftests. .arg("-Z") .arg("disable-text-aa") - .args(["-f", "-o"]) + .args(["-f", "-o"].as_slice()) .arg(png_filename.as_slice()) .arg({ let mut url = Url::from_file_path(&reftest.files[side]).unwrap(); @@ -280,7 +284,7 @@ fn capture(reftest: &Reftest, side: uint) -> (u32, u32, Vec<u8>) { let image = png::load_png(&from_str::<Path>(png_filename.as_slice()).unwrap()).unwrap(); let rgba8_bytes = match image.pixels { - png::RGBA8(pixels) => pixels, + png::PixelsByColorType::RGBA8(pixels) => pixels, _ => panic!(), }; (image.width, image.height, rgba8_bytes) @@ -320,7 +324,7 @@ fn check_reftest(reftest: Reftest) { let mut img = png::Image { width: left_width, height: left_height, - pixels: png::RGBA8(pixels), + pixels: png::PixelsByColorType::RGBA8(pixels), }; let res = png::store_png(&mut img, &output); assert!(res.is_ok()); |