1/*
2 * Copyright (C) 2013 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 WKPageContextMenuClient_h
27#define WKPageContextMenuClient_h
28
29#include <WebKit/WKBase.h>
30#include <WebKit/WKGeometry.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo);
37typedef void (*WKPageCustomContextMenuItemSelectedCallback)(WKPageRef page, WKContextMenuItemRef contextMenuItem, const void* clientInfo);
38typedef void (*WKPageContextMenuDismissedCallback)(WKPageRef page, const void* clientInfo);
39typedef void (*WKPageShowContextMenuCallback)(WKPageRef page, WKPoint menuLocation, WKArrayRef menuItems, const void* clientInfo);
40typedef void (*WKPageHideContextMenuCallback)(WKPageRef page, const void* clientInfo);
41
42// Deprecated
43typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKTypeRef userData, const void* clientInfo);
44
45typedef struct WKPageContextMenuClientBase {
46    int                                                                          version;
47    const void *                                                                 clientInfo;
48} WKPageContextMenuClientBase;
49
50typedef struct WKPageContextMenuClientV0 {
51    WKPageContextMenuClientBase                                                  base;
52
53    // Version 0.
54    WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0   getContextMenuFromProposedMenu_deprecatedForUseWithV0;
55    WKPageCustomContextMenuItemSelectedCallback                                  customContextMenuItemSelected;
56} WKPageContextMenuClientV0;
57
58typedef struct WKPageContextMenuClientV1 {
59    WKPageContextMenuClientBase                                                  base;
60
61    // Version 0.
62    WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0   getContextMenuFromProposedMenu_deprecatedForUseWithV0;
63    WKPageCustomContextMenuItemSelectedCallback                                  customContextMenuItemSelected;
64
65    // Version 1.
66    WKPageContextMenuDismissedCallback                                           contextMenuDismissed;
67} WKPageContextMenuClientV1;
68
69typedef struct WKPageContextMenuClientV2 {
70    WKPageContextMenuClientBase                                                  base;
71
72    // Version 0.
73    WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0   getContextMenuFromProposedMenu_deprecatedForUseWithV0;
74    WKPageCustomContextMenuItemSelectedCallback                                  customContextMenuItemSelected;
75
76    // Version 1.
77    WKPageContextMenuDismissedCallback                                           contextMenuDismissed;
78
79    // Version 2.
80    WKPageGetContextMenuFromProposedContextMenuCallback                          getContextMenuFromProposedMenu;
81} WKPageContextMenuClientV2;
82
83typedef struct WKPageContextMenuClientV3 {
84    WKPageContextMenuClientBase                                                  base;
85
86    // Version 0.
87    WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0   getContextMenuFromProposedMenu_deprecatedForUseWithV0;
88    WKPageCustomContextMenuItemSelectedCallback                                  customContextMenuItemSelected;
89
90    // Version 1.
91    WKPageContextMenuDismissedCallback                                           contextMenuDismissed;
92
93    // Version 2.
94    WKPageGetContextMenuFromProposedContextMenuCallback                          getContextMenuFromProposedMenu;
95
96    // Version 3.
97    WKPageShowContextMenuCallback                                                showContextMenu;
98    WKPageHideContextMenuCallback                                                hideContextMenu;
99} WKPageContextMenuClientV3;
100
101enum { kWKPageContextMenuClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 3 };
102typedef struct WKPageContextMenuClient {
103    int                                                                          version;
104    const void *                                                                 clientInfo;
105
106    // Version 0.
107    WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0   getContextMenuFromProposedMenu_deprecatedForUseWithV0;
108    WKPageCustomContextMenuItemSelectedCallback                                  customContextMenuItemSelected;
109
110    // Version 1.
111    WKPageContextMenuDismissedCallback                                           contextMenuDismissed;
112
113    // Version 2.
114    WKPageGetContextMenuFromProposedContextMenuCallback                          getContextMenuFromProposedMenu;
115
116    // Version 3.
117    WKPageShowContextMenuCallback                                                showContextMenu;
118    WKPageHideContextMenuCallback                                                hideContextMenu;
119} WKPageContextMenuClient WK_DEPRECATED("Use an explicit versioned struct instead");
120
121#ifdef __cplusplus
122}
123#endif
124
125
126#endif // WKPageContextMenuClient_h
127