Auto merge of #7468 - JoshTheGoldfish:Issue7460, r=jdm

Making test-tidy check that = have space after them

For issue #7460. Need to ensure compatibility with #7390.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7468)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-09-01 08:33:02 -06:00
commit 15de679f11
23 changed files with 127 additions and 111 deletions

View file

@ -39,9 +39,9 @@ extern crate clipboard;
extern crate time; extern crate time;
extern crate url; extern crate url;
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
extern crate core_graphics; extern crate core_graphics;
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
extern crate core_text; extern crate core_text;
pub use compositor_task::{CompositorEventListener, CompositorProxy, CompositorTask}; pub use compositor_task::{CompositorEventListener, CompositorProxy, CompositorTask};

View file

@ -101,13 +101,13 @@ pub struct Font {
bitflags! { bitflags! {
flags ShapingFlags: u8 { flags ShapingFlags: u8 {
#[doc="Set if the text is entirely whitespace."] #[doc = "Set if the text is entirely whitespace."]
const IS_WHITESPACE_SHAPING_FLAG = 0x01, const IS_WHITESPACE_SHAPING_FLAG = 0x01,
#[doc="Set if we are to ignore ligatures."] #[doc = "Set if we are to ignore ligatures."]
const IGNORE_LIGATURES_SHAPING_FLAG = 0x02, const IGNORE_LIGATURES_SHAPING_FLAG = 0x02,
#[doc="Set if we are to disable kerning."] #[doc = "Set if we are to disable kerning."]
const DISABLE_KERNING_SHAPING_FLAG = 0x04, const DISABLE_KERNING_SHAPING_FLAG = 0x04,
#[doc="Text direction is right-to-left."] #[doc = "Text direction is right-to-left."]
const RTL_FLAG = 0x08, const RTL_FLAG = 0x08,
} }
} }

View file

@ -31,16 +31,16 @@ use std::sync::Arc;
use azure::azure_hl::BackendType; use azure::azure_hl::BackendType;
use azure::scaled_font::ScaledFont; use azure::scaled_font::ScaledFont;
#[cfg(any(target_os="linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use azure::scaled_font::FontInfo; use azure::scaled_font::FontInfo;
#[cfg(any(target_os="linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont { fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
ScaledFont::new(BackendType::Skia, FontInfo::FontData(&template.bytes), ScaledFont::new(BackendType::Skia, FontInfo::FontData(&template.bytes),
pt_size.to_f32_px()) pt_size.to_f32_px())
} }
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont { fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
let cgfont = template.ctfont().as_ref().unwrap().copy_to_CGFont(); let cgfont = template.ctfont().as_ref().unwrap().copy_to_CGFont();
ScaledFont::new(BackendType::Skia, &cgfont, pt_size.to_f32_px()) ScaledFont::new(BackendType::Skia, &cgfont, pt_size.to_f32_px())

View file

@ -3,12 +3,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(arc_weak)] #![feature(arc_weak)]
#![cfg_attr(any(target_os="linux", target_os = "android"), feature(box_raw))] #![cfg_attr(any(target_os = "linux", target_os = "android"), feature(box_raw))]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![feature(custom_derive)] #![feature(custom_derive)]
#![feature(hashmap_hasher)] #![feature(hashmap_hasher)]
#![cfg_attr(any(target_os="linux", target_os = "android"), feature(heap_api))] #![cfg_attr(any(target_os = "linux", target_os = "android"), feature(heap_api))]
#![feature(mpsc_select)] #![feature(mpsc_select)]
#![feature(plugin)] #![feature(plugin)]
#![feature(str_char)] #![feature(str_char)]
@ -55,23 +55,23 @@ extern crate canvas_traits;
extern crate harfbuzz; extern crate harfbuzz;
// Linux and Android-specific library dependencies // Linux and Android-specific library dependencies
#[cfg(any(target_os="linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
extern crate fontconfig; extern crate fontconfig;
#[cfg(any(target_os="linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
extern crate freetype; extern crate freetype;
// Mac OS-specific library dependencies // Mac OS-specific library dependencies
#[cfg(target_os="macos")] extern crate core_foundation; #[cfg(target_os = "macos")] extern crate core_foundation;
#[cfg(target_os="macos")] extern crate core_graphics; #[cfg(target_os = "macos")] extern crate core_graphics;
#[cfg(target_os="macos")] extern crate core_text; #[cfg(target_os = "macos")] extern crate core_text;
pub use paint_context::PaintContext; pub use paint_context::PaintContext;
// Private painting modules // Private painting modules
mod paint_context; mod paint_context;
#[path="display_list/mod.rs"] #[path = "display_list/mod.rs"]
pub mod display_list; pub mod display_list;
pub mod paint_task; pub mod paint_task;
@ -85,7 +85,7 @@ pub mod font_template;
mod filters; mod filters;
// Platform-specific implementations. // Platform-specific implementations.
#[path="platform/mod.rs"] #[path = "platform/mod.rs"]
pub mod platform; pub mod platform;
// Text // Text

View file

@ -139,7 +139,7 @@ pub fn get_system_default_family(generic_name: &str) -> Option<String> {
} }
} }
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
pub fn get_last_resort_font_families() -> Vec<String> { pub fn get_last_resort_font_families() -> Vec<String> {
vec!( vec!(
"Fira Sans".to_owned(), "Fira Sans".to_owned(),
@ -148,7 +148,7 @@ pub fn get_last_resort_font_families() -> Vec<String> {
) )
} }
#[cfg(target_os="android")] #[cfg(target_os = "android")]
pub fn get_last_resort_font_families() -> Vec<String> { pub fn get_last_resort_font_families() -> Vec<String> {
vec!("Roboto".to_owned()) vec!("Roboto".to_owned())
} }

View file

@ -2,13 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#[cfg(any(target_os="linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
pub use platform::freetype::{font, font_context, font_list, font_template}; pub use platform::freetype::{font, font_context, font_list, font_template};
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
pub use platform::macos::{font, font_context, font_list, font_template}; pub use platform::macos::{font, font_context, font_list, font_template};
#[cfg(any(target_os="linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
pub mod freetype { pub mod freetype {
pub mod font; pub mod font;
pub mod font_context; pub mod font_context;
@ -16,7 +16,7 @@ pub mod freetype {
pub mod font_template; pub mod font_template;
} }
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
pub mod macos { pub mod macos {
pub mod font; pub mod font;
pub mod font_context; pub mod font_context;

View file

@ -561,7 +561,7 @@ pub struct BlockFlow {
bitflags! { bitflags! {
flags BlockFlowFlags: u8 { flags BlockFlowFlags: u8 {
#[doc="If this is set, then this block flow is the root flow."] #[doc = "If this is set, then this block flow is the root flow."]
const IS_ROOT = 0x01, const IS_ROOT = 0x01,
} }
} }

View file

@ -54,7 +54,7 @@ impl PrivateLayoutData {
bitflags! { bitflags! {
flags LayoutDataFlags: u8 { flags LayoutDataFlags: u8 {
#[doc="Whether a flow has been newly constructed."] #[doc = "Whether a flow has been newly constructed."]
const HAS_NEWLY_CONSTRUCTED_FLOW = 0x01 const HAS_NEWLY_CONSTRUCTED_FLOW = 0x01
} }
} }

View file

@ -2300,10 +2300,10 @@ bitflags! {
// Various flags we can use when splitting fragments. See // Various flags we can use when splitting fragments. See
// `calculate_split_position_using_breaking_strategy()`. // `calculate_split_position_using_breaking_strategy()`.
flags SplitOptions: u8 { flags SplitOptions: u8 {
#[doc="True if this is the first fragment on the line."] #[doc = "True if this is the first fragment on the line."]
const STARTS_LINE = 0x01, const STARTS_LINE = 0x01,
#[doc="True if we should attempt to split at character boundaries if this split fails. \ #[doc = "True if we should attempt to split at character boundaries if this split fails. \
This is used to implement `overflow-wrap: break-word`."] This is used to implement `overflow-wrap: break-word`."]
const RETRY_AT_CHARACTER_BOUNDARIES = 0x02, const RETRY_AT_CHARACTER_BOUNDARIES = 0x02,
} }
} }

View file

@ -42,8 +42,8 @@ bitflags! {
bitflags! { bitflags! {
flags SpecialRestyleDamage: u8 { flags SpecialRestyleDamage: u8 {
#[doc="If this flag is set, we need to reflow the entire document. This is more or less a \ #[doc = "If this flag is set, we need to reflow the entire document. This is more or less a \
temporary hack to deal with cases that we don't handle incrementally yet."] temporary hack to deal with cases that we don't handle incrementally yet."]
const REFLOW_ENTIRE_DOCUMENT = 0x01, const REFLOW_ENTIRE_DOCUMENT = 0x01,
} }
} }

View file

@ -183,9 +183,9 @@ int_range_index! {
bitflags! { bitflags! {
flags InlineReflowFlags: u8 { flags InlineReflowFlags: u8 {
#[doc="The `white-space: nowrap` property from CSS 2.1 § 16.6 is in effect."] #[doc = "The `white-space: nowrap` property from CSS 2.1 § 16.6 is in effect."]
const NO_WRAP_INLINE_REFLOW_FLAG = 0x01, const NO_WRAP_INLINE_REFLOW_FLAG = 0x01,
#[doc="The `white-space: pre` property from CSS 2.1 § 16.6 is in effect."] #[doc = "The `white-space: pre` property from CSS 2.1 § 16.6 is in effect."]
const WRAP_ON_NEWLINE_INLINE_REFLOW_FLAG = 0x02 const WRAP_ON_NEWLINE_INLINE_REFLOW_FLAG = 0x02
} }
} }

View file

@ -20,9 +20,9 @@ extern crate util;
extern crate url; extern crate url;
extern crate style; extern crate style;
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
extern crate core_foundation; extern crate core_foundation;
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
extern crate io_surface; extern crate io_surface;
pub mod compositor_msg; pub mod compositor_msg;

View file

@ -13,9 +13,9 @@ extern crate ipc_channel;
extern crate libc; extern crate libc;
#[macro_use] #[macro_use]
extern crate profile_traits; extern crate profile_traits;
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
extern crate regex; extern crate regex;
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
extern crate task_info; extern crate task_info;
extern crate time as std_time; extern crate time as std_time;
extern crate util; extern crate util;

View file

@ -368,7 +368,7 @@ mod system_reporter {
use std::mem::size_of; use std::mem::size_of;
use std::ptr::null_mut; use std::ptr::null_mut;
use super::{JEMALLOC_HEAP_ALLOCATED_STR, SYSTEM_HEAP_ALLOCATED_STR}; use super::{JEMALLOC_HEAP_ALLOCATED_STR, SYSTEM_HEAP_ALLOCATED_STR};
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
use task_info::task_basic_info::{virtual_size, resident_size}; use task_info::task_basic_info::{virtual_size, resident_size};
/// Collects global measurements from the OS and heap allocators. /// Collects global measurements from the OS and heap allocators.
@ -418,12 +418,12 @@ mod system_reporter {
request.reports_channel.send(reports); request.reports_channel.send(reports);
} }
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
extern { extern {
fn mallinfo() -> struct_mallinfo; fn mallinfo() -> struct_mallinfo;
} }
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
#[repr(C)] #[repr(C)]
pub struct struct_mallinfo { pub struct struct_mallinfo {
arena: c_int, arena: c_int,
@ -438,7 +438,7 @@ mod system_reporter {
keepcost: c_int, keepcost: c_int,
} }
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
fn get_system_heap_allocated() -> Option<usize> { fn get_system_heap_allocated() -> Option<usize> {
let info: struct_mallinfo = unsafe { mallinfo() }; let info: struct_mallinfo = unsafe { mallinfo() };
@ -457,7 +457,7 @@ mod system_reporter {
} }
} }
#[cfg(not(target_os="linux"))] #[cfg(not(target_os = "linux"))]
fn get_system_heap_allocated() -> Option<usize> { fn get_system_heap_allocated() -> Option<usize> {
None None
} }
@ -507,14 +507,14 @@ mod system_reporter {
($e:expr) => (match $e { Some(e) => e, None => return None }) ($e:expr) => (match $e { Some(e) => e, None => return None })
); );
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
fn page_size() -> usize { fn page_size() -> usize {
unsafe { unsafe {
::libc::sysconf(::libc::_SC_PAGESIZE) as usize ::libc::sysconf(::libc::_SC_PAGESIZE) as usize
} }
} }
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
fn get_proc_self_statm_field(field: usize) -> Option<usize> { fn get_proc_self_statm_field(field: usize) -> Option<usize> {
use std::fs::File; use std::fs::File;
use std::io::Read; use std::io::Read;
@ -527,37 +527,37 @@ mod system_reporter {
Some(npages * page_size()) Some(npages * page_size())
} }
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
fn get_vsize() -> Option<usize> { fn get_vsize() -> Option<usize> {
get_proc_self_statm_field(0) get_proc_self_statm_field(0)
} }
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
fn get_resident() -> Option<usize> { fn get_resident() -> Option<usize> {
get_proc_self_statm_field(1) get_proc_self_statm_field(1)
} }
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
fn get_vsize() -> Option<usize> { fn get_vsize() -> Option<usize> {
virtual_size() virtual_size()
} }
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
fn get_resident() -> Option<usize> { fn get_resident() -> Option<usize> {
resident_size() resident_size()
} }
#[cfg(not(any(target_os="linux", target_os = "macos")))] #[cfg(not(any(target_os = "linux", target_os = "macos")))]
fn get_vsize() -> Option<usize> { fn get_vsize() -> Option<usize> {
None None
} }
#[cfg(not(any(target_os="linux", target_os = "macos")))] #[cfg(not(any(target_os = "linux", target_os = "macos")))]
fn get_resident() -> Option<usize> { fn get_resident() -> Option<usize> {
None None
} }
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
fn get_resident_segments() -> Vec<(String, usize)> { fn get_resident_segments() -> Vec<(String, usize)> {
use regex::Regex; use regex::Regex;
use std::collections::HashMap; use std::collections::HashMap;
@ -658,7 +658,7 @@ mod system_reporter {
segs segs
} }
#[cfg(not(target_os="linux"))] #[cfg(not(target_os = "linux"))]
fn get_resident_segments() -> Vec<(String, usize)> { fn get_resident_segments() -> Vec<(String, usize)> {
vec![] vec![]
} }

View file

@ -9,7 +9,7 @@ use num::Float;
use std::ops::Deref; use std::ops::Deref;
/// Encapsulates the IDL restricted float type. /// Encapsulates the IDL restricted float type.
#[derive(JSTraceable,Clone,Eq,PartialEq)] #[derive(JSTraceable, Clone, Eq, PartialEq)]
pub struct Finite<T: Float>(T); pub struct Finite<T: Float>(T);
unsafe impl<T: Float> Zeroable for Finite<T> {} unsafe impl<T: Float> Zeroable for Finite<T> {}

View file

@ -33,7 +33,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![doc="The script crate contains all matters DOM."] #![doc = "The script crate contains all matters DOM."]
#![plugin(string_cache_plugin)] #![plugin(string_cache_plugin)]
#![plugin(plugins)] #![plugin(plugins)]
@ -103,7 +103,7 @@ mod webdriver_handlers;
use dom::bindings::codegen::RegisterBindings; use dom::bindings::codegen::RegisterBindings;
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
#[allow(unsafe_code)] #[allow(unsafe_code)]
fn perform_platform_specific_initialization() { fn perform_platform_specific_initialization() {
use std::mem; use std::mem;
@ -119,7 +119,7 @@ fn perform_platform_specific_initialization() {
} }
} }
#[cfg(not(target_os="linux"))] #[cfg(not(target_os = "linux"))]
fn perform_platform_specific_initialization() {} fn perform_platform_specific_initialization() {}
#[allow(unsafe_code)] #[allow(unsafe_code)]

View file

@ -78,12 +78,12 @@ pub enum Direction {
/// Was the keyboard event accompanied by the standard control modifier, /// Was the keyboard event accompanied by the standard control modifier,
/// i.e. cmd on Mac OS or ctrl on other platforms. /// i.e. cmd on Mac OS or ctrl on other platforms.
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
fn is_control_key(mods: KeyModifiers) -> bool { fn is_control_key(mods: KeyModifiers) -> bool {
mods.contains(SUPER) && !mods.contains(CONTROL | ALT) mods.contains(SUPER) && !mods.contains(CONTROL | ALT)
} }
#[cfg(not(target_os="macos"))] #[cfg(not(target_os = "macos"))]
fn is_control_key(mods: KeyModifiers) -> bool { fn is_control_key(mods: KeyModifiers) -> bool {
mods.contains(CONTROL) && !mods.contains(SUPER | ALT) mods.contains(CONTROL) && !mods.contains(SUPER | ALT)
} }

View file

@ -25,7 +25,7 @@ extern crate glutin_app as app;
extern crate time; extern crate time;
extern crate env_logger; extern crate env_logger;
#[cfg(target_os="android")] #[cfg(target_os = "android")]
#[macro_use] #[macro_use]
extern crate android_glue; extern crate android_glue;
@ -35,7 +35,7 @@ use servo::net_traits::hosts;
use servo::util::opts; use servo::util::opts;
use std::rc::Rc; use std::rc::Rc;
#[cfg(target_os="android")] #[cfg(target_os = "android")]
use std::borrow::ToOwned; use std::borrow::ToOwned;
fn main() { fn main() {
@ -128,16 +128,16 @@ impl app::NestedEventLoopListener for BrowserWrapper {
} }
} }
#[cfg(target_os="android")] #[cfg(target_os = "android")]
fn setup_logging() { fn setup_logging() {
android::setup_logging(); android::setup_logging();
} }
#[cfg(not(target_os="android"))] #[cfg(not(target_os = "android"))]
fn setup_logging() { fn setup_logging() {
} }
#[cfg(target_os="android")] #[cfg(target_os = "android")]
fn get_args() -> Vec<String> { fn get_args() -> Vec<String> {
vec![ vec![
"servo".to_owned(), "servo".to_owned(),
@ -145,7 +145,7 @@ fn get_args() -> Vec<String> {
] ]
} }
#[cfg(not(target_os="android"))] #[cfg(not(target_os = "android"))]
fn get_args() -> Vec<String> { fn get_args() -> Vec<String> {
use std::env; use std::env;
env::args().collect() env::args().collect()

View file

@ -333,10 +333,10 @@ fn args_fail(msg: &str) -> ! {
// Always use CPU painting on android. // Always use CPU painting on android.
#[cfg(target_os="android")] #[cfg(target_os = "android")]
static FORCE_CPU_PAINTING: bool = true; static FORCE_CPU_PAINTING: bool = true;
#[cfg(not(target_os="android"))] #[cfg(not(target_os = "android"))]
static FORCE_CPU_PAINTING: bool = false; static FORCE_CPU_PAINTING: bool = false;
enum UserAgent { enum UserAgent {
@ -359,15 +359,15 @@ fn default_user_agent_string(agent: UserAgent) -> String {
}.to_owned() }.to_owned()
} }
#[cfg(target_os="android")] #[cfg(target_os = "android")]
const DEFAULT_USER_AGENT: UserAgent = UserAgent::Android; const DEFAULT_USER_AGENT: UserAgent = UserAgent::Android;
// FIXME: This requires https://github.com/servo/servo/issues/7138 to provide the // FIXME: This requires https://github.com/servo/servo/issues/7138 to provide the
// correct string in Gonk builds (i.e., it will never be chosen today). // correct string in Gonk builds (i.e., it will never be chosen today).
#[cfg(target_os="gonk")] #[cfg(target_os = "gonk")]
const DEFAULT_USER_AGENT: UserAgent = UserAgent::Gonk; const DEFAULT_USER_AGENT: UserAgent = UserAgent::Gonk;
#[cfg(not(any(target_os="android", target_os="gonk")))] #[cfg(not(any(target_os = "android", target_os = "gonk")))]
const DEFAULT_USER_AGENT: UserAgent = UserAgent::Desktop; const DEFAULT_USER_AGENT: UserAgent = UserAgent::Desktop;
pub fn default_opts() -> Opts { pub fn default_opts() -> Opts {

View file

@ -7,7 +7,7 @@
#![feature(box_syntax, result_expect)] #![feature(box_syntax, result_expect)]
#[macro_use] extern crate bitflags; #[macro_use] extern crate bitflags;
#[cfg(target_os="macos")] extern crate cgl; #[cfg(target_os = "macos")] extern crate cgl;
extern crate compositing; extern crate compositing;
extern crate euclid; extern crate euclid;
extern crate gleam; extern crate gleam;
@ -19,9 +19,9 @@ extern crate net_traits;
#[cfg(feature = "window")] extern crate script_traits; #[cfg(feature = "window")] extern crate script_traits;
extern crate time; extern crate time;
extern crate util; extern crate util;
#[cfg(target_os="android")] extern crate egl; #[cfg(target_os = "android")] extern crate egl;
extern crate url; extern crate url;
#[cfg(target_os="linux")] extern crate x11; #[cfg(target_os = "linux")] extern crate x11;
use compositing::windowing::WindowEvent; use compositing::windowing::WindowEvent;
use euclid::scale_factor::ScaleFactor; use euclid::scale_factor::ScaleFactor;

View file

@ -35,7 +35,7 @@ use std::cell::{Cell, RefCell};
#[cfg(feature = "window")] #[cfg(feature = "window")]
use util::opts; use util::opts;
#[cfg(all(feature = "headless", target_os="linux"))] #[cfg(all(feature = "headless", target_os = "linux"))]
use std::ptr; use std::ptr;
#[cfg(feature = "window")] #[cfg(feature = "window")]
@ -56,15 +56,15 @@ bitflags! {
} }
// Some shortcuts use Cmd on Mac and Control on other systems. // Some shortcuts use Cmd on Mac and Control on other systems.
#[cfg(all(feature = "window", target_os="macos"))] #[cfg(all(feature = "window", target_os = "macos"))]
const CMD_OR_CONTROL: constellation_msg::KeyModifiers = SUPER; const CMD_OR_CONTROL: constellation_msg::KeyModifiers = SUPER;
#[cfg(all(feature = "window", not(target_os="macos")))] #[cfg(all(feature = "window", not(target_os = "macos")))]
const CMD_OR_CONTROL: constellation_msg::KeyModifiers = CONTROL; const CMD_OR_CONTROL: constellation_msg::KeyModifiers = CONTROL;
// Some shortcuts use Cmd on Mac and Alt on other systems. // Some shortcuts use Cmd on Mac and Alt on other systems.
#[cfg(all(feature = "window", target_os="macos"))] #[cfg(all(feature = "window", target_os = "macos"))]
const CMD_OR_ALT: constellation_msg::KeyModifiers = SUPER; const CMD_OR_ALT: constellation_msg::KeyModifiers = SUPER;
#[cfg(all(feature = "window", not(target_os="macos")))] #[cfg(all(feature = "window", not(target_os = "macos")))]
const CMD_OR_ALT: constellation_msg::KeyModifiers = ALT; const CMD_OR_ALT: constellation_msg::KeyModifiers = ALT;
// This should vary by zoom level and maybe actual text size (focused or under cursor) // This should vary by zoom level and maybe actual text size (focused or under cursor)
@ -138,22 +138,22 @@ impl Window {
} }
} }
#[cfg(not(target_os="android"))] #[cfg(not(target_os = "android"))]
fn gl_version() -> GlRequest { fn gl_version() -> GlRequest {
GlRequest::Specific(Api::OpenGl, (3, 0)) GlRequest::Specific(Api::OpenGl, (3, 0))
} }
#[cfg(target_os="android")] #[cfg(target_os = "android")]
fn gl_version() -> GlRequest { fn gl_version() -> GlRequest {
GlRequest::Specific(Api::OpenGlEs, (2, 0)) GlRequest::Specific(Api::OpenGlEs, (2, 0))
} }
#[cfg(not(target_os="android"))] #[cfg(not(target_os = "android"))]
fn load_gl_functions(window: &glutin::Window) { fn load_gl_functions(window: &glutin::Window) {
gl::load_with(|s| window.get_proc_address(s)); gl::load_with(|s| window.get_proc_address(s));
} }
#[cfg(target_os="android")] #[cfg(target_os = "android")]
fn load_gl_functions(_: &glutin::Window) { fn load_gl_functions(_: &glutin::Window) {
} }
@ -290,7 +290,7 @@ impl Window {
self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(event)); self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(event));
} }
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
fn handle_next_event(&self) -> bool { fn handle_next_event(&self) -> bool {
let event = self.window.wait_events().next().unwrap(); let event = self.window.wait_events().next().unwrap();
let mut close = self.handle_window_event(event); let mut close = self.handle_window_event(event);
@ -305,7 +305,7 @@ impl Window {
close close
} }
#[cfg(any(target_os="linux", target_os="android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
fn handle_next_event(&self) -> bool { fn handle_next_event(&self) -> bool {
use std::thread::sleep_ms; use std::thread::sleep_ms;
@ -478,7 +478,7 @@ impl Window {
result result
} }
#[cfg(all(feature = "window", not(target_os="win")))] #[cfg(all(feature = "window", not(target_os = "win")))]
fn platform_handle_key(&self, key: Key, mods: constellation_msg::KeyModifiers) { fn platform_handle_key(&self, key: Key, mods: constellation_msg::KeyModifiers) {
match (mods, key) { match (mods, key) {
(CMD_OR_CONTROL, Key::LeftBracket) => { (CMD_OR_CONTROL, Key::LeftBracket) => {
@ -491,19 +491,19 @@ impl Window {
} }
} }
#[cfg(all(feature = "window", target_os="win"))] #[cfg(all(feature = "window", target_os = "win"))]
fn platform_handle_key(&self, key: Key, mods: constellation_msg::KeyModifiers) { fn platform_handle_key(&self, key: Key, mods: constellation_msg::KeyModifiers) {
} }
} }
// WindowProxy is not implemented for android yet // WindowProxy is not implemented for android yet
#[cfg(all(feature = "window", target_os="android"))] #[cfg(all(feature = "window", target_os = "android"))]
fn create_window_proxy(_: &Rc<Window>) -> Option<glutin::WindowProxy> { fn create_window_proxy(_: &Rc<Window>) -> Option<glutin::WindowProxy> {
None None
} }
#[cfg(all(feature = "window", not(target_os="android")))] #[cfg(all(feature = "window", not(target_os = "android")))]
fn create_window_proxy(window: &Rc<Window>) -> Option<glutin::WindowProxy> { fn create_window_proxy(window: &Rc<Window>) -> Option<glutin::WindowProxy> {
Some(window.window.create_window_proxy()) Some(window.window.create_window_proxy())
} }
@ -623,7 +623,7 @@ impl WindowMethods for Window {
true true
} }
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
fn native_display(&self) -> NativeDisplay { fn native_display(&self) -> NativeDisplay {
use x11::xlib; use x11::xlib;
unsafe { unsafe {
@ -631,7 +631,7 @@ impl WindowMethods for Window {
} }
} }
#[cfg(not(target_os="linux"))] #[cfg(not(target_os = "linux"))]
fn native_display(&self) -> NativeDisplay { fn native_display(&self) -> NativeDisplay {
NativeDisplay::new() NativeDisplay::new()
} }
@ -791,7 +791,7 @@ impl WindowMethods for Window {
true true
} }
#[cfg(target_os="linux")] #[cfg(target_os = "linux")]
fn native_display(&self) -> NativeDisplay { fn native_display(&self) -> NativeDisplay {
NativeDisplay::new(ptr::null_mut()) NativeDisplay::new(ptr::null_mut())
} }

View file

@ -188,33 +188,35 @@ def check_rust(file_name, contents):
line = merged_lines + line line = merged_lines + line
merged_lines = '' merged_lines = ''
# get rid of strings and chars because cases like regex expression # get rid of strings and chars because cases like regex expression, keep attributes
line = re.sub('".*?"|\'.*?\'', '', line) if not line_is_attribute(line):
line = re.sub('".*?"|\'.*?\'', '', line)
# get rid of comments and attributes # get rid of comments
line = re.sub('//.*?$|/\*.*?$|^\*.*?$|^#.*?$', '', line) line = re.sub('//.*?$|/\*.*?$|^\*.*?$', '', line)
# get rid of attributes that do not contain =
line = re.sub('^#[A-Za-z0-9\(\)\[\]_]*?$', '', line)
match = re.search(r",[A-Za-z0-9]", line) match = re.search(r",[A-Za-z0-9]", line)
if match: if match:
yield (idx + 1, "missing space after ,") yield (idx + 1, "missing space after ,")
# Avoid flagging <Item=Foo> constructs if line_is_attribute(line):
def is_associated_type(match, line, index): pre_space_re = r"[A-Za-z0-9]="
open_angle = line[0:match.end()].rfind('<') post_space_re = r"=[A-Za-z0-9\"]"
close_angle = line[open_angle:].find('>') if open_angle != -1 else -1 else:
is_equals = match.group(0)[index] == '=' # - not included because of scientific notation (1e-6)
generic_open = open_angle != -1 and open_angle < match.start() pre_space_re = r"[A-Za-z0-9][\+/\*%=]"
generic_close = close_angle != -1 and close_angle + open_angle >= match.end() # * not included because of dereferencing and casting
return is_equals and generic_open and generic_close # - not included because of unary negation
post_space_re = r"[\+/\%=][A-Za-z0-9\"]"
# - not included because of scientific notation (1e-6) match = re.search(pre_space_re, line)
match = re.search(r"[A-Za-z0-9][\+/\*%=]", line)
if match and not is_associated_type(match, line, 1): if match and not is_associated_type(match, line, 1):
yield (idx + 1, "missing space before %s" % match.group(0)[1]) yield (idx + 1, "missing space before %s" % match.group(0)[1])
# * not included because of dereferencing and casting match = re.search(post_space_re, line)
# - not included because of unary negation
match = re.search(r"[\+/\%=][A-Za-z0-9]", line)
if match and not is_associated_type(match, line, 0): if match and not is_associated_type(match, line, 0):
yield (idx + 1, "missing space after %s" % match.group(0)[0]) yield (idx + 1, "missing space after %s" % match.group(0)[0])
@ -270,6 +272,20 @@ def check_rust(file_name, contents):
uses = [] uses = []
# Avoid flagging <Item=Foo> constructs
def is_associated_type(match, line, index):
open_angle = line[0:match.end()].rfind('<')
close_angle = line[open_angle:].find('>') if open_angle != -1 else -1
is_equals = match.group(0)[index] == '='
generic_open = open_angle != -1 and open_angle < match.start()
generic_close = close_angle != -1 and close_angle + open_angle >= match.end()
return is_equals and generic_open and generic_close
def line_is_attribute(line):
return re.search(r"#\[.*\]", line)
def check_webidl_spec(file_name, contents): def check_webidl_spec(file_name, contents):
# Sorted by this function (in pseudo-Rust). The idea is to group the same # Sorted by this function (in pseudo-Rust). The idea is to group the same
# organization together. # organization together.

View file

@ -9,9 +9,9 @@
use msg::constellation_msg::{Key, KeyModifiers}; use msg::constellation_msg::{Key, KeyModifiers};
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
use msg::constellation_msg::SUPER; use msg::constellation_msg::SUPER;
#[cfg(not(target_os="macos"))] #[cfg(not(target_os = "macos"))]
use msg::constellation_msg::CONTROL; use msg::constellation_msg::CONTROL;
use script::clipboard_provider::DummyClipboardContext; use script::clipboard_provider::DummyClipboardContext;
@ -194,9 +194,9 @@ fn test_textinput_set_content() {
#[test] #[test]
fn test_clipboard_paste() { fn test_clipboard_paste() {
#[cfg(target_os="macos")] #[cfg(target_os = "macos")]
const MODIFIERS: KeyModifiers = SUPER; const MODIFIERS: KeyModifiers = SUPER;
#[cfg(not(target_os="macos"))] #[cfg(not(target_os = "macos"))]
const MODIFIERS: KeyModifiers = CONTROL; const MODIFIERS: KeyModifiers = CONTROL;
let mut textinput = TextInput::new(Lines::Single, "defg".to_owned(), DummyClipboardContext::new("abc")); let mut textinput = TextInput::new(Lines::Single, "defg".to_owned(), DummyClipboardContext::new("abc"));