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

Reintroducing parse_a_sizes along with tests #21178

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Reintroducing parse_a_sizes

  • Loading branch information
paavininanda committed Jul 17, 2018
commit d2f467cd7fb95d14ba4bc23adeef945b3f405c24
@@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use app_units::{Au, AU_PER_PX};
use cssparser::{Parser, ParserInput};
use document_loader::{LoadType, LoadBlocker};
use dom::activation::Activatable;
use dom::attr::Attr;
@@ -57,7 +58,12 @@ use std::default::Default;
use std::i32;
use std::sync::{Arc, Mutex};
use style::attr::{AttrValue, LengthOrPercentageOrAuto, parse_double, parse_unsigned_integer};
use style::context::QuirksMode;
use style::parser::ParserContext;
use style::str::is_ascii_digit;
use style::stylesheets::{CssRuleType, Origin};
use style::values::specified::{source_size_list::SourceSizeList};
use style_traits::ParsingMode;
use task_source::{TaskSource, TaskSourceName};

enum ParseState {
@@ -1010,6 +1016,22 @@ pub fn collect_sequence_characters<F>(s: &str, predicate: F) -> (&str, &str)
return (s, "");
}

//https://html.spec.whatwg.org/multipage/#parse-a-sizes-attribute
pub fn parse_a_sizes_attribute(value: DOMString) -> SourceSizeList {
let mut input = ParserInput::new(&value);
let mut parser = Parser::new(&mut input);
let url = ServoUrl::parse("about:blank").unwrap();
let context = ParserContext::new(
Origin::Author,
&url,
Some(CssRuleType::Style),
ParsingMode::empty(),
QuirksMode::NoQuirks,
None,
);
SourceSizeList::parse(&context, &mut parser)
}

/// Parse an `srcset` attribute - https://html.spec.whatwg.org/multipage/#parsing-a-srcset-attribute.
pub fn parse_a_srcset_attribute(input: &str) -> Vec<ImageSource> {
let mut url_len = 0;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.