mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Add node.removeChild
This commit is contained in:
parent
995e4fdd11
commit
bcd7c0b8c6
3 changed files with 24 additions and 5 deletions
|
@ -290,7 +290,8 @@ DOMInterfaces = {
|
||||||
'Node': {
|
'Node': {
|
||||||
'nativeType': 'AbstractNode<ScriptView>',
|
'nativeType': 'AbstractNode<ScriptView>',
|
||||||
'concreteType': 'Node<ScriptView>',
|
'concreteType': 'Node<ScriptView>',
|
||||||
'pointerType': ''
|
'pointerType': '',
|
||||||
|
'needsAbstract': ['removeChild']
|
||||||
},
|
},
|
||||||
|
|
||||||
'NodeList': [
|
'NodeList': [
|
||||||
|
|
|
@ -795,7 +795,8 @@ impl DerivedWrapper for AbstractNode<ScriptView> {
|
||||||
|
|
||||||
#[deriving(ToStr)]
|
#[deriving(ToStr)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
FailureUnknown
|
FailureUnknown,
|
||||||
|
NotFound,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ErrorResult = Result<(), Error>;
|
pub type ErrorResult = Result<(), Error>;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
//! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements.
|
//! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements.
|
||||||
|
|
||||||
use dom::bindings::node;
|
use dom::bindings::node;
|
||||||
use dom::bindings::utils::{WrapperCache, DOMString, null_string, str, ErrorResult};
|
use dom::bindings::utils::{WrapperCache, DOMString, null_string, str, ErrorResult, NotFound};
|
||||||
use dom::bindings::utils::{BindingObject, CacheableWrapper, rust_box};
|
use dom::bindings::utils::{BindingObject, CacheableWrapper, rust_box};
|
||||||
use dom::bindings;
|
use dom::bindings;
|
||||||
use dom::characterdata::CharacterData;
|
use dom::characterdata::CharacterData;
|
||||||
|
@ -561,8 +561,25 @@ impl Node<ScriptView> {
|
||||||
fail!("stub")
|
fail!("stub")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn RemoveChild(&mut self, _node: AbstractNode<ScriptView>, _rv: &mut ErrorResult) -> AbstractNode<ScriptView> {
|
pub fn RemoveChild(&mut self,
|
||||||
fail!("stub")
|
abstract_self: AbstractNode<ScriptView>,
|
||||||
|
node: AbstractNode<ScriptView>,
|
||||||
|
rv: &mut ErrorResult) -> AbstractNode<ScriptView> {
|
||||||
|
fn is_not_found_err(this_node: AbstractNode<ScriptView>,
|
||||||
|
old_child: AbstractNode<ScriptView>) -> bool {
|
||||||
|
match old_child.parent_node() {
|
||||||
|
Some(parent) if parent == this_node => false,
|
||||||
|
_ => true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if is_not_found_err(abstract_self, node) {
|
||||||
|
*rv = Err(NotFound);
|
||||||
|
}
|
||||||
|
if rv.is_ok() {
|
||||||
|
abstract_self.remove_child(node);
|
||||||
|
}
|
||||||
|
node
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Normalize(&mut self) {
|
pub fn Normalize(&mut self) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue