⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 268989 in webkit


Ignore:
Timestamp:
Oct 26, 2020, 11:40:57 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Add null checks and smart pointers in PDF and Plugin code
​https://bugs.webkit.org/show_bug.cgi?id=218144
<rdar://problem/69931543>

Patch by Alex Christensen <​achristensen@webkit.org> on 2020-10-26
Reviewed by Youenn Fablet.

It's nice when things don't crash.
isBeingAsynchronouslyInitialized wasn't called anywhere, so I removed it.

  • WebProcess/Plugins/PDF/PDFPlugin.h:
  • WebProcess/Plugins/PDF/PDFPlugin.mm:

(WebKit::PDFPlugin::PDFPlugin):
(WebKit::PDFPlugin::~PDFPlugin):
(WebKit::PDFPlugin::getResourceBytesAtPosition):
(WebKit::PDFPlugin::updateScrollbars):
(WebKit::PDFPlugin::createScrollbar):
(WebKit::PDFPlugin::isActive const):
(WebKit::PDFPlugin::forceUpdateScrollbarsOnMainThreadForPerformanceTesting const):
(WebKit::PDFPlugin::jsPDFDocPrint):
(WebKit::PDFPlugin::installPDFDocument):
(WebKit::PDFPlugin::updatePageAndDeviceScaleFactors):
(WebKit::PDFPlugin::calculateSizes):
(WebKit::PDFPlugin::willDetachRenderer):
(WebKit::PDFPlugin::destroy):
(WebKit::PDFPlugin::paintControlForLayerInContext):
(WebKit::PDFPlugin::convertFromPDFViewToScreen const):
(WebKit::PDFPlugin::boundsOnScreen const):
(WebKit::PDFPlugin::visibilityDidChange):
(WebKit::PDFPlugin::showContextMenuAtPoint):
(WebKit::PDFPlugin::handleContextMenuEvent):
(WebKit::PDFPlugin::isFullFramePlugin const):
(WebKit::PDFPlugin::handlesPageScaleFactor const):
(WebKit::PDFPlugin::clickedLink):
(WebKit::PDFPlugin::save):
(WebKit::PDFPlugin::openWithPreview):
(WebKit::PDFPlugin::saveToPDF):
(WebKit::PDFPlugin::openWithNativeApplication):
(WebKit::PDFPlugin::showDefinitionForAttributedString):
(WebKit::PDFPlugin::notifySelectionChanged):
(WebKit::PDFPlugin::notifyCursorChanged):
(WebKit::PDFPlugin::axObjectCache const):
(WebKit::PDFPlugin::performWebSearch):
(WebKit::PDFPlugin::performSpotlightSearch):

  • WebProcess/Plugins/Plugin.cpp:

(WebKit::Plugin::Plugin):
(WebKit::Plugin::initialize):
(WebKit::Plugin::controller):
(WebKit::Plugin::controller const):
(WebKit::Plugin::~Plugin): Deleted.

  • WebProcess/Plugins/Plugin.h:

(WebKit::Plugin::controller): Deleted.
(WebKit::Plugin::controller const): Deleted.

  • WebProcess/Plugins/PluginController.h:
  • WebProcess/WebPage/WebFrame.h:

(WebKit::WebFrame::setLoadListener):
(WebKit::WebFrame::loadListener const):

Location:
trunk/Source/WebKit
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r268971 r268989  
     12020-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
    1602020-10-26  Youenn Fablet  <youenn@apple.com>
    261
  • trunk/Source/WebKit/PluginProcess/PluginControllerProxy.cpp

    r251445 r268989  
    120120        m_windowNPObject = m_connection->npRemoteObjectMap()->createNPObjectProxy(creationParameters.windowNPObjectID, m_plugin.get());
    121121
    122     bool returnValue = m_plugin->initialize(this, creationParameters.parameters);
     122    bool returnValue = m_plugin->initialize(*this, creationParameters.parameters);
    123123
    124124    if (!returnValue) {
  • trunk/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r259333 r268989  
    6060
    6161    static RefPtr<NetscapePlugin> fromNPP(NPP);
    62 
    63     // In-process NetscapePlugins don't support asynchronous initialization.
    64     bool isBeingAsynchronouslyInitialized() const override { return false; }
    6562
    6663#if PLATFORM(COCOA)
  • trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h

    r268003 r268989  
    4444#include <wtf/RetainPtr.h>
    4545#include <wtf/Threading.h>
     46#include <wtf/WeakPtr.h>
    4647
    4748typedef const struct OpaqueJSContext* JSContextRef;
    … …  
    214215    bool pluginHandlesContentOffsetForAccessibilityHitTest() const final;
    215216   
    216     bool isBeingAsynchronouslyInitialized() const final { return false; }
    217 
    218217    RetainPtr<PDFDocument> pdfDocumentForPrinting() const final { return m_pdfDocument; }
    219218    NSObject *accessibilityObject() const final;
    … …  
    304303    const PluginView* pluginView() const;
    305304
    306     WebFrame& m_frame;
     305    WeakPtr<WebFrame> m_frame;
    307306
    308307    bool m_isPostScript { false };
  • trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm

    r268562 r268989  
    597597inline PDFPlugin::PDFPlugin(WebFrame& frame)
    598598    : Plugin(PDFPluginType)
    599     , m_frame(frame)
     599    , m_frame(makeWeakPtr(frame))
    600600    , m_containerLayer(adoptNS([[CALayer alloc] init]))
    601601    , m_contentLayer(adoptNS([[CALayer alloc] init]))
    … …  
    618618
    619619    if (supportsForms()) {
    620         Document* document = m_frame.coreFrame()->document();
     620        auto* document = frame.coreFrame()->document();
    621621        m_annotationContainer = document->createElement(divTag, false);
    622622        m_annotationContainer->setAttributeWithoutSynchronization(idAttr, AtomString("annotationContainer", AtomString::ConstructFromLiteral));
    … …  
    631631    m_accessibilityObject = adoptNS([[WKPDFPluginAccessibilityObject alloc] initWithPDFPlugin:this]);
    632632    [m_accessibilityObject setPdfLayerController:m_pdfLayerController.get()];
    633     [m_accessibilityObject setParent:m_frame.page()->accessibilityRemoteObject()];
     633    [m_accessibilityObject setParent:frame.page()->accessibilityRemoteObject()];
    634634
    635635    [m_containerLayer addSublayer:m_contentLayer.get()];
    … …  
    637637#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    638638    if ([m_pdfLayerController respondsToSelector:@selector(setDeviceColorSpace:)]) {
    639         auto view = m_frame.coreFrame()->view();
     639        auto view = frame.coreFrame()->view();
    640640        [m_pdfLayerController setDeviceColorSpace:screenColorSpace(view)];
    641641    }
    … …  
    654654{
    655655#if ENABLE(UI_PROCESS_PDF_HUD)
    656     if (auto* page = m_frame.page())
     656    if (auto* page = m_frame ? m_frame->page() : nullptr)
    657657        page->removePDFHUD(*this);
    658658#endif
    … …  
    966966    m_outstandingByteRangeRequests.set(identifier, WTFMove(request));
    967967
    968     auto* coreFrame = m_frame.coreFrame();
     968    if (!m_frame)
     969        return;
     970    auto* coreFrame = m_frame->coreFrame();
    969971    if (!coreFrame)
    970972        return;
    … …  
    12901292    }
    12911293
    1292     FrameView* frameView = m_frame.coreFrame()->view();
     1294    auto* frameView = m_frame ? m_frame->coreFrame()->view() : nullptr;
    12931295    if (!frameView)
    12941296        return;
    … …  
    13421344    didAddScrollbar(widget.ptr(), orientation);
    13431345
    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()) {
    13461348            if (page->isMonitoringWheelEvents())
    13471349                scrollAnimator().setWheelEventTestMonitor(page->wheelEventTestMonitor());
    … …  
    14441446bool PDFPlugin::isActive() const
    14451447{
    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())
    14481450            return page->focusController().isActive();
    14491451    }
    … …  
    14541456bool PDFPlugin::forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const
    14551457{
    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())
    14581460            return page->settings().forceUpdateScrollbarsOnMainThreadForPerformanceTesting();
    14591461    }
    … …  
    15251527JSValueRef PDFPlugin::jsPDFDocPrint(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    15261528{
    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();
    15301536    if (!coreFrame)
    15311537        return JSValueMakeUndefined(ctx);
    15321538
    1533     Page* page = coreFrame->page();
     1539    auto* page = coreFrame->page();
    15341540    if (!page)
    15351541        return JSValueMakeUndefined(ctx);
    … …  
    16331639        createPasswordEntryForm();
    16341640
    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()];
    16371643}
    16381644
    … …  
    18151821    double newScaleFactor = controller()->contentsScaleFactor();
    18161822    if (!handlesPageScaleFactor()) {
    1817         if (auto* page = m_frame.page())
     1823        if (auto* page = m_frame ? m_frame->page() : nullptr)
    18181824            newScaleFactor *= page->pageScaleFactor();
    18191825    }
    … …  
    18451851
    18461852#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());
    18481856#endif
    18491857}
    … …  
    18611869void PDFPlugin::willDetachRenderer()
    18621870{
    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())
    18641874        frameView->removeScrollableArea(this);
    18651875}
    … …  
    18821892    m_pdfLayerController.get().delegate = 0;
    18831893
    1884     if (auto* frameView = m_frame.coreFrame()->view())
     1894    if (auto* frameView = m_frame && m_frame->coreFrame() ? m_frame->coreFrame()->view() : nullptr)
    18851895        frameView->removeScrollableArea(this);
    18861896
    … …  
    19091919{
    19101920#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;
    19121924    LocalDefaultSystemAppearance localAppearance(page->useDarkAppearance());
    19131925#endif
    … …  
    19982010FloatRect PDFPlugin::convertFromPDFViewToScreen(const FloatRect& rect) const
    19992011{
    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();
    20022016    if (!frameView)
    2003         return FloatRect();
     2017        return { };
    20042018
    20052019    FloatRect updatedRect = rect;
    20062020    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));
    20082025}
    20092026
    20102027IntRect PDFPlugin::boundsOnScreen() const
    20112028{
    2012     FrameView* frameView = m_frame.coreFrame()->view();
    2013 
     2029    auto* frameView = m_frame ? m_frame->coreFrame()->view() : nullptr;
    20142030    if (!frameView)
    2015         return IntRect();
     2031        return { };
    20162032
    20172033    FloatRect bounds = FloatRect(FloatPoint(), size());
    … …  
    20232039{
    20242040#if ENABLE(UI_PROCESS_PDF_HUD)
     2041    if (!m_frame)
     2042        return;
    20252043    if (visible)
    2026         m_frame.page()->createPDFHUD(*this, frameForHUD());
     2044        m_frame->page()->createPDFHUD(*this, frameForHUD());
    20272045    else
    2028         m_frame.page()->removePDFHUD(*this);
     2046        m_frame->page()->removePDFHUD(*this);
    20292047#else
    20302048    UNUSED_PARAM(visible);
    … …  
    22742292bool PDFPlugin::showContextMenuAtPoint(const IntPoint& point)
    22752293{
    2276     FrameView* frameView = m_frame.coreFrame()->view();
     2294    auto* frameView = m_frame ? m_frame->coreFrame()->view() : nullptr;
     2295    if (!frameView)
     2296        return false;
    22772297    IntPoint contentsPoint = frameView->contentsToRootView(point);
    22782298    WebMouseEvent event(WebEvent::MouseDown, WebMouseEvent::RightButton, 0, contentsPoint, contentsPoint, 0, 0, 0, 1, OptionSet<WebEvent::Modifier> { }, WallTime::now(), WebCore::ForceAtClick);
    … …  
    22822302bool PDFPlugin::handleContextMenuEvent(const WebMouseEvent& event)
    22832303{
    2284     if (!m_frame.page())
     2304    if (!m_frame || !m_frame->coreFrame())
    22852305        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
    22892313    IntPoint point = frameView->contentsToScreen(IntRect(frameView->windowToContents(event.position()), IntSize())).location();
    22902314
    … …  
    23942418    // <object> or <embed> plugins will appear to be in their parent frame, so we have to
    23952419    // 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;
    23972425    return document->isPluginDocument() && static_cast<PluginDocument*>(document)->pluginWidget() == pluginView();
    23982426}
    … …  
    24002428bool PDFPlugin::handlesPageScaleFactor() const
    24012429{
    2402     return m_frame.isMainFrame() && isFullFramePlugin();
     2430    return m_frame && m_frame->isMainFrame() && isFullFramePlugin();
    24032431}
    24042432
    … …  
    24092437        return;
    24102438
    2411     auto* frame = m_frame.coreFrame();
     2439    auto* frame = m_frame ? m_frame->coreFrame() : nullptr;
     2440    if (!frame)
     2441        return;
    24122442
    24132443    RefPtr<Event> coreEvent;
    … …  
    24922522{
    24932523    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));
    24952528}
    24962529
    … …  
    24982531{
    24992532    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());
    25012537}
    25022538
    … …  
    25112547
    25122548    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]);
    25142552}
    25152553
    25162554void PDFPlugin::openWithNativeApplication()
    25172555{
     2556    if (!m_frame || !m_frame->page())
     2557        return;
     2558
    25182559    if (!m_temporaryPDFUUID) {
    25192560        // FIXME: We should probably notify the user that they can't save before the document is finished loading.
    … …  
    25272568        ASSERT(m_temporaryPDFUUID);
    25282569
    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));
    25342575}
    25352576
    … …  
    25922633    dictionaryPopupInfo.textIndicator = dataForSelection;
    25932634   
    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));
    25952639}
    25962640
    … …  
    27002744void PDFPlugin::notifySelectionChanged(PDFSelection *)
    27012745{
    2702     m_frame.page()->didChangeSelection();
     2746    if (!m_frame || !m_frame->page())
     2747        return;
     2748    m_frame->page()->didChangeSelection();
    27032749}
    27042750
    … …  
    27182764void PDFPlugin::notifyCursorChanged(uint64_t type)
    27192765{
    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))));
    27212770}
    27222771
    … …  
    28422891WebCore::AXObjectCache* PDFPlugin::axObjectCache() const
    28432892{
    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();
    28452896}
    28462897
    … …  
    28712922void PDFPlugin::performWebSearch(NSString *string)
    28722923{
    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));
    28742927}
    28752928
    28762929void PDFPlugin::performSpotlightSearch(NSString *string)
    28772930{
    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));
    28792934}
    28802935
  • trunk/Source/WebKit/WebProcess/Plugins/Plugin.cpp

    r262994 r268989  
    2828
    2929#include "LayerTreeContext.h"
     30#include "PluginController.h"
    3031#include "WebCoreArgumentCoders.h"
    3132#include <WebCore/IntPoint.h>
    … …  
    8384Plugin::Plugin(PluginType type)
    8485    : m_type(type)
    85     , m_pluginController(0)
    8686{
    8787}
    8888
    89 Plugin::~Plugin()
    90 {
    91 }
     89Plugin::~Plugin() = default;
    9290
    93 bool Plugin::initialize(PluginController* pluginController, const Parameters& parameters)
     91bool Plugin::initialize(PluginController& pluginController, const Parameters& parameters)
    9492{
    9593    ASSERT(!m_pluginController);
    96     ASSERT(pluginController);
    9794
    98     m_pluginController = pluginController;
     95    m_pluginController = makeWeakPtr(pluginController);
    9996
    10097    return initialize(parameters);
    … …  
    121118}
    122119
     120PluginController* Plugin::controller()
     121{
     122    return m_pluginController.get();
     123}
     124
     125const PluginController* Plugin::controller() const
     126{
     127    return m_pluginController.get();
     128}
     129
    123130} // namespace WebKit
  • trunk/Source/WebKit/WebProcess/Plugins/Plugin.h

    r260025 r268989  
    3434#include <wtf/URL.h>
    3535#include <wtf/Vector.h>
     36#include <wtf/WeakPtr.h>
    3637
    3738#if PLATFORM(COCOA)
    … …  
    9798    };
    9899
    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
    105102    void destroyPlugin();
    106103
    107104    bool isBeingDestroyed() const { return m_isBeingDestroyed; }
    108105
    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;
    112108
    113109    virtual ~Plugin();
    … …  
    318314
    319315private:
    320     PluginController* m_pluginController;
     316    WeakPtr<PluginController> m_pluginController;
    321317};
    322318   
  • trunk/Source/WebKit/WebProcess/Plugins/PluginController.h

    r265753 r268989  
    2727
    2828#include <wtf/Forward.h>
     29#include <wtf/WeakPtr.h>
    2930
    3031#if PLATFORM(COCOA)
    … …  
    4849namespace WebKit {
    4950
    50 class PluginController {
     51class PluginController : public CanMakeWeakPtr<PluginController> {
    5152public:
    5253    // 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  
    6565    void didReceiveSyncPluginProxyMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);
    6666
    67     bool isBeingAsynchronouslyInitialized() const override { return m_waitingOnAsynchronousInitialization; }
    68 
    6967private:
    7068    explicit PluginProxy(uint64_t pluginProcessToken, bool isRestartedProcess);
  • trunk/Source/WebKit/WebProcess/Plugins/PluginView.cpp

    r267916 r268989  
    335335    // Cancel all pending frame loads.
    336336    for (FrameLoadMap::iterator it = m_pendingFrameLoads.begin(), end = m_pendingFrameLoads.end(); it != end; ++it)
    337         it->key->setLoadListener(0);
     337        it->key->setLoadListener(nullptr);
    338338
    339339    if (m_plugin) {
    … …  
    602602    m_didPlugInStartOffScreen = !m_webPage->plugInIntersectsSearchRect(plugInImageElement);
    603603#endif
    604     m_plugin->initialize(this, m_parameters);
     604    m_plugin->initialize(*this, m_parameters);
    605605   
    606606    // Plug-in initialization continued in didFailToInitializePlugin() or didInitializePlugin().
    … …  
    16671667    RefPtr<URLRequest> request = m_pendingFrameLoads.take(webFrame);
    16681668    ASSERT(request);
    1669     webFrame->setLoadListener(0);
     1669    webFrame->setLoadListener(nullptr);
    16701670
    16711671    m_plugin->frameDidFinishLoading(request->requestID());
    … …  
    16761676    RefPtr<URLRequest> request = m_pendingFrameLoads.take(webFrame);
    16771677    ASSERT(request);
    1678     webFrame->setLoadListener(0);
     1678    webFrame->setLoadListener(nullptr);
    16791679   
    16801680    m_plugin->frameDidFail(request->requestID(), wasCancelled);
  • trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h

    r268239 r268989  
    4141#include <wtf/RefPtr.h>
    4242#include <wtf/RetainPtr.h>
     43#include <wtf/WeakPtr.h>
    4344
    4445namespace API {
    … …  
    150151
    151152    // Simple listener class used by plug-ins to know when frames finish or fail loading.
    152     class LoadListener {
     153    class LoadListener : public CanMakeWeakPtr<LoadListener> {
    153154    public:
    154155        virtual ~LoadListener() { }
    … …  
    157158        virtual void didFailLoad(WebFrame*, bool wasCancelled) = 0;
    158159    };
    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(); }
    161162   
    162163#if PLATFORM(COCOA)
    … …  
    193194    Optional<DownloadID> m_policyDownloadID;
    194195
    195     LoadListener* m_loadListener { nullptr };
     196    WeakPtr<LoadListener> m_loadListener;
    196197   
    197198    WebCore::FrameIdentifier m_frameID;
Note: See TracChangeset for help on using the changeset viewer.