Home | History | Annotate | Download | only in mac
      1 /*
      2  * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #ifndef WebCoreSystemInterface_h
     27 #define WebCoreSystemInterface_h
     28 
     29 #include <ApplicationServices/ApplicationServices.h>
     30 #include <objc/objc.h>
     31 
     32 #if PLATFORM(MAC) && USE(CA) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
     33 #include <IOSurface/IOSurface.h>
     34 #endif
     35 
     36 typedef struct _NSRange NSRange;
     37 
     38 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
     39 typedef struct CGPoint NSPoint;
     40 typedef struct CGRect NSRect;
     41 #else
     42 typedef struct _NSPoint NSPoint;
     43 typedef struct _NSRect NSRect;
     44 #endif
     45 
     46 #ifdef __OBJC__
     47 @class NSArray;
     48 @class NSButtonCell;
     49 @class NSData;
     50 @class NSDate;
     51 @class NSEvent;
     52 @class NSFont;
     53 @class NSHTTPCookie;
     54 @class NSImage;
     55 @class NSMenu;
     56 @class NSMutableURLRequest;
     57 @class NSString;
     58 @class NSTextFieldCell;
     59 @class NSURL;
     60 @class NSURLConnection;
     61 @class NSURLRequest;
     62 @class NSURLResponse;
     63 @class NSView;
     64 @class QTMovie;
     65 @class QTMovieView;
     66 #else
     67 class NSArray;
     68 class NSButtonCell;
     69 class NSData;
     70 class NSDate;
     71 class NSEvent;
     72 class NSFont;
     73 class NSHTTPCookie;
     74 class NSImage;
     75 class NSMenu;
     76 class NSMutableArray;
     77 class NSMutableURLRequest;
     78 class NSURL;
     79 class NSURLRequest;
     80 class NSString;
     81 class NSTextFieldCell;
     82 class NSURLConnection;
     83 class NSURLResponse;
     84 class NSView;
     85 class QTMovie;
     86 class QTMovieView;
     87 #endif
     88 
     89 typedef struct _CFURLResponse *CFURLResponseRef;
     90 
     91 extern "C" {
     92 
     93 // In alphabetical order.
     94 
     95 extern void (*wkAdvanceDefaultButtonPulseAnimation)(NSButtonCell *);
     96 extern BOOL (*wkCGContextGetShouldSmoothFonts)(CGContextRef);
     97 extern CFReadStreamRef (*wkCreateCustomCFReadStream)(void *(*formCreate)(CFReadStreamRef, void *),
     98     void (*formFinalize)(CFReadStreamRef, void *),
     99     Boolean (*formOpen)(CFReadStreamRef, CFStreamError *, Boolean *, void *),
    100     CFIndex (*formRead)(CFReadStreamRef, UInt8 *, CFIndex, CFStreamError *, Boolean *, void *),
    101     Boolean (*formCanRead)(CFReadStreamRef, void *),
    102     void (*formClose)(CFReadStreamRef, void *),
    103     void (*formSchedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
    104     void (*formUnschedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
    105     void *context);
    106 extern CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
    107 extern NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
    108 extern id (*wkCreateNSURLConnectionDelegateProxy)(void);
    109 extern void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
    110 extern void (*wkDrawTextFieldCellFocusRing)(NSTextFieldCell*, NSRect);
    111 extern void (*wkDrawCapsLockIndicator)(CGContextRef, CGRect);
    112 extern void (*wkDrawBezeledTextArea)(NSRect, BOOL enabled);
    113 extern void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int radius);
    114 extern NSFont* (*wkGetFontInLanguageForRange)(NSFont*, NSString*, NSRange);
    115 extern NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar);
    116 extern BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance);
    117 extern void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime,
    118     float duration, unsigned state);
    119 extern void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
    120 extern CFStringRef (*wkSignedPublicKeyAndChallengeString)(unsigned keySize, CFStringRef challenge, CFStringRef keyDescription);
    121 extern NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*);
    122 extern NSArray* (*wkGetExtensionsForMIMEType)(NSString*);
    123 extern NSString* (*wkGetMIMETypeForExtension)(NSString*);
    124 extern ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
    125 extern double (*wkGetNSURLResponseCalculatedExpiration)(NSURLResponse *response);
    126 extern NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
    127 extern BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
    128 extern void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous);
    129 extern BOOL (*wkHitTestMediaUIPart)(int part, int themeStyle, CGRect bounds, CGPoint point);
    130 extern void (*wkMeasureMediaUIPart)(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize);
    131 extern BOOL (*wkMediaControllerThemeAvailable)(int themeStyle);
    132 extern void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
    133 extern unsigned (*wkQTIncludeOnlyModernMediaFileTypes)(void);
    134 extern int (*wkQTMovieDataRate)(QTMovie*);
    135 extern void (*wkQTMovieDisableComponent)(uint32_t[5]);
    136 extern float (*wkQTMovieMaxTimeLoaded)(QTMovie*);
    137 extern NSString *(*wkQTMovieMaxTimeLoadedChangeNotification)(void);
    138 extern float (*wkQTMovieMaxTimeSeekable)(QTMovie*);
    139 extern int (*wkQTMovieGetType)(QTMovie*);
    140 extern BOOL (*wkQTMovieHasClosedCaptions)(QTMovie*);
    141 extern void (*wkQTMovieSetShowClosedCaptions)(QTMovie*, BOOL);
    142 extern void (*wkQTMovieSelectPreferredAlternates)(QTMovie*);
    143 extern void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL);
    144 extern void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
    145 extern void (*wkSetCookieStoragePrivateBrowsingEnabled)(BOOL);
    146 extern void (*wkSetDragImage)(NSImage*, NSPoint offset);
    147 extern void (*wkSetNSURLConnectionDefersCallbacks)(NSURLConnection *, BOOL);
    148 extern void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL);
    149 extern void (*wkSetPatternBaseCTM)(CGContextRef, CGAffineTransform);
    150 extern void (*wkSetPatternPhaseInUserSpace)(CGContextRef, CGPoint);
    151 extern CGAffineTransform (*wkGetUserToBaseCTM)(CGContextRef);
    152 extern void (*wkSetUpFontCache)();
    153 extern void (*wkSignalCFReadStreamEnd)(CFReadStreamRef stream);
    154 extern void (*wkSignalCFReadStreamError)(CFReadStreamRef stream, CFStreamError *error);
    155 extern void (*wkSignalCFReadStreamHasBytes)(CFReadStreamRef stream);
    156 extern unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount);
    157 extern int (*wkGetHTTPPipeliningPriority)(NSURLRequest *);
    158 extern void (*wkSetHTTPPipeliningMaximumPriority)(int maximumPriority);
    159 extern void (*wkSetHTTPPipeliningPriority)(NSMutableURLRequest *, int priority);
    160 extern void (*wkSetHTTPPipeliningMinimumFastLanePriority)(int priority);
    161 extern void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
    162 extern void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString);
    163 extern CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL);
    164 
    165 #ifndef BUILDING_ON_TIGER
    166 extern void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t);
    167 #else
    168 #define GLYPH_VECTOR_SIZE (50 * 32)
    169 
    170 extern void (*wkClearGlyphVector)(void* glyphs);
    171 extern OSStatus (*wkConvertCharToGlyphs)(void* styleGroup, const UniChar*, unsigned numCharacters, void* glyphs);
    172 extern CFStringRef (*wkCopyFullFontName)(CGFontRef font);
    173 extern OSStatus (*wkGetATSStyleGroup)(ATSUStyle, void** styleGroup);
    174 extern CGFontRef (*wkGetCGFontFromNSFont)(NSFont*);
    175 extern void (*wkGetFontMetrics)(CGFontRef, int* ascent, int* descent, int* lineGap, unsigned* unitsPerEm);
    176 extern ATSLayoutRecord* (*wkGetGlyphVectorFirstRecord)(void* glyphVector);
    177 extern void* wkGetGlyphsForCharacters;
    178 extern int (*wkGetGlyphVectorNumGlyphs)(void* glyphVector);
    179 extern size_t (*wkGetGlyphVectorRecordSize)(void* glyphVector);
    180 extern OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs);
    181 extern void (*wkReleaseStyleGroup)(void* group);
    182 extern BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *);
    183 #endif
    184 
    185 extern BOOL (*wkUseSharedMediaUI)();
    186 
    187 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
    188 extern void* wkGetHyphenationLocationBeforeIndex;
    189 #else
    190 extern CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
    191 
    192 typedef enum {
    193     wkEventPhaseNone = 0,
    194     wkEventPhaseBegan = 1,
    195     wkEventPhaseChanged = 2,
    196     wkEventPhaseEnded = 3,
    197 } wkEventPhase;
    198 
    199 extern int (*wkGetNSEventMomentumPhase)(NSEvent *);
    200 #endif
    201 
    202 extern CTLineRef (*wkCreateCTLineWithUniCharProvider)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*);
    203 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
    204 extern CTTypesetterRef (*wkCreateCTTypesetterWithUniCharProviderAndOptions)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*, CFDictionaryRef options);
    205 
    206 extern CGContextRef (*wkIOSurfaceContextCreate)(IOSurfaceRef surface, unsigned width, unsigned height, CGColorSpaceRef colorSpace);
    207 extern CGImageRef (*wkIOSurfaceContextCreateImage)(CGContextRef context);
    208 
    209 typedef struct __WKScrollbarPainter *WKScrollbarPainterRef;
    210 typedef struct __WKScrollbarPainterController *WKScrollbarPainterControllerRef;
    211 
    212 extern WKScrollbarPainterRef (*wkMakeScrollbarPainter)(int controlSize, bool isHorizontal);
    213 extern WKScrollbarPainterRef (*wkMakeScrollbarReplacementPainter)(WKScrollbarPainterRef oldPainter, int newStyle, int controlSize, bool isHorizontal);
    214 extern void (*wkScrollbarPainterSetDelegate)(WKScrollbarPainterRef, id scrollbarPainterDelegate);
    215 extern void (*wkScrollbarPainterPaint)(WKScrollbarPainterRef, bool enabled, double value, CGFloat proportion, CGRect frameRect);
    216 extern void (*wkScrollbarPainterForceFlashScrollers)(WKScrollbarPainterControllerRef);
    217 extern int (*wkScrollbarThickness)(int controlSize);
    218 extern int (*wkScrollbarMinimumThumbLength)(WKScrollbarPainterRef);
    219 extern int (*wkScrollbarMinimumTotalLengthNeededForThumb)(WKScrollbarPainterRef);
    220 extern CGFloat (*wkScrollbarPainterKnobAlpha)(WKScrollbarPainterRef);
    221 extern void (*wkSetScrollbarPainterKnobAlpha)(WKScrollbarPainterRef, CGFloat);
    222 extern CGFloat (*wkScrollbarPainterTrackAlpha)(WKScrollbarPainterRef);
    223 extern void (*wkSetScrollbarPainterTrackAlpha)(WKScrollbarPainterRef, CGFloat);
    224 extern bool (*wkScrollbarPainterIsHorizontal)(WKScrollbarPainterRef);
    225 extern void (*wkScrollbarPainterSetOverlayState)(WKScrollbarPainterRef, int overlayScrollerState);
    226 
    227 extern WKScrollbarPainterControllerRef (*wkMakeScrollbarPainterController)(id painterControllerDelegate);
    228 extern void (*wkSetPainterForPainterController)(WKScrollbarPainterControllerRef, WKScrollbarPainterRef, bool isHorizontal);
    229 extern WKScrollbarPainterRef (*wkVerticalScrollbarPainterForController)(WKScrollbarPainterControllerRef);
    230 extern WKScrollbarPainterRef (*wkHorizontalScrollbarPainterForController)(WKScrollbarPainterControllerRef);
    231 extern void (*wkSetScrollbarPainterControllerStyle)(WKScrollbarPainterControllerRef, int newStyle);
    232 extern void (*wkContentAreaScrolled)(WKScrollbarPainterControllerRef);
    233 extern void (*wkContentAreaWillPaint)(WKScrollbarPainterControllerRef);
    234 extern void (*wkMouseEnteredContentArea)(WKScrollbarPainterControllerRef);
    235 extern void (*wkMouseExitedContentArea)(WKScrollbarPainterControllerRef);
    236 extern void (*wkMouseMovedInContentArea)(WKScrollbarPainterControllerRef);
    237 extern void (*wkWillStartLiveResize)(WKScrollbarPainterControllerRef);
    238 extern void (*wkContentAreaResized)(WKScrollbarPainterControllerRef);
    239 extern void (*wkWillEndLiveResize)(WKScrollbarPainterControllerRef);
    240 extern void (*wkContentAreaDidShow)(WKScrollbarPainterControllerRef);
    241 extern void (*wkContentAreaDidHide)(WKScrollbarPainterControllerRef);
    242 extern void (*wkDidBeginScrollGesture)(WKScrollbarPainterControllerRef);
    243 extern void (*wkDidEndScrollGesture)(WKScrollbarPainterControllerRef);
    244 
    245 extern bool (*wkScrollbarPainterUsesOverlayScrollers)(void);
    246 #endif
    247 
    248 extern void (*wkUnregisterUniqueIdForElement)(id element);
    249 extern void (*wkAccessibilityHandleFocusChanged)(void);
    250 extern CFTypeID (*wkGetAXTextMarkerTypeID)(void);
    251 extern CFTypeID (*wkGetAXTextMarkerRangeTypeID)(void);
    252 extern CFTypeRef (*wkCreateAXTextMarkerRange)(CFTypeRef start, CFTypeRef end);
    253 extern CFTypeRef (*wkCopyAXTextMarkerRangeStart)(CFTypeRef range);
    254 extern CFTypeRef (*wkCopyAXTextMarkerRangeEnd)(CFTypeRef range);
    255 extern CFTypeRef (*wkCreateAXTextMarker)(const void *bytes, size_t len);
    256 extern BOOL (*wkGetBytesFromAXTextMarker)(CFTypeRef textMarker, void *bytes, size_t length);
    257 extern AXUIElementRef (*wkCreateAXUIElementRef)(id element);
    258 
    259 typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
    260 extern CFURLStorageSessionRef (*wkCreatePrivateStorageSession)(CFStringRef);
    261 extern NSURLRequest* (*wkCopyRequestWithStorageSession)(CFURLStorageSessionRef, NSURLRequest*);
    262 
    263 typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef;
    264 extern CFHTTPCookieStorageRef (*wkCopyHTTPCookieStorage)(CFURLStorageSessionRef);
    265 extern unsigned (*wkGetHTTPCookieAcceptPolicy)(CFHTTPCookieStorageRef);
    266 extern NSArray *(*wkHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSURL *);
    267 extern void (*wkSetHTTPCookiesForURL)(CFHTTPCookieStorageRef, NSArray *, NSURL *, NSURL *);
    268 extern void (*wkDeleteHTTPCookie)(CFHTTPCookieStorageRef, NSHTTPCookie *);
    269 
    270 extern CFStringRef (*wkGetCFURLResponseMIMEType)(CFURLResponseRef);
    271 extern CFURLRef (*wkGetCFURLResponseURL)(CFURLResponseRef);
    272 extern CFHTTPMessageRef (*wkGetCFURLResponseHTTPResponse)(CFURLResponseRef);
    273 extern CFStringRef (*wkCopyCFURLResponseSuggestedFilename)(CFURLResponseRef);
    274 extern void (*wkSetCFURLResponseMIMEType)(CFURLResponseRef, CFStringRef mimeType);
    275 
    276 }
    277 
    278 #endif
    279