From a58b01bc8690e101576ce3d1937243abb01f1147 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Wed, 7 Aug 2013 19:52:30 -0700 Subject: [PATCH] support in layout to send iframe sizes --- src/components/main/constellation.rs | 2 ++ src/components/main/layout/block.rs | 20 ++++++++++++++++++++ src/components/main/layout/model.rs | 6 ++++++ 3 files changed, 28 insertions(+) diff --git a/src/components/main/constellation.rs b/src/components/main/constellation.rs index 4b70eaf04ed..80bc29dad04 100644 --- a/src/components/main/constellation.rs +++ b/src/components/main/constellation.rs @@ -398,6 +398,7 @@ impl Constellation { } fn handle_frame_rect_msg(&mut self, pipeline_id: PipelineId, subpage_id: SubpageId, rect: Rect) { + debug!("Received frame rect %? from %?, %?", rect, pipeline_id, subpage_id); let mut already_sent = HashSet::new(); // If the subframe is in the current frame tree, the compositor needs the new size @@ -639,6 +640,7 @@ impl Constellation { // TODO(tkuehn): In fact, this kind of message might be provably // impossible to occur. if current_frame.contains(pipeline_id) { + debug!("updating compositor frame tree with %?", current_frame); self.set_ids(current_frame); return; } diff --git a/src/components/main/layout/block.rs b/src/components/main/layout/block.rs index b30794a0343..bd20995348e 100644 --- a/src/components/main/layout/block.rs +++ b/src/components/main/layout/block.rs @@ -14,6 +14,7 @@ use layout::float_context::{FloatContext, Invalid}; use std::cell::Cell; use geom::point::Point2D; +use geom::size::Size2D; use geom::rect::Rect; use gfx::display_list::DisplayList; use gfx::geometry::Au; @@ -364,6 +365,25 @@ impl BlockFlowData { list: &Cell>) -> bool { + if self.common.node.is_iframe_element() { + let x = self.common.abs_position.x + do self.box.map_default(Au(0)) |box| { + box.with_model(|model| model.margin.left + model.border.left + model.padding.left) + }; + let y = self.common.abs_position.y + do self.box.map_default(Au(0)) |box| { + box.with_model(|model| model.margin.top + model.border.top + model.padding.top) + }; + let w = self.common.position.size.width - do self.box.map_default(Au(0)) |box| { + box.with_model(|model| model.noncontent_width()) + }; + let h = self.common.position.size.height - do self.box.map_default(Au(0)) |box| { + box.with_model(|model| model.noncontent_height()) + }; + do self.common.node.with_mut_iframe_element |iframe_element| { + iframe_element.size.get_mut_ref().set_rect(Rect(Point2D(x.to_f32(), y.to_f32()), + Size2D(w.to_f32(), h.to_f32()))); + } + } + let abs_rect = Rect(self.common.abs_position, self.common.position.size); if !abs_rect.intersects(dirty) { return false; diff --git a/src/components/main/layout/model.rs b/src/components/main/layout/model.rs index f3c2a4ef85d..938a175bd03 100644 --- a/src/components/main/layout/model.rs +++ b/src/components/main/layout/model.rs @@ -119,6 +119,12 @@ impl BoxModel { left + right } + pub fn noncontent_height(&self) -> Au { + let top = self.margin.top + self.border.top + self.padding.top; + let bottom = self.margin.bottom + self.border.bottom + self.padding.bottom; + top + bottom + } + pub fn offset(&self) -> Au { self.margin.left + self.border.left + self.padding.left }