1 /*******************************************************************************
2  * Copyright (c) 2003, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  * Port to the D programming language:
11  *      John Reimer <terminal.node@gmail.com>
12  *******************************************************************************/
13 module org.eclipse.swt.browser.Browser;
14 
15 import java.lang.all;
16 
17 import java.lang.Thread;
18 
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.SWTError;
21 import org.eclipse.swt.SWTException;
22 import org.eclipse.swt.widgets.Composite;
23 import org.eclipse.swt.widgets.Display;
24 import org.eclipse.swt.widgets.Widget;
25 
26 import org.eclipse.swt.browser.Mozilla;
27 import org.eclipse.swt.browser.WebBrowser;
28 import org.eclipse.swt.browser.CloseWindowListener;
29 import org.eclipse.swt.browser.LocationListener;
30 import org.eclipse.swt.browser.OpenWindowListener;
31 import org.eclipse.swt.browser.ProgressListener;
32 import org.eclipse.swt.browser.StatusTextListener;
33 import org.eclipse.swt.browser.TitleListener;
34 import org.eclipse.swt.browser.VisibilityWindowListener;
35 /**
36  * Instances of this class implement the browser user interface
37  * metaphor.  It allows the user to visualize and navigate through
38  * HTML documents.
39  * <p>
40  * Note that although this class is a subclass of <code>Composite</code>,
41  * it does not make sense to set a layout on it.
42  * </p>
43  * <dl>
44  * <dt><b>Styles:</b></dt>
45  * <dd>MOZILLA</dd>
46  * <dt><b>Events:</b></dt>
47  * <dd>CloseWindowListener, LocationListener, OpenWindowListener, ProgressListener, StatusTextListener, TitleListener, VisibilityWindowListener</dd>
48  * </dl>
49  * <p>
50  * IMPORTANT: This class is <em>not</em> intended to be subclassed.
51  * </p>
52  * 
53  * @since 3.0
54  */
55 
56 public class Browser : Composite {
57     WebBrowser webBrowser;
58     int userStyle;
59 
60     static const String PACKAGE_PREFIX = "org.eclipse.swt.browser."; //$NON-NLS-1$
61     static const String NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$
62 
63 /**
64  * Constructs a new instance of this class given its parent
65  * and a style value describing its behavior and appearance.
66  * <p>
67  * The style value is either one of the style constants defined in
68  * class <code>SWT</code> which is applicable to instances of this
69  * class, or must be built by <em>bitwise OR</em>'ing together 
70  * (that is, using the <code>int</code> "|" operator) two or more
71  * of those <code>SWT</code> style constants. The class description
72  * lists the style constants that are applicable to the class.
73  * Style bits are also inherited from superclasses.
74  * </p>
75  *
76  * @param parent a widget which will be the parent of the new instance (cannot be null)
77  * @param style the style of widget to construct
78  *
79  * @exception IllegalArgumentException <ul>
80  *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
81  * </ul>
82  * @exception SWTException <ul>
83  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
84  * </ul>
85  * @exception SWTError <ul>
86  *    <li>ERROR_NO_HANDLES if a handle could not be obtained for browser creation</li>
87  * </ul>
88  * 
89  * @see Widget#getStyle
90  * 
91  * @since 3.0
92  */
93 public this (Composite parent, int style) {
94     super (checkParent (parent), checkStyle (style));
95     userStyle = style;
96 
97     String platform = SWT.getPlatform ();
98     Display display = parent.getDisplay ();
99     if ("gtk" == platform) display.setData (NO_INPUT_METHOD, null); //$NON-NLS-1$
100     /*
101     String className = null;
102     if ((style & SWT.MOZILLA) !is 0) {
103         className = "org.eclipse.swt.browser.Mozilla"; //$NON-NLS-1$
104     } else {
105         dispose();
106         SWT.error(SWT.ERROR_NO_HANDLES);
107     }
108     */
109     webBrowser = new Mozilla;
110     if (webBrowser is null) {
111         dispose ();
112         SWT.error (SWT.ERROR_NO_HANDLES);
113     }
114 
115     webBrowser.setBrowser (this);
116     webBrowser.create (parent, style);
117 }
118 
119 static Composite checkParent (Composite parent) {
120     String platform = SWT.getPlatform ();
121     if (!("gtk" == platform)) return parent; //$NON-NLS-1$
122 
123     /*
124     * Note.  Mozilla provides all IM support needed for text input in web pages.
125     * If SWT creates another input method context for the widget it will cause
126     * indeterminate results to happen (hangs and crashes). The fix is to prevent 
127     * SWT from creating an input method context for the  Browser widget.
128     */
129     if (parent !is null && !parent.isDisposed ()) {
130         Display display = parent.getDisplay ();
131         if (display !is null) {
132             if (display.getThread () is Thread.currentThread ()) {
133                 display.setData (NO_INPUT_METHOD, stringcast("true")); //$NON-NLS-1$
134             }
135         }
136     }
137     return parent;
138 }
139 
140 static int checkStyle(int style) {
141     String platform = SWT.getPlatform ();
142     if ((style & SWT.MOZILLA) !is 0) {
143         if ("carbon" == platform) return style | SWT.EMBEDDED; //$NON-NLS-1$
144         if ("motif" == platform) return style | SWT.EMBEDDED; //$NON-NLS-1$
145         return style;
146     }
147 
148     if ("win32" == platform) { //$NON-NLS-1$
149         /*
150         * For IE on win32 the border is supplied by the embedded browser, so remove
151         * the style so that the parent Composite will not draw a second border.
152         */
153         return style & ~SWT.BORDER;
154     } else if ("motif" == platform) { //$NON-NLS-1$
155         return style | SWT.EMBEDDED;
156     }
157     return style;
158 }
159 
160 /**
161  * Clears all session cookies from all current Browser instances.
162  * 
163  * @since 3.2
164  */
165 public static void clearSessions () {
166     WebBrowser.clearSessions ();
167 }
168 
169 /**  
170  * Adds the listener to the collection of listeners who will be
171  * notified when the window hosting the receiver should be closed.
172  * <p>
173  * This notification occurs when a javascript command such as
174  * <code>window.close</code> gets executed by a <code>Browser</code>.
175  * </p>
176  *
177  * @param listener the listener which should be notified
178  *
179  * @exception IllegalArgumentException <ul>
180  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
181  * </ul>
182  * 
183  * @exception SWTException <ul>
184  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
185  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
186  * </ul>
187  *
188  * @since 3.0
189  */
190 public void addCloseWindowListener (CloseWindowListener listener) {
191     checkWidget();
192     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
193     webBrowser.addCloseWindowListener (listener);
194 }
195 
196 /**  
197  * Adds the listener to the collection of listeners who will be
198  * notified when the current location has changed or is about to change.
199  * <p>
200  * This notification typically occurs when the application navigates
201  * to a new location with {@link #setUrl(String)} or when the user
202  * activates a hyperlink.
203  * </p>
204  *
205  * @param listener the listener which should be notified
206  *
207  * @exception IllegalArgumentException <ul>
208  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
209  * </ul>
210  * 
211  * @exception SWTException <ul>
212  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
213  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
214  * </ul>
215  *
216  * @since 3.0
217  */
218 public void addLocationListener (LocationListener listener) {
219     checkWidget();
220     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
221     webBrowser.addLocationListener (listener);
222 }
223 
224 /**  
225  * Adds the listener to the collection of listeners who will be
226  * notified when a new window needs to be created.
227  * <p>
228  * This notification occurs when a javascript command such as
229  * <code>window.open</code> gets executed by a <code>Browser</code>.
230  * </p>
231  *
232  * @param listener the listener which should be notified
233  *
234  * @exception IllegalArgumentException <ul>
235  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
236  * </ul>
237  * 
238  * @exception SWTException <ul>
239  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
240  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
241  * </ul>
242  *
243  * @since 3.0
244  */
245 public void addOpenWindowListener (OpenWindowListener listener) {
246     checkWidget();
247     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
248     webBrowser.addOpenWindowListener (listener);
249 }
250 
251 /**  
252  * Adds the listener to the collection of listeners who will be
253  * notified when a progress is made during the loading of the current 
254  * URL or when the loading of the current URL has been completed.
255  *
256  * @param listener the listener which should be notified
257  *
258  * @exception IllegalArgumentException <ul>
259  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
260  * </ul>
261  * 
262  * @exception SWTException <ul>
263  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
264  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
265  * </ul>
266  *
267  * @since 3.0
268  */
269 public void addProgressListener (ProgressListener listener) {
270     checkWidget();
271     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
272     webBrowser.addProgressListener (listener);
273 }
274 
275 /**  
276  * Adds the listener to the collection of listeners who will be
277  * notified when the status text is changed.
278  * <p>
279  * The status text is typically displayed in the status bar of
280  * a browser application.
281  * </p>
282  *
283  * @param listener the listener which should be notified
284  *
285  * @exception IllegalArgumentException <ul>
286  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
287  * </ul>
288  * 
289  * @exception SWTException <ul>
290  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
291  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
292  * </ul>
293  *
294  * @since 3.0
295  */
296 public void addStatusTextListener (StatusTextListener listener) {
297     checkWidget();
298     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
299     webBrowser.addStatusTextListener (listener);
300 }
301 
302 /**  
303  * Adds the listener to the collection of listeners who will be
304  * notified when the title of the current document is available
305  * or has changed.
306  *
307  * @param listener the listener which should be notified
308  *
309  * @exception IllegalArgumentException <ul>
310  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
311  * </ul>
312  * 
313  * @exception SWTException <ul>
314  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
315  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
316  * </ul>
317  *
318  * @since 3.0
319  */
320 public void addTitleListener (TitleListener listener) {
321     checkWidget();
322     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
323     webBrowser.addTitleListener (listener);
324 }
325 
326 /**  
327  * Adds the listener to the collection of listeners who will be
328  * notified when a window hosting the receiver needs to be displayed
329  * or hidden.
330  *
331  * @param listener the listener which should be notified
332  *
333  * @exception IllegalArgumentException <ul>
334  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
335  * </ul>
336  * 
337  * @exception SWTException <ul>
338  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
339  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
340  * </ul>
341  *
342  * @since 3.0
343  */
344 public void addVisibilityWindowListener (VisibilityWindowListener listener) {
345     checkWidget();
346     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
347     webBrowser.addVisibilityWindowListener (listener);
348 }
349 
350 /**
351  * Navigate to the previous session history item.
352  *
353  * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
354  *
355  * @exception SWTException <ul>
356  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
357  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
358  * </ul>
359  *
360  * @see #forward
361  * 
362  * @since 3.0
363  */
364 public bool back () {
365     checkWidget();
366     return webBrowser.back ();
367 }
368 
369 protected void checkSubclass () {
370     String name = this.classinfo.name;
371     name = name.substring(0, name.lastIndexOf('.'));
372     int index = name.lastIndexOf('.');
373     if (!name.substring (0, index + 1).equals (PACKAGE_PREFIX)) {
374         getDwtLogger().info( __FILE__, __LINE__, "name: {} == {}", name.substring(0, index + 1), PACKAGE_PREFIX);
375         SWT.error (SWT.ERROR_INVALID_SUBCLASS);
376     }
377 }
378 
379 /**
380  * Execute the specified script.
381  *
382  * <p>
383  * Execute a script containing javascript commands in the context of the current document. 
384  * 
385  * @param script the script with javascript commands
386  *  
387  * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
388  *
389  * @exception IllegalArgumentException <ul>
390  *    <li>ERROR_NULL_ARGUMENT - if the script is null</li>
391  * </ul>
392  * 
393  * @exception SWTException <ul>
394  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
395  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
396  * </ul>
397  *
398  * @since 3.1
399  */
400 public bool execute (String script) {
401     checkWidget();
402     if (script is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
403     return webBrowser.execute (script);
404 }
405 
406 /**
407  * Navigate to the next session history item.
408  *
409  * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
410  *
411  * @exception SWTException <ul>
412  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
413  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
414  * </ul>
415  * 
416  * @see #back
417  * 
418  * @since 3.0
419  */
420 public bool forward () {
421     checkWidget();
422     return webBrowser.forward ();
423 }
424 
425 public int getStyle () {
426     /*
427     * If SWT.BORDER was specified at creation time then getStyle() should answer
428     * it even though it is removed for IE on win32 in checkStyle().
429     */
430     return super.getStyle () | (userStyle & SWT.BORDER);
431 }
432 
433 /**
434  * Returns a string with HTML that represents the content of the current page.
435  *
436  * @return HTML representing the current page or an empty <code>String</code>
437  * if this is empty
438  *
439  * @exception SWTException <ul>
440  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
441  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
442  * </ul>
443  *
444  * @since 3.4
445  */
446 public String getText () {
447     checkWidget();
448     return webBrowser.getText ();
449 }
450 
451 /**
452  * Returns the current URL.
453  *
454  * @return the current URL or an empty <code>String</code> if there is no current URL
455  *
456  * @exception SWTException <ul>
457  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
458  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
459  * </ul>
460  *
461  * @see #setUrl
462  * 
463  * @since 3.0
464  */
465 public String getUrl () {
466     checkWidget();
467     return webBrowser.getUrl ();
468 }
469 
470 /**
471  * Returns the JavaXPCOM <code>nsIWebBrowser</code> for the receiver, or <code>null</code>
472  * if it is not available.  In order for an <code>nsIWebBrowser</code> to be returned all
473  * of the following must be true: <ul>
474  *    <li>the receiver's style must be <code>SWT.MOZILLA</code></li>
475  *    <li>the classes from JavaXPCOM &gt;= 1.8.1.2 must be resolvable at runtime</li>
476  *    <li>the version of the underlying XULRunner must be &gt;= 1.8.1.2</li>
477  * </ul> 
478  *
479  * @return the receiver's JavaXPCOM <code>nsIWebBrowser</code> or <code>null</code>
480  * 
481  * @since 3.3
482  */
483 public Object getWebBrowser () {
484     checkWidget();
485     return webBrowser.getWebBrowser ();
486 }
487 
488 /**
489  * Returns <code>true</code> if the receiver can navigate to the 
490  * previous session history item, and <code>false</code> otherwise.
491  *
492  * @return the receiver's back command enabled state
493  *
494  * @exception SWTException <ul>
495  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
496  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
497  * </ul>
498  * 
499  * @see #back
500  */
501 public bool isBackEnabled () {
502     checkWidget();
503     return webBrowser.isBackEnabled ();
504 }
505 
506 public bool isFocusControl () {
507     checkWidget();
508     if (webBrowser.isFocusControl ()) return true;
509     return super.isFocusControl ();
510 }
511 
512 /**
513  * Returns <code>true</code> if the receiver can navigate to the 
514  * next session history item, and <code>false</code> otherwise.
515  *
516  * @return the receiver's forward command enabled state
517  *
518  * @exception SWTException <ul>
519  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
520  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
521  * </ul>
522  * 
523  * @see #forward
524  */
525 public bool isForwardEnabled () {
526     checkWidget();
527     return webBrowser.isForwardEnabled ();
528 }
529 
530 /**
531  * Refresh the current page.
532  *
533  * @exception SWTException <ul>
534  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
535  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
536  * </ul>
537  *
538  * @since 3.0
539  */
540 public void refresh () {
541     checkWidget();
542     webBrowser.refresh ();
543 }
544 
545 /**  
546  * Removes the listener from the collection of listeners who will
547  * be notified when the window hosting the receiver should be closed.
548  *
549  * @param listener the listener which should no longer be notified
550  *
551  * @exception IllegalArgumentException <ul>
552  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
553  * </ul>
554  * 
555  * @exception SWTException <ul>
556  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
557  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
558  * </ul>
559  * 
560  * @since 3.0
561  */
562 public void removeCloseWindowListener (CloseWindowListener listener) {
563     checkWidget();
564     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
565     webBrowser.removeCloseWindowListener (listener);
566 }
567 
568 /**  
569  * Removes the listener from the collection of listeners who will
570  * be notified when the current location is changed or about to be changed.
571  *
572  * @param listener the listener which should no longer be notified
573  *
574  * @exception IllegalArgumentException <ul>
575  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
576  * </ul>
577  * 
578  * @exception SWTException <ul>
579  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
580  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
581  * </ul>
582  * 
583  * @since 3.0
584  */
585 public void removeLocationListener (LocationListener listener) {
586     checkWidget();
587     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
588     webBrowser.removeLocationListener (listener);
589 }
590 
591 /**  
592  * Removes the listener from the collection of listeners who will
593  * be notified when a new window needs to be created.
594  *
595  * @param listener the listener which should no longer be notified
596  *
597  * @exception IllegalArgumentException <ul>
598  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
599  * </ul>
600  * 
601  * @exception SWTException <ul>
602  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
603  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
604  * </ul>
605  * 
606  * @since 3.0
607  */
608 public void removeOpenWindowListener (OpenWindowListener listener) {
609     checkWidget();
610     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
611     webBrowser.removeOpenWindowListener (listener);
612 }
613 
614 /**  
615  * Removes the listener from the collection of listeners who will
616  * be notified when a progress is made during the loading of the current 
617  * URL or when the loading of the current URL has been completed.
618  *
619  * @param listener the listener which should no longer be notified
620  *
621  * @exception IllegalArgumentException <ul>
622  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
623  * </ul>
624  * 
625  * @exception SWTException <ul>
626  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
627  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
628  * </ul>
629  * 
630  * @since 3.0
631  */
632 public void removeProgressListener (ProgressListener listener) {
633     checkWidget();
634     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
635     webBrowser.removeProgressListener (listener);
636 }
637 
638 /**  
639  * Removes the listener from the collection of listeners who will
640  * be notified when the status text is changed.
641  *
642  * @param listener the listener which should no longer be notified
643  *
644  * @exception IllegalArgumentException <ul>
645  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
646  * </ul>
647  * 
648  * @exception SWTException <ul>
649  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
650  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
651  * </ul>
652  * 
653  * @since 3.0
654  */
655 public void removeStatusTextListener (StatusTextListener listener) {
656     checkWidget();
657     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
658     webBrowser.removeStatusTextListener (listener);
659 }
660 
661 /**  
662  * Removes the listener from the collection of listeners who will
663  * be notified when the title of the current document is available
664  * or has changed.
665  *
666  * @param listener the listener which should no longer be notified
667  *
668  * @exception IllegalArgumentException <ul>
669  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
670  * </ul>
671  * 
672  * @exception SWTException <ul>
673  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
674  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
675  * </ul>
676  * 
677  * @since 3.0
678  */
679 public void removeTitleListener (TitleListener listener) {
680     checkWidget();
681     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
682     webBrowser.removeTitleListener (listener);
683 }
684 
685 /**  
686  * Removes the listener from the collection of listeners who will
687  * be notified when a window hosting the receiver needs to be displayed
688  * or hidden.
689  *
690  * @param listener the listener which should no longer be notified
691  *
692  * @exception IllegalArgumentException <ul>
693  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
694  * </ul>
695  * 
696  * @exception SWTException <ul>
697  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
698  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
699  * </ul>
700  * 
701  * @since 3.0
702  */
703 public void removeVisibilityWindowListener (VisibilityWindowListener listener) {
704     checkWidget();
705     if (listener is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
706     webBrowser.removeVisibilityWindowListener (listener);
707 }
708 
709 /**
710  * Renders HTML.
711  * 
712  * <p>
713  * The html parameter is Unicode encoded since it is a java <code>String</code>.
714  * As a result, the HTML meta tag charset should not be set. The charset is implied
715  * by the <code>String</code> itself.
716  * 
717  * @param html the HTML content to be rendered
718  *
719  * @return true if the operation was successful and false otherwise.
720  *
721  * @exception IllegalArgumentException <ul>
722  *    <li>ERROR_NULL_ARGUMENT - if the html is null</li>
723  * </ul>
724  * 
725  * @exception SWTException <ul>
726  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
727  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
728  * </ul>
729  *  
730  * @see #setUrl
731  * 
732  * @since 3.0
733  */
734 public bool setText (String html) {
735     checkWidget();
736     if (html is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
737     return webBrowser.setText (html);
738 }
739 
740 /**
741  * Loads a URL.
742  * 
743  * @param url the URL to be loaded
744  *
745  * @return true if the operation was successful and false otherwise.
746  *
747  * @exception IllegalArgumentException <ul>
748  *    <li>ERROR_NULL_ARGUMENT - if the url is null</li>
749  * </ul>
750  * 
751  * @exception SWTException <ul>
752  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
753  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
754  * </ul>
755  *  
756  * @see #getUrl
757  * 
758  * @since 3.0
759  */
760 public bool setUrl (String url) {
761     checkWidget();
762     if (url is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
763     return webBrowser.setUrl (url);
764 }
765 
766 /**
767  * Stop any loading and rendering activity.
768  *
769  * @exception SWTException <ul>
770  *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
771  *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
772  * </ul>
773  *
774  * @since 3.0
775  */
776 public void stop () {
777     checkWidget();
778     webBrowser.stop ();
779 }
780 }