annotate dwt/browser/WindowCreator2.d @ 305:c7c696cdfec2

Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
author John Reimer<terminal.node@gmail.com>
date Sat, 16 Aug 2008 22:53:35 -0700
parents b72d84d1ba95
children 3f4a5c7d138f
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;
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
44258e0b6687 More fixes for xpcom
John Reimer<terminal.node@gmail.com>
parents: 278
diff changeset
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 }
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
117 Browser browser;
278
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;
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
127 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
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);
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
132 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
133 Shell sh;
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
134 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
135 public void hide (WindowEvent event) {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
136 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
137 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
138 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
139 if (event.size !is null) {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
140 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
141 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
142 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
143 shell.open ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
144 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
145 });
305
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
146 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
147 Shell sh;
c7c696cdfec2 Mozilla module progress; fixes to other browser modules; update XPCOM interfaces
John Reimer<terminal.node@gmail.com>
parents: 303
diff changeset
148 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
149 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
150 sh.close ();
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
151 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
152 });
303
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
153 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
154 //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
155 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
156 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
157 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
158 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
159 //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
160 // 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
161 //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
162 browser.setUrl (aSpec.toString);
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
163 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
164 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
165 XPCOM.nsEmbedCString_delete (aSpec);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
166 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
167 } else {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
168 WindowEvent event = new WindowEvent (src);
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
169 event.display = src.getDisplay ();
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
170 event.widget = src;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
171 event.required = true;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
172 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
173 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
174 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
175 browser = event.browser;
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
176
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
177 /* 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
178 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
179 if (doit) {
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
180 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
181 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
182 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
183 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
184 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
185 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
186 // 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
187 // 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
188 // 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
189 // nsIWebBrowserChrome.
b72d84d1ba95 2 of 3 remaining modules to port before cyclical cleanup phase begins
John Reimer<terminal.node@gmail.com>
parents: 302
diff changeset
190 // 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
191 // 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
192 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
193 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
194 // 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
195 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
196 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
197 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
198 //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
199 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
200 //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
201 //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
202 *_retval = chrome;
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
203 } 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
204 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
205 *cancel = 1; /* PRBool */
278
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
206 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
207 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
208 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
209 }
93409d9838c5 Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
210 }