mirror of
https://github.com/servo/servo.git
synced 2025-07-25 16:20:36 +01:00
Move what is now an |impl Element| block to element.rs.
This is a simple cut/paste.
This commit is contained in:
parent
75ec093334
commit
ac8d57cda7
2 changed files with 50 additions and 51 deletions
|
@ -22,8 +22,9 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, DocumentDerived, ElementCast};
|
use dom::bindings::codegen::InheritTypes::{CharacterDataCast, DocumentDerived, ElementCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{ElementDerived, ElementTypeId, EventTargetCast};
|
use dom::bindings::codegen::InheritTypes::{ElementDerived, ElementTypeId, EventTargetCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLAnchorElementCast, HTMLBodyElementCast};
|
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::{HTMLIFrameElementCast, HTMLInputElementCast};
|
||||||
|
use dom::bindings::codegen::InheritTypes::{HTMLLegendElementDerived, HTMLOptGroupElementDerived};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLTableCellElementCast, HTMLTableElementCast};
|
use dom::bindings::codegen::InheritTypes::{HTMLTableCellElementCast, HTMLTableElementCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLTableRowElementCast, HTMLTableSectionElementCast};
|
use dom::bindings::codegen::InheritTypes::{HTMLTableRowElementCast, HTMLTableSectionElementCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLTemplateElementCast, HTMLTextAreaElementCast};
|
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)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
pub enum AttributeMutation<'a> {
|
pub enum AttributeMutation<'a> {
|
||||||
/// The attribute is set, keep track of old value.
|
/// The attribute is set, keep track of old value.
|
||||||
|
|
|
@ -22,8 +22,7 @@ use dom::bindings::codegen::InheritTypes::{CharacterDataCast, CharacterDataTypeI
|
||||||
use dom::bindings::codegen::InheritTypes::{DocumentCast, DocumentDerived, DocumentTypeCast};
|
use dom::bindings::codegen::InheritTypes::{DocumentCast, DocumentDerived, DocumentTypeCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{ElementCast, ElementDerived, ElementTypeId};
|
use dom::bindings::codegen::InheritTypes::{ElementCast, ElementDerived, ElementTypeId};
|
||||||
use dom::bindings::codegen::InheritTypes::{EventTargetCast, EventTargetTypeId};
|
use dom::bindings::codegen::InheritTypes::{EventTargetCast, EventTargetTypeId};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLElementTypeId, HTMLFieldSetElementDerived};
|
use dom::bindings::codegen::InheritTypes::{HTMLElementTypeId};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLLegendElementDerived, HTMLOptGroupElementDerived};
|
|
||||||
use dom::bindings::codegen::InheritTypes::{NodeBase, NodeCast, NodeTypeId};
|
use dom::bindings::codegen::InheritTypes::{NodeBase, NodeCast, NodeTypeId};
|
||||||
use dom::bindings::codegen::InheritTypes::{ProcessingInstructionCast, TextCast, TextDerived};
|
use dom::bindings::codegen::InheritTypes::{ProcessingInstructionCast, TextCast, TextDerived};
|
||||||
use dom::bindings::codegen::UnionTypes::NodeOrString;
|
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.
|
/// A summary of the changes that happened to a node.
|
||||||
#[derive(Copy, Clone, PartialEq, HeapSizeOf)]
|
#[derive(Copy, Clone, PartialEq, HeapSizeOf)]
|
||||||
pub enum NodeDamage {
|
pub enum NodeDamage {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue