Skip to content
Permalink
Browse files
[GTK] WebKit browser scrollbars not always correctly displayed if ove…
…rlay scrollbars are disabled

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

Patch by Michael Catanzaro <mcatanzaro@gnome.org> on 2022-02-11
Reviewed by Carlos Garcia Campos.

If overlay scrollbars are disabled, and there is not enough content for the page to be
scrollable, and scrollbars are forced using overflow:scroll, then we currently fail to
paint the scrollbars properly. At minimum, we need to paint the scrollbar background, which
is what the macOS port does. Do so.

In the future, we might want to additionally paint the rest of the scrollbars, similar to
the GTK_POLICY_ALWAYS scrollbar policy type, but this would require more work.

* platform/adwaita/ScrollbarThemeAdwaita.cpp:
(WebCore::ScrollbarThemeAdwaita::paint):
* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarThemeGtk::paint):


Canonical link: https://commits.webkit.org/247131@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289620 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
mcatanzaro authored and webkit-commit-queue committed Feb 11, 2022
1 parent 4378ecf commit 905068e504c5a021410d3871a85ec04cb6d9d9e1
Showing 3 changed files with 36 additions and 14 deletions.
@@ -1,3 +1,23 @@
2022-02-11 Michael Catanzaro <mcatanzaro@gnome.org>

[GTK] WebKit browser scrollbars not always correctly displayed if overlay scrollbars are disabled
https://bugs.webkit.org/show_bug.cgi?id=234874

Reviewed by Carlos Garcia Campos.

If overlay scrollbars are disabled, and there is not enough content for the page to be
scrollable, and scrollbars are forced using overflow:scroll, then we currently fail to
paint the scrollbars properly. At minimum, we need to paint the scrollbar background, which
is what the macOS port does. Do so.

In the future, we might want to additionally paint the rest of the scrollbars, similar to
the GTK_POLICY_ALWAYS scrollbar policy type, but this would require more work.

* platform/adwaita/ScrollbarThemeAdwaita.cpp:
(WebCore::ScrollbarThemeAdwaita::paint):
* platform/gtk/ScrollbarThemeGtk.cpp:
(WebCore::ScrollbarThemeGtk::paint):

2022-02-11 Antti Koivisto <antti@apple.com>

[CSS Container Queries] Implement container name matching
@@ -117,7 +117,7 @@ bool ScrollbarThemeAdwaita::paint(Scrollbar& scrollbar, GraphicsContext& graphic
if (graphicsContext.paintingDisabled())
return false;

if (!scrollbar.enabled())
if (!scrollbar.enabled() && usesOverlayScrollbars())
return true;

IntRect rect = scrollbar.frameRect();
@@ -331,7 +331,7 @@ bool ScrollbarThemeGtk::paint(Scrollbar& scrollbar, GraphicsContext& graphicsCon
if (graphicsContext.paintingDisabled())
return false;

if (!scrollbar.enabled())
if (!scrollbar.enabled() && usesOverlayScrollbars())
return true;

double opacity = scrollbar.hoveredPart() == NoPart ? scrollbar.opacity() : 1;
@@ -376,18 +376,20 @@ bool ScrollbarThemeGtk::paint(Scrollbar& scrollbar, GraphicsContext& graphicsCon
preferredSize += scrollbarGadget.preferredSize() - scrollbarGadget.minimumSize();

FloatRect contentsRect(rect);
// When using overlay scrollbars we always claim the size of the scrollbar when hovered, so when
// drawing the indicator we need to adjust the rectangle to its actual size in indicator mode.
if (scrollbar.orientation() == ScrollbarOrientation::Vertical) {
if (rect.width() != preferredSize.width()) {
if (!scrollbar.scrollableArea().shouldPlaceVerticalScrollbarOnLeft())
contentsRect.move(std::abs(rect.width() - preferredSize.width()), 0);
contentsRect.setWidth(preferredSize.width());
}
} else {
if (rect.height() != preferredSize.height()) {
contentsRect.move(0, std::abs(rect.height() - preferredSize.height()));
contentsRect.setHeight(preferredSize.height());
if (usesOverlayScrollbars()) {
// When using overlay scrollbars we always claim the size of the scrollbar when hovered, so when
// drawing the indicator we need to adjust the rectangle to its actual size in indicator mode.
if (scrollbar.orientation() == ScrollbarOrientation::Vertical) {
if (rect.width() != preferredSize.width()) {
if (!scrollbar.scrollableArea().shouldPlaceVerticalScrollbarOnLeft())
contentsRect.move(std::abs(rect.width() - preferredSize.width()), 0);
contentsRect.setWidth(preferredSize.width());
}
} else {
if (rect.height() != preferredSize.height()) {
contentsRect.move(0, std::abs(rect.height() - preferredSize.height()));
contentsRect.setHeight(preferredSize.height());
}
}
}

0 comments on commit 905068e

Please sign in to comment.