mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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/
This commit is contained in:
parent
77a8091996
commit
cf33f00018
10 changed files with 198 additions and 156 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue