[][src]Struct script::dom::window::Window

#[repr(C)]pub struct Window {
    globalscope: GlobalScope,
    script_chan: MainThreadScriptChan,
    task_manager: TaskManager,
    navigator: MutNullableDom<Navigator>,
    image_cache: Arc<dyn ImageCache>,
    image_cache_chan: Sender<ImageCacheMsg>,
    window_proxy: MutNullableDom<WindowProxy>,
    document: MutNullableDom<Document>,
    location: MutNullableDom<Location>,
    history: MutNullableDom<History>,
    custom_element_registry: MutNullableDom<CustomElementRegistry>,
    performance: MutNullableDom<Performance>,
    navigation_start: Cell<u64>,
    navigation_start_precise: Cell<u64>,
    screen: MutNullableDom<Screen>,
    session_storage: MutNullableDom<Storage>,
    local_storage: MutNullableDom<Storage>,
    status: DomRefCell<DOMString>,
    devtools_markers: DomRefCell<HashSet<TimelineMarkerType>>,
    devtools_marker_sender: DomRefCell<Option<IpcSender<Option<TimelineMarker>>>>,
    resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>,
    parent_info: Option<PipelineId>,
    dom_static: GlobalStaticData,
    js_runtime: DomRefCell<Option<Rc<Runtime>>>,
    layout_chan: Sender<Msg>,
    layout_rpc: Box<dyn LayoutRPC + Send + 'static>,
    window_size: Cell<WindowSizeData>,
    bluetooth_thread: IpcSender<BluetoothRequest>,
    bluetooth_extra_permission_data: BluetoothExtraPermissionData,
    page_clip_rect: Cell<UntypedRect<Au>>,
    suppress_reflow: Cell<bool>,
    pending_reflow_count: Cell<u32>,
    webdriver_script_chan: DomRefCell<Option<IpcSender<WebDriverJSResult>>>,
    current_state: Cell<WindowState>,
    current_viewport: Cell<UntypedRect<Au>>,
    error_reporter: CSSErrorReporter,
    scroll_offsets: DomRefCell<HashMap<OpaqueNode, Vector2D<f32, LayoutPixel>>>,
    media_query_lists: DOMTracker<MediaQueryList>,
    test_runner: MutNullableDom<TestRunner>,
    webgl_chan: Option<WebGLChan>,
    webxr_registry: Registry,
    pending_layout_images: DomRefCell<HashMap<PendingImageId, Vec<Dom<Node>>>>,
    unminified_js_dir: DomRefCell<Option<String>>,
    local_script_source: Option<String>,
    test_worklet: MutNullableDom<Worklet>,
    paint_worklet: MutNullableDom<Worklet>,
    webrender_document: DocumentId,
    exists_mut_observer: Cell<bool>,
    webrender_api_sender: WebrenderIpcSender,
    has_sent_idle_message: Cell<bool>,
    layout_is_busy: Arc<AtomicBool>,
    relayout_event: bool,
    prepare_for_screenshot: bool,
    unminify_js: bool,
    userscripts_path: Option<String>,
    replace_surrogates: bool,
    player_context: WindowGLContext,
    event_loop_waker: Option<Box<dyn EventLoopWaker>>,
    visible: Cell<bool>,
    layout_marker: DomRefCell<Rc<Cell<bool>>>,
    current_event: DomRefCell<Option<Dom<Event>>>,
}

Fields

globalscope: GlobalScopescript_chan: MainThreadScriptChantask_manager: TaskManagernavigator: MutNullableDom<Navigator>image_cache: Arc<dyn ImageCache>image_cache_chan: Sender<ImageCacheMsg>window_proxy: MutNullableDom<WindowProxy>document: MutNullableDom<Document>location: MutNullableDom<Location>history: MutNullableDom<History>custom_element_registry: MutNullableDom<CustomElementRegistry>performance: MutNullableDom<Performance>navigation_start: Cell<u64>navigation_start_precise: Cell<u64>screen: MutNullableDom<Screen>session_storage: MutNullableDom<Storage>local_storage: MutNullableDom<Storage>status: DomRefCell<DOMString>devtools_markers: DomRefCell<HashSet<TimelineMarkerType>>

For sending timeline markers. Will be ignored if no devtools server

devtools_marker_sender: DomRefCell<Option<IpcSender<Option<TimelineMarker>>>>resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>

Pending resize event, if any.

parent_info: Option<PipelineId>

Parent id associated with this page, if any.

dom_static: GlobalStaticData

Global static data related to the DOM.

js_runtime: DomRefCell<Option<Rc<Runtime>>>

The JavaScript runtime.

layout_chan: Sender<Msg>

A handle for communicating messages to the layout thread.

This channel shouldn't be accessed directly, but through Window::layout_chan(), which returns None if there's no layout thread anymore.

layout_rpc: Box<dyn LayoutRPC + Send + 'static>

A handle to perform RPC calls into the layout, quickly.

window_size: Cell<WindowSizeData>

The current size of the window, in pixels.

bluetooth_thread: IpcSender<BluetoothRequest>

A handle for communicating messages to the bluetooth thread.

bluetooth_extra_permission_data: BluetoothExtraPermissionDatapage_clip_rect: Cell<UntypedRect<Au>>

An enlarged rectangle around the page contents visible in the viewport, used to prevent creating display list items for content that is far away from the viewport.

suppress_reflow: Cell<bool>

Flag to suppress reflows. The first reflow will come either with RefreshTick or with FirstLoad. Until those first reflows, we want to suppress others like MissingExplicitReflow.

pending_reflow_count: Cell<u32>

A counter of the number of pending reflows for this window.

webdriver_script_chan: DomRefCell<Option<IpcSender<WebDriverJSResult>>>

A channel for communicating results of async scripts back to the webdriver server

current_state: Cell<WindowState>

The current state of the window object

current_viewport: Cell<UntypedRect<Au>>error_reporter: CSSErrorReporterscroll_offsets: DomRefCell<HashMap<OpaqueNode, Vector2D<f32, LayoutPixel>>>

A list of scroll offsets for each scrollable element.

media_query_lists: DOMTracker<MediaQueryList>

All the MediaQueryLists we need to update

test_runner: MutNullableDom<TestRunner>webgl_chan: Option<WebGLChan>

A handle for communicating messages to the WebGL thread, if available.

webxr_registry: Registrypending_layout_images: DomRefCell<HashMap<PendingImageId, Vec<Dom<Node>>>>

All of the elements that have an outstanding image request that was initiated by layout during a reflow. They are stored in the script thread to ensure that the element can be marked dirty when the image data becomes available at some point in the future.

unminified_js_dir: DomRefCell<Option<String>>

Directory to store unminified scripts for this window if unminify-js opt is enabled.

local_script_source: Option<String>

Directory with stored unminified scripts

test_worklet: MutNullableDom<Worklet>

Worklets

paint_worklet: MutNullableDom<Worklet>

https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet

webrender_document: DocumentId

The Webrender Document id associated with this window.

exists_mut_observer: Cell<bool>

Flag to identify whether mutation observers are present(true)/absent(false)

webrender_api_sender: WebrenderIpcSender

Webrender API Sender

has_sent_idle_message: Cell<bool>

Indicate whether a SetDocumentStatus message has been sent after a reflow is complete. It is used to avoid sending idle message more than once, which is unneccessary.

layout_is_busy: Arc<AtomicBool>

Flag that indicates if the layout thread is busy handling a request.

relayout_event: bool

Emits notifications when there is a relayout.

prepare_for_screenshot: bool

True if it is safe to write to the image.

unminify_js: bool

Unminify Javascript.

userscripts_path: Option<String>

Where to load userscripts from, if any. An empty string will load from the resources/user-agent-js directory, and if the option isn't passed userscripts won't be loaded.

replace_surrogates: bool

Replace unpaired surrogates in DOM strings with U+FFFD. See https://github.com/servo/servo/issues/6564

player_context: WindowGLContext

Window's GL context from application

event_loop_waker: Option<Box<dyn EventLoopWaker>>

A mechanism to force the compositor to process events.

visible: Cell<bool>layout_marker: DomRefCell<Rc<Cell<bool>>>

A shared marker for the validity of any cached layout values. A value of true indicates that any such values remain valid; any new layout that invalidates those values will cause the marker to be set to false.

current_event: DomRefCell<Option<Dom<Event>>>

https://dom.spec.whatwg.org/#window-current-event

Implementations

impl Window[src]

fn __assert_parent_type(&self)[src]

impl Window[src]

pub fn task_manager(&self) -> &TaskManager[src]

pub fn get_exists_mut_observer(&self) -> bool[src]

pub fn set_exists_mut_observer(&self)[src]

pub fn clear_js_runtime_for_script_deallocation(&self)[src]

pub fn discard_browsing_context(&self)[src]

A convenience method for https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded

pub fn ignore_all_tasks(&self)[src]

Cancel all current, and ignore all subsequently queued, tasks.

pub fn time_profiler_chan(&self) -> &TimeProfilerChan[src]

Get a sender to the time profiler thread.

pub fn origin(&self) -> &MutableOrigin[src]

pub fn get_cx(&self) -> JSContext[src]

pub fn get_js_runtime(&self) -> Ref<Option<Rc<Runtime>>>[src]

pub fn main_thread_script_chan(&self) -> &Sender<MainThreadScriptMsg>[src]

pub fn parent_info(&self) -> Option<PipelineId>[src]

pub fn new_script_pair(
    &self
) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>)
[src]

pub fn image_cache(&self) -> Arc<dyn ImageCache>[src]

pub fn window_proxy(&self) -> Root<Dom<WindowProxy>>[src]

This can panic if it is called after the browsing context has been discarded

pub fn undiscarded_window_proxy(&self) -> Option<Root<Dom<WindowProxy>>>[src]

Returns the window proxy if it has not been discarded. https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded

pub fn bluetooth_thread(&self) -> IpcSender<BluetoothRequest>[src]

pub fn bluetooth_extra_permission_data(&self) -> &BluetoothExtraPermissionData[src]

pub fn css_error_reporter(&self) -> Option<&dyn ParseErrorReporter>[src]

pub fn set_scroll_offsets(
    &self,
    offsets: HashMap<OpaqueNode, Vector2D<f32, LayoutPixel>>
)
[src]

Sets a new list of scroll offsets.

This is called when layout gives us new ones and WebRender is in use.

pub fn current_viewport(&self) -> UntypedRect<Au>[src]

pub(crate) fn webgl_chan(&self) -> Option<WebGLCommandSender>[src]

pub fn webxr_registry(&self) -> Registry[src]

fn new_paint_worklet(&self) -> Root<Dom<Worklet>>[src]

pub fn pending_image_notification(&self, response: PendingImageResponse)[src]

pub fn get_webrender_api_sender(&self) -> WebrenderIpcSender[src]

pub fn get_userscripts_path(&self) -> Option<String>[src]

pub fn replace_surrogates(&self) -> bool[src]

pub fn unminify_js(&self) -> bool[src]

pub fn get_player_context(&self) -> WindowGLContext[src]

pub fn get_event_loop_waker(&self) -> Option<Box<dyn EventLoopWaker>>[src]

pub fn dispatch_event_with_target_override(&self, event: &Event) -> EventStatus[src]

impl Window[src]

pub(crate) fn set_current_event(
    &self,
    event: Option<&Event>
) -> Option<Root<Dom<Event>>>
[src]

fn post_message_impl(
    &self,
    target_origin: &USVString,
    source_origin: ImmutableOrigin,
    source: &Window,
    cx: JSContext,
    message: HandleValue,
    transfer: CustomAutoRooterGuard<Vec<*mut JSObject>>
) -> Result<(), Error>
[src]

https://html.spec.whatwg.org/multipage/#window-post-message-steps

pub fn paint_worklet(&self) -> Root<Dom<Worklet>>[src]

pub fn get_navigation_start(&self) -> u64[src]

pub fn has_document(&self) -> bool[src]

pub fn cancel_all_tasks(&self)[src]

Cancels all the tasks associated with that window.

This sets the current task_manager.task_cancellers sentinel value to true and replaces it with a brand new one for future tasks.

pub fn cancel_all_tasks_from_source(&self, task_source_name: TaskSourceName)[src]

Cancels all the tasks from a given task source. This sets the current sentinel value to true and replaces it with a brand new one for future tasks.

pub fn clear_js_runtime(&self)[src]

pub fn scroll(&self, x_: f64, y_: f64, behavior: ScrollBehavior)[src]

pub fn perform_a_scroll(
    &self,
    x: f32,
    y: f32,
    scroll_id: ExternalScrollId,
    _behavior: ScrollBehavior,
    _element: Option<&Element>
)
[src]

pub fn update_viewport_for_scroll(&self, x: f32, y: f32)[src]

pub fn device_pixel_ratio(&self) -> Scale<f32, CSSPixel, DevicePixel>[src]

fn client_window(&self) -> (Size2D<u32, CSSPixel>, Point2D<i32, CSSPixel>)[src]

pub fn advance_animation_clock(&self, delta_ms: i32)[src]

Prepares to tick animations and then does a reflow which also advances the layout animation clock.

pub fn force_reflow(
    &self,
    reflow_goal: ReflowGoal,
    reason: ReflowReason,
    condition: Option<ReflowTriggerCondition>
) -> bool
[src]

Reflows the page unconditionally if possible and not suppressed. This method will wait for the layout thread to complete (but see the TODO below). If there is no window size yet, the page is presumed invisible and no reflow is performed. If reflow is suppressed, no reflow will be performed for ForDisplay goals.

TODO(pcwalton): Only wait for style recalc, since we have off-main-thread layout.

Returns true if layout actually happened, false otherwise.

pub fn reflow(&self, reflow_goal: ReflowGoal, reason: ReflowReason) -> bool[src]

Reflows the page if it's possible to do so and the page is dirty. This method will wait for the layout thread to complete (but see the TODO below). If there is no window size yet, the page is presumed invisible and no reflow is performed.

TODO(pcwalton): Only wait for style recalc, since we have off-main-thread layout.

Returns true if layout actually happened, false otherwise. This return value is useful for script queries, that wait for a lock that layout might hold if the first layout hasn't happened yet (which may happen in the only case a query reflow may bail out, that is, if the viewport size is not present). See #11223 for an example of that.

pub fn layout_reflow(&self, query_msg: QueryMsg) -> bool[src]

pub fn resolved_font_style_query(
    &self,
    node: &Node,
    value: String
) -> Option<ServoArc<Font>>
[src]

pub fn layout(&self) -> &dyn LayoutRPC[src]

pub fn content_box_query(&self, node: &Node) -> Option<UntypedRect<Au>>[src]

pub fn content_boxes_query(&self, node: &Node) -> Vec<UntypedRect<Au>>[src]

pub fn client_rect_query(&self, node: &Node) -> UntypedRect<i32>[src]

pub fn scroll_area_query(&self, node: &Node) -> UntypedRect<i32>[src]

pub fn scroll_offset_query(&self, node: &Node) -> Vector2D<f32, LayoutPixel>[src]

pub fn scroll_node(
    &self,
    node: &Node,
    x_: f64,
    y_: f64,
    behavior: ScrollBehavior
)
[src]

pub fn resolved_style_query(
    &self,
    element: TrustedNodeAddress,
    pseudo: Option<PseudoElement>,
    property: PropertyId
) -> DOMString
[src]

pub fn inner_window_dimensions_query(
    &self,
    browsing_context: BrowsingContextId
) -> Option<Size2D<f32, CSSPixel>>
[src]

pub fn offset_parent_query(
    &self,
    node: &Node
) -> (Option<Root<Dom<Element>>>, UntypedRect<Au>)
[src]

pub fn text_index_query(
    &self,
    node: &Node,
    point_in_node: UntypedPoint2D<f32>
) -> TextIndexResponse
[src]

pub fn init_window_proxy(&self, window_proxy: &WindowProxy)[src]

pub fn init_document(&self, document: &Document)[src]

pub fn load_url(
    &self,
    replace: HistoryEntryReplacement,
    force_reload: bool,
    load_data: LoadData
)
[src]

Commence a new URL load which will either replace this window or scroll to a fragment.

https://html.spec.whatwg.org/multipage/#navigating-across-documents

pub fn handle_fire_timer(&self, timer_id: TimerEventId)[src]

pub fn set_window_size(&self, size: WindowSizeData)[src]

pub fn window_size(&self) -> WindowSizeData[src]

pub fn get_url(&self) -> ServoUrl[src]

pub fn layout_chan(&self) -> Option<&Sender<Msg>>[src]

pub fn windowproxy_handler(&self) -> WindowProxyHandler[src]

pub fn get_pending_reflow_count(&self) -> u32[src]

pub fn add_pending_reflow(&self)[src]

pub fn set_resize_event(
    &self,
    event: WindowSizeData,
    event_type: WindowSizeType
)
[src]

pub fn steal_resize_event(&self) -> Option<(WindowSizeData, WindowSizeType)>[src]

pub fn set_page_clip_rect_with_new_viewport(
    &self,
    viewport: UntypedRect<f32>
) -> bool
[src]

pub fn suspend(&self)[src]

pub fn resume(&self)[src]

pub fn need_emit_timeline_marker(
    &self,
    timeline_type: TimelineMarkerType
) -> bool
[src]

pub fn emit_timeline_marker(&self, marker: TimelineMarker)[src]

pub fn set_devtools_timeline_markers(
    &self,
    markers: Vec<TimelineMarkerType>,
    reply: IpcSender<Option<TimelineMarker>>
)
[src]

pub fn drop_devtools_timeline_markers(&self, markers: Vec<TimelineMarkerType>)[src]

pub fn set_webdriver_script_chan(
    &self,
    chan: Option<IpcSender<WebDriverJSResult>>
)
[src]

pub fn is_alive(&self) -> bool[src]

pub fn is_top_level(&self) -> bool[src]

pub fn evaluate_media_queries_and_report_changes(&self)[src]

pub fn alter_resource_utilization(&self, visible: bool)[src]

Slow down/speed up timers based on visibility.

pub fn visible(&self) -> bool[src]

pub fn unminified_js_dir(&self) -> Option<String>[src]

pub fn local_script_source(&self) -> &Option<String>[src]

pub fn set_navigation_start(&self)[src]

pub fn send_to_embedder(&self, msg: EmbedderMsg)[src]

pub fn send_to_constellation(&self, msg: ScriptMsg)[src]

pub fn webrender_document(&self) -> DocumentId[src]

pub fn in_immersive_xr_session(&self) -> bool[src]

impl Window[src]

pub fn new(
    runtime: Rc<Runtime>,
    script_chan: MainThreadScriptChan,
    task_manager: TaskManager,
    image_cache_chan: Sender<ImageCacheMsg>,
    image_cache: Arc<dyn ImageCache>,
    resource_threads: ResourceThreads,
    bluetooth_thread: IpcSender<BluetoothRequest>,
    mem_profiler_chan: MemProfilerChan,
    time_profiler_chan: TimeProfilerChan,
    devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
    constellation_chan: ScriptToConstellationChan,
    control_chan: IpcSender<ConstellationControlMsg>,
    scheduler_chan: IpcSender<TimerSchedulerMsg>,
    layout_chan: Sender<Msg>,
    pipelineid: PipelineId,
    parent_info: Option<PipelineId>,
    window_size: WindowSizeData,
    origin: MutableOrigin,
    navigation_start: u64,
    navigation_start_precise: u64,
    webgl_chan: Option<WebGLChan>,
    webxr_registry: Registry,
    microtask_queue: Rc<MicrotaskQueue>,
    webrender_document: DocumentId,
    webrender_api_sender: WebrenderIpcSender,
    layout_is_busy: Arc<AtomicBool>,
    relayout_event: bool,
    prepare_for_screenshot: bool,
    unminify_js: bool,
    local_script_source: Option<String>,
    userscripts_path: Option<String>,
    is_headless: bool,
    replace_surrogates: bool,
    user_agent: Cow<'static, str>,
    player_context: WindowGLContext,
    event_loop_waker: Option<Box<dyn EventLoopWaker>>,
    gpu_id_hub: Arc<ParkMutex<Identities>>
) -> Root<Dom<Self>>
[src]

pub fn pipeline_id(&self) -> PipelineId[src]

pub fn cache_layout_value<T>(&self, value: T) -> LayoutValue<T> where
    T: Copy + JSTraceable + MallocSizeOf
[src]

Create a new cached instance of the given value.

impl Window[src]

pub fn post_message(
    &self,
    target_origin: Option<ImmutableOrigin>,
    source_origin: ImmutableOrigin,
    source: &WindowProxy,
    data: StructuredSerializedData
)
[src]

Trait Implementations

impl Castable for Window[src]

impl DerivedFrom<EventTarget> for Window[src]

impl DerivedFrom<GlobalScope> for Window[src]

impl DomObject for Window[src]

impl HasParent for Window[src]

type Parent = GlobalScope

fn as_parent(&self) -> &GlobalScope[src]

This is used in a type assertion to ensure that the source and webidls agree as to what the parent type is

impl IDLInterface for Window[src]

impl JSTraceable for Window[src]

impl MallocSizeOf for Window[src]

impl MutDomObject for Window[src]

impl PartialEq<Window> for Window[src]

impl ToJSValConvertible for Window[src]

impl WindowMethods for Window[src]

fn RequestAnimationFrame(&self, callback: Rc<FrameRequestCallback>) -> u32[src]

fn CancelAnimationFrame(&self, ident: u32)[src]

fn PostMessage_(
    &self,
    cx: JSContext,
    message: HandleValue,
    options: RootedTraceableBox<WindowPostMessageOptions>
) -> Result<(), Error>
[src]

Auto Trait Implementations

impl !RefUnwindSafe for Window

impl !Send for Window

impl !Sync for Window

impl Unpin for Window

impl !UnwindSafe for Window

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MaybeBoxed<Box<T>> for T[src]

impl<T> MaybeBoxed<T> for T[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> SetParameter for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]