Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make content changing trigger reflow instantly. #424

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Make content changing trigger reflow instantly.

  • Loading branch information
jdm committed May 20, 2013
commit bb16cf0e7f36eed67305d015098dae05bfab7b94
@@ -4,11 +4,10 @@

use dom::bindings::document;
use dom::bindings::utils::{DOMString, WrapperCache};
use dom::event::ReflowEvent;
use dom::htmlcollection::HTMLCollection;
use dom::node::AbstractNode;
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 servo_util::tree::{TreeNodeRef, TreeUtils};
@@ -65,7 +64,7 @@ pub impl Document {

fn content_changed(&self) {
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::window;
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 core::comm::{Port, Chan, SharedChan};
@@ -82,6 +82,12 @@ pub impl Window {
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)
-> @mut Window {
let script_chan_copy = script_chan.clone();
@@ -102,8 +108,10 @@ pub impl Window {
script_context: script_context,
};

let compartment = global_script_context().js_compartment;
window::create(compartment, win);
unsafe {
let compartment = (*script_context).js_compartment;
window::create(compartment, 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
/// layout task, and then request a new layout run. It won't wait for the new layout
/// computation to finish.
@@ -412,7 +418,6 @@ impl ScriptContext {

/// Sends the given query to layout.
pub fn query_layout(&mut self, query: LayoutQuery) -> LayoutQueryResponse {
//self.relayout();
self.join_layout();

let (response_port, response_chan) = comm::stream();
@@ -6,7 +6,6 @@ var start = new Date();
for (var i = 0; i < count; i++) {
div.setAttribute('id', 'styled');
div.getBoundingClientRect();
window.alert(i);
}
var stop = new Date();
window.alert((stop - start) / count * 1e6);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.