pub trait ThreadSafeLayoutNode<'dom>: Clone + Copy + Debug + NodeInfo + PartialEq + Sized {
type ConcreteNode: LayoutNode<'dom, ConcreteThreadSafeLayoutNode = Self>;
type ConcreteElement: TElement;
type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<'dom, ConcreteThreadSafeLayoutNode = Self> + Element<Impl = SelectorImpl>;
type ChildrenIterator: Iterator<Item = Self> + Sized;
Show 33 methods
// Required methods
fn opaque(&self) -> OpaqueNode;
fn type_id(&self) -> Option<LayoutNodeType>;
fn parent_style(&self) -> Arc<ComputedValues>;
fn debug_id(self) -> usize;
fn children(&self) -> LayoutIterator<Self::ChildrenIterator>;
fn as_element(&self) -> Option<Self::ConcreteThreadSafeLayoutElement>;
fn as_html_element(&self) -> Option<Self::ConcreteThreadSafeLayoutElement>;
fn style_data(&self) -> Option<&'dom StyleData>;
fn layout_data(&self) -> Option<&'dom GenericLayoutData>;
fn is_ignorable_whitespace(&self, context: &SharedStyleContext<'_>) -> bool;
fn unsafe_get(self) -> Self::ConcreteNode;
fn node_text_content(self) -> Cow<'dom, str>;
fn selection(&self) -> Option<Range<ByteIndex>>;
fn image_url(&self) -> Option<ServoUrl>;
fn image_density(&self) -> Option<f64>;
fn image_data(
&self,
) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)>;
fn canvas_data(&self) -> Option<HTMLCanvasData>;
fn svg_data(&self) -> Option<SVGSVGData>;
fn media_data(&self) -> Option<HTMLMediaData>;
fn iframe_browsing_context_id(&self) -> Option<BrowsingContextId>;
fn iframe_pipeline_id(&self) -> Option<PipelineId>;
fn get_span(&self) -> Option<u32>;
fn get_colspan(&self) -> Option<u32>;
fn get_rowspan(&self) -> Option<u32>;
// Provided methods
fn get_before_pseudo(&self) -> Option<Self> { ... }
fn get_after_pseudo(&self) -> Option<Self> { ... }
fn get_details_summary_pseudo(&self) -> Option<Self> { ... }
fn get_details_content_pseudo(&self) -> Option<Self> { ... }
fn get_pseudo_element_type(&self) -> PseudoElementType { ... }
fn style(&self, context: &SharedStyleContext<'_>) -> Arc<ComputedValues> { ... }
fn selected_style(&self) -> Arc<ComputedValues> { ... }
fn is_content(&self) -> bool { ... }
fn fragment_type(&self) -> FragmentType { ... }
}
Expand description
A thread-safe version of LayoutNode
, used during flow construction. This type of layout
node does not allow any parents or siblings of nodes to be accessed, to avoid races.
Required Associated Types§
type ConcreteNode: LayoutNode<'dom, ConcreteThreadSafeLayoutNode = Self>
type ConcreteElement: TElement
type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<'dom, ConcreteThreadSafeLayoutNode = Self> + Element<Impl = SelectorImpl>
type ChildrenIterator: Iterator<Item = Self> + Sized
Required Methods§
sourcefn opaque(&self) -> OpaqueNode
fn opaque(&self) -> OpaqueNode
Converts self into an OpaqueNode
.
sourcefn type_id(&self) -> Option<LayoutNodeType>
fn type_id(&self) -> Option<LayoutNodeType>
Returns the type ID of this node.
Returns None
if this is a pseudo-element; otherwise, returns Some
.
sourcefn parent_style(&self) -> Arc<ComputedValues>
fn parent_style(&self) -> Arc<ComputedValues>
Returns the style for a text node. This is computed on the fly from the parent style to avoid traversing text nodes in the style system.
Note that this does require accessing the parent, which this interface technically forbids. But accessing the parent is only unsafe insofar as it can be used to reach siblings and cousins. A simple immutable borrow of the parent data is fine, since the bottom-up traversal will not process the parent until all the children have been processed.
fn debug_id(self) -> usize
sourcefn children(&self) -> LayoutIterator<Self::ChildrenIterator>
fn children(&self) -> LayoutIterator<Self::ChildrenIterator>
Returns an iterator over this node’s children.
sourcefn as_element(&self) -> Option<Self::ConcreteThreadSafeLayoutElement>
fn as_element(&self) -> Option<Self::ConcreteThreadSafeLayoutElement>
Returns a ThreadSafeLayoutElement if this is an element, None otherwise.
sourcefn as_html_element(&self) -> Option<Self::ConcreteThreadSafeLayoutElement>
fn as_html_element(&self) -> Option<Self::ConcreteThreadSafeLayoutElement>
Returns a ThreadSafeLayoutElement if this is an element in an HTML namespace, None otherwise.
sourcefn style_data(&self) -> Option<&'dom StyleData>
fn style_data(&self) -> Option<&'dom StyleData>
Get the StyleData
for this node. Returns None if the node is unstyled.
sourcefn layout_data(&self) -> Option<&'dom GenericLayoutData>
fn layout_data(&self) -> Option<&'dom GenericLayoutData>
Get the layout data of this node, attempting to downcast it to the desired type. Returns None if there is no layout data or it isn’t of the desired type.
fn is_ignorable_whitespace(&self, context: &SharedStyleContext<'_>) -> bool
sourcefn unsafe_get(self) -> Self::ConcreteNode
fn unsafe_get(self) -> Self::ConcreteNode
Returns access to the underlying LayoutNode. This is breaks the abstraction barrier of ThreadSafeLayout wrapper layer, and can lead to races if not used carefully.
We need this because the implementation of some methods need to access the layout data flags, and we have this annoying trait separation between script and layout :-(
fn node_text_content(self) -> Cow<'dom, str>
sourcefn selection(&self) -> Option<Range<ByteIndex>>
fn selection(&self) -> Option<Range<ByteIndex>>
If the insertion point is within this node, returns it. Otherwise, returns None
.
sourcefn image_url(&self) -> Option<ServoUrl>
fn image_url(&self) -> Option<ServoUrl>
If this is an image element, returns its URL. If this is not an image element, fails.
sourcefn image_density(&self) -> Option<f64>
fn image_density(&self) -> Option<f64>
If this is an image element, returns its current-pixel-density. If this is not an image element, fails.
sourcefn image_data(&self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)>
fn image_data(&self) -> Option<(Option<StdArc<Image>>, Option<ImageMetadata>)>
If this is an image element, returns its image data. Otherwise, returns None
.
fn canvas_data(&self) -> Option<HTMLCanvasData>
fn svg_data(&self) -> Option<SVGSVGData>
fn media_data(&self) -> Option<HTMLMediaData>
sourcefn iframe_browsing_context_id(&self) -> Option<BrowsingContextId>
fn iframe_browsing_context_id(&self) -> Option<BrowsingContextId>
If this node is an iframe element, returns its browsing context ID. If this node is not an iframe element, fails. Returns None if there is no nested browsing context.
sourcefn iframe_pipeline_id(&self) -> Option<PipelineId>
fn iframe_pipeline_id(&self) -> Option<PipelineId>
If this node is an iframe element, returns its pipeline ID. If this node is not an iframe element, fails. Returns None if there is no nested browsing context.
fn get_span(&self) -> Option<u32>
fn get_colspan(&self) -> Option<u32>
fn get_rowspan(&self) -> Option<u32>
Provided Methods§
fn get_before_pseudo(&self) -> Option<Self>
fn get_after_pseudo(&self) -> Option<Self>
fn get_details_summary_pseudo(&self) -> Option<Self>
fn get_details_content_pseudo(&self) -> Option<Self>
fn get_pseudo_element_type(&self) -> PseudoElementType
fn style(&self, context: &SharedStyleContext<'_>) -> Arc<ComputedValues>
fn selected_style(&self) -> Arc<ComputedValues>
sourcefn is_content(&self) -> bool
fn is_content(&self) -> bool
Returns true if this node contributes content. This is used in the implementation of
empty_cells
per CSS 2.1 § 17.6.1.1.