Implemented fullscreen top layer

This commit is contained in:
Alan Jeffrey 2019-02-04 19:35:03 -06:00
parent a34c8f952e
commit 386c0f80ed
6 changed files with 38 additions and 7 deletions

View file

@ -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),

View file

@ -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<FilterOp>,
@ -220,6 +224,7 @@ impl StackingContext {
bounds: LayoutRect,
overflow: LayoutRect,
z_index: i32,
in_top_layer: InTopLayer,
filters: Vec<FilterOp>,
mix_blend_mode: MixBlendMode,
transform: Option<LayoutTransform>,
@ -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);
}

View file

@ -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",

View file

@ -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")]

View file

@ -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 {

View file

@ -1,3 +0,0 @@
[fullscreen-hides-others.html]
type: reftest
expected: FAIL