Auto merge of #6666 - glennw:exit-flag, r=larsbergstrom

Restore exit after load command line flag.

Also updates glutin with a crash fix that was exposed by this patch.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6666)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-07-20 15:37:33 -06:00
commit 5ac80bff8e
6 changed files with 24 additions and 12 deletions

View file

@ -412,7 +412,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.got_load_complete_message = true;
// If we're painting in headless mode, schedule a recomposite.
if opts::get().output_file.is_some() {
if opts::get().output_file.is_some() || opts::get().exit_after_load {
self.composite_if_necessary(CompositingReason::Headless);
}
@ -1376,8 +1376,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
if !self.is_ready_to_paint_image_output() {
return None
}
},
_ => {}
}
CompositeTarget::Window => {
if opts::get().exit_after_load && !self.is_ready_to_paint_image_output() {
return None
}
}
}
let (framebuffer_ids, texture_ids) = match target {
@ -1414,15 +1418,17 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let path = opts::get().output_file.as_ref().unwrap();
let res = png::store_png(&mut img, &path);
assert!(res.is_ok());
debug!("shutting down the constellation after generating an output file");
let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(ConstellationMsg::Exit).unwrap();
self.shutdown_state = ShutdownState::ShuttingDown;
None
}
};
if opts::get().output_file.is_some() || opts::get().exit_after_load {
debug!("shutting down the constellation (after generating an output file or exit flag specified)");
let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(ConstellationMsg::Exit).unwrap();
self.shutdown_state = ShutdownState::ShuttingDown;
}
// Perform the page flip. This will likely block for a while.
self.window.present();

View file

@ -183,7 +183,8 @@ impl<'a> LayoutContext<'a> {
Err(state) => {
// If we are emitting an output file, then we need to block on
// image load or we risk emitting an output file missing the image.
let is_sync = opts::get().output_file.is_some();
let is_sync = opts::get().output_file.is_some() ||
opts::get().exit_after_load;
match (state, is_sync) {
// Image failed to load, so just return nothing

View file

@ -502,7 +502,7 @@ dependencies = [
[[package]]
name = "glutin"
version = "0.0.26"
source = "git+https://github.com/servo/glutin?branch=servo#4cf15370a18d6327d159fb4f9950061bf1b715f6"
source = "git+https://github.com/servo/glutin?branch=servo#c6d08b017703abcb00221462fb8ebbfad3495374"
dependencies = [
"android_glue 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cocoa 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -163,6 +163,9 @@ pub struct Opts {
/// Whether to run absolute position calculation and display list construction in parallel.
pub parallel_display_list_building: bool,
/// True to exit after the page load (`-x`).
pub exit_after_load: bool,
}
fn print_usage(app: &str, opts: &[getopts::OptGroup]) {
@ -261,6 +264,7 @@ pub fn default_opts() -> Opts {
sniff_mime_types: false,
disable_share_style_cache: false,
parallel_display_list_building: false,
exit_after_load: false,
}
}
@ -437,6 +441,7 @@ pub fn from_cmdline_args(args: &[String]) {
sniff_mime_types: opt_match.opt_present("sniff-mime-types"),
disable_share_style_cache: debug_options.contains(&"disable-share-style-cache"),
parallel_display_list_building: debug_options.contains(&"parallel-display-list-building"),
exit_after_load: opt_match.opt_present("x"),
};
set(opts);

2
ports/cef/Cargo.lock generated
View file

@ -494,7 +494,7 @@ dependencies = [
[[package]]
name = "glutin"
version = "0.0.26"
source = "git+https://github.com/servo/glutin?branch=servo#4cf15370a18d6327d159fb4f9950061bf1b715f6"
source = "git+https://github.com/servo/glutin?branch=servo#c6d08b017703abcb00221462fb8ebbfad3495374"
dependencies = [
"android_glue 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cocoa 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -345,7 +345,7 @@ impl Window {
// When writing to a file then exiting, use event
// polling so that we don't block on a GUI event
// such as mouse click.
if opts::get().output_file.is_some() {
if opts::get().output_file.is_some() || opts::get().exit_after_load {
while let Some(event) = self.window.poll_events().next() {
close_event = self.handle_window_event(event) || close_event;
}