diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2015-07-18 14:45:52 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2015-07-25 19:09:40 +0200 |
commit | 7b40cc9fd7ea4dcc3816be0cb1ad6543bb5c88e0 (patch) | |
tree | e5667ee45868c9cbb34d8458cb88a85343467aae /components/script/dom/htmltextareaelement.rs | |
parent | 389a9ff643b714c6c8ba01fd8f1d208773dccb7a (diff) | |
download | servo-7b40cc9fd7ea4dcc3816be0cb1ad6543bb5c88e0.tar.gz servo-7b40cc9fd7ea4dcc3816be0cb1ad6543bb5c88e0.zip |
Introduce VirtualMethods::children_changed()
This virtual method mimics the behaviour of mutation observers and make it more
viable than the older child_inserted(), which didn't cover removed nodes and
was called as many times as there were inserted nodes.
A few other shortcomings where remove_child() was called directly instead of
Node::remove() were also fixed while at it.
Diffstat (limited to 'components/script/dom/htmltextareaelement.rs')
-rw-r--r-- | components/script/dom/htmltextareaelement.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 17e646d71ed..22e843fa08f 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaEl use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::InheritTypes::{ElementCast, EventTargetCast, HTMLElementCast, NodeCast}; use dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementDerived, HTMLFieldSetElementDerived}; -use dom::bindings::codegen::InheritTypes::{KeyboardEventCast, TextDerived}; +use dom::bindings::codegen::InheritTypes::KeyboardEventCast; use dom::bindings::global::GlobalRef; use dom::bindings::js::{LayoutJS, Root}; use dom::bindings::refcounted::Trusted; @@ -23,8 +23,8 @@ use dom::element::ElementTypeId; use dom::htmlelement::{HTMLElement, HTMLElementTypeId}; use dom::htmlformelement::FormControl; use dom::keyboardevent::KeyboardEvent; -use dom::node::{DisabledStateHelpers, Node, NodeHelpers, NodeDamage, NodeTypeId}; -use dom::node::{document_from_node, window_from_node}; +use dom::node::{ChildrenMutation, DisabledStateHelpers, Node, NodeDamage}; +use dom::node::{NodeHelpers, NodeTypeId, document_from_node, window_from_node}; use textinput::{TextInput, Lines, KeyReaction}; use dom::virtualmethods::VirtualMethods; use dom::window::WindowHelpers; @@ -330,12 +330,11 @@ impl<'a> VirtualMethods for &'a HTMLTextAreaElement { } } - fn child_inserted(&self, child: &Node) { - if let Some(s) = self.super_type() { - s.child_inserted(child); + fn children_changed(&self, mutation: &ChildrenMutation) { + if let Some(ref s) = self.super_type() { + s.children_changed(mutation); } - - if child.is_text() && !self.value_changed.get() { + if !self.value_changed.get() { self.reset(); } } |