mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
layout: Fix percentages in relatively positioned elements
This commit is contained in:
parent
2e5b210c95
commit
aabda89a90
4 changed files with 12 additions and 11 deletions
|
@ -1171,7 +1171,7 @@ impl BlockFlow {
|
|||
let mut info = *info;
|
||||
let mut rel_offset = Point2D(Au(0), Au(0));
|
||||
for fragment in self.box_.iter() {
|
||||
rel_offset = fragment.relative_position(&info.containing_block_size);
|
||||
rel_offset = fragment.relative_position(&info.relative_containing_block_size);
|
||||
|
||||
// Add the box that starts the block context.
|
||||
fragment.build_display_list(stacking_context,
|
||||
|
@ -1184,11 +1184,12 @@ impl BlockFlow {
|
|||
// For relatively-positioned descendants, the containing block formed by a block is
|
||||
// just the content box. The containing block for absolutely-positioned descendants,
|
||||
// on the other hand, only established if we are positioned.
|
||||
let container_block_size = fragment.content_box_size();
|
||||
info.relative_containing_block_size = fragment.content_box_size();
|
||||
if self.is_positioned() {
|
||||
info.absolute_containing_block_position = self.base.abs_position +
|
||||
info.absolute_containing_block_position =
|
||||
self.base.abs_position +
|
||||
self.generated_cb_position() +
|
||||
fragment.relative_position(&container_block_size)
|
||||
fragment.relative_position(&info.relative_containing_block_size)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ pub struct DisplayListBuilder<'a> {
|
|||
|
||||
/// Information needed at each step of the display list building traversal.
|
||||
pub struct DisplayListBuildingInfo {
|
||||
/// The size of the containing block.
|
||||
containing_block_size: Size2D<Au>,
|
||||
/// The absolute position of the absolute containing block.
|
||||
/// The size of the containing block for relatively-positioned descendants.
|
||||
relative_containing_block_size: Size2D<Au>,
|
||||
/// The position and size of the absolute containing block.
|
||||
absolute_containing_block_position: Point2D<Au>,
|
||||
/// Whether the absolute containing block forces positioned descendants to be layerized.
|
||||
layers_needed_for_positioned_flows: bool,
|
||||
|
|
|
@ -495,7 +495,7 @@ impl InlineFlow {
|
|||
debug!("Flow: building display list for {:u} inline boxes", self.boxes.len());
|
||||
|
||||
for box_ in self.boxes.iter() {
|
||||
let rel_offset: Point2D<Au> = box_.relative_position(&info.containing_block_size);
|
||||
let rel_offset = box_.relative_position(&info.relative_containing_block_size);
|
||||
box_.build_display_list(stacking_context,
|
||||
builder,
|
||||
info,
|
||||
|
|
|
@ -634,7 +634,7 @@ impl LayoutTask {
|
|||
dirty: flow::base(layout_root).position.clone(),
|
||||
};
|
||||
let display_list_building_info = DisplayListBuildingInfo {
|
||||
containing_block_size: flow::base(layout_root).position.size,
|
||||
relative_containing_block_size: flow::base(layout_root).position.size,
|
||||
absolute_containing_block_position: Point2D(Au(0), Au(0)),
|
||||
layers_needed_for_positioned_flows: false,
|
||||
};
|
||||
|
@ -672,10 +672,10 @@ impl LayoutTask {
|
|||
}
|
||||
}
|
||||
|
||||
let root_size = Size2D(display_list_building_info.containing_block_size
|
||||
let root_size = Size2D(display_list_building_info.relative_containing_block_size
|
||||
.width
|
||||
.to_nearest_px() as uint,
|
||||
display_list_building_info.containing_block_size
|
||||
display_list_building_info.relative_containing_block_size
|
||||
.height
|
||||
.to_nearest_px() as uint);
|
||||
let render_layer = RenderLayer {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue