Skip to content

Commit

Permalink
Auto merge of #7203 - jdm:style, r=Ms2ger
Browse files Browse the repository at this point in the history
Add automated style nit checks to test-tidy

Expands on the work by @Wilmoz and cleans up the existing errors. Closes #7180. Closes #7111.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7203)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Aug 16, 2015
2 parents 4d7dd66 + f6b3beb commit e74825f
Show file tree
Hide file tree
Showing 94 changed files with 489 additions and 405 deletions.
4 changes: 2 additions & 2 deletions components/canvas_traits/lib.rs
Expand Up @@ -66,13 +66,13 @@ pub enum FromPaintMsg {
}

impl Serialize for FromPaintMsg {
fn serialize<S>(&self, _: &mut S) -> Result<(),S::Error> where S: Serializer {
fn serialize<S>(&self, _: &mut S) -> Result<(), S::Error> where S: Serializer {
panic!("can't serialize a `FromPaintMsg`!")
}
}

impl Deserialize for FromPaintMsg {
fn deserialize<D>(_: &mut D) -> Result<FromPaintMsg,D::Error> where D: Deserializer {
fn deserialize<D>(_: &mut D) -> Result<FromPaintMsg, D::Error> where D: Deserializer {
panic!("can't deserialize a `FromPaintMsg`!")
}
}
Expand Down
10 changes: 5 additions & 5 deletions components/compositing/compositor.rs
Expand Up @@ -52,7 +52,7 @@ use url::Url;
use util::geometry::{Au, PagePx, ScreenPx, ViewportPx};
use util::opts;

const BUFFER_MAP_SIZE : usize = 10000000;
const BUFFER_MAP_SIZE: usize = 10000000;

/// Holds the state when running reftests that determines when it is
/// safe to save the output image.
Expand Down Expand Up @@ -163,8 +163,8 @@ pub struct IOCompositor<Window: WindowMethods> {
}

pub struct ScrollEvent {
delta: TypedPoint2D<DevicePixel,f32>,
cursor: TypedPoint2D<DevicePixel,i32>,
delta: TypedPoint2D<DevicePixel, f32>,
cursor: TypedPoint2D<DevicePixel, i32>,
}

#[derive(PartialEq)]
Expand Down Expand Up @@ -249,7 +249,7 @@ pub fn reporter_name() -> String {

impl<Window: WindowMethods> IOCompositor<Window> {
fn new(window: Rc<Window>,
sender: Box<CompositorProxy+Send>,
sender: Box<CompositorProxy + Send>,
receiver: Box<CompositorReceiver>,
constellation_chan: ConstellationChan,
time_profiler_chan: time::ProfilerChan,
Expand Down Expand Up @@ -312,7 +312,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}

pub fn create(window: Rc<Window>,
sender: Box<CompositorProxy+Send>,
sender: Box<CompositorProxy + Send>,
receiver: Box<CompositorReceiver>,
constellation_chan: ConstellationChan,
time_profiler_chan: time::ProfilerChan,
Expand Down
2 changes: 1 addition & 1 deletion components/compositing/compositor_layer.rs
Expand Up @@ -365,7 +365,7 @@ impl CompositorLayer for Layer<CompositorData> {
let content_size = calculate_content_size_for_layer(self);
let min_x = (layer_size.width - content_size.width).get().min(0.0);
let min_y = (layer_size.height - content_size.height).get().min(0.0);
let new_offset : TypedPoint2D<LayerPixel, f32> =
let new_offset: TypedPoint2D<LayerPixel, f32> =
Point2D::new(Length::new(new_offset.x.get().clamp(&min_x, &0.0)),
Length::new(new_offset.y.get().clamp(&min_y, &0.0)));

Expand Down
8 changes: 4 additions & 4 deletions components/compositing/compositor_task.rs
Expand Up @@ -37,7 +37,7 @@ pub trait CompositorProxy : 'static + Send {
/// Sends a message to the compositor.
fn send(&self, msg: Msg);
/// Clones the compositor proxy.
fn clone_compositor_proxy(&self) -> Box<CompositorProxy+'static+Send>;
fn clone_compositor_proxy(&self) -> Box<CompositorProxy + 'static + Send>;
}

/// The port that the compositor receives messages on. As above, this is a trait supplied by the
Expand Down Expand Up @@ -88,7 +88,7 @@ pub fn run_script_listener_thread(compositor_proxy: Box<CompositorProxy + 'stati
}

/// Implementation of the abstract `PaintListener` interface.
impl PaintListener for Box<CompositorProxy+'static+Send> {
impl PaintListener for Box<CompositorProxy + 'static + Send> {
fn native_display(&mut self) -> Option<NativeDisplay> {
let (chan, port) = channel();
self.send(Msg::GetNativeDisplay(chan));
Expand Down Expand Up @@ -204,7 +204,7 @@ pub enum Msg {
}

impl Debug for Msg {
fn fmt(&self, f: &mut Formatter) -> Result<(),Error> {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
match *self {
Msg::Exit(..) => write!(f, "Exit"),
Msg::ShutdownComplete(..) => write!(f, "ShutdownComplete"),
Expand Down Expand Up @@ -240,7 +240,7 @@ pub struct CompositorTask;

impl CompositorTask {
pub fn create<Window>(window: Option<Rc<Window>>,
sender: Box<CompositorProxy+Send>,
sender: Box<CompositorProxy + Send>,
receiver: Box<CompositorReceiver>,
constellation_chan: ConstellationChan,
time_profiler_chan: time::ProfilerChan,
Expand Down
4 changes: 2 additions & 2 deletions components/compositing/constellation.rs
Expand Up @@ -219,7 +219,7 @@ enum ExitPipelineMode {
}

impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
pub fn start(compositor_proxy: Box<CompositorProxy+Send>,
pub fn start(compositor_proxy: Box<CompositorProxy + Send>,
resource_task: ResourceTask,
image_cache_task: ImageCacheTask,
font_cache_task: FontCacheTask,
Expand Down Expand Up @@ -1019,7 +1019,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {

fn load_url_for_webdriver(&mut self,
pipeline_id: PipelineId,
load_data:LoadData,
load_data: LoadData,
reply: IpcSender<webdriver_msg::LoadStatus>) {
let new_pipeline_id = self.load_url(pipeline_id, load_data);
if let Some(id) = new_pipeline_id {
Expand Down
36 changes: 18 additions & 18 deletions components/compositing/pipeline.rs
Expand Up @@ -67,23 +67,23 @@ impl Pipeline {
/// Starts a paint task, layout task, and possibly a script task.
/// Returns the channels wrapped in a struct.
/// If script_pipeline is not None, then subpage_id must also be not None.
pub fn create<LTF,STF>(id: PipelineId,
parent_info: Option<(PipelineId, SubpageId)>,
constellation_chan: ConstellationChan,
compositor_proxy: Box<CompositorProxy+'static+Send>,
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
image_cache_task: ImageCacheTask,
font_cache_task: FontCacheTask,
resource_task: ResourceTask,
storage_task: StorageTask,
time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: profile_mem::ProfilerChan,
window_rect: Option<TypedRect<PagePx, f32>>,
script_chan: Option<Sender<ConstellationControlMsg>>,
load_data: LoadData,
device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>)
-> (Pipeline, PipelineContent)
where LTF: LayoutTaskFactory, STF:ScriptTaskFactory {
pub fn create<LTF, STF>(id: PipelineId,
parent_info: Option<(PipelineId, SubpageId)>,
constellation_chan: ConstellationChan,
compositor_proxy: Box<CompositorProxy + 'static + Send>,
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
image_cache_task: ImageCacheTask,
font_cache_task: FontCacheTask,
resource_task: ResourceTask,
storage_task: StorageTask,
time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: profile_mem::ProfilerChan,
window_rect: Option<TypedRect<PagePx, f32>>,
script_chan: Option<Sender<ConstellationControlMsg>>,
load_data: LoadData,
device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>)
-> (Pipeline, PipelineContent)
where LTF: LayoutTaskFactory, STF: ScriptTaskFactory {
let (layout_to_paint_chan, layout_to_paint_port) = util::ipc::optional_ipc_channel();
let (chrome_to_paint_chan, chrome_to_paint_port) = channel();
let (paint_shutdown_chan, paint_shutdown_port) = channel();
Expand Down Expand Up @@ -305,7 +305,7 @@ pub struct PipelineContent {
}

impl PipelineContent {
pub fn start_all<LTF,STF>(mut self) where LTF: LayoutTaskFactory, STF: ScriptTaskFactory {
pub fn start_all<LTF, STF>(mut self) where LTF: LayoutTaskFactory, STF: ScriptTaskFactory {
let layout_pair = ScriptTaskFactory::create_layout_channel(None::<&mut STF>);
let (script_to_compositor_chan, script_to_compositor_port) = ipc::channel().unwrap();

Expand Down
2 changes: 1 addition & 1 deletion components/compositing/scrolling.rs
Expand Up @@ -30,7 +30,7 @@ enum ToScrollingTimerMsg {
}

impl ScrollingTimerProxy {
pub fn new(compositor_proxy: Box<CompositorProxy+Send>) -> ScrollingTimerProxy {
pub fn new(compositor_proxy: Box<CompositorProxy + Send>) -> ScrollingTimerProxy {
let (to_scrolling_timer_sender, to_scrolling_timer_receiver) = channel();
Builder::new().spawn(move || {
let mut scrolling_timer = ScrollingTimer {
Expand Down
4 changes: 2 additions & 2 deletions components/compositing/windowing.rs
Expand Up @@ -75,7 +75,7 @@ pub enum WindowEvent {
}

impl Debug for WindowEvent {
fn fmt(&self, f: &mut Formatter) -> Result<(),Error> {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
match *self {
WindowEvent::Idle => write!(f, "Idle"),
WindowEvent::Refresh => write!(f, "Refresh"),
Expand Down Expand Up @@ -130,7 +130,7 @@ pub trait WindowMethods {
/// This is part of the windowing system because its implementation often involves OS-specific
/// magic to wake the up window's event loop.
fn create_compositor_channel(_: &Option<Rc<Self>>)
-> (Box<CompositorProxy+Send>, Box<CompositorReceiver>);
-> (Box<CompositorProxy + Send>, Box<CompositorReceiver>);

/// Requests that the window system prepare a composite. Typically this will involve making
/// some type of platform-specific graphics context current. Returns true if the composite may
Expand Down
8 changes: 4 additions & 4 deletions components/devtools/actor.rs
Expand Up @@ -86,8 +86,8 @@ impl Actor + Send {

/// A list of known, owned actors.
pub struct ActorRegistry {
actors: HashMap<String, Box<Actor+Send>>,
new_actors: RefCell<Vec<Box<Actor+Send>>>,
actors: HashMap<String, Box<Actor + Send>>,
new_actors: RefCell<Vec<Box<Actor + Send>>>,
old_actors: RefCell<Vec<String>>,
script_actors: RefCell<HashMap<String, String>>,
shareable: Option<Arc<Mutex<ActorRegistry>>>,
Expand Down Expand Up @@ -167,11 +167,11 @@ impl ActorRegistry {
}

/// Add an actor to the registry of known actors that can receive messages.
pub fn register(&mut self, actor: Box<Actor+Send>) {
pub fn register(&mut self, actor: Box<Actor + Send>) {
self.actors.insert(actor.name().to_string(), actor);
}

pub fn register_later(&self, actor: Box<Actor+Send>) {
pub fn register_later(&self, actor: Box<Actor + Send>) {
let mut actors = self.new_actors.borrow_mut();
actors.push(actor);
}
Expand Down
4 changes: 2 additions & 2 deletions components/devtools/actors/inspector.rs
Expand Up @@ -93,7 +93,7 @@ impl Actor for HighlighterActor {
}

#[derive(RustcEncodable)]
struct ModifyAttributeReply{
struct ModifyAttributeReply {
from: String,
}

Expand All @@ -119,7 +119,7 @@ impl Actor for NodeActor {
registry.actor_to_script(target.to_string()),
modifications))
.unwrap();
let reply = ModifyAttributeReply{
let reply = ModifyAttributeReply {
from: self.name(),
};
stream.write_json_packet(&reply);
Expand Down
12 changes: 6 additions & 6 deletions components/gfx/display_list/mod.rs
Expand Up @@ -471,11 +471,11 @@ impl StackingContext {
mut point: Point2D<Au>,
result: &mut Vec<DisplayItemMetadata>,
topmost_only: bool) {
fn hit_test_in_list<'a,I>(point: Point2D<Au>,
result: &mut Vec<DisplayItemMetadata>,
topmost_only: bool,
iterator: I)
where I: Iterator<Item=&'a DisplayItem> {
fn hit_test_in_list<'a, I>(point: Point2D<Au>,
result: &mut Vec<DisplayItemMetadata>,
topmost_only: bool,
iterator: I)
where I: Iterator<Item=&'a DisplayItem> {
for item in iterator {
// TODO(pcwalton): Use a precise algorithm here. This will allow us to properly hit
// test elements with `border-radius`, for example.
Expand Down Expand Up @@ -1016,7 +1016,7 @@ pub enum BoxShadowClipMode {

pub enum DisplayItemIterator<'a> {
Empty,
Parent(linked_list::Iter<'a,DisplayItem>),
Parent(linked_list::Iter<'a, DisplayItem>),
}

impl<'a> Iterator for DisplayItemIterator<'a> {
Expand Down
16 changes: 8 additions & 8 deletions components/gfx/display_list/optimizer.rs
Expand Up @@ -45,10 +45,10 @@ impl DisplayListOptimizer {
}

/// Adds display items that intersect the visible rect to `result_list`.
fn add_in_bounds_display_items<'a,I>(&self,
result_list: &mut LinkedList<DisplayItem>,
display_items: I)
where I: Iterator<Item=&'a DisplayItem> {
fn add_in_bounds_display_items<'a, I>(&self,
result_list: &mut LinkedList<DisplayItem>,
display_items: I)
where I: Iterator<Item=&'a DisplayItem> {
for display_item in display_items {
if self.visible_rect.intersects(&display_item.base().bounds) &&
display_item.base().clip.might_intersect_rect(&self.visible_rect) {
Expand All @@ -58,10 +58,10 @@ impl DisplayListOptimizer {
}

/// Adds child stacking contexts whose boundaries intersect the visible rect to `result_list`.
fn add_in_bounds_stacking_contexts<'a,I>(&self,
result_list: &mut LinkedList<Arc<StackingContext>>,
stacking_contexts: I)
where I: Iterator<Item=&'a Arc<StackingContext>> {
fn add_in_bounds_stacking_contexts<'a, I>(&self,
result_list: &mut LinkedList<Arc<StackingContext>>,
stacking_contexts: I)
where I: Iterator<Item=&'a Arc<StackingContext>> {
for stacking_context in stacking_contexts {
if stacking_context.layer.is_none() {
// Transform this stacking context to get it into the same space as
Expand Down
4 changes: 2 additions & 2 deletions components/gfx/font.rs
Expand Up @@ -95,8 +95,8 @@ pub struct Font {
pub requested_pt_size: Au,
pub actual_pt_size: Au,
pub shaper: Option<Shaper>,
pub shape_cache: HashCache<ShapeCacheEntry,Arc<GlyphStore>>,
pub glyph_advance_cache: HashCache<u32,FractionalPixel>,
pub shape_cache: HashCache<ShapeCacheEntry, Arc<GlyphStore>>,
pub glyph_advance_cache: HashCache<u32, FractionalPixel>,
}

bitflags! {
Expand Down
4 changes: 2 additions & 2 deletions components/gfx/font_context.rs
Expand Up @@ -82,7 +82,7 @@ pub struct FontContext {
paint_font_cache: Vec<PaintFontCacheEntry>,

layout_font_group_cache:
HashMap<LayoutFontGroupCacheKey,Rc<FontGroup>,DefaultState<FnvHasher>>,
HashMap<LayoutFontGroupCacheKey, Rc<FontGroup>, DefaultState<FnvHasher>>,
}

impl FontContext {
Expand Down Expand Up @@ -273,7 +273,7 @@ impl FontContext {
}

let paint_font = Rc::new(RefCell::new(create_scaled_font(template, pt_size)));
self.paint_font_cache.push(PaintFontCacheEntry{
self.paint_font_cache.push(PaintFontCacheEntry {
font: paint_font.clone(),
pt_size: pt_size,
identifier: template.identifier.clone(),
Expand Down
16 changes: 8 additions & 8 deletions components/gfx/paint_context.rs
Expand Up @@ -751,11 +751,11 @@ impl<'a> PaintContext<'a> {
border: &SideOffsets2D<f32>,
radius: &BorderRadii<AzFloat>,
color: Color) {
let scaled_border = SideOffsets2D::new((1.0/3.0) * border.top,
(1.0/3.0) * border.right,
(1.0/3.0) * border.bottom,
(1.0/3.0) * border.left);
let inner_scaled_bounds = self.compute_scaled_bounds(bounds, border, 2.0/3.0);
let scaled_border = SideOffsets2D::new((1.0 / 3.0) * border.top,
(1.0 / 3.0) * border.right,
(1.0 / 3.0) * border.bottom,
(1.0 / 3.0) * border.left);
let inner_scaled_bounds = self.compute_scaled_bounds(bounds, border, 2.0 / 3.0);
// draw the outer portion of the double border.
self.draw_solid_border_segment(direction, bounds, &scaled_border, radius, color);
// draw the inner portion of the double border.
Expand Down Expand Up @@ -786,7 +786,7 @@ impl<'a> PaintContext<'a> {
let lighter_color;
let mut darker_color = color::black();
if color != darker_color {
darker_color = self.scale_color(color, if is_groove { 1.0/3.0 } else { 2.0/3.0 });
darker_color = self.scale_color(color, if is_groove { 1.0 / 3.0 } else { 2.0 / 3.0 });
lighter_color = color;
} else {
// You can't scale black color (i.e. 'scaled = 0 * scale', equals black).
Expand Down Expand Up @@ -832,10 +832,10 @@ impl<'a> PaintContext<'a> {
if color != scaled_color {
scaled_color = match direction {
Direction::Top | Direction::Left => {
self.scale_color(color, if is_inset { 2.0/3.0 } else { 1.0 })
self.scale_color(color, if is_inset { 2.0 / 3.0 } else { 1.0 })
}
Direction::Right | Direction::Bottom => {
self.scale_color(color, if is_inset { 1.0 } else { 2.0/3.0 })
self.scale_color(color, if is_inset { 1.0 } else { 2.0 / 3.0 })
}
};
} else {
Expand Down
16 changes: 8 additions & 8 deletions components/gfx/paint_task.rs
Expand Up @@ -659,12 +659,12 @@ enum MsgFromWorkerThread {
}

pub static THREAD_TINT_COLORS: [Color; 8] = [
Color { r: 6.0/255.0, g: 153.0/255.0, b: 198.0/255.0, a: 0.7 },
Color { r: 255.0/255.0, g: 212.0/255.0, b: 83.0/255.0, a: 0.7 },
Color { r: 116.0/255.0, g: 29.0/255.0, b: 109.0/255.0, a: 0.7 },
Color { r: 204.0/255.0, g: 158.0/255.0, b: 199.0/255.0, a: 0.7 },
Color { r: 242.0/255.0, g: 46.0/255.0, b: 121.0/255.0, a: 0.7 },
Color { r: 116.0/255.0, g: 203.0/255.0, b: 196.0/255.0, a: 0.7 },
Color { r: 255.0/255.0, g: 249.0/255.0, b: 201.0/255.0, a: 0.7 },
Color { r: 137.0/255.0, g: 196.0/255.0, b: 78.0/255.0, a: 0.7 },
Color { r: 6.0 / 255.0, g: 153.0 / 255.0, b: 198.0 / 255.0, a: 0.7 },
Color { r: 255.0 / 255.0, g: 212.0 / 255.0, b: 83.0 / 255.0, a: 0.7 },
Color { r: 116.0 / 255.0, g: 29.0 / 255.0, b: 109.0 / 255.0, a: 0.7 },
Color { r: 204.0 / 255.0, g: 158.0 / 255.0, b: 199.0 / 255.0, a: 0.7 },
Color { r: 242.0 / 255.0, g: 46.0 / 255.0, b: 121.0 / 255.0, a: 0.7 },
Color { r: 116.0 / 255.0, g: 203.0 / 255.0, b: 196.0 / 255.0, a: 0.7 },
Color { r: 255.0 / 255.0, g: 249.0 / 255.0, b: 201.0 / 255.0, a: 0.7 },
Color { r: 137.0 / 255.0, g: 196.0 / 255.0, b: 78.0 / 255.0, a: 0.7 },
];

0 comments on commit e74825f

Please sign in to comment.