WKSharedAPICast.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  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. #ifndef WKSharedAPICast_h
  26. #define WKSharedAPICast_h
  27. #include "ImageOptions.h"
  28. #include "SameDocumentNavigationType.h"
  29. #include "WKBase.h"
  30. #include "WKContextMenuItemTypes.h"
  31. #include "WKEvent.h"
  32. #include "WKFindOptions.h"
  33. #include "WKGeometry.h"
  34. #include "WKImage.h"
  35. #include "WKPageLoadTypes.h"
  36. #include "WKPageLoadTypesPrivate.h"
  37. #include "WKPageVisibilityTypes.h"
  38. #include "WebError.h"
  39. #include "WebEvent.h"
  40. #include "WebFindOptions.h"
  41. #include "WebNumber.h"
  42. #include "WebSecurityOrigin.h"
  43. #include "WebString.h"
  44. #include "WebURL.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/PageVisibilityState.h>
  53. #include <WebCore/SecurityOrigin.h>
  54. #include <WebCore/UserContentTypes.h>
  55. #include <WebCore/UserScriptTypes.h>
  56. #include <wtf/TypeTraits.h>
  57. namespace WebKit {
  58. class ImmutableArray;
  59. class ImmutableDictionary;
  60. class MutableArray;
  61. class MutableDictionary;
  62. class ObjCObjectGraph;
  63. class WebArchive;
  64. class WebArchiveResource;
  65. class WebCertificateInfo;
  66. class WebConnection;
  67. class WebContextMenuItem;
  68. class WebData;
  69. class WebGraphicsContext;
  70. class WebImage;
  71. class WebPoint;
  72. class WebRect;
  73. class WebSecurityOrigin;
  74. class WebSerializedScriptValue;
  75. class WebSize;
  76. class WebURLRequest;
  77. class WebURLResponse;
  78. class WebUserContentURLPattern;
  79. template<typename APIType> struct APITypeInfo { };
  80. 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; };
  84. WK_ADD_API_MAPPING(WKArrayRef, ImmutableArray)
  85. WK_ADD_API_MAPPING(WKBooleanRef, WebBoolean)
  86. WK_ADD_API_MAPPING(WKCertificateInfoRef, WebCertificateInfo)
  87. WK_ADD_API_MAPPING(WKConnectionRef, WebConnection)
  88. WK_ADD_API_MAPPING(WKContextMenuItemRef, WebContextMenuItem)
  89. WK_ADD_API_MAPPING(WKDataRef, WebData)
  90. WK_ADD_API_MAPPING(WKDictionaryRef, ImmutableDictionary)
  91. WK_ADD_API_MAPPING(WKDoubleRef, WebDouble)
  92. WK_ADD_API_MAPPING(WKErrorRef, WebError)
  93. WK_ADD_API_MAPPING(WKGraphicsContextRef, WebGraphicsContext)
  94. WK_ADD_API_MAPPING(WKImageRef, WebImage)
  95. WK_ADD_API_MAPPING(WKMutableArrayRef, MutableArray)
  96. WK_ADD_API_MAPPING(WKMutableDictionaryRef, MutableDictionary)
  97. WK_ADD_API_MAPPING(WKPointRef, WebPoint)
  98. WK_ADD_API_MAPPING(WKRectRef, WebRect)
  99. WK_ADD_API_MAPPING(WKSecurityOriginRef, WebSecurityOrigin)
  100. WK_ADD_API_MAPPING(WKSerializedScriptValueRef, WebSerializedScriptValue)
  101. WK_ADD_API_MAPPING(WKSizeRef, WebSize)
  102. WK_ADD_API_MAPPING(WKStringRef, WebString)
  103. WK_ADD_API_MAPPING(WKTypeRef, APIObject)
  104. WK_ADD_API_MAPPING(WKUInt64Ref, WebUInt64)
  105. WK_ADD_API_MAPPING(WKURLRef, WebURL)
  106. WK_ADD_API_MAPPING(WKURLRequestRef, WebURLRequest)
  107. WK_ADD_API_MAPPING(WKURLResponseRef, WebURLResponse)
  108. WK_ADD_API_MAPPING(WKUserContentURLPatternRef, WebUserContentURLPattern)
  109. #if PLATFORM(MAC)
  110. WK_ADD_API_MAPPING(WKWebArchiveRef, WebArchive)
  111. WK_ADD_API_MAPPING(WKWebArchiveResourceRef, WebArchiveResource)
  112. WK_ADD_API_MAPPING(WKObjCTypeWrapperRef, ObjCObjectGraph)
  113. #endif
  114. template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType>
  115. class ProxyingRefPtr {
  116. public:
  117. ProxyingRefPtr(PassRefPtr<ImplType> impl)
  118. : m_impl(impl)
  119. {
  120. }
  121. operator APIType() { return toAPI(m_impl.get()); }
  122. private:
  123. RefPtr<ImplType> m_impl;
  124. };
  125. /* Opaque typing convenience methods */
  126. template<typename T>
  127. inline typename APITypeInfo<T>::ImplType toImpl(T t)
  128. {
  129. // An example of the conversions that take place:
  130. // const struct OpaqueWKArray* -> const struct OpaqueWKArray -> struct OpaqueWKArray -> struct OpaqueWKArray* -> ImmutableArray*
  131. typedef typename WTF::RemovePointer<T>::Type PotentiallyConstValueType;
  132. typedef typename WTF::RemoveConst<PotentiallyConstValueType>::Type NonConstValueType;
  133. return reinterpret_cast<typename APITypeInfo<T>::ImplType>(const_cast<NonConstValueType*>(t));
  134. }
  135. template<typename T>
  136. inline typename ImplTypeInfo<T>::APIType toAPI(T t)
  137. {
  138. return reinterpret_cast<typename ImplTypeInfo<T>::APIType>(t);
  139. }
  140. /* Special cases. */
  141. inline ProxyingRefPtr<WebString> toAPI(StringImpl* string)
  142. {
  143. return ProxyingRefPtr<WebString>(WebString::create(string));
  144. }
  145. inline WKStringRef toCopiedAPI(const String& string)
  146. {
  147. RefPtr<WebString> webString = WebString::create(string);
  148. return toAPI(webString.release().leakRef());
  149. }
  150. inline ProxyingRefPtr<WebURL> toURLRef(StringImpl* string)
  151. {
  152. if (!string)
  153. return ProxyingRefPtr<WebURL>(0);
  154. return ProxyingRefPtr<WebURL>(WebURL::create(String(string)));
  155. }
  156. inline WKURLRef toCopiedURLAPI(const String& string)
  157. {
  158. if (!string)
  159. return 0;
  160. RefPtr<WebURL> webURL = WebURL::create(string);
  161. return toAPI(webURL.release().leakRef());
  162. }
  163. inline String toWTFString(WKStringRef stringRef)
  164. {
  165. if (!stringRef)
  166. return String();
  167. return toImpl(stringRef)->string();
  168. }
  169. inline String toWTFString(WKURLRef urlRef)
  170. {
  171. if (!urlRef)
  172. return String();
  173. return toImpl(urlRef)->string();
  174. }
  175. inline ProxyingRefPtr<WebError> toAPI(const WebCore::ResourceError& error)
  176. {
  177. return ProxyingRefPtr<WebError>(WebError::create(error));
  178. }
  179. inline ProxyingRefPtr<WebURLRequest> toAPI(const WebCore::ResourceRequest& request)
  180. {
  181. return ProxyingRefPtr<WebURLRequest>(WebURLRequest::create(request));
  182. }
  183. inline ProxyingRefPtr<WebURLResponse> toAPI(const WebCore::ResourceResponse& response)
  184. {
  185. return ProxyingRefPtr<WebURLResponse>(WebURLResponse::create(response));
  186. }
  187. inline WKSecurityOriginRef toCopiedAPI(WebCore::SecurityOrigin* origin)
  188. {
  189. if (!origin)
  190. return 0;
  191. return toAPI(WebSecurityOrigin::create(origin).leakRef());
  192. }
  193. /* Geometry conversions */
  194. inline WebCore::FloatRect toFloatRect(const WKRect& wkRect)
  195. {
  196. return WebCore::FloatRect(static_cast<float>(wkRect.origin.x), static_cast<float>(wkRect.origin.y),
  197. static_cast<float>(wkRect.size.width), static_cast<float>(wkRect.size.height));
  198. }
  199. inline WebCore::IntSize toIntSize(const WKSize& wkSize)
  200. {
  201. return WebCore::IntSize(static_cast<int>(wkSize.width), static_cast<int>(wkSize.height));
  202. }
  203. inline WebCore::IntPoint toIntPoint(const WKPoint& wkPoint)
  204. {
  205. return WebCore::IntPoint(static_cast<int>(wkPoint.x), static_cast<int>(wkPoint.y));
  206. }
  207. inline WebCore::IntRect toIntRect(const WKRect& wkRect)
  208. {
  209. return WebCore::IntRect(static_cast<int>(wkRect.origin.x), static_cast<int>(wkRect.origin.y),
  210. static_cast<int>(wkRect.size.width), static_cast<int>(wkRect.size.height));
  211. }
  212. inline WKRect toAPI(const WebCore::FloatRect& rect)
  213. {
  214. WKRect wkRect;
  215. wkRect.origin.x = rect.x();
  216. wkRect.origin.y = rect.y();
  217. wkRect.size.width = rect.width();
  218. wkRect.size.height = rect.height();
  219. return wkRect;
  220. }
  221. inline WKRect toAPI(const WebCore::IntRect& rect)
  222. {
  223. WKRect wkRect;
  224. wkRect.origin.x = rect.x();
  225. wkRect.origin.y = rect.y();
  226. wkRect.size.width = rect.width();
  227. wkRect.size.height = rect.height();
  228. return wkRect;
  229. }
  230. inline WKSize toAPI(const WebCore::IntSize& size)
  231. {
  232. WKSize wkSize;
  233. wkSize.width = size.width();
  234. wkSize.height = size.height();
  235. return wkSize;
  236. }
  237. inline WKPoint toAPI(const WebCore::IntPoint& point)
  238. {
  239. WKPoint wkPoint;
  240. wkPoint.x = point.x();
  241. wkPoint.y = point.y();
  242. return wkPoint;
  243. }
  244. /* Enum conversions */
  245. inline WKTypeID toAPI(APIObject::Type type)
  246. {
  247. return static_cast<WKTypeID>(type);
  248. }
  249. inline WKEventModifiers toAPI(WebEvent::Modifiers modifiers)
  250. {
  251. WKEventModifiers wkModifiers = 0;
  252. if (modifiers & WebEvent::ShiftKey)
  253. wkModifiers |= kWKEventModifiersShiftKey;
  254. if (modifiers & WebEvent::ControlKey)
  255. wkModifiers |= kWKEventModifiersControlKey;
  256. if (modifiers & WebEvent::AltKey)
  257. wkModifiers |= kWKEventModifiersAltKey;
  258. if (modifiers & WebEvent::MetaKey)
  259. wkModifiers |= kWKEventModifiersMetaKey;
  260. return wkModifiers;
  261. }
  262. inline WKEventMouseButton toAPI(WebMouseEvent::Button mouseButton)
  263. {
  264. WKEventMouseButton wkMouseButton = kWKEventMouseButtonNoButton;
  265. switch (mouseButton) {
  266. case WebMouseEvent::NoButton:
  267. wkMouseButton = kWKEventMouseButtonNoButton;
  268. break;
  269. case WebMouseEvent::LeftButton:
  270. wkMouseButton = kWKEventMouseButtonLeftButton;
  271. break;
  272. case WebMouseEvent::MiddleButton:
  273. wkMouseButton = kWKEventMouseButtonMiddleButton;
  274. break;
  275. case WebMouseEvent::RightButton:
  276. wkMouseButton = kWKEventMouseButtonRightButton;
  277. break;
  278. }
  279. return wkMouseButton;
  280. }
  281. inline WKContextMenuItemTag toAPI(WebCore::ContextMenuAction action)
  282. {
  283. switch (action) {
  284. case WebCore::ContextMenuItemTagNoAction:
  285. return kWKContextMenuItemTagNoAction;
  286. case WebCore::ContextMenuItemTagOpenLinkInNewWindow:
  287. return kWKContextMenuItemTagOpenLinkInNewWindow;
  288. case WebCore::ContextMenuItemTagDownloadLinkToDisk:
  289. return kWKContextMenuItemTagDownloadLinkToDisk;
  290. case WebCore::ContextMenuItemTagCopyLinkToClipboard:
  291. return kWKContextMenuItemTagCopyLinkToClipboard;
  292. case WebCore::ContextMenuItemTagOpenImageInNewWindow:
  293. return kWKContextMenuItemTagOpenImageInNewWindow;
  294. case WebCore::ContextMenuItemTagDownloadImageToDisk:
  295. return kWKContextMenuItemTagDownloadImageToDisk;
  296. case WebCore::ContextMenuItemTagCopyImageToClipboard:
  297. return kWKContextMenuItemTagCopyImageToClipboard;
  298. #if PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(QT)
  299. case WebCore::ContextMenuItemTagCopyImageUrlToClipboard:
  300. return kWKContextMenuItemTagCopyImageUrlToClipboard;
  301. #endif
  302. case WebCore::ContextMenuItemTagOpenFrameInNewWindow:
  303. return kWKContextMenuItemTagOpenFrameInNewWindow;
  304. case WebCore::ContextMenuItemTagCopy:
  305. return kWKContextMenuItemTagCopy;
  306. case WebCore::ContextMenuItemTagGoBack:
  307. return kWKContextMenuItemTagGoBack;
  308. case WebCore::ContextMenuItemTagGoForward:
  309. return kWKContextMenuItemTagGoForward;
  310. case WebCore::ContextMenuItemTagStop:
  311. return kWKContextMenuItemTagStop;
  312. case WebCore::ContextMenuItemTagReload:
  313. return kWKContextMenuItemTagReload;
  314. case WebCore::ContextMenuItemTagCut:
  315. return kWKContextMenuItemTagCut;
  316. case WebCore::ContextMenuItemTagPaste:
  317. return kWKContextMenuItemTagPaste;
  318. #if PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(QT)
  319. case WebCore::ContextMenuItemTagSelectAll:
  320. return kWKContextMenuItemTagSelectAll;
  321. #endif
  322. case WebCore::ContextMenuItemTagSpellingGuess:
  323. return kWKContextMenuItemTagSpellingGuess;
  324. case WebCore::ContextMenuItemTagNoGuessesFound:
  325. return kWKContextMenuItemTagNoGuessesFound;
  326. case WebCore::ContextMenuItemTagIgnoreSpelling:
  327. return kWKContextMenuItemTagIgnoreSpelling;
  328. case WebCore::ContextMenuItemTagLearnSpelling:
  329. return kWKContextMenuItemTagLearnSpelling;
  330. case WebCore::ContextMenuItemTagOther:
  331. return kWKContextMenuItemTagOther;
  332. case WebCore::ContextMenuItemTagSearchInSpotlight:
  333. return kWKContextMenuItemTagSearchInSpotlight;
  334. case WebCore::ContextMenuItemTagSearchWeb:
  335. return kWKContextMenuItemTagSearchWeb;
  336. case WebCore::ContextMenuItemTagLookUpInDictionary:
  337. return kWKContextMenuItemTagLookUpInDictionary;
  338. case WebCore::ContextMenuItemTagOpenWithDefaultApplication:
  339. return kWKContextMenuItemTagOpenWithDefaultApplication;
  340. case WebCore::ContextMenuItemPDFActualSize:
  341. return kWKContextMenuItemTagPDFActualSize;
  342. case WebCore::ContextMenuItemPDFZoomIn:
  343. return kWKContextMenuItemTagPDFZoomIn;
  344. case WebCore::ContextMenuItemPDFZoomOut:
  345. return kWKContextMenuItemTagPDFZoomOut;
  346. case WebCore::ContextMenuItemPDFAutoSize:
  347. return kWKContextMenuItemTagPDFAutoSize;
  348. case WebCore::ContextMenuItemPDFSinglePage:
  349. return kWKContextMenuItemTagPDFSinglePage;
  350. case WebCore::ContextMenuItemPDFFacingPages:
  351. return kWKContextMenuItemTagPDFFacingPages;
  352. case WebCore::ContextMenuItemPDFContinuous:
  353. return kWKContextMenuItemTagPDFContinuous;
  354. case WebCore::ContextMenuItemPDFNextPage:
  355. return kWKContextMenuItemTagPDFNextPage;
  356. case WebCore::ContextMenuItemPDFPreviousPage:
  357. return kWKContextMenuItemTagPDFPreviousPage;
  358. case WebCore::ContextMenuItemTagOpenLink:
  359. return kWKContextMenuItemTagOpenLink;
  360. case WebCore::ContextMenuItemTagIgnoreGrammar:
  361. return kWKContextMenuItemTagIgnoreGrammar;
  362. case WebCore::ContextMenuItemTagSpellingMenu:
  363. return kWKContextMenuItemTagSpellingMenu;
  364. case WebCore::ContextMenuItemTagShowSpellingPanel:
  365. return kWKContextMenuItemTagShowSpellingPanel;
  366. case WebCore::ContextMenuItemTagCheckSpelling:
  367. return kWKContextMenuItemTagCheckSpelling;
  368. case WebCore::ContextMenuItemTagCheckSpellingWhileTyping:
  369. return kWKContextMenuItemTagCheckSpellingWhileTyping;
  370. case WebCore::ContextMenuItemTagCheckGrammarWithSpelling:
  371. return kWKContextMenuItemTagCheckGrammarWithSpelling;
  372. case WebCore::ContextMenuItemTagFontMenu:
  373. return kWKContextMenuItemTagFontMenu;
  374. case WebCore::ContextMenuItemTagShowFonts:
  375. return kWKContextMenuItemTagShowFonts;
  376. case WebCore::ContextMenuItemTagBold:
  377. return kWKContextMenuItemTagBold;
  378. case WebCore::ContextMenuItemTagItalic:
  379. return kWKContextMenuItemTagItalic;
  380. case WebCore::ContextMenuItemTagUnderline:
  381. return kWKContextMenuItemTagUnderline;
  382. case WebCore::ContextMenuItemTagOutline:
  383. return kWKContextMenuItemTagOutline;
  384. case WebCore::ContextMenuItemTagStyles:
  385. return kWKContextMenuItemTagStyles;
  386. case WebCore::ContextMenuItemTagShowColors:
  387. return kWKContextMenuItemTagShowColors;
  388. case WebCore::ContextMenuItemTagSpeechMenu:
  389. return kWKContextMenuItemTagSpeechMenu;
  390. case WebCore::ContextMenuItemTagStartSpeaking:
  391. return kWKContextMenuItemTagStartSpeaking;
  392. case WebCore::ContextMenuItemTagStopSpeaking:
  393. return kWKContextMenuItemTagStopSpeaking;
  394. case WebCore::ContextMenuItemTagWritingDirectionMenu:
  395. return kWKContextMenuItemTagWritingDirectionMenu;
  396. case WebCore::ContextMenuItemTagDefaultDirection:
  397. return kWKContextMenuItemTagDefaultDirection;
  398. case WebCore::ContextMenuItemTagLeftToRight:
  399. return kWKContextMenuItemTagLeftToRight;
  400. case WebCore::ContextMenuItemTagRightToLeft:
  401. return kWKContextMenuItemTagRightToLeft;
  402. case WebCore::ContextMenuItemTagPDFSinglePageScrolling:
  403. return kWKContextMenuItemTagPDFSinglePageScrolling;
  404. case WebCore::ContextMenuItemTagPDFFacingPagesScrolling:
  405. return kWKContextMenuItemTagPDFFacingPagesScrolling;
  406. case WebCore::ContextMenuItemTagDictationAlternative:
  407. return kWKContextMenuItemTagDictationAlternative;
  408. #if ENABLE(INSPECTOR)
  409. case WebCore::ContextMenuItemTagInspectElement:
  410. return kWKContextMenuItemTagInspectElement;
  411. #endif
  412. case WebCore::ContextMenuItemTagTextDirectionMenu:
  413. return kWKContextMenuItemTagTextDirectionMenu;
  414. case WebCore::ContextMenuItemTagTextDirectionDefault:
  415. return kWKContextMenuItemTagTextDirectionDefault;
  416. case WebCore::ContextMenuItemTagTextDirectionLeftToRight:
  417. return kWKContextMenuItemTagTextDirectionLeftToRight;
  418. case WebCore::ContextMenuItemTagTextDirectionRightToLeft:
  419. return kWKContextMenuItemTagTextDirectionRightToLeft;
  420. case WebCore::ContextMenuItemTagOpenMediaInNewWindow:
  421. return kWKContextMenuItemTagOpenMediaInNewWindow;
  422. case WebCore::ContextMenuItemTagDownloadMediaToDisk:
  423. return kWKContextMenuItemTagDownloadMediaToDisk;
  424. case WebCore::ContextMenuItemTagCopyMediaLinkToClipboard:
  425. return kWKContextMenuItemTagCopyMediaLinkToClipboard;
  426. case WebCore::ContextMenuItemTagToggleMediaControls:
  427. return kWKContextMenuItemTagToggleMediaControls;
  428. case WebCore::ContextMenuItemTagToggleMediaLoop:
  429. return kWKContextMenuItemTagToggleMediaLoop;
  430. case WebCore::ContextMenuItemTagToggleVideoFullscreen:
  431. return kWKContextMenuItemTagToggleVideoFullscreen;
  432. case WebCore::ContextMenuItemTagEnterVideoFullscreen:
  433. return kWKContextMenuItemTagEnterVideoFullscreen;
  434. case WebCore::ContextMenuItemTagMediaPlayPause:
  435. return kWKContextMenuItemTagMediaPlayPause;
  436. case WebCore::ContextMenuItemTagMediaMute:
  437. return kWKContextMenuItemTagMediaMute;
  438. #if PLATFORM(MAC)
  439. case WebCore::ContextMenuItemTagCorrectSpellingAutomatically:
  440. return kWKContextMenuItemTagCorrectSpellingAutomatically;
  441. case WebCore::ContextMenuItemTagSubstitutionsMenu:
  442. return kWKContextMenuItemTagSubstitutionsMenu;
  443. case WebCore::ContextMenuItemTagShowSubstitutions:
  444. return kWKContextMenuItemTagShowSubstitutions;
  445. case WebCore::ContextMenuItemTagSmartCopyPaste:
  446. return kWKContextMenuItemTagSmartCopyPaste;
  447. case WebCore::ContextMenuItemTagSmartQuotes:
  448. return kWKContextMenuItemTagSmartQuotes;
  449. case WebCore::ContextMenuItemTagSmartDashes:
  450. return kWKContextMenuItemTagSmartDashes;
  451. case WebCore::ContextMenuItemTagSmartLinks:
  452. return kWKContextMenuItemTagSmartLinks;
  453. case WebCore::ContextMenuItemTagTextReplacement:
  454. return kWKContextMenuItemTagTextReplacement;
  455. case WebCore::ContextMenuItemTagTransformationsMenu:
  456. return kWKContextMenuItemTagTransformationsMenu;
  457. case WebCore::ContextMenuItemTagMakeUpperCase:
  458. return kWKContextMenuItemTagMakeUpperCase;
  459. case WebCore::ContextMenuItemTagMakeLowerCase:
  460. return kWKContextMenuItemTagMakeLowerCase;
  461. case WebCore::ContextMenuItemTagCapitalize:
  462. return kWKContextMenuItemTagCapitalize;
  463. case WebCore::ContextMenuItemTagChangeBack:
  464. return kWKContextMenuItemTagChangeBack;
  465. #endif
  466. case WebCore::ContextMenuItemTagOpenLinkInThisWindow:
  467. return kWKContextMenuItemTagOpenLinkInThisWindow;
  468. default:
  469. if (action < WebCore::ContextMenuItemBaseApplicationTag)
  470. LOG_ERROR("ContextMenuAction %i is an unknown tag but is below the allowable custom tag value of %i", action, WebCore:: ContextMenuItemBaseApplicationTag);
  471. return static_cast<WKContextMenuItemTag>(action);
  472. }
  473. }
  474. inline WebCore::ContextMenuAction toImpl(WKContextMenuItemTag tag)
  475. {
  476. switch (tag) {
  477. case kWKContextMenuItemTagNoAction:
  478. return WebCore::ContextMenuItemTagNoAction;
  479. case kWKContextMenuItemTagOpenLinkInNewWindow:
  480. return WebCore::ContextMenuItemTagOpenLinkInNewWindow;
  481. case kWKContextMenuItemTagDownloadLinkToDisk:
  482. return WebCore::ContextMenuItemTagDownloadLinkToDisk;
  483. case kWKContextMenuItemTagCopyLinkToClipboard:
  484. return WebCore::ContextMenuItemTagCopyLinkToClipboard;
  485. case kWKContextMenuItemTagOpenImageInNewWindow:
  486. return WebCore::ContextMenuItemTagOpenImageInNewWindow;
  487. case kWKContextMenuItemTagDownloadImageToDisk:
  488. return WebCore::ContextMenuItemTagDownloadImageToDisk;
  489. case kWKContextMenuItemTagCopyImageToClipboard:
  490. return WebCore::ContextMenuItemTagCopyImageToClipboard;
  491. case kWKContextMenuItemTagOpenFrameInNewWindow:
  492. #if PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(QT)
  493. case kWKContextMenuItemTagCopyImageUrlToClipboard:
  494. return WebCore::ContextMenuItemTagCopyImageUrlToClipboard;
  495. #endif
  496. return WebCore::ContextMenuItemTagOpenFrameInNewWindow;
  497. case kWKContextMenuItemTagCopy:
  498. return WebCore::ContextMenuItemTagCopy;
  499. case kWKContextMenuItemTagGoBack:
  500. return WebCore::ContextMenuItemTagGoBack;
  501. case kWKContextMenuItemTagGoForward:
  502. return WebCore::ContextMenuItemTagGoForward;
  503. case kWKContextMenuItemTagStop:
  504. return WebCore::ContextMenuItemTagStop;
  505. case kWKContextMenuItemTagReload:
  506. return WebCore::ContextMenuItemTagReload;
  507. case kWKContextMenuItemTagCut:
  508. return WebCore::ContextMenuItemTagCut;
  509. case kWKContextMenuItemTagPaste:
  510. return WebCore::ContextMenuItemTagPaste;
  511. #if PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(QT)
  512. case kWKContextMenuItemTagSelectAll:
  513. return WebCore::ContextMenuItemTagSelectAll;
  514. #endif
  515. case kWKContextMenuItemTagSpellingGuess:
  516. return WebCore::ContextMenuItemTagSpellingGuess;
  517. case kWKContextMenuItemTagNoGuessesFound:
  518. return WebCore::ContextMenuItemTagNoGuessesFound;
  519. case kWKContextMenuItemTagIgnoreSpelling:
  520. return WebCore::ContextMenuItemTagIgnoreSpelling;
  521. case kWKContextMenuItemTagLearnSpelling:
  522. return WebCore::ContextMenuItemTagLearnSpelling;
  523. case kWKContextMenuItemTagOther:
  524. return WebCore::ContextMenuItemTagOther;
  525. case kWKContextMenuItemTagSearchInSpotlight:
  526. return WebCore::ContextMenuItemTagSearchInSpotlight;
  527. case kWKContextMenuItemTagSearchWeb:
  528. return WebCore::ContextMenuItemTagSearchWeb;
  529. case kWKContextMenuItemTagLookUpInDictionary:
  530. return WebCore::ContextMenuItemTagLookUpInDictionary;
  531. case kWKContextMenuItemTagOpenWithDefaultApplication:
  532. return WebCore::ContextMenuItemTagOpenWithDefaultApplication;
  533. case kWKContextMenuItemTagPDFActualSize:
  534. return WebCore::ContextMenuItemPDFActualSize;
  535. case kWKContextMenuItemTagPDFZoomIn:
  536. return WebCore::ContextMenuItemPDFZoomIn;
  537. case kWKContextMenuItemTagPDFZoomOut:
  538. return WebCore::ContextMenuItemPDFZoomOut;
  539. case kWKContextMenuItemTagPDFAutoSize:
  540. return WebCore::ContextMenuItemPDFAutoSize;
  541. case kWKContextMenuItemTagPDFSinglePage:
  542. return WebCore::ContextMenuItemPDFSinglePage;
  543. case kWKContextMenuItemTagPDFFacingPages:
  544. return WebCore::ContextMenuItemPDFFacingPages;
  545. case kWKContextMenuItemTagPDFContinuous:
  546. return WebCore::ContextMenuItemPDFContinuous;
  547. case kWKContextMenuItemTagPDFNextPage:
  548. return WebCore::ContextMenuItemPDFNextPage;
  549. case kWKContextMenuItemTagPDFPreviousPage:
  550. return WebCore::ContextMenuItemPDFPreviousPage;
  551. case kWKContextMenuItemTagOpenLink:
  552. return WebCore::ContextMenuItemTagOpenLink;
  553. case kWKContextMenuItemTagIgnoreGrammar:
  554. return WebCore::ContextMenuItemTagIgnoreGrammar;
  555. case kWKContextMenuItemTagSpellingMenu:
  556. return WebCore::ContextMenuItemTagSpellingMenu;
  557. case kWKContextMenuItemTagShowSpellingPanel:
  558. return WebCore::ContextMenuItemTagShowSpellingPanel;
  559. case kWKContextMenuItemTagCheckSpelling:
  560. return WebCore::ContextMenuItemTagCheckSpelling;
  561. case kWKContextMenuItemTagCheckSpellingWhileTyping:
  562. return WebCore::ContextMenuItemTagCheckSpellingWhileTyping;
  563. case kWKContextMenuItemTagCheckGrammarWithSpelling:
  564. return WebCore::ContextMenuItemTagCheckGrammarWithSpelling;
  565. case kWKContextMenuItemTagFontMenu:
  566. return WebCore::ContextMenuItemTagFontMenu;
  567. case kWKContextMenuItemTagShowFonts:
  568. return WebCore::ContextMenuItemTagShowFonts;
  569. case kWKContextMenuItemTagBold:
  570. return WebCore::ContextMenuItemTagBold;
  571. case kWKContextMenuItemTagItalic:
  572. return WebCore::ContextMenuItemTagItalic;
  573. case kWKContextMenuItemTagUnderline:
  574. return WebCore::ContextMenuItemTagUnderline;
  575. case kWKContextMenuItemTagOutline:
  576. return WebCore::ContextMenuItemTagOutline;
  577. case kWKContextMenuItemTagStyles:
  578. return WebCore::ContextMenuItemTagStyles;
  579. case kWKContextMenuItemTagShowColors:
  580. return WebCore::ContextMenuItemTagShowColors;
  581. case kWKContextMenuItemTagSpeechMenu:
  582. return WebCore::ContextMenuItemTagSpeechMenu;
  583. case kWKContextMenuItemTagStartSpeaking:
  584. return WebCore::ContextMenuItemTagStartSpeaking;
  585. case kWKContextMenuItemTagStopSpeaking:
  586. return WebCore::ContextMenuItemTagStopSpeaking;
  587. case kWKContextMenuItemTagWritingDirectionMenu:
  588. return WebCore::ContextMenuItemTagWritingDirectionMenu;
  589. case kWKContextMenuItemTagDefaultDirection:
  590. return WebCore::ContextMenuItemTagDefaultDirection;
  591. case kWKContextMenuItemTagLeftToRight:
  592. return WebCore::ContextMenuItemTagLeftToRight;
  593. case kWKContextMenuItemTagRightToLeft:
  594. return WebCore::ContextMenuItemTagRightToLeft;
  595. case kWKContextMenuItemTagPDFSinglePageScrolling:
  596. return WebCore::ContextMenuItemTagPDFSinglePageScrolling;
  597. case kWKContextMenuItemTagPDFFacingPagesScrolling:
  598. return WebCore::ContextMenuItemTagPDFFacingPagesScrolling;
  599. case kWKContextMenuItemTagDictationAlternative:
  600. return WebCore::ContextMenuItemTagDictationAlternative;
  601. #if ENABLE(INSPECTOR)
  602. case kWKContextMenuItemTagInspectElement:
  603. return WebCore::ContextMenuItemTagInspectElement;
  604. #endif
  605. case kWKContextMenuItemTagTextDirectionMenu:
  606. return WebCore::ContextMenuItemTagTextDirectionMenu;
  607. case kWKContextMenuItemTagTextDirectionDefault:
  608. return WebCore::ContextMenuItemTagTextDirectionDefault;
  609. case kWKContextMenuItemTagTextDirectionLeftToRight:
  610. return WebCore::ContextMenuItemTagTextDirectionLeftToRight;
  611. case kWKContextMenuItemTagTextDirectionRightToLeft:
  612. return WebCore::ContextMenuItemTagTextDirectionRightToLeft;
  613. case kWKContextMenuItemTagOpenMediaInNewWindow:
  614. return WebCore::ContextMenuItemTagOpenMediaInNewWindow;
  615. case kWKContextMenuItemTagDownloadMediaToDisk:
  616. return WebCore::ContextMenuItemTagDownloadMediaToDisk;
  617. case kWKContextMenuItemTagCopyMediaLinkToClipboard:
  618. return WebCore::ContextMenuItemTagCopyMediaLinkToClipboard;
  619. case kWKContextMenuItemTagToggleMediaControls:
  620. return WebCore::ContextMenuItemTagToggleMediaControls;
  621. case kWKContextMenuItemTagToggleMediaLoop:
  622. return WebCore::ContextMenuItemTagToggleMediaLoop;
  623. case kWKContextMenuItemTagToggleVideoFullscreen:
  624. return WebCore::ContextMenuItemTagToggleVideoFullscreen;
  625. case kWKContextMenuItemTagEnterVideoFullscreen:
  626. return WebCore::ContextMenuItemTagEnterVideoFullscreen;
  627. case kWKContextMenuItemTagMediaPlayPause:
  628. return WebCore::ContextMenuItemTagMediaPlayPause;
  629. case kWKContextMenuItemTagMediaMute:
  630. return WebCore::ContextMenuItemTagMediaMute;
  631. #if PLATFORM(MAC)
  632. case kWKContextMenuItemTagCorrectSpellingAutomatically:
  633. return WebCore::ContextMenuItemTagCorrectSpellingAutomatically;
  634. case kWKContextMenuItemTagSubstitutionsMenu:
  635. return WebCore::ContextMenuItemTagSubstitutionsMenu;
  636. case kWKContextMenuItemTagShowSubstitutions:
  637. return WebCore::ContextMenuItemTagShowSubstitutions;
  638. case kWKContextMenuItemTagSmartCopyPaste:
  639. return WebCore::ContextMenuItemTagSmartCopyPaste;
  640. case kWKContextMenuItemTagSmartQuotes:
  641. return WebCore::ContextMenuItemTagSmartQuotes;
  642. case kWKContextMenuItemTagSmartDashes:
  643. return WebCore::ContextMenuItemTagSmartDashes;
  644. case kWKContextMenuItemTagSmartLinks:
  645. return WebCore::ContextMenuItemTagSmartLinks;
  646. case kWKContextMenuItemTagTextReplacement:
  647. return WebCore::ContextMenuItemTagTextReplacement;
  648. case kWKContextMenuItemTagTransformationsMenu:
  649. return WebCore::ContextMenuItemTagTransformationsMenu;
  650. case kWKContextMenuItemTagMakeUpperCase:
  651. return WebCore::ContextMenuItemTagMakeUpperCase;
  652. case kWKContextMenuItemTagMakeLowerCase:
  653. return WebCore::ContextMenuItemTagMakeLowerCase;
  654. case kWKContextMenuItemTagCapitalize:
  655. return WebCore::ContextMenuItemTagCapitalize;
  656. case kWKContextMenuItemTagChangeBack:
  657. return WebCore::ContextMenuItemTagChangeBack;
  658. #endif
  659. case kWKContextMenuItemTagOpenLinkInThisWindow:
  660. return WebCore::ContextMenuItemTagOpenLinkInThisWindow;
  661. default:
  662. if (tag < kWKContextMenuItemBaseApplicationTag)
  663. LOG_ERROR("WKContextMenuItemTag %i is an unknown tag but is below the allowable custom tag value of %i", tag, kWKContextMenuItemBaseApplicationTag);
  664. return static_cast<WebCore::ContextMenuAction>(tag);
  665. }
  666. }
  667. inline WKContextMenuItemType toAPI(WebCore::ContextMenuItemType type)
  668. {
  669. switch(type) {
  670. case WebCore::ActionType:
  671. return kWKContextMenuItemTypeAction;
  672. case WebCore::CheckableActionType:
  673. return kWKContextMenuItemTypeCheckableAction;
  674. case WebCore::SeparatorType:
  675. return kWKContextMenuItemTypeSeparator;
  676. case WebCore::SubmenuType:
  677. return kWKContextMenuItemTypeSubmenu;
  678. default:
  679. ASSERT_NOT_REACHED();
  680. return kWKContextMenuItemTypeAction;
  681. }
  682. }
  683. inline FindOptions toFindOptions(WKFindOptions wkFindOptions)
  684. {
  685. unsigned findOptions = 0;
  686. if (wkFindOptions & kWKFindOptionsCaseInsensitive)
  687. findOptions |= FindOptionsCaseInsensitive;
  688. if (wkFindOptions & kWKFindOptionsAtWordStarts)
  689. findOptions |= FindOptionsAtWordStarts;
  690. if (wkFindOptions & kWKFindOptionsTreatMedialCapitalAsWordStart)
  691. findOptions |= FindOptionsTreatMedialCapitalAsWordStart;
  692. if (wkFindOptions & kWKFindOptionsBackwards)
  693. findOptions |= FindOptionsBackwards;
  694. if (wkFindOptions & kWKFindOptionsWrapAround)
  695. findOptions |= FindOptionsWrapAround;
  696. if (wkFindOptions & kWKFindOptionsShowOverlay)
  697. findOptions |= FindOptionsShowOverlay;
  698. if (wkFindOptions & kWKFindOptionsShowFindIndicator)
  699. findOptions |= FindOptionsShowFindIndicator;
  700. if (wkFindOptions & kWKFindOptionsShowHighlight)
  701. findOptions |= FindOptionsShowHighlight;
  702. return static_cast<FindOptions>(findOptions);
  703. }
  704. inline WKFrameNavigationType toAPI(WebCore::NavigationType type)
  705. {
  706. WKFrameNavigationType wkType = kWKFrameNavigationTypeOther;
  707. switch (type) {
  708. case WebCore::NavigationTypeLinkClicked:
  709. wkType = kWKFrameNavigationTypeLinkClicked;
  710. break;
  711. case WebCore::NavigationTypeFormSubmitted:
  712. wkType = kWKFrameNavigationTypeFormSubmitted;
  713. break;
  714. case WebCore::NavigationTypeBackForward:
  715. wkType = kWKFrameNavigationTypeBackForward;
  716. break;
  717. case WebCore::NavigationTypeReload:
  718. wkType = kWKFrameNavigationTypeReload;
  719. break;
  720. case WebCore::NavigationTypeFormResubmitted:
  721. wkType = kWKFrameNavigationTypeFormResubmitted;
  722. break;
  723. case WebCore::NavigationTypeOther:
  724. wkType = kWKFrameNavigationTypeOther;
  725. break;
  726. }
  727. return wkType;
  728. }
  729. inline WKSameDocumentNavigationType toAPI(SameDocumentNavigationType type)
  730. {
  731. WKFrameNavigationType wkType = kWKSameDocumentNavigationAnchorNavigation;
  732. switch (type) {
  733. case SameDocumentNavigationAnchorNavigation:
  734. wkType = kWKSameDocumentNavigationAnchorNavigation;
  735. break;
  736. case SameDocumentNavigationSessionStatePush:
  737. wkType = kWKSameDocumentNavigationSessionStatePush;
  738. break;
  739. case SameDocumentNavigationSessionStateReplace:
  740. wkType = kWKSameDocumentNavigationSessionStateReplace;
  741. break;
  742. case SameDocumentNavigationSessionStatePop:
  743. wkType = kWKSameDocumentNavigationSessionStatePop;
  744. break;
  745. }
  746. return wkType;
  747. }
  748. inline WKLayoutMilestones toWKLayoutMilestones(WebCore::LayoutMilestones milestones)
  749. {
  750. unsigned wkMilestones = 0;
  751. if (milestones & WebCore::DidFirstLayout)
  752. wkMilestones |= kWKDidFirstLayout;
  753. if (milestones & WebCore::DidFirstVisuallyNonEmptyLayout)
  754. wkMilestones |= kWKDidFirstVisuallyNonEmptyLayout;
  755. if (milestones & WebCore::DidHitRelevantRepaintedObjectsAreaThreshold)
  756. wkMilestones |= kWKDidHitRelevantRepaintedObjectsAreaThreshold;
  757. if (milestones & WebCore::DidFirstFlushForHeaderLayer)
  758. wkMilestones |= kWKDidFirstFlushForHeaderLayer;
  759. if (milestones & WebCore::DidFirstLayoutAfterSuppressedIncrementalRendering)
  760. wkMilestones |= kWKDidFirstLayoutAfterSuppressedIncrementalRendering;
  761. if (milestones & WebCore::DidFirstPaintAfterSuppressedIncrementalRendering)
  762. wkMilestones |= kWKDidFirstPaintAfterSuppressedIncrementalRendering;
  763. return wkMilestones;
  764. }
  765. inline WebCore::LayoutMilestones toLayoutMilestones(WKLayoutMilestones wkMilestones)
  766. {
  767. WebCore::LayoutMilestones milestones = 0;
  768. if (wkMilestones & kWKDidFirstLayout)
  769. milestones |= WebCore::DidFirstLayout;
  770. if (wkMilestones & kWKDidFirstVisuallyNonEmptyLayout)
  771. milestones |= WebCore::DidFirstVisuallyNonEmptyLayout;
  772. if (wkMilestones & kWKDidHitRelevantRepaintedObjectsAreaThreshold)
  773. milestones |= WebCore::DidHitRelevantRepaintedObjectsAreaThreshold;
  774. if (wkMilestones & kWKDidFirstFlushForHeaderLayer)
  775. milestones |= WebCore::DidFirstFlushForHeaderLayer;
  776. if (wkMilestones & kWKDidFirstLayoutAfterSuppressedIncrementalRendering)
  777. milestones |= WebCore::DidFirstLayoutAfterSuppressedIncrementalRendering;
  778. if (wkMilestones & kWKDidFirstPaintAfterSuppressedIncrementalRendering)
  779. milestones |= WebCore::DidFirstPaintAfterSuppressedIncrementalRendering;
  780. return milestones;
  781. }
  782. inline WebCore::PageVisibilityState toPageVisibilityState(WKPageVisibilityState wkPageVisibilityState)
  783. {
  784. switch (wkPageVisibilityState) {
  785. case kWKPageVisibilityStateVisible:
  786. return WebCore::PageVisibilityStateVisible;
  787. case kWKPageVisibilityStateHidden:
  788. return WebCore::PageVisibilityStateHidden;
  789. case kWKPageVisibilityStatePrerender:
  790. return WebCore::PageVisibilityStatePrerender;
  791. case kWKPageVisibilityStateUnloaded:
  792. return WebCore::PageVisibilityStateUnloaded;
  793. }
  794. ASSERT_NOT_REACHED();
  795. return WebCore::PageVisibilityStateVisible;
  796. }
  797. inline ImageOptions toImageOptions(WKImageOptions wkImageOptions)
  798. {
  799. unsigned imageOptions = 0;
  800. if (wkImageOptions & kWKImageOptionsShareable)
  801. imageOptions |= ImageOptionsShareable;
  802. return static_cast<ImageOptions>(imageOptions);
  803. }
  804. inline SnapshotOptions snapshotOptionsFromImageOptions(WKImageOptions wkImageOptions)
  805. {
  806. unsigned snapshotOptions = 0;
  807. if (wkImageOptions & kWKImageOptionsShareable)
  808. snapshotOptions |= SnapshotOptionsShareable;
  809. return snapshotOptions;
  810. }
  811. inline SnapshotOptions toSnapshotOptions(WKSnapshotOptions wkSnapshotOptions)
  812. {
  813. unsigned snapshotOptions = 0;
  814. if (wkSnapshotOptions & kWKSnapshotOptionsShareable)
  815. snapshotOptions |= SnapshotOptionsShareable;
  816. if (wkSnapshotOptions & kWKSnapshotOptionsExcludeSelectionHighlighting)
  817. snapshotOptions |= SnapshotOptionsExcludeSelectionHighlighting;
  818. if (wkSnapshotOptions & kWKSnapshotOptionsInViewCoordinates)
  819. snapshotOptions |= SnapshotOptionsInViewCoordinates;
  820. if (wkSnapshotOptions & kWKSnapshotOptionsPaintSelectionRectangle)
  821. snapshotOptions |= SnapshotOptionsPaintSelectionRectangle;
  822. return snapshotOptions;
  823. }
  824. inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptInjectionTime wkInjectedTime)
  825. {
  826. switch (wkInjectedTime) {
  827. case kWKInjectAtDocumentStart:
  828. return WebCore::InjectAtDocumentStart;
  829. case kWKInjectAtDocumentEnd:
  830. return WebCore::InjectAtDocumentEnd;
  831. }
  832. ASSERT_NOT_REACHED();
  833. return WebCore::InjectAtDocumentStart;
  834. }
  835. inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames)
  836. {
  837. switch (wkInjectedFrames) {
  838. case kWKInjectInAllFrames:
  839. return WebCore::InjectInAllFrames;
  840. case kWKInjectInTopFrameOnly:
  841. return WebCore::InjectInTopFrameOnly;
  842. }
  843. ASSERT_NOT_REACHED();
  844. return WebCore::InjectInAllFrames;
  845. }
  846. } // namespace WebKit
  847. #endif // WKSharedAPICast_h