Bug 1618303 - Add an inherited style bit to know whether an element is in an opacity: 0 subtree. r=hiro

I think this should work for the animation throttling stuff.

Opacity works on the element tree, so I think this is sound.

Differential Revision: https://phabricator.services.mozilla.com/D64441

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2020-02-27 02:26:39 +00:00
Родитель b6a0b062af
Коммит 551edfd98f
3 изменённых файлов: 27 добавлений и 13 удалений

Просмотреть файл

@ -166,6 +166,10 @@ class ComputedStyle {
return bool(Flags() & Flag::IS_ROOT_ELEMENT_STYLE);
}
bool IsInOpacityZeroSubtree() const {
return bool(Flags() & Flag::IS_IN_OPACITY_ZERO_SUBTREE);
}
ComputedStyle* GetCachedInheritingAnonBoxStyle(
PseudoStyleType aPseudoType) const {
MOZ_ASSERT(PseudoStyle::IsInheritingAnonBox(aPseudoType));

Просмотреть файл

@ -67,6 +67,9 @@ bitflags! {
/// Whether this style is the style of the document element.
const IS_ROOT_ELEMENT_STYLE = 1 << 11;
/// Whether this element is inside an `opacity: 0` subtree.
const IS_IN_OPACITY_ZERO_SUBTREE = 1 << 12;
}
}
@ -74,10 +77,11 @@ impl ComputedValueFlags {
/// Flags that are unconditionally propagated to descendants.
#[inline]
fn inherited_flags() -> Self {
ComputedValueFlags::IS_RELEVANT_LINK_VISITED |
ComputedValueFlags::CAN_BE_FRAGMENTED |
ComputedValueFlags::IS_IN_PSEUDO_ELEMENT_SUBTREE |
ComputedValueFlags::HAS_TEXT_DECORATION_LINES
Self::IS_RELEVANT_LINK_VISITED |
Self::CAN_BE_FRAGMENTED |
Self::IS_IN_PSEUDO_ELEMENT_SUBTREE |
Self::HAS_TEXT_DECORATION_LINES |
Self::IS_IN_OPACITY_ZERO_SUBTREE
}
/// Flags that may be propagated to descendants.

Просмотреть файл

@ -227,15 +227,21 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
fn set_bits(&mut self) {
let display = self.style.get_box().clone_display();
if !display.is_contents() &&
!self
.style
.get_text()
.clone_text_decoration_line()
.is_empty()
{
self.style
.add_flags(ComputedValueFlags::HAS_TEXT_DECORATION_LINES);
if !display.is_contents() {
if !self
.style
.get_text()
.clone_text_decoration_line()
.is_empty()
{
self.style
.add_flags(ComputedValueFlags::HAS_TEXT_DECORATION_LINES);
}
if self.style.get_effects().clone_opacity() == 0. {
self.style
.add_flags(ComputedValueFlags::IS_IN_OPACITY_ZERO_SUBTREE);
}
}
if self.style.is_pseudo_element() {