Changeset 98285 in webkit


Ignore:
Timestamp:
Oct 24, 2011, 3:07:24 PM (14 years ago)
Author:
weinig@apple.com
Message:

Hook up minimalist load delegate to WKBrowsingContextController
https://bugs.webkit.org/show_bug.cgi?id=70764

Reviewed by Simon Fraser.

  • UIProcess/API/mac/WKBrowsingContextController.h:
  • UIProcess/API/mac/WKBrowsingContextController.mm:

(-[WKBrowsingContextController loadDelegate]):
(-[WKBrowsingContextController setLoadDelegate:]):
Add loadDelegate getter/setter. As per convention, the delegate is not
retained.

(didStartProvisionalLoadForFrame):
(didCommitLoadForFrame):
(didFinishLoadForFrame):
(setUpPageLoaderClient):
(-[WKBrowsingContextController initWithPageRef:]):
Hookup the delegate to a WKPageLoaderClient.

  • UIProcess/API/mac/WKBrowsingContextLoadDelegate.h: Added.

Add load delegate as a proper protocol.

  • WebKit2.xcodeproj/project.pbxproj:

Add new file.

Location:
trunk/Source/WebKit2
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r98280 r98285  
     12011-10-24  Sam Weinig  <sam@webkit.org>
     2
     3        Hook up minimalist load delegate to WKBrowsingContextController
     4        https://bugs.webkit.org/show_bug.cgi?id=70764
     5
     6        Reviewed by Simon Fraser.
     7
     8        * UIProcess/API/mac/WKBrowsingContextController.h:
     9        * UIProcess/API/mac/WKBrowsingContextController.mm:
     10        (-[WKBrowsingContextController loadDelegate]):
     11        (-[WKBrowsingContextController setLoadDelegate:]):
     12        Add loadDelegate getter/setter. As per convention, the delegate is not
     13        retained.
     14
     15        (didStartProvisionalLoadForFrame):
     16        (didCommitLoadForFrame):
     17        (didFinishLoadForFrame):
     18        (setUpPageLoaderClient):
     19        (-[WKBrowsingContextController initWithPageRef:]):
     20        Hookup the delegate to a WKPageLoaderClient.
     21
     22        * UIProcess/API/mac/WKBrowsingContextLoadDelegate.h: Added.
     23        Add load delegate as a proper protocol.
     24
     25        * WebKit2.xcodeproj/project.pbxproj:
     26        Add new file.
     27
    1282011-10-24  Michael Saboff  <msaboff@apple.com>
    229
  • trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h

    r98270 r98285  
    2828
    2929@class WKBrowsingContextControllerData;
     30@protocol WKBrowsingContextLoadDelegate;
    3031
    3132WK_EXPORT
     
    3435    WKBrowsingContextControllerData *_data;
    3536}
     37
     38#pragma mark Delegates
     39
     40@property(assign) id<WKBrowsingContextLoadDelegate> loadDelegate;
     41
    3642
    3743#pragma mark Loading
  • trunk/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm

    r98270 r98285  
    3636#import "WKURLRequestNS.h"
    3737
     38#import "WKBrowsingContextLoadDelegate.h"
    3839
    3940static inline NSString *autoreleased(WKStringRef string)
     
    5253@interface WKBrowsingContextControllerData : NSObject {
    5354@public
     55    // Underlying WKPageRef.
    5456    WKRetainPtr<WKPageRef> _pageRef;
     57   
     58    // Delegate for load callbacks.
     59    id<WKBrowsingContextLoadDelegate> _loadDelegate;
    5560}
    5661@end
     
    7277}
    7378
     79#pragma mark Delegates
     80
     81- (id<WKBrowsingContextLoadDelegate>)loadDelegate
     82{
     83    return _data->_loadDelegate;
     84}
     85
     86- (void)setLoadDelegate:(id<WKBrowsingContextLoadDelegate>)loadDelegate
     87{
     88    _data->_loadDelegate = loadDelegate;
     89}
     90
     91
    7492#pragma mark Loading
    7593
     
    185203
    186204@implementation WKBrowsingContextController (Internal)
     205
     206static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
     207{
     208    if (!WKFrameIsMainFrame(frame))
     209        return;
     210
     211    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     212    [browsingContext.loadDelegate browsingContextControllerDidStartProvisionalLoad:browsingContext];
     213}
     214
     215static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
     216{
     217    if (!WKFrameIsMainFrame(frame))
     218        return;
     219
     220    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     221    [browsingContext.loadDelegate browsingContextControllerDidCommitLoad:browsingContext];
     222}
     223
     224static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
     225{
     226    if (!WKFrameIsMainFrame(frame))
     227        return;
     228
     229    WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
     230    [browsingContext.loadDelegate browsingContextControllerDidFinishLoad:browsingContext];
     231}
     232
     233static void setUpPageLoaderClient(WKBrowsingContextController *browsingContext, WKPageRef pageRef)
     234{
     235    WKPageLoaderClient loaderClient;
     236    memset(&loaderClient, 0, sizeof(loaderClient));
     237   
     238    loaderClient.version = kWKPageLoaderClientCurrentVersion;
     239    loaderClient.clientInfo = browsingContext;
     240    loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
     241    loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
     242    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
     243
     244    WKPageSetPageLoaderClient(pageRef, &loaderClient);
     245}
     246
    187247
    188248/* This should only be called from associate view. */
     
    197257    _data->_pageRef = pageRef;
    198258
     259    setUpPageLoaderClient(self, pageRef);
     260
    199261    return self;
    200262}
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r98184 r98285  
    696696                BCBAACF51452324F0053F82F /* WKBrowsingContextGroup.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCBAACEF145232440053F82F /* WKBrowsingContextGroup.mm */; };
    697697                BCBAACF61452324F0053F82F /* WKBrowsingContextGroupInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAACF0145232480053F82F /* WKBrowsingContextGroupInternal.h */; };
     698                BCBAAD0B14560A430053F82F /* WKBrowsingContextLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */; };
    698699                BCBCB0CB1215E32100DE59CA /* ImmutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = BCBCB0CA1215E32100DE59CA /* ImmutableDictionary.h */; };
    699700                BCBCB0CD1215E33A00DE59CA /* ImmutableDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCBCB0CC1215E33A00DE59CA /* ImmutableDictionary.cpp */; };
     
    727728                BCD597D1112B56AC00EC8C23 /* WKPreferences.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD597CF112B56AC00EC8C23 /* WKPreferences.cpp */; };
    728729                BCD597D6112B56DC00EC8C23 /* WKPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD597D4112B56DC00EC8C23 /* WKPage.cpp */; };
    729                 BCD597D7112B56DC00EC8C23 /* WKPage.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD597D5112B56DC00EC8C23 /* WKPage.h */; settings = {ATTRIBUTES = (Private, ); }; };
     730                BCD597D7112B56DC00EC8C23 /* WKPage.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD597D5112B56DC00EC8C23 /* WKPage.h */; settings = {ATTRIBUTES = (Public, ); }; };
    730731                BCD597FF112B57BE00EC8C23 /* WebPreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD597FD112B57BE00EC8C23 /* WebPreferences.h */; };
    731732                BCD59800112B57BE00EC8C23 /* WebPreferences.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD597FE112B57BE00EC8C23 /* WebPreferences.cpp */; };
     
    16611662                BCBAACEF145232440053F82F /* WKBrowsingContextGroup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBrowsingContextGroup.mm; sourceTree = "<group>"; };
    16621663                BCBAACF0145232480053F82F /* WKBrowsingContextGroupInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextGroupInternal.h; sourceTree = "<group>"; };
     1664                BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextLoadDelegate.h; sourceTree = "<group>"; };
    16631665                BCBCB0CA1215E32100DE59CA /* ImmutableDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImmutableDictionary.h; sourceTree = "<group>"; };
    16641666                BCBCB0CC1215E33A00DE59CA /* ImmutableDictionary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImmutableDictionary.cpp; sourceTree = "<group>"; };
     
    29352937                                BCBAACEF145232440053F82F /* WKBrowsingContextGroup.mm */,
    29362938                                BCBAACF0145232480053F82F /* WKBrowsingContextGroupInternal.h */,
     2939                                BCBAAD0A14560A430053F82F /* WKBrowsingContextLoadDelegate.h */,
    29372940                                BCBAACE5145225C90053F82F /* WKProcessGroup.h */,
    29382941                                BCBAACE6145225CA0053F82F /* WKProcessGroup.mm */,
     
    39243927                                BCBAACF41452324F0053F82F /* WKBrowsingContextGroup.h in Headers */,
    39253928                                BCBAACF61452324F0053F82F /* WKBrowsingContextGroupInternal.h in Headers */,
     3929                                BCBAAD0B14560A430053F82F /* WKBrowsingContextLoadDelegate.h in Headers */,
    39263930                        );
    39273931                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.