Mercurial > projects > dwt-linux
annotate dwt/browser/WindowCreator2.d @ 303:b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
author | John Reimer<terminal.node@gmail.com> |
---|---|
date | Wed, 13 Aug 2008 18:49:58 -0700 |
parents | bfe1c57259e3 |
children | c7c696cdfec2 |
rev | line source |
---|---|
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
1 /******************************************************************************* |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2003, 2007 IBM Corporation and others. |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
7 * |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
8 * Contributors: |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
10 * Port to the D programming language: |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
11 * John Reimer <terminal.node@gmail.com> |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
12 *******************************************************************************/ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
13 module dwt.browser.WindowCreator2; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
14 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
15 //import dwt.dwthelper.utils; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
16 |
286 | 17 import dwt.DWT; |
18 import dwt.graphics.Point; | |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
19 //import dwt.internal.C; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
20 import dwt.internal.Platform; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
21 import dwt.internal.mozilla.XPCOM; |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
22 //import dwt.internal.mozilla.XPCOMObject; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
23 import dwt.internal.mozilla.nsIBaseWindow; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
24 import dwt.internal.mozilla.nsID; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
25 import dwt.internal.mozilla.nsISupports; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
26 import dwt.internal.mozilla.nsIURI; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
27 import dwt.internal.mozilla.nsIWebBrowser; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
28 import dwt.internal.mozilla.nsIWebBrowserChrome; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
29 import dwt.internal.mozilla.nsIWindowCreator; |
286 | 30 import dwt.internal.mozilla.nsIWindowCreator2; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
31 import dwt.layout.FillLayout; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
32 import dwt.widgets.Shell; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
33 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
34 class WindowCreator2 : nsIWindowCreator2{ |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
35 // XPCOMObject supports; |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
36 // XPCOMObject windowCreator; |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
37 // XPCOMObject windowCreator2; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
38 int refCount = 0; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
39 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
40 this () { |
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
41 // createCOMInterfaces (); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
42 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
43 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
44 nsrefcnt AddRef () { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
45 refCount++; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
46 return refCount; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
47 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
48 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
49 nsresult QueryInterface (nsID* riid, void** ppvObject) { |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
50 if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE; |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
51 //nsID guid = new nsID (); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
52 //XPCOM.memmove (guid, riid, nsID.sizeof); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
53 |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
54 if (*riid == nsISupports.IID) { |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
55 *ppvObject = cast(void*)cast(nsISupports)this; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
56 AddRef (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
57 return XPCOM.NS_OK; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
58 } |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
59 if (*riid == nsIWindowCreator.IID) { |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
60 *ppvObject = cast(void*)cast(nsIWindowCreator)this; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
61 AddRef (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
62 return XPCOM.NS_OK; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
63 } |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
64 if (*riid == nsIWindowCreator2.IID) { |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
65 *ppvObject == cast(void*)cast(nsIWindowCreator2)this; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
66 AddRef (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
67 return XPCOM.NS_OK; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
68 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
69 |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
70 *ppvObject = null; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
71 return XPCOM.NS_ERROR_NO_INTERFACE; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
72 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
73 |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
74 nsresult Release () { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
75 refCount--; |
302
bfe1c57259e3
More browser code ported
John Reimer<terminal.node@gmail.com>
parents:
286
diff
changeset
|
76 //if (refCount is 0) disposeCOMInterfaces (); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
77 return refCount; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
78 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
79 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
80 /* nsIWindowCreator */ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
81 |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
82 nsresult CreateChromeWindow (nsIWebBrowserChrome parent, PRUint32 chromeFlags, nsIWebBrowserChrome* _retval) { |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
83 return CreateChromeWindow2 (parent, chromeFlags, 0, null, null, _retval); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
84 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
85 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
86 /* nsIWindowCreator2 */ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
87 |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
88 nsresult CreateChromeWindow2 (nsIWebBrowserChrome parent, PRUint32 chromeFlags, PRUint32 contextFlags, nsIURI uri, PRBool* cancel, nsIWebBrowserChrome* _retval) { |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
89 if (parent is null && (chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) is 0) { |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
90 return XPCOM.NS_ERROR_NOT_IMPLEMENTED; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
91 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
92 Browser src = null; |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
93 if (parent !is null) { |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
94 //nsIWebBrowserChrome browserChromeParent = new nsIWebBrowserChrome (parent); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
95 nsIWebBrowser webBrowser; |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
96 int rc = parent.GetWebBrowser (&webBrowser); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
97 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
98 if (webBrowser is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
99 |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
100 //nsIWebBrowser webBrowser = new nsIWebBrowser (aWebBrowser[0]); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
101 nsIBaseWindow baseWindow; |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
102 rc = webBrowser.QueryInterface (nsIBaseWindow.IID, cast(void**)&baseWindow); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
103 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
104 if (baseWindow is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
105 webBrowser.Release (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
106 |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
107 //nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
108 //result[0] = 0; |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
109 nativeWindow aParentNativeWindow; // nativeWindow is "void*" (represents GtkWidget*) |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
110 rc = baseWindow.GetParentNativeWindow (&aParentNativeWindow); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
111 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
112 if (aParentNativeWindow is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
113 baseWindow.Release (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
114 |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
115 src = Mozilla.findBrowser (aParentNativeWindow); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
116 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
117 final Browser browser; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
118 bool doit = true; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
119 if ((chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) !is 0) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
120 /* |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
121 * Mozilla will request a new Browser in a modal window in order to emulate a native |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
122 * dialog that is not available to it (eg.- a print dialog on Linux). For this |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
123 * reason modal requests are handled here so that the user is not exposed to them. |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
124 */ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
125 int style = DWT.DIALOG_TRIM; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
126 if ((chromeFlags & nsIWebBrowserChrome.CHROME_MODAL) !is 0) style |= DWT.APPLICATION_MODAL; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
127 final Shell shell = src is null ? |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
128 new Shell (style) : |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
129 new Shell (src.getShell(), style); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
130 shell.setLayout (new FillLayout ()); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
131 browser = new Browser (shell, src is null ? DWT.MOZILLA : src.getStyle () & DWT.MOZILLA); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
132 browser.addVisibilityWindowListener (new VisibilityWindowListener () { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
133 public void hide (WindowEvent event) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
134 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
135 public void show (WindowEvent event) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
136 if (event.location !is null) shell.setLocation (event.location); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
137 if (event.size !is null) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
138 Point size = event.size; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
139 shell.setSize (shell.computeSize (size.x, size.y)); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
140 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
141 shell.open (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
142 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
143 }); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
144 browser.addCloseWindowListener (new CloseWindowListener () { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
145 public void close (WindowEvent event) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
146 shell.close (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
147 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
148 }); |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
149 if (uri !is null) { |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
150 //nsIURI location = new nsIURI (uri); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
151 scope auto aSpec = new nsEmbedCString; |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
152 if (uri.GetSpec (cast(nsACString*)aSpec) is XPCOM.NS_OK) { |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
153 int span = aSpec.toString().length; |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
154 if (span > 0) { |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
155 //int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
156 // byte[] dest = new byte[length]; |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
157 //XPCOM.memmove (dest, buffer, length); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
158 browser.setUrl (aSpec.toString); |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
159 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
160 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
161 XPCOM.nsEmbedCString_delete (aSpec); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
162 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
163 } else { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
164 WindowEvent event = new WindowEvent (src); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
165 event.display = src.getDisplay (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
166 event.widget = src; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
167 event.required = true; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
168 for (int i = 0; i < src.webBrowser.openWindowListeners.length; i++) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
169 src.webBrowser.openWindowListeners[i].open (event); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
170 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
171 browser = event.browser; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
172 |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
173 /* Ensure that the Browser provided by the client is valid for use */ |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
174 doit = browser !is null && !browser.isDisposed (); |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
175 if (doit) { |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
176 String platform = Platform.PLATFORM; |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
177 bool isMozillaNativePlatform = platform == "gtk" || platform == "motif"; //$NON-NLS-1$ //$NON-NLS-2$ |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
178 doit = isMozillaNativePlatform || (browser.getStyle () & DWT.MOZILLA) !is 0; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
179 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
180 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
181 if (doit) { |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
182 // STRANGE but TRUE: browser.webBrowser is always instantiated as Mozilla (on this platform), |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
183 // so it can be cast back to the subclass Mozilla safely. Looks very dangerous, though... |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
184 // considering the next few lines of code that cast the Mozilla class to the interface, |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
185 // nsIWebBrowserChrome. |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
186 // This is an ugly D conversion hack because interfaces are implemented differently than |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
187 // in the Java SWT version. Watch this code section carefully for errors/bugs. -JJR |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
188 Mozilla mozilla = cast(Mozilla)browser.webBrowser; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
189 mozilla.isChild = true; |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
190 // And since Mozilla class implements the nsIWebBrowserChrome interface.... |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
191 nsIWebBrowserChrome chrome; |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
192 nsresult rc = mozilla.QueryInterface( nsIWebBrowserChrome.IID, cast(void**)&chrome); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
193 if (rc !is XPCOM.NS_OK) Mozilla.error (rc); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
194 //nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (chromePtr); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
195 chrome.SetChromeFlags (chromeFlags); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
196 //chrome.AddRef (); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
197 //XPCOM.memmove (_retval, new int /*long*/[] {chromePtr}, C.PTR_SIZEOF); |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
198 *_retval = chrome; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
199 } else { |
303
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
200 if (cancel !is null) { |
b72d84d1ba95
2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents:
302
diff
changeset
|
201 *cancel = 1; /* PRBool */ |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
202 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
203 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
204 return doit ? XPCOM.NS_OK : XPCOM.NS_ERROR_NOT_IMPLEMENTED; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
205 } |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
206 } |