Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Style invalidation affecting siblings does not work with inline-style…
… changes https://bugs.webkit.org/show_bug.cgi?id=149189 Patch by Benjamin Poulain <bpoulain@apple.com> on 2015-09-15 Reviewed by Antti Koivisto. Source/WebCore: Style::resolveTree() made the assumption that inline style changes only affect descendants and should not participate in "StyleRecalcAffectsNextSiblingElementStyle". That was wrong. If the inline style change through CSSOM, it can cause the creation of a style attribute, which is observable through "StyleRecalcAffectsNextSiblingElementStyle". This patch removes the incorrect assumption. Style invalidation is always propagated now. Tests: fast/css/style-attribute-invalidation-propagates-to-counted-siblings.html fast/css/style-attribute-invalidation-propagates-to-direct-siblings.html fast/css/style-attribute-invalidation-propagates-to-indirect-siblings.html * css/PropertySetCSSStyleDeclaration.cpp: (WebCore::InlineCSSStyleDeclaration::didMutate): Deleted. * dom/StyledElement.cpp: (WebCore::StyledElement::inlineStyleChanged): * dom/StyledElement.h: (WebCore::StyledElement::invalidateStyleAttribute): Clean up inline-style invalidation a tiny bit. * style/StyleResolveTree.cpp: (WebCore::Style::resolveTree): Fix the bug. LayoutTests: * fast/css/style-attribute-invalidation-propagates-to-counted-siblings-expected.txt: Added. * fast/css/style-attribute-invalidation-propagates-to-counted-siblings.html: Added. * fast/css/style-attribute-invalidation-propagates-to-direct-siblings-expected.txt: Added. * fast/css/style-attribute-invalidation-propagates-to-direct-siblings.html: Added. * fast/css/style-attribute-invalidation-propagates-to-indirect-siblings-expected.txt: Added. * fast/css/style-attribute-invalidation-propagates-to-indirect-siblings.html: Added. Canonical link: https://commits.webkit.org/167293@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
9f99388
commit 14a298f
Showing
12 changed files
with
367 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...utTests/fast/css/style-attribute-invalidation-propagates-to-counted-siblings-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Test that style invalidation through inline-style propagates correctly to siblings when a combinator requires it. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(255, 192, 203)" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
91 changes: 91 additions & 0 deletions
91
LayoutTests/fast/css/style-attribute-invalidation-propagates-to-counted-siblings.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
<style> | ||
target { | ||
color: black; | ||
} | ||
target:nth-child(2 of target, trigger[style]) { | ||
color: pink; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div> | ||
<!-- With renderer --> | ||
<trigger></trigger> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<target></target> | ||
</div> | ||
<div style="display:none;"> | ||
<!-- Without renderer --> | ||
<trigger></trigger> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<target></target> | ||
</div> | ||
</body> | ||
<script> | ||
|
||
description('Test that style invalidation through inline-style propagates correctly to siblings when a combinator requires it.'); | ||
|
||
function testTargetColor(expectedColor) { | ||
let allTargets = document.querySelectorAll("target"); | ||
for (let i = 0; i < allTargets.length; ++i) { | ||
shouldBeEqualToString('getComputedStyle(document.querySelectorAll("target")[' + i + ']).color', expectedColor); | ||
} | ||
} | ||
|
||
testTargetColor('rgb(0, 0, 0)'); | ||
|
||
// Set a style through CSS OM. | ||
function setPropertyWithCSSOM() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].style.cursor = "auto"; | ||
} | ||
} | ||
setPropertyWithCSSOM() | ||
testTargetColor('rgb(255, 192, 203)'); | ||
|
||
// If we remove the attribute, we should be back to normal. | ||
function removeStyleAttribute() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].removeAttribute("style"); | ||
} | ||
} | ||
removeStyleAttribute(); | ||
testTargetColor('rgb(0, 0, 0)'); | ||
|
||
// Setting the style through a style attribute directly. | ||
function setStyleAttribute() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].setAttribute("style", "alt: \"WebKit!\""); | ||
} | ||
} | ||
setStyleAttribute(); | ||
testTargetColor('rgb(255, 192, 203)'); | ||
|
||
// Removing the property on the style attribute through CSSOM. | ||
// This leaves an empty style attribute. | ||
function removePropertyWithCSSOM() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].style.removeProperty("alt"); | ||
} | ||
} | ||
removePropertyWithCSSOM() | ||
testTargetColor('rgb(255, 192, 203)'); | ||
</script> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</html> |
19 changes: 19 additions & 0 deletions
19
LayoutTests/fast/css/style-attribute-invalidation-propagates-to-direct-siblings-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Test that style invalidation through inline-style propagates correctly to siblings when a combinator requires it. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(255, 192, 203)" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
81 changes: 81 additions & 0 deletions
81
LayoutTests/fast/css/style-attribute-invalidation-propagates-to-direct-siblings.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
<style> | ||
target { | ||
color: black; | ||
} | ||
trigger[style] + target { | ||
color: pink; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div> | ||
<!-- With renderer --> | ||
<trigger></trigger> | ||
<target></target> | ||
</div> | ||
<div style="display:none;"> | ||
<!-- Without renderer --> | ||
<trigger></trigger> | ||
<target></target> | ||
</div> | ||
</body> | ||
<script> | ||
|
||
description('Test that style invalidation through inline-style propagates correctly to siblings when a combinator requires it.'); | ||
|
||
function testTargetColor(expectedColor) { | ||
let allTargets = document.querySelectorAll("target"); | ||
for (let i = 0; i < allTargets.length; ++i) { | ||
shouldBeEqualToString('getComputedStyle(document.querySelectorAll("target")[' + i + ']).color', expectedColor); | ||
} | ||
} | ||
|
||
testTargetColor('rgb(0, 0, 0)'); | ||
|
||
// Set a style through CSS OM. | ||
function setPropertyWithCSSOM() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].style.cursor = "auto"; | ||
} | ||
} | ||
setPropertyWithCSSOM() | ||
testTargetColor('rgb(255, 192, 203)'); | ||
|
||
// If we remove the attribute, we should be back to normal. | ||
function removeStyleAttribute() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].removeAttribute("style"); | ||
} | ||
} | ||
removeStyleAttribute(); | ||
testTargetColor('rgb(0, 0, 0)'); | ||
|
||
// Setting the style through a style attribute directly. | ||
function setStyleAttribute() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].setAttribute("style", "alt: \"WebKit!\""); | ||
} | ||
} | ||
setStyleAttribute(); | ||
testTargetColor('rgb(255, 192, 203)'); | ||
|
||
// Removing the property on the style attribute through CSSOM. | ||
// This leaves an empty style attribute. | ||
function removePropertyWithCSSOM() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].style.removeProperty("alt"); | ||
} | ||
} | ||
removePropertyWithCSSOM() | ||
testTargetColor('rgb(255, 192, 203)'); | ||
</script> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</html> |
19 changes: 19 additions & 0 deletions
19
...tTests/fast/css/style-attribute-invalidation-propagates-to-indirect-siblings-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Test that style invalidation through inline-style propagates correctly to siblings when a combinator requires it. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(255, 192, 203)" | ||
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(255, 192, 203)" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
91 changes: 91 additions & 0 deletions
91
LayoutTests/fast/css/style-attribute-invalidation-propagates-to-indirect-siblings.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
<style> | ||
target { | ||
color: black; | ||
} | ||
trigger[style] ~ target { | ||
color: pink; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div> | ||
<!-- With renderer --> | ||
<trigger></trigger> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<target></target> | ||
</div> | ||
<div style="display:none;"> | ||
<!-- Without renderer --> | ||
<trigger></trigger> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<padding></padding> | ||
<target></target> | ||
</div> | ||
</body> | ||
<script> | ||
|
||
description('Test that style invalidation through inline-style propagates correctly to siblings when a combinator requires it.'); | ||
|
||
function testTargetColor(expectedColor) { | ||
let allTargets = document.querySelectorAll("target"); | ||
for (let i = 0; i < allTargets.length; ++i) { | ||
shouldBeEqualToString('getComputedStyle(document.querySelectorAll("target")[' + i + ']).color', expectedColor); | ||
} | ||
} | ||
|
||
testTargetColor('rgb(0, 0, 0)'); | ||
|
||
// Set a style through CSS OM. | ||
function setPropertyWithCSSOM() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].style.cursor = "auto"; | ||
} | ||
} | ||
setPropertyWithCSSOM() | ||
testTargetColor('rgb(255, 192, 203)'); | ||
|
||
// If we remove the attribute, we should be back to normal. | ||
function removeStyleAttribute() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].removeAttribute("style"); | ||
} | ||
} | ||
removeStyleAttribute(); | ||
testTargetColor('rgb(0, 0, 0)'); | ||
|
||
// Setting the style through a style attribute directly. | ||
function setStyleAttribute() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].setAttribute("style", "alt: \"WebKit!\""); | ||
} | ||
} | ||
setStyleAttribute(); | ||
testTargetColor('rgb(255, 192, 203)'); | ||
|
||
// Removing the property on the style attribute through CSSOM. | ||
// This leaves an empty style attribute. | ||
function removePropertyWithCSSOM() { | ||
let allTriggers = document.querySelectorAll("trigger"); | ||
for (let i = 0; i < allTriggers.length; ++i) { | ||
allTriggers[i].style.removeProperty("alt"); | ||
} | ||
} | ||
removePropertyWithCSSOM() | ||
testTargetColor('rgb(255, 192, 203)'); | ||
</script> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.