aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-09-06 22:42:19 +0200
committerMs2ger <ms2ger@gmail.com>2014-09-07 15:10:07 +0200
commitc56f8a2c79386b5f5b4cae77232f9d8e38ef0e7b (patch)
treef54ebbcd75e424e12ff1d8992e6e860b826db769
parent0d202b6bda9ca10980e839bf7b00d1e51b51a531 (diff)
downloadservo-c56f8a2c79386b5f5b4cae77232f9d8e38ef0e7b.tar.gz
servo-c56f8a2c79386b5f5b4cae77232f9d8e38ef0e7b.zip
Correct the iterator adaptors used in parsing integers (fixes #3208).
This avoids Azure segfaulting trying to set up a 100999px*100999px canvas. The test still fails due to its use of getComputedStyle.
-rw-r--r--src/components/util/str.rs14
-rw-r--r--src/test/wpt/metadata/html/dom/reflection-embedded.html.ini6
-rw-r--r--src/test/wpt/metadata/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.html.ini4
-rw-r--r--src/test/wpt/metadata/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.html.ini4
4 files changed, 14 insertions, 14 deletions
diff --git a/src/components/util/str.rs b/src/components/util/str.rs
index 8f698ac3271..9d07cf80b99 100644
--- a/src/components/util/str.rs
+++ b/src/components/util/str.rs
@@ -51,10 +51,10 @@ pub fn split_html_space_chars<'a>(s: &'a str) -> Filter<'a, &'a str, CharSplits<
/// <http://www.whatwg.org/html/#rules-for-parsing-integers> or
/// <http://www.whatwg.org/html/#rules-for-parsing-non-negative-integers>.
fn do_parse_integer<T: Iterator<char>>(input: T) -> Option<i64> {
- fn as_ascii_digit(c: char) -> Option<i64> {
- match c {
- '0'..'9' => Some(c as i64 - '0' as i64),
- _ => None,
+ fn is_ascii_digit(c: &char) -> bool {
+ match *c {
+ '0'..'9' => true,
+ _ => false,
}
}
@@ -77,11 +77,13 @@ fn do_parse_integer<T: Iterator<char>>(input: T) -> Option<i64> {
};
match input.peek() {
- Some(&c) if as_ascii_digit(c).is_some() => (),
+ Some(c) if is_ascii_digit(c) => (),
_ => return None,
}
- let value = input.filter_map(as_ascii_digit).fuse().fold(Some(0i64), |accumulator, d| {
+ let value = input.take_while(is_ascii_digit).map(|d| {
+ d as i64 - '0' as i64
+ }).fold(Some(0i64), |accumulator, d| {
accumulator.and_then(|accumulator| {
accumulator.checked_mul(&10)
}).and_then(|accumulator| {
diff --git a/src/test/wpt/metadata/html/dom/reflection-embedded.html.ini b/src/test/wpt/metadata/html/dom/reflection-embedded.html.ini
index 3be5c8162b2..114f4de8aa9 100644
--- a/src/test/wpt/metadata/html/dom/reflection-embedded.html.ini
+++ b/src/test/wpt/metadata/html/dom/reflection-embedded.html.ini
@@ -20376,9 +20376,6 @@
[canvas.width: setAttribute() to 4294967295 followed by IDL get]
expected: FAIL
- [canvas.width: setAttribute() to 1.5 followed by IDL get]
- expected: FAIL
-
[canvas.width: setAttribute() to object "3" followed by getAttribute()]
expected: FAIL
@@ -20391,9 +20388,6 @@
[canvas.height: setAttribute() to 4294967295 followed by IDL get]
expected: FAIL
- [canvas.height: setAttribute() to 1.5 followed by IDL get]
- expected: FAIL
-
[canvas.height: setAttribute() to object "3" followed by getAttribute()]
expected: FAIL
diff --git a/src/test/wpt/metadata/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.html.ini b/src/test/wpt/metadata/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.html.ini
index 83a3b082c9a..de2ec6fd202 100644
--- a/src/test/wpt/metadata/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.html.ini
+++ b/src/test/wpt/metadata/html/semantics/embedded-content/the-canvas-element/size.attributes.parse.decimal.html.ini
@@ -1,3 +1,5 @@
[size.attributes.parse.decimal.html]
type: testharness
- expected: TIMEOUT
+ [Parsing of non-negative integers]
+ expected: FAIL
+
diff --git a/src/test/wpt/metadata/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.html.ini b/src/test/wpt/metadata/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.html.ini
index 611dddb4161..bc02c56db8a 100644
--- a/src/test/wpt/metadata/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.html.ini
+++ b/src/test/wpt/metadata/html/semantics/embedded-content/the-canvas-element/size.attributes.setAttribute.decimal.html.ini
@@ -1,3 +1,5 @@
[size.attributes.setAttribute.decimal.html]
type: testharness
- expected: TIMEOUT
+ [Parsing of non-negative integers in setAttribute]
+ expected: FAIL
+