Struct layout_2013::fragment::Fragment
source · pub struct Fragment {Show 14 fields
pub node: OpaqueNode,
pub style: Arc<ComputedValues>,
pub selected_style: Arc<ComputedValues>,
pub border_box: LogicalRect<Au>,
pub border_padding: LogicalMargin<Au>,
pub margin: LogicalMargin<Au>,
pub specific: SpecificFragmentInfo,
pub inline_context: Option<InlineFragmentContext>,
pub restyle_damage: RestyleDamage,
pub pseudo: PseudoElementType,
pub flags: FragmentFlags,
debug_id: DebugId,
pub stacking_context_id: StackingContextId,
pub established_reference_frame: Option<ClipScrollNodeIndex>,
}
Expand description
Fragments (struct Fragment
) are the leaves of the layout tree. They cannot position
themselves. In general, fragments do not have a simple correspondence with CSS fragments in the
specification:
-
Several fragments may correspond to the same CSS box or DOM node. For example, a CSS text box broken across two lines is represented by two fragments.
-
Some CSS fragments are not created at all, such as some anonymous block fragments induced by inline fragments with block-level sibling fragments. In that case, Servo uses an
InlineFlow
withBlockFlow
siblings; theInlineFlow
is block-level, but not a block container. It is positioned as if it were a block fragment, but its children are positioned according to inline flow.
A SpecificFragmentInfo::Generic
is an empty fragment that contributes only borders, margins,
padding, and backgrounds. It is analogous to a CSS nonreplaced content box.
A fragment’s type influences how its styles are interpreted during layout. For example, replaced content such as images are resized differently from tables, text, or other content. Different types of fragments may also contain custom data; for example, text fragments contain text.
Do not add fields to this structure unless they’re really really mega necessary! Fragments get moved around a lot and thus their size impacts performance of layout quite a bit.
FIXME(#2260, pcwalton): This can be slimmed down some by (at least) moving inline_context
to be on InlineFlow
only.
Fields§
§node: OpaqueNode
An opaque reference to the DOM node that this Fragment
originates from.
style: Arc<ComputedValues>
The CSS style of this fragment.
selected_style: Arc<ComputedValues>
The CSS style of this fragment when it’s selected
border_box: LogicalRect<Au>
The position of this fragment relative to its owning flow. The size includes padding and border, but not margin.
NB: This does not account for relative positioning. NB: Collapsed borders are not included in this.
border_padding: LogicalMargin<Au>
The sum of border and padding; i.e. the distance from the edge of the border box to the content edge of the fragment.
margin: LogicalMargin<Au>
The margin of the content box.
specific: SpecificFragmentInfo
Info specific to the kind of fragment. Keep this enum small.
inline_context: Option<InlineFragmentContext>
Holds the style context information for fragments that are part of an inline formatting context.
restyle_damage: RestyleDamage
How damaged this fragment is since last reflow.
pseudo: PseudoElementType
The pseudo-element that this fragment represents.
flags: FragmentFlags
Various flags for this fragment.
debug_id: DebugId
A debug ID that is consistent for the life of this fragment (via transform etc). This ID should not be considered stable across multiple layouts or fragment manipulations.
stacking_context_id: StackingContextId
The ID of the StackingContext that contains this fragment. This is initialized to 0, but it assigned during the collect_stacking_contexts phase of display list construction.
established_reference_frame: Option<ClipScrollNodeIndex>
The indices of this Fragment’s ClipScrollNode. If this fragment doesn’t have a
established_reference_frame
assigned, it will use the clipping_and_scrolling
of the
parent block.
Implementations§
source§impl Fragment
impl Fragment
pub fn collect_stacking_contexts_for_blocklike_fragment( &mut self, state: &mut StackingContextCollectionState, ) -> bool
pub fn create_stacking_context_for_inline_block( &mut self, base: &BaseFlow, state: &mut StackingContextCollectionState, ) -> bool
sourcefn build_display_list_for_background_if_applicable(
&self,
state: &mut DisplayListBuildState<'_>,
style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: Rect<Au>,
)
fn build_display_list_for_background_if_applicable( &self, state: &mut DisplayListBuildState<'_>, style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: Rect<Au>, )
Adds the display items necessary to paint the background of this fragment to the display list if necessary.
sourcefn build_display_list_for_background_if_applicable_with_background(
&self,
state: &mut DisplayListBuildState<'_>,
style: &ComputedValues,
background: &Background,
background_color: AbsoluteColor,
display_list_section: DisplayListSection,
absolute_bounds: Rect<Au>,
)
fn build_display_list_for_background_if_applicable_with_background( &self, state: &mut DisplayListBuildState<'_>, style: &ComputedValues, background: &Background, background_color: AbsoluteColor, display_list_section: DisplayListSection, absolute_bounds: Rect<Au>, )
Same as build_display_list_for_background_if_applicable, but lets you override the actual background used
sourcefn build_display_list_for_webrender_image(
&self,
state: &mut DisplayListBuildState<'_>,
style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: Rect<Au>,
webrender_image: WebRenderImageInfo,
index: usize,
)
fn build_display_list_for_webrender_image( &self, state: &mut DisplayListBuildState<'_>, style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: Rect<Au>, webrender_image: WebRenderImageInfo, index: usize, )
Adds the display items necessary to paint a webrender image of this fragment to the appropriate section of the display list.
sourcefn get_webrender_image_for_paint_worklet(
&self,
state: &mut DisplayListBuildState<'_>,
style: &ComputedValues,
paint_worklet: &PaintWorklet,
size_in_au: Size2D<Au>,
) -> Option<WebRenderImageInfo>
fn get_webrender_image_for_paint_worklet( &self, state: &mut DisplayListBuildState<'_>, style: &ComputedValues, paint_worklet: &PaintWorklet, size_in_au: Size2D<Au>, ) -> Option<WebRenderImageInfo>
Calculates the webrender image for a paint worklet. Returns None if the worklet is not registered. If the worklet has missing image URLs, it passes them to the image cache for loading.
sourcefn build_display_list_for_background_gradient(
&self,
state: &mut DisplayListBuildState<'_>,
display_list_section: DisplayListSection,
absolute_bounds: Rect<Au>,
gradient: &Gradient,
style: &ComputedValues,
index: usize,
)
fn build_display_list_for_background_gradient( &self, state: &mut DisplayListBuildState<'_>, display_list_section: DisplayListSection, absolute_bounds: Rect<Au>, gradient: &Gradient, style: &ComputedValues, index: usize, )
Adds the display items necessary to paint the background linear gradient of this fragment to the appropriate section of the display list.
sourcefn build_display_list_for_box_shadow_if_applicable(
&self,
state: &mut DisplayListBuildState<'_>,
style: &ComputedValues,
display_list_section: DisplayListSection,
absolute_bounds: Rect<Au>,
clip: Rect<Au>,
)
fn build_display_list_for_box_shadow_if_applicable( &self, state: &mut DisplayListBuildState<'_>, style: &ComputedValues, display_list_section: DisplayListSection, absolute_bounds: Rect<Au>, clip: Rect<Au>, )
Adds the display items necessary to paint the box shadow of this fragment to the display list if necessary.
sourcefn build_display_list_for_borders_if_applicable(
&self,
state: &mut DisplayListBuildState<'_>,
style: &ComputedValues,
inline_info: Option<InlineNodeBorderInfo>,
border_painting_mode: BorderPaintingMode<'_>,
bounds: Rect<Au>,
display_list_section: DisplayListSection,
clip: Rect<Au>,
)
fn build_display_list_for_borders_if_applicable( &self, state: &mut DisplayListBuildState<'_>, style: &ComputedValues, inline_info: Option<InlineNodeBorderInfo>, border_painting_mode: BorderPaintingMode<'_>, bounds: Rect<Au>, display_list_section: DisplayListSection, clip: Rect<Au>, )
Adds the display items necessary to paint the borders of this fragment to a display list if necessary.
sourcefn build_display_list_for_border_image(
&self,
state: &mut DisplayListBuildState<'_>,
style: &ComputedValues,
base: BaseDisplayItem,
bounds: Rect<Au>,
image: &Image,
border_width: UntypedSideOffsets2D<Au>,
) -> Option<()>
fn build_display_list_for_border_image( &self, state: &mut DisplayListBuildState<'_>, style: &ComputedValues, base: BaseDisplayItem, bounds: Rect<Au>, image: &Image, border_width: UntypedSideOffsets2D<Au>, ) -> Option<()>
Add display item for image border.
Returns Some
if the addition was successful.
sourcefn build_display_list_for_outline_if_applicable(
&self,
state: &mut DisplayListBuildState<'_>,
style: &ComputedValues,
bounds: Rect<Au>,
clip: Rect<Au>,
)
fn build_display_list_for_outline_if_applicable( &self, state: &mut DisplayListBuildState<'_>, style: &ComputedValues, bounds: Rect<Au>, clip: Rect<Au>, )
Adds the display items necessary to paint the outline of this fragment to the display list if necessary.
sourcefn build_debug_borders_around_text_fragments(
&self,
state: &mut DisplayListBuildState<'_>,
style: &ComputedValues,
stacking_relative_border_box: Rect<Au>,
stacking_relative_content_box: Rect<Au>,
text_fragment: &ScannedTextFragmentInfo,
clip: Rect<Au>,
)
fn build_debug_borders_around_text_fragments( &self, state: &mut DisplayListBuildState<'_>, style: &ComputedValues, stacking_relative_border_box: Rect<Au>, stacking_relative_content_box: Rect<Au>, text_fragment: &ScannedTextFragmentInfo, clip: Rect<Au>, )
Adds display items necessary to draw debug boxes around a scanned text fragment.
sourcefn build_debug_borders_around_fragment(
&self,
state: &mut DisplayListBuildState<'_>,
stacking_relative_border_box: Rect<Au>,
clip: Rect<Au>,
)
fn build_debug_borders_around_fragment( &self, state: &mut DisplayListBuildState<'_>, stacking_relative_border_box: Rect<Au>, clip: Rect<Au>, )
Adds display items necessary to draw debug boxes around this fragment.
sourcefn build_display_items_for_selection_if_necessary(
&self,
state: &mut DisplayListBuildState<'_>,
stacking_relative_border_box: Rect<Au>,
display_list_section: DisplayListSection,
)
fn build_display_items_for_selection_if_necessary( &self, state: &mut DisplayListBuildState<'_>, stacking_relative_border_box: Rect<Au>, display_list_section: DisplayListSection, )
Builds the display items necessary to paint the selection and/or caret for this fragment, if any.
sourcepub fn build_display_list(
&mut self,
state: &mut DisplayListBuildState<'_>,
stacking_relative_border_box: Rect<Au>,
border_painting_mode: BorderPaintingMode<'_>,
display_list_section: DisplayListSection,
clip: Rect<Au>,
overflow_content_size: Option<Size2D<Au>>,
)
pub fn build_display_list( &mut self, state: &mut DisplayListBuildState<'_>, stacking_relative_border_box: Rect<Au>, border_painting_mode: BorderPaintingMode<'_>, display_list_section: DisplayListSection, clip: Rect<Au>, overflow_content_size: Option<Size2D<Au>>, )
Adds the display items for this fragment to the given display list.
Arguments:
state
: The display building state, including the display list currently under construction and other metadata useful for constructing it.dirty
: The dirty rectangle in the coordinate system of the owning flow.clip
: The region to clip the display items to.overflow_content_size
: The size of content associated with this fragment that must have overflow handling applied to it. For a scrollable block flow, it is expected that this is the size of the child boxes.
sourcefn build_display_list_no_damage(
&self,
state: &mut DisplayListBuildState<'_>,
stacking_relative_border_box: Rect<Au>,
border_painting_mode: BorderPaintingMode<'_>,
display_list_section: DisplayListSection,
clip: Rect<Au>,
overflow_content_size: Option<Size2D<Au>>,
)
fn build_display_list_no_damage( &self, state: &mut DisplayListBuildState<'_>, stacking_relative_border_box: Rect<Au>, border_painting_mode: BorderPaintingMode<'_>, display_list_section: DisplayListSection, clip: Rect<Au>, overflow_content_size: Option<Size2D<Au>>, )
build_display_list, but don’t update the restyle damage
Must be paired with a self.restyle_damage.remove(REPAINT) somewhere
sourcefn build_fragment_type_specific_display_items(
&self,
state: &mut DisplayListBuildState<'_>,
stacking_relative_border_box: Rect<Au>,
clip: Rect<Au>,
)
fn build_fragment_type_specific_display_items( &self, state: &mut DisplayListBuildState<'_>, stacking_relative_border_box: Rect<Au>, clip: Rect<Au>, )
A helper method that build_display_list
calls to create per-fragment-type display items.
sourcefn create_stacking_context(
&self,
id: StackingContextId,
base_flow: &BaseFlow,
context_type: StackingContextType,
established_reference_frame: Option<ClipScrollNodeIndex>,
parent_clipping_and_scrolling: ClippingAndScrolling,
) -> StackingContext
fn create_stacking_context( &self, id: StackingContextId, base_flow: &BaseFlow, context_type: StackingContextType, established_reference_frame: Option<ClipScrollNodeIndex>, parent_clipping_and_scrolling: ClippingAndScrolling, ) -> StackingContext
Creates a stacking context for associated fragment.
sourcefn build_display_list_for_text_fragment(
&self,
state: &mut DisplayListBuildState<'_>,
text_fragment: &ScannedTextFragmentInfo,
stacking_relative_content_box: Rect<Au>,
text_shadows: &[SimpleShadow],
clip: Rect<Au>,
)
fn build_display_list_for_text_fragment( &self, state: &mut DisplayListBuildState<'_>, text_fragment: &ScannedTextFragmentInfo, stacking_relative_content_box: Rect<Au>, text_shadows: &[SimpleShadow], clip: Rect<Au>, )
Creates the text display item for one text fragment. This can be called multiple times for one fragment if there are text shadows.
text_shadow
will be Some
if this is rendering a shadow.
sourcefn build_display_list_for_text_decoration(
&self,
state: &mut DisplayListBuildState<'_>,
color: &AbsoluteColor,
stacking_relative_box: &LogicalRect<Au>,
clip: Rect<Au>,
)
fn build_display_list_for_text_decoration( &self, state: &mut DisplayListBuildState<'_>, color: &AbsoluteColor, stacking_relative_box: &LogicalRect<Au>, clip: Rect<Au>, )
Creates the display item for a text decoration: underline, overline, or line-through.
fn unique_id(&self) -> u64
fn fragment_type(&self) -> FragmentType
source§impl Fragment
impl Fragment
sourcepub fn new<'dom>(
node: &impl ThreadSafeLayoutNode<'dom>,
specific: SpecificFragmentInfo,
ctx: &LayoutContext<'_>,
) -> Fragment
pub fn new<'dom>( node: &impl ThreadSafeLayoutNode<'dom>, specific: SpecificFragmentInfo, ctx: &LayoutContext<'_>, ) -> Fragment
Constructs a new Fragment
instance.
sourcepub fn from_opaque_node_and_style(
node: OpaqueNode,
pseudo: PseudoElementType,
style: ServoArc<ComputedValues>,
selected_style: ServoArc<ComputedValues>,
restyle_damage: RestyleDamage,
specific: SpecificFragmentInfo,
) -> Fragment
pub fn from_opaque_node_and_style( node: OpaqueNode, pseudo: PseudoElementType, style: ServoArc<ComputedValues>, selected_style: ServoArc<ComputedValues>, restyle_damage: RestyleDamage, specific: SpecificFragmentInfo, ) -> Fragment
Constructs a new Fragment
instance from an opaque node.
sourcepub fn create_similar_anonymous_fragment(
&self,
style: ServoArc<ComputedValues>,
specific: SpecificFragmentInfo,
) -> Fragment
pub fn create_similar_anonymous_fragment( &self, style: ServoArc<ComputedValues>, specific: SpecificFragmentInfo, ) -> Fragment
Creates an anonymous fragment just like this one but with the given style and fragment type. For the new anonymous fragment, layout-related values (border box, etc.) are reset to initial values.
sourcepub fn transform(
&self,
size: LogicalSize<Au>,
info: SpecificFragmentInfo,
) -> Fragment
pub fn transform( &self, size: LogicalSize<Au>, info: SpecificFragmentInfo, ) -> Fragment
Transforms this fragment into another fragment of the given type, with the given size, preserving all the other data.
sourcepub fn transform_with_split_info(
&self,
split: &SplitInfo,
text_run: Arc<TextRun>,
first: bool,
) -> Fragment
pub fn transform_with_split_info( &self, split: &SplitInfo, text_run: Arc<TextRun>, first: bool, ) -> Fragment
Transforms this fragment using the given SplitInfo
, preserving all the other data.
If this is the first half of a split, first
is true
sourcepub fn transform_into_ellipsis(
&self,
layout_context: &LayoutContext<'_>,
text_overflow_string: String,
) -> Fragment
pub fn transform_into_ellipsis( &self, layout_context: &LayoutContext<'_>, text_overflow_string: String, ) -> Fragment
Transforms this fragment into an ellipsis fragment, preserving all the other data.
pub fn restyle_damage(&self) -> RestyleDamage
pub fn contains_node(&self, node_address: OpaqueNode) -> bool
sourcepub fn add_inline_context_style(&mut self, node_info: InlineFragmentNodeInfo)
pub fn add_inline_context_style(&mut self, node_info: InlineFragmentNodeInfo)
Adds a style to the inline context for this fragment. If the inline context doesn’t exist yet, it will be created.
sourcefn quantities_included_in_intrinsic_inline_size(
&self,
) -> QuantitiesIncludedInIntrinsicInlineSizes
fn quantities_included_in_intrinsic_inline_size( &self, ) -> QuantitiesIncludedInIntrinsicInlineSizes
Determines which quantities (border/padding/margin/specified) should be included in the intrinsic inline size of this fragment.
sourcepub fn surrounding_intrinsic_inline_size(&self) -> (Au, Au)
pub fn surrounding_intrinsic_inline_size(&self) -> (Au, Au)
Returns the portion of the intrinsic inline-size that consists of borders/padding and margins, respectively.
FIXME(#2261, pcwalton): This won’t work well for inlines: is this OK?
sourcepub fn style_specified_intrinsic_inline_size(
&self,
) -> IntrinsicISizesContribution
pub fn style_specified_intrinsic_inline_size( &self, ) -> IntrinsicISizesContribution
Uses the style only to estimate the intrinsic inline-sizes. These may be modified for text or replaced elements.
sourcepub fn intrinsic_width(&self) -> Au
pub fn intrinsic_width(&self) -> Au
intrinsic width of this replaced element.
sourcepub fn intrinsic_height(&self) -> Au
pub fn intrinsic_height(&self) -> Au
intrinsic width of this replaced element.
sourcepub fn has_intrinsic_ratio(&self) -> bool
pub fn has_intrinsic_ratio(&self) -> bool
Whether this replace element has intrinsic aspect ratio.
sourcepub fn calculate_replaced_sizes(
&self,
containing_inline_size: Option<Au>,
containing_block_size: Option<Au>,
) -> (Au, Au)
pub fn calculate_replaced_sizes( &self, containing_inline_size: Option<Au>, containing_block_size: Option<Au>, ) -> (Au, Au)
CSS 2.1 § 10.3.2 & 10.6.2 Calculate the used width and height of a replaced element.
When a parameter is None
it means the specified size in certain direction
is unconstrained. The inline containing size can also be None
since this
method is also used for calculating intrinsic inline size contribution.
sourcepub fn size_constraint(
&self,
containing_size: Option<Au>,
direction: Direction,
) -> SizeConstraint
pub fn size_constraint( &self, containing_size: Option<Au>, direction: Direction, ) -> SizeConstraint
Return a size constraint that can be used the clamp size in given direction.
To take box-sizing: border-box
into account, the border_padding
field
must be initialized first.
TODO(stshine): Maybe there is a more convenient way.
sourcepub fn guess_inline_content_edge_offsets(
&self,
) -> SpeculatedInlineContentEdgeOffsets
pub fn guess_inline_content_edge_offsets( &self, ) -> SpeculatedInlineContentEdgeOffsets
Returns a guess as to the distances from the margin edge of this fragment to its content in the inline direction. This will generally be correct unless percentages are involved.
This is used for the float placement speculation logic.
sourcepub fn border_width(&self) -> LogicalMargin<Au>
pub fn border_width(&self) -> LogicalMargin<Au>
Returns the sum of the inline-sizes of all the borders of this fragment. Note that this
can be expensive to compute, so if possible use the border_padding
field instead.
sourcepub fn box_sizing_boundary(&self, direction: Direction) -> Au
pub fn box_sizing_boundary(&self, direction: Direction) -> Au
Returns the border width in given direction if this fragment has property
‘box-sizing: border-box’. The border_padding
field must have been initialized.
sourcepub fn compute_inline_direction_margins(
&mut self,
containing_block_inline_size: Au,
)
pub fn compute_inline_direction_margins( &mut self, containing_block_inline_size: Au, )
Computes the margins in the inline direction from the containing block inline-size and the
style. After this call, the inline direction of the margin
field will be correct.
Do not use this method if the inline direction margins are to be computed some other way (for example, via constraint solving for blocks).
sourcepub fn compute_block_direction_margins(
&mut self,
containing_block_inline_size: Au,
)
pub fn compute_block_direction_margins( &mut self, containing_block_inline_size: Au, )
Computes the margins in the block direction from the containing block inline-size and the
style. After this call, the block direction of the margin
field will be correct.
Do not use this method if the block direction margins are to be computed some other way (for example, via constraint solving for absolutely-positioned flows).
sourcepub fn compute_border_and_padding(&mut self, containing_block_inline_size: Au)
pub fn compute_border_and_padding(&mut self, containing_block_inline_size: Au)
Computes the border and padding in both inline and block directions from the containing
block inline-size and the style. After this call, the border_padding
field will be
correct.
pub fn relative_position( &self, containing_block_size: &LogicalSize<Au>, ) -> LogicalSize<Au>
sourcepub fn clear(&self) -> Option<ClearType>
pub fn clear(&self) -> Option<ClearType>
Always inline for SCCP.
FIXME(pcwalton): Just replace with the clear type from the style module for speed?
pub fn style(&self) -> &ComputedValues
pub fn selected_style(&self) -> &ComputedValues
pub fn white_space_collapse(&self) -> WhiteSpaceCollapse
pub fn text_wrap_mode(&self) -> TextWrapMode
pub fn color(&self) -> Color
sourcepub fn text_decoration_line(&self) -> TextDecorationLine
pub fn text_decoration_line(&self) -> TextDecorationLine
Returns the text decoration line of this fragment, according to the style of the nearest ancestor element.
NB: This may not be the actual text decoration line, because of the override rules specified in CSS 2.1 § 16.3.1. Unfortunately, computing this properly doesn’t really fit into Servo’s model. Therefore, this is a best lower bound approximation, but the end result may actually have the various decoration flags turned on afterward.
sourcepub fn inline_start_offset(&self) -> Au
pub fn inline_start_offset(&self) -> Au
Returns the inline-start offset from margin edge to content edge.
FIXME(#2262, pcwalton): I think this method is pretty bogus, because it won’t work for inlines.
sourcepub fn column_span(&self) -> u32
pub fn column_span(&self) -> u32
If this is a Column fragment, get the col span
Panics for non-column fragments
sourcepub fn can_split(&self) -> bool
pub fn can_split(&self) -> bool
Returns true if this element can be split. This is true for text fragments, unless
white-space: pre
or white-space: nowrap
is set.
sourcepub fn is_unscanned_generated_content(&self) -> bool
pub fn is_unscanned_generated_content(&self) -> bool
Returns true if and only if this fragment is a generated content fragment.
sourcepub fn is_scanned_text_fragment(&self) -> bool
pub fn is_scanned_text_fragment(&self) -> bool
Returns true if and only if this is a scanned text fragment.
pub fn suppress_line_break_before(&self) -> bool
sourcepub fn compute_intrinsic_inline_sizes(&mut self) -> IntrinsicISizesContribution
pub fn compute_intrinsic_inline_sizes(&mut self) -> IntrinsicISizesContribution
Computes the intrinsic inline-sizes of this fragment.
sourcepub fn minimum_splittable_inline_size(&self) -> Au
pub fn minimum_splittable_inline_size(&self) -> Au
Returns the narrowest inline-size that the first splittable part of this fragment could possibly be split to. (In most cases, this returns the inline-size of the first word in this fragment.)
sourcepub fn content_box(&self) -> LogicalRect<Au>
pub fn content_box(&self) -> LogicalRect<Au>
Returns the dimensions of the content box.
This is marked #[inline]
because it is frequently called when only one or two of the
values are needed and that will save computation.
sourcepub fn calculate_split_position(
&self,
max_inline_size: Au,
starts_line: bool,
) -> Option<SplitResult>
pub fn calculate_split_position( &self, max_inline_size: Au, starts_line: bool, ) -> Option<SplitResult>
Attempts to find the split positions of a text fragment so that its inline-size is no more
than max_inline_size
.
A return value of None
indicates that the fragment could not be split. Otherwise the
information pertaining to the split is returned. The inline-start and inline-end split
information are both optional due to the possibility of them being whitespace.
sourcepub fn is_on_glyph_run_boundary(&self) -> bool
pub fn is_on_glyph_run_boundary(&self) -> bool
Does this fragment start on a glyph run boundary?
sourcepub fn truncate_to_inline_size(self, max_inline_size: Au) -> Fragment
pub fn truncate_to_inline_size(self, max_inline_size: Au) -> Fragment
Truncates this fragment to the given max_inline_size
, using a character-based breaking
strategy. The resulting fragment will have SpecificFragmentInfo::TruncatedFragment
,
preserving the original fragment for use in incremental reflow.
This function will panic if self is already truncated.
sourcefn calculate_truncate_to_inline_size(
&self,
max_inline_size: Au,
) -> Option<TruncationResult>
fn calculate_truncate_to_inline_size( &self, max_inline_size: Au, ) -> Option<TruncationResult>
Truncates this fragment to the given max_inline_size
, using a character-based breaking
strategy. If no characters could fit, returns None
.
sourcefn calculate_split_position_using_breaking_strategy<'a, I>(
&self,
slice_iterator: I,
max_inline_size: Au,
flags: SplitOptions,
) -> Option<SplitResult>where
I: Iterator<Item = TextRunSlice<'a>>,
fn calculate_split_position_using_breaking_strategy<'a, I>(
&self,
slice_iterator: I,
max_inline_size: Au,
flags: SplitOptions,
) -> Option<SplitResult>where
I: Iterator<Item = TextRunSlice<'a>>,
A helper method that uses the breaking strategy described by slice_iterator
(at present,
either natural word breaking or character breaking) to split this fragment.
sourcepub fn merge_with(&mut self, next_fragment: Fragment)
pub fn merge_with(&mut self, next_fragment: Fragment)
The opposite of calculate_split_position_using_breaking_strategy
: merges this fragment
with the next one.
sourcepub fn reset_text_range_and_inline_size(&mut self)
pub fn reset_text_range_and_inline_size(&mut self)
Restore any whitespace that was stripped from a text fragment, and recompute inline metrics if necessary.
sourcepub fn assign_replaced_inline_size_if_necessary(
&mut self,
container_inline_size: Au,
container_block_size: Option<Au>,
)
pub fn assign_replaced_inline_size_if_necessary( &mut self, container_inline_size: Au, container_block_size: Option<Au>, )
Assigns replaced inline-size, padding, and margins for this fragment only if it is replaced content per CSS 2.1 § 10.3.2.
sourcepub fn assign_replaced_block_size_if_necessary(&mut self)
pub fn assign_replaced_block_size_if_necessary(&mut self)
Assign block-size for this fragment if it is replaced content. The inline-size must have been assigned first.
Ideally, this should follow CSS 2.1 § 10.6.2.
sourcepub fn is_replaced(&self) -> bool
pub fn is_replaced(&self) -> bool
Returns true if this fragment is replaced content.
sourcepub fn is_replaced_or_inline_block(&self) -> bool
pub fn is_replaced_or_inline_block(&self) -> bool
Returns true if this fragment is replaced content or an inline-block or false otherwise.
sourcefn content_inline_metrics(
&self,
layout_context: &LayoutContext<'_>,
) -> InlineMetrics
fn content_inline_metrics( &self, layout_context: &LayoutContext<'_>, ) -> InlineMetrics
Calculates block-size above baseline, depth below baseline, and ascent for this fragment when used in an inline formatting context. See CSS 2.1 § 10.8.1.
This does not take vertical-align
into account. For that, use aligned_inline_metrics()
.
sourcefn vertical_alignment_offset(
&self,
layout_context: &LayoutContext<'_>,
content_inline_metrics: &InlineMetrics,
minimum_line_metrics: &LineMetrics,
actual_line_metrics: Option<&LineMetrics>,
) -> Au
fn vertical_alignment_offset( &self, layout_context: &LayoutContext<'_>, content_inline_metrics: &InlineMetrics, minimum_line_metrics: &LineMetrics, actual_line_metrics: Option<&LineMetrics>, ) -> Au
Calculates the offset from the baseline that applies to this fragment due to
vertical-align
. Positive values represent downward displacement.
If actual_line_metrics
is supplied, then these metrics are used to determine the
displacement of the fragment when top
or bottom
vertical-align
values are
encountered. If this is not supplied, then top
and bottom
values are ignored.
sourcepub fn aligned_inline_metrics(
&self,
layout_context: &LayoutContext<'_>,
minimum_line_metrics: &LineMetrics,
actual_line_metrics: Option<&LineMetrics>,
) -> InlineMetrics
pub fn aligned_inline_metrics( &self, layout_context: &LayoutContext<'_>, minimum_line_metrics: &LineMetrics, actual_line_metrics: Option<&LineMetrics>, ) -> InlineMetrics
Calculates block-size above baseline, depth below baseline, and ascent for this fragment
when used in an inline formatting context, taking vertical-align
(other than top
or
bottom
) into account. See CSS 2.1 § 10.8.1.
If actual_line_metrics
is supplied, then these metrics are used to determine the
displacement of the fragment when top
or bottom
vertical-align
values are
encountered. If this is not supplied, then top
and bottom
values are ignored.
sourcepub fn is_hypothetical(&self) -> bool
pub fn is_hypothetical(&self) -> bool
Returns true if this fragment is a hypothetical box. See CSS 2.1 § 10.3.7.
sourcepub fn can_merge_with_fragment(&self, other: &Fragment) -> bool
pub fn can_merge_with_fragment(&self, other: &Fragment) -> bool
Returns true if this fragment can merge with another immediately-following fragment or false otherwise.
sourcepub fn is_primary_fragment(&self) -> bool
pub fn is_primary_fragment(&self) -> bool
Returns true if and only if this is the primary fragment for the fragment’s style object (conceptually, though style sharing makes this not really true, of course). The primary fragment is the one that draws backgrounds, borders, etc., and takes borders, padding and margins into account. Every style object has at most one primary fragment.
At present, all fragments are primary fragments except for inline-block and table wrapper fragments. Inline-block fragments are not primary fragments because the corresponding block flow is the primary fragment, while table wrapper fragments are not primary fragments because the corresponding table flow is the primary fragment.
sourcepub fn update_late_computed_replaced_inline_size_if_necessary(&mut self)
pub fn update_late_computed_replaced_inline_size_if_necessary(&mut self)
Determines the inline sizes of inline-block fragments. These cannot be fully computed until inline size assignment has run for the child flow: thus it is computed “late”, during block size assignment.
pub fn update_late_computed_inline_position_if_necessary(&mut self)
pub fn update_late_computed_block_position_if_necessary(&mut self)
pub fn repair_style(&mut self, new_style: &ServoArc<ComputedValues>)
sourcepub fn stacking_relative_border_box(
&self,
stacking_relative_flow_origin: &Vector2D<Au>,
relative_containing_block_size: &LogicalSize<Au>,
relative_containing_block_mode: WritingMode,
coordinate_system: CoordinateSystem,
) -> Rect<Au>
pub fn stacking_relative_border_box( &self, stacking_relative_flow_origin: &Vector2D<Au>, relative_containing_block_size: &LogicalSize<Au>, relative_containing_block_mode: WritingMode, coordinate_system: CoordinateSystem, ) -> Rect<Au>
Given the stacking-context-relative position of the containing flow, returns the border box
of this fragment relative to the parent stacking context. This takes position: relative
into account.
If coordinate_system
is Parent
, this returns the border box in the parent stacking
context’s coordinate system. Otherwise, if coordinate_system
is Own
and this fragment
establishes a stacking context itself, this returns a border box anchored at (0, 0). (If
this fragment does not establish a stacking context, then it always belongs to its parent
stacking context and thus coordinate_system
is ignored.)
This is the method you should use for display list construction as well as
getBoundingClientRect()
and so forth.
sourcepub fn stacking_relative_content_box(
&self,
stacking_relative_border_box: Rect<Au>,
) -> Rect<Au>
pub fn stacking_relative_content_box( &self, stacking_relative_border_box: Rect<Au>, ) -> Rect<Au>
Given the stacking-context-relative border box, returns the stacking-context-relative content box.
sourcepub fn can_establish_reference_frame(&self) -> bool
pub fn can_establish_reference_frame(&self) -> bool
Returns true if this fragment may establish a reference frame.
sourcepub fn has_filter_transform_or_perspective(&self) -> bool
pub fn has_filter_transform_or_perspective(&self) -> bool
Returns true if this fragment has a filter, transform, or perspective property set.
sourcepub fn has_non_invertible_transform_or_zero_scale(&self) -> bool
pub fn has_non_invertible_transform_or_zero_scale(&self) -> bool
Returns true if this fragment has a transform applied that causes it to take up no space.
sourcepub fn establishes_stacking_context(&self) -> bool
pub fn establishes_stacking_context(&self) -> bool
Returns true if this fragment establishes a new stacking context and false otherwise.
pub fn effective_z_index(&self) -> i32
sourcepub fn compute_overflow(
&self,
flow_size: &Size2D<Au>,
relative_containing_block_size: &LogicalSize<Au>,
) -> Overflow
pub fn compute_overflow( &self, flow_size: &Size2D<Au>, relative_containing_block_size: &LogicalSize<Au>, ) -> Overflow
Computes the overflow rect of this fragment relative to the start of the flow.
pub fn requires_line_break_afterward_if_wrapping_on_newlines(&self) -> bool
pub fn strip_leading_whitespace_if_necessary( &mut self, ) -> WhitespaceStrippingResult
sourcepub fn strip_trailing_whitespace_if_necessary(
&mut self,
) -> WhitespaceStrippingResult
pub fn strip_trailing_whitespace_if_necessary( &mut self, ) -> WhitespaceStrippingResult
Returns true if the entire fragment was stripped.
pub fn inline_styles(&self) -> InlineStyleIterator<'_> ⓘ
sourcepub fn margin_box_inline_size(&self) -> Au
pub fn margin_box_inline_size(&self) -> Au
Returns the inline-size of this fragment’s margin box.
sourcepub fn is_positioned(&self) -> bool
pub fn is_positioned(&self) -> bool
Returns true if this node or any of the nodes within its inline fragment context have
non-static
position
.
sourcepub fn is_absolutely_positioned(&self) -> bool
pub fn is_absolutely_positioned(&self) -> bool
Returns true if this node is absolutely positioned.
pub fn is_inline_absolute(&self) -> bool
pub fn meld_with_next_inline_fragment(&mut self, next_fragment: &Fragment)
pub fn meld_with_prev_inline_fragment(&mut self, prev_fragment: &Fragment)
sourcepub fn is_vertically_aligned_to_top_or_bottom(&self) -> bool
pub fn is_vertically_aligned_to_top_or_bottom(&self) -> bool
Returns true if any of the inline styles associated with this fragment have
vertical-align
set to top
or bottom
.
pub fn is_text_or_replaced(&self) -> bool
sourcepub fn transform_matrix(
&self,
stacking_relative_border_box: &Rect<Au>,
) -> Option<LayoutTransform>
pub fn transform_matrix( &self, stacking_relative_border_box: &Rect<Au>, ) -> Option<LayoutTransform>
Returns the 4D matrix representing this fragment’s transform.
sourcepub fn perspective_matrix(
&self,
stacking_relative_border_box: &Rect<Au>,
) -> Option<LayoutTransform>
pub fn perspective_matrix( &self, stacking_relative_border_box: &Rect<Au>, ) -> Option<LayoutTransform>
Returns the 4D matrix representing this fragment’s perspective.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Fragment
impl !RefUnwindSafe for Fragment
impl Send for Fragment
impl Sync for Fragment
impl Unpin for Fragment
impl !UnwindSafe for Fragment
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