servo: Merge #1905 - script: Fix background color of Acid2 (from pcwalton: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

Source-Repo: https://github.com/servo/servo
Source-Revision: 58f3946e4b73b88bf96312baad38f77d1156e82e
This commit is contained in:
Patrick Walton 2014-03-14 10:16:57 -04:00
Родитель fefe0b3f01
Коммит 151f48873a
3 изменённых файлов: 26 добавлений и 7 удалений

Просмотреть файл

@ -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)));
}
_ => {}
}

Просмотреть файл

@ -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,
}
}

Просмотреть файл

@ -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',
];