From c2db10217c4d78a917dfb28b5d9f6bdb727a5556 Mon Sep 17 00:00:00 2001 From: Philipp Hartwig Date: Fri, 18 Sep 2015 23:08:10 +0200 Subject: [PATCH 1/2] Use computed `display` property for hypothetical box of root element The root element should never be treated as an inline element by the flow construction. Closes #7558. --- components/style/properties.mako.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index 374b9b875d0..4b7145dbf0c 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -554,10 +554,14 @@ pub mod longhands { } #[inline] - pub fn derive_from_display(_: super::display::computed_value::T, + pub fn derive_from_display(computed_value: super::display::computed_value::T, context: &computed::Context) -> computed_value::T { - context.display + if context.is_root_element { + computed_value + } else { + context.display + } } @@ -6643,7 +6647,12 @@ pub fn cascade(viewport_size: Size2D, // The initial value of display may be changed at computed value time. if !seen.get_display() { let box_ = Arc::make_mut(&mut style.box_); - box_.display = box_.display.to_computed_value(&context); + let computed_value = box_.display.to_computed_value(&context); + box_.display = computed_value; + box_._servo_display_for_hypothetical_box = + longhands::_servo_display_for_hypothetical_box::derive_from_display( + computed_value, + &context); } // The initial value of outline width may be changed at computed value time. From 7d3a712b3a4a1d53d94f079c82607b00807132f6 Mon Sep 17 00:00:00 2001 From: Philipp Hartwig Date: Wed, 23 Sep 2015 22:44:49 +0200 Subject: [PATCH 2/2] Add ref tests for #7558 --- tests/ref/basic.list | 2 ++ tests/ref/root_display_inline_a.html | 8 ++++++++ tests/ref/root_display_ref.html | 8 ++++++++ tests/ref/root_display_without_style_a.html | 15 +++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 tests/ref/root_display_inline_a.html create mode 100644 tests/ref/root_display_ref.html create mode 100644 tests/ref/root_display_without_style_a.html diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 404adece8de..ffbf3836e2a 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -319,6 +319,8 @@ device-pixel-ratio=2 != pixel_snapping_border_a.html pixel_snapping_border_ref.h == pseudo_inherit.html pseudo_inherit_ref.html == quotes_none_a.html quotes_none_ref.html == quotes_simple_a.html quotes_simple_ref.html +== root_display_inline_a.html root_display_ref.html +== root_display_without_style_a.html root_display_ref.html == root_height_a.html root_height_b.html == root_margin_collapse_a.html root_margin_collapse_b.html == root_pseudo_a.html root_pseudo_b.html diff --git a/tests/ref/root_display_inline_a.html b/tests/ref/root_display_inline_a.html new file mode 100644 index 00000000000..07fe6a96c21 --- /dev/null +++ b/tests/ref/root_display_inline_a.html @@ -0,0 +1,8 @@ + + + + + +Hello world! + + diff --git a/tests/ref/root_display_ref.html b/tests/ref/root_display_ref.html new file mode 100644 index 00000000000..26ba9034a26 --- /dev/null +++ b/tests/ref/root_display_ref.html @@ -0,0 +1,8 @@ + + + + + +Hello world! + + diff --git a/tests/ref/root_display_without_style_a.html b/tests/ref/root_display_without_style_a.html new file mode 100644 index 00000000000..9f02354f48f --- /dev/null +++ b/tests/ref/root_display_without_style_a.html @@ -0,0 +1,15 @@ + + + + + + + +