2013-04-06 03:31:01 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2012-11-13 00:08:38 +04:00
|
|
|
//! Configuration options for a single run of the servo application. Created
|
|
|
|
//! from command line arguments.
|
|
|
|
|
2017-06-14 17:25:05 +03:00
|
|
|
use euclid::TypedSize2D;
|
2015-08-07 23:05:19 +03:00
|
|
|
use getopts::Options;
|
2015-05-05 17:11:30 +03:00
|
|
|
use num_cpus;
|
2016-07-03 18:19:04 +03:00
|
|
|
use prefs::{self, PrefValue, PREFS};
|
2015-09-25 17:18:06 +03:00
|
|
|
use resource_files::set_resources_path;
|
2017-02-22 07:45:20 +03:00
|
|
|
use servo_geometry::DeviceIndependentPixel;
|
2016-11-18 00:34:47 +03:00
|
|
|
use servo_url::ServoUrl;
|
2016-10-11 12:04:20 +03:00
|
|
|
use std::borrow::Cow;
|
2014-05-02 22:58:29 +04:00
|
|
|
use std::cmp;
|
2015-08-14 03:11:57 +03:00
|
|
|
use std::default::Default;
|
2015-02-13 15:33:49 +03:00
|
|
|
use std::env;
|
2016-05-25 10:52:10 +03:00
|
|
|
use std::fs::{self, File};
|
2016-08-13 21:37:37 +03:00
|
|
|
use std::io::{self, Read, Write};
|
2016-04-28 12:47:35 +03:00
|
|
|
use std::path::{Path, PathBuf};
|
2015-06-26 21:55:23 +03:00
|
|
|
use std::process;
|
2015-11-20 01:29:48 +03:00
|
|
|
use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
|
2015-05-12 11:26:54 +03:00
|
|
|
use url::{self, Url};
|
2012-11-13 00:08:38 +04:00
|
|
|
|
2016-05-25 10:52:10 +03:00
|
|
|
|
2013-10-26 04:01:22 +04:00
|
|
|
/// Global flags for Servo, currently set on the command line.
|
2017-04-07 12:34:47 +03:00
|
|
|
#[derive(Clone, Deserialize, Serialize)]
|
2012-11-13 00:08:38 +04:00
|
|
|
pub struct Opts {
|
2015-11-05 01:38:30 +03:00
|
|
|
pub is_running_problem_test: bool,
|
|
|
|
|
2015-04-08 06:08:33 +03:00
|
|
|
/// The initial URL to load.
|
2016-11-18 00:34:47 +03:00
|
|
|
pub url: Option<ServoUrl>,
|
2013-10-26 04:01:22 +04:00
|
|
|
|
|
|
|
/// The maximum size of each tile in pixels (`-s`).
|
2015-02-28 17:21:53 +03:00
|
|
|
pub tile_size: usize,
|
2013-10-26 04:01:22 +04:00
|
|
|
|
2014-06-03 00:52:32 +04:00
|
|
|
/// The ratio of device pixels per px at the default scale. If unspecified, will use the
|
|
|
|
/// platform default setting.
|
2015-07-01 16:54:15 +03:00
|
|
|
pub device_pixels_per_px: Option<f32>,
|
2014-06-03 00:52:32 +04:00
|
|
|
|
2017-07-06 18:27:55 +03:00
|
|
|
/// `None` to disable the time profiler or `Some` to enable it with:
|
|
|
|
/// - an interval in seconds to cause it to produce output on that interval.
|
|
|
|
/// (`i.e. -p 5`).
|
|
|
|
/// - a file path to write profiling info to a TSV file upon Servo's termination.
|
|
|
|
/// (`i.e. -p out.tsv`).
|
|
|
|
/// - an InfluxDB hostname to store profiling info upon Servo's termination.
|
|
|
|
/// (`i.e. -p http://localhost:8086`)
|
2016-05-12 03:19:53 +03:00
|
|
|
pub time_profiling: Option<OutputOptions>,
|
2014-06-27 04:17:59 +04:00
|
|
|
|
2016-04-28 12:47:35 +03:00
|
|
|
/// When the profiler is enabled, this is an optional path to dump a self-contained HTML file
|
|
|
|
/// visualizing the traces as a timeline.
|
|
|
|
pub time_profiler_trace_path: Option<String>,
|
|
|
|
|
2014-07-11 15:57:48 +04:00
|
|
|
/// `None` to disable the memory profiler or `Some` with an interval in seconds to enable it
|
2014-06-27 04:17:59 +04:00
|
|
|
/// and cause it to produce output on that interval (`-m`).
|
2015-03-26 06:18:48 +03:00
|
|
|
pub mem_profiler_period: Option<f64>,
|
2013-10-26 04:01:22 +04:00
|
|
|
|
2014-10-20 22:54:34 +04:00
|
|
|
pub nonincremental_layout: bool,
|
2014-10-15 02:51:30 +04:00
|
|
|
|
2015-04-01 22:15:46 +03:00
|
|
|
/// Where to load userscripts from, if any. An empty string will load from
|
|
|
|
/// the resources/user-agent-js directory, and if the option isn't passed userscripts
|
|
|
|
/// won't be loaded
|
|
|
|
pub userscripts: Option<String>,
|
2015-03-14 17:39:48 +03:00
|
|
|
|
2016-11-18 00:34:47 +03:00
|
|
|
pub user_stylesheets: Vec<(Vec<u8>, ServoUrl)>,
|
2015-08-07 23:05:19 +03:00
|
|
|
|
2014-06-05 21:58:44 +04:00
|
|
|
pub output_file: Option<String>,
|
2015-07-14 06:49:04 +03:00
|
|
|
|
|
|
|
/// Replace unpaires surrogates in DOM strings with U+FFFD.
|
|
|
|
/// See https://github.com/servo/servo/issues/6564
|
|
|
|
pub replace_surrogates: bool,
|
|
|
|
|
2015-08-07 15:14:12 +03:00
|
|
|
/// Log GC passes and their durations.
|
|
|
|
pub gc_profile: bool,
|
|
|
|
|
2015-11-07 07:23:19 +03:00
|
|
|
/// Load web fonts synchronously to avoid non-deterministic network-driven reflows.
|
|
|
|
pub load_webfonts_synchronously: bool,
|
|
|
|
|
2014-04-28 02:52:39 +04:00
|
|
|
pub headless: bool,
|
|
|
|
pub hard_fail: bool,
|
2014-02-25 09:04:32 +04:00
|
|
|
|
|
|
|
/// True if we should bubble intrinsic widths sequentially (`-b`). If this is true, then
|
|
|
|
/// intrinsic widths are computed as a separate pass instead of during flow construction. You
|
|
|
|
/// may wish to turn this flag on in order to benchmark style recalculation against other
|
|
|
|
/// browser engines.
|
2014-07-19 00:27:23 +04:00
|
|
|
pub bubble_inline_sizes_separately: bool,
|
2014-07-24 23:16:27 +04:00
|
|
|
|
2015-02-21 09:06:48 +03:00
|
|
|
/// True if we should show borders on all fragments for debugging purposes
|
|
|
|
/// (`--show-debug-fragment-borders`).
|
2014-10-22 03:06:40 +04:00
|
|
|
pub show_debug_fragment_borders: bool,
|
|
|
|
|
2015-02-21 09:06:48 +03:00
|
|
|
/// True if we should paint borders around flows based on which thread painted them.
|
|
|
|
pub show_debug_parallel_layout: bool,
|
|
|
|
|
2014-09-03 19:16:53 +04:00
|
|
|
/// If set with --disable-text-aa, disable antialiasing on fonts. This is primarily useful for reftests
|
|
|
|
/// where pixel perfect results are required when using fonts such as the Ahem
|
|
|
|
/// font for layout tests.
|
|
|
|
pub enable_text_antialiasing: bool,
|
2014-09-08 10:33:09 +04:00
|
|
|
|
2017-05-08 04:27:46 +03:00
|
|
|
/// If set with --disable-subpixel, use subpixel antialiasing for glyphs. In the future
|
2016-11-08 17:10:19 +03:00
|
|
|
/// this will likely become the default, but for now it's opt-in while we work
|
|
|
|
/// out any bugs and improve the implementation.
|
|
|
|
pub enable_subpixel_text_antialiasing: bool,
|
|
|
|
|
2015-05-28 22:59:36 +03:00
|
|
|
/// If set with --disable-canvas-aa, disable antialiasing on the HTML canvas element.
|
|
|
|
/// Like --disable-text-aa, this is useful for reftests where pixel perfect results are required.
|
|
|
|
pub enable_canvas_antialiasing: bool,
|
|
|
|
|
2014-09-08 10:33:09 +04:00
|
|
|
/// True if each step of layout is traced to an external JSON file
|
|
|
|
/// for debugging purposes. Settings this implies sequential layout
|
2014-12-08 20:28:10 +03:00
|
|
|
/// and paint.
|
2014-09-08 10:33:09 +04:00
|
|
|
pub trace_layout: bool,
|
2014-09-19 17:15:03 +04:00
|
|
|
|
2016-01-10 13:19:04 +03:00
|
|
|
/// Periodically print out on which events script threads spend their processing time.
|
2015-08-28 02:00:15 +03:00
|
|
|
pub profile_script_events: bool,
|
|
|
|
|
2015-10-30 09:56:10 +03:00
|
|
|
/// Enable all heartbeats for profiling.
|
|
|
|
pub profile_heartbeats: bool,
|
|
|
|
|
2016-09-12 18:19:17 +03:00
|
|
|
/// `None` to disable debugger or `Some` with a port number to start a server to listen to
|
|
|
|
/// remote Firefox debugger connections.
|
|
|
|
pub debugger_port: Option<u16>,
|
|
|
|
|
2014-10-08 18:24:36 +04:00
|
|
|
/// `None` to disable devtools or `Some` with a port number to start a server to listen to
|
|
|
|
/// remote Firefox devtools connections.
|
|
|
|
pub devtools_port: Option<u16>,
|
2014-09-26 04:27:38 +04:00
|
|
|
|
2015-04-07 06:09:44 +03:00
|
|
|
/// `None` to disable WebDriver or `Some` with a port number to start a server to listen to
|
|
|
|
/// remote WebDriver commands.
|
|
|
|
pub webdriver_port: Option<u16>,
|
|
|
|
|
2014-09-26 04:27:38 +04:00
|
|
|
/// The initial requested size of the window.
|
2017-02-22 07:45:20 +03:00
|
|
|
pub initial_window_size: TypedSize2D<u32, DeviceIndependentPixel>,
|
2014-10-07 09:21:32 +04:00
|
|
|
|
|
|
|
/// An optional string allowing the user agent to be set for testing.
|
2016-10-11 12:04:20 +03:00
|
|
|
pub user_agent: Cow<'static, str>,
|
2014-10-09 09:33:33 +04:00
|
|
|
|
2015-11-20 01:29:48 +03:00
|
|
|
/// Whether we're running in multiprocess mode.
|
2015-07-31 18:43:40 +03:00
|
|
|
pub multiprocess: bool,
|
|
|
|
|
2015-11-20 01:29:48 +03:00
|
|
|
/// Whether we're running inside the sandbox.
|
|
|
|
pub sandbox: bool,
|
|
|
|
|
2016-03-26 18:45:59 +03:00
|
|
|
/// Probability of randomly closing a pipeline,
|
|
|
|
/// used for testing the hardening of the constellation.
|
|
|
|
pub random_pipeline_closure_probability: Option<f32>,
|
|
|
|
|
|
|
|
/// The seed for the RNG used to randomly close pipelines,
|
|
|
|
/// used for testing the hardening of the constellation.
|
|
|
|
pub random_pipeline_closure_seed: Option<usize>,
|
|
|
|
|
2016-08-13 04:55:27 +03:00
|
|
|
/// Dumps the DOM after restyle.
|
|
|
|
pub dump_style_tree: bool,
|
|
|
|
|
2016-11-06 01:11:24 +03:00
|
|
|
/// Dumps the rule tree.
|
|
|
|
pub dump_rule_tree: bool,
|
|
|
|
|
2014-10-09 09:33:33 +04:00
|
|
|
/// Dumps the flow tree after a layout.
|
|
|
|
pub dump_flow_tree: bool,
|
2014-10-22 03:51:43 +04:00
|
|
|
|
2015-04-17 23:33:06 +03:00
|
|
|
/// Dumps the display list after a layout.
|
2015-02-26 06:15:56 +03:00
|
|
|
pub dump_display_list: bool,
|
|
|
|
|
2015-07-15 23:04:55 +03:00
|
|
|
/// Dumps the display list in JSON form after a layout.
|
|
|
|
pub dump_display_list_json: bool,
|
|
|
|
|
2015-03-07 07:48:50 +03:00
|
|
|
/// Emits notifications when there is a relayout.
|
|
|
|
pub relayout_event: bool,
|
|
|
|
|
2015-04-10 11:06:11 +03:00
|
|
|
/// Whether Style Sharing Cache is used
|
|
|
|
pub disable_share_style_cache: bool,
|
2015-07-06 16:08:58 +03:00
|
|
|
|
2016-08-18 00:34:30 +03:00
|
|
|
/// Whether to show in stdout style sharing cache stats after a restyle.
|
|
|
|
pub style_sharing_stats: bool,
|
|
|
|
|
2015-10-23 00:54:01 +03:00
|
|
|
/// Translate mouse input into touch events.
|
|
|
|
pub convert_mouse_to_touch: bool,
|
|
|
|
|
2015-07-21 00:37:33 +03:00
|
|
|
/// True to exit after the page load (`-x`).
|
|
|
|
pub exit_after_load: bool,
|
2015-09-29 22:45:57 +03:00
|
|
|
|
|
|
|
/// Do not use native titlebar
|
|
|
|
pub no_native_titlebar: bool,
|
2015-12-01 02:56:00 +03:00
|
|
|
|
|
|
|
/// Enable vsync in the compositor
|
|
|
|
pub enable_vsync: bool,
|
2016-02-18 22:24:06 +03:00
|
|
|
|
|
|
|
/// True to show webrender profiling stats on screen.
|
|
|
|
pub webrender_stats: bool,
|
|
|
|
|
2016-08-03 15:50:06 +03:00
|
|
|
/// True to show webrender debug on screen.
|
|
|
|
pub webrender_debug: bool,
|
|
|
|
|
2016-11-18 17:29:27 +03:00
|
|
|
/// True if webrender recording should be enabled.
|
|
|
|
pub webrender_record: bool,
|
|
|
|
|
2017-05-22 03:07:40 +03:00
|
|
|
/// True if webrender is allowed to batch draw calls as instances.
|
|
|
|
pub webrender_batch: bool,
|
|
|
|
|
2016-09-16 04:23:30 +03:00
|
|
|
/// True to compile all webrender shaders at init time. This is mostly
|
|
|
|
/// useful when modifying the shaders, to ensure they all compile
|
|
|
|
/// after each change is made.
|
|
|
|
pub precache_shaders: bool,
|
|
|
|
|
2016-02-18 22:24:06 +03:00
|
|
|
/// True if WebRender should use multisample antialiasing.
|
|
|
|
pub use_msaa: bool,
|
2016-03-11 00:23:59 +03:00
|
|
|
|
2016-05-25 10:52:10 +03:00
|
|
|
/// Directory for a default config directory
|
2016-11-12 14:56:59 +03:00
|
|
|
pub config_dir: Option<PathBuf>,
|
2016-03-20 09:55:10 +03:00
|
|
|
|
2016-04-05 10:32:01 +03:00
|
|
|
// don't skip any backtraces on panic
|
|
|
|
pub full_backtraces: bool,
|
2016-06-29 17:05:35 +03:00
|
|
|
|
2016-10-01 12:18:56 +03:00
|
|
|
/// True to use OS native signposting facilities. This makes profiling events (script activity,
|
|
|
|
/// reflow, compositing, etc.) appear in Instruments.app on macOS.
|
|
|
|
pub signpost: bool,
|
|
|
|
|
2016-06-29 17:05:35 +03:00
|
|
|
/// Print the version and exit.
|
|
|
|
pub is_printing_version: bool,
|
2017-04-06 13:53:14 +03:00
|
|
|
|
|
|
|
/// Path to SSL certificates.
|
|
|
|
pub certificate_path: Option<String>,
|
2017-04-12 19:11:23 +03:00
|
|
|
|
|
|
|
/// Unminify Javascript.
|
|
|
|
pub unminify_js: bool,
|
2017-07-20 21:34:35 +03:00
|
|
|
|
|
|
|
/// Print Progressive Web Metrics to console.
|
|
|
|
pub print_pwm: bool,
|
2012-11-13 00:08:38 +04:00
|
|
|
}
|
|
|
|
|
2015-08-07 23:05:19 +03:00
|
|
|
fn print_usage(app: &str, opts: &Options) {
|
2013-11-19 03:58:28 +04:00
|
|
|
let message = format!("Usage: {} [ options ... ] [URL]\n\twhere options include", app);
|
2015-08-07 23:05:19 +03:00
|
|
|
println!("{}", opts.usage(&message));
|
2013-11-19 03:58:28 +04:00
|
|
|
}
|
|
|
|
|
2015-08-14 03:11:57 +03:00
|
|
|
|
|
|
|
/// Debug options for Servo, currently set on the command line with -Z
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct DebugOptions {
|
|
|
|
/// List all the debug options.
|
|
|
|
pub help: bool,
|
|
|
|
|
|
|
|
/// Bubble intrinsic widths separately like other engines.
|
|
|
|
pub bubble_widths: bool,
|
|
|
|
|
|
|
|
/// Disable antialiasing of rendered text.
|
|
|
|
pub disable_text_aa: bool,
|
|
|
|
|
2017-05-08 04:27:46 +03:00
|
|
|
/// Disable subpixel antialiasing of rendered text.
|
|
|
|
pub disable_subpixel_aa: bool,
|
2016-11-08 17:10:19 +03:00
|
|
|
|
2015-08-14 03:11:57 +03:00
|
|
|
/// Disable antialiasing of rendered text on the HTML canvas element.
|
|
|
|
pub disable_canvas_aa: bool,
|
|
|
|
|
2016-08-13 04:55:27 +03:00
|
|
|
/// Print the DOM after each restyle.
|
|
|
|
pub dump_style_tree: bool,
|
|
|
|
|
2016-11-06 01:11:24 +03:00
|
|
|
/// Dumps the rule tree.
|
|
|
|
pub dump_rule_tree: bool,
|
|
|
|
|
2015-08-14 03:11:57 +03:00
|
|
|
/// Print the flow tree after each layout.
|
|
|
|
pub dump_flow_tree: bool,
|
|
|
|
|
|
|
|
/// Print the display list after each layout.
|
|
|
|
pub dump_display_list: bool,
|
|
|
|
|
|
|
|
/// Print the display list in JSON form.
|
|
|
|
pub dump_display_list_json: bool,
|
|
|
|
|
|
|
|
/// Print notifications when there is a relayout.
|
|
|
|
pub relayout_event: bool,
|
|
|
|
|
2016-01-10 13:19:04 +03:00
|
|
|
/// Profile which events script threads spend their time on.
|
2015-08-28 02:00:15 +03:00
|
|
|
pub profile_script_events: bool,
|
|
|
|
|
2015-10-30 09:56:10 +03:00
|
|
|
/// Enable all heartbeats for profiling.
|
|
|
|
pub profile_heartbeats: bool,
|
|
|
|
|
2015-08-14 03:11:57 +03:00
|
|
|
/// Paint borders along fragment boundaries.
|
|
|
|
pub show_fragment_borders: bool,
|
|
|
|
|
|
|
|
/// Mark which thread laid each flow out with colors.
|
|
|
|
pub show_parallel_layout: bool,
|
|
|
|
|
|
|
|
/// Write layout trace to an external file for debugging.
|
|
|
|
pub trace_layout: bool,
|
|
|
|
|
|
|
|
/// Disable the style sharing cache.
|
|
|
|
pub disable_share_style_cache: bool,
|
|
|
|
|
2016-08-18 00:34:30 +03:00
|
|
|
/// Whether to show in stdout style sharing cache stats after a restyle.
|
|
|
|
pub style_sharing_stats: bool,
|
|
|
|
|
2015-10-23 00:54:01 +03:00
|
|
|
/// Translate mouse input into touch events.
|
|
|
|
pub convert_mouse_to_touch: bool,
|
|
|
|
|
2015-08-14 03:11:57 +03:00
|
|
|
/// Replace unpaires surrogates in DOM strings with U+FFFD.
|
|
|
|
/// See https://github.com/servo/servo/issues/6564
|
|
|
|
pub replace_surrogates: bool,
|
|
|
|
|
|
|
|
/// Log GC passes and their durations.
|
|
|
|
pub gc_profile: bool,
|
2015-11-07 07:23:19 +03:00
|
|
|
|
|
|
|
/// Load web fonts synchronously to avoid non-deterministic network-driven reflows.
|
|
|
|
pub load_webfonts_synchronously: bool,
|
2015-12-01 02:56:00 +03:00
|
|
|
|
|
|
|
/// Disable vsync in the compositor
|
|
|
|
pub disable_vsync: bool,
|
2016-02-18 22:24:06 +03:00
|
|
|
|
|
|
|
/// Show webrender profiling stats on screen.
|
|
|
|
pub webrender_stats: bool,
|
|
|
|
|
2016-08-03 15:50:06 +03:00
|
|
|
/// Show webrender debug on screen.
|
|
|
|
pub webrender_debug: bool,
|
|
|
|
|
2016-11-18 17:29:27 +03:00
|
|
|
/// Enable webrender recording.
|
|
|
|
pub webrender_record: bool,
|
|
|
|
|
2017-05-22 03:07:40 +03:00
|
|
|
/// Enable webrender instanced draw call batching.
|
2017-05-24 17:21:07 +03:00
|
|
|
pub webrender_disable_batch: bool,
|
2017-05-22 03:07:40 +03:00
|
|
|
|
2016-02-18 22:24:06 +03:00
|
|
|
/// Use multisample antialiasing in WebRender.
|
|
|
|
pub use_msaa: bool,
|
2016-03-26 18:45:59 +03:00
|
|
|
|
2016-04-05 10:32:01 +03:00
|
|
|
// don't skip any backtraces on panic
|
|
|
|
pub full_backtraces: bool,
|
|
|
|
|
2016-09-16 04:23:30 +03:00
|
|
|
/// True to compile all webrender shaders at init time. This is mostly
|
|
|
|
/// useful when modifying the shaders, to ensure they all compile
|
|
|
|
/// after each change is made.
|
|
|
|
pub precache_shaders: bool,
|
2016-10-01 12:18:56 +03:00
|
|
|
|
|
|
|
/// True to use OS native signposting facilities. This makes profiling events (script activity,
|
|
|
|
/// reflow, compositing, etc.) appear in Instruments.app on macOS.
|
|
|
|
pub signpost: bool,
|
2015-08-14 03:11:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl DebugOptions {
|
2016-11-22 11:23:48 +03:00
|
|
|
pub fn extend(&mut self, debug_string: String) -> Result<(), String> {
|
2015-08-14 03:11:57 +03:00
|
|
|
for option in debug_string.split(',') {
|
|
|
|
match option {
|
2016-11-22 11:23:48 +03:00
|
|
|
"help" => self.help = true,
|
|
|
|
"bubble-widths" => self.bubble_widths = true,
|
|
|
|
"disable-text-aa" => self.disable_text_aa = true,
|
2017-05-08 04:27:46 +03:00
|
|
|
"disable-subpixel-aa" => self.disable_subpixel_aa = true,
|
2016-11-22 11:23:48 +03:00
|
|
|
"disable-canvas-aa" => self.disable_text_aa = true,
|
|
|
|
"dump-style-tree" => self.dump_style_tree = true,
|
|
|
|
"dump-rule-tree" => self.dump_rule_tree = true,
|
|
|
|
"dump-flow-tree" => self.dump_flow_tree = true,
|
|
|
|
"dump-display-list" => self.dump_display_list = true,
|
|
|
|
"dump-display-list-json" => self.dump_display_list_json = true,
|
|
|
|
"relayout-event" => self.relayout_event = true,
|
|
|
|
"profile-script-events" => self.profile_script_events = true,
|
|
|
|
"profile-heartbeats" => self.profile_heartbeats = true,
|
|
|
|
"show-fragment-borders" => self.show_fragment_borders = true,
|
|
|
|
"show-parallel-layout" => self.show_parallel_layout = true,
|
|
|
|
"trace-layout" => self.trace_layout = true,
|
|
|
|
"disable-share-style-cache" => self.disable_share_style_cache = true,
|
|
|
|
"style-sharing-stats" => self.style_sharing_stats = true,
|
|
|
|
"convert-mouse-to-touch" => self.convert_mouse_to_touch = true,
|
|
|
|
"replace-surrogates" => self.replace_surrogates = true,
|
|
|
|
"gc-profile" => self.gc_profile = true,
|
|
|
|
"load-webfonts-synchronously" => self.load_webfonts_synchronously = true,
|
|
|
|
"disable-vsync" => self.disable_vsync = true,
|
|
|
|
"wr-stats" => self.webrender_stats = true,
|
|
|
|
"wr-debug" => self.webrender_debug = true,
|
|
|
|
"wr-record" => self.webrender_record = true,
|
2017-05-24 17:21:07 +03:00
|
|
|
"wr-no-batch" => self.webrender_disable_batch = true,
|
2016-11-22 11:23:48 +03:00
|
|
|
"msaa" => self.use_msaa = true,
|
|
|
|
"full-backtraces" => self.full_backtraces = true,
|
|
|
|
"precache-shaders" => self.precache_shaders = true,
|
|
|
|
"signpost" => self.signpost = true,
|
2015-08-14 03:11:57 +03:00
|
|
|
"" => {},
|
2016-11-22 11:23:48 +03:00
|
|
|
_ => return Err(String::from(option)),
|
2015-08-14 03:11:57 +03:00
|
|
|
};
|
|
|
|
};
|
2016-11-22 11:23:48 +03:00
|
|
|
Ok(())
|
2015-08-14 03:11:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-09 23:19:49 +03:00
|
|
|
fn print_debug_usage(app: &str) -> ! {
|
2014-11-04 21:36:30 +03:00
|
|
|
fn print_option(name: &str, description: &str) {
|
|
|
|
println!("\t{:<35} {}", name, description);
|
|
|
|
}
|
|
|
|
|
|
|
|
println!("Usage: {} debug option,[options,...]\n\twhere options include\n\nOptions:", app);
|
|
|
|
|
|
|
|
print_option("bubble-widths", "Bubble intrinsic widths separately like other engines.");
|
|
|
|
print_option("disable-text-aa", "Disable antialiasing of rendered text.");
|
2015-08-14 03:11:57 +03:00
|
|
|
print_option("disable-canvas-aa", "Disable antialiasing on the HTML canvas element.");
|
2016-08-13 04:55:27 +03:00
|
|
|
print_option("dump-style-tree", "Print the DOM with computed styles after each restyle.");
|
2014-11-04 21:36:30 +03:00
|
|
|
print_option("dump-flow-tree", "Print the flow tree after each layout.");
|
2015-02-26 06:15:56 +03:00
|
|
|
print_option("dump-display-list", "Print the display list after each layout.");
|
2015-07-15 23:04:55 +03:00
|
|
|
print_option("dump-display-list-json", "Print the display list in JSON form.");
|
2015-03-07 07:48:50 +03:00
|
|
|
print_option("relayout-event", "Print notifications when there is a relayout.");
|
2015-10-30 09:56:10 +03:00
|
|
|
print_option("profile-script-events", "Enable profiling of script-related events.");
|
2016-01-10 13:19:04 +03:00
|
|
|
print_option("profile-heartbeats", "Enable heartbeats for all thread categories.");
|
2014-11-04 21:36:30 +03:00
|
|
|
print_option("show-fragment-borders", "Paint borders along fragment boundaries.");
|
2015-02-21 09:06:48 +03:00
|
|
|
print_option("show-parallel-layout", "Mark which thread laid each flow out with colors.");
|
2014-11-04 21:36:30 +03:00
|
|
|
print_option("trace-layout", "Write layout trace to an external file for debugging.");
|
2015-04-10 11:06:11 +03:00
|
|
|
print_option("disable-share-style-cache",
|
|
|
|
"Disable the style sharing cache.");
|
2015-07-06 16:08:58 +03:00
|
|
|
print_option("parallel-display-list-building", "Build display lists in parallel.");
|
2015-10-30 09:56:10 +03:00
|
|
|
print_option("convert-mouse-to-touch", "Send touch events instead of mouse events");
|
2015-07-14 06:49:04 +03:00
|
|
|
print_option("replace-surrogates", "Replace unpaires surrogates in DOM strings with U+FFFD. \
|
|
|
|
See https://github.com/servo/servo/issues/6564");
|
2015-08-07 15:14:12 +03:00
|
|
|
print_option("gc-profile", "Log GC passes and their durations.");
|
2015-11-07 07:23:19 +03:00
|
|
|
print_option("load-webfonts-synchronously",
|
|
|
|
"Load web fonts synchronously to avoid non-deterministic network-driven reflows");
|
2015-12-01 02:56:00 +03:00
|
|
|
print_option("disable-vsync",
|
|
|
|
"Disable vsync mode in the compositor to allow profiling at more than monitor refresh rate");
|
2016-02-18 22:24:06 +03:00
|
|
|
print_option("wr-stats", "Show WebRender profiler on screen.");
|
|
|
|
print_option("msaa", "Use multisample antialiasing in WebRender.");
|
2016-04-05 10:32:01 +03:00
|
|
|
print_option("full-backtraces", "Print full backtraces for all errors");
|
2017-05-11 10:11:56 +03:00
|
|
|
print_option("wr-debug", "Display webrender tile borders.");
|
2017-05-22 03:07:40 +03:00
|
|
|
print_option("wr-no-batch", "Disable webrender instanced batching.");
|
2017-05-11 10:11:56 +03:00
|
|
|
print_option("precache-shaders", "Compile all shaders during init.");
|
2016-10-01 12:18:56 +03:00
|
|
|
print_option("signpost", "Emit native OS signposts for profile events (currently macOS only)");
|
2014-11-04 21:36:30 +03:00
|
|
|
|
|
|
|
println!("");
|
2015-06-26 21:55:23 +03:00
|
|
|
|
|
|
|
process::exit(0)
|
2014-11-04 21:36:30 +03:00
|
|
|
}
|
|
|
|
|
2017-04-07 12:34:47 +03:00
|
|
|
#[derive(Clone, Deserialize, Serialize)]
|
2016-05-12 03:19:53 +03:00
|
|
|
pub enum OutputOptions {
|
2017-07-06 18:27:55 +03:00
|
|
|
/// Database connection config (hostname, name, user, pass)
|
|
|
|
DB(ServoUrl, Option<String>, Option<String>, Option<String>),
|
2016-05-12 03:19:53 +03:00
|
|
|
FileName(String),
|
2017-07-06 18:27:55 +03:00
|
|
|
Stdout(f64),
|
2016-05-12 03:19:53 +03:00
|
|
|
}
|
|
|
|
|
2015-06-26 21:55:23 +03:00
|
|
|
fn args_fail(msg: &str) -> ! {
|
2016-10-10 02:45:03 +03:00
|
|
|
writeln!(io::stderr(), "{}", msg).unwrap();
|
2015-06-26 21:55:23 +03:00
|
|
|
process::exit(1)
|
2014-02-27 07:37:38 +04:00
|
|
|
}
|
|
|
|
|
2015-11-20 01:29:48 +03:00
|
|
|
static MULTIPROCESS: AtomicBool = ATOMIC_BOOL_INIT;
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub fn multiprocess() -> bool {
|
|
|
|
MULTIPROCESS.load(Ordering::Relaxed)
|
|
|
|
}
|
|
|
|
|
2015-08-18 07:44:38 +03:00
|
|
|
enum UserAgent {
|
|
|
|
Desktop,
|
|
|
|
Android,
|
2017-08-28 21:39:25 +03:00
|
|
|
#[allow(non_camel_case_types)]
|
2017-08-24 00:05:35 +03:00
|
|
|
iOS
|
2015-08-18 07:44:38 +03:00
|
|
|
}
|
|
|
|
|
2016-10-11 12:04:20 +03:00
|
|
|
fn default_user_agent_string(agent: UserAgent) -> &'static str {
|
2015-11-05 18:14:07 +03:00
|
|
|
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
|
|
|
|
const DESKTOP_UA_STRING: &'static str =
|
2017-08-16 02:21:51 +03:00
|
|
|
"Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Servo/1.0 Firefox/55.0";
|
2015-11-05 18:14:07 +03:00
|
|
|
#[cfg(all(target_os = "linux", not(target_arch = "x86_64")))]
|
|
|
|
const DESKTOP_UA_STRING: &'static str =
|
2017-08-16 02:21:51 +03:00
|
|
|
"Mozilla/5.0 (X11; Linux i686; rv:55.0) Servo/1.0 Firefox/55.0";
|
2015-11-05 18:14:07 +03:00
|
|
|
|
|
|
|
#[cfg(all(target_os = "windows", target_arch = "x86_64"))]
|
|
|
|
const DESKTOP_UA_STRING: &'static str =
|
2017-08-16 02:21:51 +03:00
|
|
|
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:55.0) Servo/1.0 Firefox/55.0";
|
2015-11-05 18:14:07 +03:00
|
|
|
#[cfg(all(target_os = "windows", not(target_arch = "x86_64")))]
|
|
|
|
const DESKTOP_UA_STRING: &'static str =
|
2017-08-16 02:21:51 +03:00
|
|
|
"Mozilla/5.0 (Windows NT 6.1; rv:55.0) Servo/1.0 Firefox/55.0";
|
2015-11-05 18:14:07 +03:00
|
|
|
|
|
|
|
#[cfg(not(any(target_os = "linux", target_os = "windows")))]
|
|
|
|
// Neither Linux nor Windows, so maybe OS X, and if not then OS X is an okay fallback.
|
|
|
|
const DESKTOP_UA_STRING: &'static str =
|
2017-08-16 02:21:51 +03:00
|
|
|
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:55.0) Servo/1.0 Firefox/55.0";
|
2015-11-05 18:14:07 +03:00
|
|
|
|
|
|
|
|
2015-08-18 07:44:38 +03:00
|
|
|
match agent {
|
|
|
|
UserAgent::Desktop => {
|
2015-11-05 18:14:07 +03:00
|
|
|
DESKTOP_UA_STRING
|
2015-08-18 07:44:38 +03:00
|
|
|
}
|
|
|
|
UserAgent::Android => {
|
2017-08-16 02:21:51 +03:00
|
|
|
"Mozilla/5.0 (Android; Mobile; rv:55.0) Servo/1.0 Firefox/55.0"
|
2015-08-18 07:44:38 +03:00
|
|
|
}
|
2017-08-24 00:05:35 +03:00
|
|
|
UserAgent::iOS => {
|
|
|
|
"Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X; rv:55.0) Servo/1.0 Firefox/55.0"
|
|
|
|
}
|
2016-10-11 12:04:20 +03:00
|
|
|
}
|
2015-08-18 07:44:38 +03:00
|
|
|
}
|
|
|
|
|
2015-09-01 17:33:02 +03:00
|
|
|
#[cfg(target_os = "android")]
|
2015-08-18 07:44:38 +03:00
|
|
|
const DEFAULT_USER_AGENT: UserAgent = UserAgent::Android;
|
2015-08-11 03:18:27 +03:00
|
|
|
|
2017-08-24 00:05:35 +03:00
|
|
|
#[cfg(target_os = "ios")]
|
|
|
|
const DEFAULT_USER_AGENT: UserAgent = UserAgent::iOS;
|
|
|
|
|
|
|
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
2015-08-18 07:44:38 +03:00
|
|
|
const DEFAULT_USER_AGENT: UserAgent = UserAgent::Desktop;
|
2015-08-11 03:18:27 +03:00
|
|
|
|
2014-11-22 06:00:36 +03:00
|
|
|
pub fn default_opts() -> Opts {
|
2014-10-28 21:36:51 +03:00
|
|
|
Opts {
|
2015-11-05 01:38:30 +03:00
|
|
|
is_running_problem_test: false,
|
2017-06-12 07:16:06 +03:00
|
|
|
url: None,
|
2014-10-28 21:36:51 +03:00
|
|
|
tile_size: 512,
|
|
|
|
device_pixels_per_px: None,
|
2016-05-12 03:19:53 +03:00
|
|
|
time_profiling: None,
|
2016-04-28 12:47:35 +03:00
|
|
|
time_profiler_trace_path: None,
|
2015-03-26 06:18:48 +03:00
|
|
|
mem_profiler_period: None,
|
2014-10-28 21:36:51 +03:00
|
|
|
nonincremental_layout: false,
|
2015-04-01 22:15:46 +03:00
|
|
|
userscripts: None,
|
2015-08-07 23:05:19 +03:00
|
|
|
user_stylesheets: Vec::new(),
|
2014-10-28 21:36:51 +03:00
|
|
|
output_file: None,
|
2015-07-14 06:49:04 +03:00
|
|
|
replace_surrogates: false,
|
2015-08-07 15:14:12 +03:00
|
|
|
gc_profile: false,
|
2015-11-07 07:23:19 +03:00
|
|
|
load_webfonts_synchronously: false,
|
2017-05-18 08:56:30 +03:00
|
|
|
headless: false,
|
2014-10-28 21:36:51 +03:00
|
|
|
hard_fail: true,
|
|
|
|
bubble_inline_sizes_separately: false,
|
|
|
|
show_debug_fragment_borders: false,
|
2015-02-21 09:06:48 +03:00
|
|
|
show_debug_parallel_layout: false,
|
2017-08-29 19:26:45 +03:00
|
|
|
enable_text_antialiasing: true,
|
|
|
|
enable_subpixel_text_antialiasing: true,
|
|
|
|
enable_canvas_antialiasing: true,
|
2014-10-28 21:36:51 +03:00
|
|
|
trace_layout: false,
|
2016-09-12 18:19:17 +03:00
|
|
|
debugger_port: None,
|
2014-10-28 21:36:51 +03:00
|
|
|
devtools_port: None,
|
2015-04-07 06:09:44 +03:00
|
|
|
webdriver_port: None,
|
2016-08-12 04:12:29 +03:00
|
|
|
initial_window_size: TypedSize2D::new(1024, 740),
|
2016-10-11 12:04:20 +03:00
|
|
|
user_agent: default_user_agent_string(DEFAULT_USER_AGENT).into(),
|
2015-07-31 18:43:40 +03:00
|
|
|
multiprocess: false,
|
2016-03-26 18:45:59 +03:00
|
|
|
random_pipeline_closure_probability: None,
|
|
|
|
random_pipeline_closure_seed: None,
|
2015-11-20 01:29:48 +03:00
|
|
|
sandbox: false,
|
2016-08-13 04:55:27 +03:00
|
|
|
dump_style_tree: false,
|
2016-11-06 01:11:24 +03:00
|
|
|
dump_rule_tree: false,
|
2014-10-28 21:36:51 +03:00
|
|
|
dump_flow_tree: false,
|
2015-02-26 06:15:56 +03:00
|
|
|
dump_display_list: false,
|
2015-07-15 23:04:55 +03:00
|
|
|
dump_display_list_json: false,
|
2015-03-07 07:48:50 +03:00
|
|
|
relayout_event: false,
|
2015-08-28 02:00:15 +03:00
|
|
|
profile_script_events: false,
|
2015-10-30 09:56:10 +03:00
|
|
|
profile_heartbeats: false,
|
2015-04-10 11:06:11 +03:00
|
|
|
disable_share_style_cache: false,
|
2016-08-18 00:34:30 +03:00
|
|
|
style_sharing_stats: false,
|
2015-10-23 00:54:01 +03:00
|
|
|
convert_mouse_to_touch: false,
|
2015-07-21 00:37:33 +03:00
|
|
|
exit_after_load: false,
|
2015-09-29 22:45:57 +03:00
|
|
|
no_native_titlebar: false,
|
2015-12-01 02:56:00 +03:00
|
|
|
enable_vsync: true,
|
2016-02-18 22:24:06 +03:00
|
|
|
webrender_stats: false,
|
|
|
|
use_msaa: false,
|
2016-05-25 10:52:10 +03:00
|
|
|
config_dir: None,
|
2016-04-05 10:32:01 +03:00
|
|
|
full_backtraces: false,
|
2016-06-29 17:05:35 +03:00
|
|
|
is_printing_version: false,
|
2016-08-03 15:50:06 +03:00
|
|
|
webrender_debug: false,
|
2016-11-18 17:29:27 +03:00
|
|
|
webrender_record: false,
|
2017-05-22 03:07:40 +03:00
|
|
|
webrender_batch: true,
|
2016-09-16 04:23:30 +03:00
|
|
|
precache_shaders: false,
|
2016-10-01 12:18:56 +03:00
|
|
|
signpost: false,
|
2017-04-06 13:53:14 +03:00
|
|
|
certificate_path: None,
|
2017-04-12 19:11:23 +03:00
|
|
|
unminify_js: false,
|
2017-07-20 21:34:35 +03:00
|
|
|
print_pwm: false,
|
2014-10-28 21:36:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-20 01:29:48 +03:00
|
|
|
pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
|
2015-07-30 23:46:13 +03:00
|
|
|
let (app_name, args) = args.split_first().unwrap();
|
2012-11-13 00:08:38 +04:00
|
|
|
|
2015-08-07 23:05:19 +03:00
|
|
|
let mut opts = Options::new();
|
2017-01-24 22:14:28 +03:00
|
|
|
opts.optflag("c", "cpu", "CPU painting");
|
|
|
|
opts.optflag("g", "gpu", "GPU painting");
|
2015-08-07 23:05:19 +03:00
|
|
|
opts.optopt("o", "output", "Output file", "output.png");
|
|
|
|
opts.optopt("s", "size", "Size of tiles", "512");
|
|
|
|
opts.optopt("", "device-pixel-ratio", "Device pixels per px", "");
|
|
|
|
opts.optopt("t", "threads", "Number of paint threads", "1");
|
2016-05-20 18:09:58 +03:00
|
|
|
opts.optflagopt("p", "profile", "Time profiler flag and either a TSV output filename \
|
2016-05-12 03:19:53 +03:00
|
|
|
OR an interval for output to Stdout (blank for Stdout with interval of 5s)", "10 \
|
2016-05-20 18:09:58 +03:00
|
|
|
OR time.tsv");
|
2016-04-28 12:47:35 +03:00
|
|
|
opts.optflagopt("", "profiler-trace-path",
|
|
|
|
"Path to dump a self-contained HTML timeline of profiler traces",
|
|
|
|
"");
|
2015-08-07 23:05:19 +03:00
|
|
|
opts.optflagopt("m", "memory-profile", "Memory profiler flag and output interval", "10");
|
|
|
|
opts.optflag("x", "exit", "Exit after load flag");
|
|
|
|
opts.optopt("y", "layout-threads", "Number of threads to use for layout", "1");
|
|
|
|
opts.optflag("i", "nonincremental-layout", "Enable to turn off incremental layout.");
|
|
|
|
opts.optflagopt("", "userscripts",
|
2015-09-02 21:05:58 +03:00
|
|
|
"Uses userscripts in resources/user-agent-js, or a specified full path", "");
|
2015-08-07 23:05:19 +03:00
|
|
|
opts.optmulti("", "user-stylesheet",
|
|
|
|
"A user stylesheet to be added to every document", "file.css");
|
|
|
|
opts.optflag("z", "headless", "Headless mode");
|
2016-01-10 13:19:04 +03:00
|
|
|
opts.optflag("f", "hard-fail", "Exit on thread failure instead of displaying about:failure");
|
2016-04-07 08:18:10 +03:00
|
|
|
opts.optflag("F", "soft-fail", "Display about:failure on thread failure instead of exiting");
|
2016-09-12 18:19:17 +03:00
|
|
|
opts.optflagopt("", "remote-debugging-port", "Start remote debugger server on port", "2794");
|
2015-08-07 23:05:19 +03:00
|
|
|
opts.optflagopt("", "devtools", "Start remote devtools server on port", "6000");
|
|
|
|
opts.optflagopt("", "webdriver", "Start remote WebDriver server on port", "7000");
|
2016-07-01 06:43:02 +03:00
|
|
|
opts.optopt("", "resolution", "Set window resolution.", "1024x740");
|
2015-08-18 07:44:38 +03:00
|
|
|
opts.optopt("u",
|
|
|
|
"user-agent",
|
2017-08-24 00:05:35 +03:00
|
|
|
"Set custom user agent string (or ios / android / desktop for platform default)",
|
2015-08-18 07:44:38 +03:00
|
|
|
"NCSA Mosaic/1.0 (X11;SunOS 4.1.4 sun4m)");
|
2015-08-07 23:05:19 +03:00
|
|
|
opts.optflag("M", "multiprocess", "Run in multiprocess mode");
|
2015-11-20 01:29:48 +03:00
|
|
|
opts.optflag("S", "sandbox", "Run in a sandbox if multiprocess");
|
2016-03-26 18:45:59 +03:00
|
|
|
opts.optopt("",
|
|
|
|
"random-pipeline-closure-probability",
|
|
|
|
"Probability of randomly closing a pipeline (for testing constellation hardening).",
|
|
|
|
"0.0");
|
|
|
|
opts.optopt("", "random-pipeline-closure-seed", "A fixed seed for repeatbility of random pipeline closure.", "");
|
2016-11-22 11:23:48 +03:00
|
|
|
opts.optmulti("Z", "debug",
|
|
|
|
"A comma-separated string of debug options. Pass help to show available options.", "");
|
2015-08-07 23:05:19 +03:00
|
|
|
opts.optflag("h", "help", "Print this message");
|
|
|
|
opts.optopt("", "resources-path", "Path to find static resources", "/home/servo/resources");
|
2017-04-06 13:53:14 +03:00
|
|
|
opts.optopt("", "certificate-path", "Path to find SSL certificates", "/home/servo/resources/certs");
|
2015-11-20 01:29:48 +03:00
|
|
|
opts.optopt("", "content-process" , "Run as a content process and connect to the given pipe",
|
|
|
|
"servo-ipc-channel.abcdefg");
|
2015-08-28 19:08:32 +03:00
|
|
|
opts.optmulti("", "pref",
|
|
|
|
"A preference to set to enable", "dom.mozbrowser.enabled");
|
2015-09-29 22:45:57 +03:00
|
|
|
opts.optflag("b", "no-native-titlebar", "Do not use native titlebar");
|
2017-01-24 22:14:28 +03:00
|
|
|
opts.optflag("w", "webrender", "Use webrender backend");
|
2016-03-11 00:23:59 +03:00
|
|
|
opts.optopt("G", "graphics", "Select graphics backend (gl or es2)", "gl");
|
2016-05-25 10:52:10 +03:00
|
|
|
opts.optopt("", "config-dir",
|
|
|
|
"config directory following xdg spec on linux platform", "");
|
2016-06-29 17:05:35 +03:00
|
|
|
opts.optflag("v", "version", "Display servo version information");
|
2017-04-12 19:11:23 +03:00
|
|
|
opts.optflag("", "unminify-js", "Unminify Javascript");
|
2017-07-06 18:27:55 +03:00
|
|
|
opts.optopt("", "profiler-db-user", "Profiler database user", "");
|
|
|
|
opts.optopt("", "profiler-db-pass", "Profiler database password", "");
|
|
|
|
opts.optopt("", "profiler-db-name", "Profiler database name", "");
|
2017-07-20 21:34:35 +03:00
|
|
|
opts.optflag("", "print-pwm", "Print Progressive Web Metrics");
|
2016-05-25 10:52:10 +03:00
|
|
|
|
2015-08-07 23:05:19 +03:00
|
|
|
let opt_match = match opts.parse(args) {
|
2013-10-26 04:01:22 +04:00
|
|
|
Ok(m) => m,
|
2015-06-26 21:55:23 +03:00
|
|
|
Err(f) => args_fail(&f.to_string()),
|
2012-11-13 00:08:38 +04:00
|
|
|
};
|
2013-07-11 03:15:51 +04:00
|
|
|
|
2015-09-25 17:18:06 +03:00
|
|
|
set_resources_path(opt_match.opt_str("resources-path"));
|
|
|
|
|
2013-11-19 03:58:28 +04:00
|
|
|
if opt_match.opt_present("h") || opt_match.opt_present("help") {
|
2015-07-30 23:46:13 +03:00
|
|
|
print_usage(app_name, &opts);
|
2015-06-26 21:55:23 +03:00
|
|
|
process::exit(0);
|
2013-11-19 03:58:28 +04:00
|
|
|
};
|
|
|
|
|
2015-11-20 01:29:48 +03:00
|
|
|
// If this is the content process, we'll receive the real options over IPC. So just fill in
|
|
|
|
// some dummy options for now.
|
|
|
|
if let Some(content_process) = opt_match.opt_str("content-process") {
|
|
|
|
MULTIPROCESS.store(true, Ordering::SeqCst);
|
|
|
|
return ArgumentParsingResult::ContentProcess(content_process);
|
|
|
|
}
|
|
|
|
|
2016-11-22 11:23:48 +03:00
|
|
|
let mut debug_options = DebugOptions::default();
|
2015-08-14 03:11:57 +03:00
|
|
|
|
2016-11-22 11:23:48 +03:00
|
|
|
for debug_string in opt_match.opt_strs("Z") {
|
|
|
|
if let Err(e) = debug_options.extend(debug_string) {
|
2016-11-29 23:20:58 +03:00
|
|
|
args_fail(&format!("error: unrecognized debug option: {}", e));
|
2016-11-22 11:23:48 +03:00
|
|
|
}
|
|
|
|
}
|
2015-08-14 03:11:57 +03:00
|
|
|
|
|
|
|
if debug_options.help {
|
2015-07-30 23:46:13 +03:00
|
|
|
print_debug_usage(app_name)
|
2014-11-04 21:36:30 +03:00
|
|
|
}
|
|
|
|
|
2015-08-07 23:05:19 +03:00
|
|
|
let cwd = env::current_dir().unwrap();
|
2015-09-25 17:18:06 +03:00
|
|
|
let url_opt = if !opt_match.free.is_empty() {
|
|
|
|
Some(&opt_match.free[0][..])
|
2012-11-13 00:08:38 +04:00
|
|
|
} else {
|
2017-06-12 07:16:06 +03:00
|
|
|
None
|
2015-09-25 17:18:06 +03:00
|
|
|
};
|
2015-11-05 01:38:30 +03:00
|
|
|
let is_running_problem_test =
|
|
|
|
url_opt
|
|
|
|
.as_ref()
|
2016-01-03 06:46:34 +03:00
|
|
|
.map_or(false, |url|
|
2015-11-05 01:38:30 +03:00
|
|
|
url.starts_with("http://web-platform.test:8000/2dcontext/drawing-images-to-the-canvas/") ||
|
|
|
|
url.starts_with("http://web-platform.test:8000/_mozilla/mozilla/canvas/") ||
|
2016-01-03 06:46:34 +03:00
|
|
|
url.starts_with("http://web-platform.test:8000/_mozilla/css/canvas_over_area.html"));
|
2015-11-05 01:38:30 +03:00
|
|
|
|
2017-06-12 07:16:06 +03:00
|
|
|
let url_opt = url_opt.and_then(|url_string| parse_url_or_filename(&cwd, url_string)
|
|
|
|
.or_else(|error| {
|
|
|
|
warn!("URL parsing failed ({:?}).", error);
|
|
|
|
Err(error)
|
|
|
|
}).ok());
|
2012-11-13 00:08:38 +04:00
|
|
|
|
2015-02-28 17:21:53 +03:00
|
|
|
let tile_size: usize = match opt_match.opt_str("s") {
|
2016-03-27 12:21:34 +03:00
|
|
|
Some(tile_size_str) => tile_size_str.parse()
|
|
|
|
.unwrap_or_else(|err| args_fail(&format!("Error parsing option: -s ({})", err))),
|
2012-11-16 08:47:27 +04:00
|
|
|
None => 512,
|
|
|
|
};
|
|
|
|
|
2014-06-03 00:52:32 +04:00
|
|
|
let device_pixels_per_px = opt_match.opt_str("device-pixel-ratio").map(|dppx_str|
|
2016-03-27 12:21:34 +03:00
|
|
|
dppx_str.parse()
|
|
|
|
.unwrap_or_else(|err| args_fail(&format!("Error parsing option: --device-pixel-ratio ({})", err)))
|
2014-06-03 00:52:32 +04:00
|
|
|
);
|
|
|
|
|
2016-05-12 03:19:53 +03:00
|
|
|
// If only the flag is present, default to a 5 second period for both profilers
|
|
|
|
let time_profiling = if opt_match.opt_present("p") {
|
|
|
|
match opt_match.opt_str("p") {
|
|
|
|
Some(argument) => match argument.parse::<f64>() {
|
|
|
|
Ok(interval) => Some(OutputOptions::Stdout(interval)) ,
|
2017-07-06 18:27:55 +03:00
|
|
|
Err(_) => {
|
|
|
|
match ServoUrl::parse(&argument) {
|
|
|
|
Ok(url) => Some(OutputOptions::DB(url, opt_match.opt_str("profiler-db-name"),
|
|
|
|
opt_match.opt_str("profiler-db-user"),
|
|
|
|
opt_match.opt_str("profiler-db-pass"))),
|
|
|
|
Err(_) => Some(OutputOptions::FileName(argument)),
|
|
|
|
}
|
|
|
|
}
|
2016-05-12 03:19:53 +03:00
|
|
|
},
|
2016-08-14 10:27:19 +03:00
|
|
|
None => Some(OutputOptions::Stdout(5.0 as f64)),
|
2016-05-12 03:19:53 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// if the p option doesn't exist:
|
|
|
|
None
|
|
|
|
};
|
2016-02-16 20:43:55 +03:00
|
|
|
|
2016-04-28 12:47:35 +03:00
|
|
|
if let Some(ref time_profiler_trace_path) = opt_match.opt_str("profiler-trace-path") {
|
|
|
|
let mut path = PathBuf::from(time_profiler_trace_path);
|
|
|
|
path.pop();
|
|
|
|
if let Err(why) = fs::create_dir_all(&path) {
|
|
|
|
error!("Couldn't create/open {:?}: {:?}",
|
|
|
|
Path::new(time_profiler_trace_path).to_string_lossy(), why);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-26 06:18:48 +03:00
|
|
|
let mem_profiler_period = opt_match.opt_default("m", "5").map(|period| {
|
2016-03-27 12:21:34 +03:00
|
|
|
period.parse().unwrap_or_else(|err| args_fail(&format!("Error parsing option: -m ({})", err)))
|
2014-01-13 07:16:21 +04:00
|
|
|
});
|
2013-06-14 04:45:25 +04:00
|
|
|
|
2016-08-14 10:27:19 +03:00
|
|
|
let mut layout_threads: Option<usize> = opt_match.opt_str("y")
|
|
|
|
.map(|layout_threads_str| {
|
|
|
|
layout_threads_str.parse()
|
|
|
|
.unwrap_or_else(|err| args_fail(&format!("Error parsing option: -y ({})", err)))
|
|
|
|
});
|
2014-01-23 04:04:08 +04:00
|
|
|
|
2014-10-20 22:54:34 +04:00
|
|
|
let nonincremental_layout = opt_match.opt_present("i");
|
2014-10-15 02:51:30 +04:00
|
|
|
|
2016-03-26 18:45:59 +03:00
|
|
|
let random_pipeline_closure_probability = opt_match.opt_str("random-pipeline-closure-probability").map(|prob|
|
2016-03-27 12:21:34 +03:00
|
|
|
prob.parse().unwrap_or_else(|err| {
|
|
|
|
args_fail(&format!("Error parsing option: --random-pipeline-closure-probability ({})", err))
|
|
|
|
})
|
2016-03-26 18:45:59 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
let random_pipeline_closure_seed = opt_match.opt_str("random-pipeline-closure-seed").map(|seed|
|
2016-03-27 12:21:34 +03:00
|
|
|
seed.parse().unwrap_or_else(|err| {
|
|
|
|
args_fail(&format!("Error parsing option: --random-pipeline-closure-seed ({})", err))
|
|
|
|
})
|
2016-03-26 18:45:59 +03:00
|
|
|
);
|
|
|
|
|
2015-08-14 03:11:57 +03:00
|
|
|
let mut bubble_inline_sizes_separately = debug_options.bubble_widths;
|
|
|
|
if debug_options.trace_layout {
|
2016-08-14 10:27:19 +03:00
|
|
|
layout_threads = Some(1);
|
2014-09-08 10:33:09 +04:00
|
|
|
bubble_inline_sizes_separately = true;
|
|
|
|
}
|
|
|
|
|
2016-09-12 18:19:17 +03:00
|
|
|
let debugger_port = opt_match.opt_default("remote-debugging-port", "2794").map(|port| {
|
|
|
|
port.parse()
|
|
|
|
.unwrap_or_else(|err| args_fail(&format!("Error parsing option: --remote-debugging-port ({})", err)))
|
|
|
|
});
|
|
|
|
|
2014-10-08 18:24:36 +04:00
|
|
|
let devtools_port = opt_match.opt_default("devtools", "6000").map(|port| {
|
2016-03-27 12:21:34 +03:00
|
|
|
port.parse().unwrap_or_else(|err| args_fail(&format!("Error parsing option: --devtools ({})", err)))
|
2014-10-08 18:24:36 +04:00
|
|
|
});
|
|
|
|
|
2015-04-07 06:09:44 +03:00
|
|
|
let webdriver_port = opt_match.opt_default("webdriver", "7000").map(|port| {
|
2016-03-27 12:21:34 +03:00
|
|
|
port.parse().unwrap_or_else(|err| args_fail(&format!("Error parsing option: --webdriver ({})", err)))
|
2015-04-07 06:09:44 +03:00
|
|
|
});
|
|
|
|
|
2014-09-26 04:27:38 +04:00
|
|
|
let initial_window_size = match opt_match.opt_str("resolution") {
|
|
|
|
Some(res_string) => {
|
2016-02-16 20:43:55 +03:00
|
|
|
let res: Vec<u32> = res_string.split('x').map(|r| {
|
2016-03-27 12:21:34 +03:00
|
|
|
r.parse().unwrap_or_else(|err| args_fail(&format!("Error parsing option: --resolution ({})", err)))
|
2016-02-16 20:43:55 +03:00
|
|
|
}).collect();
|
2016-08-12 04:12:29 +03:00
|
|
|
TypedSize2D::new(res[0], res[1])
|
2014-09-26 04:27:38 +04:00
|
|
|
}
|
|
|
|
None => {
|
2016-08-12 04:12:29 +03:00
|
|
|
TypedSize2D::new(1024, 740)
|
2014-09-26 04:27:38 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-11-20 01:29:48 +03:00
|
|
|
if opt_match.opt_present("M") {
|
|
|
|
MULTIPROCESS.store(true, Ordering::SeqCst)
|
|
|
|
}
|
|
|
|
|
2015-08-18 07:44:38 +03:00
|
|
|
let user_agent = match opt_match.opt_str("u") {
|
2017-08-24 00:05:35 +03:00
|
|
|
Some(ref ua) if ua == "ios" => default_user_agent_string(UserAgent::iOS).into(),
|
2016-10-11 12:04:20 +03:00
|
|
|
Some(ref ua) if ua == "android" => default_user_agent_string(UserAgent::Android).into(),
|
|
|
|
Some(ref ua) if ua == "desktop" => default_user_agent_string(UserAgent::Desktop).into(),
|
|
|
|
Some(ua) => ua.into(),
|
|
|
|
None => default_user_agent_string(DEFAULT_USER_AGENT).into(),
|
2015-08-18 07:44:38 +03:00
|
|
|
};
|
2015-08-11 03:18:27 +03:00
|
|
|
|
2015-08-07 23:05:19 +03:00
|
|
|
let user_stylesheets = opt_match.opt_strs("user-stylesheet").iter().map(|filename| {
|
|
|
|
let path = cwd.join(filename);
|
2016-11-18 00:34:47 +03:00
|
|
|
let url = ServoUrl::from_url(Url::from_file_path(&path).unwrap());
|
2015-08-07 23:05:19 +03:00
|
|
|
let mut contents = Vec::new();
|
|
|
|
File::open(path)
|
2016-10-10 04:12:38 +03:00
|
|
|
.unwrap_or_else(|err| args_fail(&format!("Couldn't open {}: {}", filename, err)))
|
2015-08-07 23:05:19 +03:00
|
|
|
.read_to_end(&mut contents)
|
2016-10-10 04:12:38 +03:00
|
|
|
.unwrap_or_else(|err| args_fail(&format!("Couldn't read {}: {}", filename, err)));
|
2015-08-07 23:05:19 +03:00
|
|
|
(contents, url)
|
|
|
|
}).collect();
|
|
|
|
|
2016-04-02 03:41:46 +03:00
|
|
|
let do_not_use_native_titlebar =
|
|
|
|
opt_match.opt_present("b") ||
|
2016-07-03 18:19:04 +03:00
|
|
|
!PREFS.get("shell.native-titlebar.enabled").as_boolean().unwrap();
|
2016-04-02 03:41:46 +03:00
|
|
|
|
2016-06-29 17:05:35 +03:00
|
|
|
let is_printing_version = opt_match.opt_present("v") || opt_match.opt_present("version");
|
|
|
|
|
2014-10-14 01:21:44 +04:00
|
|
|
let opts = Opts {
|
2015-11-05 01:38:30 +03:00
|
|
|
is_running_problem_test: is_running_problem_test,
|
2017-06-12 07:16:06 +03:00
|
|
|
url: url_opt,
|
2012-11-16 08:47:27 +04:00
|
|
|
tile_size: tile_size,
|
2014-06-03 00:52:32 +04:00
|
|
|
device_pixels_per_px: device_pixels_per_px,
|
2016-05-12 03:19:53 +03:00
|
|
|
time_profiling: time_profiling,
|
2016-04-28 12:47:35 +03:00
|
|
|
time_profiler_trace_path: opt_match.opt_str("profiler-trace-path"),
|
2015-03-26 06:18:48 +03:00
|
|
|
mem_profiler_period: mem_profiler_period,
|
2014-10-20 22:54:34 +04:00
|
|
|
nonincremental_layout: nonincremental_layout,
|
2015-04-01 22:15:46 +03:00
|
|
|
userscripts: opt_match.opt_default("userscripts", ""),
|
2015-08-07 23:05:19 +03:00
|
|
|
user_stylesheets: user_stylesheets,
|
2013-10-23 00:52:14 +04:00
|
|
|
output_file: opt_match.opt_str("o"),
|
2015-08-14 03:11:57 +03:00
|
|
|
replace_surrogates: debug_options.replace_surrogates,
|
|
|
|
gc_profile: debug_options.gc_profile,
|
2015-11-07 07:23:19 +03:00
|
|
|
load_webfonts_synchronously: debug_options.load_webfonts_synchronously,
|
2013-10-23 00:52:14 +04:00
|
|
|
headless: opt_match.opt_present("z"),
|
2016-04-07 08:18:10 +03:00
|
|
|
hard_fail: opt_match.opt_present("f") && !opt_match.opt_present("F"),
|
2014-09-08 10:33:09 +04:00
|
|
|
bubble_inline_sizes_separately: bubble_inline_sizes_separately,
|
2015-08-28 02:00:15 +03:00
|
|
|
profile_script_events: debug_options.profile_script_events,
|
2015-10-30 09:56:10 +03:00
|
|
|
profile_heartbeats: debug_options.profile_heartbeats,
|
2015-08-14 03:11:57 +03:00
|
|
|
trace_layout: debug_options.trace_layout,
|
2016-09-12 18:19:17 +03:00
|
|
|
debugger_port: debugger_port,
|
2014-10-08 18:24:36 +04:00
|
|
|
devtools_port: devtools_port,
|
2015-04-07 06:09:44 +03:00
|
|
|
webdriver_port: webdriver_port,
|
2014-09-26 04:27:38 +04:00
|
|
|
initial_window_size: initial_window_size,
|
2015-08-11 03:18:27 +03:00
|
|
|
user_agent: user_agent,
|
2015-07-31 18:43:40 +03:00
|
|
|
multiprocess: opt_match.opt_present("M"),
|
2015-11-20 01:29:48 +03:00
|
|
|
sandbox: opt_match.opt_present("S"),
|
2016-03-26 18:45:59 +03:00
|
|
|
random_pipeline_closure_probability: random_pipeline_closure_probability,
|
|
|
|
random_pipeline_closure_seed: random_pipeline_closure_seed,
|
2015-08-14 03:11:57 +03:00
|
|
|
show_debug_fragment_borders: debug_options.show_fragment_borders,
|
|
|
|
show_debug_parallel_layout: debug_options.show_parallel_layout,
|
|
|
|
enable_text_antialiasing: !debug_options.disable_text_aa,
|
2017-05-08 04:27:46 +03:00
|
|
|
enable_subpixel_text_antialiasing: !debug_options.disable_subpixel_aa,
|
2015-08-14 03:11:57 +03:00
|
|
|
enable_canvas_antialiasing: !debug_options.disable_canvas_aa,
|
2016-08-13 04:55:27 +03:00
|
|
|
dump_style_tree: debug_options.dump_style_tree,
|
2016-11-06 01:11:24 +03:00
|
|
|
dump_rule_tree: debug_options.dump_rule_tree,
|
2015-08-14 03:11:57 +03:00
|
|
|
dump_flow_tree: debug_options.dump_flow_tree,
|
|
|
|
dump_display_list: debug_options.dump_display_list,
|
|
|
|
dump_display_list_json: debug_options.dump_display_list_json,
|
|
|
|
relayout_event: debug_options.relayout_event,
|
|
|
|
disable_share_style_cache: debug_options.disable_share_style_cache,
|
2016-08-18 00:34:30 +03:00
|
|
|
style_sharing_stats: debug_options.style_sharing_stats,
|
2015-10-23 00:54:01 +03:00
|
|
|
convert_mouse_to_touch: debug_options.convert_mouse_to_touch,
|
2015-07-21 00:37:33 +03:00
|
|
|
exit_after_load: opt_match.opt_present("x"),
|
2016-04-02 03:41:46 +03:00
|
|
|
no_native_titlebar: do_not_use_native_titlebar,
|
2015-12-01 02:56:00 +03:00
|
|
|
enable_vsync: !debug_options.disable_vsync,
|
2016-02-18 22:24:06 +03:00
|
|
|
webrender_stats: debug_options.webrender_stats,
|
|
|
|
use_msaa: debug_options.use_msaa,
|
2016-11-12 14:56:59 +03:00
|
|
|
config_dir: opt_match.opt_str("config-dir").map(Into::into),
|
2016-04-05 10:32:01 +03:00
|
|
|
full_backtraces: debug_options.full_backtraces,
|
2016-06-29 17:05:35 +03:00
|
|
|
is_printing_version: is_printing_version,
|
2016-08-03 15:50:06 +03:00
|
|
|
webrender_debug: debug_options.webrender_debug,
|
2016-11-18 17:29:27 +03:00
|
|
|
webrender_record: debug_options.webrender_record,
|
2017-05-24 17:21:07 +03:00
|
|
|
webrender_batch: !debug_options.webrender_disable_batch,
|
2016-09-16 04:23:30 +03:00
|
|
|
precache_shaders: debug_options.precache_shaders,
|
2016-10-01 12:18:56 +03:00
|
|
|
signpost: debug_options.signpost,
|
2017-04-06 13:53:14 +03:00
|
|
|
certificate_path: opt_match.opt_str("certificate-path"),
|
2017-04-12 19:11:23 +03:00
|
|
|
unminify_js: opt_match.opt_present("unminify-js"),
|
2017-07-20 21:34:35 +03:00
|
|
|
print_pwm: opt_match.opt_present("print-pwm"),
|
2014-10-14 01:21:44 +04:00
|
|
|
};
|
|
|
|
|
2015-07-21 16:17:47 +03:00
|
|
|
set_defaults(opts);
|
2014-07-19 00:27:23 +04:00
|
|
|
|
2016-04-02 06:03:42 +03:00
|
|
|
// These must happen after setting the default options, since the prefs rely on
|
2015-08-28 19:08:32 +03:00
|
|
|
// on the resource path.
|
2016-04-02 06:03:42 +03:00
|
|
|
// Note that command line preferences have the highest precedence
|
2016-05-25 10:52:10 +03:00
|
|
|
|
|
|
|
prefs::add_user_prefs();
|
|
|
|
|
2015-08-28 19:08:32 +03:00
|
|
|
for pref in opt_match.opt_strs("pref").iter() {
|
2017-01-05 23:09:01 +03:00
|
|
|
parse_pref_from_command_line(pref);
|
2015-08-28 19:08:32 +03:00
|
|
|
}
|
2015-11-20 01:29:48 +03:00
|
|
|
|
2016-08-14 10:27:19 +03:00
|
|
|
if let Some(layout_threads) = layout_threads {
|
|
|
|
PREFS.set("layout.threads", PrefValue::Number(layout_threads as f64));
|
|
|
|
} else if let Some(layout_threads) = PREFS.get("layout.threads").as_string() {
|
|
|
|
PREFS.set("layout.threads", PrefValue::Number(layout_threads.parse::<f64>().unwrap()));
|
|
|
|
} else if *PREFS.get("layout.threads") == PrefValue::Missing {
|
|
|
|
let layout_threads = cmp::max(num_cpus::get() * 3 / 4, 1);
|
|
|
|
PREFS.set("layout.threads", PrefValue::Number(layout_threads as f64));
|
|
|
|
}
|
|
|
|
|
2015-11-20 01:29:48 +03:00
|
|
|
ArgumentParsingResult::ChromeProcess
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum ArgumentParsingResult {
|
|
|
|
ChromeProcess,
|
|
|
|
ContentProcess(String),
|
|
|
|
}
|
|
|
|
|
2014-10-14 01:21:44 +04:00
|
|
|
// Make Opts available globally. This saves having to clone and pass
|
|
|
|
// opts everywhere it is used, which gets particularly cumbersome
|
|
|
|
// when passing through the DOM structures.
|
2015-07-21 16:17:47 +03:00
|
|
|
static mut DEFAULT_OPTIONS: *mut Opts = 0 as *mut Opts;
|
|
|
|
const INVALID_OPTIONS: *mut Opts = 0x01 as *mut Opts;
|
|
|
|
|
|
|
|
lazy_static! {
|
|
|
|
static ref OPTIONS: Opts = {
|
2015-08-28 19:08:32 +03:00
|
|
|
unsafe {
|
2015-07-21 16:17:47 +03:00
|
|
|
let initial = if !DEFAULT_OPTIONS.is_null() {
|
|
|
|
let opts = Box::from_raw(DEFAULT_OPTIONS);
|
|
|
|
*opts
|
|
|
|
} else {
|
|
|
|
default_opts()
|
|
|
|
};
|
|
|
|
DEFAULT_OPTIONS = INVALID_OPTIONS;
|
|
|
|
initial
|
2015-08-28 19:08:32 +03:00
|
|
|
}
|
2015-07-21 16:17:47 +03:00
|
|
|
};
|
|
|
|
}
|
2014-10-14 01:21:44 +04:00
|
|
|
|
2015-07-21 16:17:47 +03:00
|
|
|
pub fn set_defaults(opts: Opts) {
|
2014-10-20 07:33:25 +04:00
|
|
|
unsafe {
|
2015-07-21 16:17:47 +03:00
|
|
|
assert!(DEFAULT_OPTIONS.is_null());
|
|
|
|
assert!(DEFAULT_OPTIONS != INVALID_OPTIONS);
|
2016-06-22 17:43:20 +03:00
|
|
|
let box_opts = Box::new(opts);
|
2015-07-21 16:17:47 +03:00
|
|
|
DEFAULT_OPTIONS = Box::into_raw(box_opts);
|
2014-10-20 07:33:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-05 23:09:01 +03:00
|
|
|
pub fn parse_pref_from_command_line(pref: &str) {
|
|
|
|
let split: Vec<&str> = pref.splitn(2, '=').collect();
|
|
|
|
let pref_name = split[0];
|
|
|
|
let value = split.get(1);
|
|
|
|
match value {
|
|
|
|
Some(&"false") => PREFS.set(pref_name, PrefValue::Boolean(false)),
|
|
|
|
Some(&"true") | None => PREFS.set(pref_name, PrefValue::Boolean(true)),
|
|
|
|
Some(value) => match value.parse::<f64>() {
|
|
|
|
Ok(v) => PREFS.set(pref_name, PrefValue::Number(v)),
|
|
|
|
Err(_) => PREFS.set(pref_name, PrefValue::String(value.to_string()))
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-10-20 07:33:25 +04:00
|
|
|
#[inline]
|
2015-07-21 16:17:47 +03:00
|
|
|
pub fn get() -> &'static Opts {
|
|
|
|
&OPTIONS
|
2014-10-14 01:21:44 +04:00
|
|
|
}
|
2015-09-12 18:10:37 +03:00
|
|
|
|
2016-11-18 00:34:47 +03:00
|
|
|
pub fn parse_url_or_filename(cwd: &Path, input: &str) -> Result<ServoUrl, ()> {
|
|
|
|
match ServoUrl::parse(input) {
|
2015-09-12 18:10:37 +03:00
|
|
|
Ok(url) => Ok(url),
|
|
|
|
Err(url::ParseError::RelativeUrlWithoutBase) => {
|
2016-11-18 00:34:47 +03:00
|
|
|
Url::from_file_path(&*cwd.join(input)).map(ServoUrl::from_url)
|
2015-09-12 18:10:37 +03:00
|
|
|
}
|
|
|
|
Err(_) => Err(()),
|
|
|
|
}
|
|
|
|
}
|
2016-09-28 05:46:13 +03:00
|
|
|
|
|
|
|
impl Opts {
|
|
|
|
pub fn should_use_osmesa(&self) -> bool {
|
|
|
|
self.headless
|
|
|
|
}
|
|
|
|
}
|