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