annotate dwt/browser/WindowCreator2.d @ 348:9a4d7706df52

Test Update to fix linux XPCOM interface issues
author John Reimer <terminal.node@gmail.com>
date Fri, 31 Oct 2008 21:46:44 -0700
parents 2e591eb01162
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
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
44258e0b6687 More fixes for xpcom
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
17 import dwt.DWT;
44258e0b6687 More fixes for xpcom
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
18 import dwt.graphics.Point;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
19
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;
340
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
21 import dwt.internal.mozilla.Common;
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
22
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
23 import XPCOM = dwt.internal.mozilla.XPCOM;
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
24
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
25 import dwt.internal.mozilla.nsIBaseWindow;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
26 import dwt.internal.mozilla.nsID;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
27 import dwt.internal.mozilla.nsISupports;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
28 import dwt.internal.mozilla.nsIURI;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
29 import dwt.internal.mozilla.nsIWebBrowser;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
30 import dwt.internal.mozilla.nsIWebBrowserChrome;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
31 import dwt.internal.mozilla.nsIWindowCreator;
286
44258e0b6687 More fixes for xpcom
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
32 import dwt.internal.mozilla.nsIWindowCreator2;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
33 import dwt.internal.mozilla.nsStringAPI;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
34 import dwt.internal.mozilla.nsEmbedString;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
35
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
36 import dwt.layout.FillLayout;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
37 import dwt.widgets.Shell;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
38
340
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
39 import dwt.browser.Browser;
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
40 import dwt.browser.Mozilla;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
41 import dwt.browser.VisibilityWindowListener;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
42 import dwt.browser.CloseWindowListener;
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
43 import dwt.browser.WindowEvent;
340
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
44
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
45 class WindowCreator2 : nsIWindowCreator2 {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
46 int refCount = 0;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
47
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
48 this () {}
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
49
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
50 extern(System)
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
51 nsrefcnt AddRef () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
52 refCount++;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
53 return refCount;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
54 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
55
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
56 extern(System)
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
57 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
58 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
59 //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
60 //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
61
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
62 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
63 *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
64 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
65 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
66 }
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
67 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
68 *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
69 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
70 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
71 }
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
72 if (*riid == nsIWindowCreator2.IID) {
340
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
73 *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
74 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
75 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
76 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
77
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
78 *ppvObject = null;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
79 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
80 }
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
81
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
82 extern(System)
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
83 nsresult Release () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
84 refCount--;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
85 //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
86 return refCount;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
87 }
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
88
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
89 /* nsIWindowCreator */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
90
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
91 extern(System)
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
92 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
93 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
94 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
95
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
96 /* nsIWindowCreator2 */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
97
348
9a4d7706df52 Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents: 346
diff changeset
98 extern(System)
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
99 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
100 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
101 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
102 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
103 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
104 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
105 //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
106 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
107 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
108 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
109 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
110
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
111 //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
112 nsIBaseWindow baseWindow;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
113 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
114 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
115 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
116 webBrowser.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
117
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
118 //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
119 //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
120 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
121 rc = baseWindow.GetParentNativeWindow (&aParentNativeWindow);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
122 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
123 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
124 baseWindow.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
125
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
126 src = Mozilla.findBrowser (aParentNativeWindow);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
127 }
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
128 Browser browser;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
129 bool doit = true;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
130 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
131 /*
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
132 * 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
133 * 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
134 * 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
135 */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
136 int style = DWT.DIALOG_TRIM;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
137 if ((chromeFlags & nsIWebBrowserChrome.CHROME_MODAL) !is 0) style |= DWT.APPLICATION_MODAL;
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
138 Shell shell = src is null ?
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
139 new Shell (style) :
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
140 new Shell (src.getShell(), style);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
141 shell.setLayout (new FillLayout ());
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
142 browser = new Browser (shell, src is null ? DWT.MOZILLA : src.getStyle () & DWT.MOZILLA);
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
143 browser.addVisibilityWindowListener (new class(shell) VisibilityWindowListener {
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
144 Shell sh;
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
145 this (Shell shell) { this.sh = shell; }
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
146 public void hide (WindowEvent event) {
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 public void show (WindowEvent event) {
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
149 if (event.location !is null) sh.setLocation (event.location);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
150 if (event.size !is null) {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
151 Point size = event.size;
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
152 sh.setSize (sh.computeSize (size.x, size.y));
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
153 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
154 shell.open ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
155 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
156 });
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
157 browser.addCloseWindowListener (new class(shell) CloseWindowListener {
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
158 Shell sh;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
159 this (Shell shell) { this.sh = shell; }
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
160 public void close (WindowEvent event) {
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
161 sh.close ();
278
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 });
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
164 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
165 //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
166 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
167 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
168 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
169 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
170 //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
171 // 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
172 //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
173 browser.setUrl (aSpec.toString);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
174 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
175 }
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
176 //XPCOM.nsEmbedCString_delete (aSpec);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
177 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
178 } else {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
179 WindowEvent event = new WindowEvent (src);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
180 event.display = src.getDisplay ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
181 event.widget = src;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
182 event.required = true;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
183 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
184 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
185 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
186 browser = event.browser;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
187
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
188 /* 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
189 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
190 if (doit) {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
191 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
192 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
193 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
194 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
195 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
196 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
197 // 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
198 // 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
199 // 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
200 // nsIWebBrowserChrome.
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
201 // 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
202 // 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
203 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
204 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
205 // 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
206 nsIWebBrowserChrome chrome;
346
2e591eb01162 Browser Package now compiles (phase 2 complete)
John Reimer <terminal.node@gmail.com>
parents: 340
diff changeset
207 nsresult rc = mozilla.QueryInterface( &nsIWebBrowserChrome.IID, cast(void**)&chrome);
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
208 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
209 //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
210 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
211 //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
212 //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
213 *_retval = chrome;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
214 } 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
215 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
216 *cancel = 1; /* PRBool */
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
217 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
218 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
219 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
220 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
221 }