From 179a70b3053ec29e6d7655b1cb6eabe4b8a47672 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 15 May 2015 16:50:58 -0700 Subject: [PATCH] Fix layout of RTL tables in LTR flow Fixes #6006. --- components/layout/table_wrapper.rs | 20 ++++++++++++++------ tests/ref/basic.list | 1 + tests/ref/rtl_table_a.html | 19 +++++++++++++++++++ tests/ref/rtl_table_ref.html | 18 ++++++++++++++++++ 4 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 tests/ref/rtl_table_a.html create mode 100644 tests/ref/rtl_table_ref.html diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 1adf5c174c3..592ad213f93 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -190,6 +190,18 @@ impl TableWrapperFlow { table_border_padding + spacing; self.block_flow.base.position.size.inline = total_used_inline_size + table_border_padding + spacing + self.block_flow.fragment.margin.inline_start_end(); + + let writing_mode = self.block_flow.base.writing_mode; + let container_mode = self.block_flow.base.block_container_writing_mode; + + if writing_mode.is_bidi_ltr() != container_mode.is_bidi_ltr() { + // If our "start" direction is different from our parent flow, then `border_box.start.i` + // depends on `border_box.size.inline`. + self.block_flow.fragment.border_box.start.i = + self.block_flow.base.block_container_inline_size - + self.block_flow.fragment.margin.inline_end - + self.block_flow.fragment.border_box.size.inline; + } } fn compute_used_inline_size( @@ -314,12 +326,8 @@ impl Flow for TableWrapperFlow { let inline_start_content_edge = self.block_flow.fragment.border_box.start.i; let content_inline_size = self.block_flow.fragment.border_box.size.inline; - - // FIXME (mbrubeck): Test mixed RTL/LTR table layout, make sure this is right. - let inline_end_content_edge = self.block_flow.base.block_container_inline_size - - self.block_flow.fragment.margin.inline_end - - content_inline_size - - inline_start_content_edge; + let inline_end_content_edge = self.block_flow.fragment.border_padding.inline_end + + self.block_flow.fragment.margin.inline_end; // In case of fixed layout, column inline-sizes are calculated in table flow. let assigned_column_inline_sizes = match self.table_layout { diff --git a/tests/ref/basic.list b/tests/ref/basic.list index a4a9d5ed254..c0db44c6de9 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -268,6 +268,7 @@ experimental != overconstrained_block.html overconstrained_block_ref.html experimental == rtl_body.html rtl_body_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 == servo_center_a.html servo_center_ref.html == setattribute_id_restyle_a.html setattribute_id_restyle_b.html == stacking_context_overflow_a.html stacking_context_overflow_ref.html diff --git a/tests/ref/rtl_table_a.html b/tests/ref/rtl_table_a.html new file mode 100644 index 00000000000..7d1e8497dbb --- /dev/null +++ b/tests/ref/rtl_table_a.html @@ -0,0 +1,19 @@ + + + + + RTL Table test + + + +
+ + + diff --git a/tests/ref/rtl_table_ref.html b/tests/ref/rtl_table_ref.html new file mode 100644 index 00000000000..94b66b93f74 --- /dev/null +++ b/tests/ref/rtl_table_ref.html @@ -0,0 +1,18 @@ + + + + + RTL Table reference + + + +
+ + +