mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Auto merge of #21111 - gterzian:implement_document_load_cancellation, r=jdm
Implement document load cancellation <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #19309 fix #21114 fix #21113 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21111) <!-- Reviewable:end -->
This commit is contained in:
commit
076198fe80
19 changed files with 195 additions and 104 deletions
|
@ -12,6 +12,7 @@ use dom::bindings::cell::DomRefCell;
|
|||
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState};
|
||||
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||
use dom::bindings::codegen::Bindings::HistoryBinding::HistoryBinding::HistoryMethods;
|
||||
use dom::bindings::codegen::Bindings::MediaQueryListBinding::MediaQueryListBinding::MediaQueryListMethods;
|
||||
use dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState;
|
||||
use dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::{self, FrameRequestCallback, WindowMethods};
|
||||
|
@ -27,6 +28,7 @@ use dom::bindings::str::{DOMString, USVString};
|
|||
use dom::bindings::structuredclone::StructuredCloneData;
|
||||
use dom::bindings::trace::RootedTraceableBox;
|
||||
use dom::bindings::utils::{GlobalStaticData, WindowProxyHandler};
|
||||
use dom::bindings::weakref::DOMTracker;
|
||||
use dom::bluetooth::BluetoothExtraPermissionData;
|
||||
use dom::crypto::Crypto;
|
||||
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
|
||||
|
@ -39,7 +41,8 @@ use dom::globalscope::GlobalScope;
|
|||
use dom::hashchangeevent::HashChangeEvent;
|
||||
use dom::history::History;
|
||||
use dom::location::Location;
|
||||
use dom::mediaquerylist::{MediaQueryList, WeakMediaQueryListVec};
|
||||
use dom::mediaquerylist::{MediaQueryList, MediaQueryListMatchState};
|
||||
use dom::mediaquerylistevent::MediaQueryListEvent;
|
||||
use dom::messageevent::MessageEvent;
|
||||
use dom::navigator::Navigator;
|
||||
use dom::node::{Node, NodeDamage, document_from_node, from_untrusted_node_address};
|
||||
|
@ -263,7 +266,7 @@ pub struct Window {
|
|||
scroll_offsets: DomRefCell<HashMap<UntrustedNodeAddress, Vector2D<f32>>>,
|
||||
|
||||
/// All the MediaQueryLists we need to update
|
||||
media_query_lists: WeakMediaQueryListVec,
|
||||
media_query_lists: DOMTracker<MediaQueryList>,
|
||||
|
||||
test_runner: MutNullableDom<TestRunner>,
|
||||
|
||||
|
@ -555,6 +558,13 @@ impl WindowMethods for Window {
|
|||
receiver.recv().unwrap();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-window-stop
|
||||
fn Stop(&self) {
|
||||
// TODO: Cancel ongoing navigation.
|
||||
let doc = self.Document();
|
||||
doc.abort();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-window-closed
|
||||
fn Closed(&self) -> bool {
|
||||
self.window_proxy.get()
|
||||
|
@ -1048,7 +1058,7 @@ impl WindowMethods for Window {
|
|||
media_queries::MediaList::parse(&context, &mut parser);
|
||||
let document = self.Document();
|
||||
let mql = MediaQueryList::new(&document, media_query_list);
|
||||
self.media_query_lists.push(&*mql);
|
||||
self.media_query_lists.track(&*mql);
|
||||
mql
|
||||
}
|
||||
|
||||
|
@ -1113,6 +1123,16 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
/// 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 cancel_all_tasks_from_source(&self, task_source_name: TaskSourceName) {
|
||||
let mut ignore_flags = self.ignore_further_async_events.borrow_mut();
|
||||
let flag = ignore_flags.entry(task_source_name).or_insert(Default::default());
|
||||
let cancelled = mem::replace(&mut *flag, Default::default());
|
||||
cancelled.store(true, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
pub fn clear_js_runtime(&self) {
|
||||
// We tear down the active document, which causes all the attached
|
||||
// nodes to dispose of their layout data. This messages the layout
|
||||
|
@ -1777,8 +1797,25 @@ impl Window {
|
|||
self.parent_info.is_none()
|
||||
}
|
||||
|
||||
/// Evaluate media query lists and report changes
|
||||
/// <https://drafts.csswg.org/cssom-view/#evaluate-media-queries-and-report-changes>
|
||||
pub fn evaluate_media_queries_and_report_changes(&self) {
|
||||
self.media_query_lists.evaluate_and_report_changes();
|
||||
rooted_vec!(let mut mql_list);
|
||||
self.media_query_lists.for_each(|mql| {
|
||||
if let MediaQueryListMatchState::Changed(_) = mql.evaluate_changes() {
|
||||
// Recording list of changed Media Queries
|
||||
mql_list.push(Dom::from_ref(&*mql));
|
||||
}
|
||||
});
|
||||
// Sending change events for all changed Media Queries
|
||||
for mql in mql_list.iter() {
|
||||
let event = MediaQueryListEvent::new(&mql.global(),
|
||||
atom!("change"),
|
||||
false, false,
|
||||
mql.Media(),
|
||||
mql.Matches());
|
||||
event.upcast::<Event>().fire(mql.upcast::<EventTarget>());
|
||||
}
|
||||
}
|
||||
|
||||
/// Slow down/speed up timers based on visibility.
|
||||
|
@ -1917,7 +1954,7 @@ impl Window {
|
|||
ignore_further_async_events: Default::default(),
|
||||
error_reporter,
|
||||
scroll_offsets: Default::default(),
|
||||
media_query_lists: WeakMediaQueryListVec::new(),
|
||||
media_query_lists: DOMTracker::new(),
|
||||
test_runner: Default::default(),
|
||||
webgl_chan,
|
||||
webvr_chan,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue