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 WKBundleAPICast_h
27 #define WKBundleAPICast_h
28
29 #include "WKSharedAPICast.h"
30 #include "WKBundlePage.h"
31 #include "WKBundlePagePrivate.h"
32 #include "WKBundlePrivate.h"
33 #include <WebCore/EditorInsertAction.h>
34 #include <WebCore/TextAffinity.h>
35 #include <WebCore/UserContentTypes.h>
36 #include <WebCore/UserScriptTypes.h>
37
38 namespace WebCore {
39 class CSSStyleDeclaration;
40 }
41
42 namespace WebKit {
43
44 class InjectedBundle;
45 class InjectedBundleBackForwardList;
46 class InjectedBundleBackForwardListItem;
47 class InjectedBundleHitTestResult;
48 class InjectedBundleNavigationAction;
49 class InjectedBundleNodeHandle;
50 class InjectedBundleRangeHandle;
51 class InjectedBundleScriptWorld;
52 class PageOverlay;
53 class WebFrame;
54 class WebInspector;
55 class WebPage;
56 class WebPageGroupProxy;
57
WK_ADD_API_MAPPING(WKBundleBackForwardListItemRef,InjectedBundleBackForwardListItem)58 WK_ADD_API_MAPPING(WKBundleBackForwardListItemRef, InjectedBundleBackForwardListItem)
59 WK_ADD_API_MAPPING(WKBundleBackForwardListRef, InjectedBundleBackForwardList)
60 WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, WebCore::CSSStyleDeclaration)
61 WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame)
62 WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult)
63 WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector)
64 WK_ADD_API_MAPPING(WKBundleNavigationActionRef, InjectedBundleNavigationAction)
65 WK_ADD_API_MAPPING(WKBundleNodeHandleRef, InjectedBundleNodeHandle)
66 WK_ADD_API_MAPPING(WKBundlePageGroupRef, WebPageGroupProxy)
67 WK_ADD_API_MAPPING(WKBundlePageOverlayRef, PageOverlay)
68 WK_ADD_API_MAPPING(WKBundlePageRef, WebPage)
69 WK_ADD_API_MAPPING(WKBundleRangeHandleRef, InjectedBundleRangeHandle)
70 WK_ADD_API_MAPPING(WKBundleRef, InjectedBundle)
71 WK_ADD_API_MAPPING(WKBundleScriptWorldRef, InjectedBundleScriptWorld)
72
73 inline WKInsertActionType toAPI(WebCore::EditorInsertAction action)
74 {
75 switch (action) {
76 case WebCore::EditorInsertActionTyped:
77 return kWKInsertActionTyped;
78 break;
79 case WebCore::EditorInsertActionPasted:
80 return kWKInsertActionPasted;
81 break;
82 case WebCore::EditorInsertActionDropped:
83 return kWKInsertActionDropped;
84 break;
85 }
86 ASSERT_NOT_REACHED();
87 return kWKInsertActionTyped;
88 }
89
toAPI(WebCore::EAffinity affinity)90 inline WKAffinityType toAPI(WebCore::EAffinity affinity)
91 {
92 switch (affinity) {
93 case WebCore::UPSTREAM:
94 return kWKAffinityUpstream;
95 break;
96 case WebCore::DOWNSTREAM:
97 return kWKAffinityDownstream;
98 break;
99 }
100 ASSERT_NOT_REACHED();
101 return kWKAffinityUpstream;
102 }
103
toUserScriptInjectionTime(WKUserScriptInjectionTime wkInjectedTime)104 inline WebCore::UserScriptInjectionTime toUserScriptInjectionTime(WKUserScriptInjectionTime wkInjectedTime)
105 {
106 switch (wkInjectedTime) {
107 case kWKInjectAtDocumentStart:
108 return WebCore::InjectAtDocumentStart;
109 case kWKInjectAtDocumentEnd:
110 return WebCore::InjectAtDocumentEnd;
111 }
112
113 ASSERT_NOT_REACHED();
114 return WebCore::InjectAtDocumentStart;
115 }
116
toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames)117 inline WebCore::UserContentInjectedFrames toUserContentInjectedFrames(WKUserContentInjectedFrames wkInjectedFrames)
118 {
119 switch (wkInjectedFrames) {
120 case kWKInjectInAllFrames:
121 return WebCore::InjectInAllFrames;
122 case kWKInjectInTopFrameOnly:
123 return WebCore::InjectInTopFrameOnly;
124 }
125
126 ASSERT_NOT_REACHED();
127 return WebCore::InjectInAllFrames;
128 }
129
130 } // namespace WebKit
131
132 #endif // WKBundleAPICast_h
133