script: Fix background color of Acid2.

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.
This commit is contained in:
Patrick Walton 2014-03-13 10:35:29 -07:00
parent 3933d17262
commit 3f8882450c
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_msg::constellation_msg::SubpageId;
use servo_net::resource_task::{Load, Payload, Done, ResourceTask, load_whole_resource}; use servo_net::resource_task::{Load, Payload, Done, ResourceTask, load_whole_resource};
use servo_util::namespace::Null; 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::task::spawn_named;
use servo_util::url::parse_url; use servo_util::url::parse_url;
use std::ascii::StrAsciiExt;
use std::cast; use std::cast;
use std::cell::RefCell; use std::cell::RefCell;
use std::comm::{Port, SharedChan}; use std::comm::{Port, SharedChan};
@ -337,13 +338,17 @@ pub fn parse_html(page: &Page,
ElementNodeTypeId(HTMLLinkElementTypeId) => { ElementNodeTypeId(HTMLLinkElementTypeId) => {
match (element.get().get_attribute(Null, "rel"), match (element.get().get_attribute(Null, "rel"),
element.get().get_attribute(Null, "href")) { element.get().get_attribute(Null, "href")) {
(Some(rel), Some(href)) => { (Some(ref rel), Some(ref href)) if rel.get()
if "stylesheet" == rel.get().value_ref() { .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()); debug!("found CSS stylesheet: {:s}", href.get().value_ref());
let url = parse_url(href.get().value_ref(), Some(url2.clone())); let url = parse_url(href.get().value_ref(), Some(url2.clone()));
css_chan2.send(CSSTaskNewFile(UrlProvenance(url))); 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())); let image_url = parse_url(url.as_slice(), Some(base_url.clone()));
Some(Some(image_url)) Some(Some(image_url))
}, },
&ast::Ident(ref value) if "none" == value.to_ascii_lower() => Some(None),
_ => None, _ => None,
} }
} }

View file

@ -25,3 +25,16 @@ pub fn is_whitespace(s: &str) -> bool {
_ => false _ => 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_fixed_static_y_a.html position_fixed_static_y_b.html
== position_relative_a.html position_relative_b.html == position_relative_a.html position_relative_b.html
== position_relative_top_percentage_a.html position_relative_top_percentage_b.html == position_relative_top_percentage_a.html position_relative_top_percentage_b.html
== background_none_a.html background_none_b.html