Page overlay action context override should indicate the source of the request
[WebKit-https.git] / Source / WebKit2 / WebProcess / InjectedBundle / API / c / WKBundlePageOverlay.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 WKBundlePageOverlay_h
27 #define WKBundlePageOverlay_h
28
29 #include <WebKit/WKBase.h>
30 #include <WebKit/WKEvent.h>
31 #include <WebKit/WKGeometry.h>
32
33 #ifndef __cplusplus
34 #include <stdbool.h>
35 #endif
36
37 #include <stdint.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 enum {
44     kWKBundlePageOverlayActionContextForActionMenuRequestType = 0,
45     kWKBundlePageOverlayActionContextForImmediateActionRequestType,
46 };
47 typedef uint32_t _WKBundlePageOverlayActionContextRequestType;
48
49 // Page overlay client.
50 typedef void (*WKBundlePageOverlayWillMoveToPageCallback)(WKBundlePageOverlayRef pageOverlay, WKBundlePageRef page, const void* clientInfo);
51 typedef void (*WKBundlePageOverlayDidMoveToPageCallback)(WKBundlePageOverlayRef pageOverlay, WKBundlePageRef page, const void* clientInfo);
52 typedef void (*WKBundlePageOverlayDrawRectCallback)(WKBundlePageOverlayRef pageOverlay, void* graphicsContext, WKRect dirtyRect, const void* clientInfo);
53 typedef bool (*WKBundlePageOverlayMouseDownCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo);
54 typedef bool (*WKBundlePageOverlayMouseUpCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo);
55 typedef bool (*WKBundlePageOverlayMouseMovedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, const void* clientInfo);
56 typedef bool (*WKBundlePageOverlayMouseDraggedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo);
57
58 typedef void* (*WKBundlePageOverlayActionContextForResultAtPointCallback_deprecatedForUseWithV1)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKBundleRangeHandleRef* rangeHandle, const void* clientInfo);
59 typedef void* (*WKBundlePageOverlayActionContextForResultAtPointCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKBundleRangeHandleRef* rangeHandle, _WKBundlePageOverlayActionContextRequestType requestType, const void* clientInfo);
60 typedef void (*WKBundlePageOverlayDataDetectorsDidPresentUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
61 typedef void (*WKBundlePageOverlayDataDetectorsDidChangeUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
62 typedef void (*WKBundlePageOverlayDataDetectorsDidHideUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
63
64 typedef struct WKBundlePageOverlayClientBase {
65     int                                                                 version;
66     const void *                                                        clientInfo;
67 } WKBundlePageOverlayClientBase;
68
69 typedef struct WKBundlePageOverlayClientV0 {
70     WKBundlePageOverlayClientBase                                       base;
71
72     WKBundlePageOverlayWillMoveToPageCallback                           willMoveToPage;
73     WKBundlePageOverlayDidMoveToPageCallback                            didMoveToPage;
74     WKBundlePageOverlayDrawRectCallback                                 drawRect;
75     WKBundlePageOverlayMouseDownCallback                                mouseDown;
76     WKBundlePageOverlayMouseUpCallback                                  mouseUp;
77     WKBundlePageOverlayMouseMovedCallback                               mouseMoved;
78     WKBundlePageOverlayMouseDraggedCallback                             mouseDragged;
79 } WKBundlePageOverlayClientV0;
80
81 typedef struct WKBundlePageOverlayClientV1 {
82     WKBundlePageOverlayClientBase                                       base;
83
84     WKBundlePageOverlayWillMoveToPageCallback                           willMoveToPage;
85     WKBundlePageOverlayDidMoveToPageCallback                            didMoveToPage;
86     WKBundlePageOverlayDrawRectCallback                                 drawRect;
87     WKBundlePageOverlayMouseDownCallback                                mouseDown;
88     WKBundlePageOverlayMouseUpCallback                                  mouseUp;
89     WKBundlePageOverlayMouseMovedCallback                               mouseMoved;
90     WKBundlePageOverlayMouseDraggedCallback                             mouseDragged;
91
92     WKBundlePageOverlayActionContextForResultAtPointCallback            actionContextForResultAtPoint;
93     WKBundlePageOverlayDataDetectorsDidPresentUI                        dataDetectorsDidPresentUI;
94     WKBundlePageOverlayDataDetectorsDidChangeUI                         dataDetectorsDidChangeUI;
95     WKBundlePageOverlayDataDetectorsDidHideUI                           dataDetectorsDidHideUI;
96 } WKBundlePageOverlayClientV1;
97
98 typedef struct WKBundlePageOverlayClientV2 {
99     WKBundlePageOverlayClientBase                                       base;
100
101     WKBundlePageOverlayWillMoveToPageCallback                           willMoveToPage;
102     WKBundlePageOverlayDidMoveToPageCallback                            didMoveToPage;
103     WKBundlePageOverlayDrawRectCallback                                 drawRect;
104     WKBundlePageOverlayMouseDownCallback                                mouseDown;
105     WKBundlePageOverlayMouseUpCallback                                  mouseUp;
106     WKBundlePageOverlayMouseMovedCallback                               mouseMoved;
107     WKBundlePageOverlayMouseDraggedCallback                             mouseDragged;
108
109     WKBundlePageOverlayActionContextForResultAtPointCallback_deprecatedForUseWithV1 actionContextForResultAtPoint_deprecatedForUseWithV1;
110     WKBundlePageOverlayDataDetectorsDidPresentUI                        dataDetectorsDidPresentUI;
111     WKBundlePageOverlayDataDetectorsDidChangeUI                         dataDetectorsDidChangeUI;
112     WKBundlePageOverlayDataDetectorsDidHideUI                           dataDetectorsDidHideUI;
113
114     WKBundlePageOverlayActionContextForResultAtPointCallback            actionContextForResultAtPoint;
115 } WKBundlePageOverlayClientV2;
116
117 enum { kWKBundlePageOverlayClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 };
118 typedef struct WKBundlePageOverlayClient {
119     int                                                                 version;
120     const void *                                                        clientInfo;
121
122     WKBundlePageOverlayWillMoveToPageCallback                           willMoveToPage;
123     WKBundlePageOverlayDidMoveToPageCallback                            didMoveToPage;
124     WKBundlePageOverlayDrawRectCallback                                 drawRect;
125     WKBundlePageOverlayMouseDownCallback                                mouseDown;
126     WKBundlePageOverlayMouseUpCallback                                  mouseUp;
127     WKBundlePageOverlayMouseMovedCallback                               mouseMoved;
128     WKBundlePageOverlayMouseDraggedCallback                             mouseDragged;
129 } WKBundlePageOverlayClient WK_C_DEPRECATED("Use an explicit versioned struct instead");
130
131 typedef WKTypeRef (*WKAccessibilityAttributeValueCallback)(WKBundlePageOverlayRef pageOverlay, WKStringRef attribute, WKTypeRef parameter, const void* clientInfo);
132 typedef WKArrayRef (*WKAccessibilityAttributeNamesCallback)(WKBundlePageOverlayRef pageOverlay, bool parameterizedNames, const void* clientInfo);
133
134 typedef struct WKBundlePageOverlayAccessibilityClientBase {
135     int                                                                 version;
136     const void *                                                        clientInfo;
137 } WKBundlePageOverlayAccessibilityClientBase;
138
139 typedef struct WKBundlePageOverlayAccessibilityClientV0 {
140     WKBundlePageOverlayAccessibilityClientBase                          base;
141
142     // Version 0.
143     WKAccessibilityAttributeValueCallback                               copyAccessibilityAttributeValue;
144     WKAccessibilityAttributeNamesCallback                               copyAccessibilityAttributeNames;
145 } WKBundlePageOverlayAccessibilityClientV0;
146
147 enum { kWKBundlePageOverlayAccessibilityClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 };
148 typedef struct WKBundlePageOverlayAccessibilityClient {
149     int                                                                 version;
150     const void *                                                        clientInfo;
151
152     // Version 0.
153     WKAccessibilityAttributeValueCallback                               copyAccessibilityAttributeValue;
154     WKAccessibilityAttributeNamesCallback                               copyAccessibilityAttributeNames;
155 } WKBundlePageOverlayAccessibilityClient WK_C_DEPRECATED("Use an explicit versioned struct instead");
156
157 WK_EXPORT WKTypeID WKBundlePageOverlayGetTypeID();
158
159 WK_EXPORT WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClientBase* client);
160 WK_EXPORT void WKBundlePageOverlaySetNeedsDisplay(WKBundlePageOverlayRef bundlePageOverlay, WKRect rect);
161 WK_EXPORT float WKBundlePageOverlayFractionFadedIn(WKBundlePageOverlayRef bundlePageOverlay);
162 WK_EXPORT void WKBundlePageOverlaySetAccessibilityClient(WKBundlePageOverlayRef bundlePageOverlay, WKBundlePageOverlayAccessibilityClientBase* client);
163 WK_EXPORT void WKBundlePageOverlayClear(WKBundlePageOverlayRef bundlePageOverlay);
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169 #endif // WKBundlePageOverlay_h