Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle properly alternate stylesheet #14911

Merged
merged 3 commits into from Jan 11, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Handle properly alternate stylesheet

  • Loading branch information
charlesvdv committed Jan 10, 2017
commit 19e31d5c506f83585812856738e53d33a53d32c5
@@ -99,6 +99,17 @@ impl HTMLLinkElement {
})
})
}

pub fn is_alternate(&self) -> bool {
let rel = get_attr(self.upcast(), &local_name!("rel"));
match rel {
Some(ref value) => {
value.split(HTML_SPACE_CHARACTERS)
.any(|s| s.eq_ignore_ascii_case("alternate"))
},
None => false,
}
}
}

fn get_attr(element: &Element, local_name: &LocalName) -> Option<String> {
@@ -112,17 +123,8 @@ fn get_attr(element: &Element, local_name: &LocalName) -> Option<String> {
fn string_is_stylesheet(value: &Option<String>) -> bool {
match *value {
Some(ref value) => {
let mut found_stylesheet = false;
for s in value.split(HTML_SPACE_CHARACTERS).into_iter() {
if s.eq_ignore_ascii_case("alternate") {
return false;
}

if s.eq_ignore_ascii_case("stylesheet") {
found_stylesheet = true;
}
}
found_stylesheet
value.split(HTML_SPACE_CHARACTERS)
.any(|s| s.eq_ignore_ascii_case("stylesheet"))
},
None => false,
}
@@ -138,6 +138,9 @@ impl FetchResponseListener for StylesheetContext {
Some(&loader),
win.css_error_reporter(),
ParserContextExtraData::default()));
if elem.downcast::<HTMLLinkElement>().unwrap().is_alternate() {
sheet.set_disabled(true);
}
elem.downcast::<HTMLLinkElement>()
.unwrap()
.set_stylesheet(sheet.clone());
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.