From 386c0f80edf660580d3dba12d08782e1d82517d7 Mon Sep 17 00:00:00 2001 From: Alan Jeffrey Date: Mon, 4 Feb 2019 19:35:03 -0600 Subject: [PATCH] Implemented fullscreen top layer --- components/layout/display_list/builder.rs | 1 + components/layout/display_list/items.rs | 17 +++++++++++++++++ .../style/properties/longhands/box.mako.rs | 11 +++++++++++ components/style/properties/properties.mako.rs | 9 +++++---- resources/user-agent.css | 4 ++++ .../reftests/fullscreen-hides-others.html.ini | 3 --- 6 files changed, 38 insertions(+), 7 deletions(-) delete mode 100644 tests/wpt/mozilla/meta/mozilla/fullscreen/reftests/fullscreen-hides-others.html.ini diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index 17cdd5cdc1a..11ce2fd513e 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -1917,6 +1917,7 @@ impl Fragment { border_box.to_layout(), overflow.to_layout(), self.effective_z_index(), + self.style().get_box()._servo_top_layer, filters, self.style().get_effects().mix_blend_mode.to_layout(), self.transform_matrix(&border_box), diff --git a/components/layout/display_list/items.rs b/components/layout/display_list/items.rs index 4b1df780087..c66f0c8942b 100644 --- a/components/layout/display_list/items.rs +++ b/components/layout/display_list/items.rs @@ -22,6 +22,7 @@ use std::cmp::Ordering; use std::collections::HashMap; use std::f32; use std::fmt; +use style::computed_values::_servo_top_layer::T as InTopLayer; use webrender_api as wr; use webrender_api::{BorderRadius, ClipMode}; use webrender_api::{ComplexClipRegion, ExternalScrollId, FilterOp}; @@ -189,6 +190,9 @@ pub struct StackingContext { /// The `z-index` for this stacking context. pub z_index: i32, + /// Whether this is the top layer. + pub in_top_layer: InTopLayer, + /// CSS filters to be applied to this stacking context (including opacity). pub filters: Vec, @@ -220,6 +224,7 @@ impl StackingContext { bounds: LayoutRect, overflow: LayoutRect, z_index: i32, + in_top_layer: InTopLayer, filters: Vec, mix_blend_mode: MixBlendMode, transform: Option, @@ -234,6 +239,7 @@ impl StackingContext { bounds, overflow, z_index, + in_top_layer, filters, mix_blend_mode, transform, @@ -252,6 +258,7 @@ impl StackingContext { LayoutRect::zero(), LayoutRect::zero(), 0, + InTopLayer::None, vec![], MixBlendMode::Normal, None, @@ -283,6 +290,16 @@ impl StackingContext { impl Ord for StackingContext { fn cmp(&self, other: &Self) -> Ordering { + if self.in_top_layer == InTopLayer::Top { + if other.in_top_layer == InTopLayer::Top { + return Ordering::Equal; + } else { + return Ordering::Greater; + } + } else if other.in_top_layer == InTopLayer::Top { + return Ordering::Less; + } + if self.z_index != 0 || other.z_index != 0 { return self.z_index.cmp(&other.z_index); } diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs index 10e610a32af..f956dd2f606 100644 --- a/components/style/properties/longhands/box.mako.rs +++ b/components/style/properties/longhands/box.mako.rs @@ -34,6 +34,17 @@ ${helpers.single_keyword( spec="Internal (not web-exposed)", )} +// An internal-only attribute for elements in a top layer +// https://fullscreen.spec.whatwg.org/#top-layer +${helpers.single_keyword( + "-servo-top-layer", + "none top", + products="servo", + animation_value_type="none", + enabled_in="ua", + spec="Internal (not web-exposed)", +)} + ${helpers.single_keyword( "position", "static absolute relative fixed sticky", diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 9220c3b1a66..6a263c8ca35 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -3627,11 +3627,12 @@ impl<'a> StyleBuilder<'a> { Position::Absolute | Position::Fixed) } - /// Whether this style has a top-layer style. That's implemented in Gecko - /// via the -moz-top-layer property, but servo doesn't have any concept of a - /// top layer (yet, it's needed for fullscreen). + /// Whether this style has a top-layer style. #[cfg(feature = "servo")] - pub fn in_top_layer(&self) -> bool { false } + pub fn in_top_layer(&self) -> bool { + matches!(self.get_box().clone__servo_top_layer(), + longhands::_servo_top_layer::computed_value::T::Top) + } /// Whether this style has a top-layer style. #[cfg(feature = "gecko")] diff --git a/resources/user-agent.css b/resources/user-agent.css index 141b9b21de9..fbbc7bef3ea 100644 --- a/resources/user-agent.css +++ b/resources/user-agent.css @@ -302,6 +302,10 @@ textarea { white-space: pre-wrap; } /* intentionally not !important */ object-fit:contain; + + /* The internal-only -servo-top-layer attribute is used + to implement https://fullscreen.spec.whatwg.org/#top-layer */ + -servo-top-layer: top; } iframe:fullscreen { diff --git a/tests/wpt/mozilla/meta/mozilla/fullscreen/reftests/fullscreen-hides-others.html.ini b/tests/wpt/mozilla/meta/mozilla/fullscreen/reftests/fullscreen-hides-others.html.ini deleted file mode 100644 index 7396f085c15..00000000000 --- a/tests/wpt/mozilla/meta/mozilla/fullscreen/reftests/fullscreen-hides-others.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[fullscreen-hides-others.html] - type: reftest - expected: FAIL