Skip to content

Commit

Permalink
[UI-side compositing] NSScrollerImps are still created in the web pro…
Browse files Browse the repository at this point in the history
…cess (triggering CATransactions)

https://bugs.webkit.org/show_bug.cgi?id=258369
rdar://109689491

Reviewed by Simon Fraser.

With UI-side compositing, NSScrollerImps are now kept in the UI-process for all scrollbars
except for RenderListBox scrollbars. To prevent the unnecessary creation of NSScrollerImps
in the web process in ScrollbarThemeMac::registerScrollbar, check if the scrollbar is one
of a RenderListBox and if we have a RemoteScrollbarsController.

* Source/WebCore/platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::shouldRegisterScrollbars const):
* Source/WebCore/platform/ScrollableArea.h:
* Source/WebCore/platform/Scrollbar.cpp:
(WebCore::Scrollbar::shouldRegisterScrollbar const):
* Source/WebCore/platform/Scrollbar.h:
* Source/WebCore/platform/ScrollbarsController.h:
(WebCore::ScrollbarsController::shouldRegisterScrollbars const):
* Source/WebCore/platform/mac/ScrollbarThemeMac.mm:
(WebCore::ScrollbarThemeMac::registerScrollbar):
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollbarsController.h:

Canonical link: https://commits.webkit.org/265731@main
  • Loading branch information
nmoucht committed Jul 3, 2023
1 parent dd9d402 commit 1b57a2e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Source/WebCore/platform/Scrollbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,4 +528,9 @@ float Scrollbar::deviceScaleFactor() const
return m_scrollableArea.deviceScaleFactor();
}

bool Scrollbar::shouldRegisterScrollbar() const
{
return m_scrollableArea.scrollbarsController().shouldRegisterScrollbars();
}

} // namespace WebCore
2 changes: 2 additions & 0 deletions Source/WebCore/platform/Scrollbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class Scrollbar : public Widget {

float deviceScaleFactor() const;

bool shouldRegisterScrollbar() const;

protected:
Scrollbar(ScrollableArea&, ScrollbarOrientation, ScrollbarWidth, ScrollbarTheme* = nullptr, bool isCustomScrollbar = false);

Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/platform/ScrollbarsController.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class ScrollbarsController {
WEBCORE_EXPORT virtual void setScrollbarVisibilityState(ScrollbarOrientation, bool) { }

WEBCORE_EXPORT virtual bool shouldDrawIntoScrollbarLayer(Scrollbar&) const { return true; }
WEBCORE_EXPORT virtual bool shouldRegisterScrollbars() const { return true; }

private:
ScrollableArea& m_scrollableArea;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/mac/ScrollbarThemeMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ + (void)registerAsObserver

void ScrollbarThemeMac::registerScrollbar(Scrollbar& scrollbar)
{
if (scrollbar.isCustomScrollbar())
if (scrollbar.isCustomScrollbar() || !scrollbar.shouldRegisterScrollbar())
return;

bool isHorizontal = scrollbar.orientation() == ScrollbarOrientation::Horizontal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class RemoteScrollbarsController final : public WebCore::ScrollbarsController {

void setScrollbarVisibilityState(WebCore::ScrollbarOrientation, bool) final;
bool shouldDrawIntoScrollbarLayer(WebCore::Scrollbar&) const final;
bool shouldRegisterScrollbars() const final { return scrollableArea().isListBox(); }

private:
bool m_horizontalOverlayScrollbarIsVisible { false };
Expand Down

0 comments on commit 1b57a2e

Please sign in to comment.