Changeset 176924 in webkit


Ignore:
Timestamp:
Dec 7, 2014 9:28:01 AM (9 years ago)
Author:
mitz@apple.com
Message:

Introduce and deploy a function that allocates and returns an instance of a soft-linked class
https://bugs.webkit.org/show_bug.cgi?id=139348

Reviewed by Anders Carlsson.

In [[getFooClass() alloc] init*], the type of the result of +alloc is id, so the compiler
picks an arbitrary declaration of init*, not necessarily the Foo one. This can then lead
to warnings or errors if the types or attributes don’t match, or to runtime errors if Foo
doesn’t even have the expected initializer. The new allocFooInstance() returns a Foo *, thus
avoiding the ambiguity.

Source/WebCore:

  • editing/mac/DataDetection.mm:

(WebCore::DataDetection::detectItemAroundHitTestResult):

  • platform/audio/ios/MediaSessionManagerIOS.mm:

(-[WebMediaSessionHelper allocateVolumeView]):
(-[WebMediaSessionHelper startMonitoringAirPlayRoutes]):

  • platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:

(WebCore::AudioSourceProviderAVFObjC::createMix):

  • platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm:
  • platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoOutput):

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::streamSession):

  • platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:

(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::abort):
(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):

  • platform/graphics/ca/mac/PlatformCALayerMac.mm:

(PlatformCALayerMac::PlatformCALayerMac): Cast the result of +alloc to an instance of the
expected class.

  • platform/graphics/mac/FontMac.mm:

(WebCore::showLetterpressedGlyphsWithAdvances):

  • platform/graphics/mac/MediaPlayerPrivateQTKit.mm:

(WebCore::MediaPlayerPrivateQTKit::createQTMovie):
(WebCore::MediaPlayerPrivateQTKit::createQTMovieLayer):

  • platform/graphics/mac/PDFDocumentImageMac.mm:

(WebCore::PDFDocumentImage::createPDFDocument):

  • platform/ios/PlatformSpeechSynthesizerIOS.mm:

(SOFT_LINK_CONSTANT):
(-[WebSpeechSynthesisWrapper speakUtterance:]):

  • platform/ios/WebCoreMotionManager.mm:

(-[WebCoreMotionManager initializeOnMainThread]):

  • platform/ios/WebVideoFullscreenInterfaceAVKit.mm:

(-[WebAVPlayerController init]):
(WebVideoFullscreenInterfaceAVKit::setupFullscreen):

  • platform/mac/ContentFilterMac.mm:

(WebCore::ContentFilter::ContentFilter):

  • platform/mac/SoftLinking.h: Added alloc##className##instance().
  • platform/mac/WebVideoFullscreenController.mm:

(-[WebVideoFullscreenController setVideoElement:]):

  • platform/mediastream/mac/AVAudioCaptureSource.mm:

(WebCore::AVAudioCaptureSource::setupCaptureSession):

  • platform/mediastream/mac/AVCaptureDeviceManager.mm:

(WebCore::AVCaptureDeviceManager::verifyConstraintsForMediaType):

  • platform/mediastream/mac/AVMediaCaptureSource.mm:

(WebCore::AVMediaCaptureSource::setupSession):

  • platform/mediastream/mac/AVVideoCaptureSource.mm:

(WebCore::AVVideoCaptureSource::setupCaptureSession):

  • platform/network/ios/QuickLook.mm:

(WebCore::registerQLPreviewConverterIfNeeded):
(WebCore::QuickLookHandle::QuickLookHandle):

Source/WebKit/ios:

  • Misc/WebGeolocationCoreLocationProvider.mm:

(-[WebGeolocationCoreLocationProvider createLocationManager]):

Source/WebKit/mac:

  • WebView/WebActionMenuController.mm:

(-[WebActionMenuController _defaultMenuItemsForDataDetectableLink]):

Source/WebKit2:

  • UIProcess/ios/forms/WKAirPlayRoutePicker.mm:

(-[WKAirPlayRoutePicker showAirPlayPickerIPad:fromRect:]):
(-[WKAirPlayRoutePicker showAirPlayPickerIPhone:]):
(-[WKAirPlayRoutePicker show:fromRect:]):

  • UIProcess/ios/forms/WKFileUploadPanel.mm:

(-[_WKVideoFileUploadItem displayImage]):

  • UIProcess/mac/WKActionMenuController.mm:

(-[WKActionMenuController _defaultMenuItemsForDataDetectableLink]):

  • WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:

(WebKit::PlatformCALayerRemoteCustom::clone):

Location:
trunk/Source
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176920 r176924  
     12014-12-07  Dan Bernstein  <mitz@apple.com>
     2
     3        Introduce and deploy a function that allocates and returns an instance of a soft-linked class
     4        https://bugs.webkit.org/show_bug.cgi?id=139348
     5
     6        Reviewed by Anders Carlsson.
     7
     8        In [[getFooClass() alloc] init*], the type of the result of +alloc is id, so the compiler
     9        picks an arbitrary declaration of init*, not necessarily the Foo one. This can then lead
     10        to warnings or errors if the types or attributes don’t match, or to runtime errors if Foo
     11        doesn’t even have the expected initializer. The new allocFooInstance() returns a Foo *, thus
     12        avoiding the ambiguity.
     13
     14        * editing/mac/DataDetection.mm:
     15        (WebCore::DataDetection::detectItemAroundHitTestResult):
     16        * platform/audio/ios/MediaSessionManagerIOS.mm:
     17        (-[WebMediaSessionHelper allocateVolumeView]):
     18        (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]):
     19        * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
     20        (WebCore::AudioSourceProviderAVFObjC::createMix):
     21        * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm:
     22        * platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm:
     23        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     24        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer):
     25        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
     26        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer):
     27        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem):
     28        (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoOutput):
     29        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     30        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
     31        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
     32        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::streamSession):
     33        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
     34        (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
     35        (WebCore::SourceBufferPrivateAVFObjC::abort):
     36        (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
     37
     38        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
     39        (PlatformCALayerMac::PlatformCALayerMac): Cast the result of +alloc to an instance of the
     40        expected class.
     41
     42        * platform/graphics/mac/FontMac.mm:
     43        (WebCore::showLetterpressedGlyphsWithAdvances):
     44        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
     45        (WebCore::MediaPlayerPrivateQTKit::createQTMovie):
     46        (WebCore::MediaPlayerPrivateQTKit::createQTMovieLayer):
     47        * platform/graphics/mac/PDFDocumentImageMac.mm:
     48        (WebCore::PDFDocumentImage::createPDFDocument):
     49        * platform/ios/PlatformSpeechSynthesizerIOS.mm:
     50        (SOFT_LINK_CONSTANT):
     51        (-[WebSpeechSynthesisWrapper speakUtterance:]):
     52        * platform/ios/WebCoreMotionManager.mm:
     53        (-[WebCoreMotionManager initializeOnMainThread]):
     54        * platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
     55        (-[WebAVPlayerController init]):
     56        (WebVideoFullscreenInterfaceAVKit::setupFullscreen):
     57        * platform/mac/ContentFilterMac.mm:
     58        (WebCore::ContentFilter::ContentFilter):
     59
     60        * platform/mac/SoftLinking.h: Added alloc##className##instance().
     61
     62        * platform/mac/WebVideoFullscreenController.mm:
     63        (-[WebVideoFullscreenController setVideoElement:]):
     64        * platform/mediastream/mac/AVAudioCaptureSource.mm:
     65        (WebCore::AVAudioCaptureSource::setupCaptureSession):
     66        * platform/mediastream/mac/AVCaptureDeviceManager.mm:
     67        (WebCore::AVCaptureDeviceManager::verifyConstraintsForMediaType):
     68        * platform/mediastream/mac/AVMediaCaptureSource.mm:
     69        (WebCore::AVMediaCaptureSource::setupSession):
     70        * platform/mediastream/mac/AVVideoCaptureSource.mm:
     71        (WebCore::AVVideoCaptureSource::setupCaptureSession):
     72        * platform/network/ios/QuickLook.mm:
     73        (WebCore::registerQLPreviewConverterIfNeeded):
     74        (WebCore::QuickLookHandle::QuickLookHandle):
     75
    1762014-12-07  Carlos Garcia Campos  <cgarcia@igalia.com>
    277
  • trunk/Source/WebCore/editing/mac/DataDetection.mm

    r176156 r176924  
    8686        return nullptr;
    8787
    88     RetainPtr<DDActionContext> actionContext = adoptNS([[getDDActionContextClass() alloc] init]);
     88    RetainPtr<DDActionContext> actionContext = adoptNS([allocDDActionContextInstance() init]);
    8989    [actionContext setAllResults:@[ (id)mainResult ]];
    9090    [actionContext setMainResult:mainResult];
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

    r176471 r176924  
    242242    }
    243243
    244     _volumeView = adoptNS([[getMPVolumeViewClass() alloc] init]);
     244    _volumeView = adoptNS([allocMPVolumeViewInstance() init]);
    245245    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wirelessRoutesAvailableDidChange:) name:MPVolumeViewWirelessRoutesAvailableDidChangeNotification object:_volumeView.get()];
    246246   
     
    325325            return;
    326326
    327         strongSelf->_airPlayPresenceRoutingController = adoptNS([[getMPAVRoutingControllerClass() alloc] initWithName:@"WebCore - HTML media element checking for AirPlay route presence"]);
     327        strongSelf->_airPlayPresenceRoutingController = adoptNS([allocMPAVRoutingControllerInstance() initWithName:@"WebCore - HTML media element checking for AirPlay route presence"]);
    328328        [strongSelf->_airPlayPresenceRoutingController setDiscoveryMode:MPRouteDiscoveryModePresence];
    329329    });
  • trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm

    r176910 r176924  
    185185    ASSERT(m_client);
    186186
    187     m_avAudioMix = adoptNS([(AVMutableAudioMix *)[getAVMutableAudioMixClass() alloc] init]);
     187    m_avAudioMix = adoptNS([allocAVMutableAudioMixInstance() init]);
    188188
    189189    MTAudioProcessingTapCallbacks callbacks = {
     
    202202    ASSERT(m_tap == tap);
    203203
    204     RetainPtr<AVMutableAudioMixInputParameters> parameters = adoptNS([(AVMutableAudioMixInputParameters *)[getAVMutableAudioMixInputParametersClass() alloc] init]);
     204    RetainPtr<AVMutableAudioMixInputParameters> parameters = adoptNS([allocAVMutableAudioMixInputParametersInstance() init]);
    205205    [parameters setAudioTapProcessor:m_tap.get()];
    206206
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm

    r164514 r176924  
    3939#import <objc/objc-runtime.h>
    4040
    41 namespace WebCore {
    42 
    4341SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
    4442SOFT_LINK_CLASS(AVFoundation, AVURLAsset)
     
    4644#define AVURLAsset getAVURLAssetClass()
    4745#define AVAssetResourceLoadingRequest getAVAssetResourceLoadingRequest()
     46
     47namespace WebCore {
    4848
    4949CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC(MediaPlayerPrivateAVFoundationObjC* parent)
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm

    r170379 r176924  
    4141SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
    4242
    43 #define AVPlayer getAVPlayerClass()
    44 #define AVPlayerItem getAVPlayerItemClass()
    45 
    4643SOFT_LINK_CLASS(AVFoundation, AVPlayer)
    4744SOFT_LINK_CLASS(AVFoundation, AVPlayerItem)
     
    6663SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicEasyToRead, NSString *)
    6764
     65#define AVPlayer getAVPlayerClass()
     66#define AVPlayerItem getAVPlayerItemClass()
    6867#define AVMetadataItem getAVMetadataItemClass()
    6968#define AVPlayerItemLegibleOutput getAVPlayerItemLegibleOutputClass()
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/InbandTextTrackPrivateLegacyAVFObjC.mm

    r170379 r176924  
    3838
    3939SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
    40 #define AVPlayerItem getAVPlayerItemClass()
    4140
    4241SOFT_LINK_CLASS(AVFoundation, AVPlayerItem)
     
    4948SOFT_LINK_POINTER(AVFoundation, AVMetadataKeySpaceCommon, NSString *)
    5049
     50#define AVPlayerItem getAVPlayerItemClass()
    5151#define AVMetadataItem getAVMetadataItemClass()
    5252#define AVMediaCharacteristicLegible getAVMediaCharacteristicLegible()
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r176725 r176924  
    614614        return;
    615615
    616     m_videoLayer = adoptNS([[AVPlayerLayer alloc] init]);
     616    m_videoLayer = adoptNS([allocAVPlayerLayerInstance() init]);
    617617    [m_videoLayer setPlayer:m_avPlayer.get()];
    618618    [m_videoLayer setBackgroundColor:cachedCGColor(Color::black, ColorSpaceDeviceRGB)];
     
    839839
    840840    NSURL *cocoaURL = canonicalURL(url);
    841     m_avAsset = adoptNS([[AVURLAsset alloc] initWithURL:cocoaURL options:options.get()]);
     841    m_avAsset = adoptNS([allocAVURLAssetInstance() initWithURL:cocoaURL options:options.get()]);
    842842
    843843#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
     
    876876    setDelayCallbacks(true);
    877877
    878     m_avPlayer = adoptNS([[AVPlayer alloc] init]);
     878    m_avPlayer = adoptNS([allocAVPlayerInstance() init]);
    879879    [m_avPlayer.get() addObserver:m_objcObserver.get() forKeyPath:@"rate" options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextPlayer];
    880880#if ENABLE(IOS_AIRPLAY)
     
    910910
    911911    // Create the player item so we can load media data.
    912     m_avPlayerItem = adoptNS([[AVPlayerItem alloc] initWithAsset:m_avAsset.get()]);
     912    m_avPlayerItem = adoptNS([allocAVPlayerItemInstance() initWithAsset:m_avAsset.get()]);
    913913
    914914    [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get() selector:@selector(didEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:m_avPlayerItem.get()];
     
    931931
    932932    RetainPtr<NSArray> subtypes = adoptNS([[NSArray alloc] initWithObjects:[NSNumber numberWithUnsignedInt:kCMSubtitleFormatType_WebVTT], nil]);
    933     m_legibleOutput = adoptNS([[AVPlayerItemLegibleOutput alloc] initWithMediaSubtypesForNativeRepresentation:subtypes.get()]);
     933    m_legibleOutput = adoptNS([allocAVPlayerItemLegibleOutputInstance() initWithMediaSubtypesForNativeRepresentation:subtypes.get()]);
    934934    [m_legibleOutput.get() setSuppressesPlayerRendering:YES];
    935935
     
    20322032                                nil];
    20332033#endif
    2034     m_videoOutput = adoptNS([[getAVPlayerItemVideoOutputClass() alloc] initWithPixelBufferAttributes:attributes]);
     2034    m_videoOutput = adoptNS([allocAVPlayerItemVideoOutputInstance() initWithPixelBufferAttributes:attributes]);
    20352035    ASSERT(m_videoOutput);
    20362036
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r176459 r176924  
    144144    : m_player(player)
    145145    , m_weakPtrFactory(this)
    146     , m_synchronizer(adoptNS([[getAVSampleBufferRenderSynchronizerClass() alloc] init]))
     146    , m_synchronizer(adoptNS([allocAVSampleBufferRenderSynchronizerInstance() init]))
    147147    , m_seekTimer(*this, &MediaPlayerPrivateMediaSourceAVFObjC::seekTimerFired)
    148148    , m_session(nullptr)
     
    608608        return;
    609609
    610     m_sampleBufferDisplayLayer = adoptNS([[getAVSampleBufferDisplayLayerClass() alloc] init]);
     610    m_sampleBufferDisplayLayer = adoptNS([allocAVSampleBufferDisplayLayerInstance() init]);
    611611#ifndef NDEBUG
    612612    [m_sampleBufferDisplayLayer setName:@"MediaPlayerPrivateMediaSource AVSampleBufferDisplayLayer"];
     
    696696
    697697        String storagePath = pathByAppendingComponent(storageDirectory, "SecureStop.plist");
    698         m_streamSession = adoptNS([[getAVStreamSessionClass() alloc] initWithStorageDirectoryAtURL:[NSURL fileURLWithPath:storagePath]]);
     698        m_streamSession = adoptNS([allocAVStreamSessionInstance() initWithStorageDirectoryAtURL:[NSURL fileURLWithPath:storagePath]]);
    699699    }
    700700    return m_streamSession.get();
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm

    r175284 r176924  
    581581SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC* parent)
    582582    : m_weakFactory(this)
    583     , m_parser(adoptNS([[getAVStreamDataParserClass() alloc] init]))
     583    , m_parser(adoptNS([allocAVStreamDataParserInstance() init]))
    584584    , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:createWeakPtr()]))
    585585    , m_errorListener(adoptNS([[WebAVSampleBufferErrorListener alloc] initWithParent:this]))
     
    778778    destroyParser();
    779779
    780     m_parser = adoptNS([[getAVStreamDataParserClass() alloc] init]);
     780    m_parser = adoptNS([allocAVStreamDataParserInstance() init]);
    781781    m_delegate = adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:createWeakPtr()]);
    782782}
     
    863863        [m_parser setShouldProvideMediaData:YES forTrackID:trackID];
    864864        if (!m_displayLayer) {
    865             m_displayLayer = adoptNS([[getAVSampleBufferDisplayLayerClass() alloc] init]);
     865            m_displayLayer = adoptNS([allocAVSampleBufferDisplayLayerInstance() init]);
    866866            [m_displayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^{
    867867                didBecomeReadyForMoreSamples(trackID);
     
    887887        RetainPtr<AVSampleBufferAudioRenderer> renderer;
    888888        if (!m_audioRenderers.count(trackID)) {
    889             renderer = adoptNS([[getAVSampleBufferAudioRendererClass() alloc] init]);
     889            renderer = adoptNS([allocAVSampleBufferAudioRendererInstance() init]);
    890890            [renderer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^{
    891891                didBecomeReadyForMoreSamples(trackID);
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm

    r176204 r176924  
    255255
    256256    if (layerClass)
    257         m_layer = adoptNS([[layerClass alloc] init]);
     257        m_layer = adoptNS([(CALayer *)[layerClass alloc] init]);
    258258
    259259    commonInit();
  • trunk/Source/WebCore/platform/graphics/mac/FontMac.mm

    r176910 r176924  
    115115    static CUIStyleEffectConfiguration *styleConfiguration;
    116116    if (!styleConfiguration) {
    117         styleConfiguration = [(CUIStyleEffectConfiguration *)[getCUIStyleEffectConfigurationClass() alloc] init];
     117        styleConfiguration = [allocCUIStyleEffectConfigurationInstance() init];
    118118        styleConfiguration.useSimplifiedEffect = YES;
    119119    }
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

    r176459 r176924  
    330330   
    331331    NSError *error = nil;
    332     m_qtMovie = adoptNS([[QTMovie alloc] initWithAttributes:movieAttributes error:&error]);
     332    m_qtMovie = adoptNS([allocQTMovieInstance() initWithAttributes:movieAttributes error:&error]);
    333333   
    334334    if (!m_qtMovie)
     
    426426   
    427427    if (!m_qtVideoLayer) {
    428         m_qtVideoLayer = adoptNS([[QTMovieLayer alloc] init]);
     428        m_qtVideoLayer = adoptNS([allocQTMovieLayerInstance() init]);
    429429        if (!m_qtVideoLayer)
    430430            return;
  • trunk/Source/WebCore/platform/graphics/mac/PDFDocumentImageMac.mm

    r161568 r176924  
    5454void PDFDocumentImage::createPDFDocument()
    5555{
    56     m_document = adoptNS([[getPDFDocumentClass() alloc] initWithData:data()->createNSData().get()]);
     56    m_document = adoptNS([allocPDFDocumentInstance() initWithData:data()->createNSData().get()]);
    5757}
    5858
  • trunk/Source/WebCore/platform/ios/PlatformSpeechSynthesizerIOS.mm

    r176910 r176924  
    4747#define AVSpeechUtteranceMaximumSpeechRate getAVSpeechUtteranceMaximumSpeechRate()
    4848
    49 #define AVSpeechSynthesizerClass getAVSpeechSynthesizerClass()
    5049#define AVSpeechUtteranceClass getAVSpeechUtteranceClass()
    5150#define AVSpeechSynthesisVoiceClass getAVSpeechSynthesisVoiceClass()
     
    9897   
    9998    if (!m_synthesizer) {
    100         m_synthesizer = adoptNS([(AVSpeechSynthesizer *)[AVSpeechSynthesizerClass alloc] init]);
     99        m_synthesizer = adoptNS([allocAVSpeechSynthesizerInstance() init]);
    101100        [m_synthesizer setDelegate:self];
    102101    }
  • trunk/Source/WebCore/platform/ios/WebCoreMotionManager.mm

    r176910 r176924  
    139139    ASSERT(!WebThreadIsCurrent());
    140140
    141     m_motionManager = [(CMMotionManager *)[getCMMotionManagerClass() alloc] init];
     141    m_motionManager = [allocCMMotionManagerInstance() init];
    142142
    143143    m_gyroAvailable = m_motionManager.deviceMotionAvailable;
     
    148148        m_motionManager.accelerometerUpdateInterval = kMotionUpdateInterval;
    149149
    150     m_locationManager = [(CLLocationManager *)[getCLLocationManagerClass() alloc] init];
     150    m_locationManager = [allocCLLocationManagerInstance() init];
    151151    m_headingAvailable = [getCLLocationManagerClass() headingAvailable];
    152152
  • trunk/Source/WebCore/platform/ios/WebVideoFullscreenInterfaceAVKit.mm

    r176841 r176924  
    136136   
    137137    initAVPlayerController();
    138     self.playerControllerProxy = [[[getAVPlayerControllerClass() alloc] init] autorelease];
     138    self.playerControllerProxy = [[allocAVPlayerControllerInstance() init] autorelease];
    139139    return self;
    140140}
     
    802802
    803803        if (!applicationIsAdSheet()) {
    804             m_window = adoptNS([[getUIWindowClass() alloc] initWithFrame:[[getUIScreenClass() mainScreen] bounds]]);
     804            m_window = adoptNS([allocUIWindowInstance() initWithFrame:[[getUIScreenClass() mainScreen] bounds]]);
    805805            [m_window setBackgroundColor:[getUIColorClass() clearColor]];
    806             m_viewController = adoptNS([[getUIViewControllerClass() alloc] init]);
     806            m_viewController = adoptNS([allocUIViewControllerInstance() init]);
    807807            [[m_viewController view] setFrame:[m_window bounds]];
    808808            [m_window setRootViewController:m_viewController.get()];
     
    820820        [m_videoLayerContainer setVideoRect:videoRect];
    821821
    822         m_playerViewController = adoptNS([[getAVPlayerViewControllerClass() alloc] initWithVideoLayer:m_videoLayerContainer.get()]);
     822        m_playerViewController = adoptNS([allocAVPlayerViewControllerInstance() initWithVideoLayer:m_videoLayerContainer.get()]);
    823823        [m_playerViewController setShowsPlaybackControls:NO];
    824824        [m_playerViewController setPlayerController:(AVPlayerController *)playerController()];
  • trunk/Source/WebCore/platform/mac/ContentFilterMac.mm

    r172293 r176924  
    101101{
    102102    if ([getWebFilterEvaluatorClass() isManagedSession])
    103         m_platformContentFilter = adoptNS([[getWebFilterEvaluatorClass() alloc] initWithResponse:response.nsURLResponse()]);
     103        m_platformContentFilter = adoptNS([allocWebFilterEvaluatorInstance() initWithResponse:response.nsURLResponse()]);
    104104
    105105#if HAVE(NE_FILTER_SOURCE)
    106106    if ([getNEFilterSourceClass() filterRequired]) {
    107         m_neFilterSource = adoptNS([[getNEFilterSourceClass() alloc] initWithURL:[response.nsURLResponse() URL] direction:NEFilterSourceDirectionInbound socketIdentifier:0]);
     107        m_neFilterSource = adoptNS([allocNEFilterSourceInstance() initWithURL:[response.nsURLResponse() URL] direction:NEFilterSourceDirectionInbound socketIdentifier:0]);
    108108        m_neFilterSourceQueue = dispatch_queue_create("com.apple.WebCore.NEFilterSourceQueue", DISPATCH_QUEUE_SERIAL);
    109109       
  • trunk/Source/WebCore/platform/mac/SoftLinking.h

    r175000 r176924  
    144144
    145145#define SOFT_LINK_CLASS(framework, className) \
     146    @class className; \
    146147    static Class init##className(); \
    147148    static Class (*get##className##Class)() = init##className; \
     
    160161        get##className##Class = className##Function; \
    161162        return class##className; \
    162     }
     163    } \
     164    _Pragma("clang diagnostic push") \
     165    _Pragma("clang diagnostic ignored \"-Wunused-function\"") \
     166    static className *alloc##className##Instance() \
     167    { \
     168        return [get##className##Class() alloc]; \
     169    } \
     170    _Pragma("clang diagnostic pop")
    163171
    164172#define SOFT_LINK_CLASS_OPTIONAL(framework, className) \
     173    @class className; \
    165174    static Class init##className(); \
    166175    static Class (*get##className##Class)() = init##className; \
     
    178187        get##className##Class = className##Function; \
    179188        return class##className; \
    180     }
     189    } \
     190    _Pragma("clang diagnostic push") \
     191    _Pragma("clang diagnostic ignored \"-Wunused-function\"") \
     192    static className *alloc##className##Instance() \
     193    { \
     194        return [get##className##Class() alloc]; \
     195    } \
     196    _Pragma("clang diagnostic pop")
    181197
    182198#define SOFT_LINK_POINTER(framework, name, type) \
  • trunk/Source/WebCore/platform/mac/WebVideoFullscreenController.mm

    r173230 r176924  
    130130        if (_videoElement->platformMedia().type == PlatformMedia::QTMovieType) {
    131131            QTMovie *movie = _videoElement->platformMedia().media.qtMovie;
    132             QTMovieLayer *layer = [[getQTMovieLayerClass() alloc] init];
     132            QTMovieLayer *layer = [allocQTMovieLayerInstance() init];
    133133            [layer setMovie:movie];
    134134            [self setupVideoOverlay:layer];
     
    141141        } else if (_videoElement->platformMedia().type == PlatformMedia::AVFoundationMediaPlayerType) {
    142142            AVPlayer *player = _videoElement->platformMedia().media.avfMediaPlayer;
    143             AVPlayerLayer *layer = [[getAVPlayerLayerClass() alloc] init];
     143            AVPlayerLayer *layer = [allocAVPlayerLayerInstance() init];
    144144            [self setupVideoOverlay:layer];
    145145            [layer setPlayer:player];
  • trunk/Source/WebCore/platform/mediastream/mac/AVAudioCaptureSource.mm

    r165676 r176924  
    5252SOFT_LINK_CLASS(AVFoundation, AVCaptureOutput)
    5353
    54 #define AVCaptureAudioDataOutput getAVCaptureAudioDataOutputClass()
    55 #define AVCaptureConnection getAVCaptureConnectionClass()
    56 #define AVCaptureDevice getAVCaptureDeviceClass()
    57 #define AVCaptureDeviceInput getAVCaptureDeviceInputClass()
    58 #define AVCaptureOutput getAVCaptureOutputClass()
    59 
    6054SOFT_LINK_POINTER(AVFoundation, AVMediaTypeAudio, NSString *)
    6155
     
    9387void AVAudioCaptureSource::setupCaptureSession()
    9488{
    95     RetainPtr<AVCaptureDeviceInputType> audioIn = adoptNS([[AVCaptureDeviceInput alloc] initWithDevice:device() error:nil]);
     89    RetainPtr<AVCaptureDeviceInputType> audioIn = adoptNS([allocAVCaptureDeviceInputInstance() initWithDevice:device() error:nil]);
    9690    ASSERT([session() canAddInput:audioIn.get()]);
    9791    if ([session() canAddInput:audioIn.get()])
    9892        [session() addInput:audioIn.get()];
    9993   
    100     RetainPtr<AVCaptureAudioDataOutputType> audioOutput = adoptNS([[AVCaptureAudioDataOutput alloc] init]);
     94    RetainPtr<AVCaptureAudioDataOutputType> audioOutput = adoptNS([allocAVCaptureAudioDataOutputInstance() init]);
    10195    setAudioSampleBufferDelegate(audioOutput.get());
    10296    ASSERT([session() canAddOutput:audioOutput.get()]);
  • trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm

    r168367 r176924  
    359359    constraints->getMandatoryConstraints(mandatoryConstraints);
    360360    if (mandatoryConstraints.size()) {
    361         RetainPtr<AVCaptureSessionType> session = adoptNS([[AVCaptureSession alloc] init]);
     361        RetainPtr<AVCaptureSessionType> session = adoptNS([allocAVCaptureSessionInstance() init]);
    362362        for (size_t i = 0; i < mandatoryConstraints.size(); ++i) {
    363363            const MediaConstraint& constraint = mandatoryConstraints[i];
  • trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm

    r168367 r176924  
    178178        return;
    179179
    180     m_session = adoptNS([[AVCaptureSession alloc] init]);
     180    m_session = adoptNS([allocAVCaptureSessionInstance() init]);
    181181   
    182182    [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get() selector:@selector(captureSessionStoppedRunning:) name:AVCaptureSessionDidStopRunningNotification object:nil];
  • trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm

    r165676 r176924  
    209209void AVVideoCaptureSource::setupCaptureSession()
    210210{
    211     RetainPtr<AVCaptureDeviceInputType> videoIn = adoptNS([[AVCaptureDeviceInput alloc] initWithDevice:device() error:nil]);
     211    RetainPtr<AVCaptureDeviceInputType> videoIn = adoptNS([allocAVCaptureDeviceInputInstance() initWithDevice:device() error:nil]);
    212212    ASSERT([session() canAddInput:videoIn.get()]);
    213213    if ([session() canAddInput:videoIn.get()])
     
    217217        applyConstraints(constraints());
    218218
    219     RetainPtr<AVCaptureVideoDataOutputType> videoOutput = adoptNS([[AVCaptureVideoDataOutput alloc] init]);
     219    RetainPtr<AVCaptureVideoDataOutputType> videoOutput = adoptNS([allocAVCaptureVideoDataOutputInstance() init]);
    220220    setVideoSampleBufferDelegate(videoOutput.get());
    221221    ASSERT([session() canAddOutput:videoOutput.get()]);
  • trunk/Source/WebCore/platform/network/ios/QuickLook.mm

    r176142 r176924  
    196196        RetainPtr<NSString> uti = adoptNS(WebCore::QLTypeCopyUTIForURLAndMimeType(url, updatedMIMEType.get()));
    197197
    198         RetainPtr<id> converter = adoptNS([[QLPreviewConverterClass() alloc] initWithData:data name:nil uti:uti.get() options:nil]);
     198        RetainPtr<id> converter = adoptNS([allocQLPreviewConverterInstance() initWithData:data name:nil uti:uti.get() options:nil]);
    199199        NSURLRequest *request = [converter previewRequest];
    200200
     
    448448QuickLookHandle::QuickLookHandle(NSURL *firstRequestURL, NSURLConnection *connection, NSURLResponse *nsResponse, id delegate)
    449449    : m_firstRequestURL(firstRequestURL)
    450     , m_converter(adoptNS([[QLPreviewConverterClass() alloc] initWithConnection:connection delegate:delegate response:nsResponse options:nil]))
     450    , m_converter(adoptNS([allocQLPreviewConverterInstance() initWithConnection:connection delegate:delegate response:nsResponse options:nil]))
    451451    , m_delegate(delegate)
    452452    , m_finishedLoadingDataIntoConverter(false)
  • trunk/Source/WebKit/ios/ChangeLog

    r176912 r176924  
     12014-12-07  Dan Bernstein  <mitz@apple.com>
     2
     3        Introduce and deploy a function that allocates and returns an instance of a soft-linked class
     4        https://bugs.webkit.org/show_bug.cgi?id=139348
     5
     6        Reviewed by Anders Carlsson.
     7
     8        In [[getFooClass() alloc] init*], the type of the result of +alloc is id, so the compiler
     9        picks an arbitrary declaration of init*, not necessarily the Foo one. This can then lead
     10        to warnings or errors if the types or attributes don’t match, or to runtime errors if Foo
     11        doesn’t even have the expected initializer. The new allocFooInstance() returns a Foo *, thus
     12        avoiding the ambiguity.
     13
     14        * Misc/WebGeolocationCoreLocationProvider.mm:
     15        (-[WebGeolocationCoreLocationProvider createLocationManager]):
     16
    1172014-12-06  Anders Carlsson  <andersca@apple.com>
    218
  • trunk/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.mm

    r176912 r176924  
    6666    ASSERT(!_locationManager);
    6767
    68     _locationManager = adoptNS([(CLLocationManager *)[getCLLocationManagerClass() alloc] init]);
     68    _locationManager = adoptNS([allocCLLocationManagerInstance() init]);
    6969    _lastAuthorizationStatus = [getCLLocationManagerClass() authorizationStatus];
    7070
  • trunk/Source/WebKit/mac/ChangeLog

    r176913 r176924  
     12014-12-07  Dan Bernstein  <mitz@apple.com>
     2
     3        Introduce and deploy a function that allocates and returns an instance of a soft-linked class
     4        https://bugs.webkit.org/show_bug.cgi?id=139348
     5
     6        Reviewed by Anders Carlsson.
     7
     8        In [[getFooClass() alloc] init*], the type of the result of +alloc is id, so the compiler
     9        picks an arbitrary declaration of init*, not necessarily the Foo one. This can then lead
     10        to warnings or errors if the types or attributes don’t match, or to runtime errors if Foo
     11        doesn’t even have the expected initializer. The new allocFooInstance() returns a Foo *, thus
     12        avoiding the ambiguity.
     13
     14        * WebView/WebActionMenuController.mm:
     15        (-[WebActionMenuController _defaultMenuItemsForDataDetectableLink]):
     16
    1172014-12-06  Anders Carlsson  <andersca@apple.com>
    218
  • trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm

    r176777 r176924  
    293293        return @[ ];
    294294
    295     RetainPtr<DDActionContext> actionContext = [[getDDActionContextClass() alloc] init];
     295    RetainPtr<DDActionContext> actionContext = [allocDDActionContextInstance() init];
    296296
    297297    // FIXME: Should this show a yellow highlight?
  • trunk/Source/WebKit2/ChangeLog

    r176915 r176924  
     12014-12-07  Dan Bernstein  <mitz@apple.com>
     2
     3        Introduce and deploy a function that allocates and returns an instance of a soft-linked class
     4        https://bugs.webkit.org/show_bug.cgi?id=139348
     5
     6        Reviewed by Anders Carlsson.
     7
     8        In [[getFooClass() alloc] init*], the type of the result of +alloc is id, so the compiler
     9        picks an arbitrary declaration of init*, not necessarily the Foo one. This can then lead
     10        to warnings or errors if the types or attributes don’t match, or to runtime errors if Foo
     11        doesn’t even have the expected initializer. The new allocFooInstance() returns a Foo *, thus
     12        avoiding the ambiguity.
     13
     14        * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
     15        (-[WKAirPlayRoutePicker showAirPlayPickerIPad:fromRect:]):
     16        (-[WKAirPlayRoutePicker showAirPlayPickerIPhone:]):
     17        (-[WKAirPlayRoutePicker show:fromRect:]):
     18        * UIProcess/ios/forms/WKFileUploadPanel.mm:
     19        (-[_WKVideoFileUploadItem displayImage]):
     20        * UIProcess/mac/WKActionMenuController.mm:
     21        (-[WKActionMenuController _defaultMenuItemsForDataDetectableLink]):
     22        * WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm:
     23        (WebKit::PlatformCALayerRemoteCustom::clone):
     24
    1252014-12-06  Anders Carlsson  <andersca@apple.com>
    226
  • trunk/Source/WebKit2/UIProcess/ios/forms/WKAirPlayRoutePicker.mm

    r176448 r176924  
    114114        return;
    115115
    116     _popoverController = adoptNS([(MPAudioVideoRoutingPopoverController *)[getMPAudioVideoRoutingPopoverControllerClass() alloc] initWithType:itemType]);
     116    _popoverController = adoptNS([allocMPAudioVideoRoutingPopoverControllerInstance() initWithType:itemType]);
    117117    [_popoverController setDelegate:self];
    118118
     
    129129        return;
    130130
    131     _actionSheet = adoptNS([(MPAudioVideoRoutingActionSheet *)[getMPAudioVideoRoutingActionSheetClass() alloc] initWithType:itemType]);
     131    _actionSheet = adoptNS([allocMPAudioVideoRoutingActionSheetInstance() initWithType:itemType]);
    132132
    133133    [_actionSheet
     
    144144- (void)show:(BOOL)hasVideo fromRect:(CGRect)elementRect
    145145{
    146     _routingController = adoptNS([(MPAVRoutingController *)[getMPAVRoutingControllerClass() alloc] initWithName:@"WebKit2 - HTML media element showing AirPlay route picker"]);
     146    _routingController = adoptNS([allocMPAVRoutingControllerInstance() initWithName:@"WebKit2 - HTML media element showing AirPlay route picker"]);
    147147    [_routingController setDiscoveryMode:MPRouteDiscoveryModeDetailed];
    148148
  • trunk/Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.mm

    r170952 r176924  
    5757SOFT_LINK_CLASS(AVFoundation, AVAssetImageGenerator);
    5858SOFT_LINK_CLASS(AVFoundation, AVURLAsset);
    59 #define AVAssetImageGenerator_class getAVAssetImageGeneratorClass()
    60 #define AVURLAsset_class getAVURLAssetClass()
    6159
    6260SOFT_LINK_FRAMEWORK(CoreMedia);
     
    208206- (UIImage *)displayImage
    209207{
    210     RetainPtr<AVURLAsset> asset = adoptNS([[AVURLAsset_class alloc] initWithURL:_mediaURL.get() options:nil]);
    211     RetainPtr<AVAssetImageGenerator> generator = adoptNS([[AVAssetImageGenerator_class alloc] initWithAsset:asset.get()]);
     208    RetainPtr<AVURLAsset> asset = adoptNS([allocAVURLAssetInstance() initWithURL:_mediaURL.get() options:nil]);
     209    RetainPtr<AVAssetImageGenerator> generator = adoptNS([allocAVAssetImageGeneratorInstance() initWithAsset:asset.get()]);
    212210    [generator setAppliesPreferredTrackTransform:YES];
    213211
  • trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm

    r176883 r176924  
    865865{
    866866    RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
    867     RetainPtr<DDActionContext> actionContext = [[getDDActionContextClass() alloc] init];
     867    RetainPtr<DDActionContext> actionContext = [allocDDActionContextInstance() init];
    868868
    869869    // FIXME: Should this show a yellow highlight?
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemoteCustom.mm

    r173702 r176924  
    105105
    106106    if (layerType() == LayerTypeAVPlayerLayer) {
    107         clonedLayer = adoptNS([[getAVPlayerLayerClass() alloc] init]);
     107        clonedLayer = adoptNS([allocAVPlayerLayerInstance() init]);
    108108
    109109        AVPlayerLayer* destinationPlayerLayer = static_cast<AVPlayerLayer *>(clonedLayer.get());
Note: See TracChangeset for help on using the changeset viewer.