From 1bd551ddc22dab63e6bcb861763a05290e0f0e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 27 Feb 2020 02:26:39 +0000 Subject: [PATCH] style: Add an inherited style bit to know whether an element is in an opacity: 0 subtree. 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 --- .../style/properties/computed_value_flags.rs | 12 ++++++---- components/style/style_adjuster.rs | 24 ++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/components/style/properties/computed_value_flags.rs b/components/style/properties/computed_value_flags.rs index 4363f3f36e9..b5294093adf 100644 --- a/components/style/properties/computed_value_flags.rs +++ b/components/style/properties/computed_value_flags.rs @@ -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. diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs index a2c6e5a2928..aed3c5fc980 100644 --- a/components/style/style_adjuster.rs +++ b/components/style/style_adjuster.rs @@ -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() {