summaryrefslogtreecommitdiffstats
path: root/servo/components/style/traversal_flags.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /servo/components/style/traversal_flags.rs
parentInitial commit. (diff)
downloadthunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz
thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'servo/components/style/traversal_flags.rs')
-rw-r--r--servo/components/style/traversal_flags.rs68
1 files changed, 68 insertions, 0 deletions
diff --git a/servo/components/style/traversal_flags.rs b/servo/components/style/traversal_flags.rs
new file mode 100644
index 0000000000..4bb8e1374a
--- /dev/null
+++ b/servo/components/style/traversal_flags.rs
@@ -0,0 +1,68 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+
+//! Flags that control the traversal process.
+//!
+//! We CamelCase rather than UPPER_CASING so that we can grep for the same
+//! strings across gecko and servo.
+#![allow(non_upper_case_globals)]
+
+bitflags! {
+ /// Flags that control the traversal process.
+ #[derive(Clone, Copy, Eq, PartialEq)]
+ pub struct TraversalFlags: u32 {
+ /// Traverse only elements for animation restyles.
+ const AnimationOnly = 1 << 0;
+ /// Traverse and update all elements with CSS animations since
+ /// @keyframes rules may have changed. Triggered by CSS rule changes.
+ const ForCSSRuleChanges = 1 << 1;
+ /// The final animation-only traversal, which shouldn't really care about other
+ /// style changes anymore.
+ const FinalAnimationTraversal = 1 << 2;
+ /// Allows the traversal to run in parallel if there are sufficient cores on
+ /// the machine.
+ const ParallelTraversal = 1 << 7;
+ /// Flush throttled animations. By default, we only update throttled animations
+ /// when we have other non-throttled work to do. With this flag, we
+ /// unconditionally tick and process them.
+ const FlushThrottledAnimations = 1 << 8;
+
+ }
+}
+
+/// Asserts that all TraversalFlags flags have a matching ServoTraversalFlags value in gecko.
+#[cfg(feature = "gecko")]
+#[inline]
+pub fn assert_traversal_flags_match() {
+ use crate::gecko_bindings::structs;
+
+ macro_rules! check_traversal_flags {
+ ( $( $a:ident => $b:path ),*, ) => {
+ if cfg!(debug_assertions) {
+ let mut modes = TraversalFlags::all();
+ $(
+ assert_eq!(structs::$a as usize, $b.bits() as usize, stringify!($b));
+ modes.remove($b);
+ )*
+ assert_eq!(modes, TraversalFlags::empty(), "all TraversalFlags bits should have an assertion");
+ }
+ }
+ }
+
+ check_traversal_flags! {
+ ServoTraversalFlags_AnimationOnly => TraversalFlags::AnimationOnly,
+ ServoTraversalFlags_ForCSSRuleChanges => TraversalFlags::ForCSSRuleChanges,
+ ServoTraversalFlags_FinalAnimationTraversal => TraversalFlags::FinalAnimationTraversal,
+ ServoTraversalFlags_ParallelTraversal => TraversalFlags::ParallelTraversal,
+ ServoTraversalFlags_FlushThrottledAnimations => TraversalFlags::FlushThrottledAnimations,
+ }
+}
+
+impl TraversalFlags {
+ /// Returns true if the traversal is for animation-only restyles.
+ #[inline]
+ pub fn for_animation_only(&self) -> bool {
+ self.contains(TraversalFlags::AnimationOnly)
+ }
+}