mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
Make content changing trigger reflow instantly.
This commit is contained in:
parent
621da6b4cd
commit
bb16cf0e7f
4 changed files with 19 additions and 8 deletions
|
@ -4,11 +4,10 @@
|
||||||
|
|
||||||
use dom::bindings::document;
|
use dom::bindings::document;
|
||||||
use dom::bindings::utils::{DOMString, WrapperCache};
|
use dom::bindings::utils::{DOMString, WrapperCache};
|
||||||
use dom::event::ReflowEvent;
|
|
||||||
use dom::htmlcollection::HTMLCollection;
|
use dom::htmlcollection::HTMLCollection;
|
||||||
use dom::node::AbstractNode;
|
use dom::node::AbstractNode;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use scripting::script_task::{SendEventMsg, global_script_context};
|
use scripting::script_task::global_script_context;
|
||||||
|
|
||||||
use js::jsapi::bindgen::{JS_AddObjectRoot, JS_RemoveObjectRoot};
|
use js::jsapi::bindgen::{JS_AddObjectRoot, JS_RemoveObjectRoot};
|
||||||
use servo_util::tree::{TreeNodeRef, TreeUtils};
|
use servo_util::tree::{TreeNodeRef, TreeUtils};
|
||||||
|
@ -65,7 +64,7 @@ pub impl Document {
|
||||||
|
|
||||||
fn content_changed(&self) {
|
fn content_changed(&self) {
|
||||||
for self.window.each |window| {
|
for self.window.each |window| {
|
||||||
window.script_chan.send(SendEventMsg(ReflowEvent))
|
window.content_changed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::utils::WrapperCache;
|
use dom::bindings::utils::WrapperCache;
|
||||||
use dom::bindings::window;
|
use dom::bindings::window;
|
||||||
use scripting::script_task::{ExitMsg, FireTimerMsg, ScriptMsg, ScriptContext};
|
use scripting::script_task::{ExitMsg, FireTimerMsg, ScriptMsg, ScriptContext};
|
||||||
use scripting::script_task::{global_script_context};
|
use layout::layout_task::MatchSelectorsDamage;
|
||||||
use util::task::spawn_listener;
|
use util::task::spawn_listener;
|
||||||
|
|
||||||
use core::comm::{Port, Chan, SharedChan};
|
use core::comm::{Port, Chan, SharedChan};
|
||||||
|
@ -82,6 +82,12 @@ pub impl Window {
|
||||||
TimerMessage_Fire(~TimerData(argc, argv)));
|
TimerMessage_Fire(~TimerData(argc, argv)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn content_changed(&self) {
|
||||||
|
unsafe {
|
||||||
|
(*self.script_context).trigger_relayout(MatchSelectorsDamage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new(script_chan: SharedChan<ScriptMsg>, script_context: *mut ScriptContext)
|
pub fn new(script_chan: SharedChan<ScriptMsg>, script_context: *mut ScriptContext)
|
||||||
-> @mut Window {
|
-> @mut Window {
|
||||||
let script_chan_copy = script_chan.clone();
|
let script_chan_copy = script_chan.clone();
|
||||||
|
@ -102,8 +108,10 @@ pub impl Window {
|
||||||
script_context: script_context,
|
script_context: script_context,
|
||||||
};
|
};
|
||||||
|
|
||||||
let compartment = global_script_context().js_compartment;
|
unsafe {
|
||||||
window::create(compartment, win);
|
let compartment = (*script_context).js_compartment;
|
||||||
|
window::create(compartment, win);
|
||||||
|
}
|
||||||
win
|
win
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,6 +375,12 @@ impl ScriptContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Initiate an asynchronous relayout operation
|
||||||
|
pub fn trigger_relayout(&mut self, damage: Damage) {
|
||||||
|
self.damage.add(damage);
|
||||||
|
self.relayout();
|
||||||
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
/// layout task, and then request a new layout run. It won't wait for the new layout
|
/// layout task, and then request a new layout run. It won't wait for the new layout
|
||||||
/// computation to finish.
|
/// computation to finish.
|
||||||
|
@ -412,7 +418,6 @@ impl ScriptContext {
|
||||||
|
|
||||||
/// Sends the given query to layout.
|
/// Sends the given query to layout.
|
||||||
pub fn query_layout(&mut self, query: LayoutQuery) -> LayoutQueryResponse {
|
pub fn query_layout(&mut self, query: LayoutQuery) -> LayoutQueryResponse {
|
||||||
//self.relayout();
|
|
||||||
self.join_layout();
|
self.join_layout();
|
||||||
|
|
||||||
let (response_port, response_chan) = comm::stream();
|
let (response_port, response_chan) = comm::stream();
|
||||||
|
|
|
@ -6,7 +6,6 @@ var start = new Date();
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
div.setAttribute('id', 'styled');
|
div.setAttribute('id', 'styled');
|
||||||
div.getBoundingClientRect();
|
div.getBoundingClientRect();
|
||||||
window.alert(i);
|
|
||||||
}
|
}
|
||||||
var stop = new Date();
|
var stop = new Date();
|
||||||
window.alert((stop - start) / count * 1e6);
|
window.alert((stop - start) / count * 1e6);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue