-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWebUIDelegate.cs
More file actions
367 lines (293 loc) · 10.7 KB
/
WebUIDelegate.cs
File metadata and controls
367 lines (293 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
/*
* Copyright (c) 2009, Peter Nelson (charn.opcode@gmail.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
// Handles events relating to UI changes. More info at
// http://developer.apple.com/documentation/Cocoa/Reference/WebKit/Protocols/WebUIDelegate_Protocol
// TODO: most of these events aren't used at all (yet). Find out what they
// do and whether they are actually working in WebKit.
using System;
using System.Collections.Generic;
using System.Text;
using WebKit.Interop;
using System.Diagnostics;
using System.Drawing.Printing;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace WebKit
{
internal delegate void CreateWebViewWithRequestEvent(IWebURLRequest request, out WebView webView);
internal class WebUIDelegate : IWebUIDelegate
{
public event CreateWebViewWithRequestEvent CreateWebViewWithRequest;
private WebKitBrowser owner;
public WebUIDelegate(WebKitBrowser browser)
{
this.owner = browser;
}
#region IWebUIDelegate Members
public void addCustomMenuDrawingData(WebView sender, int hMenu)
{
}
public int canRedo()
{
throw new NotImplementedException();
}
public int canRunModal(WebView WebView)
{
throw new NotImplementedException();
}
public void canTakeFocus(WebView sender, int forward, out int result)
{
throw new NotImplementedException();
}
public int canUndo()
{
throw new NotImplementedException();
}
public void cleanUpCustomMenuDrawingData(WebView sender, int hMenu)
{
}
public void contextMenuItemSelected(WebView sender, IntPtr item, CFDictionaryPropertyBag element)
{
}
public int contextMenuItemsForElement(WebView sender, CFDictionaryPropertyBag element, int defaultItemsHMenu)
{
return owner.IsWebBrowserContextMenuEnabled ? defaultItemsHMenu : 0;
}
public WebView createModalDialog(WebView sender, IWebURLRequest request)
{
throw new NotImplementedException();
}
public WebView createWebViewWithRequest(WebView sender, IWebURLRequest request)
{
// this should be caught in the WebPolicyDelegate, but isn't in the Cairo build
if (owner.AllowNewWindows)
{
WebView view;
CreateWebViewWithRequest(request, out view);
return view;
}
else
{
return null;
}
}
public WebDragDestinationAction dragDestinationActionMaskForDraggingInfo(WebView WebView, IDataObject draggingInfo)
{
throw new NotImplementedException();
}
public WebDragSourceAction dragSourceActionMaskForPoint(WebView WebView, ref tagPOINT point)
{
throw new NotImplementedException();
}
public void drawCustomMenuItem(WebView sender, IntPtr drawItem)
{
}
public void drawFooterInRect(WebView WebView, ref tagRECT rect, int drawingContext, uint pageIndex, uint pageCount)
{
}
public void drawHeaderInRect(WebView WebView, ref tagRECT rect, int drawingContext)
{
}
public string ftpDirectoryTemplatePath(WebView WebView)
{
throw new NotImplementedException();
}
public int hasCustomMenuImplementation()
{
throw new NotImplementedException();
}
public int isMenuBarVisible(WebView WebView)
{
throw new NotImplementedException();
}
public void makeFirstResponder(WebView sender, int responderHWnd)
{
}
public void measureCustomMenuItem(WebView sender, IntPtr measureItem)
{
}
public void mouseDidMoveOverElement(WebView sender, CFDictionaryPropertyBag elementInformation, uint modifierFlags)
{
}
public void paintCustomScrollCorner(WebView WebView, int hDC, tagRECT rect)
{
}
public void paintCustomScrollbar(WebView WebView, int hDC, tagRECT rect, WebScrollBarControlSize size, uint state, WebScrollbarControlPart pressedPart, int vertical, float value, float proportion, uint parts)
{
}
public void printFrame(WebView WebView, webFrame frame)
{
}
public void redo()
{
}
public void registerUndoWithTarget(IWebUndoTarget target, string actionName, object actionArg)
{
}
public void removeAllActionsWithTarget(IWebUndoTarget target)
{
}
public int runBeforeUnloadConfirmPanelWithMessage(WebView sender, string message, webFrame initiatedByFrame)
{
throw new NotImplementedException();
}
public int runDatabaseSizeLimitPrompt(WebView WebView, string displayName, webFrame initiatedByFrame)
{
throw new NotImplementedException();
}
public void runJavaScriptAlertPanelWithMessage(WebView sender, string message)
{
}
public int runJavaScriptConfirmPanelWithMessage(WebView sender, string message)
{
throw new NotImplementedException();
}
public string runJavaScriptTextInputPanelWithPrompt(WebView sender, string message, string defaultText)
{
throw new NotImplementedException();
}
public void runModal(WebView WebView)
{
}
public void runOpenPanelForFileButtonWithResultListener(WebView sender, IWebOpenPanelResultListener resultListener)
{
}
public void setActionTitle(string actionTitle)
{
}
public void setContentRect(WebView sender, ref tagRECT contentRect)
{
}
public void setFrame(WebView sender, ref tagRECT frame)
{
}
public void setMenuBarVisible(WebView WebView, int visible)
{
}
public void setResizable(WebView sender, int resizable)
{
}
public void setStatusBarVisible(WebView sender, int visible)
{
}
public void setStatusText(WebView sender, string text)
{
}
public void setToolbarsVisible(WebView sender, int visible)
{
}
public void shouldPerformAction(WebView WebView, uint itemCommandID, uint sender)
{
}
public void takeFocus(WebView sender, int forward)
{
}
public void trackCustomPopupMenu(WebView sender, int hMenu, ref tagPOINT point)
{
}
public void undo()
{
}
public int validateUserInterfaceItem(WebView WebView, uint itemCommandID, int defaultValidation)
{
throw new NotImplementedException();
}
public int webViewAreToolbarsVisible(WebView sender)
{
throw new NotImplementedException();
}
public void webViewClose(WebView sender)
{
}
public tagRECT webViewContentRect(WebView sender)
{
throw new NotImplementedException();
}
public int webViewFirstResponder(WebView sender)
{
throw new NotImplementedException();
}
public void webViewFocus(WebView sender)
{
}
public float webViewFooterHeight(WebView WebView)
{
throw new NotImplementedException();
}
public tagRECT webViewFrame(WebView sender)
{
throw new NotImplementedException();
}
public float webViewHeaderHeight(WebView WebView)
{
throw new NotImplementedException();
}
public int webViewIsResizable(WebView sender)
{
throw new NotImplementedException();
}
public int webViewIsStatusBarVisible(WebView sender)
{
return 0;
}
public tagRECT webViewPrintingMarginRect(WebView WebView)
{
PageSettings settings = owner.PageSettings;
// WebKit specifies margins in 1000ths of an inch.
// PrinterResolution.Y returns 0 for some reason,
// on Adobe distiller anyway, so we'll use X for the moment.
int dpi = settings.PrinterResolution.X;
int marginLeft = settings.Margins.Left;
int marginRight = settings.Margins.Right;
int marginTop = settings.Margins.Top;
int marginBottom = settings.Margins.Bottom;
tagRECT rect = new tagRECT();
rect.left = marginLeft * 10;
rect.top = marginTop * 10;
rect.right = marginRight * 10;
rect.bottom = marginBottom * 10;
return rect;
}
public void webViewShow(WebView sender)
{
}
public string webViewStatusText(WebView sender)
{
throw new NotImplementedException();
}
public void webViewUnfocus(WebView sender)
{
}
public void willPerformDragDestinationAction(WebView WebView, WebDragDestinationAction action, IDataObject draggingInfo)
{
}
public IDataObject willPerformDragSourceAction(WebView WebView, WebDragSourceAction action, ref tagPOINT point, IDataObject pasteboard)
{
throw new NotImplementedException();
}
#endregion
}
}