Auto merge of #22825 - asajeffrey:layout-fullscreen-top-layer, r=jdm

Layout fullscreen top layer

<!-- Please describe your changes on the following line: -->

Implement the fullscreen top layer described at https://fullscreen.spec.whatwg.org/#top-layer

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] There are tests for these changes OR

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22825)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-02-06 15:31:12 -05:00 committed by GitHub
commit 73ff9995fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 7 deletions

View file

@ -1917,6 +1917,7 @@ impl Fragment {
border_box.to_layout(), border_box.to_layout(),
overflow.to_layout(), overflow.to_layout(),
self.effective_z_index(), self.effective_z_index(),
self.style().get_box()._servo_top_layer,
filters, filters,
self.style().get_effects().mix_blend_mode.to_layout(), self.style().get_effects().mix_blend_mode.to_layout(),
self.transform_matrix(&border_box), self.transform_matrix(&border_box),

View file

@ -22,6 +22,7 @@ use std::cmp::Ordering;
use std::collections::HashMap; use std::collections::HashMap;
use std::f32; use std::f32;
use std::fmt; use std::fmt;
use style::computed_values::_servo_top_layer::T as InTopLayer;
use webrender_api as wr; use webrender_api as wr;
use webrender_api::{BorderRadius, ClipMode}; use webrender_api::{BorderRadius, ClipMode};
use webrender_api::{ComplexClipRegion, ExternalScrollId, FilterOp}; use webrender_api::{ComplexClipRegion, ExternalScrollId, FilterOp};
@ -189,6 +190,9 @@ pub struct StackingContext {
/// The `z-index` for this stacking context. /// The `z-index` for this stacking context.
pub z_index: i32, 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). /// CSS filters to be applied to this stacking context (including opacity).
pub filters: Vec<FilterOp>, pub filters: Vec<FilterOp>,
@ -220,6 +224,7 @@ impl StackingContext {
bounds: LayoutRect, bounds: LayoutRect,
overflow: LayoutRect, overflow: LayoutRect,
z_index: i32, z_index: i32,
in_top_layer: InTopLayer,
filters: Vec<FilterOp>, filters: Vec<FilterOp>,
mix_blend_mode: MixBlendMode, mix_blend_mode: MixBlendMode,
transform: Option<LayoutTransform>, transform: Option<LayoutTransform>,
@ -234,6 +239,7 @@ impl StackingContext {
bounds, bounds,
overflow, overflow,
z_index, z_index,
in_top_layer,
filters, filters,
mix_blend_mode, mix_blend_mode,
transform, transform,
@ -252,6 +258,7 @@ impl StackingContext {
LayoutRect::zero(), LayoutRect::zero(),
LayoutRect::zero(), LayoutRect::zero(),
0, 0,
InTopLayer::None,
vec![], vec![],
MixBlendMode::Normal, MixBlendMode::Normal,
None, None,
@ -283,6 +290,16 @@ impl StackingContext {
impl Ord for StackingContext { impl Ord for StackingContext {
fn cmp(&self, other: &Self) -> Ordering { 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 { if self.z_index != 0 || other.z_index != 0 {
return self.z_index.cmp(&other.z_index); return self.z_index.cmp(&other.z_index);
} }

View file

@ -34,6 +34,17 @@ ${helpers.single_keyword(
spec="Internal (not web-exposed)", 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( ${helpers.single_keyword(
"position", "position",
"static absolute relative fixed sticky", "static absolute relative fixed sticky",

View file

@ -3627,11 +3627,12 @@ impl<'a> StyleBuilder<'a> {
Position::Absolute | Position::Fixed) Position::Absolute | Position::Fixed)
} }
/// Whether this style has a top-layer style. That's implemented in Gecko /// Whether this style has a top-layer style.
/// via the -moz-top-layer property, but servo doesn't have any concept of a
/// top layer (yet, it's needed for fullscreen).
#[cfg(feature = "servo")] #[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. /// Whether this style has a top-layer style.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]

View file

@ -302,6 +302,10 @@ textarea { white-space: pre-wrap; }
/* intentionally not !important */ /* intentionally not !important */
object-fit:contain; 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 { iframe:fullscreen {

View file

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