From 7b56e75adb0002a3bd001aa61b55249c938fc60e Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Wed, 19 Feb 2014 15:52:58 +0900 Subject: Support base_url in stylesheet --- src/components/script/dom/element.rs | 4 +- src/components/script/html/hubbub_html_parser.rs | 7 +- src/components/style/media_queries.rs | 7 +- src/components/style/properties.rs.mako | 129 ++++++++++++++++++++--- src/components/style/stylesheets.rs | 12 +-- 5 files changed, 133 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index 9ffb17c3254..2eb0553f2f6 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -221,7 +221,9 @@ impl Element { match local_name.as_slice() { "style" => { - self.style_attribute = Some(style::parse_style_attribute(value)) + let doc = self.node.owner_doc(); + let base_url = doc.document().url.clone(); + self.style_attribute = Some(style::parse_style_attribute(value, &base_url)) } "id" if abstract_self.is_in_doc() => { // XXX: this dual declaration are workaround to avoid the compile error: diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index 4ba46343817..9b66e4ecb1a 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -26,7 +26,6 @@ use servo_util::url::parse_url; use std::cast; use std::cell::RefCell; use std::comm::{Port, SharedChan}; -use std::from_str::FromStr; use std::str; use style::Stylesheet; @@ -277,7 +276,8 @@ pub fn parse_html(cx: *JSContext, debug!("Fetched page; metadata is {:?}", load_response.metadata); - let url2 = load_response.metadata.final_url.clone(); + let base_url = load_response.metadata.final_url.clone(); + let url2 = base_url.clone(); let url3 = url2.clone(); // Store the final URL before we start parsing, so that DOM routines @@ -485,7 +485,6 @@ pub fn parse_html(cx: *JSContext, // We've reached the end of a