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