e.display.update();
public Browser(Composite parent, int style) {	super(parent, style);	/*	* Note.  Loading the webkit bundle on Jaguar causes a crash.	* The workaround is to detect any OS prior to 10.30 and fail	* without crashing.	*/	int[] response = new int[1];	int err = OS.Gestalt(OS.gestaltSystemVersion, response);	if (err != OS.noErr || ((response[0] & 0xffff) < 0x1030)) {		dispose();		SWT.error(SWT.ERROR_NO_HANDLES);	}	int outControl[] = new int[1];	try {		WebKit.HIWebViewCreate(outControl);	} catch (UnsatisfiedLinkError e) {		dispose();		SWT.error(SWT.ERROR_NO_HANDLES);	}	webViewHandle = outControl[0];	if (webViewHandle == 0) {		dispose();		SWT.error(SWT.ERROR_NO_HANDLES);			}	Display display = getDisplay();	display.setData(ADD_WIDGET_KEY, new Object[] {new Integer(webViewHandle), this});		/*	* Bug in Safari.  For some reason, every application must contain	* a visible window that has never had a WebView or mouse move events	* are not delivered.  This seems to happen after a browser has been	* either hidden or disposed in any window.  The fix is to create a	* single transparent overlay window that is disposed when the display	* is disposed.	*/	if (display.getData(BROWSER_WINDOW) == null) {		Rect bounds = new Rect ();		OS.SetRect (bounds, (short) 0, (short) 0, (short) 1, (short) 1);		final int[] outWindow = new int[1];		OS.CreateNewWindow(OS.kOverlayWindowClass, 0, bounds, outWindow);		OS.ShowWindow(outWindow[0]);		display.disposeExec(new Runnable() {			public void run() {				if (outWindow[0] != 0) {					OS.DisposeWindow(outWindow[0]);				}				outWindow[0] = 0;			}		});		display.setData(BROWSER_WINDOW, outWindow);	}		/*	 * Bug in Safari. The WebView does not receive mouse and key events when it is added	 * to a visible top window.  It is assumed that Safari hooks its own event listener	 * when the top window emits the kEventWindowShown event. The workaround is to send a	 * fake kEventWindowShown event to the top window after the WebView has been added	 * to the HIView (after the top window is visible) to give Safari a chance to hook	 * events.	 */	OS.HIViewAddSubview(handle, webViewHandle);	OS.HIViewSetVisible(webViewHandle, true);		if (getShell().isVisible()) {		int[] showEvent = new int[1];		OS.CreateEvent(0, OS.kEventClassWindow, OS.kEventWindowShown, 0.0, OS.kEventAttributeUserEvent, showEvent);		OS.SetEventParameter(showEvent[0], OS.kEventParamDirectObject, OS.typeWindowRef, 4, new int[] {OS.GetControlOwner(handle)});		OS.SendEventToEventTarget(showEvent[0], OS.GetWindowEventTarget(OS.GetControlOwner(handle)));		if (showEvent[0] != 0) OS.ReleaseEvent(showEvent[0]);	}	final int webView = WebKit.HIWebViewGetWebView(webViewHandle);	/*	* This code is intentionally commented. Setting a group name is the right thing	* to do in order to avoid multiple open window requests. For some reason, Safari	* crashes when requested to reopen the same window if that window was previously	* closed. This may be because that window was not correctly closed. 	*/	//	String groupName = "MyDocument"; //$NON-NLS-1$//	int length = groupName.length();//	char[] buffer = new char[length];//	groupName.getChars(0, length, buffer, 0);//	int groupNameString = OS.CFStringCreateWithCharacters(0, buffer, length);//	// [webView setGroupName:@"MyDocument"];//	WebKit.objc_msgSend(webView, WebKit.S_setGroupName, groupNameString);//	OS.CFRelease(groupNameString);		final int notificationCenter = WebKit.objc_msgSend(WebKit.C_NSNotificationCenter, WebKit.S_defaultCenter);	Listener listener = new Listener() {		public void handleEvent(Event e) {			switch (e.type) {				case SWT.Dispose: {					Shell shell = getShell();					shell.removeListener(SWT.Resize, this);					shell.removeListener(SWT.Show, this);					shell.removeListener(SWT.Hide, this);					Control c = Browser.this;					do {						c.removeListener(SWT.Show, this);						c.removeListener(SWT.Hide, this);						c = c.getParent();					} while (c != shell);										e.display.setData(ADD_WIDGET_KEY, new Object[] {new Integer(webViewHandle), null});					WebKit.objc_msgSend(webView, WebKit.S_setFrameLoadDelegate, 0);					WebKit.objc_msgSend(webView, WebKit.S_setResourceLoadDelegate, 0);					WebKit.objc_msgSend(webView, WebKit.S_setUIDelegate, 0);					WebKit.objc_msgSend(webView, WebKit.S_setPolicyDelegate, 0);					WebKit.objc_msgSend(notificationCenter, WebKit.S_removeObserver, delegate);										WebKit.objc_msgSend(delegate, WebKit.S_release);										break;				}				case SWT.Hide: {					/*					* Bug on Safari. The web view cannot be obscured by other views above it.					* This problem is specified in the apple documentation for HiWebViewCreate.					* The workaround is to hook Hide and Show events on the browser's parents					* and set its size to 0 in Hide and to restore its size in Show.					*/					CGRect bounds = new CGRect();					bounds.x = bounds.y = -MIN_SIZE;					bounds.width = bounds.height = MIN_SIZE;					OS.HIViewSetFrame(webViewHandle, bounds);					break;				}				case SWT.Show: {					/*					* Bug on Safari. The web view cannot be obscured by other views above it.					* This problem is specified in the apple documentation for HiWebViewCreate.					* The workaround is to hook Hide and Show events on the browser's parents					* and set its size to 0 in Hide and to restore its size in Show.					*/					CGRect bounds = new CGRect();					OS.HIViewGetFrame(handle, bounds);					/* 					* Bug in Safari.  For some reason, the web view will display incorrectly or					* blank depending on its contents, if its size is set to a value smaller than					* MIN_SIZE. It will not display properly even after the size is made larger.					* The fix is to avoid setting sizes smaller than MIN_SIZE. 					*/					if (bounds.width <= MIN_SIZE) bounds.width = MIN_SIZE;					if (bounds.height <= MIN_SIZE) bounds.height = MIN_SIZE;					OS.HIViewSetFrame(webViewHandle, bounds);					break;				}				case SWT.Resize: {					/* Do not update size when it is not visible */					if (!isVisible()) return;					/*					* Bug on Safari. Resizing the height of a Shell containing a Browser at					* a fixed location causes the Browser to redraw at a wrong location.					* The web view is a HIView container that internally hosts					* a Cocoa NSView that uses a coordinates system with the origin at the					* bottom left corner of a window instead of the coordinates system used					* in Carbon that starts at the top left corner. The workaround is to					* reposition the web view every time the Shell of the Browser is resized.					*/					CGRect bounds = new CGRect();					OS.HIViewGetFrame(handle, bounds);					/* 					* Bug in Safari.  For some reason, the web view will display incorrectly or					* blank depending on its contents, if its size is set to a value smaller than					* MIN_SIZE. It will not display properly even after the size is made larger.					* The fix is to avoid setting sizes smaller than MIN_SIZE. 					*/					if (bounds.width <= MIN_SIZE) bounds.width = MIN_SIZE;					if (bounds.height <= MIN_SIZE) bounds.height = MIN_SIZE;					OS.HIViewSetFrame(webViewHandle, bounds);					/*					* Bug on Webkit. Resizing a Cocoa WebView in a Carbon window does not					* redraw the new area of the WebView. The workaround is to call Display.update.					* That call invokes UpdateControls on the Carbon window and that causes the					* Cocoa view to redraw correctly.					*/					e.display.update();					break;				}			}		}	};	addListener(SWT.Dispose, listener);	addListener(SWT.Resize, listener);	Shell shell = getShell();	shell.addListener(SWT.Resize, listener);	shell.addListener(SWT.Show, listener);	shell.addListener(SWT.Hide, listener);	Control c = this;	do {		c.addListener(SWT.Show, listener);		c.addListener(SWT.Hide, listener);		c = c.getParent();	} while (c != shell);		if (Callback3 == null) Callback3 = new Callback(this.getClass(), "eventProc3", 3); //$NON-NLS-1$	int callback3Address = Callback3.getAddress();	if (callback3Address == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);	int[] mask = new int[] {		OS.kEventClassKeyboard, OS.kEventRawKeyDown,		OS.kEventClassControl, OS.kEventControlDraw,		OS.kEventClassTextInput, OS.kEventTextInputUnicodeForKeyEvent,	};	int controlTarget = OS.GetControlEventTarget(webViewHandle);	OS.InstallEventHandler(controlTarget, callback3Address, mask.length / 2, mask, webViewHandle, null);	if (Callback7 == null) Callback7 = new Callback(this.getClass(), "eventProc7", 7); //$NON-NLS-1$	int callback7Address = Callback7.getAddress();	if (callback7Address == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);		// delegate = [[WebResourceLoadDelegate alloc] init eventProc];	delegate = WebKit.objc_msgSend(WebKit.C_WebKitDelegate, WebKit.S_alloc);	delegate = WebKit.objc_msgSend(delegate, WebKit.S_initWithProc, callback7Address, webViewHandle);					// [webView setFrameLoadDelegate:delegate];	WebKit.objc_msgSend(webView, WebKit.S_setFrameLoadDelegate, delegate);			// [webView setResourceLoadDelegate:delegate];	WebKit.objc_msgSend(webView, WebKit.S_setResourceLoadDelegate, delegate);	// [webView setUIDelegate:delegate];	WebKit.objc_msgSend(webView, WebKit.S_setUIDelegate, delegate);		/* register delegate for all notifications send out from webview */	WebKit.objc_msgSend(notificationCenter, WebKit.S_addObserver_selector_name_object, delegate, WebKit.S_handleNotification, 0, webView);		// [webView setPolicyDelegate:delegate];	WebKit.objc_msgSend(webView, WebKit.S_setPolicyDelegate, delegate);}