annotate dwt/browser/WindowCreator2.d @ 340:3f4a5c7d138f

Fixes
author John Reimer <terminal.node@gmail.com>
date Sun, 26 Oct 2008 08:09:00 -0700
parents c7c696cdfec2
children 2e591eb01162
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
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
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;
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;
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
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
25 //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
26 import dwt.internal.mozilla.nsIBaseWindow;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
27 import dwt.internal.mozilla.nsID;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
28 import dwt.internal.mozilla.nsISupports;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
29 import dwt.internal.mozilla.nsIURI;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
30 import dwt.internal.mozilla.nsIWebBrowser;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
31 import dwt.internal.mozilla.nsIWebBrowserChrome;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
32 import dwt.internal.mozilla.nsIWindowCreator;
286
44258e0b6687 More fixes for xpcom
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
33 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
34 import dwt.layout.FillLayout;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
35 import dwt.widgets.Shell;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
36
340
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
37 import dwt.browser.Browser;
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
38 import dwt.browser.Mozilla;
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
39
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
40 class WindowCreator2 : nsIWindowCreator2 {
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
41 // XPCOMObject supports;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
42 // XPCOMObject windowCreator;
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
43 // XPCOMObject windowCreator2;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
44 int refCount = 0;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
45
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
46 this () {
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
47 // createCOMInterfaces ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
48 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
49
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
50 nsrefcnt AddRef () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
51 refCount++;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
52 return refCount;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
53 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
54
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
55 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
56 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
57 //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
58 //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
59
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
60 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
61 *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
62 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
63 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
64 }
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
65 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
66 *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
67 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
68 return XPCOM.NS_OK;
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 if (*riid == nsIWindowCreator2.IID) {
340
John Reimer <terminal.node@gmail.com>
parents: 305
diff changeset
71 *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
72 AddRef ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
73 return XPCOM.NS_OK;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
74 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
75
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
76 *ppvObject = null;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
77 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
78 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
79
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
80 nsresult Release () {
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
81 refCount--;
302
bfe1c57259e3 More browser code ported
John Reimer<terminal.node@gmail.com>
parents: 286
diff changeset
82 //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
83 return refCount;
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 /* nsIWindowCreator */
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 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
89 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
90 }
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 /* nsIWindowCreator2 */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
93
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
94 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
95 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
96 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
97 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
98 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
99 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
100 //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
101 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
102 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
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 (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
105
303
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 = 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
107 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
108 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
109 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
110 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
111 webBrowser.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
112
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
113 //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
114 //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
115 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
116 rc = baseWindow.GetParentNativeWindow (&aParentNativeWindow);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
117 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
118 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
119 baseWindow.Release ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
120
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
121 src = Mozilla.findBrowser (aParentNativeWindow);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
122 }
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
123 Browser browser;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
124 bool doit = true;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
125 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
126 /*
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
127 * 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
128 * 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
129 * 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
130 */
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
131 int style = DWT.DIALOG_TRIM;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
132 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
133 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
134 new Shell (style) :
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
135 new Shell (src.getShell(), style);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
136 shell.setLayout (new FillLayout ());
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
137 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
138 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
139 Shell sh;
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
140 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
141 public void hide (WindowEvent event) {
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 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
144 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
145 if (event.size !is null) {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
146 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
147 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
148 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
149 shell.open ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
150 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
151 });
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
152 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
153 Shell sh;
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
154 this (Shell shell) { this.shell = shell; }
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
155 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
156 sh.close ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
157 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
158 });
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
159 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
160 //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
161 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
162 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
163 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
164 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
165 //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
166 // 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
167 //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
168 browser.setUrl (aSpec.toString);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
169 }
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 XPCOM.nsEmbedCString_delete (aSpec);
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 } else {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
174 WindowEvent event = new WindowEvent (src);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
175 event.display = src.getDisplay ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
176 event.widget = src;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
177 event.required = true;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
178 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
179 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
180 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
181 browser = event.browser;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
182
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
183 /* 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
184 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
185 if (doit) {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
186 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
187 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
188 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
189 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
190 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
191 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
192 // 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
193 // 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
194 // 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
195 // nsIWebBrowserChrome.
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
196 // 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
197 // 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
198 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
199 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
200 // 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
201 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
202 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
203 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
204 //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
205 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
206 //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
207 //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
208 *_retval = chrome;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
209 } 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
210 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
211 *cancel = 1; /* PRBool */
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
212 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
213 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
214 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
215 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
216 }