2010-10-28 Ivan Krstić <ike@apple.com>
[WebKit-https.git] / WebKitLibraries / WebKitSystemInterface.h
1 /*      
2     WebKitSystemInterface.h
3     Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4
5     Public header file.
6 */
7
8 #import <Cocoa/Cocoa.h>
9 #import <Carbon/Carbon.h>
10
11 @class QTMovie;
12 @class QTMovieView;
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 typedef enum {
19     WKCertificateParseResultSucceeded  = 0,
20     WKCertificateParseResultFailed     = 1,
21     WKCertificateParseResultPKCS7      = 2,
22 } WKCertificateParseResult;
23
24 CFStringRef WKCopyCFLocalizationPreferredName(CFStringRef localization);
25 CFStringRef WKSignedPublicKeyAndChallengeString(unsigned keySize, CFStringRef challenge, CFStringRef keyDescription);
26 WKCertificateParseResult WKAddCertificatesToKeychainFromData(const void *bytes, unsigned length);
27
28 NSString *WKGetPreferredExtensionForMIMEType(NSString *type);
29 NSArray *WKGetExtensionsForMIMEType(NSString *type);
30 NSString *WKGetMIMETypeForExtension(NSString *extension);
31
32 NSDate *WKGetNSURLResponseLastModifiedDate(NSURLResponse *response);
33 NSTimeInterval WKGetNSURLResponseFreshnessLifetime(NSURLResponse *response);
34 NSString *WKCopyNSURLResponseStatusLine(NSURLResponse *response);
35
36 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
37 CFArrayRef WKCopyNSURLResponseCertificateChain(NSURLResponse *response);
38 #endif
39
40 CFStringEncoding WKGetWebDefaultCFStringEncoding(void);
41
42 void WKSetMetadataURL(NSString *URLString, NSString *referrer, NSString *path);
43 void WKSetNSURLConnectionDefersCallbacks(NSURLConnection *connection, BOOL defers);
44
45 void WKShowKeyAndMain(void);
46 #ifndef __LP64__
47 OSStatus WKSyncWindowWithCGAfterMove(WindowRef);
48 unsigned WKCarbonWindowMask(void);
49 void *WKGetNativeWindowFromWindowRef(WindowRef);
50 OSType WKCarbonWindowPropertyCreator(void);
51 OSType WKCarbonWindowPropertyTag(void);
52 #endif
53
54 typedef id WKNSURLConnectionDelegateProxyPtr;
55
56 WKNSURLConnectionDelegateProxyPtr WKCreateNSURLConnectionDelegateProxy(void);
57
58 void WKDisableCGDeferredUpdates(void);
59
60 Class WKNSURLProtocolClassForRequest(NSURLRequest *request);
61 void WKSetNSURLRequestShouldContentSniff(NSMutableURLRequest *request, BOOL shouldContentSniff);
62
63 void WKSetCookieStoragePrivateBrowsingEnabled(BOOL enabled);
64
65 unsigned WKGetNSAutoreleasePoolCount(void);
66
67 void WKAdvanceDefaultButtonPulseAnimation(NSButtonCell *button);
68
69 NSString *WKMouseMovedNotification(void);
70 NSString *WKWindowWillOrderOnScreenNotification(void);
71 void WKSetNSWindowShouldPostEventNotifications(NSWindow *window, BOOL post);
72
73 CFTypeID WKGetAXTextMarkerTypeID(void);
74 CFTypeID WKGetAXTextMarkerRangeTypeID(void);
75 CFTypeRef WKCreateAXTextMarker(const void *bytes, size_t len);
76 BOOL WKGetBytesFromAXTextMarker(CFTypeRef textMarker, void *bytes, size_t length);
77 CFTypeRef WKCreateAXTextMarkerRange(CFTypeRef start, CFTypeRef end);
78 CFTypeRef WKCopyAXTextMarkerRangeStart(CFTypeRef range);
79 CFTypeRef WKCopyAXTextMarkerRangeEnd(CFTypeRef range);
80 void WKAccessibilityHandleFocusChanged(void);
81 AXUIElementRef WKCreateAXUIElementRef(id element);
82 void WKUnregisterUniqueIdForElement(id element);
83
84 void WKSetUpFontCache(void);
85
86 void WKSignalCFReadStreamEnd(CFReadStreamRef stream);
87 void WKSignalCFReadStreamHasBytes(CFReadStreamRef stream);
88 void WKSignalCFReadStreamError(CFReadStreamRef stream, CFStreamError *error);
89
90 CFReadStreamRef WKCreateCustomCFReadStream(void *(*formCreate)(CFReadStreamRef, void *), 
91     void (*formFinalize)(CFReadStreamRef, void *), 
92     Boolean (*formOpen)(CFReadStreamRef, CFStreamError *, Boolean *, void *), 
93     CFIndex (*formRead)(CFReadStreamRef, UInt8 *, CFIndex, CFStreamError *, Boolean *, void *), 
94     Boolean (*formCanRead)(CFReadStreamRef, void *), 
95     void (*formClose)(CFReadStreamRef, void *), 
96     void (*formSchedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *), 
97     void (*formUnschedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
98     void *context);
99
100 void WKDrawCapsLockIndicator(CGContextRef, CGRect);
101
102 void WKDrawFocusRing(CGContextRef context, CGColorRef color, int radius);
103     // The CG context's current path is the focus ring's path.
104     // A color of 0 means "use system focus ring color".
105     // A radius of 0 means "use default focus ring radius".
106
107 void WKSetDragImage(NSImage *image, NSPoint offset);
108
109 void WKDrawBezeledTextFieldCell(NSRect, BOOL enabled);
110 void WKDrawTextFieldCellFocusRing(NSTextFieldCell*, NSRect);
111 void WKDrawBezeledTextArea(NSRect, BOOL enabled);
112 void WKPopupMenu(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
113
114 void WKSendUserChangeNotifications(void);
115 #ifndef __LP64__
116 BOOL WKConvertNSEventToCarbonEvent(EventRecord *carbonEvent, NSEvent *cocoaEvent);
117 void WKSendKeyEventToTSM(NSEvent *theEvent);
118 void WKCallDrawingNotification(CGrafPtr port, Rect *bounds);
119 #endif
120
121 BOOL WKGetGlyphTransformedAdvances(CGFontRef, NSFont*, CGAffineTransform *m, ATSGlyphRef *glyph, CGSize *advance);
122 NSFont *WKGetFontInLanguageForRange(NSFont *font, NSString *string, NSRange range);
123 NSFont *WKGetFontInLanguageForCharacter(NSFont *font, UniChar ch);
124 void WKSetCGFontRenderingMode(CGContextRef cgContext, NSFont *font);
125 BOOL WKCGContextGetShouldSmoothFonts(CGContextRef cgContext);
126
127 #ifdef BUILDING_ON_TIGER
128 // CGFontGetAscent, CGFontGetDescent, CGFontGetLeading and CGFontGetUnitsPerEm were not available until Leopard
129 void WKGetFontMetrics(CGFontRef font, int *ascent, int *descent, int *lineGap, unsigned *unitsPerEm);
130 // CTFontCopyGraphicsFont was not available until Leopard
131 CGFontRef WKGetCGFontFromNSFont(NSFont *font);
132 // CTFontGetPlatformFont was not available until Leopard
133 ATSUFontID WKGetNSFontATSUFontId(NSFont *font);
134 // CGFontCopyFullName was not available until Leopard
135 CFStringRef WKCopyFullFontName(CGFontRef font);
136 #endif
137
138 void WKSetPatternBaseCTM(CGContextRef, CGAffineTransform);
139 void WKSetPatternPhaseInUserSpace(CGContextRef, CGPoint);
140 CGAffineTransform WKGetUserToBaseCTM(CGContextRef);
141
142 #ifndef BUILDING_ON_TIGER
143 void WKGetGlyphsForCharacters(CGFontRef, const UniChar[], CGGlyph[], size_t);
144 #else
145 typedef void *WKGlyphVectorRef;
146 OSStatus WKConvertCharToGlyphs(void *styleGroup, const UniChar *characters, unsigned numCharacters, WKGlyphVectorRef glyphs);
147 OSStatus WKGetATSStyleGroup(ATSUStyle fontStyle, void **styleGroup);
148 void WKReleaseStyleGroup(void *group);
149 OSStatus WKInitializeGlyphVector(int count, WKGlyphVectorRef glyphs);
150 void WKClearGlyphVector(WKGlyphVectorRef glyphs);
151
152 int WKGetGlyphVectorNumGlyphs(WKGlyphVectorRef glyphVector);
153 ATSLayoutRecord *WKGetGlyphVectorFirstRecord(WKGlyphVectorRef glyphVector);
154 size_t WKGetGlyphVectorRecordSize(WKGlyphVectorRef glyphVector);
155 #endif
156
157 #ifndef __LP64__
158 NSEvent *WKCreateNSEventWithCarbonEvent(EventRef eventRef);
159 NSEvent *WKCreateNSEventWithCarbonMouseMoveEvent(EventRef inEvent, NSWindow *window);
160 NSEvent *WKCreateNSEventWithCarbonClickEvent(EventRef inEvent, WindowRef windowRef);
161 #endif
162
163 CGContextRef WKNSWindowOverrideCGContext(NSWindow *, CGContextRef);
164 void WKNSWindowRestoreCGContext(NSWindow *, CGContextRef);
165
166 void WKNSWindowMakeBottomCornersSquare(NSWindow *);
167
168 // These constants match the ones used by ThemeScrollbarArrowStyle (some of the values are private, so we can't just
169 // use that enum directly).
170 typedef enum {
171     WKThemeScrollBarArrowsSingle     = 0,
172     WKThemeScrollBarArrowsLowerRight = 1,
173     WKThemeScrollBarArrowsDouble     = 2,
174     WKThemeScrollBarArrowsUpperLeft  = 3,
175 } WKThemeScrollBarArrowStyle;
176
177 OSStatus WKThemeDrawTrack(const HIThemeTrackDrawInfo* inDrawInfo, CGContextRef inContext, int inArrowStyle);
178
179 #ifdef BUILDING_ON_TIGER
180 // WKSupportsMultipartXMixedReplace is not required on Leopard as multipart/x-mixed-replace is always handled by NSURLRequest
181 BOOL WKSupportsMultipartXMixedReplace(NSMutableURLRequest *request);
182 #endif
183
184 BOOL WKCGContextIsBitmapContext(CGContextRef context);
185
186 void WKGetWheelEventDeltas(NSEvent *, float *deltaX, float *deltaY, BOOL *continuous);
187
188 BOOL WKAppVersionCheckLessThan(NSString *, int, double);
189
190 typedef enum {
191     WKMovieTypeUnknown,
192     WKMovieTypeDownload,
193     WKMovieTypeStoredStream,
194     WKMovieTypeLiveStream
195 } WKMovieType;
196
197 int WKQTMovieGetType(QTMovie* movie);
198
199 BOOL WKQTMovieHasClosedCaptions(QTMovie* movie);
200 void WKQTMovieSetShowClosedCaptions(QTMovie* movie, BOOL showClosedCaptions);
201 void WKQTMovieSelectPreferredAlternates(QTMovie* movie);
202 void WKQTMovieSelectPreferredAlternateTrackForMediaType(QTMovie* movie, NSString* mediaType);
203
204 unsigned WKQTIncludeOnlyModernMediaFileTypes(void);
205 int WKQTMovieDataRate(QTMovie* movie);
206 float WKQTMovieMaxTimeLoaded(QTMovie* movie);
207 float WKQTMovieMaxTimeSeekable(QTMovie* movie);
208 NSString *WKQTMovieMaxTimeLoadedChangeNotification(void);
209 void WKQTMovieViewSetDrawSynchronously(QTMovieView* view, BOOL sync);
210 void WKQTMovieDisableComponent(uint32_t[5]);
211
212 CFStringRef WKCopyFoundationCacheDirectory(void);
213
214 void WKSetVisibleApplicationName(CFStringRef);
215
216 typedef enum {
217     WKMediaUIPartFullscreenButton   = 0,
218     WKMediaUIPartMuteButton,
219     WKMediaUIPartPlayButton,
220     WKMediaUIPartSeekBackButton,
221     WKMediaUIPartSeekForwardButton,
222     WKMediaUIPartTimelineSlider,
223     WKMediaUIPartTimelineSliderThumb,
224     WKMediaUIPartRewindButton,
225     WKMediaUIPartSeekToRealtimeButton,
226     WKMediaUIPartShowClosedCaptionsButton,
227     WKMediaUIPartHideClosedCaptionsButton,
228     WKMediaUIPartUnMuteButton,
229     WKMediaUIPartPauseButton,
230     WKMediaUIPartBackground,
231     WKMediaUIPartCurrentTimeDisplay,
232     WKMediaUIPartTimeRemainingDisplay,
233     WKMediaUIPartStatusDisplay,
234     WKMediaUIPartControlsPanel,
235     WKMediaUIPartVolumeSliderContainer,
236     WKMediaUIPartVolumeSlider,
237     WKMediaUIPartVolumeSliderThumb
238 } WKMediaUIPart;
239
240 typedef enum {
241     WKMediaControllerThemeClassic   = 1,
242     WKMediaControllerThemeQuickTime = 2
243 } WKMediaControllerThemeStyle;
244
245 typedef enum {
246     WKMediaControllerFlagDisabled = 1 << 0,
247     WKMediaControllerFlagPressed = 1 << 1,
248     WKMediaControllerFlagDrawEndCaps = 1 << 3,
249     WKMediaControllerFlagFocused = 1 << 4
250 } WKMediaControllerThemeState;
251
252 BOOL WKMediaControllerThemeAvailable(int themeStyle);
253 BOOL WKHitTestMediaUIPart(int part, int themeStyle, CGRect bounds, CGPoint point);
254 void WKMeasureMediaUIPart(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize);
255 void WKDrawMediaUIPart(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
256 void WKDrawMediaSliderTrack(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration, unsigned state);
257 NSView *WKCreateMediaUIBackgroundView(void);
258
259 typedef enum {
260     WKMediaUIControlTimeline,
261     WKMediaUIControlSlider,
262     WKMediaUIControlPlayPauseButton,
263     WKMediaUIControlExitFullscreenButton,
264     WKMediaUIControlRewindButton,
265     WKMediaUIControlFastForwardButton,
266     WKMediaUIControlVolumeUpButton,
267     WKMediaUIControlVolumeDownButton
268 } WKMediaUIControlType;
269     
270 NSControl *WKCreateMediaUIControl(int controlType);
271
272 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
273 mach_port_t WKInitializeRenderServer(void);
274     
275 @class CALayer;
276
277 CALayer *WKMakeRenderLayer(uint32_t contextID);
278     
279 typedef struct __WKSoftwareCARendererRef *WKSoftwareCARendererRef;
280
281 WKSoftwareCARendererRef WKSoftwareCARendererCreate(uint32_t contextID);
282 void WKSoftwareCARendererDestroy(WKSoftwareCARendererRef);
283 void WKSoftwareCARendererRender(WKSoftwareCARendererRef, CGContextRef, CGRect);
284
285 typedef struct __WKCARemoteLayerClientRef *WKCARemoteLayerClientRef;
286
287 WKCARemoteLayerClientRef WKCARemoteLayerClientMakeWithServerPort(mach_port_t port);
288 void WKCARemoteLayerClientInvalidate(WKCARemoteLayerClientRef);
289 uint32_t WKCARemoteLayerClientGetClientId(WKCARemoteLayerClientRef);
290 void WKCARemoteLayerClientSetLayer(WKCARemoteLayerClientRef, CALayer *);
291 CALayer *WKCARemoteLayerClientGetLayer(WKCARemoteLayerClientRef);
292
293 typedef struct __WKWindowBounceAnimationContext *WKWindowBounceAnimationContextRef;
294
295 WKWindowBounceAnimationContextRef WKWindowBounceAnimationContextCreate(NSWindow *window);
296 void WKWindowBounceAnimationContextDestroy(WKWindowBounceAnimationContextRef context);
297 void WKWindowBounceAnimationSetAnimationProgress(WKWindowBounceAnimationContextRef context, double animationProgress);
298
299 #if defined(__x86_64__)
300 #import <mach/mig.h>
301
302 CFRunLoopSourceRef WKCreateMIGServerSource(mig_subsystem_t subsystem, mach_port_t serverPort);
303
304 NSUInteger WKGetInputPanelWindowStyle(void);
305  
306 UInt8 WKGetNSEventKeyChar(NSEvent *);
307 #endif // defined(__x86_64__)
308 #endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
309
310 @class CAPropertyAnimation;
311 void WKSetCAAnimationValueFunction(CAPropertyAnimation*, NSString* function);
312
313 unsigned WKInitializeMaximumHTTPConnectionCountPerHost(unsigned preferredConnectionCount);
314
315 void WKSetCONNECTProxyForStream(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
316 void WKSetCONNECTProxyAuthorizationForStream(CFReadStreamRef, CFStringRef proxyAuthorizationString);
317 CFHTTPMessageRef WKCopyCONNECTProxyResponse(CFReadStreamRef, CFURLRef responseURL);
318
319 BOOL WKIsLatchingWheelEvent(NSEvent *);
320
321 #ifndef BUILDING_ON_TIGER
322 void WKWindowSetAlpha(NSWindow *window, float alphaValue);
323 void WKWindowSetScaledFrame(NSWindow *window, NSRect scaleFrame, NSRect nonScaledFrame);
324 #endif
325
326 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
327 void WKSyncSurfaceToView(NSView *view);
328 #endif
329
330 #if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
331 CFIndex WKGetHyphenationLocationBeforeIndex(CFStringRef string, CFIndex index);
332 #endif
333
334 #ifdef __cplusplus
335 }
336 #endif