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

  • Loading branch information
aneesh87 committed May 4, 2016
commit 246d980ed31c5e1ba9df5bccc7a9c66e7aa6a2c7
@@ -35,6 +35,7 @@ use url::Url;
use util::str::{DOMString, LengthOrPercentageOrAuto};
use style::values::specified::Length;
use std::collections::LinkedList;
use util;

#[derive(JSTraceable, HeapSizeOf)]
#[allow(dead_code)]
@@ -433,7 +434,7 @@ fn collect_sequence_characters<'a, P>(s: &'a str, predicate: P)
fn parse_a_srcset_attribute(input: String) -> Vec<ImageSource> {
let position = &input;
let candidate: Vec<ImageSource> = Vec::new();
let(spaces, position) = collect_sequence_characters(position, |c| c ==',' || c == ' ');
let(spaces, position) = collect_sequence_characters(position, |c| c ==',' || util::str::char_is_whitespace(c));
println!("{} {}", spaces, position);
let x = spaces.find(',');
match x {
@@ -444,7 +445,7 @@ fn parse_a_srcset_attribute(input: String) -> Vec<ImageSource> {
//Does something need to be asserted here? The algorithm says abort the steps is this condition exists
return candidate;
}
let (url, spaces) = collect_sequence_characters(position, |c| c != ' ');
let (url, spaces) = collect_sequence_characters(position, |c| !util::str::char_is_whitespace(c));

let comma_count = url.chars().rev().take_while(|c| *c==',').count();
let url: String = url.chars().take(url.chars().count() - comma_count).collect();
@@ -453,7 +454,12 @@ fn parse_a_srcset_attribute(input: String) -> Vec<ImageSource> {
}

let mut descriptor = LinkedList::<String>::new();
// Descriptor Tokeniser: whitespace
let (space, position) = collect_sequence_characters(position, |c| util::str::char_is_whitespace(c));

let current_descriptor = 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.