Struct layout_2013::block::BlockFlow
source · #[repr(C)]pub struct BlockFlow {
pub base: BaseFlow,
pub fragment: Fragment,
pub float: Option<Box<FloatedBlockInfo>>,
flags: BlockFlowFlags,
}
Fields§
§base: BaseFlow
Data common to all flows.
fragment: Fragment
The associated fragment.
float: Option<Box<FloatedBlockInfo>>
Additional floating flow members.
flags: BlockFlowFlags
Various flags.
Implementations§
source§impl BlockFlow
impl BlockFlow
pub fn from_fragment(fragment: Fragment) -> BlockFlow
pub fn from_fragment_and_float_kind( fragment: Fragment, float_kind: Option<FloatKind>, ) -> BlockFlow
sourcepub fn block_type(&self) -> BlockType
pub fn block_type(&self) -> BlockType
Return the type of this block.
This determines the algorithm used to calculate inline-size, block-size, and the relevant margins for this Block.
sourcepub fn compute_used_inline_size(
&mut self,
shared_context: &SharedStyleContext<'_>,
containing_block_inline_size: Au,
)
pub fn compute_used_inline_size( &mut self, shared_context: &SharedStyleContext<'_>, containing_block_inline_size: Au, )
Compute the actual inline size and position for this block.
pub fn stacking_relative_border_box(&self, coor: CoordinateSystem) -> Rect<Au>
sourcepub fn containing_block_size(
&self,
viewport_size: &Size2D<Au>,
descendant: OpaqueFlow,
) -> LogicalSize<Au>
pub fn containing_block_size( &self, viewport_size: &Size2D<Au>, descendant: OpaqueFlow, ) -> LogicalSize<Au>
Return the size of the containing block for the given immediate absolute descendant of this flow.
Right now, this only gets the containing block size for absolutely positioned elements. Note: We assume this is called in a top-down traversal, so it is ok to reference the CB.
sourcepub fn get_shrink_to_fit_inline_size(&self, available_inline_size: Au) -> Au
pub fn get_shrink_to_fit_inline_size(&self, available_inline_size: Au) -> Au
Return shrink-to-fit inline-size.
This is where we use the preferred inline-sizes and minimum inline-sizes calculated in the bubble-inline-sizes traversal.
sourcefn adjust_fragments_for_collapsed_margins_if_root(
&mut self,
shared_context: &SharedStyleContext<'_>,
)
fn adjust_fragments_for_collapsed_margins_if_root( &mut self, shared_context: &SharedStyleContext<'_>, )
If this is the root flow, shifts all kids down and adjusts our size to account for root flow margins, which should never be collapsed according to CSS § 8.3.1.
TODO(#2017, pcwalton): This is somewhat inefficient (traverses kids twice); can we do better?
fn clone_with_children(&self, new_children: FlowList) -> BlockFlow
sourcefn propagate_early_absolute_position_info_to_children(&mut self)
fn propagate_early_absolute_position_info_to_children(&mut self)
Writes in the size of the relative containing block for children. (This information is also needed to handle RTL.)
sourcepub fn assign_block_size_block_base(
&mut self,
layout_context: &LayoutContext<'_>,
fragmentation_context: Option<FragmentationContext>,
margins_may_collapse: MarginsMayCollapseFlag,
) -> Option<Arc<dyn Flow>>
pub fn assign_block_size_block_base( &mut self, layout_context: &LayoutContext<'_>, fragmentation_context: Option<FragmentationContext>, margins_may_collapse: MarginsMayCollapseFlag, ) -> Option<Arc<dyn Flow>>
Assign block-size for current flow.
- Collapse margins for flow’s children and set in-flow child flows’ block offsets now that we know their block-sizes.
- Calculate and set the block-size of the current flow.
- Calculate block-size, vertical margins, and block offset for the flow’s box using CSS § 10.6.7.
For absolute flows, we store the calculated content block-size for the flow. We defer the calculation of the other values until a later traversal at root flow.
When fragmentation_context
is given (not None
), this should fit as much of the content
as possible within the available block size.
If there is more content (that doesn’t fit), this flow is fragmented
with the extra content moved to another fragment (a flow like this one) which is returned.
See Flow::fragment
.
The return value is always None
when fragmentation_context
is None
.
inline(always)
because this is only ever called by in-order or non-in-order top-level
methods.
sourcepub fn place_float(&mut self)
pub fn place_float(&mut self)
Add placement information about current float flow for use by the parent.
Also, use information given by parent about other floats to find out our relative position.
This does not give any information about any float descendants because they do not affect elements outside of the subtree rooted at this float.
This function is called on a kid flow by a parent. Therefore, assign_block_size_float
was
already called on this kid flow by the traversal function. So, the values used are
well-defined.
pub fn explicit_block_containing_size( &self, shared_context: &SharedStyleContext<'_>, ) -> Option<Au>
pub fn explicit_block_size( &self, containing_block_size: Option<Au>, ) -> Option<Au>
fn calculate_absolute_block_size_and_margins( &mut self, shared_context: &SharedStyleContext<'_>, )
sourcefn propagate_and_compute_used_inline_size(
&mut self,
shared_context: &SharedStyleContext<'_>,
)
fn propagate_and_compute_used_inline_size( &mut self, shared_context: &SharedStyleContext<'_>, )
Compute inline size based using the block_container_inline_size
set by the parent flow.
This is run in the AssignISizes
traversal.
sourcepub fn propagate_assigned_inline_size_to_children<F>(
&mut self,
shared_context: &SharedStyleContext<'_>,
inline_start_content_edge: Au,
inline_end_content_edge: Au,
content_inline_size: Au,
callback: F,
)
pub fn propagate_assigned_inline_size_to_children<F>( &mut self, shared_context: &SharedStyleContext<'_>, inline_start_content_edge: Au, inline_end_content_edge: Au, content_inline_size: Au, callback: F, )
Assigns the computed inline-start content edge and inline-size to all the children of this
block flow. The given callback
, if supplied, will be called once per child; it is
currently used to push down column sizes for tables.
#[inline(always)]
because this is called only from block or table inline-size assignment
and the code for block layout is significantly simpler.
sourcepub fn formatting_context_type(&self) -> FormattingContextType
pub fn formatting_context_type(&self) -> FormattingContextType
Determines the type of formatting context this is. See the definition of
FormattingContextType
.
sourcefn assign_inline_position_for_formatting_context(
&mut self,
layout_context: &LayoutContext<'_>,
content_box: LogicalRect<Au>,
)
fn assign_inline_position_for_formatting_context( &mut self, layout_context: &LayoutContext<'_>, content_box: LogicalRect<Au>, )
Per CSS 2.1 § 9.5, block formatting contexts’ inline widths and positions are affected by the presence of floats. This is the part of the assign-heights traversal that computes the final inline position and width for such flows.
Note that this is part of the assign-block-sizes traversal, not the assign-inline-sizes traversal as one might expect. That is because, in general, float placement cannot occur until heights are assigned. To work around this unfortunate circular dependency, by the time we get here we have already estimated the width of the block formatting context based on the floats we could see at the time of inline-size assignment. The job of this function, therefore, is not only to assign the final size but also to perform the layout again for this block formatting context if our speculation was wrong.
fn is_inline_block_or_inline_flex(&self) -> bool
sourcefn content_intrinsic_inline_sizes(&self) -> IntrinsicISizes
fn content_intrinsic_inline_sizes(&self) -> IntrinsicISizes
Computes the content portion (only) of the intrinsic inline sizes of this flow. This is used for calculating shrink-to-fit width. Assumes that intrinsic sizes have already been computed for this flow.
sourcepub fn bubble_inline_sizes_for_block(&mut self, consult_children: bool)
pub fn bubble_inline_sizes_for_block(&mut self, consult_children: bool)
Computes intrinsic inline sizes for a block.
pub fn overflow_style_may_require_clip_scroll_node(&self) -> bool
pub fn compute_inline_sizes(&mut self, shared_context: &SharedStyleContext<'_>)
sourcepub fn initialize_container_size_for_root(
&mut self,
shared_context: &SharedStyleContext<'_>,
)
pub fn initialize_container_size_for_root( &mut self, shared_context: &SharedStyleContext<'_>, )
If this is the root flow, initialize values that would normally be set by the parent.
Should be called during assign_inline_sizes
for flows that may be the root.
fn guess_inline_size_for_block_formatting_context_if_necessary(&mut self)
fn definitely_has_zero_block_size(&self) -> bool
pub fn is_inline_flex_item(&self) -> bool
pub fn is_block_flex_item(&self) -> bool
pub fn mark_scrolling_overflow(&mut self, has_scrolling_overflow: bool)
pub fn has_scrolling_overflow(&self) -> bool
pub fn sticky_position(&self) -> SideOffsets2D<MaybeAuto>
pub fn background_border_section(&self) -> DisplayListSection
source§impl BlockFlow
impl BlockFlow
fn transform_clip_to_coordinate_space( &mut self, state: &mut StackingContextCollectionState, preserved_state: &mut SavedStackingContextCollectionState, )
sourcefn is_reference_frame(&self, context_type: Option<StackingContextType>) -> bool
fn is_reference_frame(&self, context_type: Option<StackingContextType>) -> bool
Returns true if this fragment may establish a reference frame and this block creates a stacking context. Both are necessary in order to establish a reference frame.
pub fn collect_stacking_contexts_for_block( &mut self, state: &mut StackingContextCollectionState, flags: StackingContextCollectionFlags, )
fn setup_clipping_for_block( &mut self, state: &mut StackingContextCollectionState, preserved_state: &mut SavedStackingContextCollectionState, stacking_context_type: Option<StackingContextType>, established_reference_frame: Option<ClipScrollNodeIndex>, flags: StackingContextCollectionFlags, ) -> ClippingAndScrolling
fn setup_clip_scroll_node_for_position( &mut self, state: &mut StackingContextCollectionState, border_box: Rect<Au>, )
fn setup_clip_scroll_node_for_overflow( &mut self, state: &mut StackingContextCollectionState, border_box: Rect<Au>, )
sourcefn setup_clip_scroll_node_for_css_clip(
&mut self,
state: &mut StackingContextCollectionState,
preserved_state: &mut SavedStackingContextCollectionState,
stacking_relative_border_box: Rect<Au>,
)
fn setup_clip_scroll_node_for_css_clip( &mut self, state: &mut StackingContextCollectionState, preserved_state: &mut SavedStackingContextCollectionState, stacking_relative_border_box: Rect<Au>, )
Adds a scroll root for a block to take the clip
property into account
per CSS 2.1 § 11.1.2.
fn create_pseudo_stacking_context_for_block( &mut self, stacking_context_type: StackingContextType, parent_stacking_context_id: StackingContextId, parent_clipping_and_scrolling: ClippingAndScrolling, state: &mut StackingContextCollectionState, )
fn create_real_stacking_context_for_block( &mut self, parent_stacking_context_id: StackingContextId, parent_clipping_and_scrolling: ClippingAndScrolling, established_reference_frame: Option<ClipScrollNodeIndex>, state: &mut StackingContextCollectionState, )
pub fn build_display_list_for_block_no_damage( &self, state: &mut DisplayListBuildState<'_>, border_painting_mode: BorderPaintingMode<'_>, )
pub fn build_display_list_for_block( &mut self, state: &mut DisplayListBuildState<'_>, border_painting_mode: BorderPaintingMode<'_>, )
pub fn build_display_list_for_background_if_applicable_with_background( &self, state: &mut DisplayListBuildState<'_>, background: &Background, background_color: AbsoluteColor, )
fn stacking_context_type( &self, flags: StackingContextCollectionFlags, ) -> Option<StackingContextType>
Trait Implementations§
source§impl Flow for BlockFlow
impl Flow for BlockFlow
source§fn bubble_inline_sizes(&mut self)
fn bubble_inline_sizes(&mut self)
Pass 1 of reflow: computes minimum and preferred inline-sizes.
Recursively (bottom-up) determine the flow’s minimum and preferred inline-sizes. When called on this flow, all child flows have had their minimum and preferred inline-sizes set. This function must decide minimum/preferred inline-sizes based on its children’s inline-sizes and the dimensions of any fragments it is responsible for flowing.
source§fn assign_inline_sizes(&mut self, layout_context: &LayoutContext<'_>)
fn assign_inline_sizes(&mut self, layout_context: &LayoutContext<'_>)
Recursively (top-down) determines the actual inline-size of child contexts and fragments. When called on this context, the context has had its inline-size set by the parent context.
Dual fragments consume some inline-size first, and the remainder is assigned to all child (block) contexts.
source§fn positioning(&self) -> Position
fn positioning(&self) -> Position
The ‘position’ property of this flow.
source§fn generated_containing_block_size(&self, _: OpaqueFlow) -> LogicalSize<Au>
fn generated_containing_block_size(&self, _: OpaqueFlow) -> LogicalSize<Au>
Return the dimensions of the containing block generated by this flow for absolutely- positioned descendants. For block flows, this is the padding box.
source§fn contains_roots_of_absolute_flow_tree(&self) -> bool
fn contains_roots_of_absolute_flow_tree(&self) -> bool
Returns true if this flow contains fragments that are roots of an absolute flow tree.
source§fn is_absolute_containing_block(&self) -> bool
fn is_absolute_containing_block(&self) -> bool
Returns true if this is an absolute containing block.
source§fn as_mut_block(&mut self) -> &mut BlockFlow
fn as_mut_block(&mut self) -> &mut BlockFlow
source§fn as_block(&self) -> &BlockFlow
fn as_block(&self) -> &BlockFlow
source§fn place_float_if_applicable<'a>(&mut self)
fn place_float_if_applicable<'a>(&mut self)
source§fn assign_block_size_for_inorder_child_if_necessary(
&mut self,
layout_context: &LayoutContext<'_>,
parent_thread_id: u8,
content_box: LogicalRect<Au>,
) -> bool
fn assign_block_size_for_inorder_child_if_necessary( &mut self, layout_context: &LayoutContext<'_>, parent_thread_id: u8, content_box: LogicalRect<Au>, ) -> bool
source§fn assign_block_size(&mut self, ctx: &LayoutContext<'_>)
fn assign_block_size(&mut self, ctx: &LayoutContext<'_>)
source§fn fragment(
&mut self,
layout_context: &LayoutContext<'_>,
fragmentation_context: Option<FragmentationContext>,
) -> Option<Arc<dyn Flow>>
fn fragment( &mut self, layout_context: &LayoutContext<'_>, fragmentation_context: Option<FragmentationContext>, ) -> Option<Arc<dyn Flow>>
assign_block_size
, but is recurses explicitly into descendants.
Fit as much content as possible within available_block_size
.
If that’s not all of it, truncate the contents of self
and return a new flow similar to self
with the rest of the content. Read moresource§fn compute_stacking_relative_position(
&mut self,
_layout_context: &LayoutContext<'_>,
)
fn compute_stacking_relative_position( &mut self, _layout_context: &LayoutContext<'_>, )
source§fn mark_as_root(&mut self)
fn mark_as_root(&mut self)
fn is_root(&self) -> bool
source§fn update_late_computed_inline_position_if_necessary(
&mut self,
inline_position: Au,
)
fn update_late_computed_inline_position_if_necessary( &mut self, inline_position: Au, )
source§fn update_late_computed_block_position_if_necessary(
&mut self,
block_position: Au,
)
fn update_late_computed_block_position_if_necessary( &mut self, block_position: Au, )
fn collect_stacking_contexts( &mut self, state: &mut StackingContextCollectionState, )
source§fn build_display_list(&mut self, state: &mut DisplayListBuildState<'_>)
fn build_display_list(&mut self, state: &mut DisplayListBuildState<'_>)
source§fn repair_style(&mut self, new_style: &Arc<ComputedValues>)
fn repair_style(&mut self, new_style: &Arc<ComputedValues>)
source§fn compute_overflow(&self) -> Overflow
fn compute_overflow(&self) -> Overflow
source§fn iterate_through_fragment_border_boxes(
&self,
iterator: &mut dyn FragmentBorderBoxIterator,
level: i32,
stacking_context_position: &Point2D<Au>,
)
fn iterate_through_fragment_border_boxes( &self, iterator: &mut dyn FragmentBorderBoxIterator, level: i32, stacking_context_position: &Point2D<Au>, )
source§fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment))
fn mutate_fragments(&mut self, mutator: &mut dyn FnMut(&mut Fragment))
source§fn print_extra_flow_children(&self, print_tree: &mut PrintTree)
fn print_extra_flow_children(&self, print_tree: &mut PrintTree)
source§fn as_flex(&self) -> &FlexFlow
fn as_flex(&self) -> &FlexFlow
source§fn as_inline(&self) -> &InlineFlow
fn as_inline(&self) -> &InlineFlow
source§fn as_mut_inline(&mut self) -> &mut InlineFlow
fn as_mut_inline(&mut self) -> &mut InlineFlow
source§fn as_table_wrapper(&self) -> &TableWrapperFlow
fn as_table_wrapper(&self) -> &TableWrapperFlow
source§fn as_mut_table(&mut self) -> &mut TableFlow
fn as_mut_table(&mut self) -> &mut TableFlow
source§fn as_table(&self) -> &TableFlow
fn as_table(&self) -> &TableFlow
source§fn as_mut_table_colgroup(&mut self) -> &mut TableColGroupFlow
fn as_mut_table_colgroup(&mut self) -> &mut TableColGroupFlow
source§fn as_table_colgroup(&self) -> &TableColGroupFlow
fn as_table_colgroup(&self) -> &TableColGroupFlow
source§fn as_mut_table_rowgroup(&mut self) -> &mut TableRowGroupFlow
fn as_mut_table_rowgroup(&mut self) -> &mut TableRowGroupFlow
source§fn as_table_rowgroup(&self) -> &TableRowGroupFlow
fn as_table_rowgroup(&self) -> &TableRowGroupFlow
source§fn as_mut_table_row(&mut self) -> &mut TableRowFlow
fn as_mut_table_row(&mut self) -> &mut TableRowFlow
source§fn as_table_row(&self) -> &TableRowFlow
fn as_table_row(&self) -> &TableRowFlow
source§fn as_mut_table_cell(&mut self) -> &mut TableCellFlow
fn as_mut_table_cell(&mut self) -> &mut TableCellFlow
source§fn as_table_cell(&self) -> &TableCellFlow
fn as_table_cell(&self) -> &TableCellFlow
fn has_non_invertible_transform_or_zero_scale(&self) -> bool
fn get_overflow_in_parent_coordinates(&self) -> Overflow
source§fn store_overflow(&mut self, _: &LayoutContext<'_>)
fn store_overflow(&mut self, _: &LayoutContext<'_>)
fn contains_positioned_fragments(&self) -> bool
fn contains_relatively_positioned_fragments(&self) -> bool
fn clipping_and_scrolling(&self) -> ClippingAndScrolling
source§impl TableLikeFlow for BlockFlow
impl TableLikeFlow for BlockFlow
source§fn assign_block_size_for_table_like_flow(
&mut self,
block_direction_spacing: Au,
layout_context: &LayoutContext<'_>,
)
fn assign_block_size_for_table_like_flow( &mut self, block_direction_spacing: Au, layout_context: &LayoutContext<'_>, )
impl HasBaseFlow for BlockFlow
Auto Trait Implementations§
impl !Freeze for BlockFlow
impl !RefUnwindSafe for BlockFlow
impl Send for BlockFlow
impl Sync for BlockFlow
impl Unpin for BlockFlow
impl !UnwindSafe for BlockFlow
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> GetBaseFlow for Twhere
T: HasBaseFlow + ?Sized,
impl<T> GetBaseFlow for Twhere
T: HasBaseFlow + ?Sized,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more