mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Backed out changeset f7944c3f9e5b (bug 1711437
) for causing mochitest failures. CLOSED TREE
This commit is contained in:
parent
8dffd1552c
commit
95df13ddf8
@ -17,5 +17,5 @@ interface CSSImportRule : CSSRule {
|
||||
[SameObject, PutForwards=mediaText] readonly attribute MediaList? media;
|
||||
// Per spec, the .styleSheet is never null, but in our implementation it can
|
||||
// be. See <https://bugzilla.mozilla.org/show_bug.cgi?id=1326509>.
|
||||
[SameObject, BinaryName="styleSheetForBindings"] readonly attribute CSSStyleSheet? styleSheet;
|
||||
[SameObject] readonly attribute CSSStyleSheet? styleSheet;
|
||||
};
|
||||
|
@ -45,12 +45,6 @@ void ServoStyleRuleMap::SheetAdded(StyleSheet& aStyleSheet) {
|
||||
}
|
||||
}
|
||||
|
||||
void ServoStyleRuleMap::SheetCloned(StyleSheet& aStyleSheet) {
|
||||
// Invalidate all data inside. We could probably track down all the individual
|
||||
// rules that changed etc, but it doesn't seem worth it.
|
||||
mTable.Clear();
|
||||
}
|
||||
|
||||
void ServoStyleRuleMap::SheetRemoved(StyleSheet& aStyleSheet) {
|
||||
// Invalidate all data inside. This isn't strictly necessary since
|
||||
// we should always get update from document before new queries come.
|
||||
|
@ -36,7 +36,6 @@ class ServoStyleRuleMap {
|
||||
|
||||
void SheetAdded(StyleSheet&);
|
||||
void SheetRemoved(StyleSheet&);
|
||||
void SheetCloned(StyleSheet&);
|
||||
|
||||
void RuleAdded(StyleSheet& aStyleSheet, css::Rule&);
|
||||
void RuleRemoved(StyleSheet& aStyleSheet, css::Rule&);
|
||||
|
@ -31,11 +31,6 @@ uint16_t CSSCounterStyleRule::Type() const {
|
||||
return CSSRule_Binding::COUNTER_STYLE_RULE;
|
||||
}
|
||||
|
||||
void CSSCounterStyleRule::SetRawAfterClone(
|
||||
RefPtr<RawServoCounterStyleRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
}
|
||||
|
||||
void CSSCounterStyleRule::GetCssText(nsACString& aCssText) const {
|
||||
Servo_CounterStyleRule_GetCssText(mRawRule, &aCssText);
|
||||
}
|
||||
@ -47,27 +42,16 @@ void CSSCounterStyleRule::GetName(nsAString& aName) {
|
||||
nsStyleUtil::AppendEscapedCSSIdent(nameStr, aName);
|
||||
}
|
||||
|
||||
template <typename Func>
|
||||
void CSSCounterStyleRule::ModifyRule(Func aCallback) {
|
||||
void CSSCounterStyleRule::SetName(const nsAString& aName) {
|
||||
if (IsReadOnly()) {
|
||||
return;
|
||||
}
|
||||
|
||||
StyleSheet* sheet = GetStyleSheet();
|
||||
if (sheet) {
|
||||
sheet->WillDirty();
|
||||
NS_ConvertUTF16toUTF8 name(aName);
|
||||
if (Servo_CounterStyleRule_SetName(mRawRule, &name)) {
|
||||
if (StyleSheet* sheet = GetStyleSheet()) {
|
||||
sheet->RuleChanged(this, StyleRuleChangeKind::Generic);
|
||||
}
|
||||
}
|
||||
|
||||
if (aCallback() && sheet) {
|
||||
sheet->RuleChanged(this, StyleRuleChangeKind::Generic);
|
||||
}
|
||||
}
|
||||
|
||||
void CSSCounterStyleRule::SetName(const nsAString& aName) {
|
||||
ModifyRule([&] {
|
||||
NS_ConvertUTF16toUTF8 name(aName);
|
||||
return Servo_CounterStyleRule_SetName(mRawRule, &name);
|
||||
});
|
||||
}
|
||||
|
||||
#define CSS_COUNTER_DESC(name_, method_) \
|
||||
@ -77,10 +61,15 @@ void CSSCounterStyleRule::SetName(const nsAString& aName) {
|
||||
mRawRule, eCSSCounterDesc_##method_, &aValue); \
|
||||
} \
|
||||
void CSSCounterStyleRule::Set##method_(const nsACString& aValue) { \
|
||||
ModifyRule([&] { \
|
||||
return Servo_CounterStyleRule_SetDescriptor( \
|
||||
mRawRule, eCSSCounterDesc_##method_, &aValue); \
|
||||
}); \
|
||||
if (IsReadOnly()) { \
|
||||
return; \
|
||||
} \
|
||||
if (Servo_CounterStyleRule_SetDescriptor( \
|
||||
mRawRule, eCSSCounterDesc_##method_, &aValue)) { \
|
||||
if (StyleSheet* sheet = GetStyleSheet()) { \
|
||||
sheet->RuleChanged(this, StyleRuleChangeKind::Generic); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#include "nsCSSCounterDescList.h"
|
||||
#undef CSS_COUNTER_DESC
|
||||
|
@ -27,14 +27,10 @@ class CSSCounterStyleRule final : public css::Rule {
|
||||
CSSCounterStyleRule(const CSSCounterStyleRule& aCopy) = delete;
|
||||
~CSSCounterStyleRule() = default;
|
||||
|
||||
template <typename Func>
|
||||
void ModifyRule(Func);
|
||||
|
||||
public:
|
||||
bool IsCCLeaf() const final;
|
||||
|
||||
const RawServoCounterStyleRule* Raw() const { return mRawRule.get(); }
|
||||
void SetRawAfterClone(RefPtr<RawServoCounterStyleRule>);
|
||||
|
||||
#ifdef DEBUG
|
||||
void List(FILE* out = stdout, int32_t aIndent = 0) const final;
|
||||
|
@ -34,10 +34,6 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMPL_ADDREF_USING_AGGREGATOR(CSSFontFaceRuleDecl, ContainingRule())
|
||||
NS_IMPL_RELEASE_USING_AGGREGATOR(CSSFontFaceRuleDecl, ContainingRule())
|
||||
|
||||
void CSSFontFaceRuleDecl::SetRawAfterClone(RefPtr<RawServoFontFaceRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
}
|
||||
|
||||
// helper for string GetPropertyValue and RemovePropertyValue
|
||||
void CSSFontFaceRuleDecl::GetPropertyValue(nsCSSFontDesc aFontDescID,
|
||||
nsACString& aResult) const {
|
||||
@ -201,10 +197,6 @@ uint16_t CSSFontFaceRule::Type() const {
|
||||
return CSSRule_Binding::FONT_FACE_RULE;
|
||||
}
|
||||
|
||||
void CSSFontFaceRule::SetRawAfterClone(RefPtr<RawServoFontFaceRule> aRaw) {
|
||||
mDecl.SetRawAfterClone(std::move(aRaw));
|
||||
}
|
||||
|
||||
void CSSFontFaceRule::GetCssText(nsACString& aCssText) const {
|
||||
aCssText.Truncate();
|
||||
Servo_FontFaceRule_GetCssText(Raw(), &aCssText);
|
||||
|
@ -43,7 +43,6 @@ class CSSFontFaceRuleDecl final : public nsICSSDeclaration {
|
||||
inline const CSSFontFaceRule* ContainingRule() const;
|
||||
|
||||
RefPtr<RawServoFontFaceRule> mRawRule;
|
||||
void SetRawAfterClone(RefPtr<RawServoFontFaceRule>);
|
||||
|
||||
private:
|
||||
void* operator new(size_t size) noexcept(true) = delete;
|
||||
@ -65,7 +64,6 @@ class CSSFontFaceRule final : public css::Rule {
|
||||
bool IsCCLeaf() const final;
|
||||
|
||||
RawServoFontFaceRule* Raw() const { return mDecl.mRawRule; }
|
||||
void SetRawAfterClone(RefPtr<RawServoFontFaceRule>);
|
||||
|
||||
// WebIDL interface
|
||||
uint16_t Type() const final;
|
||||
|
@ -28,11 +28,6 @@ void CSSFontFeatureValuesRule::List(FILE* out, int32_t aIndent) const {
|
||||
}
|
||||
#endif
|
||||
|
||||
void CSSFontFeatureValuesRule::SetRawAfterClone(
|
||||
RefPtr<RawServoFontFeatureValuesRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
}
|
||||
|
||||
/* CSSRule implementation */
|
||||
|
||||
void CSSFontFeatureValuesRule::GetCssText(nsACString& aCssText) const {
|
||||
|
@ -26,7 +26,6 @@ class CSSFontFeatureValuesRule final : public css::Rule {
|
||||
virtual bool IsCCLeaf() const override;
|
||||
|
||||
RawServoFontFeatureValuesRule* Raw() const { return mRawRule; }
|
||||
void SetRawAfterClone(RefPtr<RawServoFontFeatureValuesRule> aRaw);
|
||||
|
||||
// WebIDL interfaces
|
||||
uint16_t Type() const final {
|
||||
|
@ -71,28 +71,9 @@ void CSSImportRule::List(FILE* out, int32_t aIndent) const {
|
||||
}
|
||||
#endif
|
||||
|
||||
void CSSImportRule::SetRawAfterClone(RefPtr<RawServoImportRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
mChildSheet =
|
||||
const_cast<StyleSheet*>(Servo_ImportRule_GetSheet(mRawRule.get()));
|
||||
}
|
||||
|
||||
StyleSheet* CSSImportRule::GetStyleSheetForBindings() {
|
||||
// FIXME(emilio): This is needed to make sure we don't expose shared sheets to
|
||||
// the OM (see wpt /css/cssom/cssimportrule-sheet-identity.html for example).
|
||||
//
|
||||
// Perhaps instead we could create a clone of the stylesheet and keep it in
|
||||
// mChildSheet, without calling EnsureUniqueInner(), or something like that?
|
||||
if (StyleSheet* parent = GetParentStyleSheet()) {
|
||||
parent->EnsureUniqueInner();
|
||||
}
|
||||
return mChildSheet;
|
||||
}
|
||||
|
||||
dom::MediaList* CSSImportRule::GetMedia() {
|
||||
auto* sheet = GetStyleSheetForBindings();
|
||||
dom::MediaList* CSSImportRule::GetMedia() const {
|
||||
// When Bug 1326509 is fixed, we can assert mChildSheet instead.
|
||||
return sheet ? sheet->Media() : nullptr;
|
||||
return mChildSheet ? mChildSheet->Media() : nullptr;
|
||||
}
|
||||
|
||||
void CSSImportRule::DropSheetReference() {
|
||||
|
@ -35,9 +35,8 @@ class CSSImportRule final : public css::Rule {
|
||||
uint16_t Type() const final { return CSSRule_Binding::IMPORT_RULE; }
|
||||
void GetCssText(nsACString& aCssText) const override;
|
||||
void GetHref(nsAString& aHref) const;
|
||||
dom::MediaList* GetMedia();
|
||||
dom::MediaList* GetMedia() const;
|
||||
StyleSheet* GetStyleSheet() const { return mChildSheet; }
|
||||
StyleSheet* GetStyleSheetForBindings();
|
||||
|
||||
// Clear the mSheet pointer on this rule and descendants.
|
||||
void DropSheetReference() final;
|
||||
@ -46,7 +45,6 @@ class CSSImportRule final : public css::Rule {
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
const RawServoImportRule* Raw() const { return mRawRule.get(); }
|
||||
void SetRawAfterClone(RefPtr<RawServoImportRule>);
|
||||
|
||||
private:
|
||||
~CSSImportRule();
|
||||
|
@ -22,7 +22,6 @@ class CSSKeyframeDeclaration : public nsDOMCSSDeclaration {
|
||||
explicit CSSKeyframeDeclaration(CSSKeyframeRule* aRule) : mRule(aRule) {
|
||||
mDecls =
|
||||
new DeclarationBlock(Servo_Keyframe_GetStyle(aRule->Raw()).Consume());
|
||||
mDecls->SetOwningRule(aRule);
|
||||
}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
@ -38,11 +37,6 @@ class CSSKeyframeDeclaration : public nsDOMCSSDeclaration {
|
||||
|
||||
DeclarationBlock* GetOrCreateCSSDeclaration(
|
||||
Operation aOperation, DeclarationBlock** aCreated) final {
|
||||
if (aOperation != Operation::Read && mRule) {
|
||||
if (StyleSheet* sheet = mRule->GetStyleSheet()) {
|
||||
sheet->WillDirty();
|
||||
}
|
||||
}
|
||||
return mDecls;
|
||||
}
|
||||
nsresult SetCSSDeclaration(DeclarationBlock* aDecls,
|
||||
@ -80,12 +74,6 @@ class CSSKeyframeDeclaration : public nsDOMCSSDeclaration {
|
||||
return n;
|
||||
}
|
||||
|
||||
void SetRawAfterClone(RawServoKeyframe* aKeyframe) {
|
||||
mDecls->SetOwningRule(nullptr);
|
||||
mDecls = new DeclarationBlock(Servo_Keyframe_GetStyle(aKeyframe).Consume());
|
||||
mDecls->SetOwningRule(mRule);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual ~CSSKeyframeDeclaration() {
|
||||
MOZ_ASSERT(!mRule, "Backpointer should have been cleared");
|
||||
@ -142,14 +130,6 @@ bool CSSKeyframeRule::IsCCLeaf() const {
|
||||
return Rule::IsCCLeaf() && !mDeclaration;
|
||||
}
|
||||
|
||||
void CSSKeyframeRule::SetRawAfterClone(RefPtr<RawServoKeyframe> aRaw) {
|
||||
mRaw = std::move(aRaw);
|
||||
|
||||
if (mDeclaration) {
|
||||
mDeclaration->SetRawAfterClone(mRaw);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* virtual */
|
||||
void CSSKeyframeRule::List(FILE* out, int32_t aIndent) const {
|
||||
@ -168,14 +148,9 @@ void CSSKeyframeRule::UpdateRule(Func aCallback) {
|
||||
return;
|
||||
}
|
||||
|
||||
StyleSheet* sheet = GetStyleSheet();
|
||||
if (sheet) {
|
||||
sheet->WillDirty();
|
||||
}
|
||||
|
||||
aCallback();
|
||||
|
||||
if (sheet) {
|
||||
if (StyleSheet* sheet = GetStyleSheet()) {
|
||||
sheet->RuleChanged(this, StyleRuleChangeKind::Generic);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ class CSSKeyframeRule final : public css::Rule {
|
||||
#endif
|
||||
|
||||
RawServoKeyframe* Raw() const { return mRaw; }
|
||||
void SetRawAfterClone(RefPtr<RawServoKeyframe>);
|
||||
|
||||
// WebIDL interface
|
||||
uint16_t Type() const final { return CSSRule_Binding::KEYFRAME_RULE; }
|
||||
|
@ -31,22 +31,6 @@ class CSSKeyframeList : public dom::CSSRuleList {
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CSSKeyframeList, dom::CSSRuleList)
|
||||
|
||||
void SetRawAfterClone(RefPtr<RawServoKeyframesRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
uint32_t index = 0;
|
||||
for (css::Rule* rule : mRules) {
|
||||
if (rule) {
|
||||
uint32_t line = 0, column = 0;
|
||||
RefPtr<RawServoKeyframe> keyframe =
|
||||
Servo_KeyframesRule_GetKeyframeAt(mRawRule, index, &line, &column)
|
||||
.Consume();
|
||||
static_cast<CSSKeyframeRule*>(rule)->SetRawAfterClone(
|
||||
std::move(keyframe));
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
void DropSheetReference() {
|
||||
if (!mStyleSheet) {
|
||||
return;
|
||||
@ -207,13 +191,6 @@ bool CSSKeyframesRule::IsCCLeaf() const {
|
||||
return Rule::IsCCLeaf() && !mKeyframeList;
|
||||
}
|
||||
|
||||
void CSSKeyframesRule::SetRawAfterClone(RefPtr<RawServoKeyframesRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
if (mKeyframeList) {
|
||||
mKeyframeList->SetRawAfterClone(mRawRule);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* virtual */
|
||||
void CSSKeyframesRule::List(FILE* out, int32_t aIndent) const {
|
||||
@ -247,14 +224,8 @@ nsresult CSSKeyframesRule::UpdateRule(Func aCallback) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
StyleSheet* sheet = GetStyleSheet();
|
||||
if (sheet) {
|
||||
sheet->WillDirty();
|
||||
}
|
||||
|
||||
aCallback();
|
||||
|
||||
if (sheet) {
|
||||
if (StyleSheet* sheet = GetStyleSheet()) {
|
||||
sheet->RuleChanged(this, StyleRuleChangeKind::Generic);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@ class CSSKeyframesRule final : public css::Rule {
|
||||
// WebIDL interface
|
||||
uint16_t Type() const final { return CSSRule_Binding::KEYFRAMES_RULE; }
|
||||
const RawServoKeyframesRule* Raw() const { return mRawRule.get(); }
|
||||
void SetRawAfterClone(RefPtr<RawServoKeyframesRule>);
|
||||
|
||||
void GetCssText(nsACString& aCssText) const final;
|
||||
void GetName(nsAString& aName) const;
|
||||
|
@ -56,15 +56,6 @@ void CSSMediaRule::DropSheetReference() {
|
||||
ConditionRule::DropSheetReference();
|
||||
}
|
||||
|
||||
void CSSMediaRule::SetRawAfterClone(RefPtr<RawServoMediaRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
if (mMediaList) {
|
||||
mMediaList->SetRawAfterClone(Servo_MediaRule_GetMedia(mRawRule).Consume());
|
||||
}
|
||||
css::ConditionRule::SetRawAfterClone(
|
||||
Servo_MediaRule_GetRules(mRawRule).Consume());
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* virtual */
|
||||
void CSSMediaRule::List(FILE* out, int32_t aIndent) const {
|
||||
|
@ -28,7 +28,6 @@ class CSSMediaRule final : public css::ConditionRule {
|
||||
#endif
|
||||
|
||||
RawServoMediaRule* Raw() const { return mRawRule; }
|
||||
void SetRawAfterClone(RefPtr<RawServoMediaRule>);
|
||||
|
||||
// WebIDL interface
|
||||
uint16_t Type() const override { return CSSRule_Binding::MEDIA_RULE; }
|
||||
|
@ -108,13 +108,6 @@ void CSSMozDocumentRule::List(FILE* out, int32_t aIndent) const {
|
||||
}
|
||||
#endif
|
||||
|
||||
void CSSMozDocumentRule::SetRawAfterClone(
|
||||
RefPtr<RawServoMozDocumentRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
css::ConditionRule::SetRawAfterClone(
|
||||
Servo_MozDocumentRule_GetRules(mRawRule).Consume());
|
||||
}
|
||||
|
||||
void CSSMozDocumentRule::GetConditionText(nsACString& aConditionText) {
|
||||
Servo_MozDocumentRule_GetConditionText(mRawRule, &aConditionText);
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ class CSSMozDocumentRule final : public css::ConditionRule {
|
||||
#endif
|
||||
|
||||
RawServoMozDocumentRule* Raw() const { return mRawRule; }
|
||||
void SetRawAfterClone(RefPtr<RawServoMozDocumentRule>);
|
||||
|
||||
// WebIDL interface
|
||||
uint16_t Type() const final { return CSSRule_Binding::DOCUMENT_RULE; }
|
||||
|
@ -38,10 +38,6 @@ void CSSNamespaceRule::GetCssText(nsACString& aCssText) const {
|
||||
Servo_NamespaceRule_GetCssText(mRawRule, &aCssText);
|
||||
}
|
||||
|
||||
void CSSNamespaceRule::SetRawAfterClone(RefPtr<RawServoNamespaceRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
}
|
||||
|
||||
size_t CSSNamespaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
|
||||
return aMallocSizeOf(this);
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ class CSSNamespaceRule final : public css::Rule {
|
||||
uint16_t Type() const final { return CSSRule_Binding::NAMESPACE_RULE; }
|
||||
|
||||
const RawServoNamespaceRule* Raw() const { return mRawRule.get(); }
|
||||
void SetRawAfterClone(RefPtr<RawServoNamespaceRule>);
|
||||
|
||||
void GetNamespaceURI(nsString& aNamespaceURI) { GetURLSpec(aNamespaceURI); }
|
||||
|
||||
|
@ -17,9 +17,7 @@ namespace dom {
|
||||
|
||||
CSSPageRuleDeclaration::CSSPageRuleDeclaration(
|
||||
already_AddRefed<RawServoDeclarationBlock> aDecls)
|
||||
: mDecls(new DeclarationBlock(std::move(aDecls))) {
|
||||
mDecls->SetOwningRule(Rule());
|
||||
}
|
||||
: mDecls(new DeclarationBlock(std::move(aDecls))) {}
|
||||
|
||||
CSSPageRuleDeclaration::~CSSPageRuleDeclaration() {
|
||||
mDecls->SetOwningRule(nullptr);
|
||||
@ -53,26 +51,18 @@ nsISupports* CSSPageRuleDeclaration::GetParentObject() const {
|
||||
|
||||
DeclarationBlock* CSSPageRuleDeclaration::GetOrCreateCSSDeclaration(
|
||||
Operation aOperation, DeclarationBlock** aCreated) {
|
||||
if (aOperation != Operation::Read) {
|
||||
if (StyleSheet* sheet = Rule()->GetStyleSheet()) {
|
||||
sheet->WillDirty();
|
||||
}
|
||||
}
|
||||
return mDecls;
|
||||
}
|
||||
|
||||
void CSSPageRuleDeclaration::SetRawAfterClone(
|
||||
RefPtr<RawServoDeclarationBlock> aDeclarationBlock) {
|
||||
mDecls->SetOwningRule(nullptr);
|
||||
mDecls = new DeclarationBlock(aDeclarationBlock.forget());
|
||||
mDecls->SetOwningRule(Rule());
|
||||
}
|
||||
|
||||
nsresult CSSPageRuleDeclaration::SetCSSDeclaration(
|
||||
DeclarationBlock* aDecl, MutationClosureData* aClosureData) {
|
||||
MOZ_ASSERT(aDecl, "must be non-null");
|
||||
CSSPageRule* rule = Rule();
|
||||
|
||||
if (rule->IsReadOnly()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aDecl != mDecls) {
|
||||
mDecls->SetOwningRule(nullptr);
|
||||
RefPtr<DeclarationBlock> decls = aDecl;
|
||||
@ -139,11 +129,6 @@ bool CSSPageRule::IsCCLeaf() const {
|
||||
return !mDecls.PreservingWrapper();
|
||||
}
|
||||
|
||||
void CSSPageRule::SetRawAfterClone(RefPtr<RawServoPageRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
mDecls.SetRawAfterClone(Servo_PageRule_GetStyle(mRawRule.get()).Consume());
|
||||
}
|
||||
|
||||
size_t CSSPageRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
|
||||
// TODO Implement this!
|
||||
return aMallocSizeOf(this);
|
||||
|
@ -43,8 +43,6 @@ class CSSPageRuleDeclaration final : public nsDOMCSSDeclaration {
|
||||
|
||||
explicit CSSPageRuleDeclaration(
|
||||
already_AddRefed<RawServoDeclarationBlock> aDecls);
|
||||
void SetRawAfterClone(RefPtr<RawServoDeclarationBlock>);
|
||||
|
||||
~CSSPageRuleDeclaration();
|
||||
|
||||
inline CSSPageRule* Rule();
|
||||
@ -64,7 +62,6 @@ class CSSPageRule final : public css::Rule {
|
||||
bool IsCCLeaf() const final;
|
||||
|
||||
RawServoPageRule* Raw() const { return mRawRule; }
|
||||
void SetRawAfterClone(RefPtr<RawServoPageRule>);
|
||||
|
||||
// WebIDL interfaces
|
||||
uint16_t Type() const final { return CSSRule_Binding::PAGE_RULE; }
|
||||
|
@ -25,9 +25,7 @@ namespace dom {
|
||||
|
||||
CSSStyleRuleDeclaration::CSSStyleRuleDeclaration(
|
||||
already_AddRefed<RawServoDeclarationBlock> aDecls)
|
||||
: mDecls(new DeclarationBlock(std::move(aDecls))) {
|
||||
mDecls->SetOwningRule(Rule());
|
||||
}
|
||||
: mDecls(new DeclarationBlock(std::move(aDecls))) {}
|
||||
|
||||
CSSStyleRuleDeclaration::~CSSStyleRuleDeclaration() {
|
||||
mDecls->SetOwningRule(nullptr);
|
||||
@ -61,31 +59,18 @@ nsISupports* CSSStyleRuleDeclaration::GetParentObject() const {
|
||||
|
||||
DeclarationBlock* CSSStyleRuleDeclaration::GetOrCreateCSSDeclaration(
|
||||
Operation aOperation, DeclarationBlock** aCreated) {
|
||||
if (aOperation != Operation::Read) {
|
||||
if (StyleSheet* sheet = Rule()->GetStyleSheet()) {
|
||||
sheet->WillDirty();
|
||||
}
|
||||
}
|
||||
return mDecls;
|
||||
}
|
||||
|
||||
void CSSStyleRule::SetRawAfterClone(RefPtr<RawServoStyleRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
mDecls.SetRawAfterClone(Servo_StyleRule_GetStyle(mRawRule).Consume());
|
||||
}
|
||||
|
||||
void CSSStyleRuleDeclaration::SetRawAfterClone(RefPtr<RawServoDeclarationBlock> aRaw) {
|
||||
RefPtr<DeclarationBlock> block = new DeclarationBlock(aRaw.forget());
|
||||
mDecls->SetOwningRule(nullptr);
|
||||
mDecls = std::move(block);
|
||||
mDecls->SetOwningRule(Rule());
|
||||
}
|
||||
|
||||
nsresult CSSStyleRuleDeclaration::SetCSSDeclaration(
|
||||
DeclarationBlock* aDecl, MutationClosureData* aClosureData) {
|
||||
CSSStyleRule* rule = Rule();
|
||||
|
||||
if (StyleSheet* sheet = rule->GetStyleSheet()) {
|
||||
if (rule->IsReadOnly()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (RefPtr<StyleSheet> sheet = rule->GetStyleSheet()) {
|
||||
if (aDecl != mDecls) {
|
||||
mDecls->SetOwningRule(nullptr);
|
||||
RefPtr<DeclarationBlock> decls = aDecl;
|
||||
@ -191,7 +176,10 @@ void CSSStyleRule::SetSelectorText(const nsACString& aSelectorText) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (StyleSheet* sheet = GetStyleSheet()) {
|
||||
if (RefPtr<StyleSheet> sheet = GetStyleSheet()) {
|
||||
// StyleRule lives inside of the Inner, it is unsafe to call WillDirty
|
||||
// if sheet does not already have a unique Inner.
|
||||
sheet->AssertHasUniqueInner();
|
||||
sheet->WillDirty();
|
||||
|
||||
// TODO(emilio): May actually be more efficient to handle this as rule
|
||||
|
@ -49,8 +49,6 @@ class CSSStyleRuleDeclaration final : public nsDOMCSSDeclaration {
|
||||
inline CSSStyleRule* Rule();
|
||||
inline const CSSStyleRule* Rule() const;
|
||||
|
||||
void SetRawAfterClone(RefPtr<RawServoDeclarationBlock>);
|
||||
|
||||
RefPtr<DeclarationBlock> mDecls;
|
||||
};
|
||||
|
||||
@ -83,7 +81,6 @@ class CSSStyleRule final : public BindingStyleRule, public SupportsWeakPtr {
|
||||
nsICSSDeclaration* Style() final;
|
||||
|
||||
RawServoStyleRule* Raw() const { return mRawRule; }
|
||||
void SetRawAfterClone(RefPtr<RawServoStyleRule>);
|
||||
|
||||
// Methods of mozilla::css::Rule
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
|
||||
|
@ -59,13 +59,6 @@ void CSSSupportsRule::GetCssText(nsACString& aCssText) const {
|
||||
Servo_SupportsRule_GetCssText(mRawRule, &aCssText);
|
||||
}
|
||||
|
||||
void CSSSupportsRule::SetRawAfterClone(RefPtr<RawServoSupportsRule> aRaw) {
|
||||
mRawRule = std::move(aRaw);
|
||||
|
||||
css::ConditionRule::SetRawAfterClone(
|
||||
Servo_SupportsRule_GetRules(mRawRule).Consume());
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
size_t CSSSupportsRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
|
||||
// TODO Implement this!
|
||||
|
@ -25,7 +25,6 @@ class CSSSupportsRule : public css::ConditionRule {
|
||||
#endif
|
||||
|
||||
RawServoSupportsRule* Raw() const { return mRawRule; }
|
||||
void SetRawAfterClone(RefPtr<RawServoSupportsRule>);
|
||||
|
||||
// WebIDL interface
|
||||
uint16_t Type() const override { return CSSRule_Binding::SUPPORTS_RULE; }
|
||||
|
@ -55,10 +55,6 @@ class GroupRule : public Rule {
|
||||
return mRuleList->GetRule(aIndex);
|
||||
}
|
||||
|
||||
void SetRawAfterClone(RefPtr<ServoCssRules> aRules) {
|
||||
mRuleList->SetRawAfterClone(std::move(aRules));
|
||||
}
|
||||
|
||||
/*
|
||||
* The next method should never be called unless you have first called
|
||||
* WillDirty() on the parent stylesheet.
|
||||
|
@ -47,9 +47,6 @@ class MediaList final : public nsISupports, public nsWrapperCache {
|
||||
bool Matches(const Document&) const;
|
||||
|
||||
void SetStyleSheet(StyleSheet* aSheet);
|
||||
void SetRawAfterClone(RefPtr<RawServoMediaList> aRaw) {
|
||||
mRawList = std::move(aRaw);
|
||||
}
|
||||
|
||||
// WebIDL
|
||||
void GetMediaText(nsACString& aMediaText);
|
||||
|
@ -49,7 +49,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ServoCSSRuleList)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(dom::CSSRuleList)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ServoCSSRuleList,
|
||||
dom::CSSRuleList)
|
||||
tmp->EnumerateInstantiatedRules([&](css::Rule* aRule, uint32_t) {
|
||||
tmp->EnumerateInstantiatedRules([&](css::Rule* aRule) {
|
||||
if (!aRule->IsCCLeaf()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mRules[i]");
|
||||
cb.NoteXPCOMChild(aRule);
|
||||
@ -65,13 +65,12 @@ css::Rule* ServoCSSRuleList::GetRule(uint32_t aIndex) {
|
||||
#define CASE_RULE(const_, name_) \
|
||||
case CSSRule_Binding::const_##_RULE: { \
|
||||
uint32_t line = 0, column = 0; \
|
||||
RefPtr<RawServo##name_##Rule> raw = \
|
||||
RefPtr<RawServo##name_##Rule> rule = \
|
||||
Servo_CssRules_Get##name_##RuleAt(mRawRules, aIndex, &line, &column) \
|
||||
.Consume(); \
|
||||
MOZ_ASSERT(raw); \
|
||||
ruleObj = new CSS##name_##Rule(raw.forget(), mStyleSheet, mParentRule, \
|
||||
MOZ_ASSERT(rule); \
|
||||
ruleObj = new CSS##name_##Rule(rule.forget(), mStyleSheet, mParentRule, \
|
||||
line, column); \
|
||||
MOZ_ASSERT(ruleObj->Type() == rule); \
|
||||
break; \
|
||||
}
|
||||
CASE_RULE(STYLE, Style)
|
||||
@ -110,12 +109,10 @@ css::Rule* ServoCSSRuleList::IndexedGetter(uint32_t aIndex, bool& aFound) {
|
||||
|
||||
template <typename Func>
|
||||
void ServoCSSRuleList::EnumerateInstantiatedRules(Func aCallback) {
|
||||
uint32_t index = 0;
|
||||
for (uintptr_t rule : mRules) {
|
||||
if (rule > kMaxRuleType) {
|
||||
aCallback(CastToPtr(rule), index);
|
||||
aCallback(CastToPtr(rule));
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,13 +146,13 @@ void ServoCSSRuleList::DropSheetReference() {
|
||||
}
|
||||
mStyleSheet = nullptr;
|
||||
EnumerateInstantiatedRules(
|
||||
[](css::Rule* rule, uint32_t) { rule->DropSheetReference(); });
|
||||
[](css::Rule* rule) { rule->DropSheetReference(); });
|
||||
}
|
||||
|
||||
void ServoCSSRuleList::DropParentRuleReference() {
|
||||
mParentRule = nullptr;
|
||||
EnumerateInstantiatedRules(
|
||||
[](css::Rule* rule, uint32_t) { rule->DropParentRuleReference(); });
|
||||
[](css::Rule* rule) { rule->DropParentRuleReference(); });
|
||||
}
|
||||
|
||||
nsresult ServoCSSRuleList::InsertRule(const nsACString& aRule,
|
||||
@ -168,8 +165,6 @@ nsresult ServoCSSRuleList::InsertRule(const nsACString& aRule,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mStyleSheet->WillDirty();
|
||||
|
||||
bool nested = !!mParentRule;
|
||||
css::Loader* loader = nullptr;
|
||||
auto allowImportRules = mStyleSheet->SelfOrAncestorIsConstructed()
|
||||
@ -219,42 +214,6 @@ uint16_t ServoCSSRuleList::GetDOMCSSRuleType(uint32_t aIndex) const {
|
||||
return CastToPtr(rule)->Type();
|
||||
}
|
||||
|
||||
void ServoCSSRuleList::SetRawAfterClone(RefPtr<ServoCssRules> aNewRules) {
|
||||
mRawRules = std::move(aNewRules);
|
||||
EnumerateInstantiatedRules([&](css::Rule* aRule, uint32_t aIndex) {
|
||||
#define CASE_FOR(constant_, type_) \
|
||||
case CSSRule_Binding::constant_##_RULE: { \
|
||||
uint32_t line = 0, column = 0; \
|
||||
RefPtr<RawServo##type_##Rule> raw = \
|
||||
Servo_CssRules_Get##type_##RuleAt(mRawRules, aIndex, &line, &column) \
|
||||
.Consume(); \
|
||||
static_cast<dom::CSS##type_##Rule*>(aRule)->SetRawAfterClone( \
|
||||
std::move(raw)); \
|
||||
break; \
|
||||
}
|
||||
switch (aRule->Type()) {
|
||||
CASE_FOR(STYLE, Style)
|
||||
CASE_FOR(KEYFRAMES, Keyframes)
|
||||
CASE_FOR(MEDIA, Media)
|
||||
CASE_FOR(NAMESPACE, Namespace)
|
||||
CASE_FOR(PAGE, Page)
|
||||
CASE_FOR(SUPPORTS, Supports)
|
||||
CASE_FOR(DOCUMENT, MozDocument)
|
||||
CASE_FOR(IMPORT, Import)
|
||||
CASE_FOR(FONT_FEATURE_VALUES, FontFeatureValues)
|
||||
CASE_FOR(FONT_FACE, FontFace)
|
||||
CASE_FOR(COUNTER_STYLE, CounterStyle)
|
||||
case CSSRule_Binding::KEYFRAME_RULE:
|
||||
MOZ_ASSERT_UNREACHABLE("keyframe rule cannot be here");
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Which rule do we have here?");
|
||||
break;
|
||||
}
|
||||
#undef CASE_FOR
|
||||
});
|
||||
}
|
||||
|
||||
ServoCSSRuleList::~ServoCSSRuleList() {
|
||||
MOZ_ASSERT(!mStyleSheet, "Backpointer should have been cleared");
|
||||
MOZ_ASSERT(!mParentRule, "Backpointer should have been cleared");
|
||||
|
@ -50,8 +50,6 @@ class ServoCSSRuleList final : public dom::CSSRuleList {
|
||||
|
||||
uint16_t GetDOMCSSRuleType(uint32_t aIndex) const;
|
||||
|
||||
void SetRawAfterClone(RefPtr<ServoCssRules>);
|
||||
|
||||
private:
|
||||
virtual ~ServoCSSRuleList();
|
||||
|
||||
|
@ -942,13 +942,6 @@ void ServoStyleSet::RuleChanged(StyleSheet& aSheet, css::Rule* aRule,
|
||||
}
|
||||
}
|
||||
|
||||
void ServoStyleSet::SheetCloned(StyleSheet& aSheet) {
|
||||
mNeedsRestyleAfterEnsureUniqueInner = true;
|
||||
if (mStyleRuleMap) {
|
||||
mStyleRuleMap->SheetCloned(aSheet);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void ServoStyleSet::AssertTreeIsClean() {
|
||||
DocumentStyleRootIterator iter(mDocument);
|
||||
|
@ -119,7 +119,7 @@ class ServoStyleSet {
|
||||
void RuleAdded(StyleSheet&, css::Rule&);
|
||||
void RuleRemoved(StyleSheet&, css::Rule&);
|
||||
void RuleChanged(StyleSheet&, css::Rule*, StyleRuleChangeKind);
|
||||
void SheetCloned(StyleSheet&);
|
||||
void SheetCloned(StyleSheet&) { mNeedsRestyleAfterEnsureUniqueInner = true; }
|
||||
void ImportRuleLoaded(dom::CSSImportRule&, StyleSheet&);
|
||||
|
||||
// Runs style invalidation due to document state changes.
|
||||
|
@ -537,14 +537,13 @@ void StyleSheet::EnsureUniqueInner() {
|
||||
|
||||
StyleSheetInfo* clone = mInner->CloneFor(this);
|
||||
MOZ_ASSERT(clone);
|
||||
|
||||
mInner->RemoveSheet(this);
|
||||
mInner = clone;
|
||||
|
||||
// Fixup the child lists and parent links in the Servo sheet. This is done
|
||||
// here instead of in StyleSheetInner::CloneFor, because it's just more
|
||||
// convenient to do so instead.
|
||||
FixUpAfterInnerClone();
|
||||
BuildChildListAfterInnerClone();
|
||||
|
||||
// let our containing style sets know that if we call
|
||||
// nsPresContext::EnsureSafeToHandOutCSSRules we will need to restyle the
|
||||
@ -817,8 +816,6 @@ void StyleSheet::RuleRemoved(css::Rule& aRule) {
|
||||
}
|
||||
|
||||
void StyleSheet::RuleChanged(css::Rule* aRule, StyleRuleChangeKind aKind) {
|
||||
MOZ_ASSERT(!aRule || HasUniqueInner(),
|
||||
"Shouldn't have mutated a shared sheet");
|
||||
SetModifiedRules();
|
||||
NOTIFY(RuleChanged, (*this, aRule, aKind));
|
||||
}
|
||||
@ -1109,7 +1106,7 @@ JSObject* StyleSheet::WrapObject(JSContext* aCx,
|
||||
return dom::CSSStyleSheet_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void StyleSheet::FixUpAfterInnerClone() {
|
||||
void StyleSheet::BuildChildListAfterInnerClone() {
|
||||
MOZ_ASSERT(Inner().mSheets.Length() == 1, "Should've just cloned");
|
||||
MOZ_ASSERT(Inner().mSheets[0] == this);
|
||||
MOZ_ASSERT(Inner().mChildren.IsEmpty());
|
||||
@ -1117,10 +1114,6 @@ void StyleSheet::FixUpAfterInnerClone() {
|
||||
auto* contents = Inner().mContents.get();
|
||||
RefPtr<ServoCssRules> rules = Servo_StyleSheet_GetRules(contents).Consume();
|
||||
|
||||
if (mRuleList) {
|
||||
mRuleList->SetRawAfterClone(rules);
|
||||
}
|
||||
|
||||
uint32_t index = 0;
|
||||
while (true) {
|
||||
uint32_t line, column; // Actually unused.
|
||||
@ -1387,6 +1380,8 @@ already_AddRefed<StyleSheet> StyleSheet::CloneAdoptedSheet(
|
||||
|
||||
ServoCSSRuleList* StyleSheet::GetCssRulesInternal() {
|
||||
if (!mRuleList) {
|
||||
EnsureUniqueInner();
|
||||
|
||||
RefPtr<ServoCssRules> rawRules =
|
||||
Servo_StyleSheet_GetRules(Inner().mContents).Consume();
|
||||
MOZ_ASSERT(rawRules);
|
||||
|
@ -501,7 +501,7 @@ class StyleSheet final : public nsICSSLoaderObserver, public nsWrapperCache {
|
||||
|
||||
// Take the recently cloned sheets from the `@import` rules, and reparent them
|
||||
// correctly to `aPrimarySheet`.
|
||||
void FixUpAfterInnerClone();
|
||||
void BuildChildListAfterInnerClone();
|
||||
|
||||
void DropRuleList();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user