mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Create FlexFlow's for 'display: flex' nodes.
This commit doesn't implement any flexbox behavior at all. It just constructs FlexFlow's, which act just like the BlockFlow from which they "inherit."
This commit is contained in:
parent
45b7ee9bdb
commit
0488a36862
6 changed files with 286 additions and 1 deletions
|
@ -16,6 +16,7 @@
|
|||
use block::BlockFlow;
|
||||
use context::LayoutContext;
|
||||
use data::{HAS_NEWLY_CONSTRUCTED_FLOW, LayoutDataWrapper};
|
||||
use flex::FlexFlow;
|
||||
use floats::FloatKind;
|
||||
use flow::{MutableFlowUtils, MutableOwnedFlowUtils};
|
||||
use flow::{self, AbsoluteDescendants, Flow, ImmutableFlowUtils, IS_ABSOLUTELY_POSITIONED};
|
||||
|
@ -1277,6 +1278,14 @@ impl<'a> FlowConstructor<'a> {
|
|||
ConstructionResult::Flow(flow, AbsoluteDescendants::new())
|
||||
}
|
||||
|
||||
/// Builds a flow for a node with 'display: flex'.
|
||||
fn build_flow_for_flex(&mut self, node: &ThreadSafeLayoutNode, float_kind: Option<FloatKind>)
|
||||
-> ConstructionResult {
|
||||
let fragment = self.build_fragment_for_block(node);
|
||||
let flow = Box::new(FlexFlow::from_fragment(fragment, float_kind));
|
||||
self.build_flow_for_block_like(FlowRef::new(flow), node)
|
||||
}
|
||||
|
||||
/// Attempts to perform incremental repair to account for recent changes to this node. This
|
||||
/// can fail and return false, indicating that flows will need to be reconstructed.
|
||||
///
|
||||
|
@ -1518,6 +1527,13 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
|
|||
self.set_flow_construction_result(node, construction_result)
|
||||
}
|
||||
|
||||
// Flex items contribute flex flow construction results.
|
||||
(display::T::flex, float_value, _) => {
|
||||
let float_kind = FloatKind::from_property(float_value);
|
||||
let construction_result = self.build_flow_for_flex(node, float_kind);
|
||||
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`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue