Make AllowedLengthType.is_ok() returning true if parsing mode allows all numeric values.

Even if the type is NonNegative and the given value is a negative.
This commit is contained in:
Hiroyuki Ikezoe 2017-06-14 09:51:53 +09:00
parent 8bfed4cb3c
commit 7341574b66
3 changed files with 26 additions and 17 deletions

View file

@ -204,6 +204,7 @@ macro_rules! __define_css_keyword_enum__actual {
/// Helper types for the handling of specified values.
pub mod specified {
use ParsingMode;
use app_units::Au;
use std::cmp;
@ -228,7 +229,10 @@ pub mod specified {
impl AllowedLengthType {
/// Whether value is valid for this allowed length type.
#[inline]
pub fn is_ok(&self, value: f32) -> bool {
pub fn is_ok(&self, parsing_mode: ParsingMode, value: f32) -> bool {
if parsing_mode.allows_all_numeric_values() {
return true;
}
match *self {
AllowedLengthType::All => true,
AllowedLengthType::NonNegative => value >= 0.,