mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Stop rendering when script queries layout
This commit is contained in:
parent
e6ff135c01
commit
8d3b6aefa8
3 changed files with 42 additions and 28 deletions
|
@ -36,7 +36,7 @@ use script::layout_interface::{AddStylesheetMsg, BuildData, BuildMsg, ContentBox
|
||||||
use script::layout_interface::{HitTestQuery, ContentBoxResponse, HitTestResponse};
|
use script::layout_interface::{HitTestQuery, ContentBoxResponse, HitTestResponse};
|
||||||
use script::layout_interface::{ContentBoxesQuery, ContentBoxesResponse, ExitMsg, LayoutQuery};
|
use script::layout_interface::{ContentBoxesQuery, ContentBoxesResponse, ExitMsg, LayoutQuery};
|
||||||
use script::layout_interface::{LayoutResponse, LayoutTask, MatchSelectorsDamage, Msg, NoDamage};
|
use script::layout_interface::{LayoutResponse, LayoutTask, MatchSelectorsDamage, Msg, NoDamage};
|
||||||
use script::layout_interface::{QueryMsg, ReflowDamage};
|
use script::layout_interface::{QueryMsg, ReflowDamage, ReflowForDisplay};
|
||||||
use script::script_task::{ScriptMsg, SendEventMsg};
|
use script::script_task::{ScriptMsg, SendEventMsg};
|
||||||
use servo_net::image_cache_task::{ImageCacheTask, ImageResponseMsg};
|
use servo_net::image_cache_task::{ImageCacheTask, ImageResponseMsg};
|
||||||
use servo_net::local_image_cache::LocalImageCache;
|
use servo_net::local_image_cache::LocalImageCache;
|
||||||
|
@ -227,7 +227,8 @@ impl Layout {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the display list, and send it to the renderer.
|
// Build the display list if necessary, and send it to the renderer.
|
||||||
|
if data.goal == ReflowForDisplay {
|
||||||
do profile(time::LayoutDispListBuildCategory, self.profiler_chan.clone()) {
|
do profile(time::LayoutDispListBuildCategory, self.profiler_chan.clone()) {
|
||||||
let builder = DisplayListBuilder {
|
let builder = DisplayListBuilder {
|
||||||
ctx: &layout_ctx,
|
ctx: &layout_ctx,
|
||||||
|
@ -250,6 +251,7 @@ impl Layout {
|
||||||
|
|
||||||
self.render_task.channel.send(RenderMsg(render_layer));
|
self.render_task.channel.send(RenderMsg(render_layer));
|
||||||
} // time(layout: display list building)
|
} // time(layout: display list building)
|
||||||
|
}
|
||||||
|
|
||||||
// Tell script that we're done.
|
// Tell script that we're done.
|
||||||
data.script_join_chan.send(());
|
data.script_join_chan.send(());
|
||||||
|
|
|
@ -86,11 +86,22 @@ impl Damage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Why we're doing reflow.
|
||||||
|
#[deriving(Eq)]
|
||||||
|
pub enum ReflowGoal {
|
||||||
|
/// We're reflowing in order to send a display list to the screen.
|
||||||
|
ReflowForDisplay,
|
||||||
|
/// We're reflowing in order to satisfy a script query. No display list will be created.
|
||||||
|
ReflowForScriptQuery,
|
||||||
|
}
|
||||||
|
|
||||||
/// Information needed for a reflow.
|
/// Information needed for a reflow.
|
||||||
pub struct BuildData {
|
pub struct BuildData {
|
||||||
node: AbstractNode<ScriptView>,
|
node: AbstractNode<ScriptView>,
|
||||||
/// What reflow needs to be done.
|
/// What reflow needs to be done.
|
||||||
damage: Damage,
|
damage: Damage,
|
||||||
|
/// The goal of reflow: either to render to the screen or to flush layout info for script.
|
||||||
|
goal: ReflowGoal,
|
||||||
/// The URL of the page.
|
/// The URL of the page.
|
||||||
url: Url,
|
url: Url,
|
||||||
/// The channel through which messages can be sent back to the script task.
|
/// The channel through which messages can be sent back to the script task.
|
||||||
|
|
|
@ -12,7 +12,7 @@ use dom::node::define_bindings;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use layout_interface::{AddStylesheetMsg, BuildData, BuildMsg, Damage, LayoutQuery, HitTestQuery};
|
use layout_interface::{AddStylesheetMsg, BuildData, BuildMsg, Damage, LayoutQuery, HitTestQuery};
|
||||||
use layout_interface::{LayoutResponse, HitTestResponse, LayoutTask, MatchSelectorsDamage, NoDamage};
|
use layout_interface::{LayoutResponse, HitTestResponse, LayoutTask, MatchSelectorsDamage, NoDamage};
|
||||||
use layout_interface::{QueryMsg, ReflowDamage};
|
use layout_interface::{QueryMsg, ReflowDamage, ReflowForDisplay, ReflowForScriptQuery, ReflowGoal};
|
||||||
use layout_interface;
|
use layout_interface;
|
||||||
|
|
||||||
use core::cast::transmute;
|
use core::cast::transmute;
|
||||||
|
@ -283,7 +283,7 @@ impl ScriptContext {
|
||||||
null(),
|
null(),
|
||||||
&rval);
|
&rval);
|
||||||
|
|
||||||
self.relayout()
|
self.relayout(ReflowForScriptQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles a request to exit the script task and shut down layout.
|
/// Handles a request to exit the script task and shut down layout.
|
||||||
|
@ -349,7 +349,7 @@ impl ScriptContext {
|
||||||
|
|
||||||
// Perform the initial reflow.
|
// Perform the initial reflow.
|
||||||
self.damage.add(MatchSelectorsDamage);
|
self.damage.add(MatchSelectorsDamage);
|
||||||
self.relayout();
|
self.relayout(ReflowForDisplay);
|
||||||
|
|
||||||
// Define debug functions.
|
// Define debug functions.
|
||||||
self.js_compartment.define_functions(debug_fns);
|
self.js_compartment.define_functions(debug_fns);
|
||||||
|
@ -383,10 +383,10 @@ impl ScriptContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initiate an asynchronous relayout operation
|
/// Initiate an asynchronous relayout operation to handle a script layout query.
|
||||||
pub fn trigger_relayout(&mut self, damage: Damage) {
|
pub fn trigger_relayout(&mut self, damage: Damage) {
|
||||||
self.damage.add(damage);
|
self.damage.add(damage);
|
||||||
self.relayout();
|
self.relayout(ReflowForScriptQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This method will wait until the layout task has completed its current action, join the
|
/// This method will wait until the layout task has completed its current action, join the
|
||||||
|
@ -394,7 +394,7 @@ impl ScriptContext {
|
||||||
/// computation to finish.
|
/// computation to finish.
|
||||||
///
|
///
|
||||||
/// This function fails if there is no root frame.
|
/// This function fails if there is no root frame.
|
||||||
fn relayout(&mut self) {
|
fn relayout(&mut self, goal: ReflowGoal) {
|
||||||
debug!("script: performing relayout");
|
debug!("script: performing relayout");
|
||||||
|
|
||||||
// Now, join the layout so that they will see the latest changes we have made.
|
// Now, join the layout so that they will see the latest changes we have made.
|
||||||
|
@ -411,6 +411,7 @@ impl ScriptContext {
|
||||||
let data = ~BuildData {
|
let data = ~BuildData {
|
||||||
node: root_frame.document.root,
|
node: root_frame.document.root,
|
||||||
url: copy root_frame.url,
|
url: copy root_frame.url,
|
||||||
|
goal: goal,
|
||||||
script_chan: self.script_chan.clone(),
|
script_chan: self.script_chan.clone(),
|
||||||
window_size: self.window_size,
|
window_size: self.window_size,
|
||||||
script_join_chan: join_chan,
|
script_join_chan: join_chan,
|
||||||
|
@ -445,7 +446,7 @@ impl ScriptContext {
|
||||||
self.window_size = Size2D(new_width, new_height);
|
self.window_size = Size2D(new_width, new_height);
|
||||||
|
|
||||||
if self.root_frame.is_some() {
|
if self.root_frame.is_some() {
|
||||||
self.relayout()
|
self.relayout(ReflowForDisplay)
|
||||||
}
|
}
|
||||||
|
|
||||||
response_chan.send(())
|
response_chan.send(())
|
||||||
|
@ -457,7 +458,7 @@ impl ScriptContext {
|
||||||
self.damage.add(MatchSelectorsDamage);
|
self.damage.add(MatchSelectorsDamage);
|
||||||
|
|
||||||
if self.root_frame.is_some() {
|
if self.root_frame.is_some() {
|
||||||
self.relayout()
|
self.relayout(ReflowForDisplay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue