Changeset 268989 in webkit
- Timestamp:
- Oct 26, 2020, 11:40:57 AM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 11 edited
-
ChangeLog (modified) (1 diff)
-
PluginProcess/PluginControllerProxy.cpp (modified) (1 diff)
-
WebProcess/Plugins/Netscape/NetscapePlugin.h (modified) (1 diff)
-
WebProcess/Plugins/PDF/PDFPlugin.h (modified) (3 diffs)
-
WebProcess/Plugins/PDF/PDFPlugin.mm (modified) (33 diffs)
-
WebProcess/Plugins/Plugin.cpp (modified) (3 diffs)
-
WebProcess/Plugins/Plugin.h (modified) (3 diffs)
-
WebProcess/Plugins/PluginController.h (modified) (2 diffs)
-
WebProcess/Plugins/PluginProxy.h (modified) (1 diff)
-
WebProcess/Plugins/PluginView.cpp (modified) (4 diffs)
-
WebProcess/WebPage/WebFrame.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r268971 r268989 1 2020-10-26 Alex Christensen <achristensen@webkit.org> 2 3 Add null checks and smart pointers in PDF and Plugin code 4 https://bugs.webkit.org/show_bug.cgi?id=218144 5 <rdar://problem/69931543> 6 7 Reviewed by Youenn Fablet. 8 9 It's nice when things don't crash. 10 isBeingAsynchronouslyInitialized wasn't called anywhere, so I removed it. 11 12 * WebProcess/Plugins/PDF/PDFPlugin.h: 13 * WebProcess/Plugins/PDF/PDFPlugin.mm: 14 (WebKit::PDFPlugin::PDFPlugin): 15 (WebKit::PDFPlugin::~PDFPlugin): 16 (WebKit::PDFPlugin::getResourceBytesAtPosition): 17 (WebKit::PDFPlugin::updateScrollbars): 18 (WebKit::PDFPlugin::createScrollbar): 19 (WebKit::PDFPlugin::isActive const): 20 (WebKit::PDFPlugin::forceUpdateScrollbarsOnMainThreadForPerformanceTesting const): 21 (WebKit::PDFPlugin::jsPDFDocPrint): 22 (WebKit::PDFPlugin::installPDFDocument): 23 (WebKit::PDFPlugin::updatePageAndDeviceScaleFactors): 24 (WebKit::PDFPlugin::calculateSizes): 25 (WebKit::PDFPlugin::willDetachRenderer): 26 (WebKit::PDFPlugin::destroy): 27 (WebKit::PDFPlugin::paintControlForLayerInContext): 28 (WebKit::PDFPlugin::convertFromPDFViewToScreen const): 29 (WebKit::PDFPlugin::boundsOnScreen const): 30 (WebKit::PDFPlugin::visibilityDidChange): 31 (WebKit::PDFPlugin::showContextMenuAtPoint): 32 (WebKit::PDFPlugin::handleContextMenuEvent): 33 (WebKit::PDFPlugin::isFullFramePlugin const): 34 (WebKit::PDFPlugin::handlesPageScaleFactor const): 35 (WebKit::PDFPlugin::clickedLink): 36 (WebKit::PDFPlugin::save): 37 (WebKit::PDFPlugin::openWithPreview): 38 (WebKit::PDFPlugin::saveToPDF): 39 (WebKit::PDFPlugin::openWithNativeApplication): 40 (WebKit::PDFPlugin::showDefinitionForAttributedString): 41 (WebKit::PDFPlugin::notifySelectionChanged): 42 (WebKit::PDFPlugin::notifyCursorChanged): 43 (WebKit::PDFPlugin::axObjectCache const): 44 (WebKit::PDFPlugin::performWebSearch): 45 (WebKit::PDFPlugin::performSpotlightSearch): 46 * WebProcess/Plugins/Plugin.cpp: 47 (WebKit::Plugin::Plugin): 48 (WebKit::Plugin::initialize): 49 (WebKit::Plugin::controller): 50 (WebKit::Plugin::controller const): 51 (WebKit::Plugin::~Plugin): Deleted. 52 * WebProcess/Plugins/Plugin.h: 53 (WebKit::Plugin::controller): Deleted. 54 (WebKit::Plugin::controller const): Deleted. 55 * WebProcess/Plugins/PluginController.h: 56 * WebProcess/WebPage/WebFrame.h: 57 (WebKit::WebFrame::setLoadListener): 58 (WebKit::WebFrame::loadListener const): 59 1 60 2020-10-26 Youenn Fablet <youenn@apple.com> 2 61 -
trunk/Source/WebKit/PluginProcess/PluginControllerProxy.cpp
r251445 r268989 120 120 m_windowNPObject = m_connection->npRemoteObjectMap()->createNPObjectProxy(creationParameters.windowNPObjectID, m_plugin.get()); 121 121 122 bool returnValue = m_plugin->initialize( this, creationParameters.parameters);122 bool returnValue = m_plugin->initialize(*this, creationParameters.parameters); 123 123 124 124 if (!returnValue) { -
trunk/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.h
r259333 r268989 60 60 61 61 static RefPtr<NetscapePlugin> fromNPP(NPP); 62 63 // In-process NetscapePlugins don't support asynchronous initialization.64 bool isBeingAsynchronouslyInitialized() const override { return false; }65 62 66 63 #if PLATFORM(COCOA) -
trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h
r268003 r268989 44 44 #include <wtf/RetainPtr.h> 45 45 #include <wtf/Threading.h> 46 #include <wtf/WeakPtr.h> 46 47 47 48 typedef const struct OpaqueJSContext* JSContextRef; … … 214 215 bool pluginHandlesContentOffsetForAccessibilityHitTest() const final; 215 216 216 bool isBeingAsynchronouslyInitialized() const final { return false; }217 218 217 RetainPtr<PDFDocument> pdfDocumentForPrinting() const final { return m_pdfDocument; } 219 218 NSObject *accessibilityObject() const final; … … 304 303 const PluginView* pluginView() const; 305 304 306 We bFrame&m_frame;305 WeakPtr<WebFrame> m_frame; 307 306 308 307 bool m_isPostScript { false }; -
trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
r268562 r268989 597 597 inline PDFPlugin::PDFPlugin(WebFrame& frame) 598 598 : Plugin(PDFPluginType) 599 , m_frame( frame)599 , m_frame(makeWeakPtr(frame)) 600 600 , m_containerLayer(adoptNS([[CALayer alloc] init])) 601 601 , m_contentLayer(adoptNS([[CALayer alloc] init])) … … 618 618 619 619 if (supportsForms()) { 620 Document* document = m_frame.coreFrame()->document();620 auto* document = frame.coreFrame()->document(); 621 621 m_annotationContainer = document->createElement(divTag, false); 622 622 m_annotationContainer->setAttributeWithoutSynchronization(idAttr, AtomString("annotationContainer", AtomString::ConstructFromLiteral)); … … 631 631 m_accessibilityObject = adoptNS([[WKPDFPluginAccessibilityObject alloc] initWithPDFPlugin:this]); 632 632 [m_accessibilityObject setPdfLayerController:m_pdfLayerController.get()]; 633 [m_accessibilityObject setParent: m_frame.page()->accessibilityRemoteObject()];633 [m_accessibilityObject setParent:frame.page()->accessibilityRemoteObject()]; 634 634 635 635 [m_containerLayer addSublayer:m_contentLayer.get()]; … … 637 637 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 638 638 if ([m_pdfLayerController respondsToSelector:@selector(setDeviceColorSpace:)]) { 639 auto view = m_frame.coreFrame()->view();639 auto view = frame.coreFrame()->view(); 640 640 [m_pdfLayerController setDeviceColorSpace:screenColorSpace(view)]; 641 641 } … … 654 654 { 655 655 #if ENABLE(UI_PROCESS_PDF_HUD) 656 if (auto* page = m_frame .page())656 if (auto* page = m_frame ? m_frame->page() : nullptr) 657 657 page->removePDFHUD(*this); 658 658 #endif … … 966 966 m_outstandingByteRangeRequests.set(identifier, WTFMove(request)); 967 967 968 auto* coreFrame = m_frame.coreFrame(); 968 if (!m_frame) 969 return; 970 auto* coreFrame = m_frame->coreFrame(); 969 971 if (!coreFrame) 970 972 return; … … 1290 1292 } 1291 1293 1292 FrameView* frameView = m_frame.coreFrame()->view();1294 auto* frameView = m_frame ? m_frame->coreFrame()->view() : nullptr; 1293 1295 if (!frameView) 1294 1296 return; … … 1342 1344 didAddScrollbar(widget.ptr(), orientation); 1343 1345 1344 if (auto* frame = m_frame .coreFrame()) {1345 if ( Page* page = frame->page()) {1346 if (auto* frame = m_frame ? m_frame->coreFrame() : nullptr) { 1347 if (auto* page = frame->page()) { 1346 1348 if (page->isMonitoringWheelEvents()) 1347 1349 scrollAnimator().setWheelEventTestMonitor(page->wheelEventTestMonitor()); … … 1444 1446 bool PDFPlugin::isActive() const 1445 1447 { 1446 if ( Frame* coreFrame = m_frame.coreFrame()) {1447 if ( Page* page = coreFrame->page())1448 if (auto* coreFrame = m_frame ? m_frame->coreFrame() : nullptr) { 1449 if (auto* page = coreFrame->page()) 1448 1450 return page->focusController().isActive(); 1449 1451 } … … 1454 1456 bool PDFPlugin::forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const 1455 1457 { 1456 if ( Frame* coreFrame = m_frame.coreFrame()) {1457 if ( Page* page = coreFrame->page())1458 if (auto* coreFrame = m_frame ? m_frame->coreFrame() : nullptr) { 1459 if (auto* page = coreFrame->page()) 1458 1460 return page->settings().forceUpdateScrollbarsOnMainThreadForPerformanceTesting(); 1459 1461 } … … 1525 1527 JSValueRef PDFPlugin::jsPDFDocPrint(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 1526 1528 { 1527 PDFPlugin* pdfPlugin = static_cast<PDFPlugin*>(JSObjectGetPrivate(thisObject)); 1528 1529 Frame* coreFrame = pdfPlugin->m_frame.coreFrame(); 1529 auto* pdfPlugin = static_cast<PDFPlugin*>(JSObjectGetPrivate(thisObject)); 1530 1531 auto* frame = pdfPlugin->m_frame.get(); 1532 if (!frame) 1533 return JSValueMakeUndefined(ctx); 1534 1535 auto* coreFrame = frame->coreFrame(); 1530 1536 if (!coreFrame) 1531 1537 return JSValueMakeUndefined(ctx); 1532 1538 1533 Page* page = coreFrame->page();1539 auto* page = coreFrame->page(); 1534 1540 if (!page) 1535 1541 return JSValueMakeUndefined(ctx); … … 1633 1639 createPasswordEntryForm(); 1634 1640 1635 if ( [m_pdfLayerController respondsToSelector:@selector(setURLFragment:)])1636 [m_pdfLayerController setURLFragment:m_frame .url().fragmentIdentifier().createNSString().get()];1641 if (m_frame && [m_pdfLayerController respondsToSelector:@selector(setURLFragment:)]) 1642 [m_pdfLayerController setURLFragment:m_frame->url().fragmentIdentifier().createNSString().get()]; 1637 1643 } 1638 1644 … … 1815 1821 double newScaleFactor = controller()->contentsScaleFactor(); 1816 1822 if (!handlesPageScaleFactor()) { 1817 if (auto* page = m_frame .page())1823 if (auto* page = m_frame ? m_frame->page() : nullptr) 1818 1824 newScaleFactor *= page->pageScaleFactor(); 1819 1825 } … … 1845 1851 1846 1852 #if ENABLE(UI_PROCESS_PDF_HUD) 1847 m_frame.page()->updatePDFHUDLocation(*this, frameForHUD()); 1853 if (!m_frame || !m_frame->page()) 1854 return; 1855 m_frame->page()->updatePDFHUDLocation(*this, frameForHUD()); 1848 1856 #endif 1849 1857 } … … 1861 1869 void PDFPlugin::willDetachRenderer() 1862 1870 { 1863 if (auto* frameView = m_frame.coreFrame()->view()) 1871 if (!m_frame || !m_frame->coreFrame()) 1872 return; 1873 if (auto* frameView = m_frame->coreFrame()->view()) 1864 1874 frameView->removeScrollableArea(this); 1865 1875 } … … 1882 1892 m_pdfLayerController.get().delegate = 0; 1883 1893 1884 if (auto* frameView = m_frame .coreFrame()->view())1894 if (auto* frameView = m_frame && m_frame->coreFrame() ? m_frame->coreFrame()->view() : nullptr) 1885 1895 frameView->removeScrollableArea(this); 1886 1896 … … 1909 1919 { 1910 1920 #if PLATFORM(MAC) 1911 auto* page = m_frame.coreFrame()->page(); 1921 auto* page = m_frame && m_frame->coreFrame() ? m_frame->coreFrame()->page() : nullptr; 1922 if (!page) 1923 return; 1912 1924 LocalDefaultSystemAppearance localAppearance(page->useDarkAppearance()); 1913 1925 #endif … … 1998 2010 FloatRect PDFPlugin::convertFromPDFViewToScreen(const FloatRect& rect) const 1999 2011 { 2000 FrameView* frameView = m_frame.coreFrame()->view(); 2001 2012 auto* coreFrame = m_frame ? m_frame->coreFrame() : nullptr; 2013 if (!coreFrame) 2014 return { }; 2015 auto* frameView = coreFrame->view(); 2002 2016 if (!frameView) 2003 return FloatRect();2017 return { }; 2004 2018 2005 2019 FloatRect updatedRect = rect; 2006 2020 updatedRect.setLocation(convertFromPDFViewToRootView(IntPoint(updatedRect.location()))); 2007 return m_frame.coreFrame()->page()->chrome().rootViewToScreen(enclosingIntRect(updatedRect)); 2021 auto* page = coreFrame->page(); 2022 if (!page) 2023 return { }; 2024 return page->chrome().rootViewToScreen(enclosingIntRect(updatedRect)); 2008 2025 } 2009 2026 2010 2027 IntRect PDFPlugin::boundsOnScreen() const 2011 2028 { 2012 FrameView* frameView = m_frame.coreFrame()->view(); 2013 2029 auto* frameView = m_frame ? m_frame->coreFrame()->view() : nullptr; 2014 2030 if (!frameView) 2015 return IntRect();2031 return { }; 2016 2032 2017 2033 FloatRect bounds = FloatRect(FloatPoint(), size()); … … 2023 2039 { 2024 2040 #if ENABLE(UI_PROCESS_PDF_HUD) 2041 if (!m_frame) 2042 return; 2025 2043 if (visible) 2026 m_frame .page()->createPDFHUD(*this, frameForHUD());2044 m_frame->page()->createPDFHUD(*this, frameForHUD()); 2027 2045 else 2028 m_frame .page()->removePDFHUD(*this);2046 m_frame->page()->removePDFHUD(*this); 2029 2047 #else 2030 2048 UNUSED_PARAM(visible); … … 2274 2292 bool PDFPlugin::showContextMenuAtPoint(const IntPoint& point) 2275 2293 { 2276 FrameView* frameView = m_frame.coreFrame()->view(); 2294 auto* frameView = m_frame ? m_frame->coreFrame()->view() : nullptr; 2295 if (!frameView) 2296 return false; 2277 2297 IntPoint contentsPoint = frameView->contentsToRootView(point); 2278 2298 WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, 0, contentsPoint, contentsPoint, 0, 0, 0, 1, OptionSet<WebEvent::Modifier> { }, WallTime::now(), WebCore::ForceAtClick); … … 2282 2302 bool PDFPlugin::handleContextMenuEvent(const WebMouseEvent& event) 2283 2303 { 2284 if (!m_frame .page())2304 if (!m_frame || !m_frame->coreFrame()) 2285 2305 return false; 2286 2287 WebPage* webPage = m_frame.page(); 2288 FrameView* frameView = m_frame.coreFrame()->view(); 2306 auto* webPage = m_frame->page(); 2307 if (!webPage) 2308 return false; 2309 auto* frameView = m_frame->coreFrame()->view(); 2310 if (!frameView) 2311 return false; 2312 2289 2313 IntPoint point = frameView->contentsToScreen(IntRect(frameView->windowToContents(event.position()), IntSize())).location(); 2290 2314 … … 2394 2418 // <object> or <embed> plugins will appear to be in their parent frame, so we have to 2395 2419 // check whether our frame's widget is exactly our PluginView. 2396 Document* document = m_frame.coreFrame()->document(); 2420 if (!m_frame || !m_frame->coreFrame()) 2421 return false; 2422 auto* document = m_frame->coreFrame()->document(); 2423 if (!document) 2424 return false; 2397 2425 return document->isPluginDocument() && static_cast<PluginDocument*>(document)->pluginWidget() == pluginView(); 2398 2426 } … … 2400 2428 bool PDFPlugin::handlesPageScaleFactor() const 2401 2429 { 2402 return m_frame .isMainFrame() && isFullFramePlugin();2430 return m_frame && m_frame->isMainFrame() && isFullFramePlugin(); 2403 2431 } 2404 2432 … … 2409 2437 return; 2410 2438 2411 auto* frame = m_frame.coreFrame(); 2439 auto* frame = m_frame ? m_frame->coreFrame() : nullptr; 2440 if (!frame) 2441 return; 2412 2442 2413 2443 RefPtr<Event> coreEvent; … … 2492 2522 { 2493 2523 NSData *data = liveData(); 2494 completionHandler(m_suggestedFilename, m_frame.url(), IPC:: DataReference(static_cast<const uint8_t*>(data.bytes), data.length)); 2524 URL url; 2525 if (m_frame) 2526 url = m_frame->url(); 2527 completionHandler(m_suggestedFilename, url, IPC:: DataReference(static_cast<const uint8_t*>(data.bytes), data.length)); 2495 2528 } 2496 2529 … … 2498 2531 { 2499 2532 NSData *data = liveData(); 2500 completionHandler(m_suggestedFilename, m_frame.info(), IPC:: DataReference { static_cast<const uint8_t*>(data.bytes), data.length }, createCanonicalUUIDString()); 2533 FrameInfoData frameInfo; 2534 if (m_frame) 2535 frameInfo = m_frame->info(); 2536 completionHandler(m_suggestedFilename, WTFMove(frameInfo), IPC:: DataReference { static_cast<const uint8_t*>(data.bytes), data.length }, createCanonicalUUIDString()); 2501 2537 } 2502 2538 … … 2511 2547 2512 2548 NSData *data = liveData(); 2513 m_frame.page()->savePDFToFileInDownloadsFolder(m_suggestedFilename, m_frame.url(), static_cast<const unsigned char *>([data bytes]), [data length]); 2549 if (!m_frame || !m_frame->page()) 2550 return; 2551 m_frame->page()->savePDFToFileInDownloadsFolder(m_suggestedFilename, m_frame->url(), static_cast<const unsigned char *>([data bytes]), [data length]); 2514 2552 } 2515 2553 2516 2554 void PDFPlugin::openWithNativeApplication() 2517 2555 { 2556 if (!m_frame || !m_frame->page()) 2557 return; 2558 2518 2559 if (!m_temporaryPDFUUID) { 2519 2560 // FIXME: We should probably notify the user that they can't save before the document is finished loading. … … 2527 2568 ASSERT(m_temporaryPDFUUID); 2528 2569 2529 m_frame .page()->savePDFToTemporaryFolderAndOpenWithNativeApplication(m_suggestedFilename, m_frame.info(), static_cast<const unsigned char *>([data bytes]), [data length], m_temporaryPDFUUID);2530 return; 2531 } 2532 2533 m_frame .page()->send(Messages::WebPageProxy::OpenPDFFromTemporaryFolderWithNativeApplication(m_frame.info(), m_temporaryPDFUUID));2570 m_frame->page()->savePDFToTemporaryFolderAndOpenWithNativeApplication(m_suggestedFilename, m_frame->info(), static_cast<const unsigned char *>([data bytes]), [data length], m_temporaryPDFUUID); 2571 return; 2572 } 2573 2574 m_frame->page()->send(Messages::WebPageProxy::OpenPDFFromTemporaryFolderWithNativeApplication(m_frame->info(), m_temporaryPDFUUID)); 2534 2575 } 2535 2576 … … 2592 2633 dictionaryPopupInfo.textIndicator = dataForSelection; 2593 2634 2594 m_frame.page()->send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo)); 2635 if (!m_frame || !m_frame->page()) 2636 return; 2637 2638 m_frame->page()->send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo)); 2595 2639 } 2596 2640 … … 2700 2744 void PDFPlugin::notifySelectionChanged(PDFSelection *) 2701 2745 { 2702 m_frame.page()->didChangeSelection(); 2746 if (!m_frame || !m_frame->page()) 2747 return; 2748 m_frame->page()->didChangeSelection(); 2703 2749 } 2704 2750 … … 2718 2764 void PDFPlugin::notifyCursorChanged(uint64_t type) 2719 2765 { 2720 m_frame.page()->send(Messages::WebPageProxy::SetCursor(coreCursor(static_cast<PDFLayerControllerCursorType>(type)))); 2766 if (!m_frame || !m_frame->page()) 2767 return; 2768 2769 m_frame->page()->send(Messages::WebPageProxy::SetCursor(coreCursor(static_cast<PDFLayerControllerCursorType>(type)))); 2721 2770 } 2722 2771 … … 2842 2891 WebCore::AXObjectCache* PDFPlugin::axObjectCache() const 2843 2892 { 2844 return m_frame.coreFrame()->document()->axObjectCache(); 2893 if (!m_frame || !m_frame->coreFrame() || !m_frame->coreFrame()->document()) 2894 return nullptr; 2895 return m_frame->coreFrame()->document()->axObjectCache(); 2845 2896 } 2846 2897 … … 2871 2922 void PDFPlugin::performWebSearch(NSString *string) 2872 2923 { 2873 m_frame.page()->send(Messages::WebPageProxy::SearchTheWeb(string)); 2924 if (!m_frame || !m_frame->page()) 2925 return; 2926 m_frame->page()->send(Messages::WebPageProxy::SearchTheWeb(string)); 2874 2927 } 2875 2928 2876 2929 void PDFPlugin::performSpotlightSearch(NSString *string) 2877 2930 { 2878 m_frame.page()->send(Messages::WebPageProxy::SearchWithSpotlight(string)); 2931 if (!m_frame || !m_frame->page()) 2932 return; 2933 m_frame->page()->send(Messages::WebPageProxy::SearchWithSpotlight(string)); 2879 2934 } 2880 2935 -
trunk/Source/WebKit/WebProcess/Plugins/Plugin.cpp
r262994 r268989 28 28 29 29 #include "LayerTreeContext.h" 30 #include "PluginController.h" 30 31 #include "WebCoreArgumentCoders.h" 31 32 #include <WebCore/IntPoint.h> … … 83 84 Plugin::Plugin(PluginType type) 84 85 : m_type(type) 85 , m_pluginController(0)86 86 { 87 87 } 88 88 89 Plugin::~Plugin() 90 { 91 } 89 Plugin::~Plugin() = default; 92 90 93 bool Plugin::initialize(PluginController *pluginController, const Parameters& parameters)91 bool Plugin::initialize(PluginController& pluginController, const Parameters& parameters) 94 92 { 95 93 ASSERT(!m_pluginController); 96 ASSERT(pluginController);97 94 98 m_pluginController = pluginController;95 m_pluginController = makeWeakPtr(pluginController); 99 96 100 97 return initialize(parameters); … … 121 118 } 122 119 120 PluginController* Plugin::controller() 121 { 122 return m_pluginController.get(); 123 } 124 125 const PluginController* Plugin::controller() const 126 { 127 return m_pluginController.get(); 128 } 129 123 130 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/Plugins/Plugin.h
r260025 r268989 34 34 #include <wtf/URL.h> 35 35 #include <wtf/Vector.h> 36 #include <wtf/WeakPtr.h> 36 37 37 38 #if PLATFORM(COCOA) … … 97 98 }; 98 99 99 // Sets the active plug-in controller and initializes the plug-in. 100 bool initialize(PluginController*, const Parameters&); 101 102 virtual bool isBeingAsynchronouslyInitialized() const = 0; 103 104 // Destroys the plug-in. 100 bool initialize(PluginController&, const Parameters&); 101 105 102 void destroyPlugin(); 106 103 107 104 bool isBeingDestroyed() const { return m_isBeingDestroyed; } 108 105 109 // Returns the plug-in controller for this plug-in. 110 PluginController* controller() { return m_pluginController; } 111 const PluginController* controller() const { return m_pluginController; } 106 PluginController* controller(); 107 const PluginController* controller() const; 112 108 113 109 virtual ~Plugin(); … … 318 314 319 315 private: 320 PluginController*m_pluginController;316 WeakPtr<PluginController> m_pluginController; 321 317 }; 322 318 -
trunk/Source/WebKit/WebProcess/Plugins/PluginController.h
r265753 r268989 27 27 28 28 #include <wtf/Forward.h> 29 #include <wtf/WeakPtr.h> 29 30 30 31 #if PLATFORM(COCOA) … … 48 49 namespace WebKit { 49 50 50 class PluginController {51 class PluginController : public CanMakeWeakPtr<PluginController> { 51 52 public: 52 53 // Tells the controller that the plug-in wants the given rect to be repainted. The rect is in the plug-in's coordinate system. -
trunk/Source/WebKit/WebProcess/Plugins/PluginProxy.h
r259333 r268989 65 65 void didReceiveSyncPluginProxyMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&); 66 66 67 bool isBeingAsynchronouslyInitialized() const override { return m_waitingOnAsynchronousInitialization; }68 69 67 private: 70 68 explicit PluginProxy(uint64_t pluginProcessToken, bool isRestartedProcess); -
trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp
r267916 r268989 335 335 // Cancel all pending frame loads. 336 336 for (FrameLoadMap::iterator it = m_pendingFrameLoads.begin(), end = m_pendingFrameLoads.end(); it != end; ++it) 337 it->key->setLoadListener( 0);337 it->key->setLoadListener(nullptr); 338 338 339 339 if (m_plugin) { … … 602 602 m_didPlugInStartOffScreen = !m_webPage->plugInIntersectsSearchRect(plugInImageElement); 603 603 #endif 604 m_plugin->initialize( this, m_parameters);604 m_plugin->initialize(*this, m_parameters); 605 605 606 606 // Plug-in initialization continued in didFailToInitializePlugin() or didInitializePlugin(). … … 1667 1667 RefPtr<URLRequest> request = m_pendingFrameLoads.take(webFrame); 1668 1668 ASSERT(request); 1669 webFrame->setLoadListener( 0);1669 webFrame->setLoadListener(nullptr); 1670 1670 1671 1671 m_plugin->frameDidFinishLoading(request->requestID()); … … 1676 1676 RefPtr<URLRequest> request = m_pendingFrameLoads.take(webFrame); 1677 1677 ASSERT(request); 1678 webFrame->setLoadListener( 0);1678 webFrame->setLoadListener(nullptr); 1679 1679 1680 1680 m_plugin->frameDidFail(request->requestID(), wasCancelled); -
trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h
r268239 r268989 41 41 #include <wtf/RefPtr.h> 42 42 #include <wtf/RetainPtr.h> 43 #include <wtf/WeakPtr.h> 43 44 44 45 namespace API { … … 150 151 151 152 // Simple listener class used by plug-ins to know when frames finish or fail loading. 152 class LoadListener {153 class LoadListener : public CanMakeWeakPtr<LoadListener> { 153 154 public: 154 155 virtual ~LoadListener() { } … … 157 158 virtual void didFailLoad(WebFrame*, bool wasCancelled) = 0; 158 159 }; 159 void setLoadListener(LoadListener* loadListener) { m_loadListener = loadListener; }160 LoadListener* loadListener() const { return m_loadListener ; }160 void setLoadListener(LoadListener* loadListener) { m_loadListener = makeWeakPtr(loadListener); } 161 LoadListener* loadListener() const { return m_loadListener.get(); } 161 162 162 163 #if PLATFORM(COCOA) … … 193 194 Optional<DownloadID> m_policyDownloadID; 194 195 195 LoadListener* m_loadListener { nullptr };196 WeakPtr<LoadListener> m_loadListener; 196 197 197 198 WebCore::FrameIdentifier m_frameID;
Note:
See TracChangeset
for help on using the changeset viewer.