diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2013-11-09 21:39:39 -0800 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2013-11-18 11:24:11 -0800 |
commit | 155befe10dc56cfb2dfbf0cca7b652293dba9753 (patch) | |
tree | 43c3e51689cd42a3fb623eda84740f49dd667f5e /src/components/main/css/node_util.rs | |
parent | 37f9427b6c53b90234e82d219217a97c10811243 (diff) | |
download | servo-155befe10dc56cfb2dfbf0cca7b652293dba9753.tar.gz servo-155befe10dc56cfb2dfbf0cca7b652293dba9753.zip |
Rewrite flow construction to be incrementalizable and parallelizable.
This replaces flow construction with a strict bottom-up tree traversal,
allowing for parallelism. Each step of the traversal creates a flow or
a `ConstructionItem`, similar to how Gecko works. {ib} splits are
handled by not creating `InlineFlow`s until the containing block is
reached.
This should be able to be incrementalized by storing the `Flow` from
layout to layout, and performing fixups during flow construction
and/or wiping containing blocks in a previous pass.
Diffstat (limited to 'src/components/main/css/node_util.rs')
-rw-r--r-- | src/components/main/css/node_util.rs | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/components/main/css/node_util.rs b/src/components/main/css/node_util.rs index 104174b7b8c..5ca43c69243 100644 --- a/src/components/main/css/node_util.rs +++ b/src/components/main/css/node_util.rs @@ -27,22 +27,29 @@ impl<'self> NodeUtil<'self> for AbstractNode<LayoutView> { * FIXME: This isn't completely memory safe since the style is * stored in a box that can be overwritten */ + #[inline] fn get_css_select_results(self) -> &'self ComputedValues { - let layout_data = self.layout_data(); - match *layout_data.style.borrow().ptr { - None => fail!(~"style() called on node without a style!"), - Some(ref style) => unsafe { cast::transmute_region(style) } + unsafe { + cast::transmute_region(self.borrow_layout_data_unchecked() + .as_ref() + .unwrap() + .style + .as_ref() + .unwrap()) } } /// Does this node have a computed style yet? fn have_css_select_results(self) -> bool { - self.layout_data().style.borrow().ptr.is_some() + self.borrow_layout_data().ptr.as_ref().unwrap().style.is_some() } /// Update the computed style of an HTML element with a style specified by CSS. fn set_css_select_results(self, decl: ComputedValues) { - *self.layout_data().style.mutate().ptr = Some(decl) + match *self.mutate_layout_data().ptr { + Some(ref mut data) => data.style = Some(decl), + _ => fail!("no layout data for this node"), + } } /// Get the description of how to account for recent style changes. @@ -56,17 +63,21 @@ impl<'self> NodeUtil<'self> for AbstractNode<LayoutView> { RestyleDamage::none() }; - self.layout_data() - .restyle_damage - .borrow() + self.borrow_layout_data() .ptr + .as_ref() + .unwrap() + .restyle_damage .map(|x| RestyleDamage::from_int(x)) .unwrap_or(default) } /// Set the restyle damage field. fn set_restyle_damage(self, damage: RestyleDamage) { - *self.layout_data().restyle_damage.mutate().ptr = Some(damage.to_int()) + match *self.mutate_layout_data().ptr { + Some(ref mut data) => data.restyle_damage = Some(damage.to_int()), + _ => fail!("no layout data for this node"), + } } } |