Mercurial > projects > dwt-mac
annotate dwt/browser/Safari.d @ 126:38807a925e24
Fixed compile errors, support for SWT language files
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Fri, 16 Jan 2009 23:35:40 +0100 |
parents | 5583f8eeee6c |
children |
rev | line source |
---|---|
125 | 1 /******************************************************************************* |
45 | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
7 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
8 * Contributors: |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
10 * |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
11 * Port to the D programming language: |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
12 * Jacob Carlborg <doob@me.com> |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
13 *******************************************************************************/ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
14 module dwt.browser.Safari; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
15 |
45 | 16 import dwt.dwthelper.utils; |
17 | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
18 import dwt.DWT; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
19 import dwt.graphics.Point; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
20 import dwt.graphics.Rectangle; |
45 | 21 import dwt.internal.C; |
22 import dwt.internal.Compatibility; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
23 import dwt.internal.cocoa.DOMDocument; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
24 import dwt.internal.cocoa.DOMKeyboardEvent; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
25 import dwt.internal.cocoa.DOMMouseEvent; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
26 import dwt.internal.cocoa.DOMWheelEvent; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
27 import dwt.internal.cocoa.NSArray; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
28 import dwt.internal.cocoa.NSDictionary; |
45 | 29 import dwt.internal.cocoa.NSError; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
30 import dwt.internal.cocoa.NSHTTPCookie; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
31 import dwt.internal.cocoa.NSHTTPCookieStorage; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
32 import dwt.internal.cocoa.NSNotificationCenter; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
33 import dwt.internal.cocoa.NSNumber; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
34 import dwt.internal.cocoa.NSPrintInfo; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
35 import dwt.internal.cocoa.NSPrintOperation; |
45 | 36 import dwt.internal.cocoa.NSRect; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
37 import dwt.internal.cocoa.NSString; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
38 import dwt.internal.cocoa.NSURL; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
39 import dwt.internal.cocoa.NSURLDownload; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
40 import dwt.internal.cocoa.NSURLRequest; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
41 import dwt.internal.cocoa.OS; |
35
7d135fe0caf2
Ported dwt.graphics.Cursor and dwt.widgets.MenuItem
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
13
diff
changeset
|
42 import dwt.internal.cocoa.SWTWebViewDelegate; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
43 import dwt.internal.cocoa.WebDataSource; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
44 import dwt.internal.cocoa.WebDocumentRepresentation; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
45 import dwt.internal.cocoa.WebFrame; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
46 import dwt.internal.cocoa.WebFrameView; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
47 import dwt.internal.cocoa.WebOpenPanelResultListener; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
48 import dwt.internal.cocoa.WebPolicyDecisionListener; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
49 import dwt.internal.cocoa.WebPreferences; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
50 import dwt.internal.cocoa.WebView; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
51 import dwt.internal.cocoa.id; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
52 import dwt.widgets.Composite; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
53 import dwt.widgets.Display; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
54 import dwt.widgets.Event; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
55 import dwt.widgets.FileDialog; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
56 import dwt.widgets.Listener; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
57 import dwt.widgets.Menu; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
58 import dwt.widgets.MessageBox; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
59 import dwt.widgets.Shell; |
45 | 60 import dwt.widgets.Widget; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
61 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
62 import dwt.browser.Browser; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
63 import dwt.browser.LocationEvent; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
64 import dwt.browser.ProgressEvent; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
65 import dwt.browser.ProgressListener; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
66 import dwt.browser.StatusTextEvent; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
67 import dwt.browser.TitleEvent; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
68 import dwt.browser.TitleListener; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
69 import dwt.browser.WebBrowser; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
70 import dwt.browser.WindowEvent; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
71 import Carbon = dwt.internal.c.Carbon; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
72 import dwt.internal.objc.cocoa.Cocoa; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
73 import objc = dwt.internal.objc.runtime; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
74 |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
75 class Safari : WebBrowser { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
76 WebView webView; |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
77 SWTWebViewDelegate delegate_; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
78 bool changingLocation; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
79 String lastHoveredLinkURL; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
80 String html; |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
81 objc.id identifier; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
82 int resourceCount; |
45 | 83 String url = ""; //$NON-NLS-1$ |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
84 Point location; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
85 Point size; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
86 bool statusBar = true, toolBar = true, ignoreDispose; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
87 int lastMouseMoveX, lastMouseMoveY; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
88 //TEMPORARY CODE |
45 | 89 // bool doit; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
90 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
91 static bool Initialized; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
92 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
93 static const int MIN_SIZE = 16; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
94 static const int MAX_PROGRESS = 100; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
95 static const String WebElementLinkURLKey = "WebElementLinkURL"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
96 static const String AGENT_STRING = "Safari/unknown"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
97 static const String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
98 static const String PROTOCOL_FILE = "file://"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
99 static const String PROTOCOL_HTTP = "http://"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
100 static const String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
101 static const String ADD_WIDGET_KEY = "dwt.internal.addWidget"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
102 static const String SAFARI_EVENTS_FIX_KEY = "dwt.internal.safariEventsFix"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
103 static const String DWT_OBJECT = "DWT_OBJECT"; //$NON-NLS-1$ |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
104 |
45 | 105 /* event strings */ |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
106 static const String DOMEVENT_KEYUP = "keyup"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
107 static const String DOMEVENT_KEYDOWN = "keydown"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
108 static const String DOMEVENT_MOUSEDOWN = "mousedown"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
109 static const String DOMEVENT_MOUSEUP = "mouseup"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
110 static const String DOMEVENT_MOUSEMOVE = "mousemove"; //$NON-NLS-1$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
111 static const String DOMEVENT_MOUSEWHEEL = "mousewheel"; //$NON-NLS-1$ |
45 | 112 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
113 static this () { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
114 NativeClearSessions = new class () Runnable { |
45 | 115 public void run() { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
116 NSHTTPCookieStorage storage = NSHTTPCookieStorage.sharedHTTPCookieStorage(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
117 NSArray cookies = storage.cookies(); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
118 NSUInteger count = cookies.count(); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
119 for (NSUInteger i = 0; i < count; i++) { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
120 NSHTTPCookie cookie = new NSHTTPCookie(cookies.objectAtIndex(i)); |
45 | 121 if (cookie.isSessionOnly()) { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
122 storage.deleteCookie(cookie); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
123 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
124 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
125 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
126 }; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
127 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
128 |
45 | 129 public void create (Composite parent, int style) { |
130 String className = "SWTWebViewDelegate"; //$NON-NLS-1$ | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
131 if (OS.objc_lookUpClass(className) is null) { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
132 Class safariClass = this.classinfo; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
133 objc.IMP proc3;// = cast(objc.IMP) &browserProc3; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
134 objc.IMP proc4;// = cast(objc.IMP) &browserProc4; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
135 objc.IMP proc5;// = cast(objc.IMP) &browserProc5; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
136 objc.IMP proc6;// = cast(objc.IMP) &browserProc6; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
137 objc.IMP proc7;// = cast(objc.IMP) &browserProc7; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
138 objc.IMP setFrameProc = OS.webView_setFrame_CALLBACK(proc4); |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
139 |
45 | 140 String types = "*"; //$NON-NLS-1$ |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
141 size_t size = C.PTR_SIZEOF, align_ = C.PTR_SIZEOF is 4 ? 2 : 3; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
142 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
143 objc.Class cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
144 OS.class_addIvar(cls, DWT_OBJECT, size, cast(byte)align_, types); |
45 | 145 OS.class_addMethod(cls, OS.sel_webView_didChangeLocationWithinPageForFrame_, proc4, "@:@@"); //$NON-NLS-1$ |
146 OS.class_addMethod(cls, OS.sel_webView_didFailProvisionalLoadWithError_forFrame_, proc5, "@:@@@"); //$NON-NLS-1$ | |
147 OS.class_addMethod(cls, OS.sel_webView_didFinishLoadForFrame_, proc4, "@:@@"); //$NON-NLS-1$ | |
148 OS.class_addMethod(cls, OS.sel_webView_didReceiveTitle_forFrame_, proc5, "@:@@@"); //$NON-NLS-1$ | |
149 OS.class_addMethod(cls, OS.sel_webView_didStartProvisionalLoadForFrame_, proc4, "@:@@"); //$NON-NLS-1$ | |
150 OS.class_addMethod(cls, OS.sel_webView_didCommitLoadForFrame_, proc4, "@:@@"); //$NON-NLS-1$ | |
151 OS.class_addMethod(cls, OS.sel_webView_resource_didFinishLoadingFromDataSource_, proc5, "@:@@@"); //$NON-NLS-1$ | |
152 OS.class_addMethod(cls, OS.sel_webView_resource_didFailLoadingWithError_fromDataSource_, proc6, "@:@@@@"); //$NON-NLS-1$ | |
153 OS.class_addMethod(cls, OS.sel_webView_identifierForInitialRequest_fromDataSource_, proc5, "@:@@@"); //$NON-NLS-1$ | |
154 OS.class_addMethod(cls, OS.sel_webView_resource_willSendRequest_redirectResponse_fromDataSource_, proc7, "@:@@@@@"); //$NON-NLS-1$ | |
155 OS.class_addMethod(cls, OS.sel_handleNotification_, proc3, "@:@"); //$NON-NLS-1$ | |
156 OS.class_addMethod(cls, OS.sel_webView_createWebViewWithRequest_, proc4, "@:@@"); //$NON-NLS-1$ | |
157 OS.class_addMethod(cls, OS.sel_webViewShow_, proc3, "@:@"); //$NON-NLS-1$ | |
158 OS.class_addMethod(cls, OS.sel_webViewClose_, proc3, "@:@"); //$NON-NLS-1$ | |
159 OS.class_addMethod(cls, OS.sel_webView_contextMenuItemsForElement_defaultMenuItems_, proc5, "@:@@@"); //$NON-NLS-1$ | |
160 OS.class_addMethod(cls, OS.sel_webView_setStatusBarVisible_, proc4, "@:@B"); //$NON-NLS-1$ | |
161 OS.class_addMethod(cls, OS.sel_webView_setResizable_, proc4, "@:@B"); //$NON-NLS-1$ | |
162 OS.class_addMethod(cls, OS.sel_webView_setToolbarsVisible_, proc4, "@:@B"); //$NON-NLS-1$ | |
163 OS.class_addMethod(cls, OS.sel_webView_setStatusText_, proc4, "@:@@"); //$NON-NLS-1$ | |
164 OS.class_addMethod(cls, OS.sel_webViewFocus_, proc3, "@:@"); //$NON-NLS-1$ | |
165 OS.class_addMethod(cls, OS.sel_webViewUnfocus_, proc3, "@:@"); //$NON-NLS-1$ | |
166 OS.class_addMethod(cls, OS.sel_webView_runJavaScriptAlertPanelWithMessage_, proc4, "@:@@"); //$NON-NLS-1$ | |
167 OS.class_addMethod(cls, OS.sel_webView_runJavaScriptConfirmPanelWithMessage_, proc4, "@:@@"); //$NON-NLS-1$ | |
168 OS.class_addMethod(cls, OS.sel_webView_runOpenPanelForFileButtonWithResultListener_, proc4, "@:@@"); //$NON-NLS-1$ | |
169 OS.class_addMethod(cls, OS.sel_webView_mouseDidMoveOverElement_modifierFlags_, proc5, "@:@@I"); //$NON-NLS-1$ | |
170 OS.class_addMethod(cls, OS.sel_webView_printFrameView_, proc4, "@:@@"); //$NON-NLS-1$ | |
171 OS.class_addMethod(cls, OS.sel_webView_decidePolicyForMIMEType_request_frame_decisionListener_, proc7, "@:@@@@@"); //$NON-NLS-1$ | |
172 OS.class_addMethod(cls, OS.sel_webView_decidePolicyForNavigationAction_request_frame_decisionListener_, proc7, "@:@@@@@"); //$NON-NLS-1$ | |
173 OS.class_addMethod(cls, OS.sel_webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener_, proc7, "@:@@@@@"); //$NON-NLS-1$ | |
174 OS.class_addMethod(cls, OS.sel_webView_unableToImplementPolicyWithError_frame_, proc5, "@:@@@"); //$NON-NLS-1$ | |
175 OS.class_addMethod(cls, OS.sel_download_decideDestinationWithSuggestedFilename_, proc4, "@:@@"); //$NON-NLS-1$ | |
176 OS.class_addMethod(cls, OS.sel_handleEvent_, proc3, "@:@"); //$NON-NLS-1$ | |
177 OS.class_addMethod(cls, OS.sel_webView_setFrame_, setFrameProc, "@:@{NSRect}"); //$NON-NLS-1$ | |
178 OS.objc_registerClassPair(cls); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
179 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
180 |
45 | 181 /* |
182 * Override the default event mechanism to not send key events so | |
183 * that the browser can send them by listening to the DOM instead. | |
184 */ | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
185 browser.setData(new ArrayWrapperString(SAFARI_EVENTS_FIX_KEY)); |
45 | 186 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
187 WebView webView = cast(WebView)(new WebView()).alloc(); |
45 | 188 if (webView is null) DWT.error(DWT.ERROR_NO_HANDLES); |
189 webView.initWithFrame(browser.view.frame(), null, null); | |
190 webView.setAutoresizingMask(OS.NSViewWidthSizable | OS.NSViewHeightSizable); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
191 final SWTWebViewDelegate delegate_ = cast(SWTWebViewDelegate)(new SWTWebViewDelegate()).alloc().init(); |
45 | 192 Display display = browser.getDisplay(); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
193 display.setData(ADD_WIDGET_KEY, new ArrayWrapperObject([cast(Object) delegate_, browser])); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
194 this.delegate_ = delegate_; |
45 | 195 this.webView = webView; |
196 browser.view.addSubview(webView); | |
197 | |
198 final NSNotificationCenter notificationCenter = NSNotificationCenter.defaultCenter(); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
199 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
200 Listener listener = new class () Listener { |
45 | 201 public void handleEvent(Event e) { |
202 switch (e.type) { | |
203 case DWT.FocusIn: | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
204 this.outer.webView.window().makeFirstResponder(this.outer.webView); |
45 | 205 break; |
206 case DWT.Dispose: { | |
207 /* make this handler run after other dispose listeners */ | |
208 if (ignoreDispose) { | |
209 ignoreDispose = false; | |
210 break; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
211 } |
45 | 212 ignoreDispose = true; |
213 browser.notifyListeners (e.type, e); | |
214 e.type = DWT.NONE; | |
215 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
216 e.display.setData(ADD_WIDGET_KEY, new ArrayWrapperObject([delegate_, null])); |
45 | 217 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
218 this.outer.webView.setFrameLoadDelegate(null); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
219 this.outer.webView.setResourceLoadDelegate(null); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
220 this.outer.webView.setUIDelegate(null); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
221 this.outer.webView.setPolicyDelegate(null); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
222 this.outer.webView.setDownloadDelegate(null); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
223 notificationCenter.removeObserver(delegate_); |
45 | 224 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
225 this.outer.webView.release(); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
226 this.outer.webView = null; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
227 this.outer.delegate_.release(); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
228 this.outer.delegate_ = null; |
45 | 229 html = null; |
230 lastHoveredLinkURL = null; | |
231 break; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
232 } |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
233 default: |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
234 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
235 } |
45 | 236 }; |
237 browser.addListener(DWT.Dispose, listener); | |
238 /* Needed to be able to tab into the browser */ | |
239 browser.addListener(DWT.KeyDown, listener); | |
240 browser.addListener(DWT.FocusIn, listener); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
241 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
242 webView.setFrameLoadDelegate(delegate_); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
243 webView.setResourceLoadDelegate(delegate_); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
244 webView.setUIDelegate(delegate_); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
245 notificationCenter.addObserver(delegate_, OS.sel_handleNotification_, null, webView); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
246 webView.setPolicyDelegate(delegate_); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
247 webView.setDownloadDelegate(delegate_); |
45 | 248 webView.setApplicationNameForUserAgent(NSString.stringWith(AGENT_STRING)); |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
249 |
45 | 250 if (!Initialized) { |
251 Initialized = true; | |
252 /* disable applets */ | |
253 WebPreferences.standardPreferences().setJavaEnabled(false); | |
254 } | |
255 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
256 |
45 | 257 public bool back() { |
258 html = null; | |
259 return webView.goBack(); | |
260 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
261 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
262 static objc.id browserProc3(objc.id id, objc.SEL sel, objc.id arg0) { |
45 | 263 Widget widget = Display.getCurrent().findWidget(id); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
264 if (widget is null) return null; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
265 Safari safari = cast(Safari)(cast(Browser)widget).webBrowser; |
45 | 266 if (sel is OS.sel_handleNotification_) { |
267 safari.handleNotification(arg0); | |
268 } else if (sel is OS.sel_webViewShow_) { | |
269 safari.webViewShow(arg0); | |
270 } else if (sel is OS.sel_webViewClose_) { | |
271 safari.webViewClose(arg0); | |
272 } else if (sel is OS.sel_webViewFocus_) { | |
273 safari.webViewFocus(arg0); | |
274 } else if (sel is OS.sel_webViewUnfocus_) { | |
275 safari.webViewUnfocus(arg0); | |
276 } else if (sel is OS.sel_handleEvent_) { | |
277 safari.handleEvent(arg0); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
278 } |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
279 return null; |
45 | 280 } |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
281 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
282 static objc.id browserProc4(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1) { |
45 | 283 Widget widget = Display.getCurrent().findWidget(id); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
284 if (widget is null) return null; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
285 Safari safari = cast(Safari)(cast(Browser)widget).webBrowser; |
45 | 286 if (sel is OS.sel_webView_didChangeLocationWithinPageForFrame_) { |
287 safari.webView_didChangeLocationWithinPageForFrame(arg0, arg1); | |
288 } else if (sel is OS.sel_webView_didFinishLoadForFrame_) { | |
289 safari.webView_didFinishLoadForFrame(arg0, arg1); | |
290 } else if (sel is OS.sel_webView_didStartProvisionalLoadForFrame_) { | |
291 safari.webView_didStartProvisionalLoadForFrame(arg0, arg1); | |
292 } else if (sel is OS.sel_webView_didCommitLoadForFrame_) { | |
293 safari.webView_didCommitLoadForFrame(arg0, arg1); | |
294 } else if (sel is OS.sel_webView_setFrame_) { | |
295 safari.webView_setFrame(arg0, arg1); | |
296 } else if (sel is OS.sel_webView_createWebViewWithRequest_) { | |
297 return safari.webView_createWebViewWithRequest(arg0, arg1); | |
298 } else if (sel is OS.sel_webView_setStatusBarVisible_) { | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
299 safari.webView_setStatusBarVisible(arg0, arg1 !is null); |
45 | 300 } else if (sel is OS.sel_webView_setResizable_) { |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
301 safari.webView_setResizable(arg0, arg1 !is null); |
45 | 302 } else if (sel is OS.sel_webView_setStatusText_) { |
303 safari.webView_setStatusText(arg0, arg1); | |
304 } else if (sel is OS.sel_webView_setToolbarsVisible_) { | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
305 safari.webView_setToolbarsVisible(arg0, arg1 !is null); |
45 | 306 } else if (sel is OS.sel_webView_runJavaScriptAlertPanelWithMessage_) { |
307 safari.webView_runJavaScriptAlertPanelWithMessage(arg0, arg1); | |
308 } else if (sel is OS.sel_webView_runJavaScriptConfirmPanelWithMessage_) { | |
309 return safari.webView_runJavaScriptConfirmPanelWithMessage(arg0, arg1); | |
310 } else if (sel is OS.sel_webView_runOpenPanelForFileButtonWithResultListener_) { | |
311 safari.webView_runOpenPanelForFileButtonWithResultListener(arg0, arg1); | |
312 } else if (sel is OS.sel_download_decideDestinationWithSuggestedFilename_) { | |
313 safari.download_decideDestinationWithSuggestedFilename(arg0, arg1); | |
314 } else if (sel is OS.sel_webView_printFrameView_) { | |
315 safari.webView_printFrameView(arg0, arg1); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
316 } |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
317 return null; |
45 | 318 } |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
319 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
320 static objc.id browserProc5(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1, objc.id arg2) { |
45 | 321 Widget widget = Display.getCurrent().findWidget(id); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
322 if (widget is null) return null; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
323 Safari safari = cast(Safari)(cast(Browser)widget).webBrowser; |
45 | 324 if (sel is OS.sel_webView_didFailProvisionalLoadWithError_forFrame_) { |
325 safari.webView_didFailProvisionalLoadWithError_forFrame(arg0, arg1, arg2); | |
326 } else if (sel is OS.sel_webView_didReceiveTitle_forFrame_) { | |
327 safari.webView_didReceiveTitle_forFrame(arg0, arg1, arg2); | |
328 } else if (sel is OS.sel_webView_resource_didFinishLoadingFromDataSource_) { | |
329 safari.webView_resource_didFinishLoadingFromDataSource(arg0, arg1, arg2); | |
330 } else if (sel is OS.sel_webView_identifierForInitialRequest_fromDataSource_) { | |
331 return safari.webView_identifierForInitialRequest_fromDataSource(arg0, arg1, arg2); | |
332 } else if (sel is OS.sel_webView_contextMenuItemsForElement_defaultMenuItems_) { | |
333 return safari.webView_contextMenuItemsForElement_defaultMenuItems(arg0, arg1, arg2); | |
334 } else if (sel is OS.sel_webView_mouseDidMoveOverElement_modifierFlags_) { | |
335 safari.webView_mouseDidMoveOverElement_modifierFlags(arg0, arg1, arg2); | |
336 } else if (sel is OS.sel_webView_unableToImplementPolicyWithError_frame_) { | |
337 safari.webView_unableToImplementPolicyWithError_frame(arg0, arg1, arg2); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
338 } |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
339 return null; |
45 | 340 } |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
341 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
342 static objc.id browserProc6(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1, objc.id arg2, objc.id arg3) { |
45 | 343 Widget widget = Display.getCurrent().findWidget(id); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
344 if (widget is null) return null; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
345 Safari safari = cast(Safari)(cast(Browser)widget).webBrowser; |
45 | 346 if (sel is OS.sel_webView_resource_didFailLoadingWithError_fromDataSource_) { |
347 safari.webView_resource_didFailLoadingWithError_fromDataSource(arg0, arg1, arg2, arg3); | |
348 } | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
349 return null; |
45 | 350 } |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
351 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
352 static objc.id browserProc7(objc.id id, objc.SEL sel, objc.id arg0, objc.id arg1, objc.id arg2, objc.id arg3, objc.id arg4) { |
45 | 353 Widget widget = Display.getCurrent().findWidget(id); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
354 if (widget is null) return null; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
355 Safari safari = cast(Safari)(cast(Browser)widget).webBrowser; |
45 | 356 if (sel is OS.sel_webView_resource_willSendRequest_redirectResponse_fromDataSource_) { |
357 return safari.webView_resource_willSendRequest_redirectResponse_fromDataSource(arg0, arg1, arg2, arg3, arg4); | |
358 } else if (sel is OS.sel_webView_decidePolicyForMIMEType_request_frame_decisionListener_) { | |
359 safari.webView_decidePolicyForMIMEType_request_frame_decisionListener(arg0, arg1, arg2, arg3, arg4); | |
360 } else if (sel is OS.sel_webView_decidePolicyForNavigationAction_request_frame_decisionListener_) { | |
361 safari.webView_decidePolicyForNavigationAction_request_frame_decisionListener(arg0, arg1, arg2, arg3, arg4); | |
362 } else if (sel is OS.sel_webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener_) { | |
363 safari.webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener(arg0, arg1, arg2, arg3, arg4); | |
364 } | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
365 return null; |
45 | 366 } |
367 | |
368 public bool execute(String script) { | |
369 return webView.stringByEvaluatingJavaScriptFromString(NSString.stringWith(script)) !is null; | |
370 } | |
371 | |
372 public bool forward() { | |
373 html = null; | |
374 return webView.goForward(); | |
375 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
376 |
45 | 377 public String getBrowserType () { |
378 return "safari"; //$NON-NLS-1$ | |
379 } | |
380 | |
381 public String getText() { | |
382 WebFrame mainFrame = webView.mainFrame(); | |
383 WebDataSource dataSource = mainFrame.dataSource(); | |
384 if (dataSource is null) return ""; //$NON-NLS-1$ | |
385 WebDocumentRepresentation representation = dataSource.representation(); | |
386 if (representation is null) return ""; //$NON-NLS-1$ | |
387 NSString source = representation.documentSource(); | |
388 if (source is null) return ""; //$NON-NLS-1$ | |
389 return source.getString(); | |
390 } | |
391 | |
392 public String getUrl() { | |
393 return url; | |
394 } | |
395 | |
396 public bool isBackEnabled() { | |
397 return webView.canGoBack(); | |
398 } | |
399 | |
400 public bool isForwardEnabled() { | |
401 return webView.canGoForward(); | |
402 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
403 |
45 | 404 public void refresh() { |
405 webView.reload(null); | |
406 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
407 |
45 | 408 public bool setText(String html) { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
409 /* |
45 | 410 * Bug in Safari. The web view segment faults in some circumstances |
411 * when the text changes during the location changing callback. The | |
412 * fix is to defer the work until the callback is done. | |
413 */ | |
414 if (changingLocation) { | |
415 this.html = html; | |
416 } else { | |
417 _setText(html); | |
418 } | |
419 return true; | |
420 } | |
421 | |
422 void _setText(String html) { | |
423 NSString string = NSString.stringWith(html); | |
424 NSString URLString = NSString.stringWith(URI_FROMMEMORY); | |
425 NSURL URL = NSURL.URLWithString(URLString); | |
426 WebFrame mainFrame = webView.mainFrame(); | |
427 mainFrame.loadHTMLString(string, URL); | |
428 } | |
429 | |
430 public bool setUrl(String url) { | |
431 html = null; | |
432 | |
433 if (url.indexOf('/') is 0) { | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
434 url = PROTOCOL_FILE ~ url; |
45 | 435 } else if (url.indexOf(':') is -1) { |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
436 url = PROTOCOL_HTTP ~ url; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
437 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
438 |
45 | 439 NSString str = NSString.stringWith(url); |
440 NSString unescapedStr = NSString.stringWith("%#"); //$NON-NLS-1$ | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
441 Carbon.CFStringRef ptr = OS.CFURLCreateStringByAddingPercentEscapes(null, cast(Carbon.CFStringRef) str.id, cast(Carbon.CFStringRef) unescapedStr.id, null, OS.kCFStringEncodingUTF8); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
442 NSString escapedString = new NSString(cast(objc.id) ptr); |
45 | 443 NSURL inURL = NSURL.URLWithString(escapedString); |
444 OS.CFRelease(ptr); | |
445 NSURLRequest request = NSURLRequest.requestWithURL(inURL); | |
446 WebFrame mainFrame = webView.mainFrame(); | |
447 mainFrame.loadRequest(request); | |
448 return true; | |
449 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
450 |
45 | 451 public void stop() { |
452 html = null; | |
453 webView.stopLoading(null); | |
454 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
455 |
45 | 456 /* WebFrameLoadDelegate */ |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
457 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
458 void webView_didChangeLocationWithinPageForFrame(objc.id sender, objc.id frameID) { |
45 | 459 WebFrame frame = new WebFrame(frameID); |
460 WebDataSource dataSource = frame.dataSource(); | |
461 NSURLRequest request = dataSource.request(); | |
462 NSURL url = request.URL(); | |
463 NSString s = url.absoluteString(); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
464 NSUInteger length = s.length(); |
45 | 465 if (length is 0) return; |
466 String url2 = s.getString(); | |
467 /* | |
468 * If the URI indicates that the page is being rendered from memory | |
469 * (via setText()) then set it to about:blank to be consistent with IE. | |
470 */ | |
471 if (url2.equals (URI_FROMMEMORY)) url2 = ABOUT_BLANK; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
472 |
45 | 473 final Display display = browser.getDisplay(); |
474 bool top = frameID is webView.mainFrame().id; | |
475 if (top) { | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
476 StatusTextEvent statusText = new StatusTextEvent(browser); |
45 | 477 statusText.display = display; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
478 statusText.widget = browser; |
45 | 479 statusText.text = url2; |
480 for (int i = 0; i < statusTextListeners.length; i++) { | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
481 statusTextListeners[i].changed(statusText); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
482 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
483 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
484 |
45 | 485 LocationEvent location = new LocationEvent(browser); |
486 location.display = display; | |
487 location.widget = browser; | |
488 location.location = url2; | |
489 location.top = top; | |
490 for (int i = 0; i < locationListeners.length; i++) { | |
491 locationListeners[i].changed(location); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
492 } |
45 | 493 } |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
494 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
495 void webView_didFailProvisionalLoadWithError_forFrame(objc.id sender, objc.id error, objc.id frame) { |
45 | 496 if (frame is webView.mainFrame().id) { |
497 /* | |
498 * Feature on Safari. The identifier is used here as a marker for the events | |
499 * related to the top frame and the URL changes related to that top frame as | |
500 * they should appear on the location bar of a browser. It is expected to reset | |
501 * the identifier to 0 when the event didFinishLoadingFromDataSource related to | |
502 * the identifierForInitialRequest event is received. However, Safari fires | |
503 * the didFinishLoadingFromDataSource event before the entire content of the | |
504 * top frame is loaded. It is possible to receive multiple willSendRequest | |
505 * events in this interval, causing the Browser widget to send unwanted | |
506 * Location.changing events. For this reason, the identifier is reset to 0 | |
507 * when the top frame has either finished loading (didFinishLoadForFrame | |
508 * event) or failed (didFailProvisionalLoadWithError). | |
509 */ | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
510 identifier = null; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
511 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
512 |
45 | 513 NSError nserror = new NSError(error); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
514 NSInteger errorCode = nserror.code(); |
45 | 515 if (errorCode <= OS.NSURLErrorBadURL) { |
516 NSString description = nserror.localizedDescription(); | |
517 if (description !is null) { | |
518 String descriptionString = description.getString(); | |
519 String urlString = null; | |
520 NSDictionary info = nserror.userInfo(); | |
521 if (info !is null) { | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
522 NSString key = new NSString(OS.NSErrorFailingURLStringKey_); |
45 | 523 id id = info.valueForKey(key); |
524 if (id !is null) { | |
525 NSString url = new NSString(id); | |
526 urlString = url.getString(); | |
527 } | |
528 } | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
529 String message = urlString !is null ? urlString ~ "\n\n" : ""; //$NON-NLS-1$ //$NON-NLS-2$ |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
530 message ~= Compatibility.getMessage ("DWT_Page_Load_Failed", [new ArrayWrapperString(descriptionString)]); //$NON-NLS-1$ |
45 | 531 MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.ICON_ERROR); |
532 messageBox.setMessage(message); | |
533 messageBox.open(); | |
534 } | |
535 } | |
536 } | |
537 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
538 void webView_didFinishLoadForFrame(objc.id sender, objc.id frameID) { |
45 | 539 hookDOMMouseListeners(frameID); |
540 if (frameID is webView.mainFrame().id) { | |
541 hookDOMKeyListeners(frameID); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
542 |
45 | 543 final Display display = browser.getDisplay(); |
544 /* | |
545 * To be consistent with other platforms a title event should be fired when a | |
546 * page has completed loading. A page with a <title> tag will do this | |
547 * automatically when the didReceiveTitle callback is received. However a page | |
548 * without a <title> tag will not do this by default, so fire the event | |
549 * here with the page's url as the title. | |
550 */ | |
551 WebFrame frame = new WebFrame(frameID); | |
552 WebDataSource dataSource = frame.dataSource(); | |
553 if (dataSource !is null) { | |
554 NSString title = dataSource.pageTitle(); | |
555 if (title is null) { /* page has no title */ | |
556 final TitleEvent newEvent = new TitleEvent(browser); | |
557 newEvent.display = display; | |
558 newEvent.widget = browser; | |
559 newEvent.title = url; | |
560 for (int i = 0; i < titleListeners.length; i++) { | |
561 final TitleListener listener = titleListeners[i]; | |
562 /* | |
563 * Note on WebKit. Running the event loop from a Browser | |
564 * delegate callback breaks the WebKit (stop loading or | |
565 * crash). The workaround is to invoke Display.asyncExec() | |
566 * so that the Browser does not crash if this is attempted. | |
567 */ | |
568 display.asyncExec( | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
569 new class (display, browser, listener) Runnable { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
570 |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
571 Display display; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
572 Browser browser; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
573 TitleListener listener; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
574 |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
575 this (Display display, Browser browser, TitleListener listener) |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
576 { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
577 this.display = display; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
578 this.browser = browser; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
579 this.listener = listener; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
580 } |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
581 |
45 | 582 public void run() { |
583 if (!display.isDisposed() && !browser.isDisposed()) { | |
584 listener.changed(newEvent); | |
585 } | |
586 } | |
587 } | |
588 ); | |
589 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
590 } |
45 | 591 } |
592 final ProgressEvent progress = new ProgressEvent(browser); | |
593 progress.display = display; | |
594 progress.widget = browser; | |
595 progress.current = MAX_PROGRESS; | |
596 progress.total = MAX_PROGRESS; | |
597 for (int i = 0; i < progressListeners.length; i++) { | |
598 final ProgressListener listener = progressListeners[i]; | |
599 /* | |
600 * Note on WebKit. Running the event loop from a Browser | |
601 * delegate callback breaks the WebKit (stop loading or | |
602 * crash). The ProgressBar widget currently touches the | |
603 * event loop every time the method setSelection is called. | |
604 * The workaround is to invoke Display.asyncExec() so that | |
605 * the Browser does not crash when the user updates the | |
606 * selection of the ProgressBar. | |
607 */ | |
608 display.asyncExec( | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
609 new class (display, browser, listener) Runnable { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
610 |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
611 Display display; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
612 Browser browser; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
613 ProgressListener listener; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
614 |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
615 this (Display display, Browser browser, ProgressListener listener) |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
616 { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
617 this.display = display; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
618 this.browser = browser; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
619 this.listener = listener; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
620 } |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
621 |
45 | 622 public void run() { |
623 if (!display.isDisposed() && !browser.isDisposed()) { | |
624 listener.completed(progress); | |
625 } | |
626 } | |
627 } | |
628 ); | |
629 } | |
630 /* | |
631 * Feature on Safari. The identifier is used here as a marker for the events | |
632 * related to the top frame and the URL changes related to that top frame as | |
633 * they should appear on the location bar of a browser. It is expected to reset | |
634 * the identifier to 0 when the event didFinishLoadingFromDataSource related to | |
635 * the identifierForInitialRequest event is received. However, Safari fires | |
636 * the didFinishLoadingFromDataSource event before the entire content of the | |
637 * top frame is loaded. It is possible to receive multiple willSendRequest | |
638 * events in this interval, causing the Browser widget to send unwanted | |
639 * Location.changing events. For this reason, the identifier is reset to 0 | |
640 * when the top frame has either finished loading (didFinishLoadForFrame | |
641 * event) or failed (didFailProvisionalLoadWithError). | |
642 */ | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
643 identifier = null; |
45 | 644 } |
645 } | |
646 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
647 void hookDOMKeyListeners(objc.id frameID) { |
45 | 648 WebFrame frame = new WebFrame(frameID); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
649 DOMDocument document = frame.DOMDocument_(); |
45 | 650 |
651 NSString type = NSString.stringWith(DOMEVENT_KEYDOWN); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
652 document.addEventListener(type, delegate_, false); |
45 | 653 |
654 type = NSString.stringWith(DOMEVENT_KEYUP); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
655 document.addEventListener(type, delegate_, false); |
45 | 656 } |
657 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
658 void hookDOMMouseListeners(objc.id frameID) { |
45 | 659 WebFrame frame = new WebFrame(frameID); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
660 DOMDocument document = frame.DOMDocument_(); |
45 | 661 |
662 NSString type = NSString.stringWith(DOMEVENT_MOUSEDOWN); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
663 document.addEventListener(type, delegate_, false); |
45 | 664 |
665 type = NSString.stringWith(DOMEVENT_MOUSEUP); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
666 document.addEventListener(type, delegate_, false); |
45 | 667 |
668 type = NSString.stringWith(DOMEVENT_MOUSEMOVE); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
669 document.addEventListener(type, delegate_, false); |
45 | 670 |
671 type = NSString.stringWith(DOMEVENT_MOUSEWHEEL); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
672 document.addEventListener(type, delegate_, false); |
45 | 673 } |
674 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
675 void webView_didReceiveTitle_forFrame(objc.id sender, objc.id titleID, objc.id frameID) { |
45 | 676 if (frameID is webView.mainFrame().id) { |
677 NSString title = new NSString(titleID); | |
678 String newTitle = title.getString(); | |
679 TitleEvent newEvent = new TitleEvent(browser); | |
680 newEvent.display = browser.getDisplay(); | |
681 newEvent.widget = browser; | |
682 newEvent.title = newTitle; | |
683 for (int i = 0; i < titleListeners.length; i++) { | |
684 titleListeners[i].changed(newEvent); | |
685 } | |
686 } | |
687 } | |
688 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
689 void webView_didStartProvisionalLoadForFrame(objc.id sender, objc.id frameID) { |
45 | 690 /* |
691 * This code is intentionally commented. WebFrameLoadDelegate:didStartProvisionalLoadForFrame is | |
692 * called before WebResourceLoadDelegate:willSendRequest and | |
693 * WebFrameLoadDelegate:didCommitLoadForFrame. The resource count is reset when didCommitLoadForFrame | |
694 * is received for the top frame. | |
695 */ | |
696 // if (frameID is webView.mainFrame().id) { | |
697 // /* reset resource status variables */ | |
698 // resourceCount= 0; | |
699 // } | |
700 } | |
701 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
702 void webView_didCommitLoadForFrame(objc.id sender, objc.id frameID) { |
45 | 703 WebFrame frame = new WebFrame(frameID); |
704 WebDataSource dataSource = frame.dataSource(); | |
705 NSURLRequest request = dataSource.request(); | |
706 NSURL url = request.URL(); | |
707 NSString s = url.absoluteString(); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
708 NSUInteger length = s.length(); |
45 | 709 if (length is 0) return; |
710 String url2 = s.getString(); | |
711 /* | |
712 * If the URI indicates that the page is being rendered from memory | |
713 * (via setText()) then set it to about:blank to be consistent with IE. | |
714 */ | |
715 if (url2.equals (URI_FROMMEMORY)) url2 = ABOUT_BLANK; | |
716 | |
717 final Display display = browser.getDisplay(); | |
718 bool top = frameID is webView.mainFrame().id; | |
719 if (top) { | |
720 /* reset resource status variables */ | |
721 resourceCount = 0; | |
722 this.url = url2; | |
723 | |
724 final ProgressEvent progress = new ProgressEvent(browser); | |
725 progress.display = display; | |
726 progress.widget = browser; | |
727 progress.current = 1; | |
728 progress.total = MAX_PROGRESS; | |
729 for (int i = 0; i < progressListeners.length; i++) { | |
730 final ProgressListener listener = progressListeners[i]; | |
731 /* | |
732 * Note on WebKit. Running the event loop from a Browser | |
733 * delegate callback breaks the WebKit (stop loading or | |
734 * crash). The widget ProgressBar currently touches the | |
735 * event loop every time the method setSelection is called. | |
736 * The workaround is to invoke Display.asyncexec so that | |
737 * the Browser does not crash when the user updates the | |
738 * selection of the ProgressBar. | |
739 */ | |
740 display.asyncExec( | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
741 new class (display, browser, listener) Runnable { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
742 |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
743 Display display; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
744 Browser browser; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
745 ProgressListener listener; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
746 |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
747 this (Display display, Browser browser, ProgressListener listener) |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
748 { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
749 this.display = display; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
750 this.browser = browser; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
751 this.listener = listener; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
752 } |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
753 |
45 | 754 public void run() { |
755 if (!display.isDisposed() && !browser.isDisposed()) | |
756 listener.changed(progress); | |
757 } | |
758 } | |
759 ); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
760 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
761 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
762 StatusTextEvent statusText = new StatusTextEvent(browser); |
45 | 763 statusText.display = display; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
764 statusText.widget = browser; |
45 | 765 statusText.text = url2; |
766 for (int i = 0; i < statusTextListeners.length; i++) { | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
767 statusTextListeners[i].changed(statusText); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
768 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
769 } |
45 | 770 LocationEvent location = new LocationEvent(browser); |
771 location.display = display; | |
772 location.widget = browser; | |
773 location.location = url2; | |
774 location.top = top; | |
775 for (int i = 0; i < locationListeners.length; i++) { | |
776 locationListeners[i].changed(location); | |
777 } | |
778 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
779 |
45 | 780 /* WebResourceLoadDelegate */ |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
781 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
782 void webView_resource_didFinishLoadingFromDataSource(objc.id sender, objc.id identifier, objc.id dataSource) { |
45 | 783 /* |
784 * Feature on Safari. The identifier is used here as a marker for the events | |
785 * related to the top frame and the URL changes related to that top frame as | |
786 * they should appear on the location bar of a browser. It is expected to reset | |
787 * the identifier to 0 when the event didFinishLoadingFromDataSource related to | |
788 * the identifierForInitialRequest event is received. However, Safari fires | |
789 * the didFinishLoadingFromDataSource event before the entire content of the | |
790 * top frame is loaded. It is possible to receive multiple willSendRequest | |
791 * events in this interval, causing the Browser widget to send unwanted | |
792 * Location.changing events. For this reason, the identifier is reset to 0 | |
793 * when the top frame has either finished loading (didFinishLoadForFrame | |
794 * event) or failed (didFailProvisionalLoadWithError). | |
795 */ | |
796 // this code is intentionally commented | |
797 //if (this.identifier is identifier) this.identifier = 0; | |
798 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
799 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
800 void webView_resource_didFailLoadingWithError_fromDataSource(objc.id sender, objc.id identifier, objc.id error, objc.id dataSource) { |
45 | 801 /* |
802 * Feature on Safari. The identifier is used here as a marker for the events | |
803 * related to the top frame and the URL changes related to that top frame as | |
804 * they should appear on the location bar of a browser. It is expected to reset | |
805 * the identifier to 0 when the event didFinishLoadingFromDataSource related to | |
806 * the identifierForInitialRequest event is received. However, Safari fires | |
807 * the didFinishLoadingFromDataSource event before the entire content of the | |
808 * top frame is loaded. It is possible to receive multiple willSendRequest | |
809 * events in this interval, causing the Browser widget to send unwanted | |
810 * Location.changing events. For this reason, the identifier is reset to 0 | |
811 * when the top frame has either finished loading (didFinishLoadForFrame | |
812 * event) or failed (didFailProvisionalLoadWithError). | |
813 */ | |
814 // this code is intentionally commented | |
815 //if (this.identifier is identifier) this.identifier = 0; | |
816 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
817 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
818 objc.id webView_identifierForInitialRequest_fromDataSource(objc.id sender, objc.id request, objc.id dataSourceID) { |
45 | 819 final Display display = browser.getDisplay(); |
820 final ProgressEvent progress = new ProgressEvent(browser); | |
821 progress.display = display; | |
822 progress.widget = browser; | |
823 progress.current = resourceCount; | |
824 progress.total = Math.max(resourceCount, MAX_PROGRESS); | |
825 for (int i = 0; i < progressListeners.length; i++) { | |
826 final ProgressListener listener = progressListeners[i]; | |
827 /* | |
828 * Note on WebKit. Running the event loop from a Browser | |
829 * delegate callback breaks the WebKit (stop loading or | |
830 * crash). The widget ProgressBar currently touches the | |
831 * event loop every time the method setSelection is called. | |
832 * The workaround is to invoke Display.asyncexec so that | |
833 * the Browser does not crash when the user updates the | |
834 * selection of the ProgressBar. | |
835 */ | |
836 display.asyncExec( | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
837 new class (display, browser, listener) Runnable { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
838 |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
839 Display display; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
840 Browser browser; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
841 ProgressListener listener; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
842 |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
843 this (Display display, Browser browser, ProgressListener listener) |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
844 { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
845 this.display = display; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
846 this.browser = browser; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
847 this.listener = listener; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
848 } |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
849 |
45 | 850 public void run() { |
851 if (!display.isDisposed() && !browser.isDisposed()) | |
852 listener.changed(progress); | |
853 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
854 } |
45 | 855 ); |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
856 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
857 |
45 | 858 NSNumber identifier = NSNumber.numberWithInt(resourceCount++); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
859 if (this.identifier is null) { |
45 | 860 WebDataSource dataSource = new WebDataSource(dataSourceID); |
861 WebFrame frame = dataSource.webFrame(); | |
862 if (frame.id is webView.mainFrame().id) this.identifier = identifier.id; | |
863 } | |
864 return identifier.id; | |
865 | |
866 } | |
867 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
868 objc.id webView_resource_willSendRequest_redirectResponse_fromDataSource(objc.id sender, objc.id identifier, objc.id request, objc.id redirectResponse, objc.id dataSource) { |
45 | 869 return request; |
870 } | |
871 | |
872 /* handleNotification */ | |
873 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
874 void handleNotification(objc.id notification) { |
45 | 875 } |
876 | |
877 /* UIDelegate */ | |
878 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
879 objc.id webView_createWebViewWithRequest(objc.id sender, objc.id request) { |
45 | 880 WindowEvent newEvent = new WindowEvent(browser); |
881 newEvent.display = browser.getDisplay(); | |
882 newEvent.widget = browser; | |
883 newEvent.required = true; | |
884 if (openWindowListeners !is null) { | |
885 for (int i = 0; i < openWindowListeners.length; i++) { | |
886 openWindowListeners[i].open(newEvent); | |
887 } | |
888 } | |
889 WebView result = null; | |
890 Browser browser = null; | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
891 if (newEvent.browser !is null && cast(Safari) newEvent.browser.webBrowser) { |
45 | 892 browser = newEvent.browser; |
893 } | |
894 if (browser !is null && !browser.isDisposed()) { | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
895 result = (cast(Safari)browser.webBrowser).webView; |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
896 if (request !is null) { |
45 | 897 WebFrame mainFrame = webView.mainFrame(); |
898 mainFrame.loadRequest(new NSURLRequest(request)); | |
899 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
900 } |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
901 return result !is null ? result.id : null; |
45 | 902 } |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
903 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
904 void webViewShow(objc.id sender) { |
45 | 905 /* |
906 * Feature on WebKit. The Safari WebKit expects the application | |
907 * to create a new Window using the Objective C Cocoa API in response | |
908 * to UIDelegate.createWebViewWithRequest. The application is then | |
909 * expected to use Objective C Cocoa API to make this window visible | |
910 * when receiving the UIDelegate.webViewShow message. For some reason, | |
911 * a window created with the Carbon API hosting the new browser instance | |
912 * does not redraw until it has been resized. The fix is to increase the | |
913 * size of the Shell and restore it to its initial size. | |
914 */ | |
915 Shell parent = browser.getShell(); | |
916 Point pt = parent.getSize(); | |
917 parent.setSize(pt.x+1, pt.y); | |
918 parent.setSize(pt.x, pt.y); | |
919 WindowEvent newEvent = new WindowEvent(browser); | |
920 newEvent.display = browser.getDisplay(); | |
921 newEvent.widget = browser; | |
922 if (location !is null) newEvent.location = location; | |
923 if (size !is null) newEvent.size = size; | |
924 /* | |
925 * Feature in Safari. Safari's tool bar contains | |
926 * the address bar. The address bar is displayed | |
927 * if the tool bar is displayed. There is no separate | |
928 * notification for the address bar. | |
929 * Feature in Safari. The menu bar is always | |
930 * displayed. There is no notification to hide | |
931 * the menu bar. | |
932 */ | |
933 newEvent.addressBar = toolBar; | |
934 newEvent.menuBar = true; | |
935 newEvent.statusBar = statusBar; | |
936 newEvent.toolBar = toolBar; | |
937 for (int i = 0; i < visibilityWindowListeners.length; i++) { | |
938 visibilityWindowListeners[i].show(newEvent); | |
939 } | |
940 location = null; | |
941 size = null; | |
942 } | |
943 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
944 void webView_setFrame(objc.id sender, objc.id frame) { |
46
cfa563df4fdd
Updated Widget and Display to 3.514
Jacob Carlborg <doob@me.com>
parents:
45
diff
changeset
|
945 NSRect rect = NSRect(); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
946 OS.memmove(&rect, frame, NSRect.sizeof); |
45 | 947 /* convert to DWT system coordinates */ |
948 Rectangle bounds = browser.getDisplay().getBounds(); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
949 location = new Point(cast(int)rect.x, bounds.height - cast(int)rect.y - cast(int)rect.height); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
950 size = new Point(cast(int)rect.width, cast(int)rect.height); |
45 | 951 } |
952 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
953 void webViewFocus(objc.id sender) { |
45 | 954 } |
955 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
956 void webViewUnfocus(objc.id sender) { |
45 | 957 } |
958 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
959 void webView_runJavaScriptAlertPanelWithMessage(objc.id sender, objc.id messageID) { |
45 | 960 NSString message = new NSString(messageID); |
961 String text = message.getString(); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
962 |
45 | 963 MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.ICON_WARNING); |
964 messageBox.setText("Javascript"); //$NON-NLS-1$ | |
965 messageBox.setMessage(text); | |
966 messageBox.open(); | |
967 } | |
968 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
969 objc.id webView_runJavaScriptConfirmPanelWithMessage(objc.id sender, objc.id messageID) { |
45 | 970 NSString message = new NSString(messageID); |
971 String text = message.getString(); | |
972 | |
973 MessageBox messageBox = new MessageBox(browser.getShell(), DWT.OK | DWT.CANCEL | DWT.ICON_QUESTION); | |
974 messageBox.setText("Javascript"); //$NON-NLS-1$ | |
975 messageBox.setMessage(text); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
976 return messageBox.open() is DWT.OK ? cast(objc.id) 1 : null; |
45 | 977 } |
978 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
979 void webView_runOpenPanelForFileButtonWithResultListener(objc.id sender, objc.id resultListenerID) { |
45 | 980 FileDialog dialog = new FileDialog(browser.getShell(), DWT.NONE); |
981 String result = dialog.open(); | |
982 WebOpenPanelResultListener resultListener = new WebOpenPanelResultListener(resultListenerID); | |
983 if (result is null) { | |
984 resultListener.cancel(); | |
985 return; | |
986 } | |
987 resultListener.chooseFilename(NSString.stringWith(result)); | |
988 } | |
989 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
990 void webViewClose(objc.id sender) { |
45 | 991 Shell parent = browser.getShell(); |
992 WindowEvent newEvent = new WindowEvent(browser); | |
993 newEvent.display = browser.getDisplay(); | |
994 newEvent.widget = browser; | |
995 for (int i = 0; i < closeWindowListeners.length; i++) { | |
996 closeWindowListeners[i].close(newEvent); | |
997 } | |
998 browser.dispose(); | |
999 if (parent.isDisposed()) return; | |
1000 /* | |
1001 * Feature on WebKit. The Safari WebKit expects the application | |
1002 * to create a new Window using the Objective C Cocoa API in response | |
1003 * to UIDelegate.createWebViewWithRequest. The application is then | |
1004 * expected to use Objective C Cocoa API to make this window visible | |
1005 * when receiving the UIDelegate.webViewShow message. For some reason, | |
1006 * a window created with the Carbon API hosting the new browser instance | |
1007 * does not redraw until it has been resized. The fix is to increase the | |
1008 * size of the Shell and restore it to its initial size. | |
1009 */ | |
1010 Point pt = parent.getSize(); | |
1011 parent.setSize(pt.x+1, pt.y); | |
1012 parent.setSize(pt.x, pt.y); | |
1013 } | |
1014 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1015 objc.id webView_contextMenuItemsForElement_defaultMenuItems(objc.id sender, objc.id element, objc.id defaultMenuItems) { |
45 | 1016 Point pt = browser.getDisplay().getCursorLocation(); |
1017 Event event = new Event(); | |
1018 event.x = pt.x; | |
1019 event.y = pt.y; | |
1020 browser.notifyListeners(DWT.MenuDetect, event); | |
1021 Menu menu = browser.getMenu(); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1022 if (!event.doit) return null; |
45 | 1023 if (menu !is null && !menu.isDisposed()) { |
1024 if (event.x !is pt.x || event.y !is pt.y) { | |
1025 menu.setLocation(event.x, event.y); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1026 } |
45 | 1027 menu.setVisible(true); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1028 return null; |
45 | 1029 } |
1030 return defaultMenuItems; | |
1031 } | |
1032 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1033 void webView_setStatusBarVisible(objc.id sender, bool visible) { |
45 | 1034 /* Note. Webkit only emits the notification when the status bar should be hidden. */ |
1035 statusBar = visible; | |
1036 } | |
1037 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1038 void webView_setStatusText(objc.id sender, objc.id textID) { |
45 | 1039 NSString text = new NSString(textID); |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1040 NSUInteger length = text.length(); |
45 | 1041 if (length is 0) return; |
1042 | |
1043 StatusTextEvent statusText = new StatusTextEvent(browser); | |
1044 statusText.display = browser.getDisplay(); | |
1045 statusText.widget = browser; | |
1046 statusText.text = text.getString(); | |
1047 for (int i = 0; i < statusTextListeners.length; i++) { | |
1048 statusTextListeners[i].changed(statusText); | |
1049 } | |
1050 } | |
1051 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1052 void webView_setResizable(objc.id sender, bool visible) { |
45 | 1053 } |
1054 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1055 void webView_setToolbarsVisible(objc.id sender, bool visible) { |
45 | 1056 /* Note. Webkit only emits the notification when the tool bar should be hidden. */ |
1057 toolBar = visible; | |
1058 } | |
1059 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1060 void webView_mouseDidMoveOverElement_modifierFlags (objc.id sender, objc.id elementInformationID, objc.id modifierFlags) { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1061 if (elementInformationID is null) return; |
45 | 1062 |
1063 NSString key = NSString.stringWith(WebElementLinkURLKey); | |
1064 NSDictionary elementInformation = new NSDictionary(elementInformationID); | |
1065 id value = elementInformation.valueForKey(key); | |
1066 if (value is null) { | |
1067 /* not currently over a link */ | |
1068 if (lastHoveredLinkURL is null) return; | |
1069 lastHoveredLinkURL = null; | |
1070 StatusTextEvent statusText = new StatusTextEvent(browser); | |
1071 statusText.display = browser.getDisplay(); | |
1072 statusText.widget = browser; | |
1073 statusText.text = ""; //$NON-NLS-1$ | |
1074 for (int i = 0; i < statusTextListeners.length; i++) { | |
1075 statusTextListeners[i].changed(statusText); | |
1076 } | |
1077 return; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1078 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1079 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1080 NSString url = (new NSURL(value.id)).absoluteString(); |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1081 NSUInteger length = url.length(); |
45 | 1082 String urlString; |
1083 if (length is 0) { | |
1084 urlString = ""; //$NON-NLS-1$ | |
1085 } else { | |
1086 urlString = url.getString(); | |
1087 } | |
1088 if (urlString.equals(lastHoveredLinkURL)) return; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1089 |
45 | 1090 lastHoveredLinkURL = urlString; |
1091 StatusTextEvent statusText = new StatusTextEvent(browser); | |
1092 statusText.display = browser.getDisplay(); | |
1093 statusText.widget = browser; | |
1094 statusText.text = urlString; | |
1095 for (int i = 0; i < statusTextListeners.length; i++) { | |
1096 statusTextListeners[i].changed(statusText); | |
1097 } | |
1098 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1099 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1100 void webView_printFrameView (objc.id sender, objc.id frameViewID) { |
45 | 1101 WebFrameView view = new WebFrameView(frameViewID); |
1102 bool viewPrint = view.documentViewShouldHandlePrint(); | |
1103 if (viewPrint) { | |
1104 view.printDocumentView(); | |
1105 return; | |
1106 } | |
1107 NSPrintInfo info = NSPrintInfo.sharedPrintInfo(); | |
1108 NSPrintOperation operation = view.printOperationWithPrintInfo(info); | |
1109 if (operation !is null) operation.runOperation(); | |
1110 } | |
1111 | |
1112 /* PolicyDelegate */ | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1113 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1114 void webView_decidePolicyForMIMEType_request_frame_decisionListener(objc.id sender, objc.id type, objc.id request, objc.id frame, objc.id listenerID) { |
45 | 1115 bool canShow = WebView.canShowMIMEType(new NSString(type)); |
1116 WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID); | |
1117 if (canShow) { | |
1118 listener.use(); | |
1119 } else { | |
1120 listener.download(); | |
1121 } | |
1122 } | |
1123 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1124 void webView_decidePolicyForNavigationAction_request_frame_decisionListener(objc.id sender, objc.id actionInformation, objc.id request, objc.id frame, objc.id listenerID) { |
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1125 NSURL url = (new NSURLRequest(request)).URL(); |
45 | 1126 WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID); |
1127 if (url is null) { | |
1128 /* indicates that a URL with an invalid format was specified */ | |
1129 listener.ignore(); | |
1130 return; | |
1131 } | |
1132 NSString s = url.absoluteString(); | |
1133 String url2 = s.getString(); | |
1134 /* | |
1135 * If the URI indicates that the page is being rendered from memory | |
1136 * (via setText()) then set it to about:blank to be consistent with IE. | |
1137 */ | |
1138 if (url2.equals (URI_FROMMEMORY)) url2 = ABOUT_BLANK; | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1139 |
45 | 1140 LocationEvent newEvent = new LocationEvent(browser); |
1141 newEvent.display = browser.getDisplay(); | |
1142 newEvent.widget = browser; | |
1143 newEvent.location = url2; | |
1144 newEvent.doit = true; | |
1145 if (locationListeners !is null) { | |
1146 changingLocation = true; | |
1147 for (int i = 0; i < locationListeners.length; i++) { | |
1148 locationListeners[i].changing(newEvent); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1149 } |
45 | 1150 changingLocation = false; |
1151 } | |
1152 if (newEvent.doit) { | |
1153 listener.use(); | |
1154 } else { | |
1155 listener.ignore(); | |
1156 } | |
1157 if (html !is null && !browser.isDisposed()) { | |
1158 String html = this.html; | |
1159 this.html = null; | |
1160 _setText(html); | |
1161 } | |
1162 } | |
1163 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1164 void webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener(objc.id sender, objc.id actionInformation, objc.id request, objc.id frameName, objc.id listenerID) { |
45 | 1165 WebPolicyDecisionListener listener = new WebPolicyDecisionListener(listenerID); |
1166 listener.use(); | |
1167 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1168 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1169 void webView_unableToImplementPolicyWithError_frame(objc.id sender, objc.id error, objc.id frame) { |
45 | 1170 } |
1171 | |
1172 /* WebDownload */ | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1173 |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1174 void download_decideDestinationWithSuggestedFilename(objc.id downloadId, objc.id filename) { |
45 | 1175 NSString string = new NSString(filename); |
1176 String name = string.getString(); | |
1177 FileDialog dialog = new FileDialog(browser.getShell(), DWT.SAVE); | |
1178 dialog.setText(DWT.getMessage ("DWT_FileDownload")); //$NON-NLS-1$ | |
1179 dialog.setFileName(name); | |
1180 String path = dialog.open(); | |
1181 NSURLDownload download = new NSURLDownload(downloadId); | |
1182 if (path is null) { | |
1183 /* cancel pressed */ | |
1184 download.cancel(); | |
1185 return; | |
1186 } | |
1187 download.setDestination(NSString.stringWith(path), true); | |
1188 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1189 |
45 | 1190 /* DOMEventListener */ |
1191 | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1192 void handleEvent(objc.id evtId) { |
45 | 1193 NSString string = new NSString(OS.objc_msgSend(evtId, OS.sel_type)); |
1194 String type = string.getString(); | |
1195 | |
1196 if (DOMEVENT_KEYDOWN.equals(type) || DOMEVENT_KEYUP.equals(type)) { | |
1197 DOMKeyboardEvent event = new DOMKeyboardEvent(evtId); | |
1198 | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1199 bool ctrl = event.ctrlKey(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1200 bool shift = event.shiftKey(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1201 bool alt = event.altKey(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1202 bool meta = event.metaKey(); |
45 | 1203 int keyCode = event.keyCode(); |
1204 int charCode = event.charCode(); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1205 |
45 | 1206 Event keyEvent = new Event(); |
1207 keyEvent.widget = browser; | |
1208 if (DOMEVENT_KEYDOWN.equals(type)) { | |
1209 keyEvent.type = DWT.KeyDown; | |
1210 } else { | |
1211 keyEvent.type = DWT.KeyUp; | |
1212 } | |
1213 keyEvent.keyCode = translateKey(keyCode); | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1214 keyEvent.character = cast(char)charCode; |
45 | 1215 keyEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0); |
1216 browser.notifyListeners(keyEvent.type, keyEvent); | |
1217 if (!keyEvent.doit) { | |
1218 event.preventDefault(); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1219 } |
45 | 1220 return; |
1221 } | |
1222 | |
1223 if (DOMEVENT_MOUSEWHEEL.equals(type)) { | |
1224 DOMWheelEvent event = new DOMWheelEvent(evtId); | |
1225 int clientX = event.clientX(); | |
1226 int clientY = event.clientY(); | |
1227 int delta = event.wheelDelta(); | |
1228 bool ctrl = event.ctrlKey(); | |
1229 bool shift = event.shiftKey(); | |
1230 bool alt = event.altKey(); | |
1231 bool meta = event.metaKey(); | |
1232 Event mouseEvent = new Event(); | |
1233 mouseEvent.type = DWT.MouseWheel; | |
1234 mouseEvent.widget = browser; | |
1235 mouseEvent.x = clientX; mouseEvent.y = clientY; | |
1236 mouseEvent.count = delta / 120; | |
1237 mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0); | |
1238 browser.notifyListeners (mouseEvent.type, mouseEvent); | |
1239 return; | |
1240 } | |
1241 | |
1242 /* mouse event */ | |
1243 | |
1244 DOMMouseEvent event = new DOMMouseEvent(evtId); | |
1245 | |
1246 int clientX = event.clientX(); | |
1247 int clientY = event.clientY(); | |
1248 int detail = event.detail(); | |
1249 int button = event.button(); | |
1250 bool ctrl = event.ctrlKey(); | |
1251 bool shift = event.shiftKey(); | |
1252 bool alt = event.altKey(); | |
1253 bool meta = event.metaKey(); | |
1254 | |
1255 Event mouseEvent = new Event (); | |
1256 mouseEvent.widget = browser; | |
1257 mouseEvent.x = clientX; mouseEvent.y = clientY; | |
1258 mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0); | |
1259 if (DOMEVENT_MOUSEDOWN.equals (type)) { | |
1260 mouseEvent.type = DWT.MouseDown; | |
1261 mouseEvent.button = button + 1; | |
1262 mouseEvent.count = detail; | |
1263 } else if (DOMEVENT_MOUSEUP.equals (type)) { | |
1264 mouseEvent.type = DWT.MouseUp; | |
1265 mouseEvent.button = button + 1; | |
1266 mouseEvent.count = detail; | |
1267 switch (mouseEvent.button) { | |
1268 case 1: mouseEvent.stateMask |= DWT.BUTTON1; break; | |
1269 case 2: mouseEvent.stateMask |= DWT.BUTTON2; break; | |
1270 case 3: mouseEvent.stateMask |= DWT.BUTTON3; break; | |
1271 case 4: mouseEvent.stateMask |= DWT.BUTTON4; break; | |
1272 case 5: mouseEvent.stateMask |= DWT.BUTTON5; break; | |
126
38807a925e24
Fixed compile errors, support for SWT language files
Jacob Carlborg <doob@me.com>
parents:
125
diff
changeset
|
1273 default: |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1274 } |
45 | 1275 } else if (DOMEVENT_MOUSEMOVE.equals (type)) { |
1276 /* | |
1277 * Bug in Safari. Spurious and redundant mousemove events are received in | |
1278 * various contexts, including following every MouseUp. The workaround is | |
1279 * to not fire MouseMove events whose x and y values match the last MouseMove | |
1280 */ | |
1281 if (mouseEvent.x is lastMouseMoveX && mouseEvent.y is lastMouseMoveY) return; | |
1282 mouseEvent.type = DWT.MouseMove; | |
1283 lastMouseMoveX = mouseEvent.x; lastMouseMoveY = mouseEvent.y; | |
1284 } | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1285 |
45 | 1286 browser.notifyListeners (mouseEvent.type, mouseEvent); |
1287 if (detail is 2 && DOMEVENT_MOUSEDOWN.equals (type)) { | |
1288 mouseEvent = new Event (); | |
1289 mouseEvent.widget = browser; | |
1290 mouseEvent.x = clientX; mouseEvent.y = clientY; | |
1291 mouseEvent.stateMask = (alt ? DWT.ALT : 0) | (ctrl ? DWT.CTRL : 0) | (shift ? DWT.SHIFT : 0) | (meta ? DWT.COMMAND : 0); | |
1292 mouseEvent.type = DWT.MouseDoubleClick; | |
1293 mouseEvent.button = button + 1; | |
1294 mouseEvent.count = detail; | |
1295 browser.notifyListeners (mouseEvent.type, mouseEvent); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1296 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1297 } |
45 | 1298 } |