Bug 1402218. Make sure to clone our CSSDeclaration as needed when removing properties. r=emilio

MozReview-Commit-ID: 6LRjLU3QQok
This commit is contained in:
Boris Zbarsky 2017-09-28 22:04:34 -04:00
Родитель 4f6bea99ba
Коммит c842174571
4 изменённых файлов: 26 добавлений и 11 удалений

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

@ -46,6 +46,15 @@ DeclarationBlock::EnsureMutable()
AsGecko()->AssertNotExpanded();
}
#endif
if (IsServo() && !IsDirty()) {
// In stylo, the old DeclarationBlock is stored in element's rule node tree
// directly, to avoid new values replacing the DeclarationBlock in the tree
// directly, we need to copy the old one here if we haven't yet copied.
// As a result the new value does not replace rule node tree until traversal
// happens.
return Clone();
}
if (!IsMutable()) {
return Clone();
}

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

@ -0,0 +1,15 @@
<!DOCTYPE html>
<style>
#wrapper::first-line {}
</style>
<body>
<div id="wrapper">
<div id="test"></div>
</div>
<script>
document.querySelector('#test').style.position = 'absolute';
document.body.offsetHeight;
document.querySelector('#wrapper').style.color = 'green';
document.querySelector('#test').style.position = '';
</script>
</body>

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

@ -233,5 +233,6 @@ load 1402366.html
load 1402419.html
load 1402472.html
load 1403028.html
load 1402218-1.html
load 1403615.html
load 1403592.html

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

@ -305,17 +305,7 @@ nsDOMCSSDeclaration::ModifyDeclaration(GeckoFunc aGeckoFunc,
// between when we mutate the declaration and when we set the new
// rule (see stack in bug 209575).
mozAutoDocConditionalContentUpdateBatch autoUpdate(DocToUpdate(), true);
RefPtr<DeclarationBlock> decl;
if (olddecl->IsServo() && !olddecl->IsDirty()) {
// In stylo, the old DeclarationBlock is stored in element's rule node tree
// directly, to avoid new values replacing the DeclarationBlock in the tree
// directly, we need to copy the old one here if we haven't yet copied.
// As a result the new value does not replace rule node tree until traversal
// happens.
decl = olddecl->Clone();
} else {
decl = olddecl->EnsureMutable();
}
RefPtr<DeclarationBlock> decl = olddecl->EnsureMutable();
bool changed;
if (decl->IsGecko()) {