mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Parse the size attribute on input elements.
This commit is contained in:
parent
214c356ecd
commit
e1bb3c3b06
2 changed files with 26905 additions and 6 deletions
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::attr::Attr;
|
use dom::attr::{Attr, AttrValue, UIntAttrValue};
|
||||||
use dom::attr::AttrHelpers;
|
use dom::attr::AttrHelpers;
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||||
|
@ -24,7 +24,7 @@ use dom::htmlformelement::{InputElement, FormOwner, HTMLFormElement, HTMLFormEle
|
||||||
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId, document_from_node, window_from_node};
|
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId, document_from_node, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
|
||||||
use servo_util::str::{DOMString, parse_unsigned_integer};
|
use servo_util::str::DOMString;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
|
|
||||||
use std::ascii::OwnedStrAsciiExt;
|
use std::ascii::OwnedStrAsciiExt;
|
||||||
|
@ -282,9 +282,10 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
self.update_checked_state(true);
|
self.update_checked_state(true);
|
||||||
}
|
}
|
||||||
&atom!("size") => {
|
&atom!("size") => {
|
||||||
let value = attr.value();
|
match *attr.value() {
|
||||||
let parsed = parse_unsigned_integer(value.as_slice().chars());
|
UIntAttrValue(_, value) => self.size.set(value),
|
||||||
self.size.set(parsed.unwrap_or(DEFAULT_INPUT_SIZE));
|
_ => fail!("Expected a UIntAttrValue"),
|
||||||
|
}
|
||||||
self.force_relayout();
|
self.force_relayout();
|
||||||
}
|
}
|
||||||
&atom!("type") => {
|
&atom!("type") => {
|
||||||
|
@ -363,6 +364,13 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
||||||
|
match name {
|
||||||
|
&atom!("size") => AttrValue::from_u32(value, DEFAULT_INPUT_SIZE),
|
||||||
|
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, tree_in_doc: bool) {
|
fn bind_to_tree(&self, tree_in_doc: bool) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue