mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Incremental Style Recalc
This patch puts in the initial framework for incremental reflow. Nodes' styles are no longer recalculated unless the node has changed. I've been hacking on the general problem of incremental reflow for the past couple weeks, and I've yet to get a full implementation that actually passes all the reftests + wikipedia + cnn. Therefore, I'm going to try to land the different parts of it one by one. This patch only does incremental style recalc, without incremental flow construction, inline-size bubbling, reflow, or display lists. Those will be coming in that order as I finish them. At least with this strategy, I can land a working version of incremental reflow, even if not yet complete. r? @pcwalton
This commit is contained in:
parent
510f8a817f
commit
d12c6e7383
31 changed files with 641 additions and 424 deletions
|
@ -28,8 +28,6 @@ use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator, document_fro
|
|||
use dom::node::{window_from_node, LayoutNodeHelpers};
|
||||
use dom::nodelist::NodeList;
|
||||
use dom::virtualmethods::{VirtualMethods, vtable_for};
|
||||
use layout_interface::ContentChangedDocumentDamage;
|
||||
use layout_interface::MatchSelectorsDocumentDamage;
|
||||
use devtools_traits::AttrInfo;
|
||||
use style::{matches, parse_selector_list_from_str};
|
||||
use style;
|
||||
|
@ -323,6 +321,7 @@ pub trait AttributeHandlers {
|
|||
fn remove_attribute(self, namespace: Namespace, name: &str);
|
||||
fn notify_attribute_changed(self, local_name: &Atom);
|
||||
fn has_class(&self, name: &str) -> bool;
|
||||
fn notify_attribute_removed(self);
|
||||
|
||||
fn set_atomic_attribute(self, name: &str, value: DOMString);
|
||||
|
||||
|
@ -436,19 +435,24 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
}
|
||||
|
||||
self.attrs.borrow_mut().remove(idx);
|
||||
self.notify_attribute_removed();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn notify_attribute_changed(self, local_name: &Atom) {
|
||||
fn notify_attribute_changed(self, _local_name: &Atom) {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
if node.is_in_doc() {
|
||||
let damage = match local_name.as_slice() {
|
||||
"style" | "id" | "class" => MatchSelectorsDocumentDamage,
|
||||
_ => ContentChangedDocumentDamage
|
||||
};
|
||||
let document = node.owner_doc().root();
|
||||
document.damage_and_reflow(damage);
|
||||
document.content_changed(node);
|
||||
}
|
||||
}
|
||||
|
||||
fn notify_attribute_removed(self) {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
if node.is_in_doc() {
|
||||
let document = node.owner_doc().root();
|
||||
document.content_changed(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue