mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Adds support for input element's maxlength attr
servo/servo#7320 servo/servo#7004
This commit is contained in:
parent
2be60be062
commit
d26c555e2a
6 changed files with 196 additions and 13 deletions
|
@ -5,7 +5,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::{DOMString, LengthOrPercentageOrAuto, parse_integer, parse_unsigned_integer, parse_legacy_color, parse_length};
|
||||
use util::str::{split_html_space_chars, str_join};
|
||||
use values::specified::{Length};
|
||||
|
||||
|
@ -17,6 +17,7 @@ pub enum AttrValue {
|
|||
String(DOMString),
|
||||
TokenList(DOMString, Vec<Atom>),
|
||||
UInt(DOMString, u32),
|
||||
Int(DOMString, i32),
|
||||
Atom(Atom),
|
||||
Length(DOMString, Option<Length>),
|
||||
Color(DOMString, Option<RGBA>),
|
||||
|
@ -52,6 +53,12 @@ impl AttrValue {
|
|||
AttrValue::UInt(string, result)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/infrastructure.html#limited-to-only-non-negative-numbers
|
||||
pub fn from_i32(string: DOMString, default: i32) -> AttrValue {
|
||||
let result = parse_integer(string.chars()).unwrap_or(default);
|
||||
AttrValue::Int(string, result)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#limited-to-only-non-negative-numbers-greater-than-zero
|
||||
pub fn from_limited_u32(string: DOMString, default: u32) -> AttrValue {
|
||||
let result = parse_unsigned_integer(string.chars()).unwrap_or(default);
|
||||
|
@ -165,6 +172,7 @@ impl Deref for AttrValue {
|
|||
AttrValue::UInt(ref value, _) |
|
||||
AttrValue::Length(ref value, _) |
|
||||
AttrValue::Color(ref value, _) |
|
||||
AttrValue::Int(ref value, _) |
|
||||
AttrValue::Dimension(ref value, _) => &value,
|
||||
AttrValue::Atom(ref value) => &value,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue