mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #27438 - paulrouget:crashReporter, r=jdm
UWP Crash reporter This is supposed to address #27167 and #26523. Also fix #27435. These changes are still WIP as I found a few bugs, it needs more testing and the actual code to upload is not implemented yet. But I'd like to get an early feedback. First, panics are caught via `panic::set_hook` instead of `catch_unwind` allowing us to catch more panics. We also now report panics reported via the `Embedder:Panic` message. Once the panic is caught, if possible, we try to recover. I haven't found a way to recover when the panic is caught is a non-GL thread. We need a generic way to throw from the UWP code, and even trying to add a UnhandledEvent handler doesn't appear to work. Once a panic is caught (even if we can not recover) a crash-report file is created, including the backtrace, stdout, and the current url. If the app did not crash at that point, or after a restart if it did, we check if the crash report file is present, and if so, we present a panel to the user to allow them to upload the report. At that point the user can also add details to the report. <img width="1079" alt="Screen Shot 2020-07-29 at 12 35 44" src="https://user-images.githubusercontent.com/373579/88790406-6d777180-d198-11ea-9237-6f80dc9d0340.png">
This commit is contained in:
commit
52c90955dc
15 changed files with 388 additions and 279 deletions
|
@ -482,6 +482,9 @@ mod gen {
|
|||
max_length: i64,
|
||||
},
|
||||
shell: {
|
||||
crash_reporter: {
|
||||
enabled: bool,
|
||||
},
|
||||
homepage: String,
|
||||
keep_screen_on: {
|
||||
enabled: bool,
|
||||
|
|
|
@ -148,6 +148,8 @@ pub trait HostTrait {
|
|||
fn on_media_session_set_position_state(&self, duration: f64, position: f64, playback_rate: f64);
|
||||
/// Called when devtools server is started
|
||||
fn on_devtools_started(&self, port: Result<u16, ()>, token: String);
|
||||
/// Called when we get a panic message from constellation
|
||||
fn on_panic(&self, reason: String, backtrace: Option<String>);
|
||||
}
|
||||
|
||||
pub struct ServoGlue {
|
||||
|
@ -764,6 +766,9 @@ impl ServoGlue {
|
|||
.host_callbacks
|
||||
.on_devtools_started(port, token);
|
||||
},
|
||||
EmbedderMsg::Panic(reason, backtrace) => {
|
||||
self.callbacks.host_callbacks.on_panic(reason, backtrace);
|
||||
},
|
||||
EmbedderMsg::Status(..) |
|
||||
EmbedderMsg::SelectFiles(..) |
|
||||
EmbedderMsg::MoveTo(..) |
|
||||
|
@ -773,7 +778,6 @@ impl ServoGlue {
|
|||
EmbedderMsg::NewFavicon(..) |
|
||||
EmbedderMsg::HeadParsed |
|
||||
EmbedderMsg::SetFullscreenState(..) |
|
||||
EmbedderMsg::Panic(..) |
|
||||
EmbedderMsg::ReportProfile(..) => {},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ mod prefs;
|
|||
#[cfg(target_os = "windows")]
|
||||
mod vslogger;
|
||||
|
||||
use backtrace::Backtrace;
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
use env_logger;
|
||||
use keyboard_types::Key;
|
||||
|
@ -27,7 +26,6 @@ use std::ffi::{CStr, CString};
|
|||
#[cfg(target_os = "windows")]
|
||||
use std::mem;
|
||||
use std::os::raw::{c_char, c_uint, c_void};
|
||||
use std::panic::{self, UnwindSafe};
|
||||
use std::slice;
|
||||
use std::str::FromStr;
|
||||
use std::sync::{Mutex, RwLock};
|
||||
|
@ -51,22 +49,15 @@ pub extern "C" fn register_panic_handler(on_panic: extern "C" fn(*const c_char))
|
|||
*ON_PANIC.write().unwrap() = on_panic;
|
||||
}
|
||||
|
||||
/// Catch any panic function used by extern "C" functions.
|
||||
fn catch_any_panic<T, F: FnOnce() -> T + UnwindSafe>(function: F) -> T {
|
||||
match panic::catch_unwind(function) {
|
||||
Err(_) => {
|
||||
let thread = std::thread::current()
|
||||
.name()
|
||||
.map(|n| format!(" for thread \"{}\"", n))
|
||||
.unwrap_or("".to_owned());
|
||||
let message = format!("Stack trace{}\n{:?}", thread, Backtrace::new());
|
||||
let error = CString::new(message).expect("Can't create string");
|
||||
(ON_PANIC.read().unwrap())(error.as_ptr());
|
||||
// At that point the embedder is supposed to have panicked
|
||||
panic!("Uncaught Rust panic");
|
||||
},
|
||||
Ok(r) => r,
|
||||
}
|
||||
/// Report panic to embedder.
|
||||
fn report_panic(reason: &str, backtrace: Option<String>) {
|
||||
let message = match backtrace {
|
||||
Some(bt) => format!("Servo panic ({})\n{}", reason, bt),
|
||||
None => format!("Servo panic ({})", reason),
|
||||
};
|
||||
let error = CString::new(message).expect("Can't create string");
|
||||
(ON_PANIC.read().unwrap())(error.as_ptr());
|
||||
panic!("At that point, embedder should have thrown");
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
|
@ -396,6 +387,31 @@ unsafe fn init(
|
|||
wakeup: extern "C" fn(),
|
||||
callbacks: CHostCallbacks,
|
||||
) {
|
||||
// Catch any panics.
|
||||
std::panic::set_hook(Box::new(|info| {
|
||||
let msg = match info.payload().downcast_ref::<&'static str>() {
|
||||
Some(s) => *s,
|
||||
None => match info.payload().downcast_ref::<String>() {
|
||||
Some(s) => &**s,
|
||||
None => "Box<Any>",
|
||||
},
|
||||
};
|
||||
let current_thread = std::thread::current();
|
||||
let name = current_thread.name().unwrap_or("<unnamed>");
|
||||
let details = if let Some(location) = info.location() {
|
||||
format!(
|
||||
"{} (thread {}, at {}:{})",
|
||||
msg,
|
||||
name,
|
||||
location.file(),
|
||||
location.line()
|
||||
)
|
||||
} else {
|
||||
format!("{} (thread {})", msg, name)
|
||||
};
|
||||
report_panic("General panic handler", Some(details));
|
||||
}));
|
||||
|
||||
let args = if !opts.args.is_null() {
|
||||
let args = CStr::from_ptr(opts.args);
|
||||
args.to_str()
|
||||
|
@ -463,19 +479,17 @@ pub extern "C" fn init_with_egl(
|
|||
wakeup: extern "C" fn(),
|
||||
callbacks: CHostCallbacks,
|
||||
) {
|
||||
catch_any_panic(|| {
|
||||
let gl = gl_glue::egl::init().unwrap();
|
||||
unsafe {
|
||||
init(
|
||||
opts,
|
||||
gl.gl_wrapper,
|
||||
Some(gl.gl_context),
|
||||
Some(gl.display),
|
||||
wakeup,
|
||||
callbacks,
|
||||
)
|
||||
}
|
||||
});
|
||||
let gl = gl_glue::egl::init().unwrap();
|
||||
unsafe {
|
||||
init(
|
||||
opts,
|
||||
gl.gl_wrapper,
|
||||
Some(gl.gl_context),
|
||||
Some(gl.display),
|
||||
wakeup,
|
||||
callbacks,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
|
||||
|
@ -485,244 +499,186 @@ pub extern "C" fn init_with_gl(
|
|||
wakeup: extern "C" fn(),
|
||||
callbacks: CHostCallbacks,
|
||||
) {
|
||||
catch_any_panic(|| {
|
||||
let gl = gl_glue::gl::init().unwrap();
|
||||
unsafe { init(opts, gl, None, None, wakeup, callbacks) }
|
||||
});
|
||||
let gl = gl_glue::gl::init().unwrap();
|
||||
unsafe { init(opts, gl, None, None, wakeup, callbacks) }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn deinit() {
|
||||
catch_any_panic(|| {
|
||||
debug!("deinit");
|
||||
simpleservo::deinit();
|
||||
});
|
||||
debug!("deinit");
|
||||
simpleservo::deinit();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn request_shutdown() {
|
||||
catch_any_panic(|| {
|
||||
debug!("request_shutdown");
|
||||
call(|s| s.request_shutdown());
|
||||
});
|
||||
debug!("request_shutdown");
|
||||
call(|s| s.request_shutdown());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn set_batch_mode(batch: bool) {
|
||||
catch_any_panic(|| {
|
||||
debug!("set_batch_mode");
|
||||
call(|s| s.set_batch_mode(batch));
|
||||
});
|
||||
debug!("set_batch_mode");
|
||||
call(|s| s.set_batch_mode(batch));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn on_context_menu_closed(result: CContextMenuResult, item: u32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("on_context_menu_closed");
|
||||
call(|s| s.on_context_menu_closed(result.convert(item)));
|
||||
});
|
||||
debug!("on_context_menu_closed");
|
||||
call(|s| s.on_context_menu_closed(result.convert(item)));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn resize(width: i32, height: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("resize {}/{}", width, height);
|
||||
call(|s| {
|
||||
let coordinates = Coordinates::new(0, 0, width, height, width, height);
|
||||
s.resize(coordinates)
|
||||
});
|
||||
debug!("resize {}/{}", width, height);
|
||||
call(|s| {
|
||||
let coordinates = Coordinates::new(0, 0, width, height, width, height);
|
||||
s.resize(coordinates)
|
||||
});
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn perform_updates() {
|
||||
catch_any_panic(|| {
|
||||
debug!("perform_updates");
|
||||
// We might have allocated some memory to respond to a potential
|
||||
// request, from the embedder, for a copy of Servo's preferences.
|
||||
prefs::free_prefs();
|
||||
call(|s| s.perform_updates());
|
||||
});
|
||||
debug!("perform_updates");
|
||||
// We might have allocated some memory to respond to a potential
|
||||
// request, from the embedder, for a copy of Servo's preferences.
|
||||
prefs::free_prefs();
|
||||
call(|s| s.perform_updates());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn is_uri_valid(url: *const c_char) -> bool {
|
||||
catch_any_panic(|| {
|
||||
debug!("is_uri_valid");
|
||||
let url = unsafe { CStr::from_ptr(url) };
|
||||
let url = url.to_str().expect("Can't read string");
|
||||
simpleservo::is_uri_valid(url)
|
||||
})
|
||||
debug!("is_uri_valid");
|
||||
let url = unsafe { CStr::from_ptr(url) };
|
||||
let url = url.to_str().expect("Can't read string");
|
||||
simpleservo::is_uri_valid(url)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn load_uri(url: *const c_char) -> bool {
|
||||
catch_any_panic(|| {
|
||||
debug!("load_url");
|
||||
let url = unsafe { CStr::from_ptr(url) };
|
||||
let url = url.to_str().expect("Can't read string");
|
||||
call(|s| Ok(s.load_uri(url).is_ok()))
|
||||
})
|
||||
debug!("load_url");
|
||||
let url = unsafe { CStr::from_ptr(url) };
|
||||
let url = url.to_str().expect("Can't read string");
|
||||
call(|s| Ok(s.load_uri(url).is_ok()))
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn clear_cache() {
|
||||
catch_any_panic(|| {
|
||||
debug!("clear_cache");
|
||||
call(|s| s.clear_cache())
|
||||
});
|
||||
debug!("clear_cache");
|
||||
call(|s| s.clear_cache())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn reload() {
|
||||
catch_any_panic(|| {
|
||||
debug!("reload");
|
||||
call(|s| s.reload());
|
||||
});
|
||||
debug!("reload");
|
||||
call(|s| s.reload());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn stop() {
|
||||
catch_any_panic(|| {
|
||||
debug!("stop");
|
||||
call(|s| s.stop());
|
||||
});
|
||||
debug!("stop");
|
||||
call(|s| s.stop());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn refresh() {
|
||||
catch_any_panic(|| {
|
||||
debug!("refresh");
|
||||
call(|s| s.refresh());
|
||||
});
|
||||
debug!("refresh");
|
||||
call(|s| s.refresh());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn go_back() {
|
||||
catch_any_panic(|| {
|
||||
debug!("go_back");
|
||||
call(|s| s.go_back());
|
||||
});
|
||||
debug!("go_back");
|
||||
call(|s| s.go_back());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn go_forward() {
|
||||
catch_any_panic(|| {
|
||||
debug!("go_forward");
|
||||
call(|s| s.go_forward());
|
||||
});
|
||||
debug!("go_forward");
|
||||
call(|s| s.go_forward());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn scroll_start(dx: i32, dy: i32, x: i32, y: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("scroll_start");
|
||||
call(|s| s.scroll_start(dx as f32, dy as f32, x, y));
|
||||
})
|
||||
debug!("scroll_start");
|
||||
call(|s| s.scroll_start(dx as f32, dy as f32, x, y));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn scroll_end(dx: i32, dy: i32, x: i32, y: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("scroll_end");
|
||||
call(|s| s.scroll_end(dx as f32, dy as f32, x, y));
|
||||
});
|
||||
debug!("scroll_end");
|
||||
call(|s| s.scroll_end(dx as f32, dy as f32, x, y));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn scroll(dx: i32, dy: i32, x: i32, y: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("scroll");
|
||||
call(|s| s.scroll(dx as f32, dy as f32, x, y));
|
||||
});
|
||||
debug!("scroll");
|
||||
call(|s| s.scroll(dx as f32, dy as f32, x, y));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn touch_down(x: f32, y: f32, pointer_id: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("touch down");
|
||||
call(|s| s.touch_down(x, y, pointer_id));
|
||||
});
|
||||
debug!("touch down");
|
||||
call(|s| s.touch_down(x, y, pointer_id));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn touch_up(x: f32, y: f32, pointer_id: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("touch up");
|
||||
call(|s| s.touch_up(x, y, pointer_id));
|
||||
});
|
||||
debug!("touch up");
|
||||
call(|s| s.touch_up(x, y, pointer_id));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn touch_move(x: f32, y: f32, pointer_id: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("touch move");
|
||||
call(|s| s.touch_move(x, y, pointer_id));
|
||||
});
|
||||
debug!("touch move");
|
||||
call(|s| s.touch_move(x, y, pointer_id));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn touch_cancel(x: f32, y: f32, pointer_id: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("touch cancel");
|
||||
call(|s| s.touch_cancel(x, y, pointer_id));
|
||||
});
|
||||
debug!("touch cancel");
|
||||
call(|s| s.touch_cancel(x, y, pointer_id));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn pinchzoom_start(factor: f32, x: i32, y: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("pinchzoom_start");
|
||||
call(|s| s.pinchzoom_start(factor, x as u32, y as u32));
|
||||
});
|
||||
debug!("pinchzoom_start");
|
||||
call(|s| s.pinchzoom_start(factor, x as u32, y as u32));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn pinchzoom(factor: f32, x: i32, y: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("pinchzoom");
|
||||
call(|s| s.pinchzoom(factor, x as u32, y as u32));
|
||||
});
|
||||
debug!("pinchzoom");
|
||||
call(|s| s.pinchzoom(factor, x as u32, y as u32));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn pinchzoom_end(factor: f32, x: i32, y: i32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("pinchzoom_end");
|
||||
call(|s| s.pinchzoom_end(factor, x as u32, y as u32));
|
||||
});
|
||||
debug!("pinchzoom_end");
|
||||
call(|s| s.pinchzoom_end(factor, x as u32, y as u32));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mouse_move(x: f32, y: f32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("mouse_move");
|
||||
call(|s| s.mouse_move(x, y));
|
||||
});
|
||||
debug!("mouse_move");
|
||||
call(|s| s.mouse_move(x, y));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mouse_down(x: f32, y: f32, button: CMouseButton) {
|
||||
catch_any_panic(|| {
|
||||
debug!("mouse_down");
|
||||
call(|s| s.mouse_down(x, y, button.convert()));
|
||||
});
|
||||
debug!("mouse_down");
|
||||
call(|s| s.mouse_down(x, y, button.convert()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mouse_up(x: f32, y: f32, button: CMouseButton) {
|
||||
catch_any_panic(|| {
|
||||
debug!("mouse_up");
|
||||
call(|s| s.mouse_up(x, y, button.convert()));
|
||||
});
|
||||
debug!("mouse_up");
|
||||
call(|s| s.mouse_up(x, y, button.convert()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn click(x: f32, y: f32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("click");
|
||||
call(|s| s.click(x, y));
|
||||
});
|
||||
debug!("click");
|
||||
call(|s| s.click(x, y));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -738,46 +694,38 @@ pub extern "C" fn key_up(name: *const c_char) {
|
|||
}
|
||||
|
||||
fn key_event(name: *const c_char, up: bool) {
|
||||
catch_any_panic(|| {
|
||||
let name = unsafe { CStr::from_ptr(name) };
|
||||
let name = match name.to_str() {
|
||||
Ok(name) => name,
|
||||
Err(..) => {
|
||||
warn!("Couldn't not read str");
|
||||
return;
|
||||
},
|
||||
};
|
||||
let key = Key::from_str(&name);
|
||||
if let Ok(key) = key {
|
||||
call(|s| if up { s.key_up(key) } else { s.key_down(key) });
|
||||
} else {
|
||||
warn!("Received unknown keys");
|
||||
}
|
||||
});
|
||||
let name = unsafe { CStr::from_ptr(name) };
|
||||
let name = match name.to_str() {
|
||||
Ok(name) => name,
|
||||
Err(..) => {
|
||||
warn!("Couldn't not read str");
|
||||
return;
|
||||
},
|
||||
};
|
||||
let key = Key::from_str(&name);
|
||||
if let Ok(key) = key {
|
||||
call(|s| if up { s.key_up(key) } else { s.key_down(key) });
|
||||
} else {
|
||||
warn!("Received unknown keys");
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn media_session_action(action: CMediaSessionActionType) {
|
||||
catch_any_panic(|| {
|
||||
debug!("media_session_action");
|
||||
call(|s| s.media_session_action(action.convert()));
|
||||
});
|
||||
debug!("media_session_action");
|
||||
call(|s| s.media_session_action(action.convert()));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn change_visibility(visible: bool) {
|
||||
catch_any_panic(|| {
|
||||
debug!("change_visibility");
|
||||
call(|s| s.change_visibility(visible));
|
||||
});
|
||||
debug!("change_visibility");
|
||||
call(|s| s.change_visibility(visible));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ime_dismissed() {
|
||||
catch_any_panic(|| {
|
||||
debug!("ime_dismissed");
|
||||
call(|s| s.ime_dismissed());
|
||||
});
|
||||
debug!("ime_dismissed");
|
||||
call(|s| s.ime_dismissed());
|
||||
}
|
||||
|
||||
pub struct WakeupCallback(extern "C" fn());
|
||||
|
@ -952,6 +900,10 @@ impl HostTrait for HostCallbacks {
|
|||
Some(contents_str.to_owned())
|
||||
}
|
||||
|
||||
fn on_panic(&self, reason: String, details: Option<String>) {
|
||||
report_panic(&reason, details);
|
||||
}
|
||||
|
||||
fn on_devtools_started(&self, port: Result<u16, ()>, token: String) {
|
||||
let token = CString::new(token).expect("Can't create string");
|
||||
match port {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
//! retrieve an array (CPREFS) of struct of pointers (CPrefs) to the C-compatible preferences
|
||||
//! (LocalCPref).
|
||||
|
||||
use crate::catch_any_panic;
|
||||
use crate::simpleservo::{self, PrefValue};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
|
@ -19,7 +18,7 @@ thread_local! {
|
|||
// The CPREFS are structs holding pointers to values held alive by LOCALCPREFS.
|
||||
// This is emptied in free_prefs the next time perform_updates is called.
|
||||
static CPREFS: RefCell<Vec<CPref>> = RefCell::new(Vec::new());
|
||||
static LOCALCPREFS: RefCell<BTreeMap<String, LocalCPref>> = RefCell::new(BTreeMap::new());
|
||||
static LOCALCPREFS: RefCell<BTreeMap<String, Box<LocalCPref>>> = RefCell::new(BTreeMap::new());
|
||||
}
|
||||
|
||||
struct LocalCPref {
|
||||
|
@ -71,7 +70,7 @@ pub struct CPref {
|
|||
}
|
||||
|
||||
impl CPref {
|
||||
fn new(local: &LocalCPref) -> CPref {
|
||||
fn new(local: &Box<LocalCPref>) -> CPref {
|
||||
let (pref_type, value) = match &local.value {
|
||||
LocalCPrefValue::Float(v) => (CPrefType::Float, v as *const f64 as *const c_void),
|
||||
LocalCPrefValue::Int(v) => (CPrefType::Int, v as *const i64 as *const c_void),
|
||||
|
@ -136,49 +135,41 @@ pub extern "C" fn get_pref_as_bool(ptr: *const c_void) -> *const bool {
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn reset_all_prefs() {
|
||||
catch_any_panic(|| {
|
||||
debug!("reset_all_prefs");
|
||||
simpleservo::reset_all_prefs()
|
||||
})
|
||||
debug!("reset_all_prefs");
|
||||
simpleservo::reset_all_prefs()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn reset_pref(key: *const c_char) -> bool {
|
||||
catch_any_panic(|| {
|
||||
debug!("reset_pref");
|
||||
let key = unsafe { CStr::from_ptr(key) };
|
||||
let key = key.to_str().expect("Can't read string");
|
||||
simpleservo::reset_pref(key)
|
||||
})
|
||||
debug!("reset_pref");
|
||||
let key = unsafe { CStr::from_ptr(key) };
|
||||
let key = key.to_str().expect("Can't read string");
|
||||
simpleservo::reset_pref(key)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn get_pref(key: *const c_char) -> CPref {
|
||||
catch_any_panic(|| {
|
||||
debug!("get_pref");
|
||||
LOCALCPREFS.with(|localmap| {
|
||||
let key = unsafe { CStr::from_ptr(key) };
|
||||
let key = key.to_str().expect("Can't read string");
|
||||
let (value, is_default) = simpleservo::get_pref(key);
|
||||
let local = LocalCPref {
|
||||
key: CString::new(key).unwrap(),
|
||||
value: LocalCPrefValue::new(&value),
|
||||
is_default: is_default,
|
||||
};
|
||||
let cpref = CPref::new(&local);
|
||||
localmap.borrow_mut().insert(key.to_string(), local);
|
||||
cpref
|
||||
})
|
||||
debug!("get_pref");
|
||||
LOCALCPREFS.with(|localmap| {
|
||||
let key = unsafe { CStr::from_ptr(key) };
|
||||
let key = key.to_str().expect("Can't read string");
|
||||
let (value, is_default) = simpleservo::get_pref(key);
|
||||
let local = Box::new(LocalCPref {
|
||||
key: CString::new(key).unwrap(),
|
||||
value: LocalCPrefValue::new(&value),
|
||||
is_default: is_default,
|
||||
});
|
||||
let cpref = CPref::new(&local);
|
||||
localmap.borrow_mut().insert(key.to_string(), local);
|
||||
cpref
|
||||
})
|
||||
}
|
||||
|
||||
fn set_pref(key: *const c_char, value: PrefValue) -> bool {
|
||||
catch_any_panic(|| {
|
||||
debug!("set_pref");
|
||||
let key = unsafe { CStr::from_ptr(key) };
|
||||
let key = key.to_str().expect("Can't read string");
|
||||
simpleservo::set_pref(key, value).is_ok()
|
||||
})
|
||||
debug!("set_pref");
|
||||
let key = unsafe { CStr::from_ptr(key) };
|
||||
let key = key.to_str().expect("Can't read string");
|
||||
simpleservo::set_pref(key, value).is_ok()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -206,33 +197,31 @@ pub extern "C" fn set_str_pref(key: *const c_char, value: *const c_char) -> bool
|
|||
#[no_mangle]
|
||||
pub extern "C" fn get_prefs() -> CPrefList {
|
||||
// Called from any thread
|
||||
catch_any_panic(|| {
|
||||
debug!("get_prefs");
|
||||
let map = simpleservo::get_prefs();
|
||||
let local: BTreeMap<String, LocalCPref> = map
|
||||
.into_iter()
|
||||
.map(|(key, (value, is_default))| {
|
||||
let l = LocalCPref {
|
||||
key: CString::new(key.clone()).unwrap(),
|
||||
value: LocalCPrefValue::new(&value),
|
||||
is_default: is_default,
|
||||
};
|
||||
(key, l)
|
||||
})
|
||||
.collect();
|
||||
debug!("get_prefs");
|
||||
let map = simpleservo::get_prefs();
|
||||
let local: BTreeMap<String, Box<LocalCPref>> = map
|
||||
.into_iter()
|
||||
.map(|(key, (value, is_default))| {
|
||||
let l = Box::new(LocalCPref {
|
||||
key: CString::new(key.clone()).unwrap(),
|
||||
value: LocalCPrefValue::new(&value),
|
||||
is_default: is_default,
|
||||
});
|
||||
(key, l)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let ptrs: Vec<CPref> = local.iter().map(|(_, local)| CPref::new(&local)).collect();
|
||||
let ptrs: Vec<CPref> = local.iter().map(|(_, local)| CPref::new(&local)).collect();
|
||||
|
||||
let list = CPrefList {
|
||||
len: ptrs.len(),
|
||||
list: ptrs.as_ptr(),
|
||||
};
|
||||
let list = CPrefList {
|
||||
len: ptrs.len(),
|
||||
list: ptrs.as_ptr(),
|
||||
};
|
||||
|
||||
LOCALCPREFS.with(|p| *p.borrow_mut() = local);
|
||||
CPREFS.with(|p| *p.borrow_mut() = ptrs);
|
||||
LOCALCPREFS.with(|p| *p.borrow_mut() = local);
|
||||
CPREFS.with(|p| *p.borrow_mut() = ptrs);
|
||||
|
||||
list
|
||||
})
|
||||
list
|
||||
}
|
||||
|
||||
pub(crate) fn free_prefs() {
|
||||
|
|
|
@ -111,6 +111,7 @@
|
|||
"network.http-cache.disabled": false,
|
||||
"network.mime.sniff": false,
|
||||
"session-history.max-length": 20,
|
||||
"shell.crash_reporter.enabled": false,
|
||||
"shell.homepage": "https://servo.org",
|
||||
"shell.keep_screen_on.enabled": false,
|
||||
"shell.native-orientation": "both",
|
||||
|
|
|
@ -19,6 +19,7 @@ using namespace winrt::Windows::ApplicationModel::Resources;
|
|||
using namespace winrt::Windows::UI::Notifications;
|
||||
using namespace winrt::Windows::Data::Json;
|
||||
using namespace winrt::Windows::Data::Xml::Dom;
|
||||
using namespace winrt::Windows::Storage;
|
||||
using namespace winrt::servo;
|
||||
|
||||
namespace winrt::ServoApp::implementation {
|
||||
|
@ -37,15 +38,19 @@ void BrowserPage::BindServoEvents() {
|
|||
backButton().IsEnabled(back);
|
||||
forwardButton().IsEnabled(forward);
|
||||
});
|
||||
servoView().OnServoPanic([=](const auto &, hstring /*message*/) {
|
||||
mPanicking = true;
|
||||
CheckCrashReport();
|
||||
});
|
||||
servoView().OnLoadStarted([=] {
|
||||
urlbarLoadingIndicator().IsActive(true);
|
||||
transientLoadingIndicator().IsIndeterminate(true);
|
||||
|
||||
reloadButton().IsEnabled(false);
|
||||
reloadButton().Visibility(Visibility::Collapsed);
|
||||
stopButton().IsEnabled(true);
|
||||
stopButton().Visibility(Visibility::Visible);
|
||||
devtoolsButton().IsEnabled(true);
|
||||
CheckCrashReport();
|
||||
});
|
||||
servoView().OnLoadEnded([=] {
|
||||
urlbarLoadingIndicator().IsActive(false);
|
||||
|
@ -297,24 +302,59 @@ void BrowserPage::OnDevtoolsMessage(DevtoolsMessageLevel level, hstring source,
|
|||
});
|
||||
}
|
||||
|
||||
void BrowserPage::CheckCrashReport() {
|
||||
Concurrency::create_task([=] {
|
||||
auto pref = servo::Servo::GetPref(L"shell.crash_reporter.enabled");
|
||||
bool reporter_enabled = unbox_value<bool>(std::get<1>(pref));
|
||||
auto storageFolder = ApplicationData::Current().LocalFolder();
|
||||
bool file_exist =
|
||||
storageFolder.TryGetItemAsync(L"crash-report.txt").get() != nullptr;
|
||||
if (reporter_enabled && file_exist) {
|
||||
auto crash_file = storageFolder.GetFileAsync(L"crash-report.txt").get();
|
||||
auto content = FileIO::ReadTextAsync(crash_file).get();
|
||||
Dispatcher().RunAsync(CoreDispatcherPriority::High, [=] {
|
||||
auto resourceLoader = ResourceLoader::GetForCurrentView();
|
||||
auto message = resourceLoader.GetString(mPanicking ? L"crash/Happening"
|
||||
: L"crash/Happened");
|
||||
crashTabMessage().Text(message);
|
||||
crashReport().Text(content);
|
||||
crashTab().Visibility(Visibility::Visible);
|
||||
crashTab().IsSelected(true);
|
||||
ShowToolbox();
|
||||
});
|
||||
} else {
|
||||
Dispatcher().RunAsync(CoreDispatcherPriority::High, [=] {
|
||||
crashTab().Visibility(Visibility::Collapsed);
|
||||
devtoolsTabConsole().IsSelected(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void BrowserPage::OnDismissCrashReport(IInspectable const &,
|
||||
RoutedEventArgs const &) {
|
||||
Concurrency::create_task([=] {
|
||||
auto storageFolder = ApplicationData::Current().LocalFolder();
|
||||
auto crash_file = storageFolder.GetFileAsync(L"crash-report.txt").get();
|
||||
crash_file.DeleteAsync().get();
|
||||
});
|
||||
HideToolbox();
|
||||
}
|
||||
|
||||
void BrowserPage::OnSubmitCrashReport(IInspectable const &,
|
||||
RoutedEventArgs const &) {
|
||||
// FIXME
|
||||
}
|
||||
|
||||
void BrowserPage::OnDevtoolsDetached() {}
|
||||
|
||||
void BrowserPage::OnDevtoolsButtonClicked(IInspectable const &,
|
||||
RoutedEventArgs const &) {
|
||||
void BrowserPage::ShowToolbox() {
|
||||
if (toolbox().Visibility() == Visibility::Visible) {
|
||||
prefList().Children().Clear();
|
||||
toolbox().Visibility(Visibility::Collapsed);
|
||||
ClearConsole();
|
||||
if (mDevtoolsClient != nullptr) {
|
||||
mDevtoolsClient->Stop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
toolbox().Visibility(Visibility::Visible);
|
||||
|
||||
CheckCrashReport();
|
||||
BuildPrefList();
|
||||
|
||||
auto resourceLoader = ResourceLoader::GetForCurrentView();
|
||||
if (mDevtoolsStatus == DevtoolsStatus::Running) {
|
||||
hstring port = to_hstring(mDevtoolsPort);
|
||||
|
@ -337,6 +377,24 @@ void BrowserPage::OnDevtoolsButtonClicked(IInspectable const &,
|
|||
}
|
||||
}
|
||||
|
||||
void BrowserPage::HideToolbox() {
|
||||
prefList().Children().Clear();
|
||||
toolbox().Visibility(Visibility::Collapsed);
|
||||
ClearConsole();
|
||||
if (mDevtoolsClient != nullptr) {
|
||||
mDevtoolsClient->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserPage::OnDevtoolsButtonClicked(IInspectable const &,
|
||||
RoutedEventArgs const &) {
|
||||
if (toolbox().Visibility() == Visibility::Visible) {
|
||||
HideToolbox();
|
||||
} else {
|
||||
ShowToolbox();
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserPage::OnJSInputEdited(IInspectable const &,
|
||||
Input::KeyRoutedEventArgs const &e) {
|
||||
if (e.Key() == Windows::System::VirtualKey::Enter) {
|
||||
|
|
|
@ -41,6 +41,8 @@ public:
|
|||
void Shutdown();
|
||||
void LoadFXRURI(Uri uri);
|
||||
void SetArgs(hstring);
|
||||
void OnDismissCrashReport(IInspectable const &, RoutedEventArgs const &);
|
||||
void OnSubmitCrashReport(IInspectable const &, RoutedEventArgs const &);
|
||||
void OnMediaControlsPlayClicked(IInspectable const &,
|
||||
RoutedEventArgs const &);
|
||||
void OnMediaControlsPauseClicked(IInspectable const &,
|
||||
|
@ -55,11 +57,15 @@ public:
|
|||
private:
|
||||
void SetTransientMode(bool);
|
||||
void UpdatePref(ServoApp::Pref, Controls::Control);
|
||||
void CheckCrashReport();
|
||||
void BindServoEvents();
|
||||
void BuildPrefList();
|
||||
void ShowToolbox();
|
||||
void HideToolbox();
|
||||
DevtoolsStatus mDevtoolsStatus = DevtoolsStatus::Stopped;
|
||||
unsigned int mDevtoolsPort = 0;
|
||||
hstring mDevtoolsToken;
|
||||
bool mPanicking = false;
|
||||
std::unique_ptr<servo::DevtoolsClient> mDevtoolsClient;
|
||||
Collections::IObservableVector<IInspectable> mLogs;
|
||||
};
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
</Button>
|
||||
</Grid>
|
||||
</muxc:TabView.TabStripFooter>
|
||||
<muxc:TabViewItem x:Uid="devtoolsTabConsole" IsClosable="False">
|
||||
<muxc:TabViewItem x:Uid="devtoolsTabConsole" x:Name="devtoolsTabConsole" IsClosable="False">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
|
@ -199,6 +199,20 @@
|
|||
</ScrollViewer>
|
||||
</Grid>
|
||||
</muxc:TabViewItem>
|
||||
<muxc:TabViewItem x:Uid="crashTab" x:Name="crashTab" IsClosable="False" Visibility="Collapsed">
|
||||
<Grid VerticalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Padding="4" Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" x:Name="crashTabMessage"></TextBlock>
|
||||
<Button IsTabStop="true" x:Uid="SubmitCrashReportButton" Margin="4" Click="OnSubmitCrashReport"/>
|
||||
<Button IsTabStop="true" x:Uid="DismissCrashReportButton" Margin="4" Click="OnDismissCrashReport"/>
|
||||
</StackPanel>
|
||||
<TextBox Grid.Row="1" TextWrapping="Wrap" IsTabStop="true" x:Name="crashReport" AcceptsReturn="True" IsSpellCheckEnabled="False" Margin="3"/>
|
||||
</Grid>
|
||||
</muxc:TabViewItem>
|
||||
</muxc:TabView>
|
||||
<ProgressBar x:Name="transientLoadingIndicator" Visibility="Collapsed" Grid.Row="3"/>
|
||||
<CommandBar Grid.Row="4" x:Name="mediaControls" Visibility="Collapsed">
|
||||
|
|
|
@ -79,7 +79,7 @@ IAsyncAction DevtoolsClient::Loop() {
|
|||
} catch (...) {
|
||||
throw hresult_error(E_FAIL, L"Can't parse message header:" + c);
|
||||
}
|
||||
if (len >= 10000) {
|
||||
if (len >= 100000) {
|
||||
throw hresult_error(E_FAIL, L"Message length too long");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,10 @@ void on_title_changed(const char *title) {
|
|||
sServo->Delegate().OnServoTitleChanged(char2hstring(title));
|
||||
}
|
||||
|
||||
void on_url_changed(const char *url) {
|
||||
sServo->Delegate().OnServoURLChanged(char2hstring(url));
|
||||
void on_url_changed(const char *curl) {
|
||||
auto url = char2hstring(curl);
|
||||
sServo->CurrentUrl(url);
|
||||
sServo->Delegate().OnServoURLChanged(url);
|
||||
}
|
||||
|
||||
void wakeup() { sServo->Delegate().WakeUp(); }
|
||||
|
@ -35,12 +37,46 @@ void on_animating_changed(bool aAnimating) {
|
|||
sServo->Delegate().OnServoAnimatingChanged(aAnimating);
|
||||
}
|
||||
|
||||
void on_panic(const char *backtrace) {
|
||||
void on_panic(const char *cbacktrace) {
|
||||
|
||||
if (sLogHandle != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(sLogHandle);
|
||||
sLogHandle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
throw hresult_error(E_FAIL, char2hstring(backtrace));
|
||||
|
||||
auto backtrace = char2hstring(cbacktrace);
|
||||
|
||||
try {
|
||||
// Making all sync operations sync, as we are crashing.
|
||||
auto storageFolder = ApplicationData::Current().LocalFolder();
|
||||
auto stdout_txt = storageFolder.GetFileAsync(L"stdout.txt").get();
|
||||
auto crash_txt =
|
||||
storageFolder
|
||||
.CreateFileAsync(L"crash-report.txt",
|
||||
CreationCollisionOption::ReplaceExisting)
|
||||
.get();
|
||||
auto out = FileIO::ReadTextAsync(stdout_txt).get();
|
||||
FileIO::WriteTextAsync(crash_txt, L"--- CUSTOM MESSAGE ---\r\n").get();
|
||||
FileIO::AppendTextAsync(crash_txt,
|
||||
L"Feel free to add details here before reporting")
|
||||
.get();
|
||||
FileIO::AppendTextAsync(
|
||||
crash_txt, L"\r\n--- CURRENT URL (remove if sensitive) ---\r\n")
|
||||
.get();
|
||||
FileIO::AppendTextAsync(crash_txt, sServo->CurrentUrl()).get();
|
||||
FileIO::AppendTextAsync(crash_txt, L"\r\n--- BACKTRACE ---\r\n").get();
|
||||
FileIO::AppendTextAsync(crash_txt, backtrace).get();
|
||||
FileIO::AppendTextAsync(crash_txt, L"\r\n--- STDOUT ---\r\n").get();
|
||||
FileIO::AppendTextAsync(crash_txt, out).get();
|
||||
FileIO::AppendTextAsync(crash_txt, L"\r\n").get();
|
||||
} catch (...) {
|
||||
log(L"Failed to log panic to crash report");
|
||||
}
|
||||
|
||||
// If this is happening in the GL thread, the app can continue running.
|
||||
// So let's show the crash report:
|
||||
sServo->Delegate().OnServoPanic(backtrace);
|
||||
throw hresult_error(E_FAIL, backtrace);
|
||||
}
|
||||
|
||||
void on_ime_show(const char *text, int32_t x, int32_t y, int32_t width,
|
||||
|
@ -371,9 +407,7 @@ std::vector<Servo::PrefTuple> Servo::GetPrefs() {
|
|||
return {};
|
||||
}
|
||||
auto prefs = capi::get_prefs();
|
||||
std::vector<
|
||||
std::tuple<hstring, winrt::Windows::Foundation::IInspectable, bool>>
|
||||
vec;
|
||||
std::vector<PrefTuple> vec;
|
||||
for (auto i = 0; i < prefs.len; i++) {
|
||||
auto pref = WrapPref(prefs.list[i]);
|
||||
vec.push_back(pref);
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
float, ServoDelegate &, bool);
|
||||
~Servo();
|
||||
ServoDelegate &Delegate() { return mDelegate; }
|
||||
hstring CurrentUrl() { return mUrl; }
|
||||
void CurrentUrl(hstring url) { mUrl = url; }
|
||||
|
||||
typedef std::tuple<hstring, winrt::Windows::Foundation::IInspectable, bool>
|
||||
PrefTuple;
|
||||
|
@ -96,6 +98,7 @@ public:
|
|||
|
||||
private:
|
||||
ServoDelegate &mDelegate;
|
||||
hstring mUrl;
|
||||
GLsizei mWindowWidth;
|
||||
GLsizei mWindowHeight;
|
||||
static void SaveUserPref(PrefTuple);
|
||||
|
@ -115,6 +118,7 @@ public:
|
|||
virtual void OnServoURLChanged(hstring) = 0;
|
||||
virtual bool OnServoAllowNavigation(hstring) = 0;
|
||||
virtual void OnServoAnimatingChanged(bool) = 0;
|
||||
virtual void OnServoPanic(hstring) = 0;
|
||||
virtual void OnServoIMEShow(hstring text, int32_t x, int32_t y, int32_t width,
|
||||
int32_t height) = 0;
|
||||
virtual void OnServoIMEHide() = 0;
|
||||
|
|
|
@ -418,34 +418,48 @@ void ServoControl::Loop() {
|
|||
|
||||
while (true) {
|
||||
EnterCriticalSection(&mGLLock);
|
||||
while (mTasks.size() == 0 && !mAnimating && mLooping) {
|
||||
SleepConditionVariableCS(&mGLCondVar, &mGLLock, INFINITE);
|
||||
}
|
||||
if (!mLooping) {
|
||||
try {
|
||||
while (mTasks.size() == 0 && !mAnimating && mLooping) {
|
||||
SleepConditionVariableCS(&mGLCondVar, &mGLLock, INFINITE);
|
||||
}
|
||||
if (!mLooping) {
|
||||
LeaveCriticalSection(&mGLLock);
|
||||
break;
|
||||
}
|
||||
for (auto &&task : mTasks) {
|
||||
task();
|
||||
}
|
||||
mTasks.clear();
|
||||
LeaveCriticalSection(&mGLLock);
|
||||
break;
|
||||
mServo->PerformUpdates();
|
||||
} catch (hresult_error const &e) {
|
||||
log(L"GL Thread exception: %s", e.message().c_str());
|
||||
throw e;
|
||||
} catch (...) {
|
||||
log(L"GL Thread exception");
|
||||
throw winrt::hresult_error(E_FAIL, L"GL Thread exception");
|
||||
}
|
||||
for (auto &&task : mTasks) {
|
||||
task();
|
||||
}
|
||||
mTasks.clear();
|
||||
LeaveCriticalSection(&mGLLock);
|
||||
mServo->PerformUpdates();
|
||||
}
|
||||
mServo->DeInit();
|
||||
}
|
||||
|
||||
void ServoControl::StartRenderLoop() {
|
||||
if (mLooping) {
|
||||
#if defined _DEBUG
|
||||
throw winrt::hresult_error(E_FAIL, L"GL thread is already looping");
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
mLooping = true;
|
||||
log(L"BrowserPage::StartRenderLoop(). UI thread: %i", GetCurrentThreadId());
|
||||
auto task = Concurrency::create_task([=] { Loop(); });
|
||||
auto task = Concurrency::create_task([=] {
|
||||
try {
|
||||
Loop();
|
||||
} catch (...) {
|
||||
// Do our best to recover. Exception has been logged at that point.
|
||||
mLooping = false;
|
||||
mLoopTask.reset();
|
||||
mServo.reset();
|
||||
LeaveCriticalSection(&mGLLock);
|
||||
}
|
||||
});
|
||||
mLoopTask = std::make_unique<Concurrency::task<void>>(task);
|
||||
}
|
||||
|
||||
|
@ -502,6 +516,10 @@ bool ServoControl::OnServoAllowNavigation(hstring uri) {
|
|||
return !mTransient;
|
||||
}
|
||||
|
||||
void ServoControl::OnServoPanic(hstring backtrace) {
|
||||
RunOnUIThread([=] { mOnServoPanic(*this, backtrace); });
|
||||
}
|
||||
|
||||
void ServoControl::OnServoAnimatingChanged(bool animating) {
|
||||
EnterCriticalSection(&mGLLock);
|
||||
mAnimating = animating;
|
||||
|
|
|
@ -100,6 +100,14 @@ struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate {
|
|||
mOnTitleChangedEvent.remove(token);
|
||||
}
|
||||
|
||||
winrt::event_token
|
||||
OnServoPanic(Windows::Foundation::EventHandler<hstring> const &handler) {
|
||||
return mOnServoPanic.add(handler);
|
||||
};
|
||||
void OnServoPanic(winrt::event_token const &token) noexcept {
|
||||
mOnServoPanic.remove(token);
|
||||
}
|
||||
|
||||
winrt::event_token OnHistoryChanged(HistoryChangedDelegate const &handler) {
|
||||
return mOnHistoryChangedEvent.add(handler);
|
||||
};
|
||||
|
@ -173,6 +181,7 @@ struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate {
|
|||
virtual void OnServoURLChanged(winrt::hstring);
|
||||
virtual bool OnServoAllowNavigation(winrt::hstring);
|
||||
virtual void OnServoAnimatingChanged(bool);
|
||||
virtual void OnServoPanic(hstring);
|
||||
virtual void OnServoIMEHide();
|
||||
virtual void OnServoIMEShow(hstring text, int32_t, int32_t, int32_t, int32_t);
|
||||
virtual void OnServoMediaSessionMetadata(winrt::hstring, winrt::hstring,
|
||||
|
@ -193,6 +202,7 @@ struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate {
|
|||
private:
|
||||
winrt::event<Windows::Foundation::EventHandler<hstring>> mOnURLChangedEvent;
|
||||
winrt::event<Windows::Foundation::EventHandler<hstring>> mOnTitleChangedEvent;
|
||||
winrt::event<Windows::Foundation::EventHandler<hstring>> mOnServoPanic;
|
||||
winrt::event<HistoryChangedDelegate> mOnHistoryChangedEvent;
|
||||
winrt::event<DevtoolsStatusChangedDelegate> mOnDevtoolsStatusChangedEvent;
|
||||
winrt::event<EventDelegate> mOnLoadStartedEvent;
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace ServoApp {
|
|||
event DevtoolsStatusChangedDelegate OnDevtoolsStatusChanged;
|
||||
event HistoryChangedDelegate OnHistoryChanged;
|
||||
event Windows.Foundation.EventHandler<String> OnTitleChanged;
|
||||
event Windows.Foundation.EventHandler<String> OnServoPanic;
|
||||
event Windows.Foundation.EventHandler<String> OnURLChanged;
|
||||
event MediaSessionMetadataDelegate OnMediaSessionMetadata;
|
||||
event Windows.Foundation.EventHandler<int> OnMediaSessionPlaybackStateChange;
|
||||
|
|
|
@ -114,6 +114,21 @@
|
|||
<data name="devtoolsTabPrefs.[using:Microsoft.UI.Xaml.Controls]TabViewItem.Header" xml:space="preserve">
|
||||
<value>Preferences</value>
|
||||
</data>
|
||||
<data name="crashTab.[using:Microsoft.UI.Xaml.Controls]TabViewItem.Header" xml:space="preserve">
|
||||
<value>Crash Report</value>
|
||||
</data>
|
||||
<data name="crash.Happening" xml:space="preserve">
|
||||
<value>Internal crash detected. Application might be unstable:</value>
|
||||
</data>
|
||||
<data name="crash.Happened" xml:space="preserve">
|
||||
<value>Internal crash was detected during last run:</value>
|
||||
</data>
|
||||
<data name="SubmitCrashReportButton.Content" xml:space="preserve">
|
||||
<value>Send crash report</value>
|
||||
</data>
|
||||
<data name="DismissCrashReportButton.Content" xml:space="preserve">
|
||||
<value>Dismiss</value>
|
||||
</data>
|
||||
<data name="preferenceSearchbox.PlaceholderText" xml:space="preserve">
|
||||
<value>Search Preferences</value>
|
||||
</data>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue