mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Make all DOM manipulation wait until it's safe to do so (ie. all reflows for the page have completed). Fix a race where a newly-initiated reflow would be considered complete when receiving the completion notice for the previous reflow.
This commit is contained in:
parent
37787d55d0
commit
d465abdb1c
7 changed files with 49 additions and 10 deletions
|
@ -625,6 +625,8 @@ impl Node<ScriptView> {
|
|||
self.replace_all(abstract_self, node);
|
||||
}
|
||||
CommentNodeTypeId | TextNodeTypeId => {
|
||||
self.wait_until_safe_to_modify_dom();
|
||||
|
||||
do abstract_self.with_mut_characterdata() |characterdata| {
|
||||
characterdata.data = value.to_str();
|
||||
|
||||
|
@ -644,6 +646,14 @@ impl Node<ScriptView> {
|
|||
fail!("stub")
|
||||
}
|
||||
|
||||
fn wait_until_safe_to_modify_dom(&self) {
|
||||
for doc in self.owner_doc.iter() {
|
||||
do doc.with_base |doc| {
|
||||
doc.wait_until_safe_to_modify_dom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn AppendChild(&mut self,
|
||||
abstract_self: AbstractNode<ScriptView>,
|
||||
node: AbstractNode<ScriptView>,
|
||||
|
@ -676,6 +686,8 @@ impl Node<ScriptView> {
|
|||
// TODO: Should we handle WRONG_DOCUMENT_ERR here?
|
||||
|
||||
if rv.is_ok() {
|
||||
self.wait_until_safe_to_modify_dom();
|
||||
|
||||
// If the node already exists it is removed from current parent node.
|
||||
node.parent_node().map(|parent| parent.remove_child(node));
|
||||
abstract_self.add_child(node);
|
||||
|
@ -709,6 +721,8 @@ impl Node<ScriptView> {
|
|||
*rv = Err(NotFound);
|
||||
}
|
||||
if rv.is_ok() {
|
||||
self.wait_until_safe_to_modify_dom();
|
||||
|
||||
abstract_self.remove_child(node);
|
||||
self.remove_from_doc();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue