Skip to content

Commit

Permalink
stylo: Make URLs work in inline style
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 6Tc0kBw4V8c
  • Loading branch information
Manishearth committed Mar 11, 2017
1 parent 06f99c1 commit 4deae33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
11 changes: 4 additions & 7 deletions components/style/gecko/wrapper.rs
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion components/style/gecko_bindings/bindings.rs
Expand Up @@ -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" {
Expand Down
8 changes: 6 additions & 2 deletions ports/geckolib/glue.rs
Expand Up @@ -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]
Expand Down

0 comments on commit 4deae33

Please sign in to comment.