aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/lib.rs
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2019-10-26 12:53:34 +0200
committerSimon Sapin <simon.sapin@exyr.org>2019-10-26 12:59:17 +0200
commit642b8b041567016c0ad3f6f4342c68a2fcd35daa (patch)
tree9411a86316d76f392fbea82ab19dd9bbce5a2c74 /components/script/lib.rs
parentc7c0bfdd8d99f3f4fb7d1577610562d69ed0109b (diff)
downloadservo-642b8b041567016c0ad3f6f4342c68a2fcd35daa.tar.gz
servo-642b8b041567016c0ad3f6f4342c68a2fcd35daa.zip
Move items at the root of the script crate to a module
Diffstat (limited to 'components/script/lib.rs')
-rw-r--r--components/script/lib.rs69
1 files changed, 3 insertions, 66 deletions
diff --git a/components/script/lib.rs b/components/script/lib.rs
index c87e705d1e9..0d85e377cf4 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -59,6 +59,7 @@ mod canvas_state;
mod compartments;
pub mod fetch;
mod image_listener;
+mod init;
mod layout_image;
mod mem;
mod microtask;
@@ -79,6 +80,8 @@ mod timers;
mod unpremultiplytable;
mod webdriver_handlers;
+pub use init::{init, init_service_workers};
+
/// A module with everything layout can use from script.
///
/// Try to keep this small!
@@ -98,69 +101,3 @@ pub mod layout_exports {
pub use crate::dom::shadowroot::{LayoutShadowRootHelpers, ShadowRoot};
pub use crate::dom::text::Text;
}
-
-use crate::dom::bindings::codegen::RegisterBindings;
-use crate::dom::bindings::proxyhandler;
-use crate::serviceworker_manager::ServiceWorkerManager;
-use script_traits::SWManagerSenders;
-
-#[cfg(target_os = "linux")]
-#[allow(unsafe_code)]
-fn perform_platform_specific_initialization() {
- // 4096 is default max on many linux systems
- const MAX_FILE_LIMIT: libc::rlim_t = 4096;
-
- // Bump up our number of file descriptors to save us from impending doom caused by an onslaught
- // of iframes.
- unsafe {
- let mut rlim = libc::rlimit {
- rlim_cur: 0,
- rlim_max: 0,
- };
- match libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) {
- 0 => {
- if rlim.rlim_cur >= MAX_FILE_LIMIT {
- // we have more than enough
- return;
- }
-
- rlim.rlim_cur = match rlim.rlim_max {
- libc::RLIM_INFINITY => MAX_FILE_LIMIT,
- _ => {
- if rlim.rlim_max < MAX_FILE_LIMIT {
- rlim.rlim_max
- } else {
- MAX_FILE_LIMIT
- }
- },
- };
- match libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) {
- 0 => (),
- _ => warn!("Failed to set file count limit"),
- };
- },
- _ => warn!("Failed to get file count limit"),
- };
- }
-}
-
-#[cfg(not(target_os = "linux"))]
-fn perform_platform_specific_initialization() {}
-
-pub fn init_service_workers(sw_senders: SWManagerSenders) {
- // Spawn the service worker manager passing the constellation sender
- ServiceWorkerManager::spawn_manager(sw_senders);
-}
-
-#[allow(unsafe_code)]
-pub fn init() {
- unsafe {
- proxyhandler::init();
-
- // Create the global vtables used by the (generated) DOM
- // bindings to implement JS proxies.
- RegisterBindings::RegisterProxyHandlers();
- }
-
- perform_platform_specific_initialization();
-}