aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/compositing/lib.rs4
-rw-r--r--components/gfx/font.rs8
-rw-r--r--components/gfx/font_context.rs6
-rw-r--r--components/gfx/lib.rs18
-rw-r--r--components/gfx/platform/freetype/font_list.rs4
-rw-r--r--components/gfx/platform/mod.rs8
-rw-r--r--components/layout/block.rs2
-rw-r--r--components/layout/data.rs2
-rw-r--r--components/layout/fragment.rs6
-rw-r--r--components/layout/incremental.rs4
-rw-r--r--components/layout/inline.rs4
-rw-r--r--components/msg/lib.rs4
-rw-r--r--components/profile/lib.rs4
-rw-r--r--components/profile/mem.rs30
-rw-r--r--components/script/dom/bindings/num.rs2
-rw-r--r--components/script/lib.rs6
-rw-r--r--components/script/textinput.rs4
-rw-r--r--components/servo/main.rs12
-rw-r--r--components/util/opts.rs10
-rw-r--r--ports/glutin/lib.rs6
-rw-r--r--ports/glutin/window.rs36
-rw-r--r--python/tidy.py52
-rw-r--r--tests/unit/script/textinput.rs8
23 files changed, 128 insertions, 112 deletions
diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs
index 95eba39c8e7..92a633674b4 100644
--- a/components/compositing/lib.rs
+++ b/components/compositing/lib.rs
@@ -39,9 +39,9 @@ extern crate clipboard;
extern crate time;
extern crate url;
-#[cfg(target_os="macos")]
+#[cfg(target_os = "macos")]
extern crate core_graphics;
-#[cfg(target_os="macos")]
+#[cfg(target_os = "macos")]
extern crate core_text;
pub use compositor_task::{CompositorEventListener, CompositorProxy, CompositorTask};
diff --git a/components/gfx/font.rs b/components/gfx/font.rs
index fd17fa4e467..ba11c2a63cc 100644
--- a/components/gfx/font.rs
+++ b/components/gfx/font.rs
@@ -101,13 +101,13 @@ pub struct Font {
bitflags! {
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,
- #[doc="Set if we are to ignore ligatures."]
+ #[doc = "Set if we are to ignore ligatures."]
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,
- #[doc="Text direction is right-to-left."]
+ #[doc = "Text direction is right-to-left."]
const RTL_FLAG = 0x08,
}
}
diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs
index 18ee5e9ff42..640b2b8250c 100644
--- a/components/gfx/font_context.rs
+++ b/components/gfx/font_context.rs
@@ -31,16 +31,16 @@ use std::sync::Arc;
use azure::azure_hl::BackendType;
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;
-#[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 {
ScaledFont::new(BackendType::Skia, FontInfo::FontData(&template.bytes),
pt_size.to_f32_px())
}
-#[cfg(target_os="macos")]
+#[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(BackendType::Skia, &cgfont, pt_size.to_f32_px())
diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs
index 6ffbe36fb5b..db73b9b200d 100644
--- a/components/gfx/lib.rs
+++ b/components/gfx/lib.rs
@@ -3,12 +3,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![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(custom_attribute)]
#![feature(custom_derive)]
#![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(plugin)]
#![feature(str_char)]
@@ -55,23 +55,23 @@ extern crate canvas_traits;
extern crate harfbuzz;
// 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;
-#[cfg(any(target_os="linux", target_os = "android"))]
+#[cfg(any(target_os = "linux", target_os = "android"))]
extern crate freetype;
// Mac OS-specific library dependencies
-#[cfg(target_os="macos")] extern crate core_foundation;
-#[cfg(target_os="macos")] extern crate core_graphics;
-#[cfg(target_os="macos")] extern crate core_text;
+#[cfg(target_os = "macos")] extern crate core_foundation;
+#[cfg(target_os = "macos")] extern crate core_graphics;
+#[cfg(target_os = "macos")] extern crate core_text;
pub use paint_context::PaintContext;
// Private painting modules
mod paint_context;
-#[path="display_list/mod.rs"]
+#[path = "display_list/mod.rs"]
pub mod display_list;
pub mod paint_task;
@@ -85,7 +85,7 @@ pub mod font_template;
mod filters;
// Platform-specific implementations.
-#[path="platform/mod.rs"]
+#[path = "platform/mod.rs"]
pub mod platform;
// Text
diff --git a/components/gfx/platform/freetype/font_list.rs b/components/gfx/platform/freetype/font_list.rs
index f3557d7dd2f..9e0a5177312 100644
--- a/components/gfx/platform/freetype/font_list.rs
+++ b/components/gfx/platform/freetype/font_list.rs
@@ -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> {
vec!(
"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> {
vec!("Roboto".to_owned())
}
diff --git a/components/gfx/platform/mod.rs b/components/gfx/platform/mod.rs
index f3bc3f6ec08..085da7cc932 100644
--- a/components/gfx/platform/mod.rs
+++ b/components/gfx/platform/mod.rs
@@ -2,13 +2,13 @@
* 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/. */
-#[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};
-#[cfg(target_os="macos")]
+#[cfg(target_os = "macos")]
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 font;
pub mod font_context;
@@ -16,7 +16,7 @@ pub mod freetype {
pub mod font_template;
}
-#[cfg(target_os="macos")]
+#[cfg(target_os = "macos")]
pub mod macos {
pub mod font;
pub mod font_context;
diff --git a/components/layout/block.rs b/components/layout/block.rs
index d697cad97a9..79e73a482f8 100644
--- a/components/layout/block.rs
+++ b/components/layout/block.rs
@@ -561,7 +561,7 @@ pub struct BlockFlow {
bitflags! {
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,
}
}
diff --git a/components/layout/data.rs b/components/layout/data.rs
index 4b551e2fd9e..097852096fa 100644
--- a/components/layout/data.rs
+++ b/components/layout/data.rs
@@ -54,7 +54,7 @@ impl PrivateLayoutData {
bitflags! {
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
}
}
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index 02af5569d84..749a3cf5660 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -2300,10 +2300,10 @@ bitflags! {
// Various flags we can use when splitting fragments. See
// `calculate_split_position_using_breaking_strategy()`.
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,
- #[doc="True if we should attempt to split at character boundaries if this split fails. \
- This is used to implement `overflow-wrap: break-word`."]
+ #[doc = "True if we should attempt to split at character boundaries if this split fails. \
+ This is used to implement `overflow-wrap: break-word`."]
const RETRY_AT_CHARACTER_BOUNDARIES = 0x02,
}
}
diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs
index 623fa4685fe..14205b32cb5 100644
--- a/components/layout/incremental.rs
+++ b/components/layout/incremental.rs
@@ -42,8 +42,8 @@ bitflags! {
bitflags! {
flags SpecialRestyleDamage: u8 {
- #[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."]
+ #[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."]
const REFLOW_ENTIRE_DOCUMENT = 0x01,
}
}
diff --git a/components/layout/inline.rs b/components/layout/inline.rs
index 4b5a6b985c7..4202b6b9d16 100644
--- a/components/layout/inline.rs
+++ b/components/layout/inline.rs
@@ -183,9 +183,9 @@ int_range_index! {
bitflags! {
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,
- #[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
}
}
diff --git a/components/msg/lib.rs b/components/msg/lib.rs
index 7c03b73d591..34a87cfd805 100644
--- a/components/msg/lib.rs
+++ b/components/msg/lib.rs
@@ -20,9 +20,9 @@ extern crate util;
extern crate url;
extern crate style;
-#[cfg(target_os="macos")]
+#[cfg(target_os = "macos")]
extern crate core_foundation;
-#[cfg(target_os="macos")]
+#[cfg(target_os = "macos")]
extern crate io_surface;
pub mod compositor_msg;
diff --git a/components/profile/lib.rs b/components/profile/lib.rs
index 9bf2018f4be..635b9af083f 100644
--- a/components/profile/lib.rs
+++ b/components/profile/lib.rs
@@ -13,9 +13,9 @@ extern crate ipc_channel;
extern crate libc;
#[macro_use]
extern crate profile_traits;
-#[cfg(target_os="linux")]
+#[cfg(target_os = "linux")]
extern crate regex;
-#[cfg(target_os="macos")]
+#[cfg(target_os = "macos")]
extern crate task_info;
extern crate time as std_time;
extern crate util;
diff --git a/components/profile/mem.rs b/components/profile/mem.rs
index dae86a535fd..8b1e7b1397d 100644
--- a/components/profile/mem.rs
+++ b/components/profile/mem.rs
@@ -368,7 +368,7 @@ mod system_reporter {
use std::mem::size_of;
use std::ptr::null_mut;
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};
/// Collects global measurements from the OS and heap allocators.
@@ -418,12 +418,12 @@ mod system_reporter {
request.reports_channel.send(reports);
}
- #[cfg(target_os="linux")]
+ #[cfg(target_os = "linux")]
extern {
fn mallinfo() -> struct_mallinfo;
}
- #[cfg(target_os="linux")]
+ #[cfg(target_os = "linux")]
#[repr(C)]
pub struct struct_mallinfo {
arena: c_int,
@@ -438,7 +438,7 @@ mod system_reporter {
keepcost: c_int,
}
- #[cfg(target_os="linux")]
+ #[cfg(target_os = "linux")]
fn get_system_heap_allocated() -> Option<usize> {
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> {
None
}
@@ -507,14 +507,14 @@ mod system_reporter {
($e:expr) => (match $e { Some(e) => e, None => return None })
);
- #[cfg(target_os="linux")]
+ #[cfg(target_os = "linux")]
fn page_size() -> usize {
unsafe {
::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> {
use std::fs::File;
use std::io::Read;
@@ -527,37 +527,37 @@ mod system_reporter {
Some(npages * page_size())
}
- #[cfg(target_os="linux")]
+ #[cfg(target_os = "linux")]
fn get_vsize() -> Option<usize> {
get_proc_self_statm_field(0)
}
- #[cfg(target_os="linux")]
+ #[cfg(target_os = "linux")]
fn get_resident() -> Option<usize> {
get_proc_self_statm_field(1)
}
- #[cfg(target_os="macos")]
+ #[cfg(target_os = "macos")]
fn get_vsize() -> Option<usize> {
virtual_size()
}
- #[cfg(target_os="macos")]
+ #[cfg(target_os = "macos")]
fn get_resident() -> Option<usize> {
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> {
None
}
- #[cfg(not(any(target_os="linux", target_os = "macos")))]
+ #[cfg(not(any(target_os = "linux", target_os = "macos")))]
fn get_resident() -> Option<usize> {
None
}
- #[cfg(target_os="linux")]
+ #[cfg(target_os = "linux")]
fn get_resident_segments() -> Vec<(String, usize)> {
use regex::Regex;
use std::collections::HashMap;
@@ -658,7 +658,7 @@ mod system_reporter {
segs
}
- #[cfg(not(target_os="linux"))]
+ #[cfg(not(target_os = "linux"))]
fn get_resident_segments() -> Vec<(String, usize)> {
vec![]
}
diff --git a/components/script/dom/bindings/num.rs b/components/script/dom/bindings/num.rs
index 87c5e38a3bb..1169ccdec7f 100644
--- a/components/script/dom/bindings/num.rs
+++ b/components/script/dom/bindings/num.rs
@@ -9,7 +9,7 @@ use num::Float;
use std::ops::Deref;
/// Encapsulates the IDL restricted float type.
-#[derive(JSTraceable,Clone,Eq,PartialEq)]
+#[derive(JSTraceable, Clone, Eq, PartialEq)]
pub struct Finite<T: Float>(T);
unsafe impl<T: Float> Zeroable for Finite<T> {}
diff --git a/components/script/lib.rs b/components/script/lib.rs
index 651af1a7f60..ab2f0b94669 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -33,7 +33,7 @@
#![deny(unsafe_code)]
#![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(plugins)]
@@ -103,7 +103,7 @@ mod webdriver_handlers;
use dom::bindings::codegen::RegisterBindings;
-#[cfg(target_os="linux")]
+#[cfg(target_os = "linux")]
#[allow(unsafe_code)]
fn perform_platform_specific_initialization() {
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() {}
#[allow(unsafe_code)]
diff --git a/components/script/textinput.rs b/components/script/textinput.rs
index 0f7164d5fa0..c647f63d4d8 100644
--- a/components/script/textinput.rs
+++ b/components/script/textinput.rs
@@ -78,12 +78,12 @@ pub enum Direction {
/// Was the keyboard event accompanied by the standard control modifier,
/// 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 {
mods.contains(SUPER) && !mods.contains(CONTROL | ALT)
}
-#[cfg(not(target_os="macos"))]
+#[cfg(not(target_os = "macos"))]
fn is_control_key(mods: KeyModifiers) -> bool {
mods.contains(CONTROL) && !mods.contains(SUPER | ALT)
}
diff --git a/components/servo/main.rs b/components/servo/main.rs
index e96703026fe..f7c8495cc6f 100644
--- a/components/servo/main.rs
+++ b/components/servo/main.rs
@@ -31,7 +31,7 @@ extern crate glutin_app as app;
extern crate time;
extern crate env_logger;
-#[cfg(target_os="android")]
+#[cfg(target_os = "android")]
#[macro_use]
extern crate android_glue;
@@ -41,7 +41,7 @@ use servo::Browser;
use std::rc::Rc;
use util::opts;
-#[cfg(target_os="android")]
+#[cfg(target_os = "android")]
use std::borrow::ToOwned;
fn main() {
@@ -134,16 +134,16 @@ impl app::NestedEventLoopListener for BrowserWrapper {
}
}
-#[cfg(target_os="android")]
+#[cfg(target_os = "android")]
fn setup_logging() {
android::setup_logging();
}
-#[cfg(not(target_os="android"))]
+#[cfg(not(target_os = "android"))]
fn setup_logging() {
}
-#[cfg(target_os="android")]
+#[cfg(target_os = "android")]
fn get_args() -> Vec<String> {
vec![
"servo".to_owned(),
@@ -151,7 +151,7 @@ fn get_args() -> Vec<String> {
]
}
-#[cfg(not(target_os="android"))]
+#[cfg(not(target_os = "android"))]
fn get_args() -> Vec<String> {
use std::env;
env::args().collect()
diff --git a/components/util/opts.rs b/components/util/opts.rs
index 10a2bd84a78..7c0bbff0164 100644
--- a/components/util/opts.rs
+++ b/components/util/opts.rs
@@ -335,10 +335,10 @@ fn args_fail(msg: &str) -> ! {
// Always use CPU painting on android.
-#[cfg(target_os="android")]
+#[cfg(target_os = "android")]
static FORCE_CPU_PAINTING: bool = true;
-#[cfg(not(target_os="android"))]
+#[cfg(not(target_os = "android"))]
static FORCE_CPU_PAINTING: bool = false;
enum UserAgent {
@@ -361,15 +361,15 @@ fn default_user_agent_string(agent: UserAgent) -> String {
}.to_owned()
}
-#[cfg(target_os="android")]
+#[cfg(target_os = "android")]
const DEFAULT_USER_AGENT: UserAgent = UserAgent::Android;
// 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).
-#[cfg(target_os="gonk")]
+#[cfg(target_os = "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;
pub fn default_opts() -> Opts {
diff --git a/ports/glutin/lib.rs b/ports/glutin/lib.rs
index 0bd7fffff8e..cb611153be0 100644
--- a/ports/glutin/lib.rs
+++ b/ports/glutin/lib.rs
@@ -7,7 +7,7 @@
#![feature(box_syntax, result_expect)]
#[macro_use] extern crate bitflags;
-#[cfg(target_os="macos")] extern crate cgl;
+#[cfg(target_os = "macos")] extern crate cgl;
extern crate compositing;
extern crate euclid;
extern crate gleam;
@@ -19,9 +19,9 @@ extern crate net_traits;
#[cfg(feature = "window")] extern crate script_traits;
extern crate time;
extern crate util;
-#[cfg(target_os="android")] extern crate egl;
+#[cfg(target_os = "android")] extern crate egl;
extern crate url;
-#[cfg(target_os="linux")] extern crate x11;
+#[cfg(target_os = "linux")] extern crate x11;
use compositing::windowing::WindowEvent;
use euclid::scale_factor::ScaleFactor;
diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs
index a01987ee1f7..ec96727d811 100644
--- a/ports/glutin/window.rs
+++ b/ports/glutin/window.rs
@@ -35,7 +35,7 @@ use std::cell::{Cell, RefCell};
#[cfg(feature = "window")]
use util::opts;
-#[cfg(all(feature = "headless", target_os="linux"))]
+#[cfg(all(feature = "headless", target_os = "linux"))]
use std::ptr;
#[cfg(feature = "window")]
@@ -56,15 +56,15 @@ bitflags! {
}
// 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;
-#[cfg(all(feature = "window", not(target_os="macos")))]
+#[cfg(all(feature = "window", not(target_os = "macos")))]
const CMD_OR_CONTROL: constellation_msg::KeyModifiers = CONTROL;
// 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;
-#[cfg(all(feature = "window", not(target_os="macos")))]
+#[cfg(all(feature = "window", not(target_os = "macos")))]
const CMD_OR_ALT: constellation_msg::KeyModifiers = ALT;
// 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 {
GlRequest::Specific(Api::OpenGl, (3, 0))
}
- #[cfg(target_os="android")]
+ #[cfg(target_os = "android")]
fn gl_version() -> GlRequest {
GlRequest::Specific(Api::OpenGlEs, (2, 0))
}
- #[cfg(not(target_os="android"))]
+ #[cfg(not(target_os = "android"))]
fn load_gl_functions(window: &glutin::Window) {
gl::load_with(|s| window.get_proc_address(s));
}
- #[cfg(target_os="android")]
+ #[cfg(target_os = "android")]
fn load_gl_functions(_: &glutin::Window) {
}
@@ -290,7 +290,7 @@ impl Window {
self.event_queue.borrow_mut().push(WindowEvent::MouseWindowEventClass(event));
}
- #[cfg(target_os="macos")]
+ #[cfg(target_os = "macos")]
fn handle_next_event(&self) -> bool {
let event = self.window.wait_events().next().unwrap();
let mut close = self.handle_window_event(event);
@@ -305,7 +305,7 @@ impl Window {
close
}
- #[cfg(any(target_os="linux", target_os="android"))]
+ #[cfg(any(target_os = "linux", target_os = "android"))]
fn handle_next_event(&self) -> bool {
use std::thread::sleep_ms;
@@ -478,7 +478,7 @@ impl Window {
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) {
match (mods, key) {
(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) {
}
}
// 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> {
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> {
Some(window.window.create_window_proxy())
}
@@ -623,7 +623,7 @@ impl WindowMethods for Window {
true
}
- #[cfg(target_os="linux")]
+ #[cfg(target_os = "linux")]
fn native_display(&self) -> NativeDisplay {
use x11::xlib;
unsafe {
@@ -631,7 +631,7 @@ impl WindowMethods for Window {
}
}
- #[cfg(not(target_os="linux"))]
+ #[cfg(not(target_os = "linux"))]
fn native_display(&self) -> NativeDisplay {
NativeDisplay::new()
}
@@ -791,7 +791,7 @@ impl WindowMethods for Window {
true
}
- #[cfg(target_os="linux")]
+ #[cfg(target_os = "linux")]
fn native_display(&self) -> NativeDisplay {
NativeDisplay::new(ptr::null_mut())
}
diff --git a/python/tidy.py b/python/tidy.py
index 9ea9de24f30..6f1cbea5ea0 100644
--- a/python/tidy.py
+++ b/python/tidy.py
@@ -188,33 +188,35 @@ def check_rust(file_name, contents):
line = merged_lines + line
merged_lines = ''
- # get rid of strings and chars because cases like regex expression
- line = re.sub('".*?"|\'.*?\'', '', line)
+ # get rid of strings and chars because cases like regex expression, keep attributes
+ if not line_is_attribute(line):
+ line = re.sub('".*?"|\'.*?\'', '', line)
- # get rid of comments and attributes
- line = re.sub('//.*?$|/\*.*?$|^\*.*?$|^#.*?$', '', line)
+ # get rid of comments
+ 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)
if match:
yield (idx + 1, "missing space after ,")
- # 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
-
- # - not included because of scientific notation (1e-6)
- match = re.search(r"[A-Za-z0-9][\+/\*%=]", line)
+ if line_is_attribute(line):
+ pre_space_re = r"[A-Za-z0-9]="
+ post_space_re = r"=[A-Za-z0-9\"]"
+ else:
+ # - not included because of scientific notation (1e-6)
+ pre_space_re = r"[A-Za-z0-9][\+/\*%=]"
+ # * not included because of dereferencing and casting
+ # - not included because of unary negation
+ post_space_re = r"[\+/\%=][A-Za-z0-9\"]"
+
+ match = re.search(pre_space_re, line)
if match and not is_associated_type(match, line, 1):
yield (idx + 1, "missing space before %s" % match.group(0)[1])
- # * not included because of dereferencing and casting
- # - not included because of unary negation
- match = re.search(r"[\+/\%=][A-Za-z0-9]", line)
+ match = re.search(post_space_re, line)
if match and not is_associated_type(match, line, 0):
yield (idx + 1, "missing space after %s" % match.group(0)[0])
@@ -260,6 +262,20 @@ def check_rust(file_name, contents):
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):
# Sorted by this function (in pseudo-Rust). The idea is to group the same
# organization together.
diff --git a/tests/unit/script/textinput.rs b/tests/unit/script/textinput.rs
index 313ab62fe0a..c5b802f233d 100644
--- a/tests/unit/script/textinput.rs
+++ b/tests/unit/script/textinput.rs
@@ -9,9 +9,9 @@
use msg::constellation_msg::{Key, KeyModifiers};
-#[cfg(target_os="macos")]
+#[cfg(target_os = "macos")]
use msg::constellation_msg::SUPER;
-#[cfg(not(target_os="macos"))]
+#[cfg(not(target_os = "macos"))]
use msg::constellation_msg::CONTROL;
use script::clipboard_provider::DummyClipboardContext;
@@ -194,9 +194,9 @@ fn test_textinput_set_content() {
#[test]
fn test_clipboard_paste() {
- #[cfg(target_os="macos")]
+ #[cfg(target_os = "macos")]
const MODIFIERS: KeyModifiers = SUPER;
- #[cfg(not(target_os="macos"))]
+ #[cfg(not(target_os = "macos"))]
const MODIFIERS: KeyModifiers = CONTROL;
let mut textinput = TextInput::new(Lines::Single, "defg".to_owned(), DummyClipboardContext::new("abc"));