2
* Copyright (C) 2010 Apple Inc. All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
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.
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.
26
#ifndef WKSharedAPICast_h
27
#define WKSharedAPICast_h
29
#include "ImageOptions.h"
30
#include "SameDocumentNavigationType.h"
32
#include "WKContextMenuItemTypes.h"
34
#include "WKFindOptions.h"
35
#include "WKGeometry.h"
37
#include "WKPageLoadTypes.h"
40
#include "WebFindOptions.h"
41
#include "WebNumber.h"
42
#include "WebSecurityOrigin.h"
43
#include "WebString.h"
45
#include "WebURLRequest.h"
46
#include "WebURLResponse.h"
47
#include <WebCore/ContextMenuItem.h>
48
#include <WebCore/FloatRect.h>
49
#include <WebCore/FrameLoaderTypes.h>
50
#include <WebCore/IntRect.h>
51
#include <WebCore/LayoutMilestones.h>
52
#include <WebCore/SecurityOrigin.h>
53
#include <WebCore/UserContentTypes.h>
54
#include <WebCore/UserScriptTypes.h>
55
#include <wtf/TypeTraits.h>
60
class ImmutableDictionary;
62
class MutableDictionary;
63
class WebCertificateInfo;
65
class WebContextMenuItem;
67
class WebGraphicsContext;
71
class WebSecurityOrigin;
72
class WebSerializedScriptValue;
76
class WebUserContentURLPattern;
78
template<typename APIType> struct APITypeInfo { };
79
template<typename ImplType> struct ImplTypeInfo { };
81
#define WK_ADD_API_MAPPING(TheAPIType, TheImplType) \
82
template<> struct APITypeInfo<TheAPIType> { typedef TheImplType* ImplType; }; \
83
template<> struct ImplTypeInfo<TheImplType*> { typedef TheAPIType APIType; };
85
WK_ADD_API_MAPPING(WKArrayRef, ImmutableArray)
86
WK_ADD_API_MAPPING(WKBooleanRef, WebBoolean)
87
WK_ADD_API_MAPPING(WKCertificateInfoRef, WebCertificateInfo)
88
WK_ADD_API_MAPPING(WKConnectionRef, WebConnection)
89
WK_ADD_API_MAPPING(WKContextMenuItemRef, WebContextMenuItem)
90
WK_ADD_API_MAPPING(WKDataRef, WebData)
91
WK_ADD_API_MAPPING(WKDictionaryRef, ImmutableDictionary)
92
WK_ADD_API_MAPPING(WKDoubleRef, WebDouble)
93
WK_ADD_API_MAPPING(WKErrorRef, WebError)
94
WK_ADD_API_MAPPING(WKGraphicsContextRef, WebGraphicsContext)
95
WK_ADD_API_MAPPING(WKImageRef, WebImage)
96
WK_ADD_API_MAPPING(WKMutableArrayRef, MutableArray)
97
WK_ADD_API_MAPPING(WKMutableDictionaryRef, MutableDictionary)
98
WK_ADD_API_MAPPING(WKPointRef, WebPoint)
99
WK_ADD_API_MAPPING(WKRectRef, WebRect)
100
WK_ADD_API_MAPPING(WKSecurityOriginRef, WebSecurityOrigin)
101
WK_ADD_API_MAPPING(WKSerializedScriptValueRef, WebSerializedScriptValue)
102
WK_ADD_API_MAPPING(WKSizeRef, WebSize)
103
WK_ADD_API_MAPPING(WKStringRef, WebString)
104
WK_ADD_API_MAPPING(WKTypeRef, APIObject)
105
WK_ADD_API_MAPPING(WKUInt64Ref, WebUInt64)
106
WK_ADD_API_MAPPING(WKURLRef, WebURL)
107
WK_ADD_API_MAPPING(WKURLRequestRef, WebURLRequest)
108
WK_ADD_API_MAPPING(WKURLResponseRef, WebURLResponse)
109
WK_ADD_API_MAPPING(WKUserContentURLPatternRef, WebUserContentURLPattern)
111
template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType>
112
class ProxyingRefPtr {
114
ProxyingRefPtr(PassRefPtr<ImplType> impl)
119
operator APIType() { return toAPI(m_impl.get()); }
122
RefPtr<ImplType> m_impl;
125
/* Opaque typing convenience methods */
128
inline typename APITypeInfo<T>::ImplType toImpl(T t)
130
// An example of the conversions that take place:
131
// const struct OpaqueWKArray* -> const struct OpaqueWKArray -> struct OpaqueWKArray -> struct OpaqueWKArray* -> ImmutableArray*
133
typedef typename WTF::RemovePointer<T>::Type PotentiallyConstValueType;
134
typedef typename WTF::RemoveConst<PotentiallyConstValueType>::Type NonConstValueType;
136
return reinterpret_cast<typename APITypeInfo<T>::ImplType>(const_cast<NonConstValueType*>(t));
140
inline typename ImplTypeInfo<T>::APIType toAPI(T t)
142
return reinterpret_cast<typename ImplTypeInfo<T>::APIType>(t);
147
inline ProxyingRefPtr<WebString> toAPI(StringImpl* string)
149
return ProxyingRefPtr<WebString>(WebString::create(string));
152
inline WKStringRef toCopiedAPI(const String& string)
154
RefPtr<WebString> webString = WebString::create(string);
155
return toAPI(webString.release().leakRef());
158
inline ProxyingRefPtr<WebURL> toURLRef(StringImpl* string)
161
return ProxyingRefPtr<WebURL>(0);
162
return ProxyingRefPtr<WebURL>(WebURL::create(String(string)));
165
inline WKURLRef toCopiedURLAPI(const String& string)
169
RefPtr<WebURL> webURL = WebURL::create(string);
170
return toAPI(webURL.release().leakRef());
173
inline String toWTFString(WKStringRef stringRef)
177
return toImpl(stringRef)->string();
180
inline String toWTFString(WKURLRef urlRef)
184
return toImpl(urlRef)->string();
187
inline ProxyingRefPtr<WebError> toAPI(const WebCore::ResourceError& error)
189
return ProxyingRefPtr<WebError>(WebError::create(error));
192
inline ProxyingRefPtr<WebURLRequest> toAPI(const WebCore::ResourceRequest& request)
194
return ProxyingRefPtr<WebURLRequest>(WebURLRequest::create(request));
197
inline ProxyingRefPtr<WebURLResponse> toAPI(const WebCore::ResourceResponse& response)
199
return ProxyingRefPtr<WebURLResponse>(WebURLResponse::create(response));
202
inline WKSecurityOriginRef toCopiedAPI(WebCore::SecurityOrigin* origin)
206
return toAPI(WebSecurityOrigin::create(origin).leakRef());
209
/* Geometry conversions */
211
inline WebCore::FloatRect toFloatRect(const WKRect& wkRect)
213
return WebCore::FloatRect(static_cast<float>(wkRect.origin.x), static_cast<float>(wkRect.origin.y),
214
static_cast<float>(wkRect.size.width), static_cast<float>(wkRect.size.height));
217
inline WebCore::IntSize toIntSize(const WKSize& wkSize)
219
return WebCore::IntSize(static_cast<int>(wkSize.width), static_cast<int>(wkSize.height));
222
inline WebCore::IntPoint toIntPoint(const WKPoint& wkPoint)
224
return WebCore::IntPoint(static_cast<int>(wkPoint.x), static_cast<int>(wkPoint.y));
227
inline WebCore::IntRect toIntRect(const WKRect& wkRect)
229
return WebCore::IntRect(static_cast<int>(wkRect.origin.x), static_cast<int>(wkRect.origin.y),
230
static_cast<int>(wkRect.size.width), static_cast<int>(wkRect.size.height));
233
inline WKRect toAPI(const WebCore::FloatRect& rect)
236
wkRect.origin.x = rect.x();
237
wkRect.origin.y = rect.y();
238
wkRect.size.width = rect.width();
239
wkRect.size.height = rect.height();
243
inline WKRect toAPI(const WebCore::IntRect& rect)
246
wkRect.origin.x = rect.x();
247
wkRect.origin.y = rect.y();
248
wkRect.size.width = rect.width();
249
wkRect.size.height = rect.height();
253
inline WKSize toAPI(const WebCore::IntSize& size)
256
wkSize.width = size.width();
257
wkSize.height = size.height();
261
inline WKPoint toAPI(const WebCore::IntPoint& point)
264
wkPoint.x = point.x();
265
wkPoint.y = point.y();
269
/* Enum conversions */
271
inline WKTypeID toAPI(APIObject::Type type)
273
return static_cast<WKTypeID>(type);
276
inline WKEventModifiers toAPI(WebEvent::Modifiers modifiers)
278
WKEventModifiers wkModifiers = 0;
279
if (modifiers & WebEvent::ShiftKey)
280
wkModifiers |= kWKEventModifiersShiftKey;
281
if (modifiers & WebEvent::ControlKey)
282
wkModifiers |= kWKEventModifiersControlKey;
283
if (modifiers & WebEvent::AltKey)
284
wkModifiers |= kWKEventModifiersAltKey;
285
if (modifiers & WebEvent::MetaKey)
286
wkModifiers |= kWKEventModifiersMetaKey;
290
inline WKEventMouseButton toAPI(WebMouseEvent::Button mouseButton)
292
WKEventMouseButton wkMouseButton = kWKEventMouseButtonNoButton;
294
switch (mouseButton) {
295
case WebMouseEvent::NoButton:
296
wkMouseButton = kWKEventMouseButtonNoButton;
298
case WebMouseEvent::LeftButton:
299
wkMouseButton = kWKEventMouseButtonLeftButton;
301
case WebMouseEvent::MiddleButton:
302
wkMouseButton = kWKEventMouseButtonMiddleButton;
304
case WebMouseEvent::RightButton:
305
wkMouseButton = kWKEventMouseButtonRightButton;
309
return wkMouseButton;
312
inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
315
case WebCore::ContextMenuItemTagNoAction:
316
return kWKContextMenuItemTagNoAction;
317
case WebCore::ContextMenuItemTagOpenLinkInNewWindow:
318
return kWKContextMenuItemTagOpenLinkInNewWindow;
319
case WebCore::ContextMenuItemTagDownloadLinkToDisk:
320
return kWKContextMenuItemTagDownloadLinkToDisk;
321
case WebCore::ContextMenuItemTagCopyLinkToClipboard:
322
return kWKContextMenuItemTagCopyLinkToClipboard;
323
case WebCore::ContextMenuItemTagOpenImageInNewWindow:
324
return kWKContextMenuItemTagOpenImageInNewWindow;
325
case WebCore::ContextMenuItemTagDownloadImageToDisk:
326
return kWKContextMenuItemTagDownloadImageToDisk;
327
case WebCore::ContextMenuItemTagCopyImageToClipboard:
328
return kWKContextMenuItemTagCopyImageToClipboard;
329
case WebCore::ContextMenuItemTagOpenFrameInNewWindow:
330
return kWKContextMenuItemTagOpenFrameInNewWindow;
331
case WebCore::ContextMenuItemTagCopy:
332
return kWKContextMenuItemTagCopy;
333
case WebCore::ContextMenuItemTagGoBack:
334
return kWKContextMenuItemTagGoBack;
335
case WebCore::ContextMenuItemTagGoForward:
336
return kWKContextMenuItemTagGoForward;
337
case WebCore::ContextMenuItemTagStop:
338
return kWKContextMenuItemTagStop;
339
case WebCore::ContextMenuItemTagReload:
340
return kWKContextMenuItemTagReload;
341
case WebCore::ContextMenuItemTagCut:
342
return kWKContextMenuItemTagCut;
343
case WebCore::ContextMenuItemTagPaste:
344
return kWKContextMenuItemTagPaste;
345
case WebCore::ContextMenuItemTagSpellingGuess:
346
return kWKContextMenuItemTagSpellingGuess;
347
case WebCore::ContextMenuItemTagNoGuessesFound:
348
return kWKContextMenuItemTagNoGuessesFound;
349
case WebCore::ContextMenuItemTagIgnoreSpelling:
350
return kWKContextMenuItemTagIgnoreSpelling;
351
case WebCore::ContextMenuItemTagLearnSpelling:
352
return kWKContextMenuItemTagLearnSpelling;
353
case WebCore::ContextMenuItemTagOther:
354
return kWKContextMenuItemTagOther;
355
case WebCore::ContextMenuItemTagSearchInSpotlight:
356
return kWKContextMenuItemTagSearchInSpotlight;
357
case WebCore::ContextMenuItemTagSearchWeb:
358
return kWKContextMenuItemTagSearchWeb;
359
case WebCore::ContextMenuItemTagLookUpInDictionary:
360
return kWKContextMenuItemTagLookUpInDictionary;
361
case WebCore::ContextMenuItemTagOpenWithDefaultApplication:
362
return kWKContextMenuItemTagOpenWithDefaultApplication;
363
case WebCore::ContextMenuItemPDFActualSize:
364
return kWKContextMenuItemTagPDFActualSize;
365
case WebCore::ContextMenuItemPDFZoomIn:
366
return kWKContextMenuItemTagPDFZoomIn;
367
case WebCore::ContextMenuItemPDFZoomOut:
368
return kWKContextMenuItemTagPDFZoomOut;
369
case WebCore::ContextMenuItemPDFAutoSize:
370
return kWKContextMenuItemTagPDFAutoSize;
371
case WebCore::ContextMenuItemPDFSinglePage:
372
return kWKContextMenuItemTagPDFSinglePage;
373
case WebCore::ContextMenuItemPDFFacingPages:
374
return kWKContextMenuItemTagPDFFacingPages;
375
case WebCore::ContextMenuItemPDFContinuous:
376
return kWKContextMenuItemTagPDFContinuous;
377
case WebCore::ContextMenuItemPDFNextPage:
378
return kWKContextMenuItemTagPDFNextPage;
379
case WebCore::ContextMenuItemPDFPreviousPage:
380
return kWKContextMenuItemTagPDFPreviousPage;
381
case WebCore::ContextMenuItemTagOpenLink:
382
return kWKContextMenuItemTagOpenLink;
383
case WebCore::ContextMenuItemTagIgnoreGrammar:
384
return kWKContextMenuItemTagIgnoreGrammar;
385
case WebCore::ContextMenuItemTagSpellingMenu:
386
return kWKContextMenuItemTagSpellingMenu;
387
case WebCore::ContextMenuItemTagShowSpellingPanel:
388
return kWKContextMenuItemTagShowSpellingPanel;
389
case WebCore::ContextMenuItemTagCheckSpelling:
390
return kWKContextMenuItemTagCheckSpelling;
391
case WebCore::ContextMenuItemTagCheckSpellingWhileTyping:
392
return kWKContextMenuItemTagCheckSpellingWhileTyping;
393
case WebCore::ContextMenuItemTagCheckGrammarWithSpelling:
394
return kWKContextMenuItemTagCheckGrammarWithSpelling;
395
case WebCore::ContextMenuItemTagFontMenu:
396
return kWKContextMenuItemTagFontMenu;
397
case WebCore::ContextMenuItemTagShowFonts:
398
return kWKContextMenuItemTagShowFonts;
399
case WebCore::ContextMenuItemTagBold:
400
return kWKContextMenuItemTagBold;
401
case WebCore::ContextMenuItemTagItalic:
402
return kWKContextMenuItemTagItalic;
403
case WebCore::ContextMenuItemTagUnderline:
404
return kWKContextMenuItemTagUnderline;
405
case WebCore::ContextMenuItemTagOutline:
406
return kWKContextMenuItemTagOutline;
407
case WebCore::ContextMenuItemTagStyles:
408
return kWKContextMenuItemTagStyles;
409
case WebCore::ContextMenuItemTagShowColors:
410
return kWKContextMenuItemTagShowColors;
411
case WebCore::ContextMenuItemTagSpeechMenu:
412
return kWKContextMenuItemTagSpeechMenu;
413
case WebCore::ContextMenuItemTagStartSpeaking:
414
return kWKContextMenuItemTagStartSpeaking;
415
case WebCore::ContextMenuItemTagStopSpeaking:
416
return kWKContextMenuItemTagStopSpeaking;
417
case WebCore::ContextMenuItemTagWritingDirectionMenu:
418
return kWKContextMenuItemTagWritingDirectionMenu;
419
case WebCore::ContextMenuItemTagDefaultDirection:
420
return kWKContextMenuItemTagDefaultDirection;
421
case WebCore::ContextMenuItemTagLeftToRight:
422
return kWKContextMenuItemTagLeftToRight;
423
case WebCore::ContextMenuItemTagRightToLeft:
424
return kWKContextMenuItemTagRightToLeft;
425
case WebCore::ContextMenuItemTagPDFSinglePageScrolling:
426
return kWKContextMenuItemTagPDFSinglePageScrolling;
427
case WebCore::ContextMenuItemTagPDFFacingPagesScrolling:
428
return kWKContextMenuItemTagPDFFacingPagesScrolling;
429
case WebCore::ContextMenuItemTagDictationAlternative:
430
return kWKContextMenuItemTagDictationAlternative;
431
#if ENABLE(INSPECTOR)
432
case WebCore::ContextMenuItemTagInspectElement:
433
return kWKContextMenuItemTagInspectElement;
435
case WebCore::ContextMenuItemTagTextDirectionMenu:
436
return kWKContextMenuItemTagTextDirectionMenu;
437
case WebCore::ContextMenuItemTagTextDirectionDefault:
438
return kWKContextMenuItemTagTextDirectionDefault;
439
case WebCore::ContextMenuItemTagTextDirectionLeftToRight:
440
return kWKContextMenuItemTagTextDirectionLeftToRight;
441
case WebCore::ContextMenuItemTagTextDirectionRightToLeft:
442
return kWKContextMenuItemTagTextDirectionRightToLeft;
443
case WebCore::ContextMenuItemTagOpenMediaInNewWindow:
444
return kWKContextMenuItemTagOpenMediaInNewWindow;
445
case WebCore::ContextMenuItemTagCopyMediaLinkToClipboard:
446
return kWKContextMenuItemTagCopyMediaLinkToClipboard;
447
case WebCore::ContextMenuItemTagToggleMediaControls:
448
return kWKContextMenuItemTagToggleMediaControls;
449
case WebCore::ContextMenuItemTagToggleMediaLoop:
450
return kWKContextMenuItemTagToggleMediaLoop;
451
case WebCore::ContextMenuItemTagEnterVideoFullscreen:
452
return kWKContextMenuItemTagEnterVideoFullscreen;
453
case WebCore::ContextMenuItemTagMediaPlayPause:
454
return kWKContextMenuItemTagMediaPlayPause;
455
case WebCore::ContextMenuItemTagMediaMute:
456
return kWKContextMenuItemTagMediaMute;
458
case WebCore::ContextMenuItemTagCorrectSpellingAutomatically:
459
return kWKContextMenuItemTagCorrectSpellingAutomatically;
460
case WebCore::ContextMenuItemTagSubstitutionsMenu:
461
return kWKContextMenuItemTagSubstitutionsMenu;
462
case WebCore::ContextMenuItemTagShowSubstitutions:
463
return kWKContextMenuItemTagShowSubstitutions;
464
case WebCore::ContextMenuItemTagSmartCopyPaste:
465
return kWKContextMenuItemTagSmartCopyPaste;
466
case WebCore::ContextMenuItemTagSmartQuotes:
467
return kWKContextMenuItemTagSmartQuotes;
468
case WebCore::ContextMenuItemTagSmartDashes:
469
return kWKContextMenuItemTagSmartDashes;
470
case WebCore::ContextMenuItemTagSmartLinks:
471
return kWKContextMenuItemTagSmartLinks;
472
case WebCore::ContextMenuItemTagTextReplacement:
473
return kWKContextMenuItemTagTextReplacement;
474
case WebCore::ContextMenuItemTagTransformationsMenu:
475
return kWKContextMenuItemTagTransformationsMenu;
476
case WebCore::ContextMenuItemTagMakeUpperCase:
477
return kWKContextMenuItemTagMakeUpperCase;
478
case WebCore::ContextMenuItemTagMakeLowerCase:
479
return kWKContextMenuItemTagMakeLowerCase;
480
case WebCore::ContextMenuItemTagCapitalize:
481
return kWKContextMenuItemTagCapitalize;
482
case WebCore::ContextMenuItemTagChangeBack:
483
return kWKContextMenuItemTagChangeBack;
486
if (action < WebCore::ContextMenuItemBaseApplicationTag)
487
LOG_ERROR("ContextMenuAction %i is an unknown tag but is below the allowable custom tag value of %i", action, WebCore:: ContextMenuItemBaseApplicationTag);
488
return static_cast<WKContextMenuItemTag>(action);
492
inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
495
case kWKContextMenuItemTagNoAction:
496
return WebCore::ContextMenuItemTagNoAction;
497
case kWKContextMenuItemTagOpenLinkInNewWindow:
498
return WebCore::ContextMenuItemTagOpenLinkInNewWindow;
499
case kWKContextMenuItemTagDownloadLinkToDisk:
500
return WebCore::ContextMenuItemTagDownloadLinkToDisk;
501
case kWKContextMenuItemTagCopyLinkToClipboard:
502
return WebCore::ContextMenuItemTagCopyLinkToClipboard;
503
case kWKContextMenuItemTagOpenImageInNewWindow:
504
return WebCore::ContextMenuItemTagOpenImageInNewWindow;
505
case kWKContextMenuItemTagDownloadImageToDisk:
506
return WebCore::ContextMenuItemTagDownloadImageToDisk;
507
case kWKContextMenuItemTagCopyImageToClipboard:
508
return WebCore::ContextMenuItemTagCopyImageToClipboard;
509
case kWKContextMenuItemTagOpenFrameInNewWindow:
510
return WebCore::ContextMenuItemTagOpenFrameInNewWindow;
511
case kWKContextMenuItemTagCopy:
512
return WebCore::ContextMenuItemTagCopy;
513
case kWKContextMenuItemTagGoBack:
514
return WebCore::ContextMenuItemTagGoBack;
515
case kWKContextMenuItemTagGoForward:
516
return WebCore::ContextMenuItemTagGoForward;
517
case kWKContextMenuItemTagStop:
518
return WebCore::ContextMenuItemTagStop;
519
case kWKContextMenuItemTagReload:
520
return WebCore::ContextMenuItemTagReload;
521
case kWKContextMenuItemTagCut:
522
return WebCore::ContextMenuItemTagCut;
523
case kWKContextMenuItemTagPaste:
524
return WebCore::ContextMenuItemTagPaste;
525
case kWKContextMenuItemTagSpellingGuess:
526
return WebCore::ContextMenuItemTagSpellingGuess;
527
case kWKContextMenuItemTagNoGuessesFound:
528
return WebCore::ContextMenuItemTagNoGuessesFound;
529
case kWKContextMenuItemTagIgnoreSpelling:
530
return WebCore::ContextMenuItemTagIgnoreSpelling;
531
case kWKContextMenuItemTagLearnSpelling:
532
return WebCore::ContextMenuItemTagLearnSpelling;
533
case kWKContextMenuItemTagOther:
534
return WebCore::ContextMenuItemTagOther;
535
case kWKContextMenuItemTagSearchInSpotlight:
536
return WebCore::ContextMenuItemTagSearchInSpotlight;
537
case kWKContextMenuItemTagSearchWeb:
538
return WebCore::ContextMenuItemTagSearchWeb;
539
case kWKContextMenuItemTagLookUpInDictionary:
540
return WebCore::ContextMenuItemTagLookUpInDictionary;
541
case kWKContextMenuItemTagOpenWithDefaultApplication:
542
return WebCore::ContextMenuItemTagOpenWithDefaultApplication;
543
case kWKContextMenuItemTagPDFActualSize:
544
return WebCore::ContextMenuItemPDFActualSize;
545
case kWKContextMenuItemTagPDFZoomIn:
546
return WebCore::ContextMenuItemPDFZoomIn;
547
case kWKContextMenuItemTagPDFZoomOut:
548
return WebCore::ContextMenuItemPDFZoomOut;
549
case kWKContextMenuItemTagPDFAutoSize:
550
return WebCore::ContextMenuItemPDFAutoSize;
551
case kWKContextMenuItemTagPDFSinglePage:
552
return WebCore::ContextMenuItemPDFSinglePage;
553
case kWKContextMenuItemTagPDFFacingPages:
554
return WebCore::ContextMenuItemPDFFacingPages;
555
case kWKContextMenuItemTagPDFContinuous:
556
return WebCore::ContextMenuItemPDFContinuous;
557
case kWKContextMenuItemTagPDFNextPage:
558
return WebCore::ContextMenuItemPDFNextPage;
559
case kWKContextMenuItemTagPDFPreviousPage:
560
return WebCore::ContextMenuItemPDFPreviousPage;
561
case kWKContextMenuItemTagOpenLink:
562
return WebCore::ContextMenuItemTagOpenLink;
563
case kWKContextMenuItemTagIgnoreGrammar:
564
return WebCore::ContextMenuItemTagIgnoreGrammar;
565
case kWKContextMenuItemTagSpellingMenu:
566
return WebCore::ContextMenuItemTagSpellingMenu;
567
case kWKContextMenuItemTagShowSpellingPanel:
568
return WebCore::ContextMenuItemTagShowSpellingPanel;
569
case kWKContextMenuItemTagCheckSpelling:
570
return WebCore::ContextMenuItemTagCheckSpelling;
571
case kWKContextMenuItemTagCheckSpellingWhileTyping:
572
return WebCore::ContextMenuItemTagCheckSpellingWhileTyping;
573
case kWKContextMenuItemTagCheckGrammarWithSpelling:
574
return WebCore::ContextMenuItemTagCheckGrammarWithSpelling;
575
case kWKContextMenuItemTagFontMenu:
576
return WebCore::ContextMenuItemTagFontMenu;
577
case kWKContextMenuItemTagShowFonts:
578
return WebCore::ContextMenuItemTagShowFonts;
579
case kWKContextMenuItemTagBold:
580
return WebCore::ContextMenuItemTagBold;
581
case kWKContextMenuItemTagItalic:
582
return WebCore::ContextMenuItemTagItalic;
583
case kWKContextMenuItemTagUnderline:
584
return WebCore::ContextMenuItemTagUnderline;
585
case kWKContextMenuItemTagOutline:
586
return WebCore::ContextMenuItemTagOutline;
587
case kWKContextMenuItemTagStyles:
588
return WebCore::ContextMenuItemTagStyles;
589
case kWKContextMenuItemTagShowColors:
590
return WebCore::ContextMenuItemTagShowColors;
591
case kWKContextMenuItemTagSpeechMenu:
592
return WebCore::ContextMenuItemTagSpeechMenu;
593
case kWKContextMenuItemTagStartSpeaking:
594
return WebCore::ContextMenuItemTagStartSpeaking;
595
case kWKContextMenuItemTagStopSpeaking:
596
return WebCore::ContextMenuItemTagStopSpeaking;
597
case kWKContextMenuItemTagWritingDirectionMenu:
598
return WebCore::ContextMenuItemTagWritingDirectionMenu;
599
case kWKContextMenuItemTagDefaultDirection:
600
return WebCore::ContextMenuItemTagDefaultDirection;
601
case kWKContextMenuItemTagLeftToRight:
602
return WebCore::ContextMenuItemTagLeftToRight;
603
case kWKContextMenuItemTagRightToLeft:
604
return WebCore::ContextMenuItemTagRightToLeft;
605
case kWKContextMenuItemTagPDFSinglePageScrolling:
606
return WebCore::ContextMenuItemTagPDFSinglePageScrolling;
607
case kWKContextMenuItemTagPDFFacingPagesScrolling:
608
return WebCore::ContextMenuItemTagPDFFacingPagesScrolling;
609
case kWKContextMenuItemTagDictationAlternative:
610
return WebCore::ContextMenuItemTagDictationAlternative;
611
#if ENABLE(INSPECTOR)
612
case kWKContextMenuItemTagInspectElement:
613
return WebCore::ContextMenuItemTagInspectElement;
615
case kWKContextMenuItemTagTextDirectionMenu:
616
return WebCore::ContextMenuItemTagTextDirectionMenu;
617
case kWKContextMenuItemTagTextDirectionDefault:
618
return WebCore::ContextMenuItemTagTextDirectionDefault;
619
case kWKContextMenuItemTagTextDirectionLeftToRight:
620
return WebCore::ContextMenuItemTagTextDirectionLeftToRight;
621
case kWKContextMenuItemTagTextDirectionRightToLeft:
622
return WebCore::ContextMenuItemTagTextDirectionRightToLeft;
623
case kWKContextMenuItemTagOpenMediaInNewWindow:
624
return WebCore::ContextMenuItemTagOpenMediaInNewWindow;
625
case kWKContextMenuItemTagCopyMediaLinkToClipboard:
626
return WebCore::ContextMenuItemTagCopyMediaLinkToClipboard;
627
case kWKContextMenuItemTagToggleMediaControls:
628
return WebCore::ContextMenuItemTagToggleMediaControls;
629
case kWKContextMenuItemTagToggleMediaLoop:
630
return WebCore::ContextMenuItemTagToggleMediaLoop;
631
case kWKContextMenuItemTagEnterVideoFullscreen:
632
return WebCore::ContextMenuItemTagEnterVideoFullscreen;
633
case kWKContextMenuItemTagMediaPlayPause:
634
return WebCore::ContextMenuItemTagMediaPlayPause;
635
case kWKContextMenuItemTagMediaMute:
636
return WebCore::ContextMenuItemTagMediaMute;
638
case kWKContextMenuItemTagCorrectSpellingAutomatically:
639
return WebCore::ContextMenuItemTagCorrectSpellingAutomatically;
640
case kWKContextMenuItemTagSubstitutionsMenu:
641
return WebCore::ContextMenuItemTagSubstitutionsMenu;
642
case kWKContextMenuItemTagShowSubstitutions:
643
return WebCore::ContextMenuItemTagShowSubstitutions;
644
case kWKContextMenuItemTagSmartCopyPaste:
645
return WebCore::ContextMenuItemTagSmartCopyPaste;
646
case kWKContextMenuItemTagSmartQuotes:
647
return WebCore::ContextMenuItemTagSmartQuotes;
648
case kWKContextMenuItemTagSmartDashes:
649
return WebCore::ContextMenuItemTagSmartDashes;
650
case kWKContextMenuItemTagSmartLinks:
651
return WebCore::ContextMenuItemTagSmartLinks;
652
case kWKContextMenuItemTagTextReplacement:
653
return WebCore::ContextMenuItemTagTextReplacement;
654
case kWKContextMenuItemTagTransformationsMenu:
655
return WebCore::ContextMenuItemTagTransformationsMenu;
656
case kWKContextMenuItemTagMakeUpperCase:
657
return WebCore::ContextMenuItemTagMakeUpperCase;
658
case kWKContextMenuItemTagMakeLowerCase:
659
return WebCore::ContextMenuItemTagMakeLowerCase;
660
case kWKContextMenuItemTagCapitalize:
661
return WebCore::ContextMenuItemTagCapitalize;
662
case kWKContextMenuItemTagChangeBack:
663
return WebCore::ContextMenuItemTagChangeBack;
666
if (tag < kWKContextMenuItemBaseApplicationTag)
667
LOG_ERROR("WKContextMenuItemTag %i is an unknown tag but is below the allowable custom tag value of %i", tag, kWKContextMenuItemBaseApplicationTag);
668
return static_cast<WebCore::ContextMenuAction>(tag);
672
inline WKContextMenuItemType toAPI(WebCore::ContextMenuItemType type)
675
case WebCore::ActionType:
676
return kWKContextMenuItemTypeAction;
677
case WebCore::CheckableActionType:
678
return kWKContextMenuItemTypeCheckableAction;
679
case WebCore::SeparatorType:
680
return kWKContextMenuItemTypeSeparator;
681
case WebCore::SubmenuType:
682
return kWKContextMenuItemTypeSubmenu;
684
ASSERT_NOT_REACHED();
685
return kWKContextMenuItemTypeAction;
689
inline FindOptions toFindOptions(WKFindOptions wkFindOptions)
691
unsigned findOptions = 0;
693
if (wkFindOptions & kWKFindOptionsCaseInsensitive)
694
findOptions |= FindOptionsCaseInsensitive;
695
if (wkFindOptions & kWKFindOptionsAtWordStarts)
696
findOptions |= FindOptionsAtWordStarts;
697
if (wkFindOptions & kWKFindOptionsTreatMedialCapitalAsWordStart)
698
findOptions |= FindOptionsTreatMedialCapitalAsWordStart;
699
if (wkFindOptions & kWKFindOptionsBackwards)
700
findOptions |= FindOptionsBackwards;
701
if (wkFindOptions & kWKFindOptionsWrapAround)
702
findOptions |= FindOptionsWrapAround;
703
if (wkFindOptions & kWKFindOptionsShowOverlay)
704
findOptions |= FindOptionsShowOverlay;
705
if (wkFindOptions & kWKFindOptionsShowFindIndicator)
706
findOptions |= FindOptionsShowFindIndicator;
707
if (wkFindOptions & kWKFindOptionsShowHighlight)
708
findOptions |= FindOptionsShowHighlight;
710
return static_cast<FindOptions>(findOptions);
713
inline WKFrameNavigationType toAPI(WebCore::NavigationType type)
715
WKFrameNavigationType wkType = kWKFrameNavigationTypeOther;
718
case WebCore::NavigationTypeLinkClicked:
719
wkType = kWKFrameNavigationTypeLinkClicked;
721
case WebCore::NavigationTypeFormSubmitted:
722
wkType = kWKFrameNavigationTypeFormSubmitted;
724
case WebCore::NavigationTypeBackForward:
725
wkType = kWKFrameNavigationTypeBackForward;
727
case WebCore::NavigationTypeReload:
728
wkType = kWKFrameNavigationTypeReload;
730
case WebCore::NavigationTypeFormResubmitted:
731
wkType = kWKFrameNavigationTypeFormResubmitted;
733
case WebCore::NavigationTypeOther:
734
wkType = kWKFrameNavigationTypeOther;
741
inline WKSameDocumentNavigationType toAPI(SameDocumentNavigationType type)
743
WKFrameNavigationType wkType = kWKSameDocumentNavigationAnchorNavigation;
746
case SameDocumentNavigationAnchorNavigation:
747
wkType = kWKSameDocumentNavigationAnchorNavigation;
749
case SameDocumentNavigationSessionStatePush:
750
wkType = kWKSameDocumentNavigationSessionStatePush;
752
case SameDocumentNavigationSessionStateReplace:
753
wkType = kWKSameDocumentNavigationSessionStateReplace;
755
case SameDocumentNavigationSessionStatePop:
756
wkType = kWKSameDocumentNavigationSessionStatePop;
763
inline WKLayoutMilestones toWKLayoutMilestones(WebCore::LayoutMilestones milestones)
765
unsigned wkMilestones = 0;
767
if (milestones & WebCore::DidFirstLayout)
768
wkMilestones |= kWKDidFirstLayout;
769
if (milestones & WebCore::DidFirstVisuallyNonEmptyLayout)
770
wkMilestones |= kWKDidFirstVisuallyNonEmptyLayout;
771
if (milestones & WebCore::DidHitRelevantRepaintedObjectsAreaThreshold)
772
wkMilestones |= kWKDidHitRelevantRepaintedObjectsAreaThreshold;
777
inline WebCore::LayoutMilestones toLayoutMilestones(WKLayoutMilestones wkMilestones)
779
WebCore::LayoutMilestones milestones = 0;
781
if (wkMilestones & kWKDidFirstLayout)
782
milestones |= WebCore::DidFirstLayout;
783
if (wkMilestones & kWKDidFirstVisuallyNonEmptyLayout)
784
milestones |= WebCore::DidFirstVisuallyNonEmptyLayout;
785
if (wkMilestones & kWKDidHitRelevantRepaintedObjectsAreaThreshold)
786
milestones |= WebCore::DidHitRelevantRepaintedObjectsAreaThreshold;
791
inline ImageOptions toImageOptions(WKImageOptions wkImageOptions)
793
unsigned imageOptions = 0;
795
if (wkImageOptions & kWKImageOptionsShareable)
796
imageOptions |= ImageOptionsShareable;
798
return static_cast<ImageOptions>(imageOptions);
801
inline SnapshotOptions snapshotOptionsFromImageOptions(WKImageOptions wkImageOptions)
803
unsigned snapshotOptions = 0;
805
if (wkImageOptions & kWKImageOptionsShareable)
806
snapshotOptions |= SnapshotOptionsShareable;
808
return snapshotOptions;
811
inline SnapshotOptions toSnapshotOptions(WKSnapshotOptions wkSnapshotOptions)
813
unsigned snapshotOptions = 0;
815
if (wkSnapshotOptions & kWKSnapshotOptionsShareable)
816
snapshotOptions |= SnapshotOptionsShareable;
817
if (wkSnapshotOptions & kWKSnapshotOptionsExcludeSelectionHighlighting)
818
snapshotOptions |= SnapshotOptionsExcludeSelectionHighlighting;
819
if (wkSnapshotOptions & kWKSnapshotOptionsInViewCoordinates)
820
snapshotOptions |= SnapshotOptionsInViewCoordinates;
821
if (wkSnapshotOptions & kWKSnapshotOptionsPaintSelectionRectangle)
822
snapshotOptions |= SnapshotOptionsPaintSelectionRectangle;
824
return snapshotOptions;
827
inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptInjectionTime wkInjectedTime)
829
switch (wkInjectedTime) {
830
case kWKInjectAtDocumentStart:
831
return WebCore::InjectAtDocumentStart;
832
case kWKInjectAtDocumentEnd:
833
return WebCore::InjectAtDocumentEnd;
836
ASSERT_NOT_REACHED();
837
return WebCore::InjectAtDocumentStart;
840
inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames)
842
switch (wkInjectedFrames) {
843
case kWKInjectInAllFrames:
844
return WebCore::InjectInAllFrames;
845
case kWKInjectInTopFrameOnly:
846
return WebCore::InjectInTopFrameOnly;
849
ASSERT_NOT_REACHED();
850
return WebCore::InjectInAllFrames;
853
} // namespace WebKit
855
#endif // WKSharedAPICast_h