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

Parse srcset algo #10829

Closed
wants to merge 10 commits into from

Further Steps Parseset

  • Loading branch information
aneesh87 committed May 3, 2016
commit bb26ef10ee47f306d583b8b957964f9d86f660ce
@@ -45,6 +45,13 @@ enum State {
Broken,
}
#[derive(JSTraceable, HeapSizeOf)]
#[allow(dead_code)]
enum ParseState {
InDescriptor,
InParens,
AfterDescriptor,
}
#[derive(JSTraceable, HeapSizeOf)]
struct ImageRequest {
state: State,
url: Option<Url>,
@@ -438,7 +445,15 @@ fn parse_a_srcset_attribute(input: String) -> Vec<ImageSource> {
return candidate;
}
let (url, spaces) = collect_sequence_characters(position, |c| c != ' ');

let comma_count = url.chars().rev().take_while(|c| *c==',').count();
let url: String = url.chars().take(url.chars().count() - comma_count).collect();
if comma_count > 1 {
println!("Parse Error (trailing commas)")
}

let mut descriptor = LinkedList::<String>::new();
let mut state = ParseState::InDescriptor;
return candidate;

}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.