Skip to content

Commit 6e0255e

Browse files
committed
Address safer CPP failures in WebKit/WebProcess/Plugins
https://bugs.webkit.org/show_bug.cgi?id=301916 Reviewed by Darin Adler. * Source/WebCore/accessibility/AXCoreObject.h: * Source/WebKit/SaferCPPExpectations/UnretainedCallArgsCheckerExpectations: * Source/WebKit/WebProcess/Plugins/PDF/PDFIncrementalLoader.mm: (WebKit::PDFIncrementalLoader::threadEntry): * Source/WebKit/WebProcess/Plugins/PDF/PDFPluginAnnotation.h: (WebKit::PDFPluginAnnotation::protectedAnnotation const): * Source/WebKit/WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm: (WebKit::PDFPluginChoiceAnnotation::updateGeometry): (WebKit::PDFPluginChoiceAnnotation::commit): * Source/WebKit/WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm: (WebKit::PDFPluginTextAnnotation::updateGeometry): (WebKit::PDFPluginTextAnnotation::commit): * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm: (WebKit::UnifiedPDFPlugin::paintPDFContent): (WebKit::UnifiedPDFPlugin::setActiveAnnotation): * Source/WebKit/WebProcess/Plugins/PDF/WKAccessibilityPDFDocumentObject.mm: (-[WKAccessibilityPDFDocumentObject accessibilityScroll:]): (-[WKAccessibilityPDFDocumentObject accessibilityFocusedUIElement]): (-[WKAccessibilityPDFDocumentObject accessibilityParent]): Canonical link: https://commits.webkit.org/302532@main
1 parent 7d39c09 commit 6e0255e

File tree

8 files changed

+15
-18
lines changed

8 files changed

+15
-18
lines changed

Source/WebCore/accessibility/AXCoreObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ class AXCoreObject : public RefCountedAndCanMakeWeakPtr<AXCoreObject> {
11971197

11981198
AccessibilityObjectWrapper* wrapper() const { return m_wrapper.get(); }
11991199
#if PLATFORM(COCOA)
1200-
RetainPtr<AccessibilityObjectWrapper> protectedWrapper() const;
1200+
WEBCORE_EXPORT RetainPtr<AccessibilityObjectWrapper> protectedWrapper() const;
12011201
#endif
12021202
void setWrapper(AccessibilityObjectWrapper* wrapper) { m_wrapper = wrapper; }
12031203
void detachWrapper(AccessibilityDetachmentType);

Source/WebKit/SaferCPPExpectations/UnretainedCallArgsCheckerExpectations

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@
6464
[ iOS ] UIProcess/ios/forms/WKFormSelectPopover.mm
6565
[ iOS ] UIProcess/ios/fullscreen/WKFullScreenViewController.mm
6666
[ iOS ] UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm
67-
WebProcess/Plugins/PDF/PDFIncrementalLoader.mm
68-
WebProcess/Plugins/PDF/PDFPluginChoiceAnnotation.mm
69-
WebProcess/Plugins/PDF/PDFPluginTextAnnotation.mm
70-
WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
71-
WebProcess/Plugins/PDF/WKAccessibilityPDFDocumentObject.mm
7267
[ iOS ] WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
7368
[ iOS ] WebProcess/WebPage/WKAccessibilityWebPageObjectIOS.mm
7469
[ iOS ] WebProcess/WebPage/ios/WebPageIOS.mm

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ static void dataProviderReleaseInfoCallback(void* info)
804804
BinarySemaphore firstPageSemaphore;
805805
auto firstPageQueue = WorkQueue::create("PDF first page work queue"_s);
806806

807-
[m_backgroundThreadDocument preloadDataOfPagesInRange:NSMakeRange(0, 1) onQueue:firstPageQueue->dispatchQueue() completion:[&firstPageSemaphore, protectedThis = Ref { *this }] (NSIndexSet *) mutable {
807+
[m_backgroundThreadDocument preloadDataOfPagesInRange:NSMakeRange(0, 1) onQueue:firstPageQueue->protectedDispatchQueue().get() completion:[&firstPageSemaphore, protectedThis = Ref { *this }] (NSIndexSet *) mutable {
808808
callOnMainRunLoop([protectedThis] {
809809
protectedThis->transitionToMainThreadDocument();
810810
});

Source/WebKit/WebProcess/Plugins/PDF/PDFPluginAnnotation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class PDFPluginAnnotation : public RefCounted<PDFPluginAnnotation>, public CanMa
5555

5656
WebCore::Element* element() const { return m_element.get(); }
5757
PDFAnnotation *annotation() const { return m_annotation.get(); }
58+
RetainPtr<PDFAnnotation> protectedAnnotation() const { return m_annotation; }
5859
PDFPluginBase* plugin() const { return m_plugin.get(); }
5960

6061
RefPtr<WebCore::Element> protectedElement() const { return element(); }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
PDFPluginAnnotation::updateGeometry();
5555

5656
Ref styledElement = downcast<StyledElement>(*element());
57-
styledElement->setInlineStyleProperty(CSSPropertyFontSize, annotation().font.pointSize * plugin()->contentScaleFactor(), CSSUnitType::CSS_PX);
57+
styledElement->setInlineStyleProperty(CSSPropertyFontSize, protectedAnnotation().get().font.pointSize * plugin()->contentScaleFactor(), CSSUnitType::CSS_PX);
5858
}
5959

6060
void PDFPluginChoiceAnnotation::commit()
6161
{
62-
annotation().widgetStringValue = downcast<HTMLSelectElement>(protectedElement())->value().createNSString().get();
62+
protectedAnnotation().get().widgetStringValue = downcast<HTMLSelectElement>(protectedElement())->value().createNSString().get();
6363

6464
PDFPluginAnnotation::commit();
6565
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ static const String cssAlignmentValueForNSTextAlignment(NSTextAlignment alignmen
106106
PDFPluginAnnotation::updateGeometry();
107107

108108
Ref styledElement = downcast<StyledElement>(*element());
109-
styledElement->setInlineStyleProperty(CSSPropertyFontSize, annotation().font.pointSize * plugin()->contentScaleFactor(), CSSUnitType::CSS_PX);
109+
styledElement->setInlineStyleProperty(CSSPropertyFontSize, protectedAnnotation().get().font.pointSize * plugin()->contentScaleFactor(), CSSUnitType::CSS_PX);
110110
}
111111

112112
void PDFPluginTextAnnotation::commit()
113113
{
114-
annotation().widgetStringValue = value().createNSString().get();
114+
protectedAnnotation().get().widgetStringValue = value().createNSString().get();
115115
PDFPluginAnnotation::commit();
116116
}
117117

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ - (void)formChanged:(NSNotification *)notification
202202
[m_accessibilityDocumentObject setPDFPlugin:this];
203203
RefPtr frame = m_frame.get();
204204
if (isFullMainFramePlugin())
205-
[m_accessibilityDocumentObject setParent:frame->protectedPage()->accessibilityRemoteObject()];
205+
[m_accessibilityDocumentObject setParent:frame->protectedPage()->protectedAccessibilityRemoteObject().get()];
206206

207207
if (protectedPresentationController()->wantsWheelEvents())
208208
wantsWheelEventsChanged();
@@ -913,7 +913,7 @@ static String mutationObserverNotificationString()
913913

914914
if (!asyncRenderer) {
915915
LOG_WITH_STREAM(PDF, stream << "UnifiedPDFPlugin: painting PDF page " << pageInfo.pageIndex << " into rect " << pageDestinationRect << " with clip " << clipRect);
916-
[page drawWithBox:kPDFDisplayBoxCropBox toContext:context.platformContext()];
916+
[page drawWithBox:kPDFDisplayBoxCropBox toContext:context.protectedPlatformContext().get()];
917917
}
918918

919919
if constexpr (hasFullAnnotationSupport) {
@@ -4070,7 +4070,8 @@ static NSStringCompareOptions compareOptionsForFindOptions(WebCore::FindOptions
40704070
if (isInPluginCleanup != IsInPluginCleanup::Yes) {
40714071
if (RefPtr activeAnnotation = m_activeAnnotation) {
40724072
activeAnnotation->commit();
4073-
setNeedsRepaintForAnnotation(activeAnnotation->annotation(), repaintRequirementsForAnnotation(activeAnnotation->annotation(), IsAnnotationCommit::Yes));
4073+
RetainPtr pdfAnnotation = activeAnnotation->annotation();
4074+
setNeedsRepaintForAnnotation(pdfAnnotation.get(), repaintRequirementsForAnnotation(pdfAnnotation.get(), IsAnnotationCommit::Yes));
40744075
}
40754076
}
40764077

@@ -4083,7 +4084,7 @@ static NSStringCompareOptions compareOptionsForFindOptions(WebCore::FindOptions
40834084
RefPtr newActiveAnnotation = PDFPluginAnnotation::create(annotation.get(), this);
40844085
newActiveAnnotation->attach(m_annotationContainer.get());
40854086
m_activeAnnotation = WTFMove(newActiveAnnotation);
4086-
revealAnnotation(protectedActiveAnnotation()->annotation());
4087+
revealAnnotation(protectedActiveAnnotation()->protectedAnnotation().get());
40874088
} else
40884089
m_activeAnnotation = nullptr;
40894090
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ - (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction
146146
{
147147
if (RefPtr plugin = _pdfPlugin.get()) {
148148
if (auto coreObject = plugin->accessibilityCoreObject())
149-
[coreObject->wrapper() accessibilityScroll:direction];
149+
[coreObject->protectedWrapper() accessibilityScroll:direction];
150150
}
151151
return YES;
152152
}
@@ -165,7 +165,7 @@ - (id)accessibilityFocusedUIElement
165165
if (CheckedPtr existingCache = plugin->axObjectCache()) {
166166
if (RefPtr object = existingCache->exportedGetOrCreate(activeAnnotation->protectedElement().get())) {
167167
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
168-
return [object->wrapper() accessibilityAttributeValue:@"_AXAssociatedPluginParent"];
168+
return [object->protectedWrapper() accessibilityAttributeValue:@"_AXAssociatedPluginParent"];
169169
ALLOW_DEPRECATED_DECLARATIONS_END
170170
}
171171
}
@@ -225,7 +225,7 @@ - (NSObject *)accessibilityParent
225225
callOnMainRunLoopAndWait([protectedSelf] {
226226
if (CheckedPtr axObjectCache = protectedSelf->_pdfPlugin.get()->axObjectCache()) {
227227
if (RefPtr pluginAxObject = axObjectCache->exportedGetOrCreate(RefPtr { protectedSelf->_pluginElement.get() }.get()))
228-
protectedSelf->_parent = pluginAxObject->wrapper();
228+
protectedSelf->_parent = pluginAxObject->protectedWrapper().get();
229229
}
230230
});
231231
}

0 commit comments

Comments
 (0)