mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
* Fix the HTML event-loop: add a update the rendering task add rendering task source sketch structure to update the rendering resize steps composition events fix warnings in rendering task source refactor handling of composition events: put window and doc for pipeline on top set script as user interacting in update the rendering task fmt add todos for other steps, put all compositor handling logic in one place update the rendering: evaluate media queries and report changes update the rendering: update animations and send events update the rendering: run animation frames update the rendering: order docs put rendering related info on documents map tidy update the rendering: add issue numbers to todos update the rendering: reflow as last step update the rendering: add todo for top layer removals note rendering opportunity when ticking animations for testing fix double borrow crash in css/basic-transition fix faster reversing of transitions test undo ordering of docs bypass not fully-active pipeline task throttling for rendering tasks ensure tasks are dequed from task queue prioritize update the rendering task remove servo media stuff from set activity tidy debug update the rendering: perform microtask checkpoint after task tidy-up only run evaluate media queries if resized re-add evaluation of media queries for each rendering task, re-prioritize rendering tasks, re-add microtask checkpoint for all sequential messages re-structure resize steps, and their interaction with evaluating media queries and reacting to environment changes update the rendering: remove reflow call at the end update webmessaging expectations update to FAIL /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html update to FAIL load-pageshow-events-window-open.html add issue number for ordering of docs nits move batching of mouse move event to document info nits add doc for mouse move event index reset mouse move event index when taking pending compositor events fix replacing mouse move event nits * move update the rendering related data to document * move re-taking of tasks to try_recv * address nits * change task queue try_recv into take_tasks_and_recv, with nits * refactor process_pending_compositor_events * when updating the rendering, return early if script cannot continue running * use an instant for the last render opportunity time * nits * remove handle_tick_all_animations * use a vec for pending resize and compositor events * fix spec links * Fix a few other nits before landing --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
216 lines
7.2 KiB
Rust
216 lines
7.2 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
use std::collections::HashMap;
|
|
use std::sync::atomic::AtomicBool;
|
|
use std::sync::Arc;
|
|
|
|
use crate::dom::bindings::cell::DomRefCell;
|
|
use crate::task::TaskCanceller;
|
|
use crate::task_source::dom_manipulation::DOMManipulationTaskSource;
|
|
use crate::task_source::file_reading::FileReadingTaskSource;
|
|
use crate::task_source::gamepad::GamepadTaskSource;
|
|
use crate::task_source::history_traversal::HistoryTraversalTaskSource;
|
|
use crate::task_source::media_element::MediaElementTaskSource;
|
|
use crate::task_source::networking::NetworkingTaskSource;
|
|
use crate::task_source::performance_timeline::PerformanceTimelineTaskSource;
|
|
use crate::task_source::port_message::PortMessageQueue;
|
|
use crate::task_source::remote_event::RemoteEventTaskSource;
|
|
use crate::task_source::rendering::RenderingTaskSource;
|
|
use crate::task_source::timer::TimerTaskSource;
|
|
use crate::task_source::user_interaction::UserInteractionTaskSource;
|
|
use crate::task_source::websocket::WebsocketTaskSource;
|
|
use crate::task_source::TaskSourceName;
|
|
|
|
macro_rules! task_source_functions {
|
|
($self:ident,$with_canceller:ident,$task_source:ident,$task_source_type:ident,$task_source_name:ident) => {
|
|
pub fn $with_canceller(&$self) -> ($task_source_type, TaskCanceller) {
|
|
($self.$task_source.clone(), $self.task_canceller(TaskSourceName::$task_source_name))
|
|
}
|
|
|
|
pub fn $task_source(&$self) -> $task_source_type {
|
|
$self.$task_source.clone()
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(JSTraceable, MallocSizeOf)]
|
|
pub struct TaskManager {
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
pub task_cancellers: DomRefCell<HashMap<TaskSourceName, Arc<AtomicBool>>>,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
dom_manipulation_task_source: DOMManipulationTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
file_reading_task_source: FileReadingTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
gamepad_task_source: GamepadTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
history_traversal_task_source: HistoryTraversalTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
media_element_task_source: MediaElementTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
networking_task_source: NetworkingTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
performance_timeline_task_source: PerformanceTimelineTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
port_message_queue: PortMessageQueue,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
user_interaction_task_source: UserInteractionTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
remote_event_task_source: RemoteEventTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
rendering_task_source: RenderingTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
timer_task_source: TimerTaskSource,
|
|
#[ignore_malloc_size_of = "task sources are hard"]
|
|
websocket_task_source: WebsocketTaskSource,
|
|
}
|
|
|
|
impl TaskManager {
|
|
#[allow(clippy::too_many_arguments)]
|
|
pub fn new(
|
|
dom_manipulation_task_source: DOMManipulationTaskSource,
|
|
file_reading_task_source: FileReadingTaskSource,
|
|
gamepad_task_source: GamepadTaskSource,
|
|
history_traversal_task_source: HistoryTraversalTaskSource,
|
|
media_element_task_source: MediaElementTaskSource,
|
|
networking_task_source: NetworkingTaskSource,
|
|
performance_timeline_task_source: PerformanceTimelineTaskSource,
|
|
port_message_queue: PortMessageQueue,
|
|
user_interaction_task_source: UserInteractionTaskSource,
|
|
remote_event_task_source: RemoteEventTaskSource,
|
|
rendering_task_source: RenderingTaskSource,
|
|
timer_task_source: TimerTaskSource,
|
|
websocket_task_source: WebsocketTaskSource,
|
|
) -> Self {
|
|
TaskManager {
|
|
dom_manipulation_task_source,
|
|
file_reading_task_source,
|
|
gamepad_task_source,
|
|
history_traversal_task_source,
|
|
media_element_task_source,
|
|
networking_task_source,
|
|
performance_timeline_task_source,
|
|
port_message_queue,
|
|
user_interaction_task_source,
|
|
remote_event_task_source,
|
|
rendering_task_source,
|
|
timer_task_source,
|
|
websocket_task_source,
|
|
task_cancellers: Default::default(),
|
|
}
|
|
}
|
|
|
|
task_source_functions!(
|
|
self,
|
|
dom_manipulation_task_source_with_canceller,
|
|
dom_manipulation_task_source,
|
|
DOMManipulationTaskSource,
|
|
DOMManipulation
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
gamepad_task_source_with_canceller,
|
|
gamepad_task_source,
|
|
GamepadTaskSource,
|
|
Gamepad
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
media_element_task_source_with_canceller,
|
|
media_element_task_source,
|
|
MediaElementTaskSource,
|
|
MediaElement
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
user_interaction_task_source_with_canceller,
|
|
user_interaction_task_source,
|
|
UserInteractionTaskSource,
|
|
UserInteraction
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
networking_task_source_with_canceller,
|
|
networking_task_source,
|
|
NetworkingTaskSource,
|
|
Networking
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
file_reading_task_source_with_canceller,
|
|
file_reading_task_source,
|
|
FileReadingTaskSource,
|
|
FileReading
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
history_traversal_task_source_with_canceller,
|
|
history_traversal_task_source,
|
|
HistoryTraversalTaskSource,
|
|
HistoryTraversal
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
performance_timeline_task_source_with_canceller,
|
|
performance_timeline_task_source,
|
|
PerformanceTimelineTaskSource,
|
|
PerformanceTimeline
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
port_message_queue_with_canceller,
|
|
port_message_queue,
|
|
PortMessageQueue,
|
|
PortMessage
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
remote_event_task_source_with_canceller,
|
|
remote_event_task_source,
|
|
RemoteEventTaskSource,
|
|
RemoteEvent
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
rendering_task_source_with_canceller,
|
|
rendering_task_source,
|
|
RenderingTaskSource,
|
|
Rendering
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
timer_task_source_with_canceller,
|
|
timer_task_source,
|
|
TimerTaskSource,
|
|
Timer
|
|
);
|
|
|
|
task_source_functions!(
|
|
self,
|
|
websocket_task_source_with_canceller,
|
|
websocket_task_source,
|
|
WebsocketTaskSource,
|
|
Websocket
|
|
);
|
|
|
|
pub fn task_canceller(&self, name: TaskSourceName) -> TaskCanceller {
|
|
let mut flags = self.task_cancellers.borrow_mut();
|
|
let cancel_flag = flags.entry(name).or_default();
|
|
TaskCanceller {
|
|
cancelled: cancel_flag.clone(),
|
|
}
|
|
}
|
|
}
|