Implemented display: inline-flex

This commit is contained in:
Shing Lyu 2017-01-03 11:37:29 +08:00 committed by Shing Lyu
parent 987b640c54
commit e31ee04dad
9 changed files with 28 additions and 26 deletions

View file

@ -937,9 +937,14 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
ConstructionResult::ConstructionItem(construction_item)
}
fn build_fragment_for_inline_block(&mut self, node: &ConcreteThreadSafeLayoutNode)
-> ConstructionResult {
let block_flow_result = self.build_flow_for_block(node, None);
/// Build the fragment for an inline-block or inline-flex, based on the `display` flag
fn build_fragment_for_inline_block_or_inline_flex(&mut self, node: &ConcreteThreadSafeLayoutNode,
display: display::T) -> ConstructionResult {
let block_flow_result = match display {
display::T::inline_block => self.build_flow_for_block(node, None),
display::T::inline_flex => self.build_flow_for_flex(node, None),
_ => panic!("The flag should be inline-block or inline-flex")
};
let (block_flow, abs_descendants) = match block_flow_result {
ConstructionResult::Flow(block_flow, abs_descendants) => (block_flow, abs_descendants),
_ => unreachable!()
@ -1548,7 +1553,8 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
// Inline-block items contribute inline fragment construction results.
(display::T::inline_block, float::T::none, _) => {
let construction_result = self.build_fragment_for_inline_block(node);
let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node,
display::T::inline_block);
self.set_flow_construction_result(node, construction_result)
}
@ -1597,6 +1603,12 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
self.set_flow_construction_result(node, construction_result)
}
(display::T::inline_flex, _, _) => {
let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node,
display::T::inline_flex);
self.set_flow_construction_result(node, construction_result)
}
// Block flows that are not floated contribute block flow construction results.
//
// TODO(pcwalton): Make this only trigger for blocks and handle the other `display`