mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Fix document load event firing after pipeline is closed.
This commit is contained in:
parent
fada39164c
commit
b84c6fa5db
3 changed files with 32 additions and 9 deletions
|
@ -296,7 +296,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
||||||
// If we own buffers in the compositor and we are not exiting completely, wait
|
// If we own buffers in the compositor and we are not exiting completely, wait
|
||||||
// for the compositor to return buffers, so that we can release them properly.
|
// for the compositor to return buffers, so that we can release them properly.
|
||||||
// When doing a complete exit, the compositor lets all buffers leak.
|
// When doing a complete exit, the compositor lets all buffers leak.
|
||||||
println!("PaintTask {:?}: Saw ExitMsg, {} buffers in use", self.id, self.used_buffer_count);
|
debug!("PaintTask {:?}: Saw ExitMsg, {} buffers in use", self.id, self.used_buffer_count);
|
||||||
waiting_for_compositor_buffers_to_exit = true;
|
waiting_for_compositor_buffers_to_exit = true;
|
||||||
exit_response_channel = response_channel;
|
exit_response_channel = response_channel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1830,13 +1830,17 @@ impl DocumentProgressHandler {
|
||||||
|
|
||||||
impl Runnable for DocumentProgressHandler {
|
impl Runnable for DocumentProgressHandler {
|
||||||
fn handler(self: Box<DocumentProgressHandler>) {
|
fn handler(self: Box<DocumentProgressHandler>) {
|
||||||
match self.task {
|
let document = self.addr.to_temporary().root();
|
||||||
DocumentProgressTask::DOMContentLoaded => {
|
let window = document.r().window().root();
|
||||||
self.dispatch_dom_content_loaded();
|
if window.r().is_alive() {
|
||||||
}
|
match self.task {
|
||||||
DocumentProgressTask::Load => {
|
DocumentProgressTask::DOMContentLoaded => {
|
||||||
self.set_ready_state_complete();
|
self.dispatch_dom_content_loaded();
|
||||||
self.dispatch_load();
|
}
|
||||||
|
DocumentProgressTask::Load => {
|
||||||
|
self.set_ready_state_complete();
|
||||||
|
self.dispatch_load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,14 @@ use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
use std::sync::mpsc::TryRecvError::{Empty, Disconnected};
|
use std::sync::mpsc::TryRecvError::{Empty, Disconnected};
|
||||||
use time;
|
use time;
|
||||||
|
|
||||||
|
/// Current state of the window object
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
|
#[jstraceable]
|
||||||
|
enum WindowState {
|
||||||
|
Alive,
|
||||||
|
Zombie, // Pipeline is closed, but the window hasn't been GCed yet.
|
||||||
|
}
|
||||||
|
|
||||||
/// Extra information concerning the reason for reflowing.
|
/// Extra information concerning the reason for reflowing.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ReflowReason {
|
pub enum ReflowReason {
|
||||||
|
@ -170,7 +178,10 @@ pub struct Window {
|
||||||
pending_reflow_count: Cell<u32>,
|
pending_reflow_count: Cell<u32>,
|
||||||
|
|
||||||
/// A channel for communicating results of async scripts back to the webdriver server
|
/// A channel for communicating results of async scripts back to the webdriver server
|
||||||
webdriver_script_chan: RefCell<Option<Sender<WebDriverJSResult>>>
|
webdriver_script_chan: RefCell<Option<Sender<WebDriverJSResult>>>,
|
||||||
|
|
||||||
|
/// The current state of the window object
|
||||||
|
current_state: Cell<WindowState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
@ -179,6 +190,7 @@ impl Window {
|
||||||
unsafe {
|
unsafe {
|
||||||
*self.js_runtime.borrow_for_script_deallocation() = None;
|
*self.js_runtime.borrow_for_script_deallocation() = None;
|
||||||
*self.browser_context.borrow_for_script_deallocation() = None;
|
*self.browser_context.borrow_for_script_deallocation() = None;
|
||||||
|
self.current_state.set(WindowState::Zombie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,6 +556,7 @@ pub trait WindowHelpers {
|
||||||
fn set_devtools_timeline_marker(self, marker: TimelineMarkerType, reply: Sender<TimelineMarker>);
|
fn set_devtools_timeline_marker(self, marker: TimelineMarkerType, reply: Sender<TimelineMarker>);
|
||||||
fn drop_devtools_timeline_markers(self);
|
fn drop_devtools_timeline_markers(self);
|
||||||
fn set_webdriver_script_chan(self, chan: Option<Sender<WebDriverJSResult>>);
|
fn set_webdriver_script_chan(self, chan: Option<Sender<WebDriverJSResult>>);
|
||||||
|
fn is_alive(self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ScriptHelpers {
|
pub trait ScriptHelpers {
|
||||||
|
@ -595,6 +608,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
// which causes a panic!
|
// which causes a panic!
|
||||||
self.Gc();
|
self.Gc();
|
||||||
|
|
||||||
|
self.current_state.set(WindowState::Zombie);
|
||||||
*self.js_runtime.borrow_mut() = None;
|
*self.js_runtime.borrow_mut() = None;
|
||||||
*self.browser_context.borrow_mut() = None;
|
*self.browser_context.borrow_mut() = None;
|
||||||
}
|
}
|
||||||
|
@ -916,6 +930,10 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
|
||||||
fn set_webdriver_script_chan(self, chan: Option<Sender<WebDriverJSResult>>) {
|
fn set_webdriver_script_chan(self, chan: Option<Sender<WebDriverJSResult>>) {
|
||||||
*self.webdriver_script_chan.borrow_mut() = chan;
|
*self.webdriver_script_chan.borrow_mut() = chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_alive(self) -> bool {
|
||||||
|
self.current_state.get() == WindowState::Alive
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
@ -979,6 +997,7 @@ impl Window {
|
||||||
layout_join_port: DOMRefCell::new(None),
|
layout_join_port: DOMRefCell::new(None),
|
||||||
window_size: Cell::new(window_size),
|
window_size: Cell::new(window_size),
|
||||||
pending_reflow_count: Cell::new(0),
|
pending_reflow_count: Cell::new(0),
|
||||||
|
current_state: Cell::new(WindowState::Alive),
|
||||||
|
|
||||||
devtools_marker_sender: RefCell::new(None),
|
devtools_marker_sender: RefCell::new(None),
|
||||||
devtools_markers: RefCell::new(HashSet::new()),
|
devtools_markers: RefCell::new(HashSet::new()),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue