diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 5198dc05b14..566506e987e 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -11,7 +11,7 @@ name = "style" path = "lib.rs" [features] -gecko = [] +gecko = ["gecko_bindings"] [dependencies] app_units = {version = "0.2.3", features = ["plugins"]} @@ -20,6 +20,7 @@ cssparser = {version = "0.5.5", features = ["heap_size", "serde-serialization"]} encoding = "0.2" euclid = {version = "0.6.4", features = ["plugins"]} fnv = "1.0" +gecko_bindings = {path = "../../ports/geckolib/gecko_bindings", optional = true} heapsize = "0.3.0" heapsize_plugin = "0.1.2" lazy_static = "0.2" diff --git a/components/style/lib.rs b/components/style/lib.rs index 00d5d079066..4ec45e45e04 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -28,6 +28,8 @@ extern crate cssparser; extern crate encoding; extern crate euclid; extern crate fnv; +#[cfg(feature = "gecko")] +extern crate gecko_bindings; extern crate heapsize; #[allow(unused_extern_crates)] #[macro_use] diff --git a/components/style/parser.rs b/components/style/parser.rs index 5a38c2f22b5..eadb778db55 100644 --- a/components/style/parser.rs +++ b/components/style/parser.rs @@ -5,6 +5,8 @@ use cssparser::{Parser, SourcePosition}; use error_reporting::ParseErrorReporter; +#[cfg(feature = "gecko")] +use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI}; use selectors::parser::ParserContext as SelectorParserContext; use stylesheets::Origin; use url::Url; @@ -14,6 +16,9 @@ pub struct ParserContextExtraData; #[cfg(feature = "gecko")] pub struct ParserContextExtraData { + pub base: Option, + pub referrer: Option, + pub principal: Option, } impl ParserContextExtraData { @@ -24,7 +29,7 @@ impl ParserContextExtraData { #[cfg(feature = "gecko")] pub fn default() -> ParserContextExtraData { - ParserContextExtraData { } + ParserContextExtraData { base: None, referrer: None, principal: None } } } diff --git a/ports/geckolib/Cargo.lock b/ports/geckolib/Cargo.lock index 3e88bea0062..54b62cd7830 100644 --- a/ports/geckolib/Cargo.lock +++ b/ports/geckolib/Cargo.lock @@ -453,6 +453,7 @@ dependencies = [ "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gecko_bindings 0.0.1", "heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index d4c268f58fb..578fb5a1a77 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -10,7 +10,8 @@ use env_logger; use euclid::Size2D; use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode}; use gecko_bindings::bindings::{RawServoStyleSet, RawServoStyleSheet, ServoComputedValues, ServoNodeData}; -use gecko_bindings::bindings::{nsIAtom}; +use gecko_bindings::bindings::{ThreadSafePrincipalHolder, ThreadSafeURIHolder, nsIAtom}; +use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI}; use gecko_bindings::structs::SheetParsingMode; use properties::GeckoComputedValues; use selector_impl::{GeckoSelectorImpl, PseudoElement, SharedStyleContext, Stylesheet}; @@ -121,7 +122,11 @@ pub extern "C" fn Servo_DropNodeData(data: *mut ServoNodeData) -> () { #[no_mangle] pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const u8, length: u32, - mode: SheetParsingMode) -> *mut RawServoStyleSheet { + mode: SheetParsingMode, + base: *mut ThreadSafeURIHolder, + referrer: *mut ThreadSafeURIHolder, + principal: *mut ThreadSafePrincipalHolder) + -> *mut RawServoStyleSheet { let input = unsafe { from_utf8_unchecked(slice::from_raw_parts(bytes, length as usize)) }; @@ -133,7 +138,11 @@ pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const u8, // FIXME(heycam): Pass in the real base URL. let url = Url::parse("about:none").unwrap(); - let extra_data = ParserContextExtraData { }; + let extra_data = ParserContextExtraData { + base: Some(GeckoArcURI::new(base)), + referrer: Some(GeckoArcURI::new(referrer)), + principal: Some(GeckoArcPrincipal::new(principal)), + }; let sheet = Arc::new(Stylesheet::from_str(input, url, origin, Box::new(StdoutErrorReporter), extra_data)); unsafe {