diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-07-20 15:37:33 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-07-20 15:37:33 -0600 |
commit | 5ac80bff8e25be65e96daaf6b7403b11d23d561a (patch) | |
tree | 647d9ca1144dc5df63f99cb8110c089ea1b68133 | |
parent | 58e9bc6583b6ebbeb27e3b28a6b271ee48cd695a (diff) | |
parent | 4f28c93f4003817305283dcc80bf56db5ce46b02 (diff) | |
download | servo-5ac80bff8e25be65e96daaf6b7403b11d23d561a.tar.gz servo-5ac80bff8e25be65e96daaf6b7403b11d23d561a.zip |
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 -->
-rw-r--r-- | components/compositing/compositor.rs | 22 | ||||
-rw-r--r-- | components/layout/context.rs | 3 | ||||
-rw-r--r-- | components/servo/Cargo.lock | 2 | ||||
-rw-r--r-- | components/util/opts.rs | 5 | ||||
-rw-r--r-- | ports/cef/Cargo.lock | 2 | ||||
-rw-r--r-- | ports/glutin/window.rs | 2 |
6 files changed, 24 insertions, 12 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 0f397a7d4f7..4f6a8bdbc71 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -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(); diff --git a/components/layout/context.rs b/components/layout/context.rs index 353d37d9d0c..cd7615e1a97 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -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 diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index ff8c039ee28..e3d29f62fa2 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -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)", diff --git a/components/util/opts.rs b/components/util/opts.rs index 550dd2a408e..2ec9bb43794 100644 --- a/components/util/opts.rs +++ b/components/util/opts.rs @@ -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); diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index cf7a519b8e4..20ba98b553a 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -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)", diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index 6397abb1d1f..6cf7f37dc2a 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -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; } |