Skip to content

Commit

Permalink
Fix some writing mode mismatch assertions errors.
Browse files Browse the repository at this point in the history
The rendering is still wrong beause of servo#2795, but at least we get a rendering.

(This test change is just for readability, it should be equivalent to before.)
  • Loading branch information
SimonSapin committed Dec 18, 2014
1 parent eea49ee commit 7be30de
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
6 changes: 3 additions & 3 deletions components/layout/block.rs
Expand Up @@ -1783,9 +1783,9 @@ impl Flow for BlockFlow {
if !flow::base(kid).flags.contains(IS_ABSOLUTELY_POSITIONED) {
let kid_base = flow::mut_base(kid);
kid_base.stacking_relative_position =
origin_for_children +
(kid_base.position.start + relative_offset).to_physical(writing_mode,
container_size);
origin_for_children
+ kid_base.position.start.to_physical(kid_base.writing_mode, container_size)
+ relative_offset.to_physical(writing_mode);
}

flow::mut_base(kid).absolute_position_info = absolute_position_info_for_children;
Expand Down
11 changes: 9 additions & 2 deletions components/layout/flow.rs
Expand Up @@ -1191,20 +1191,27 @@ impl<'a> MutableFlowUtils for &'a mut Flow + 'a {
let mut overflow = my_position;

if self.is_block_container() {
let writing_mode = base(self).writing_mode;
// FIXME(#2795): Get the real container size
let container_size = Size2D::zero();
for kid in child_iter(self) {
if kid.is_store_overflow_delayed() {
// Absolute flows will be handled by their CB. If we are
// their CB, they will show up in `abs_descendants`.
continue;
}
let mut kid_overflow = base(kid).overflow;
let kid_base = base(kid);
let mut kid_overflow = kid_base.overflow.convert(
kid_base.writing_mode, writing_mode, container_size);
kid_overflow = kid_overflow.translate(&my_position.start);
overflow = overflow.union(&kid_overflow)
}

// FIXME(#2004, pcwalton): This is wrong for `position: fixed`.
for descendant_link in mut_base(self).abs_descendants.iter() {
let mut kid_overflow = base(descendant_link).overflow;
let kid_base = base(descendant_link);
let mut kid_overflow = kid_base.overflow.convert(
kid_base.writing_mode, writing_mode, container_size);
kid_overflow = kid_overflow.translate(&my_position.start);
overflow = overflow.union(&kid_overflow)
}
Expand Down
15 changes: 9 additions & 6 deletions tests/ref/overconstrained_block.html
Expand Up @@ -2,14 +2,17 @@
<head>
<title>Block with over-contrained margins+borders+padding+width = containing block width</title>
<style>
body { width: 300px; margin: 0 }
p { background: green; width: 200px; height: 100px; margin: 20px 70px }
body { width: 300px; margin: 0 0 0 400px }
div:nth-child(even) { direction: rtl }
div:nth-child(1) p, div:nth-child(2) p { margin: 20px 70px }
div:nth-child(3) p, div:nth-child(4) p { margin: 20px 120px }
p { background: green; width: 200px; height: 100px }
</style>
</head>
<body>
<p style="margin: 20px 70px"></p>
<p style="margin: 20px 70px; direction: rtl"></p>
<p style="margin: 20px 120px"></p>
<p style="margin: 20px 120px; direction: rtl"></p>
<div><p></p></div>
<div><p></p></div>
<div><p></p></div>
<div><p></p></div>
</body>
</html>

2 comments on commit 7be30de

@mbrubeck
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+

@jdm
Copy link

@jdm jdm commented on 7be30de Dec 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.