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