From f9e154af5543063e4a168b92948d1009c73f2bf3 Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Mon, 22 Apr 2024 09:06:36 +0200 Subject: Fix InsertRule to use the right CssRuleTypes (#32125) `CSSRule::Type()` returns an u16 for CSSOM. `InsertRule()` was incorrectly using this to create a `CssRuleTypes`. Instead of `CssRuleTypes::from_bits(rule_type)`, it should be something like `CssRuleTypes::from_bits(1 << rule_type)`. However, that would only work when `Type()` provides an actual value, which per https://drafts.csswg.org/cssom/#dom-cssrule-type only happens for old rule types. New rule types just return 0. Therefore, this patch changes the signature of `SpecificCSSRule::ty()` to return the actual `CssRuleType`, and then `CSSRule::Type()` can zero it out when necessary. The fix is only relevant for CSS Nesting, which is currently disabled on Servo, so no test is necessary. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes do not require tests because the fix is only relevant for CSS Nesting, which is currently disabled --- components/script/dom/csskeyframesrule.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'components/script/dom/csskeyframesrule.rs') diff --git a/components/script/dom/csskeyframesrule.rs b/components/script/dom/csskeyframesrule.rs index 62fb03ec925..272e7086a41 100644 --- a/components/script/dom/csskeyframesrule.rs +++ b/components/script/dom/csskeyframesrule.rs @@ -7,6 +7,7 @@ use dom_struct::dom_struct; use servo_arc::Arc; use style::shared_lock::{Locked, ToCssWithGuard}; use style::stylesheets::keyframes_rule::{Keyframe, KeyframeSelector, KeyframesRule}; +use style::stylesheets::CssRuleType; use style::values::KeyframesName; use crate::dom::bindings::codegen::Bindings::CSSKeyframesRuleBinding::CSSKeyframesRuleMethods; @@ -145,9 +146,8 @@ impl CSSKeyframesRuleMethods for CSSKeyframesRule { } impl SpecificCSSRule for CSSKeyframesRule { - fn ty(&self) -> u16 { - use crate::dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants; - CSSRuleConstants::KEYFRAMES_RULE + fn ty(&self) -> CssRuleType { + CssRuleType::Keyframes } fn get_css(&self) -> DOMString { -- cgit v1.2.3