mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Coalesce pending reflow messages so they don't queue up.
This commit is contained in:
parent
4e35b82770
commit
7503033e57
2 changed files with 17 additions and 2 deletions
|
@ -91,6 +91,9 @@ pub struct Page {
|
|||
|
||||
// Child Pages.
|
||||
pub children: Traceable<RefCell<Vec<Rc<Page>>>>,
|
||||
|
||||
/// Number of pending reflows that were sent while layout was active.
|
||||
pub pending_reflows: Cell<int>,
|
||||
}
|
||||
|
||||
pub struct PageIterator {
|
||||
|
@ -154,6 +157,7 @@ impl Page {
|
|||
resource_task: Untraceable::new(resource_task),
|
||||
constellation_chan: Untraceable::new(constellation_chan),
|
||||
children: Traceable::new(RefCell::new(vec!())),
|
||||
pending_reflows: Cell::new(0),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -513,6 +513,12 @@ impl ScriptTask {
|
|||
*layout_join_port = None;
|
||||
}
|
||||
self.compositor.set_ready_state(FinishedLoading);
|
||||
|
||||
if page.pending_reflows.get() > 0 {
|
||||
page.pending_reflows.set(0);
|
||||
page.damage(MatchSelectorsDocumentDamage);
|
||||
page.reflow(ReflowForDisplay, self.control_chan.clone(), self.compositor);
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles a navigate forward or backward message.
|
||||
|
@ -758,8 +764,13 @@ impl ScriptTask {
|
|||
let page = get_page(&*self.page.borrow(), pipeline_id);
|
||||
let frame = page.frame();
|
||||
if frame.is_some() {
|
||||
page.damage(MatchSelectorsDocumentDamage);
|
||||
page.reflow(ReflowForDisplay, self.control_chan.clone(), self.compositor)
|
||||
let in_layout = page.layout_join_port.deref().borrow().is_some();
|
||||
if in_layout {
|
||||
page.pending_reflows.set(page.pending_reflows.get() + 1);
|
||||
} else {
|
||||
page.damage(MatchSelectorsDocumentDamage);
|
||||
page.reflow(ReflowForDisplay, self.control_chan.clone(), self.compositor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue