9e568ccce6a31feee0268c7b3c2cf61b0337248e
[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 // Page overlay client.
44 typedef void (*WKBundlePageOverlayWillMoveToPageCallback)(WKBundlePageOverlayRef pageOverlay, WKBundlePageRef page, const void* clientInfo);
45 typedef void (*WKBundlePageOverlayDidMoveToPageCallback)(WKBundlePageOverlayRef pageOverlay, WKBundlePageRef page, const void* clientInfo);
46 typedef void (*WKBundlePageOverlayDrawRectCallback)(WKBundlePageOverlayRef pageOverlay, void* graphicsContext, WKRect dirtyRect, const void* clientInfo);
47 typedef bool (*WKBundlePageOverlayMouseDownCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo);
48 typedef bool (*WKBundlePageOverlayMouseUpCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo);
49 typedef bool (*WKBundlePageOverlayMouseMovedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, const void* clientInfo);
50 typedef bool (*WKBundlePageOverlayMouseDraggedCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKEventMouseButton mouseButton, const void* clientInfo);
51
52 typedef void* (*WKBundlePageOverlayActionContextForResultAtPointCallback)(WKBundlePageOverlayRef pageOverlay, WKPoint position, WKBundleRangeHandleRef* rangeHandle, const void* clientInfo);
53 typedef void (*WKBundlePageOverlayDatadetectorsDidPresentUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
54 typedef void (*WKBundlePageOverlayDatadetectorsDidChangeUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
55 typedef void (*WKBundlePageOverlayDatadetectorsDidHideUI)(WKBundlePageOverlayRef pageOverlay, const void* clientInfo);
56
57 typedef struct WKBundlePageOverlayClientBase {
58     int                                                                 version;
59     const void *                                                        clientInfo;
60 } WKBundlePageOverlayClientBase;
61
62 typedef struct WKBundlePageOverlayClientV0 {
63     WKBundlePageOverlayClientBase                                       base;
64
65     WKBundlePageOverlayWillMoveToPageCallback                           willMoveToPage;
66     WKBundlePageOverlayDidMoveToPageCallback                            didMoveToPage;
67     WKBundlePageOverlayDrawRectCallback                                 drawRect;
68     WKBundlePageOverlayMouseDownCallback                                mouseDown;
69     WKBundlePageOverlayMouseUpCallback                                  mouseUp;
70     WKBundlePageOverlayMouseMovedCallback                               mouseMoved;
71     WKBundlePageOverlayMouseDraggedCallback                             mouseDragged;
72 } WKBundlePageOverlayClientV0;
73
74 typedef struct WKBundlePageOverlayClientV1 {
75     WKBundlePageOverlayClientBase                                       base;
76
77     WKBundlePageOverlayWillMoveToPageCallback                           willMoveToPage;
78     WKBundlePageOverlayDidMoveToPageCallback                            didMoveToPage;
79     WKBundlePageOverlayDrawRectCallback                                 drawRect;
80     WKBundlePageOverlayMouseDownCallback                                mouseDown;
81     WKBundlePageOverlayMouseUpCallback                                  mouseUp;
82     WKBundlePageOverlayMouseMovedCallback                               mouseMoved;
83     WKBundlePageOverlayMouseDraggedCallback                             mouseDragged;
84
85     WKBundlePageOverlayActionContextForResultAtPointCallback            actionContextForResultAtPoint;
86     WKBundlePageOverlayDatadetectorsDidPresentUI                         dataDetectorsDidPresentUI;
87     WKBundlePageOverlayDatadetectorsDidChangeUI                           dataDetectorsDidChangeUI;
88     WKBundlePageOverlayDatadetectorsDidHideUI                               dataDetectorsDidHideUI;
89 } WKBundlePageOverlayClientV1;
90
91 enum { kWKBundlePageOverlayClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 };
92 typedef struct WKBundlePageOverlayClient {
93     int                                                                 version;
94     const void *                                                        clientInfo;
95
96     WKBundlePageOverlayWillMoveToPageCallback                           willMoveToPage;
97     WKBundlePageOverlayDidMoveToPageCallback                            didMoveToPage;
98     WKBundlePageOverlayDrawRectCallback                                 drawRect;
99     WKBundlePageOverlayMouseDownCallback                                mouseDown;
100     WKBundlePageOverlayMouseUpCallback                                  mouseUp;
101     WKBundlePageOverlayMouseMovedCallback                               mouseMoved;
102     WKBundlePageOverlayMouseDraggedCallback                             mouseDragged;
103 } WKBundlePageOverlayClient WK_C_DEPRECATED("Use an explicit versioned struct instead");
104
105 typedef WKTypeRef (*WKAccessibilityAttributeValueCallback)(WKBundlePageOverlayRef pageOverlay, WKStringRef attribute, WKTypeRef parameter, const void* clientInfo);
106 typedef WKArrayRef (*WKAccessibilityAttributeNamesCallback)(WKBundlePageOverlayRef pageOverlay, bool parameterizedNames, const void* clientInfo);
107
108 typedef struct WKBundlePageOverlayAccessibilityClientBase {
109     int                                                                 version;
110     const void *                                                        clientInfo;
111 } WKBundlePageOverlayAccessibilityClientBase;
112
113 typedef struct WKBundlePageOverlayAccessibilityClientV0 {
114     WKBundlePageOverlayAccessibilityClientBase                          base;
115
116     // Version 0.
117     WKAccessibilityAttributeValueCallback                               copyAccessibilityAttributeValue;
118     WKAccessibilityAttributeNamesCallback                               copyAccessibilityAttributeNames;
119 } WKBundlePageOverlayAccessibilityClientV0;
120
121 enum { kWKBundlePageOverlayAccessibilityClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 };
122 typedef struct WKBundlePageOverlayAccessibilityClient {
123     int                                                                 version;
124     const void *                                                        clientInfo;
125
126     // Version 0.
127     WKAccessibilityAttributeValueCallback                               copyAccessibilityAttributeValue;
128     WKAccessibilityAttributeNamesCallback                               copyAccessibilityAttributeNames;
129 } WKBundlePageOverlayAccessibilityClient WK_C_DEPRECATED("Use an explicit versioned struct instead");
130
131 WK_EXPORT WKTypeID WKBundlePageOverlayGetTypeID();
132
133 WK_EXPORT WKBundlePageOverlayRef WKBundlePageOverlayCreate(WKBundlePageOverlayClientBase* client);
134 WK_EXPORT void WKBundlePageOverlaySetNeedsDisplay(WKBundlePageOverlayRef bundlePageOverlay, WKRect rect);
135 WK_EXPORT float WKBundlePageOverlayFractionFadedIn(WKBundlePageOverlayRef bundlePageOverlay);
136 WK_EXPORT void WKBundlePageOverlaySetAccessibilityClient(WKBundlePageOverlayRef bundlePageOverlay, WKBundlePageOverlayAccessibilityClientBase* client);
137 WK_EXPORT void WKBundlePageOverlayClear(WKBundlePageOverlayRef bundlePageOverlay);
138
139 #ifdef __cplusplus
140 }
141 #endif
142
143 #endif // WKBundlePageOverlay_h