servo: Merge #7794 - Dirty text nodes when their content changes (from mbrubeck:setdata); r=pcwalton

Fixes #7793. r? @pcwalton

Source-Repo: https://github.com/servo/servo
Source-Revision: fb6d0946cb3bac713bc20794f17a40fa7a12bc00
This commit is contained in:
Matt Brubeck 2015-09-30 11:49:52 -06:00
Родитель e56720dd4c
Коммит 7c86fa25db
1 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -15,7 +15,7 @@ use dom::bindings::js::{LayoutJS, Root};
use dom::document::Document;
use dom::element::Element;
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::node::{Node, NodeTypeId};
use dom::node::{Node, NodeDamage, NodeTypeId};
use std::borrow::ToOwned;
use std::cell::Ref;
use util::str::DOMString;
@ -54,6 +54,7 @@ impl CharacterDataMethods for CharacterData {
// https://dom.spec.whatwg.org/#dom-characterdata-data
fn SetData(&self, data: DOMString) {
*self.data.borrow_mut() = data;
self.content_changed();
}
// https://dom.spec.whatwg.org/#dom-characterdata-length
@ -117,6 +118,7 @@ impl CharacterDataMethods for CharacterData {
new_data
};
*self.data.borrow_mut() = new_data;
self.content_changed();
// FIXME: Once we have `Range`, we should implement step 8 to step 11
Ok(())
}
@ -171,7 +173,14 @@ impl CharacterData {
}
#[inline]
pub fn append_data(&self, data: &str) {
self.data.borrow_mut().push_str(data)
self.data.borrow_mut().push_str(data);
self.content_changed();
}
fn content_changed(&self) {
let node = NodeCast::from_ref(self);
let document = node.owner_doc();
document.r().content_changed(node, NodeDamage::OtherNodeDamage);
}
}