Add WebKitSystemInterface for iOS 9.2
[WebKit-https.git] / WebKitLibraries / WebKitSystemInterface.h
1 /*      
2     WebKitSystemInterface.h
3     Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
4
5     Public header file.
6 */
7
8 #import <Foundation/Foundation.h>
9 #import <dispatch/dispatch.h>
10
11 #if !TARGET_OS_IPHONE
12 #import <AppKit/AppKit.h>
13 #import <Carbon/Carbon.h>
14 #else
15 #import <CoreImage/CoreImage.h>
16 #import <CoreText/CoreText.h>
17 #endif
18
19 @class AVAsset;
20 @class AVPlayer;
21 @class CALayer;
22 @class QTMovie;
23 @class QTMovieView;
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #pragma mark Shared
30
31 typedef struct _CFURLResponse* CFURLResponseRef;
32 typedef const struct _CFURLRequest* CFURLRequestRef;
33 typedef struct _CFURLRequest* CFMutableURLRequestRef;
34
35 typedef struct _CFURLCredential* WKCFURLCredentialRef;
36 typedef struct _CFURLProtectionSpace* CFURLProtectionSpaceRef;
37
38 typedef enum {
39     WKCertificateParseResultSucceeded  = 0,
40     WKCertificateParseResultFailed     = 1,
41     WKCertificateParseResultPKCS7      = 2,
42 } WKCertificateParseResult;
43
44 CFStringRef WKSignedPublicKeyAndChallengeString(unsigned keySize, CFStringRef challenge, CFStringRef keyDescription);
45 WKCertificateParseResult WKAddCertificatesToKeychainFromData(const void *bytes, unsigned length);
46
47 CFStringEncoding WKGetWebDefaultCFStringEncoding(void);
48
49 void WKSetMetadataURL(NSString *URLString, NSString *referrer, NSString *path);
50     
51 typedef enum {
52     WKPlugInModuleLoadPolicyLoadNormally = 0,
53     WKPlugInModuleLoadPolicyLoadUnsandboxed,
54     WKPlugInModuleLoadPolicyBlockedForSecurity,
55     WKPlugInModuleLoadPolicyBlockedForCompatibility,
56 } WKPlugInModuleLoadPolicy;
57
58 WKPlugInModuleLoadPolicy WKLoadPolicyForPluginVersion(NSString *bundleIdentifier, NSString *bundleVersionString);
59 BOOL WKShouldBlockPlugin(NSString *bundleIdentifier, NSString *bundleVersionString);
60 BOOL WKIsPluginUpdateAvailable(NSString *bundleIdentifier);
61
62 BOOL WKShouldBlockWebGL();
63 BOOL WKShouldSuggestBlockingWebGL();
64
65 enum {
66     WKCTFontTransformApplyShaping = (1 << 0),
67     WKCTFontTransformApplyPositioning = (1 << 1)
68 };
69 typedef int WKCTFontTransformOptions;
70
71 typedef enum {
72     WKPatternTilingNoDistortion,
73     WKPatternTilingConstantSpacingMinimalDistortion,
74     WKPatternTilingConstantSpacing
75 } WKPatternTiling;
76
77 CGPatternRef WKCGPatternCreateWithImageAndTransform(CGImageRef image, CGAffineTransform transform, int tiling);
78
79 BOOL WKCGContextIsBitmapContext(CGContextRef context);
80 bool WKCGContextIsPDFContext(CGContextRef context);
81
82 CFStringRef WKCopyFoundationCacheDirectory(void);
83
84 typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
85 CFURLStorageSessionRef WKCreatePrivateStorageSession(CFStringRef);
86 NSURLRequest *WKCopyRequestWithStorageSession(CFURLStorageSessionRef, NSURLRequest *);
87 NSCachedURLResponse *WKCachedResponseForRequest(CFURLStorageSessionRef, NSURLRequest *);
88
89 typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef;
90 unsigned WKGetHTTPCookieAcceptPolicy(CFHTTPCookieStorageRef);
91 NSArray *WKHTTPCookies(CFHTTPCookieStorageRef);
92 NSArray *WKHTTPCookiesForURL(CFHTTPCookieStorageRef, NSURL *, NSURL *);
93 void WKSetHTTPCookiesForURL(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
94 void WKDeleteAllHTTPCookies(CFHTTPCookieStorageRef);
95 void WKDeleteHTTPCookie(CFHTTPCookieStorageRef, NSHTTPCookie *);
96
97 CFURLRef WKCopyBundleURLForExecutableURL(CFURLRef);
98
99
100 CALayer *WKMakeRenderLayer(uint32_t contextID);
101
102 typedef struct __WKCAContextRef *WKCAContextRef;
103 WKCAContextRef WKCAContextMakeRemoteWithServerPort(mach_port_t port);
104 void WKDestroyRenderingResources(void);
105
106 void WKCALayerEnumerateRectsBeingDrawnWithBlock(CALayer *layer, CGContextRef context, void (^block)(CGRect rect));
107
108 void WKSetCONNECTProxyForStream(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
109 void WKSetCONNECTProxyAuthorizationForStream(CFReadStreamRef, CFStringRef proxyAuthorizationString);
110 CFHTTPMessageRef WKCopyCONNECTProxyResponse(CFReadStreamRef, CFURLRef responseURL, CFStringRef proxyHost, CFNumberRef proxyPort);
111
112 CFDictionaryRef WKNSURLRequestCreateSerializableRepresentation(NSURLRequest *request, CFTypeRef tokenNull);
113 NSURLRequest *WKNSURLRequestFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull);
114 CFDictionaryRef WKCFURLRequestCreateSerializableRepresentation(CFURLRequestRef cfRequest, CFTypeRef tokenNull);
115 CFURLRequestRef WKCreateCFURLRequestFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull);
116
117 CFArrayRef WKCFURLCacheCopyAllHostNamesInPersistentStore(void);
118 void WKCFURLCacheDeleteHostNamesInPersistentStore(CFArrayRef hostArray);    
119
120 typedef enum {
121     WKSandboxExtensionTypeReadOnly,
122     WKSandboxExtensionTypeReadWrite,
123 } WKSandboxExtensionType;
124 typedef struct __WKSandboxExtension *WKSandboxExtensionRef;
125
126 WKSandboxExtensionRef WKSandboxExtensionCreate(const char* path, WKSandboxExtensionType type);
127 void WKSandboxExtensionDestroy(WKSandboxExtensionRef sandboxExtension);
128
129 bool WKSandboxExtensionConsume(WKSandboxExtensionRef sandboxExtension);
130 bool WKSandboxExtensionInvalidate(WKSandboxExtensionRef sandboxExtension);
131
132 const char* WKSandboxExtensionGetSerializedFormat(WKSandboxExtensionRef sandboxExtension, size_t* length);
133 WKSandboxExtensionRef WKSandboxExtensionCreateFromSerializedFormat(const char* serializationFormat, size_t length);
134
135 void WKSetCrashReportApplicationSpecificInformation(CFStringRef);
136
137 bool WKIsPublicSuffix(NSString *domain);
138
139 CFArrayRef WKCFURLCacheCopyAllHostNamesInPersistentStoreForPartition(CFStringRef partition);
140 typedef void (^CFURLCacheCopyAllPartitionNamesResultsNotification)(CFArrayRef partitionNames);
141
142 void WKCFURLCacheDeleteHostNamesInPersistentStoreForPartition(CFArrayRef hostArray, CFStringRef partition);
143 CFStringRef WKCachePartitionKey(void);
144 void WKCFURLCacheCopyAllPartitionNames(CFURLCacheCopyAllPartitionNamesResultsNotification resultsBlock);
145
146 typedef enum {
147     WKExternalPlaybackTypeNone,
148     WKExternalPlaybackTypeAirPlay,
149     WKExternalPlaybackTypeTVOut,
150 } WKExternalPlaybackType;
151
152 int WKExernalDeviceTypeForPlayer(AVPlayer *);
153 NSString *WKExernalDeviceDisplayNameForPlayer(AVPlayer *);
154
155 bool WKQueryDecoderAvailability(void);
156
157 #pragma mark Mac Only
158
159 #if !TARGET_OS_IPHONE
160
161 void WKShowKeyAndMain(void);
162
163 void WKAdvanceDefaultButtonPulseAnimation(NSButtonCell *button);
164
165 NSString *WKWindowWillOrderOnScreenNotification(void);
166 NSString *WKWindowWillOrderOffScreenNotification(void);
167 void WKSetNSWindowShouldPostEventNotifications(NSWindow *window, BOOL post);
168
169 CFTypeID WKGetAXTextMarkerTypeID(void);
170 CFTypeID WKGetAXTextMarkerRangeTypeID(void);
171 CFTypeRef WKCreateAXTextMarker(const void *bytes, size_t len);
172 BOOL WKGetBytesFromAXTextMarker(CFTypeRef textMarker, void *bytes, size_t length);
173 CFTypeRef WKCreateAXTextMarkerRange(CFTypeRef start, CFTypeRef end);
174 CFTypeRef WKCopyAXTextMarkerRangeStart(CFTypeRef range);
175 CFTypeRef WKCopyAXTextMarkerRangeEnd(CFTypeRef range);
176 void WKAccessibilityHandleFocusChanged(void);
177 AXUIElementRef WKCreateAXUIElementRef(id element);
178 void WKUnregisterUniqueIdForElement(id element);
179     
180 NSArray *WKSpeechSynthesisGetVoiceIdentifiers(void);
181 NSString *WKSpeechSynthesisGetDefaultVoiceIdentifierForLocale(NSLocale*);
182
183 // Remote Accessibility API.
184 void WKAXInitializeElementWithPresenterPid(id, pid_t);
185 NSData *WKAXRemoteTokenForElement(id);
186 id WKAXRemoteElementForToken(NSData *);
187 void WKAXSetWindowForRemoteElement(id remoteWindow, id remoteElement);
188 void WKAXRegisterRemoteProcess(bool registerProcess, pid_t);
189 pid_t WKAXRemoteProcessIdentifier(id remoteElement);
190
191 // The CG context's current path is the focus ring's path.
192 // Color and radius are ignored. Older versions of WebKit expected to
193 // be able to change the rendering of the system focus ring.
194 void WKDrawFocusRing(CGContextRef context, CGColorRef color, int radius);
195 bool WKDrawFocusRingAtTime(CGContextRef context, NSTimeInterval time);
196 bool WKDrawCellFocusRingWithFrameAtTime(NSCell *cell, NSRect cellFrame, NSView *controlView, NSTimeInterval time);
197
198 void WKSetDragImage(NSImage *image, NSPoint offset);
199
200 void WKDrawBezeledTextArea(NSRect, BOOL enabled);
201
202 void WKPopupMenu(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*, NSControlSize controlSize, bool usesCustomAppearance);
203 void WKPopupContextMenu(NSMenu *menu, NSPoint screenLocation);
204 void WKSendUserChangeNotifications(void);
205
206 bool WKCGContextDrawsWithCorrectShadowOffsets(CGContextRef);
207
208 CGContextRef WKNSWindowOverrideCGContext(NSWindow *, CGContextRef);
209 void WKNSWindowRestoreCGContext(NSWindow *, CGContextRef);
210
211 void WKGetWheelEventDeltas(NSEvent *, float *deltaX, float *deltaY, BOOL *continuous);
212
213 BOOL WKAppVersionCheckLessThan(NSString *, int, double);
214
215 typedef enum {
216     WKMovieTypeUnknown,
217     WKMovieTypeDownload,
218     WKMovieTypeStoredStream,
219     WKMovieTypeLiveStream
220 } WKMovieType;
221
222 int WKQTMovieGetType(QTMovie* movie);
223
224 BOOL WKQTMovieHasClosedCaptions(QTMovie* movie);
225 void WKQTMovieSetShowClosedCaptions(QTMovie* movie, BOOL showClosedCaptions);
226 void WKQTMovieSelectPreferredAlternates(QTMovie* movie);
227
228 unsigned WKQTIncludeOnlyModernMediaFileTypes(void);
229 float WKQTMovieMaxTimeLoaded(QTMovie* movie);
230 NSString *WKQTMovieMaxTimeLoadedChangeNotification(void);
231 void WKQTMovieDisableComponent(uint32_t[5]);
232 NSURL *WKQTMovieResolvedURL(QTMovie* movie);
233
234 void WKSetVisibleApplicationName(CFStringRef);
235 void WKSetApplicationInformationItem(CFStringRef key, CFTypeRef value);
236
237 typedef enum {
238     WKMediaUIPartFullscreenButton   = 0,
239     WKMediaUIPartMuteButton,
240     WKMediaUIPartPlayButton,
241     WKMediaUIPartSeekBackButton,
242     WKMediaUIPartSeekForwardButton,
243     WKMediaUIPartTimelineSlider,
244     WKMediaUIPartTimelineSliderThumb,
245     WKMediaUIPartRewindButton,
246     WKMediaUIPartSeekToRealtimeButton,
247     WKMediaUIPartShowClosedCaptionsButton,
248     WKMediaUIPartHideClosedCaptionsButton,
249     WKMediaUIPartUnMuteButton,
250     WKMediaUIPartPauseButton,
251     WKMediaUIPartBackground,
252     WKMediaUIPartCurrentTimeDisplay,
253     WKMediaUIPartTimeRemainingDisplay,
254     WKMediaUIPartStatusDisplay,
255     WKMediaUIPartControlsPanel,
256     WKMediaUIPartVolumeSliderContainer,
257     WKMediaUIPartVolumeSlider,
258     WKMediaUIPartVolumeSliderThumb,
259     WKMediaUIPartFullScreenVolumeSlider,
260     WKMediaUIPartFullScreenVolumeSliderThumb,
261     WKMediaUIPartVolumeSliderMuteButton,
262     WKMediaUIPartTextTrackDisplayContainer,
263     WKMediaUIPartTextTrackDisplay,
264     WKMediaUIPartExitFullscreenButton,
265 } WKMediaUIPart;
266
267 typedef enum {
268     WKMediaControllerFlagDisabled = 1 << 0,
269     WKMediaControllerFlagPressed = 1 << 1,
270     WKMediaControllerFlagDrawEndCaps = 1 << 3,
271     WKMediaControllerFlagFocused = 1 << 4
272 } WKMediaControllerThemeState;
273
274 BOOL WKHitTestMediaUIPart(int part, CGRect bounds, CGPoint point);
275 void WKMeasureMediaUIPart(int part, CGRect *bounds, CGSize *naturalSize);
276 void WKDrawMediaUIPart(int part, CGContextRef context, CGRect rect, unsigned state);
277 void WKDrawMediaSliderTrack(CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration, unsigned state);
278 NSView *WKCreateMediaUIBackgroundView(void);
279
280 typedef enum {
281     WKMediaUIControlTimeline,
282     WKMediaUIControlSlider,
283     WKMediaUIControlPlayPauseButton,
284     WKMediaUIControlExitFullscreenButton,
285     WKMediaUIControlRewindButton,
286     WKMediaUIControlFastForwardButton,
287     WKMediaUIControlVolumeUpButton,
288     WKMediaUIControlVolumeDownButton
289 } WKMediaUIControlType;
290     
291 NSControl *WKCreateMediaUIControl(int controlType);
292
293 NSArray *WKQTGetSitesInMediaDownloadCache();
294 void WKQTClearMediaDownloadCacheForSite(NSString *site);
295 void WKQTClearMediaDownloadCache();
296     
297 mach_port_t WKInitializeRenderServer(void);
298
299 typedef struct __WKSoftwareCARendererRef *WKSoftwareCARendererRef;
300
301 WKSoftwareCARendererRef WKSoftwareCARendererCreate(uint32_t contextID);
302 void WKSoftwareCARendererDestroy(WKSoftwareCARendererRef);
303 void WKSoftwareCARendererRender(WKSoftwareCARendererRef, CGContextRef, CGRect);
304 WKCAContextRef WKCAContextMakeRemoteForWindowServer(void);
305
306 void WKWindowSetClipRect(NSWindow*, NSRect);
307
308 NSUInteger WKGetInputPanelWindowStyle(void);
309 UInt8 WKGetNSEventKeyChar(NSEvent *);
310
311 void WKWindowSetAlpha(NSWindow *window, float alphaValue);
312 void WKWindowSetScaledFrame(NSWindow *window, NSRect scaleFrame, NSRect nonScaledFrame);
313
314 void WKEnableSettingCursorWhenInBackground(void);
315
316 OSStatus WKEnableSandboxStyleFileQuarantine(void);
317
318 int WKRecommendedScrollerStyle(void);
319
320 bool WKExecutableWasLinkedOnOrBeforeSnowLeopard(void);
321
322 CFStringRef WKCopyDefaultSearchProviderDisplayName(void);
323
324 NSCursor *WKCursor(const char *name);
325
326 bool WKExecutableWasLinkedOnOrBeforeLion(void);
327
328 CGFloat WKNSElasticDeltaForTimeDelta(CGFloat initialPosition, CGFloat initialVelocity, CGFloat elapsedTime);
329 CGFloat WKNSElasticDeltaForReboundDelta(CGFloat delta);
330 CGFloat WKNSReboundDeltaForElasticDelta(CGFloat delta);
331
332 typedef enum {
333     WKOcclusionNotificationTypeApplicationBecameVisible,
334     WKOcclusionNotificationTypeApplicationBecameOccluded,
335     WKOcclusionNotificationTypeApplicationWindowModificationsStarted,
336     WKOcclusionNotificationTypeApplicationWindowModificationsStopped,
337     WKOcclusionNotificationTypeWindowBecameVisible,
338     WKOcclusionNotificationTypeWindowBecameOccluded,
339 } WKOcclusionNotificationType;
340
341 typedef uint32_t WKWindowID;
342
343 typedef void (*WKOcclusionNotificationHandler)(uint32_t, void* data, uint32_t dataLength, void*, uint32_t);
344
345 bool WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationType, WKOcclusionNotificationHandler);
346 bool WKEnableWindowOcclusionNotifications(NSInteger windowID, bool *outCurrentOcclusionState);
347
348 #if defined(__x86_64__)
349 #import <mach/mig.h>
350 CFRunLoopSourceRef WKCreateMIGServerSource(mig_subsystem_t subsystem, mach_port_t serverPort);
351 #endif
352
353
354 #ifndef __LP64__
355
356 OSStatus WKSyncWindowWithCGAfterMove(WindowRef);
357 unsigned WKCarbonWindowMask(void);
358 void *WKGetNativeWindowFromWindowRef(WindowRef);
359 OSType WKCarbonWindowPropertyCreator(void);
360 OSType WKCarbonWindowPropertyTag(void);
361
362 unsigned WKGetNSAutoreleasePoolCount(void);
363
364 BOOL WKConvertNSEventToCarbonEvent(EventRecord *carbonEvent, NSEvent *cocoaEvent);
365 void WKSendKeyEventToTSM(NSEvent *theEvent);
366 void WKCallDrawingNotification(CGrafPtr port, Rect *bounds);
367
368 NSEvent *WKCreateNSEventWithCarbonEvent(EventRef eventRef);
369 NSEvent *WKCreateNSEventWithCarbonMouseMoveEvent(EventRef inEvent, NSWindow *window);
370 NSEvent *WKCreateNSEventWithCarbonClickEvent(EventRef inEvent, WindowRef windowRef);
371
372 ScriptCode WKGetScriptCodeFromCurrentKeyboardInputSource(void);
373
374 #endif /* __LP64__ */
375
376 #endif /* !TARGET_OS_IPHONE */
377
378 #ifdef __cplusplus
379 }
380 #endif