Move what is now an |impl Element| block to element.rs.

This is a simple cut/paste.
This commit is contained in:
Bobby Holley 2015-10-08 19:15:41 -07:00
parent 75ec093334
commit ac8d57cda7
2 changed files with 50 additions and 51 deletions

View file

@ -22,8 +22,9 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, DocumentDerived, ElementCast};
use dom::bindings::codegen::InheritTypes::{ElementDerived, ElementTypeId, EventTargetCast};
use dom::bindings::codegen::InheritTypes::{HTMLAnchorElementCast, HTMLBodyElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLElementTypeId, HTMLFontElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLElementTypeId, HTMLFieldSetElementDerived, HTMLFontElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLIFrameElementCast, HTMLInputElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLLegendElementDerived, HTMLOptGroupElementDerived};
use dom::bindings::codegen::InheritTypes::{HTMLTableCellElementCast, HTMLTableElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLTableRowElementCast, HTMLTableSectionElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLTemplateElementCast, HTMLTextAreaElementCast};
@ -1900,6 +1901,53 @@ impl Element {
}
}
impl Element {
pub fn check_ancestors_disabled_state_for_form_control(&self) {
let node = NodeCast::from_ref(self);
if self.get_disabled_state() { return; }
for ancestor in node.ancestors() {
let ancestor = ancestor;
let ancestor = ancestor.r();
if !ancestor.is_htmlfieldsetelement() { continue; }
if !ElementCast::to_ref(ancestor).unwrap().get_disabled_state() { continue; }
if ancestor.is_parent_of(node) {
self.set_disabled_state(true);
self.set_enabled_state(false);
return;
}
match ancestor.children()
.find(|child| child.r().is_htmllegendelement())
{
Some(ref legend) => {
// XXXabinader: should we save previous ancestor to avoid this iteration?
if node.ancestors().any(|ancestor| ancestor == *legend) { continue; }
},
None => ()
}
self.set_disabled_state(true);
self.set_enabled_state(false);
return;
}
}
pub fn check_parent_disabled_state_for_option(&self) {
if self.get_disabled_state() { return; }
let node = NodeCast::from_ref(self);
if let Some(ref parent) = node.GetParentNode() {
if parent.r().is_htmloptgroupelement() && ElementCast::to_ref(parent.r()).unwrap().get_disabled_state() {
self.set_disabled_state(true);
self.set_enabled_state(false);
}
}
}
pub fn check_disabled_attribute(&self) {
let has_disabled_attrib = self.has_attribute(&atom!("disabled"));
self.set_disabled_state(has_disabled_attrib);
self.set_enabled_state(!has_disabled_attrib);
}
}
#[derive(Clone, Copy, PartialEq)]
pub enum AttributeMutation<'a> {
/// The attribute is set, keep track of old value.

View file

@ -22,8 +22,7 @@ use dom::bindings::codegen::InheritTypes::{CharacterDataCast, CharacterDataTypeI
use dom::bindings::codegen::InheritTypes::{DocumentCast, DocumentDerived, DocumentTypeCast};
use dom::bindings::codegen::InheritTypes::{ElementCast, ElementDerived, ElementTypeId};
use dom::bindings::codegen::InheritTypes::{EventTargetCast, EventTargetTypeId};
use dom::bindings::codegen::InheritTypes::{HTMLElementTypeId, HTMLFieldSetElementDerived};
use dom::bindings::codegen::InheritTypes::{HTMLLegendElementDerived, HTMLOptGroupElementDerived};
use dom::bindings::codegen::InheritTypes::{HTMLElementTypeId};
use dom::bindings::codegen::InheritTypes::{NodeBase, NodeCast, NodeTypeId};
use dom::bindings::codegen::InheritTypes::{ProcessingInstructionCast, TextCast, TextDerived};
use dom::bindings::codegen::UnionTypes::NodeOrString;
@ -2361,54 +2360,6 @@ impl VirtualMethods for Node {
}
}
impl Element {
pub fn check_ancestors_disabled_state_for_form_control(&self) {
let node = NodeCast::from_ref(self);
if self.get_disabled_state() { return; }
for ancestor in node.ancestors() {
let ancestor = ancestor;
let ancestor = ancestor.r();
if !ancestor.is_htmlfieldsetelement() { continue; }
if !ElementCast::to_ref(ancestor).unwrap().get_disabled_state() { continue; }
if ancestor.is_parent_of(node) {
self.set_disabled_state(true);
self.set_enabled_state(false);
return;
}
match ancestor.children()
.find(|child| child.r().is_htmllegendelement())
{
Some(ref legend) => {
// XXXabinader: should we save previous ancestor to avoid this iteration?
if node.ancestors().any(|ancestor| ancestor == *legend) { continue; }
},
None => ()
}
self.set_disabled_state(true);
self.set_enabled_state(false);
return;
}
}
pub fn check_parent_disabled_state_for_option(&self) {
if self.get_disabled_state() { return; }
let node = NodeCast::from_ref(self);
if let Some(ref parent) = node.GetParentNode() {
if parent.r().is_htmloptgroupelement() && ElementCast::to_ref(parent.r()).unwrap().get_disabled_state() {
self.set_disabled_state(true);
self.set_enabled_state(false);
}
}
}
pub fn check_disabled_attribute(&self) {
let has_disabled_attrib = self.has_attribute(&atom!("disabled"));
self.set_disabled_state(has_disabled_attrib);
self.set_enabled_state(!has_disabled_attrib);
}
}
/// A summary of the changes that happened to a node.
#[derive(Copy, Clone, PartialEq, HeapSizeOf)]
pub enum NodeDamage {