Struct layout_2013::construct::FlowConstructor
source · pub struct FlowConstructor<'a, N> {
pub layout_context: &'a LayoutContext<'a>,
phantom2: PhantomData<N>,
}
Expand description
An object that knows how to create flows.
Fields§
§layout_context: &'a LayoutContext<'a>
The layout context.
phantom2: PhantomData<N>
Satisfy the compiler about the unused parameters, which we use to improve the ergonomics of the ensuing impl {} by removing the need to parameterize all the methods individually.
Implementations§
source§impl<'a, 'dom, ConcreteThreadSafeLayoutNode> FlowConstructor<'a, ConcreteThreadSafeLayoutNode>where
ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>,
impl<'a, 'dom, ConcreteThreadSafeLayoutNode> FlowConstructor<'a, ConcreteThreadSafeLayoutNode>where
ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>,
sourcepub fn new(layout_context: &'a LayoutContext<'a>) -> Self
pub fn new(layout_context: &'a LayoutContext<'a>) -> Self
Creates a new flow constructor.
fn style_context(&self) -> &SharedStyleContext<'_>
fn set_flow_construction_result( &self, node: &ConcreteThreadSafeLayoutNode, result: ConstructionResult, )
sourcefn build_fragment_for_block(
&self,
node: &ConcreteThreadSafeLayoutNode,
) -> Fragment
fn build_fragment_for_block( &self, node: &ConcreteThreadSafeLayoutNode, ) -> Fragment
Builds the fragment for the given block or subclass thereof.
sourcefn flush_inline_fragments_to_flow(
&mut self,
fragment_accumulator: InlineFragmentsAccumulator,
flow: &mut FlowRef,
absolute_descendants: &mut AbsoluteDescendants,
legalizer: &mut Legalizer,
node: &ConcreteThreadSafeLayoutNode,
)
fn flush_inline_fragments_to_flow( &mut self, fragment_accumulator: InlineFragmentsAccumulator, flow: &mut FlowRef, absolute_descendants: &mut AbsoluteDescendants, legalizer: &mut Legalizer, node: &ConcreteThreadSafeLayoutNode, )
Creates an inline flow from a set of inline fragments, then adds it as a child of the given flow or pushes it onto the given flow list.
#[inline(always)]
because this is performance critical and LLVM will not inline it
otherwise.
fn build_block_flow_using_construction_result_of_child( &mut self, flow: &mut FlowRef, node: &ConcreteThreadSafeLayoutNode, kid: ConcreteThreadSafeLayoutNode, inline_fragment_accumulator: &mut InlineFragmentsAccumulator, abs_descendants: &mut AbsoluteDescendants, legalizer: &mut Legalizer, )
sourcefn build_flow_for_block_starting_with_fragments(
&mut self,
flow: FlowRef,
node: &ConcreteThreadSafeLayoutNode,
initial_fragments: IntermediateInlineFragments,
) -> ConstructionResult
fn build_flow_for_block_starting_with_fragments( &mut self, flow: FlowRef, node: &ConcreteThreadSafeLayoutNode, initial_fragments: IntermediateInlineFragments, ) -> ConstructionResult
Constructs a block flow, beginning with the given initial_fragments
if present and then
appending the construction results of children to the child list of the block flow. {ib}
splits and absolutely-positioned descendants are handled correctly.
sourcefn build_flow_for_block_like(
&mut self,
flow: FlowRef,
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult
fn build_flow_for_block_like( &mut self, flow: FlowRef, node: &ConcreteThreadSafeLayoutNode, ) -> ConstructionResult
Constructs a flow for the given block node and its children. This method creates an
initial fragment as appropriate and then dispatches to
build_flow_for_block_starting_with_fragments
. Currently the following kinds of flows get
initial content:
- Generated content gets the initial content specified by the
content
attribute of the CSS. <input>
and<textarea>
elements get their content.
FIXME(pcwalton): It is not clear to me that there isn’t a cleaner way to handle
<textarea>
.
sourcefn create_fragments_for_node_text_content(
&self,
fragments: &mut IntermediateInlineFragments,
node: &ConcreteThreadSafeLayoutNode,
style: &ServoArc<ComputedValues>,
)
fn create_fragments_for_node_text_content( &self, fragments: &mut IntermediateInlineFragments, node: &ConcreteThreadSafeLayoutNode, style: &ServoArc<ComputedValues>, )
Pushes fragments appropriate for the content of the given node onto the given list.
sourcefn build_flow_for_block(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
float_kind: Option<FloatKind>,
) -> ConstructionResult
fn build_flow_for_block( &mut self, node: &ConcreteThreadSafeLayoutNode, float_kind: Option<FloatKind>, ) -> ConstructionResult
Builds a flow for a node with display: block
. This yields a BlockFlow
with possibly
other BlockFlow
s or InlineFlow
s underneath it, depending on whether {ib} splits needed
to happen.
sourcefn accumulate_inline_block_splits(
&mut self,
splits: LinkedList<InlineBlockSplit>,
node: &ConcreteThreadSafeLayoutNode,
fragment_accumulator: &mut InlineFragmentsAccumulator,
opt_inline_block_splits: &mut LinkedList<InlineBlockSplit>,
)
fn accumulate_inline_block_splits( &mut self, splits: LinkedList<InlineBlockSplit>, node: &ConcreteThreadSafeLayoutNode, fragment_accumulator: &mut InlineFragmentsAccumulator, opt_inline_block_splits: &mut LinkedList<InlineBlockSplit>, )
Bubbles up {ib} splits.
sourcefn build_fragments_for_nonreplaced_inline_content(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult
fn build_fragments_for_nonreplaced_inline_content( &mut self, node: &ConcreteThreadSafeLayoutNode, ) -> ConstructionResult
Concatenates the fragments of kids, adding in our own borders/padding/margins if necessary.
Returns the InlineFragmentsConstructionResult
, if any. There will be no
InlineFragmentsConstructionResult
if this node consisted entirely of ignorable
whitespace.
sourcefn build_fragments_for_replaced_inline_content(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult
fn build_fragments_for_replaced_inline_content( &mut self, node: &ConcreteThreadSafeLayoutNode, ) -> ConstructionResult
Creates an InlineFragmentsConstructionResult
for replaced content. Replaced content
doesn’t render its children, so this just nukes a child’s fragments and creates a
Fragment
.
sourcefn build_fragment_for_inline_block_or_inline_flex(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
display: Display,
) -> ConstructionResult
fn build_fragment_for_inline_block_or_inline_flex( &mut self, node: &ConcreteThreadSafeLayoutNode, display: Display, ) -> ConstructionResult
Build the fragment for an inline-block or inline-flex, based on the display
flag
sourcefn build_fragment_for_absolutely_positioned_inline(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult
fn build_fragment_for_absolutely_positioned_inline( &mut self, node: &ConcreteThreadSafeLayoutNode, ) -> ConstructionResult
This is an annoying case, because the computed display
value is block
, but the
hypothetical box is inline.
sourcefn build_fragments_for_inline(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult
fn build_fragments_for_inline( &mut self, node: &ConcreteThreadSafeLayoutNode, ) -> ConstructionResult
Builds one or more fragments for a node with display: inline
. This yields an
InlineFragmentsConstructionResult
.
Places any table captions found under the given table wrapper, if the value of their
caption-side
property is equal to the given side
.
sourcefn build_flow_for_multicol(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
float_kind: Option<FloatKind>,
) -> ConstructionResult
fn build_flow_for_multicol( &mut self, node: &ConcreteThreadSafeLayoutNode, float_kind: Option<FloatKind>, ) -> ConstructionResult
Builds a flow for a node with column-count
or column-width
non-auto
.
This yields a MulticolFlow
with a single MulticolColumnFlow
underneath it.
sourcefn build_flow_for_table(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
float_value: Float,
) -> ConstructionResult
fn build_flow_for_table( &mut self, node: &ConcreteThreadSafeLayoutNode, float_value: Float, ) -> ConstructionResult
Builds a flow for a node with display: table
. This yields a TableWrapperFlow
with
possibly other TableCaptionFlow
s or TableFlow
s underneath it.
Builds a flow for a node with display: table-caption
. This yields a TableCaptionFlow
with possibly other BlockFlow
s or InlineFlow
s underneath it.
sourcefn build_flow_for_table_rowgroup(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult
fn build_flow_for_table_rowgroup( &mut self, node: &ConcreteThreadSafeLayoutNode, ) -> ConstructionResult
Builds a flow for a node with display: table-row-group
. This yields a TableRowGroupFlow
with possibly other TableRowFlow
s underneath it.
sourcefn build_flow_for_table_row(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult
fn build_flow_for_table_row( &mut self, node: &ConcreteThreadSafeLayoutNode, ) -> ConstructionResult
Builds a flow for a node with display: table-row
. This yields a TableRowFlow
with
possibly other TableCellFlow
s underneath it.
sourcefn build_flow_for_table_cell(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult
fn build_flow_for_table_cell( &mut self, node: &ConcreteThreadSafeLayoutNode, ) -> ConstructionResult
Builds a flow for a node with display: table-cell
. This yields a TableCellFlow
with
possibly other BlockFlow
s or InlineFlow
s underneath it.
sourcefn build_flow_for_list_item(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
flotation: Float,
) -> ConstructionResult
fn build_flow_for_list_item( &mut self, node: &ConcreteThreadSafeLayoutNode, flotation: Float, ) -> ConstructionResult
Builds a flow for a node with display: list-item
. This yields a ListItemFlow
with
possibly other BlockFlow
s or InlineFlow
s underneath it.
sourcefn build_fragments_for_table_column(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult
fn build_fragments_for_table_column( &mut self, node: &ConcreteThreadSafeLayoutNode, ) -> ConstructionResult
Creates a fragment for a node with display: table-column
.
sourcefn build_flow_for_table_colgroup(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
) -> ConstructionResult
fn build_flow_for_table_colgroup( &mut self, node: &ConcreteThreadSafeLayoutNode, ) -> ConstructionResult
Builds a flow for a node with display: table-column-group
.
This yields a TableColGroupFlow
.
sourcefn build_flow_for_flex(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
float_kind: Option<FloatKind>,
) -> ConstructionResult
fn build_flow_for_flex( &mut self, node: &ConcreteThreadSafeLayoutNode, float_kind: Option<FloatKind>, ) -> ConstructionResult
Builds a flow for a node with ‘display: flex’.
sourcepub fn repair_if_possible(
&mut self,
node: &ConcreteThreadSafeLayoutNode,
) -> bool
pub fn repair_if_possible( &mut self, node: &ConcreteThreadSafeLayoutNode, ) -> bool
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.
TODO(pcwalton): Add some more fast paths, like toggling display: none
, adding block kids
to block parents with no {ib} splits, adding out-of-flow kids, etc.
Trait Implementations§
source§impl<'a, 'dom, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<'dom, ConcreteThreadSafeLayoutNode> for FlowConstructor<'a, ConcreteThreadSafeLayoutNode>where
ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>,
impl<'a, 'dom, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<'dom, ConcreteThreadSafeLayoutNode> for FlowConstructor<'a, ConcreteThreadSafeLayoutNode>where
ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'dom>,
source§fn process(&mut self, node: &ConcreteThreadSafeLayoutNode)
fn process(&mut self, node: &ConcreteThreadSafeLayoutNode)
Auto Trait Implementations§
impl<'a, N> Freeze for FlowConstructor<'a, N>
impl<'a, N> !RefUnwindSafe for FlowConstructor<'a, N>
impl<'a, N> Send for FlowConstructor<'a, N>where
N: Send,
impl<'a, N> Sync for FlowConstructor<'a, N>where
N: Sync,
impl<'a, N> Unpin for FlowConstructor<'a, N>where
N: Unpin,
impl<'a, N> !UnwindSafe for FlowConstructor<'a, N>
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> 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