Skip to content

Commit 502be05

Browse files
committed
Remove unsafeGet from ScrollingTreeScrollingNodeDelegate
https://bugs.webkit.org/show_bug.cgi?id=301941 Reviewed by Chris Dumez. Apply https://github.com/WebKit/WebKit/wiki/Safer-CPP-Guidelines Canonical link: https://commits.webkit.org/302583@main
1 parent 9c7c6b9 commit 502be05

File tree

7 files changed

+64
-63
lines changed

7 files changed

+64
-63
lines changed

Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,6 @@ page/scrolling/ScrollingCoordinator.cpp
621621
[ Mac ] page/scrolling/ScrollingTreeGestureState.cpp
622622
[ Mac ] page/scrolling/ThreadedScrollingCoordinator.cpp
623623
[ Mac ] page/scrolling/mac/ScrollingCoordinatorMac.mm
624-
[ Mac ] page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm
625624
page/text-extraction/TextExtraction.cpp
626625
page/writing-tools/WritingToolsController.mm
627626
platform/DragImage.cpp

Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,27 @@ ScrollingTreeScrollingNodeDelegate::~ScrollingTreeScrollingNodeDelegate() = defa
4545

4646
RefPtr<ScrollingTree> ScrollingTreeScrollingNodeDelegate::scrollingTree() const
4747
{
48-
return protectedScrollingNode()->scrollingTree();
48+
return scrollingNode()->scrollingTree();
4949
}
5050

5151
FloatPoint ScrollingTreeScrollingNodeDelegate::lastCommittedScrollPosition() const
5252
{
53-
return protectedScrollingNode()->lastCommittedScrollPosition();
53+
return scrollingNode()->lastCommittedScrollPosition();
5454
}
5555

5656
FloatSize ScrollingTreeScrollingNodeDelegate::totalContentsSize()
5757
{
58-
return protectedScrollingNode()->totalContentsSize();
58+
return scrollingNode()->totalContentsSize();
5959
}
6060

6161
FloatSize ScrollingTreeScrollingNodeDelegate::reachableContentsSize()
6262
{
63-
return protectedScrollingNode()->reachableContentsSize();
63+
return scrollingNode()->reachableContentsSize();
6464
}
6565

6666
IntPoint ScrollingTreeScrollingNodeDelegate::scrollOrigin() const
6767
{
68-
return protectedScrollingNode()->scrollOrigin();
68+
return scrollingNode()->scrollOrigin();
6969
}
7070

7171
} // namespace WebCore

Source/WebCore/page/scrolling/ScrollingTreeScrollingNodeDelegate.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ class ScrollingTreeScrollingNodeDelegate {
3939
WEBCORE_EXPORT explicit ScrollingTreeScrollingNodeDelegate(ScrollingTreeScrollingNode&);
4040
WEBCORE_EXPORT virtual ~ScrollingTreeScrollingNodeDelegate();
4141

42-
RefPtr<ScrollingTreeScrollingNode> protectedScrollingNode() const { return m_scrollingNode.get(); }
43-
ScrollingTreeScrollingNode& scrollingNode() { return *protectedScrollingNode().unsafeGet(); }
44-
const ScrollingTreeScrollingNode& scrollingNode() const { return *protectedScrollingNode().unsafeGet(); }
45-
42+
Ref<ScrollingTreeScrollingNode> scrollingNode() { return m_scrollingNode.get().releaseNonNull(); }
43+
Ref<const ScrollingTreeScrollingNode> scrollingNode() const { return m_scrollingNode.get().releaseNonNull(); }
44+
4645
virtual bool startAnimatedScrollToPosition(FloatPoint) = 0;
4746
virtual void stopAnimatedScroll() = 0;
4847

@@ -72,18 +71,18 @@ class ScrollingTreeScrollingNodeDelegate {
7271
WEBCORE_EXPORT FloatSize reachableContentsSize();
7372
WEBCORE_EXPORT IntPoint scrollOrigin() const;
7473

75-
FloatPoint currentScrollPosition() const { return protectedScrollingNode()->currentScrollPosition(); }
76-
FloatPoint minimumScrollPosition() const { return protectedScrollingNode()->minimumScrollPosition(); }
77-
FloatPoint maximumScrollPosition() const { return protectedScrollingNode()->maximumScrollPosition(); }
74+
FloatPoint currentScrollPosition() const { return scrollingNode()->currentScrollPosition(); }
75+
FloatPoint minimumScrollPosition() const { return scrollingNode()->minimumScrollPosition(); }
76+
FloatPoint maximumScrollPosition() const { return scrollingNode()->maximumScrollPosition(); }
7877

79-
FloatSize scrollableAreaSize() const { return protectedScrollingNode()->scrollableAreaSize(); }
80-
FloatSize totalContentsSize() const { return protectedScrollingNode()->totalContentsSize(); }
78+
FloatSize scrollableAreaSize() const { return scrollingNode()->scrollableAreaSize(); }
79+
FloatSize totalContentsSize() const { return scrollingNode()->totalContentsSize(); }
8180

82-
bool allowsHorizontalScrolling() const { return protectedScrollingNode()->allowsHorizontalScrolling(); }
83-
bool allowsVerticalScrolling() const { return protectedScrollingNode()->allowsVerticalScrolling(); }
81+
bool allowsHorizontalScrolling() const { return scrollingNode()->allowsHorizontalScrolling(); }
82+
bool allowsVerticalScrolling() const { return scrollingNode()->allowsVerticalScrolling(); }
8483

85-
ScrollElasticity horizontalScrollElasticity() const { return protectedScrollingNode()->horizontalScrollElasticity(); }
86-
ScrollElasticity verticalScrollElasticity() const { return protectedScrollingNode()->verticalScrollElasticity(); }
84+
ScrollElasticity horizontalScrollElasticity() const { return scrollingNode()->horizontalScrollElasticity(); }
85+
ScrollElasticity verticalScrollElasticity() const { return scrollingNode()->verticalScrollElasticity(); }
8786

8887
private:
8988
ThreadSafeWeakPtr<ScrollingTreeScrollingNode> m_scrollingNode; // m_scrollingNode is expected never be null

Source/WebCore/page/scrolling/ThreadedScrollingTreeScrollingNodeDelegate.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void ThreadedScrollingTreeScrollingNodeDelegate::updateUserScrollInProgressForEv
7474
m_scrollController.updateGestureInProgressState(wheelEvent);
7575
bool isInUserScroll = m_scrollController.isUserScrollInProgress();
7676
if (isInUserScroll != wasInUserScroll)
77-
protectedScrollingNode()->setUserScrollInProgress(isInUserScroll);
77+
scrollingNode()->setUserScrollInProgress(isInUserScroll);
7878
}
7979

8080
bool ThreadedScrollingTreeScrollingNodeDelegate::startAnimatedScrollToPosition(FloatPoint destinationPosition)
@@ -97,20 +97,20 @@ void ThreadedScrollingTreeScrollingNodeDelegate::serviceScrollAnimation(Monotoni
9797
std::unique_ptr<ScrollingEffectsControllerTimer> ThreadedScrollingTreeScrollingNodeDelegate::createTimer(Function<void()>&& function)
9898
{
9999
// This is only used for a scroll snap timer.
100-
return WTF::makeUnique<ScrollingEffectsControllerTimer>(RunLoop::currentSingleton(), [function = WTFMove(function), protectedNode = Ref { scrollingNode() }] {
101-
Locker locker { protectedNode->scrollingTree()->treeLock() };
100+
return WTF::makeUnique<ScrollingEffectsControllerTimer>(RunLoop::currentSingleton(), [function = WTFMove(function), scrollingNode = this->scrollingNode()] {
101+
Locker locker { scrollingNode->scrollingTree()->treeLock() };
102102
function();
103103
});
104104
}
105105

106106
void ThreadedScrollingTreeScrollingNodeDelegate::startAnimationCallback(ScrollingEffectsController&)
107107
{
108-
protectedScrollingNode()->setScrollAnimationInProgress(true);
108+
scrollingNode()->setScrollAnimationInProgress(true);
109109
}
110110

111111
void ThreadedScrollingTreeScrollingNodeDelegate::stopAnimationCallback(ScrollingEffectsController&)
112112
{
113-
protectedScrollingNode()->setScrollAnimationInProgress(false);
113+
scrollingNode()->setScrollAnimationInProgress(false);
114114
}
115115

116116
bool ThreadedScrollingTreeScrollingNodeDelegate::allowsHorizontalScrolling() const
@@ -125,7 +125,7 @@ bool ThreadedScrollingTreeScrollingNodeDelegate::allowsVerticalScrolling() const
125125

126126
void ThreadedScrollingTreeScrollingNodeDelegate::immediateScrollBy(const FloatSize& delta, ScrollClamping clamping)
127127
{
128-
protectedScrollingNode()->scrollBy(delta, clamping);
128+
scrollingNode()->scrollBy(delta, clamping);
129129
}
130130

131131
void ThreadedScrollingTreeScrollingNodeDelegate::adjustScrollPositionToBoundsIfNecessary()
@@ -152,32 +152,32 @@ float ThreadedScrollingTreeScrollingNodeDelegate::pageScaleFactor() const
152152

153153
void ThreadedScrollingTreeScrollingNodeDelegate::willStartAnimatedScroll()
154154
{
155-
protectedScrollingNode()->willStartAnimatedScroll();
155+
scrollingNode()->willStartAnimatedScroll();
156156
}
157157

158158
void ThreadedScrollingTreeScrollingNodeDelegate::didStopAnimatedScroll()
159159
{
160-
protectedScrollingNode()->didStopAnimatedScroll();
160+
scrollingNode()->didStopAnimatedScroll();
161161
}
162162

163163
void ThreadedScrollingTreeScrollingNodeDelegate::willStartWheelEventScroll()
164164
{
165-
protectedScrollingNode()->willStartWheelEventScroll();
165+
scrollingNode()->willStartWheelEventScroll();
166166
}
167167

168168
void ThreadedScrollingTreeScrollingNodeDelegate::didStopWheelEventScroll()
169169
{
170-
protectedScrollingNode()->didStopWheelEventScroll();
170+
scrollingNode()->didStopWheelEventScroll();
171171
}
172172

173173
void ThreadedScrollingTreeScrollingNodeDelegate::willStartScrollSnapAnimation()
174174
{
175-
protectedScrollingNode()->setScrollSnapInProgress(true);
175+
scrollingNode()->setScrollSnapInProgress(true);
176176
}
177177

178178
void ThreadedScrollingTreeScrollingNodeDelegate::didStopScrollSnapAnimation()
179179
{
180-
protectedScrollingNode()->setScrollSnapInProgress(false);
180+
scrollingNode()->setScrollSnapInProgress(false);
181181
didStopAnimatedScroll();
182182
}
183183

@@ -196,7 +196,7 @@ void ThreadedScrollingTreeScrollingNodeDelegate::deferWheelEventTestCompletionFo
196196
return;
197197

198198
// Just use the scrolling node ID as the identifier, since we know this is coming from a ScrollingEffectsController associated with this node.
199-
scrollingTree()->deferWheelEventTestCompletionForReason(scrollingNode().scrollingNodeID(), reason);
199+
scrollingTree()->deferWheelEventTestCompletionForReason(scrollingNode()->scrollingNodeID(), reason);
200200
}
201201

202202
void ThreadedScrollingTreeScrollingNodeDelegate::removeWheelEventTestCompletionDeferralForReason(ScrollingNodeID, WheelEventTestMonitor::DeferReason reason) const
@@ -205,7 +205,7 @@ void ThreadedScrollingTreeScrollingNodeDelegate::removeWheelEventTestCompletionD
205205
return;
206206

207207
// Just use the scrolling node ID as the identifier, since we know this is coming from a ScrollingEffectsController associated with this node.
208-
scrollingTree()->removeWheelEventTestCompletionDeferralForReason(scrollingNode().scrollingNodeID(), reason);
208+
scrollingTree()->removeWheelEventTestCompletionDeferralForReason(scrollingNode()->scrollingNodeID(), reason);
209209
}
210210

211211
FloatPoint ThreadedScrollingTreeScrollingNodeDelegate::adjustedScrollPosition(const FloatPoint& position) const
@@ -230,7 +230,7 @@ void ThreadedScrollingTreeScrollingNodeDelegate::handleKeyboardScrollRequest(con
230230

231231
ScrollingNodeID ThreadedScrollingTreeScrollingNodeDelegate::scrollingNodeIDForTesting() const
232232
{
233-
return scrollingNode().scrollingNodeID();
233+
return scrollingNode()->scrollingNodeID();
234234
}
235235

236236

Source/WebCore/page/scrolling/coordinated/ScrollingTreeScrollingNodeDelegateCoordinated.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void ScrollingTreeScrollingNodeDelegateCoordinated::updateVisibleLengths()
4747

4848
bool ScrollingTreeScrollingNodeDelegateCoordinated::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
4949
{
50-
auto deferrer = ScrollingTreeWheelEventTestMonitorCompletionDeferrer { *scrollingTree(), scrollingNode().scrollingNodeID(), WheelEventTestMonitor::DeferReason::HandlingWheelEvent };
50+
auto deferrer = ScrollingTreeWheelEventTestMonitorCompletionDeferrer { *scrollingTree(), scrollingNode()->scrollingNodeID(), WheelEventTestMonitor::DeferReason::HandlingWheelEvent };
5151

5252
updateUserScrollInProgressForEvent(wheelEvent);
5353

Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
if (wasInMomentumPhase != m_inMomentumPhase)
138138
m_scrollerPair->setUsePresentationValues(m_inMomentumPhase);
139139

140-
auto deferrer = ScrollingTreeWheelEventTestMonitorCompletionDeferrer { *scrollingTree(), scrollingNode().scrollingNodeID(), WheelEventTestMonitor::DeferReason::HandlingWheelEvent };
140+
auto deferrer = ScrollingTreeWheelEventTestMonitorCompletionDeferrer { *scrollingTree(), scrollingNode()->scrollingNodeID(), WheelEventTestMonitor::DeferReason::HandlingWheelEvent };
141141

142142
updateUserScrollInProgressForEvent(wheelEvent);
143143

@@ -292,23 +292,23 @@
292292

293293
RectEdges<bool> ScrollingTreeScrollingNodeDelegateMac::edgePinnedState() const
294294
{
295-
return scrollingNode().edgePinnedState();
295+
return scrollingNode()->edgePinnedState();
296296
}
297297

298298
bool ScrollingTreeScrollingNodeDelegateMac::shouldRubberBandOnSide(BoxSide side) const
299299
{
300-
return scrollingNode().shouldRubberBandOnSide(side, edgePinnedState());
300+
return scrollingNode()->shouldRubberBandOnSide(side, edgePinnedState());
301301
}
302302

303303
void ScrollingTreeScrollingNodeDelegateMac::didStopRubberBandAnimation()
304304
{
305305
// Since the rubberband timer has stopped, totalContentsSizeForRubberBand can be synchronized with totalContentsSize.
306-
scrollingNode().setTotalContentsSizeForRubberBand(totalContentsSize());
306+
scrollingNode()->setTotalContentsSizeForRubberBand(totalContentsSize());
307307
}
308308

309309
void ScrollingTreeScrollingNodeDelegateMac::rubberBandingStateChanged(bool inRubberBand)
310310
{
311-
scrollingTree()->setRubberBandingInProgressForNode(scrollingNode().scrollingNodeID(), inRubberBand);
311+
scrollingTree()->setRubberBandingInProgressForNode(scrollingNode()->scrollingNodeID(), inRubberBand);
312312
}
313313

314314
void ScrollingTreeScrollingNodeDelegateMac::updateScrollbarPainters()

0 commit comments

Comments
 (0)