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