Bug 1745233 - Update CSSOM for layer rules to the spec. r=firefox-style-system-reviewers,layout-reviewers,boris

Pretty mechanical.

Tests are in https://wpt.live/css/css-cascade/layer-rules-cssom.html
which (with a fix for @import tests which I'll submit separately) we
pass.

Sync for that is bug 1743936.

Differential Revision: https://phabricator.services.mozilla.com/D133387
This commit is contained in:
Emilio Cobos Álvarez 2021-12-14 15:39:38 +00:00
parent d84300e6e7
commit f13595acc8
33 changed files with 473 additions and 330 deletions

View File

@ -283,7 +283,9 @@ var interfaceNamesInGlobalScope = [
// IMPORTANT: Do not change this list without review from a DOM peer!
{ name: "CSSKeyframesRule", insecureContext: true },
// IMPORTANT: Do not change this list without review from a DOM peer!
{ name: "CSSLayerRule", insecureContext: true, nightly: true },
{ name: "CSSLayerBlockRule", insecureContext: true, nightly: true },
// IMPORTANT: Do not change this list without review from a DOM peer!
{ name: "CSSLayerStatementRule", insecureContext: true, nightly: true },
// IMPORTANT: Do not change this list without review from a DOM peer!
{ name: "CSSMediaRule", insecureContext: true },
// IMPORTANT: Do not change this list without review from a DOM peer!

View File

@ -19,3 +19,9 @@ interface CSSImportRule : CSSRule {
// be. See <https://bugzilla.mozilla.org/show_bug.cgi?id=1326509>.
[SameObject, BinaryName="styleSheetForBindings"] readonly attribute CSSStyleSheet? styleSheet;
};
// https://drafts.csswg.org/css-cascade-5/#extensions-to-cssimportrule-interface
partial interface CSSImportRule {
[Pref="layout.css.cascade-layers.enabled"]
readonly attribute UTF8String? layerName;
};

View File

@ -3,10 +3,10 @@
* 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/.
*
* This is just scaffolding waiting for
* https://github.com/w3c/csswg-drafts/issues/6576 to get resolved.
* The origin of this IDL file is
* https://drafts.csswg.org/css-cascade-5/#the-csslayerblockrule-interface
*/
[Exposed=Window, Pref="layout.css.cascade-layers.enabled"]
interface CSSLayerRule : CSSGroupingRule {
interface CSSLayerBlockRule : CSSGroupingRule {
readonly attribute UTF8String name;
};

View File

@ -0,0 +1,14 @@
/* -*- 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.csswg.org/css-cascade-5/#the-csslayerstatementrule-interface
*/
[Exposed=Window, Pref="layout.css.cascade-layers.enabled"]
interface CSSLayerStatementRule : CSSRule {
// readonly attribute FrozenArray<CSSOMString> nameList;
[Frozen, Cached, Pure]
readonly attribute sequence<UTF8String> nameList;
};

View File

@ -478,7 +478,8 @@ WEBIDL_FILES = [
"CSSImportRule.webidl",
"CSSKeyframeRule.webidl",
"CSSKeyframesRule.webidl",
"CSSLayerRule.webidl",
"CSSLayerBlockRule.webidl",
"CSSLayerStatementRule.webidl",
"CSSMediaRule.webidl",
"CSSMozDocumentRule.webidl",
"CSSNamespaceRule.webidl",

View File

@ -85,12 +85,13 @@ void ServoStyleRuleMap::RuleRemoved(StyleSheet& aStyleSheet,
case StyleCssRuleType::Import:
case StyleCssRuleType::Media:
case StyleCssRuleType::Supports:
case StyleCssRuleType::Layer:
case StyleCssRuleType::LayerBlock:
case StyleCssRuleType::Document: {
// See the comment in StyleSheetRemoved.
mTable.Clear();
break;
}
case StyleCssRuleType::LayerStatement:
case StyleCssRuleType::FontFace:
case StyleCssRuleType::Page:
case StyleCssRuleType::Keyframes:
@ -118,7 +119,7 @@ void ServoStyleRuleMap::FillTableFromRule(css::Rule& aRule) {
mTable.InsertOrUpdate(rule.Raw(), &rule);
break;
}
case StyleCssRuleType::Layer:
case StyleCssRuleType::LayerBlock:
case StyleCssRuleType::Media:
case StyleCssRuleType::Supports:
case StyleCssRuleType::Document: {
@ -134,6 +135,7 @@ void ServoStyleRuleMap::FillTableFromRule(css::Rule& aRule) {
FillTableFromStyleSheet(*rule.GetStyleSheet());
break;
}
case StyleCssRuleType::LayerStatement:
case StyleCssRuleType::FontFace:
case StyleCssRuleType::Page:
case StyleCssRuleType::Keyframes:

View File

@ -116,6 +116,10 @@ void CSSImportRule::GetHref(nsAString& aHref) const {
Servo_ImportRule_GetHref(mRawRule, &aHref);
}
void CSSImportRule::GetLayerName(nsACString& aName) const {
Servo_ImportRule_GetLayerName(mRawRule, &aName);
}
/* virtual */
void CSSImportRule::GetCssText(nsACString& aCssText) const {
Servo_ImportRule_GetCssText(mRawRule, &aCssText);

View File

@ -38,6 +38,7 @@ class CSSImportRule final : public css::Rule {
dom::MediaList* GetMedia();
StyleSheet* GetStyleSheet() const { return mChildSheet; }
StyleSheet* GetStyleSheetForBindings();
void GetLayerName(nsACString&) const;
// Clear the mSheet pointer on this rule and descendants.
void DropSheetReference() final;

View File

@ -0,0 +1,66 @@
/* -*- 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/CSSLayerBlockRule.h"
#include "mozilla/dom/CSSLayerBlockRuleBinding.h"
#include "mozilla/ServoBindings.h"
namespace mozilla::dom {
CSSLayerBlockRule::CSSLayerBlockRule(RefPtr<RawServoLayerBlockRule> aRawRule,
StyleSheet* aSheet, css::Rule* aParentRule,
uint32_t aLine, uint32_t aColumn)
: css::GroupRule(Servo_LayerBlockRule_GetRules(aRawRule).Consume(), aSheet,
aParentRule, aLine, aColumn),
mRawRule(std::move(aRawRule)) {}
NS_IMPL_ADDREF_INHERITED(CSSLayerBlockRule, GroupRule)
NS_IMPL_RELEASE_INHERITED(CSSLayerBlockRule, GroupRule)
// QueryInterface implementation for SupportsRule
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSLayerBlockRule)
NS_INTERFACE_MAP_END_INHERITING(GroupRule)
#ifdef DEBUG
void CSSLayerBlockRule::List(FILE* out, int32_t aIndent) const {
nsAutoCString str;
for (int32_t i = 0; i < aIndent; i++) {
str.AppendLiteral(" ");
}
Servo_LayerBlockRule_Debug(mRawRule, &str);
fprintf_stderr(out, "%s\n", str.get());
}
#endif
StyleCssRuleType CSSLayerBlockRule::Type() const {
return StyleCssRuleType::LayerBlock;
}
void CSSLayerBlockRule::SetRawAfterClone(RefPtr<RawServoLayerBlockRule> aRaw) {
mRawRule = std::move(aRaw);
css::GroupRule::SetRawAfterClone(
Servo_LayerBlockRule_GetRules(mRawRule).Consume());
}
void CSSLayerBlockRule::GetCssText(nsACString& aCssText) const {
Servo_LayerBlockRule_GetCssText(mRawRule.get(), &aCssText);
}
void CSSLayerBlockRule::GetName(nsACString& aName) const {
Servo_LayerBlockRule_GetName(mRawRule.get(), &aName);
}
size_t CSSLayerBlockRule::SizeOfIncludingThis(
MallocSizeOf aMallocSizeOf) const {
return aMallocSizeOf(this);
}
JSObject* CSSLayerBlockRule::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return CSSLayerBlockRule_Binding::Wrap(aCx, this, aGivenProto);
}
} // namespace mozilla::dom

View File

@ -4,17 +4,17 @@
* 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_CSSLayerRule_h
#define mozilla_dom_CSSLayerRule_h
#ifndef mozilla_dom_CSSLayerBlockRule_h
#define mozilla_dom_CSSLayerBlockRule_h
#include "mozilla/css/GroupRule.h"
#include "mozilla/ServoBindingTypes.h"
namespace mozilla::dom {
class CSSLayerRule : public css::GroupRule {
class CSSLayerBlockRule final : public css::GroupRule {
public:
CSSLayerRule(RefPtr<RawServoLayerRule> aRawRule, StyleSheet* aSheet,
CSSLayerBlockRule(RefPtr<RawServoLayerBlockRule> aRawRule, StyleSheet* aSheet,
css::Rule* aParentRule, uint32_t aLine, uint32_t aColumn);
NS_DECL_ISUPPORTS_INHERITED
@ -23,22 +23,25 @@ class CSSLayerRule : public css::GroupRule {
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
#endif
RawServoLayerRule* Raw() const { return mRawRule; }
void SetRawAfterClone(RefPtr<RawServoLayerRule>);
RawServoLayerBlockRule* Raw() const { return mRawRule; }
void SetRawAfterClone(RefPtr<RawServoLayerBlockRule>);
// WebIDL interface
StyleCssRuleType Type() const final;
void GetCssText(nsACString& aCssText) const final;
void GetName(nsACString&) const;
size_t SizeOfIncludingThis(MallocSizeOf) const override;
JSObject* WrapObject(JSContext*, JS::Handle<JSObject*>) override;
private:
~CSSLayerRule() = default;
~CSSLayerBlockRule() = default;
RefPtr<RawServoLayerRule> mRawRule;
RefPtr<RawServoLayerBlockRule> mRawRule;
};
} // namespace mozilla::dom
#endif // mozilla_dom_CSSLayerRule_h
#endif // mozilla_dom_CSSLayerBlockRule_h

View File

@ -1,59 +0,0 @@
/* -*- 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/CSSLayerRule.h"
#include "mozilla/dom/CSSLayerRuleBinding.h"
#include "mozilla/ServoBindings.h"
namespace mozilla::dom {
CSSLayerRule::CSSLayerRule(RefPtr<RawServoLayerRule> aRawRule,
StyleSheet* aSheet, css::Rule* aParentRule,
uint32_t aLine, uint32_t aColumn)
: css::GroupRule(Servo_LayerRule_GetRules(aRawRule).Consume(), aSheet,
aParentRule, aLine, aColumn),
mRawRule(std::move(aRawRule)) {}
NS_IMPL_ADDREF_INHERITED(CSSLayerRule, GroupRule)
NS_IMPL_RELEASE_INHERITED(CSSLayerRule, GroupRule)
// QueryInterface implementation for SupportsRule
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSLayerRule)
NS_INTERFACE_MAP_END_INHERITING(GroupRule)
#ifdef DEBUG
void CSSLayerRule::List(FILE* out, int32_t aIndent) const {
nsAutoCString str;
for (int32_t i = 0; i < aIndent; i++) {
str.AppendLiteral(" ");
}
Servo_LayerRule_Debug(mRawRule, &str);
fprintf_stderr(out, "%s\n", str.get());
}
#endif
StyleCssRuleType CSSLayerRule::Type() const { return StyleCssRuleType::Layer; }
void CSSLayerRule::SetRawAfterClone(RefPtr<RawServoLayerRule> aRaw) {
mRawRule = std::move(aRaw);
css::GroupRule::SetRawAfterClone(
Servo_LayerRule_GetRules(mRawRule).Consume());
}
void CSSLayerRule::GetCssText(nsACString& aCssText) const {
Servo_LayerRule_GetCssText(mRawRule.get(), &aCssText);
}
size_t CSSLayerRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
return aMallocSizeOf(this);
}
JSObject* CSSLayerRule::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return CSSLayerRule_Binding::Wrap(aCx, this, aGivenProto);
}
} // namespace mozilla::dom

View File

@ -0,0 +1,63 @@
/* -*- 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/CSSLayerStatementRule.h"
#include "mozilla/dom/CSSLayerStatementRuleBinding.h"
#include "mozilla/ServoBindings.h"
namespace mozilla::dom {
CSSLayerStatementRule::CSSLayerStatementRule(RefPtr<RawServoLayerStatementRule> aRawRule,
StyleSheet* aSheet, css::Rule* aParentRule,
uint32_t aLine, uint32_t aColumn)
: Rule(aSheet, aParentRule, aLine, aColumn),
mRawRule(std::move(aRawRule)) {}
NS_IMPL_ADDREF_INHERITED(CSSLayerStatementRule, Rule)
NS_IMPL_RELEASE_INHERITED(CSSLayerStatementRule, Rule)
// QueryInterface implementation for SupportsRule
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSLayerStatementRule)
NS_INTERFACE_MAP_END_INHERITING(Rule)
#ifdef DEBUG
void CSSLayerStatementRule::List(FILE* out, int32_t aIndent) const {
nsAutoCString str;
for (int32_t i = 0; i < aIndent; i++) {
str.AppendLiteral(" ");
}
Servo_LayerStatementRule_Debug(mRawRule, &str);
fprintf_stderr(out, "%s\n", str.get());
}
#endif
StyleCssRuleType CSSLayerStatementRule::Type() const { return StyleCssRuleType::LayerStatement; }
void CSSLayerStatementRule::SetRawAfterClone(RefPtr<RawServoLayerStatementRule> aRaw) {
mRawRule = std::move(aRaw);
}
void CSSLayerStatementRule::GetCssText(nsACString& aCssText) const {
Servo_LayerStatementRule_GetCssText(mRawRule.get(), &aCssText);
}
void CSSLayerStatementRule::GetNameList(nsTArray<nsCString>& aNames) const {
size_t size = Servo_LayerStatementRule_GetNameCount(mRawRule.get());
for (size_t i = 0; i < size; ++i) {
Servo_LayerStatementRule_GetNameAt(mRawRule.get(), i, aNames.AppendElement());
}
}
size_t CSSLayerStatementRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
return aMallocSizeOf(this);
}
JSObject* CSSLayerStatementRule::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return CSSLayerStatementRule_Binding::Wrap(aCx, this, aGivenProto);
}
} // namespace mozilla::dom

View File

@ -0,0 +1,49 @@
/* -*- 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_CSSLayerStatementRule_h
#define mozilla_dom_CSSLayerStatementRule_h
#include "mozilla/css/Rule.h"
#include "mozilla/ServoBindingTypes.h"
namespace mozilla::dom {
class CSSLayerStatementRule final : public css::Rule {
public:
CSSLayerStatementRule(RefPtr<RawServoLayerStatementRule> aRawRule,
StyleSheet* aSheet, css::Rule* aParentRule,
uint32_t aLine, uint32_t aColumn);
NS_DECL_ISUPPORTS_INHERITED
bool IsCCLeaf() const final { return css::Rule::IsCCLeaf(); }
#ifdef DEBUG
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
#endif
RawServoLayerStatementRule* Raw() const { return mRawRule; }
void SetRawAfterClone(RefPtr<RawServoLayerStatementRule>);
// WebIDL interface
StyleCssRuleType Type() const final;
void GetCssText(nsACString& aCssText) const final;
void GetNameList(nsTArray<nsCString>&) const;
size_t SizeOfIncludingThis(MallocSizeOf) const override;
JSObject* WrapObject(JSContext*, JS::Handle<JSObject*>) override;
private:
~CSSLayerStatementRule() = default;
RefPtr<RawServoLayerStatementRule> mRawRule;
};
} // namespace mozilla::dom
#endif // mozilla_dom_CSSLayerStatementRule_h

View File

@ -100,10 +100,11 @@ void Rule::AssertParentRuleType() {
// this->Type() here since it's virtual.
if (mParentRule) {
auto type = mParentRule->Type();
MOZ_ASSERT(
type == StyleCssRuleType::Media || type == StyleCssRuleType::Document ||
type == StyleCssRuleType::Supports ||
type == StyleCssRuleType::Keyframes || type == StyleCssRuleType::Layer);
MOZ_ASSERT(type == StyleCssRuleType::Media ||
type == StyleCssRuleType::Document ||
type == StyleCssRuleType::Supports ||
type == StyleCssRuleType::Keyframes ||
type == StyleCssRuleType::LayerBlock);
}
}
#endif

View File

@ -31,7 +31,8 @@ SERVO_ARC_TYPE(AnimationValue, RawServoAnimationValue)
SERVO_ARC_TYPE(Keyframe, RawServoKeyframe)
SERVO_ARC_TYPE(KeyframesRule, RawServoKeyframesRule)
SERVO_ARC_TYPE(ScrollTimelineRule, RawServoScrollTimelineRule)
SERVO_ARC_TYPE(LayerRule, RawServoLayerRule)
SERVO_ARC_TYPE(LayerBlockRule, RawServoLayerBlockRule)
SERVO_ARC_TYPE(LayerStatementRule, RawServoLayerStatementRule)
SERVO_ARC_TYPE(MediaList, RawServoMediaList)
SERVO_ARC_TYPE(MediaRule, RawServoMediaRule)
SERVO_ARC_TYPE(NamespaceRule, RawServoNamespaceRule)

View File

@ -61,7 +61,8 @@ GROUP_RULE_FUNCS(MozDocument)
BASIC_RULE_FUNCS(Namespace)
BASIC_RULE_FUNCS(Page)
GROUP_RULE_FUNCS(Supports)
GROUP_RULE_FUNCS(Layer)
GROUP_RULE_FUNCS(LayerBlock)
BASIC_RULE_FUNCS(LayerStatement)
BASIC_RULE_FUNCS(FontFeatureValues)
BASIC_RULE_FUNCS(FontFace)
BASIC_RULE_FUNCS(CounterStyle)

View File

@ -12,7 +12,8 @@
#include "mozilla/dom/CSSFontFaceRule.h"
#include "mozilla/dom/CSSFontFeatureValuesRule.h"
#include "mozilla/dom/CSSImportRule.h"
#include "mozilla/dom/CSSLayerRule.h"
#include "mozilla/dom/CSSLayerBlockRule.h"
#include "mozilla/dom/CSSLayerStatementRule.h"
#include "mozilla/dom/CSSKeyframesRule.h"
#include "mozilla/dom/CSSMediaRule.h"
#include "mozilla/dom/CSSMozDocumentRule.h"
@ -89,7 +90,8 @@ css::Rule* ServoCSSRuleList::GetRule(uint32_t aIndex) {
CASE_RULE(FontFeatureValues, FontFeatureValues)
CASE_RULE(FontFace, FontFace)
CASE_RULE(CounterStyle, CounterStyle)
CASE_RULE(Layer, Layer)
CASE_RULE(LayerBlock, LayerBlock)
CASE_RULE(LayerStatement, LayerStatement)
CASE_RULE(ScrollTimeline, ScrollTimeline)
#undef CASE_RULE
case StyleCssRuleType::Viewport:
@ -242,7 +244,8 @@ void ServoCSSRuleList::SetRawAfterClone(RefPtr<ServoCssRules> aNewRules) {
CASE_FOR(FontFeatureValues, FontFeatureValues)
CASE_FOR(FontFace, FontFace)
CASE_FOR(CounterStyle, CounterStyle)
CASE_FOR(Layer, Layer)
CASE_FOR(LayerBlock, LayerBlock)
CASE_FOR(LayerStatement, LayerStatement)
CASE_FOR(ScrollTimeline, ScrollTimeline)
case StyleCssRuleType::Keyframe:
MOZ_ASSERT_UNREACHABLE("keyframe rule cannot be here");

View File

@ -16,6 +16,7 @@
#include "nsChangeHint.h"
#include "nsGkAtoms.h"
#include "nsAtom.h"
#include "MainThreadUtils.h"
namespace mozilla {
namespace dom {

View File

@ -41,7 +41,8 @@ template struct StyleStrong<RawServoAnimationValue>;
template struct StyleStrong<RawServoDeclarationBlock>;
template struct StyleStrong<RawServoStyleSheetContents>;
template struct StyleStrong<RawServoKeyframe>;
template struct StyleStrong<RawServoLayerRule>;
template struct StyleStrong<RawServoLayerBlockRule>;
template struct StyleStrong<RawServoLayerStatementRule>;
template struct StyleStrong<RawServoMediaList>;
template struct StyleStrong<RawServoStyleRule>;
template struct StyleStrong<RawServoImportRule>;

View File

@ -30,7 +30,8 @@
#include "mozilla/dom/CSSFontFaceRule.h"
#include "mozilla/dom/CSSFontFeatureValuesRule.h"
#include "mozilla/dom/CSSImportRule.h"
#include "mozilla/dom/CSSLayerRule.h"
#include "mozilla/dom/CSSLayerBlockRule.h"
#include "mozilla/dom/CSSLayerStatementRule.h"
#include "mozilla/dom/CSSMediaRule.h"
#include "mozilla/dom/CSSMozDocumentRule.h"
#include "mozilla/dom/CSSKeyframesRule.h"
@ -945,7 +946,8 @@ void ServoStyleSet::RuleChangedInternal(StyleSheet& aSheet, css::Rule& aRule,
CASE_FOR(Page, Page)
CASE_FOR(Document, MozDocument)
CASE_FOR(Supports, Supports)
CASE_FOR(Layer, Layer)
CASE_FOR(LayerBlock, LayerBlock)
CASE_FOR(LayerStatement, LayerStatement)
CASE_FOR(ScrollTimeline, ScrollTimeline)
// @namespace can only be inserted / removed when there are only other
// @namespace and @import rules, and can't be mutated.

View File

@ -127,7 +127,8 @@ EXPORTS.mozilla.dom += [
"CSSImportRule.h",
"CSSKeyframeRule.h",
"CSSKeyframesRule.h",
"CSSLayerRule.h",
"CSSLayerBlockRule.h",
"CSSLayerStatementRule.h",
"CSSMediaRule.h",
"CSSMozDocumentRule.h",
"CSSNamespaceRule.h",
@ -171,7 +172,8 @@ UNIFIED_SOURCES += [
"CSSImportRule.cpp",
"CSSKeyframeRule.cpp",
"CSSKeyframesRule.cpp",
"CSSLayerRule.cpp",
"CSSLayerBlockRule.cpp",
"CSSLayerStatementRule.cpp",
"CSSMediaRule.cpp",
"CSSMozDocumentRule.cpp",
"CSSNamespaceRule.cpp",

View File

@ -12,9 +12,10 @@ use crate::gecko::url::CssUrlData;
use crate::gecko_bindings::structs::{
RawServoAnimationValue, RawServoCounterStyleRule, RawServoCssUrlData, RawServoDeclarationBlock,
RawServoFontFaceRule, RawServoFontFeatureValuesRule, RawServoImportRule, RawServoKeyframe,
RawServoKeyframesRule, RawServoLayerRule, RawServoMediaList, RawServoMediaRule,
RawServoMozDocumentRule, RawServoNamespaceRule, RawServoPageRule, RawServoScrollTimelineRule,
RawServoStyleRule, RawServoStyleSheetContents, RawServoSupportsRule, ServoCssRules,
RawServoKeyframesRule, RawServoLayerBlockRule, RawServoLayerStatementRule, RawServoMediaList,
RawServoMediaRule, RawServoMozDocumentRule, RawServoNamespaceRule, RawServoPageRule,
RawServoScrollTimelineRule, RawServoStyleRule, RawServoStyleSheetContents,
RawServoSupportsRule, ServoCssRules,
};
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
use crate::media_queries::MediaList;
@ -24,8 +25,8 @@ use crate::shared_lock::Locked;
use crate::stylesheets::keyframes_rule::Keyframe;
use crate::stylesheets::{
CounterStyleRule, CssRules, DocumentRule, FontFaceRule, FontFeatureValuesRule, ImportRule,
KeyframesRule, LayerRule, MediaRule, NamespaceRule, PageRule, ScrollTimelineRule, StyleRule,
StylesheetContents, SupportsRule,
KeyframesRule, LayerBlockRule, LayerStatementRule, MediaRule, NamespaceRule, PageRule,
ScrollTimelineRule, StyleRule, StylesheetContents, SupportsRule,
};
use servo_arc::{Arc, ArcBorrow};
use std::{mem, ptr};
@ -73,8 +74,11 @@ impl_arc_ffi!(Locked<Keyframe> => RawServoKeyframe
impl_arc_ffi!(Locked<KeyframesRule> => RawServoKeyframesRule
[Servo_KeyframesRule_AddRef, Servo_KeyframesRule_Release]);
impl_arc_ffi!(Locked<LayerRule> => RawServoLayerRule
[Servo_LayerRule_AddRef, Servo_LayerRule_Release]);
impl_arc_ffi!(Locked<LayerBlockRule> => RawServoLayerBlockRule
[Servo_LayerBlockRule_AddRef, Servo_LayerBlockRule_Release]);
impl_arc_ffi!(Locked<LayerStatementRule> => RawServoLayerStatementRule
[Servo_LayerStatementRule_AddRef, Servo_LayerStatementRule_Release]);
impl_arc_ffi!(Locked<MediaList> => RawServoMediaList
[Servo_MediaList_AddRef, Servo_MediaList_Release]);

View File

@ -1709,8 +1709,8 @@ impl<'le> TElement for GeckoElement<'le> {
use crate::properties::longhands::_x_text_zoom::SpecifiedValue as SpecifiedZoom;
use crate::properties::longhands::color::SpecifiedValue as SpecifiedColor;
use crate::properties::longhands::text_align::SpecifiedValue as SpecifiedTextAlign;
use crate::values::specified::color::Color;
use crate::stylesheets::layer_rule::LayerOrder;
use crate::values::specified::color::Color;
lazy_static! {
static ref TH_RULE: ApplicableDeclarationBlock = {
let global_style_data = &*GLOBAL_STYLE_DATA;
@ -1719,7 +1719,11 @@ impl<'le> TElement for GeckoElement<'le> {
Importance::Normal,
);
let arc = Arc::new_leaked(global_style_data.shared_lock.wrap(pdb));
ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints, LayerOrder::root())
ApplicableDeclarationBlock::from_declarations(
arc,
ServoCascadeLevel::PresHints,
LayerOrder::root(),
)
};
static ref TABLE_COLOR_RULE: ApplicableDeclarationBlock = {
let global_style_data = &*GLOBAL_STYLE_DATA;
@ -1728,7 +1732,11 @@ impl<'le> TElement for GeckoElement<'le> {
Importance::Normal,
);
let arc = Arc::new_leaked(global_style_data.shared_lock.wrap(pdb));
ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints, LayerOrder::root())
ApplicableDeclarationBlock::from_declarations(
arc,
ServoCascadeLevel::PresHints,
LayerOrder::root(),
)
};
static ref MATHML_LANG_RULE: ApplicableDeclarationBlock = {
let global_style_data = &*GLOBAL_STYLE_DATA;
@ -1737,7 +1745,11 @@ impl<'le> TElement for GeckoElement<'le> {
Importance::Normal,
);
let arc = Arc::new_leaked(global_style_data.shared_lock.wrap(pdb));
ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints, LayerOrder::root())
ApplicableDeclarationBlock::from_declarations(
arc,
ServoCascadeLevel::PresHints,
LayerOrder::root(),
)
};
static ref SVG_TEXT_DISABLE_ZOOM_RULE: ApplicableDeclarationBlock = {
let global_style_data = &*GLOBAL_STYLE_DATA;
@ -1746,7 +1758,11 @@ impl<'le> TElement for GeckoElement<'le> {
Importance::Normal,
);
let arc = Arc::new_leaked(global_style_data.shared_lock.wrap(pdb));
ApplicableDeclarationBlock::from_declarations(arc, ServoCascadeLevel::PresHints, LayerOrder::root())
ApplicableDeclarationBlock::from_declarations(
arc,
ServoCascadeLevel::PresHints,
LayerOrder::root(),
)
};
};

View File

@ -541,6 +541,7 @@ impl StylesheetInvalidationSet {
Page(..) |
Viewport(..) |
FontFeatureValues(..) |
LayerStatement(..) |
FontFace(..) |
Keyframes(..) |
ScrollTimeline(..) |
@ -556,7 +557,7 @@ impl StylesheetInvalidationSet {
self.collect_invalidations_for_rule(rule, guard, device, quirks_mode)
},
Document(..) | Import(..) | Media(..) | Supports(..) | Layer(..) => {
Document(..) | Import(..) | Media(..) | Supports(..) | LayerBlock(..) => {
if !is_generic_change &&
!EffectiveRules::is_effective(guard, device, quirks_mode, rule)
{
@ -597,7 +598,8 @@ impl StylesheetInvalidationSet {
}
}
},
Document(..) | Namespace(..) | Import(..) | Media(..) | Supports(..) | Layer(..) => {
Document(..) | Namespace(..) | Import(..) | Media(..) | Supports(..) |
LayerStatement(..) | LayerBlock(..) => {
// Do nothing, relevant nested rules are visited as part of the
// iteration.
},

View File

@ -159,71 +159,34 @@ impl ToCss for LayerName {
}
}
/// The kind of layer rule this is.
#[derive(Debug, ToShmem)]
pub enum LayerRuleKind {
/// A block `@layer <name>? { ... }`
Block {
/// The layer name, or `None` if anonymous.
name: Option<LayerName>,
/// The nested rules.
rules: Arc<Locked<CssRules>>,
},
/// A statement `@layer <name>, <name>, <name>;`
Statement {
/// The list of layers to sort.
names: Vec<LayerName>,
},
}
/// A [`@layer`][layer] rule.
///
/// [layer]: https://drafts.csswg.org/css-cascade-5/#layering
#[derive(Debug, ToShmem)]
pub struct LayerRule {
/// The kind of layer rule we are.
pub kind: LayerRuleKind,
/// The source position where this media rule was found.
/// A block `@layer <name>? { ... }`
/// https://drafts.csswg.org/css-cascade-5/#layer-block
pub struct LayerBlockRule {
/// The layer name, or `None` if anonymous.
pub name: Option<LayerName>,
/// The nested rules.
pub rules: Arc<Locked<CssRules>>,
/// The source position where this rule was found.
pub source_location: SourceLocation,
}
impl ToCssWithGuard for LayerRule {
impl ToCssWithGuard for LayerBlockRule {
fn to_css(
&self,
guard: &SharedRwLockReadGuard,
dest: &mut crate::str::CssStringWriter,
) -> fmt::Result {
dest.write_str("@layer")?;
match self.kind {
LayerRuleKind::Block {
ref name,
ref rules,
} => {
if let Some(ref name) = *name {
dest.write_char(' ')?;
name.to_css(&mut CssWriter::new(dest))?;
}
rules.read_with(guard).to_css_block(guard, dest)
},
LayerRuleKind::Statement { ref names } => {
let mut writer = CssWriter::new(dest);
let mut first = true;
for name in &**names {
if first {
writer.write_char(' ')?;
} else {
writer.write_str(", ")?;
}
first = false;
name.to_css(&mut writer)?;
}
dest.write_char(';')
},
if let Some(ref name) = self.name {
dest.write_char(' ')?;
name.to_css(&mut CssWriter::new(dest))?;
}
self.rules.read_with(guard).to_css_block(guard, dest)
}
}
impl DeepCloneWithLock for LayerRule {
impl DeepCloneWithLock for LayerBlockRule {
fn deep_clone_with_lock(
&self,
lock: &SharedRwLock,
@ -231,25 +194,57 @@ impl DeepCloneWithLock for LayerRule {
params: &DeepCloneParams,
) -> Self {
Self {
kind: match self.kind {
LayerRuleKind::Block {
ref name,
ref rules,
} => LayerRuleKind::Block {
name: name.clone(),
rules: Arc::new(
lock.wrap(
rules
.read_with(guard)
.deep_clone_with_lock(lock, guard, params),
),
),
},
LayerRuleKind::Statement { ref names } => LayerRuleKind::Statement {
names: names.clone(),
},
},
name: self.name.clone(),
rules: Arc::new(
lock.wrap(
self.rules
.read_with(guard)
.deep_clone_with_lock(lock, guard, params),
),
),
source_location: self.source_location.clone(),
}
}
}
/// A statement `@layer <name>, <name>, <name>;`
///
/// https://drafts.csswg.org/css-cascade-5/#layer-empty
#[derive(Clone, Debug, ToShmem)]
pub struct LayerStatementRule {
/// The list of layers to sort.
pub names: Vec<LayerName>,
/// The source position where this rule was found.
pub source_location: SourceLocation,
}
impl ToCssWithGuard for LayerStatementRule {
fn to_css(
&self,
_: &SharedRwLockReadGuard,
dest: &mut crate::str::CssStringWriter,
) -> fmt::Result {
let mut writer = CssWriter::new(dest);
writer.write_str("@layer ")?;
let mut first = true;
for name in &*self.names {
if !first {
writer.write_str(", ")?;
}
first = false;
name.to_css(&mut writer)?;
}
writer.write_char(';')
}
}
impl DeepCloneWithLock for LayerStatementRule {
fn deep_clone_with_lock(
&self,
_: &SharedRwLock,
_: &SharedRwLockReadGuard,
_: &DeepCloneParams,
) -> Self {
self.clone()
}
}

View File

@ -51,7 +51,7 @@ pub use self::font_face_rule::FontFaceRule;
pub use self::font_feature_values_rule::FontFeatureValuesRule;
pub use self::import_rule::ImportRule;
pub use self::keyframes_rule::KeyframesRule;
pub use self::layer_rule::LayerRule;
pub use self::layer_rule::{LayerBlockRule, LayerStatementRule};
pub use self::loader::StylesheetLoader;
pub use self::media_rule::MediaRule;
pub use self::namespace_rule::NamespaceRule;
@ -261,7 +261,8 @@ pub enum CssRule {
Supports(Arc<Locked<SupportsRule>>),
Page(Arc<Locked<PageRule>>),
Document(Arc<Locked<DocumentRule>>),
Layer(Arc<Locked<LayerRule>>),
LayerBlock(Arc<Locked<LayerBlockRule>>),
LayerStatement(Arc<Locked<LayerStatementRule>>),
ScrollTimeline(Arc<Locked<ScrollTimelineRule>>),
}
@ -304,9 +305,8 @@ impl CssRule {
lock.unconditional_shallow_size_of(ops) + lock.read_with(guard).size_of(guard, ops)
},
// TODO(emilio): Add memory reporting for @layer rules.
CssRule::Layer(_) => 0,
CssRule::ScrollTimeline(_) => 0,
// TODO(emilio): Add memory reporting for these rules.
CssRule::LayerBlock(_) | CssRule::LayerStatement(_) | CssRule::ScrollTimeline(_) => 0,
}
}
}
@ -341,8 +341,9 @@ pub enum CssRuleType {
Viewport = 15,
// After viewport, all rules should return 0 from the API, but we still need
// a constant somewhere.
Layer = 16,
ScrollTimeline = 17,
LayerBlock = 16,
LayerStatement = 17,
ScrollTimeline = 18,
}
#[allow(missing_docs)]
@ -369,7 +370,8 @@ impl CssRule {
CssRule::Supports(_) => CssRuleType::Supports,
CssRule::Page(_) => CssRuleType::Page,
CssRule::Document(_) => CssRuleType::Document,
CssRule::Layer(_) => CssRuleType::Layer,
CssRule::LayerBlock(_) => CssRuleType::LayerBlock,
CssRule::LayerStatement(_) => CssRuleType::LayerStatement,
CssRule::ScrollTimeline(_) => CssRuleType::ScrollTimeline,
}
}
@ -504,9 +506,15 @@ impl DeepCloneWithLock for CssRule {
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
))
},
CssRule::Layer(ref arc) => {
CssRule::LayerStatement(ref arc) => {
let rule = arc.read_with(guard);
CssRule::Layer(Arc::new(
CssRule::LayerStatement(Arc::new(
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
))
},
CssRule::LayerBlock(ref arc) => {
let rule = arc.read_with(guard);
CssRule::LayerBlock(Arc::new(
lock.wrap(rule.deep_clone_with_lock(lock, guard, params)),
))
},
@ -534,7 +542,8 @@ impl ToCssWithGuard for CssRule {
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::Document(ref lock) => lock.read_with(guard).to_css(guard, dest),
CssRule::Layer(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::ScrollTimeline(ref lock) => lock.read_with(guard).to_css(guard, dest),
}
}

View File

@ -17,14 +17,14 @@ use crate::stylesheets::document_rule::DocumentCondition;
use crate::stylesheets::font_feature_values_rule::parse_family_name_list;
use crate::stylesheets::import_rule::ImportLayer;
use crate::stylesheets::keyframes_rule::parse_keyframe_list;
use crate::stylesheets::layer_rule::{LayerName, LayerRuleKind};
use crate::stylesheets::layer_rule::{LayerBlockRule, LayerName, LayerStatementRule};
use crate::stylesheets::scroll_timeline_rule::ScrollTimelineDescriptors;
use crate::stylesheets::stylesheet::Namespaces;
use crate::stylesheets::supports_rule::SupportsCondition;
use crate::stylesheets::{
viewport_rule, AllowImportRules, CorsMode, CssRule, CssRuleType, CssRules, DocumentRule,
FontFeatureValuesRule, KeyframesRule, LayerRule, MediaRule, NamespaceRule, PageRule,
RulesMutateError, ScrollTimelineRule, StyleRule, StylesheetLoader, SupportsRule, ViewportRule,
FontFeatureValuesRule, KeyframesRule, MediaRule, NamespaceRule, PageRule, RulesMutateError,
ScrollTimelineRule, StyleRule, StylesheetLoader, SupportsRule, ViewportRule,
};
use crate::values::computed::font::FamilyName;
use crate::values::{CssUrl, CustomIdent, KeyframesName, TimelineName};
@ -607,13 +607,13 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
0 | 1 => names.into_iter().next(),
_ => return Err(input.new_error(BasicParseErrorKind::AtRuleBodyInvalid)),
};
Ok(CssRule::Layer(Arc::new(self.shared_lock.wrap(LayerRule {
kind: LayerRuleKind::Block {
Ok(CssRule::LayerBlock(Arc::new(self.shared_lock.wrap(
LayerBlockRule {
name,
rules: self.parse_nested_rules(input, CssRuleType::Layer),
rules: self.parse_nested_rules(input, CssRuleType::LayerBlock),
source_location: start.source_location(),
},
source_location: start.source_location(),
}))))
))))
},
AtRulePrelude::Import(..) | AtRulePrelude::Namespace(..) => {
// These rules don't have blocks.
@ -648,8 +648,8 @@ impl<'a, 'b, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'b> {
if names.is_empty() {
return Err(());
}
CssRule::Layer(Arc::new(self.shared_lock.wrap(LayerRule {
kind: LayerRuleKind::Statement { names },
CssRule::LayerStatement(Arc::new(self.shared_lock.wrap(LayerStatementRule {
names,
source_location: start.source_location(),
})))
},

View File

@ -70,6 +70,7 @@ where
CssRule::Keyframes(_) |
CssRule::ScrollTimeline(_) |
CssRule::Page(_) |
CssRule::LayerStatement(_) |
CssRule::FontFeatureValues(_) => None,
CssRule::Import(ref import_rule) => {
let import_rule = import_rule.read_with(guard);
@ -103,14 +104,9 @@ where
}
Some(supports_rule.rules.read_with(guard).0.iter())
},
CssRule::Layer(ref lock) => {
use crate::stylesheets::layer_rule::LayerRuleKind;
CssRule::LayerBlock(ref lock) => {
let layer_rule = lock.read_with(guard);
match layer_rule.kind {
LayerRuleKind::Block { ref rules, .. } => Some(rules.read_with(guard).0.iter()),
LayerRuleKind::Statement { .. } => None,
}
Some(layer_rule.rules.read_with(guard).0.iter())
},
}
}

View File

@ -362,7 +362,8 @@ impl SanitizationKind {
CssRule::Import(..) |
// TODO(emilio): Perhaps Layer should not be always sanitized? But
// we sanitize @media and co, so this seems safer for now.
CssRule::Layer(..) => false,
CssRule::LayerStatement(..) |
CssRule::LayerBlock(..) => false,
CssRule::FontFace(..) | CssRule::Namespace(..) | CssRule::Style(..) => true,

View File

@ -2538,35 +2538,25 @@ impl CascadeData {
self.effective_media_query_results.saw_effective(media_rule);
}
},
CssRule::Layer(ref lock) => {
use crate::stylesheets::layer_rule::LayerRuleKind;
CssRule::LayerBlock(ref lock) => {
let layer_rule = lock.read_with(guard);
match layer_rule.kind {
LayerRuleKind::Block { ref name, .. } => {
children_layer_id = maybe_register_layers(
self,
name.as_ref(),
&mut current_layer,
&mut layer_names_to_pop,
);
},
LayerRuleKind::Statement { ref names } => {
for name in &**names {
let mut pushed = 0;
// There are no children, so we can ignore the
// return value.
maybe_register_layers(
self,
Some(name),
&mut current_layer,
&mut pushed,
);
for _ in 0..pushed {
current_layer.0.pop();
}
}
},
children_layer_id = maybe_register_layers(
self,
layer_rule.name.as_ref(),
&mut current_layer,
&mut layer_names_to_pop,
);
},
CssRule::LayerStatement(ref lock) => {
let layer_rule = lock.read_with(guard);
for name in &*layer_rule.names {
let mut pushed = 0;
// There are no children, so we can ignore the
// return value.
maybe_register_layers(self, Some(name), &mut current_layer, &mut pushed);
for _ in 0..pushed {
current_layer.0.pop();
}
}
},
// We don't care about any other rule.
@ -2682,7 +2672,8 @@ impl CascadeData {
CssRule::Page(..) |
CssRule::Viewport(..) |
CssRule::Document(..) |
CssRule::Layer(..) |
CssRule::LayerBlock(..) |
CssRule::LayerStatement(..) |
CssRule::FontFeatureValues(..) => {
// Not affected by device changes.
continue;

View File

@ -87,10 +87,11 @@ use style::gecko_bindings::structs::{nsINode as RawGeckoNode, Element as RawGeck
use style::gecko_bindings::structs::{
RawServoAnimationValue, RawServoAuthorStyles, RawServoCounterStyleRule,
RawServoDeclarationBlock, RawServoFontFaceRule, RawServoFontFeatureValuesRule,
RawServoImportRule, RawServoKeyframe, RawServoKeyframesRule, RawServoLayerRule,
RawServoMediaList, RawServoMediaRule, RawServoMozDocumentRule, RawServoNamespaceRule,
RawServoPageRule, RawServoScrollTimelineRule, RawServoSharedMemoryBuilder, RawServoStyleSet,
RawServoStyleSheetContents, RawServoSupportsRule, ServoCssRules,
RawServoImportRule, RawServoKeyframe, RawServoKeyframesRule, RawServoLayerBlockRule,
RawServoLayerStatementRule, RawServoMediaList, RawServoMediaRule, RawServoMozDocumentRule,
RawServoNamespaceRule, RawServoPageRule, RawServoScrollTimelineRule,
RawServoSharedMemoryBuilder, RawServoStyleSet, RawServoStyleSheetContents,
RawServoSupportsRule, ServoCssRules,
};
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasFFI};
use style::gecko_bindings::sugar::ownership::{
@ -118,15 +119,15 @@ use style::string_cache::{Atom, WeakAtom};
use style::style_adjuster::StyleAdjuster;
use style::stylesheets::import_rule::ImportSheet;
use style::stylesheets::keyframes_rule::{Keyframe, KeyframeSelector, KeyframesStepValue};
use style::stylesheets::layer_rule::LayerOrder;
use style::stylesheets::scroll_timeline_rule::ScrollDirection;
use style::stylesheets::supports_rule::parse_condition_or_declaration;
use style::stylesheets::layer_rule::LayerOrder;
use style::stylesheets::{
AllowImportRules, CounterStyleRule, CssRule, CssRuleType, CssRules, CssRulesHelpers,
DocumentRule, FontFaceRule, FontFeatureValuesRule, ImportRule, KeyframesRule, LayerRule,
MediaRule, NamespaceRule, Origin, OriginSet, PageRule, SanitizationData, SanitizationKind,
ScrollTimelineRule, StyleRule, StylesheetContents, StylesheetLoader as StyleStylesheetLoader,
SupportsRule, UrlExtraData,
DocumentRule, FontFaceRule, FontFeatureValuesRule, ImportRule, KeyframesRule, LayerBlockRule,
LayerStatementRule, MediaRule, NamespaceRule, Origin, OriginSet, PageRule, SanitizationData,
SanitizationKind, ScrollTimelineRule, StyleRule, StylesheetContents,
StylesheetLoader as StyleStylesheetLoader, SupportsRule, UrlExtraData,
};
use style::stylist::{add_size_of_ua_cache, AuthorStylesEnabled, RuleInclusion, Stylist};
use style::thread_state;
@ -2329,20 +2330,19 @@ impl_group_rule_funcs! { (Supports, SupportsRule, RawServoSupportsRule),
changed: Servo_StyleSet_SupportsRuleChanged,
}
impl_basic_rule_funcs! { (Layer, LayerRule, RawServoLayerRule),
getter: Servo_CssRules_GetLayerRuleAt,
debug: Servo_LayerRule_Debug,
to_css: Servo_LayerRule_GetCssText,
changed: Servo_StyleSet_LayerRuleChanged,
impl_group_rule_funcs! { (LayerBlock, LayerBlockRule, RawServoLayerBlockRule),
get_rules: Servo_LayerBlockRule_GetRules,
getter: Servo_CssRules_GetLayerBlockRuleAt,
debug: Servo_LayerBlockRule_Debug,
to_css: Servo_LayerBlockRule_GetCssText,
changed: Servo_StyleSet_LayerBlockRuleChanged,
}
#[no_mangle]
pub extern "C" fn Servo_LayerRule_GetRules(rule: &RawServoLayerRule) -> Strong<ServoCssRules> {
use style::stylesheets::layer_rule::LayerRuleKind;
read_locked_arc(rule, |rule: &LayerRule| match rule.kind {
LayerRuleKind::Block { ref rules, .. } => rules.clone().into_strong(),
LayerRuleKind::Statement { .. } => Strong::null(),
})
impl_basic_rule_funcs! { (LayerStatement, LayerStatementRule, RawServoLayerStatementRule),
getter: Servo_CssRules_GetLayerStatementRuleAt,
debug: Servo_LayerStatementRule_Debug,
to_css: Servo_LayerStatementRule_GetCssText,
changed: Servo_StyleSet_LayerStatementRuleChanged,
}
impl_group_rule_funcs! { (Document, DocumentRule, RawServoMozDocumentRule),
@ -2625,6 +2625,17 @@ pub extern "C" fn Servo_ImportRule_GetHref(rule: &RawServoImportRule, result: &m
})
}
#[no_mangle]
pub extern "C" fn Servo_ImportRule_GetLayerName(
rule: &RawServoImportRule,
result: &mut nsACString,
) {
read_locked_arc(rule, |rule: &ImportRule| match rule.layer {
Some(ref layer) => layer.name.to_css(&mut CssWriter::new(result)).unwrap(),
None => result.set_is_void(true),
})
}
#[no_mangle]
pub extern "C" fn Servo_ImportRule_GetSheet(rule: &RawServoImportRule) -> *const DomStyleSheet {
read_locked_arc(rule, |rule: &ImportRule| {
@ -7259,3 +7270,35 @@ pub extern "C" fn Servo_ColorScheme_Parse(input: &nsACString, out: &mut u8) -> b
*out = scheme.raw_bits();
true
}
#[no_mangle]
pub extern "C" fn Servo_LayerBlockRule_GetName(
rule: &RawServoLayerBlockRule,
result: &mut nsACString,
) {
read_locked_arc(rule, |rule: &LayerBlockRule| {
if let Some(ref name) = rule.name {
name.to_css(&mut CssWriter::new(result)).unwrap()
}
})
}
#[no_mangle]
pub extern "C" fn Servo_LayerStatementRule_GetNameCount(
rule: &RawServoLayerStatementRule,
) -> usize {
read_locked_arc(rule, |rule: &LayerStatementRule| rule.names.len())
}
#[no_mangle]
pub extern "C" fn Servo_LayerStatementRule_GetNameAt(
rule: &RawServoLayerStatementRule,
index: usize,
result: &mut nsACString,
) {
read_locked_arc(rule, |rule: &LayerStatementRule| {
if let Some(ref name) = rule.names.get(index) {
name.to_css(&mut CssWriter::new(result)).unwrap()
}
})
}

View File

@ -1,60 +0,0 @@
[idlharness.html]
[CSSLayerBlockRule interface: existence and properties of interface object]
expected: FAIL
[CSSLayerBlockRule interface object length]
expected: FAIL
[CSSLayerBlockRule interface object name]
expected: FAIL
[CSSLayerBlockRule interface: existence and properties of interface prototype object]
expected: FAIL
[CSSLayerBlockRule interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[CSSLayerBlockRule interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[CSSLayerBlockRule interface: attribute name]
expected: FAIL
[CSSLayerBlockRule must be primary interface of block]
expected: FAIL
[Stringification of block]
expected: FAIL
[CSSLayerBlockRule interface: block must inherit property "name" with the proper type]
expected: FAIL
[CSSLayerStatementRule interface: existence and properties of interface object]
expected: FAIL
[CSSLayerStatementRule interface object length]
expected: FAIL
[CSSLayerStatementRule interface object name]
expected: FAIL
[CSSLayerStatementRule interface: existence and properties of interface prototype object]
expected: FAIL
[CSSLayerStatementRule interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[CSSLayerStatementRule interface: existence and properties of interface prototype object's @@unscopables property]
expected: FAIL
[CSSLayerStatementRule interface: attribute nameList]
expected: FAIL
[CSSLayerStatementRule must be primary interface of statement]
expected: FAIL
[Stringification of statement]
expected: FAIL
[CSSLayerStatementRule interface: statement must inherit property "nameList" with the proper type]
expected: FAIL

View File

@ -1,18 +0,0 @@
[layer-rules-cssom.html]
[Basic layer block name]
expected: FAIL
[Anonymous layer block name]
expected: FAIL
[Basic layer statement name]
expected: FAIL
[Layer statement with multiple names]
expected: FAIL
[Nested layer block names]
expected: FAIL
[Nested layer statement name lists]
expected: FAIL