mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Drop @scroll-timeline rule entirely
This rule is not used in tests and should be removed per spec. Differential Revision: https://phabricator.services.mozilla.com/D157249
This commit is contained in:
parent
4b736595d7
commit
de396d9766
8 changed files with 15 additions and 421 deletions
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
use crate::gecko::url::CssUrlData;
|
use crate::gecko::url::CssUrlData;
|
||||||
use crate::gecko_bindings::structs::{
|
use crate::gecko_bindings::structs::{
|
||||||
RawServoAnimationValue, RawServoCounterStyleRule, RawServoCssUrlData, RawServoDeclarationBlock,
|
RawServoAnimationValue, RawServoContainerRule, RawServoCounterStyleRule, RawServoCssUrlData,
|
||||||
RawServoFontFaceRule, RawServoFontFeatureValuesRule, RawServoImportRule, RawServoKeyframe,
|
RawServoDeclarationBlock, RawServoFontFaceRule, RawServoFontFeatureValuesRule,
|
||||||
RawServoKeyframesRule, RawServoLayerBlockRule, RawServoLayerStatementRule, RawServoMediaList,
|
RawServoImportRule, RawServoKeyframe, RawServoKeyframesRule, RawServoLayerBlockRule,
|
||||||
RawServoMediaRule, RawServoMozDocumentRule, RawServoNamespaceRule, RawServoPageRule,
|
RawServoLayerStatementRule, RawServoMediaList, RawServoMediaRule, RawServoMozDocumentRule,
|
||||||
RawServoScrollTimelineRule, RawServoStyleRule, RawServoStyleSheetContents,
|
RawServoNamespaceRule, RawServoPageRule, RawServoStyleRule, RawServoStyleSheetContents,
|
||||||
RawServoSupportsRule, RawServoContainerRule, ServoCssRules,
|
RawServoSupportsRule, 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;
|
||||||
|
@ -24,9 +24,9 @@ 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::{
|
use crate::stylesheets::{
|
||||||
CounterStyleRule, CssRules, DocumentRule, FontFaceRule, FontFeatureValuesRule, ImportRule,
|
ContainerRule, CounterStyleRule, CssRules, DocumentRule, FontFaceRule, FontFeatureValuesRule,
|
||||||
KeyframesRule, LayerBlockRule, LayerStatementRule, MediaRule, NamespaceRule, PageRule,
|
ImportRule, KeyframesRule, LayerBlockRule, LayerStatementRule, MediaRule, NamespaceRule,
|
||||||
ScrollTimelineRule, StyleRule, StylesheetContents, SupportsRule, ContainerRule,
|
PageRule, StyleRule, StylesheetContents, SupportsRule,
|
||||||
};
|
};
|
||||||
use servo_arc::{Arc, ArcBorrow};
|
use servo_arc::{Arc, ArcBorrow};
|
||||||
use std::{mem, ptr};
|
use std::{mem, ptr};
|
||||||
|
@ -92,9 +92,6 @@ impl_arc_ffi!(Locked<NamespaceRule> => RawServoNamespaceRule
|
||||||
impl_arc_ffi!(Locked<PageRule> => RawServoPageRule
|
impl_arc_ffi!(Locked<PageRule> => RawServoPageRule
|
||||||
[Servo_PageRule_AddRef, Servo_PageRule_Release]);
|
[Servo_PageRule_AddRef, Servo_PageRule_Release]);
|
||||||
|
|
||||||
impl_arc_ffi!(Locked<ScrollTimelineRule> => RawServoScrollTimelineRule
|
|
||||||
[Servo_ScrollTimelineRule_AddRef, Servo_ScrollTimelineRule_Release]);
|
|
||||||
|
|
||||||
impl_arc_ffi!(Locked<SupportsRule> => RawServoSupportsRule
|
impl_arc_ffi!(Locked<SupportsRule> => RawServoSupportsRule
|
||||||
[Servo_SupportsRule_AddRef, Servo_SupportsRule_Release]);
|
[Servo_SupportsRule_AddRef, Servo_SupportsRule_Release]);
|
||||||
|
|
||||||
|
|
|
@ -555,7 +555,6 @@ impl StylesheetInvalidationSet {
|
||||||
LayerStatement(..) |
|
LayerStatement(..) |
|
||||||
FontFace(..) |
|
FontFace(..) |
|
||||||
Keyframes(..) |
|
Keyframes(..) |
|
||||||
ScrollTimeline(..) |
|
|
||||||
Container(..) |
|
Container(..) |
|
||||||
Style(..) => {
|
Style(..) => {
|
||||||
if is_generic_change {
|
if is_generic_change {
|
||||||
|
@ -633,8 +632,6 @@ impl StylesheetInvalidationSet {
|
||||||
// existing elements.
|
// existing elements.
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// TODO: Check if timeline name is referenced, though this might go away in bug 1737918.
|
|
||||||
ScrollTimeline(..) |
|
|
||||||
CounterStyle(..) |
|
CounterStyle(..) |
|
||||||
Page(..) |
|
Page(..) |
|
||||||
Viewport(..) |
|
Viewport(..) |
|
||||||
|
|
|
@ -21,7 +21,6 @@ mod page_rule;
|
||||||
mod rule_list;
|
mod rule_list;
|
||||||
mod rule_parser;
|
mod rule_parser;
|
||||||
mod rules_iterator;
|
mod rules_iterator;
|
||||||
pub mod scroll_timeline_rule;
|
|
||||||
mod style_rule;
|
mod style_rule;
|
||||||
mod stylesheet;
|
mod stylesheet;
|
||||||
pub mod supports_rule;
|
pub mod supports_rule;
|
||||||
|
@ -65,7 +64,6 @@ pub use self::rules_iterator::{AllRules, EffectiveRules};
|
||||||
pub use self::rules_iterator::{
|
pub use self::rules_iterator::{
|
||||||
EffectiveRulesIterator, NestedRuleIterationCondition, RulesIterator,
|
EffectiveRulesIterator, NestedRuleIterationCondition, RulesIterator,
|
||||||
};
|
};
|
||||||
pub use self::scroll_timeline_rule::ScrollTimelineRule;
|
|
||||||
pub use self::style_rule::StyleRule;
|
pub use self::style_rule::StyleRule;
|
||||||
pub use self::stylesheet::{AllowImportRules, SanitizationData, SanitizationKind};
|
pub use self::stylesheet::{AllowImportRules, SanitizationData, SanitizationKind};
|
||||||
pub use self::stylesheet::{DocumentStyleSheet, Namespaces, Stylesheet};
|
pub use self::stylesheet::{DocumentStyleSheet, Namespaces, Stylesheet};
|
||||||
|
@ -266,7 +264,6 @@ pub enum CssRule {
|
||||||
Document(Arc<Locked<DocumentRule>>),
|
Document(Arc<Locked<DocumentRule>>),
|
||||||
LayerBlock(Arc<Locked<LayerBlockRule>>),
|
LayerBlock(Arc<Locked<LayerBlockRule>>),
|
||||||
LayerStatement(Arc<Locked<LayerStatementRule>>),
|
LayerStatement(Arc<Locked<LayerStatementRule>>),
|
||||||
ScrollTimeline(Arc<Locked<ScrollTimelineRule>>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CssRule {
|
impl CssRule {
|
||||||
|
@ -313,7 +310,7 @@ impl CssRule {
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO(emilio): Add memory reporting for these rules.
|
// TODO(emilio): Add memory reporting for these rules.
|
||||||
CssRule::LayerBlock(_) | CssRule::LayerStatement(_) | CssRule::ScrollTimeline(_) => 0,
|
CssRule::LayerBlock(_) | CssRule::LayerStatement(_) => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,8 +347,7 @@ pub enum CssRuleType {
|
||||||
// a constant somewhere.
|
// a constant somewhere.
|
||||||
LayerBlock = 16,
|
LayerBlock = 16,
|
||||||
LayerStatement = 17,
|
LayerStatement = 17,
|
||||||
ScrollTimeline = 18,
|
Container = 18,
|
||||||
Container = 19,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
|
@ -380,7 +376,6 @@ impl CssRule {
|
||||||
CssRule::Document(_) => CssRuleType::Document,
|
CssRule::Document(_) => CssRuleType::Document,
|
||||||
CssRule::LayerBlock(_) => CssRuleType::LayerBlock,
|
CssRule::LayerBlock(_) => CssRuleType::LayerBlock,
|
||||||
CssRule::LayerStatement(_) => CssRuleType::LayerStatement,
|
CssRule::LayerStatement(_) => CssRuleType::LayerStatement,
|
||||||
CssRule::ScrollTimeline(_) => CssRuleType::ScrollTimeline,
|
|
||||||
CssRule::Container(_) => CssRuleType::Container,
|
CssRule::Container(_) => CssRuleType::Container,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -523,10 +518,6 @@ impl DeepCloneWithLock for CssRule {
|
||||||
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
CssRule::ScrollTimeline(ref arc) => {
|
|
||||||
let rule = arc.read_with(guard);
|
|
||||||
CssRule::ScrollTimeline(Arc::new(lock.wrap(rule.clone())))
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,7 +540,6 @@ impl ToCssWithGuard for CssRule {
|
||||||
CssRule::Document(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Document(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||||
CssRule::LayerBlock(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::LayerBlock(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||||
CssRule::LayerStatement(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::LayerStatement(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||||
CssRule::ScrollTimeline(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
|
||||||
CssRule::Container(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
CssRule::Container(ref lock) => lock.read_with(guard).to_css(guard, dest),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,15 @@ use crate::stylesheets::font_feature_values_rule::parse_family_name_list;
|
||||||
use crate::stylesheets::import_rule::ImportLayer;
|
use crate::stylesheets::import_rule::ImportLayer;
|
||||||
use crate::stylesheets::keyframes_rule::parse_keyframe_list;
|
use crate::stylesheets::keyframes_rule::parse_keyframe_list;
|
||||||
use crate::stylesheets::layer_rule::{LayerBlockRule, LayerName, LayerStatementRule};
|
use crate::stylesheets::layer_rule::{LayerBlockRule, LayerName, LayerStatementRule};
|
||||||
use crate::stylesheets::scroll_timeline_rule::ScrollTimelineDescriptors;
|
|
||||||
use crate::stylesheets::stylesheet::Namespaces;
|
use crate::stylesheets::stylesheet::Namespaces;
|
||||||
use crate::stylesheets::supports_rule::SupportsCondition;
|
use crate::stylesheets::supports_rule::SupportsCondition;
|
||||||
use crate::stylesheets::{
|
use crate::stylesheets::{
|
||||||
viewport_rule, AllowImportRules, CorsMode, CssRule, CssRuleType, CssRules, DocumentRule,
|
viewport_rule, AllowImportRules, CorsMode, CssRule, CssRuleType, CssRules, DocumentRule,
|
||||||
FontFeatureValuesRule, KeyframesRule, MediaRule, NamespaceRule, PageRule, PageSelectors,
|
FontFeatureValuesRule, KeyframesRule, MediaRule, NamespaceRule, PageRule, PageSelectors,
|
||||||
RulesMutateError, ScrollTimelineRule, StyleRule, StylesheetLoader, SupportsRule, ViewportRule,
|
RulesMutateError, StyleRule, StylesheetLoader, SupportsRule, ViewportRule,
|
||||||
};
|
};
|
||||||
use crate::values::computed::font::FamilyName;
|
use crate::values::computed::font::FamilyName;
|
||||||
use crate::values::{CssUrl, CustomIdent, KeyframesName, TimelineName};
|
use crate::values::{CssUrl, CustomIdent, KeyframesName};
|
||||||
use crate::{Namespace, Prefix};
|
use crate::{Namespace, Prefix};
|
||||||
use cssparser::{
|
use cssparser::{
|
||||||
AtRuleParser, BasicParseError, BasicParseErrorKind, CowRcStr, Parser, ParserState,
|
AtRuleParser, BasicParseError, BasicParseErrorKind, CowRcStr, Parser, ParserState,
|
||||||
|
@ -207,8 +206,6 @@ pub enum AtRulePrelude {
|
||||||
Namespace(Option<Prefix>, Namespace),
|
Namespace(Option<Prefix>, Namespace),
|
||||||
/// A @layer rule prelude.
|
/// A @layer rule prelude.
|
||||||
Layer(Vec<LayerName>),
|
Layer(Vec<LayerName>),
|
||||||
/// A @scroll-timeline rule prelude.
|
|
||||||
ScrollTimeline(TimelineName),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
|
||||||
|
@ -538,11 +535,6 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
||||||
let cond = DocumentCondition::parse(self.context, input)?;
|
let cond = DocumentCondition::parse(self.context, input)?;
|
||||||
AtRulePrelude::Document(cond)
|
AtRulePrelude::Document(cond)
|
||||||
},
|
},
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
"scroll-timeline" if static_prefs::pref!("layout.css.scroll-linked-animations.enabled") => {
|
|
||||||
let name = TimelineName::parse(self.context, input)?;
|
|
||||||
AtRulePrelude::ScrollTimeline(name)
|
|
||||||
},
|
|
||||||
_ => return Err(input.new_custom_error(StyleParseErrorKind::UnsupportedAtRule(name.clone())))
|
_ => return Err(input.new_custom_error(StyleParseErrorKind::UnsupportedAtRule(name.clone())))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -698,21 +690,6 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
|
||||||
// These rules don't have blocks.
|
// These rules don't have blocks.
|
||||||
Err(input.new_unexpected_token_error(cssparser::Token::CurlyBracketBlock))
|
Err(input.new_unexpected_token_error(cssparser::Token::CurlyBracketBlock))
|
||||||
},
|
},
|
||||||
AtRulePrelude::ScrollTimeline(name) => {
|
|
||||||
let context = ParserContext::new_with_rule_type(
|
|
||||||
self.context,
|
|
||||||
CssRuleType::ScrollTimeline,
|
|
||||||
self.namespaces,
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(CssRule::ScrollTimeline(Arc::new(self.shared_lock.wrap(
|
|
||||||
ScrollTimelineRule {
|
|
||||||
name,
|
|
||||||
descriptors: ScrollTimelineDescriptors::parse(&context, input)?,
|
|
||||||
source_location: start.source_location(),
|
|
||||||
},
|
|
||||||
))))
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,6 @@ where
|
||||||
CssRule::CounterStyle(_) |
|
CssRule::CounterStyle(_) |
|
||||||
CssRule::Viewport(_) |
|
CssRule::Viewport(_) |
|
||||||
CssRule::Keyframes(_) |
|
CssRule::Keyframes(_) |
|
||||||
CssRule::ScrollTimeline(_) |
|
|
||||||
CssRule::Page(_) |
|
CssRule::Page(_) |
|
||||||
CssRule::LayerStatement(_) |
|
CssRule::LayerStatement(_) |
|
||||||
CssRule::FontFeatureValues(_) => None,
|
CssRule::FontFeatureValues(_) => None,
|
||||||
|
|
|
@ -1,337 +0,0 @@
|
||||||
/* 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/. */
|
|
||||||
|
|
||||||
//! scroll-timeline-at-rule: https://drafts.csswg.org/scroll-animations/#scroll-timeline-at-rule
|
|
||||||
|
|
||||||
use crate::parser::{Parse, ParserContext};
|
|
||||||
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
|
|
||||||
use crate::str::CssStringWriter;
|
|
||||||
use crate::values::specified::{LengthPercentage, Number};
|
|
||||||
use crate::values::{AtomIdent, TimelineName};
|
|
||||||
use cssparser::{AtRuleParser, CowRcStr, DeclarationParser, Parser, SourceLocation, Token};
|
|
||||||
use selectors::parser::SelectorParseErrorKind;
|
|
||||||
use std::fmt::{self, Debug, Write};
|
|
||||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
|
||||||
|
|
||||||
/// A [`@scroll-timeline`][descriptors] rule.
|
|
||||||
///
|
|
||||||
/// [descriptors] https://drafts.csswg.org/scroll-animations/#scroll-timeline-descriptors
|
|
||||||
#[derive(Clone, Debug, ToShmem)]
|
|
||||||
pub struct ScrollTimelineRule {
|
|
||||||
/// The name of the current scroll timeline.
|
|
||||||
pub name: TimelineName,
|
|
||||||
/// The descriptors.
|
|
||||||
pub descriptors: ScrollTimelineDescriptors,
|
|
||||||
/// The line and column of the rule's source code.
|
|
||||||
pub source_location: SourceLocation,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToCssWithGuard for ScrollTimelineRule {
|
|
||||||
fn to_css(&self, _guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
|
|
||||||
let mut dest = CssWriter::new(dest);
|
|
||||||
dest.write_str("@scroll-timeline ")?;
|
|
||||||
self.name.to_css(&mut dest)?;
|
|
||||||
dest.write_str(" { ")?;
|
|
||||||
self.descriptors.to_css(&mut dest)?;
|
|
||||||
dest.write_str("}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The descriptors of @scroll-timeline.
|
|
||||||
///
|
|
||||||
/// https://drafts.csswg.org/scroll-animations/#scroll-timeline-descriptors
|
|
||||||
#[derive(Clone, Debug, Default, ToShmem)]
|
|
||||||
pub struct ScrollTimelineDescriptors {
|
|
||||||
/// The source of the current scroll timeline.
|
|
||||||
pub source: Option<Source>,
|
|
||||||
/// The orientation of the current scroll timeline.
|
|
||||||
pub orientation: Option<Orientation>,
|
|
||||||
/// The scroll timeline's scrollOffsets.
|
|
||||||
pub offsets: Option<ScrollOffsets>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for ScrollTimelineDescriptors {
|
|
||||||
fn parse<'i, 't>(
|
|
||||||
context: &ParserContext,
|
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
) -> Result<Self, ParseError<'i>> {
|
|
||||||
use crate::cssparser::DeclarationListParser;
|
|
||||||
use crate::error_reporting::ContextualParseError;
|
|
||||||
|
|
||||||
let mut descriptors = ScrollTimelineDescriptors::default();
|
|
||||||
let parser = ScrollTimelineDescriptorsParser {
|
|
||||||
context,
|
|
||||||
descriptors: &mut descriptors,
|
|
||||||
};
|
|
||||||
let mut iter = DeclarationListParser::new(input, parser);
|
|
||||||
while let Some(declaration) = iter.next() {
|
|
||||||
if let Err((error, slice)) = declaration {
|
|
||||||
let location = error.location;
|
|
||||||
let error = ContextualParseError::UnsupportedRule(slice, error);
|
|
||||||
context.log_css_error(location, error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(descriptors)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Basically, this is used for the serialization of CSSScrollTimelineRule, so we follow the
|
|
||||||
// instructions in https://drafts.csswg.org/scroll-animations-1/#serialize-a-cssscrolltimelinerule.
|
|
||||||
impl ToCss for ScrollTimelineDescriptors {
|
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
||||||
where
|
|
||||||
W: Write,
|
|
||||||
{
|
|
||||||
if let Some(ref value) = self.source {
|
|
||||||
dest.write_str("source: ")?;
|
|
||||||
value.to_css(dest)?;
|
|
||||||
dest.write_str("; ")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(ref value) = self.orientation {
|
|
||||||
dest.write_str("orientation: ")?;
|
|
||||||
value.to_css(dest)?;
|
|
||||||
dest.write_str("; ")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://github.com/w3c/csswg-drafts/issues/6617
|
|
||||||
if let Some(ref value) = self.offsets {
|
|
||||||
dest.write_str("scroll-offsets: ")?;
|
|
||||||
value.to_css(dest)?;
|
|
||||||
dest.write_str("; ")?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ScrollTimelineDescriptorsParser<'a, 'b: 'a> {
|
|
||||||
context: &'a ParserContext<'b>,
|
|
||||||
descriptors: &'a mut ScrollTimelineDescriptors,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b, 'i> AtRuleParser<'i> for ScrollTimelineDescriptorsParser<'a, 'b> {
|
|
||||||
type Prelude = ();
|
|
||||||
type AtRule = ();
|
|
||||||
type Error = StyleParseErrorKind<'i>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b, 'i> DeclarationParser<'i> for ScrollTimelineDescriptorsParser<'a, 'b> {
|
|
||||||
type Declaration = ();
|
|
||||||
type Error = StyleParseErrorKind<'i>;
|
|
||||||
|
|
||||||
fn parse_value<'t>(
|
|
||||||
&mut self,
|
|
||||||
name: CowRcStr<'i>,
|
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
) -> Result<(), ParseError<'i>> {
|
|
||||||
macro_rules! parse_descriptor {
|
|
||||||
(
|
|
||||||
$( $name: tt / $ident: ident, )*
|
|
||||||
) => {
|
|
||||||
match_ignore_ascii_case! { &*name,
|
|
||||||
$(
|
|
||||||
$name => {
|
|
||||||
let value = input.parse_entirely(|i| Parse::parse(self.context, i))?;
|
|
||||||
self.descriptors.$ident = Some(value)
|
|
||||||
},
|
|
||||||
)*
|
|
||||||
_ => {
|
|
||||||
return Err(input.new_custom_error(
|
|
||||||
SelectorParseErrorKind::UnexpectedIdent(name.clone()),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parse_descriptor! {
|
|
||||||
"source" / source,
|
|
||||||
"orientation" / orientation,
|
|
||||||
"scroll-offsets" / offsets,
|
|
||||||
};
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The scroll-timeline source.
|
|
||||||
///
|
|
||||||
/// https://drafts.csswg.org/scroll-animations/#descdef-scroll-timeline-source
|
|
||||||
// FIXME: Bug 1733260 may drop the entire @scroll-timeline, and now we don't support source other
|
|
||||||
// than the default value (so use #[css(skip)]).
|
|
||||||
#[derive(Clone, Debug, Parse, PartialEq, ToCss, ToShmem)]
|
|
||||||
pub enum Source {
|
|
||||||
/// The scroll container.
|
|
||||||
#[css(skip)]
|
|
||||||
Selector(ScrollTimelineSelector),
|
|
||||||
/// The initial value. The scrollingElement of the Document associated with the Window that is
|
|
||||||
/// the current global object.
|
|
||||||
Auto,
|
|
||||||
/// Null. However, it's not clear what is the expected behavior of this. See the spec issue:
|
|
||||||
/// https://drafts.csswg.org/scroll-animations/#issue-0d1e73bd
|
|
||||||
#[css(skip)]
|
|
||||||
None,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Source {
|
|
||||||
fn default() -> Self {
|
|
||||||
Source::Auto
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The scroll-timeline orientation.
|
|
||||||
/// https://drafts.csswg.org/scroll-animations/#descdef-scroll-timeline-orientation
|
|
||||||
///
|
|
||||||
/// Note: the initial orientation is auto, and we will treat it as block, the same as the
|
|
||||||
/// definition of ScrollTimelineOptions (WebIDL API).
|
|
||||||
/// https://drafts.csswg.org/scroll-animations/#dom-scrolltimelineoptions-orientation
|
|
||||||
#[derive(Clone, Copy, Debug, MallocSizeOf, Eq, Parse, PartialEq, PartialOrd, ToCss, ToShmem)]
|
|
||||||
#[repr(u8)]
|
|
||||||
pub enum ScrollDirection {
|
|
||||||
/// The initial value.
|
|
||||||
Auto,
|
|
||||||
/// The direction along the block axis. This is the default value.
|
|
||||||
Block,
|
|
||||||
/// The direction along the inline axis
|
|
||||||
Inline,
|
|
||||||
/// The physical horizontal direction.
|
|
||||||
Horizontal,
|
|
||||||
/// The physical vertical direction.
|
|
||||||
Vertical,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ScrollDirection {
|
|
||||||
fn default() -> Self {
|
|
||||||
ScrollDirection::Auto
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub use self::ScrollDirection as Orientation;
|
|
||||||
|
|
||||||
/// Scroll-timeline offsets. We treat None as an empty vector.
|
|
||||||
/// value: none | <scroll-timeline-offset>#
|
|
||||||
///
|
|
||||||
/// https://drafts.csswg.org/scroll-animations/#descdef-scroll-timeline-scroll-offsets
|
|
||||||
#[derive(Clone, Default, Debug, ToCss, ToShmem)]
|
|
||||||
#[css(comma)]
|
|
||||||
pub struct ScrollOffsets(#[css(if_empty = "none", iterable)] Box<[ScrollTimelineOffset]>);
|
|
||||||
|
|
||||||
impl Parse for ScrollOffsets {
|
|
||||||
fn parse<'i, 't>(
|
|
||||||
_context: &ParserContext,
|
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
) -> Result<Self, ParseError<'i>> {
|
|
||||||
if input.try_parse(|i| i.expect_ident_matching("none")).is_ok() {
|
|
||||||
return Ok(ScrollOffsets(Box::new([])));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(ScrollOffsets(
|
|
||||||
input
|
|
||||||
.parse_comma_separated(|i| ScrollTimelineOffset::parse(i))?
|
|
||||||
.into_boxed_slice(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A <scroll-timeline-offset>.
|
|
||||||
/// value: auto | <length-percentage> | <element-offset>
|
|
||||||
///
|
|
||||||
/// https://drafts.csswg.org/scroll-animations/#typedef-scroll-timeline-offset
|
|
||||||
// FIXME: Bug 1733260 may drop the entire @scroll-timeline, and now we don't support
|
|
||||||
// <scroll-timeline-offset> other than the default value (so use #[css(skip)]).
|
|
||||||
#[derive(Clone, Debug, Parse, PartialEq, ToCss, ToShmem)]
|
|
||||||
pub enum ScrollTimelineOffset {
|
|
||||||
/// The initial value. A container-based offset.
|
|
||||||
Auto,
|
|
||||||
/// A container-based offset with the distance indicated by the value along source's scroll
|
|
||||||
/// range in orientation.
|
|
||||||
#[css(skip)]
|
|
||||||
LengthPercentage(LengthPercentage),
|
|
||||||
/// An element-based offset.
|
|
||||||
#[css(skip)]
|
|
||||||
ElementOffset(ElementOffset),
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An <element-offset-edge>.
|
|
||||||
///
|
|
||||||
/// https://drafts.csswg.org/scroll-animations-1/#typedef-element-offset-edge
|
|
||||||
#[derive(Clone, Copy, Debug, MallocSizeOf, Eq, Parse, PartialEq, PartialOrd, ToCss, ToShmem)]
|
|
||||||
pub enum ElementOffsetEdge {
|
|
||||||
/// Start edge
|
|
||||||
Start,
|
|
||||||
/// End edge.
|
|
||||||
End,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An <element-offset>.
|
|
||||||
/// value: selector( <id-selector> ) [<element-offset-edge> || <number>]?
|
|
||||||
///
|
|
||||||
/// https://drafts.csswg.org/scroll-animations-1/#typedef-element-offset
|
|
||||||
#[derive(Clone, Debug, PartialEq, ToCss, ToShmem)]
|
|
||||||
pub struct ElementOffset {
|
|
||||||
/// The target whose intersection with source's scrolling box determines the concrete scroll
|
|
||||||
/// offset.
|
|
||||||
target: ScrollTimelineSelector,
|
|
||||||
/// An optional value of <element-offset-edge>. If not provided, the default value is start.
|
|
||||||
edge: Option<ElementOffsetEdge>,
|
|
||||||
/// An optional value of threshold. If not provided, the default value is 0.
|
|
||||||
threshold: Option<Number>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for ElementOffset {
|
|
||||||
fn parse<'i, 't>(
|
|
||||||
context: &ParserContext,
|
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
) -> Result<Self, ParseError<'i>> {
|
|
||||||
let target = ScrollTimelineSelector::parse(context, input)?;
|
|
||||||
|
|
||||||
// Parse `[<element-offset-edge> || <number>]?`
|
|
||||||
let mut edge = input.try_parse(ElementOffsetEdge::parse).ok();
|
|
||||||
let threshold = input.try_parse(|i| Number::parse(context, i)).ok();
|
|
||||||
if edge.is_none() {
|
|
||||||
edge = input.try_parse(ElementOffsetEdge::parse).ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(ElementOffset {
|
|
||||||
target,
|
|
||||||
edge,
|
|
||||||
threshold,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The type of the selector ID.
|
|
||||||
#[derive(Clone, Eq, PartialEq, ToShmem)]
|
|
||||||
pub struct ScrollTimelineSelector(AtomIdent);
|
|
||||||
|
|
||||||
impl Parse for ScrollTimelineSelector {
|
|
||||||
fn parse<'i, 't>(
|
|
||||||
_context: &ParserContext,
|
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
) -> Result<Self, ParseError<'i>> {
|
|
||||||
// Parse `selector(<id-selector>)`.
|
|
||||||
input.expect_function_matching("selector")?;
|
|
||||||
input.parse_nested_block(|i| match i.next()? {
|
|
||||||
Token::IDHash(id) => Ok(ScrollTimelineSelector(id.as_ref().into())),
|
|
||||||
_ => Err(i.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToCss for ScrollTimelineSelector {
|
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
||||||
where
|
|
||||||
W: Write,
|
|
||||||
{
|
|
||||||
dest.write_str("selector(")?;
|
|
||||||
dest.write_char('#')?;
|
|
||||||
self.0.to_css(dest)?;
|
|
||||||
dest.write_char(')')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for ScrollTimelineSelector {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
self.to_css(&mut CssWriter::new(f))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -382,8 +382,7 @@ impl SanitizationKind {
|
||||||
CssRule::Page(..) |
|
CssRule::Page(..) |
|
||||||
CssRule::FontFeatureValues(..) |
|
CssRule::FontFeatureValues(..) |
|
||||||
CssRule::Viewport(..) |
|
CssRule::Viewport(..) |
|
||||||
CssRule::CounterStyle(..) |
|
CssRule::CounterStyle(..) => !is_standard,
|
||||||
CssRule::ScrollTimeline(..) => !is_standard,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,7 @@ use crate::stylesheets::keyframes_rule::KeyframesAnimation;
|
||||||
use crate::stylesheets::layer_rule::{LayerName, LayerOrder};
|
use crate::stylesheets::layer_rule::{LayerName, LayerOrder};
|
||||||
use crate::stylesheets::viewport_rule::{self, MaybeNew, ViewportRule};
|
use crate::stylesheets::viewport_rule::{self, MaybeNew, ViewportRule};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use crate::stylesheets::{
|
use crate::stylesheets::{CounterStyleRule, FontFaceRule, FontFeatureValuesRule, PageRule};
|
||||||
CounterStyleRule, FontFaceRule, FontFeatureValuesRule, ScrollTimelineRule,
|
|
||||||
};
|
|
||||||
use crate::stylesheets::{
|
use crate::stylesheets::{
|
||||||
CssRule, EffectiveRulesIterator, Origin, OriginSet, PageRule, PerOrigin, PerOriginIter,
|
CssRule, EffectiveRulesIterator, Origin, OriginSet, PageRule, PerOrigin, PerOriginIter,
|
||||||
};
|
};
|
||||||
|
@ -1689,10 +1687,6 @@ pub struct ExtraStyleData {
|
||||||
/// A map of effective page rules.
|
/// A map of effective page rules.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub pages: PageRuleMap,
|
pub pages: PageRuleMap,
|
||||||
|
|
||||||
/// A map of effective scroll-timeline rules.
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
pub scroll_timelines: LayerOrderedMap<Arc<Locked<ScrollTimelineRule>>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
@ -1744,23 +1738,11 @@ impl ExtraStyleData {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add the given @scroll-timeline rule.
|
|
||||||
fn add_scroll_timeline(
|
|
||||||
&mut self,
|
|
||||||
guard: &SharedRwLockReadGuard,
|
|
||||||
rule: &Arc<Locked<ScrollTimelineRule>>,
|
|
||||||
layer: LayerId,
|
|
||||||
) -> Result<(), AllocErr> {
|
|
||||||
let name = rule.read_with(guard).name.as_atom().clone();
|
|
||||||
self.scroll_timelines.try_insert(name, rule.clone(), layer)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sort_by_layer(&mut self, layers: &[CascadeLayer]) {
|
fn sort_by_layer(&mut self, layers: &[CascadeLayer]) {
|
||||||
self.font_faces.sort(layers);
|
self.font_faces.sort(layers);
|
||||||
self.font_feature_values.sort(layers);
|
self.font_feature_values.sort(layers);
|
||||||
self.counter_styles.sort(layers);
|
self.counter_styles.sort(layers);
|
||||||
self.pages.global.sort(layers);
|
self.pages.global.sort(layers);
|
||||||
self.scroll_timelines.sort(layers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear(&mut self) {
|
fn clear(&mut self) {
|
||||||
|
@ -1770,7 +1752,6 @@ impl ExtraStyleData {
|
||||||
self.font_feature_values.clear();
|
self.font_feature_values.clear();
|
||||||
self.counter_styles.clear();
|
self.counter_styles.clear();
|
||||||
self.pages.clear();
|
self.pages.clear();
|
||||||
self.scroll_timelines.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1807,7 +1788,6 @@ impl MallocSizeOf for ExtraStyleData {
|
||||||
n += self.font_feature_values.shallow_size_of(ops);
|
n += self.font_feature_values.shallow_size_of(ops);
|
||||||
n += self.counter_styles.shallow_size_of(ops);
|
n += self.counter_styles.shallow_size_of(ops);
|
||||||
n += self.pages.shallow_size_of(ops);
|
n += self.pages.shallow_size_of(ops);
|
||||||
n += self.scroll_timelines.shallow_size_of(ops);
|
|
||||||
n
|
n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2631,13 +2611,6 @@ impl CascadeData {
|
||||||
)?;
|
)?;
|
||||||
},
|
},
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
CssRule::ScrollTimeline(ref rule) => {
|
|
||||||
// Note: Bug 1733260: we may drop @scroll-timeline rule once this spec issue
|
|
||||||
// https://github.com/w3c/csswg-drafts/issues/6674 gets landed.
|
|
||||||
self.extra_data
|
|
||||||
.add_scroll_timeline(guard, rule, containing_rule_state.layer_id)?;
|
|
||||||
},
|
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
CssRule::FontFace(ref rule) => {
|
CssRule::FontFace(ref rule) => {
|
||||||
// NOTE(emilio): We don't care about container_condition_id
|
// NOTE(emilio): We don't care about container_condition_id
|
||||||
// because:
|
// because:
|
||||||
|
@ -2905,7 +2878,6 @@ impl CascadeData {
|
||||||
CssRule::CounterStyle(..) |
|
CssRule::CounterStyle(..) |
|
||||||
CssRule::Supports(..) |
|
CssRule::Supports(..) |
|
||||||
CssRule::Keyframes(..) |
|
CssRule::Keyframes(..) |
|
||||||
CssRule::ScrollTimeline(..) |
|
|
||||||
CssRule::Page(..) |
|
CssRule::Page(..) |
|
||||||
CssRule::Viewport(..) |
|
CssRule::Viewport(..) |
|
||||||
CssRule::Document(..) |
|
CssRule::Document(..) |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue