aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-08-31 20:35:06 -0600
committerbors-servo <metajack+bors@gmail.com>2015-08-31 20:35:06 -0600
commitdee6283483a79b034565a6f9ad979f87c2765f78 (patch)
tree857db5330e63f994b4a1e667a0d18f6444c1ae83
parenta4d5c8ce4ade329ec61b4d211c5bc7499d1df095 (diff)
parent36759338c754ecf44aec93c8c680e5d0d040f3cd (diff)
downloadservo-dee6283483a79b034565a6f9ad979f87c2765f78.tar.gz
servo-dee6283483a79b034565a6f9ad979f87c2765f78.zip
Auto merge of #7474 - notriddle:master, r=pcwalton
Inline constraint resolver for absolutely positioned tables. Fixes #7425. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7474) <!-- Reviewable:end -->
-rw-r--r--components/layout/table_wrapper.rs75
-rw-r--r--tests/ref/absolute_table.html7
-rw-r--r--tests/ref/absolute_table_ref.html7
-rw-r--r--tests/ref/basic.list1
4 files changed, 88 insertions, 2 deletions
diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs
index c3312bceba9..ebf96020634 100644
--- a/components/layout/table_wrapper.rs
+++ b/components/layout/table_wrapper.rs
@@ -13,12 +13,12 @@
#![deny(unsafe_code)]
-use block::{BlockFlow, FloatNonReplaced, ISizeAndMarginsComputer, ISizeConstraintInput};
+use block::{BlockFlow, FloatNonReplaced, AbsoluteNonReplaced, ISizeAndMarginsComputer, ISizeConstraintInput};
use block::{ISizeConstraintSolution, MarginsMayCollapseFlag};
use context::LayoutContext;
use floats::FloatKind;
use flow::{FlowClass, Flow, ImmutableFlowUtils};
-use flow::{IMPACTED_BY_LEFT_FLOATS, IMPACTED_BY_RIGHT_FLOATS, OpaqueFlow};
+use flow::{IMPACTED_BY_LEFT_FLOATS, IMPACTED_BY_RIGHT_FLOATS, INLINE_POSITION_IS_STATIC, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator};
use model::MaybeAuto;
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize};
@@ -242,6 +242,26 @@ impl TableWrapperFlow {
return
}
+ if !self.block_flow.base.flags.contains(INLINE_POSITION_IS_STATIC) {
+ let inline_size_computer = AbsoluteTable {
+ minimum_width_of_all_columns: minimum_width_of_all_columns,
+ preferred_width_of_all_columns: preferred_width_of_all_columns,
+ border_collapse: border_collapse,
+ };
+ let input =
+ inline_size_computer.compute_inline_size_constraint_inputs(&mut self.block_flow,
+ parent_flow_inline_size,
+ layout_context);
+
+ let solution = inline_size_computer.solve_inline_size_constraints(&mut self.block_flow,
+ &input);
+ inline_size_computer.set_inline_size_constraint_solutions(&mut self.block_flow,
+ solution);
+ inline_size_computer.set_inline_position_of_flow_if_necessary(&mut self.block_flow,
+ solution);
+ return
+ }
+
let inline_size_computer = Table {
minimum_width_of_all_columns: minimum_width_of_all_columns,
preferred_width_of_all_columns: preferred_width_of_all_columns,
@@ -791,3 +811,54 @@ impl ISizeAndMarginsComputer for FloatedTable {
FloatNonReplaced.solve_inline_size_constraints(block, input)
}
}
+
+struct AbsoluteTable {
+ minimum_width_of_all_columns: Au,
+ preferred_width_of_all_columns: Au,
+ border_collapse: border_collapse::T,
+}
+
+impl ISizeAndMarginsComputer for AbsoluteTable {
+ fn compute_border_and_padding(&self, block: &mut BlockFlow, containing_block_inline_size: Au) {
+ block.fragment.compute_border_and_padding(containing_block_inline_size,
+ self.border_collapse)
+ }
+
+ fn initial_computed_inline_size(&self,
+ block: &mut BlockFlow,
+ parent_flow_inline_size: Au,
+ layout_context: &LayoutContext)
+ -> MaybeAuto {
+ let containing_block_inline_size =
+ self.containing_block_inline_size(block,
+ parent_flow_inline_size,
+ layout_context);
+ initial_computed_inline_size(block,
+ containing_block_inline_size,
+ self.minimum_width_of_all_columns,
+ self.preferred_width_of_all_columns)
+ }
+
+ fn containing_block_inline_size(&self,
+ block: &mut BlockFlow,
+ parent_flow_inline_size: Au,
+ layout_context: &LayoutContext)
+ -> Au {
+ AbsoluteNonReplaced.containing_block_inline_size(block, parent_flow_inline_size, layout_context)
+ }
+
+ fn solve_inline_size_constraints(&self,
+ block: &mut BlockFlow,
+ input: &ISizeConstraintInput)
+ -> ISizeConstraintSolution {
+ AbsoluteNonReplaced.solve_inline_size_constraints(block, input)
+ }
+
+ fn set_inline_position_of_flow_if_necessary(&self,
+ block: &mut BlockFlow,
+ solution: ISizeConstraintSolution) {
+ AbsoluteNonReplaced.set_inline_position_of_flow_if_necessary(block, solution);
+ }
+
+}
+
diff --git a/tests/ref/absolute_table.html b/tests/ref/absolute_table.html
new file mode 100644
index 00000000000..b0dc978e34f
--- /dev/null
+++ b/tests/ref/absolute_table.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<style>
+div { display:table;position:absolute;top:0px;right:40px }
+</style>
+<div>
+XXX
+</div>
diff --git a/tests/ref/absolute_table_ref.html b/tests/ref/absolute_table_ref.html
new file mode 100644
index 00000000000..40018562574
--- /dev/null
+++ b/tests/ref/absolute_table_ref.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<style>
+div { display:block;position:absolute;top:0px;right:40px }
+</style>
+<div>
+XXX
+</div>
diff --git a/tests/ref/basic.list b/tests/ref/basic.list
index a7e3d2154ba..c2c3adf2963 100644
--- a/tests/ref/basic.list
+++ b/tests/ref/basic.list
@@ -12,6 +12,7 @@ fragment=top != ../html/acid2.html acid2_ref.html
== abs_rel_explicit_height.html abs_rel_explicit_height_ref.html
== absolute_hypothetical_with_intervening_inline_block_a.html absolute_hypothetical_with_intervening_inline_block_ref.html
== absolute_inline_containing_block_a.html absolute_inline_containing_block_ref.html
+== absolute_table.html absolute_table_ref.html
== absolute_z_index_auto_paint_order_a.html absolute_z_index_auto_paint_order_ref.html
== acid1_a.html acid1_b.html
== acid2_noscroll.html acid2_ref_broken.html