From b1ae5e7523461390d332e39a98a847b243afab3b Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 26 May 2015 21:18:32 -0400 Subject: [PATCH] make Opts.url an Option<> type, only emit initial url load if url exists this is a necessary change for embedded apps to prevent an initial about:blank page load from overwriting whatever the app was actually trying to load --- components/servo/lib.rs | 11 +++++++---- components/util/opts.rs | 6 +++--- ports/cef/core.rs | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 4f254d5f6826..1cc349de1dde 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -168,10 +168,13 @@ fn create_constellation(opts: opts::Opts, storage_task); // Send the URL command to the constellation. - { - let ConstellationChan(ref chan) = constellation_chan; - chan.send(ConstellationMsg::InitLoadUrl(opts.url.clone())).unwrap(); - } + match opts.url { + Some(url) => { + let ConstellationChan(ref chan) = constellation_chan; + chan.send(ConstellationMsg::InitLoadUrl(url.clone())).unwrap(); + }, + None => () + }; constellation_chan } diff --git a/components/util/opts.rs b/components/util/opts.rs index f3e7487f4685..0b19f8155968 100644 --- a/components/util/opts.rs +++ b/components/util/opts.rs @@ -24,7 +24,7 @@ use url::{self, Url}; #[derive(Clone)] pub struct Opts { /// The initial URL to load. - pub url: Url, + pub url: Option, /// How many threads to use for CPU painting (`-t`). /// @@ -198,7 +198,7 @@ static FORCE_CPU_PAINTING: bool = false; pub fn default_opts() -> Opts { Opts { - url: Url::parse("about:blank").unwrap(), + url: Some(Url::parse("about:blank").unwrap()), paint_threads: 1, gpu_painting: false, tile_size: 512, @@ -370,7 +370,7 @@ pub fn from_cmdline_args(args: &[String]) -> bool { }; let opts = Opts { - url: url, + url: Some(url), paint_threads: paint_threads, gpu_painting: gpu_painting, tile_size: tile_size, diff --git a/ports/cef/core.rs b/ports/cef/core.rs index cfd411da3ad5..04a889918387 100644 --- a/ports/cef/core.rs +++ b/ports/cef/core.rs @@ -74,6 +74,7 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t, temp_opts.hard_fail = false; temp_opts.enable_text_antialiasing = true; temp_opts.resources_path = None; + temp_opts.url = None; opts::set(temp_opts); if unsafe { (*settings).windowless_rendering_enabled != 0 } {