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