diff options
author | Corey Farwell <coreyf@rwell.org> | 2015-12-21 19:49:30 -0800 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2015-12-24 13:20:43 -0800 |
commit | ba659cb99cd07ca93736e44226bf164dd7f01088 (patch) | |
tree | d9898cccc51298e0dfd4e7321e892e992acb933d /components/style/attr.rs | |
parent | dafdc856ac3fc2bd000e61bdcaed2c024828de0c (diff) | |
download | servo-ba659cb99cd07ca93736e44226bf164dd7f01088.tar.gz servo-ba659cb99cd07ca93736e44226bf164dd7f01088.zip |
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.
Diffstat (limited to 'components/style/attr.rs')
-rw-r--r-- | components/style/attr.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/components/style/attr.rs b/components/style/attr.rs index 0569b235a9c..aa7eb621839 100644 --- a/components/style/attr.rs +++ b/components/style/attr.rs @@ -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 |