mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
auto merge of #3897 : Ms2ger/servo/enable-reflection, r=Manishearth
This commit is contained in:
commit
fba6cb9c42
5 changed files with 26915 additions and 13 deletions
|
@ -509,7 +509,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
value: DOMString) -> AttrValue {
|
||||
if *namespace == ns!("") {
|
||||
vtable_for(&NodeCast::from_ref(self))
|
||||
.parse_plain_attribute(local_name.as_slice(), value)
|
||||
.parse_plain_attribute(local_name, value)
|
||||
} else {
|
||||
StringAttrValue(value)
|
||||
}
|
||||
|
@ -1028,10 +1028,10 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
|||
self.notify_content_changed();
|
||||
}
|
||||
|
||||
fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue {
|
||||
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
||||
match name {
|
||||
"id" => AttrValue::from_atomic(value),
|
||||
"class" => AttrValue::from_tokenlist(value),
|
||||
&atom!("id") => AttrValue::from_atomic(value),
|
||||
&atom!("class") => AttrValue::from_tokenlist(value),
|
||||
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,9 +195,10 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue {
|
||||
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
||||
match name {
|
||||
"width" | "height" | "hspace" | "vspace" => AttrValue::from_u32(value, 0),
|
||||
&atom!("width") | &atom!("height") |
|
||||
&atom!("hspace") | &atom!("vspace") => AttrValue::from_u32(value, 0),
|
||||
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
use dom::attr::Attr;
|
||||
use dom::attr::{Attr, AttrValue, UIntAttrValue};
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
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::virtualmethods::VirtualMethods;
|
||||
|
||||
use servo_util::str::{DOMString, parse_unsigned_integer};
|
||||
use servo_util::str::DOMString;
|
||||
use string_cache::Atom;
|
||||
|
||||
use std::ascii::OwnedStrAsciiExt;
|
||||
|
@ -282,9 +282,10 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
|||
self.update_checked_state(true);
|
||||
}
|
||||
&atom!("size") => {
|
||||
let value = attr.value();
|
||||
let parsed = parse_unsigned_integer(value.as_slice().chars());
|
||||
self.size.set(parsed.unwrap_or(DEFAULT_INPUT_SIZE));
|
||||
match *attr.value() {
|
||||
UIntAttrValue(_, value) => self.size.set(value),
|
||||
_ => fail!("Expected a UIntAttrValue"),
|
||||
}
|
||||
self.force_relayout();
|
||||
}
|
||||
&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) {
|
||||
match self.super_type() {
|
||||
Some(ref s) => s.bind_to_tree(tree_in_doc),
|
||||
|
|
|
@ -68,6 +68,8 @@ use dom::node::{Node, NodeHelpers, ElementNodeTypeId, CloneChildrenFlag};
|
|||
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
use string_cache::Atom;
|
||||
|
||||
/// Trait to allow DOM nodes to opt-in to overriding (or adding to) common
|
||||
/// behaviours. Replicates the effect of C++ virtual methods.
|
||||
pub trait VirtualMethods {
|
||||
|
@ -95,7 +97,7 @@ pub trait VirtualMethods {
|
|||
|
||||
/// Returns the right AttrValue variant for the attribute with name `name`
|
||||
/// on this element.
|
||||
fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue {
|
||||
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
||||
match self.super_type() {
|
||||
Some(ref s) => s.parse_plain_attribute(name, value),
|
||||
_ => StringAttrValue(value),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue