style: Add a simple CSSLayerRule implementation

The specifics of how this is going to work are still getting spec'd /
discussed in https://github.com/w3c/csswg-drafts/issues/6576, but this
allows DevTools to work fine and the feature to be complete enough for
Nightly experimentation (with the other in-flight patches).

Otherwise devtools crashes when trying to inspect pages that use them.

Differential Revision: https://phabricator.services.mozilla.com/D124656
This commit is contained in:
Emilio Cobos Álvarez 2023-05-27 06:58:09 +02:00 committed by Oriol Brufau
parent 0cc049946e
commit 7108be870d
2 changed files with 20 additions and 24 deletions

View file

@ -9,34 +9,26 @@
#![allow(non_snake_case, missing_docs)] #![allow(non_snake_case, missing_docs)]
use crate::gecko::url::CssUrlData; use crate::gecko::url::CssUrlData;
use crate::gecko_bindings::structs::RawServoAnimationValue; use crate::gecko_bindings::structs::{
use crate::gecko_bindings::structs::RawServoCounterStyleRule; RawServoAnimationValue, RawServoCounterStyleRule, RawServoCssUrlData,
use crate::gecko_bindings::structs::RawServoCssUrlData; RawServoDeclarationBlock, RawServoFontFaceRule,
use crate::gecko_bindings::structs::RawServoDeclarationBlock; RawServoFontFeatureValuesRule, RawServoImportRule, RawServoKeyframe,
use crate::gecko_bindings::structs::RawServoFontFaceRule; RawServoKeyframesRule, RawServoLayerRule, RawServoMediaList,
use crate::gecko_bindings::structs::RawServoFontFeatureValuesRule; RawServoMediaRule, RawServoMozDocumentRule, RawServoNamespaceRule,
use crate::gecko_bindings::structs::RawServoImportRule; RawServoPageRule, RawServoStyleRule, RawServoStyleSheetContents,
use crate::gecko_bindings::structs::RawServoKeyframe; RawServoSupportsRule, ServoCssRules
use crate::gecko_bindings::structs::RawServoKeyframesRule; };
use crate::gecko_bindings::structs::RawServoMediaList;
use crate::gecko_bindings::structs::RawServoMediaRule;
use crate::gecko_bindings::structs::RawServoMozDocumentRule;
use crate::gecko_bindings::structs::RawServoNamespaceRule;
use crate::gecko_bindings::structs::RawServoPageRule;
use crate::gecko_bindings::structs::RawServoStyleRule;
use crate::gecko_bindings::structs::RawServoStyleSheetContents;
use crate::gecko_bindings::structs::RawServoSupportsRule;
use crate::gecko_bindings::structs::ServoCssRules;
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong}; use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
use crate::media_queries::MediaList; use crate::media_queries::MediaList;
use crate::properties::animated_properties::AnimationValue; use crate::properties::animated_properties::AnimationValue;
use crate::properties::{ComputedValues, PropertyDeclarationBlock}; use crate::properties::{ComputedValues, PropertyDeclarationBlock};
use crate::shared_lock::Locked; use crate::shared_lock::Locked;
use crate::stylesheets::keyframes_rule::Keyframe; use crate::stylesheets::keyframes_rule::Keyframe;
use crate::stylesheets::{CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule}; use crate::stylesheets::{
use crate::stylesheets::{DocumentRule, ImportRule, KeyframesRule, MediaRule}; CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule,
use crate::stylesheets::{NamespaceRule, PageRule}; DocumentRule, ImportRule, KeyframesRule, LayerRule, MediaRule,
use crate::stylesheets::{StyleRule, StylesheetContents, SupportsRule}; NamespaceRule, PageRule, StyleRule, StylesheetContents, SupportsRule
};
use servo_arc::{Arc, ArcBorrow}; use servo_arc::{Arc, ArcBorrow};
use std::{mem, ptr}; use std::{mem, ptr};
@ -83,6 +75,9 @@ impl_arc_ffi!(Locked<Keyframe> => RawServoKeyframe
impl_arc_ffi!(Locked<KeyframesRule> => RawServoKeyframesRule impl_arc_ffi!(Locked<KeyframesRule> => RawServoKeyframesRule
[Servo_KeyframesRule_AddRef, Servo_KeyframesRule_Release]); [Servo_KeyframesRule_AddRef, Servo_KeyframesRule_Release]);
impl_arc_ffi!(Locked<LayerRule> => RawServoLayerRule
[Servo_LayerRule_AddRef, Servo_LayerRule_Release]);
impl_arc_ffi!(Locked<MediaList> => RawServoMediaList impl_arc_ffi!(Locked<MediaList> => RawServoMediaList
[Servo_MediaList_AddRef, Servo_MediaList_Release]); [Servo_MediaList_AddRef, Servo_MediaList_Release]);

View file

@ -310,10 +310,11 @@ impl CssRule {
/// https://drafts.csswg.org/cssom-1/#dom-cssrule-type /// https://drafts.csswg.org/cssom-1/#dom-cssrule-type
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, PartialEq)] #[derive(Clone, Copy, Debug, Eq, FromPrimitive, PartialEq)]
#[repr(u8)]
pub enum CssRuleType { pub enum CssRuleType {
// https://drafts.csswg.org/cssom/#the-cssrule-interface // https://drafts.csswg.org/cssom/#the-cssrule-interface
Style = 1, Style = 1,
Charset = 2, // Charset = 2, // Historical
Import = 3, Import = 3,
Media = 4, Media = 4,
FontFace = 5, FontFace = 5,
@ -322,7 +323,7 @@ pub enum CssRuleType {
Keyframes = 7, Keyframes = 7,
Keyframe = 8, Keyframe = 8,
// https://drafts.csswg.org/cssom/#the-cssrule-interface // https://drafts.csswg.org/cssom/#the-cssrule-interface
Margin = 9, // Margin = 9, // Not implemented yet.
Namespace = 10, Namespace = 10,
// https://drafts.csswg.org/css-counter-styles-3/#extentions-to-cssrule-interface // https://drafts.csswg.org/css-counter-styles-3/#extentions-to-cssrule-interface
CounterStyle = 11, CounterStyle = 11,