diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index c1bca4d56dc..df4f7380526 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -556,10 +556,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 + } } @@ -6647,7 +6651,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. diff --git a/tests/ref/basic.list b/tests/ref/basic.list index fbcb78bc891..7d3ff35c43a 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -320,6 +320,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 @@ + + + + + + + +