diff options
63 files changed, 445 insertions, 439 deletions
diff --git a/components/canvas/canvas_paint_task.rs b/components/canvas/canvas_paint_task.rs index 4d8adef0478..637d73b40b5 100644 --- a/components/canvas/canvas_paint_task.rs +++ b/components/canvas/canvas_paint_task.rs @@ -2,8 +2,8 @@ * 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 azure::azure_hl::{DrawTarget, Color, B8G8R8A8, SkiaBackend, StrokeOptions, DrawOptions}; -use azure::azure_hl::{ColorPattern, ColorPatternRef}; +use azure::azure_hl::{DrawTarget, Color, SurfaceFormat, BackendType, StrokeOptions, DrawOptions}; +use azure::azure_hl::{ColorPattern, PatternRef}; use geom::rect::Rect; use geom::size::Size2D; use servo_util::task::spawn_named; @@ -55,7 +55,8 @@ impl CanvasPaintTask { fn fill_rect(&self, rect: &Rect<f32>) { let drawopts = DrawOptions::new(1.0, 0); - self.drawtarget.fill_rect(rect, ColorPatternRef(&self.fill_color), Some(&drawopts)); + self.drawtarget.fill_rect(rect, PatternRef::ColorPatternRef(&self.fill_color), + Some(&drawopts)); } fn clear_rect(&self, rect: &Rect<f32>) { @@ -68,7 +69,7 @@ impl CanvasPaintTask { } fn create(size: Size2D<i32>) -> DrawTarget { - DrawTarget::new(SkiaBackend, size, B8G8R8A8) + DrawTarget::new(BackendType::SkiaBackend, size, SurfaceFormat::B8G8R8A8) } fn recreate(&mut self, size: Size2D<i32>) { diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index ada75f62540..b4dd37a2915 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -18,7 +18,8 @@ use geom::point::{Point2D, TypedPoint2D}; use geom::rect::{Rect, TypedRect}; use geom::size::TypedSize2D; use geom::scale_factor::ScaleFactor; -use gfx::paint_task::{PaintChan, PaintMsg, PaintRequest, UnusedBufferMsg}; +use gfx::paint_task::Msg as PaintMsg; +use gfx::paint_task::{PaintChan, PaintRequest}; use layers::geometry::{DevicePixel, LayerPixel}; use layers::layers::{BufferRequest, Layer, LayerBufferSet}; use layers::rendergl; @@ -27,17 +28,17 @@ use layers::scene::Scene; use png; use gleam::gl::types::{GLint, GLsizei}; use gleam::gl; -use script_traits::{ViewportMsg, ScriptControlChan}; -use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, IdlePaintState, LayerId}; -use servo_msg::compositor_msg::{ReadyState, PaintState, PaintingPaintState, Scrollable}; -use servo_msg::constellation_msg::{mod, ConstellationChan, ExitMsg}; -use servo_msg::constellation_msg::{GetPipelineTitleMsg, Key, KeyModifiers, KeyState, LoadData}; -use servo_msg::constellation_msg::{LoadUrlMsg, NavigateMsg, PipelineId, ResizedWindowMsg}; -use servo_msg::constellation_msg::{WindowSizeData}; +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::constellation_msg::Msg as ConstellationMsg; +use servo_msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData}; +use servo_msg::constellation_msg::{PipelineId, WindowSizeData}; use servo_util::geometry::{PagePx, ScreenPx, ViewportPx}; use servo_util::memory::MemoryProfilerChan; use servo_util::opts; -use servo_util::time::{profile, TimeProfilerChan}; +use servo_util::time::{TimeProfilerCategory, profile, TimeProfilerChan}; use servo_util::{memory, time}; use std::collections::HashMap; use std::collections::hash_map::{Occupied, Vacant}; @@ -236,7 +237,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { (Msg::Exit(chan), _) => { debug!("shutting down the constellation"); let ConstellationChan(ref con_chan) = self.constellation_chan; - con_chan.send(ExitMsg); + con_chan.send(ConstellationMsg::Exit); chan.send(()); self.shutdown_state = ShutdownState::ShuttingDown; } @@ -410,7 +411,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { if self.ready_states.len() == 0 { return false; } - return self.paint_states.values().all(|&value| value == IdlePaintState); + return self.paint_states.values().all(|&value| value == PaintState::Idle); } fn has_paint_msg_tracking(&self) -> bool { @@ -504,7 +505,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { -> Rc<Layer<CompositorData>> { // Initialize the ReadyState and PaintState for this pipeline. self.ready_states.insert(frame_tree.pipeline.id, Blank); - self.paint_states.insert(frame_tree.pipeline.id, PaintingPaintState); + self.paint_states.insert(frame_tree.pipeline.id, PaintState::Painting); let root_layer = self.create_root_layer_for_pipeline_and_rect(&frame_tree.pipeline, frame_rect); @@ -588,7 +589,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { let visible_viewport = initial_viewport / self.viewport_zoom; let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(ResizedWindowMsg(WindowSizeData { + chan.send(ConstellationMsg::ResizedWindow(WindowSizeData { device_pixel_ratio: dppx, initial_viewport: initial_viewport, visible_viewport: visible_viewport, @@ -662,7 +663,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { None => { match self.paint_channels.entry(pipeline_id) { Occupied(entry) => { - let message = UnusedBufferMsg(new_layer_buffer_set.buffers); + let message = PaintMsg::UnusedBuffer(new_layer_buffer_set.buffers); let _ = entry.get().send_opt(message); }, Vacant(_) => panic!("Received a buffer from an unknown pipeline!"), @@ -753,7 +754,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { WindowEvent::Quit => { debug!("shutting down the constellation for WindowEvent::Quit"); let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(ExitMsg); + chan.send(ConstellationMsg::Exit); self.shutdown_state = ShutdownState::ShuttingDown; } } @@ -788,8 +789,8 @@ impl<Window: WindowMethods> IOCompositor<Window> { layers"), }; - let msg = LoadUrlMsg(root_pipeline_id, - LoadData::new(Url::parse(url_string.as_slice()).unwrap())); + let msg = ConstellationMsg::LoadUrl(root_pipeline_id, + LoadData::new(Url::parse(url_string.as_slice()).unwrap())); let ConstellationChan(ref chan) = self.constellation_chan; chan.send(msg); } @@ -910,7 +911,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { windowing::WindowNavigateMsg::Back => constellation_msg::Back, }; let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(NavigateMsg(direction)) + chan.send(ConstellationMsg::Navigate(direction)) } fn on_key_event(&self, key: Key, state: KeyState, modifiers: KeyModifiers) { @@ -962,7 +963,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { Some(ref pipeline) => { let unused_buffers = self.scene.collect_unused_buffers(); if unused_buffers.len() != 0 { - let message = UnusedBufferMsg(unused_buffers); + let message = PaintMsg::UnusedBuffer(unused_buffers); let _ = pipeline.paint_chan.send_opt(message); } }, @@ -976,7 +977,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { layer.bounds.borrow().size.to_untyped()); let pipeline = &layer.extra_data.borrow().pipeline; let ScriptControlChan(ref chan) = pipeline.script_chan; - chan.send(ViewportMsg(pipeline.id.clone(), layer_rect)); + chan.send(ConstellationControlMsg::Viewport(pipeline.id.clone(), layer_rect)); } for kid in layer.children().iter() { @@ -1012,7 +1013,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { let mut num_paint_msgs_sent = 0; for (_pipeline_id, (chan, requests)) in pipeline_requests.into_iter() { num_paint_msgs_sent += 1; - let _ = chan.send_opt(PaintMsg(requests)); + let _ = chan.send_opt(PaintMsg::Paint(requests)); } self.add_outstanding_paint_msg(num_paint_msgs_sent); @@ -1073,7 +1074,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { gl::bind_texture(gl::TEXTURE_2D, 0); } - profile(time::CompositingCategory, None, self.time_profiler_chan.clone(), || { + profile(TimeProfilerCategory::Compositing, None, self.time_profiler_chan.clone(), || { debug!("compositor: compositing"); // Adjust the layer dimensions as necessary to correspond to the size of the window. self.scene.viewport = Rect { @@ -1129,7 +1130,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { debug!("shutting down the constellation after generating an output file"); let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(ExitMsg); + chan.send(ConstellationMsg::Exit); self.shutdown_state = ShutdownState::ShuttingDown; } @@ -1339,6 +1340,6 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind Some(ref root_pipeline) => root_pipeline.id, }; let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(GetPipelineTitleMsg(root_pipeline_id)); + chan.send(ConstellationMsg::GetPipelineTitle(root_pipeline_id)); } } diff --git a/components/compositing/compositor_layer.rs b/components/compositing/compositor_layer.rs index 4fa7fc54437..4c13d7fb8a0 100644 --- a/components/compositing/compositor_layer.rs +++ b/components/compositing/compositor_layer.rs @@ -12,13 +12,13 @@ use geom::matrix::identity; use geom::point::{Point2D, TypedPoint2D}; use geom::size::TypedSize2D; use geom::rect::Rect; -use gfx::paint_task::UnusedBufferMsg; +use gfx::paint_task::Msg as PaintMsg; 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, SendEventMsg}; -use script_traits::{ScriptControlChan}; +use script_traits::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent}; +use script_traits::{ScriptControlChan, ConstellationControlMsg}; use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId, ScrollPolicy}; use std::num::Float; use std::num::FloatMath; @@ -196,7 +196,7 @@ impl CompositorLayer for Layer<CompositorData> { self.extra_data.borrow().epoch, epoch, self.extra_data.borrow().pipeline.id); - let msg = UnusedBufferMsg(new_buffers.buffers); + let msg = PaintMsg::UnusedBuffer(new_buffers.buffers); let _ = self.extra_data.borrow().pipeline.paint_chan.send_opt(msg); return false; } @@ -208,7 +208,7 @@ impl CompositorLayer for Layer<CompositorData> { let unused_buffers = self.collect_unused_buffers(); if !unused_buffers.is_empty() { // send back unused buffers - let msg = UnusedBufferMsg(unused_buffers); + let msg = PaintMsg::UnusedBuffer(unused_buffers); let _ = self.extra_data.borrow().pipeline.paint_chan.send_opt(msg); } } @@ -227,7 +227,7 @@ impl CompositorLayer for Layer<CompositorData> { buffer.mark_wont_leak() } - let _ = self.extra_data.borrow().pipeline.paint_chan.send_opt(UnusedBufferMsg(buffers)); + let _ = self.extra_data.borrow().pipeline.paint_chan.send_opt(PaintMsg::UnusedBuffer(buffers)); } } @@ -328,7 +328,7 @@ impl CompositorLayer for Layer<CompositorData> { }; let pipeline = &self.extra_data.borrow().pipeline; let ScriptControlChan(ref chan) = pipeline.script_chan; - let _ = chan.send_opt(SendEventMsg(pipeline.id.clone(), message)); + let _ = chan.send_opt(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message)); } fn send_mouse_move_event(&self, @@ -336,7 +336,7 @@ impl CompositorLayer for Layer<CompositorData> { let message = MouseMoveEvent(cursor.to_untyped()); let pipeline = &self.extra_data.borrow().pipeline; let ScriptControlChan(ref chan) = pipeline.script_chan; - let _ = chan.send_opt(SendEventMsg(pipeline.id.clone(), message)); + let _ = chan.send_opt(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message)); } fn scroll_layer_and_all_child_layers(&self, diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 5d64dec93b1..9ec8fb9aaa6 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -14,17 +14,15 @@ use gfx::font_cache_task::FontCacheTask; use layers::geometry::DevicePixel; use layout_traits::LayoutTaskFactory; use libc; -use script_traits::{mod, GetTitleMsg, ResizeMsg, ResizeInactiveMsg, SendEventMsg}; +use script_traits::{mod, ConstellationControlMsg}; use script_traits::{ScriptControlChan, ScriptTaskFactory}; use servo_msg::compositor_msg::LayerId; -use servo_msg::constellation_msg::{mod, ConstellationChan, ExitMsg, FailureMsg, Failure}; -use servo_msg::constellation_msg::{FrameRectMsg, GetPipelineTitleMsg}; -use servo_msg::constellation_msg::{IFrameSandboxState, IFrameUnsandboxed, InitLoadUrlMsg}; -use servo_msg::constellation_msg::{KeyEvent, Key, KeyState, KeyModifiers, LoadCompleteMsg}; -use servo_msg::constellation_msg::{LoadData, LoadUrlMsg, NavigateMsg, NavigationType}; -use servo_msg::constellation_msg::{PainterReadyMsg, PipelineExitType, PipelineId, ResizedWindowMsg}; -use servo_msg::constellation_msg::{ScriptLoadedURLInIFrameMsg, SetCursorMsg, SubpageId}; -use servo_msg::constellation_msg::{WindowSizeData}; +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::{LoadData, NavigationType}; +use servo_msg::constellation_msg::{PipelineExitType, PipelineId}; +use servo_msg::constellation_msg::{SubpageId, WindowSizeData}; use servo_msg::constellation_msg::Msg as ConstellationMsg; use servo_net::image_cache_task::{ImageCacheTask, ImageCacheTaskClient}; use servo_net::resource_task::ResourceTask; @@ -446,65 +444,65 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { /// Handles loading pages, navigation, and granting access to the compositor fn handle_request(&mut self, request: ConstellationMsg) -> bool { match request { - ExitMsg => { + ConstellationMsg::Exit => { debug!("constellation exiting"); self.handle_exit(); return false; } - FailureMsg(Failure { pipeline_id, subpage_id }) => { + ConstellationMsg::Failure(Failure { pipeline_id, subpage_id }) => { self.handle_failure_msg(pipeline_id, subpage_id); } // This should only be called once per constellation, and only by the browser - InitLoadUrlMsg(url) => { + ConstellationMsg::InitLoadUrl(url) => { debug!("constellation got init load URL message"); self.handle_init_load(url); } // A layout assigned a size and position to a subframe. This needs to be reflected by // all frame trees in the navigation context containing the subframe. - FrameRectMsg(pipeline_id, subpage_id, rect) => { + ConstellationMsg::FrameRect(pipeline_id, subpage_id, rect) => { debug!("constellation got frame rect message"); self.handle_frame_rect_msg(pipeline_id, subpage_id, Rect::from_untyped(&rect)); } - ScriptLoadedURLInIFrameMsg(url, source_pipeline_id, subpage_id, sandbox) => { + ConstellationMsg::ScriptLoadedURLInIFrame(url, source_pipeline_id, subpage_id, sandbox) => { debug!("constellation got iframe URL load message"); self.handle_script_loaded_url_in_iframe_msg(url, source_pipeline_id, subpage_id, sandbox); } - SetCursorMsg(cursor) => self.handle_set_cursor_msg(cursor), + ConstellationMsg::SetCursor(cursor) => self.handle_set_cursor_msg(cursor), // Load a new page, usually -- but not always -- from a mouse click or typed url // If there is already a pending page (self.pending_frames), it will not be overridden; // However, if the id is not encompassed by another change, it will be. - LoadUrlMsg(source_id, load_data) => { + ConstellationMsg::LoadUrl(source_id, load_data) => { debug!("constellation got URL load message"); self.handle_load_url_msg(source_id, load_data); } // A page loaded through one of several methods above has completed all parsing, // script, and reflow messages have been sent. - LoadCompleteMsg => { + ConstellationMsg::LoadComplete => { debug!("constellation got load complete message"); self.compositor_proxy.send(CompositorMsg::LoadComplete); } // Handle a forward or back request - NavigateMsg(direction) => { + ConstellationMsg::Navigate(direction) => { debug!("constellation got navigation message"); self.handle_navigate_msg(direction); } // Notification that painting has finished and is requesting permission to paint. - PainterReadyMsg(pipeline_id) => { + ConstellationMsg::PainterReady(pipeline_id) => { debug!("constellation got painter ready message"); self.handle_painter_ready_msg(pipeline_id); } - ResizedWindowMsg(new_size) => { + ConstellationMsg::ResizedWindow(new_size) => { debug!("constellation got window resize message"); self.handle_resized_window_msg(new_size); } - KeyEvent(key, state, modifiers) => { + ConstellationMsg::KeyEvent(key, state, modifiers) => { debug!("constellation got key event message"); self.handle_key_msg(key, state, modifiers); } - GetPipelineTitleMsg(pipeline_id) => { + ConstellationMsg::GetPipelineTitle(pipeline_id) => { debug!("constellation got get-pipeline-title message"); self.handle_get_pipeline_title_msg(pipeline_id); } @@ -674,7 +672,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { if !already_sent.contains(&pipeline.id) { if is_active { let ScriptControlChan(ref script_chan) = pipeline.script_chan; - script_chan.send(ResizeMsg(pipeline.id, WindowSizeData { + script_chan.send(ConstellationControlMsg::Resize(pipeline.id, WindowSizeData { visible_viewport: rect.size, initial_viewport: rect.size * ScaleFactor(1.0), device_pixel_ratio: device_pixel_ratio, @@ -704,7 +702,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { // and add the new pipeline to their sub frames. let frame_trees = self.find_all(source_pipeline_id); if frame_trees.is_empty() { - panic!("Constellation: source pipeline id of ScriptLoadedURLInIFrameMsg is not in + panic!("Constellation: source pipeline id of ScriptLoadedURLInIFrame is not in navigation context, nor is it in a pending frame. This should be impossible."); } @@ -714,7 +712,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { // Compare the pipeline's url to the new url. If the origin is the same, // then reuse the script task in creating the new pipeline let source_pipeline = self.pipelines.get(&source_pipeline_id).expect("Constellation: - source Id of ScriptLoadedURLInIFrameMsg does have an associated pipeline in + source Id of ScriptLoadedURLInIFrame does have an associated pipeline in constellation. This should be impossible.").clone(); let source_url = source_pipeline.load_data.url.clone(); @@ -759,7 +757,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { debug!("Constellation: received message to load {}", url); // Make sure no pending page would be overridden. let source_frame = self.current_frame().as_ref().unwrap().find(source_id).expect( - "Constellation: received a LoadUrlMsg from a pipeline_id associated + "Constellation: received a LoadUrl message from a pipeline_id associated with a pipeline not in the active frame tree. This should be impossible."); @@ -840,7 +838,7 @@ 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(SendEventMsg(frame.pipeline.id, script_traits::KeyEvent(key, state, mods))); + chan.send(ConstellationControlMsg::SendEvent(frame.pipeline.id, script_traits::KeyEvent(key, state, mods))); }); } @@ -849,7 +847,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { None => self.compositor_proxy.send(CompositorMsg::ChangePageTitle(pipeline_id, None)), Some(pipeline) => { let ScriptControlChan(ref script_channel) = pipeline.script_chan; - script_channel.send(GetTitleMsg(pipeline_id)); + script_channel.send(ConstellationControlMsg::GetTitle(pipeline_id)); } } } @@ -947,7 +945,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { debug!("constellation sending resize message to active frame"); let pipeline = &frame_tree.pipeline; let ScriptControlChan(ref chan) = pipeline.script_chan; - let _ = chan.send_opt(ResizeMsg(pipeline.id, new_size)); + let _ = chan.send_opt(ConstellationControlMsg::Resize(pipeline.id, new_size)); already_seen.insert(pipeline.id); } for frame_tree in self.navigation_context.previous.iter() @@ -956,7 +954,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { if !already_seen.contains(&pipeline.id) { debug!("constellation sending resize message to inactive frame"); let ScriptControlChan(ref chan) = pipeline.script_chan; - let _ = chan.send_opt(ResizeInactiveMsg(pipeline.id, new_size)); + let _ = chan.send_opt(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size)); already_seen.insert(pipeline.id); } } @@ -969,7 +967,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { debug!("constellation sending resize message to pending outer frame ({})", frame_tree.pipeline.id); let ScriptControlChan(ref chan) = frame_tree.pipeline.script_chan; - let _ = chan.send_opt(ResizeMsg(frame_tree.pipeline.id, new_size)); + let _ = chan.send_opt(ConstellationControlMsg::Resize(frame_tree.pipeline.id, new_size)); } } diff --git a/components/compositing/headless.rs b/components/compositing/headless.rs index e2ed207b274..a7464a6723a 100644 --- a/components/compositing/headless.rs +++ b/components/compositing/headless.rs @@ -7,7 +7,8 @@ use windowing::WindowEvent; use geom::scale_factor::ScaleFactor; use geom::size::TypedSize2D; -use servo_msg::constellation_msg::{ConstellationChan, ExitMsg, ResizedWindowMsg, WindowSizeData}; +use servo_msg::constellation_msg::Msg as ConstellationMsg; +use servo_msg::constellation_msg::{ConstellationChan, WindowSizeData}; use servo_util::memory::MemoryProfilerChan; use servo_util::memory; use servo_util::time::TimeProfilerChan; @@ -55,7 +56,7 @@ impl NullCompositor { // Tell the constellation about the initial fake size. { let ConstellationChan(ref chan) = compositor.constellation_chan; - chan.send(ResizedWindowMsg(WindowSizeData { + chan.send(ConstellationMsg::ResizedWindow(WindowSizeData { initial_viewport: TypedSize2D(640_f32, 480_f32), visible_viewport: TypedSize2D(640_f32, 480_f32), device_pixel_ratio: ScaleFactor(1.0), @@ -72,7 +73,7 @@ impl CompositorEventListener for NullCompositor { Msg::Exit(chan) => { debug!("shutting down the constellation"); let ConstellationChan(ref con_chan) = self.constellation_chan; - con_chan.send(ExitMsg); + con_chan.send(ConstellationMsg::Exit); chan.send(()); } diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index 2c2ccdcb714..05e405f6a5b 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -25,7 +25,6 @@ extern crate "util" as servo_util; extern crate gleam; extern crate libc; -extern crate native; extern crate time; extern crate url; diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index e90bf221e1d..8c22d7c9ea4 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -5,13 +5,13 @@ use CompositorProxy; use layout_traits::{ExitNowMsg, LayoutTaskFactory, LayoutControlChan}; use script_traits::{ScriptControlChan, ScriptTaskFactory}; -use script_traits::{AttachLayoutMsg, LoadMsg, NewLayoutInfo, ExitPipelineMsg}; +use script_traits::{NewLayoutInfo, ConstellationControlMsg}; use devtools_traits::DevtoolsControlChan; -use gfx::paint_task; +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, ExitMsg, Failure, PipelineId, SubpageId}; +use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineId, SubpageId}; use servo_msg::constellation_msg::{LoadData, WindowSizeData, PipelineExitType}; use servo_net::image_cache_task::ImageCacheTask; use gfx::font_cache_task::FontCacheTask; @@ -100,7 +100,7 @@ impl Pipeline { }; let ScriptControlChan(ref chan) = spipe.script_chan; - chan.send(AttachLayoutMsg(new_layout_info)); + chan.send(ConstellationControlMsg::AttachLayout(new_layout_info)); spipe.script_chan.clone() } }; @@ -162,7 +162,7 @@ impl Pipeline { pub fn load(&self) { let ScriptControlChan(ref chan) = self.script_chan; - chan.send(LoadMsg(self.id, self.load_data.clone())); + chan.send(ConstellationControlMsg::Load(self.id, self.load_data.clone())); } pub fn grant_paint_permission(&self) { @@ -180,7 +180,7 @@ impl Pipeline { // Script task handles shutting down layout, and layout handles shutting down the painter. // For now, if the script task has failed, we give up on clean shutdown. let ScriptControlChan(ref chan) = self.script_chan; - if chan.send_opt(ExitPipelineMsg(self.id, exit_type)).is_ok() { + if chan.send_opt(ConstellationControlMsg::ExitPipeline(self.id, exit_type)).is_ok() { // Wait until all slave tasks have terminated and run destructors // NOTE: We don't wait for script task as we don't always own it let _ = self.paint_shutdown_port.recv_opt(); @@ -191,8 +191,10 @@ impl Pipeline { pub fn force_exit(&self) { let ScriptControlChan(ref script_channel) = self.script_chan; - let _ = script_channel.send_opt( ExitPipelineMsg(self.id, PipelineExitType::PipelineOnly)); - let _ = self.paint_chan.send_opt(paint_task::ExitMsg(None, PipelineExitType::PipelineOnly)); + let _ = script_channel.send_opt( + ConstellationControlMsg::ExitPipeline(self.id, + 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)); } diff --git a/components/compositing/scrolling.rs b/components/compositing/scrolling.rs index d36674b69e9..8649ac1d9a4 100644 --- a/components/compositing/scrolling.rs +++ b/components/compositing/scrolling.rs @@ -6,7 +6,6 @@ use compositor_task::{CompositorProxy, Msg}; -use native::task::NativeTaskBuilder; use std::io::timer; use std::task::TaskBuilder; use std::time::duration::Duration; @@ -34,7 +33,7 @@ enum ToScrollingTimerMsg { impl ScrollingTimerProxy { pub fn new(compositor_proxy: Box<CompositorProxy+Send>) -> ScrollingTimerProxy { let (to_scrolling_timer_sender, to_scrolling_timer_receiver) = channel(); - TaskBuilder::new().native().spawn(proc() { + TaskBuilder::new().spawn(proc() { let mut scrolling_timer = ScrollingTimer { compositor_proxy: compositor_proxy, receiver: to_scrolling_timer_receiver, diff --git a/components/devtools/actor.rs b/components/devtools/actor.rs index 178b840ebce..47d0c30761d 100644 --- a/components/devtools/actor.rs +++ b/components/devtools/actor.rs @@ -25,7 +25,7 @@ pub trait Actor : Any { fn name(&self) -> String; } -impl<'a> AnyMutRefExt<'a> for &'a mut Actor + 'a { +impl<'a> AnyMutRefExt<'a> for &'a mut (Actor + 'a) { fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> { if self.is::<T>() { unsafe { @@ -41,7 +41,7 @@ impl<'a> AnyMutRefExt<'a> for &'a mut Actor + 'a { } } -impl<'a> AnyRefExt<'a> for &'a Actor + 'a { +impl<'a> AnyRefExt<'a> for &'a (Actor + 'a) { fn is<T: 'static>(self) -> bool { // This implementation is only needed so long as there's a Rust bug that // prevents downcast_ref from giving realistic return values. diff --git a/components/devtools_traits/lib.rs b/components/devtools_traits/lib.rs index b22b04f9ac1..6b6bb91f987 100644 --- a/components/devtools_traits/lib.rs +++ b/components/devtools_traits/lib.rs @@ -6,6 +6,7 @@ #![crate_type = "rlib"] #![allow(non_snake_case)] +#![feature(globs)] extern crate "msg" as servo_msg; extern crate serialize; @@ -16,6 +17,10 @@ extern crate "util" as servo_util; /// The traits are here instead of in script so that the devtools crate can be /// modified independently of the rest of Servo. +pub use self::DevtoolsControlMsg::*; +pub use self::DevtoolScriptControlMsg::*; +pub use self::EvaluateJSReply::*; + use serialize::{Decodable, Decoder}; use servo_msg::constellation_msg::PipelineId; use servo_util::str::DOMString; diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 4ac959679a7..af32ffad76b 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -41,7 +41,7 @@ use std::fmt; use std::slice::Items; use style::ComputedValues; use style::computed_values::border_style; -use style::computed_values::cursor::{AutoCursor, SpecifiedCursor}; +use style::computed_values::cursor; use sync::Arc; // It seems cleaner to have layout code not mention Azure directly, so let's just reexport this for @@ -629,8 +629,8 @@ impl DisplayItemMetadata { DisplayItemMetadata { node: node, cursor: match style.get_pointing().cursor { - AutoCursor => default_cursor, - SpecifiedCursor(cursor) => cursor, + cursor::T::AutoCursor => default_cursor, + cursor::T::SpecifiedCursor(cursor) => cursor, }, } } diff --git a/components/gfx/font.rs b/components/gfx/font.rs index a81c51b4bda..1e01e78a21f 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -194,8 +194,8 @@ impl Font { pub fn glyph_index(&self, codepoint: char) -> Option<GlyphId> { let codepoint = match self.variant { - font_variant::small_caps => codepoint.to_uppercase(), - font_variant::normal => codepoint, + font_variant::T::small_caps => codepoint.to_uppercase(), + font_variant::T::normal => codepoint, }; self.handle.glyph_index(codepoint) } diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index bd8500318da..a18a801b4e1 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -22,21 +22,22 @@ use std::cell::RefCell; use sync::Arc; use azure::AzFloat; -use azure::azure_hl::SkiaBackend; +use azure::azure_hl::BackendType; use azure::scaled_font::ScaledFont; #[cfg(any(target_os="linux", target_os = "android"))] -use azure::scaled_font::FontData; +use azure::scaled_font::FontInfo; #[cfg(any(target_os="linux", target_os = "android"))] fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont { - ScaledFont::new(SkiaBackend, FontData(&template.bytes), pt_size.to_subpx() as AzFloat) + ScaledFont::new(BackendType::SkiaBackend, FontInfo::FontData(&template.bytes), + pt_size.to_subpx() as AzFloat) } #[cfg(target_os="macos")] fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont { let cgfont = template.ctfont.as_ref().unwrap().copy_to_CGFont(); - ScaledFont::new(SkiaBackend, &cgfont, pt_size.to_subpx() as AzFloat) + ScaledFont::new(BackendType::SkiaBackend, &cgfont, pt_size.to_subpx() as AzFloat) } static SMALL_CAPS_SCALE_FACTOR: f64 = 0.8; // Matches FireFox (see gfxFont.h) @@ -100,8 +101,8 @@ impl FontContext { // painting. We should also support true small-caps (where the // font supports it) in the future. let actual_pt_size = match variant { - font_variant::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR), - font_variant::normal => pt_size, + font_variant::T::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR), + font_variant::T::normal => pt_size, }; let handle: FontHandle = FontHandleMethods::new_from_template(&self.platform_handle, @@ -138,7 +139,7 @@ impl FontContext { // so they will never be released. Find out a good time to drop them. let desc = FontTemplateDescriptor::new(style.font_weight, - style.font_style == font_style::italic); + style.font_style == font_style::T::italic); let mut fonts = SmallVec8::new(); for family in style.font_family.iter() { diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs index 4d54758288d..e7ad3c65a4c 100644 --- a/components/gfx/lib.rs +++ b/components/gfx/lib.rs @@ -16,7 +16,6 @@ extern crate collections; extern crate geom; extern crate layers; extern crate libc; -extern crate native; extern crate rustrt; extern crate stb_image; extern crate png; diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index 62f41745922..2f277de6a84 100644 --- a/components/gfx/paint_context.rs +++ b/components/gfx/paint_context.rs @@ -5,11 +5,11 @@ //! Painting of display lists using Moz2D/Azure. use azure::azure::AzIntSize; -use azure::azure_hl::{A8, B8G8R8A8, Color, ColorPattern, ColorPatternRef, DrawOptions}; -use azure::azure_hl::{DrawSurfaceOptions, DrawTarget, ExtendClamp, GaussianBlurFilterType}; -use azure::azure_hl::{GaussianBlurInput, GradientStop, Linear, LinearGradientPattern}; -use azure::azure_hl::{LinearGradientPatternRef, Path, PathBuilder, SourceOp}; -use azure::azure_hl::{StdDeviationGaussianBlurAttribute, StrokeOptions}; +use azure::azure_hl::{SurfaceFormat, Color, ColorPattern, DrawOptions}; +use azure::azure_hl::{DrawSurfaceOptions, DrawTarget, ExtendMode, FilterType}; +use azure::azure_hl::{GaussianBlurInput, GradientStop, Filter, LinearGradientPattern}; +use azure::azure_hl::{PatternRef, Path, PathBuilder, CompositionOp}; +use azure::azure_hl::{GaussianBlurAttribute, StrokeOptions}; use azure::scaled_font::ScaledFont; use azure::{AZ_CAP_BUTT, AzFloat, struct__AzDrawOptions, struct__AzGlyph}; use azure::{struct__AzGlyphBuffer, struct__AzPoint, AzDrawTargetFillGlyphs}; @@ -23,7 +23,7 @@ use geom::side_offsets::SideOffsets2D; use geom::size::Size2D; use libc::size_t; use libc::types::common::c99::{uint16_t, uint32_t}; -use png::{RGB8, RGBA8, K8, KA8}; +use png::PixelsByColorType; use servo_net::image::base::Image; use servo_util::geometry::{Au, MAX_RECT}; use servo_util::opts; @@ -72,7 +72,7 @@ impl<'a> PaintContext<'a> { pub fn draw_solid_color(&self, bounds: &Rect<Au>, color: Color) { self.draw_target.make_current(); self.draw_target.fill_rect(&bounds.to_azure_rect(), - ColorPatternRef(&ColorPattern::new(color)), + PatternRef::ColorPatternRef(&ColorPattern::new(color)), None); } @@ -123,10 +123,10 @@ impl<'a> PaintContext<'a> { pub fn draw_image(&self, bounds: Rect<Au>, image: Arc<Box<Image>>) { let size = Size2D(image.width as i32, image.height as i32); let (pixel_width, pixels, source_format) = match image.pixels { - RGBA8(ref pixels) => (4, pixels.as_slice(), B8G8R8A8), - K8(ref pixels) => (1, pixels.as_slice(), A8), - RGB8(_) => panic!("RGB8 color type not supported"), - KA8(_) => panic!("KA8 color type not supported"), + PixelsByColorType::RGBA8(ref pixels) => (4, pixels.as_slice(), SurfaceFormat::B8G8R8A8), + PixelsByColorType::K8(ref pixels) => (1, pixels.as_slice(), SurfaceFormat::A8), + PixelsByColorType::RGB8(_) => panic!("RGB8 color type not supported"), + PixelsByColorType::KA8(_) => panic!("KA8 color type not supported"), }; let stride = image.width * pixel_width; @@ -139,7 +139,7 @@ impl<'a> PaintContext<'a> { let source_rect = Rect(Point2D(0.0, 0.0), Size2D(image.width as AzFloat, image.height as AzFloat)); let dest_rect = bounds.to_azure_rect(); - let draw_surface_options = DrawSurfaceOptions::new(Linear, true); + let draw_surface_options = DrawSurfaceOptions::new(Filter::Linear, true); let draw_options = DrawOptions::new(1.0, 0); draw_target_ref.draw_surface(azure_surface, dest_rect, @@ -155,9 +155,10 @@ impl<'a> PaintContext<'a> { Size2D(self.screen_rect.size.width as AzFloat, self.screen_rect.size.height as AzFloat)); let mut draw_options = DrawOptions::new(1.0, 0); - draw_options.set_composition_op(SourceOp); + draw_options.set_composition_op(CompositionOp::SourceOp); self.draw_target.make_current(); - self.draw_target.fill_rect(&rect, ColorPatternRef(&pattern), Some(&draw_options)); + self.draw_target.fill_rect(&rect, PatternRef::ColorPatternRef(&pattern), + Some(&draw_options)); } fn draw_border_segment(&self, @@ -175,8 +176,8 @@ impl<'a> PaintContext<'a> { }; match style_select { - border_style::none | border_style::hidden => {} - border_style::dotted => { + border_style::T::none | border_style::T::hidden => {} + border_style::T::dotted => { // FIXME(sammykim): This doesn't work well with dash_pattern and cap_style. self.draw_dashed_border_segment(direction, bounds, @@ -184,20 +185,20 @@ impl<'a> PaintContext<'a> { color_select, DashSize::DottedBorder); } - border_style::dashed => { + border_style::T::dashed => { self.draw_dashed_border_segment(direction, bounds, border, color_select, DashSize::DashedBorder); } - border_style::solid => { + border_style::T::solid => { self.draw_solid_border_segment(direction, bounds, border, radius, color_select); } - border_style::double => { + border_style::T::double => { self.draw_double_border_segment(direction, bounds, border, radius, color_select); } - border_style::groove | border_style::ridge => { + border_style::T::groove | border_style::T::ridge => { self.draw_groove_ridge_border_segment(direction, bounds, border, @@ -205,7 +206,7 @@ impl<'a> PaintContext<'a> { color_select, style_select); } - border_style::inset | border_style::outset => { + border_style::T::inset | border_style::T::outset => { self.draw_inset_outset_border_segment(direction, bounds, border, @@ -223,28 +224,28 @@ impl<'a> PaintContext<'a> { style: border_style::T) { let border = SideOffsets2D::new_all_same(bounds.size.width).to_float_px(); match style { - border_style::none | border_style::hidden => {} - border_style::dotted => { + border_style::T::none | border_style::T::hidden => {} + border_style::T::dotted => { self.draw_dashed_border_segment(Direction::Right, bounds, &border, color, DashSize::DottedBorder); } - border_style::dashed => { + border_style::T::dashed => { self.draw_dashed_border_segment(Direction::Right, bounds, &border, color, DashSize::DashedBorder); } - border_style::solid => { + border_style::T::solid => { self.draw_solid_border_segment(Direction::Right, bounds, &border, radius, color) } - border_style::double => { + border_style::T::double => { self.draw_double_border_segment(Direction::Right, bounds, &border, radius, color) } - border_style::groove | border_style::ridge => { + border_style::T::groove | border_style::T::ridge => { self.draw_groove_ridge_border_segment(Direction::Right, bounds, &border, @@ -252,7 +253,7 @@ impl<'a> PaintContext<'a> { color, style); } - border_style::inset | border_style::outset => { + border_style::T::inset | border_style::T::outset => { self.draw_inset_outset_border_segment(Direction::Right, bounds, &border, @@ -718,9 +719,9 @@ impl<'a> PaintContext<'a> { 0.5 * border.bottom, 0.5 * border.left); let is_groove = match style { - border_style::groove => true, - border_style::ridge => false, - _ => panic!("invalid border style") + border_style::T::groove => true, + border_style::T::ridge => false, + _ => panic!("invalid border style") }; let mut lighter_color; @@ -761,9 +762,9 @@ impl<'a> PaintContext<'a> { color: Color, style: border_style::T) { let is_inset = match style { - border_style::inset => true, - border_style::outset => false, - _ => panic!("invalid border style") + border_style::T::inset => true, + border_style::T::outset => false, + _ => panic!("invalid border style") }; // original bounds as a Rect<f32> let original_bounds = self.get_scaled_bounds(bounds, border, 0.0); @@ -855,14 +856,14 @@ impl<'a> PaintContext<'a> { stops: &[GradientStop]) { self.draw_target.make_current(); - let stops = self.draw_target.create_gradient_stops(stops, ExtendClamp); + let stops = self.draw_target.create_gradient_stops(stops, ExtendMode::ExtendClamp); let pattern = LinearGradientPattern::new(&start_point.to_azure_point(), &end_point.to_azure_point(), stops, &Matrix2D::identity()); self.draw_target.fill_rect(&bounds.to_azure_rect(), - LinearGradientPatternRef(&pattern), + PatternRef::LinearGradientPatternRef(&pattern), None); } @@ -905,7 +906,7 @@ impl<'a> PaintContext<'a> { temporary_draw_target.set_transform(&Matrix2D::identity()); let rect = Rect(Point2D(0.0, 0.0), self.draw_target.get_size().to_azure_size()); let source_surface = temporary_draw_target.snapshot(); - let draw_surface_options = DrawSurfaceOptions::new(Linear, true); + let draw_surface_options = DrawSurfaceOptions::new(Filter::Linear, true); let draw_options = DrawOptions::new(opacity, 0); self.draw_target.draw_surface(source_surface, rect, @@ -970,9 +971,9 @@ impl<'a> PaintContext<'a> { if blur_radius > Au(0) { // Go ahead and create the blur now. Despite the name, Azure's notion of `StdDeviation` // describes the blur radius, not the sigma for the Gaussian blur. - let blur_filter = self.draw_target.create_filter(GaussianBlurFilterType); - blur_filter.set_attribute(StdDeviationGaussianBlurAttribute(blur_radius.to_subpx() as - AzFloat)); + let blur_filter = self.draw_target.create_filter(FilterType::GaussianBlurFilterType); + blur_filter.set_attribute(GaussianBlurAttribute::StdDeviationGaussianBlurAttribute( + blur_radius.to_subpx() as AzFloat)); blur_filter.set_input(GaussianBlurInput, &temporary_draw_target.snapshot()); // Blit the blur onto the tile. We undo the transforms here because we want to directly diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index 676e0ec5d6b..1210c34627b 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -10,7 +10,7 @@ use font_cache_task::FontCacheTask; use font_context::FontContext; use paint_context::PaintContext; -use azure::azure_hl::{B8G8R8A8, Color, DrawTarget, SkiaBackend, StolenGLResources}; +use azure::azure_hl::{SurfaceFormat, Color, DrawTarget, BackendType, StolenGLResources}; use azure::AzFloat; use geom::matrix2d::Matrix2D; use geom::point::Point2D; @@ -20,19 +20,18 @@ use layers::platform::surface::{NativeGraphicsMetadata, NativePaintingGraphicsCo use layers::platform::surface::{NativeSurface, NativeSurfaceMethods}; use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet}; use layers; -use native::task::NativeTaskBuilder; -use servo_msg::compositor_msg::{Epoch, IdlePaintState, LayerId}; -use servo_msg::compositor_msg::{LayerMetadata, PaintListener, PaintingPaintState, ScrollPolicy}; -use servo_msg::constellation_msg::{ConstellationChan, Failure, FailureMsg, PipelineExitType}; -use servo_msg::constellation_msg::{PipelineId, PainterReadyMsg}; +use servo_msg::compositor_msg::{Epoch, PaintState, LayerId}; +use servo_msg::compositor_msg::{LayerMetadata, PaintListener, ScrollPolicy}; +use servo_msg::constellation_msg::Msg as ConstellationMsg; +use servo_msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; +use servo_msg::constellation_msg::PipelineExitType; use servo_msg::platform::surface::NativeSurfaceAzureMethods; use servo_util::geometry::{Au, ZERO_POINT}; use servo_util::opts; use servo_util::smallvec::SmallVec; use servo_util::task::spawn_named_with_send_on_failure; use servo_util::task_state; -use servo_util::time::{TimeProfilerChan, profile}; -use servo_util::time; +use servo_util::time::{TimeProfilerChan, TimeProfilerCategory, profile}; use std::comm::{Receiver, Sender, channel}; use std::mem; use std::task::TaskBuilder; @@ -68,12 +67,12 @@ pub struct PaintRequest { } pub enum Msg { - PaintInitMsg(Arc<StackingContext>), - PaintMsg(Vec<PaintRequest>), - UnusedBufferMsg(Vec<Box<LayerBuffer>>), + PaintInit(Arc<StackingContext>), + Paint(Vec<PaintRequest>), + UnusedBuffer(Vec<Box<LayerBuffer>>), PaintPermissionGranted, PaintPermissionRevoked, - ExitMsg(Option<Sender<()>>, PipelineExitType), + Exit(Option<Sender<()>>, PipelineExitType), } #[deriving(Clone)] @@ -224,7 +223,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send { debug!("paint_task: shutdown_chan send"); shutdown_chan.send(()); - }, FailureMsg(failure_msg), c, true); + }, ConstellationMsg::Failure(failure_msg), c, true); } fn start(&mut self) { @@ -234,14 +233,14 @@ impl<C> PaintTask<C> where C: PaintListener + Send { let mut waiting_for_compositor_buffers_to_exit = false; loop { match self.port.recv() { - Msg::PaintInitMsg(stacking_context) => { + Msg::PaintInit(stacking_context) => { self.epoch.next(); self.root_stacking_context = Some(stacking_context.clone()); if !self.paint_permission { debug!("PaintTask: paint ready msg"); let ConstellationChan(ref mut c) = self.constellation_chan; - c.send(PainterReadyMsg(self.id)); + c.send(ConstellationMsg::PainterReady(self.id)); continue; } @@ -250,17 +249,17 @@ impl<C> PaintTask<C> where C: PaintListener + Send { self.epoch, &*stacking_context); } - Msg::PaintMsg(requests) => { + Msg::Paint(requests) => { if !self.paint_permission { debug!("PaintTask: paint ready msg"); let ConstellationChan(ref mut c) = self.constellation_chan; - c.send(PainterReadyMsg(self.id)); + c.send(ConstellationMsg::PainterReady(self.id)); self.compositor.paint_msg_discarded(); continue; } let mut replies = Vec::new(); - self.compositor.set_paint_state(self.id, PaintingPaintState); + self.compositor.set_paint_state(self.id, PaintState::Painting); for PaintRequest { buffer_requests, scale, layer_id, epoch } in requests.into_iter() { if self.epoch == epoch { @@ -270,7 +269,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send { } } - self.compositor.set_paint_state(self.id, IdlePaintState); + self.compositor.set_paint_state(self.id, PaintState::Idle); for reply in replies.iter() { let &(_, ref buffer_set) = reply; @@ -280,7 +279,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send { debug!("PaintTask: returning surfaces"); self.compositor.paint(self.id, self.epoch, replies); } - Msg::UnusedBufferMsg(unused_buffers) => { + Msg::UnusedBuffer(unused_buffers) => { debug!("PaintTask: Received {} unused buffers", unused_buffers.len()); self.used_buffer_count -= unused_buffers.len(); @@ -311,7 +310,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send { Msg::PaintPermissionRevoked => { self.paint_permission = false; } - Msg::ExitMsg(response_channel, exit_type) => { + Msg::Exit(response_channel, exit_type) => { let should_wait_for_compositor_buffers = match exit_type { PipelineExitType::Complete => false, PipelineExitType::PipelineOnly => self.used_buffer_count != 0 @@ -383,7 +382,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send { mut tiles: Vec<BufferRequest>, scale: f32, layer_id: LayerId) { - time::profile(time::PaintingCategory, None, self.time_profiler_chan.clone(), || { + profile(TimeProfilerCategory::Painting, None, self.time_profiler_chan.clone(), || { // Bail out if there is no appropriate stacking context. let stacking_context = match self.root_stacking_context { Some(ref stacking_context) => { @@ -442,7 +441,7 @@ impl WorkerThreadProxy { let native_graphics_metadata = native_graphics_metadata.clone(); let font_cache_task = font_cache_task.clone(); let time_profiler_chan = time_profiler_chan.clone(); - TaskBuilder::new().native().spawn(proc() { + TaskBuilder::new().spawn(proc() { let mut worker_thread = WorkerThread::new(from_worker_sender, to_worker_receiver, native_graphics_metadata, @@ -525,14 +524,14 @@ impl WorkerThread { -> DrawTarget { let size = Size2D(tile.screen_rect.size.width as i32, tile.screen_rect.size.height as i32); let draw_target = if !opts::get().gpu_painting { - DrawTarget::new(SkiaBackend, size, B8G8R8A8) + DrawTarget::new(BackendType::SkiaBackend, size, SurfaceFormat::B8G8R8A8) } else { // FIXME(pcwalton): Cache the components of draw targets (texture color buffer, // paintbuffers) instead of recreating them. - let draw_target = DrawTarget::new_with_fbo(SkiaBackend, + let draw_target = DrawTarget::new_with_fbo(BackendType::SkiaBackend, native_graphics_context!(self), size, - B8G8R8A8); + SurfaceFormat::B8G8R8A8); draw_target.make_current(); draw_target }; @@ -559,7 +558,8 @@ impl WorkerThread { paint_context.clear(); // Draw the display list. - profile(time::PaintingPerTileCategory, None, self.time_profiler_sender.clone(), || { + profile(TimeProfilerCategory::PaintingPerTile, None, + self.time_profiler_sender.clone(), || { stacking_context.optimize_and_draw_into_context(&mut paint_context, &tile.page_rect, &matrix, @@ -586,8 +586,8 @@ impl WorkerThread { let mut buffer = layer_buffer.unwrap(); draw_target.snapshot().get_data_surface().with_data(|data| { buffer.native_surface.upload(native_graphics_context!(self), data); - debug!("painting worker thread uploading to native surface {:d}", - buffer.native_surface.get_id() as int); + debug!("painting worker thread uploading to native surface {}", + buffer.native_surface.get_id()); }); return buffer } diff --git a/components/gfx/platform/freetype/font.rs b/components/gfx/platform/freetype/font.rs index 5896a335585..a68e443183d 100644 --- a/components/gfx/platform/freetype/font.rs +++ b/components/gfx/platform/freetype/font.rs @@ -130,7 +130,7 @@ impl FontHandleMethods for FontHandle { unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC != 0 } } fn boldness(&self) -> font_weight::T { - let default_weight = font_weight::Weight400; + let default_weight = font_weight::T::Weight400; if unsafe { (*self.face).style_flags & FT_STYLE_FLAG_BOLD == 0 } { default_weight } else { @@ -140,15 +140,15 @@ impl FontHandleMethods for FontHandle { if valid { let weight =(*os2).usWeightClass; match weight { - 1 | 100...199 => font_weight::Weight100, - 2 | 200...299 => font_weight::Weight200, - 3 | 300...399 => font_weight::Weight300, - 4 | 400...499 => font_weight::Weight400, - 5 | 500...599 => font_weight::Weight500, - 6 | 600...699 => font_weight::Weight600, - 7 | 700...799 => font_weight::Weight700, - 8 | 800...899 => font_weight::Weight800, - 9 | 900...999 => font_weight::Weight900, + 1 | 100...199 => font_weight::T::Weight100, + 2 | 200...299 => font_weight::T::Weight200, + 3 | 300...399 => font_weight::T::Weight300, + 4 | 400...499 => font_weight::T::Weight400, + 5 | 500...599 => font_weight::T::Weight500, + 6 | 600...699 => font_weight::T::Weight600, + 7 | 700...799 => font_weight::T::Weight700, + 8 | 800...899 => font_weight::T::Weight800, + 9 | 900...999 => font_weight::T::Weight900, _ => default_weight } } else { @@ -255,7 +255,7 @@ impl FontHandleMethods for FontHandle { line_gap: height, }; - debug!("Font metrics (@{:f} pt): {}", geometry::to_pt(em_size), metrics); + debug!("Font metrics (@{} pt): {}", geometry::to_pt(em_size), metrics); return metrics; } diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index 87beceb9d47..1a36f8c4cbb 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -557,7 +557,7 @@ impl<'a> GlyphStore { (true, _) => GlyphEntry::missing(1), (false, true) => GlyphEntry::simple(data.id, data.advance), (false, false) => { - let glyph = [DetailedGlyph::new(data.id, data.advance, data.offset)]; + let glyph = &[DetailedGlyph::new(data.id, data.advance, data.offset)]; self.detail_store.add_detailed_glyphs_for_entry(i, glyph); GlyphEntry::complex(data.cluster_start, data.ligature_start, 1) } diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index 4cf0575dbee..6e10384615b 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -307,7 +307,7 @@ impl Shaper { debug!("text: {}", text); debug!("(char idx): char->(glyph index):"); for (i, ch) in text.char_indices() { - debug!("{}: {} --> {:d}", i, ch, *byte_to_glyph.get(i).unwrap() as int); + debug!("{}: {} --> {}", i, ch, byte_to_glyph[i]); } // some helpers diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index 662e79d0846..a9ca6d5f547 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -32,7 +32,8 @@ use gfx::display_list::{SidewaysRight, SolidColorDisplayItem}; use gfx::display_list::{StackingContext, TextDisplayItem, Upright}; use gfx::paint_task::PaintLayer; use servo_msg::compositor_msg::{FixedPosition, Scrollable}; -use servo_msg::constellation_msg::{ConstellationChan, FrameRectMsg}; +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::geometry::{mod, Au, ZERO_POINT}; @@ -904,9 +905,9 @@ impl FragmentDisplayListBuilding for Fragment { iframe_fragment.pipeline_id, iframe_fragment.subpage_id); let ConstellationChan(ref chan) = layout_context.shared.constellation_chan; - chan.send(FrameRectMsg(iframe_fragment.pipeline_id, - iframe_fragment.subpage_id, - iframe_rect)); + chan.send(ConstellationMsg::FrameRect(iframe_fragment.pipeline_id, + iframe_fragment.subpage_id, + iframe_rect)); } fn clipping_region_for_children(&self, current_clip: &ClippingRegion, flow_origin: &Point2D<Au>) diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index c3e483d0287..090b51cee70 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -28,7 +28,8 @@ use gfx::color; use gfx::display_list::{ClippingRegion, DisplayItemMetadata, DisplayList, OpaqueNode}; use gfx::display_list::{StackingContext}; use gfx::font_cache_task::FontCacheTask; -use gfx::paint_task::{mod, PaintInitMsg, PaintChan, PaintLayer}; +use gfx::paint_task::{PaintChan, PaintLayer}; +use gfx::paint_task::Msg as PaintMsg; use layout_traits::{mod, LayoutControlMsg, LayoutTaskFactory}; use log; use script::dom::bindings::js::JS; @@ -40,11 +41,12 @@ use script::layout_interface::{ContentBoxesQuery, ContentBoxQuery}; use script::layout_interface::{HitTestResponse, LayoutChan, LayoutRPC}; use script::layout_interface::{MouseOverResponse, Msg, NoQuery}; use script::layout_interface::{Reflow, ReflowGoal, ScriptLayoutChan, TrustedNodeAddress}; -use script_traits::{SendEventMsg, ReflowEvent, ReflowCompleteMsg, OpaqueScriptLayoutChannel}; +use script_traits::{ConstellationControlMsg, ReflowEvent, OpaqueScriptLayoutChannel}; use script_traits::{ScriptControlChan, UntrustedNodeAddress}; use servo_msg::compositor_msg::Scrollable; -use servo_msg::constellation_msg::{ConstellationChan, Failure, FailureMsg, PipelineExitType}; -use servo_msg::constellation_msg::{PipelineId, SetCursorMsg}; +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}; @@ -55,7 +57,7 @@ use servo_util::opts; use servo_util::smallvec::{SmallVec, SmallVec1, VecLike}; use servo_util::task::spawn_named_with_send_on_failure; use servo_util::task_state; -use servo_util::time::{mod, ProfilerMetadata, TimeProfilerChan, TimerMetadataFrameType}; +use servo_util::time::{TimeProfilerCategory, ProfilerMetadata, TimeProfilerChan, TimerMetadataFrameType}; use servo_util::time::{TimerMetadataReflowType, profile}; use servo_util::workqueue::WorkQueue; use std::cell::Cell; @@ -159,7 +161,7 @@ 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(SendEventMsg(id.clone(), ReflowEvent(nodes)))) + drop(chan.send_opt(ConstellationControlMsg::SendEvent(id.clone(), ReflowEvent(nodes)))) }; f } @@ -200,7 +202,7 @@ impl LayoutTaskFactory for LayoutTask { layout.start(); } shutdown_chan.send(()); - }, FailureMsg(failure_msg), con_chan, false); + }, ConstellationMsg::Failure(failure_msg), con_chan, false); } } @@ -397,7 +399,7 @@ impl LayoutTask { Box<LayoutRPC + Send>); }, Msg::Reflow(data) => { - profile(time::LayoutPerformCategory, + profile(TimeProfilerCategory::LayoutPerform, self.profiler_metadata(&*data), self.time_profiler_chan.clone(), || self.handle_reflow(&*data, possibly_locked_rw_data)); @@ -465,7 +467,7 @@ impl LayoutTask { LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data); } - self.paint_chan.send(paint_task::ExitMsg(Some(response_chan), exit_type)); + self.paint_chan.send(PaintMsg::Exit(Some(response_chan), exit_type)); response_port.recv() } @@ -626,7 +628,7 @@ impl LayoutTask { shared_layout_context: &mut SharedLayoutContext, rw_data: &mut RWGuard<'a>) { let writing_mode = flow::base(&**layout_root).writing_mode; - profile(time::LayoutDispListBuildCategory, + profile(TimeProfilerCategory::LayoutDispListBuild, self.profiler_metadata(data), self.time_profiler_chan.clone(), || { @@ -700,7 +702,7 @@ impl LayoutTask { debug!("Layout done!"); - self.paint_chan.send(PaintInitMsg(stacking_context)); + self.paint_chan.send(PaintMsg::PaintInit(stacking_context)); }); } @@ -770,7 +772,7 @@ impl LayoutTask { |mut flow| LayoutTask::reflow_all_nodes(flow.deref_mut())); } - let mut layout_root = profile(time::LayoutStyleRecalcCategory, + let mut layout_root = profile(TimeProfilerCategory::LayoutStyleRecalc, self.profiler_metadata(data), self.time_profiler_chan.clone(), || { @@ -788,7 +790,7 @@ impl LayoutTask { self.get_layout_root((*node).clone()) }); - profile(time::LayoutRestyleDamagePropagation, + profile(TimeProfilerCategory::LayoutRestyleDamagePropagation, self.profiler_metadata(data), self.time_profiler_chan.clone(), || { @@ -810,7 +812,7 @@ impl LayoutTask { // Perform the primary layout passes over the flow tree to compute the locations of all // the boxes. - profile(time::LayoutMainCategory, + profile(TimeProfilerCategory::LayoutMain, self.profiler_metadata(data), self.time_profiler_chan.clone(), || { @@ -870,7 +872,7 @@ impl LayoutTask { // either select or a filtered recv() that only looks for messages of a given type. data.script_join_chan.send(()); let ScriptControlChan(ref chan) = data.script_chan; - chan.send(ReflowCompleteMsg(self.id, data.id)); + chan.send(ConstellationControlMsg::ReflowComplete(self.id, data.id)); } unsafe fn dirty_all_nodes(node: &mut LayoutNode) { @@ -999,7 +1001,7 @@ impl LayoutRPC for LayoutRPCImpl { DefaultCursor }; let ConstellationChan(ref constellation_chan) = rw_data.constellation_chan; - constellation_chan.send(SetCursorMsg(cursor)); + constellation_chan.send(ConstellationMsg::SetCursor(cursor)); } if mouse_over_list.is_empty() { diff --git a/components/layout/parallel.rs b/components/layout/parallel.rs index 5537ba95998..a6a20ad33ba 100644 --- a/components/layout/parallel.rs +++ b/components/layout/parallel.rs @@ -19,7 +19,7 @@ use wrapper::{PostorderNodeMutTraversal, UnsafeLayoutNode}; use wrapper::{PreorderDomTraversal, PostorderDomTraversal}; use servo_util::opts; -use servo_util::time::{mod, ProfilerMetadata, TimeProfilerChan, profile}; +use servo_util::time::{TimeProfilerCategory, ProfilerMetadata, TimeProfilerChan, profile}; use servo_util::workqueue::{WorkQueue, WorkUnit, WorkerProxy}; use std::mem; use std::ptr; @@ -432,7 +432,8 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef, queue.data = shared_layout_context as *const _; - profile(time::LayoutParallelWarmupCategory, profiler_metadata, time_profiler_chan, || { + profile(TimeProfilerCategory::LayoutParallelWarmup, profiler_metadata, + time_profiler_chan, || { queue.push(WorkUnit { fun: assign_inline_sizes, data: mut_owned_flow_to_unsafe_flow(root), @@ -451,7 +452,8 @@ pub fn build_display_list_for_subtree(root: &mut FlowRef, queue: &mut WorkQueue<*const SharedLayoutContext,UnsafeFlow>) { queue.data = shared_layout_context as *const _; - profile(time::LayoutParallelWarmupCategory, profiler_metadata, time_profiler_chan, || { + profile(TimeProfilerCategory::LayoutParallelWarmup, profiler_metadata, + time_profiler_chan, || { queue.push(WorkUnit { fun: compute_absolute_positions, data: mut_owned_flow_to_unsafe_flow(root), diff --git a/components/msg/compositor_msg.rs b/components/msg/compositor_msg.rs index 32717ec8f17..284e40b53af 100644 --- a/components/msg/compositor_msg.rs +++ b/components/msg/compositor_msg.rs @@ -16,8 +16,8 @@ use constellation_msg::PipelineId; /// The status of the painter. #[deriving(PartialEq, Clone)] pub enum PaintState { - IdlePaintState, - PaintingPaintState, + Idle, + Painting, } #[deriving(Eq, Ord, PartialEq, PartialOrd, Clone, Show)] diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index e9e69c669c7..023df2ccae0 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -9,7 +9,7 @@ use geom::rect::Rect; use geom::size::TypedSize2D; use geom::scale_factor::ScaleFactor; use hyper::header::Headers; -use hyper::method::{Method, Get}; +use hyper::method::Method; use layers::geometry::DevicePixel; use servo_util::cursor::Cursor; use servo_util::geometry::{PagePx, ViewportPx}; @@ -195,26 +195,26 @@ bitflags! { /// Messages from the compositor and script to the constellation. pub enum Msg { - ExitMsg, - FailureMsg(Failure), - InitLoadUrlMsg(Url), - LoadCompleteMsg, - FrameRectMsg(PipelineId, SubpageId, Rect<f32>), - LoadUrlMsg(PipelineId, LoadData), - ScriptLoadedURLInIFrameMsg(Url, PipelineId, SubpageId, IFrameSandboxState), - NavigateMsg(NavigationDirection), - PainterReadyMsg(PipelineId), - ResizedWindowMsg(WindowSizeData), + Exit, + Failure(Failure), + InitLoadUrl(Url), + LoadComplete, + FrameRect(PipelineId, SubpageId, Rect<f32>), + LoadUrl(PipelineId, LoadData), + ScriptLoadedURLInIFrame(Url, PipelineId, SubpageId, IFrameSandboxState), + Navigate(NavigationDirection), + PainterReady(PipelineId), + ResizedWindow(WindowSizeData), KeyEvent(Key, KeyState, KeyModifiers), /// Requests that the constellation inform the compositor of the title of the pipeline /// immediately. - GetPipelineTitleMsg(PipelineId), + GetPipelineTitle(PipelineId), /// Requests that the constellation inform the compositor of the a cursor change. - SetCursorMsg(Cursor), + SetCursor(Cursor), } /// Similar to net::resource_task::LoadData -/// can be passed to LoadUrlMsg to load a page with GET/POST +/// can be passed to LoadUrl to load a page with GET/POST /// parameters or headers #[deriving(Clone)] pub struct LoadData { @@ -228,7 +228,7 @@ impl LoadData { pub fn new(url: Url) -> LoadData { LoadData { url: url, - method: Get, + method: Method::Get, headers: Headers::new(), data: None, } diff --git a/components/net/fetch/request.rs b/components/net/fetch/request.rs index 4e4139f1f7f..f4dd62971f8 100644 --- a/components/net/fetch/request.rs +++ b/components/net/fetch/request.rs @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use url::Url; -use hyper::method::{Get, Method}; -use hyper::mime::{Mime, Text, Html, Charset, Utf8}; +use hyper::method::Method; +use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value}; use hyper::header::Headers; use hyper::header::common::ContentType; use fetch::cors_cache::CORSCache; @@ -87,7 +87,7 @@ pub struct Request { impl Request { pub fn new(url: Url, context: Context) -> Request { Request { - method: Get, + method: Method::Get, url: url, headers: Headers::new(), unsafe_request: false, @@ -118,7 +118,9 @@ impl Request { "about" => match self.url.non_relative_scheme_data() { Some(s) if s.as_slice() == "blank" => { let mut response = Response::new(); - response.headers.set(ContentType(Mime(Text, Html, vec![(Charset, Utf8)]))); + response.headers.set(ContentType(Mime( + TopLevel::Text, SubLevel::Html, + vec![(Attr::Charset, Value::Utf8)]))); response }, _ => Response::network_error() diff --git a/components/net/fetch/response.rs b/components/net/fetch/response.rs index e194aa9375d..f2ee213560d 100644 --- a/components/net/fetch/response.rs +++ b/components/net/fetch/response.rs @@ -4,7 +4,6 @@ use url::Url; use hyper::status::StatusCode; -use hyper::status::Ok as StatusOk; use hyper::header::Headers; use std::ascii::AsciiExt; use std::comm::Receiver; @@ -70,7 +69,7 @@ impl Response { response_type: ResponseType::Default, termination_reason: None, url: None, - status: Some(StatusOk), + status: Some(StatusCode::Ok), headers: Headers::new(), body: ResponseBody::Empty, internal_response: None diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 2c523209203..ccfca4deb26 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -9,8 +9,8 @@ use log; use std::collections::HashSet; use hyper::client::Request; use hyper::header::common::{ContentLength, ContentType, Host, Location}; -use hyper::method::{Get, Head}; -use hyper::status::Redirection; +use hyper::method::Method; +use hyper::status::StatusClass; use std::io::Reader; use servo_util::task::spawn_named; use url::{Url, UrlParser}; @@ -108,7 +108,7 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) { }, None => { match load_data.method { - Get | Head => (), + Method::Get | Method::Head => (), _ => req.headers_mut().set(ContentLength(0)) } match req.start() { @@ -136,7 +136,7 @@ fn load(load_data: LoadData, start_chan: Sender<TargetedLoadResponse>) { } } - if response.status.class() == Redirection { + if response.status.class() == StatusClass::Redirection { match response.headers.get::<Location>() { Some(&Location(ref new_url)) => { // CORS (http://fetch.spec.whatwg.org/#http-fetch, status section, point 9, 10) diff --git a/components/net/image/base.rs b/components/net/image/base.rs index affbd705ae0..8192d469fde 100644 --- a/components/net/image/base.rs +++ b/components/net/image/base.rs @@ -50,8 +50,8 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> { match png::load_png_from_memory(buffer) { Ok(mut png_image) => { match png_image.pixels { - png::RGB8(ref mut data) => byte_swap(data.as_mut_slice()), - png::RGBA8(ref mut data) => { + png::PixelsByColorType::RGB8(ref mut data) => byte_swap(data.as_mut_slice()), + png::PixelsByColorType::RGBA8(ref mut data) => { byte_swap_and_premultiply(data.as_mut_slice()) } _ => {} @@ -66,20 +66,20 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> { static FORCE_DEPTH: uint = 4; match stb_image::load_from_memory_with_depth(buffer, FORCE_DEPTH, true) { - stb_image::ImageU8(mut image) => { + stb_image::LoadResult::ImageU8(mut image) => { assert!(image.depth == 4); byte_swap(image.data.as_mut_slice()); Some(png::Image { width: image.width as u32, height: image.height as u32, - pixels: png::RGBA8(image.data) + pixels: png::PixelsByColorType::RGBA8(image.data) }) } - stb_image::ImageF32(_image) => { + stb_image::LoadResult::ImageF32(_image) => { error!("HDR images not implemented"); None } - stb_image::Error(e) => { + stb_image::LoadResult::Error(e) => { error!("stb_image failed: {}", e); None } diff --git a/components/net/image_cache_task.rs b/components/net/image_cache_task.rs index 0d202a78d3e..aa0097cd86b 100644 --- a/components/net/image_cache_task.rs +++ b/components/net/image_cache_task.rs @@ -13,7 +13,6 @@ use std::comm::{channel, Receiver, Sender}; use std::collections::HashMap; use std::collections::hash_map::{Occupied, Vacant}; use std::mem::replace; -use std::result; use sync::{Arc, Mutex}; use serialize::{Encoder, Encodable}; use url::Url; @@ -456,10 +455,10 @@ fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<Vec<u8>, ()> Payload(data) => { image_data.push_all(data.as_slice()); } - Done(result::Ok(..)) => { + Done(Ok(..)) => { return Ok(image_data); } - Done(result::Err(..)) => { + Done(Err(..)) => { return Err(()); } } diff --git a/components/net/resource_task.rs b/components/net/resource_task.rs index 23cb90f38be..d7bd8f2e40f 100644 --- a/components/net/resource_task.rs +++ b/components/net/resource_task.rs @@ -16,8 +16,8 @@ use servo_util::task::spawn_named; use hyper::header::common::UserAgent; use hyper::header::Headers; use hyper::http::RawStatus; -use hyper::method::{Method, Get}; -use hyper::mime::{Mime, Charset}; +use hyper::method::Method; +use hyper::mime::{Mime, Attr}; use url::Url; use std::comm::{channel, Receiver, Sender}; @@ -43,7 +43,7 @@ impl LoadData { pub fn new(url: Url, consumer: Sender<LoadResponse>) -> LoadData { LoadData { url: url, - method: Get, + method: Method::Get, headers: Headers::new(), data: None, cors: None, @@ -97,7 +97,7 @@ impl Metadata { Some(&Mime(ref type_, ref subtype, ref parameters)) => { self.content_type = Some((type_.to_string(), subtype.to_string())); for &(ref k, ref v) in parameters.iter() { - if &Charset == k { + if &Attr::Charset == k { self.charset = Some(v.to_string()); } } diff --git a/components/script/cors.rs b/components/script/cors.rs index 6b83bd889e9..24900e1daa1 100644 --- a/components/script/cors.rs +++ b/components/script/cors.rs @@ -18,10 +18,10 @@ use time::{now, Timespec}; use hyper::header::{Headers, Header, HeaderFormat, HeaderView}; use hyper::header::common::util as header_util; use hyper::client::Request; -use hyper::mime::{mod, Mime}; +use hyper::mime::{Mime, TopLevel, SubLevel}; use hyper::header::common::{ContentType, Host}; -use hyper::method::{Method, Get, Head, Post, Options}; -use hyper::status::Success; +use hyper::method::Method; +use hyper::status::StatusClass::Success; use url::{SchemeData, Url}; @@ -118,7 +118,7 @@ impl CORSRequest { let mut cors_response = CORSResponse::new(); let mut preflight = self.clone(); // Step 1 - preflight.method = Options; // Step 2 + preflight.method = Method::Options; // Step 2 preflight.headers = Headers::new(); // Step 3 // Step 4 preflight.headers.set(AccessControlRequestMethod(self.method.clone())); @@ -364,9 +364,9 @@ fn is_simple_header(h: &HeaderView) -> bool { match h.name().to_ascii_lower().as_slice() { "accept" | "accept-language" | "content-language" => true, "content-type" => match h.value() { - Some(&ContentType(Mime(mime::Text, mime::Plain, _))) | - Some(&ContentType(Mime(mime::Application, mime::WwwFormUrlEncoded, _))) | - Some(&ContentType(Mime(mime::Multipart, mime::FormData, _))) => true, + Some(&ContentType(Mime(TopLevel::Text, SubLevel::Plain, _))) | + Some(&ContentType(Mime(TopLevel::Application, SubLevel::WwwFormUrlEncoded, _))) | + Some(&ContentType(Mime(TopLevel::Multipart, SubLevel::FormData, _))) => true, _ => false @@ -377,7 +377,7 @@ fn is_simple_header(h: &HeaderView) -> bool { fn is_simple_method(m: &Method) -> bool { match *m { - Get | Head | Post => true, + Method::Get | Method::Head | Method::Post => true, _ => false } } diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index dc9beb97ed4..82b79eb1971 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -674,7 +674,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None, default = "None" else: assert defaultValue.type.tag() == IDLType.Tags.domstring - value = "str::from_utf8(data).unwrap().into_string()" + value = "str::from_utf8(&data).unwrap().into_string()" if type.nullable(): value = "Some(%s)" % value diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 5299360adb7..ff730ea1e12 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -39,7 +39,7 @@ use geom::rect::Rect; use html5ever::tree_builder::QuirksMode; use hyper::header::Headers; use hyper::method::Method; -use js::jsapi::{JSObject, JSTracer, JS_CallTracer, JSTRACE_OBJECT}; +use js::jsapi::{JSObject, JSTracer, JS_CallTracer, JSGCTraceKind}; use js::jsval::JSVal; use js::rust::Cx; use layout_interface::{LayoutRPC, LayoutChan}; @@ -106,7 +106,7 @@ pub fn trace_object(tracer: *mut JSTracer, description: &str, obj: *mut JSObject (*tracer).debugPrintIndex = -1; (*tracer).debugPrintArg = name.as_ptr() as *const libc::c_void; debug!("tracing {}", description); - JS_CallTracer(tracer, obj as *mut libc::c_void, JSTRACE_OBJECT); + JS_CallTracer(tracer, obj as *mut libc::c_void, JSGCTraceKind::JSTRACE_OBJECT); } } diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index 0e7b3ed6e69..99da244d1d2 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -13,7 +13,8 @@ use geom::point::Point2D; use geom::rect::Rect; use geom::size::Size2D; -use canvas::canvas_paint_task::{CanvasMsg, CanvasPaintTask, ClearRect, Close, FillRect, Recreate, StrokeRect}; +use canvas::canvas_paint_task::{CanvasMsg, CanvasPaintTask}; +use canvas::canvas_paint_task::CanvasMsg::{ClearRect, Close, FillRect, Recreate, StrokeRect}; #[dom_struct] pub struct CanvasRenderingContext2D { diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index b9c3b1fc595..7730b657215 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1396,7 +1396,7 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> { } pub trait ActivationElementHelpers<'a> { - fn as_maybe_activatable(&'a self) -> Option<&'a Activatable + 'a>; + fn as_maybe_activatable(&'a self) -> Option<&'a (Activatable + 'a)>; fn click_in_progress(self) -> bool; fn set_click_in_progress(self, click: bool); fn nearest_activable_element(self) -> Option<Temporary<Element>>; @@ -1404,12 +1404,12 @@ pub trait ActivationElementHelpers<'a> { } impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> { - fn as_maybe_activatable(&'a self) -> Option<&'a Activatable + 'a> { + fn as_maybe_activatable(&'a self) -> Option<&'a (Activatable + 'a)> { let node: JSRef<Node> = NodeCast::from_ref(*self); match node.type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => { let element: &'a JSRef<'a, HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(self).unwrap(); - Some(element as &'a Activatable + 'a) + Some(element as &'a (Activatable + 'a)) }, _ => { None diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 2108eb2975d..3720e107179 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -21,7 +21,7 @@ use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::htmlinputelement::HTMLInputElement; use dom::htmltextareaelement::HTMLTextAreaElement; use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node}; -use hyper::method::Post; +use hyper::method::Method; use servo_msg::constellation_msg::LoadData; use servo_util::str::DOMString; use script_task::{ScriptChan, ScriptMsg}; @@ -196,7 +196,7 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> { load_data.url.query = Some(parsed_data); }, ("http", FormMethod::FormPost) | ("https", FormMethod::FormPost) => { - load_data.method = Post; + load_data.method = Method::Post; load_data.data = Some(parsed_data.into_bytes()); }, // https://html.spec.whatwg.org/multipage/forms.html#submit-get-action diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 0069e2e51e0..ab50117b776 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -22,9 +22,9 @@ use dom::virtualmethods::VirtualMethods; use dom::window::Window; use page::IterablePage; -use servo_msg::constellation_msg::{PipelineId, SubpageId}; -use servo_msg::constellation_msg::{IFrameSandboxed, IFrameUnsandboxed}; -use servo_msg::constellation_msg::{ConstellationChan, ScriptLoadedURLInIFrameMsg}; +use servo_msg::constellation_msg::{PipelineId, SubpageId, ConstellationChan}; +use servo_msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed}; +use servo_msg::constellation_msg::Msg as ConstellationMsg; use servo_util::str::DOMString; use std::ascii::AsciiExt; @@ -123,7 +123,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> { })); let ConstellationChan(ref chan) = page.constellation_chan; - chan.send(ScriptLoadedURLInIFrameMsg(url, page.id, subpage_id, sandboxed)); + chan.send(ConstellationMsg::ScriptLoadedURLInIFrame(url, page.id, subpage_id, sandboxed)); } } diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 7a1123850ed..0fb926666fa 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -61,7 +61,7 @@ impl<'a> PrivateHTMLImageElementHelpers for JSRef<'a, HTMLImageElement> { // inform the image cache to load this, but don't store a // handle. - image_cache.send(image_cache_task::Prefetch(img_url)); + image_cache.send(image_cache_task::Msg::Prefetch(img_url)); } } } diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index 4e11b9a4f5b..43478c532d5 100644 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -69,7 +69,7 @@ impl<'a> ProcessDataURL for JSRef<'a, HTMLObjectElement> { if is_image_data(uri.as_slice()) { let data_url = Url::parse(uri.as_slice()).unwrap(); // Issue #84 - image_cache.send(image_cache_task::Prefetch(data_url)); + image_cache.send(image_cache_task::Msg::Prefetch(data_url)); } } _ => { } diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 05f9d4750d6..57578d61dda 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -145,76 +145,76 @@ pub trait VirtualMethods { /// method call on the trait object will invoke the corresponding method on the /// concrete type, propagating up the parent hierarchy unless otherwise /// interrupted. -pub fn vtable_for<'a>(node: &'a JSRef<'a, Node>) -> &'a VirtualMethods + 'a { +pub fn vtable_for<'a>(node: &'a JSRef<'a, Node>) -> &'a (VirtualMethods + 'a) { match node.type_id() { NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) => { let element: &'a JSRef<'a, HTMLAnchorElement> = HTMLAnchorElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAreaElement)) => { let element: &'a JSRef<'a, HTMLAreaElement> = HTMLAreaElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement)) => { let element: &'a JSRef<'a, HTMLBodyElement> = HTMLBodyElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLButtonElement)) => { let element: &'a JSRef<'a, HTMLButtonElement> = HTMLButtonElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLCanvasElement)) => { let element: &'a JSRef<'a, HTMLCanvasElement> = HTMLCanvasElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLFieldSetElement)) => { let element: &'a JSRef<'a, HTMLFieldSetElement> = HTMLFieldSetElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLImageElement)) => { let element: &'a JSRef<'a, HTMLImageElement> = HTMLImageElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLIFrameElement)) => { let element: &'a JSRef<'a, HTMLIFrameElement> = HTMLIFrameElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLInputElement)) => { let element: &'a JSRef<'a, HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLLinkElement)) => { let element: &'a JSRef<'a, HTMLLinkElement> = HTMLLinkElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLObjectElement)) => { let element: &'a JSRef<'a, HTMLObjectElement> = HTMLObjectElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptGroupElement)) => { let element: &'a JSRef<'a, HTMLOptGroupElement> = HTMLOptGroupElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOptionElement)) => { let element: &'a JSRef<'a, HTMLOptionElement> = HTMLOptionElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLScriptElement)) => { let element: &'a JSRef<'a, HTMLScriptElement> = HTMLScriptElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) => { let element: &'a JSRef<'a, HTMLSelectElement> = HTMLSelectElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLStyleElement)) => { let element: &'a JSRef<'a, HTMLStyleElement> = HTMLStyleElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableElement)) => { let element: &'a JSRef<'a, HTMLTableElement> = HTMLTableElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement( HTMLElementTypeId::HTMLTableCellElement( @@ -224,37 +224,37 @@ pub fn vtable_for<'a>(node: &'a JSRef<'a, Node>) -> &'a VirtualMethods + 'a { HTMLTableCellElementTypeId::HTMLTableHeaderCellElement))) => { let element: &'a JSRef<'a, HTMLTableCellElement> = HTMLTableCellElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableRowElement)) => { let element: &'a JSRef<'a, HTMLTableRowElement> = HTMLTableRowElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTableSectionElement)) => { let element: &'a JSRef<'a, HTMLTableSectionElement> = HTMLTableSectionElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) => { let element: &'a JSRef<'a, HTMLTextAreaElement> = HTMLTextAreaElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTitleElement)) => { let element: &'a JSRef<'a, HTMLTitleElement> = HTMLTitleElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(ElementTypeId::Element) => { let element: &'a JSRef<'a, Element> = ElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } NodeTypeId::Element(_) => { let element: &'a JSRef<'a, HTMLElement> = HTMLElementCast::to_borrowed_ref(node).unwrap(); - element as &'a VirtualMethods + 'a + element as &'a (VirtualMethods + 'a) } _ => { - node as &'a VirtualMethods + 'a + node as &'a (VirtualMethods + 'a) } } } diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index b509128230b..2dc5b91b691 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -36,13 +36,15 @@ use hyper::header::Headers; use hyper::header::common::{Accept, ContentLength, ContentType}; use hyper::http::RawStatus; use hyper::mime::{mod, Mime}; -use hyper::method::{Method, Get, Head, Connect, Trace, Extension}; +use hyper::method::Method; use js::jsapi::{JS_ParseJSON, JSContext}; use js::jsapi::JS_ClearPendingException; use js::jsval::{JSVal, NullValue, UndefinedValue}; -use net::resource_task::{ResourceTask, ResourceCORSData, Load, LoadData, LoadResponse, Payload, Done}; +use net::resource_task::{ResourceTask, ResourceCORSData, LoadData, LoadResponse}; +use net::resource_task::ControlMsg::Load; +use net::resource_task::ProgressMsg::{Payload, Done}; use cors::{allow_cross_origin_request, CORSRequest, RequestMode}; use servo_util::str::DOMString; use servo_util::task::spawn_named; @@ -173,7 +175,7 @@ impl XMLHttpRequest { response_xml: Default::default(), response_headers: DOMRefCell::new(Headers::new()), - request_method: DOMRefCell::new(Get), + request_method: DOMRefCell::new(Method::Get), request_url: DOMRefCell::new(None), request_headers: DOMRefCell::new(Headers::new()), request_body_len: Cell::new(0), @@ -360,8 +362,8 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { // Step 2 match maybe_method { // Step 4 - Some(Connect) | Some(Trace) => Err(Security), - Some(Extension(ref t)) if t.as_slice() == "TRACK" => Err(Security), + Some(Method::Connect) | Some(Method::Trace) => Err(Security), + Some(Method::Extension(ref t)) if t.as_slice() == "TRACK" => Err(Security), Some(_) if method.is_token() => { *self.request_method.borrow_mut() = maybe_method.unwrap(); @@ -493,7 +495,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { } let data = match *self.request_method.borrow() { - Get | Head => None, // Step 3 + Method::Get | Method::Head => None, // Step 3 _ => data }; let extracted = data.as_ref().map(|d| d.extract()); @@ -955,7 +957,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { match self.response_headers.borrow().get() { Some(&ContentType(mime::Mime(_, _, ref params))) => { for &(ref name, ref value) in params.iter() { - if name == &mime::Charset { + if name == &mime::Attr::Charset { encoding = encoding_from_whatwg_label(value.to_string().as_slice()).unwrap_or(encoding); } } diff --git a/components/script/lib.rs b/components/script/lib.rs index 9c8bbccc701..490acb01c08 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -23,7 +23,6 @@ extern crate hyper; extern crate js; extern crate libc; extern crate msg; -extern crate native; extern crate net; extern crate rustrt; extern crate serialize; diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs index a650895e4c3..d8aba1090b0 100644 --- a/components/script/parse/html.rs +++ b/components/script/parse/html.rs @@ -21,7 +21,7 @@ use parse::Parser; use encoding::all::UTF_8; use encoding::types::{Encoding, DecoderTrap}; -use servo_net::resource_task::{Payload, Done, LoadResponse}; +use servo_net::resource_task::{ProgressMsg, LoadResponse}; use servo_util::task_state; use servo_util::task_state::IN_HTML_PARSER; use std::ascii::AsciiExt; @@ -186,15 +186,15 @@ pub fn parse_html(document: JSRef<Document>, _ => { for msg in load_response.progress_port.iter() { match msg { - Payload(data) => { + ProgressMsg::Payload(data) => { // FIXME: use Vec<u8> (html5ever #34) let data = UTF_8.decode(data.as_slice(), DecoderTrap::Replace).unwrap(); parser.parse_chunk(data); } - Done(Err(err)) => { + ProgressMsg::Done(Err(err)) => { panic!("Failed to load page URL {}, error: {}", url.serialize(), err); } - Done(Ok(())) => break, + ProgressMsg::Done(Ok(())) => break, } } } diff --git a/components/script/script_task.rs b/components/script/script_task.rs index b1fc9d2ac40..2b192c75587 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -38,22 +38,23 @@ use devtools; use devtools_traits::{DevtoolsControlChan, DevtoolsControlPort, NewGlobal, GetRootNode, DevtoolsPageInfo}; use devtools_traits::{DevtoolScriptControlMsg, EvaluateJS, GetDocumentElement}; use devtools_traits::{GetChildren, GetLayout, ModifyAttribute}; -use script_traits::{CompositorEvent, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent}; -use script_traits::{MouseMoveEvent, MouseUpEvent, ConstellationControlMsg, ScriptTaskFactory}; -use script_traits::{ResizeMsg, AttachLayoutMsg, GetTitleMsg, KeyEvent, LoadMsg, ViewportMsg}; -use script_traits::{ResizeInactiveMsg, ExitPipelineMsg, NewLayoutInfo, OpaqueScriptLayoutChannel}; -use script_traits::{ScriptControlChan, ReflowCompleteMsg, SendEventMsg}; -use servo_msg::compositor_msg::{FinishedLoading, LayerId, Loading, PerformingLayout}; -use servo_msg::compositor_msg::{ScriptListener}; -use servo_msg::constellation_msg::{ConstellationChan, LoadCompleteMsg}; -use servo_msg::constellation_msg::{LoadData, LoadUrlMsg, NavigationDirection, PipelineId}; -use servo_msg::constellation_msg::{Failure, FailureMsg, WindowSizeData, Key, KeyState}; -use servo_msg::constellation_msg::{KeyModifiers, SUPER, SHIFT, CONTROL, ALT, Repeated, Pressed}; -use servo_msg::constellation_msg::{Released}; +use script_traits::CompositorEvent; +use script_traits::CompositorEvent::{ResizeEvent, ReflowEvent, ClickEvent}; +use script_traits::CompositorEvent::{MouseDownEvent, MouseUpEvent}; +use script_traits::CompositorEvent::{MouseMoveEvent, KeyEvent}; +use script_traits::{NewLayoutInfo, OpaqueScriptLayoutChannel}; +use script_traits::{ConstellationControlMsg, ScriptControlChan}; +use script_traits::ScriptTaskFactory; +use servo_msg::compositor_msg::ReadyState::{FinishedLoading, Loading, PerformingLayout}; +use servo_msg::compositor_msg::{LayerId, ScriptListener}; +use servo_msg::constellation_msg::{ConstellationChan}; +use servo_msg::constellation_msg::{LoadData, NavigationDirection, PipelineId}; +use servo_msg::constellation_msg::{Failure, Msg, WindowSizeData, Key, KeyState}; +use servo_msg::constellation_msg::{KeyModifiers, SUPER, SHIFT, CONTROL, ALT}; use servo_msg::constellation_msg::{PipelineExitType}; -use servo_msg::constellation_msg; +use servo_msg::constellation_msg::Msg as ConstellationMsg; use servo_net::image_cache_task::ImageCacheTask; -use servo_net::resource_task::{ResourceTask, Load}; +use servo_net::resource_task::{ResourceTask, ControlMsg}; use servo_net::resource_task::LoadData as NetLoadData; use servo_net::storage_task::StorageTask; use servo_util::geometry::to_frac_px; @@ -313,7 +314,7 @@ impl ScriptTaskFactory for ScriptTask { // This must always be the very last operation performed before the task completes failsafe.neuter(); - }, FailureMsg(failure_msg), const_chan, false); + }, ConstellationMsg::Failure(failure_msg), const_chan, false); } } @@ -505,15 +506,15 @@ impl ScriptTask { // This has to be handled before the ResizeMsg below, // otherwise the page may not have been added to the // child list yet, causing the find() to fail. - MixedMessage::FromConstellation(AttachLayoutMsg(new_layout_info)) => { + MixedMessage::FromConstellation(ConstellationControlMsg::AttachLayout(new_layout_info)) => { self.handle_new_layout(new_layout_info); } - MixedMessage::FromConstellation(ResizeMsg(id, size)) => { + MixedMessage::FromConstellation(ConstellationControlMsg::Resize(id, size)) => { let page = self.page.borrow_mut(); let page = page.find(id).expect("resize sent to nonexistent pipeline"); page.resize_event.set(Some(size)); } - MixedMessage::FromConstellation(ViewportMsg(id, rect)) => { + MixedMessage::FromConstellation(ConstellationControlMsg::Viewport(id, rect)) => { let page = self.page.borrow_mut(); let inner_page = page.find(id).expect("Page rect message sent to nonexistent pipeline"); if inner_page.set_page_clip_rect_with_new_viewport(rect) { @@ -544,7 +545,7 @@ impl ScriptTask { // Process the gathered events. for msg in sequential.into_iter() { match msg { - MixedMessage::FromConstellation(ExitPipelineMsg(id, exit_type)) => { + MixedMessage::FromConstellation(ConstellationControlMsg::ExitPipeline(id, exit_type)) => { if self.handle_exit_pipeline_msg(id, exit_type) { return false } @@ -560,24 +561,23 @@ impl ScriptTask { fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) { match msg { - // TODO(tkuehn) need to handle auxiliary layouts for iframes - AttachLayoutMsg(_) => - panic!("should have handled AttachLayoutMsg already"), - LoadMsg(id, load_data) => + ConstellationControlMsg::AttachLayout(_) => + panic!("should have handled AttachLayout already"), + ConstellationControlMsg::Load(id, load_data) => self.load(id, load_data), - SendEventMsg(id, event) => + ConstellationControlMsg::SendEvent(id, event) => self.handle_event(id, event), - ReflowCompleteMsg(id, reflow_id) => + ConstellationControlMsg::ReflowComplete(id, reflow_id) => self.handle_reflow_complete_msg(id, reflow_id), - ResizeInactiveMsg(id, new_size) => + ConstellationControlMsg::ResizeInactive(id, new_size) => self.handle_resize_inactive_msg(id, new_size), - ViewportMsg(..) => - panic!("should have handled ViewportMsg already"), - ResizeMsg(..) => - panic!("should have handled ResizeMsg already"), - ExitPipelineMsg(..) => - panic!("should have handled ExitPipelineMsg already"), - GetTitleMsg(pipeline_id) => + ConstellationControlMsg::Viewport(..) => + panic!("should have handled Viewport already"), + ConstellationControlMsg::Resize(..) => + panic!("should have handled Resize already"), + ConstellationControlMsg::ExitPipeline(..) => + panic!("should have handled ExitPipeline already"), + ConstellationControlMsg::GetTitle(pipeline_id) => self.handle_get_title_msg(pipeline_id), } } @@ -677,7 +677,7 @@ impl ScriptTask { /// TODO(tkuehn): is it ever possible to navigate only on a subframe? fn handle_navigate_msg(&self, direction: NavigationDirection) { let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(constellation_msg::NavigateMsg(direction)); + chan.send(ConstellationMsg::Navigate(direction)); } /// Window was resized, but this script was not active, so don't reflow yet @@ -807,7 +807,7 @@ impl ScriptTask { let (parser_input, final_url) = if !is_javascript { // Wait for the LoadResponse so that the parser knows the final URL. let (input_chan, input_port) = channel(); - self.resource_task.send(Load(NetLoadData { + self.resource_task.send(ControlMsg::Load(NetLoadData { url: url, method: load_data.method, headers: load_data.headers, @@ -882,7 +882,7 @@ impl ScriptTask { *page.fragment_name.borrow_mut() = final_url.fragment.clone(); let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(LoadCompleteMsg); + chan.send(ConstellationMsg::LoadComplete); // Notify devtools that a new script global exists. match self.devtools_chan { @@ -1054,7 +1054,7 @@ impl ScriptTask { /// for the given pipeline. fn trigger_load(&self, pipeline_id: PipelineId, load_data: LoadData) { let ConstellationChan(ref const_chan) = self.constellation_chan; - const_chan.send(LoadUrlMsg(pipeline_id, load_data)); + const_chan.send(ConstellationMsg::LoadUrl(pipeline_id, load_data)); } /// The entry point for content to notify that a fragment url has been requested diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 15cbf36027d..f53ce386aad 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -50,23 +50,23 @@ pub struct NewLayoutInfo { /// Messages sent from the constellation to the script task pub enum ConstellationControlMsg { /// Loads a new URL on the specified pipeline. - LoadMsg(PipelineId, LoadData), + Load(PipelineId, LoadData), /// Gives a channel and ID to a layout task, as well as the ID of that layout's parent - AttachLayoutMsg(NewLayoutInfo), + AttachLayout(NewLayoutInfo), /// Window resized. Sends a DOM event eventually, but first we combine events. - ResizeMsg(PipelineId, WindowSizeData), + Resize(PipelineId, WindowSizeData), /// Notifies script that window has been resized but to not take immediate action. - ResizeInactiveMsg(PipelineId, WindowSizeData), + ResizeInactive(PipelineId, WindowSizeData), /// Notifies the script that a pipeline should be closed. - ExitPipelineMsg(PipelineId, PipelineExitType), + ExitPipeline(PipelineId, PipelineExitType), /// Sends a DOM event. - SendEventMsg(PipelineId, CompositorEvent), + SendEvent(PipelineId, CompositorEvent), /// Notifies script that reflow is finished. - ReflowCompleteMsg(PipelineId, uint), + ReflowComplete(PipelineId, uint), /// Notifies script of the viewport. - ViewportMsg(PipelineId, Rect<f32>), + Viewport(PipelineId, Rect<f32>), /// Requests that the script task immediately send the constellation the title of a pipeline. - GetTitleMsg(PipelineId), + GetTitle(PipelineId), } /// Events from the compositor that the script task needs to know about diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 6d623eaed1c..8d64a1d73bc 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -20,7 +20,6 @@ extern crate script; extern crate layout; extern crate gfx; extern crate libc; -extern crate native; extern crate rustrt; extern crate url; @@ -30,7 +29,9 @@ use compositing::windowing::{WindowEvent, WindowMethods}; #[cfg(not(test))] use compositing::{CompositorProxy, CompositorTask, Constellation}; #[cfg(not(test))] -use servo_msg::constellation_msg::{ConstellationChan, InitLoadUrlMsg}; +use servo_msg::constellation_msg::Msg as ConstellationMsg; +#[cfg(not(test))] +use servo_msg::constellation_msg::ConstellationChan; #[cfg(not(test))] use script::dom::bindings::codegen::RegisterBindings; @@ -120,7 +121,7 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static { }; let ConstellationChan(ref chan) = constellation_chan; - chan.send(InitLoadUrlMsg(url)); + chan.send(ConstellationMsg::InitLoadUrl(url)); } // Send the constallation Chan as the result diff --git a/components/servo/main.rs b/components/servo/main.rs index 905ff205c61..be8dc7e7f03 100644 --- a/components/servo/main.rs +++ b/components/servo/main.rs @@ -11,7 +11,6 @@ extern crate libc; extern crate servo; -extern crate native; extern crate time; extern crate "util" as servo_util; diff --git a/components/style/font_face.rs b/components/style/font_face.rs index d724a190880..2e06f514510 100644 --- a/components/style/font_face.rs +++ b/components/style/font_face.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::ast::*; +use cssparser::ast::ComponentValue::*; use cssparser::parse_declaration_list; use errors::{ErrorLoggerIterator, log_css_error}; use std::ascii::AsciiExt; diff --git a/components/style/media_queries.rs b/components/style/media_queries.rs index 6ff7a412280..60a6ed5fc59 100644 --- a/components/style/media_queries.rs +++ b/components/style/media_queries.rs @@ -5,6 +5,7 @@ use std::ascii::AsciiExt; use cssparser::parse_rule_list; use cssparser::ast::*; +use cssparser::ast::ComponentValue::*; use errors::{ErrorLoggerIterator, log_css_error}; use geom::size::TypedSize2D; diff --git a/components/style/namespaces.rs b/components/style/namespaces.rs index cfcd3d8615e..b1e1df89cd7 100644 --- a/components/style/namespaces.rs +++ b/components/style/namespaces.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::ast::*; +use cssparser::ast::ComponentValue::*; use std::collections::HashMap; use servo_util::namespace; use errors::log_css_error; diff --git a/components/style/parsing_utils.rs b/components/style/parsing_utils.rs index 204c01a62a9..97ebb3cad4d 100644 --- a/components/style/parsing_utils.rs +++ b/components/style/parsing_utils.rs @@ -4,7 +4,8 @@ use std::ascii::AsciiExt; -use cssparser::ast::{ComponentValue, Ident, Comma, SkipWhitespaceIterable, SkipWhitespaceIterator}; +use cssparser::ast::{SkipWhitespaceIterable, SkipWhitespaceIterator}; +use cssparser::ast::ComponentValue::{mod, Ident, Comma}; pub fn one_component_value<'a>(input: &'a [ComponentValue]) -> Result<&'a ComponentValue, ()> { diff --git a/components/style/properties/common_types.rs b/components/style/properties/common_types.rs index f55d9ee7fb2..5a5f1a95f20 100644 --- a/components/style/properties/common_types.rs +++ b/components/style/properties/common_types.rs @@ -24,7 +24,7 @@ macro_rules! define_css_keyword_enum { impl $name { pub fn parse(component_value: &::cssparser::ast::ComponentValue) -> Result<$name, ()> { match component_value { - &::cssparser::ast::Ident(ref value) => { + &::cssparser::ast::ComponentValue::Ident(ref value) => { match_ignore_ascii_case! { value: $( $css => Ok($name::$variant) ),+ _ => Err(()) @@ -63,8 +63,9 @@ pub mod specified { use std::fmt; use std::fmt::{Formatter, Show}; use url::Url; - use cssparser::{mod, ast, ToCss, CssStringWriter}; + use cssparser::{mod, ToCss, CssStringWriter}; use cssparser::ast::*; + use cssparser::ast::ComponentValue::*; use text_writer::{mod, TextWriter}; use parsing_utils::{mod, BufferedIter, ParserIter}; use super::{Au, CSSFloat}; @@ -244,7 +245,7 @@ pub mod specified { &Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => Length::parse_dimension(value.value, unit.as_slice()) .map(LengthOrPercentage::Length), - &ast::Percentage(ref value) if negative_ok || value.value >= 0. => + &Percentage(ref value) if negative_ok || value.value >= 0. => Ok(LengthOrPercentage::Percentage(value.value / 100.)), &Number(ref value) if value.value == 0. => Ok(LengthOrPercentage::Length(Length::Au(Au(0)))), @@ -289,7 +290,7 @@ pub mod specified { match input { &Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => Length::parse_dimension(value.value, unit.as_slice()).map(LengthOrPercentageOrAuto::Length), - &ast::Percentage(ref value) if negative_ok || value.value >= 0. => + &Percentage(ref value) if negative_ok || value.value >= 0. => Ok(LengthOrPercentageOrAuto::Percentage(value.value / 100.)), &Number(ref value) if value.value == 0. => Ok(LengthOrPercentageOrAuto::Length(Length::Au(Au(0)))), @@ -335,7 +336,7 @@ pub mod specified { match input { &Dimension(ref value, ref unit) if negative_ok || value.value >= 0. => Length::parse_dimension(value.value, unit.as_slice()).map(LengthOrPercentageOrNone::Length), - &ast::Percentage(ref value) if negative_ok || value.value >= 0. + &Percentage(ref value) if negative_ok || value.value >= 0. => Ok(LengthOrPercentageOrNone::Percentage(value.value / 100.)), &Number(ref value) if value.value == 0. => Ok(LengthOrPercentageOrNone::Length(Length::Au(Au(0)))), &Ident(ref value) if value.as_slice().eq_ignore_ascii_case("none") => Ok(LengthOrPercentageOrNone::None), @@ -369,7 +370,7 @@ pub mod specified { match input { &Dimension(ref value, ref unit) => Length::parse_dimension(value.value, unit.as_slice()).map(PositionComponent::Length), - &ast::Percentage(ref value) => Ok(PositionComponent::Percentage(value.value / 100.)), + &Percentage(ref value) => Ok(PositionComponent::Percentage(value.value / 100.)), &Number(ref value) if value.value == 0. => Ok(PositionComponent::Length(Length::Au(Au(0)))), &Ident(ref value) => { if value.as_slice().eq_ignore_ascii_case("center") { Ok(PositionComponent::Center) } @@ -464,11 +465,11 @@ pub mod specified { pub fn from_component_value(component_value: &ComponentValue, base_url: &Url) -> Result<Image,()> { match component_value { - &ast::URL(ref url) => { + &URL(ref url) => { let image_url = super::parse_url(url.as_slice(), base_url); Ok(Image::Url(image_url)) }, - &ast::Function(ref name, ref args) => { + &Function(ref name, ref args) => { if name.as_slice().eq_ignore_ascii_case("linear-gradient") { Ok(Image::LinearGradient(try!( super::specified::LinearGradient::parse_function( diff --git a/components/style/properties/mod.rs.mako b/components/style/properties/mod.rs.mako index 5cadf89fd46..02e3886c522 100644 --- a/components/style/properties/mod.rs.mako +++ b/components/style/properties/mod.rs.mako @@ -14,6 +14,7 @@ pub use url::Url; pub use cssparser::*; pub use cssparser::ast::*; +pub use cssparser::ast::ComponentValue::*; pub use geom::SideOffsets2D; pub use self::common_types::specified::{Angle, AngleOrCorner}; pub use self::common_types::specified::{HorizontalDirection, VerticalDirection}; @@ -480,7 +481,7 @@ pub mod longhands { fn from_component_value(input: &ComponentValue, _: &Url) -> Result<SpecifiedValue,()> { match *input { Ident(ref keyword) if keyword.as_slice().eq_ignore_ascii_case("auto") => Ok(T::Auto), - ast::Number(ast::NumericValue { + Number(NumericValue { int_value: Some(value), .. }) => Ok(T::Number(value as i32)), @@ -563,9 +564,9 @@ pub mod longhands { pub fn from_component_value(input: &ComponentValue, _base_url: &Url) -> Result<SpecifiedValue, ()> { match input { - &ast::Number(ref value) if value.value >= 0. => + &Number(ref value) if value.value >= 0. => Ok(SpecifiedValue::Number(value.value)), - &ast::Percentage(ref value) if value.value >= 0. => + &Percentage(ref value) if value.value >= 0. => Ok(SpecifiedValue::Percentage(value.value / 100.)), &Dimension(ref value, ref unit) if value.value >= 0. => specified::Length::parse_dimension(value.value, unit.as_slice()) @@ -829,7 +830,8 @@ pub mod longhands { pub fn from_component_value(component_value: &ComponentValue, base_url: &Url) -> Result<SpecifiedValue, ()> { match component_value { - &ast::Ident(ref value) if value.as_slice().eq_ignore_ascii_case("none") => { + &Ident(ref value) + if value.as_slice().eq_ignore_ascii_case("none") => { Ok(CSSImage(None)) } _ => { diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index 203c70ff7f5..a5a1f556d16 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -5,7 +5,6 @@ use std::ascii::AsciiExt; use std::collections::HashMap; use std::hash::Hash; -use std::num::div_rem; use sync::Arc; use url::Url; @@ -300,7 +299,7 @@ impl Stylist { // (Does it make a difference?) for &filename in ["user-agent.css", "servo.css", "presentational-hints.css"].iter() { let ua_stylesheet = Stylesheet::from_bytes( - read_resource_file([filename]).unwrap().as_slice(), + read_resource_file(&[filename]).unwrap().as_slice(), Url::parse(format!("chrome:///{}", filename).as_slice()).unwrap(), None, None, @@ -392,7 +391,7 @@ impl Stylist { pub fn add_quirks_mode_stylesheet(&mut self) { self.add_stylesheet(Stylesheet::from_bytes( - read_resource_file(["quirks-mode.css"]).unwrap().as_slice(), + read_resource_file(&["quirks-mode.css"]).unwrap().as_slice(), Url::parse("chrome:///quirks-mode.css").unwrap(), None, None, @@ -1083,15 +1082,14 @@ fn matches_generic_nth_child<'a,E,N>(element: &N, index += 1; } } - } if a == 0 { - return b == index; + b == index + } else { + (index - b) / a >= 0 && + (index - b) % a == 0 } - - let (n, r) = div_rem(index - b, a); - n >= 0 && r == 0 } #[inline] diff --git a/components/style/selectors.rs b/components/style/selectors.rs index 4ad7e404cc9..5b5833d308d 100644 --- a/components/style/selectors.rs +++ b/components/style/selectors.rs @@ -7,6 +7,7 @@ use std::ascii::{AsciiExt, OwnedAsciiExt}; use sync::Arc; use cssparser::ast::*; +use cssparser::ast::ComponentValue::*; use cssparser::{tokenize, parse_nth}; use selector_matching::StylesheetOrigin; diff --git a/components/util/lib.rs b/components/util/lib.rs index 6dbac1094d6..a1d31be4298 100644 --- a/components/util/lib.rs +++ b/components/util/lib.rs @@ -18,7 +18,6 @@ extern crate geom; extern crate getopts; extern crate layers; extern crate libc; -extern crate native; extern crate rand; extern crate rustrt; extern crate serialize; diff --git a/components/util/task.rs b/components/util/task.rs index 6047fdb3dae..5907841e434 100644 --- a/components/util/task.rs +++ b/components/util/task.rs @@ -6,7 +6,6 @@ use std::str::IntoMaybeOwned; use std::task; use std::comm::Sender; use std::task::TaskBuilder; -use native::task::NativeTaskBuilder; use rtinstrument; use task_state; @@ -18,10 +17,7 @@ pub fn spawn_named<S: IntoMaybeOwned<'static>>(name: S, f: proc():Send) { } pub fn spawn_named_native<S: IntoMaybeOwned<'static>>(name: S, f: proc():Send) { - let builder = task::TaskBuilder::new().named(name).native(); - builder.spawn(proc() { - rtinstrument::instrument(f); - }); + spawn_named(name, f) } /// Arrange to send a particular message to a channel if the task fails. @@ -30,17 +26,11 @@ pub fn spawn_named_with_send_on_failure<T: Send>(name: &'static str, f: proc(): Send, msg: T, dest: Sender<T>, - native: bool) { - let with_state = proc() { + _native: bool) { + let future_result = TaskBuilder::new().named(name).try_future(proc() { task_state::initialize(state); rtinstrument::instrument(f); - }; - - let future_result = if native { - TaskBuilder::new().named(name).native().try_future(with_state) - } else { - TaskBuilder::new().named(name).try_future(with_state) - }; + }); let watched_name = name.into_string(); let watcher_name = format!("{}Watcher", watched_name); diff --git a/components/util/time.rs b/components/util/time.rs index c4a994bc832..96d037c520a 100644 --- a/components/util/time.rs +++ b/components/util/time.rs @@ -71,21 +71,21 @@ pub enum TimeProfilerMsg { #[repr(u32)] #[deriving(PartialEq, Clone, PartialOrd, Eq, Ord)] pub enum TimeProfilerCategory { - CompositingCategory, - LayoutPerformCategory, - LayoutStyleRecalcCategory, + Compositing, + LayoutPerform, + LayoutStyleRecalc, LayoutRestyleDamagePropagation, LayoutNonIncrementalReset, - LayoutSelectorMatchCategory, - LayoutTreeBuilderCategory, - LayoutDamagePropagateCategory, - LayoutMainCategory, - LayoutParallelWarmupCategory, - LayoutShapingCategory, - LayoutDispListBuildCategory, - PaintingPerTileCategory, - PaintingPrepBuffCategory, - PaintingCategory, + LayoutSelectorMatch, + LayoutTreeBuilder, + LayoutDamagePropagate, + LayoutMain, + LayoutParallelWarmup, + LayoutShaping, + LayoutDispListBuild, + PaintingPerTile, + PaintingPrepBuff, + Painting, } impl Formatable for TimeProfilerCategory { @@ -93,36 +93,36 @@ impl Formatable for TimeProfilerCategory { // and should be printed to indicate this fn format(&self) -> String { let padding = match *self { - TimeProfilerCategory::LayoutStyleRecalcCategory | + TimeProfilerCategory::LayoutStyleRecalc | TimeProfilerCategory::LayoutRestyleDamagePropagation | TimeProfilerCategory::LayoutNonIncrementalReset | - TimeProfilerCategory::LayoutMainCategory | - TimeProfilerCategory::LayoutDispListBuildCategory | - TimeProfilerCategory::LayoutShapingCategory | - TimeProfilerCategory::LayoutDamagePropagateCategory | - TimeProfilerCategory::PaintingPerTileCategory | - TimeProfilerCategory::PaintingPrepBuffCategory => "+ ", - TimeProfilerCategory::LayoutParallelWarmupCategory | - TimeProfilerCategory::LayoutSelectorMatchCategory | - TimeProfilerCategory::LayoutTreeBuilderCategory => "| + ", + TimeProfilerCategory::LayoutMain | + TimeProfilerCategory::LayoutDispListBuild | + TimeProfilerCategory::LayoutShaping | + TimeProfilerCategory::LayoutDamagePropagate | + TimeProfilerCategory::PaintingPerTile | + TimeProfilerCategory::PaintingPrepBuff => "+ ", + TimeProfilerCategory::LayoutParallelWarmup | + TimeProfilerCategory::LayoutSelectorMatch | + TimeProfilerCategory::LayoutTreeBuilder => "| + ", _ => "" }; let name = match *self { - TimeProfilerCategory::CompositingCategory => "Compositing", - TimeProfilerCategory::LayoutPerformCategory => "Layout", - TimeProfilerCategory::LayoutStyleRecalcCategory => "Style Recalc", + TimeProfilerCategory::Compositing => "Compositing", + TimeProfilerCategory::LayoutPerform => "Layout", + TimeProfilerCategory::LayoutStyleRecalc => "Style Recalc", TimeProfilerCategory::LayoutRestyleDamagePropagation => "Restyle Damage Propagation", TimeProfilerCategory::LayoutNonIncrementalReset => "Non-incremental reset (temporary)", - TimeProfilerCategory::LayoutSelectorMatchCategory => "Selector Matching", - TimeProfilerCategory::LayoutTreeBuilderCategory => "Tree Building", - TimeProfilerCategory::LayoutDamagePropagateCategory => "Damage Propagation", - TimeProfilerCategory::LayoutMainCategory => "Primary Layout Pass", - TimeProfilerCategory::LayoutParallelWarmupCategory => "Parallel Warmup", - TimeProfilerCategory::LayoutShapingCategory => "Shaping", - TimeProfilerCategory::LayoutDispListBuildCategory => "Display List Construction", - TimeProfilerCategory::PaintingPerTileCategory => "Painting Per Tile", - TimeProfilerCategory::PaintingPrepBuffCategory => "Buffer Prep", - TimeProfilerCategory::PaintingCategory => "Painting", + TimeProfilerCategory::LayoutSelectorMatch => "Selector Matching", + TimeProfilerCategory::LayoutTreeBuilder => "Tree Building", + TimeProfilerCategory::LayoutDamagePropagate => "Damage Propagation", + TimeProfilerCategory::LayoutMain => "Primary Layout Pass", + TimeProfilerCategory::LayoutParallelWarmup => "Parallel Warmup", + TimeProfilerCategory::LayoutShaping => "Shaping", + TimeProfilerCategory::LayoutDispListBuild => "Display List Construction", + TimeProfilerCategory::PaintingPerTile => "Painting Per Tile", + TimeProfilerCategory::PaintingPrepBuff => "Buffer Prep", + TimeProfilerCategory::Painting => "Painting", }; format!("{}{}", padding, name) } diff --git a/ports/glfw/window.rs b/ports/glfw/window.rs index 377bb2839b6..9410949ef66 100644 --- a/ports/glfw/window.rs +++ b/ports/glfw/window.rs @@ -23,8 +23,8 @@ use gleam::gl; use layers::geometry::DevicePixel; use layers::platform::surface::NativeGraphicsMetadata; use libc::c_int; -use msg::compositor_msg::{Blank, FinishedLoading, IdlePaintState, Loading, PaintState}; -use msg::compositor_msg::{PaintingPaintState, PerformingLayout, ReadyState}; +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 std::cell::{Cell, RefCell}; @@ -81,7 +81,7 @@ impl Window { mouse_down_point: Cell::new(Point2D(0 as c_int, 0)), ready_state: Cell::new(Blank), - paint_state: Cell::new(IdlePaintState), + paint_state: Cell::new(PaintState::Idle), last_title_set_time: Cell::new(Timespec::new(0, 0)), }; @@ -354,10 +354,10 @@ impl Window { } FinishedLoading => { match self.paint_state.get() { - PaintingPaintState => { + PaintState::Painting => { self.glfw_window.set_title("Rendering — Servo [GLFW]") } - IdlePaintState => { + PaintState::Idle => { self.glfw_window.set_title("Servo [GLFW]") } } diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index f463d42483d..500be58fbfa 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -19,8 +19,8 @@ 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::{IdlePaintState, PaintState, PaintingPaintState}; -use msg::compositor_msg::{FinishedLoading, Blank, Loading, PerformingLayout, ReadyState}; +use msg::compositor_msg::{PaintState, FinishedLoading, Blank, Loading}; +use msg::compositor_msg::{PerformingLayout, ReadyState}; use msg::constellation_msg::LoadData; use std::cell::{Cell, RefCell}; use std::num::Float; @@ -156,7 +156,7 @@ impl Window { mouse_pos: Cell::new(Point2D(0, 0)), ready_state: Cell::new(Blank), - paint_state: Cell::new(IdlePaintState), + paint_state: Cell::new(PaintState::Idle), key_modifiers: Cell::new(KeyModifiers::empty()), last_title_set_time: Cell::new(Timespec::new(0, 0)), @@ -344,10 +344,10 @@ impl Window { } FinishedLoading => { match self.paint_state.get() { - PaintingPaintState => { + PaintState::Painting => { window.set_title("Rendering - Servo [glutin]") } - IdlePaintState => { + PaintState::Idle => { window.set_title("Servo [glutin]") } } diff --git a/ports/gonk/src/lib.rs b/ports/gonk/src/lib.rs index 17243bf37e2..468ae25938c 100644 --- a/ports/gonk/src/lib.rs +++ b/ports/gonk/src/lib.rs @@ -20,7 +20,6 @@ extern crate script; extern crate layout; extern crate gfx; extern crate libc; -extern crate native; extern crate rustrt; extern crate url; diff --git a/ports/gonk/src/main.rs b/ports/gonk/src/main.rs index ce233f901da..55aa1a6936e 100644 --- a/ports/gonk/src/main.rs +++ b/ports/gonk/src/main.rs @@ -6,7 +6,6 @@ #![deny(unused_variables)] extern crate servo; -extern crate native; extern crate time; extern crate "util" as servo_util; diff --git a/ports/gonk/src/window.rs b/ports/gonk/src/window.rs index 141cd409843..fd99df29ec4 100644 --- a/ports/gonk/src/window.rs +++ b/ports/gonk/src/window.rs @@ -11,8 +11,7 @@ use geom::size::TypedSize2D; use layers::geometry::DevicePixel; use layers::platform::surface::NativeGraphicsMetadata; use libc::c_int; -use msg::compositor_msg::{Blank, IdlePaintState}; -use msg::compositor_msg::{ReadyState, PaintState}; +use msg::compositor_msg::{Blank, ReadyState, PaintState}; use msg::constellation_msg::{Key, KeyModifiers}; use msg::constellation_msg::LoadData; use std::cell::Cell; @@ -748,7 +747,7 @@ impl Window { surf: eglwindow, ready_state: Cell::new(Blank), - paint_state: Cell::new(IdlePaintState), + paint_state: Cell::new(PaintState::Idle), }; Rc::new(window) |