diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2015-11-20 09:51:05 -0800 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2015-11-28 18:01:02 -0800 |
commit | cf33f00018c7dc44a09086d6bb68b253153635ae (patch) | |
tree | efa655a0967756601963042f0b321e18ed37ed02 /components/layout/fragment.rs | |
parent | 77a80919967446639141321ba83b3b0b6d1d1665 (diff) | |
download | servo-cf33f00018c7dc44a09086d6bb68b253153635ae.tar.gz servo-cf33f00018c7dc44a09086d6bb68b253153635ae.zip |
Generalize the rest of layout to operate on generic Layout*.
There wasn't a good way to split this up, unfortunately.
With this change, the only remaining usage of the Servo-specific structures is
in layout_task, where the root node is received from the script task. \o/
Diffstat (limited to 'components/layout/fragment.rs')
-rw-r--r-- | components/layout/fragment.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 06167c3b59b..5eae8be6891 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -50,7 +50,7 @@ use util::geometry::ZERO_POINT; use util::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use util::range::*; use util::str::slice_chars; -use wrapper::{PseudoElementType, ServoThreadSafeLayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; +use wrapper::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode}; /// Fragments (`struct Fragment`) are the leaves of the layout tree. They cannot position /// themselves. In general, fragments do not have a simple correspondence with CSS fragments in the @@ -309,7 +309,7 @@ pub struct CanvasFragmentInfo { } impl CanvasFragmentInfo { - pub fn new(node: &ServoThreadSafeLayoutNode, data: HTMLCanvasData) -> CanvasFragmentInfo { + pub fn new<'ln, N: ThreadSafeLayoutNode<'ln>>(node: &N, data: HTMLCanvasData) -> CanvasFragmentInfo { CanvasFragmentInfo { replaced_image_fragment_info: ReplacedImageFragmentInfo::new(node, Some(Au::from_px(data.width as i32)), @@ -345,11 +345,10 @@ impl ImageFragmentInfo { /// /// FIXME(pcwalton): The fact that image fragments store the cache in the fragment makes little /// sense to me. - pub fn new(node: &ServoThreadSafeLayoutNode, - url: Option<Url>, - layout_context: &LayoutContext) - -> ImageFragmentInfo { - fn convert_length(node: &ServoThreadSafeLayoutNode, name: &Atom) -> Option<Au> { + pub fn new<'ln, N: ThreadSafeLayoutNode<'ln>>(node: &N, url: Option<Url>, + layout_context: &LayoutContext) -> ImageFragmentInfo { + fn convert_length<'ln, N>(node: &N, name: &Atom) -> Option<Au> + where N: ThreadSafeLayoutNode<'ln> { let element = node.as_element(); element.get_attr(&ns!(), name) .and_then(|string| string.parse().ok()) @@ -423,9 +422,10 @@ pub struct ReplacedImageFragmentInfo { } impl ReplacedImageFragmentInfo { - pub fn new(node: &ServoThreadSafeLayoutNode, - dom_width: Option<Au>, - dom_height: Option<Au>) -> ReplacedImageFragmentInfo { + pub fn new<'ln, N>(node: &N, + dom_width: Option<Au>, + dom_height: Option<Au>) -> ReplacedImageFragmentInfo + where N: ThreadSafeLayoutNode<'ln> { let is_vertical = node.style().writing_mode.is_vertical(); ReplacedImageFragmentInfo { computed_inline_size: None, @@ -583,7 +583,7 @@ pub struct IframeFragmentInfo { impl IframeFragmentInfo { /// Creates the information specific to an iframe fragment. - pub fn new(node: &ServoThreadSafeLayoutNode) -> IframeFragmentInfo { + pub fn new<'ln, N: ThreadSafeLayoutNode<'ln>>(node: &N) -> IframeFragmentInfo { let pipeline_id = node.iframe_pipeline_id(); IframeFragmentInfo { pipeline_id: pipeline_id, @@ -758,7 +758,7 @@ pub struct TableColumnFragmentInfo { impl TableColumnFragmentInfo { /// Create the information specific to an table column fragment. - pub fn new(node: &ServoThreadSafeLayoutNode) -> TableColumnFragmentInfo { + pub fn new<'ln, N: ThreadSafeLayoutNode<'ln>>(node: &N) -> TableColumnFragmentInfo { let element = node.as_element(); let span = element.get_attr(&ns!(), &atom!("span")) .and_then(|string| string.parse().ok()) @@ -771,7 +771,7 @@ impl TableColumnFragmentInfo { impl Fragment { /// Constructs a new `Fragment` instance. - pub fn new(node: &ServoThreadSafeLayoutNode, specific: SpecificFragmentInfo) -> Fragment { + pub fn new<'ln, N: ThreadSafeLayoutNode<'ln>>(node: &N, specific: SpecificFragmentInfo) -> Fragment { let style = node.style().clone(); let writing_mode = style.writing_mode; |