From 4deae33ab17a72c45bcb243703c81ebbf56259f7 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 10 Mar 2017 18:28:02 -0800 Subject: [PATCH] stylo: Make URLs work in inline style MozReview-Commit-ID: 6Tc0kBw4V8c --- components/style/gecko/wrapper.rs | 11 ++++------- components/style/gecko_bindings/bindings.rs | 4 +++- ports/geckolib/glue.rs | 8 ++++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index d4d0c2dd3db0..85ed91525800 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -296,13 +296,10 @@ impl<'le> fmt::Debug for GeckoElement<'le> { impl<'le> GeckoElement<'le> { /// Parse the style attribute of an element. - pub fn parse_style_attribute(value: &str) -> PropertyDeclarationBlock { - // FIXME(bholley): Real base URL and error reporter. - let base_url = &*DUMMY_BASE_URL; - // FIXME(heycam): Needs real ParserContextExtraData so that URLs parse - // properly. - let extra_data = ParserContextExtraData::default(); - parse_style_attribute(value, &base_url, Box::new(StdoutErrorReporter), extra_data) + pub fn parse_style_attribute(value: &str, + base_url: &ServoUrl, + extra_data: ParserContextExtraData) -> PropertyDeclarationBlock { + parse_style_attribute(value, base_url, Box::new(StdoutErrorReporter), extra_data) } fn flags(&self) -> u32 { diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 8a38318de01d..a4454c460391 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1415,7 +1415,9 @@ extern "C" { -> bool; } extern "C" { - pub fn Servo_ParseStyleAttribute(data: *const nsACString_internal) + pub fn Servo_ParseStyleAttribute(data: *const nsACString_internal, + base: *const nsACString_internal, + extraData: *const GeckoParserExtraData) -> RawServoDeclarationBlockStrong; } extern "C" { diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 0c85b8a45a70..1a3ee5ac9a93 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -718,9 +718,13 @@ pub extern "C" fn Servo_ParseProperty(property: *const nsACString, value: *const } #[no_mangle] -pub extern "C" fn Servo_ParseStyleAttribute(data: *const nsACString) -> RawServoDeclarationBlockStrong { +pub extern "C" fn Servo_ParseStyleAttribute(data: *const nsACString, + base: *const nsACString, + raw_extra_data: *const structs::GeckoParserExtraData) + -> RawServoDeclarationBlockStrong { let value = unsafe { data.as_ref().unwrap().as_str_unchecked() }; - Arc::new(RwLock::new(GeckoElement::parse_style_attribute(value))).into_strong() + make_context!((base, raw_extra_data) => (base_url, extra_data)); + Arc::new(RwLock::new(GeckoElement::parse_style_attribute(value, &base_url, extra_data))).into_strong() } #[no_mangle]