Bug 1855668 - Make ::backdrop inherit from the originating element. r=zrhoffman
This is as a result of a spec change (see link in the test), but it addresses a very long-standing issue with this pseudo-element, see https://github.com/whatwg/fullscreen/issues/124. Differential Revision: https://phabricator.services.mozilla.com/D189484
This commit is contained in:
@@ -1078,7 +1078,7 @@ void nsFrameConstructorState::ConstructBackdropFrameFor(nsIContent* aContent,
|
|||||||
RefPtr<ComputedStyle> style =
|
RefPtr<ComputedStyle> style =
|
||||||
mPresShell->StyleSet()->ResolvePseudoElementStyle(
|
mPresShell->StyleSet()->ResolvePseudoElementStyle(
|
||||||
*aContent->AsElement(), PseudoStyleType::backdrop, nullptr,
|
*aContent->AsElement(), PseudoStyleType::backdrop, nullptr,
|
||||||
/* aParentStyle */ nullptr);
|
aFrame->Style());
|
||||||
MOZ_ASSERT(style->StyleDisplay()->mTopLayer == StyleTopLayer::Top);
|
MOZ_ASSERT(style->StyleDisplay()->mTopLayer == StyleTopLayer::Top);
|
||||||
nsContainerFrame* parentFrame =
|
nsContainerFrame* parentFrame =
|
||||||
GetGeometricParent(*style->StyleDisplay(), nullptr);
|
GetGeometricParent(*style->StyleDisplay(), nullptr);
|
||||||
|
|||||||
@@ -70,15 +70,6 @@ impl PseudoElement {
|
|||||||
PseudoElementCascadeType::Lazy
|
PseudoElementCascadeType::Lazy
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the pseudo-element should inherit from the default computed
|
|
||||||
/// values instead of from the parent element.
|
|
||||||
///
|
|
||||||
/// This is not the common thing, but there are some pseudos (namely:
|
|
||||||
/// ::backdrop), that shouldn't inherit from the parent element.
|
|
||||||
pub fn inherits_from_default_values(&self) -> bool {
|
|
||||||
matches!(*self, PseudoElement::Backdrop)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the canonical index of this eagerly-cascaded pseudo-element.
|
/// Gets the canonical index of this eagerly-cascaded pseudo-element.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn eager_index(&self) -> usize {
|
pub fn eager_index(&self) -> usize {
|
||||||
|
|||||||
@@ -1050,7 +1050,6 @@ impl Stylist {
|
|||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
rule_inclusion: RuleInclusion,
|
rule_inclusion: RuleInclusion,
|
||||||
originating_element_style: &ComputedValues,
|
originating_element_style: &ComputedValues,
|
||||||
parent_style: &Arc<ComputedValues>,
|
|
||||||
is_probe: bool,
|
is_probe: bool,
|
||||||
matching_fn: Option<&dyn Fn(&PseudoElement) -> bool>,
|
matching_fn: Option<&dyn Fn(&PseudoElement) -> bool>,
|
||||||
) -> Option<Arc<ComputedValues>>
|
) -> Option<Arc<ComputedValues>>
|
||||||
@@ -1061,7 +1060,6 @@ impl Stylist {
|
|||||||
guards,
|
guards,
|
||||||
element,
|
element,
|
||||||
originating_element_style,
|
originating_element_style,
|
||||||
parent_style,
|
|
||||||
pseudo,
|
pseudo,
|
||||||
is_probe,
|
is_probe,
|
||||||
rule_inclusion,
|
rule_inclusion,
|
||||||
@@ -1073,7 +1071,7 @@ impl Stylist {
|
|||||||
pseudo,
|
pseudo,
|
||||||
guards,
|
guards,
|
||||||
Some(originating_element_style),
|
Some(originating_element_style),
|
||||||
Some(parent_style),
|
Some(originating_element_style),
|
||||||
Some(element),
|
Some(element),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@@ -1195,7 +1193,6 @@ impl Stylist {
|
|||||||
guards: &StylesheetGuards,
|
guards: &StylesheetGuards,
|
||||||
element: E,
|
element: E,
|
||||||
originating_element_style: &ComputedValues,
|
originating_element_style: &ComputedValues,
|
||||||
parent_style: &Arc<ComputedValues>,
|
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
is_probe: bool,
|
is_probe: bool,
|
||||||
rule_inclusion: RuleInclusion,
|
rule_inclusion: RuleInclusion,
|
||||||
@@ -1246,7 +1243,7 @@ impl Stylist {
|
|||||||
let rules = self.rule_tree.compute_rule_node(&mut declarations, guards);
|
let rules = self.rule_tree.compute_rule_node(&mut declarations, guards);
|
||||||
|
|
||||||
let mut visited_rules = None;
|
let mut visited_rules = None;
|
||||||
if parent_style.visited_style().is_some() {
|
if originating_element_style.visited_style().is_some() {
|
||||||
let mut declarations = ApplicableDeclarationList::new();
|
let mut declarations = ApplicableDeclarationList::new();
|
||||||
let mut selector_caches = SelectorCaches::default();
|
let mut selector_caches = SelectorCaches::default();
|
||||||
|
|
||||||
|
|||||||
@@ -4120,19 +4120,14 @@ fn get_pseudo_style(
|
|||||||
inherited_styles.is_none() ||
|
inherited_styles.is_none() ||
|
||||||
ptr::eq(inherited_styles.unwrap(), &**styles.primary())
|
ptr::eq(inherited_styles.unwrap(), &**styles.primary())
|
||||||
);
|
);
|
||||||
let base = if pseudo.inherits_from_default_values() {
|
let originating_element_style = styles.primary();
|
||||||
stylist.device().default_computed_values_arc()
|
|
||||||
} else {
|
|
||||||
styles.primary()
|
|
||||||
};
|
|
||||||
let guards = StylesheetGuards::same(guard);
|
let guards = StylesheetGuards::same(guard);
|
||||||
stylist.lazily_compute_pseudo_element_style(
|
stylist.lazily_compute_pseudo_element_style(
|
||||||
&guards,
|
&guards,
|
||||||
element,
|
element,
|
||||||
&pseudo,
|
&pseudo,
|
||||||
rule_inclusion,
|
rule_inclusion,
|
||||||
styles.primary(),
|
originating_element_style,
|
||||||
base,
|
|
||||||
is_probe,
|
is_probe,
|
||||||
matching_func,
|
matching_func,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
::backdrop {
|
::backdrop {
|
||||||
|
visibility: visible;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<style>
|
|
||||||
#backdrop {
|
|
||||||
position: absolute;
|
|
||||||
top: 100px;
|
|
||||||
left: 100px;
|
|
||||||
height: 100px;
|
|
||||||
width: 100px;
|
|
||||||
background: green;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<body>
|
|
||||||
Test that ::backdrop does not inherit from anything. The test passes if there is
|
|
||||||
a green box and no red.
|
|
||||||
<div id="backdrop"></div>
|
|
||||||
</body>
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<link rel="match" href="backdrop-does-not-inherit-ref.html">
|
|
||||||
<link rel="help" href="https://fullscreen.spec.whatwg.org/#new-stacking-layer">
|
|
||||||
<style>
|
|
||||||
dialog {
|
|
||||||
visibility: inherit;
|
|
||||||
background: red;
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog::backdrop {
|
|
||||||
position: absolute;
|
|
||||||
top: 100px;
|
|
||||||
left: 100px;
|
|
||||||
height: 100px;
|
|
||||||
width: 100px;
|
|
||||||
visibility: inherit;
|
|
||||||
background: green;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<body>
|
|
||||||
Test that ::backdrop does not inherit from anything. The test passes if there is
|
|
||||||
a green box and no red.
|
|
||||||
<div style="visibility: hidden">
|
|
||||||
<dialog></dialog>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
document.querySelector('dialog').showModal();
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
@@ -9,6 +9,7 @@ dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
::backdrop {
|
::backdrop {
|
||||||
|
visibility: visible;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 100px;
|
top: 100px;
|
||||||
left: 100px;
|
left: 100px;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dialog::backdrop {
|
dialog::backdrop {
|
||||||
|
visibility: visible;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
width: 50px;
|
width: 50px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<style>
|
||||||
|
#backdrop {
|
||||||
|
position: absolute;
|
||||||
|
top: 100px;
|
||||||
|
left: 100px;
|
||||||
|
height: 100px;
|
||||||
|
width: 100px;
|
||||||
|
background: green;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<body>
|
||||||
|
Test that ::backdrop inherits from its originating element. The test passes if
|
||||||
|
there is a green box and no red.
|
||||||
|
<div id="backdrop"></div>
|
||||||
|
</body>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<link rel="match" href="backdrop-inherits-ref.html">
|
||||||
|
<link rel="help" href="https://drafts.csswg.org/css-position-4/#backdrop">
|
||||||
|
<style>
|
||||||
|
dialog {
|
||||||
|
--backdrop-bg: green;
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog::backdrop {
|
||||||
|
position: absolute;
|
||||||
|
top: 100px;
|
||||||
|
left: 100px;
|
||||||
|
height: 100px;
|
||||||
|
width: 100px;
|
||||||
|
visibility: visible;
|
||||||
|
background-color: var(--backdrop-bg);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
Test that ::backdrop inherits from its originating element. The test passes if
|
||||||
|
there is a green box and no red.
|
||||||
|
<dialog></dialog>
|
||||||
|
<script>
|
||||||
|
document.querySelector('dialog').showModal();
|
||||||
|
</script>
|
||||||
@@ -11,6 +11,8 @@ dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dialog::backdrop {
|
dialog::backdrop {
|
||||||
|
visibility: visible;
|
||||||
|
pointer-events: initial;
|
||||||
background-color: red;
|
background-color: red;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user