2 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
31 #import "WKBackForwardListInternal.h"
32 #import "WKBackForwardListItemInternal.h"
33 #import "WKBrowsingContextControllerInternal.h"
34 #import "WKBrowsingContextGroupInternal.h"
35 #import "WKConnectionInternal.h"
36 #import "WKFrameHandleInternal.h"
39 #import "WKNSDictionary.h"
41 #import "WKNSString.h"
43 #import "WKNSURLAuthenticationChallenge.h"
44 #import "WKNSURLProtectionSpace.h"
45 #import "WKNavigationDataInternal.h"
46 #import "WKProcessPoolInternal.h"
47 #import "WKWebProcessPlugInBrowserContextControllerInternal.h"
48 #import "WKWebProcessPlugInFrameInternal.h"
49 #import "WKWebProcessPlugInHitTestResultInternal.h"
50 #import "WKWebProcessPlugInInternal.h"
51 #import "WKWebProcessPlugInNodeHandleInternal.h"
52 #import "WKWebProcessPlugInPageGroupInternal.h"
53 #import "WKWebProcessPlugInScriptWorldInternal.h"
67 void* Object::newObject(size_t size, Type type)
69 NSObject <WKObject> *wrapper;
71 // Wrappers that inherit from WKObject store the API::Object in their extra bytes, so they are
72 // allocated using NSAllocatedObject. The other wrapper classes contain inline storage for the
73 // API::Object, so they are allocated using +alloc.
77 wrapper = [WKNSArray alloc];
80 case Type::AuthenticationChallenge:
81 wrapper = NSAllocateObject([WKNSURLAuthenticationChallenge self], size, nullptr);
84 case Type::BackForwardList:
85 wrapper = [WKBackForwardList alloc];
88 case Type::BackForwardListItem:
89 wrapper = [WKBackForwardListItem alloc];
93 wrapper = [WKWebProcessPlugInController alloc];
96 case Type::BundlePage:
97 wrapper = [WKWebProcessPlugInBrowserContextController alloc];
100 case Type::Connection:
101 wrapper = NSAllocateObject([WKConnection self], size, nullptr);
105 wrapper = [WKProcessPool alloc];
109 wrapper = [WKNSData alloc];
112 case Type::Dictionary:
113 wrapper = [WKNSDictionary alloc];
117 wrapper = NSAllocateObject([WKNSError self], size, nullptr);
120 case Type::FrameHandle:
121 wrapper = [WKFrameHandle alloc];
124 case Type::NavigationData:
125 wrapper = [WKNavigationData alloc];
128 case Type::PageGroup:
129 wrapper = [WKBrowsingContextGroup alloc];
132 case Type::ProtectionSpace:
133 wrapper = NSAllocateObject([WKNSURLProtectionSpace class], size, nullptr);
137 wrapper = NSAllocateObject([WKNSString class], size, nullptr);
141 wrapper = NSAllocateObject([WKNSURL class], size, nullptr);
144 case Type::BundleFrame:
145 wrapper = [WKWebProcessPlugInFrame alloc];
148 case Type::BundleHitTestResult:
149 wrapper = [WKWebProcessPlugInHitTestResult alloc];
152 case Type::BundleNodeHandle:
153 wrapper = [WKWebProcessPlugInNodeHandle alloc];
156 case Type::BundlePageGroup:
157 wrapper = [WKWebProcessPlugInPageGroup alloc];
160 case Type::BundleScriptWorld:
161 wrapper = [WKWebProcessPlugInScriptWorld alloc];
165 wrapper = NSAllocateObject([WKObject class], size, nullptr);
169 Object& object = wrapper._apiObject;
170 object.m_wrapper = wrapper;
177 #endif // WK_API_ENABLED