diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2015-12-17 16:21:29 -0800 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2015-12-29 11:50:03 -0800 |
commit | 47059d2d26f14f71e5b7212fa8bc01608eca11b5 (patch) | |
tree | d0693fb9987a7113323c7d6fb5502cb5621d8f15 /components/layout/construct.rs | |
parent | 89ab368258eb827b0dcc8d6e6deecd3ed3c1de71 (diff) | |
download | servo-47059d2d26f14f71e5b7212fa8bc01608eca11b5.tar.gz servo-47059d2d26f14f71e5b7212fa8bc01608eca11b5.zip |
Separate style+layout and layout-specific wrapper functionality.
This patch does a number of things, unfortunately all at once:
* Hoists a large subset of the layout wrapper functionality into the style system.
* Merges TElementAttributes into the newly-created TElement.
* Reorganizes LayoutData by style vs layout, and removes LayoutDataShared.
* Simplifies the API for borrowing style/layout data.
There's still more to do to make the style system usable standalone, but
this is a good start.
Diffstat (limited to 'components/layout/construct.rs')
-rw-r--r-- | components/layout/construct.rs | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 49cc3567d57..6e6ea30332c 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -15,7 +15,7 @@ use block::BlockFlow; use context::LayoutContext; -use data::{HAS_NEWLY_CONSTRUCTED_FLOW, LayoutDataWrapper}; +use data::{HAS_NEWLY_CONSTRUCTED_FLOW, PrivateLayoutData}; use flex::FlexFlow; use floats::FloatKind; use flow::{MutableFlowUtils, MutableOwnedFlowUtils}; @@ -58,7 +58,7 @@ use traversal::PostorderNodeMutTraversal; use url::Url; use util::linked_list; use util::opts; -use wrapper::{PseudoElementType, TextContent, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; +use wrapper::{LayoutNode, PseudoElementType, TextContent, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; /// The results of flow construction for a DOM node. #[derive(Clone)] @@ -1326,10 +1326,9 @@ impl<'a, 'ln, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'ln>> let mut style = node.style().clone(); - let mut layout_data_ref = node.mutate_layout_data(); - let layout_data = layout_data_ref.as_mut().expect("no layout data"); - let damage = layout_data.data.restyle_damage; - match *node.construction_result_mut(layout_data) { + let mut data = node.mutate_layout_data().unwrap(); + let damage = data.restyle_damage; + match *node.construction_result_mut(&mut *data) { ConstructionResult::None => true, ConstructionResult::Flow(ref mut flow, _) => { // The node's flow is of the same type and has the same set of children and can @@ -1580,7 +1579,7 @@ trait NodeUtils { /// Returns true if this node doesn't render its kids and false otherwise. fn is_replaced_content(&self) -> bool; - fn construction_result_mut(self, layout_data: &mut LayoutDataWrapper) -> &mut ConstructionResult; + fn construction_result_mut(self, layout_data: &mut PrivateLayoutData) -> &mut ConstructionResult; /// Sets the construction result of a flow. fn set_flow_construction_result(self, result: ConstructionResult); @@ -1611,30 +1610,26 @@ impl<'ln, ConcreteThreadSafeLayoutNode> NodeUtils for ConcreteThreadSafeLayoutNo } } - fn construction_result_mut(self, layout_data: &mut LayoutDataWrapper) -> &mut ConstructionResult { + fn construction_result_mut(self, data: &mut PrivateLayoutData) -> &mut ConstructionResult { match self.get_pseudo_element_type() { - PseudoElementType::Before(_) => &mut layout_data.data.before_flow_construction_result, - PseudoElementType::After (_) => &mut layout_data.data.after_flow_construction_result, - PseudoElementType::Normal => &mut layout_data.data.flow_construction_result, + PseudoElementType::Before(_) => &mut data.before_flow_construction_result, + PseudoElementType::After (_) => &mut data.after_flow_construction_result, + PseudoElementType::Normal => &mut data.flow_construction_result, } } #[inline(always)] fn set_flow_construction_result(self, result: ConstructionResult) { - let mut layout_data_ref = self.mutate_layout_data(); - let layout_data = layout_data_ref.as_mut().expect("no layout data"); - - let dst = self.construction_result_mut(layout_data); + let mut layout_data = self.mutate_layout_data().unwrap(); + let dst = self.construction_result_mut(&mut *layout_data); *dst = result; } #[inline(always)] fn swap_out_construction_result(self) -> ConstructionResult { - let mut layout_data_ref = self.mutate_layout_data(); - let layout_data = layout_data_ref.as_mut().expect("no layout data"); - - self.construction_result_mut(layout_data).swap_out() + let mut layout_data = self.mutate_layout_data().unwrap(); + self.construction_result_mut(&mut *layout_data).swap_out() } } |