mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
implement basic infra for ResizeObserver (#31108)
This commit is contained in:
parent
3c1c395dfc
commit
3d78d60619
29 changed files with 706 additions and 4 deletions
|
@ -859,6 +859,13 @@ impl ScriptThreadFactory for ScriptThread {
|
|||
}
|
||||
|
||||
impl ScriptThread {
|
||||
pub fn note_rendering_opportunity(pipeline_id: PipelineId) {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
script_thread.rendering_opportunity(pipeline_id);
|
||||
})
|
||||
}
|
||||
|
||||
pub fn runtime_handle() -> ParentRuntime {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
|
@ -1692,7 +1699,17 @@ impl ScriptThread {
|
|||
// Run the animation frame callbacks.
|
||||
document.tick_all_animations();
|
||||
|
||||
// TODO(#31006): Implement the resize observer steps.
|
||||
// Run the resize observer steps.
|
||||
let _realm = enter_realm(&*document);
|
||||
let mut depth = Default::default();
|
||||
while document.gather_active_resize_observations_at_depth(&depth) {
|
||||
// Note: this will reflow the doc.
|
||||
depth = document.broadcast_active_resize_observations();
|
||||
}
|
||||
|
||||
if document.has_skipped_resize_observations() {
|
||||
document.deliver_resize_loop_error_notification();
|
||||
}
|
||||
|
||||
// TODO(#31870): Implement step 17: if the focused area of doc is not a focusable area,
|
||||
// then run the focusing steps for document's viewport.
|
||||
|
@ -1963,6 +1980,9 @@ impl ScriptThread {
|
|||
for document in docs.iter() {
|
||||
let _realm = enter_realm(&**document);
|
||||
document.maybe_queue_document_completion();
|
||||
|
||||
// Document load is a rendering opportunity.
|
||||
ScriptThread::note_rendering_opportunity(document.window().pipeline_id());
|
||||
}
|
||||
docs.clear();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue