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
:dir pseudo class doesn't invalidate after removing dir content attri…
…bute from document element https://bugs.webkit.org/show_bug.cgi?id=255568 Reviewed by Tim Nguyen and Antti Koivisto. The bug was caused by dirAttributeChanged not calling HTMLElement::dirAttributeChanged not updating the effective directionality state when removing a content attribute. Fixed the bug by recursively invalidating the pseudo class state using updateEffectiveDirectionality, which is now updated to take std::optional<TextDirection>. Also removed redundant calls to HTMLElement::setUsesEffectiveTextDirection(true) in HTMLElement::dirAttributeChanged. * LayoutTests/fast/css/dir-ltr-removal-expected.html: Added. * LayoutTests/fast/css/dir-ltr-removal.html: Added. * LayoutTests/fast/css/dir-rtl-removal-expected.html: Added. * LayoutTests/fast/css/dir-rtl-removal.html: Added. * Source/WebCore/html/HTMLElement.cpp: (WebCore::HTMLElement::dirAttributeChanged): (WebCore::HTMLElement::updateEffectiveDirectionality): Canonical link: https://commits.webkit.org/263357@main
- Loading branch information
Showing
6 changed files
with
66 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html dir="rtl"> | ||
<body> | ||
<div class="box"></div> | ||
<style> | ||
body { text-align: left; } | ||
.box { width: 100px; height: 100px; background: green; display: inline-block; } | ||
</style> | ||
</body> | ||
</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,18 @@ | ||
<!DOCTYPE html> | ||
<html dir="rtl"> | ||
<body> | ||
<div id="element" dir="ltr" class="box"></div><div id="host" dir="ltr"></div> | ||
<style> | ||
body { text-align: left; } | ||
.box { width: 50px; height: 100px; background: green; display: inline-block; } | ||
.box:dir(ltr) { background: red; } | ||
#host { display: inline-block; } | ||
</style> | ||
<script> | ||
host.attachShadow({mode: 'closed'}).innerHTML = '<div class="box"></div><style>.box { width: 50px; height: 100px; background: green; } .box:dir(ltr) { background: red; }</style>'; | ||
element.getBoundingClientRect(); | ||
element.removeAttribute('dir'); | ||
host.removeAttribute('dir'); | ||
</script> | ||
</body> | ||
</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,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<div class="box"></div> | ||
<style> | ||
.box { width: 100px; height: 100px; background: green; } | ||
</style> | ||
</body> | ||
</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,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<div id="element" class="box"></div> | ||
<div id="host" class="box"></div> | ||
<style> | ||
.box { width: 100px; height: 50px; background: green; } | ||
.box:dir(rtl) { background: red; } | ||
</style> | ||
<script> | ||
document.documentElement.setAttribute('dir', 'rtl'); | ||
host.attachShadow({mode: 'closed'}).innerHTML = '<div class="box"></div><style>.box { width: 100px; height: 50px; background: green; } .box:dir(rtl) { background: red; }</style>' | ||
element.getBoundingClientRect(); | ||
document.documentElement.removeAttribute('dir'); | ||
</script> | ||
</body> | ||
</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