Bug 1833540 - [css-properties-values-api] Implement parsing and serialization for @property at-rule r=emilio

Implemented behind the new properties-and-values pref.

Support for the CSSPropertyRule WebIDL interface is also added in this
patch, because until it's added, any attempt to access the rule using
the CSSOM would crash the browser.

Depends on D178268

Differential Revision: https://phabricator.services.mozilla.com/D178270
This commit is contained in:
Zach Hoffman 2023-05-22 19:11:30 +00:00
parent a03bac885c
commit 18c5efd367
32 changed files with 581 additions and 293 deletions

View File

@ -8,6 +8,13 @@ MimeNotCssWarn=The stylesheet %1$S was loaded as CSS even though its MIME type,
PEDeclDropped=Declaration dropped.
PEDeclSkipped=Skipped to next declaration.
PEUnknownProperty=Unknown property %1$S.
PEPRSyntaxFieldEmptyInput=@property syntax descriptor is empty.
PEPRSyntaxFieldExpectedPipe=@property syntax descriptor %S contains components without a pipe between them.
PEPRSyntaxFieldInvalidNameStart=@property syntax descriptor %S contains a component name that starts with an invalid character.
PEPRSyntaxFieldInvalidName=@property syntax descriptor %S contains a component name with an invalid character.
PEPRSyntaxFieldUnclosedDataTypeName=@property syntax descriptor %S contains an unclosed data type name.
PEPRSyntaxFieldUnexpectedEOF=@property syntax descriptor %S is incomplete.
PEPRSyntaxFieldUnknownDataTypeName=@property syntax descriptor %S contains an unknown data type name.
PEValueParsingError=Error in parsing value for %1$S.
PEUnknownAtRule=Unrecognized at-rule or error parsing at-rule %1$S.
PEMQUnexpectedOperator=Unexpected operator in media list.

View File

@ -0,0 +1,17 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://drafts.css-houdini.org/css-properties-values-api-1/#the-css-property-rule-interface
*/
// https://drafts.css-houdini.org/css-properties-values-api-1/#the-css-property-rule-interface
[Exposed=Window, Pref="layout.css.properties-and-values.enabled"]
interface CSSPropertyRule : CSSRule {
readonly attribute UTF8String name;
readonly attribute UTF8String syntax;
readonly attribute boolean inherits;
readonly attribute UTF8String? initialValue;
};

View File

@ -492,6 +492,7 @@ WEBIDL_FILES = [
"CSSMozDocumentRule.webidl",
"CSSNamespaceRule.webidl",
"CSSPageRule.webidl",
"CSSPropertyRule.webidl",
"CSSPseudoElement.webidl",
"CSSRule.webidl",
"CSSRuleList.webidl",

View File

@ -98,6 +98,7 @@ void ServoStyleRuleMap::RuleRemoved(StyleSheet& aStyleSheet,
case StyleCssRuleType::LayerStatement:
case StyleCssRuleType::FontFace:
case StyleCssRuleType::Page:
case StyleCssRuleType::Property:
case StyleCssRuleType::Keyframes:
case StyleCssRuleType::Keyframe:
case StyleCssRuleType::Namespace:
@ -144,6 +145,7 @@ void ServoStyleRuleMap::FillTableFromRule(css::Rule& aRule) {
case StyleCssRuleType::LayerStatement:
case StyleCssRuleType::FontFace:
case StyleCssRuleType::Page:
case StyleCssRuleType::Property:
case StyleCssRuleType::Keyframes:
case StyleCssRuleType::Keyframe:
case StyleCssRuleType::Namespace:

View File

@ -0,0 +1,72 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/CSSPropertyRule.h"
#include "mozilla/dom/CSSPropertyRuleBinding.h"
#include "mozilla/ServoBindings.h"
namespace mozilla::dom {
bool CSSPropertyRule::IsCCLeaf() const { return Rule::IsCCLeaf(); }
void CSSPropertyRule::SetRawAfterClone(RefPtr<StyleLockedPropertyRule> aRaw) {
mRawRule = std::move(aRaw);
}
/* virtual */
JSObject* CSSPropertyRule::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return CSSPropertyRule_Binding::Wrap(aCx, this, aGivenProto);
}
#ifdef DEBUG
void CSSPropertyRule::List(FILE* out, int32_t aIndent) const {
nsAutoCString str;
for (int32_t i = 0; i < aIndent; i++) {
str.AppendLiteral(" ");
}
Servo_PropertyRule_Debug(mRawRule, &str);
fprintf_stderr(out, "%s\n", str.get());
}
#endif
size_t CSSPropertyRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
// TODO Implement this!
return aMallocSizeOf(this);
}
StyleCssRuleType CSSPropertyRule::Type() const {
return StyleCssRuleType::Property;
}
/* CSSRule implementation */
void CSSPropertyRule::GetCssText(nsACString& aCssText) const {
Servo_PropertyRule_GetCssText(mRawRule, &aCssText);
}
/* CSSPropertyRule implementation */
void CSSPropertyRule::GetName(nsACString& aNameStr) const {
Servo_PropertyRule_GetName(mRawRule, &aNameStr);
}
void CSSPropertyRule::GetSyntax(nsACString& aSyntaxStr) const {
Servo_PropertyRule_GetSyntax(mRawRule, &aSyntaxStr);
}
bool CSSPropertyRule::Inherits() const {
return Servo_PropertyRule_GetInherits(mRawRule);
}
void CSSPropertyRule::GetInitialValue(nsACString& aInitialValueStr) const {
bool found = Servo_PropertyRule_GetInitialValue(mRawRule, &aInitialValueStr);
if (!found) {
aInitialValueStr.SetIsVoid(true);
}
}
} // namespace mozilla::dom

View File

@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_CSSPropertyRule_h
#define mozilla_dom_CSSPropertyRule_h
#include "mozilla/css/Rule.h"
#include "mozilla/ServoBindingTypes.h"
#include "nsICSSDeclaration.h"
struct StyleLockedPropertyRule;
namespace mozilla::dom {
class CSSPropertyRule final : public css::Rule {
public:
CSSPropertyRule(already_AddRefed<StyleLockedPropertyRule> aRawRule,
StyleSheet* aSheet, css::Rule* aParentRule, uint32_t aLine,
uint32_t aColumn)
: css::Rule(aSheet, aParentRule, aLine, aColumn),
mRawRule(std::move(aRawRule)) {}
bool IsCCLeaf() const final;
StyleLockedPropertyRule* Raw() const { return mRawRule; }
void SetRawAfterClone(RefPtr<StyleLockedPropertyRule> aRaw);
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
#ifdef DEBUG
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
#endif
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
// WebIDL interfaces
StyleCssRuleType Type() const final;
void GetName(nsACString& aName) const;
void GetSyntax(nsACString& aSyntax) const;
bool Inherits() const;
void GetInitialValue(nsACString& aInitialValueStr) const;
void GetCssText(nsACString& aCssText) const final;
private:
~CSSPropertyRule() = default;
RefPtr<StyleLockedPropertyRule> mRawRule;
};
} // namespace mozilla::dom
#endif // mozilla_dom_CSSPropertyRule_h

View File

@ -63,6 +63,7 @@ GROUP_RULE_FUNCS(Media)
GROUP_RULE_FUNCS(Document)
BASIC_RULE_FUNCS(Namespace)
BASIC_RULE_FUNCS(Page)
BASIC_RULE_FUNCS(Property)
GROUP_RULE_FUNCS(Supports)
GROUP_RULE_FUNCS(LayerBlock)
BASIC_RULE_FUNCS(LayerStatement)

View File

@ -21,6 +21,7 @@
#include "mozilla/dom/CSSMozDocumentRule.h"
#include "mozilla/dom/CSSNamespaceRule.h"
#include "mozilla/dom/CSSPageRule.h"
#include "mozilla/dom/CSSPropertyRule.h"
#include "mozilla/dom/CSSStyleRule.h"
#include "mozilla/dom/CSSSupportsRule.h"
#include "mozilla/IntegerRange.h"
@ -83,6 +84,7 @@ css::Rule* ServoCSSRuleList::GetRule(uint32_t aIndex) {
CASE_RULE(Media, Media)
CASE_RULE(Namespace, Namespace)
CASE_RULE(Page, Page)
CASE_RULE(Property, Property)
CASE_RULE(Supports, Supports)
CASE_RULE(Document, MozDocument)
CASE_RULE(Import, Import)
@ -253,6 +255,7 @@ void ServoCSSRuleList::SetRawContents(RefPtr<StyleLockedCssRules> aNewRules,
CASE_FOR(Media, Media)
CASE_FOR(Namespace, Namespace)
CASE_FOR(Page, Page)
CASE_FOR(Property, Property)
CASE_FOR(Supports, Supports)
CASE_FOR(Document, MozDocument)
CASE_FOR(Import, Import)

View File

@ -27,6 +27,7 @@ SERVO_LOCKED_ARC_TYPE(NamespaceRule)
SERVO_LOCKED_ARC_TYPE(SupportsRule)
SERVO_LOCKED_ARC_TYPE(DocumentRule)
SERVO_LOCKED_ARC_TYPE(PageRule)
SERVO_LOCKED_ARC_TYPE(PropertyRule)
SERVO_LOCKED_ARC_TYPE(ContainerRule)
SERVO_LOCKED_ARC_TYPE(FontFeatureValuesRule)
SERVO_LOCKED_ARC_TYPE(FontPaletteValuesRule)

View File

@ -46,6 +46,7 @@ template struct StyleStrong<StyleLockedMediaRule>;
template struct StyleStrong<StyleLockedDocumentRule>;
template struct StyleStrong<StyleLockedNamespaceRule>;
template struct StyleStrong<StyleLockedPageRule>;
template struct StyleStrong<StyleLockedPropertyRule>;
template struct StyleStrong<StyleLockedSupportsRule>;
template struct StyleStrong<StyleLockedFontFeatureValuesRule>;
template struct StyleStrong<StyleLockedFontPaletteValuesRule>;

View File

@ -39,6 +39,7 @@
#include "mozilla/dom/CSSKeyframeRule.h"
#include "mozilla/dom/CSSNamespaceRule.h"
#include "mozilla/dom/CSSPageRule.h"
#include "mozilla/dom/CSSPropertyRule.h"
#include "mozilla/dom/CSSSupportsRule.h"
#include "mozilla/dom/FontFaceSet.h"
#include "mozilla/dom/Element.h"
@ -1014,6 +1015,7 @@ void ServoStyleSet::RuleChangedInternal(StyleSheet& aSheet, css::Rule& aRule,
CASE_FOR(FontPaletteValues, FontPaletteValues)
CASE_FOR(FontFace, FontFace)
CASE_FOR(Page, Page)
CASE_FOR(Property, Property)
CASE_FOR(Document, MozDocument)
CASE_FOR(Supports, Supports)
CASE_FOR(LayerBlock, LayerBlock)

View File

@ -135,6 +135,7 @@ EXPORTS.mozilla.dom += [
"CSSMozDocumentRule.h",
"CSSNamespaceRule.h",
"CSSPageRule.h",
"CSSPropertyRule.h",
"CSSRuleList.h",
"CSSStyleRule.h",
"CSSSupportsRule.h",
@ -185,6 +186,7 @@ UNIFIED_SOURCES += [
"CSSMozDocumentRule.cpp",
"CSSNamespaceRule.cpp",
"CSSPageRule.cpp",
"CSSPropertyRule.cpp",
"CSSRuleList.cpp",
"CSSStyleRule.cpp",
"CSSSupportsRule.cpp",

View File

@ -8791,6 +8791,13 @@
value: @IS_EARLY_BETA_OR_EARLIER@
mirror: always
# Whether Properties and Values is enabled
- name: layout.css.properties-and-values.enabled
type: RelaxedAtomicBool
value: false
mirror: always
rust: true
# Dictates whether or not the prefers contrast media query will be
# usable.
# true: prefers-contrast will toggle based on OS and browser settings.

View File

@ -22,6 +22,8 @@ pub enum ContextualParseError<'a> {
ParseError<'a>,
Option<&'a SelectorList<SelectorImpl>>,
),
/// A property descriptor was not recognized.
UnsupportedPropertyDescriptor(&'a str, ParseError<'a>),
/// A font face descriptor was not recognized.
UnsupportedFontFaceDescriptor(&'a str, ParseError<'a>),
/// A font feature values descriptor was not recognized.
@ -135,6 +137,14 @@ impl<'a> fmt::Display for ContextualParseError<'a> {
write!(f, "Unsupported property declaration: '{}', ", decl)?;
parse_error_to_str(err, f)
},
ContextualParseError::UnsupportedPropertyDescriptor(decl, ref err) => {
write!(
f,
"Unsupported @property descriptor declaration: '{}', ",
decl
)?;
parse_error_to_str(err, f)
},
ContextualParseError::UnsupportedFontFaceDescriptor(decl, ref err) => {
write!(
f,

View File

@ -16,7 +16,7 @@ use crate::stylesheets::keyframes_rule::Keyframe;
use crate::stylesheets::{
ContainerRule, CounterStyleRule, CssRules, DocumentRule, FontFaceRule, FontFeatureValuesRule,
FontPaletteValuesRule, ImportRule, KeyframesRule, LayerBlockRule, LayerStatementRule,
MediaRule, NamespaceRule, PageRule, StyleRule, StylesheetContents, SupportsRule,
MediaRule, NamespaceRule, PageRule, PropertyRule, StyleRule, StylesheetContents, SupportsRule,
};
use servo_arc::Arc;
@ -114,6 +114,12 @@ impl_locked_arc_ffi!(
Servo_PageRule_AddRef,
Servo_PageRule_Release
);
impl_locked_arc_ffi!(
PropertyRule,
LockedPropertyRule,
Servo_PropertyRule_AddRef,
Servo_PropertyRule_Release
);
impl_locked_arc_ffi!(
SupportsRule,
LockedSupportsRule,

View File

@ -550,6 +550,7 @@ impl StylesheetInvalidationSet {
},
CounterStyle(..) |
Page(..) |
Property(..) |
Viewport(..) |
FontFeatureValues(..) |
FontPaletteValues(..) |
@ -633,7 +634,11 @@ impl StylesheetInvalidationSet {
// existing elements.
}
},
CounterStyle(..) | Page(..) | Viewport(..) | FontFeatureValues(..) |
CounterStyle(..) |
Page(..) |
Property(..) |
Viewport(..) |
FontFeatureValues(..) |
FontPaletteValues(..) => {
debug!(
" > Found unsupported rule, marking the whole subtree \

View File

@ -6,4 +6,5 @@
//!
//! https://drafts.css-houdini.org/css-properties-values-api-1/
pub mod rule;
pub mod syntax;

View File

@ -0,0 +1,245 @@
/* 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/. */
//! The [`@property`] at-rule.
//!
//! https://drafts.css-houdini.org/css-properties-values-api-1/#at-property-rule
use crate::custom_properties::{Name as CustomPropertyName, SpecifiedValue};
use crate::error_reporting::ContextualParseError;
use crate::parser::{Parse, ParserContext};
use crate::properties_and_values::syntax::Descriptor as SyntaxDescriptor;
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
use crate::str::CssStringWriter;
use crate::values::serialize_atom_name;
use cssparser::{
AtRuleParser, CowRcStr, DeclarationParser, ParseErrorKind, Parser, QualifiedRuleParser,
RuleBodyItemParser, RuleBodyParser, SourceLocation,
};
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use selectors::parser::SelectorParseErrorKind;
use servo_arc::Arc;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
use to_shmem::{SharedMemoryBuilder, ToShmem};
/// Parse the block inside a `@property` rule.
///
/// Valid `@property` rules result in a registered custom property, as if `registerProperty()` had
/// been called with equivalent parameters.
pub fn parse_property_block(
context: &ParserContext,
input: &mut Parser,
name: PropertyRuleName,
location: SourceLocation,
) -> PropertyRuleData {
let mut rule = PropertyRuleData::empty(name, location);
let mut parser = PropertyRuleParser {
context,
rule: &mut rule,
};
let mut iter = RuleBodyParser::new(input, &mut parser);
while let Some(declaration) = iter.next() {
if !context.error_reporting_enabled() {
continue;
}
if let Err((error, slice)) = declaration {
let location = error.location;
let error = if matches!(
error.kind,
ParseErrorKind::Custom(StyleParseErrorKind::PropertySyntaxField(_))
) {
ContextualParseError::UnsupportedValue(slice, error)
} else {
ContextualParseError::UnsupportedPropertyDescriptor(slice, error)
};
context.log_css_error(location, error);
}
}
rule
}
struct PropertyRuleParser<'a, 'b: 'a> {
context: &'a ParserContext<'b>,
rule: &'a mut PropertyRuleData,
}
/// Default methods reject all at rules.
impl<'a, 'b, 'i> AtRuleParser<'i> for PropertyRuleParser<'a, 'b> {
type Prelude = ();
type AtRule = ();
type Error = StyleParseErrorKind<'i>;
}
impl<'a, 'b, 'i> QualifiedRuleParser<'i> for PropertyRuleParser<'a, 'b> {
type Prelude = ();
type QualifiedRule = ();
type Error = StyleParseErrorKind<'i>;
}
impl<'a, 'b, 'i> RuleBodyItemParser<'i, (), StyleParseErrorKind<'i>>
for PropertyRuleParser<'a, 'b>
{
fn parse_qualified(&self) -> bool {
false
}
fn parse_declarations(&self) -> bool {
true
}
}
macro_rules! property_descriptors {
(
$( #[$doc: meta] $name: tt $ident: ident: $ty: ty, )*
) => {
/// Data inside a `@property` rule.
///
/// <https://drafts.css-houdini.org/css-properties-values-api-1/#at-property-rule>
#[derive(Clone, Debug, PartialEq)]
pub struct PropertyRuleData {
/// The custom property name.
pub name: PropertyRuleName,
$(
#[$doc]
pub $ident: Option<$ty>,
)*
/// Line and column of the @property rule source code.
pub source_location: SourceLocation,
}
impl PropertyRuleData {
/// Create an empty property rule
pub fn empty(name: PropertyRuleName, source_location: SourceLocation) -> Self {
PropertyRuleData {
name,
$(
$ident: None,
)*
source_location,
}
}
/// Serialization of declarations in PropertyRuleData
pub fn decl_to_css(&self, dest: &mut CssStringWriter) -> fmt::Result {
$(
if let Some(ref value) = self.$ident {
dest.write_str(concat!($name, ": "))?;
value.to_css(&mut CssWriter::new(dest))?;
dest.write_str("; ")?;
}
)*
Ok(())
}
}
impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyRuleParser<'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>> {
match_ignore_ascii_case! { &*name,
$(
$name => {
// DeclarationParser also calls parse_entirely so wed normally not need
// to, but in this case we do because we set the value as a side effect
// rather than returning it.
let value = input.parse_entirely(|i| Parse::parse(self.context, i))?;
self.rule.$ident = Some(value)
},
)*
_ => return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone()))),
}
Ok(())
}
}
}
}
#[cfg(feature = "gecko")]
property_descriptors! {
/// <https://drafts.css-houdini.org/css-properties-values-api-1/#the-syntax-descriptor>
"syntax" syntax: SyntaxDescriptor,
/// <https://drafts.css-houdini.org/css-properties-values-api-1/#inherits-descriptor>
"inherits" inherits: Inherits,
/// <https://drafts.css-houdini.org/css-properties-values-api-1/#initial-value-descriptor>
"initial-value" initial_value: InitialValue,
}
impl PropertyRuleData {
/// Measure heap usage.
#[cfg(feature = "gecko")]
pub fn size_of(&self, _guard: &SharedRwLockReadGuard, ops: &mut MallocSizeOfOps) -> usize {
self.name.0.size_of(ops) +
self.syntax.size_of(ops) +
self.inherits.size_of(ops) +
if let Some(ref initial_value) = self.initial_value {
initial_value.size_of(ops)
} else {
0
}
}
}
impl ToCssWithGuard for PropertyRuleData {
/// <https://drafts.css-houdini.org/css-properties-values-api-1/#serialize-a-csspropertyrule>
fn to_css(&self, _guard: &SharedRwLockReadGuard, dest: &mut CssStringWriter) -> fmt::Result {
dest.write_str("@property ")?;
self.name.to_css(&mut CssWriter::new(dest))?;
dest.write_str(" { ")?;
self.decl_to_css(dest)?;
dest.write_char('}')
}
}
impl ToShmem for PropertyRuleData {
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> to_shmem::Result<Self> {
Err(String::from(
"ToShmem failed for PropertyRule: cannot handle @property rules",
))
}
}
/// A custom property name wrapper that includes the `--` prefix in its serialization
#[derive(Clone, Debug, PartialEq)]
pub struct PropertyRuleName(pub Arc<CustomPropertyName>);
impl ToCss for PropertyRuleName {
fn to_css<W: Write>(&self, dest: &mut CssWriter<W>) -> fmt::Result {
dest.write_str("--")?;
serialize_atom_name(&self.0, dest)
}
}
/// <https://drafts.css-houdini.org/css-properties-values-api-1/#inherits-descriptor>
#[derive(Clone, Debug, MallocSizeOf, Parse, PartialEq, ToCss)]
pub enum Inherits {
/// `true` value for the `inherits` descriptor
True,
/// `false` value for the `inherits` descriptor
False,
}
/// Specifies the initial value of the custom property registration represented by the @property
/// rule, controlling the propertys initial value.
///
/// The SpecifiedValue is wrapped in an Arc to avoid copying when using it.
pub type InitialValue = Arc<SpecifiedValue>;
impl Parse for InitialValue {
fn parse<'i, 't>(
_context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
input.skip_whitespace();
SpecifiedValue::parse(input)
}
}

View File

@ -19,6 +19,7 @@ mod media_rule;
mod namespace_rule;
pub mod origin;
mod page_rule;
mod property_rule;
mod rule_list;
mod rule_parser;
mod rules_iterator;
@ -61,6 +62,7 @@ pub use self::media_rule::MediaRule;
pub use self::namespace_rule::NamespaceRule;
pub use self::origin::{Origin, OriginSet, OriginSetIterator, PerOrigin, PerOriginIter};
pub use self::page_rule::{PageRule, PageSelector, PageSelectors};
pub use self::property_rule::PropertyRule;
pub use self::rule_list::{CssRules, CssRulesHelpers};
pub use self::rule_parser::{InsertRuleContext, State, TopLevelRuleParser};
pub use self::rules_iterator::{AllRules, EffectiveRules};
@ -261,6 +263,7 @@ pub enum CssRule {
Keyframes(Arc<Locked<KeyframesRule>>),
Supports(Arc<Locked<SupportsRule>>),
Page(Arc<Locked<PageRule>>),
Property(Arc<Locked<PropertyRule>>),
Document(Arc<Locked<DocumentRule>>),
LayerBlock(Arc<Locked<LayerBlockRule>>),
LayerStatement(Arc<Locked<LayerStatementRule>>),
@ -306,6 +309,10 @@ impl CssRule {
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
},
CssRule::Property(ref lock) => {
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
},
CssRule::Document(ref lock) => {
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
},
@ -350,6 +357,8 @@ pub enum CssRuleType {
LayerStatement = 17,
Container = 18,
FontPaletteValues = 19,
// 20 is an arbitrary number to use for Property.
Property = 20,
}
impl CssRuleType {
@ -413,6 +422,7 @@ impl CssRule {
CssRule::Viewport(_) => CssRuleType::Viewport,
CssRule::Supports(_) => CssRuleType::Supports,
CssRule::Page(_) => CssRuleType::Page,
CssRule::Property(_) => CssRuleType::Property,
CssRule::Document(_) => CssRuleType::Document,
CssRule::LayerBlock(_) => CssRuleType::LayerBlock,
CssRule::LayerStatement(_) => CssRuleType::LayerStatement,
@ -545,6 +555,10 @@ impl DeepCloneWithLock for CssRule {
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
))
},
CssRule::Property(ref arc) => {
let rule = arc.read_with(guard);
CssRule::Property(Arc::new(lock.wrap(rule.clone())))
},
CssRule::Document(ref arc) => {
let rule = arc.read_with(guard);
CssRule::Document(Arc::new(
@ -583,6 +597,7 @@ impl ToCssWithGuard for CssRule {
CssRule::Media(ref lock) => lock.read_with(guard).to_css(guard, dest),
CssRule::Supports(ref lock) => lock.read_with(guard).to_css(guard, dest),
CssRule::Page(ref lock) => lock.read_with(guard).to_css(guard, dest),
CssRule::Property(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::LayerStatement(ref lock) => lock.read_with(guard).to_css(guard, dest),

View File

@ -0,0 +1,5 @@
/* 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/. */
pub use crate::properties_and_values::rule::PropertyRuleData as PropertyRule;

View File

@ -5,6 +5,7 @@
//! Parsing of the stylesheet contents.
use crate::counter_style::{parse_counter_style_body, parse_counter_style_name_definition};
use crate::custom_properties::parse_name as parse_custom_property_name;
use crate::error_reporting::ContextualParseError;
use crate::font_face::parse_font_face_block;
use crate::media_queries::MediaList;
@ -12,6 +13,7 @@ use crate::parser::{Parse, ParserContext};
use crate::properties::declaration_block::{
parse_property_declaration_list, DeclarationParserState, PropertyDeclarationBlock,
};
use crate::properties_and_values::rule::{parse_property_block, PropertyRuleName};
use crate::selector_parser::{SelectorImpl, SelectorParser};
use crate::shared_lock::{Locked, SharedRwLock};
use crate::str::starts_with_ignore_ascii_case;
@ -30,7 +32,7 @@ use crate::stylesheets::{
};
use crate::values::computed::font::FamilyName;
use crate::values::{CssUrl, CustomIdent, DashedIdent, KeyframesName};
use crate::{Namespace, Prefix};
use crate::{Atom, Namespace, Prefix};
use cssparser::{
AtRuleParser, BasicParseError, BasicParseErrorKind, CowRcStr, DeclarationParser, Parser,
ParserState, QualifiedRuleParser, RuleBodyItemParser, RuleBodyParser, SourceLocation,
@ -201,6 +203,8 @@ pub enum AtRulePrelude {
Keyframes(KeyframesName, Option<VendorPrefix>),
/// A @page rule prelude, with its page name if it exists.
Page(PageSelectors),
/// A @property rule prelude.
Property(PropertyRuleName),
/// A @document rule, with its conditional.
Document(DocumentCondition),
/// A @import rule prelude.
@ -586,6 +590,13 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
input.try_parse(|i| PageSelectors::parse(self.context, i)).unwrap_or_default()
)
},
"property" if static_prefs::pref!("layout.css.properties-and-values.enabled") => {
let name = input.expect_ident_cloned()?;
let name = parse_custom_property_name(&name).map_err(|_| {
input.new_custom_error(StyleParseErrorKind::UnexpectedIdent(name.clone()))
})?;
AtRulePrelude::Property(PropertyRuleName(Arc::new(Atom::from(name))))
},
"-moz-document" if cfg!(feature = "gecko") => {
let cond = DocumentCondition::parse(self.context, input)?;
AtRulePrelude::Document(cond)
@ -690,6 +701,11 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b, 'i> {
source_location: start.source_location(),
})))
},
AtRulePrelude::Property(name) => self.nest_for_rule(CssRuleType::Property, |p| {
CssRule::Property(Arc::new(p.shared_lock.wrap(
parse_property_block(&p.context, input, name, start.source_location()),
)))
}),
AtRulePrelude::Document(condition) => {
if !cfg!(feature = "gecko") {
unreachable!()

View File

@ -68,6 +68,7 @@ where
CssRule::Viewport(_) |
CssRule::Keyframes(_) |
CssRule::Page(_) |
CssRule::Property(_) |
CssRule::LayerStatement(_) |
CssRule::FontFeatureValues(_) |
CssRule::FontPaletteValues(_) => None,

View File

@ -366,6 +366,7 @@ impl SanitizationKind {
CssRule::Keyframes(..) |
CssRule::Page(..) |
CssRule::Property(..) |
CssRule::FontFeatureValues(..) |
CssRule::FontPaletteValues(..) |
CssRule::Viewport(..) |

View File

@ -2841,6 +2841,7 @@ impl CascadeData {
self.extra_data
.add_page(guard, rule, containing_rule_state.layer_id)?;
},
// TODO: Handle CssRule::Property
CssRule::Viewport(..) => {},
_ => {
handled = false;
@ -3082,6 +3083,7 @@ impl CascadeData {
CssRule::Supports(..) |
CssRule::Keyframes(..) |
CssRule::Page(..) |
CssRule::Property(..) |
CssRule::Viewport(..) |
CssRule::Document(..) |
CssRule::LayerBlock(..) |

View File

@ -143,6 +143,8 @@ pub enum StyleParseErrorKind<'i> {
DisallowedImportRule,
/// Unexpected @charset rule encountered.
UnexpectedCharsetRule,
/// The @property `<custom-property-name>` must start with `--`
UnexpectedIdent(CowRcStr<'i>),
/// A placeholder for many sources of errors that require more specific variants.
UnspecifiedError,
/// An unexpected token was found within a namespace rule.

View File

@ -18,7 +18,7 @@ use style::gecko_bindings::structs::URLExtraData as RawUrlExtraData;
use style::gecko_bindings::structs::{nsIURI, Loader, StyleSheet as DomStyleSheet};
use style::selector_parser::SelectorImpl;
use style::stylesheets::UrlExtraData;
use style_traits::{StyleParseErrorKind, ValueParseErrorKind};
use style_traits::{PropertySyntaxParseError, StyleParseErrorKind, ValueParseErrorKind};
pub type ErrorKind<'i> = ParseErrorKind<'i, StyleParseErrorKind<'i>>;
@ -190,6 +190,7 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
fn error_data(self) -> (CowRcStr<'a>, ErrorKind<'a>) {
match self {
ContextualParseError::UnsupportedPropertyDeclaration(s, err, _) |
ContextualParseError::UnsupportedPropertyDescriptor(s, err) |
ContextualParseError::UnsupportedFontFaceDescriptor(s, err) |
ContextualParseError::UnsupportedFontFeatureValuesDescriptor(s, err) |
ContextualParseError::UnsupportedFontPaletteValuesDescriptor(s, err) |
@ -393,6 +394,7 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
ContextualParseError::InvalidCounterStyleWithoutAdditiveSymbols |
ContextualParseError::InvalidCounterStyleExtendsWithSymbols |
ContextualParseError::InvalidCounterStyleExtendsWithAdditiveSymbols |
ContextualParseError::UnsupportedPropertyDescriptor(..) |
ContextualParseError::UnsupportedFontFeatureValuesDescriptor(..) |
ContextualParseError::UnsupportedFontPaletteValuesDescriptor(..) |
ContextualParseError::InvalidFontFeatureValuesRule(..) => {
@ -403,6 +405,32 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
ParseErrorKind::Custom(StyleParseErrorKind::ValueError(
ValueParseErrorKind::InvalidColor(..),
)) => (cstr!("PEColorNotColor"), Action::Nothing),
ParseErrorKind::Custom(StyleParseErrorKind::PropertySyntaxField(ref kind)) => {
let name = match kind {
PropertySyntaxParseError::EmptyInput => {
cstr!("PEPRSyntaxFieldEmptyInput")
},
PropertySyntaxParseError::ExpectedPipeBetweenComponents => {
cstr!("PEPRSyntaxFieldExpectedPipe")
},
PropertySyntaxParseError::InvalidNameStart => {
cstr!("PEPRSyntaxFieldInvalidNameStart")
},
PropertySyntaxParseError::InvalidName => {
cstr!("PEPRSyntaxFieldInvalidName")
},
PropertySyntaxParseError::UnclosedDataTypeName => {
cstr!("PEPRSyntaxFieldUnclosedDataTypeName")
},
PropertySyntaxParseError::UnexpectedEOF => {
cstr!("PEPRSyntaxFieldUnexpectedEOF")
},
PropertySyntaxParseError::UnknownDataTypeName => {
cstr!("PEPRSyntaxFieldUnknownDataTypeName")
},
};
(name, Action::Nothing)
},
_ => {
// Not the best error message, since we weren't parsing
// a declaration, just a value. But we don't produce

View File

@ -34,7 +34,7 @@ use style::gecko::arc_types::{
LockedDocumentRule, LockedFontFaceRule, LockedFontFeatureValuesRule,
LockedFontPaletteValuesRule, LockedImportRule, LockedKeyframe, LockedKeyframesRule,
LockedLayerBlockRule, LockedLayerStatementRule, LockedMediaList, LockedMediaRule,
LockedNamespaceRule, LockedPageRule, LockedStyleRule, LockedSupportsRule,
LockedNamespaceRule, LockedPageRule, LockedPropertyRule, LockedStyleRule, LockedSupportsRule,
};
use style::gecko::data::{
AuthorStyles, GeckoStyleSheet, PerDocumentStyleData, PerDocumentStyleDataImpl,
@ -105,6 +105,7 @@ use style::properties::{ComputedValues, CountedUnknownProperty, Importance, NonC
use style::properties::{LonghandId, LonghandIdSet, PropertyDeclarationBlock, PropertyId};
use style::properties::{PropertyDeclarationId, ShorthandId};
use style::properties::{SourcePropertyDeclaration, StyleBuilder};
use style::properties_and_values::rule::Inherits as PropertyInherits;
use style::rule_cache::RuleCacheConditions;
use style::rule_tree::{CascadeLevel, StrongRuleNode};
use style::selector_parser::PseudoElementCascadeType;
@ -122,8 +123,8 @@ use style::stylesheets::{
AllowImportRules, ContainerRule, CounterStyleRule, CssRule, CssRuleType, CssRules,
CssRulesHelpers, DocumentRule, FontFaceRule, FontFeatureValuesRule, FontPaletteValuesRule,
ImportRule, KeyframesRule, LayerBlockRule, LayerStatementRule, MediaRule, NamespaceRule,
Origin, OriginSet, PageRule, SanitizationData, SanitizationKind, StyleRule, StylesheetContents,
StylesheetLoader as StyleStylesheetLoader, SupportsRule, UrlExtraData,
Origin, OriginSet, PageRule, PropertyRule, SanitizationData, SanitizationKind, StyleRule,
StylesheetContents, StylesheetLoader as StyleStylesheetLoader, SupportsRule, UrlExtraData,
};
use style::stylist::{add_size_of_ua_cache, AuthorStylesEnabled, RuleInclusion, Stylist};
use style::thread_state;
@ -2266,6 +2267,13 @@ impl_basic_rule_funcs! { (Page, PageRule),
changed: Servo_StyleSet_PageRuleChanged,
}
impl_basic_rule_funcs! { (Property, PropertyRule),
getter: Servo_CssRules_GetPropertyRuleAt,
debug: Servo_PropertyRule_Debug,
to_css: Servo_PropertyRule_GetCssText,
changed: Servo_StyleSet_PropertyRuleChanged,
}
impl_group_rule_funcs! { (Supports, SupportsRule),
get_rules: Servo_SupportsRule_GetRules,
getter: Servo_CssRules_GetSupportsRuleAt,
@ -2829,6 +2837,42 @@ pub extern "C" fn Servo_PageRule_SetSelectorText(
})
}
#[no_mangle]
pub extern "C" fn Servo_PropertyRule_GetName(rule: &LockedPropertyRule, result: &mut nsACString) {
read_locked_arc(rule, |rule: &PropertyRule| {
rule.name.to_css(&mut CssWriter::new(result)).unwrap()
})
}
#[no_mangle]
pub extern "C" fn Servo_PropertyRule_GetSyntax(rule: &LockedPropertyRule, result: &mut nsACString) {
read_locked_arc(rule, |rule: &PropertyRule| {
if let Some(ref syntax) = rule.syntax {
CssWriter::new(result).write_str(syntax.as_str()).unwrap()
}
})
}
#[no_mangle]
pub extern "C" fn Servo_PropertyRule_GetInherits(rule: &LockedPropertyRule) -> bool {
read_locked_arc(rule, |rule: &PropertyRule| {
matches!(rule.inherits, Some(PropertyInherits::True))
})
}
#[no_mangle]
pub extern "C" fn Servo_PropertyRule_GetInitialValue(
rule: &LockedPropertyRule,
result: &mut nsACString,
) -> bool {
read_locked_arc(rule, |rule: &PropertyRule| {
rule.initial_value
.to_css(&mut CssWriter::new(result))
.unwrap();
rule.initial_value.is_some()
})
}
#[no_mangle]
pub extern "C" fn Servo_SupportsRule_GetConditionText(
rule: &LockedSupportsRule,

View File

@ -1 +1,2 @@
implementation-status: backlog
prefs: [layout.css.properties-and-values.enabled:true]

View File

@ -1,187 +1,4 @@
[at-property-cssom.html]
[Rule for --no-descriptors returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --valid returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --initial-value-only returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --no-syntax returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --valid returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --initial-value-only returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --valid-whitespace returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --valid-universal returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --valid-universal returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --valid-universal returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --valid-whitespace returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --no-syntax has expected cssText]
expected: FAIL
[Rule for --syntax-only returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --no-syntax returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --initial-value-only returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --no-initial-value has expected cssText]
expected: FAIL
[Rule for --no-syntax returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --no-initial-value returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --valid-whitespace has expected cssText]
expected: FAIL
[Rule for --syntax-only returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --no-descriptors returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --syntax-only returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --no-inherits returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --valid-whitespace returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --valid-reverse has expected cssText]
expected: FAIL
[Rule for --valid-reverse returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --no-inherits returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --vALId returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --no-inherits has expected cssText]
expected: FAIL
[Rule for --valid-reverse returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --vALId has expected cssText]
expected: FAIL
[Rule for --no-descriptors has expected cssText]
expected: FAIL
[Rule for --syntax-only has expected cssText]
expected: FAIL
[Rule for --valid-universal returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --initial-value-only has expected cssText]
expected: FAIL
[Rule for --syntax-only returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --no-syntax returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --inherits-only returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --no-initial-value returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --initial-value-only returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --inherits-only has expected cssText]
expected: FAIL
[Rule for --vALId returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --valid returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --no-initial-value returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --valid returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --valid-universal has expected cssText]
expected: FAIL
[Rule for --valid has expected cssText]
expected: FAIL
[Rule for --inherits-only returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --valid-reverse returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --no-descriptors returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --no-inherits returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --inherits-only returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --inherits-only returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --valid-whitespace returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --vALId returns expected value for CSSPropertyRule.name]
expected: FAIL
[Rule for --no-descriptors returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --valid-reverse returns expected value for CSSPropertyRule.initialValue]
expected: FAIL
[Rule for --vALId returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[Rule for --no-inherits returns expected value for CSSPropertyRule.syntax]
expected: FAIL
[Rule for --no-initial-value returns expected value for CSSPropertyRule.inherits]
expected: FAIL
[CSSRule.type returns 0]
expected: FAIL
[Rule for --tab\ttab has expected cssText]
expected: FAIL

View File

@ -5,18 +5,12 @@
[Rule applied [<color>, rgb(1, 2, 3), false\]]
expected: FAIL
[Attribute 'inherits' returns expected value for ["false"\]]
expected: FAIL
[Rule applied [<number>, 2.5, false\]]
expected: FAIL
[Rule applied [<angle>, 42deg, false\]]
expected: FAIL
[Attribute 'inherits' returns expected value for [0\]]
expected: FAIL
[Rule applied [<angle>, 1turn, false\]]
expected: FAIL
@ -26,39 +20,21 @@
[Rule applied [<length-percentage>, 10%, false\]]
expected: FAIL
[Attribute 'syntax' returns expected value for [rgb(255, 0, 0)\]]
expected: FAIL
[Rule applied [<integer>, 5, false\]]
expected: FAIL
[Attribute 'initial-value' returns expected value for [red\]]
expected: FAIL
[Attribute 'syntax' returns expected value for ["<color># | <image> | none"\]]
expected: FAIL
[Rule applied [*, if(){}, false\]]
expected: FAIL
[Rule applied [<color>, green, false\]]
expected: FAIL
[Attribute 'initial-value' returns expected value for [rgb(1, 2, 3)\]]
expected: FAIL
[Rule applied [<resolution>, 96dpi, false\]]
expected: FAIL
[Attribute 'inherits' returns expected value for [none\]]
expected: FAIL
[Non-inherited properties do not inherit]
expected: FAIL
[Attribute 'inherits' returns expected value for ["true"\]]
expected: FAIL
[Rule applied [<color>, tomato, false\]]
expected: FAIL
@ -68,57 +44,18 @@
[Rule applied [<length>, 10px, false\]]
expected: FAIL
[Attribute 'initial-value' returns expected value for [var(--x)\]]
expected: FAIL
[Rule applied [<transform-list>, rotateX(0deg) translateX(10px), false\]]
expected: FAIL
[Rule applied [<length-percentage>, calc(10% + 10px), false\]]
expected: FAIL
[Attribute 'syntax' returns expected value for ["notasyntax"\]]
expected: FAIL
[Rule applied [<time>, 1000ms, false\]]
expected: FAIL
[Attribute 'syntax' returns expected value for ["foo | bar | baz"\]]
expected: FAIL
[Attribute 'initial-value' returns expected value for [if(){}\]]
expected: FAIL
[Attribute 'syntax' returns expected value for [foo | bar\]]
expected: FAIL
[Attribute 'inherits' returns expected value for [1\]]
expected: FAIL
[Rule applied [<image>, url("http://a/"), false\]]
expected: FAIL
[Attribute 'initial-value' returns expected value for [10px\]]
expected: FAIL
[Attribute 'inherits' returns expected value for [true\]]
expected: FAIL
[Attribute 'syntax' returns expected value for ["*"\]]
expected: FAIL
[Attribute 'syntax' returns expected value for ["<color>"\]]
expected: FAIL
[Attribute 'initial-value' returns expected value for [foo\]]
expected: FAIL
[Attribute 'syntax' returns expected value for [red\]]
expected: FAIL
[Attribute 'syntax' returns expected value for [<color>\]]
expected: FAIL
[Rule applied [<percentage>, 10%, false\]]
expected: FAIL
@ -131,20 +68,11 @@
[Rule applied [<color>, tomato, true\]]
expected: FAIL
[Attribute 'syntax' returns expected value for ["<color> | none"\]]
expected: FAIL
[Rule applied [<resolution>, 50dppx, false\]]
expected: FAIL
[Initial values substituted as computed value]
expected: FAIL
[Attribute 'inherits' returns expected value for [calc(0)\]]
expected: FAIL
[Attribute 'inherits' returns expected value for [false\]]
expected: FAIL
[Rule applied [<transform-function>, rotateX(0deg), false\]]
expected: FAIL

View File

@ -1,39 +1,9 @@
[idlharness.html]
expected:
if debug and (os == "linux"): ["OK", "TIMEOUT"]
[CSSPropertyRule interface: attribute inherits]
expected: FAIL
[CSSPropertyRule interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[CSSPropertyRule interface object name]
expected: FAIL
[CSSPropertyRule interface: attribute initialValue]
expected: FAIL
[CSSPropertyRule interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[CSSPropertyRule interface object length]
expected: FAIL
[CSSPropertyRule interface: attribute syntax]
expected: FAIL
[CSSPropertyRule interface: attribute name]
expected: FAIL
[CSS namespace: operation registerProperty(PropertyDefinition)]
expected: FAIL
[CSSPropertyRule interface: existence and properties of interface object]
expected: FAIL
[CSSPropertyRule interface: existence and properties of interface prototype object]
expected: FAIL
[idl_test setup]
expected:
if debug and (os == "linux"): ["PASS", "TIMEOUT"]

View File

@ -43,15 +43,29 @@ function test_descriptor(descriptor, specified_value, expected_value) {
test_descriptor('syntax', '"<color>"', '<color>');
test_descriptor('syntax', '"<color> | none"', '<color> | none');
test_descriptor('syntax', '"<color># | <image> | none"', '<color># | <image> | none');
test_descriptor('syntax', '"foo | <length>#"', 'foo | <length>#');
test_descriptor('syntax', '"foo | bar | baz"', 'foo | bar | baz');
test_descriptor('syntax', '"*"', '*');
test_descriptor('syntax', '"notasyntax"', 'notasyntax');
// syntax: universal
for (const syntax of ["*", " * ", "* ", "\t*\t"]) {
test_descriptor('syntax', `"${syntax}"`, syntax);
}
test_descriptor('syntax', 'red', '');
test_descriptor('syntax', 'rgb(255, 0, 0)', '');
test_descriptor('syntax', '<color>', '');
test_descriptor('syntax', 'foo | bar', '');
// syntax: pipe between components
test_descriptor('syntax', 'foo bar', '');
test_descriptor('syntax', 'Foo <length>', '');
test_descriptor('syntax', 'foo, bar', '');
test_descriptor('syntax', '<length> <percentage>', '');
// syntax: leaading bar
test_descriptor('syntax', '|<length>', '');
// initial-value
test_descriptor('initial-value', '10px');
test_descriptor('initial-value', 'rgb(1, 2, 3)');