1/*
2 * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
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.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef WebCoreSystemInterface_h
27#define WebCoreSystemInterface_h
28
29#include <objc/objc.h>
30
31typedef const struct __CFString * CFStringRef;
32typedef const struct __CFNumber * CFNumberRef;
33typedef const struct __CFDictionary * CFDictionaryRef;
34typedef struct CGPoint CGPoint;
35typedef struct CGSize CGSize;
36typedef struct CGRect CGRect;
37typedef struct CGAffineTransform CGAffineTransform;
38typedef struct CGContext *CGContextRef;
39typedef struct CGImage *CGImageRef;
40typedef struct CGColor *CGColorRef;
41typedef struct CGFont *CGFontRef;
42typedef struct CGColorSpace *CGColorSpaceRef;
43typedef struct CGPattern *CGPatternRef;
44typedef struct CGPath *CGMutablePathRef;
45typedef unsigned short CGGlyph;
46typedef struct __CFReadStream * CFReadStreamRef;
47typedef struct __CFRunLoop * CFRunLoopRef;
48typedef struct __CFHTTPMessage *CFHTTPMessageRef;
49typedef struct _CFURLResponse *CFURLResponseRef;
50typedef const struct _CFURLRequest *CFURLRequestRef;
51typedef const struct __CTFont * CTFontRef;
52typedef const struct __CTLine * CTLineRef;
53typedef const struct __CTRun * CTRunRef;
54typedef const struct __CTTypesetter * CTTypesetterRef;
55typedef const struct __AXUIElement *AXUIElementRef;
56typedef struct _NSRange NSRange;
57
58typedef UInt32 FMFont;
59typedef FMFont ATSUFontID;
60typedef UInt16 ATSGlyphRef;
61
62#if PLATFORM(MAC) && USE(CA) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
63typedef struct __IOSurface *IOSurfaceRef;
64#endif
65
66#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
67typedef struct CGPoint NSPoint;
68typedef struct CGRect NSRect;
69#else
70typedef struct _NSPoint NSPoint;
71typedef struct _NSRect NSRect;
72#endif
73
74#if USE(CFNETWORK)
75typedef struct OpaqueCFHTTPCookieStorage*  CFHTTPCookieStorageRef;
76typedef struct _CFURLProtectionSpace* CFURLProtectionSpaceRef;
77typedef struct _CFURLCredential* WKCFURLCredentialRef;
78typedef struct _CFURLRequest* CFMutableURLRequestRef;
79typedef const struct _CFURLRequest* CFURLRequestRef;
80#endif
81
82OBJC_CLASS AVAsset;
83OBJC_CLASS CALayer;
84OBJC_CLASS NSArray;
85OBJC_CLASS NSButtonCell;
86OBJC_CLASS NSControl;
87OBJC_CLASS NSCursor;
88OBJC_CLASS NSData;
89OBJC_CLASS NSDate;
90OBJC_CLASS NSEvent;
91OBJC_CLASS NSFont;
92OBJC_CLASS NSHTTPCookie;
93OBJC_CLASS NSImage;
94OBJC_CLASS NSLocale;
95OBJC_CLASS NSMenu;
96OBJC_CLASS NSMutableURLRequest;
97OBJC_CLASS NSString;
98OBJC_CLASS NSTextFieldCell;
99OBJC_CLASS NSURL;
100OBJC_CLASS NSURLConnection;
101OBJC_CLASS NSURLRequest;
102OBJC_CLASS NSURLResponse;
103OBJC_CLASS NSView;
104OBJC_CLASS NSWindow;
105OBJC_CLASS QTMovie;
106OBJC_CLASS QTMovieView;
107OBJC_CLASS WebFilterEvaluator;
108
109extern "C" {
110
111// In alphabetical order.
112
113extern void (*wkAdvanceDefaultButtonPulseAnimation)(NSButtonCell *);
114#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
115extern void (*wkCALayerEnumerateRectsBeingDrawnWithBlock)(CALayer *, CGContextRef, void (^block)(CGRect rect));
116#endif
117
118extern BOOL (*wkCGContextGetShouldSmoothFonts)(CGContextRef);
119typedef enum {
120    wkPatternTilingNoDistortion,
121    wkPatternTilingConstantSpacingMinimalDistortion,
122    wkPatternTilingConstantSpacing
123} wkPatternTiling;
124extern void (*wkCGContextResetClip)(CGContextRef);
125#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
126extern bool (*wkCGContextDrawsWithCorrectShadowOffsets)(CGContextRef);
127#endif
128extern CGPatternRef (*wkCGPatternCreateWithImageAndTransform)(CGImageRef, CGAffineTransform, int);
129extern CFReadStreamRef (*wkCreateCustomCFReadStream)(void *(*formCreate)(CFReadStreamRef, void *),
130    void (*formFinalize)(CFReadStreamRef, void *),
131    Boolean (*formOpen)(CFReadStreamRef, CFStreamError *, Boolean *, void *),
132    CFIndex (*formRead)(CFReadStreamRef, UInt8 *, CFIndex, CFStreamError *, Boolean *, void *),
133    Boolean (*formCanRead)(CFReadStreamRef, void *),
134    void (*formClose)(CFReadStreamRef, void *),
135    void (*formSchedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
136    void (*formUnschedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
137    void *context);
138extern CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
139extern NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
140extern CFArrayRef (*wkCopyNSURLResponseCertificateChain)(NSURLResponse*);
141extern void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
142extern void (*wkDrawTextFieldCellFocusRing)(NSTextFieldCell*, NSRect);
143extern void (*wkDrawCapsLockIndicator)(CGContextRef, CGRect);
144extern void (*wkDrawBezeledTextArea)(NSRect, BOOL enabled);
145extern void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int radius);
146extern NSFont* (*wkGetFontInLanguageForRange)(NSFont*, NSString*, NSRange);
147extern NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar);
148extern BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance);
149extern void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime,
150    float duration, unsigned state);
151extern void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
152extern CFStringRef (*wkSignedPublicKeyAndChallengeString)(unsigned keySize, CFStringRef challenge, CFStringRef keyDescription);
153extern NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*);
154extern NSArray* (*wkGetExtensionsForMIMEType)(NSString*);
155extern NSString* (*wkGetMIMETypeForExtension)(NSString*);
156extern ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
157extern double (*wkGetNSURLResponseCalculatedExpiration)(NSURLResponse *response);
158extern NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
159extern BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
160extern void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous);
161extern UInt8 (*wkGetNSEventKeyChar)(NSEvent *);
162extern BOOL (*wkHitTestMediaUIPart)(int part, int themeStyle, CGRect bounds, CGPoint point);
163extern void (*wkMeasureMediaUIPart)(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize);
164extern NSView *(*wkCreateMediaUIBackgroundView)(void);
165
166typedef enum {
167    wkMediaUIControlTimeline,
168    wkMediaUIControlSlider,
169    wkMediaUIControlPlayPauseButton,
170    wkMediaUIControlExitFullscreenButton,
171    wkMediaUIControlRewindButton,
172    wkMediaUIControlFastForwardButton,
173    wkMediaUIControlVolumeUpButton,
174    wkMediaUIControlVolumeDownButton
175} wkMediaUIControlType;
176extern NSControl *(*wkCreateMediaUIControl)(int);
177
178extern void (*wkWindowSetAlpha)(NSWindow *, float);
179extern void (*wkWindowSetScaledFrame)(NSWindow *, NSRect, NSRect);
180extern BOOL (*wkMediaControllerThemeAvailable)(int themeStyle);
181extern void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
182extern unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void);
183extern int (*wkQTMovieDataRate)(QTMovie*);
184extern void (*wkQTMovieDisableComponent)(uint32_t[5]);
185extern float (*wkQTMovieMaxTimeLoaded)(QTMovie*);
186extern NSString *(*wkQTMovieMaxTimeLoadedChangeNotification)(void);
187extern float (*wkQTMovieMaxTimeSeekable)(QTMovie*);
188extern int (*wkQTMovieGetType)(QTMovie*);
189extern BOOL (*wkQTMovieHasClosedCaptions)(QTMovie*);
190extern NSURL *(*wkQTMovieResolvedURL)(QTMovie*);
191extern void (*wkQTMovieSetShowClosedCaptions)(QTMovie*, BOOL);
192extern void (*wkQTMovieSelectPreferredAlternates)(QTMovie*);
193extern void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL);
194extern NSArray *(*wkQTGetSitesInMediaDownloadCache)();
195extern void (*wkQTClearMediaDownloadCacheForSite)(NSString *site);
196extern void (*wkQTClearMediaDownloadCache)();
197#if PLATFORM(MAC)
198extern void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*, BOOL);
199#else
200extern void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
201#endif
202extern void (*wkSetDragImage)(NSImage*, NSPoint offset);
203extern void (*wkSetNSURLConnectionDefersCallbacks)(NSURLConnection *, BOOL);
204extern void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL);
205extern void (*wkSetBaseCTM)(CGContextRef, CGAffineTransform);
206extern void (*wkSetPatternPhaseInUserSpace)(CGContextRef, CGPoint);
207extern CGAffineTransform (*wkGetUserToBaseCTM)(CGContextRef);
208extern bool (*wkCGContextIsPDFContext)(CGContextRef);
209extern void (*wkSetUpFontCache)();
210extern void (*wkSignalCFReadStreamEnd)(CFReadStreamRef stream);
211extern void (*wkSignalCFReadStreamError)(CFReadStreamRef stream, CFStreamError *error);
212extern void (*wkSignalCFReadStreamHasBytes)(CFReadStreamRef stream);
213extern unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount);
214extern int (*wkGetHTTPPipeliningPriority)(CFURLRequestRef);
215extern void (*wkSetHTTPPipeliningMaximumPriority)(int maximumPriority);
216extern void (*wkSetHTTPPipeliningPriority)(CFURLRequestRef, int priority);
217extern void (*wkSetHTTPPipeliningMinimumFastLanePriority)(int priority);
218extern void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
219extern void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
220extern CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL, CFStringRef proxyHost, CFNumberRef proxyPort);
221
222extern void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t);
223extern bool (*wkGetVerticalGlyphsForCharacters)(CTFontRef, const UniChar[], CGGlyph[], size_t);
224
225extern BOOL (*wkUseSharedMediaUI)();
226
227#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
228extern void* wkGetHyphenationLocationBeforeIndex;
229#else
230extern CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
231
232typedef enum {
233    wkEventPhaseNone = 0,
234    wkEventPhaseBegan = 1,
235    wkEventPhaseChanged = 2,
236    wkEventPhaseEnded = 3,
237} wkEventPhase;
238
239extern int (*wkGetNSEventMomentumPhase)(NSEvent *);
240#endif
241
242extern CTLineRef (*wkCreateCTLineWithUniCharProvider)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*);
243
244#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
245enum {
246    wkCTFontTransformApplyShaping = (1 << 0),
247    wkCTFontTransformApplyPositioning = (1 << 1)
248};
249
250typedef int wkCTFontTransformOptions;
251
252extern bool (*wkCTFontTransformGlyphs)(CTFontRef font, CGGlyph glyphs[], CGSize advances[], CFIndex count, wkCTFontTransformOptions options);
253#endif
254
255#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
256
257extern CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
258
259extern CGSize (*wkCTRunGetInitialAdvance)(CTRunRef);
260
261#if PLATFORM(MAC) && USE(CA)
262extern CGContextRef (*wkIOSurfaceContextCreate)(IOSurfaceRef surface, unsigned width, unsigned height, CGColorSpaceRef colorSpace);
263extern CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context);
264#endif
265
266extern int (*wkRecommendedScrollerStyle)(void);
267
268extern bool (*wkExecutableWasLinkedOnOrBeforeSnowLeopard)(void);
269
270extern CFStringRef (*wkCopyDefaultSearchProviderDisplayName)(void);
271extern void (*wkSetCrashReportApplicationSpecificInformation)(CFStringRef);
272
273extern NSURL *(*wkAVAssetResolvedURL)(AVAsset*);
274
275extern NSCursor *(*wkCursor)(const char*);
276
277#endif
278
279#if PLATFORM(MAC)
280extern NSArray *(*wkSpeechSynthesisGetVoiceIdentifiers)(void);
281extern NSString *(*wkSpeechSynthesisGetDefaultVoiceIdentifierForLocale)(NSLocale *);
282#endif
283
284extern void (*wkUnregisterUniqueIdForElement)(id element);
285extern void (*wkAccessibilityHandleFocusChanged)(void);
286extern CFTypeID (*wkGetAXTextMarkerTypeID)(void);
287extern CFTypeID (*wkGetAXTextMarkerRangeTypeID)(void);
288extern CFTypeRef (*wkCreateAXTextMarkerRange)(CFTypeRef start, CFTypeRef end);
289extern CFTypeRef (*wkCopyAXTextMarkerRangeStart)(CFTypeRef range);
290extern CFTypeRef (*wkCopyAXTextMarkerRangeEnd)(CFTypeRef range);
291extern CFTypeRef (*wkCreateAXTextMarker)(const void *bytes, size_t len);
292extern BOOL (*wkGetBytesFromAXTextMarker)(CFTypeRef textMarker, void *bytes, size_t length);
293extern AXUIElementRef (*wkCreateAXUIElementRef)(id element);
294
295#if __MAC_OS_X_VERSION_MIN_REQUIRED == 1060
296typedef struct __CFURLStorageSession* CFURLStorageSessionRef;
297#else
298typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
299#endif
300extern CFURLStorageSessionRef (*wkCreatePrivateStorageSession)(CFStringRef);
301extern NSURLRequest* (*wkCopyRequestWithStorageSession)(CFURLStorageSessionRef, NSURLRequest*);
302
303typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef;
304extern CFHTTPCookieStorageRef (*wkCopyHTTPCookieStorage)(CFURLStorageSessionRef);
305extern unsigned (*wkGetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef);
306extern void (*wkSetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef, unsigned);
307extern NSArray *(*wkHTTPCookies)(CFHTTPCookieStorageRef);
308extern NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *);
309extern void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
310extern void (*wkDeleteHTTPCookie)(CFHTTPCookieStorageRef, NSHTTPCookie *);
311extern void (*wkDeleteAllHTTPCookies)(CFHTTPCookieStorageRef);
312
313extern CFStringRef (*wkGetCFURLResponseMIMEType)(CFURLResponseRef);
314extern CFURLRef (*wkGetCFURLResponseURL)(CFURLResponseRef);
315extern CFHTTPMessageRef (*wkGetCFURLResponseHTTPResponse)(CFURLResponseRef);
316extern CFStringRef (*wkCopyCFURLResponseSuggestedFilename)(CFURLResponseRef);
317extern void (*wkSetCFURLResponseMIMEType)(CFURLResponseRef, CFStringRef mimeType);
318
319extern void(*wkDestroyRenderingResources)(void);
320
321#if USE(CFNETWORK)
322extern CFHTTPCookieStorageRef (*wkGetDefaultHTTPCookieStorage)();
323extern WKCFURLCredentialRef (*wkCopyCredentialFromCFPersistentStorage)(CFURLProtectionSpaceRef protectionSpace);
324extern void (*wkSetCFURLRequestShouldContentSniff)(CFMutableURLRequestRef, bool);
325extern CFArrayRef (*wkCFURLRequestCopyHTTPRequestBodyParts)(CFURLRequestRef);
326extern void (*wkCFURLRequestSetHTTPRequestBodyParts)(CFMutableURLRequestRef, CFArrayRef bodyParts);
327extern void (*wkSetRequestStorageSession)(CFURLStorageSessionRef, CFMutableURLRequestRef);
328#endif
329extern void (*wkSetMetadataURL)(NSString *urlString, NSString *referrer, NSString *path);
330
331#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
332#import <dispatch/dispatch.h>
333
334extern dispatch_source_t (*wkCreateVMPressureDispatchOnMainQueue)(void);
335
336#endif
337
338#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
339extern dispatch_source_t (*wkCreateMemoryStatusPressureCriticalDispatchOnMainQueue)(void);
340#endif
341
342#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
343extern bool (*wkExecutableWasLinkedOnOrBeforeLion)(void);
344#endif
345
346#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
347extern void (*wkCGPathAddRoundedRect)(CGMutablePathRef path, const CGAffineTransform* matrix, CGRect rect, CGFloat cornerWidth, CGFloat cornerHeight);
348#endif
349
350#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
351extern void (*wkCFURLRequestAllowAllPostCaching)(CFURLRequestRef);
352#endif
353
354#if USE(CONTENT_FILTERING)
355extern BOOL (*wkFilterIsManagedSession)(void);
356extern WebFilterEvaluator *(*wkFilterCreateInstance)(NSURLResponse *);
357extern BOOL (*wkFilterWasBlocked)(WebFilterEvaluator *);
358extern BOOL (*wkFilterIsBuffering)(WebFilterEvaluator *);
359extern NSData *(*wkFilterAddData)(WebFilterEvaluator *, NSData *);
360extern NSData *(*wkFilterDataComplete)(WebFilterEvaluator *);
361#endif
362
363#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
364extern CGFloat (*wkNSElasticDeltaForTimeDelta)(CGFloat initialPosition, CGFloat initialVelocity, CGFloat elapsedTime);
365extern CGFloat (*wkNSElasticDeltaForReboundDelta)(CGFloat delta);
366extern CGFloat (*wkNSReboundDeltaForElasticDelta)(CGFloat delta);
367#endif
368
369#if ENABLE(PUBLIC_SUFFIX_LIST)
370extern bool (*wkIsPublicSuffix)(NSString *host);
371#endif
372
373#if ENABLE(CACHE_PARTITIONING)
374extern CFStringRef (*wkCachePartitionKey)(void);
375#endif
376}
377
378#endif
379