mirror of
https://github.com/servo/servo.git
synced 2025-06-25 17:44:33 +01:00
script: Don't do anything before the window size comes in.
This fixes the `getBoundingClientRect()` content test.
This commit is contained in:
parent
c5d81f13c1
commit
10150b0ec5
3 changed files with 23 additions and 21 deletions
|
@ -116,8 +116,8 @@ pub struct Page {
|
|||
/// What parts of the document are dirty, if any.
|
||||
damage: Option<DocumentDamage>,
|
||||
|
||||
/// The current size of the window, in pixels. If `None`, we do not know the window size yet.
|
||||
window_size: Option<Size2D<uint>>,
|
||||
/// The current size of the window, in pixels.
|
||||
window_size: Size2D<uint>,
|
||||
|
||||
js_info: Option<JSPageInfo>,
|
||||
|
||||
|
@ -146,7 +146,7 @@ pub struct PageTreeIterator<'self> {
|
|||
}
|
||||
|
||||
impl PageTree {
|
||||
fn new(id: PipelineId, layout_chan: LayoutChan) -> PageTree {
|
||||
fn new(id: PipelineId, layout_chan: LayoutChan, window_size: Size2D<uint>) -> PageTree {
|
||||
PageTree {
|
||||
page: @mut Page {
|
||||
id: id,
|
||||
|
@ -154,7 +154,7 @@ impl PageTree {
|
|||
layout_chan: layout_chan,
|
||||
layout_join_port: None,
|
||||
damage: None,
|
||||
window_size: None,
|
||||
window_size: window_size,
|
||||
js_info: None,
|
||||
url: None,
|
||||
next_subpage_id: SubpageId(0),
|
||||
|
@ -296,14 +296,6 @@ impl Page {
|
|||
}
|
||||
};
|
||||
|
||||
let window_size = match self.window_size {
|
||||
None => {
|
||||
debug!("not reflowing due to lack of a window size");
|
||||
return
|
||||
}
|
||||
Some(window_size) => window_size,
|
||||
};
|
||||
|
||||
match root {
|
||||
None => {},
|
||||
Some(root) => {
|
||||
|
@ -326,7 +318,7 @@ impl Page {
|
|||
document_root: root,
|
||||
url: self.url.get_ref().first().clone(),
|
||||
goal: goal,
|
||||
window_size: window_size,
|
||||
window_size: self.window_size,
|
||||
script_chan: script_chan,
|
||||
script_join_chan: join_chan,
|
||||
damage: replace(&mut self.damage, None).unwrap(),
|
||||
|
@ -437,12 +429,13 @@ impl ScriptTask {
|
|||
chan: ScriptChan,
|
||||
constellation_chan: ConstellationChan,
|
||||
resource_task: ResourceTask,
|
||||
img_cache_task: ImageCacheTask)
|
||||
img_cache_task: ImageCacheTask,
|
||||
window_size: Size2D<uint>)
|
||||
-> @mut ScriptTask {
|
||||
let js_runtime = js::rust::rt();
|
||||
|
||||
let script_task = @mut ScriptTask {
|
||||
page_tree: PageTree::new(id, layout_chan),
|
||||
page_tree: PageTree::new(id, layout_chan, window_size),
|
||||
|
||||
image_cache_task: img_cache_task,
|
||||
resource_task: resource_task,
|
||||
|
@ -474,7 +467,8 @@ impl ScriptTask {
|
|||
chan: ScriptChan,
|
||||
constellation_chan: ConstellationChan,
|
||||
resource_task: ResourceTask,
|
||||
image_cache_task: ImageCacheTask) {
|
||||
image_cache_task: ImageCacheTask,
|
||||
window_size: Size2D<uint>) {
|
||||
let parms = Cell::new((compositor,
|
||||
layout_chan,
|
||||
port,
|
||||
|
@ -500,7 +494,8 @@ impl ScriptTask {
|
|||
chan,
|
||||
constellation_chan,
|
||||
resource_task,
|
||||
image_cache_task);
|
||||
image_cache_task,
|
||||
window_size);
|
||||
script_task.start();
|
||||
}
|
||||
}
|
||||
|
@ -580,7 +575,7 @@ impl ScriptTask {
|
|||
let parent_page_tree = self.page_tree.find(old_id).expect("ScriptTask: received a layout
|
||||
whose parent has a PipelineId which does not correspond to a pipeline in the script
|
||||
task's page tree. This is a bug.");
|
||||
let new_page_tree = PageTree::new(new_id, layout_chan);
|
||||
let new_page_tree = PageTree::new(new_id, layout_chan, parent_page_tree.page.window_size);
|
||||
parent_page_tree.inner.push(new_page_tree);
|
||||
}
|
||||
|
||||
|
@ -634,7 +629,7 @@ impl ScriptTask {
|
|||
fn handle_resize_inactive_msg(&mut self, id: PipelineId, new_size: Size2D<uint>) {
|
||||
let page = self.page_tree.find(id).expect("Received resize message for PipelineId not associated
|
||||
with a page in the page tree. This is a bug.").page;
|
||||
page.window_size = Some(new_size);
|
||||
page.window_size = new_size;
|
||||
let last_loaded_url = replace(&mut page.url, None);
|
||||
for url in last_loaded_url.iter() {
|
||||
page.url = Some((url.first(), true));
|
||||
|
@ -846,7 +841,7 @@ impl ScriptTask {
|
|||
ResizeEvent(new_width, new_height) => {
|
||||
debug!("script got resize event: {:u}, {:u}", new_width, new_height);
|
||||
|
||||
page.window_size = Some(Size2D(new_width, new_height));
|
||||
page.window_size = Size2D(new_width, new_height);
|
||||
|
||||
if page.frame.is_some() {
|
||||
page.damage(ReflowDocumentDamage);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue