mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
layout: Minor stylistic cleanup.
This commit is contained in:
parent
acd08c67c6
commit
82fcbf7870
4 changed files with 74 additions and 43 deletions
|
@ -230,7 +230,7 @@ impl BSizeConstraintSolution {
|
||||||
/// Constraint equation:
|
/// Constraint equation:
|
||||||
/// block-start + block-end + block-size + margin-block-start + margin-block-end
|
/// block-start + block-end + block-size + margin-block-start + margin-block-end
|
||||||
/// = absolute containing block block-size - (vertical padding and border)
|
/// = absolute containing block block-size - (vertical padding and border)
|
||||||
/// [aka available_block-size]
|
/// [aka available block-size]
|
||||||
///
|
///
|
||||||
/// Return the solution for the equation.
|
/// Return the solution for the equation.
|
||||||
fn solve_vertical_constraints_abs_replaced(block_size: Au,
|
fn solve_vertical_constraints_abs_replaced(block_size: Au,
|
||||||
|
@ -564,7 +564,9 @@ impl BlockFlow {
|
||||||
pub fn from_node_and_fragment(node: &ThreadSafeLayoutNode, fragment: Fragment) -> BlockFlow {
|
pub fn from_node_and_fragment(node: &ThreadSafeLayoutNode, fragment: Fragment) -> BlockFlow {
|
||||||
let writing_mode = node.style().writing_mode;
|
let writing_mode = node.style().writing_mode;
|
||||||
BlockFlow {
|
BlockFlow {
|
||||||
base: BaseFlow::new(Some((*node).clone()), writing_mode, ForceNonfloatedFlag::ForceNonfloated),
|
base: BaseFlow::new(Some((*node).clone()),
|
||||||
|
writing_mode,
|
||||||
|
ForceNonfloatedFlag::ForceNonfloated),
|
||||||
fragment: fragment,
|
fragment: fragment,
|
||||||
inline_size_of_preceding_left_floats: Au(0),
|
inline_size_of_preceding_left_floats: Au(0),
|
||||||
inline_size_of_preceding_right_floats: Au(0),
|
inline_size_of_preceding_right_floats: Au(0),
|
||||||
|
@ -579,7 +581,9 @@ impl BlockFlow {
|
||||||
-> BlockFlow {
|
-> BlockFlow {
|
||||||
let writing_mode = node.style().writing_mode;
|
let writing_mode = node.style().writing_mode;
|
||||||
BlockFlow {
|
BlockFlow {
|
||||||
base: BaseFlow::new(Some((*node).clone()), writing_mode, ForceNonfloatedFlag::FloatIfNecessary),
|
base: BaseFlow::new(Some((*node).clone()),
|
||||||
|
writing_mode,
|
||||||
|
ForceNonfloatedFlag::FloatIfNecessary),
|
||||||
fragment: fragment,
|
fragment: fragment,
|
||||||
inline_size_of_preceding_left_floats: Au(0),
|
inline_size_of_preceding_left_floats: Au(0),
|
||||||
inline_size_of_preceding_right_floats: Au(0),
|
inline_size_of_preceding_right_floats: Au(0),
|
||||||
|
@ -616,33 +620,45 @@ impl BlockFlow {
|
||||||
|
|
||||||
/// Compute the actual inline size and position for this block.
|
/// Compute the actual inline size and position for this block.
|
||||||
pub fn compute_used_inline_size(&mut self,
|
pub fn compute_used_inline_size(&mut self,
|
||||||
ctx: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
containing_block_inline_size: Au) {
|
containing_block_inline_size: Au) {
|
||||||
let block_type = self.block_type();
|
let block_type = self.block_type();
|
||||||
match block_type {
|
match block_type {
|
||||||
BlockType::AbsoluteReplaced => {
|
BlockType::AbsoluteReplaced => {
|
||||||
let inline_size_computer = AbsoluteReplaced;
|
let inline_size_computer = AbsoluteReplaced;
|
||||||
inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size);
|
inline_size_computer.compute_used_inline_size(self,
|
||||||
|
layout_context,
|
||||||
|
containing_block_inline_size);
|
||||||
}
|
}
|
||||||
BlockType::AbsoluteNonReplaced => {
|
BlockType::AbsoluteNonReplaced => {
|
||||||
let inline_size_computer = AbsoluteNonReplaced;
|
let inline_size_computer = AbsoluteNonReplaced;
|
||||||
inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size);
|
inline_size_computer.compute_used_inline_size(self,
|
||||||
|
layout_context,
|
||||||
|
containing_block_inline_size);
|
||||||
}
|
}
|
||||||
BlockType::FloatReplaced => {
|
BlockType::FloatReplaced => {
|
||||||
let inline_size_computer = FloatReplaced;
|
let inline_size_computer = FloatReplaced;
|
||||||
inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size);
|
inline_size_computer.compute_used_inline_size(self,
|
||||||
|
layout_context,
|
||||||
|
containing_block_inline_size);
|
||||||
}
|
}
|
||||||
BlockType::FloatNonReplaced => {
|
BlockType::FloatNonReplaced => {
|
||||||
let inline_size_computer = FloatNonReplaced;
|
let inline_size_computer = FloatNonReplaced;
|
||||||
inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size);
|
inline_size_computer.compute_used_inline_size(self,
|
||||||
|
layout_context,
|
||||||
|
containing_block_inline_size);
|
||||||
}
|
}
|
||||||
BlockType::Replaced => {
|
BlockType::Replaced => {
|
||||||
let inline_size_computer = BlockReplaced;
|
let inline_size_computer = BlockReplaced;
|
||||||
inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size);
|
inline_size_computer.compute_used_inline_size(self,
|
||||||
|
layout_context,
|
||||||
|
containing_block_inline_size);
|
||||||
}
|
}
|
||||||
BlockType::NonReplaced => {
|
BlockType::NonReplaced => {
|
||||||
let inline_size_computer = BlockNonReplaced;
|
let inline_size_computer = BlockNonReplaced;
|
||||||
inline_size_computer.compute_used_inline_size(self, ctx, containing_block_inline_size);
|
inline_size_computer.compute_used_inline_size(self,
|
||||||
|
layout_context,
|
||||||
|
containing_block_inline_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -675,8 +691,8 @@ impl BlockFlow {
|
||||||
/// their direct absolute descendants.
|
/// their direct absolute descendants.
|
||||||
///
|
///
|
||||||
/// Return true if the traversal is to continue or false to stop.
|
/// Return true if the traversal is to continue or false to stop.
|
||||||
fn traverse_preorder_absolute_flows<T:PreorderFlowTraversal>(&mut self,
|
fn traverse_preorder_absolute_flows<T>(&mut self, traversal: &mut T)
|
||||||
traversal: &mut T) {
|
where T: PreorderFlowTraversal {
|
||||||
let flow = self as &mut Flow;
|
let flow = self as &mut Flow;
|
||||||
|
|
||||||
traversal.process(flow);
|
traversal.process(flow);
|
||||||
|
@ -690,8 +706,8 @@ impl BlockFlow {
|
||||||
/// Traverse the Absolute flow tree in postorder.
|
/// Traverse the Absolute flow tree in postorder.
|
||||||
///
|
///
|
||||||
/// Return true if the traversal is to continue or false to stop.
|
/// Return true if the traversal is to continue or false to stop.
|
||||||
fn traverse_postorder_absolute_flows<T:PostorderFlowTraversal>(&mut self,
|
fn traverse_postorder_absolute_flows<T>(&mut self, traversal: &mut T)
|
||||||
traversal: &mut T) {
|
where T: PostorderFlowTraversal {
|
||||||
let flow = self as &mut Flow;
|
let flow = self as &mut Flow;
|
||||||
|
|
||||||
for descendant_link in mut_base(flow).abs_descendants.iter() {
|
for descendant_link in mut_base(flow).abs_descendants.iter() {
|
||||||
|
@ -1478,7 +1494,8 @@ impl Flow for BlockFlow {
|
||||||
let mut left_float_width = Au(0);
|
let mut left_float_width = Au(0);
|
||||||
let mut right_float_width = Au(0);
|
let mut right_float_width = Au(0);
|
||||||
for kid in self.base.child_iter() {
|
for kid in self.base.child_iter() {
|
||||||
let is_absolutely_positioned = flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED);
|
let is_absolutely_positioned =
|
||||||
|
flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED);
|
||||||
let child_base = flow::mut_base(kid);
|
let child_base = flow::mut_base(kid);
|
||||||
let float_kind = child_base.flags.float_kind();
|
let float_kind = child_base.flags.float_kind();
|
||||||
if !is_absolutely_positioned && !fixed_width {
|
if !is_absolutely_positioned && !fixed_width {
|
||||||
|
@ -2112,8 +2129,10 @@ pub trait ISizeAndMarginsComputer {
|
||||||
flow::mut_base(block).position.size.inline = inline_size + extra_inline_size_from_margin;
|
flow::mut_base(block).position.size.inline = inline_size + extra_inline_size_from_margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the x coordinate of the given flow if it is absolutely positioned.
|
/// Set the inline coordinate of the given flow if it is absolutely positioned.
|
||||||
fn set_flow_x_coord_if_necessary(&self, _: &mut BlockFlow, _: ISizeConstraintSolution) {}
|
fn set_inline_position_of_flow_if_necessary(&self,
|
||||||
|
_: &mut BlockFlow,
|
||||||
|
_: ISizeConstraintSolution) {}
|
||||||
|
|
||||||
/// Solve the inline-size and margins constraints for this block flow.
|
/// Solve the inline-size and margins constraints for this block flow.
|
||||||
fn solve_inline_size_constraints(&self,
|
fn solve_inline_size_constraints(&self,
|
||||||
|
@ -2179,7 +2198,7 @@ pub trait ISizeAndMarginsComputer {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.set_inline_size_constraint_solutions(block, solution);
|
self.set_inline_size_constraint_solutions(block, solution);
|
||||||
self.set_flow_x_coord_if_necessary(block, solution);
|
self.set_inline_position_of_flow_if_necessary(block, solution);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes inline-start and inline-end margins and inline-size.
|
/// Computes inline-start and inline-end margins and inline-size.
|
||||||
|
@ -2291,7 +2310,7 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced {
|
||||||
/// Constraint equation:
|
/// Constraint equation:
|
||||||
/// inline-start + inline-end + inline-size + margin-inline-start + margin-inline-end
|
/// inline-start + inline-end + inline-size + margin-inline-start + margin-inline-end
|
||||||
/// = absolute containing block inline-size - (horizontal padding and border)
|
/// = absolute containing block inline-size - (horizontal padding and border)
|
||||||
/// [aka available_inline-size]
|
/// [aka available inline-size]
|
||||||
///
|
///
|
||||||
/// Return the solution for the equation.
|
/// Return the solution for the equation.
|
||||||
fn solve_inline_size_constraints(&self,
|
fn solve_inline_size_constraints(&self,
|
||||||
|
@ -2440,11 +2459,15 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced {
|
||||||
margin_inline_end)
|
margin_inline_end)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn containing_block_inline_size(&self, block: &mut BlockFlow, _: Au, ctx: &LayoutContext) -> Au {
|
fn containing_block_inline_size(&self,
|
||||||
block.containing_block_size(ctx.shared.screen_size).inline
|
block: &mut BlockFlow,
|
||||||
|
_: Au,
|
||||||
|
layout_context: &LayoutContext)
|
||||||
|
-> Au {
|
||||||
|
block.containing_block_size(layout_context.shared.screen_size).inline
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_flow_x_coord_if_necessary(&self,
|
fn set_inline_position_of_flow_if_necessary(&self,
|
||||||
block: &mut BlockFlow,
|
block: &mut BlockFlow,
|
||||||
solution: ISizeConstraintSolution) {
|
solution: ISizeConstraintSolution) {
|
||||||
// Set the inline position of the absolute flow wrt to its containing block.
|
// Set the inline position of the absolute flow wrt to its containing block.
|
||||||
|
@ -2565,7 +2588,7 @@ impl ISizeAndMarginsComputer for AbsoluteReplaced {
|
||||||
block.containing_block_size(ctx.shared.screen_size).inline
|
block.containing_block_size(ctx.shared.screen_size).inline
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_flow_x_coord_if_necessary(&self,
|
fn set_inline_position_of_flow_if_necessary(&self,
|
||||||
block: &mut BlockFlow,
|
block: &mut BlockFlow,
|
||||||
solution: ISizeConstraintSolution) {
|
solution: ISizeConstraintSolution) {
|
||||||
// Set the x-coordinate of the absolute flow wrt to its containing block.
|
// Set the x-coordinate of the absolute flow wrt to its containing block.
|
||||||
|
@ -2622,13 +2645,15 @@ impl ISizeAndMarginsComputer for FloatNonReplaced {
|
||||||
block: &mut BlockFlow,
|
block: &mut BlockFlow,
|
||||||
input: &ISizeConstraintInput)
|
input: &ISizeConstraintInput)
|
||||||
-> ISizeConstraintSolution {
|
-> ISizeConstraintSolution {
|
||||||
let (computed_inline_size, inline_start_margin, inline_end_margin, available_inline_size) = (input.computed_inline_size,
|
let (computed_inline_size, inline_start_margin, inline_end_margin, available_inline_size) =
|
||||||
|
(input.computed_inline_size,
|
||||||
input.inline_start_margin,
|
input.inline_start_margin,
|
||||||
input.inline_end_margin,
|
input.inline_end_margin,
|
||||||
input.available_inline_size);
|
input.available_inline_size);
|
||||||
let margin_inline_start = inline_start_margin.specified_or_zero();
|
let margin_inline_start = inline_start_margin.specified_or_zero();
|
||||||
let margin_inline_end = inline_end_margin.specified_or_zero();
|
let margin_inline_end = inline_end_margin.specified_or_zero();
|
||||||
let available_inline_size_float = available_inline_size - margin_inline_start - margin_inline_end;
|
let available_inline_size_float = available_inline_size - margin_inline_start -
|
||||||
|
margin_inline_end;
|
||||||
let shrink_to_fit = block.get_shrink_to_fit_inline_size(available_inline_size_float);
|
let shrink_to_fit = block.get_shrink_to_fit_inline_size(available_inline_size_float);
|
||||||
let inline_size = computed_inline_size.specified_or_default(shrink_to_fit);
|
let inline_size = computed_inline_size.specified_or_default(shrink_to_fit);
|
||||||
debug!("assign_inline_sizes_float -- inline_size: {:?}", inline_size);
|
debug!("assign_inline_sizes_float -- inline_size: {:?}", inline_size);
|
||||||
|
@ -2642,9 +2667,8 @@ impl ISizeAndMarginsComputer for FloatReplaced {
|
||||||
/// If inline-size is computed as 'auto', the used value is the 'shrink-to-fit' inline-size.
|
/// If inline-size is computed as 'auto', the used value is the 'shrink-to-fit' inline-size.
|
||||||
fn solve_inline_size_constraints(&self, _: &mut BlockFlow, input: &ISizeConstraintInput)
|
fn solve_inline_size_constraints(&self, _: &mut BlockFlow, input: &ISizeConstraintInput)
|
||||||
-> ISizeConstraintSolution {
|
-> ISizeConstraintSolution {
|
||||||
let (computed_inline_size, inline_start_margin, inline_end_margin) = (input.computed_inline_size,
|
let (computed_inline_size, inline_start_margin, inline_end_margin) =
|
||||||
input.inline_start_margin,
|
(input.computed_inline_size, input.inline_start_margin, input.inline_end_margin);
|
||||||
input.inline_end_margin);
|
|
||||||
let margin_inline_start = inline_start_margin.specified_or_zero();
|
let margin_inline_start = inline_start_margin.specified_or_zero();
|
||||||
let margin_inline_end = inline_end_margin.specified_or_zero();
|
let margin_inline_end = inline_end_margin.specified_or_zero();
|
||||||
let inline_size = match computed_inline_size {
|
let inline_size = match computed_inline_size {
|
||||||
|
|
|
@ -1226,7 +1226,8 @@ impl Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// TODO: What exactly does this function return? Why is it Au(0) for SpecificFragmentInfo::Generic?
|
/// TODO: What exactly does this function return? Why is it Au(0) for
|
||||||
|
/// SpecificFragmentInfo::Generic?
|
||||||
pub fn content_inline_size(&self) -> Au {
|
pub fn content_inline_size(&self) -> Au {
|
||||||
match self.specific {
|
match self.specific {
|
||||||
SpecificFragmentInfo::Generic |
|
SpecificFragmentInfo::Generic |
|
||||||
|
|
|
@ -211,12 +211,14 @@ impl TableWrapperFlow {
|
||||||
let solution = FloatNonReplaced.solve_inline_size_constraints(&mut self.block_flow,
|
let solution = FloatNonReplaced.solve_inline_size_constraints(&mut self.block_flow,
|
||||||
&input);
|
&input);
|
||||||
FloatNonReplaced.set_inline_size_constraint_solutions(&mut self.block_flow, solution);
|
FloatNonReplaced.set_inline_size_constraint_solutions(&mut self.block_flow, solution);
|
||||||
FloatNonReplaced.set_flow_x_coord_if_necessary(&mut self.block_flow, solution);
|
FloatNonReplaced.set_inline_position_of_flow_if_necessary(&mut self.block_flow,
|
||||||
|
solution);
|
||||||
} else {
|
} else {
|
||||||
let solution = BlockNonReplaced.solve_inline_size_constraints(&mut self.block_flow,
|
let solution = BlockNonReplaced.solve_inline_size_constraints(&mut self.block_flow,
|
||||||
&input);
|
&input);
|
||||||
BlockNonReplaced.set_inline_size_constraint_solutions(&mut self.block_flow, solution);
|
BlockNonReplaced.set_inline_size_constraint_solutions(&mut self.block_flow, solution);
|
||||||
BlockNonReplaced.set_flow_x_coord_if_necessary(&mut self.block_flow, solution);
|
BlockNonReplaced.set_inline_position_of_flow_if_necessary(&mut self.block_flow,
|
||||||
|
solution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4704,7 +4704,11 @@ impl ComputedValues {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn content_inline_size(&self) -> computed::LengthOrPercentageOrAuto {
|
pub fn content_inline_size(&self) -> computed::LengthOrPercentageOrAuto {
|
||||||
let box_style = self.get_box();
|
let box_style = self.get_box();
|
||||||
if self.writing_mode.is_vertical() { box_style.height } else { box_style.width }
|
if self.writing_mode.is_vertical() {
|
||||||
|
box_style.height
|
||||||
|
} else {
|
||||||
|
box_style.width
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue