From 4da1171474cd905a1d4d81487f2e8b5b5b430bd3 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 2 Mar 2016 16:38:53 -0800 Subject: [PATCH] Stop using servo UA stylesheets for geckolib. Gecko will provide these. This also removes the need to reference the servo resource directory. --- components/style/selector_impl.rs | 6 +-- components/style/selector_matching.rs | 4 +- ports/geckolib/glue.rs | 5 --- ports/geckolib/selector_impl.rs | 58 ++------------------------- 4 files changed, 9 insertions(+), 64 deletions(-) diff --git a/components/style/selector_impl.rs b/components/style/selector_impl.rs index 1aa2469b6f5..77aa23ca808 100644 --- a/components/style/selector_impl.rs +++ b/components/style/selector_impl.rs @@ -19,7 +19,7 @@ pub trait SelectorImplExt : SelectorImpl + Sized { fn get_user_or_user_agent_stylesheets() -> &'static [Stylesheet]; - fn get_quirks_mode_stylesheet() -> &'static Stylesheet; + fn get_quirks_mode_stylesheet() -> Option<&'static Stylesheet>; } #[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)] @@ -135,7 +135,7 @@ impl SelectorImplExt for ServoSelectorImpl { } #[inline] - fn get_quirks_mode_stylesheet() -> &'static Stylesheet { - &*QUIRKS_MODE_STYLESHEET + fn get_quirks_mode_stylesheet() -> Option<&'static Stylesheet> { + Some(&*QUIRKS_MODE_STYLESHEET) } } diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index a6c93cebcbc..614ea681e18 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -146,7 +146,9 @@ impl Stylist { } 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() { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index b63453f9559..9185d701c18 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -22,7 +22,6 @@ use style::stylesheets::Origin; use traversal::RecalcStyleOnly; use url::Url; use util::arc_ptr_eq; -use util::resource_files::set_resources_path; 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) }; - // 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); data.stylesheets_changed = false; diff --git a/ports/geckolib/selector_impl.rs b/ports/geckolib/selector_impl.rs index 2b2b3a3eb2b..45ded949052 100644 --- a/ports/geckolib/selector_impl.rs +++ b/ports/geckolib/selector_impl.rs @@ -10,7 +10,6 @@ use style::error_reporting::StdoutErrorReporter; use style::selector_impl::SelectorImplExt; use style::stylesheets::Origin; use url::Url; -use util::resource_files::read_resource_file; pub type Stylist = style::selector_matching::Stylist; pub type Stylesheet = style::stylesheets::Stylesheet; @@ -19,56 +18,6 @@ pub type PrivateStyleData = style::data::PrivateStyleData; pub struct GeckoSelectorImpl; -// TODO: Replace this with Gecko's stylesheets -lazy_static! { - static ref USER_OR_USER_AGENT_STYLESHEETS: Vec = { - 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)] pub enum PseudoElement { Before, @@ -294,14 +243,13 @@ impl SelectorImplExt for GeckoSelectorImpl { pc.state_flag() } - // FIXME: Don't use Servo's UA stylesheets, use Gecko's instead #[inline] fn get_user_or_user_agent_stylesheets() -> &'static [Stylesheet] { - &*USER_OR_USER_AGENT_STYLESHEETS + &[] } #[inline] - fn get_quirks_mode_stylesheet() -> &'static Stylesheet { - &*QUIRKS_MODE_STYLESHEET + fn get_quirks_mode_stylesheet() -> Option<&'static Stylesheet> { + None } }