Skip to content

Commit

Permalink
Position layers using their absolute position
Browse files Browse the repository at this point in the history
Layers are currently all children of the root layer, so instead of
using coordinates relative to the parent flow we should use coordinates
relative to the page.

Fixes #2061.
  • Loading branch information
mrobinson committed Oct 8, 2014
1 parent 8c858b4 commit 659c45e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/layout/block.rs
Expand Up @@ -1251,8 +1251,9 @@ impl BlockFlow {
let layer_rect = self.base.position.union(&self.base.overflow);
let size = Size2D(layer_rect.size.inline.to_nearest_px() as uint,
layer_rect.size.block.to_nearest_px() as uint);
let origin = Point2D(layer_rect.start.i.to_nearest_px() as uint,
layer_rect.start.b.to_nearest_px() as uint);
let origin = Point2D(self.base.abs_position.x.to_nearest_px() as uint,
self.base.abs_position.y.to_nearest_px() as uint);

let scroll_policy = if self.is_fixed() {
FixedPosition
} else {
Expand Down
1 change: 1 addition & 0 deletions tests/ref/basic.list
Expand Up @@ -61,6 +61,7 @@
== position_fixed_background_color_a.html position_fixed_background_color_b.html
== position_fixed_overflow_a.html position_fixed_overflow_b.html
== position_fixed_tile_edge.html position_fixed_tile_edge_ref.html
== position_fixed_tile_edge_2.html position_fixed_tile_edge_ref.html
== position_relative_a.html position_relative_b.html
== position_relative_top_percentage_a.html position_relative_top_percentage_b.html
== background_none_a.html background_none_b.html
Expand Down
10 changes: 10 additions & 0 deletions tests/ref/position_fixed_tile_edge_2.html
@@ -0,0 +1,10 @@
<html>
<body>
<div style="position: absolute; top: 0px; left: 512px;">
<div style="position: absolute; background: green; width: 20px; height: 20px;"></div>

<!-- This position:fixed sibling should force its sibling to be layerized. -->
<div style="position: fixed;"></div>
</div>
</body>
</html>

5 comments on commit 659c45e

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

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

saw approval from pcwalton
at mrobinson@659c45e

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

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

merging mrobinson/servo/layer-positioning = 659c45e into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

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

mrobinson/servo/layer-positioning = 659c45e merged ok, testing candidate = eff0de0

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

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

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

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

fast-forwarding master to auto = eff0de0

Please sign in to comment.