#[repr(C)]pub struct Document {Show 94 fields
node: Node,
document_or_shadow_root: DocumentOrShadowRoot,
window: Dom<Window>,
implementation: MutNullableDom<DOMImplementation>,
content_type: Mime,
last_modified: Option<String>,
encoding: Cell<&'static Encoding>,
has_browsing_context: bool,
is_html_document: bool,
activity: Cell<DocumentActivity>,
url: DomRefCell<ServoUrl>,
quirks_mode: Cell<QuirksMode>,
id_map: DomRefCell<HashMap<Atom, Vec<Dom<Element>>>>,
name_map: DomRefCell<HashMap<Atom, Vec<Dom<Element>>>>,
tag_map: DomRefCell<HashMap<LocalName, Dom<HTMLCollection>>>,
tagns_map: DomRefCell<HashMap<QualName, Dom<HTMLCollection>>>,
classes_map: DomRefCell<HashMap<Vec<Atom>, Dom<HTMLCollection>>>,
images: MutNullableDom<HTMLCollection>,
embeds: MutNullableDom<HTMLCollection>,
links: MutNullableDom<HTMLCollection>,
forms: MutNullableDom<HTMLCollection>,
scripts: MutNullableDom<HTMLCollection>,
anchors: MutNullableDom<HTMLCollection>,
applets: MutNullableDom<HTMLCollection>,
style_shared_lock: StyleSharedRwLock,
stylesheets: DomRefCell<DocumentStylesheetSet<StyleSheetInDocument>>,
stylesheet_list: MutNullableDom<StyleSheetList>,
ready_state: Cell<DocumentReadyState>,
domcontentloaded_dispatched: Cell<bool>,
focus_transaction: DomRefCell<FocusTransaction>,
focused: MutNullableDom<Element>,
current_script: MutNullableDom<HTMLScriptElement>,
pending_parsing_blocking_script: DomRefCell<Option<PendingScript>>,
script_blocking_stylesheets_count: Cell<u32>,
deferred_scripts: PendingInOrderScriptVec,
asap_in_order_scripts_list: PendingInOrderScriptVec,
asap_scripts_set: DomRefCell<Vec<Dom<HTMLScriptElement>>>,
scripting_enabled: bool,
animation_frame_ident: Cell<u32>,
animation_frame_list: DomRefCell<Vec<(u32, Option<AnimationFrameCallback>)>>,
running_animation_callbacks: Cell<bool>,
loader: DomRefCell<DocumentLoader>,
current_parser: MutNullableDom<ServoParser>,
reflow_timeout: Cell<Option<u64>>,
base_element: MutNullableDom<HTMLBaseElement>,
appropriate_template_contents_owner_document: MutNullableDom<Document>,
pending_restyles: DomRefCell<HashMap<Dom<Element>, PendingRestyle>>,
needs_paint: Cell<bool>,
active_touch_points: DomRefCell<Vec<Dom<Touch>>>,
dom_loading: Cell<u64>,
dom_interactive: Cell<u64>,
dom_content_loaded_event_start: Cell<u64>,
dom_content_loaded_event_end: Cell<u64>,
dom_complete: Cell<u64>,
top_level_dom_complete: Cell<u64>,
load_event_start: Cell<u64>,
load_event_end: Cell<u64>,
unload_event_start: Cell<u64>,
unload_event_end: Cell<u64>,
https_state: Cell<HttpsState>,
origin: MutableOrigin,
referrer_policy: Cell<Option<ReferrerPolicy>>,
referrer: Option<String>,
target_element: MutNullableDom<Element>,
last_click_info: DomRefCell<Option<(Instant, Point2D<f32>)>>,
ignore_destructive_writes_counter: Cell<u32>,
ignore_opens_during_unload_counter: Cell<u32>,
spurious_animation_frames: Cell<u8>,
dom_count: Cell<u32>,
fullscreen_element: MutNullableDom<Element>,
form_id_listener_map: DomRefCell<HashMap<Atom, HashSet<Dom<Element>>>>,
interactive_time: DomRefCell<InteractiveMetrics>,
tti_window: DomRefCell<InteractiveWindow>,
canceller: FetchCanceller,
throw_on_dynamic_markup_insertion_counter: Cell<u64>,
page_showing: Cell<bool>,
salvageable: Cell<bool>,
active_parser_was_aborted: Cell<bool>,
fired_unload: Cell<bool>,
responsive_images: DomRefCell<Vec<Dom<HTMLImageElement>>>,
redirect_count: Cell<u16>,
script_and_layout_blockers: Cell<u32>,
delayed_tasks: DomRefCell<Vec<Box<dyn TaskBox>>>,
completely_loaded: Cell<bool>,
shadow_roots: DomRefCell<HashSet<Dom<ShadowRoot>>>,
shadow_roots_styles_changed: Cell<bool>,
media_controls: DomRefCell<HashMap<String, Dom<ShadowRoot>>>,
dirty_webgl_contexts: DomRefCell<HashMap<WebGLContextId, Dom<WebGLRenderingContext>>>,
dirty_webgpu_contexts: DomRefCell<HashMap<WebGPUContextId, Dom<GPUCanvasContext>>>,
csp_list: DomRefCell<Option<CspList>>,
selection: MutNullableDom<Selection>,
animation_timeline: DomRefCell<AnimationTimeline>,
animations: DomRefCell<Animations>,
dirty_root: MutNullableDom<Element>,
}
Expand description
Fields§
§node: Node
§document_or_shadow_root: DocumentOrShadowRoot
§window: Dom<Window>
§implementation: MutNullableDom<DOMImplementation>
§content_type: Mime
§last_modified: Option<String>
§encoding: Cell<&'static Encoding>
§has_browsing_context: bool
§is_html_document: bool
§activity: Cell<DocumentActivity>
§url: DomRefCell<ServoUrl>
§quirks_mode: Cell<QuirksMode>
§id_map: DomRefCell<HashMap<Atom, Vec<Dom<Element>>>>
Caches for the getElement methods
name_map: DomRefCell<HashMap<Atom, Vec<Dom<Element>>>>
§tag_map: DomRefCell<HashMap<LocalName, Dom<HTMLCollection>>>
§tagns_map: DomRefCell<HashMap<QualName, Dom<HTMLCollection>>>
§classes_map: DomRefCell<HashMap<Vec<Atom>, Dom<HTMLCollection>>>
§images: MutNullableDom<HTMLCollection>
§embeds: MutNullableDom<HTMLCollection>
§links: MutNullableDom<HTMLCollection>
§forms: MutNullableDom<HTMLCollection>
§scripts: MutNullableDom<HTMLCollection>
§anchors: MutNullableDom<HTMLCollection>
§applets: MutNullableDom<HTMLCollection>
Lock use for style attributes and author-origin stylesheet objects in this document. Can be acquired once for accessing many objects.
stylesheets: DomRefCell<DocumentStylesheetSet<StyleSheetInDocument>>
List of stylesheets associated with nodes in this document. |None| if the list needs to be refreshed.
stylesheet_list: MutNullableDom<StyleSheetList>
§ready_state: Cell<DocumentReadyState>
§domcontentloaded_dispatched: Cell<bool>
Whether the DOMContentLoaded event has already been dispatched.
focus_transaction: DomRefCell<FocusTransaction>
The state of this document’s focus transaction.
focused: MutNullableDom<Element>
The element that currently has the document focus context.
current_script: MutNullableDom<HTMLScriptElement>
The script element that is currently executing.
pending_parsing_blocking_script: DomRefCell<Option<PendingScript>>
§script_blocking_stylesheets_count: Cell<u32>
Number of stylesheets that block executing the next parser-inserted script
deferred_scripts: PendingInOrderScriptVec
https://html.spec.whatwg.org/multipage/#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing
asap_in_order_scripts_list: PendingInOrderScriptVec
§asap_scripts_set: DomRefCell<Vec<Dom<HTMLScriptElement>>>
§scripting_enabled: bool
https://html.spec.whatwg.org/multipage/#concept-n-noscript True if scripting is enabled for all scripts in this document
animation_frame_ident: Cell<u32>
https://html.spec.whatwg.org/multipage/#animation-frame-callback-identifier Current identifier of animation frame callback
animation_frame_list: DomRefCell<Vec<(u32, Option<AnimationFrameCallback>)>>
https://html.spec.whatwg.org/multipage/#list-of-animation-frame-callbacks List of animation frame callbacks
running_animation_callbacks: Cell<bool>
Whether we’re in the process of running animation callbacks.
Tracking this is not necessary for correctness. Instead, it is an optimization to avoid
sending needless ChangeRunningAnimationsState
messages to the compositor.
loader: DomRefCell<DocumentLoader>
Tracks all outstanding loads related to this document.
current_parser: MutNullableDom<ServoParser>
The current active HTML parser, to allow resuming after interruptions.
reflow_timeout: Cell<Option<u64>>
When we should kick off a reflow. This happens during parsing.
base_element: MutNullableDom<HTMLBaseElement>
The cached first base
element with an href
attribute.
appropriate_template_contents_owner_document: MutNullableDom<Document>
This field is set to the document itself for inert documents. https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document
pending_restyles: DomRefCell<HashMap<Dom<Element>, PendingRestyle>>
Information on elements needing restyle to ship over to the layout thread when the time comes.
needs_paint: Cell<bool>
This flag will be true if layout suppressed a reflow attempt that was needed in order for the page to be painted.
active_touch_points: DomRefCell<Vec<Dom<Touch>>>
§dom_loading: Cell<u64>
Navigation Timing properties: https://w3c.github.io/navigation-timing/#sec-PerformanceNavigationTiming
dom_interactive: Cell<u64>
§dom_content_loaded_event_start: Cell<u64>
§dom_content_loaded_event_end: Cell<u64>
§dom_complete: Cell<u64>
§top_level_dom_complete: Cell<u64>
§load_event_start: Cell<u64>
§load_event_end: Cell<u64>
§unload_event_start: Cell<u64>
§unload_event_end: Cell<u64>
§https_state: Cell<HttpsState>
§origin: MutableOrigin
The document’s origin.
referrer_policy: Cell<Option<ReferrerPolicy>>
https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-states
referrer: Option<String>
§target_element: MutNullableDom<Element>
§last_click_info: DomRefCell<Option<(Instant, Point2D<f32>)>>
§ignore_destructive_writes_counter: Cell<u32>
§ignore_opens_during_unload_counter: Cell<u32>
§spurious_animation_frames: Cell<u8>
The number of spurious requestAnimationFrame()
requests we’ve received.
A rAF request is considered spurious if nothing was actually reflowed.
dom_count: Cell<u32>
Track the total number of elements in this DOM’s tree. This is sent to the layout thread every time a reflow is done; layout uses this to determine if the gains from parallel layout will be worth the overhead.
See also: https://github.com/servo/servo/issues/10110
fullscreen_element: MutNullableDom<Element>
Entry node for fullscreen.
form_id_listener_map: DomRefCell<HashMap<Atom, HashSet<Dom<Element>>>>
Map from ID to set of form control elements that have that ID as their ‘form’ content attribute. Used to reset form controls whenever any element with the same ID as the form attribute is inserted or removed from the document. See https://html.spec.whatwg.org/multipage/#form-owner
interactive_time: DomRefCell<InteractiveMetrics>
§tti_window: DomRefCell<InteractiveWindow>
§canceller: FetchCanceller
RAII canceller for Fetch
throw_on_dynamic_markup_insertion_counter: Cell<u64>
https://html.spec.whatwg.org/multipage/#throw-on-dynamic-markup-insertion-counter
page_showing: Cell<bool>
https://html.spec.whatwg.org/multipage/#page-showing
salvageable: Cell<bool>
Whether the document is salvageable.
active_parser_was_aborted: Cell<bool>
Whether the document was aborted with an active parser
fired_unload: Cell<bool>
Whether the unload event has already been fired.
responsive_images: DomRefCell<Vec<Dom<HTMLImageElement>>>
List of responsive images
redirect_count: Cell<u16>
Number of redirects for the document load
script_and_layout_blockers: Cell<u32>
Number of outstanding requests to prevent JS or layout from running.
delayed_tasks: DomRefCell<Vec<Box<dyn TaskBox>>>
List of tasks to execute as soon as last script/layout blocker is removed.
completely_loaded: Cell<bool>
https://html.spec.whatwg.org/multipage/#completely-loaded
shadow_roots: DomRefCell<HashSet<Dom<ShadowRoot>>>
Set of shadow roots connected to the document tree.
shadow_roots_styles_changed: Cell<bool>
Whether any of the shadow roots need the stylesheets flushed.
media_controls: DomRefCell<HashMap<String, Dom<ShadowRoot>>>
List of registered media controls.
We need to keep this list to allow the media controls to
access the “privileged” document.servoGetMediaControls(id) API,
where id
needs to match any of the registered ShadowRoots
hosting the media controls UI.
dirty_webgl_contexts: DomRefCell<HashMap<WebGLContextId, Dom<WebGLRenderingContext>>>
List of all WebGL context IDs that need flushing.
dirty_webgpu_contexts: DomRefCell<HashMap<WebGPUContextId, Dom<GPUCanvasContext>>>
List of all WebGPU context IDs that need flushing.
csp_list: DomRefCell<Option<CspList>>
https://html.spec.whatwg.org/multipage/#concept-document-csp-list
selection: MutNullableDom<Selection>
https://w3c.github.io/slection-api/#dfn-selection
animation_timeline: DomRefCell<AnimationTimeline>
A timeline for animations which is used for synchronizing animations. https://drafts.csswg.org/web-animations/#timeline
animations: DomRefCell<Animations>
Animations for this Document
dirty_root: MutNullableDom<Element>
The nearest inclusive ancestors to all the nodes that require a restyle.
Implementations§
source§impl Document
impl Document
pub fn note_node_with_dirty_descendants(&self, node: &Node)
pub fn take_dirty_root(&self) -> Option<Root<Dom<Element>>>
pub fn loader(&self) -> Ref<'_, DocumentLoader>
pub fn loader_mut(&self) -> RefMut<'_, DocumentLoader>
pub fn has_browsing_context(&self) -> bool
sourcepub fn browsing_context(&self) -> Option<Root<Dom<WindowProxy>>>
pub fn browsing_context(&self) -> Option<Root<Dom<WindowProxy>>>
pub fn window(&self) -> &Window
pub fn is_html_document(&self) -> bool
pub fn set_https_state(&self, https_state: HttpsState)
pub fn is_fully_active(&self) -> bool
pub fn is_active(&self) -> bool
pub fn set_activity(&self, activity: DocumentActivity)
pub fn origin(&self) -> &MutableOrigin
pub fn url(&self) -> ServoUrl
pub fn set_url(&self, url: ServoUrl)
pub fn fallback_base_url(&self) -> ServoUrl
pub fn base_url(&self) -> ServoUrl
pub fn needs_paint(&self) -> bool
pub fn needs_reflow(&self) -> Option<ReflowTriggerCondition>
sourcepub fn base_element(&self) -> Option<Root<Dom<HTMLBaseElement>>>
pub fn base_element(&self) -> Option<Root<Dom<HTMLBaseElement>>>
Returns the first base
element in the DOM that has an href
attribute.
sourcepub fn refresh_base_element(&self)
pub fn refresh_base_element(&self)
Refresh the cached first base element in the DOM. https://github.com/w3c/web-platform-tests/issues/2122
pub fn dom_count(&self) -> u32
sourcepub fn increment_dom_count(&self)
pub fn increment_dom_count(&self)
This is called by bind_to_tree
when a node is added to the DOM.
The internal count is used by layout to determine whether to be sequential or parallel.
(it’s sequential for small DOMs)
sourcepub fn decrement_dom_count(&self)
pub fn decrement_dom_count(&self)
This is called by unbind_from_tree
when a node is removed from the DOM.
pub fn quirks_mode(&self) -> QuirksMode
pub fn set_quirks_mode(&self, mode: QuirksMode)
pub fn encoding(&self) -> &'static Encoding
pub fn set_encoding(&self, encoding: &'static Encoding)
pub fn content_and_heritage_changed(&self, node: &Node)
sourcepub fn reflow_if_reflow_timer_expired(&self)
pub fn reflow_if_reflow_timer_expired(&self)
Reflows and disarms the timer if the reflow timer has expired.
sourcepub fn set_reflow_timeout(&self, timeout: u64)
pub fn set_reflow_timeout(&self, timeout: u64)
Schedules a reflow to be kicked off at the given timeout
(in time::precise_time_ns()
units). This reflow happens even if the event loop is busy. This is used to display initial
page content during parsing.
sourcepub fn unregister_element_id(&self, to_unregister: &Element, id: Atom)
pub fn unregister_element_id(&self, to_unregister: &Element, id: Atom)
Remove any existing association between the provided id and any elements in this document.
sourcepub fn register_element_id(&self, element: &Element, id: Atom)
pub fn register_element_id(&self, element: &Element, id: Atom)
Associate an element present in this document with the provided id.
sourcepub fn unregister_element_name(&self, to_unregister: &Element, name: Atom)
pub fn unregister_element_name(&self, to_unregister: &Element, name: Atom)
Remove any existing association between the provided name and any elements in this document.
sourcepub fn register_element_name(&self, element: &Element, name: Atom)
pub fn register_element_name(&self, element: &Element, name: Atom)
Associate an element present in this document with the provided name.
pub fn register_form_id_listener<T: ?Sized + FormControl>(
&self,
id: DOMString,
listener: &T
)
pub fn unregister_form_id_listener<T: ?Sized + FormControl>(
&self,
id: DOMString,
listener: &T
)
sourcepub fn find_fragment_node(&self, fragid: &str) -> Option<Root<Dom<Element>>>
pub fn find_fragment_node(&self, fragid: &str) -> Option<Root<Dom<Element>>>
Attempt to find a named element in this page’s document. https://html.spec.whatwg.org/multipage/#the-indicated-part-of-the-document
sourcepub fn check_and_scroll_fragment(&self, fragment: &str)
pub fn check_and_scroll_fragment(&self, fragment: &str)
Scroll to the target element, and when we do not find a target and the fragment is empty or “top”, scroll to the top. https://html.spec.whatwg.org/multipage/#scroll-to-the-fragment-identifier
fn get_anchor_by_name(&self, name: &str) -> Option<Root<Dom<Element>>>
pub fn set_ready_state(&self, state: DocumentReadyState)
sourcepub fn is_scripting_enabled(&self) -> bool
pub fn is_scripting_enabled(&self) -> bool
Return whether scripting is enabled or not
sourcepub fn get_focused_element(&self) -> Option<Root<Dom<Element>>>
pub fn get_focused_element(&self) -> Option<Root<Dom<Element>>>
Return the element that currently has focus.
sourcefn begin_focus_transaction(&self)
fn begin_focus_transaction(&self)
Initiate a new round of checking for elements requesting focus. The last element to call
request_focus
before commit_focus_transaction
is called will receive focus.
sourcepub(crate) fn perform_focus_fixup_rule(&self, not_focusable: &Element)
pub(crate) fn perform_focus_fixup_rule(&self, not_focusable: &Element)
sourcepub(crate) fn request_focus(&self, elem: Option<&Element>, focus_type: FocusType)
pub(crate) fn request_focus(&self, elem: Option<&Element>, focus_type: FocusType)
Request that the given element receive focus once the current transaction is complete. If None is passed, then whatever element is currently focused will no longer be focused once the transaction is complete.
sourcefn commit_focus_transaction(&self, focus_type: FocusType)
fn commit_focus_transaction(&self, focus_type: FocusType)
Reassign the focus context to the element that last requested focus during this transaction, or none if no elements requested it.
sourcepub fn title_changed(&self)
pub fn title_changed(&self)
Handles any updates when the document’s title has changed.
sourcepub fn send_title_to_embedder(&self)
pub fn send_title_to_embedder(&self)
Sends this document’s title to the constellation.
fn send_to_embedder(&self, msg: EmbedderMsg)
pub fn dirty_all_nodes(&self)
pub unsafe fn handle_mouse_event(
&self,
button: MouseButton,
client_point: Point2D<f32>,
mouse_event_type: MouseEventType,
node_address: Option<UntrustedNodeAddress>,
point_in_node: Option<Point2D<f32>>,
pressed_mouse_buttons: u16
)
fn maybe_fire_dblclick(
&self,
click_pos: Point2D<f32>,
target: &Node,
pressed_mouse_buttons: u16
)
pub fn fire_mouse_event(
&self,
client_point: Point2D<f32>,
target: &EventTarget,
event_name: FireMouseEventType,
can_bubble: EventBubbles,
cancelable: EventCancelable,
pressed_mouse_buttons: u16
)
pub unsafe fn handle_mouse_move_event(
&self,
client_point: Point2D<f32>,
prev_mouse_over_target: &MutNullableDom<Element>,
node_address: Option<UntrustedNodeAddress>,
pressed_mouse_buttons: u16
)
fn handle_mouse_enter_leave_event(
&self,
client_point: Point2D<f32>,
event_type: FireMouseEventType,
related_target: Option<Root<Dom<Node>>>,
event_target: Root<Dom<Node>>,
pressed_mouse_buttons: u16
)
pub unsafe fn handle_wheel_event(
&self,
delta: WheelDelta,
client_point: Point2D<f32>,
node_address: Option<UntrustedNodeAddress>
)
pub unsafe fn handle_touch_event(
&self,
event_type: TouchEventType,
touch_id: TouchId,
point: Point2D<f32>,
node_address: Option<UntrustedNodeAddress>
) -> TouchEventResult
sourcepub fn dispatch_key_event(&self, keyboard_event: KeyboardEvent)
pub fn dispatch_key_event(&self, keyboard_event: KeyboardEvent)
The entry point for all key processing for web content
pub fn ime_dismissed(&self)
pub fn dispatch_composition_event(&self, composition_event: CompositionEvent)
pub fn node_from_nodes_and_strings(
&self,
nodes: Vec<NodeOrString>
) -> Result<Root<Dom<Node>>, Error>
pub fn get_body_attribute(&self, local_name: &LocalName) -> DOMString
pub fn set_body_attribute(&self, local_name: &LocalName, value: DOMString)
pub fn set_current_script(&self, script: Option<&HTMLScriptElement>)
pub fn get_script_blocking_stylesheets_count(&self) -> u32
pub fn increment_script_blocking_stylesheet_count(&self)
pub fn decrement_script_blocking_stylesheet_count(&self)
pub fn invalidate_stylesheets(&self)
sourcepub fn request_animation_frame(&self, callback: AnimationFrameCallback) -> u32
pub fn request_animation_frame(&self, callback: AnimationFrameCallback) -> u32
sourcepub fn cancel_animation_frame(&self, ident: u32)
pub fn cancel_animation_frame(&self, ident: u32)
sourcepub fn run_the_animation_frame_callbacks(&self)
pub fn run_the_animation_frame_callbacks(&self)
pub fn fetch_async(
&self,
load: LoadType,
request: RequestBuilder,
fetch_target: IpcSender<FetchResponseMsg>
)
pub fn finish_load(&self, load: LoadType)
pub fn prompt_to_unload(&self, recursive_flag: bool) -> bool
pub fn unload(&self, recursive_flag: bool)
pub fn maybe_queue_document_completion(&self)
pub fn set_pending_parsing_blocking_script(
&self,
script: &HTMLScriptElement,
load: Option<Result<ScriptOrigin, NetworkError>>
)
pub fn has_pending_parsing_blocking_script(&self) -> bool
sourcepub fn pending_parsing_blocking_script_loaded(
&self,
element: &HTMLScriptElement,
result: Result<ScriptOrigin, NetworkError>
)
pub fn pending_parsing_blocking_script_loaded(
&self,
element: &HTMLScriptElement,
result: Result<ScriptOrigin, NetworkError>
)
https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d.
fn process_pending_parsing_blocking_script(&self)
pub fn add_asap_script(&self, script: &HTMLScriptElement)
sourcepub fn asap_script_loaded(
&self,
element: &HTMLScriptElement,
result: Result<ScriptOrigin, NetworkError>
)
pub fn asap_script_loaded(
&self,
element: &HTMLScriptElement,
result: Result<ScriptOrigin, NetworkError>
)
https://html.spec.whatwg.org/multipage/#the-end step 5. https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d.
pub fn push_asap_in_order_script(&self, script: &HTMLScriptElement)
sourcepub fn asap_in_order_script_loaded(
&self,
element: &HTMLScriptElement,
result: Result<ScriptOrigin, NetworkError>
)
pub fn asap_in_order_script_loaded(
&self,
element: &HTMLScriptElement,
result: Result<ScriptOrigin, NetworkError>
)
https://html.spec.whatwg.org/multipage/#the-end step 5. https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.c.
pub fn add_deferred_script(&self, script: &HTMLScriptElement)
sourcepub fn deferred_script_loaded(
&self,
element: &HTMLScriptElement,
result: Result<ScriptOrigin, NetworkError>
)
pub fn deferred_script_loaded(
&self,
element: &HTMLScriptElement,
result: Result<ScriptOrigin, NetworkError>
)
https://html.spec.whatwg.org/multipage/#the-end step 3. https://html.spec.whatwg.org/multipage/#prepare-a-script step 22.d.
sourcefn process_deferred_scripts(&self)
fn process_deferred_scripts(&self)
https://html.spec.whatwg.org/multipage/#the-end step 3.
pub fn maybe_dispatch_dom_content_loaded(&self)
pub fn abort(&self)
pub fn notify_constellation_load(&self)
pub fn set_current_parser(&self, script: Option<&ServoParser>)
pub fn get_current_parser(&self) -> Option<Root<Dom<ServoParser>>>
pub fn can_invoke_script(&self) -> bool
sourcepub fn iter_iframes(&self) -> impl Iterator<Item = Root<Dom<HTMLIFrameElement>>>
pub fn iter_iframes(&self) -> impl Iterator<Item = Root<Dom<HTMLIFrameElement>>>
Iterate over all iframes in the document.
sourcepub fn find_iframe(
&self,
browsing_context_id: BrowsingContextId
) -> Option<Root<Dom<HTMLIFrameElement>>>
pub fn find_iframe(
&self,
browsing_context_id: BrowsingContextId
) -> Option<Root<Dom<HTMLIFrameElement>>>
Find an iframe element in the document.
pub fn get_dom_loading(&self) -> u64
pub fn get_dom_interactive(&self) -> u64
pub fn get_interactive_metrics(&self) -> Ref<'_, InteractiveMetrics>
pub fn has_recorded_tti_metric(&self) -> bool
pub fn get_dom_content_loaded_event_start(&self) -> u64
pub fn get_dom_content_loaded_event_end(&self) -> u64
pub fn get_dom_complete(&self) -> u64
pub fn get_top_level_dom_complete(&self) -> u64
pub fn get_load_event_start(&self) -> u64
pub fn get_load_event_end(&self) -> u64
pub fn get_unload_event_start(&self) -> u64
pub fn get_unload_event_end(&self) -> u64
pub fn start_tti(&self)
sourcepub fn record_tti_if_necessary(&self)
pub fn record_tti_if_necessary(&self)
check tti for this document if it’s been 10s since this doc encountered a task over 50ms, then we consider the main thread available and try to set tti
fn fire_focus_event(
&self,
focus_event_type: FocusEventType,
node: &Node,
related_target: Option<&EventTarget>
)
sourcepub fn lookup_custom_element_definition(
&self,
namespace: &Namespace,
local_name: &LocalName,
is: Option<&LocalName>
) -> Option<Rc<CustomElementDefinition>>
pub fn lookup_custom_element_definition(
&self,
namespace: &Namespace,
local_name: &LocalName,
is: Option<&LocalName>
) -> Option<Rc<CustomElementDefinition>>
pub fn increment_throw_on_dynamic_markup_insertion_counter(&self)
pub fn decrement_throw_on_dynamic_markup_insertion_counter(&self)
pub fn react_to_environment_changes(&self)
pub fn register_responsive_image(&self, img: &HTMLImageElement)
pub fn unregister_responsive_image(&self, img: &HTMLImageElement)
pub fn register_media_controls(&self, controls: &ShadowRoot) -> String
pub fn unregister_media_controls(&self, id: &str)
pub fn add_dirty_webgl_canvas(&self, context: &WebGLRenderingContext)
pub fn flush_dirty_webgl_canvases(&self)
pub fn add_dirty_webgpu_canvas(&self, context: &GPUCanvasContext)
pub fn flush_dirty_webgpu_canvases(&self)
pub fn id_map(&self) -> Ref<'_, HashMap<Atom, Vec<Dom<Element>>>>
pub fn name_map(&self) -> Ref<'_, HashMap<Atom, Vec<Dom<Element>>>>
source§impl Document
impl Document
pub fn new_inherited(
window: &Window,
has_browsing_context: HasBrowsingContext,
url: Option<ServoUrl>,
origin: MutableOrigin,
is_html_document: IsHTMLDocument,
content_type: Option<Mime>,
last_modified: Option<String>,
activity: DocumentActivity,
source: DocumentSource,
doc_loader: DocumentLoader,
referrer: Option<String>,
referrer_policy: Option<ReferrerPolicy>,
canceller: FetchCanceller
) -> Document
pub fn set_csp_list(&self, csp_list: Option<CspList>)
pub fn get_csp_list(&self) -> Option<Ref<'_, CspList>>
sourcepub fn should_elements_inline_type_behavior_be_blocked(
&self,
el: &Element,
type_: InlineCheckType,
source: &str
) -> CheckResult
pub fn should_elements_inline_type_behavior_be_blocked(
&self,
el: &Element,
type_: InlineCheckType,
source: &str
) -> CheckResult
https://www.w3.org/TR/CSP/#should-block-inline
sourcepub fn add_script_and_layout_blocker(&self)
pub fn add_script_and_layout_blocker(&self)
Prevent any JS or layout from running until the corresponding call to
remove_script_and_layout_blocker
. Used to isolate periods in which
the DOM is in an unstable state and should not be exposed to arbitrary
web content. Any attempts to invoke content JS or query layout during
that time will trigger a panic. add_delayed_task
will cause the
provided task to be executed as soon as the last blocker is removed.
sourcepub fn remove_script_and_layout_blocker(&self)
pub fn remove_script_and_layout_blocker(&self)
Terminate the period in which JS or layout is disallowed from running. If no further blockers remain, any delayed tasks in the queue will be executed in queue order until the queue is empty.
sourcepub fn add_delayed_task<T: 'static + TaskBox>(&self, task: T)
pub fn add_delayed_task<T: 'static + TaskBox>(&self, task: T)
Enqueue a task to run as soon as any JS and layout blockers are removed.
sourcepub fn ensure_safe_to_run_script_or_layout(&self)
pub fn ensure_safe_to_run_script_or_layout(&self)
Assert that the DOM is in a state that will allow running content JS or performing a layout operation.
pub fn Constructor(
window: &Window,
proto: Option<HandleObject<'_>>
) -> Result<Root<Dom<Document>>, Error>
pub fn new(
window: &Window,
has_browsing_context: HasBrowsingContext,
url: Option<ServoUrl>,
origin: MutableOrigin,
doctype: IsHTMLDocument,
content_type: Option<Mime>,
last_modified: Option<String>,
activity: DocumentActivity,
source: DocumentSource,
doc_loader: DocumentLoader,
referrer: Option<String>,
referrer_policy: Option<ReferrerPolicy>,
canceller: FetchCanceller
) -> Root<Dom<Document>>
fn new_with_proto(
window: &Window,
proto: Option<HandleObject<'_>>,
has_browsing_context: HasBrowsingContext,
url: Option<ServoUrl>,
origin: MutableOrigin,
doctype: IsHTMLDocument,
content_type: Option<Mime>,
last_modified: Option<String>,
activity: DocumentActivity,
source: DocumentSource,
doc_loader: DocumentLoader,
referrer: Option<String>,
referrer_policy: Option<ReferrerPolicy>,
canceller: FetchCanceller
) -> Root<Dom<Document>>
pub fn get_redirect_count(&self) -> u16
pub fn set_redirect_count(&self, count: u16)
pub fn elements_by_name_count(&self, name: &DOMString) -> u32
pub fn nth_element_by_name(
&self,
index: u32,
name: &DOMString
) -> Option<Root<Dom<Node>>>
fn is_element_in_get_by_name(node: &Node, name: &DOMString) -> bool
fn count_node_list<F: Fn(&Node) -> bool>(&self, callback: F) -> u32
fn nth_in_node_list<F: Fn(&Node) -> bool>(
&self,
index: u32,
callback: F
) -> Option<Root<Dom<Node>>>
fn get_html_element(&self) -> Option<Root<Dom<HTMLHtmlElement>>>
Return a reference to the per-document shared lock used in stylesheets.
sourcepub fn flush_stylesheets_for_reflow(&self) -> bool
pub fn flush_stylesheets_for_reflow(&self) -> bool
Flushes the stylesheet list, and returns whether any stylesheet changed.
sourcepub fn device(&self) -> Device
pub fn device(&self) -> Device
Returns a Device
suitable for media query evaluation.
FIXME(emilio): This really needs to be somehow more in sync with layout. Feels like a hack.
pub fn salvageable(&self) -> bool
sourcepub fn appropriate_template_contents_owner_document(
&self
) -> Root<Dom<Document>>
pub fn appropriate_template_contents_owner_document(
&self
) -> Root<Dom<Document>>
pub fn get_element_by_id(&self, id: &Atom) -> Option<Root<Dom<Element>>>
pub fn ensure_pending_restyle(&self, el: &Element) -> RefMut<'_, PendingRestyle>
pub fn element_state_will_change(&self, el: &Element)
pub fn element_attr_will_change(&self, el: &Element, attr: &Attr)
pub fn set_referrer_policy(&self, policy: Option<ReferrerPolicy>)
pub fn get_referrer_policy(&self) -> Option<ReferrerPolicy>
pub fn set_target_element(&self, node: Option<&Element>)
pub fn incr_ignore_destructive_writes_counter(&self)
pub fn decr_ignore_destructive_writes_counter(&self)
pub fn is_prompting_or_unloading(&self) -> bool
fn incr_ignore_opens_during_unload_counter(&self)
fn decr_ignore_opens_during_unload_counter(&self)
sourcefn is_faking_animation_frames(&self) -> bool
fn is_faking_animation_frames(&self) -> bool
Whether we’ve seen so many spurious animation frames (i.e. animation frames that didn’t mutate the DOM) that we’ve decided to fall back to fake ones.
pub fn enter_fullscreen(&self, pending: &Element) -> Rc<Promise>
pub fn exit_fullscreen(&self) -> Rc<Promise>
pub fn set_fullscreen_element(&self, element: Option<&Element>)
pub fn get_allow_fullscreen(&self) -> bool
fn reset_form_owner_for_listeners(&self, id: &Atom)
pub fn register_shadow_root(&self, shadow_root: &ShadowRoot)
pub fn unregister_shadow_root(&self, shadow_root: &ShadowRoot)
pub fn invalidate_shadow_roots_stylesheets(&self)
pub fn shadow_roots_styles_changed(&self) -> bool
pub fn flush_shadow_roots_stylesheets(&self)
pub fn stylesheet_count(&self) -> usize
pub fn stylesheet_at(&self, index: usize) -> Option<Root<Dom<CSSStyleSheet>>>
sourcepub fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>)
pub fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>)
Add a stylesheet owned by owner
to the list of document sheets, in the
correct tree position.
sourcepub fn remove_stylesheet(&self, owner: &Element, s: &Arc<Stylesheet>)
pub fn remove_stylesheet(&self, owner: &Element, s: &Arc<Stylesheet>)
Remove a stylesheet owned by owner
from the list of document sheets.