auto merge of #1905 : pcwalton/servo/acid2-fixes, r=SimonSapin

There were two problems here: (1) we did not process style sheets with an
unexpected `rel` attribute but a correct MIME type; (2) we did not
consider `none` a valid value for the `background` property.

r? @SimonSapin
This commit is contained in:
bors-servo 2014-03-14 10:16:57 -04:00
commit 58f3946e4b
6 changed files with 64 additions and 7 deletions

View file

@ -22,9 +22,10 @@ use hubbub::hubbub;
use servo_msg::constellation_msg::SubpageId;
use servo_net::resource_task::{Load, Payload, Done, ResourceTask, load_whole_resource};
use servo_util::namespace::Null;
use servo_util::str::DOMString;
use servo_util::str::{DOMString, HTML_SPACE_CHARACTERS};
use servo_util::task::spawn_named;
use servo_util::url::parse_url;
use std::ascii::StrAsciiExt;
use std::cast;
use std::cell::RefCell;
use std::comm::{Port, SharedChan};
@ -337,12 +338,16 @@ pub fn parse_html(page: &Page,
ElementNodeTypeId(HTMLLinkElementTypeId) => {
match (element.get().get_attribute(Null, "rel"),
element.get().get_attribute(Null, "href")) {
(Some(rel), Some(href)) => {
if "stylesheet" == rel.get().value_ref() {
debug!("found CSS stylesheet: {:s}", href.get().value_ref());
let url = parse_url(href.get().value_ref(), Some(url2.clone()));
css_chan2.send(CSSTaskNewFile(UrlProvenance(url)));
}
(Some(ref rel), Some(ref href)) if rel.get()
.value_ref()
.split(HTML_SPACE_CHARACTERS.
as_slice())
.any(|s| {
s.eq_ignore_ascii_case("stylesheet")
}) => {
debug!("found CSS stylesheet: {:s}", href.get().value_ref());
let url = parse_url(href.get().value_ref(), Some(url2.clone()));
css_chan2.send(CSSTaskNewFile(UrlProvenance(url)));
}
_ => {}
}

View file

@ -499,6 +499,7 @@ pub mod longhands {
let image_url = parse_url(url.as_slice(), Some(base_url.clone()));
Some(Some(image_url))
},
&ast::Ident(ref value) if "none" == value.to_ascii_lower() => Some(None),
_ => None,
}
}

View file

@ -25,3 +25,16 @@ pub fn is_whitespace(s: &str) -> bool {
_ => false
})
}
/// A "space character" according to:
///
/// http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#
/// space-character
pub static HTML_SPACE_CHARACTERS: [char, ..5] = [
'\u0020',
'\u0009',
'\u000a',
'\u000c',
'\u000d',
];

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>background: none test</title>
<style>
#a {
background: red;
width: 32px;
height: 32px;
}
#a {
background: none;
}
</style>
</head>
<body>
<div id=a></div>
</body>
</html>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>background: none test</title>
<style>
#a {
width: 32px;
height: 32px;
}
</style>
</head>
<body>
<div id=a></div>
</body>
</html>

View file

@ -53,3 +53,4 @@
== position_fixed_static_y_a.html position_fixed_static_y_b.html
== position_relative_a.html position_relative_b.html
== position_relative_top_percentage_a.html position_relative_top_percentage_b.html
== background_none_a.html background_none_b.html