зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #3601 - Read user-agent.css at run time. Fix #3516 (from SimonSapin:runtime-ua-stylesheet); r=jdm
When we want to use Servo binaries outside of their `target` build directory, `./resources` is what we’ll need to ship with them. r? @jdm Source-Repo: https://github.com/servo/servo Source-Revision: 8312fde154768c4a5ce133a1aaaf1293529a5558 --HG-- rename : servo/tests/html/failure.html => servo/resources/failure.html rename : servo/components/style/user-agent.css => servo/resources/user-agent.css
This commit is contained in:
Родитель
949eeba3a8
Коммит
006cccd339
|
@ -5,10 +5,10 @@
|
|||
use resource_task::{LoadResponse, Metadata, Done, LoadData, start_sending};
|
||||
use file_loader;
|
||||
|
||||
use std::os;
|
||||
use std::io::fs::PathExtensions;
|
||||
use url::Url;
|
||||
use http::status::Ok as StatusOk;
|
||||
use servo_util::resource_files::resources_dir_path;
|
||||
|
||||
|
||||
pub fn factory(mut load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
||||
|
@ -26,13 +26,8 @@ pub fn factory(mut load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
|||
}
|
||||
"crash" => fail!("Loading the about:crash URL."),
|
||||
"failure" => {
|
||||
// FIXME: Find a way to load this without relying on the `../src` directory.
|
||||
let mut path = os::self_exe_path().expect("can't get exe path");
|
||||
path.pop();
|
||||
if !path.join(Path::new("./tests/")).is_dir() {
|
||||
path.pop();
|
||||
}
|
||||
path.push_many(["tests", "html", "failure.html"]);
|
||||
let mut path = resources_dir_path();
|
||||
path.push("failure.html");
|
||||
assert!(path.exists());
|
||||
load_data.url = Url::from_file_path(&path).unwrap();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use sync::Arc;
|
|||
use url::Url;
|
||||
|
||||
use servo_util::bloom::BloomFilter;
|
||||
use servo_util::resource_files::read_resource_file;
|
||||
use servo_util::smallvec::VecLike;
|
||||
use servo_util::sort;
|
||||
use string_cache::Atom;
|
||||
|
@ -279,7 +280,7 @@ impl Stylist {
|
|||
rules_source_order: 0u,
|
||||
};
|
||||
let ua_stylesheet = Stylesheet::from_bytes(
|
||||
include_bin!("user-agent.css"),
|
||||
read_resource_file(["user-agent.css"]).unwrap().as_slice(),
|
||||
Url::parse("chrome:///user-agent.css").unwrap(),
|
||||
None,
|
||||
None);
|
||||
|
|
|
@ -42,6 +42,7 @@ pub mod memory;
|
|||
pub mod namespace;
|
||||
pub mod opts;
|
||||
pub mod range;
|
||||
pub mod resource_files;
|
||||
pub mod smallvec;
|
||||
pub mod sort;
|
||||
pub mod str;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/* 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/. */
|
||||
|
||||
use std::io::{File, IoResult};
|
||||
use std::io::fs::PathExtensions;
|
||||
use std::os;
|
||||
use std::path::Path;
|
||||
|
||||
|
||||
pub fn resources_dir_path() -> Path {
|
||||
// FIXME: Find a way to not rely on the executable being under `<servo source>/target`.
|
||||
let mut path = os::self_exe_path().expect("can't get exe path");
|
||||
path.pop();
|
||||
path.push("resources");
|
||||
if !path.is_dir() {
|
||||
path.pop();
|
||||
path.pop();
|
||||
path.push("resources");
|
||||
}
|
||||
path
|
||||
}
|
||||
|
||||
|
||||
pub fn read_resource_file(relative_path_components: &[&str]) -> IoResult<Vec<u8>> {
|
||||
let mut path = resources_dir_path();
|
||||
path.push_many(relative_path_components);
|
||||
let mut file = try!(File::open(&path));
|
||||
file.read_to_end()
|
||||
}
|
|
@ -4,8 +4,8 @@ body, div,
|
|||
dt, fieldset, form,
|
||||
frame, frameset,
|
||||
h1, h2, h3, h4,
|
||||
h5, h6, noframes,
|
||||
center, dir,
|
||||
h5, h6, noframes,
|
||||
center, dir,
|
||||
hr, menu, pre { display: block; unicode-bidi: embed }
|
||||
head, noscript { display: none }
|
||||
table { display: table }
|
||||
|
@ -54,7 +54,7 @@ thead, tbody,
|
|||
/* lists */
|
||||
dd { display: block; margin-left: 40px }
|
||||
p, dl, multicol { display: block; margin: 1em 0 }
|
||||
ul { display: block; list-style-type: disc;
|
||||
ul { display: block; list-style-type: disc;
|
||||
margin: 1em 0; padding-left: 40px }
|
||||
|
||||
ol { display: block; list-style-type: decimal;
|
Загрузка…
Ссылка в новой задаче