annotate dwt/browser.old/WindowCreator2.d @ 288:4ee8c4237614

old branches... commit by mistake
author John Reimer<terminal.node@gmail.com>
date Tue, 05 Aug 2008 18:00:50 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
288
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
1 /*******************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2003, 2007 IBM Corporation and others.
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
7 *
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
8 * Contributors:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
10 * Port to the D programming language:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
11 * John Reimer <terminal.node@gmail.com>
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
12 *******************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
13 module dwt.browser.WindowCreator2;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
14
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
15 import dwt.dwthelper.utils;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
16
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
17 import dwt.internal.Platform;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
18
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
19 import dwt.internal.mozilla.XPCOM;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
20 import dwt.internal.mozilla.nsIBaseWindow;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
21 import dwt.internal.mozilla.nsID;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
22 import dwt.internal.mozilla.nsISupports;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
23 import dwt.internal.mozilla.nsIURI;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
24 import dwt.internal.mozilla.nsIWebBrowser;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
25 import dwt.internal.mozilla.nsIWebBrowserChrome;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
26 import dwt.internal.mozilla.nsIWindowCreator;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
27
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
28 import dwt.DWT;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
29 import dwt.graphics.Point;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
30 import dwt.layout.FillLayout;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
31 import dwt.widgets.Shell;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
32
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
33 class WindowCreator2 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
34 XPCOMObject supports;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
35 XPCOMObject windowCreator;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
36 XPCOMObject windowCreator2;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
37 int refCount = 0;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
38
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
39 WindowCreator2 () {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
40 createCOMInterfaces ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
41 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
42
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
43 int AddRef () {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
44 refCount++;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
45 return refCount;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
46 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
47
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
48 void createCOMInterfaces () {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
49 /* Create each of the interfaces that this object implements */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
50 supports = new XPCOMObject (new int[] {2, 0, 0}) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
51 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
52 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
53 public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
54 };
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
55
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
56 windowCreator = new XPCOMObject (new int[] {2, 0, 0, 3}) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
57 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
58 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
59 public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
60 public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
61 };
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
62
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
63 windowCreator2 = new XPCOMObject (new int[] {2, 0, 0, 3, 6}) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
64 public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
65 public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
66 public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
67 public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
68 public int /*long*/ method4 (int /*long*/[] args) {return CreateChromeWindow2 (args[0], (int)/*64*/args[1], (int)/*64*/args[2], args[3], args[4], args[5]);}
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
69 };
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
70 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
71
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
72 void disposeCOMInterfaces () {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
73 if (supports !is null) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
74 supports.dispose ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
75 supports = null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
76 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
77 if (windowCreator !is null) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
78 windowCreator.dispose ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
79 windowCreator = null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
80 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
81
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
82 if (windowCreator2 !is null) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
83 windowCreator2.dispose ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
84 windowCreator2 = null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
85 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
86 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
87
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
88 int /*long*/ getAddress () {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
89 return windowCreator.getAddress ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
90 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
91
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
92 int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
93 if (riid is 0 || ppvObject is 0) return XPCOM.NS_ERROR_NO_INTERFACE;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
94 nsID guid = new nsID ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
95 XPCOM.memmove (guid, riid, nsID.sizeof);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
96
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
97 if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
98 XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
99 AddRef ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
100 return XPCOM.NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
101 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
102 if (guid.Equals (nsIWindowCreator.NS_IWINDOWCREATOR_IID)) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
103 XPCOM.memmove (ppvObject, new int /*long*/[] {windowCreator.getAddress ()}, C.PTR_SIZEOF);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
104 AddRef ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
105 return XPCOM.NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
106 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
107 if (guid.Equals (nsIWindowCreator2.NS_IWINDOWCREATOR2_IID)) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
108 XPCOM.memmove (ppvObject, new int /*long*/[] {windowCreator2.getAddress ()}, C.PTR_SIZEOF);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
109 AddRef ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
110 return XPCOM.NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
111 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
112
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
113 XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
114 return XPCOM.NS_ERROR_NO_INTERFACE;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
115 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
116
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
117 int Release () {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
118 refCount--;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
119 if (refCount is 0) disposeCOMInterfaces ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
120 return refCount;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
121 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
122
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
123 /* nsIWindowCreator */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
124
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
125 int CreateChromeWindow (int /*long*/ parent, int chromeFlags, int /*long*/ _retval) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
126 return CreateChromeWindow2 (parent, chromeFlags, 0, 0, 0, _retval);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
127 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
128
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
129 /* nsIWindowCreator2 */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
130
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
131 int CreateChromeWindow2 (int /*long*/ parent, int chromeFlags, int contextFlags, int /*long*/ uri, int /*long*/ cancel, int /*long*/ _retval) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
132 if (parent is 0 && (chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) is 0) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
133 return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
134 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
135 Browser src = null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
136 if (parent !is 0) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
137 nsIWebBrowserChrome browserChromeParent = new nsIWebBrowserChrome (parent);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
138 int /*long*/[] aWebBrowser = new int /*long*/[1];
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
139 int rc = browserChromeParent.GetWebBrowser (aWebBrowser);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
140 if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
141 if (aWebBrowser[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
142
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
143 nsIWebBrowser webBrowser = new nsIWebBrowser (aWebBrowser[0]);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
144 int /*long*/[] result = new int /*long*/[1];
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
145 rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
146 if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
147 if (result[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
148 webBrowser.Release ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
149
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
150 nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
151 result[0] = 0;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
152 int /*long*/[] aParentNativeWindow = new int /*long*/[1];
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
153 rc = baseWindow.GetParentNativeWindow (aParentNativeWindow);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
154 if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
155 if (aParentNativeWindow[0] is 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
156 baseWindow.Release ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
157
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
158 src = Mozilla.findBrowser (aParentNativeWindow[0]);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
159 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
160 final Browser browser;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
161 bool doit = true;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
162 if ((chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) !is 0) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
163 /*
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
164 * Mozilla will request a new Browser in a modal window in order to emulate a native
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
165 * dialog that is not available to it (eg.- a print dialog on Linux). For this
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
166 * reason modal requests are handled here so that the user is not exposed to them.
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
167 */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
168 int style = DWT.DIALOG_TRIM;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
169 if ((chromeFlags & nsIWebBrowserChrome.CHROME_MODAL) !is 0) style |= DWT.APPLICATION_MODAL;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
170 final Shell shell = src is null ?
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
171 new Shell (style) :
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
172 new Shell (src.getShell(), style);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
173 shell.setLayout (new FillLayout ());
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
174 browser = new Browser (shell, src is null ? DWT.MOZILLA : src.getStyle () & DWT.MOZILLA);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
175 browser.addVisibilityWindowListener (new VisibilityWindowListener () {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
176 public void hide (WindowEvent event) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
177 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
178 public void show (WindowEvent event) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
179 if (event.location !is null) shell.setLocation (event.location);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
180 if (event.size !is null) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
181 Point size = event.size;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
182 shell.setSize (shell.computeSize (size.x, size.y));
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
183 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
184 shell.open ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
185 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
186 });
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
187 browser.addCloseWindowListener (new CloseWindowListener () {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
188 public void close (WindowEvent event) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
189 shell.close ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
190 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
191 });
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
192 if (uri !is 0) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
193 nsIURI location = new nsIURI (uri);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
194 int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
195 if (location.GetSpec (aSpec) is XPCOM.NS_OK) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
196 int length = XPCOM.nsEmbedCString_Length (aSpec);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
197 if (length > 0) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
198 int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
199 byte[] dest = new byte[length];
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
200 XPCOM.memmove (dest, buffer, length);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
201 browser.setUrl (new String (dest));
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
202 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
203 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
204 XPCOM.nsEmbedCString_delete (aSpec);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
205 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
206 } else {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
207 WindowEvent event = new WindowEvent (src);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
208 event.display = src.getDisplay ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
209 event.widget = src;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
210 event.required = true;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
211 for (int i = 0; i < src.webBrowser.openWindowListeners.length; i++) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
212 src.webBrowser.openWindowListeners[i].open (event);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
213 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
214 browser = event.browser;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
215
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
216 /* Ensure that the Browser provided by the client is valid for use */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
217 doit = browser !is null && !browser.isDisposed ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
218 if (doit) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
219 String platform = Platform.PLATFORM;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
220 bool isMozillaNativePlatform = platform.equals ("gtk") || platform.equals ("motif"); //$NON-NLS-1$ //$NON-NLS-2$
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
221 doit = isMozillaNativePlatform || (browser.getStyle () & DWT.MOZILLA) !is 0;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
222 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
223 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
224 if (doit) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
225 Mozilla mozilla = (Mozilla)browser.webBrowser;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
226 mozilla.isChild = true;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
227 int /*long*/ chromePtr = mozilla.webBrowserChrome.getAddress ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
228 nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (chromePtr);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
229 webBrowserChrome.SetChromeFlags (chromeFlags);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
230 webBrowserChrome.AddRef ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
231 XPCOM.memmove (_retval, new int /*long*/[] {chromePtr}, C.PTR_SIZEOF);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
232 } else {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
233 if (cancel !is 0) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
234 C.memmove (cancel, new int[] {1}, 4); /* PRBool */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
235 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
236 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
237 return doit ? XPCOM.NS_OK : XPCOM.NS_ERROR_NOT_IMPLEMENTED;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
238 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
239 }