mirror of
https://github.com/servo/servo.git
synced 2025-06-23 00:24:35 +01:00
Move special cases of CSS 'display' the property to computed value, per spec.
This commit is contained in:
parent
90431a1907
commit
5c59699e4c
2 changed files with 49 additions and 36 deletions
|
@ -379,38 +379,21 @@ impl LayoutTreeBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub fn box_generator_for_node<'a>(&mut self,
|
pub fn box_generator_for_node<'a>(&mut self,
|
||||||
node: AbstractNode<LayoutView>,
|
node: AbstractNode<LayoutView>,
|
||||||
grandparent_generator: Option<&mut BoxGenerator<'a>>,
|
grandparent_generator: Option<&mut BoxGenerator<'a>>,
|
||||||
parent_generator: &mut BoxGenerator<'a>,
|
parent_generator: &mut BoxGenerator<'a>,
|
||||||
mut sibling_generator: Option<&mut BoxGenerator<'a>>)
|
mut sibling_generator: Option<&mut BoxGenerator<'a>>)
|
||||||
-> BoxGenResult<'a> {
|
-> BoxGenResult<'a> {
|
||||||
let display = if node.is_element() {
|
let display = match node.type_id() {
|
||||||
let display = node.style().Box.display;
|
ElementNodeTypeId(_) => match node.style().Box.display {
|
||||||
if node.is_root() {
|
|
||||||
match display {
|
|
||||||
display::none => return NoGenerator,
|
display::none => return NoGenerator,
|
||||||
display::inline => display::block,
|
display => display,
|
||||||
display::list_item => display::block,
|
},
|
||||||
v => v
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
match display {
|
|
||||||
display::none => return NoGenerator,
|
|
||||||
display::list_item => display::block,
|
|
||||||
v => v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
match node.type_id() {
|
|
||||||
ElementNodeTypeId(_) => display::inline,
|
|
||||||
TextNodeTypeId => display::inline,
|
TextNodeTypeId => display::inline,
|
||||||
DoctypeNodeTypeId |
|
DoctypeNodeTypeId |
|
||||||
DocumentFragmentNodeTypeId |
|
DocumentFragmentNodeTypeId |
|
||||||
CommentNodeTypeId => return NoGenerator,
|
CommentNodeTypeId => return NoGenerator,
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME(pcwalton): Unsafe.
|
// FIXME(pcwalton): Unsafe.
|
||||||
|
|
|
@ -101,10 +101,9 @@ pub mod longhands {
|
||||||
</%self:longhand>
|
</%self:longhand>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="single_keyword(name, values, inherited=False)">
|
<%def name="single_keyword_computed(name, values, inherited=False)">
|
||||||
<%self:single_component_value name="${name}" inherited="${inherited}">
|
<%self:single_component_value name="${name}" inherited="${inherited}">
|
||||||
// The computed value is the same as the specified value.
|
${caller.body()}
|
||||||
pub use to_computed_value = super::computed_as_specified;
|
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
#[deriving(Eq, Clone)]
|
#[deriving(Eq, Clone)]
|
||||||
pub enum T {
|
pub enum T {
|
||||||
|
@ -130,6 +129,13 @@ pub mod longhands {
|
||||||
</%self:single_component_value>
|
</%self:single_component_value>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
<%def name="single_keyword(name, values, inherited=False)">
|
||||||
|
<%self:single_keyword_computed name="${name}" values="${values}" inherited="${inherited}">
|
||||||
|
// The computed value is the same as the specified value.
|
||||||
|
pub use to_computed_value = super::computed_as_specified;
|
||||||
|
</%self:single_keyword_computed>
|
||||||
|
</%def>
|
||||||
|
|
||||||
<%def name="predefined_type(name, type, initial_value, parse_method='parse', inherited=False)">
|
<%def name="predefined_type(name, type, initial_value, parse_method='parse', inherited=False)">
|
||||||
<%self:single_component_value name="${name}" inherited="${inherited}">
|
<%self:single_component_value name="${name}" inherited="${inherited}">
|
||||||
pub use to_computed_value = super::super::common_types::computed::compute_${type};
|
pub use to_computed_value = super::super::common_types::computed::compute_${type};
|
||||||
|
@ -217,11 +223,35 @@ pub mod longhands {
|
||||||
${new_style_struct("Box")}
|
${new_style_struct("Box")}
|
||||||
|
|
||||||
// TODO: don't parse values we don't support
|
// TODO: don't parse values we don't support
|
||||||
${single_keyword("display",
|
<%self:single_keyword_computed name="display"
|
||||||
"inline block list-item inline-block none "
|
values="inline block inline-block none">
|
||||||
)}
|
// list-item
|
||||||
// "table inline-table table-row-group table-header-group table-footer-group "
|
// table inline-table table-row-group table-header-group table-footer-group
|
||||||
// "table-row table-column-group table-column table-cell table-caption"
|
// table-row table-column-group table-column table-cell table-caption
|
||||||
|
pub fn to_computed_value(value: SpecifiedValue, context: &computed::Context)
|
||||||
|
-> computed_value::T {
|
||||||
|
// if context.is_root_element && value == list_item {
|
||||||
|
// return block
|
||||||
|
// }
|
||||||
|
let positioned = match context.position {
|
||||||
|
position::absolute | position::fixed => true,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
if positioned || context.float != float::none || context.is_root_element {
|
||||||
|
match value {
|
||||||
|
// inline_table => table,
|
||||||
|
inline | inline_block
|
||||||
|
// | table_row_group | table_column | table_column_group
|
||||||
|
// | table_header_group | table_footer_group | table_row
|
||||||
|
// | table_cell | table_caption
|
||||||
|
=> block,
|
||||||
|
_ => value,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</%self:single_keyword_computed>
|
||||||
|
|
||||||
${single_keyword("position", "static absolute relative fixed")}
|
${single_keyword("position", "static absolute relative fixed")}
|
||||||
${single_keyword("float", "none left right")}
|
${single_keyword("float", "none left right")}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue