9ed8885363ddf2d3ef15a61f9662e7dd06e2de97
[WebKit-https.git] / Source / WebKit2 / WebProcess / InjectedBundle / API / c / WKBundleAPICast.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 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
36 namespace WebKit {
37
38 class InjectedBundle;
39 class InjectedBundleBackForwardList;
40 class InjectedBundleBackForwardListItem;
41 class InjectedBundleCSSStyleDeclarationHandle;
42 class InjectedBundleDOMWindowExtension;
43 class InjectedBundleFileHandle;
44 class InjectedBundleHitTestResult;
45 class InjectedBundleNavigationAction;
46 class InjectedBundleNodeHandle;
47 class InjectedBundleRangeHandle;
48 class InjectedBundleScriptWorld;
49 class PageBanner;
50 class WebFrame;
51 class WebInspector;
52 class WebPage;
53 class WebPageGroupProxy;
54 class WebPageOverlay;
55
56 WK_ADD_API_MAPPING(WKBundleBackForwardListItemRef, InjectedBundleBackForwardListItem)
57 WK_ADD_API_MAPPING(WKBundleBackForwardListRef, InjectedBundleBackForwardList)
58 WK_ADD_API_MAPPING(WKBundleCSSStyleDeclarationRef, InjectedBundleCSSStyleDeclarationHandle)
59 WK_ADD_API_MAPPING(WKBundleDOMWindowExtensionRef, InjectedBundleDOMWindowExtension)
60 WK_ADD_API_MAPPING(WKBundleFileHandleRef, InjectedBundleFileHandle)
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(WKBundlePageBannerRef, PageBanner)
67 WK_ADD_API_MAPPING(WKBundlePageGroupRef, WebPageGroupProxy)
68 WK_ADD_API_MAPPING(WKBundlePageOverlayRef, WebPageOverlay)
69 WK_ADD_API_MAPPING(WKBundlePageRef, WebPage)
70 WK_ADD_API_MAPPING(WKBundleRangeHandleRef, InjectedBundleRangeHandle)
71 WK_ADD_API_MAPPING(WKBundleRef, InjectedBundle)
72 WK_ADD_API_MAPPING(WKBundleScriptWorldRef, InjectedBundleScriptWorld)
73
74 inline WKInsertActionType toAPI(WebCore::EditorInsertAction action)
75 {
76     switch (action) {
77     case WebCore::EditorInsertActionTyped:
78         return kWKInsertActionTyped;
79     case WebCore::EditorInsertActionPasted:
80         return kWKInsertActionPasted;
81     case WebCore::EditorInsertActionDropped:
82         return kWKInsertActionDropped;
83     }
84     ASSERT_NOT_REACHED();
85     return kWKInsertActionTyped;
86 }
87
88 inline WKAffinityType toAPI(WebCore::EAffinity affinity)
89 {
90     switch (affinity) {
91     case WebCore::UPSTREAM:
92         return kWKAffinityUpstream;
93     case WebCore::DOWNSTREAM:
94         return kWKAffinityDownstream;
95     }
96     ASSERT_NOT_REACHED();
97     return kWKAffinityUpstream;
98 }
99
100 } // namespace WebKit
101
102 #endif // WKBundleAPICast_h