aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/components/main/layout/box_.rs8
-rw-r--r--src/components/main/layout/flow.rs6
-rw-r--r--src/test/ref/basic.list1
-rw-r--r--src/test/ref/position_relative_top_percentage_a.html25
-rw-r--r--src/test/ref/position_relative_top_percentage_b.html28
5 files changed, 65 insertions, 3 deletions
diff --git a/src/components/main/layout/box_.rs b/src/components/main/layout/box_.rs
index 4f4a85b14fe..732bca8a819 100644
--- a/src/components/main/layout/box_.rs
+++ b/src/components/main/layout/box_.rs
@@ -1279,6 +1279,7 @@ impl Box {
}
+ /// TODO: What exactly does this function return? Why is it Au(0) for GenericBox?
pub fn content_width(&self) -> Au {
match self.specific {
GenericBox | IframeBox(_) => Au(0),
@@ -1312,6 +1313,13 @@ impl Box {
}
}
+ /// Return the size of the content box.
+ pub fn content_box_size(&self) -> Size2D<Au> {
+ let border_box_size = self.border_box.get().size;
+ Size2D(border_box_size.width - self.noncontent_width(),
+ border_box_size.height - self.noncontent_height())
+ }
+
/// Split box which includes new-line character
pub fn split_by_new_line(&self) -> SplitBoxResult {
match self.specific {
diff --git a/src/components/main/layout/flow.rs b/src/components/main/layout/flow.rs
index d8abda6d7e8..512c61746bd 100644
--- a/src/components/main/layout/flow.rs
+++ b/src/components/main/layout/flow.rs
@@ -957,9 +957,9 @@ impl<'a> MutableFlowUtils for &'a mut Flow {
// TODO(pradeep): Move this into a generated CB function and stuff in Flow.
match block.box_ {
Some(ref box_) => {
- // FIXME: This should be the size of the content box (which is the
- // Containing Block formed by a BlockFlow), not the border box.
- container_block_size = box_.border_box.get().size;
+ // The Containing Block formed by a Block for relatively
+ // positioned descendants is the content box.
+ container_block_size = box_.content_box_size();
abs_cb_position = if block.is_positioned() {
block.base.abs_position + block.generated_cb_position()
diff --git a/src/test/ref/basic.list b/src/test/ref/basic.list
index d883d036054..c47a03dd3fb 100644
--- a/src/test/ref/basic.list
+++ b/src/test/ref/basic.list
@@ -52,3 +52,4 @@
== position_fixed_simple_a.html position_fixed_simple_b.html
== position_fixed_static_y_a.html position_fixed_static_y_b.html
== position_relative_a.html position_relative_b.html
+== position_relative_top_percentage_a.html position_relative_top_percentage_b.html
diff --git a/src/test/ref/position_relative_top_percentage_a.html b/src/test/ref/position_relative_top_percentage_a.html
new file mode 100644
index 00000000000..d79945421e1
--- /dev/null
+++ b/src/test/ref/position_relative_top_percentage_a.html
@@ -0,0 +1,25 @@
+<html>
+ <head>
+ <style>
+ #first {
+ width: 100px;
+ height: 100px;
+ border: solid 10px;
+ }
+ #rel {
+ position: relative;
+ left: 50%;
+ top: 50%;
+ width: 50px;
+ height: 50px;
+ background: green;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="first">
+ <div id="rel">
+ </div>
+ </div>
+ </body>
+</html>
diff --git a/src/test/ref/position_relative_top_percentage_b.html b/src/test/ref/position_relative_top_percentage_b.html
new file mode 100644
index 00000000000..c2d3dea7968
--- /dev/null
+++ b/src/test/ref/position_relative_top_percentage_b.html
@@ -0,0 +1,28 @@
+<html>
+ <head>
+ <style>
+ #first {
+ width: 100px;
+ height: 100px;
+ border: solid 10px;
+ }
+ .box {
+ width: 50px;
+ height: 50px;
+ }
+ #green_square {
+ height: 50px;
+ width: 50px;
+ margin-left: 50px;
+ background: green;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="first">
+ <div class="box"></div>
+ <div id="green_square">
+ </div>
+ </div>
+ </body>
+</html>