Backed out 2 changesets (bug 1644102, bug 1752392) for causing mochitest failures in test_parseStyleSheetImport.html CLOSED TREE

Backed out changeset b5c0bdafaf5e (bug 1644102)
Backed out changeset 092814d96f1d (bug 1752392)
This commit is contained in:
Cristian Tuns 2022-04-28 05:37:52 -04:00
Родитель dbecbdfdfe
Коммит 1ea913ec8d
7 изменённых файлов: 20 добавлений и 73 удалений

Просмотреть файл

@ -36,7 +36,9 @@ ServoCSSRuleList::ServoCSSRuleList(already_AddRefed<ServoCssRules> aRawRules,
StyleSheet* aSheet,
css::GroupRule* aParentRule)
: mStyleSheet(aSheet), mParentRule(aParentRule), mRawRules(aRawRules) {
ResetRules();
if (mRawRules) {
Servo_CssRules_ListTypes(mRawRules, &mRules);
}
}
// QueryInterface implementation for ServoCSSRuleList
@ -132,7 +134,10 @@ static void DropRule(already_AddRefed<css::Rule> aRule) {
rule->DropReferences();
}
void ServoCSSRuleList::ResetRules() {
void ServoCSSRuleList::DropAllRules() {
mStyleSheet = nullptr;
mParentRule = nullptr;
mRawRules = nullptr;
// DropRule could reenter here via the cycle collector.
auto rules = std::move(mRules);
for (uintptr_t rule : rules) {
@ -141,17 +146,6 @@ void ServoCSSRuleList::ResetRules() {
}
}
MOZ_ASSERT(mRules.IsEmpty());
if (mRawRules) {
Servo_CssRules_ListTypes(mRawRules, &mRules);
}
}
void ServoCSSRuleList::DropAllRules() {
mStyleSheet = nullptr;
mParentRule = nullptr;
mRawRules = nullptr;
ResetRules();
}
void ServoCSSRuleList::DropSheetReference() {
@ -227,14 +221,8 @@ nsresult ServoCSSRuleList::DeleteRule(uint32_t aIndex) {
return rv;
}
void ServoCSSRuleList::SetRawContents(RefPtr<ServoCssRules> aNewRules,
bool aFromClone) {
void ServoCSSRuleList::SetRawAfterClone(RefPtr<ServoCssRules> aNewRules) {
mRawRules = std::move(aNewRules);
if (!aFromClone) {
ResetRules();
return;
}
EnumerateInstantiatedRules([&](css::Rule* aRule, uint32_t aIndex) {
#define CASE_FOR(constant_, type_) \
case StyleCssRuleType::constant_: { \

Просмотреть файл

@ -48,13 +48,7 @@ class ServoCSSRuleList final : public dom::CSSRuleList {
nsresult InsertRule(const nsACString& aRule, uint32_t aIndex);
nsresult DeleteRule(uint32_t aIndex);
// aFromClone says whether this comes from a clone of the stylesheet (and thus
// we should also fix up the wrappers for the individual rules in the rule
// lists).
void SetRawContents(RefPtr<ServoCssRules>, bool aFromClone);
void SetRawAfterClone(RefPtr<ServoCssRules> aRules) {
SetRawContents(std::move(aRules), /* aFromClone = */ true);
}
void SetRawAfterClone(RefPtr<ServoCssRules>);
private:
virtual ~ServoCSSRuleList();
@ -75,7 +69,6 @@ class ServoCSSRuleList final : public dom::CSSRuleList {
void EnumerateInstantiatedRules(Func aCallback);
void DropAllRules();
void ResetRules();
bool IsReadOnly() const;

Просмотреть файл

@ -773,8 +773,8 @@ void StyleSheet::ReplaceSync(const nsACString& aText, ErrorResult& aRv) {
.Consume();
// 5. Set sheet's rules to the new rules.
DropRuleList();
Inner().mContents = std::move(rawContent);
FixUpRuleListAfterContentsChangeIfNeeded();
FinishParse();
RuleChanged(nullptr, StyleRuleChangeKind::Generic);
}
@ -1109,25 +1109,18 @@ JSObject* StyleSheet::WrapObject(JSContext* aCx,
return dom::CSSStyleSheet_Binding::Wrap(aCx, this, aGivenProto);
}
void StyleSheet::FixUpRuleListAfterContentsChangeIfNeeded(bool aFromClone) {
if (!mRuleList) {
return;
}
RefPtr<ServoCssRules> rules =
Servo_StyleSheet_GetRules(Inner().mContents.get()).Consume();
mRuleList->SetRawContents(std::move(rules), aFromClone);
}
void StyleSheet::FixUpAfterInnerClone() {
MOZ_ASSERT(Inner().mSheets.Length() == 1, "Should've just cloned");
MOZ_ASSERT(Inner().mSheets[0] == this);
MOZ_ASSERT(Inner().mChildren.IsEmpty());
FixUpRuleListAfterContentsChangeIfNeeded(/* aFromClone = */ true);
auto* contents = Inner().mContents.get();
RefPtr<ServoCssRules> rules = Servo_StyleSheet_GetRules(contents).Consume();
if (mRuleList) {
mRuleList->SetRawAfterClone(rules);
}
RefPtr<ServoCssRules> rules =
Servo_StyleSheet_GetRules(Inner().mContents.get()).Consume();
uint32_t index = 0;
while (true) {
uint32_t line, column; // Actually unused.
@ -1336,11 +1329,11 @@ void StyleSheet::ReparseSheet(const nsACString& aInput, ErrorResult& aRv) {
}
}
DropRuleList();
ParseSheetSync(loader, aInput, /* aLoadData = */ nullptr, lineNumber,
&reusableSheets);
FixUpRuleListAfterContentsChangeIfNeeded();
// Notify the stylesets about the new rules.
{
// Get the rule list (which will need to be regenerated after ParseSheet).

Просмотреть файл

@ -516,11 +516,6 @@ class StyleSheet final : public nsICSSLoaderObserver, public nsWrapperCache {
// correctly to `aPrimarySheet`.
void FixUpAfterInnerClone();
// aFromClone says whether this comes from a clone of the stylesheet (and thus
// we should also fix up the wrappers for the individual rules in the rule
// lists).
void FixUpRuleListAfterContentsChangeIfNeeded(bool aFromClone = false);
void DropRuleList();
// Called when a rule is removed from the sheet from CSSOM.

Просмотреть файл

@ -7330,7 +7330,7 @@
# Whether Constructable Stylesheets are enabled in script.
- name: layout.css.constructable-stylesheets.enabled
type: bool
value: true
value: false
mirror: always
# Whether trigonometric constants and functions are enabled in calc().

Просмотреть файл

@ -1,22 +0,0 @@
<!doctype html>
<meta charset="utf-8">
<title>CSSStyleSheet.replace/replaceSync() doesn't change cssRules object</title>
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="author" href="https://mozilla.org" title="Mozilla">
<link rel="help" href="https://drafts.csswg.org/cssom/#extensions-to-the-document-or-shadow-root-interface">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1752392">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<span>Should be green</span>
<script>
promise_test(async function() {
const sheet = new CSSStyleSheet();
let rules = sheet.cssRules;
sheet.replaceSync('span {color:blue;}');
assert_equals(rules, sheet.cssRules, "Rules should be the same after replaceSync");
await sheet.replace('span {color: lime;}');
assert_equals(rules, sheet.cssRules, "Rules should be the same after replace()");
document.adoptedStyleSheets = [sheet];
assert_equals(getComputedStyle(document.querySelector("span")).color, "rgb(0, 255, 0)", "Sheet should apply");
}, "cssRules doesn't change on replace / replaceSync");
</script>

Просмотреть файл

@ -40,7 +40,7 @@ preference = "layout.css.constructable-stylesheets.enabled"
type = "boolean"
bug-numbers = [1520690]
is-public = {default = false, nightly = true}
default-value = true
default-value = false
[devtools-compatibility-panel]
title = "experimental-features-devtools-compatibility-panel"