forked from LadybirdBrowser/ladybird
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Invalidate layout if pseudo-element style changes
Pseudo-elements' style is only computed while building the layout tree. This meant that previously, they would not have their style recomputed in some cases. (Such as when :hover is applied to an ancestor.) Now, when recomputing an element's style, we also return a full invalidation if one or more pseudo-elements would exist either before or after style recomputation. This heuristic produces some false positives, but no false negatives. Because pseudo-elements' style is computed during layout building, any computation done here is then thrown away. So this approach minimises the amount of wasted style computation. Plus it's simple, until we have data on what approach would be faster. This fixes the Acid2 nose becoming blue when the .nose div is hovered.
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
Tests/LibWeb/Text/expected/css/update-pseudo-elements-on-hover.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,3 @@ | ||
Hi Not hovering: 16 | ||
Hovering: 78 | ||
Not hovering: 16 |
33 changes: 33 additions & 0 deletions
33
Tests/LibWeb/Text/input/css/update-pseudo-elements-on-hover.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,33 @@ | ||
<!doctype html> | ||
<style> | ||
.outer { | ||
height: 100px; | ||
} | ||
.inner { | ||
display: inline-block; | ||
} | ||
.inner::before { | ||
content: "Hi"; | ||
background-color: red; | ||
} | ||
.outer:hover .inner::before { | ||
content: "Long text"; | ||
background-color: lime; | ||
} | ||
</style> | ||
<script src="../include.js"></script> | ||
<div class="outer"><div class="inner"></div></div> | ||
<script> | ||
test(() => { | ||
const inner = document.querySelector('.inner'); | ||
println('Not hovering: ' + inner.clientWidth); | ||
|
||
// Move mouse over .outer | ||
internals.movePointerTo(80, 80); | ||
println('Hovering: ' + inner.clientWidth); | ||
|
||
// Move mouse away again | ||
internals.movePointerTo(200, 200); | ||
println('Not hovering: ' + inner.clientWidth); | ||
}); | ||
</script> |
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