mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Pass Gecko sheet base/referrer/principal from Servo_StylesheetFromUTF8Bytes through ParserContext.
This commit is contained in:
parent
6dfb51f272
commit
6d67aa8a01
5 changed files with 23 additions and 5 deletions
|
@ -11,7 +11,7 @@ name = "style"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
gecko = []
|
gecko = ["gecko_bindings"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
app_units = {version = "0.2.3", features = ["plugins"]}
|
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"
|
encoding = "0.2"
|
||||||
euclid = {version = "0.6.4", features = ["plugins"]}
|
euclid = {version = "0.6.4", features = ["plugins"]}
|
||||||
fnv = "1.0"
|
fnv = "1.0"
|
||||||
|
gecko_bindings = {path = "../../ports/geckolib/gecko_bindings", optional = true}
|
||||||
heapsize = "0.3.0"
|
heapsize = "0.3.0"
|
||||||
heapsize_plugin = "0.1.2"
|
heapsize_plugin = "0.1.2"
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
|
|
|
@ -28,6 +28,8 @@ extern crate cssparser;
|
||||||
extern crate encoding;
|
extern crate encoding;
|
||||||
extern crate euclid;
|
extern crate euclid;
|
||||||
extern crate fnv;
|
extern crate fnv;
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
extern crate gecko_bindings;
|
||||||
extern crate heapsize;
|
extern crate heapsize;
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
use cssparser::{Parser, SourcePosition};
|
use cssparser::{Parser, SourcePosition};
|
||||||
use error_reporting::ParseErrorReporter;
|
use error_reporting::ParseErrorReporter;
|
||||||
|
#[cfg(feature = "gecko")]
|
||||||
|
use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||||
use selectors::parser::ParserContext as SelectorParserContext;
|
use selectors::parser::ParserContext as SelectorParserContext;
|
||||||
use stylesheets::Origin;
|
use stylesheets::Origin;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -14,6 +16,9 @@ pub struct ParserContextExtraData;
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub struct ParserContextExtraData {
|
pub struct ParserContextExtraData {
|
||||||
|
pub base: Option<GeckoArcURI>,
|
||||||
|
pub referrer: Option<GeckoArcURI>,
|
||||||
|
pub principal: Option<GeckoArcPrincipal>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ParserContextExtraData {
|
impl ParserContextExtraData {
|
||||||
|
@ -24,7 +29,7 @@ impl ParserContextExtraData {
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub fn default() -> ParserContextExtraData {
|
pub fn default() -> ParserContextExtraData {
|
||||||
ParserContextExtraData { }
|
ParserContextExtraData { base: None, referrer: None, principal: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
ports/geckolib/Cargo.lock
generated
1
ports/geckolib/Cargo.lock
generated
|
@ -453,6 +453,7 @@ dependencies = [
|
||||||
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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)",
|
"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 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)",
|
"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)",
|
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -10,7 +10,8 @@ use env_logger;
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||||
use gecko_bindings::bindings::{RawServoStyleSet, RawServoStyleSheet, ServoComputedValues, ServoNodeData};
|
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 gecko_bindings::structs::SheetParsingMode;
|
||||||
use properties::GeckoComputedValues;
|
use properties::GeckoComputedValues;
|
||||||
use selector_impl::{GeckoSelectorImpl, PseudoElement, SharedStyleContext, Stylesheet};
|
use selector_impl::{GeckoSelectorImpl, PseudoElement, SharedStyleContext, Stylesheet};
|
||||||
|
@ -121,7 +122,11 @@ pub extern "C" fn Servo_DropNodeData(data: *mut ServoNodeData) -> () {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const u8,
|
pub extern "C" fn Servo_StylesheetFromUTF8Bytes(bytes: *const u8,
|
||||||
length: u32,
|
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)) };
|
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.
|
// FIXME(heycam): Pass in the real base URL.
|
||||||
let url = Url::parse("about:none").unwrap();
|
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),
|
let sheet = Arc::new(Stylesheet::from_str(input, url, origin, Box::new(StdoutErrorReporter),
|
||||||
extra_data));
|
extra_data));
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue