aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/layout_interface.rs
diff options
context:
space:
mode:
authorClark Gaebel <cgaebel@mozilla.com>2014-10-06 11:40:05 -0400
committerClark Gaebel <cgaebel@mozilla.com>2014-10-09 12:55:21 -0400
commitd12c6e7383e0be0a64a4f00f1416323038516395 (patch)
tree1b959fd51cd51a91a8a562c91423a9af724897bb /components/script/layout_interface.rs
parent510f8a817f8144dd5046886d4ca7c612f19a3d08 (diff)
downloadservo-d12c6e7383e0be0a64a4f00f1416323038516395.tar.gz
servo-d12c6e7383e0be0a64a4f00f1416323038516395.zip
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
Diffstat (limited to 'components/script/layout_interface.rs')
-rw-r--r--components/script/layout_interface.rs59
1 files changed, 2 insertions, 57 deletions
diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs
index 7de7260d8c5..a3c8de5a66a 100644
--- a/components/script/layout_interface.rs
+++ b/components/script/layout_interface.rs
@@ -14,11 +14,10 @@ use geom::point::Point2D;
use geom::rect::Rect;
use js::jsapi::JSTracer;
use libc::c_void;
-use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel};
+use script_traits::{ScriptControlChan, OpaqueScriptLayoutChannel, UntrustedNodeAddress};
use servo_msg::constellation_msg::WindowSizeData;
use servo_util::geometry::Au;
use std::any::{Any, AnyRefExt};
-use std::cmp;
use std::comm::{channel, Receiver, Sender};
use std::owned::BoxAny;
use style::Stylesheet;
@@ -85,47 +84,13 @@ impl JSTraceable for TrustedNodeAddress {
}
}
-/// The address of a node. Layout sends these back. They must be validated via
-/// `from_untrusted_node_address` before they can be used, because we do not trust layout.
-pub type UntrustedNodeAddress = *const c_void;
-
pub struct ContentBoxResponse(pub Rect<Au>);
pub struct ContentBoxesResponse(pub Vec<Rect<Au>>);
pub struct HitTestResponse(pub UntrustedNodeAddress);
pub struct MouseOverResponse(pub Vec<UntrustedNodeAddress>);
-/// Determines which part of the
-#[deriving(PartialEq, PartialOrd, Eq, Ord)]
-#[jstraceable]
-pub enum DocumentDamageLevel {
- /// Reflow, but do not perform CSS selector matching.
- ReflowDocumentDamage,
- /// Perform CSS selector matching and reflow.
- MatchSelectorsDocumentDamage,
- /// Content changed; set full style damage and do the above.
- ContentChangedDocumentDamage,
-}
-
-impl DocumentDamageLevel {
- /// Sets this damage to the maximum of this damage and the given damage.
- pub fn add(&mut self, new_damage: DocumentDamageLevel) {
- *self = cmp::max(*self, new_damage);
- }
-}
-
-/// What parts of the document have changed, as far as the script task can tell.
-///
-/// Note that this is fairly coarse-grained and is separate from layout's notion of the document
-#[jstraceable]
-pub struct DocumentDamage {
- /// The topmost node in the tree that has changed.
- pub root: TrustedNodeAddress,
- /// The amount of damage that occurred.
- pub level: DocumentDamageLevel,
-}
-
/// Why we're doing reflow.
-#[deriving(PartialEq)]
+#[deriving(PartialEq, Show)]
pub enum ReflowGoal {
/// We're reflowing in order to send a display list to the screen.
ReflowForDisplay,
@@ -137,8 +102,6 @@ pub enum ReflowGoal {
pub struct Reflow {
/// The document node.
pub document_root: TrustedNodeAddress,
- /// The style changes that need to be done.
- pub damage: DocumentDamage,
/// The goal of reflow: either to render to the screen or to flush layout info for script.
pub goal: ReflowGoal,
/// The URL of the page.
@@ -190,21 +153,3 @@ impl ScriptLayoutChan for OpaqueScriptLayoutChannel {
*receiver.downcast::<Receiver<Msg>>().unwrap()
}
}
-
-#[test]
-fn test_add_damage() {
- fn assert_add(mut a: DocumentDamageLevel, b: DocumentDamageLevel,
- result: DocumentDamageLevel) {
- a.add(b);
- assert!(a == result);
- }
-
- assert_add(ReflowDocumentDamage, ReflowDocumentDamage, ReflowDocumentDamage);
- assert_add(ContentChangedDocumentDamage, ContentChangedDocumentDamage, ContentChangedDocumentDamage);
- assert_add(ReflowDocumentDamage, MatchSelectorsDocumentDamage, MatchSelectorsDocumentDamage);
- assert_add(MatchSelectorsDocumentDamage, ReflowDocumentDamage, MatchSelectorsDocumentDamage);
- assert_add(ReflowDocumentDamage, ContentChangedDocumentDamage, ContentChangedDocumentDamage);
- assert_add(ContentChangedDocumentDamage, ReflowDocumentDamage, ContentChangedDocumentDamage);
- assert_add(MatchSelectorsDocumentDamage, ContentChangedDocumentDamage, ContentChangedDocumentDamage);
- assert_add(ContentChangedDocumentDamage, MatchSelectorsDocumentDamage, ContentChangedDocumentDamage);
-}