mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
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.
This commit is contained in:
parent
389a9ff643
commit
7b40cc9fd7
7 changed files with 194 additions and 180 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue