Skip to content

Commit d13ccff

Browse files
committed
[Safer CPP] Address UncountedLocalVars warnings under WebProcess/Plugins/PDF/
https://bugs.webkit.org/show_bug.cgi?id=290287 rdar://147691053 Reviewed by Chris Dumez. * Source/WebKit/SaferCPPExpectations/UncountedLocalVarsCheckerExpectations: * Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm: (WebKit::PDFPluginBase::~PDFPluginBase): * Source/WebKit/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm: (WebKit::PDFPluginTextAnnotation::createAnnotationElement): * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm: (WebKit::UnifiedPDFPlugin::createScrollingNodeIfNecessary): (WebKit::UnifiedPDFPlugin::didChangeIsInWindow): (WebKit::UnifiedPDFPlugin::updateOverflowControlsLayers): (WebKit::UnifiedPDFPlugin::positionOverflowControlsLayers): (WebKit::UnifiedPDFPlugin::invalidateScrollbarRect): (WebKit::UnifiedPDFPlugin::invalidateScrollCornerRect): (WebKit::UnifiedPDFPlugin::updateScrollingExtents): (WebKit::UnifiedPDFPlugin::requestScrollToPosition): (WebKit::UnifiedPDFPlugin::requestStartKeyboardScrollAnimation): (WebKit::UnifiedPDFPlugin::requestStopKeyboardScrollAnimation): Canonical link: https://commits.webkit.org/292583@main
1 parent 0308948 commit d13ccff

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

Source/WebKit/SaferCPPExpectations/UncountedLocalVarsCheckerExpectations

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ WebProcess/Network/webrtc/LibWebRTCNetworkManager.cpp
4444
WebProcess/Network/webrtc/LibWebRTCProvider.cpp
4545
WebProcess/Network/webrtc/WebMDNSRegister.cpp
4646
WebProcess/Notifications/WebNotificationManager.cpp
47-
WebProcess/Plugins/PDF/PDFPluginBase.mm
48-
WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
49-
WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
5047
WebProcess/Plugins/WebPluginInfoProvider.cpp
5148
WebProcess/Storage/WebSWClientConnection.cpp
5249
WebProcess/Storage/WebServiceWorkerProvider.cpp

Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
PDFPluginBase::~PDFPluginBase()
142142
{
143143
#if ENABLE(PDF_HUD)
144-
if (auto* page = m_frame ? m_frame->page() : nullptr)
144+
if (RefPtr page = m_frame ? m_frame->page() : nullptr)
145145
page->removePDFHUD(*this);
146146
#endif
147147

Source/WebKit/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#import <WebCore/CSSPropertyNames.h>
3636
#import <WebCore/ColorCocoa.h>
3737
#import <WebCore/ColorSerialization.h>
38+
#import <WebCore/Document.h>
3839
#import <WebCore/Event.h>
3940
#import <WebCore/EventNames.h>
4041
#import <WebCore/HTMLElement.h>
@@ -43,6 +44,7 @@
4344
#import <WebCore/HTMLTextAreaElement.h>
4445
#import <WebCore/KeyboardEvent.h>
4546
#import <WebCore/Page.h>
47+
#import <wtf/Ref.h>
4648

4749
namespace WebKit {
4850
using namespace WebCore;
@@ -79,11 +81,11 @@ static const String cssAlignmentValueForNSTextAlignment(NSTextAlignment alignmen
7981

8082
Ref<Element> PDFPluginTextAnnotation::createAnnotationElement()
8183
{
82-
Document& document = parent()->document();
84+
Ref document = parent()->document();
8385
RetainPtr textAnnotation = annotation();
8486
bool isMultiline = [textAnnotation isMultiline];
8587

86-
Ref element = downcast<HTMLTextFormControlElement>(document.createElement(isMultiline ? textareaTag : inputTag, false));
88+
Ref element = downcast<HTMLTextFormControlElement>(document->createElement(isMultiline ? textareaTag : inputTag, false));
8789
element->addEventListener(eventNames().keydownEvent, *eventListener(), false);
8890

8991
if (!textAnnotation)

Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,13 @@ static String mutationObserverNotificationString()
645645
#if ENABLE(SCROLLING_THREAD)
646646
m_scrollContainerLayer->setScrollingNodeID(*m_scrollingNodeID);
647647

648-
if (auto* layer = layerForHorizontalScrollbar())
648+
if (RefPtr layer = layerForHorizontalScrollbar())
649649
layer->setScrollingNodeID(*m_scrollingNodeID);
650650

651-
if (auto* layer = layerForVerticalScrollbar())
651+
if (RefPtr layer = layerForVerticalScrollbar())
652652
layer->setScrollingNodeID(*m_scrollingNodeID);
653653

654-
if (auto* layer = layerForScrollCorner())
654+
if (RefPtr layer = layerForScrollCorner())
655655
layer->setScrollingNodeID(*m_scrollingNodeID);
656656
#endif
657657

@@ -752,8 +752,8 @@ static String mutationObserverNotificationString()
752752
m_presentationController->updateIsInWindow(isInWindow);
753753

754754
if (!isInWindow) {
755-
auto& scrollingCoordinator = *page->scrollingCoordinator();
756-
scrollingCoordinator.scrollableAreaWillBeDetached(*this);
755+
RefPtr scrollingCoordinator = page->scrollingCoordinator();
756+
scrollingCoordinator->scrollableAreaWillBeDetached(*this);
757757
}
758758
}
759759

@@ -1528,11 +1528,11 @@ static String mutationObserverNotificationString()
15281528

15291529
layersChanged |= createOrDestroyLayer(m_layerForScrollCorner, needsScrollCornerLayer, "scroll corner"_s);
15301530

1531-
auto& scrollingCoordinator = *page->scrollingCoordinator();
1531+
RefPtr scrollingCoordinator = page->scrollingCoordinator();
15321532
if (horizontalScrollbarLayerChanged)
1533-
scrollingCoordinator.scrollableAreaScrollbarLayerDidChange(*this, ScrollbarOrientation::Horizontal);
1533+
scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(*this, ScrollbarOrientation::Horizontal);
15341534
if (verticalScrollbarLayerChanged)
1535-
scrollingCoordinator.scrollableAreaScrollbarLayerDidChange(*this, ScrollbarOrientation::Vertical);
1535+
scrollingCoordinator->scrollableAreaScrollbarLayerDidChange(*this, ScrollbarOrientation::Vertical);
15361536

15371537
return layersChanged;
15381538
}
@@ -1546,13 +1546,13 @@ static String mutationObserverNotificationString()
15461546
layer.setSize(scrollbarRect.size());
15471547
};
15481548

1549-
if (auto* layer = layerForHorizontalScrollbar())
1549+
if (RefPtr layer = layerForHorizontalScrollbar())
15501550
positionScrollbarLayer(*layer, viewRelativeHorizontalScrollbarRect());
15511551

1552-
if (auto* layer = layerForVerticalScrollbar())
1552+
if (RefPtr layer = layerForVerticalScrollbar())
15531553
positionScrollbarLayer(*layer, viewRelativeVerticalScrollbarRect());
15541554

1555-
if (auto* layer = layerForScrollCorner()) {
1555+
if (RefPtr layer = layerForScrollCorner()) {
15561556
auto cornerRect = viewRelativeScrollCornerRect();
15571557
layer->setPosition(cornerRect.location());
15581558
layer->setSize(cornerRect.size());
@@ -1564,7 +1564,7 @@ static String mutationObserverNotificationString()
15641564
void UnifiedPDFPlugin::invalidateScrollbarRect(WebCore::Scrollbar& scrollbar, const WebCore::IntRect& rect)
15651565
{
15661566
if (&scrollbar == m_verticalScrollbar.get()) {
1567-
if (auto* layer = layerForVerticalScrollbar()) {
1567+
if (RefPtr layer = layerForVerticalScrollbar()) {
15681568
layer->setNeedsDisplayInRect(rect);
15691569
return;
15701570
}
@@ -1573,7 +1573,7 @@ static String mutationObserverNotificationString()
15731573
}
15741574

15751575
if (&scrollbar == m_horizontalScrollbar.get()) {
1576-
if (auto* layer = layerForHorizontalScrollbar()) {
1576+
if (RefPtr layer = layerForHorizontalScrollbar()) {
15771577
layer->setNeedsDisplayInRect(rect);
15781578
return;
15791579
}
@@ -1583,7 +1583,7 @@ static String mutationObserverNotificationString()
15831583

15841584
void UnifiedPDFPlugin::invalidateScrollCornerRect(const WebCore::IntRect& rect)
15851585
{
1586-
if (auto* layer = layerForScrollCorner()) {
1586+
if (RefPtr layer = layerForScrollCorner()) {
15871587
layer->setNeedsDisplayInRect(rect);
15881588
return;
15891589
}
@@ -1689,8 +1689,8 @@ static String mutationObserverNotificationString()
16891689
setCurrentScrollType(oldScrollType);
16901690
}
16911691

1692-
auto& scrollingCoordinator = *page->scrollingCoordinator();
1693-
scrollingCoordinator.setScrollingNodeScrollableAreaGeometry(m_scrollingNodeID, *this);
1692+
RefPtr scrollingCoordinator = page->scrollingCoordinator();
1693+
scrollingCoordinator->setScrollingNodeScrollableAreaGeometry(m_scrollingNodeID, *this);
16941694

16951695
m_presentationController->updateForCurrentScrollability(computeScrollability());
16961696

@@ -1710,8 +1710,8 @@ static String mutationObserverNotificationString()
17101710
if (!page)
17111711
return false;
17121712

1713-
auto& scrollingCoordinator = *page->scrollingCoordinator();
1714-
return scrollingCoordinator.requestScrollToPosition(*this, position, options);
1713+
RefPtr scrollingCoordinator = page->scrollingCoordinator();
1714+
return scrollingCoordinator->requestScrollToPosition(*this, position, options);
17151715
}
17161716

17171717
bool UnifiedPDFPlugin::requestStartKeyboardScrollAnimation(const KeyboardScroll& scrollData)
@@ -1720,8 +1720,8 @@ static String mutationObserverNotificationString()
17201720
if (!page)
17211721
return false;
17221722

1723-
auto& scrollingCoordinator = *page->scrollingCoordinator();
1724-
return scrollingCoordinator.requestStartKeyboardScrollAnimation(*this, scrollData);
1723+
RefPtr scrollingCoordinator = page->scrollingCoordinator();
1724+
return scrollingCoordinator->requestStartKeyboardScrollAnimation(*this, scrollData);
17251725
}
17261726

17271727
bool UnifiedPDFPlugin::requestStopKeyboardScrollAnimation(bool immediate)
@@ -1730,8 +1730,8 @@ static String mutationObserverNotificationString()
17301730
if (!page)
17311731
return false;
17321732

1733-
auto& scrollingCoordinator = *page->scrollingCoordinator();
1734-
return scrollingCoordinator.requestStopKeyboardScrollAnimation(*this, immediate);
1733+
RefPtr scrollingCoordinator = page->scrollingCoordinator();
1734+
return scrollingCoordinator->requestStopKeyboardScrollAnimation(*this, immediate);
17351735
}
17361736

17371737
WebCore::OverscrollBehavior UnifiedPDFPlugin::overscrollBehavior() const

0 commit comments

Comments
 (0)