mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Fix float placement bugs & add hacky non-percen heights to blocks.
This commit is contained in:
parent
650bd65460
commit
602334a316
3 changed files with 22 additions and 15 deletions
|
@ -249,12 +249,14 @@ impl BlockFlowData {
|
||||||
pub fn assign_height_block(@mut self, ctx: &mut LayoutContext) {
|
pub fn assign_height_block(@mut self, ctx: &mut LayoutContext) {
|
||||||
let mut cur_y = Au(0);
|
let mut cur_y = Au(0);
|
||||||
let mut top_offset = Au(0);
|
let mut top_offset = Au(0);
|
||||||
|
let mut bottom_offset = Au(0);
|
||||||
let mut left_offset = Au(0);
|
let mut left_offset = Au(0);
|
||||||
|
|
||||||
for self.box.iter().advance |&box| {
|
for self.box.iter().advance |&box| {
|
||||||
do box.with_model |model| {
|
do box.with_model |model| {
|
||||||
top_offset = model.margin.top + model.border.top + model.padding.top;
|
top_offset = model.margin.top + model.border.top + model.padding.top;
|
||||||
cur_y = cur_y + top_offset;
|
cur_y = cur_y + top_offset;
|
||||||
|
bottom_offset = model.margin.bottom + model.border.bottom + model.padding.bottom;
|
||||||
left_offset = model.offset();
|
left_offset = model.offset();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -277,7 +279,7 @@ impl BlockFlowData {
|
||||||
}
|
}
|
||||||
kid.assign_height(ctx);
|
kid.assign_height(ctx);
|
||||||
do kid.with_mut_base |child_node| {
|
do kid.with_mut_base |child_node| {
|
||||||
float_ctx = child_node.floats_out.translate(Point2D(Au(0), -child_node.position.size.height));
|
float_ctx = child_node.floats_out.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -288,12 +290,19 @@ impl BlockFlowData {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let height = if self.is_root {
|
let mut height = if self.is_root {
|
||||||
Au::max(ctx.screen_size.size.height, cur_y)
|
Au::max(ctx.screen_size.size.height, cur_y)
|
||||||
} else {
|
} else {
|
||||||
cur_y - top_offset
|
cur_y - top_offset
|
||||||
};
|
};
|
||||||
|
|
||||||
|
for self.box.each |&box| {
|
||||||
|
let style = box.style();
|
||||||
|
let maybe_height = MaybeAuto::from_height(style.height(), Au(0));
|
||||||
|
let maybe_height = maybe_height.spec_or_default(Au(0));
|
||||||
|
height = geometry::max(height, maybe_height);
|
||||||
|
}
|
||||||
|
|
||||||
let mut noncontent_height = Au(0);
|
let mut noncontent_height = Au(0);
|
||||||
self.box.map(|&box| {
|
self.box.map(|&box| {
|
||||||
do box.with_mut_base |base| {
|
do box.with_mut_base |base| {
|
||||||
|
@ -311,8 +320,8 @@ impl BlockFlowData {
|
||||||
//TODO(eatkinson): compute heights using the 'height' property.
|
//TODO(eatkinson): compute heights using the 'height' property.
|
||||||
self.common.position.size.height = height + noncontent_height;
|
self.common.position.size.height = height + noncontent_height;
|
||||||
|
|
||||||
|
let extra_height = height - (cur_y - top_offset) + bottom_offset;
|
||||||
self.common.floats_out = float_ctx.translate(Point2D(left_offset, self.common.position.size.height));
|
self.common.floats_out = float_ctx.translate(Point2D(left_offset, -extra_height));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_display_list_block<E:ExtraDisplayListData>(@mut self,
|
pub fn build_display_list_block<E:ExtraDisplayListData>(@mut self,
|
||||||
|
|
|
@ -8,7 +8,7 @@ use layout::display_list_builder::{DisplayListBuilder, ExtraDisplayListData};
|
||||||
use layout::display_list_builder::{FlowDisplayListBuilderMethods};
|
use layout::display_list_builder::{FlowDisplayListBuilderMethods};
|
||||||
use layout::flow::{FloatFlow, FlowData};
|
use layout::flow::{FloatFlow, FlowData};
|
||||||
use layout::model::{MaybeAuto};
|
use layout::model::{MaybeAuto};
|
||||||
use layout::float_context::{FloatContext, PlacementInfo, FloatLeft, FloatType};
|
use layout::float_context::{FloatContext, PlacementInfo, FloatType};
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
|
|
|
@ -196,14 +196,12 @@ impl FloatContextBase{
|
||||||
_ => fail!("Reached unreachable state when computing float area")
|
_ => fail!("Reached unreachable state when computing float area")
|
||||||
};
|
};
|
||||||
|
|
||||||
// When the window is smaller than the float, we will return a rect
|
// This assertion is too strong and fails in some cases. It is OK to
|
||||||
// with negative width.
|
// return negative widths since we check against that right away, but
|
||||||
assert!(max_left < min_right
|
// we should still undersrtand why they occur and add a stronger
|
||||||
|| max_left > max_x - self.offset.x
|
// assertion here.
|
||||||
|| min_right < Au(0) - self.offset.x
|
//assert!(max_left < min_right);
|
||||||
,"Float position error");
|
|
||||||
|
|
||||||
//TODO(eatkinson): do we need to do something similar for heights?
|
|
||||||
assert!(top < bottom, "Float position error");
|
assert!(top < bottom, "Float position error");
|
||||||
|
|
||||||
Some(Rect{
|
Some(Rect{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue