servo: Merge #14592 - Remove the util crate (from asajeffrey:util-goodbye); r=mbrubeck

<!-- Please describe your changes on the following line: -->

This PR removes the `util` crate.

* Replaced the `spawn_named` and `clamp` functions by appropriate uses of `std:🧵:Builder::spawn`, `std::cmp::min` and `std::cmp::max`.
* Moved `opts`, `prefs` and `resource_files` into a new `config` crate.
* Moved `remutex` and `geometry` into their own crates.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because they are refactorings

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: 4eb653817f87e5fb47de34356f558eb76ecbca9f

--HG--
rename : servo/components/util/Cargo.toml => servo/components/config/Cargo.toml
rename : servo/components/util/basedir.rs => servo/components/config/basedir.rs
rename : servo/components/util/lib.rs => servo/components/config/lib.rs
rename : servo/components/util/opts.rs => servo/components/config/opts.rs
rename : servo/components/util/prefs.rs => servo/components/config/prefs.rs
rename : servo/components/util/resource_files.rs => servo/components/config/resource_files.rs
rename : servo/components/util/geometry.rs => servo/components/geometry/lib.rs
rename : servo/components/util/remutex.rs => servo/components/remutex/lib.rs
rename : servo/tests/unit/util/lib.rs => servo/tests/unit/servo_config/lib.rs
rename : servo/tests/unit/util/opts.rs => servo/tests/unit/servo_config/opts.rs
rename : servo/tests/unit/util/prefs.rs => servo/tests/unit/servo_config/prefs.rs
rename : servo/tests/unit/util/remutex.rs => servo/tests/unit/servo_remutex/lib.rs
This commit is contained in:
Alan Jeffrey 2016-12-14 16:48:42 -08:00
Родитель 560fb3dc8f
Коммит 07258edab3
133 изменённых файлов: 396 добавлений и 352 удалений

131
servo/Cargo.lock сгенерированный
Просмотреть файл

@ -14,9 +14,9 @@ dependencies = [
"regex 0.1.76 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"script_traits 0.0.1",
"servo_config 0.0.1",
"servo_url 0.0.1",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webdriver 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -185,7 +185,6 @@ dependencies = [
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
"util 0.0.1",
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -197,7 +196,7 @@ dependencies = [
"regex 0.1.76 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"servo_config 0.0.1",
]
[[package]]
@ -265,7 +264,7 @@ dependencies = [
"num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"offscreen_gl_context 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"util 0.0.1",
"servo_config 0.0.1",
"webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
]
@ -398,10 +397,11 @@ dependencies = [
"script_traits 0.0.1",
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"servo_geometry 0.0.1",
"servo_url 0.0.1",
"style_traits 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"webrender 0.11.0 (git+https://github.com/servo/webrender)",
"webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
]
@ -433,9 +433,10 @@ dependencies = [
"script_traits 0.0.1",
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"servo_remutex 0.0.1",
"servo_url 0.0.1",
"style_traits 0.0.1",
"util 0.0.1",
"webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
]
@ -544,7 +545,6 @@ name = "debugger"
version = "0.0.1"
dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"ws 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -582,7 +582,6 @@ dependencies = [
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
[[package]]
@ -657,9 +656,10 @@ dependencies = [
"objc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"script_traits 0.0.1",
"servo_config 0.0.1",
"servo_geometry 0.0.1",
"servo_url 0.0.1",
"style_traits 0.0.1",
"util 0.0.1",
"x11 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -941,6 +941,7 @@ dependencies = [
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-fontconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_atoms 0.0.1",
"servo_geometry 0.0.1",
"servo_url 0.0.1",
"simd 0.1.1 (git+https://github.com/huonw/simd)",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -948,7 +949,6 @@ dependencies = [
"style_traits 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
"xi-unicode 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1026,10 +1026,11 @@ dependencies = [
"script_traits 0.0.1",
"servo-egl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-glutin 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"servo_geometry 0.0.1",
"servo_url 0.0.1",
"style_traits 0.0.1",
"user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"x11 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1322,13 +1323,13 @@ dependencies = [
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_atoms 0.0.1",
"servo_config 0.0.1",
"servo_url 0.0.1",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"style_traits 0.0.1",
"unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
]
@ -1367,9 +1368,10 @@ dependencies = [
"selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"servo_geometry 0.0.1",
"servo_url 0.0.1",
"style 0.0.1",
"util 0.0.1",
"webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
]
@ -1489,11 +1491,11 @@ dependencies = [
"script 0.0.1",
"script_layout_interface 0.0.1",
"script_traits 0.0.1",
"servo_config 0.0.1",
"servo_url 0.0.1",
"sig 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"webdriver_server 0.0.1",
"webrender 0.11.0 (git+https://github.com/servo/webrender)",
"webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
@ -1676,13 +1678,13 @@ dependencies = [
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"servo_url 0.0.1",
"threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1716,11 +1718,11 @@ dependencies = [
"net_traits 0.0.1",
"plugins 0.0.1",
"profile_traits 0.0.1",
"servo_config 0.0.1",
"servo_url 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
[[package]]
@ -1741,9 +1743,9 @@ dependencies = [
"num-traits 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"servo_url 0.0.1",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2088,9 +2090,9 @@ dependencies = [
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"task_info 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
[[package]]
@ -2113,9 +2115,9 @@ dependencies = [
"plugins 0.0.1",
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1",
"signpost 0.1.0 (git+https://github.com/pcwalton/signpost.git)",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
[[package]]
@ -2292,6 +2294,8 @@ dependencies = [
"selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_atoms 0.0.1",
"servo_config 0.0.1",
"servo_geometry 0.0.1",
"servo_url 0.0.1",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"style 0.0.1",
@ -2299,7 +2303,6 @@ dependencies = [
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.11.0 (git+https://github.com/servo/webrender)",
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2464,9 +2467,10 @@ dependencies = [
"plugin_compiletest 0.0.1",
"profile_tests 0.0.1",
"script_tests 0.0.1",
"servo_config_tests 0.0.1",
"servo_remutex_tests 0.0.1",
"sig 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"style_tests 0.0.1",
"util_tests 0.0.1",
]
[[package]]
@ -2562,6 +2566,58 @@ dependencies = [
"string_cache_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "servo_config"
version = "0.0.1"
dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.1.0 (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)",
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_geometry 0.0.1",
"servo_url 0.0.1",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"xdg 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "servo_config_tests"
version = "0.0.1"
dependencies = [
"servo_config 0.0.1",
]
[[package]]
name = "servo_geometry"
version = "0.0.1"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "servo_remutex"
version = "0.0.1"
dependencies = [
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "servo_remutex_tests"
version = "0.0.1"
dependencies = [
"servo_remutex 0.0.1",
]
[[package]]
name = "servo_url"
version = "0.0.1"
@ -2695,12 +2751,12 @@ dependencies = [
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_atoms 0.0.1",
"servo_config 0.0.1",
"servo_url 0.0.1",
"smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"style_traits 0.0.1",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"walkdir 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -2718,10 +2774,10 @@ dependencies = [
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_atoms 0.0.1",
"servo_config 0.0.1",
"servo_url 0.0.1",
"style 0.0.1",
"style_traits 0.0.1",
"util 0.0.1",
]
[[package]]
@ -3018,35 +3074,6 @@ name = "utf8-ranges"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "util"
version = "0.0.1"
dependencies = [
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (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.7 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.1.0 (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)",
"serde 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.18 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_url 0.0.1",
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"xdg 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "util_tests"
version = "0.0.1"
dependencies = [
"util 0.0.1",
]
[[package]]
name = "uuid"
version = "0.3.1"

Просмотреть файл

@ -15,7 +15,6 @@ bluetooth_traits = {path = "../bluetooth_traits"}
device = {git = "https://github.com/servo/devices", features = ["bluetooth-test"]}
ipc-channel = "0.5"
rand = "0.3"
util = {path = "../util"}
uuid = {version = "0.3.1", features = ["v4"]}
[target.'cfg(target_os = "linux")'.dependencies]

Просмотреть файл

@ -10,7 +10,6 @@ extern crate ipc_channel;
extern crate rand;
#[cfg(target_os = "linux")]
extern crate tinyfiledialogs;
extern crate util;
extern crate uuid;
pub mod test;
@ -29,7 +28,6 @@ use std::collections::{HashMap, HashSet};
use std::string::String;
use std::thread;
use std::time::Duration;
use util::thread::spawn_named;
// A transaction not completed within 30 seconds shall time out. Such a transaction shall be considered to have failed.
// https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=286439 (Vol. 3, page 480)
@ -88,9 +86,9 @@ impl BluetoothThreadFactory for IpcSender<BluetoothRequest> {
fn new() -> IpcSender<BluetoothRequest> {
let (sender, receiver) = ipc::channel().unwrap();
let adapter = BluetoothAdapter::init().ok();
spawn_named("BluetoothThread".to_owned(), move || {
thread::Builder::new().name("BluetoothThread".to_owned()).spawn(move || {
BluetoothManager::new(receiver, adapter).start();
});
}).expect("Thread spawning failed");
sender
}
}

Просмотреть файл

@ -14,4 +14,4 @@ ipc-channel = "0.5"
regex = "0.1.43"
serde = "0.8"
serde_derive = "0.8"
util = {path = "../util"}
servo_config = {path = "../config"}

Просмотреть файл

@ -3,11 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use regex::Regex;
use servo_config::resource_files::read_resource_file;
use std::cell::RefCell;
use std::collections::HashMap;
use std::io::BufRead;
use std::string::String;
use util::resource_files::read_resource_file;
const BLOCKLIST_FILE: &'static str = "gatt_blocklist.txt";
const BLOCKLIST_FILE_NOT_FOUND: &'static str = "Could not find gatt_blocklist.txt file";

Просмотреть файл

@ -8,7 +8,7 @@ extern crate ipc_channel;
extern crate regex;
#[macro_use]
extern crate serde_derive;
extern crate util;
extern crate servo_config;
pub mod blocklist;
pub mod scanfilter;

Просмотреть файл

@ -19,7 +19,7 @@ log = "0.3.5"
num-traits = "0.1.32"
offscreen_gl_context = "0.5.0"
plugins = {path = "../plugins"}
util = {path = "../util"}
servo_config = {path = "../config"}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"

Просмотреть файл

@ -15,7 +15,7 @@ use ipc_channel::ipc::{self, IpcSender};
use num_traits::ToPrimitive;
use std::borrow::ToOwned;
use std::mem;
use util::thread::spawn_named;
use std::thread;
use webrender_traits;
impl<'a> CanvasPaintThread<'a> {
@ -121,7 +121,7 @@ impl<'a> CanvasPaintThread<'a> {
antialias: bool)
-> IpcSender<CanvasMsg> {
let (sender, receiver) = ipc::channel::<CanvasMsg>().unwrap();
spawn_named("CanvasThread".to_owned(), move || {
thread::Builder::new().name("CanvasThread".to_owned()).spawn(move || {
let mut painter = CanvasPaintThread::new(size, webrender_api_sender, antialias);
loop {
let msg = receiver.recv();
@ -211,7 +211,7 @@ impl<'a> CanvasPaintThread<'a> {
CanvasMsg::WebGL(_) => panic!("Wrong message sent to Canvas2D thread"),
}
}
});
}).expect("Thread spawning failed");
sender
}

Просмотреть файл

@ -17,7 +17,7 @@ extern crate ipc_channel;
extern crate log;
extern crate num_traits;
extern crate offscreen_gl_context;
extern crate util;
extern crate servo_config;
extern crate webrender_traits;
pub mod canvas_paint_thread;

Просмотреть файл

@ -9,10 +9,10 @@ use gleam::gl;
use ipc_channel::ipc::{self, IpcSender};
use offscreen_gl_context::{ColorAttachmentType, GLContext, GLLimits};
use offscreen_gl_context::{GLContextAttributes, NativeGLContext, OSMesaContext};
use servo_config::opts;
use std::borrow::ToOwned;
use std::sync::mpsc::channel;
use util::opts;
use util::thread::spawn_named;
use std::thread;
use webrender_traits;
enum GLContextWrapper {
@ -151,7 +151,7 @@ impl WebGLPaintThread {
-> Result<(IpcSender<CanvasMsg>, GLLimits), String> {
let (sender, receiver) = ipc::channel::<CanvasMsg>().unwrap();
let (result_chan, result_port) = channel();
spawn_named("WebGLThread".to_owned(), move || {
thread::Builder::new().name("WebGLThread".to_owned()).spawn(move || {
let mut painter = match WebGLPaintThread::new(size, attrs, webrender_api_sender) {
Ok((thread, limits)) => {
result_chan.send(Ok(limits)).unwrap();
@ -191,7 +191,7 @@ impl WebGLPaintThread {
CanvasMsg::Canvas2d(_) => panic!("Wrong message sent to WebGLThread"),
}
}
});
}).expect("Thread spawning failed");
result_port.recv().unwrap().map(|limits| (sender, limits))
}

Просмотреть файл

@ -23,10 +23,11 @@ profile_traits = {path = "../profile_traits"}
script_traits = {path = "../script_traits"}
serde = "0.8"
serde_derive = "0.8"
servo_config = {path = "../config", features = ["servo"]}
servo_geometry = {path = "../geometry", features = ["servo"]}
servo_url = {path = "../url", features = ["servo"]}
style_traits = {path = "../style_traits"}
time = "0.1.17"
util = {path = "../util"}
[dependencies.webrender]
git = "https://github.com/servo/webrender"

Просмотреть файл

@ -26,6 +26,9 @@ use script_traits::{ConstellationMsg, LayoutControlMsg, LoadData, MouseButton};
use script_traits::{MouseEventType, StackingContextScrollState};
use script_traits::{TouchpadPressurePhase, TouchEventType, TouchId, WindowSizeData, WindowSizeType};
use script_traits::CompositorEvent::{self, MouseMoveEvent, MouseButtonEvent, TouchEvent, TouchpadPressureEvent};
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_geometry::ScreenPx;
use servo_url::ServoUrl;
use std::collections::HashMap;
use std::fs::File;
@ -36,9 +39,6 @@ use style_traits::{PagePx, ViewportPx};
use style_traits::viewport::ViewportConstraints;
use time::{precise_time_ns, precise_time_s};
use touch::{TouchHandler, TouchAction};
use util::geometry::ScreenPx;
use util::opts;
use util::prefs::PREFS;
use webrender;
use webrender_traits::{self, ScrollEventPhase, ServoScrollRootId};
use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};

Просмотреть файл

@ -23,11 +23,11 @@ extern crate profile_traits;
extern crate script_traits;
#[macro_use]
extern crate serde_derive;
extern crate servo_config;
extern crate servo_geometry;
extern crate servo_url;
extern crate style_traits;
extern crate time;
#[macro_use]
extern crate util;
extern crate webrender;
extern crate webrender_traits;

Просмотреть файл

@ -13,10 +13,10 @@ use gfx_traits::DevicePixel;
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
use net_traits::net_error_list::NetError;
use script_traits::{MouseButton, TouchEventType, TouchId, TouchpadPressurePhase};
use servo_geometry::ScreenPx;
use servo_url::ServoUrl;
use std::fmt::{Debug, Error, Formatter};
use style_traits::cursor::Cursor;
use util::geometry::ScreenPx;
#[derive(Clone)]
pub enum MouseWindowEvent {

Просмотреть файл

@ -1,31 +1,29 @@
[package]
name = "util"
name = "servo_config"
version = "0.0.1"
authors = ["The Servo Project Developers"]
license = "MPL-2.0"
publish = false
[lib]
name = "util"
name = "servo_config"
path = "lib.rs"
[features]
# servo as opposed to geckolib
servo = ["serde", "serde_derive", "app_units/plugins",
"euclid/unstable", "url/heap_size", "url/serde", "plugins"]
servo = ["serde", "serde_derive", "url/heap_size", "url/serde", "plugins"]
[dependencies]
app_units = "0.3"
bitflags = "0.7"
euclid = "0.10.1"
getopts = "0.2.11"
heapsize = "0.3.0"
lazy_static = "0.2"
log = "0.3.5"
num_cpus = "1.1.0"
rustc-serialize = "0.3"
serde = {version = "0.8", optional = true}
serde_derive = {version = "0.8", optional = true}
servo_geometry = {path = "../geometry"}
servo_url = {path = "../url"}
plugins = {path = "../plugins", optional = true}
url = "1.2"

Просмотреть файл

Просмотреть файл

@ -2,37 +2,32 @@
* 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_attr(feature = "servo", feature(nonzero))]
#![cfg_attr(feature = "servo", feature(plugin))]
#![cfg_attr(feature = "servo", feature(proc_macro))]
#![cfg_attr(feature = "servo", plugin(plugins))]
#![deny(unsafe_code)]
extern crate app_units;
#[allow(unused_extern_crates)] #[macro_use] extern crate bitflags;
extern crate core;
#[macro_use] extern crate euclid;
extern crate euclid;
extern crate getopts;
#[macro_use] extern crate heapsize;
#[allow(unused_extern_crates)] #[macro_use] extern crate lazy_static;
#[macro_use] extern crate log;
extern crate num_cpus;
extern crate rustc_serialize;
#[cfg(feature = "servo")] extern crate serde;
#[cfg(feature = "servo")] #[macro_use] extern crate serde_derive;
extern crate servo_geometry;
extern crate servo_url;
extern crate url;
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
extern crate xdg;
pub mod basedir;
pub mod geometry;
#[allow(unsafe_code)] pub mod opts;
pub mod prefs;
#[cfg(feature = "servo")] pub mod remutex;
pub mod resource_files;
pub mod thread;
pub fn servo_version() -> String {
let cargo_version = env!("CARGO_PKG_VERSION");
@ -42,13 +37,3 @@ pub fn servo_version() -> String {
None => format!("Servo {}", cargo_version),
}
}
pub fn clamp<T: Ord>(lo: T, mid: T, hi: T) -> T {
if mid < lo {
lo
} else if mid > hi {
hi
} else {
mid
}
}

Просмотреть файл

@ -6,11 +6,11 @@
//! from command line arguments.
use euclid::size::TypedSize2D;
use geometry::ScreenPx;
use getopts::Options;
use num_cpus;
use prefs::{self, PrefValue, PREFS};
use resource_files::set_resources_path;
use servo_geometry::ScreenPx;
use servo_url::ServoUrl;
use std::borrow::Cow;
use std::cmp;

Просмотреть файл

Просмотреть файл

@ -33,8 +33,9 @@ script_traits = {path = "../script_traits"}
serde = "0.8"
serde_derive = "0.8"
style_traits = {path = "../style_traits"}
servo_config = {path = "../config", features = ["servo"]}
servo_remutex = {path = "../remutex"}
servo_url = {path = "../url", features = ["servo"]}
util = {path = "../util"}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"

Просмотреть файл

@ -47,6 +47,9 @@ use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, Scri
use script_traits::{LogEntry, ServiceWorkerMsg, webdriver_msg};
use script_traits::{MozBrowserErrorType, MozBrowserEvent, WebDriverCommandMsg, WindowSizeData};
use script_traits::{SWManagerMsg, ScopeThings, WindowSizeType};
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_remutex::ReentrantMutex;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::collections::{HashMap, VecDeque};
@ -64,10 +67,6 @@ use style_traits::PagePx;
use style_traits::cursor::Cursor;
use style_traits::viewport::ViewportConstraints;
use timer_scheduler::TimerScheduler;
use util::opts;
use util::prefs::PREFS;
use util::remutex::ReentrantMutex;
use util::thread::spawn_named;
use webrender_traits;
#[derive(Debug, PartialEq)]
@ -505,7 +504,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
let (swmanager_sender, swmanager_receiver) = ipc::channel().expect("ipc channel failure");
let sw_mgr_clone = swmanager_sender.clone();
spawn_named("Constellation".to_owned(), move || {
thread::Builder::new().name("Constellation".to_owned()).spawn(move || {
let (ipc_script_sender, ipc_script_receiver) = ipc::channel().expect("ipc channel failure");
let script_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_script_receiver);
@ -568,7 +567,8 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
};
constellation.run();
});
}).expect("Thread spawning failed");
(compositor_sender, swmanager_sender)
}

Просмотреть файл

@ -36,10 +36,10 @@ extern crate script_traits;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate servo_config;
extern crate servo_remutex;
extern crate servo_url;
extern crate style_traits;
#[macro_use]
extern crate util;
extern crate webrender_traits;
mod constellation;

Просмотреть файл

@ -24,6 +24,8 @@ use script_traits::{ConstellationControlMsg, InitialScriptState};
use script_traits::{LayoutControlMsg, LayoutMsg, LoadData, MozBrowserEvent};
use script_traits::{NewLayoutInfo, SWManagerMsg, SWManagerSenders, ScriptMsg};
use script_traits::{ScriptThreadFactory, TimerEventRequest, WindowSizeData};
use servo_config::opts::{self, Opts};
use servo_config::prefs::{PREFS, Pref};
use servo_url::ServoUrl;
use std::collections::HashMap;
use std::env;
@ -33,8 +35,6 @@ use std::process;
use std::rc::Rc;
use std::sync::mpsc::Sender;
use style_traits::{PagePx, ViewportPx};
use util::opts::{self, Opts};
use util::prefs::{PREFS, Pref};
use webrender_traits;
/// A uniquely-identifiable pipeline of script thread, layout thread, and paint thread.

Просмотреть файл

@ -3,8 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use gaol::profile::{Operation, PathPattern, Profile};
use servo_config::resource_files;
use std::path::PathBuf;
use util::resource_files;
/// Our content process sandbox profile on Mac. As restrictive as possible.
#[cfg(target_os = "macos")]

Просмотреть файл

@ -12,7 +12,6 @@ crate_type = ["rlib"]
[dependencies]
log = "0.3.5"
util = {path = "../util"}
[target.'cfg(not(target_os = "android"))'.dependencies]
ws = "0.5.3"

Просмотреть файл

@ -4,13 +4,12 @@
#[macro_use]
extern crate log;
extern crate util;
#[cfg(not(target_os = "android"))]
extern crate ws;
use std::sync::mpsc;
use std::sync::mpsc::channel;
use util::thread::spawn_named;
use std::thread;
#[cfg(not(target_os = "android"))]
use ws::{Builder, CloseCode, Handler, Handshake};
@ -45,14 +44,14 @@ impl Handler for Connection {
pub fn start_server(port: u16) -> Sender {
debug!("Starting server.");
let (sender, receiver) = channel();
spawn_named("debugger".to_owned(), move || {
thread::Builder::new().name("debugger".to_owned()).spawn(move || {
let socket = Builder::new().build(|sender: ws::Sender| {
Connection { sender: sender }
}).unwrap();
let sender = socket.broadcaster();
spawn_named("debugger-websocket".to_owned(), move || {
thread::Builder::new().name("debugger-websocket".to_owned()).spawn(move || {
socket.listen(("127.0.0.1", port)).unwrap();
});
}).expect("Thread spawning failed");
while let Ok(message) = receiver.recv() {
match message {
Message::ShutdownServer => {
@ -61,7 +60,7 @@ pub fn start_server(port: u16) -> Sender {
}
}
sender.shutdown().unwrap();
});
}).expect("Thread spawning failed");
Sender(sender)
}

Просмотреть файл

@ -22,4 +22,3 @@ serde = "0.8"
serde_json = "0.8"
serde_derive = "0.8"
time = "0.1"
util = {path = "../util"}

Просмотреть файл

@ -19,7 +19,6 @@ use std::net::TcpStream;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use util::thread::spawn_named;
pub struct TimelineActor {
name: String,
@ -150,7 +149,7 @@ impl TimelineActor {
return;
}
spawn_named("PullTimelineMarkers".to_owned(), move || {
thread::Builder::new().name("PullTimelineMarkers".to_owned()).spawn(move || {
loop {
if !*is_recording.lock().unwrap() {
break;
@ -164,7 +163,7 @@ impl TimelineActor {
thread::sleep(Duration::from_millis(DEFAULT_TIMELINE_DATA_PULL_TIMEOUT));
}
});
}).expect("Thread spawning failed");
}
}

Просмотреть файл

@ -30,7 +30,6 @@ extern crate serde;
extern crate serde_derive;
extern crate serde_json;
extern crate time;
extern crate util;
use actor::{Actor, ActorRegistry};
use actors::console::ConsoleActor;
@ -57,8 +56,8 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::net::{Shutdown, TcpListener, TcpStream};
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread;
use time::precise_time_ns;
use util::thread::spawn_named;
mod actor;
/// Corresponds to http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/
@ -137,9 +136,9 @@ pub fn start_server(port: u16) -> Sender<DevtoolsControlMsg> {
let (sender, receiver) = channel();
{
let sender = sender.clone();
spawn_named("Devtools".to_owned(), move || {
thread::Builder::new().name("Devtools".to_owned()).spawn(move || {
run_server(sender, receiver, port)
});
}).expect("Thread spawning failed");
}
sender
}
@ -485,23 +484,23 @@ fn run_server(sender: Sender<DevtoolsControlMsg>,
}
let sender_clone = sender.clone();
spawn_named("DevtoolsClientAcceptor".to_owned(), move || {
thread::Builder::new().name("DevtoolsClientAcceptor".to_owned()).spawn(move || {
// accept connections and process them, spawning a new thread for each one
for stream in listener.incoming() {
// connection succeeded
sender_clone.send(DevtoolsControlMsg::FromChrome(
ChromeToDevtoolsControlMsg::AddClient(stream.unwrap()))).unwrap();
}
});
}).expect("Thread spawning failed");
while let Ok(msg) = receiver.recv() {
match msg {
DevtoolsControlMsg::FromChrome(ChromeToDevtoolsControlMsg::AddClient(stream)) => {
let actors = actors.clone();
accepted_connections.push(stream.try_clone().unwrap());
spawn_named("DevtoolsClientHandler".to_owned(), move || {
thread::Builder::new().name("DevtoolsClientHandler".to_owned()).spawn(move || {
handle_client(actors, stream.try_clone().unwrap())
})
}).expect("Thread spawning failed");
}
DevtoolsControlMsg::FromScript(ScriptToDevtoolsControlMsg::FramerateTick(
actor_name, tick)) =>

Просмотреть файл

@ -0,0 +1,19 @@
[package]
name = "servo_geometry"
version = "0.0.1"
authors = ["The Servo Project Developers"]
license = "MPL-2.0"
publish = false
[lib]
name = "servo_geometry"
path = "lib.rs"
[features]
# servo as opposed to geckolib
servo = ["app_units/plugins", "euclid/unstable"]
[dependencies]
app_units = "0.3"
euclid = "0.10.1"
heapsize = "0.3.0"

Просмотреть файл

@ -2,6 +2,10 @@
* 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/. */
extern crate app_units;
#[macro_use] extern crate euclid;
#[macro_use] extern crate heapsize;
use app_units::{Au, MAX_AU};
use euclid::point::Point2D;
use euclid::rect::Rect;

Просмотреть файл

@ -32,6 +32,7 @@ range = {path = "../range"}
rustc-serialize = "0.3"
serde = "0.8"
servo_atoms = {path = "../atoms"}
servo_geometry = {path = "../geometry"}
servo_url = {path = "../url"}
serde_derive = "0.8"
smallvec = "0.1"
@ -39,7 +40,6 @@ style = {path = "../style"}
style_traits = {path = "../style_traits"}
time = "0.1.12"
unicode-script = {version = "0.1", features = ["harfbuzz"]}
util = {path = "../util"}
xi-unicode = "0.0.1"
[dependencies.webrender_traits]

Просмотреть файл

@ -25,6 +25,7 @@ use ipc_channel::ipc::IpcSharedMemory;
use msg::constellation_msg::PipelineId;
use net_traits::image::base::{Image, PixelFormat};
use range::Range;
use servo_geometry::{au_rect_to_f32_rect, f32_rect_to_au_rect, max_rect};
use std::cmp::{self, Ordering};
use std::collections::HashMap;
use std::fmt;
@ -33,7 +34,6 @@ use style::computed_values::{border_style, filter, image_rendering, mix_blend_mo
use style_traits::cursor::Cursor;
use text::TextRun;
use text::glyph::ByteIndex;
use util::geometry::{self, max_rect};
use webrender_traits::{self, ColorF, GradientStop, WebGLContextId};
pub use style::dom::OpaqueNode;
@ -397,9 +397,9 @@ impl StackingContext {
.pre_mul(&self.transform);
let transform_2d = transform.to_2d();
let overflow = geometry::au_rect_to_f32_rect(self.overflow);
let overflow = au_rect_to_f32_rect(self.overflow);
let overflow = transform_2d.transform_rect(&overflow);
geometry::f32_rect_to_au_rect(overflow)
f32_rect_to_au_rect(overflow)
}
pub fn print_with_tree(&self, print_tree: &mut PrintTree) {

Просмотреть файл

@ -21,10 +21,10 @@ use std::collections::HashMap;
use std::mem;
use std::ops::Deref;
use std::sync::{Arc, Mutex};
use std::thread;
use std::u32;
use style::font_face::{EffectiveSources, Source};
use style::properties::longhands::font_family::computed_value::FontFamily;
use util::thread::spawn_named;
use webrender_traits;
/// A list of font templates that make up a given font family.
@ -396,7 +396,7 @@ impl FontCacheThread {
let (chan, port) = ipc::channel().unwrap();
let channel_to_self = chan.clone();
spawn_named("FontCacheThread".to_owned(), move || {
thread::Builder::new().name("FontCacheThread".to_owned()).spawn(move || {
// TODO: Allow users to specify these.
let generic_fonts = populate_generic_fonts();
@ -414,7 +414,7 @@ impl FontCacheThread {
cache.refresh_local_families();
cache.run();
});
}).expect("Thread spawning failed");
FontCacheThread {
chan: chan,

Просмотреть файл

@ -63,6 +63,7 @@ extern crate rustc_serialize;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate servo_geometry;
extern crate servo_url;
#[macro_use] extern crate servo_atoms;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
@ -72,7 +73,6 @@ extern crate style;
extern crate style_traits;
extern crate time;
extern crate unicode_script;
extern crate util;
extern crate webrender_traits;
extern crate xi_unicode;

Просмотреть файл

@ -39,13 +39,13 @@ serde = "0.8"
serde_derive = "0.8"
serde_json = "0.8"
servo_atoms = {path = "../atoms"}
servo_config = {path = "../config"}
servo_url = {path = "../url"}
smallvec = "0.1"
style = {path = "../style"}
style_traits = {path = "../style_traits"}
unicode-bidi = "0.2"
unicode-script = {version = "0.1", features = ["harfbuzz"]}
util = {path = "../util"}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"

Просмотреть файл

@ -61,7 +61,6 @@ use style::properties::ServoComputedValues;
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION};
use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
use style::values::computed::LengthOrPercentageOrAuto;
use util::clamp;
/// Information specific to floated blocks.
#[derive(Clone, Serialize)]
@ -1534,7 +1533,7 @@ impl BlockFlow {
size + self.fragment.border_padding.inline_start_end(),
}
} else {
clamp(min_inline_size, available_inline_size, max_inline_size)
max(min_inline_size, min(available_inline_size, max_inline_size))
};
self.base.position.size.inline = inline_size + self.fragment.margin.inline_start_end();

Просмотреть файл

@ -38,6 +38,7 @@ use multicol::{MulticolColumnFlow, MulticolFlow};
use parallel;
use script_layout_interface::{LayoutElementType, LayoutNodeType, is_image_data};
use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
use servo_config::opts;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::collections::LinkedList;
@ -64,7 +65,6 @@ use table_rowgroup::TableRowGroupFlow;
use table_wrapper::TableWrapperFlow;
use text::TextRunScanner;
use traversal::PostorderNodeMutTraversal;
use util::opts;
use wrapper::{LayoutNodeLayoutData, TextContent, ThreadSafeLayoutNodeHelpers};
/// The results of flow construction for a DOM node.

Просмотреть файл

@ -17,6 +17,7 @@ use net_traits::image::base::Image;
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState};
use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
use parking_lot::RwLock;
use servo_config::opts;
use servo_url::ServoUrl;
use std::borrow::Borrow;
use std::cell::{RefCell, RefMut};
@ -25,7 +26,6 @@ use std::hash::BuildHasherDefault;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use style::context::{LocalStyleContext, StyleContext, SharedStyleContext};
use util::opts;
struct LocalLayoutContext {
style_context: LocalStyleContext,

Просмотреть файл

@ -35,6 +35,7 @@ use model::{self, MaybeAuto, ToGfxMatrix};
use net_traits::image::base::PixelFormat;
use net_traits::image_cache_thread::UsePlaceholder;
use range::Range;
use servo_config::opts;
use servo_url::ServoUrl;
use std::{cmp, f32};
use std::collections::HashMap;
@ -57,7 +58,6 @@ use style::values::computed::{Gradient, GradientKind, LengthOrPercentage, Length
use style::values::specified::{AngleOrCorner, HorizontalDirection, VerticalDirection};
use style_traits::cursor::Cursor;
use table_cell::CollapsedBordersForCell;
use util::opts;
use webrender_traits::{ColorF, GradientStop};
trait RgbColor {

Просмотреть файл

@ -49,13 +49,13 @@ extern crate serde;
extern crate serde_derive;
extern crate serde_json;
#[macro_use] extern crate servo_atoms;
extern crate servo_config;
extern crate servo_url;
extern crate smallvec;
extern crate style;
extern crate style_traits;
extern crate unicode_bidi;
extern crate unicode_script;
extern crate util;
extern crate webrender_traits;
#[macro_use]

Просмотреть файл

@ -13,13 +13,13 @@ use flow::{self, Flow, MutableFlowUtils, PostorderFlowTraversal, PreorderFlowTra
use flow_ref::FlowRef;
use profile_traits::time::{self, TimerMetadata, profile};
use rayon;
use servo_config::opts;
use std::mem;
use std::sync::atomic::{AtomicIsize, Ordering};
use style::dom::UnsafeNode;
use style::parallel::CHUNK_SIZE;
use traversal::{AssignISizes, BubbleISizes};
use traversal::AssignBSizes;
use util::opts;
pub use style::parallel::traverse_dom;

Просмотреть файл

@ -15,10 +15,10 @@ use flow::IS_ABSOLUTELY_POSITIONED;
use fragment::FragmentBorderBoxIterator;
use generated_content::ResolveGeneratedContent;
use gfx_traits::ScrollRootId;
use servo_config::opts;
use style::context::StyleContext;
use style::servo::restyle_damage::{REFLOW, STORE_OVERFLOW};
use traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList};
use util::opts;
pub use style::sequential::traverse_dom;

Просмотреть файл

@ -11,6 +11,7 @@ use flow::{self, PreorderFlowTraversal};
use flow::{CAN_BE_FRAGMENTED, Flow, ImmutableFlowUtils, PostorderFlowTraversal};
use gfx::display_list::OpaqueNode;
use script_layout_interface::wrapper_traits::{LayoutNode, ThreadSafeLayoutNode};
use servo_config::opts;
use std::mem;
use style::atomic_refcell::AtomicRefCell;
use style::context::{LocalStyleContext, SharedStyleContext, StyleContext};
@ -20,7 +21,6 @@ use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT};
use style::traversal::{DomTraversalContext, recalc_style_at, remove_from_bloom_filter};
use style::traversal::PerLevelTraversalData;
use util::opts;
use wrapper::{GetRawData, LayoutNodeHelpers, LayoutNodeLayoutData};
pub struct RecalcStyleAndConstructFlows<'lc> {

Просмотреть файл

@ -34,9 +34,10 @@ script_traits = {path = "../script_traits"}
selectors = "0.15"
serde_derive = "0.8"
serde_json = "0.8"
servo_config = {path = "../config"}
servo_geometry = {path = "../geometry"}
servo_url = {path = "../url"}
style = {path = "../style"}
util = {path = "../util"}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"

Просмотреть файл

@ -40,9 +40,10 @@ extern crate script_layout_interface;
extern crate script_traits;
extern crate selectors;
extern crate serde_json;
extern crate servo_config;
extern crate servo_geometry;
extern crate servo_url;
extern crate style;
extern crate util;
extern crate webrender_traits;
use app_units::Au;
@ -94,6 +95,10 @@ use script_layout_interface::wrapper_traits::LayoutNode;
use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
use script_traits::{StackingContextScrollState, UntrustedNodeAddress};
use selectors::Element;
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_config::resource_files::read_resource_file;
use servo_geometry::max_rect;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::collections::HashMap;
@ -103,6 +108,7 @@ use std::process;
use std::sync::{Arc, Mutex, MutexGuard};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread;
use style::animation::Animation;
use style::context::{LocalStyleContextCreationInfo, ReflowGoal, SharedStyleContext};
use style::data::StoredRestyleHint;
@ -117,11 +123,6 @@ use style::stylist::Stylist;
use style::thread_state;
use style::timer::Timer;
use style::traversal::DomTraversalContext;
use util::geometry::max_rect;
use util::opts;
use util::prefs::PREFS;
use util::resource_files::read_resource_file;
use util::thread;
/// Information needed by the layout thread.
pub struct LayoutThread {
@ -229,7 +230,7 @@ pub struct LayoutThread {
/// only be a test-mode timer during testing for animations.
timer: Timer,
// Number of layout threads. This is copied from `util::opts`, but we'd
// Number of layout threads. This is copied from `servo_config::opts`, but we'd
// rather limit the dependency on that module here.
layout_threads: usize,
}
@ -253,8 +254,7 @@ impl LayoutThreadFactory for LayoutThread {
content_process_shutdown_chan: Option<IpcSender<()>>,
webrender_api_sender: webrender_traits::RenderApiSender,
layout_threads: usize) {
thread::spawn_named(format!("LayoutThread {:?}", id),
move || {
thread::Builder::new().name(format!("LayoutThread {:?}", id)).spawn(move || {
thread_state::initialize(thread_state::LAYOUT);
if let Some(top_level_frame_id) = top_level_frame_id {
@ -285,7 +285,7 @@ impl LayoutThreadFactory for LayoutThread {
if let Some(content_process_shutdown_chan) = content_process_shutdown_chan {
let _ = content_process_shutdown_chan.send(());
}
});
}).expect("Thread spawning failed");
}
}

Просмотреть файл

@ -34,12 +34,12 @@ profile_traits = {path = "../profile_traits"}
rustc-serialize = "0.3"
serde = "0.8"
serde_derive = "0.8"
servo_config = {path = "../config"}
servo_url = {path = "../url"}
threadpool = "1.0"
time = "0.1.17"
unicase = "1.4.0"
url = {version = "1.2", features = ["heap_size", "rustc-serialize"]}
util = {path = "../util"}
uuid = {version = "0.3.1", features = ["v4"]}
websocket = "0.17"

Просмотреть файл

@ -2,10 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use servo_config::resource_files::resources_dir_path;
use servo_url::ServoUrl;
use std::fs::canonicalize;
use url::percent_encoding::percent_decode;
use util::resource_files::resources_dir_path;
pub fn resolve_chrome_url(url: &ServoUrl) -> Result<ServoUrl, ()> {
assert_eq!(url.scheme(), "chrome");

Просмотреть файл

@ -6,8 +6,8 @@ use hyper::client::Pool;
use hyper::net::{HttpStream, HttpsConnector, SslClient};
use openssl::ssl::{SSL_OP_NO_COMPRESSION, SSL_OP_NO_SSLV2, SSL_OP_NO_SSLV3, SSL_VERIFY_PEER};
use openssl::ssl::{Ssl, SslContext, SslMethod, SslStream};
use servo_config::resource_files::resources_dir_path;
use std::sync::Arc;
use util::resource_files::resources_dir_path;
pub type Connector = HttpsConnector<ServoSslClient>;

Просмотреть файл

@ -3,9 +3,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use content_blocker_parser::{RuleList, parse_list};
use servo_config::resource_files::read_resource_file;
use std::str;
use std::sync::Arc;
use util::resource_files::read_resource_file;
lazy_static! {
pub static ref BLOCKED_CONTENT_RULES: Arc<Option<RuleList>> = Arc::new(create_rule_list());

Просмотреть файл

@ -7,6 +7,7 @@ use mime_guess::guess_mime_type_opt;
use net_traits::blob_url_store::{BlobBuf, BlobURLStoreError};
use net_traits::filemanager_thread::{FileManagerResult, FileManagerThreadMsg, FileOrigin, FilterPattern};
use net_traits::filemanager_thread::{FileManagerThreadError, ReadFileProgress, RelativePos, SelectedFile};
use servo_config::prefs::PREFS;
use std::collections::HashMap;
use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
@ -14,11 +15,10 @@ use std::ops::Index;
use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock};
use std::sync::atomic::{self, AtomicBool, AtomicUsize, Ordering};
use std::thread;
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
use tinyfiledialogs;
use url::Url;
use util::prefs::PREFS;
use util::thread::spawn_named;
use uuid::Uuid;
/// The provider of file-dialog UI should implement this trait.
@ -129,12 +129,12 @@ impl FileManager {
check_url_validity: bool,
origin: FileOrigin) {
let store = self.store.clone();
spawn_named("read file".to_owned(), move || {
thread::Builder::new().name("read file".to_owned()).spawn(move || {
if let Err(e) = store.try_read_file(&sender, id, check_url_validity,
origin) {
let _ = sender.send(Err(FileManagerThreadError::BlobURLStoreError(e)));
}
})
}).expect("Thread spawning failed");
}
pub fn promote_memory(&self,
@ -143,9 +143,9 @@ impl FileManager {
sender: IpcSender<Result<Uuid, BlobURLStoreError>>,
origin: FileOrigin) {
let store = self.store.clone();
spawn_named("transfer memory".to_owned(), move || {
thread::Builder::new().name("transfer memory".to_owned()).spawn(move || {
store.promote_memory(blob_buf, set_valid, sender, origin);
})
}).expect("Thread spawning failed");
}
/// Message handler
@ -157,15 +157,15 @@ impl FileManager {
match msg {
FileManagerThreadMsg::SelectFile(filter, sender, origin, opt_test_path) => {
let store = self.store.clone();
spawn_named("select file".to_owned(), move || {
thread::Builder::new().name("select file".to_owned()).spawn(move || {
store.select_file(filter, sender, origin, opt_test_path, ui);
});
}).expect("Thread spawning failed");
}
FileManagerThreadMsg::SelectFiles(filter, sender, origin, opt_test_paths) => {
let store = self.store.clone();
spawn_named("select files".to_owned(), move || {
thread::Builder::new().name("select files".to_owned()).spawn(move || {
store.select_files(filter, sender, origin, opt_test_paths, ui);
})
}).expect("Thread spawning failed");
}
FileManagerThreadMsg::ReadFile(sender, id, check_url_validity, origin) => {
self.read_file(sender, id, check_url_validity, origin);

Просмотреть файл

@ -4,11 +4,11 @@
use net_traits::IncludeSubdomains;
use rustc_serialize::json::decode;
use servo_config::resource_files::read_resource_file;
use std::net::{Ipv4Addr, Ipv6Addr};
use std::str::from_utf8;
use time;
use url::Url;
use util::resource_files::read_resource_file;
#[derive(RustcDecodable, RustcEncodable, Clone)]
pub struct HstsEntry {

Просмотреть файл

@ -47,11 +47,11 @@ use std::ops::Deref;
use std::rc::Rc;
use std::sync::{Arc, RwLock};
use std::sync::mpsc::{channel, Sender};
use std::thread;
use time;
use time::Tm;
use unicase::UniCase;
use url::Origin as UrlOrigin;
use util::thread::spawn_named;
use uuid;
fn read_block<R: Read>(reader: &mut R) -> Result<Data, ()> {
@ -1071,7 +1071,7 @@ fn http_network_fetch(request: Rc<Request>,
let devtools_sender = context.devtools_chan.clone();
let meta_status = meta.status.clone();
let meta_headers = meta.headers.clone();
spawn_named(format!("fetch worker thread"), move || {
thread::Builder::new().name(format!("fetch worker thread")).spawn(move || {
match StreamedResponse::from_http_response(res) {
Ok(mut res) => {
*res_body.lock().unwrap() = ResponseBody::Receiving(vec![]);
@ -1123,7 +1123,7 @@ fn http_network_fetch(request: Rc<Request>,
let _ = done_sender.send(Data::Done);
}
}
});
}).expect("Thread spawning failed");
// TODO these substeps aren't possible yet
// Substep 1

Просмотреть файл

@ -11,6 +11,7 @@ use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheCommand, ImageCac
use net_traits::image_cache_thread::{ImageCacheResult, ImageOrMetadataAvailable, ImageResponse, UsePlaceholder};
use net_traits::image_cache_thread::ImageResponder;
use net_traits::request::{Destination, RequestInit, Type as RequestType};
use servo_config::resource_files::resources_dir_path;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
use std::collections::HashMap;
@ -20,9 +21,8 @@ use std::io::{self, Read};
use std::mem;
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread;
use threadpool::ThreadPool;
use util::resource_files::resources_dir_path;
use util::thread::spawn_named;
use webrender_traits;
///
@ -648,9 +648,9 @@ pub fn new_image_cache_thread(core_resource_thread: CoreResourceThread,
webrender_api: webrender_traits::RenderApi) -> ImageCacheThread {
let (ipc_command_sender, ipc_command_receiver) = ipc::channel().unwrap();
spawn_named("ImageCacheThread".to_owned(), move || {
thread::Builder::new().name("ImageCacheThread".to_owned()).spawn(move || {
ImageCache::run(core_resource_thread, webrender_api, ipc_command_receiver)
});
}).expect("Thread spawning failed");
ImageCacheThread::new(ipc_command_sender)
}

Просмотреть файл

@ -35,6 +35,7 @@ extern crate profile_traits;
extern crate rustc_serialize;
#[macro_use]
extern crate serde_derive;
extern crate servo_config;
extern crate servo_url;
extern crate threadpool;
extern crate time;
@ -42,7 +43,6 @@ extern crate time;
extern crate tinyfiledialogs;
extern crate unicase;
extern crate url;
extern crate util;
extern crate uuid;
extern crate webrender_traits;
extern crate websocket;

Просмотреть файл

@ -37,8 +37,8 @@ use std::path::{Path, PathBuf};
use std::rc::Rc;
use std::sync::{Arc, RwLock};
use std::sync::mpsc::Sender;
use std::thread;
use storage_thread::StorageThreadFactory;
use util::thread::spawn_named;
use websocket_loader;
const TFD_PROVIDER: &'static TFDProvider = &TFDProvider;
@ -76,7 +76,7 @@ pub fn new_core_resource_thread(user_agent: Cow<'static, str>,
-> (CoreResourceThread, CoreResourceThread) {
let (public_setup_chan, public_setup_port) = ipc::channel().unwrap();
let (private_setup_chan, private_setup_port) = ipc::channel().unwrap();
spawn_named("ResourceManager".to_owned(), move || {
thread::Builder::new().name("ResourceManager".to_owned()).spawn(move || {
let resource_manager = CoreResourceManager::new(
user_agent, devtools_chan, profiler_chan
);
@ -87,7 +87,7 @@ pub fn new_core_resource_thread(user_agent: Cow<'static, str>,
};
channel_manager.start(public_setup_port,
private_setup_port);
});
}).expect("Thread spawning failed");
(public_setup_chan, private_setup_chan)
}
@ -343,7 +343,7 @@ impl CoreResourceManager {
let ua = self.user_agent.clone();
let dc = self.devtools_chan.clone();
let filemanager = self.filemanager.clone();
spawn_named(format!("fetch thread for {}", init.url), move || {
thread::Builder::new().name(format!("fetch thread for {}", init.url)).spawn(move || {
let request = Request::from_init(init);
// XXXManishearth: Check origin against pipeline id (also ensure that the mode is allowed)
// todo load context / mimesniff in fetch
@ -357,7 +357,7 @@ impl CoreResourceManager {
filemanager: filemanager,
};
fetch(Rc::new(request), &mut target, &context);
})
}).expect("Thread spawning failed");
}
fn websocket_connect(&self,

Просмотреть файл

@ -10,7 +10,7 @@ use std::borrow::ToOwned;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::path::PathBuf;
use util::thread::spawn_named;
use std::thread;
const QUOTA_SIZE_LIMIT: usize = 5 * 1024 * 1024;
@ -22,9 +22,9 @@ impl StorageThreadFactory for IpcSender<StorageThreadMsg> {
/// Create a storage thread
fn new(config_dir: Option<PathBuf>) -> IpcSender<StorageThreadMsg> {
let (chan, port) = ipc::channel().unwrap();
spawn_named("StorageManager".to_owned(), move || {
thread::Builder::new().name("StorageManager".to_owned()).spawn(move || {
StorageManager::new(port, config_dir).start();
});
}).expect("Thread spawning failed");
chan
}
}

Просмотреть файл

@ -14,7 +14,6 @@ use std::ascii::AsciiExt;
use std::sync::{Arc, Mutex, RwLock};
use std::sync::atomic::{AtomicBool, Ordering};
use std::thread;
use util::thread::spawn_named;
use websocket::{Client, Message};
use websocket::header::{Headers, Origin, WebSocketProtocol};
use websocket::message::Type;
@ -64,7 +63,7 @@ fn establish_a_websocket_connection(resource_url: &ServoUrl, net_url: (Host, Str
}
pub fn init(connect: WebSocketCommunicate, connect_data: WebSocketConnectData, cookie_jar: Arc<RwLock<CookieStorage>>) {
spawn_named(format!("WebSocket connection to {}", connect_data.resource_url), move || {
thread::Builder::new().name(format!("WebSocket connection to {}", connect_data.resource_url)).spawn(move || {
// Step 8: Protocols.
// Step 9.
@ -162,5 +161,5 @@ pub fn init(connect: WebSocketCommunicate, connect_data: WebSocketConnectData, c
}
}
});
});
}).expect("Thread spawning failed");
}

Просмотреть файл

@ -11,7 +11,6 @@ path = "lib.rs"
[dependencies]
bluetooth_traits = {path = "../bluetooth_traits"}
util = {path = "../util"}
msg = {path = "../msg"}
ipc-channel = "0.5"
heapsize = "0.3.0"
@ -24,6 +23,7 @@ log = "0.3.5"
num-traits = "0.1.32"
serde = "0.8"
serde_derive = "0.8"
servo_config = {path = "../config", features = ["servo"]}
servo_url = {path = "../url", features = ["servo"]}
url = {version = "1.2", features = ["heap_size"]}
websocket = "0.17"

Просмотреть файл

@ -27,9 +27,9 @@ extern crate num_traits;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate servo_config;
extern crate servo_url;
extern crate url;
extern crate util;
extern crate uuid;
extern crate webrender_traits;
extern crate websocket;

Просмотреть файл

@ -14,10 +14,10 @@
//! we don't need to make the code more complex for it. The `mach` update command makes sure that
//! those cases are not present.
use servo_config::resource_files::read_resource_file;
use std::collections::HashSet;
use std::iter::FromIterator;
use std::str::from_utf8;
use util::resource_files::read_resource_file;
#[derive(Clone,Debug)]
pub struct PubDomainRules {

Просмотреть файл

@ -12,13 +12,13 @@ path = "lib.rs"
[dependencies]
profile_traits = {path = "../profile_traits"}
plugins = {path = "../plugins"}
util = {path = "../util", features = ["servo"]}
ipc-channel = "0.5"
heartbeats-simple = "0.3"
log = "0.3.5"
serde = "0.8"
serde_derive = "0.8"
serde_json = "0.8"
servo_config = {path = "../config", features = ["servo"]}
time = "0.1.12"
[target.'cfg(target_os = "macos")'.dependencies]

Просмотреть файл

@ -6,13 +6,13 @@
use heartbeats_simple::HeartbeatPow as Heartbeat;
use heartbeats_simple::HeartbeatPowContext as HeartbeatContext;
use profile_traits::time::ProfilerCategory;
use servo_config::opts;
use std::collections::HashMap;
use std::env::var_os;
use std::error::Error;
use std::fs::File;
use std::mem;
use std::path::Path;
use util::opts;
static mut HBS: Option<*mut HashMap<ProfilerCategory, Heartbeat>> = None;

Просмотреть файл

@ -27,10 +27,10 @@ extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate servo_config;
#[cfg(target_os = "macos")]
extern crate task_info;
extern crate time as std_time;
extern crate util;
#[allow(unsafe_code)]
mod heartbeats;

Просмотреть файл

@ -13,7 +13,6 @@ use std::cmp::Ordering;
use std::collections::HashMap;
use std::thread;
use time::duration_from_seconds;
use util::thread::spawn_named;
pub struct Profiler {
/// The port through which messages are received.
@ -33,22 +32,22 @@ impl Profiler {
// Create the timer thread if a period was provided.
if let Some(period) = period {
let chan = chan.clone();
spawn_named("Memory profiler timer".to_owned(), move || {
thread::Builder::new().name("Memory profiler timer".to_owned()).spawn(move || {
loop {
thread::sleep(duration_from_seconds(period));
if chan.send(ProfilerMsg::Print).is_err() {
break;
}
}
});
}).expect("Thread spawning failed");
}
// Always spawn the memory profiler. If there is no timer thread it won't receive regular
// `Print` events, but it will still receive the other events.
spawn_named("Memory profiler".to_owned(), move || {
thread::Builder::new().name("Memory profiler".to_owned()).spawn(move || {
let mut mem_profiler = Profiler::new(port);
mem_profiler.start();
});
}).expect("Thread spawning failed");
let mem_profiler_chan = ProfilerChan(chan);

Просмотреть файл

@ -9,6 +9,7 @@ use ipc_channel::ipc::{self, IpcReceiver};
use profile_traits::energy::{energy_interval_ms, read_energy_uj};
use profile_traits::time::{ProfilerCategory, ProfilerChan, ProfilerMsg, TimerMetadata};
use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
use servo_config::opts::OutputOptions;
use std::{f64, thread, u32, u64};
use std::borrow::ToOwned;
use std::cmp::Ordering;
@ -22,8 +23,6 @@ use std::path::Path;
use std::time::Duration;
use std_time::precise_time_ns;
use trace_dump::TraceDump;
use util::opts::OutputOptions;
use util::thread::spawn_named;
pub trait Formattable {
fn format(&self, output: &Option<OutputOptions>) -> String;
@ -176,28 +175,28 @@ impl Profiler {
Some(ref option) => {
// Spawn the time profiler thread
let outputoption = option.clone();
spawn_named("Time profiler".to_owned(), move || {
thread::Builder::new().name("Time profiler".to_owned()).spawn(move || {
let trace = file_path.as_ref()
.map(path::Path::new)
.map(fs::File::create)
.map(|res| TraceDump::new(res.unwrap()));
let mut profiler = Profiler::new(port, trace, Some(outputoption));
profiler.start();
});
}).expect("Thread spawning failed");
// decide if we need to spawn the timer thread
match option {
&OutputOptions::FileName(_) => { /* no timer thread needed */ },
&OutputOptions::Stdout(period) => {
// Spawn a timer thread
let chan = chan.clone();
spawn_named("Time profiler timer".to_owned(), move || {
thread::Builder::new().name("Time profiler timer".to_owned()).spawn(move || {
loop {
thread::sleep(duration_from_seconds(period));
if chan.send(ProfilerMsg::Print).is_err() {
break;
}
}
});
}).expect("Thread spawning failed");
},
}
},
@ -205,17 +204,17 @@ impl Profiler {
// this is when the -p option hasn't been specified
if file_path.is_some() {
// Spawn the time profiler
spawn_named("Time profiler".to_owned(), move || {
thread::Builder::new().name("Time profiler".to_owned()).spawn(move || {
let trace = file_path.as_ref()
.map(path::Path::new)
.map(fs::File::create)
.map(|res| TraceDump::new(res.unwrap()));
let mut profiler = Profiler::new(port, trace, None);
profiler.start();
});
}).expect("Thread spawning failed");
} else {
// No-op to handle messages when the time profiler is not printing:
spawn_named("Time profiler".to_owned(), move || {
thread::Builder::new().name("Time profiler".to_owned()).spawn(move || {
loop {
match port.recv() {
Err(_) => break,
@ -226,7 +225,7 @@ impl Profiler {
_ => {}
}
}
});
}).expect("Thread spawning failed");
}
}
}
@ -247,7 +246,7 @@ impl Profiler {
const MAX_ENERGY_INTERVAL_MS: u32 = 1000;
let interval_ms = enforce_range(MIN_ENERGY_INTERVAL_MS, MAX_ENERGY_INTERVAL_MS, energy_interval_ms());
let loop_count: u32 = (interval_ms as f32 / SLEEP_MS as f32).ceil() as u32;
spawn_named("Application heartbeat profiler".to_owned(), move || {
thread::Builder::new().name("Application heartbeat profiler".to_owned()).spawn(move || {
let mut start_time = precise_time_ns();
let mut start_energy = read_energy_uj();
loop {
@ -272,7 +271,7 @@ impl Profiler {
start_time = end_time;
start_energy = end_energy;
}
});
}).expect("Thread spawning failed");
}
profiler_chan

Просмотреть файл

@ -20,7 +20,7 @@ log = "0.3.5"
plugins = {path = "../plugins"}
serde = "0.8"
serde_derive = "0.8"
servo_config = {path = "../config"}
signpost = {git = "https://github.com/pcwalton/signpost.git"}
time = "0.1.12"
util = {path = "../util"}

Просмотреть файл

@ -18,8 +18,8 @@ extern crate log;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate servo_config;
extern crate signpost;
extern crate util;
#[allow(unsafe_code)]
pub mod energy;

Просмотреть файл

@ -7,8 +7,8 @@ extern crate time as std_time;
use energy::read_energy_uj;
use ipc_channel::ipc::IpcSender;
use self::std_time::precise_time_ns;
use servo_config::opts;
use signpost;
use util::opts;
#[derive(PartialEq, Clone, PartialOrd, Eq, Ord, Debug, Deserialize, Serialize)]
pub struct TimerMetadata {

Просмотреть файл

@ -0,0 +1,14 @@
[package]
name = "servo_remutex"
version = "0.0.1"
authors = ["The Servo Project Developers"]
license = "MPL-2.0"
publish = false
[lib]
name = "servo_remutex"
path = "lib.rs"
[dependencies]
lazy_static = "0.2"
log = "0.3.5"

Просмотреть файл

@ -10,6 +10,12 @@
//! It provides the same interface as https://github.com/rust-lang/rust/blob/master/src/libstd/sys/common/remutex.rs
//! so if those types are ever exported, we should be able to replace this implemtation.
#![feature(nonzero)]
extern crate core;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate log;
use core::nonzero::NonZero;
use std::cell::{Cell, UnsafeCell};
use std::ops::Deref;

Просмотреть файл

@ -70,13 +70,14 @@ script_traits = {path = "../script_traits"}
selectors = "0.15"
serde = "0.8"
servo_atoms = {path = "../atoms"}
servo_config = {path = "../config", features = ["servo"] }
servo_geometry = {path = "../geometry" }
servo_url = {path = "../url", features = ["servo"] }
smallvec = "0.1"
style = {path = "../style"}
style_traits = {path = "../style_traits"}
time = "0.1.12"
url = {version = "1.2", features = ["heap_size", "query_encoding"]}
util = {path = "../util"}
uuid = {version = "0.3.1", features = ["v4"]}
websocket = "0.17"
xml5ever = {version = "0.2", features = ["unstable"]}

Просмотреть файл

@ -5603,7 +5603,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'dom::globalscope::GlobalScope',
'mem::heap_size_of_raw_self_and_children',
'libc',
'util::prefs::PREFS',
'servo_config::prefs::PREFS',
'std::borrow::ToOwned',
'std::cmp',
'std::mem',

Просмотреть файл

@ -56,8 +56,8 @@ use js::jsval::{ObjectValue, StringValue};
use js::rust::{ToString, get_object_class, is_dom_class, is_dom_object, maybe_wrap_value};
use libc;
use num_traits::Float;
use servo_config::opts;
use std::{char, mem, ptr, slice};
use util::opts;
/// A trait to check whether a given `JSObject` implements an IDL interface.
pub trait IDLInterface {

Просмотреть файл

@ -5,7 +5,7 @@
//! Machinery to conditionally expose things.
use js::jsapi::{HandleObject, JSContext};
use util::prefs::PREFS;
use servo_config::prefs::PREFS;
/// A container with a condition.
pub struct Guard<T: Clone + Copy> {

Просмотреть файл

@ -19,8 +19,8 @@ use dom::element::Element;
use dom::node::{Node, NodeDamage};
use dom::processinginstruction::ProcessingInstruction;
use dom::text::Text;
use servo_config::opts;
use std::cell::Ref;
use util::opts;
// https://dom.spec.whatwg.org/#characterdata
#[dom_struct]

Просмотреть файл

@ -78,7 +78,7 @@ use dom::htmlunknownelement::HTMLUnknownElement;
use dom::htmlvideoelement::HTMLVideoElement;
use dom::svgsvgelement::SVGSVGElement;
use html5ever_atoms::{Prefix, QualName};
use util::prefs::PREFS;
use servo_config::prefs::PREFS;
fn create_svg_element(name: QualName,
prefix: Option<DOMString>,

Просмотреть файл

@ -38,8 +38,8 @@ use std::mem::replace;
use std::sync::{Arc, Mutex};
use std::sync::atomic::AtomicBool;
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
use std::thread;
use style::thread_state;
use util::thread::spawn_named;
/// Set the `worker` field of a related DedicatedWorkerGlobalScope object to a particular
/// value for the duration of this object's lifetime. This ensures that the related Worker
@ -160,7 +160,7 @@ impl DedicatedWorkerGlobalScope {
let name = format!("WebWorker for {}", serialized_worker_url);
let top_level_frame_id = FrameId::installed();
spawn_named(name, move || {
thread::Builder::new().name(name).spawn(move || {
thread_state::initialize(thread_state::SCRIPT | thread_state::IN_WORKER);
if let Some(top_level_frame_id) = top_level_frame_id {
@ -243,7 +243,7 @@ impl DedicatedWorkerGlobalScope {
global.handle_event(event);
}
}, reporter_name, parent_sender, CommonScriptMsg::CollectReports);
});
}).expect("Thread spawning failed");
}
pub fn script_chan(&self) -> Box<ScriptChan + Send> {

Просмотреть файл

@ -113,6 +113,7 @@ use script_traits::{ScriptMsg as ConstellationMsg, TouchpadPressurePhase};
use script_traits::{TouchEventType, TouchId};
use script_traits::UntrustedNodeAddress;
use servo_atoms::Atom;
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
@ -133,7 +134,6 @@ use style::str::{split_html_space_chars, str_join};
use style::stylesheets::Stylesheet;
use time;
use url::percent_encoding::percent_decode;
use util::prefs::PREFS;
pub enum TouchEventResult {
Processed(bool),

Просмотреть файл

@ -34,9 +34,9 @@ use servo_atoms::Atom;
use std::cell::Cell;
use std::ptr;
use std::sync::Arc;
use std::thread;
use task_source::TaskSource;
use task_source::file_reading::{FileReadingTaskSource, FileReadingRunnable, FileReadingTask};
use util::thread::spawn_named;
#[derive(PartialEq, Clone, Copy, JSTraceable, HeapSizeOf)]
pub enum FileReaderFunction {
@ -401,9 +401,10 @@ impl FileReader {
let wrapper = global.get_runnable_wrapper();
let task_source = global.file_reading_task_source();
spawn_named("file reader async operation".to_owned(), move || {
thread::Builder::new().name("file reader async operation".to_owned()).spawn(move || {
perform_annotated_read_operation(gen_id, load_data, blob_contents, fr, task_source, wrapper)
});
}).expect("Thread spawning failed");
Ok(())
}

Просмотреть файл

@ -28,10 +28,10 @@ use html5ever_atoms::LocalName;
use net_traits::ReferrerPolicy;
use num_traits::ToPrimitive;
use script_traits::MozBrowserEvent;
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::default::Default;
use style::attr::AttrValue;
use util::prefs::PREFS;
#[dom_struct]
pub struct HTMLAnchorElement {

Просмотреть файл

@ -48,13 +48,13 @@ use script_traits::{IFrameLoadInfo, IFrameLoadInfoWithData, LoadData};
use script_traits::{MozBrowserEvent, NewLayoutInfo, ScriptMsg as ConstellationMsg};
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
use servo_atoms::Atom;
use servo_config::prefs::PREFS;
use servo_config::servo_version;
use servo_url::ServoUrl;
use std::cell::Cell;
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
use style::context::ReflowGoal;
use task_source::TaskSource;
use util::prefs::PREFS;
use util::servo_version;
bitflags! {
#[derive(JSTraceable, HeapSizeOf)]

Просмотреть файл

@ -19,6 +19,7 @@ use dom::node::{Node, UnbindContext, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;
use html5ever_atoms::LocalName;
use parking_lot::RwLock;
use servo_config::prefs::PREFS;
use std::ascii::AsciiExt;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
@ -89,7 +90,7 @@ impl HTMLMetaElement {
}
fn apply_viewport(&self) {
if !::util::prefs::PREFS.get("layout.viewport.enabled").as_boolean().unwrap_or(false) {
if !PREFS.get("layout.viewport.enabled").as_boolean().unwrap_or(false) {
return;
}
let element = self.upcast::<Element>();

Просмотреть файл

@ -14,9 +14,9 @@ use dom::event::{Event, EventBubbles, EventCancelable};
use dom::eventtarget::EventTarget;
use dom::uievent::UIEvent;
use dom::window::Window;
use servo_config::prefs::PREFS;
use std::cell::Cell;
use std::default::Default;
use util::prefs::PREFS;
#[dom_struct]
pub struct MouseEvent {

Просмотреть файл

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::str::DOMString;
use util::opts;
use servo_config::opts;
pub fn Product() -> DOMString {
DOMString::from("Gecko")

Просмотреть файл

@ -28,13 +28,12 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as Req
use rand::random;
use script_runtime::{CommonScriptMsg, StackRootTLS, get_reports, new_rt_and_cx, ScriptChan};
use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin};
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
use std::thread;
use std::time::Duration;
use style::thread_state::{self, IN_WORKER, SCRIPT};
use util::prefs::PREFS;
use util::thread::spawn_named;
/// Messages used to control service worker event loop
pub enum ServiceWorkerScriptMsg {
@ -151,7 +150,7 @@ impl ServiceWorkerGlobalScope {
.. } = scope_things;
let serialized_worker_url = script_url.to_string();
spawn_named(format!("ServiceWorker for {}", serialized_worker_url), move || {
thread::Builder::new().name(format!("ServiceWorker for {}", serialized_worker_url)).spawn(move || {
thread_state::initialize(SCRIPT | IN_WORKER);
let roots = RootCollection::new();
let _stack_roots_tls = StackRootTLS::new(&roots);
@ -202,11 +201,11 @@ impl ServiceWorkerGlobalScope {
scope.execute_script(DOMString::from(source));
// Service workers are time limited
spawn_named("SWTimeoutThread".to_owned(), move || {
thread::Builder::new().name("SWTimeoutThread".to_owned()).spawn(move || {
let sw_lifetime_timeout = PREFS.get("dom.serviceworker.timeout_seconds").as_u64().unwrap();
thread::sleep(Duration::new(sw_lifetime_timeout, 0));
let _ = timer_chan.send(());
});
}).expect("Thread spawning failed");
global.dispatch_activate();
let reporter_name = format!("service-worker-reporter-{}", random::<u64>());
@ -217,7 +216,7 @@ impl ServiceWorkerGlobalScope {
}
}
}, reporter_name, scope.script_chan(), CommonScriptMsg::CollectReports);
});
}).expect("Thread spawning failed");
}
fn handle_event(&self, event: MixedMessage) -> bool {

Просмотреть файл

@ -32,10 +32,10 @@ use network_listener::PreInvoke;
use profile_traits::time::{TimerMetadata, TimerMetadataFrameType};
use profile_traits::time::{TimerMetadataReflowType, ProfilerCategory, profile};
use script_thread::ScriptThread;
use servo_config::resource_files::read_resource_file;
use servo_url::ServoUrl;
use std::cell::Cell;
use std::mem;
use util::resource_files::read_resource_file;
mod html;
mod xml;

Просмотреть файл

@ -37,11 +37,11 @@ use js::jsapi::{HandleObject, HandleValue, JSContext, JSObject, JSAutoCompartmen
use js::jsapi::{JS_NewPlainObject, JS_NewUint8ClampedArray};
use js::jsval::{JSVal, NullValue};
use script_traits::MsDuration;
use servo_config::prefs::PREFS;
use std::borrow::ToOwned;
use std::ptr;
use std::rc::Rc;
use timers::OneshotTimerCallback;
use util::prefs::PREFS;
#[dom_struct]
pub struct TestBinding {

Просмотреть файл

@ -9,11 +9,11 @@ use dom::bindings::js::RootedReference;
use dom::bindings::str::DOMString;
use dom::htmlheadelement::HTMLHeadElement;
use dom::node::Node;
use servo_config::opts;
use servo_config::resource_files::resources_dir_path;
use std::borrow::ToOwned;
use std::fs::read_dir;
use std::path::PathBuf;
use util::opts;
use util::resource_files::resources_dir_path;
pub fn load_script(head: &HTMLHeadElement) {

Просмотреть файл

@ -77,6 +77,9 @@ use script_traits::{DocumentState, TimerEvent, TimerEventId};
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest, WindowSizeData, WindowSizeType};
use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use servo_atoms::Atom;
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_geometry::{f32_rect_to_au_rect, max_rect};
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
@ -106,9 +109,6 @@ use timers::{IsInterval, TimerCallback};
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
use tinyfiledialogs::{self, MessageBoxIcon};
use url::Position;
use util::geometry::{self, max_rect};
use util::opts;
use util::prefs::PREFS;
use webdriver_handlers::jsval_to_webdriver;
/// Current state of the window object
@ -1413,13 +1413,13 @@ impl Window {
}
pub fn set_page_clip_rect_with_new_viewport(&self, viewport: Rect<f32>) -> bool {
let rect = geometry::f32_rect_to_au_rect(viewport.clone());
let rect = f32_rect_to_au_rect(viewport.clone());
self.current_viewport.set(rect);
// We use a clipping rectangle that is five times the size of the of the viewport,
// so that we don't collect display list items for areas too far outside the viewport,
// but also don't trigger reflows every time the viewport changes.
static VIEWPORT_EXPANSION: f32 = 2.0; // 2 lengths on each side plus original length is 5 total.
let proposed_clip_rect = geometry::f32_rect_to_au_rect(
let proposed_clip_rect = f32_rect_to_au_rect(
viewport.inflate(viewport.size.width * VIEWPORT_EXPANSION,
viewport.size.height * VIEWPORT_EXPANSION));
let clip_rect = self.page_clip_rect.get();

Просмотреть файл

@ -53,6 +53,7 @@ use net_traits::request::{CredentialsMode, Destination, RequestInit, RequestMode
use net_traits::trim_http_whitespace;
use network_listener::{NetworkListener, PreInvoke};
use servo_atoms::Atom;
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
@ -64,7 +65,6 @@ use task_source::networking::NetworkingTaskSource;
use time;
use timers::{OneshotTimerCallback, OneshotTimerHandle};
use url::Position;
use util::prefs::PREFS;
#[derive(JSTraceable, PartialEq, Copy, Clone, HeapSizeOf)]
enum XMLHttpRequestState {

Просмотреть файл

@ -83,6 +83,8 @@ extern crate script_traits;
extern crate selectors;
extern crate serde;
#[macro_use] extern crate servo_atoms;
#[macro_use] extern crate servo_config;
extern crate servo_geometry;
extern crate servo_url;
extern crate smallvec;
#[macro_use]
@ -93,7 +95,6 @@ extern crate time;
extern crate tinyfiledialogs;
extern crate url;
#[macro_use]
extern crate util;
extern crate uuid;
extern crate webrender_traits;
extern crate websocket;

Просмотреть файл

@ -25,6 +25,8 @@ use js::rust::Runtime;
use msg::constellation_msg::PipelineId;
use profile_traits::mem::{Report, ReportKind, ReportsChan};
use script_thread::{Runnable, STACK_ROOTS, trace_thread};
use servo_config::opts;
use servo_config::prefs::PREFS;
use std::cell::Cell;
use std::io::{Write, stdout};
use std::marker::PhantomData;
@ -35,8 +37,6 @@ use std::ptr;
use std::rc::Rc;
use style::thread_state;
use time::{Tm, now};
use util::opts;
use util::prefs::PREFS;
/// Common messages used to control the event loops in both the script and the worker
pub enum CommonScriptMsg {

Просмотреть файл

@ -91,6 +91,7 @@ use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent,
use script_traits::CompositorEvent::{TouchEvent, TouchpadPressureEvent};
use script_traits::webdriver_msg::WebDriverScriptCommand;
use serviceworkerjob::{Job, JobQueue, AsyncJobHandler, FinishJobHandler, InvokeType, SettleType};
use servo_config::opts;
use servo_url::ServoUrl;
use std::cell::Cell;
use std::collections::{hash_map, HashMap, HashSet};
@ -101,6 +102,7 @@ use std::result::Result;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{Receiver, Select, Sender, channel};
use std::thread;
use style::context::ReflowGoal;
use style::dom::{TNode, UnsafeNode};
use style::thread_state;
@ -112,8 +114,6 @@ use task_source::networking::NetworkingTaskSource;
use task_source::user_interaction::{UserInteractionTask, UserInteractionTaskSource};
use time::Tm;
use url::Position;
use util::opts;
use util::thread;
use webdriver_handlers;
thread_local!(pub static STACK_ROOTS: Cell<Option<RootCollectionPtr>> = Cell::new(None));
@ -519,8 +519,7 @@ impl ScriptThreadFactory for ScriptThread {
let (sender, receiver) = channel();
let layout_chan = sender.clone();
thread::spawn_named(format!("ScriptThread {:?}", state.id),
move || {
thread::Builder::new().name(format!("ScriptThread {:?}", state.id)).spawn(move || {
thread_state::initialize(thread_state::SCRIPT);
PipelineNamespace::install(state.pipeline_namespace_id);
FrameId::install(state.top_level_frame_id);
@ -553,7 +552,7 @@ impl ScriptThreadFactory for ScriptThread {
// This must always be the very last operation performed before the thread completes
failsafe.neuter();
});
}).expect("Thread spawning failed");
(sender, receiver)
}

Просмотреть файл

@ -16,11 +16,11 @@ use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use net_traits::{CustomResponseMediator, CoreResourceMsg};
use script_traits::{ServiceWorkerMsg, ScopeThings, SWManagerMsg, SWManagerSenders, DOMMessage};
use servo_config::prefs::PREFS;
use servo_url::ServoUrl;
use std::collections::HashMap;
use std::sync::mpsc::{channel, Sender, Receiver, RecvError};
use util::prefs::PREFS;
use util::thread::spawn_named;
use std::thread;
enum Message {
FromResource(CustomResponseMediator),
@ -60,11 +60,11 @@ impl ServiceWorkerManager {
let resource_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(resource_port);
let _ = sw_senders.resource_sender.send(CoreResourceMsg::NetworkMediator(resource_chan));
let _ = sw_senders.swmanager_sender.send(SWManagerMsg::OwnSender(own_sender.clone()));
spawn_named("ServiceWorkerManager".to_owned(), move || {
thread::Builder::new().name("ServiceWorkerManager".to_owned()).spawn(move || {
ServiceWorkerManager::new(own_sender,
from_constellation,
resource_port).handle_message();
});
}).expect("Thread spawning failed");
}
pub fn get_matching_scope(&self, load_url: &ServoUrl) -> Option<ServoUrl> {

Просмотреть файл

@ -18,12 +18,12 @@ use js::jsapi::{HandleValue, Heap};
use js::jsval::{JSVal, UndefinedValue};
use script_traits::{MsDuration, precise_time_ms};
use script_traits::{TimerEvent, TimerEventId, TimerEventRequest, TimerSource};
use servo_config::prefs::PREFS;
use std::cell::Cell;
use std::cmp::{self, Ord, Ordering};
use std::collections::HashMap;
use std::default::Default;
use std::rc::Rc;
use util::prefs::PREFS;
#[derive(JSTraceable, PartialEq, Eq, Copy, Clone, HeapSizeOf, Hash, PartialOrd, Ord, Debug)]
pub struct OneshotTimerHandle(i32);

Просмотреть файл

@ -50,10 +50,10 @@ profile_traits = {path = "../profile_traits"}
script = {path = "../script"}
script_layout_interface = {path = "../script_layout_interface"}
script_traits = {path = "../script_traits"}
servo_config = {path = "../config"}
servo_url = {path = "../url"}
style = {path = "../style", features = ["servo"]}
url = "1.2"
util = {path = "../util"}
webdriver_server = {path = "../webdriver_server", optional = true}
[dependencies.webrender]

Просмотреть файл

@ -45,10 +45,9 @@ pub extern crate profile_traits;
pub extern crate script;
pub extern crate script_traits;
pub extern crate script_layout_interface;
pub extern crate servo_config;
pub extern crate servo_url;
pub extern crate style;
pub extern crate url;
pub extern crate util;
#[cfg(feature = "webdriver")]
extern crate webdriver_server;
@ -88,17 +87,19 @@ use profile::time as profile_time;
use profile_traits::mem;
use profile_traits::time;
use script_traits::{ConstellationMsg, SWManagerSenders, ScriptMsg};
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_config::resource_files::resources_dir_path;
use servo_url::ServoUrl;
use std::borrow::Cow;
use std::cmp::max;
use std::path::PathBuf;
use std::rc::Rc;
use std::sync::mpsc::Sender;
use util::opts;
use util::prefs::PREFS;
use util::resource_files::resources_dir_path;
pub use gleam::gl;
pub use servo_config as config;
pub use servo_url as url;
/// The in-process interface to Servo.
///

Просмотреть файл

@ -50,12 +50,12 @@ selectors = "0.15"
serde = {version = "0.8", optional = true}
serde_derive = {version = "0.8", optional = true}
servo_atoms = {path = "../atoms", optional = true}
servo_config = {path = "../config"}
smallvec = "0.1"
style_traits = {path = "../style_traits"}
servo_url = {path = "../url"}
time = "0.1"
unicode-segmentation = "0.1.2"
util = {path = "../util"}
plugins = {path = "../plugins", optional = true}
[dependencies.num_cpus]

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше