diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-03-07 11:59:36 +0000 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-03-13 15:08:35 +0100 |
commit | 6fd17ccb35b665f8518d3a11a532e217fdb9f3cc (patch) | |
tree | 2a68c99ec4220e5434006e08c7228b9b91890104 /components/style/rule_tree/mod.rs | |
parent | 80ed0706397f0767f7c1c4f419e6061d79437d99 (diff) | |
download | servo-6fd17ccb35b665f8518d3a11a532e217fdb9f3cc.tar.gz servo-6fd17ccb35b665f8518d3a11a532e217fdb9f3cc.zip |
style: Implement CSS revert keyword.
The only fishy bit is the animation stuff. In particular, there are two places
where we just mint the revert behavior:
* When serializing web-animations keyframes (the custom properties stuff in
declaration_block.rs). That codepath is already not sound and I wanted to
get rid of it in bug 1501530, but what do I know.
* When getting an animation value from a property declaration. At that point
we no longer have the CSS rules that apply to the element to compute the
right revert value handy. It'd also use the wrong style anyway, I think,
given the way StyleBuilder::for_animation works.
We _could_ probably get them out of somewhere, but it seems like a whole lot
of code reinventing the wheel which is probably not useful, and that Blink
and WebKit just cannot implement either since they don't have a rule tree,
so it just doesn't seem worth the churn.
The custom properties code looks a bit different in order to minimize hash
lookups in the common case. FWIW, `revert` for custom properties doesn't seem
very useful either, but oh well.
Differential Revision: https://phabricator.services.mozilla.com/D21877
Diffstat (limited to 'components/style/rule_tree/mod.rs')
-rw-r--r-- | components/style/rule_tree/mod.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index a2caba6f9f7..029e3d068f9 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -11,7 +11,7 @@ use crate::applicable_declarations::ApplicableDeclarationList; use crate::gecko::selector_parser::PseudoElement; use crate::properties::{Importance, LonghandIdSet, PropertyDeclarationBlock}; use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards}; -use crate::stylesheets::StyleRule; +use crate::stylesheets::{StyleRule, Origin}; use crate::thread_state; #[cfg(feature = "gecko")] use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; @@ -659,6 +659,27 @@ impl CascadeLevel { } } + /// Returns the cascade origin of the rule. + #[inline] + pub fn origin(&self) -> Origin { + match *self { + CascadeLevel::UAImportant | + CascadeLevel::UANormal => Origin::UserAgent, + CascadeLevel::UserImportant | + CascadeLevel::UserNormal => Origin::User, + CascadeLevel::PresHints | + CascadeLevel::InnerShadowNormal | + CascadeLevel::SameTreeAuthorNormal | + CascadeLevel::StyleAttributeNormal | + CascadeLevel::SMILOverride | + CascadeLevel::Animations | + CascadeLevel::SameTreeAuthorImportant | + CascadeLevel::StyleAttributeImportant | + CascadeLevel::InnerShadowImportant | + CascadeLevel::Transitions => Origin::Author, + } + } + /// Returns whether this cascade level represents an animation rules. #[inline] pub fn is_animation(&self) -> bool { |