pub struct BaseDocument {
pub net_provider: Arc<dyn NetProvider<Resource>>,
pub navigation_provider: Arc<dyn NavigationProvider>,
pub shell_provider: Arc<dyn ShellProvider>,
pub html_parser_provider: Arc<dyn HtmlParserProvider>,
/* private fields */
}Fields§
§net_provider: Arc<dyn NetProvider<Resource>>Network provider. Can be used to fetch assets.
Navigation provider. Can be used to navigate to a new page (bubbles up the event on e.g. clicking a Link)
shell_provider: Arc<dyn ShellProvider>Shell provider. Can be used to request a redraw or set the cursor icon
html_parser_provider: Arc<dyn HtmlParserProvider>HTML parser provider. Used to parse HTML for setInnerHTML
Implementations§
Source§impl BaseDocument
impl BaseDocument
Sourcepub fn new(config: DocumentConfig) -> Self
pub fn new(config: DocumentConfig) -> Self
Create a new (empty) BaseDocument with the specified configuration
Sourcepub fn set_net_provider(&mut self, net_provider: SharedProvider<Resource>)
pub fn set_net_provider(&mut self, net_provider: SharedProvider<Resource>)
Set the Document’s networking provider
Set the Document’s navigation provider
Sourcepub fn set_shell_provider(&mut self, shell_provider: Arc<dyn ShellProvider>)
pub fn set_shell_provider(&mut self, shell_provider: Arc<dyn ShellProvider>)
Set the Document’s shell provider
Sourcepub fn set_html_parser_provider(
&mut self,
html_parser_provider: Arc<dyn HtmlParserProvider>,
)
pub fn set_html_parser_provider( &mut self, html_parser_provider: Arc<dyn HtmlParserProvider>, )
Set the Document’s html parser provider
Sourcepub fn set_base_url(&mut self, url: &str)
pub fn set_base_url(&mut self, url: &str)
Set base url for resolving linked resources (stylesheets, images, fonts, etc)
pub fn guard(&self) -> &SharedRwLock
pub fn tree(&self) -> &Slab<Node>
pub fn id(&self) -> usize
pub fn get_node(&self, node_id: usize) -> Option<&Node>
pub fn get_node_mut(&mut self, node_id: usize) -> Option<&mut Node>
pub fn get_focussed_node_id(&self) -> Option<usize>
pub fn mutate<'doc>(&'doc mut self) -> DocumentMutator<'doc>
pub fn handle_dom_event<F: FnMut(DomEvent)>( &mut self, event: &mut DomEvent, dispatch_event: F, )
pub fn as_any_mut(&mut self) -> &mut dyn Any
Sourcepub fn label_bound_input_element(&self, label_node_id: usize) -> Option<&Node>
pub fn label_bound_input_element(&self, label_node_id: usize) -> Option<&Node>
Find the label’s bound input elements: the element id referenced by the “for” attribute of a given label element or the first input element which is nested in the label Note that although there should only be one bound element, we return all possibilities instead of just the first in order to allow the caller to decide which one is correct
pub fn toggle_checkbox(el: &mut ElementData) -> bool
pub fn toggle_radio(&mut self, radio_set_name: String, target_radio_id: usize)
pub fn set_style_property(&mut self, node_id: usize, name: &str, value: &str)
pub fn remove_style_property(&mut self, node_id: usize, name: &str)
pub fn root_node(&self) -> &Node
pub fn root_node_mut(&mut self) -> &mut Node
pub fn try_root_element(&self) -> Option<&Node>
pub fn root_element(&self) -> &Node
pub fn create_node(&mut self, node_data: NodeData) -> usize
Sourcepub fn has_changes(&self) -> bool
pub fn has_changes(&self) -> bool
Whether the document has been mutated
pub fn create_text_node(&mut self, text: &str) -> usize
pub fn deep_clone_node(&mut self, node_id: usize) -> usize
pub fn print_tree(&self)
pub fn print_subtree(&self, node_id: usize)
pub fn reload_resource_by_href(&mut self, href_to_reload: &str)
pub fn process_style_element(&mut self, target_id: usize)
pub fn remove_user_agent_stylesheet(&mut self, contents: &str)
pub fn add_user_agent_stylesheet(&mut self, css: &str)
pub fn make_stylesheet( &self, css: impl AsRef<str>, origin: Origin, ) -> DocumentStyleSheet
pub fn upsert_stylesheet_for_node(&mut self, node_id: usize)
pub fn add_stylesheet_for_node( &mut self, stylesheet: DocumentStyleSheet, node_id: usize, )
pub fn load_resource(&mut self, resource: Resource)
pub fn snapshot_node(&mut self, node_id: usize)
pub fn snapshot_node_and(&mut self, node_id: usize, cb: impl FnOnce(&mut Node))
Sourcepub fn resolve(&mut self, current_time_for_animations: f64)
pub fn resolve(&mut self, current_time_for_animations: f64)
Restyle the tree and then relayout it
pub fn hit(&self, x: f32, y: f32) -> Option<HitResult>
pub fn focus_next_node(&mut self) -> Option<usize>
Sourcepub fn clear_focus(&mut self)
pub fn clear_focus(&mut self)
Clear the focussed node
pub fn set_mousedown_node_id(&mut self, node_id: Option<usize>)
pub fn set_focus_to(&mut self, focus_node_id: usize) -> bool
pub fn active_node(&mut self) -> bool
pub fn unactive_node(&mut self) -> bool
pub fn set_hover_to(&mut self, x: f32, y: f32) -> bool
pub fn get_hover_node_id(&self) -> Option<usize>
pub fn set_viewport(&mut self, viewport: Viewport)
pub fn viewport(&self) -> &Viewport
pub fn viewport_mut(&mut self) -> ViewportMut<'_>
pub fn zoom_by(&mut self, increment: f32)
pub fn zoom_to(&mut self, zoom: f32)
pub fn get_viewport(&self) -> Viewport
pub fn devtools(&self) -> &DevtoolSettings
pub fn devtools_mut(&mut self) -> &mut DevtoolSettings
pub fn is_animating(&self) -> bool
Sourcepub fn set_stylist_device(&mut self, device: Device)
pub fn set_stylist_device(&mut self, device: Device)
Update the device and reset the stylist to process the new size
pub fn stylist_device(&mut self) -> &Device
Sourcepub fn resolve_layout_children(&mut self)
pub fn resolve_layout_children(&mut self)
Ensure that the layout_children field is populated for all nodes
pub fn resolve_deferred_tasks(&mut self)
Sourcepub fn resolve_layout(&mut self)
pub fn resolve_layout(&mut self)
Walk the nodes now that they’re properly styled and transfer their styles to the taffy style system
TODO: update taffy to use an associated type instead of slab key TODO: update taffy to support traited styles so we don’t even need to rely on taffy for storage
pub fn get_cursor(&self) -> Option<CursorIcon>
pub fn scroll_node_by(&mut self, node_id: usize, x: f64, y: f64)
Sourcepub fn scroll_node_by_has_changed(
&mut self,
node_id: usize,
x: f64,
y: f64,
) -> bool
pub fn scroll_node_by_has_changed( &mut self, node_id: usize, x: f64, y: f64, ) -> bool
Scroll a node by given x and y Will bubble scrolling up to parent node once it can no longer scroll further If we’re already at the root node, bubbles scrolling up to the viewport
pub fn scroll_viewport_by(&mut self, x: f64, y: f64)
Sourcepub fn scroll_viewport_by_has_changed(&mut self, x: f64, y: f64) -> bool
pub fn scroll_viewport_by_has_changed(&mut self, x: f64, y: f64) -> bool
Scroll the viewport by the given values
pub fn viewport_scroll(&self) -> Point<f64>
pub fn set_viewport_scroll(&mut self, scroll: Point<f64>)
pub fn find_title_node(&self) -> Option<&Node>
Source§impl BaseDocument
impl BaseDocument
pub fn print_taffy_tree(&self)
pub fn debug_log_node(&self, node_id: usize)
Source§impl BaseDocument
impl BaseDocument
Sourcepub fn reset_form_owner(&mut self, node_id: usize)
pub fn reset_form_owner(&mut self, node_id: usize)
Resets the form owner for a given node by either using an explicit form attribute or finding the nearest ancestor form element
§Arguments
node_id- The ID of the node whose form owner needs to be reset
https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#reset-the-form-owner
Sourcepub fn submit_form(&self, node_id: usize, submitter_id: usize)
pub fn submit_form(&self, node_id: usize, submitter_id: usize)
Submits a form with the given form node ID and submitter node ID
§Arguments
node_id- The ID of the form node to submitsubmitter_id- The ID of the node that triggered the submission
https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-algorithm
Source§impl BaseDocument
impl BaseDocument
Sourcepub fn flush_styles_to_layout(&mut self, node_id: usize)
pub fn flush_styles_to_layout(&mut self, node_id: usize)
Walk the whole tree, converting styles to layout
Source§impl BaseDocument
impl BaseDocument
Sourcepub fn get_element_by_id(&self, id: &str) -> Option<usize>
pub fn get_element_by_id(&self, id: &str) -> Option<usize>
Find the node with the specified id attribute (if one exists)
Sourcepub fn query_selector<'input>(
&self,
selector: &'input str,
) -> Result<Option<usize>, ParseError<'input>>
pub fn query_selector<'input>( &self, selector: &'input str, ) -> Result<Option<usize>, ParseError<'input>>
Find the first node that matches the selector specified as a string Returns:
- Err(_) if parsing the selector fails
- Ok(None) if nothing matches
- Ok(Some(node_id)) with the first node ID that matches if one is found
Sourcepub fn query_selector_raw(
&self,
selector_list: &SelectorList<SelectorImpl>,
) -> Option<usize>
pub fn query_selector_raw( &self, selector_list: &SelectorList<SelectorImpl>, ) -> Option<usize>
Find the first node that matches the selector(s) specified in selector_list
Sourcepub fn query_selector_all<'input>(
&self,
selector: &'input str,
) -> Result<SmallVec<[usize; 32]>, ParseError<'input>>
pub fn query_selector_all<'input>( &self, selector: &'input str, ) -> Result<SmallVec<[usize; 32]>, ParseError<'input>>
Find all nodes that match the selector specified as a string Returns:
Err(_)if parsing the selector failsOk(SmallVec<usize>)with all matching nodes otherwise
Sourcepub fn query_selector_all_raw(
&self,
selector_list: &SelectorList<SelectorImpl>,
) -> SmallVec<[usize; 32]>
pub fn query_selector_all_raw( &self, selector_list: &SelectorList<SelectorImpl>, ) -> SmallVec<[usize; 32]>
Find all nodes that match the selector(s) specified in selector_list
pub fn try_parse_selector_list<'input>( &self, input: &'input str, ) -> Result<SelectorList<SelectorImpl>, ParseError<'input>>
Source§impl BaseDocument
impl BaseDocument
pub fn resolve_stylist(&mut self, now: f64)
Source§impl BaseDocument
impl BaseDocument
Sourcepub fn node_chain(&self, node_id: usize) -> Vec<usize>
pub fn node_chain(&self, node_id: usize) -> Vec<usize>
Collect the nodes into a chain by traversing upwards
pub fn visit<F>(&self, visit: F)
Sourcepub fn non_anon_ancestor_if_anon(&self, node_id: usize) -> usize
pub fn non_anon_ancestor_if_anon(&self, node_id: usize) -> usize
If the node is non-anonymous then returns the node’s id Else find’s the first non-anonymous ancester of the node
pub fn iter_children_mut( &mut self, node_id: usize, cb: impl FnMut(usize, &mut BaseDocument), )
pub fn iter_subtree_mut( &mut self, node_id: usize, cb: impl FnMut(usize, &mut BaseDocument), )
pub fn iter_children_and_pseudos_mut( &mut self, node_id: usize, cb: impl FnMut(usize, &mut BaseDocument), )
pub fn next_node( &self, start: &Node, filter: impl FnMut(&Node) -> bool, ) -> Option<usize>
pub fn node_layout_ancestors(&self, node_id: usize) -> Vec<usize>
pub fn maybe_node_layout_ancestors(&self, node_id: Option<usize>) -> Vec<usize>
Source§impl BaseDocument
impl BaseDocument
pub fn build_accessibility_tree(&self) -> TreeUpdate
Trait Implementations§
Source§impl AsMut<BaseDocument> for BaseDocument
impl AsMut<BaseDocument> for BaseDocument
Source§fn as_mut(&mut self) -> &mut BaseDocument
fn as_mut(&mut self) -> &mut BaseDocument
Source§impl AsRef<BaseDocument> for BaseDocument
impl AsRef<BaseDocument> for BaseDocument
Source§fn as_ref(&self) -> &BaseDocument
fn as_ref(&self) -> &BaseDocument
Source§impl CacheTree for BaseDocument
impl CacheTree for BaseDocument
Source§fn cache_get(
&self,
node_id: NodeId,
known_dimensions: Size<Option<f32>>,
available_space: Size<AvailableSpace>,
run_mode: RunMode,
) -> Option<LayoutOutput>
fn cache_get( &self, node_id: NodeId, known_dimensions: Size<Option<f32>>, available_space: Size<AvailableSpace>, run_mode: RunMode, ) -> Option<LayoutOutput>
Source§fn cache_store(
&mut self,
node_id: NodeId,
known_dimensions: Size<Option<f32>>,
available_space: Size<AvailableSpace>,
run_mode: RunMode,
layout_output: LayoutOutput,
)
fn cache_store( &mut self, node_id: NodeId, known_dimensions: Size<Option<f32>>, available_space: Size<AvailableSpace>, run_mode: RunMode, layout_output: LayoutOutput, )
Source§fn cache_clear(&mut self, node_id: NodeId)
fn cache_clear(&mut self, node_id: NodeId)
Source§impl LayoutBlockContainer for BaseDocument
impl LayoutBlockContainer for BaseDocument
Source§type BlockContainerStyle<'a> = &'a Style<Atom<AtomStaticSet>>
where
Self: 'a
type BlockContainerStyle<'a> = &'a Style<Atom<AtomStaticSet>> where Self: 'a
Source§type BlockItemStyle<'a> = &'a Style<Atom<AtomStaticSet>>
where
Self: 'a
type BlockItemStyle<'a> = &'a Style<Atom<AtomStaticSet>> where Self: 'a
Source§fn get_block_container_style(
&self,
node_id: NodeId,
) -> Self::BlockContainerStyle<'_>
fn get_block_container_style( &self, node_id: NodeId, ) -> Self::BlockContainerStyle<'_>
Source§fn get_block_child_style(
&self,
child_node_id: NodeId,
) -> Self::BlockItemStyle<'_>
fn get_block_child_style( &self, child_node_id: NodeId, ) -> Self::BlockItemStyle<'_>
Source§impl LayoutFlexboxContainer for BaseDocument
impl LayoutFlexboxContainer for BaseDocument
Source§type FlexboxContainerStyle<'a> = &'a Style<Atom<AtomStaticSet>>
where
Self: 'a
type FlexboxContainerStyle<'a> = &'a Style<Atom<AtomStaticSet>> where Self: 'a
Source§type FlexboxItemStyle<'a> = &'a Style<Atom<AtomStaticSet>>
where
Self: 'a
type FlexboxItemStyle<'a> = &'a Style<Atom<AtomStaticSet>> where Self: 'a
Source§fn get_flexbox_container_style(
&self,
node_id: NodeId,
) -> Self::FlexboxContainerStyle<'_>
fn get_flexbox_container_style( &self, node_id: NodeId, ) -> Self::FlexboxContainerStyle<'_>
Source§fn get_flexbox_child_style(
&self,
child_node_id: NodeId,
) -> Self::FlexboxItemStyle<'_>
fn get_flexbox_child_style( &self, child_node_id: NodeId, ) -> Self::FlexboxItemStyle<'_>
Source§impl LayoutGridContainer for BaseDocument
impl LayoutGridContainer for BaseDocument
Source§type GridContainerStyle<'a> = &'a Style<Atom<AtomStaticSet>>
where
Self: 'a
type GridContainerStyle<'a> = &'a Style<Atom<AtomStaticSet>> where Self: 'a
Source§type GridItemStyle<'a> = &'a Style<Atom<AtomStaticSet>>
where
Self: 'a
type GridItemStyle<'a> = &'a Style<Atom<AtomStaticSet>> where Self: 'a
Source§fn get_grid_container_style(
&self,
node_id: NodeId,
) -> Self::GridContainerStyle<'_>
fn get_grid_container_style( &self, node_id: NodeId, ) -> Self::GridContainerStyle<'_>
Source§fn get_grid_child_style(&self, child_node_id: NodeId) -> Self::GridItemStyle<'_>
fn get_grid_child_style(&self, child_node_id: NodeId) -> Self::GridItemStyle<'_>
Source§impl LayoutPartialTree for BaseDocument
impl LayoutPartialTree for BaseDocument
Source§type CoreContainerStyle<'a> = &'a Style<Atom<AtomStaticSet>>
where
Self: 'a
type CoreContainerStyle<'a> = &'a Style<Atom<AtomStaticSet>> where Self: 'a
Source§type CustomIdent = Atom<AtomStaticSet>
type CustomIdent = Atom<AtomStaticSet>
Arc<str>.Source§fn set_unrounded_layout(&mut self, node_id: NodeId, layout: &Layout)
fn set_unrounded_layout(&mut self, node_id: NodeId, layout: &Layout)
Source§fn compute_child_layout(
&mut self,
node_id: NodeId,
inputs: LayoutInput,
) -> LayoutOutput
fn compute_child_layout( &mut self, node_id: NodeId, inputs: LayoutInput, ) -> LayoutOutput
Source§impl PrintTree for BaseDocument
impl PrintTree for BaseDocument
Source§fn get_debug_label(&self, node_id: NodeId) -> &'static str
fn get_debug_label(&self, node_id: NodeId) -> &'static str
Source§fn get_final_layout(&self, node_id: NodeId) -> Layout
fn get_final_layout(&self, node_id: NodeId) -> Layout
Source§impl RoundTree for BaseDocument
impl RoundTree for BaseDocument
Source§fn get_unrounded_layout(&self, node_id: NodeId) -> Layout
fn get_unrounded_layout(&self, node_id: NodeId) -> Layout
Source§fn set_final_layout(&mut self, node_id: NodeId, layout: &Layout)
fn set_final_layout(&mut self, node_id: NodeId, layout: &Layout)
Source§impl TraversePartialTree for BaseDocument
impl TraversePartialTree for BaseDocument
Source§type ChildIter<'a> = RefCellChildIter<'a>
type ChildIter<'a> = RefCellChildIter<'a>
Source§fn child_ids(&self, node_id: NodeId) -> Self::ChildIter<'_>
fn child_ids(&self, node_id: NodeId) -> Self::ChildIter<'_>
Source§fn child_count(&self, node_id: NodeId) -> usize
fn child_count(&self, node_id: NodeId) -> usize
impl TraverseTree for BaseDocument
Auto Trait Implementations§
impl !Freeze for BaseDocument
impl !RefUnwindSafe for BaseDocument
impl !Send for BaseDocument
impl !Sync for BaseDocument
impl Unpin for BaseDocument
impl !UnwindSafe for BaseDocument
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> 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