Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 77174 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java (-3 / +29 lines)
Lines 729-734 Link Here
729
	return (state & PARENT_BACKGROUND) != 0 ? parent.findBackgroundControl () : null;
729
	return (state & PARENT_BACKGROUND) != 0 ? parent.findBackgroundControl () : null;
730
}
730
}
731
731
732
protected void fixChildren (Shell newShell, Shell oldShell) {
733
	oldShell.fixShell (newShell, this);
734
}
735
732
void fixFocus (Control focusControl) {
736
void fixFocus (Control focusControl) {
733
	Shell shell = getShell ();
737
	Shell shell = getShell ();
734
	Control control = this;
738
	Control control = this;
Lines 837-843 Link Here
837
	return control.getBackgroundColor ();
841
	return control.getBackgroundColor ();
838
}
842
}
839
843
840
Color getBackgroundColor () {
844
protected Color getBackgroundColor () {
841
	return background != null ? Color.carbon_new (display, background) : defaultBackground ();
845
	return background != null ? Color.carbon_new (display, background) : defaultBackground ();
842
}
846
}
843
847
Lines 1544-1550 Link Here
1544
 */
1548
 */
1545
public boolean isReparentable () {
1549
public boolean isReparentable () {
1546
	checkWidget();
1550
	checkWidget();
1547
	return false;
1551
	return true;
1548
}
1552
}
1549
1553
1550
boolean isShowing () {
1554
boolean isShowing () {
Lines 3010-3017 Link Here
3010
 */
3014
 */
3011
public boolean setParent (Composite parent) {
3015
public boolean setParent (Composite parent) {
3012
	checkWidget();
3016
	checkWidget();
3017
	
3018
	if (parent == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
3013
	if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
3019
	if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
3014
	return false;
3020
	if (this.parent == parent) return true;
3021
	if (!isReparentable ()) return false;
3022
	
3023
	releaseParent ();
3024
	
3025
	Shell newShell = parent.getShell (), oldShell = this.parent.getShell ();
3026
	
3027
	
3028
	
3029
	int topHandle = topHandle ();
3030
	
3031
	if (OS.EmbedControl(topHandle, parent.topHandle ()) < 0) return false;
3032
	
3033
	if (oldShell != newShell)
3034
		fixChildren (newShell, oldShell);
3035
	
3036
	this.parent = parent;
3037
		
3038
	setVisible (topHandle, true);
3039
3040
	return true;
3015
}
3041
}
3016
3042
3017
/**
3043
/**
(-)Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java (+8 lines)
Lines 298-303 Link Here
298
	return layoutCount > 0 ? this : parent.findDeferredControl ();
298
	return layoutCount > 0 ? this : parent.findDeferredControl ();
299
}
299
}
300
300
301
protected void fixChildren (Shell newShell, Shell oldShell) {
302
	super.fixChildren (newShell, oldShell);
303
	Control [] children = _getChildren ();
304
	for (int i=0; i<children.length; i++) {
305
		children [i].fixChildren (newShell, oldShell);
306
	}
307
}
308
301
void fixTabList (Control control) {
309
void fixTabList (Control control) {
302
	if (tabList == null) return;
310
	if (tabList == null) return;
303
	int count = 0;
311
	int count = 0;
(-)Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java (-1 / +7 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.swt.widgets;
11
package org.eclipse.swt.widgets;
12
12
13
14
import org.eclipse.swt.internal.carbon.OS;
13
import org.eclipse.swt.internal.carbon.OS;
15
import org.eclipse.swt.internal.carbon.Rect;
14
import org.eclipse.swt.internal.carbon.Rect;
16
import org.eclipse.swt.internal.carbon.CGPoint;
15
import org.eclipse.swt.internal.carbon.CGPoint;
Lines 626-631 Link Here
626
	return layoutCount > 0 ? this : null;
625
	return layoutCount > 0 ? this : null;
627
}
626
}
628
627
628
void fixShell (Shell newShell, Control control) {
629
	if (this == newShell) return;
630
	if (control == lastActive) setActiveControl (null);
631
	if (control == savedFocus) setSavedFocus(null);
632
	if (control == defaultButton) setDefaultButton(null);
633
}
634
629
Cursor findCursor () {
635
Cursor findCursor () {
630
	return cursor;
636
	return cursor;
631
}
637
}
(-)Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java (+6 lines)
Lines 109-114 Link Here
109
	webBrowser.create (parent, style);
109
	webBrowser.create (parent, style);
110
}
110
}
111
111
112
public void fixChildren(Shell newShell, Shell oldShell)
113
{
114
	super.fixChildren(newShell, oldShell);
115
	webBrowser.fixParent();
116
}
117
112
static Composite checkParent (Composite parent) {
118
static Composite checkParent (Composite parent) {
113
	String platform = SWT.getPlatform ();
119
	String platform = SWT.getPlatform ();
114
	if (!"gtk".equals (platform)) return parent; //$NON-NLS-1$
120
	if (!"gtk".equals (platform)) return parent; //$NON-NLS-1$
(-)Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java (+4 lines)
Lines 85-90 Link Here
85
85
86
public abstract boolean execute(String script);
86
public abstract boolean execute(String script);
87
87
88
void fixParent() {
89
	
90
}
91
88
public abstract boolean forward();
92
public abstract boolean forward();
89
93
90
public abstract String getUrl();
94
public abstract String getUrl();
(-)Eclipse SWT Browser/carbon/org/eclipse/swt/browser/Safari.java (-7 / +61 lines)
Lines 41-46 Link Here
41
	Point location;
41
	Point location;
42
	Point size;
42
	Point size;
43
	boolean statusBar = true, toolBar = true, ignoreDispose;
43
	boolean statusBar = true, toolBar = true, ignoreDispose;
44
	
45
	//Keep the state around so we can use it for reparenting fixup
46
	private Listener listener;
47
	private Control oldBrowserParent; 
48
	private Shell oldBrowserShell;
49
	
44
	//TEMPORARY CODE
50
	//TEMPORARY CODE
45
//	boolean doit;
51
//	boolean doit;
46
52
Lines 154-160 Link Here
154
	
160
	
155
	final int notificationCenter = Cocoa.objc_msgSend(Cocoa.C_NSNotificationCenter, Cocoa.S_defaultCenter);
161
	final int notificationCenter = Cocoa.objc_msgSend(Cocoa.C_NSNotificationCenter, Cocoa.S_defaultCenter);
156
162
157
	Listener listener = new Listener() {
163
	listener = new Listener() {
158
		public void handleEvent(Event e) {
164
		public void handleEvent(Event e) {
159
			switch (e.type) {
165
			switch (e.type) {
160
				case SWT.Dispose: {
166
				case SWT.Dispose: {
Lines 278-293 Link Here
278
	};
284
	};
279
	browser.addListener(SWT.Dispose, listener);
285
	browser.addListener(SWT.Dispose, listener);
280
	browser.addListener(SWT.Resize, listener);
286
	browser.addListener(SWT.Resize, listener);
287
	browser.addListener(SWT.Show, listener);
288
	browser.addListener(SWT.Hide, listener);
289
	
281
	Shell shell = browser.getShell();
290
	Shell shell = browser.getShell();
282
	shell.addListener(SWT.Resize, listener);
291
	shell.addListener(SWT.Resize, listener);
283
	shell.addListener(SWT.Show, listener);
292
	shell.addListener(SWT.Show, listener);
284
	shell.addListener(SWT.Hide, listener);
293
	shell.addListener(SWT.Hide, listener);
285
	Control c = browser;
294
	
286
	do {
295
	addListenerToBrowserParents();
287
		c.addListener(SWT.Show, listener);
288
		c.addListener(SWT.Hide, listener);
289
		c = c.getParent();
290
	} while (c != shell);
291
	
296
	
292
	if (Callback3 == null) Callback3 = new Callback(this.getClass(), "eventProc3", 3); //$NON-NLS-1$
297
	if (Callback3 == null) Callback3 = new Callback(this.getClass(), "eventProc3", 3); //$NON-NLS-1$
293
	int callback3Address = Callback3.getAddress();
298
	int callback3Address = Callback3.getAddress();
Lines 345-350 Link Here
345
	return 0;
350
	return 0;
346
}
351
}
347
352
353
private void addListenerToBrowserParents()
354
{
355
	Shell shell = browser.getShell();
356
	Control c = browser.getParent();
357
	
358
	oldBrowserShell = shell;
359
	oldBrowserParent = c;
360
	
361
	while(c != shell) {
362
		c.addListener(SWT.Show, listener);
363
		c.addListener(SWT.Hide, listener);
364
		c = c.getParent();
365
	}
366
}
367
348
public boolean back() {
368
public boolean back() {
349
	html = null;
369
	html = null;
350
	int webView = Cocoa.HIWebViewGetWebView(webViewHandle);
370
	int webView = Cocoa.HIWebViewGetWebView(webViewHandle);
Lines 363-368 Link Here
363
	return value != 0;
383
	return value != 0;
364
}
384
}
365
385
386
//Since Safari is separately embedded, we need to reparent it separately
387
void fixParent() {
388
	//At this point the browser has already been updated
389
	int window = OS.GetControlOwner(browser.handle);
390
	int[] contentView = new int[1];
391
	OS.HIViewFindByID(OS.HIViewGetRoot(window), OS.kHIViewWindowContentID(), contentView);
392
	//Remove the view from its old parent
393
	OS.HIViewRemoveFromSuperview(webViewHandle);
394
	OS.HIViewAddSubview(contentView[0], webViewHandle);
395
	
396
	//Fix up the listeners
397
	removeListenerFromOldBrowserParents();
398
	addListenerToBrowserParents();
399
}
400
366
public boolean forward() {
401
public boolean forward() {
367
	html = null;
402
	html = null;
368
	int webView = Cocoa.HIWebViewGetWebView(webViewHandle);
403
	int webView = Cocoa.HIWebViewGetWebView(webViewHandle);
Lines 490-495 Link Here
490
	Cocoa.objc_msgSend(webView, Cocoa.S_reload, 0);
525
	Cocoa.objc_msgSend(webView, Cocoa.S_reload, 0);
491
}
526
}
492
527
528
private void removeListenerFromOldBrowserParents()
529
{
530
	Control c = oldBrowserParent;
531
	Shell shell = oldBrowserShell;
532
	
533
	oldBrowserParent = null;
534
	oldBrowserShell = null;
535
	
536
	if (c == null || shell == null) {
537
		return;
538
	}
539
	
540
	while(c != shell) {
541
		c.removeListener(SWT.Show, listener);
542
		c.removeListener(SWT.Hide, listener);
543
		c = c.getParent();
544
	}
545
}
546
493
public boolean setText(String html) {
547
public boolean setText(String html) {
494
	/*
548
	/*
495
	* Bug in Safari.  The web view segment faults in some circunstances
549
	* Bug in Safari.  The web view segment faults in some circunstances

Return to bug 77174