Stop using servo UA stylesheets for geckolib.

Gecko will provide these. This also removes the need to reference
the servo resource directory.
This commit is contained in:
Bobby Holley 2016-03-02 16:38:53 -08:00
parent c4aa7cd862
commit 4da1171474
4 changed files with 9 additions and 64 deletions

View file

@ -19,7 +19,7 @@ pub trait SelectorImplExt : SelectorImpl + Sized {
fn get_user_or_user_agent_stylesheets() -> &'static [Stylesheet<Self>]; fn get_user_or_user_agent_stylesheets() -> &'static [Stylesheet<Self>];
fn get_quirks_mode_stylesheet() -> &'static Stylesheet<Self>; fn get_quirks_mode_stylesheet() -> Option<&'static Stylesheet<Self>>;
} }
#[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)] #[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)]
@ -135,7 +135,7 @@ impl SelectorImplExt for ServoSelectorImpl {
} }
#[inline] #[inline]
fn get_quirks_mode_stylesheet() -> &'static Stylesheet<Self> { fn get_quirks_mode_stylesheet() -> Option<&'static Stylesheet<Self>> {
&*QUIRKS_MODE_STYLESHEET Some(&*QUIRKS_MODE_STYLESHEET)
} }
} }

View file

@ -146,7 +146,9 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
} }
if self.quirks_mode { if self.quirks_mode {
self.add_stylesheet(&Impl::get_quirks_mode_stylesheet()); if let Some(s) = Impl::get_quirks_mode_stylesheet() {
self.add_stylesheet(s);
}
} }
for ref stylesheet in doc_stylesheets.iter() { for ref stylesheet in doc_stylesheets.iter() {

View file

@ -22,7 +22,6 @@ use style::stylesheets::Origin;
use traversal::RecalcStyleOnly; use traversal::RecalcStyleOnly;
use url::Url; use url::Url;
use util::arc_ptr_eq; use util::arc_ptr_eq;
use util::resource_files::set_resources_path;
use wrapper::{GeckoDocument, GeckoNode, NonOpaqueStyleData}; use wrapper::{GeckoDocument, GeckoNode, NonOpaqueStyleData};
/* /*
@ -42,10 +41,6 @@ pub extern "C" fn Servo_RestyleDocument(doc: *mut RawGeckoDocument, raw_data: *m
}; };
let data = unsafe { &mut *(raw_data as *mut PerDocumentStyleData) }; let data = unsafe { &mut *(raw_data as *mut PerDocumentStyleData) };
// FIXME(bholley): Don't hardcode resources path. We may want to use Gecko's UA stylesheets
// anyway.
set_resources_path(Some("/files/mozilla/stylo/servo/resources/".to_owned()));
let _needs_dirtying = data.stylist.update(&data.stylesheets, data.stylesheets_changed); let _needs_dirtying = data.stylist.update(&data.stylesheets, data.stylesheets_changed);
data.stylesheets_changed = false; data.stylesheets_changed = false;

View file

@ -10,7 +10,6 @@ use style::error_reporting::StdoutErrorReporter;
use style::selector_impl::SelectorImplExt; use style::selector_impl::SelectorImplExt;
use style::stylesheets::Origin; use style::stylesheets::Origin;
use url::Url; use url::Url;
use util::resource_files::read_resource_file;
pub type Stylist = style::selector_matching::Stylist<GeckoSelectorImpl>; pub type Stylist = style::selector_matching::Stylist<GeckoSelectorImpl>;
pub type Stylesheet = style::stylesheets::Stylesheet<GeckoSelectorImpl>; pub type Stylesheet = style::stylesheets::Stylesheet<GeckoSelectorImpl>;
@ -19,56 +18,6 @@ pub type PrivateStyleData = style::data::PrivateStyleData<GeckoSelectorImpl>;
pub struct GeckoSelectorImpl; pub struct GeckoSelectorImpl;
// TODO: Replace this with Gecko's stylesheets
lazy_static! {
static ref USER_OR_USER_AGENT_STYLESHEETS: Vec<Stylesheet> = {
let mut stylesheets = vec!();
// FIXME: presentational-hints.css should be at author origin with zero specificity.
// (Does it make a difference?)
for &filename in &["user-agent.css", "servo.css", "presentational-hints.css"] {
match read_resource_file(&[filename]) {
Ok(res) => {
let ua_stylesheet = Stylesheet::from_bytes(
&res,
Url::parse(&format!("chrome:///{:?}", filename)).unwrap(),
None,
None,
Origin::UserAgent,
box StdoutErrorReporter);
stylesheets.push(ua_stylesheet);
}
Err(..) => {
error!("Failed to load UA stylesheet {}!", filename);
process::exit(1);
}
}
}
stylesheets
};
}
lazy_static! {
static ref QUIRKS_MODE_STYLESHEET: Stylesheet = {
match read_resource_file(&["quirks-mode.css"]) {
Ok(res) => {
Stylesheet::from_bytes(
&res,
url!("chrome:///quirks-mode.css"),
None,
None,
Origin::UserAgent,
box StdoutErrorReporter)
},
Err(..) => {
error!("Stylist failed to load 'quirks-mode.css'!");
process::exit(1);
}
}
};
}
#[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)] #[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)]
pub enum PseudoElement { pub enum PseudoElement {
Before, Before,
@ -294,14 +243,13 @@ impl SelectorImplExt for GeckoSelectorImpl {
pc.state_flag() pc.state_flag()
} }
// FIXME: Don't use Servo's UA stylesheets, use Gecko's instead
#[inline] #[inline]
fn get_user_or_user_agent_stylesheets() -> &'static [Stylesheet] { fn get_user_or_user_agent_stylesheets() -> &'static [Stylesheet] {
&*USER_OR_USER_AGENT_STYLESHEETS &[]
} }
#[inline] #[inline]
fn get_quirks_mode_stylesheet() -> &'static Stylesheet { fn get_quirks_mode_stylesheet() -> Option<&'static Stylesheet> {
&*QUIRKS_MODE_STYLESHEET None
} }
} }