Get rid of reflow_all

This refactoring should not alter behavior.
This commit is contained in:
Keegan McAllister 2013-12-10 13:42:30 -08:00
parent dd0bb08927
commit 39fc9eb868
2 changed files with 13 additions and 20 deletions

View file

@ -12,7 +12,7 @@ use dom::node::{AbstractNode, ScriptView};
use dom::location::Location;
use dom::navigator::Navigator;
use layout_interface::ReflowForDisplay;
use layout_interface::{ReflowForDisplay, ContentChangedDocumentDamage};
use script_task::{ExitWindowMsg, FireTimerMsg, Page, ScriptChan};
use servo_msg::compositor_msg::ScriptListener;
use servo_net::image_cache_task::ImageCacheTask;
@ -189,7 +189,8 @@ impl Window {
// FIXME This should probably be ReflowForQuery, not Display. All queries currently
// currently rely on the display list, which means we can't destroy it by
// doing a query reflow.
self.page.reflow_all(ReflowForDisplay, self.script_chan.clone(), self.compositor);
self.page.damage(ContentChangedDocumentDamage);
self.page.reflow(ReflowForDisplay, self.script_chan.clone(), self.compositor);
}
pub fn wait_until_safe_to_modify_dom(&self) {

View file

@ -224,8 +224,11 @@ impl<'self> Iterator<@mut Page> for PageTreeIterator<'self> {
impl Page {
/// Adds the given damage.
fn damage(&mut self, level: DocumentDamageLevel) {
let root = self.frame.get_ref().document.document().GetDocumentElement();
pub fn damage(&mut self, level: DocumentDamageLevel) {
let root = match self.frame {
None => return,
Some(ref frame) => frame.document.document().GetDocumentElement()
};
match root {
None => {},
Some(root) => {
@ -282,7 +285,7 @@ impl Page {
/// computation to finish.
///
/// This function fails if there is no root frame.
fn reflow(&mut self, goal: ReflowGoal, script_chan: ScriptChan, compositor: @ScriptListener) {
pub fn reflow(&mut self, goal: ReflowGoal, script_chan: ScriptChan, compositor: @ScriptListener) {
let root = match self.frame {
None => return,
Some(ref frame) => {
@ -325,19 +328,6 @@ impl Page {
}
}
/// Reflows the entire document.
///
/// FIXME: This should basically never be used.
pub fn reflow_all(&mut self, goal: ReflowGoal, script_chan: ScriptChan, compositor: @ScriptListener) {
if self.frame.is_some() {
self.damage(ContentChangedDocumentDamage);
}
//FIXME: In the case where an initial reflow is required, we should always
// ReflowForDisplay, regardless of the original goal.
self.reflow(goal, script_chan, compositor)
}
pub fn initialize_js_info(&mut self, js_context: @Cx, global: *JSObject) {
// Note that the order that these variables are initialized is _not_ arbitrary. Switching them around
// can -- and likely will -- lead to things breaking.
@ -599,7 +589,8 @@ impl ScriptTask {
}
// We don't know what the script changed, so for now we will do a total redisplay.
page.reflow_all(ReflowForDisplay, self.chan.clone(), self.compositor);
page.damage(ContentChangedDocumentDamage);
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor);
}
/// Handles a notification that reflow completed.
@ -683,7 +674,8 @@ impl ScriptTask {
if *loaded == url {
page.url = Some((loaded.clone(), false));
if needs_reflow {
page.reflow_all(ReflowForDisplay, self.chan.clone(), self.compositor);
page.damage(ContentChangedDocumentDamage);
page.reflow(ReflowForDisplay, self.chan.clone(), self.compositor);
}
return;
}