Make it possible to build the style_traits crate with a stable compiler.

Testing this on CI to make sure we don’t regress it is blocked on #11806
This commit is contained in:
Simon Sapin 2016-06-21 13:55:50 +02:00
parent b9b289c4be
commit ea73c8efac
20 changed files with 145 additions and 89 deletions

View file

@ -13,7 +13,7 @@ path = "lib.rs"
app_units = {version = "0.2.3", features = ["plugins"]} app_units = {version = "0.2.3", features = ["plugins"]}
azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]} azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]}
bitflags = "0.7" bitflags = "0.7"
euclid = {version = "0.6.4", features = ["plugins"]} euclid = {version = "0.6.4", features = ["plugins", "unstable"]}
fnv = "1.0" fnv = "1.0"
gfx_traits = {path = "../gfx_traits"} gfx_traits = {path = "../gfx_traits"}
harfbuzz-sys = "0.1" harfbuzz-sys = "0.1"

View file

@ -20,7 +20,8 @@ use azure::azure_hl::Color;
use euclid::approxeq::ApproxEq; use euclid::approxeq::ApproxEq;
use euclid::num::Zero; use euclid::num::Zero;
use euclid::rect::TypedRect; use euclid::rect::TypedRect;
use euclid::{Matrix2D, Matrix4D, Point2D, Rect, SideOffsets2D, Size2D}; use euclid::side_offsets::SideOffsets2D;
use euclid::{Matrix2D, Matrix4D, Point2D, Rect, Size2D};
use fnv::FnvHasher; use fnv::FnvHasher;
use gfx_traits::{LayerId, ScrollPolicy, StackingContextId}; use gfx_traits::{LayerId, ScrollPolicy, StackingContextId};
use ipc_channel::ipc::IpcSharedMemory; use ipc_channel::ipc::IpcSharedMemory;

View file

@ -21,6 +21,6 @@ plugins = {path = "../plugins"}
rustc-serialize = "0.3.4" rustc-serialize = "0.3.4"
serde = "0.7" serde = "0.7"
serde_macros = "0.7" serde_macros = "0.7"
url = {version = "1.0.0", features = ["heap_size"]} url = {version = "1.0.0", features = ["heap_size", "serde"]}
util = {path = "../util"} util = {path = "../util", features = ["servo"]}
webrender_traits = {git = "https://github.com/servo/webrender_traits"} webrender_traits = {git = "https://github.com/servo/webrender_traits"}

View file

@ -11,7 +11,7 @@ path = "lib.rs"
[dependencies] [dependencies]
profile_traits = {path = "../profile_traits"} profile_traits = {path = "../profile_traits"}
plugins = {path = "../plugins"} plugins = {path = "../plugins"}
util = {path = "../util"} util = {path = "../util", features = ["servo"]}
ipc-channel = {git = "https://github.com/servo/ipc-channel"} ipc-channel = {git = "https://github.com/servo/ipc-channel"}
heartbeats-simple = "0.3" heartbeats-simple = "0.3"
log = "0.3.5" log = "0.3.5"

View file

@ -15,7 +15,7 @@ msg = {path = "../msg"}
net_traits = {path = "../net_traits"} net_traits = {path = "../net_traits"}
plugins = {path = "../plugins"} plugins = {path = "../plugins"}
profile_traits = {path = "../profile_traits"} profile_traits = {path = "../profile_traits"}
style_traits = {path = "../style_traits"} style_traits = {path = "../style_traits", features = ["serde-serialization"]}
util = {path = "../util"} util = {path = "../util"}
devtools_traits = {path = "../devtools_traits"} devtools_traits = {path = "../devtools_traits"}
ipc-channel = {git = "https://github.com/servo/ipc-channel"} ipc-channel = {git = "https://github.com/servo/ipc-channel"}

View file

@ -2253,7 +2253,6 @@ dependencies = [
"euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2438,7 +2437,6 @@ dependencies = [
"euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.3 (git+https://github.com/servo/ipc-channel)", "ipc-channel 0.2.3 (git+https://github.com/servo/ipc-channel)",
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2446,7 +2444,6 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -34,10 +34,10 @@ serde = {version = "0.7", features = ["nightly"]}
serde_macros = "0.7" serde_macros = "0.7"
smallvec = "0.1" smallvec = "0.1"
string_cache = {version = "0.2.20", features = ["heap_size"]} string_cache = {version = "0.2.20", features = ["heap_size"]}
style_traits = {path = "../style_traits"} style_traits = {path = "../style_traits", features = ["heap_size"]}
time = "0.1" time = "0.1"
url = {version = "1.0.0", features = ["heap_size"]} url = {version = "1.0.0", features = ["heap_size"]}
util = {path = "../util"} util = {path = "../util", features = ["servo"]}
[build-dependencies] [build-dependencies]
walkdir = "0.1" walkdir = "0.1"

View file

@ -5,7 +5,8 @@
//! Geometry in flow-relative space. //! Geometry in flow-relative space.
use euclid::num::Zero; use euclid::num::Zero;
use euclid::{Point2D, Rect, SideOffsets2D, Size2D}; use euclid::side_offsets::SideOffsets2D;
use euclid::{Point2D, Rect, Size2D};
use std::cmp::{max, min}; use std::cmp::{max, min};
use std::fmt::{self, Debug, Error, Formatter}; use std::fmt::{self, Debug, Error, Formatter};
use std::ops::{Add, Sub}; use std::ops::{Add, Sub};

View file

@ -25,7 +25,7 @@ use cssparser::{Parser, RGBA, AtRuleParser, DeclarationParser, Delimiter,
DeclarationListParser, parse_important, ToCss, TokenSerializationType}; DeclarationListParser, parse_important, ToCss, TokenSerializationType};
use error_reporting::ParseErrorReporter; use error_reporting::ParseErrorReporter;
use url::Url; use url::Url;
use euclid::SideOffsets2D; use euclid::side_offsets::SideOffsets2D;
use euclid::size::Size2D; use euclid::size::Size2D;
use string_cache::Atom; use string_cache::Atom;
use computed_values; use computed_values;

View file

@ -8,13 +8,16 @@ publish = false
name = "style_traits" name = "style_traits"
path = "lib.rs" path = "lib.rs"
[features]
heap_size = ["heapsize", "heapsize_plugin", "cssparser/heap_size", "euclid/plugins"]
serde-serialization = ["serde", "serde_macros", "cssparser/serde-serialization", "euclid/plugins"]
[dependencies] [dependencies]
util = {path = "../util"} util = {path = "../util"}
plugins = {path = "../plugins"} cssparser = "0.5.4"
cssparser = {version = "0.5.4", features = ["heap_size", "serde-serialization"]} euclid = "0.6.4"
euclid = {version = "0.6.4", features = ["plugins"]} heapsize = {version = "0.3.0", optional = true}
heapsize = "0.3.0" heapsize_plugin = {version = "0.1.2", optional = true}
heapsize_plugin = "0.1.2"
rustc-serialize = "0.3" rustc-serialize = "0.3"
serde = "0.7" serde = {version = "0.7", optional = true}
serde_macros = "0.7" serde_macros = {version = "0.7", optional = true}

View file

@ -8,7 +8,9 @@ use cssparser::ToCss;
macro_rules! define_cursor { macro_rules! define_cursor {
($( $css: expr => $variant: ident = $value: expr, )+) => { ($( $css: expr => $variant: ident = $value: expr, )+) => {
#[derive(Clone, Copy, Debug, Deserialize, Eq, HeapSizeOf, PartialEq, Serialize)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde-serialization", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
#[repr(u8)] #[repr(u8)]
pub enum Cursor { pub enum Cursor {
$( $variant = $value ),+ $( $variant = $value ),+

View file

@ -8,19 +8,22 @@
#![crate_name = "style_traits"] #![crate_name = "style_traits"]
#![crate_type = "rlib"] #![crate_type = "rlib"]
#![feature(custom_derive)]
#![feature(plugin)]
#![plugin(heapsize_plugin)]
#![plugin(serde_macros)]
#![plugin(plugins)]
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![cfg_attr(feature = "serde-serialization", feature(custom_derive))]
#![cfg_attr(feature = "serde-serialization", feature(plugin))]
#![cfg_attr(feature = "serde-serialization", plugin(serde_macros))]
#![cfg_attr(feature = "heap_size", feature(custom_derive))]
#![cfg_attr(feature = "heap_size", feature(plugin))]
#![cfg_attr(feature = "heap_size", plugin(heapsize_plugin))]
#[macro_use] #[macro_use]
extern crate cssparser; extern crate cssparser;
extern crate euclid; extern crate euclid;
extern crate heapsize; #[cfg(feature = "heap_size")] extern crate heapsize;
extern crate rustc_serialize; extern crate rustc_serialize;
extern crate serde; #[cfg(feature = "serde-serialization")] extern crate serde;
extern crate util; extern crate util;
pub mod cursor; pub mod cursor;

View file

@ -5,12 +5,58 @@
#[macro_export] #[macro_export]
macro_rules! define_css_keyword_enum { macro_rules! define_css_keyword_enum {
($name: ident: $( $css: expr => $variant: ident ),+,) => { ($name: ident: $( $css: expr => $variant: ident ),+,) => {
define_css_keyword_enum!($name: $( $css => $variant ),+); __define_css_keyword_enum__add_serde!($name [ $( $css => $variant ),+ ]);
}; };
($name: ident: $( $css: expr => $variant: ident ),+) => { ($name: ident: $( $css: expr => $variant: ident ),+) => {
__define_css_keyword_enum__add_serde!($name [ $( $css => $variant ),+ ]);
};
}
#[cfg(feature = "serde-serialization")]
#[macro_export]
macro_rules! __define_css_keyword_enum__add_serde {
($name: ident [ $( $css: expr => $variant: ident ),+ ]) => {
__define_css_keyword_enum__add_heapsize! {
$name [ Deserialize, Serialize ] [ $( $css => $variant ),+ ]
}
};
}
#[cfg(not(feature = "serde-serialization"))]
#[macro_export]
macro_rules! __define_css_keyword_enum__add_serde {
($name: ident [ $( $css: expr => $variant: ident ),+ ]) => {
__define_css_keyword_enum__add_heapsize! {
$name [] [ $( $css => $variant ),+ ]
}
};
}
#[cfg(feature = "heap_size")]
#[macro_export]
macro_rules! __define_css_keyword_enum__add_heapsize {
($name: ident [ $( $derived_trait: ident),* ] [ $( $css: expr => $variant: ident ),+ ]) => {
__define_css_keyword_enum__actual! {
$name [ $( $derived_trait, )* HeapSizeOf ] [ $( $css => $variant ),+ ]
}
};
}
#[cfg(not(feature = "heap_size"))]
#[macro_export]
macro_rules! __define_css_keyword_enum__add_heapsize {
($name: ident [ $( $derived_trait: ident),* ] [ $( $css: expr => $variant: ident ),+ ]) => {
__define_css_keyword_enum__actual! {
$name [ $( $derived_trait ),* ] [ $( $css => $variant ),+ ]
}
};
}
#[macro_export]
macro_rules! __define_css_keyword_enum__actual {
($name: ident [ $( $derived_trait: ident),* ] [ $( $css: expr => $variant: ident ),+ ]) => {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Clone, Eq, PartialEq, Copy, Hash, RustcEncodable, Debug, HeapSizeOf)] #[derive(Clone, Eq, PartialEq, Copy, Hash, RustcEncodable, Debug $(, $derived_trait )* )]
#[derive(Deserialize, Serialize)]
pub enum $name { pub enum $name {
$( $variant ),+ $( $variant ),+
} }

View file

@ -20,7 +20,9 @@ define_css_keyword_enum!(Orientation:
"landscape" => Landscape); "landscape" => Landscape);
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, HeapSizeOf)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde-serialization", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
pub struct ViewportConstraints { pub struct ViewportConstraints {
pub size: TypedSize2D<ViewportPx, f32>, pub size: TypedSize2D<ViewportPx, f32>,
@ -54,7 +56,8 @@ impl ToCss for ViewportConstraints {
/// Zoom is a number | percentage | auto /// Zoom is a number | percentage | auto
/// See http://dev.w3.org/csswg/css-device-adapt/#descdef-viewport-zoom /// See http://dev.w3.org/csswg/css-device-adapt/#descdef-viewport-zoom
#[derive(Copy, Clone, Debug, HeapSizeOf, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
pub enum Zoom { pub enum Zoom {
Number(f32), Number(f32),
Percentage(f32), Percentage(f32),

View file

@ -8,28 +8,30 @@ publish = false
name = "util" name = "util"
path = "lib.rs" path = "lib.rs"
[features]
# servo as opposed to geckolib
servo = ["serde", "serde_macros", "backtrace", "ipc-channel", "bitflags"]
[dependencies] [dependencies]
app_units = {version = "0.2.3", features = ["plugins"]} app_units = {version = "0.2.3"}
backtrace = "0.2.1" backtrace = {version = "0.2.1", optional = true}
bitflags = "0.7" bitflags = {version = "0.7", optional = true}
deque = "0.3.1" deque = "0.3.1"
euclid = {version = "0.6.4", features = ["unstable", "plugins"]} euclid = {version = "0.6.4"}
getopts = "0.2.11" getopts = "0.2.11"
heapsize = "0.3.0" heapsize = "0.3.0"
heapsize_plugin = "0.1.2" ipc-channel = {git = "https://github.com/servo/ipc-channel", optional = true}
ipc-channel = {git = "https://github.com/servo/ipc-channel"}
lazy_static = "0.2" lazy_static = "0.2"
libc = "0.2" libc = "0.2"
log = "0.3.5" log = "0.3.5"
num_cpus = "0.2.2" num_cpus = "0.2.2"
num-traits = "0.1.32" num-traits = "0.1.32"
plugins = {path = "../plugins"}
rand = "0.3" rand = "0.3"
rustc-serialize = "0.3" rustc-serialize = "0.3"
serde = "0.7" serde = {version = "0.7", optional = true}
serde_macros = "0.7" serde_macros = {version = "0.7", optional = true}
smallvec = "0.1" smallvec = "0.1"
url = {version = "1.0.0", features = ["heap_size", "serde"]} url = {version = "1.0.0"}
[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))'.dependencies] [target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))'.dependencies]
xdg = "2.0" xdg = "2.0"

View file

@ -23,7 +23,7 @@ use std::i32;
/// ///
/// The ratio between ScreenPx and DevicePixel for a given display be found by calling /// The ratio between ScreenPx and DevicePixel for a given display be found by calling
/// `servo::windowing::WindowMethods::hidpi_factor`. /// `servo::windowing::WindowMethods::hidpi_factor`.
#[derive(Clone, Copy, Debug, HeapSizeOf)] #[derive(Clone, Copy, Debug)]
pub enum ScreenPx {} pub enum ScreenPx {}
/// One CSS "px" in the coordinate system of the "initial viewport": /// One CSS "px" in the coordinate system of the "initial viewport":
@ -35,7 +35,7 @@ pub enum ScreenPx {}
/// ///
/// At the default zoom level of 100%, one PagePx is equal to one ScreenPx. However, if the /// At the default zoom level of 100%, one PagePx is equal to one ScreenPx. However, if the
/// document is zoomed in or out then this scale may be larger or smaller. /// document is zoomed in or out then this scale may be larger or smaller.
#[derive(Clone, Copy, Debug, HeapSizeOf)] #[derive(Clone, Copy, Debug)]
pub enum ViewportPx {} pub enum ViewportPx {}
/// One CSS "px" in the root coordinate system for the content document. /// One CSS "px" in the root coordinate system for the content document.
@ -44,9 +44,11 @@ pub enum ViewportPx {}
/// This is the mobile-style "pinch zoom" that enlarges content without reflowing it. When the /// This is the mobile-style "pinch zoom" that enlarges content without reflowing it. When the
/// viewport zoom is not equal to 1.0, then the layout viewport is no longer the same physical size /// viewport zoom is not equal to 1.0, then the layout viewport is no longer the same physical size
/// as the viewable area. /// as the viewable area.
#[derive(Clone, Copy, Debug, HeapSizeOf)] #[derive(Clone, Copy, Debug)]
pub enum PagePx {} pub enum PagePx {}
known_heap_size!(0, ScreenPx, ViewportPx, PagePx);
// In summary, the hierarchy of pixel units and the factors to convert from one to the next: // In summary, the hierarchy of pixel units and the factors to convert from one to the next:
// //
// DevicePixel // DevicePixel

View file

@ -2,39 +2,31 @@
* 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/. */
#![feature(box_syntax)] #![cfg_attr(feature = "servo", feature(core_intrinsics))]
#![feature(core_intrinsics)] #![cfg_attr(feature = "servo", feature(custom_derive))]
#![feature(custom_derive)] #![cfg_attr(feature = "servo", feature(fnbox))]
#![feature(fnbox)] #![cfg_attr(feature = "servo", feature(plugin))]
#![feature(plugin)] #![cfg_attr(feature = "servo", feature(reflect_marker))]
#![feature(reflect_marker)] #![cfg_attr(feature = "servo", plugin(serde_macros))]
#![feature(step_by)]
#![plugin(heapsize_plugin, plugins, serde_macros)]
#![deny(unsafe_code)] #![deny(unsafe_code)]
extern crate app_units; extern crate app_units;
extern crate backtrace; #[cfg(feature = "servo")] extern crate backtrace;
#[allow(unused_extern_crates)] #[cfg(feature = "servo")] #[allow(unused_extern_crates)] #[macro_use] extern crate bitflags;
#[macro_use]
extern crate bitflags;
extern crate deque; extern crate deque;
extern crate euclid; extern crate euclid;
extern crate getopts; extern crate getopts;
extern crate heapsize; #[macro_use] extern crate heapsize;
extern crate ipc_channel; #[cfg(feature = "servo")] extern crate ipc_channel;
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)] #[macro_use] extern crate lazy_static;
#[macro_use]
extern crate lazy_static;
extern crate libc; extern crate libc;
#[macro_use] #[macro_use] extern crate log;
extern crate log;
extern crate num_cpus; extern crate num_cpus;
extern crate num_traits; extern crate num_traits;
extern crate rand; extern crate rand;
extern crate rustc_serialize; extern crate rustc_serialize;
extern crate serde; #[cfg(feature = "servo")] extern crate serde;
extern crate smallvec; extern crate smallvec;
extern crate url; extern crate url;
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))] #[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
@ -44,28 +36,24 @@ use std::sync::Arc;
pub mod basedir; pub mod basedir;
pub mod cache; pub mod cache;
#[allow(unsafe_code)] #[allow(unsafe_code)] pub mod debug_utils;
pub mod debug_utils;
pub mod geometry; pub mod geometry;
#[allow(unsafe_code)] #[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod ipc;
pub mod ipc; #[cfg(feature = "servo")] pub mod linked_list;
pub mod linked_list; #[allow(unsafe_code)] pub mod opts;
#[allow(unsafe_code)] #[cfg(feature = "servo")] pub mod panicking;
pub mod opts;
pub mod panicking;
pub mod prefs; pub mod prefs;
pub mod print_tree; #[cfg(feature = "servo")] pub mod print_tree;
pub mod resource_files; pub mod resource_files;
#[allow(unsafe_code)]
pub mod str; pub mod str;
pub mod thread; #[cfg(feature = "servo")] pub mod thread;
pub mod thread_state; #[cfg(feature = "servo")] pub mod thread_state;
pub mod tid; pub mod tid;
pub mod time; #[cfg(feature = "servo")] pub mod time;
pub mod vec; pub mod vec;
#[allow(unsafe_code)] #[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod workqueue;
pub mod workqueue;
#[cfg(feature = "servo")]
#[allow(unsafe_code)] #[allow(unsafe_code)]
pub fn breakpoint() { pub fn breakpoint() {
unsafe { ::std::intrinsics::breakpoint() }; unsafe { ::std::intrinsics::breakpoint() };

View file

@ -23,7 +23,8 @@ use url::{self, Url};
/// Global flags for Servo, currently set on the command line. /// Global flags for Servo, currently set on the command line.
#[derive(Clone, Deserialize, Serialize)] #[derive(Clone)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub struct Opts { pub struct Opts {
pub is_running_problem_test: bool, pub is_running_problem_test: bool,
@ -379,7 +380,8 @@ pub fn print_debug_usage(app: &str) -> ! {
process::exit(0) process::exit(0)
} }
#[derive(Clone, Deserialize, Serialize)] #[derive(Clone)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub enum OutputOptions { pub enum OutputOptions {
FileName(String), FileName(String),
Stdout(f64) Stdout(f64)
@ -404,7 +406,8 @@ enum UserAgent {
Android, Android,
} }
#[derive(Clone, Debug, Eq, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub enum RenderApi { pub enum RenderApi {
GL, GL,
ES2, ES2,
@ -858,7 +861,7 @@ pub fn set_defaults(opts: Opts) {
unsafe { unsafe {
assert!(DEFAULT_OPTIONS.is_null()); assert!(DEFAULT_OPTIONS.is_null());
assert!(DEFAULT_OPTIONS != INVALID_OPTIONS); assert!(DEFAULT_OPTIONS != INVALID_OPTIONS);
let box_opts = box opts; let box_opts = Box::new(opts);
DEFAULT_OPTIONS = Box::into_raw(box_opts); DEFAULT_OPTIONS = Box::into_raw(box_opts);
} }
} }

View file

@ -20,7 +20,8 @@ lazy_static! {
}; };
} }
#[derive(PartialEq, Clone, Debug, Deserialize, Serialize)] #[derive(PartialEq, Clone, Debug)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub enum PrefValue { pub enum PrefValue {
Boolean(bool), Boolean(bool),
String(String), String(String),
@ -91,7 +92,8 @@ impl ToJson for PrefValue {
} }
} }
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub enum Pref { pub enum Pref {
NoDefault(Arc<PrefValue>), NoDefault(Arc<PrefValue>),
WithDefault(Arc<PrefValue>, Option<Arc<PrefValue>>) WithDefault(Arc<PrefValue>, Option<Arc<PrefValue>>)

View file

@ -9,10 +9,13 @@ use super::smallvec::VecLike;
// TODO(pcwalton): Speed up with SIMD, or better yet, find some way to not do this. // TODO(pcwalton): Speed up with SIMD, or better yet, find some way to not do this.
pub fn byte_swap(data: &mut [u8]) { pub fn byte_swap(data: &mut [u8]) {
let length = data.len(); let length = data.len();
for i in (0..length).step_by(4) { // FIXME(rust #27741): Range::step_by is not stable yet as of this writing.
let mut i = 0;
while i < length {
let r = data[i + 2]; let r = data[i + 2];
data[i + 2] = data[i + 0]; data[i + 2] = data[i + 0];
data[i + 0] = r; data[i + 0] = r;
i += 4;
} }
} }