mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Usage of JSRef<Attr> in before_remove_attr & after_set_attr
JSRef<Attr> does not require allocating a DOMString for value, which are unused in most cases. It also provides more access to Attr data.
This commit is contained in:
parent
f5e8df9dac
commit
bbab8831e0
18 changed files with 255 additions and 225 deletions
|
@ -172,22 +172,14 @@ impl<'a> AttrHelpers<'a> for JSRef<'a, Attr> {
|
||||||
let namespace_is_null = self.namespace == ns!("");
|
let namespace_is_null = self.namespace == ns!("");
|
||||||
|
|
||||||
match set_type {
|
match set_type {
|
||||||
ReplacedAttr => {
|
ReplacedAttr if namespace_is_null => vtable_for(&node).before_remove_attr(self),
|
||||||
if namespace_is_null {
|
_ => ()
|
||||||
vtable_for(&node).before_remove_attr(
|
|
||||||
self.local_name(),
|
|
||||||
self.value().as_slice().to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FirstSetAttr => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*self.value.borrow_mut() = value;
|
*self.value.borrow_mut() = value;
|
||||||
|
|
||||||
if namespace_is_null {
|
if namespace_is_null {
|
||||||
vtable_for(&node).after_set_attr(
|
vtable_for(&node).after_set_attr(self)
|
||||||
self.local_name(),
|
|
||||||
self.value().as_slice().to_string())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -522,10 +522,8 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if namespace == ns!("") {
|
if namespace == ns!("") {
|
||||||
let removed_raw_value = (*self.attrs.borrow())[idx].root().Value();
|
let attr = (*self.attrs.borrow())[idx].root();
|
||||||
vtable_for(&NodeCast::from_ref(self))
|
vtable_for(&NodeCast::from_ref(self)).before_remove_attr(*attr);
|
||||||
.before_remove_attr(&local_name,
|
|
||||||
removed_raw_value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.attrs.borrow_mut().remove(idx);
|
self.attrs.borrow_mut().remove(idx);
|
||||||
|
@ -981,22 +979,24 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
Some(node as &VirtualMethods)
|
Some(node as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
match name.as_slice() {
|
match attr.local_name() {
|
||||||
"style" => {
|
&atom!("style") => {
|
||||||
let doc = document_from_node(*self).root();
|
let doc = document_from_node(*self).root();
|
||||||
let base_url = doc.url().clone();
|
let base_url = doc.url().clone();
|
||||||
|
let value = attr.value();
|
||||||
let style = Some(style::parse_style_attribute(value.as_slice(), &base_url));
|
let style = Some(style::parse_style_attribute(value.as_slice(), &base_url));
|
||||||
*self.style_attribute.borrow_mut() = style;
|
*self.style_attribute.borrow_mut() = style;
|
||||||
}
|
}
|
||||||
"id" => {
|
&atom!("id") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
if node.is_in_doc() && !value.is_empty() {
|
let value = attr.value();
|
||||||
|
if node.is_in_doc() && !value.as_slice().is_empty() {
|
||||||
let doc = document_from_node(*self).root();
|
let doc = document_from_node(*self).root();
|
||||||
let value = Atom::from_slice(value.as_slice());
|
let value = Atom::from_slice(value.as_slice());
|
||||||
doc.register_named_element(*self, value);
|
doc.register_named_element(*self, value);
|
||||||
|
@ -1005,22 +1005,23 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.notify_attribute_changed(name);
|
self.notify_attribute_changed(attr.local_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value.clone()),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
match name.as_slice() {
|
match attr.local_name() {
|
||||||
"style" => {
|
&atom!("style") => {
|
||||||
*self.style_attribute.borrow_mut() = None;
|
*self.style_attribute.borrow_mut() = None;
|
||||||
}
|
}
|
||||||
"id" => {
|
&atom!("id") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
if node.is_in_doc() && !value.is_empty() {
|
let value = attr.value();
|
||||||
|
if node.is_in_doc() && !value.as_slice().is_empty() {
|
||||||
let doc = document_from_node(*self).root();
|
let doc = document_from_node(*self).root();
|
||||||
let value = Atom::from_slice(value.as_slice());
|
let value = Atom::from_slice(value.as_slice());
|
||||||
doc.unregister_named_element(*self, value);
|
doc.unregister_named_element(*self, value);
|
||||||
|
@ -1029,7 +1030,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.notify_attribute_changed(name);
|
self.notify_attribute_changed(attr.local_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue {
|
fn parse_plain_attribute(&self, name: &str, value: DOMString) -> AttrValue {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
use dom::bindings::codegen::Bindings::HTMLBodyElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLBodyElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::HTMLBodyElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLBodyElementBinding::HTMLBodyElementMethods;
|
||||||
|
@ -18,7 +20,6 @@ use dom::node::{Node, ElementNodeTypeId, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
use string_cache::Atom;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct HTMLBodyElement {
|
pub struct HTMLBodyElement {
|
||||||
|
@ -63,13 +64,14 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
|
||||||
Some(element as &VirtualMethods)
|
Some(element as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
if name.as_slice().starts_with("on") {
|
let name = attr.local_name().as_slice();
|
||||||
|
if name.starts_with("on") {
|
||||||
static forwarded_events: &'static [&'static str] =
|
static forwarded_events: &'static [&'static str] =
|
||||||
&["onfocus", "onload", "onscroll", "onafterprint", "onbeforeprint",
|
&["onfocus", "onload", "onscroll", "onafterprint", "onbeforeprint",
|
||||||
"onbeforeunload", "onhashchange", "onlanguagechange", "onmessage",
|
"onbeforeunload", "onhashchange", "onlanguagechange", "onmessage",
|
||||||
|
@ -80,14 +82,14 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
|
||||||
window.get_url(),
|
window.get_url(),
|
||||||
window.reflector().get_jsobject());
|
window.reflector().get_jsobject());
|
||||||
let evtarget: JSRef<EventTarget> =
|
let evtarget: JSRef<EventTarget> =
|
||||||
if forwarded_events.iter().any(|&event| name.as_slice() == event) {
|
if forwarded_events.iter().any(|&event| name == event) {
|
||||||
EventTargetCast::from_ref(*window)
|
EventTargetCast::from_ref(*window)
|
||||||
} else {
|
} else {
|
||||||
EventTargetCast::from_ref(*self)
|
EventTargetCast::from_ref(*self)
|
||||||
};
|
};
|
||||||
evtarget.set_event_handler_uncompiled(cx, url, reflector,
|
evtarget.set_event_handler_uncompiled(cx, url, reflector,
|
||||||
name.as_slice().slice_from(2),
|
name.slice_from(2),
|
||||||
value);
|
attr.value().as_slice().to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::HTMLButtonElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLButtonElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, NodeCast};
|
||||||
|
@ -78,15 +80,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(true);
|
node.set_disabled_state(true);
|
||||||
node.set_enabled_state(false);
|
node.set_enabled_state(false);
|
||||||
},
|
},
|
||||||
|
@ -94,15 +96,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLButtonElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(false);
|
node.set_disabled_state(false);
|
||||||
node.set_enabled_state(true);
|
node.set_enabled_state(true);
|
||||||
node.check_ancestors_disabled_state_for_form_control();
|
node.check_ancestors_disabled_state_for_form_control();
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::HTMLCanvasElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLCanvasElementBinding::HTMLCanvasElementMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::HTMLCanvasElementDerived;
|
use dom::bindings::codegen::InheritTypes::HTMLCanvasElementDerived;
|
||||||
|
@ -18,7 +20,6 @@ use dom::node::{Node, ElementNodeTypeId, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
|
||||||
use servo_util::str::{DOMString, parse_unsigned_integer};
|
use servo_util::str::{DOMString, parse_unsigned_integer};
|
||||||
use string_cache::Atom;
|
|
||||||
|
|
||||||
use geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
|
|
||||||
|
@ -99,18 +100,18 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
|
||||||
Some(element as &VirtualMethods)
|
Some(element as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value.clone()),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
let recreate = match name.as_slice() {
|
let recreate = match attr.local_name() {
|
||||||
"width" => {
|
&atom!("width") => {
|
||||||
self.width.set(DefaultWidth);
|
self.width.set(DefaultWidth);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
"height" => {
|
&atom!("height") => {
|
||||||
self.height.set(DefaultHeight);
|
self.height.set(DefaultHeight);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -126,18 +127,19 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
let recreate = match name.as_slice() {
|
let value = attr.value();
|
||||||
"width" => {
|
let recreate = match attr.local_name() {
|
||||||
|
&atom!("width") => {
|
||||||
self.width.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DefaultWidth));
|
self.width.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DefaultWidth));
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
"height" => {
|
&atom!("height") => {
|
||||||
self.height.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DefaultHeight));
|
self.height.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DefaultHeight));
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
use dom::bindings::codegen::Bindings::HTMLElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods;
|
||||||
|
@ -18,7 +20,6 @@ use dom::node::{Node, ElementNodeTypeId, window_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
use string_cache::Atom;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct HTMLElement {
|
pub struct HTMLElement {
|
||||||
|
@ -99,21 +100,22 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
|
||||||
Some(element as &VirtualMethods)
|
Some(element as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if name.as_slice().starts_with("on") {
|
let name = attr.local_name().as_slice();
|
||||||
|
if name.starts_with("on") {
|
||||||
let window = window_from_node(*self).root();
|
let window = window_from_node(*self).root();
|
||||||
let (cx, url, reflector) = (window.get_cx(),
|
let (cx, url, reflector) = (window.get_cx(),
|
||||||
window.get_url(),
|
window.get_url(),
|
||||||
window.reflector().get_jsobject());
|
window.reflector().get_jsobject());
|
||||||
let evtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
|
let evtarget: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
|
||||||
evtarget.set_event_handler_uncompiled(cx, url, reflector,
|
evtarget.set_event_handler_uncompiled(cx, url, reflector,
|
||||||
name.as_slice().slice_from(2),
|
name.slice_from(2),
|
||||||
value);
|
attr.value().as_slice().to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding::HTMLFieldSetElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLFieldSetElementBinding::HTMLFieldSetElementMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFieldSetElementDerived, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLFieldSetElementDerived, NodeCast};
|
||||||
|
@ -83,15 +85,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(true);
|
node.set_disabled_state(true);
|
||||||
node.set_enabled_state(false);
|
node.set_enabled_state(false);
|
||||||
let maybe_legend = node.children().find(|node| node.is_htmllegendelement());
|
let maybe_legend = node.children().find(|node| node.is_htmllegendelement());
|
||||||
|
@ -115,15 +117,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLFieldSetElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(false);
|
node.set_disabled_state(false);
|
||||||
node.set_enabled_state(true);
|
node.set_enabled_state(true);
|
||||||
let maybe_legend = node.children().find(|node| node.is_htmllegendelement());
|
let maybe_legend = node.children().find(|node| node.is_htmllegendelement());
|
||||||
|
|
|
@ -2,6 +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::AttrHelpers;
|
use dom::attr::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
||||||
|
@ -23,7 +24,6 @@ use servo_msg::constellation_msg::{PipelineId, SubpageId};
|
||||||
use servo_msg::constellation_msg::{IFrameSandboxed, IFrameUnsandboxed};
|
use servo_msg::constellation_msg::{IFrameSandboxed, IFrameUnsandboxed};
|
||||||
use servo_msg::constellation_msg::{ConstellationChan, LoadIframeUrlMsg};
|
use servo_msg::constellation_msg::{ConstellationChan, LoadIframeUrlMsg};
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
use string_cache::Atom;
|
|
||||||
|
|
||||||
use std::ascii::StrAsciiExt;
|
use std::ascii::StrAsciiExt;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -188,15 +188,16 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if "sandbox" == name.as_slice() {
|
match attr.local_name() {
|
||||||
|
&atom!("sandbox") => {
|
||||||
let mut modes = AllowNothing as u8;
|
let mut modes = AllowNothing as u8;
|
||||||
for word in value.as_slice().split(' ') {
|
for word in attr.value().as_slice().split(' ') {
|
||||||
modes |= match word.to_ascii_lower().as_slice() {
|
modes |= match word.to_ascii_lower().as_slice() {
|
||||||
"allow-same-origin" => AllowSameOrigin,
|
"allow-same-origin" => AllowSameOrigin,
|
||||||
"allow-forms" => AllowForms,
|
"allow-forms" => AllowForms,
|
||||||
|
@ -208,24 +209,26 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
} as u8;
|
} as u8;
|
||||||
}
|
}
|
||||||
self.sandbox.set(Some(modes));
|
self.sandbox.set(Some(modes));
|
||||||
}
|
},
|
||||||
|
&atom!("src") => {
|
||||||
if "src" == name.as_slice() {
|
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
if node.is_in_doc() {
|
if node.is_in_doc() {
|
||||||
self.process_the_iframe_attributes()
|
self.process_the_iframe_attributes()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if "sandbox" == name.as_slice() {
|
match attr.local_name() {
|
||||||
self.sandbox.set(None);
|
&atom!("sandbox") => self.sandbox.set(None),
|
||||||
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
* 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::AttrValue;
|
use dom::attr::Attr;
|
||||||
|
use dom::attr::{AttrHelpers, AttrValue};
|
||||||
use dom::bindings::cell::DOMRefCell;
|
use dom::bindings::cell::DOMRefCell;
|
||||||
use dom::bindings::codegen::Bindings::HTMLImageElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLImageElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
|
||||||
|
@ -166,27 +167,31 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if "src" == name.as_slice() {
|
match attr.local_name() {
|
||||||
|
&atom!("src") => {
|
||||||
let window = window_from_node(*self).root();
|
let window = window_from_node(*self).root();
|
||||||
let url = window.get_url();
|
let url = window.get_url();
|
||||||
self.update_image(Some((value, &url)));
|
self.update_image(Some((attr.value().as_slice().to_string(), &url)));
|
||||||
|
},
|
||||||
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value.clone()),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if atom!("src") == *name {
|
match attr.local_name() {
|
||||||
self.update_image(None);
|
&atom!("src") => self.update_image(None),
|
||||||
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::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;
|
||||||
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||||
|
@ -13,7 +15,6 @@ use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLFor
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLFieldSetElementDerived};
|
use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLFieldSetElementDerived};
|
||||||
use dom::bindings::js::{JS, JSRef, Temporary, OptionalRootable, ResultRootable};
|
use dom::bindings::js::{JS, JSRef, Temporary, OptionalRootable, ResultRootable};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
use dom::attr::{AttrHelpers};
|
|
||||||
use dom::document::{Document, DocumentHelpers};
|
use dom::document::{Document, DocumentHelpers};
|
||||||
use dom::element::{AttributeHandlers, Element, HTMLInputElementTypeId};
|
use dom::element::{AttributeHandlers, Element, HTMLInputElementTypeId};
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
|
@ -265,27 +266,29 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(true);
|
node.set_disabled_state(true);
|
||||||
node.set_enabled_state(false);
|
node.set_enabled_state(false);
|
||||||
}
|
}
|
||||||
"checked" => {
|
&atom!("checked") => {
|
||||||
self.update_checked_state(true);
|
self.update_checked_state(true);
|
||||||
}
|
}
|
||||||
"size" => {
|
&atom!("size") => {
|
||||||
|
let value = attr.value();
|
||||||
let parsed = parse_unsigned_integer(value.as_slice().chars());
|
let parsed = parse_unsigned_integer(value.as_slice().chars());
|
||||||
self.size.set(parsed.unwrap_or(DEFAULT_INPUT_SIZE));
|
self.size.set(parsed.unwrap_or(DEFAULT_INPUT_SIZE));
|
||||||
self.force_relayout();
|
self.force_relayout();
|
||||||
}
|
}
|
||||||
"type" => {
|
&atom!("type") => {
|
||||||
|
let value = attr.value();
|
||||||
self.input_type.set(match value.as_slice() {
|
self.input_type.set(match value.as_slice() {
|
||||||
"button" => InputButton(None),
|
"button" => InputButton(None),
|
||||||
"submit" => InputButton(Some(DEFAULT_SUBMIT_VALUE)),
|
"submit" => InputButton(Some(DEFAULT_SUBMIT_VALUE)),
|
||||||
|
@ -303,12 +306,13 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
}
|
}
|
||||||
self.force_relayout();
|
self.force_relayout();
|
||||||
}
|
}
|
||||||
"value" => {
|
&atom!("value") => {
|
||||||
*self.value.borrow_mut() = Some(value);
|
*self.value.borrow_mut() = Some(attr.value().as_slice().to_string());
|
||||||
self.force_relayout();
|
self.force_relayout();
|
||||||
}
|
}
|
||||||
"name" => {
|
&atom!("name") => {
|
||||||
if self.input_type.get() == InputRadio {
|
if self.input_type.get() == InputRadio {
|
||||||
|
let value = attr.value();
|
||||||
self.radio_group_updated(Some(value.as_slice()));
|
self.radio_group_updated(Some(value.as_slice()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,27 +320,27 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(false);
|
node.set_disabled_state(false);
|
||||||
node.set_enabled_state(true);
|
node.set_enabled_state(true);
|
||||||
node.check_ancestors_disabled_state_for_form_control();
|
node.check_ancestors_disabled_state_for_form_control();
|
||||||
}
|
}
|
||||||
"checked" => {
|
&atom!("checked") => {
|
||||||
self.update_checked_state(false);
|
self.update_checked_state(false);
|
||||||
}
|
}
|
||||||
"size" => {
|
&atom!("size") => {
|
||||||
self.size.set(DEFAULT_INPUT_SIZE);
|
self.size.set(DEFAULT_INPUT_SIZE);
|
||||||
self.force_relayout();
|
self.force_relayout();
|
||||||
}
|
}
|
||||||
"type" => {
|
&atom!("type") => {
|
||||||
if self.input_type.get() == InputRadio {
|
if self.input_type.get() == InputRadio {
|
||||||
broadcast_radio_checked(*self,
|
broadcast_radio_checked(*self,
|
||||||
self.get_radio_group()
|
self.get_radio_group()
|
||||||
|
@ -346,11 +350,11 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
|
||||||
self.input_type.set(InputText);
|
self.input_type.set(InputText);
|
||||||
self.force_relayout();
|
self.force_relayout();
|
||||||
}
|
}
|
||||||
"value" => {
|
&atom!("value") => {
|
||||||
*self.value.borrow_mut() = None;
|
*self.value.borrow_mut() = None;
|
||||||
self.force_relayout();
|
self.force_relayout();
|
||||||
}
|
}
|
||||||
"name" => {
|
&atom!("name") => {
|
||||||
if self.input_type.get() == InputRadio {
|
if self.input_type.get() == InputRadio {
|
||||||
self.radio_group_updated(None);
|
self.radio_group_updated(None);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +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::AttrHelpers;
|
use dom::attr::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::HTMLLinkElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLLinkElementBinding;
|
||||||
use dom::bindings::codegen::InheritTypes::HTMLLinkElementDerived;
|
use dom::bindings::codegen::InheritTypes::HTMLLinkElementDerived;
|
||||||
|
@ -67,19 +68,19 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
let element: JSRef<Element> = ElementCast::from_ref(*self);
|
let element: JSRef<Element> = ElementCast::from_ref(*self);
|
||||||
let rel = get_attr(element, &atom!("rel"));
|
let rel = get_attr(element, &atom!("rel"));
|
||||||
|
|
||||||
match (rel, name.as_slice()) {
|
match (rel, attr.local_name()) {
|
||||||
(ref rel, "href") => {
|
(ref rel, &atom!("href")) => {
|
||||||
if is_stylesheet(rel) {
|
if is_stylesheet(rel) {
|
||||||
self.handle_stylesheet_url(value.as_slice());
|
self.handle_stylesheet_url(attr.value().as_slice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(_, _) => ()
|
(_, _) => ()
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
|
||||||
use dom::bindings::codegen::Bindings::HTMLObjectElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLObjectElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLObjectElementBinding::HTMLObjectElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLObjectElementBinding::HTMLObjectElementMethods;
|
||||||
|
@ -99,15 +101,18 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if "data" == name.as_slice() {
|
match attr.local_name() {
|
||||||
|
&atom!("data") => {
|
||||||
let window = window_from_node(*self).root();
|
let window = window_from_node(*self).root();
|
||||||
self.process_data_url(window.image_cache_task().clone());
|
self.process_data_url(window.image_cache_task().clone());
|
||||||
|
},
|
||||||
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding::HTMLOptGroupElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding::HTMLOptGroupElementMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
|
||||||
|
@ -57,15 +59,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptGroupElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(true);
|
node.set_disabled_state(true);
|
||||||
node.set_enabled_state(false);
|
node.set_enabled_state(false);
|
||||||
for child in node.children().filter(|child| child.is_htmloptionelement()) {
|
for child in node.children().filter(|child| child.is_htmloptionelement()) {
|
||||||
|
@ -77,15 +79,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptGroupElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(false);
|
node.set_disabled_state(false);
|
||||||
node.set_enabled_state(true);
|
node.set_enabled_state(true);
|
||||||
for child in node.children().filter(|child| child.is_htmloptionelement()) {
|
for child in node.children().filter(|child| child.is_htmloptionelement()) {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
|
||||||
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLOptionElementBinding::HTMLOptionElementMethods;
|
||||||
|
@ -97,15 +99,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(true);
|
node.set_disabled_state(true);
|
||||||
node.set_enabled_state(false);
|
node.set_enabled_state(false);
|
||||||
},
|
},
|
||||||
|
@ -113,15 +115,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLOptionElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(false);
|
node.set_disabled_state(false);
|
||||||
node.set_enabled_state(true);
|
node.set_enabled_state(true);
|
||||||
node.check_parent_disabled_state_for_option();
|
node.check_parent_disabled_state_for_option();
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLSelectElementBinding::HTMLSelectElementMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
|
||||||
|
@ -79,15 +81,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(true);
|
node.set_disabled_state(true);
|
||||||
node.set_enabled_state(false);
|
node.set_enabled_state(false);
|
||||||
},
|
},
|
||||||
|
@ -95,15 +97,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLSelectElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(false);
|
node.set_disabled_state(false);
|
||||||
node.set_enabled_state(true);
|
node.set_enabled_state(true);
|
||||||
node.check_ancestors_disabled_state_for_form_control();
|
node.check_ancestors_disabled_state_for_form_control();
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableCellElementDerived};
|
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableCellElementDerived};
|
||||||
use dom::bindings::js::JSRef;
|
use dom::bindings::js::JSRef;
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
|
@ -16,7 +18,6 @@ use dom::virtualmethods::VirtualMethods;
|
||||||
use servo_util::str::{AutoLpa, DOMString, LengthOrPercentageOrAuto};
|
use servo_util::str::{AutoLpa, DOMString, LengthOrPercentageOrAuto};
|
||||||
use servo_util::str;
|
use servo_util::str;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use string_cache::Atom;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct HTMLTableCellElement {
|
pub struct HTMLTableCellElement {
|
||||||
|
@ -64,27 +65,27 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTableCellElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => {}
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
match name.as_slice() {
|
match attr.local_name() {
|
||||||
"width" => self.width.set(str::parse_length(value.as_slice())),
|
&atom!("width") => self.width.set(str::parse_length(attr.value().as_slice())),
|
||||||
_ => {}
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => {}
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
match name.as_slice() {
|
match attr.local_name() {
|
||||||
"width" => self.width.set(AutoLpa),
|
&atom!("width") => self.width.set(AutoLpa),
|
||||||
_ => {}
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* 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::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
|
||||||
|
@ -62,15 +64,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
||||||
Some(htmlelement as &VirtualMethods)
|
Some(htmlelement as &VirtualMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value.clone()),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(true);
|
node.set_disabled_state(true);
|
||||||
node.set_enabled_state(false);
|
node.set_enabled_state(false);
|
||||||
},
|
},
|
||||||
|
@ -78,15 +80,15 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match attr.local_name() {
|
||||||
|
&atom!("disabled") => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||||
match name.as_slice() {
|
|
||||||
"disabled" => {
|
|
||||||
node.set_disabled_state(false);
|
node.set_disabled_state(false);
|
||||||
node.set_enabled_state(true);
|
node.set_enabled_state(true);
|
||||||
node.check_ancestors_disabled_state_for_form_control();
|
node.check_ancestors_disabled_state_for_form_control();
|
||||||
|
|
|
@ -2,6 +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::{AttrValue, StringAttrValue};
|
use dom::attr::{AttrValue, StringAttrValue};
|
||||||
use dom::bindings::codegen::InheritTypes::ElementCast;
|
use dom::bindings::codegen::InheritTypes::ElementCast;
|
||||||
use dom::bindings::codegen::InheritTypes::HTMLAnchorElementCast;
|
use dom::bindings::codegen::InheritTypes::HTMLAnchorElementCast;
|
||||||
|
@ -62,7 +63,6 @@ use dom::htmltextareaelement::HTMLTextAreaElement;
|
||||||
use dom::node::{Node, NodeHelpers, ElementNodeTypeId};
|
use dom::node::{Node, NodeHelpers, ElementNodeTypeId};
|
||||||
|
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
use string_cache::Atom;
|
|
||||||
|
|
||||||
/// Trait to allow DOM nodes to opt-in to overriding (or adding to) common
|
/// Trait to allow DOM nodes to opt-in to overriding (or adding to) common
|
||||||
/// behaviours. Replicates the effect of C++ virtual methods.
|
/// behaviours. Replicates the effect of C++ virtual methods.
|
||||||
|
@ -73,18 +73,18 @@ pub trait VirtualMethods {
|
||||||
|
|
||||||
/// Called when changing or adding attributes, after the attribute's value
|
/// Called when changing or adding attributes, after the attribute's value
|
||||||
/// has been updated.
|
/// has been updated.
|
||||||
fn after_set_attr(&self, name: &Atom, value: DOMString) {
|
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.after_set_attr(name, value),
|
Some(ref s) => s.after_set_attr(attr),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when changing or removing attributes, before any modification
|
/// Called when changing or removing attributes, before any modification
|
||||||
/// has taken place.
|
/// has taken place.
|
||||||
fn before_remove_attr(&self, name: &Atom, value: DOMString) {
|
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||||
match self.super_type() {
|
match self.super_type() {
|
||||||
Some(ref s) => s.before_remove_attr(name, value),
|
Some(ref s) => s.before_remove_attr(attr),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue