Skip to content

Commit

Permalink
Legacy scrollbar corner pseudo styles used despite standard scrollbar…
Browse files Browse the repository at this point in the history
… property usage

https://bugs.webkit.org/show_bug.cgi?id=258773

Reviewed by Simon Fraser.

This patch changes the code that retrieves the ScrollbarCorner pseudo styles to check that there's no standard
property usage.

* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-006-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-006-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-006.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-007-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-007-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-007.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-008-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-008-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-008.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-009-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-009-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-009.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-010-expected.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-010-ref.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-scrollbars/scrollbar-color-010.html: Added.
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::updateScrollCorner):
* Source/WebCore/rendering/RenderLayerScrollableArea.cpp:
(WebCore::RenderLayerScrollableArea::updateScrollCornerStyle):
* Source/WebCore/rendering/style/RenderStyle.h:
* Source/WebCore/rendering/style/RenderStyleInlines.h:
(WebCore::RenderStyle::usesStandardScrollbarStyle const):
(WebCore::RenderStyle::usesLegacyScrollbarStyle const):

Canonical link: https://commits.webkit.org/265990@main
  • Loading branch information
lukewarlow authored and Ahmad Saleem committed Jul 12, 2023
1 parent 36e066b commit 3ac44ba
Show file tree
Hide file tree
Showing 19 changed files with 337 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!doctype html>
<html>
<style>
.container {
scrollbar-gutter: stable;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
scrollbar-color: yellow blue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div id="one" class="container">
<div class="content"></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!doctype html>
<html>
<style>
.container {
scrollbar-gutter: stable;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
scrollbar-color: yellow blue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div id="one" class="container">
<div class="content"></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<html>
<title>CSS Scrollbars: scrollbar-color on scrollable areas correctly interacts with ::-webkit-scrollbar-corner</title>
<link rel="author" title="Luke Warlow" href="mailto:luke@warlow.dev" />
<link rel="match" href="scrollbar-color-006-ref.html" />
<link rel="help" href="https://drafts.csswg.org/css-scrollbars-1/" />
<style>
.container {
scrollbar-gutter: stable;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
scrollbar-color: yellow blue;
}

::-webkit-scrollbar-corner {
background-color: purple;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div id="one" class="container">
<div class="content"></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<html>
<style>
.container {
scrollbar-gutter: stable;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div id="one" class="container">
<div class="content"></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<html>
<style>
.container {
scrollbar-gutter: stable;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div id="one" class="container">
<div class="content"></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<html>
<title>CSS Scrollbars: scrollbar-color on scrollable areas correctly interacts with ::-webkit-scrollbar-corner on container</title>
<link rel="author" title="Luke Warlow" href="mailto:luke@warlow.dev" />
<link rel="match" href="scrollbar-color-007-ref.html" />
<link rel="help" href="https://drafts.csswg.org/css-scrollbars-1/" />
<style>
.container {
scrollbar-gutter: stable;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
scrollbar-color: yellow blue;
}

.container::-webkit-scrollbar-corner {
background-color: purple;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div id="one" class="container">
<div class="content"></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<html>
<style>
.container {
scrollbar-gutter: stable;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div id="one" class="container">
<div class="content"></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<html>
<style>
.container {
scrollbar-gutter: stable;
overflow: auto;
height: 200px;
min-width: 200px;
margin: 1px;
padding: 0px;
border: none;
background: deepskyblue;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div id="one" class="container">
<div class="content"></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<html>
<title>CSS Scrollbars: scrollbar-color on body correctly interacts with ::-webkit-scrollbar-corner on container</title>
<link rel="author" title="Luke Warlow" href="mailto:luke@warlow.dev" />
<link rel="match" href="scrollbar-color-008-ref.html" />
<link rel="help" href="https://drafts.csswg.org/css-scrollbars-1/" />
<style>
body {
scrollbar-color: yellow blue;
}

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

.container::-webkit-scrollbar-corner {
background-color: purple;
}

.content {
height: 300px;
width: 300px;
background: red;
}
</style>
<div id="one" class="container">
<div class="content"></div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<style>
:root {
scrollbar-color: yellow blue;
}

body {
overflow: scroll;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<style>
:root {
scrollbar-color: yellow blue;
}

body {
overflow: scroll;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<title>CSS Scrollbars: scrollbar-color on root correctly interacts with ::-webkit-scrollbar-corner</title>
<link rel="author" title="Luke Warlow" href="mailto:luke@warlow.dev" />
<link rel="match" href="scrollbar-color-009-ref.html" />
<link rel="help" href="https://drafts.csswg.org/css-scrollbars-1/" />
<style>
:root {
scrollbar-color: yellow blue;
}

body {
overflow: scroll;
}

::-webkit-scrollbar-corner {
background-color: purple;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<style>
:root {
scrollbar-color: yellow blue;
}

body {
overflow: scroll;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<style>
:root {
scrollbar-color: yellow blue;
}

body {
overflow: scroll;
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<title>CSS Scrollbars: scrollbar-color on root correctly interacts with ::-webkit-scrollbar-corner on body</title>
<link rel="author" title="Luke Warlow" href="mailto:luke@warlow.dev" />
<link rel="match" href="scrollbar-color-010-ref.html" />
<link rel="help" href="https://drafts.csswg.org/css-scrollbars-1/" />
<style>
:root {
scrollbar-color: yellow blue;
}

body {
overflow: scroll;
}

body::-webkit-scrollbar-corner {
background-color: purple;
}
</style>
15 changes: 12 additions & 3 deletions Source/WebCore/page/LocalFrameView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4513,10 +4513,19 @@ void LocalFrameView::updateScrollCorner()
RenderElement* renderer = nullptr;
std::unique_ptr<RenderStyle> cornerStyle;
IntRect cornerRect = scrollCornerRect();

if (!cornerRect.isEmpty()) {
Document* doc = m_frame->document();

auto usesStandardScrollbarStyle = [](auto& doc) {
if (!doc || !doc->documentElement())
return false;
if (!doc->documentElement()->renderer())
return false;

return doc->documentElement()->renderer()->style().usesStandardScrollbarStyle();
};

if (!(usesStandardScrollbarStyle(doc) || cornerRect.isEmpty())) {
// Try the <body> element first as a scroll corner source.
Document* doc = m_frame->document();
Element* body = doc ? doc->bodyOrFrameset() : nullptr;
if (body && body->renderer()) {
renderer = body->renderer();
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderLayerScrollableArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ void RenderLayerScrollableArea::updateScrollCornerStyle()
{
auto& renderer = m_layer.renderer();
RenderElement* actualRenderer = rendererForScrollbar(renderer);
auto corner = renderer.hasNonVisibleOverflow() ? actualRenderer->getUncachedPseudoStyle({ PseudoId::ScrollbarCorner }, &actualRenderer->style()) : nullptr;
auto corner = (renderer.hasNonVisibleOverflow() && !renderer.style().usesStandardScrollbarStyle()) ? actualRenderer->getUncachedPseudoStyle({ PseudoId::ScrollbarCorner }, &actualRenderer->style()) : nullptr;

if (!corner) {
clearScrollCorner();
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/rendering/style/RenderStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ class RenderStyle {

bool shouldPlaceVerticalScrollbarOnLeft() const;

inline bool usesStandardScrollbarStyle() const;
inline bool usesLegacyScrollbarStyle() const;

#if ENABLE(APPLE_PAY)
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/rendering/style/RenderStyleInlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,8 @@ constexpr LengthType RenderStyle::zeroLength() { return LengthType::Fixed; }
inline float RenderStyle::zoom() const { return m_nonInheritedData->rareData->zoom; }

// ignore non-standard ::-webkit-scrollbar when standard properties are in use
inline bool RenderStyle::usesLegacyScrollbarStyle() const { return hasPseudoStyle(PseudoId::Scrollbar) && scrollbarWidth() == ScrollbarWidth::Auto && !scrollbarColor().has_value(); }
inline bool RenderStyle::usesStandardScrollbarStyle() const { return scrollbarWidth() != ScrollbarWidth::Auto || scrollbarColor().has_value(); }
inline bool RenderStyle::usesLegacyScrollbarStyle() const { return hasPseudoStyle(PseudoId::Scrollbar) && !usesStandardScrollbarStyle(); }

#if ENABLE(APPLE_PAY)
inline ApplePayButtonStyle RenderStyle::applePayButtonStyle() const { return static_cast<ApplePayButtonStyle>(m_nonInheritedData->rareData->applePayButtonStyle); }
Expand Down

0 comments on commit 3ac44ba

Please sign in to comment.