Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Scrollbar doesn't update on CSS color-scheme change
https://bugs.webkit.org/show_bug.cgi?id=244494

Reviewed by Aditya Keerthi.

The color-scheme property is now diffed and triggers
invalidateScrollbars on scrollable areas.

invalidateScrollbars also now calls invalidateScrollCorners.

This causes the scrollbar and scroll corner to correctly rerender without
hovering or invalidating through other means. When UI Side Compositing is
disabled.

* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-1-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-1-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-1.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-2-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-2-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-2.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-3-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-3-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-3.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-4-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-4-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-scheme-dynamic-4.html: Added.
* Source/WebCore/platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::invalidateScrollbars):
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::styleDidChange):

Canonical link: https://commits.webkit.org/266176@main
  • Loading branch information
lukewarlow authored and Ahmad Saleem committed Jul 20, 2023
1 parent b64ff89 commit 044d44c
Show file tree
Hide file tree
Showing 14 changed files with 405 additions and 0 deletions.
@@ -0,0 +1,34 @@
<!doctype html>
<style>
:root {
color-scheme: dark;
}
body {
display: flex;
flex-wrap: wrap;
width: 200vw;
height: 200vh;
}

.container {
scrollbar-gutter: stable;
flex: 0 0;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>

<div class="container">
<div class="content"></div>
</div>
@@ -0,0 +1,34 @@
<!doctype html>
<style>
:root {
color-scheme: dark;
}
body {
display: flex;
flex-wrap: wrap;
width: 200vw;
height: 200vh;
}

.container {
scrollbar-gutter: stable;
flex: 0 0;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>

<div class="container">
<div class="content"></div>
</div>
@@ -0,0 +1,46 @@
<!doctype html>
<html class="reftest-wait">
<title>Dynamically set color-scheme and ensure scrollbars update</title>
<link rel="author" title="Luke Warlow" href="mailto:luke@warlow.dev" />
<link rel="help" href="https://drafts.csswg.org/css-scrollbars/#valdef-scrollbar-color-auto" />
<link rel="match" href="scrollbar-color-scheme-dynamic-1-ref.html" />
<script src="/common/reftest-wait.js"></script>
<style>
:root {
color-scheme: light;
}
body {
display: flex;
flex-wrap: wrap;
width: 200vw;
height: 200vh;
}

.container {
scrollbar-gutter: stable;
overflow: auto;
flex: 0 0;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div class="container">
<div class="content"></div>
</div>
<script>
requestAnimationFrame(() => requestAnimationFrame(() => {
document.documentElement.style.colorScheme = 'dark';

takeScreenshot();
}));
</script>
@@ -0,0 +1,23 @@
<!doctype html>
<style>
:root {
color-scheme: dark;
}
body {
display: flex;
flex-wrap: wrap;
overflow: scroll;
}
.container {
scrollbar-gutter: stable;
overflow: scroll;
flex: 0 0;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}
</style>
<div class="container"></div>
@@ -0,0 +1,23 @@
<!doctype html>
<style>
:root {
color-scheme: dark;
}
body {
display: flex;
flex-wrap: wrap;
overflow: scroll;
}
.container {
scrollbar-gutter: stable;
overflow: scroll;
flex: 0 0;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}
</style>
<div class="container"></div>
@@ -0,0 +1,36 @@
<!doctype html>
<html class="reftest-wait">
<title>Dynamically set color-scheme and ensure viewport scrollbars update</title>
<link rel="author" title="Luke Warlow" href="mailto:luke@warlow.dev" />
<link rel="help" href="https://drafts.csswg.org/css-scrollbars/#valdef-scrollbar-color-auto" />
<link rel="match" href="scrollbar-color-scheme-dynamic-2-ref.html" />
<script src="/common/reftest-wait.js"></script>
<style>
:root {
color-scheme: light;
}
body {
display: flex;
flex-wrap: wrap;
overflow: scroll;
}
.container {
scrollbar-gutter: stable;
overflow: scroll;
flex: 0 0;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}
</style>
<div class="container"></div>
<script>
requestAnimationFrame(() => requestAnimationFrame(() => {
document.documentElement.style.colorScheme = 'dark';

takeScreenshot();
}));
</script>
@@ -0,0 +1,35 @@
<!doctype html>
<style>
:root {
color-scheme: light;
}
body {
display: flex;
flex-wrap: wrap;
width: 200vw;
height: 200vh;
}

.container {
color-scheme: dark;
scrollbar-gutter: stable;
flex: 0 0;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>

<div class="container">
<div class="content"></div>
</div>
@@ -0,0 +1,35 @@
<!doctype html>
<style>
:root {
color-scheme: light;
}
body {
display: flex;
flex-wrap: wrap;
width: 200vw;
height: 200vh;
}

.container {
color-scheme: dark;
scrollbar-gutter: stable;
flex: 0 0;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>

<div class="container">
<div class="content"></div>
</div>
@@ -0,0 +1,46 @@
<!doctype html>
<html class="reftest-wait">
<title>Dynamically set color-scheme and ensure scrollbars update</title>
<link rel="author" title="Luke Warlow" href="mailto:luke@warlow.dev" />
<link rel="help" href="https://drafts.csswg.org/css-scrollbars/#valdef-scrollbar-color-auto" />
<link rel="match" href="scrollbar-color-scheme-dynamic-3-ref.html" />
<script src="/common/reftest-wait.js"></script>
<style>
:root {
color-scheme: light;
}
body {
display: flex;
flex-wrap: wrap;
width: 200vw;
height: 200vh;
}

.container {
scrollbar-gutter: stable;
overflow: auto;
flex: 0 0;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div class="container">
<div class="content"></div>
</div>
<script>
requestAnimationFrame(() => requestAnimationFrame(() => {
document.querySelector(".container").style.colorScheme = 'dark';

takeScreenshot();
}));
</script>
@@ -0,0 +1,24 @@
<!doctype html>
<style>
:root {
color-scheme: light;
}
body {
display: flex;
flex-wrap: wrap;
overflow: scroll;
}
.container {
color-scheme: dark;
scrollbar-gutter: stable;
overflow: scroll;
flex: 0 0;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}
</style>
<div class="container"></div>
@@ -0,0 +1,24 @@
<!doctype html>
<style>
:root {
color-scheme: light;
}
body {
display: flex;
flex-wrap: wrap;
overflow: scroll;
}
.container {
color-scheme: dark;
scrollbar-gutter: stable;
overflow: scroll;
flex: 0 0;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}
</style>
<div class="container"></div>

0 comments on commit 044d44c

Please sign in to comment.