diff options
author | bors-servo <metajack+bors@gmail.com> | 2014-11-20 13:06:32 -0700 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2014-11-20 13:06:32 -0700 |
commit | 133b523d2b3a95796e66e77fe6962abf79c3a4c7 (patch) | |
tree | 06a7ad4cf71dd8136b0049c44baa0073f3e2301c | |
parent | 9a139dac342dc72ec853749ce263c4c69a8a2b5f (diff) | |
parent | c8da9e1a5471b2407502a152c625ab8b8fb0d1e8 (diff) | |
download | servo-133b523d2b3a95796e66e77fe6962abf79c3a4c7.tar.gz servo-133b523d2b3a95796e66e77fe6962abf79c3a4c7.zip |
auto merge of #4044 : zmike/servo/embedding-process, r=jdm
Fixes #4023
@SimonSapin @jdm
-rw-r--r-- | ports/cef/core.rs | 27 | ||||
-rw-r--r-- | ports/cef/lib.rs | 1 | ||||
-rw-r--r-- | ports/cef/string.rs | 58 | ||||
-rw-r--r-- | ports/cef/switches.rs | 56 |
4 files changed, 141 insertions, 1 deletions
diff --git a/ports/cef/core.rs b/ports/cef/core.rs index 69960b146bc..f566ee83c33 100644 --- a/ports/cef/core.rs +++ b/ports/cef/core.rs @@ -6,11 +6,14 @@ use command_line::command_line_init; use geom::size::TypedSize2D; use glfw_app; +use libc::funcs::c95::string::strlen; use libc::{c_int, c_void}; use native; use servo::Browser; use servo_util::opts; use servo_util::opts::OpenGL; +use std::slice; +use switches::{KPROCESSTYPE, KWAITFORDEBUGGER}; use types::{cef_app_t, cef_main_args_t, cef_settings_t}; #[no_mangle] @@ -84,9 +87,31 @@ pub extern "C" fn cef_quit_message_loop() { } #[no_mangle] -pub extern "C" fn cef_execute_process(_args: *const cef_main_args_t, +pub extern "C" fn cef_execute_process(args: *const cef_main_args_t, _app: *mut cef_app_t, _windows_sandbox_info: *mut c_void) -> c_int { + unsafe { + if args.is_null() { + println!("args must be passed"); + return -1; + } + for i in range(0u, (*args).argc as uint) { + let u = (*args).argv.offset(i as int) as *const u8; + slice::raw::buf_as_slice(u, strlen(u as *const i8) as uint, |s| { + if s.starts_with("--".as_bytes()) { + if s.slice_from(2) == KWAITFORDEBUGGER.as_bytes() { + //FIXME: this is NOT functionally equivalent to chromium! + + //this should be a pause() call with an installed signal + //handler callback, something which is impossible now in rust + } else if s.slice_from(2) == KPROCESSTYPE.as_bytes() { + //TODO: run other process now + } + } + }); + } + } + //process type not specified, must be browser process (NOOP) -1 } diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index cd96f974d6c..5391c571799 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -54,6 +54,7 @@ pub mod string; pub mod string_list; pub mod string_map; pub mod string_multimap; +pub mod switches; pub mod task; pub mod types; pub mod urlrequest; diff --git a/ports/cef/string.rs b/ports/cef/string.rs index 9f3baac8f10..ce31c4330eb 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -7,6 +7,7 @@ use eutil::slice_to_str; use libc::{size_t, c_int, c_ushort,c_void}; use libc::types::os::arch::c95::wchar_t; use mem::{new0,newarray0,delete,deletearray}; +use std::char; use std::mem; use std::ptr; use std::slice; @@ -222,3 +223,60 @@ pub extern "C" fn cef_string_wide_set(src: *const wchar_t, src_len: size_t, outp } return 1; } + +#[no_mangle] +pub extern "C" fn cef_string_wide_cmp(a: *const cef_string_wide_t, b: *const cef_string_wide_t) -> c_int { + unsafe { + slice::raw::buf_as_slice((*a).str as *const wchar_t, (*a).length as uint, |astr:&[wchar_t]| { + slice::raw::buf_as_slice((*b).str as *const wchar_t, (*b).length as uint, |bstr:&[wchar_t]| { + match astr.cmp(bstr) { + Less => -1, + Equal => 0, + Greater => 1 + } + }) + }) + } +} + +#[no_mangle] +pub extern "C" fn cef_string_utf8_to_wide(src: *const u8, src_len: size_t, output: *mut cef_string_wide_t) -> c_int { + if mem::size_of::<wchar_t>() == mem::size_of::<u16>() { + return cef_string_utf8_to_utf16(src, src_len, output as *mut cef_string_utf16_t); + } + slice_to_str(src, src_len as uint, |result| { + let conv = result.chars().map(|c| c as u32).collect::<Vec<u32>>(); + cef_string_wide_set(conv.as_ptr() as *const wchar_t, conv.len() as size_t, output, 1) + }) +} + +#[no_mangle] +pub extern "C" fn cef_string_wide_to_utf8(src: *const wchar_t, src_len: size_t, output: *mut cef_string_utf8_t) -> c_int { + if mem::size_of::<wchar_t>() == mem::size_of::<u16>() { + return cef_string_utf16_to_utf8(src as *const u16, src_len, output); + } + unsafe { + slice::raw::buf_as_slice(src, src_len as uint, |ustr| { + let conv = ustr.iter().map(|&c| char::from_u32(c as u32).unwrap_or('\uFFFD')).collect::<String>(); + cef_string_utf8_set(conv.as_bytes().as_ptr(), conv.len() as size_t, output, 1) + }) + } +} + +#[no_mangle] +pub extern "C" fn cef_string_ascii_to_utf16(src: *const u8, src_len: size_t, output: *mut cef_string_utf16_t) -> c_int { + slice_to_str(src, src_len as uint, |result| { + let conv = result.utf16_units().collect::<Vec<u16>>(); + cef_string_utf16_set(conv.as_ptr(), conv.len() as size_t, output, 1) + }) +} + +#[no_mangle] +pub extern "C" fn cef_string_ascii_to_wide(src: *const u8, src_len: size_t, output: *mut cef_string_wide_t) -> c_int { + unsafe { + slice::raw::buf_as_slice(src, src_len as uint, |ustr| { + let conv = ustr.iter().map(|&c| c as u8).collect::<Vec<u8>>(); + cef_string_wide_set(conv.as_ptr() as *const wchar_t, conv.len() as size_t, output, 1) + }) + } +} diff --git a/ports/cef/switches.rs b/ports/cef/switches.rs new file mode 100644 index 00000000000..0638397ae65 --- /dev/null +++ b/ports/cef/switches.rs @@ -0,0 +1,56 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ + +// values taken from chromium/base/base_switches.cc + +// Disables the crash reporting. +pub static KDISABLEBREAKPAD: &'static str = "disable-breakpad"; + +// Indicates that crash reporting should be enabled. On platforms where helper +// processes cannot access to files needed to make this decision, this flag is +// generated internally. +pub static KENABLECRASHREPORTER: &'static str = "enable-crash-reporter"; + +// Generates full memory crash dump. +pub static KFULLMEMORYCRASHREPORT: &'static str = "full-memory-crash-report"; + +// The value of this switch determines whether the process is started as a +// renderer or plugin host. If it's empty, it's the browser. +pub static KPROCESSTYPE: &'static str = "type"; + +// Suppresses all error dialogs when present. +pub static KNOERRDIALOGS: &'static str = "noerrdialogs"; + +// When running certain tests that spawn child processes, this switch indicates +// to the test framework that the current process is a child process. +pub static KTESTCHILDPROCESS: &'static str = "test-child-process"; + +// Gives the default maximal active V-logging level; 0 is the default. +// Normally positive values are used for V-logging levels. +pub static KV: &'static str = "v"; + +// Gives the per-module maximal V-logging levels to override the value +// given by --v. E.g. "my_module=2,foo*=3" would change the logging +// level for all code in source files "my_module.*" and "foo*.*" +// ("-inl" suffixes are also disregarded for this matching). +// +// Any pattern containing a forward or backward slash will be tested +// against the whole pathname and not just the module. E.g., +// "*/foo/bar/*=2" would change the logging level for all code in +// source files under a "foo/bar" directory. +pub static KVMODULE: &'static str = "vmodule"; + +// Will wait for 60 seconds for a debugger to come to attach to the process. +pub static KWAITFORDEBUGGER: &'static str = "wait-for-debugger"; + +// Sends a pretty-printed version of tracing info to the console. +pub static KTRACETOCONSOLE: &'static str = "trace-to-console"; + +// Configure whether chrome://profiler will contain timing information. This +// option is enabled by default. A value of "0" will disable profiler timing, +// while all other values will enable it. +pub static KPROFILERTIMING: &'static str = "profiler-timing"; +// Value of the --profiler-timing flag that will disable timing information for +// chrome://profiler. +pub static KPROFILERTIMINGDISABLEDVALUE: &'static str = "0"; |