Implement non-zero dimension attribute parsing

Fixes #8445

The only attributes I found that we have implemented that uses non-zero
dimenion attributes:

* `width` for `<td>` and `<th>` (table cells)
* `width` for `<table>`

I updated these implementations to use the new non-zero dimension
attribute parsing and added associated regression tests.
This commit is contained in:
Corey Farwell 2015-12-21 19:49:30 -08:00
parent dafdc856ac
commit ba659cb99c
13 changed files with 227 additions and 291 deletions

View file

@ -6,7 +6,7 @@ use cssparser::RGBA;
use std::ops::Deref;
use string_cache::{Atom, Namespace};
use util::str::{DOMString, LengthOrPercentageOrAuto, parse_unsigned_integer, parse_legacy_color, parse_length};
use util::str::{split_html_space_chars, str_join, parse_integer};
use util::str::{parse_nonzero_length, split_html_space_chars, str_join, parse_integer};
use values::specified::{Length};
// Duplicated from script::dom::values.
@ -96,6 +96,11 @@ impl AttrValue {
AttrValue::Dimension(string, parsed)
}
pub fn from_nonzero_dimension(string: DOMString) -> AttrValue {
let parsed = parse_nonzero_length(&string);
AttrValue::Dimension(string, parsed)
}
/// Assumes the `AttrValue` is a `TokenList` and returns its tokens
///
/// ## Panics