diff options
Diffstat (limited to 'components/layout/layout_task.rs')
-rw-r--r-- | components/layout/layout_task.rs | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 514e3e71e66..603a08491d0 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -1082,21 +1082,45 @@ impl LayoutTask { let document = unsafe { LayoutNode::new(&data.document) }; let document = document.as_document().unwrap(); + + debug!("layout: received layout request for: {}", self.url.serialize()); + + let mut rw_data = possibly_locked_rw_data.lock(); + let node: LayoutNode = match document.root_node() { - None => return, + None => { + // Since we cannot compute anything, give spec-required placeholders. + debug!("layout: No root node: bailing"); + match data.query_type { + ReflowQueryType::ContentBoxQuery(_) => { + rw_data.content_box_response = Rect::zero(); + }, + ReflowQueryType::ContentBoxesQuery(_) => { + rw_data.content_boxes_response = Vec::new(); + }, + ReflowQueryType::NodeGeometryQuery(_) => { + rw_data.client_rect_response = Rect::zero(); + }, + ReflowQueryType::ResolvedStyleQuery(_, _, _) => { + rw_data.resolved_style_response = None; + }, + ReflowQueryType::OffsetParentQuery(_) => { + rw_data.offset_parent_response = OffsetParentResponse::empty(); + }, + ReflowQueryType::NoQuery => {} + } + return; + }, Some(x) => x, }; - debug!("layout: received layout request for: {}", self.url.serialize()); if log_enabled!(log::LogLevel::Debug) { node.dump(); } - let mut rw_data = possibly_locked_rw_data.lock(); let stylesheets: Vec<&Stylesheet> = data.document_stylesheets.iter().map(|entry| &**entry) .collect(); let stylesheets_changed = data.stylesheets_changed; - let initial_viewport = data.window_size.initial_viewport; let old_viewport_size = self.viewport_size; let current_screen_size = Size2D::new(Au::from_f32_px(initial_viewport.width.get()), @@ -1145,10 +1169,8 @@ impl LayoutTask { let modified_elements = document.drain_modified_elements(); if !needs_dirtying { - for &(el, old_state) in modified_elements.iter() { - let hint = rw_data.stylist.restyle_hint_for_state_change(&el, - el.get_state(), - old_state); + for (el, snapshot) in modified_elements { + let hint = rw_data.stylist.compute_restyle_hint(&el, &snapshot, el.get_state()); el.note_restyle_hint(hint); } } |