Use OptionSet for layout milestones
[WebKit-https.git] / Source / WebKit / Shared / API / c / WKSharedAPICast.h
1 /*
2  * Copyright (C) 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 INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef WKSharedAPICast_h
27 #define WKSharedAPICast_h
28
29 #include "APIError.h"
30 #include "APINumber.h"
31 #include "APISecurityOrigin.h"
32 #include "APIString.h"
33 #include "APIURL.h"
34 #include "APIURLRequest.h"
35 #include "APIURLResponse.h"
36 #include "ImageOptions.h"
37 #include "SameDocumentNavigationType.h"
38 #include "WKBase.h"
39 #include "WKContextMenuItemTypes.h"
40 #include "WKDiagnosticLoggingResultType.h"
41 #include "WKEvent.h"
42 #include "WKFindOptions.h"
43 #include "WKGeometry.h"
44 #include "WKImage.h"
45 #include "WKPageLoadTypes.h"
46 #include "WKPageLoadTypesPrivate.h"
47 #include "WKPageVisibilityTypes.h"
48 #include "WKUserContentInjectedFrames.h"
49 #include "WKUserScriptInjectionTime.h"
50 #include "WebEvent.h"
51 #include "WebFindOptions.h"
52 #include <WebCore/ContextMenuItem.h>
53 #include <WebCore/DiagnosticLoggingResultType.h>
54 #include <WebCore/FloatRect.h>
55 #include <WebCore/FrameLoaderTypes.h>
56 #include <WebCore/IntRect.h>
57 #include <WebCore/LayoutMilestone.h>
58 #include <WebCore/SecurityOrigin.h>
59 #include <WebCore/UserContentTypes.h>
60 #include <WebCore/UserScriptTypes.h>
61 #include <WebCore/VisibilityState.h>
62
63 namespace API {
64 class Array;
65 class Dictionary;
66 class Data;
67 class Point;
68 class Rect;
69 class SecurityOrigin;
70 class SerializedScriptValue;
71 class Size;
72 class UserContentURLPattern;
73 class WebArchive;
74 class WebArchiveResource;
75 }
76
77 namespace WebKit {
78
79 class ObjCObjectGraph;
80 class WebCertificateInfo;
81 class WebConnection;
82 class WebContextMenuItem;
83 class WebImage;
84
85 template<typename APIType> struct APITypeInfo;
86 template<typename ImplType> struct ImplTypeInfo;
87
88 #define WK_ADD_API_MAPPING(TheAPIType, TheImplType) \
89     template<> struct APITypeInfo<TheAPIType> { typedef TheImplType ImplType; }; \
90     template<> struct ImplTypeInfo<TheImplType> { typedef TheAPIType APIType; };
91
92 WK_ADD_API_MAPPING(WKArrayRef, API::Array)
93 WK_ADD_API_MAPPING(WKBooleanRef, API::Boolean)
94 WK_ADD_API_MAPPING(WKCertificateInfoRef, WebCertificateInfo)
95 WK_ADD_API_MAPPING(WKConnectionRef, WebConnection)
96 WK_ADD_API_MAPPING(WKContextMenuItemRef, WebContextMenuItem)
97 WK_ADD_API_MAPPING(WKDataRef, API::Data)
98 WK_ADD_API_MAPPING(WKDictionaryRef, API::Dictionary)
99 WK_ADD_API_MAPPING(WKDoubleRef, API::Double)
100 WK_ADD_API_MAPPING(WKErrorRef, API::Error)
101 WK_ADD_API_MAPPING(WKImageRef, WebImage)
102 WK_ADD_API_MAPPING(WKPointRef, API::Point)
103 WK_ADD_API_MAPPING(WKRectRef, API::Rect)
104 WK_ADD_API_MAPPING(WKSecurityOriginRef, API::SecurityOrigin)
105 WK_ADD_API_MAPPING(WKSerializedScriptValueRef, API::SerializedScriptValue)
106 WK_ADD_API_MAPPING(WKSizeRef, API::Size)
107 WK_ADD_API_MAPPING(WKStringRef, API::String)
108 WK_ADD_API_MAPPING(WKTypeRef, API::Object)
109 WK_ADD_API_MAPPING(WKUInt64Ref, API::UInt64)
110 WK_ADD_API_MAPPING(WKURLRef, API::URL)
111 WK_ADD_API_MAPPING(WKURLRequestRef, API::URLRequest)
112 WK_ADD_API_MAPPING(WKURLResponseRef, API::URLResponse)
113 WK_ADD_API_MAPPING(WKUserContentURLPatternRef, API::UserContentURLPattern)
114
115 template<> struct APITypeInfo<WKMutableArrayRef> { typedef API::Array ImplType; };
116 template<> struct APITypeInfo<WKMutableDictionaryRef> { typedef API::Dictionary ImplType; };
117
118 #if PLATFORM(COCOA)
119 WK_ADD_API_MAPPING(WKWebArchiveRef, API::WebArchive)
120 WK_ADD_API_MAPPING(WKWebArchiveResourceRef, API::WebArchiveResource)
121 WK_ADD_API_MAPPING(WKObjCTypeWrapperRef, ObjCObjectGraph)
122 #endif
123
124 template<typename T, typename APIType = typename ImplTypeInfo<T>::APIType>
125 auto toAPI(T* t) -> APIType
126 {
127     return reinterpret_cast<APIType>(API::Object::wrap(t));
128 }
129
130 template<typename T, typename ImplType = typename APITypeInfo<T>::ImplType>
131 auto toImpl(T t) -> ImplType*
132 {
133     return static_cast<ImplType*>(API::Object::unwrap(static_cast<void*>(const_cast<typename std::remove_const<typename std::remove_pointer<T>::type>::type*>(t))));
134 }
135
136 template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType>::APIType>
137 class ProxyingRefPtr {
138 public:
139     ProxyingRefPtr(RefPtr<ImplType>&& impl)
140         : m_impl(impl)
141     {
142     }
143
144     ProxyingRefPtr(Ref<ImplType>&& impl)
145         : m_impl(WTFMove(impl))
146     {
147     }
148
149     operator APIType() { return toAPI(m_impl.get()); }
150
151 private:
152     RefPtr<ImplType> m_impl;
153 };
154
155 /* Special cases. */
156
157 inline ProxyingRefPtr<API::String> toAPI(StringImpl* string)
158 {
159     return ProxyingRefPtr<API::String>(API::String::create(string));
160 }
161
162 inline WKStringRef toCopiedAPI(const String& string)
163 {
164     return toAPI(&API::String::create(string).leakRef());
165 }
166
167 inline ProxyingRefPtr<API::URL> toURLRef(StringImpl* string)
168 {
169     if (!string)
170         return ProxyingRefPtr<API::URL>(nullptr);
171     return ProxyingRefPtr<API::URL>(API::URL::create(String(string)));
172 }
173
174 inline WKURLRef toCopiedURLAPI(const String& string)
175 {
176     if (!string)
177         return nullptr;
178     return toAPI(&API::URL::create(string).leakRef());
179 }
180
181 inline String toWTFString(WKStringRef stringRef)
182 {
183     if (!stringRef)
184         return String();
185     return toImpl(stringRef)->string();
186 }
187
188 inline String toWTFString(WKURLRef urlRef)
189 {
190     if (!urlRef)
191         return String();
192     return toImpl(urlRef)->string();
193 }
194
195 inline ProxyingRefPtr<API::Error> toAPI(const WebCore::ResourceError& error)
196 {
197     return ProxyingRefPtr<API::Error>(API::Error::create(error));
198 }
199
200 inline ProxyingRefPtr<API::URLRequest> toAPI(const WebCore::ResourceRequest& request)
201 {
202     return ProxyingRefPtr<API::URLRequest>(API::URLRequest::create(request));
203 }
204
205 inline ProxyingRefPtr<API::URLResponse> toAPI(const WebCore::ResourceResponse& response)
206 {
207     return ProxyingRefPtr<API::URLResponse>(API::URLResponse::create(response));
208 }
209
210 inline WKSecurityOriginRef toCopiedAPI(WebCore::SecurityOrigin* origin)
211 {
212     if (!origin)
213         return nullptr;
214     return toAPI(&API::SecurityOrigin::create(*origin).leakRef());
215 }
216
217 /* Geometry conversions */
218
219 inline WebCore::FloatRect toFloatRect(const WKRect& wkRect)
220 {
221     return WebCore::FloatRect(static_cast<float>(wkRect.origin.x), static_cast<float>(wkRect.origin.y),
222                               static_cast<float>(wkRect.size.width), static_cast<float>(wkRect.size.height));
223 }
224
225 inline WebCore::IntSize toIntSize(const WKSize& wkSize)
226 {
227     return WebCore::IntSize(static_cast<int>(wkSize.width), static_cast<int>(wkSize.height));
228 }
229
230 inline WebCore::IntPoint toIntPoint(const WKPoint& wkPoint)
231 {
232     return WebCore::IntPoint(static_cast<int>(wkPoint.x), static_cast<int>(wkPoint.y));
233 }
234
235 inline WebCore::IntRect toIntRect(const WKRect& wkRect)
236 {
237     return WebCore::IntRect(static_cast<int>(wkRect.origin.x), static_cast<int>(wkRect.origin.y),
238                             static_cast<int>(wkRect.size.width), static_cast<int>(wkRect.size.height));
239 }
240
241 inline WKRect toAPI(const WebCore::FloatRect& rect)
242 {
243     WKRect wkRect;
244     wkRect.origin.x = rect.x();
245     wkRect.origin.y = rect.y();
246     wkRect.size.width = rect.width();
247     wkRect.size.height = rect.height();
248     return wkRect;
249 }
250
251 inline WKRect toAPI(const WebCore::IntRect& rect)
252 {
253     WKRect wkRect;
254     wkRect.origin.x = rect.x();
255     wkRect.origin.y = rect.y();
256     wkRect.size.width = rect.width();
257     wkRect.size.height = rect.height();
258     return wkRect;
259 }
260
261 inline WKSize toAPI(const WebCore::IntSize& size)
262 {
263     WKSize wkSize;
264     wkSize.width = size.width();
265     wkSize.height = size.height();
266     return wkSize;
267 }
268
269 inline WKPoint toAPI(const WebCore::IntPoint& point)
270 {
271     WKPoint wkPoint;
272     wkPoint.x = point.x();
273     wkPoint.y = point.y();
274     return wkPoint;
275 }
276
277 /* Enum conversions */
278
279 inline WKTypeID toAPI(API::Object::Type type)
280 {
281     return static_cast<WKTypeID>(type);
282 }
283
284 inline WKEventModifiers toAPI(WebEvent::Modifiers modifiers)
285 {
286     WKEventModifiers wkModifiers = 0;
287     if (modifiers & WebEvent::ShiftKey)
288         wkModifiers |= kWKEventModifiersShiftKey;
289     if (modifiers & WebEvent::ControlKey)
290         wkModifiers |= kWKEventModifiersControlKey;
291     if (modifiers & WebEvent::AltKey)
292         wkModifiers |= kWKEventModifiersAltKey;
293     if (modifiers & WebEvent::MetaKey)
294         wkModifiers |= kWKEventModifiersMetaKey;
295     if (modifiers & WebEvent::CapsLockKey)
296         wkModifiers |= kWKEventModifiersCapsLockKey;
297     return wkModifiers;
298 }
299
300 inline WKEventMouseButton toAPI(WebMouseEvent::Button mouseButton)
301 {
302     WKEventMouseButton wkMouseButton = kWKEventMouseButtonNoButton;
303
304     switch (mouseButton) {
305     case WebMouseEvent::NoButton:
306         wkMouseButton = kWKEventMouseButtonNoButton;
307         break;
308     case WebMouseEvent::LeftButton:
309         wkMouseButton = kWKEventMouseButtonLeftButton;
310         break;
311     case WebMouseEvent::MiddleButton:
312         wkMouseButton = kWKEventMouseButtonMiddleButton;
313         break;
314     case WebMouseEvent::RightButton:
315         wkMouseButton = kWKEventMouseButtonRightButton;
316         break;
317     }
318
319     return wkMouseButton;
320 }
321
322 inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
323 {
324     switch (action) {
325     case WebCore::ContextMenuItemTagNoAction:
326         return kWKContextMenuItemTagNoAction;
327     case WebCore::ContextMenuItemTagOpenLinkInNewWindow:
328         return kWKContextMenuItemTagOpenLinkInNewWindow;
329     case WebCore::ContextMenuItemTagDownloadLinkToDisk:
330         return kWKContextMenuItemTagDownloadLinkToDisk;
331     case WebCore::ContextMenuItemTagCopyLinkToClipboard:
332         return kWKContextMenuItemTagCopyLinkToClipboard;
333     case WebCore::ContextMenuItemTagOpenImageInNewWindow:
334         return kWKContextMenuItemTagOpenImageInNewWindow;
335     case WebCore::ContextMenuItemTagDownloadImageToDisk:
336         return kWKContextMenuItemTagDownloadImageToDisk;
337     case WebCore::ContextMenuItemTagCopyImageToClipboard:
338         return kWKContextMenuItemTagCopyImageToClipboard;
339 #if PLATFORM(GTK)
340     case WebCore::ContextMenuItemTagCopyImageUrlToClipboard:
341         return kWKContextMenuItemTagCopyImageUrlToClipboard;
342 #endif
343     case WebCore::ContextMenuItemTagOpenFrameInNewWindow:
344         return kWKContextMenuItemTagOpenFrameInNewWindow;
345     case WebCore::ContextMenuItemTagCopy:
346         return kWKContextMenuItemTagCopy;
347     case WebCore::ContextMenuItemTagGoBack:
348         return kWKContextMenuItemTagGoBack;
349     case WebCore::ContextMenuItemTagGoForward:
350         return kWKContextMenuItemTagGoForward;
351     case WebCore::ContextMenuItemTagStop:
352         return kWKContextMenuItemTagStop;
353     case WebCore::ContextMenuItemTagReload:
354         return kWKContextMenuItemTagReload;
355     case WebCore::ContextMenuItemTagCut:
356         return kWKContextMenuItemTagCut;
357     case WebCore::ContextMenuItemTagPaste:
358         return kWKContextMenuItemTagPaste;
359 #if PLATFORM(GTK)
360     case WebCore::ContextMenuItemTagSelectAll:
361         return kWKContextMenuItemTagSelectAll;
362 #endif
363     case WebCore::ContextMenuItemTagSpellingGuess:
364         return kWKContextMenuItemTagSpellingGuess;
365     case WebCore::ContextMenuItemTagNoGuessesFound:
366         return kWKContextMenuItemTagNoGuessesFound;
367     case WebCore::ContextMenuItemTagIgnoreSpelling:
368         return kWKContextMenuItemTagIgnoreSpelling;
369     case WebCore::ContextMenuItemTagLearnSpelling:
370         return kWKContextMenuItemTagLearnSpelling;
371     case WebCore::ContextMenuItemTagOther:
372         return kWKContextMenuItemTagOther;
373     case WebCore::ContextMenuItemTagSearchInSpotlight:
374         return kWKContextMenuItemTagSearchInSpotlight;
375     case WebCore::ContextMenuItemTagSearchWeb:
376         return kWKContextMenuItemTagSearchWeb;
377     case WebCore::ContextMenuItemTagLookUpInDictionary:
378         return kWKContextMenuItemTagLookUpInDictionary;
379     case WebCore::ContextMenuItemTagOpenWithDefaultApplication:
380         return kWKContextMenuItemTagOpenWithDefaultApplication;
381     case WebCore::ContextMenuItemPDFActualSize:
382         return kWKContextMenuItemTagPDFActualSize;
383     case WebCore::ContextMenuItemPDFZoomIn:
384         return kWKContextMenuItemTagPDFZoomIn;
385     case WebCore::ContextMenuItemPDFZoomOut:
386         return kWKContextMenuItemTagPDFZoomOut;
387     case WebCore::ContextMenuItemPDFAutoSize:
388         return kWKContextMenuItemTagPDFAutoSize;
389     case WebCore::ContextMenuItemPDFSinglePage:
390         return kWKContextMenuItemTagPDFSinglePage;
391     case WebCore::ContextMenuItemPDFFacingPages:
392         return kWKContextMenuItemTagPDFFacingPages;
393     case WebCore::ContextMenuItemPDFContinuous:
394         return kWKContextMenuItemTagPDFContinuous;
395     case WebCore::ContextMenuItemPDFNextPage:
396         return kWKContextMenuItemTagPDFNextPage;
397     case WebCore::ContextMenuItemPDFPreviousPage:
398         return kWKContextMenuItemTagPDFPreviousPage;
399     case WebCore::ContextMenuItemTagOpenLink:
400         return kWKContextMenuItemTagOpenLink;
401     case WebCore::ContextMenuItemTagIgnoreGrammar:
402         return kWKContextMenuItemTagIgnoreGrammar;
403     case WebCore::ContextMenuItemTagSpellingMenu:
404         return kWKContextMenuItemTagSpellingMenu;
405     case WebCore::ContextMenuItemTagShowSpellingPanel:
406         return kWKContextMenuItemTagShowSpellingPanel;
407     case WebCore::ContextMenuItemTagCheckSpelling:
408         return kWKContextMenuItemTagCheckSpelling;
409     case WebCore::ContextMenuItemTagCheckSpellingWhileTyping:
410         return kWKContextMenuItemTagCheckSpellingWhileTyping;
411     case WebCore::ContextMenuItemTagCheckGrammarWithSpelling:
412         return kWKContextMenuItemTagCheckGrammarWithSpelling;
413     case WebCore::ContextMenuItemTagFontMenu:
414         return kWKContextMenuItemTagFontMenu;
415     case WebCore::ContextMenuItemTagShowFonts:
416         return kWKContextMenuItemTagShowFonts;
417     case WebCore::ContextMenuItemTagBold:
418         return kWKContextMenuItemTagBold;
419     case WebCore::ContextMenuItemTagItalic:
420         return kWKContextMenuItemTagItalic;
421     case WebCore::ContextMenuItemTagUnderline:
422         return kWKContextMenuItemTagUnderline;
423     case WebCore::ContextMenuItemTagOutline:
424         return kWKContextMenuItemTagOutline;
425     case WebCore::ContextMenuItemTagStyles:
426         return kWKContextMenuItemTagStyles;
427     case WebCore::ContextMenuItemTagShowColors:
428         return kWKContextMenuItemTagShowColors;
429     case WebCore::ContextMenuItemTagSpeechMenu:
430         return kWKContextMenuItemTagSpeechMenu;
431     case WebCore::ContextMenuItemTagStartSpeaking:
432         return kWKContextMenuItemTagStartSpeaking;
433     case WebCore::ContextMenuItemTagStopSpeaking:
434         return kWKContextMenuItemTagStopSpeaking;
435     case WebCore::ContextMenuItemTagWritingDirectionMenu:
436         return kWKContextMenuItemTagWritingDirectionMenu;
437     case WebCore::ContextMenuItemTagDefaultDirection:
438         return kWKContextMenuItemTagDefaultDirection;
439     case WebCore::ContextMenuItemTagLeftToRight:
440         return kWKContextMenuItemTagLeftToRight;
441     case WebCore::ContextMenuItemTagRightToLeft:
442         return kWKContextMenuItemTagRightToLeft;
443     case WebCore::ContextMenuItemTagPDFSinglePageScrolling:
444         return kWKContextMenuItemTagPDFSinglePageScrolling;
445     case WebCore::ContextMenuItemTagPDFFacingPagesScrolling:
446         return kWKContextMenuItemTagPDFFacingPagesScrolling;
447     case WebCore::ContextMenuItemTagDictationAlternative:
448         return kWKContextMenuItemTagDictationAlternative;
449     case WebCore::ContextMenuItemTagInspectElement:
450         return kWKContextMenuItemTagInspectElement;
451     case WebCore::ContextMenuItemTagTextDirectionMenu:
452         return kWKContextMenuItemTagTextDirectionMenu;
453     case WebCore::ContextMenuItemTagTextDirectionDefault:
454         return kWKContextMenuItemTagTextDirectionDefault;
455     case WebCore::ContextMenuItemTagTextDirectionLeftToRight:
456         return kWKContextMenuItemTagTextDirectionLeftToRight;
457     case WebCore::ContextMenuItemTagTextDirectionRightToLeft:
458         return kWKContextMenuItemTagTextDirectionRightToLeft;
459     case WebCore::ContextMenuItemTagOpenMediaInNewWindow:
460         return kWKContextMenuItemTagOpenMediaInNewWindow;
461     case WebCore::ContextMenuItemTagDownloadMediaToDisk:
462         return kWKContextMenuItemTagDownloadMediaToDisk;
463     case WebCore::ContextMenuItemTagCopyMediaLinkToClipboard:
464         return kWKContextMenuItemTagCopyMediaLinkToClipboard;
465     case WebCore::ContextMenuItemTagToggleMediaControls:
466         return kWKContextMenuItemTagToggleMediaControls;
467     case WebCore::ContextMenuItemTagToggleMediaLoop:
468         return kWKContextMenuItemTagToggleMediaLoop;
469     case WebCore::ContextMenuItemTagToggleVideoFullscreen:
470         return kWKContextMenuItemTagToggleVideoFullscreen;
471     case WebCore::ContextMenuItemTagEnterVideoFullscreen:
472         return kWKContextMenuItemTagEnterVideoFullscreen;
473     case WebCore::ContextMenuItemTagToggleVideoEnhancedFullscreen:
474         return kWKContextMenuItemTagToggleVideoEnhancedFullscreen;
475     case WebCore::ContextMenuItemTagMediaPlayPause:
476         return kWKContextMenuItemTagMediaPlayPause;
477     case WebCore::ContextMenuItemTagMediaMute:
478         return kWKContextMenuItemTagMediaMute;
479 #if PLATFORM(COCOA)
480     case WebCore::ContextMenuItemTagCorrectSpellingAutomatically:
481         return kWKContextMenuItemTagCorrectSpellingAutomatically;
482     case WebCore::ContextMenuItemTagSubstitutionsMenu:
483         return kWKContextMenuItemTagSubstitutionsMenu;
484     case WebCore::ContextMenuItemTagShowSubstitutions:
485         return kWKContextMenuItemTagShowSubstitutions;
486     case WebCore::ContextMenuItemTagSmartCopyPaste:
487         return kWKContextMenuItemTagSmartCopyPaste;
488     case WebCore::ContextMenuItemTagSmartQuotes:
489         return kWKContextMenuItemTagSmartQuotes;
490     case WebCore::ContextMenuItemTagSmartDashes:
491         return kWKContextMenuItemTagSmartDashes;
492     case WebCore::ContextMenuItemTagSmartLinks:
493         return kWKContextMenuItemTagSmartLinks;
494     case WebCore::ContextMenuItemTagTextReplacement:
495         return kWKContextMenuItemTagTextReplacement;
496     case WebCore::ContextMenuItemTagTransformationsMenu:
497         return kWKContextMenuItemTagTransformationsMenu;
498     case WebCore::ContextMenuItemTagMakeUpperCase:
499         return kWKContextMenuItemTagMakeUpperCase;
500     case WebCore::ContextMenuItemTagMakeLowerCase:
501         return kWKContextMenuItemTagMakeLowerCase;
502     case WebCore::ContextMenuItemTagCapitalize:
503         return kWKContextMenuItemTagCapitalize;
504     case WebCore::ContextMenuItemTagChangeBack:
505         return kWKContextMenuItemTagChangeBack;
506 #endif
507     case WebCore::ContextMenuItemTagShareMenu:
508         return kWKContextMenuItemTagShareMenu;
509     default:
510         if (action < WebCore::ContextMenuItemBaseApplicationTag && !(action >= WebCore::ContextMenuItemBaseCustomTag && action <= WebCore::ContextMenuItemLastCustomTag))
511             LOG_ERROR("ContextMenuAction %i is an unknown tag but is below the allowable custom tag value of %i", action, WebCore::ContextMenuItemBaseApplicationTag);
512         return static_cast<WKContextMenuItemTag>(action);
513     }
514 }
515
516 inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
517 {
518     switch (tag) {
519     case kWKContextMenuItemTagNoAction:
520         return WebCore::ContextMenuItemTagNoAction;
521     case kWKContextMenuItemTagOpenLinkInNewWindow:
522         return WebCore::ContextMenuItemTagOpenLinkInNewWindow;
523     case kWKContextMenuItemTagDownloadLinkToDisk:
524         return WebCore::ContextMenuItemTagDownloadLinkToDisk;
525     case kWKContextMenuItemTagCopyLinkToClipboard:
526         return WebCore::ContextMenuItemTagCopyLinkToClipboard;
527     case kWKContextMenuItemTagOpenImageInNewWindow:
528         return WebCore::ContextMenuItemTagOpenImageInNewWindow;
529     case kWKContextMenuItemTagDownloadImageToDisk:
530         return WebCore::ContextMenuItemTagDownloadImageToDisk;
531     case kWKContextMenuItemTagCopyImageToClipboard:
532         return WebCore::ContextMenuItemTagCopyImageToClipboard;
533     case kWKContextMenuItemTagOpenFrameInNewWindow:
534 #if PLATFORM(GTK)
535     case kWKContextMenuItemTagCopyImageUrlToClipboard:
536         return WebCore::ContextMenuItemTagCopyImageUrlToClipboard;
537 #endif
538         return WebCore::ContextMenuItemTagOpenFrameInNewWindow;
539     case kWKContextMenuItemTagCopy:
540         return WebCore::ContextMenuItemTagCopy;
541     case kWKContextMenuItemTagGoBack:
542         return WebCore::ContextMenuItemTagGoBack;
543     case kWKContextMenuItemTagGoForward:
544         return WebCore::ContextMenuItemTagGoForward;
545     case kWKContextMenuItemTagStop:
546         return WebCore::ContextMenuItemTagStop;
547     case kWKContextMenuItemTagReload:
548         return WebCore::ContextMenuItemTagReload;
549     case kWKContextMenuItemTagCut:
550         return WebCore::ContextMenuItemTagCut;
551     case kWKContextMenuItemTagPaste:
552         return WebCore::ContextMenuItemTagPaste;
553 #if PLATFORM(GTK)
554     case kWKContextMenuItemTagSelectAll:
555         return WebCore::ContextMenuItemTagSelectAll;
556 #endif
557     case kWKContextMenuItemTagSpellingGuess:
558         return WebCore::ContextMenuItemTagSpellingGuess;
559     case kWKContextMenuItemTagNoGuessesFound:
560         return WebCore::ContextMenuItemTagNoGuessesFound;
561     case kWKContextMenuItemTagIgnoreSpelling:
562         return WebCore::ContextMenuItemTagIgnoreSpelling;
563     case kWKContextMenuItemTagLearnSpelling:
564         return WebCore::ContextMenuItemTagLearnSpelling;
565     case kWKContextMenuItemTagOther:
566         return WebCore::ContextMenuItemTagOther;
567     case kWKContextMenuItemTagSearchInSpotlight:
568         return WebCore::ContextMenuItemTagSearchInSpotlight;
569     case kWKContextMenuItemTagSearchWeb:
570         return WebCore::ContextMenuItemTagSearchWeb;
571     case kWKContextMenuItemTagLookUpInDictionary:
572         return WebCore::ContextMenuItemTagLookUpInDictionary;
573     case kWKContextMenuItemTagOpenWithDefaultApplication:
574         return WebCore::ContextMenuItemTagOpenWithDefaultApplication;
575     case kWKContextMenuItemTagPDFActualSize:
576         return WebCore::ContextMenuItemPDFActualSize;
577     case kWKContextMenuItemTagPDFZoomIn:
578         return WebCore::ContextMenuItemPDFZoomIn;
579     case kWKContextMenuItemTagPDFZoomOut:
580         return WebCore::ContextMenuItemPDFZoomOut;
581     case kWKContextMenuItemTagPDFAutoSize:
582         return WebCore::ContextMenuItemPDFAutoSize;
583     case kWKContextMenuItemTagPDFSinglePage:
584         return WebCore::ContextMenuItemPDFSinglePage;
585     case kWKContextMenuItemTagPDFFacingPages:
586         return WebCore::ContextMenuItemPDFFacingPages;
587     case kWKContextMenuItemTagPDFContinuous:
588         return WebCore::ContextMenuItemPDFContinuous;
589     case kWKContextMenuItemTagPDFNextPage:
590         return WebCore::ContextMenuItemPDFNextPage;
591     case kWKContextMenuItemTagPDFPreviousPage:
592         return WebCore::ContextMenuItemPDFPreviousPage;
593     case kWKContextMenuItemTagOpenLink:
594         return WebCore::ContextMenuItemTagOpenLink;
595     case kWKContextMenuItemTagIgnoreGrammar:
596         return WebCore::ContextMenuItemTagIgnoreGrammar;
597     case kWKContextMenuItemTagSpellingMenu:
598         return WebCore::ContextMenuItemTagSpellingMenu;
599     case kWKContextMenuItemTagShowSpellingPanel:
600         return WebCore::ContextMenuItemTagShowSpellingPanel;
601     case kWKContextMenuItemTagCheckSpelling:
602         return WebCore::ContextMenuItemTagCheckSpelling;
603     case kWKContextMenuItemTagCheckSpellingWhileTyping:
604         return WebCore::ContextMenuItemTagCheckSpellingWhileTyping;
605     case kWKContextMenuItemTagCheckGrammarWithSpelling:
606         return WebCore::ContextMenuItemTagCheckGrammarWithSpelling;
607     case kWKContextMenuItemTagFontMenu:
608         return WebCore::ContextMenuItemTagFontMenu;
609     case kWKContextMenuItemTagShowFonts:
610         return WebCore::ContextMenuItemTagShowFonts;
611     case kWKContextMenuItemTagBold:
612         return WebCore::ContextMenuItemTagBold;
613     case kWKContextMenuItemTagItalic:
614         return WebCore::ContextMenuItemTagItalic;
615     case kWKContextMenuItemTagUnderline:
616         return WebCore::ContextMenuItemTagUnderline;
617     case kWKContextMenuItemTagOutline:
618         return WebCore::ContextMenuItemTagOutline;
619     case kWKContextMenuItemTagStyles:
620         return WebCore::ContextMenuItemTagStyles;
621     case kWKContextMenuItemTagShowColors:
622         return WebCore::ContextMenuItemTagShowColors;
623     case kWKContextMenuItemTagSpeechMenu:
624         return WebCore::ContextMenuItemTagSpeechMenu;
625     case kWKContextMenuItemTagStartSpeaking:
626         return WebCore::ContextMenuItemTagStartSpeaking;
627     case kWKContextMenuItemTagStopSpeaking:
628         return WebCore::ContextMenuItemTagStopSpeaking;
629     case kWKContextMenuItemTagWritingDirectionMenu:
630         return WebCore::ContextMenuItemTagWritingDirectionMenu;
631     case kWKContextMenuItemTagDefaultDirection:
632         return WebCore::ContextMenuItemTagDefaultDirection;
633     case kWKContextMenuItemTagLeftToRight:
634         return WebCore::ContextMenuItemTagLeftToRight;
635     case kWKContextMenuItemTagRightToLeft:
636         return WebCore::ContextMenuItemTagRightToLeft;
637     case kWKContextMenuItemTagPDFSinglePageScrolling:
638         return WebCore::ContextMenuItemTagPDFSinglePageScrolling;
639     case kWKContextMenuItemTagPDFFacingPagesScrolling:
640         return WebCore::ContextMenuItemTagPDFFacingPagesScrolling;
641     case kWKContextMenuItemTagDictationAlternative:
642         return WebCore::ContextMenuItemTagDictationAlternative;
643     case kWKContextMenuItemTagInspectElement:
644         return WebCore::ContextMenuItemTagInspectElement;
645     case kWKContextMenuItemTagTextDirectionMenu:
646         return WebCore::ContextMenuItemTagTextDirectionMenu;
647     case kWKContextMenuItemTagTextDirectionDefault:
648         return WebCore::ContextMenuItemTagTextDirectionDefault;
649     case kWKContextMenuItemTagTextDirectionLeftToRight:
650         return WebCore::ContextMenuItemTagTextDirectionLeftToRight;
651     case kWKContextMenuItemTagTextDirectionRightToLeft:
652         return WebCore::ContextMenuItemTagTextDirectionRightToLeft;
653     case kWKContextMenuItemTagOpenMediaInNewWindow:
654         return WebCore::ContextMenuItemTagOpenMediaInNewWindow;
655     case kWKContextMenuItemTagDownloadMediaToDisk:
656         return WebCore::ContextMenuItemTagDownloadMediaToDisk;
657     case kWKContextMenuItemTagCopyMediaLinkToClipboard:
658         return WebCore::ContextMenuItemTagCopyMediaLinkToClipboard;
659     case kWKContextMenuItemTagToggleMediaControls:
660         return WebCore::ContextMenuItemTagToggleMediaControls;
661     case kWKContextMenuItemTagToggleMediaLoop:
662         return WebCore::ContextMenuItemTagToggleMediaLoop;
663     case kWKContextMenuItemTagToggleVideoFullscreen:
664         return WebCore::ContextMenuItemTagToggleVideoFullscreen;
665     case kWKContextMenuItemTagEnterVideoFullscreen:
666         return WebCore::ContextMenuItemTagEnterVideoFullscreen;
667     case kWKContextMenuItemTagToggleVideoEnhancedFullscreen:
668         return WebCore::ContextMenuItemTagToggleVideoEnhancedFullscreen;
669     case kWKContextMenuItemTagMediaPlayPause:
670         return WebCore::ContextMenuItemTagMediaPlayPause;
671     case kWKContextMenuItemTagMediaMute:
672         return WebCore::ContextMenuItemTagMediaMute;
673 #if PLATFORM(COCOA)
674     case kWKContextMenuItemTagCorrectSpellingAutomatically:
675         return WebCore::ContextMenuItemTagCorrectSpellingAutomatically;
676     case kWKContextMenuItemTagSubstitutionsMenu:
677         return WebCore::ContextMenuItemTagSubstitutionsMenu;
678     case kWKContextMenuItemTagShowSubstitutions:
679         return WebCore::ContextMenuItemTagShowSubstitutions;
680     case kWKContextMenuItemTagSmartCopyPaste:
681         return WebCore::ContextMenuItemTagSmartCopyPaste;
682     case kWKContextMenuItemTagSmartQuotes:
683         return WebCore::ContextMenuItemTagSmartQuotes;
684     case kWKContextMenuItemTagSmartDashes:
685         return WebCore::ContextMenuItemTagSmartDashes;
686     case kWKContextMenuItemTagSmartLinks:
687         return WebCore::ContextMenuItemTagSmartLinks;
688     case kWKContextMenuItemTagTextReplacement:
689         return WebCore::ContextMenuItemTagTextReplacement;
690     case kWKContextMenuItemTagTransformationsMenu:
691         return WebCore::ContextMenuItemTagTransformationsMenu;
692     case kWKContextMenuItemTagMakeUpperCase:
693         return WebCore::ContextMenuItemTagMakeUpperCase;
694     case kWKContextMenuItemTagMakeLowerCase:
695         return WebCore::ContextMenuItemTagMakeLowerCase;
696     case kWKContextMenuItemTagCapitalize:
697         return WebCore::ContextMenuItemTagCapitalize;
698     case kWKContextMenuItemTagChangeBack:
699         return WebCore::ContextMenuItemTagChangeBack;
700     case kWKContextMenuItemTagShareMenu:
701         return WebCore::ContextMenuItemTagShareMenu;
702 #endif
703     case kWKContextMenuItemTagOpenLinkInThisWindow:
704     default:
705         if (tag < kWKContextMenuItemBaseApplicationTag && !(tag >= WebCore::ContextMenuItemBaseCustomTag && tag <= WebCore::ContextMenuItemLastCustomTag))
706             LOG_ERROR("WKContextMenuItemTag %i is an unknown tag but is below the allowable custom tag value of %i", tag, kWKContextMenuItemBaseApplicationTag);
707         return static_cast<WebCore::ContextMenuAction>(tag);
708     }
709 }
710
711 inline WKContextMenuItemType toAPI(WebCore::ContextMenuItemType type)
712 {
713     switch(type) {
714     case WebCore::ActionType:
715         return kWKContextMenuItemTypeAction;
716     case WebCore::CheckableActionType:
717         return kWKContextMenuItemTypeCheckableAction;
718     case WebCore::SeparatorType:
719         return kWKContextMenuItemTypeSeparator;
720     case WebCore::SubmenuType:
721         return kWKContextMenuItemTypeSubmenu;
722     default:
723         ASSERT_NOT_REACHED();
724         return kWKContextMenuItemTypeAction;
725     }
726 }
727
728 inline FindOptions toFindOptions(WKFindOptions wkFindOptions)
729 {
730     unsigned findOptions = 0;
731
732     if (wkFindOptions & kWKFindOptionsCaseInsensitive)
733         findOptions |= FindOptionsCaseInsensitive;
734     if (wkFindOptions & kWKFindOptionsAtWordStarts)
735         findOptions |= FindOptionsAtWordStarts;
736     if (wkFindOptions & kWKFindOptionsTreatMedialCapitalAsWordStart)
737         findOptions |= FindOptionsTreatMedialCapitalAsWordStart;
738     if (wkFindOptions & kWKFindOptionsBackwards)
739         findOptions |= FindOptionsBackwards;
740     if (wkFindOptions & kWKFindOptionsWrapAround)
741         findOptions |= FindOptionsWrapAround;
742     if (wkFindOptions & kWKFindOptionsShowOverlay)
743         findOptions |= FindOptionsShowOverlay;
744     if (wkFindOptions & kWKFindOptionsShowFindIndicator)
745         findOptions |= FindOptionsShowFindIndicator;
746     if (wkFindOptions & kWKFindOptionsShowHighlight)
747         findOptions |= FindOptionsShowHighlight;
748
749     return static_cast<FindOptions>(findOptions);
750 }
751
752 inline WKFrameNavigationType toAPI(WebCore::NavigationType type)
753 {
754     WKFrameNavigationType wkType = kWKFrameNavigationTypeOther;
755
756     switch (type) {
757     case WebCore::NavigationType::LinkClicked:
758         wkType = kWKFrameNavigationTypeLinkClicked;
759         break;
760     case WebCore::NavigationType::FormSubmitted:
761         wkType = kWKFrameNavigationTypeFormSubmitted;
762         break;
763     case WebCore::NavigationType::BackForward:
764         wkType = kWKFrameNavigationTypeBackForward;
765         break;
766     case WebCore::NavigationType::Reload:
767         wkType = kWKFrameNavigationTypeReload;
768         break;
769     case WebCore::NavigationType::FormResubmitted:
770         wkType = kWKFrameNavigationTypeFormResubmitted;
771         break;
772     case WebCore::NavigationType::Other:
773         wkType = kWKFrameNavigationTypeOther;
774         break;
775     }
776     
777     return wkType;
778 }
779
780 inline WKSameDocumentNavigationType toAPI(SameDocumentNavigationType type)
781 {
782     WKFrameNavigationType wkType = kWKSameDocumentNavigationAnchorNavigation;
783
784     switch (type) {
785     case SameDocumentNavigationAnchorNavigation:
786         wkType = kWKSameDocumentNavigationAnchorNavigation;
787         break;
788     case SameDocumentNavigationSessionStatePush:
789         wkType = kWKSameDocumentNavigationSessionStatePush;
790         break;
791     case SameDocumentNavigationSessionStateReplace:
792         wkType = kWKSameDocumentNavigationSessionStateReplace;
793         break;
794     case SameDocumentNavigationSessionStatePop:
795         wkType = kWKSameDocumentNavigationSessionStatePop;
796         break;
797     }
798     
799     return wkType;
800 }
801
802 inline SameDocumentNavigationType toSameDocumentNavigationType(WKSameDocumentNavigationType wkType)
803 {
804     SameDocumentNavigationType type = SameDocumentNavigationAnchorNavigation;
805
806     switch (wkType) {
807     case kWKSameDocumentNavigationAnchorNavigation:
808         type = SameDocumentNavigationAnchorNavigation;
809         break;
810     case kWKSameDocumentNavigationSessionStatePush:
811         type = SameDocumentNavigationSessionStatePush;
812         break;
813     case kWKSameDocumentNavigationSessionStateReplace:
814         type = SameDocumentNavigationSessionStateReplace;
815         break;
816     case kWKSameDocumentNavigationSessionStatePop:
817         type = SameDocumentNavigationSessionStatePop;
818         break;
819     }
820     
821     return type;
822 }
823
824 inline WKDiagnosticLoggingResultType toAPI(WebCore::DiagnosticLoggingResultType type)
825 {
826     WKDiagnosticLoggingResultType wkType;
827
828     switch (type) {
829     case WebCore::DiagnosticLoggingResultPass:
830         wkType = kWKDiagnosticLoggingResultPass;
831         break;
832     case WebCore::DiagnosticLoggingResultFail:
833         wkType = kWKDiagnosticLoggingResultFail;
834         break;
835     case WebCore::DiagnosticLoggingResultNoop:
836         wkType = kWKDiagnosticLoggingResultNoop;
837         break;
838     }
839
840     return wkType;
841 }
842
843 inline WebCore::DiagnosticLoggingResultType toDiagnosticLoggingResultType(WKDiagnosticLoggingResultType wkType)
844 {
845     WebCore::DiagnosticLoggingResultType type;
846
847     switch (wkType) {
848     case kWKDiagnosticLoggingResultPass:
849         type = WebCore::DiagnosticLoggingResultPass;
850         break;
851     case kWKDiagnosticLoggingResultFail:
852         type = WebCore::DiagnosticLoggingResultFail;
853         break;
854     case kWKDiagnosticLoggingResultNoop:
855         type = WebCore::DiagnosticLoggingResultNoop;
856         break;
857     }
858
859     return type;
860 }
861
862 inline WKLayoutMilestones toWKLayoutMilestones(OptionSet<WebCore::LayoutMilestone> milestones)
863 {
864     unsigned wkMilestones = 0;
865
866     if (milestones & WebCore::DidFirstLayout)
867         wkMilestones |= kWKDidFirstLayout;
868     if (milestones & WebCore::DidFirstVisuallyNonEmptyLayout)
869         wkMilestones |= kWKDidFirstVisuallyNonEmptyLayout;
870     if (milestones & WebCore::DidHitRelevantRepaintedObjectsAreaThreshold)
871         wkMilestones |= kWKDidHitRelevantRepaintedObjectsAreaThreshold;
872     if (milestones & WebCore::DidFirstFlushForHeaderLayer)
873         wkMilestones |= kWKDidFirstFlushForHeaderLayer;
874     if (milestones & WebCore::DidFirstLayoutAfterSuppressedIncrementalRendering)
875         wkMilestones |= kWKDidFirstLayoutAfterSuppressedIncrementalRendering;
876     if (milestones & WebCore::DidFirstPaintAfterSuppressedIncrementalRendering)
877         wkMilestones |= kWKDidFirstPaintAfterSuppressedIncrementalRendering;
878     if (milestones & WebCore::DidRenderSignificantAmountOfText)
879         wkMilestones |= kWKDidRenderSignificantAmountOfText;
880     
881     return wkMilestones;
882 }
883
884 inline OptionSet<WebCore::LayoutMilestone> toLayoutMilestones(WKLayoutMilestones wkMilestones)
885 {
886     OptionSet<WebCore::LayoutMilestone> milestones;
887
888     if (wkMilestones & kWKDidFirstLayout)
889         milestones.add(WebCore::DidFirstLayout);
890     if (wkMilestones & kWKDidFirstVisuallyNonEmptyLayout)
891         milestones.add(WebCore::DidFirstVisuallyNonEmptyLayout);
892     if (wkMilestones & kWKDidHitRelevantRepaintedObjectsAreaThreshold)
893         milestones.add(WebCore::DidHitRelevantRepaintedObjectsAreaThreshold);
894     if (wkMilestones & kWKDidFirstFlushForHeaderLayer)
895         milestones.add(WebCore::DidFirstFlushForHeaderLayer);
896     if (wkMilestones & kWKDidFirstLayoutAfterSuppressedIncrementalRendering)
897         milestones.add(WebCore::DidFirstLayoutAfterSuppressedIncrementalRendering);
898     if (wkMilestones & kWKDidFirstPaintAfterSuppressedIncrementalRendering)
899         milestones.add(WebCore::DidFirstPaintAfterSuppressedIncrementalRendering);
900     if (wkMilestones & kWKDidRenderSignificantAmountOfText)
901         milestones.add(WebCore::DidRenderSignificantAmountOfText);
902     
903     return milestones;
904 }
905
906 inline WebCore::VisibilityState toVisibilityState(WKPageVisibilityState wkPageVisibilityState)
907 {
908     switch (wkPageVisibilityState) {
909     case kWKPageVisibilityStateVisible:
910         return WebCore::VisibilityState::Visible;
911     case kWKPageVisibilityStateHidden:
912         return WebCore::VisibilityState::Hidden;
913     case kWKPageVisibilityStatePrerender:
914         return WebCore::VisibilityState::Prerender;
915     }
916
917     ASSERT_NOT_REACHED();
918     return WebCore::VisibilityState::Visible;
919 }
920
921 inline ImageOptions toImageOptions(WKImageOptions wkImageOptions)
922 {
923     unsigned imageOptions = 0;
924
925     if (wkImageOptions & kWKImageOptionsShareable)
926         imageOptions |= ImageOptionsShareable;
927
928     return static_cast<ImageOptions>(imageOptions);
929 }
930
931 inline SnapshotOptions snapshotOptionsFromImageOptions(WKImageOptions wkImageOptions)
932 {
933     unsigned snapshotOptions = 0;
934
935     if (wkImageOptions & kWKImageOptionsShareable)
936         snapshotOptions |= SnapshotOptionsShareable;
937     
938     return snapshotOptions;
939 }
940
941 inline SnapshotOptions toSnapshotOptions(WKSnapshotOptions wkSnapshotOptions)
942 {
943     unsigned snapshotOptions = 0;
944
945     if (wkSnapshotOptions & kWKSnapshotOptionsShareable)
946         snapshotOptions |= SnapshotOptionsShareable;
947     if (wkSnapshotOptions & kWKSnapshotOptionsExcludeSelectionHighlighting)
948         snapshotOptions |= SnapshotOptionsExcludeSelectionHighlighting;
949     if (wkSnapshotOptions & kWKSnapshotOptionsInViewCoordinates)
950         snapshotOptions |= SnapshotOptionsInViewCoordinates;
951     if (wkSnapshotOptions & kWKSnapshotOptionsPaintSelectionRectangle)
952         snapshotOptions |= SnapshotOptionsPaintSelectionRectangle;
953     if (wkSnapshotOptions & kWKSnapshotOptionsForceBlackText)
954         snapshotOptions |= SnapshotOptionsForceBlackText;
955     if (wkSnapshotOptions & kWKSnapshotOptionsForceWhiteText)
956         snapshotOptions |= SnapshotOptionsForceWhiteText;
957     if (wkSnapshotOptions & kWKSnapshotOptionsPrinting)
958         snapshotOptions |= SnapshotOptionsPrinting;
959     if (wkSnapshotOptions & kWKSnapshotOptionsExtendedColor)
960         snapshotOptions |= SnapshotOptionsUseScreenColorSpace;
961
962     return snapshotOptions;
963 }
964
965 inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(_WKUserScriptInjectionTime wkInjectedTime)
966 {
967     switch (wkInjectedTime) {
968     case kWKInjectAtDocumentStart:
969         return WebCore::InjectAtDocumentStart;
970     case kWKInjectAtDocumentEnd:
971         return WebCore::InjectAtDocumentEnd;
972     }
973
974     ASSERT_NOT_REACHED();
975     return WebCore::InjectAtDocumentStart;
976 }
977
978 inline _WKUserScriptInjectionTime toWKUserScriptInjectionTime(WebCore::UserScriptInjectionTime injectedTime)
979 {
980     switch (injectedTime) {
981     case WebCore::InjectAtDocumentStart:
982         return kWKInjectAtDocumentStart;
983     case WebCore::InjectAtDocumentEnd:
984         return kWKInjectAtDocumentEnd;
985     }
986
987     ASSERT_NOT_REACHED();
988     return kWKInjectAtDocumentStart;
989 }
990
991 inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames)
992 {
993     switch (wkInjectedFrames) {
994     case kWKInjectInAllFrames:
995         return WebCore::InjectInAllFrames;
996     case kWKInjectInTopFrameOnly:
997         return WebCore::InjectInTopFrameOnly;
998     }
999
1000     ASSERT_NOT_REACHED();
1001     return WebCore::InjectInAllFrames;
1002 }
1003
1004 } // namespace WebKit
1005
1006 #endif // WKSharedAPICast_h