Positioning fixes for RTL floats

This commit is contained in:
Matt Brubeck 2015-05-18 16:50:51 -07:00
parent ec5c333347
commit 0048b4f2ab
6 changed files with 52 additions and 4 deletions

View file

@ -1049,7 +1049,8 @@ impl BlockFlow {
let float_offset = self.base.floats.last_float_pos().unwrap()
.convert(self.base.floats.writing_mode,
self.base.writing_mode,
container_size);
container_size)
.start;
let margin_offset = LogicalPoint::new(self.base.writing_mode,
Au(0),
self.fragment.margin.block_start);

View file

@ -4,7 +4,7 @@
use util::geometry::Au;
use util::logical_geometry::WritingMode;
use util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize};
use util::logical_geometry::{LogicalRect, LogicalSize};
use util::persistent_list::PersistentList;
use std::cmp::{max, min};
use std::i32;
@ -146,10 +146,10 @@ impl Floats {
}
/// Returns the position of the last float in flow coordinates.
pub fn last_float_pos(&self) -> Option<LogicalPoint<Au>> {
pub fn last_float_pos(&self) -> Option<LogicalRect<Au>> {
match self.list.floats.front() {
None => None,
Some(float) => Some(float.bounds.start + self.offset),
Some(float) => Some(float.bounds.translate_by_size(self.offset)),
}
}

View file

@ -919,6 +919,13 @@ impl<T: Copy + Add<T, Output=T> + Sub<T, Output=T>> LogicalRect<T> {
}
}
pub fn translate_by_size(&self, offset: LogicalSize<T>) -> LogicalRect<T> {
LogicalRect {
start: self.start + offset,
..*self
}
}
pub fn translate(&self, offset: &LogicalPoint<T>) -> LogicalRect<T> {
LogicalRect {
start: self.start + LogicalSize {

View file

@ -264,6 +264,7 @@ experimental != overconstrained_block.html overconstrained_block_ref.html
== root_margin_collapse_a.html root_margin_collapse_b.html
== root_pseudo_a.html root_pseudo_b.html
experimental == rtl_body.html rtl_body_ref.html
experimental == rtl_float_a.html rtl_float_ref.html
experimental == rtl_margin_a.html rtl_margin_ref.html
experimental == rtl_simple.html rtl_simple_ref.html
experimental == rtl_table_a.html rtl_table_ref.html

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>RTL float test</title>
<style>
div {
direction: rtl;
float: left;
background: green;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<div id="a"></div>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>RTL float reference</title>
<style>
div {
float: left;
background: green;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<div id="a"></div>
</body>
</html>