Skip to content

Commit

Permalink
Add scrollbar width style to ScrollableAreaParameters
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259017

Reviewed by Simon Fraser.

This patch adds scrollbarWidthStyle to ScrollableAreaParameters.
This is wired up to ScrollerPairMac to replace the hardcoded ScrollbarWidth::Auto.
This will allow a follow up to fix the thin value having no affect with composited scrolling.

This patch has no behaviour changes.

* Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::setScrollingNodeScrollableAreaGeometry):
* Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h:
(WebCore::ScrollableAreaParameters::operator== const):
* Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h:
* Source/WebCore/page/scrolling/mac/ScrollerPairMac.mm:
(WebCore::ScrollerPairMac::scrollbarWidthStyle const):
* Source/WebCore/platform/ScrollTypes.h:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:

Canonical link: https://commits.webkit.org/265907@main
  • Loading branch information
lukewarlow authored and smfr committed Jul 10, 2023
1 parent 2054445 commit 4a4b325
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ void AsyncScrollingCoordinator::setScrollingNodeScrollableAreaGeometry(Scrolling
scrollParameters.horizontalNativeScrollbarVisibility = scrollableArea.horizontalNativeScrollbarVisibility();
scrollParameters.verticalNativeScrollbarVisibility = scrollableArea.verticalNativeScrollbarVisibility();
scrollParameters.useDarkAppearanceForScrollbars = scrollableArea.useDarkAppearanceForScrollbars();
scrollParameters.scrollbarWidthStyle = scrollableArea.scrollbarWidthStyle();

scrollingNode->setScrollableAreaParameters(scrollParameters);

Expand Down
5 changes: 4 additions & 1 deletion Source/WebCore/page/scrolling/ScrollingCoordinatorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ struct ScrollableAreaParameters {

bool useDarkAppearanceForScrollbars { false };

ScrollbarWidth scrollbarWidthStyle { ScrollbarWidth::Auto };

bool operator==(const ScrollableAreaParameters& other) const
{
return horizontalScrollElasticity == other.horizontalScrollElasticity
Expand All @@ -101,7 +103,8 @@ struct ScrollableAreaParameters {
&& allowsVerticalScrolling == other.allowsVerticalScrolling
&& horizontalNativeScrollbarVisibility == other.horizontalNativeScrollbarVisibility
&& verticalNativeScrollbarVisibility == other.verticalNativeScrollbarVisibility
&& useDarkAppearanceForScrollbars == other.useDarkAppearanceForScrollbars;
&& useDarkAppearanceForScrollbars == other.useDarkAppearanceForScrollbars
&& scrollbarWidthStyle == other.scrollbarWidthStyle;
}
};

Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ class WEBCORE_EXPORT ScrollingTreeScrollingNode : public ScrollingTreeNode {

OverscrollBehavior horizontalOverscrollBehavior() const { return m_scrollableAreaParameters.horizontalOverscrollBehavior; }
OverscrollBehavior verticalOverscrollBehavior() const { return m_scrollableAreaParameters.verticalOverscrollBehavior; }


ScrollbarWidth scrollbarWidthStyle() const { return m_scrollableAreaParameters.scrollbarWidthStyle; }

virtual String scrollbarStateForOrientation(ScrollbarOrientation) const { return ""_s; }

void scrollbarVisibilityDidChange(ScrollbarOrientation, bool);
Expand Down
3 changes: 1 addition & 2 deletions Source/WebCore/page/scrolling/mac/ScrollerPairMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ - (void)scrollerImpPair:(NSScrollerImpPair *)scrollerImpPair updateScrollerStyle

ScrollbarWidth ScrollerPairMac::scrollbarWidthStyle() const
{
// FIXME: This should be based on the element style. See <https://webkit.org/b/257430>
return ScrollbarWidth::Auto;
return m_scrollingNode.scrollbarWidthStyle();
}

ScrollerPairMac::Values ScrollerPairMac::valuesForOrientation(ScrollbarOrientation orientation)
Expand Down
9 changes: 9 additions & 0 deletions Source/WebCore/platform/ScrollTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,13 @@ template<> struct EnumTraits<WebCore::ScrollbarOrientation> {
WebCore::ScrollbarOrientation::Vertical
>;
};

template<> struct EnumTraits<WebCore::ScrollbarWidth> {
using values = EnumValues<
WebCore::ScrollbarWidth,
WebCore::ScrollbarWidth::Auto,
WebCore::ScrollbarWidth::Thin,
WebCore::ScrollbarWidth::None
>;
};
} // namespace WTF
8 changes: 8 additions & 0 deletions Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,13 @@ header: <WebCore/ScrollTypes.h>
ReplacedByCustomScrollbar
};

header: <WebCore/ScrollTypes.h>
[CustomHeader] enum class WebCore::ScrollbarWidth : uint8_t {
Auto,
Thin,
None
};

header: <WebCore/ScrollingCoordinatorTypes.h>
[CustomHeader] struct WebCore::ScrollableAreaParameters {
WebCore::ScrollElasticity horizontalScrollElasticity;
Expand All @@ -1993,6 +2000,7 @@ header: <WebCore/ScrollingCoordinatorTypes.h>
WebCore::NativeScrollbarVisibility horizontalNativeScrollbarVisibility;
WebCore::NativeScrollbarVisibility verticalNativeScrollbarVisibility;
bool useDarkAppearanceForScrollbars;
WebCore::ScrollbarWidth scrollbarWidthStyle;
};

header: <WebCore/ScrollingCoordinatorTypes.h>
Expand Down

0 comments on commit 4a4b325

Please sign in to comment.