diff dwt/browser/Browser.d @ 286:44258e0b6687

More fixes for xpcom
author John Reimer<terminal.node@gmail.com>
date Tue, 05 Aug 2008 10:11:58 -0700
parents 93409d9838c5
children 16ba3d9cb209
line wrap: on
line diff
--- a/dwt/browser/Browser.d	Thu Jul 31 21:56:03 2008 -0700
+++ b/dwt/browser/Browser.d	Tue Aug 05 10:11:58 2008 -0700
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *      John Reimer <terminal.node@gmail.com>
  *******************************************************************************/
 module dwt.browser.Browser;
 
@@ -40,7 +42,7 @@
  * @since 3.0
  */
 
-public class Browser extends Composite {
+public class Browser : Composite {
     WebBrowser webBrowser;
     int userStyle;
 
@@ -77,40 +79,23 @@
  * 
  * @since 3.0
  */
-public Browser (Composite parent, int style) {
+public this (Composite parent, int style) {
     super (checkParent (parent), checkStyle (style));
     userStyle = style;
 
     String platform = DWT.getPlatform ();
     Display display = parent.getDisplay ();
-    if ("gtk".equals (platform)) display.setData (NO_INPUT_METHOD, null); //$NON-NLS-1$
+    if ("gtk" == platform) display.setData (NO_INPUT_METHOD, null); //$NON-NLS-1$
+    /*
     String className = null;
     if ((style & DWT.MOZILLA) !is 0) {
         className = "dwt.browser.Mozilla"; //$NON-NLS-1$
     } else {
-        if ("win32".equals (platform) || "wpf".equals (platform)) { //$NON-NLS-1$ $NON-NLS-2$
-            className = "dwt.browser.IE"; //$NON-NLS-1$
-        } else if ("motif".equals (platform)) { //$NON-NLS-1$
-            className = "dwt.browser.Mozilla"; //$NON-NLS-1$
-        } else if ("gtk".equals (platform)) { //$NON-NLS-1$
-            className = "dwt.browser.Mozilla"; //$NON-NLS-1$
-        } else if ("carbon".equals (platform) || "cocoa".equals (platform)) { //$NON-NLS-1$
-            className = "dwt.browser.Safari"; //$NON-NLS-1$
-        } else if ("photon".equals (platform)) { //$NON-NLS-1$
-            className = "dwt.browser.Voyager"; //$NON-NLS-1$
-        } else {
-            dispose ();
-            DWT.error (DWT.ERROR_NO_HANDLES);
-        }
+        dispose();
+        DWT.error(DWT.ERROR_NO_HANDLES);
     }
-
-    try {
-        Class clazz = Class.forName (className);
-        webBrowser = (WebBrowser)clazz.newInstance ();
-    } catch (ClassNotFoundException e) {
-    } catch (IllegalAccessException e) {
-    } catch (InstantiationException e) {
-    }
+    */
+    auto webBrowser = new Mozilla;
     if (webBrowser is null) {
         dispose ();
         DWT.error (DWT.ERROR_NO_HANDLES);
@@ -122,7 +107,7 @@
 
 static Composite checkParent (Composite parent) {
     String platform = DWT.getPlatform ();
-    if (!"gtk".equals (platform)) return parent; //$NON-NLS-1$
+    if (!("gtk" == platform)) return parent; //$NON-NLS-1$
 
     /*
     * Note.  Mozilla provides all IM support needed for text input in web pages.
@@ -144,18 +129,18 @@
 static int checkStyle(int style) {
     String platform = DWT.getPlatform ();
     if ((style & DWT.MOZILLA) !is 0) {
-        if ("carbon".equals (platform)) return style | DWT.EMBEDDED; //$NON-NLS-1$
-        if ("motif".equals (platform)) return style | DWT.EMBEDDED; //$NON-NLS-1$
+        if ("carbon" == platform) return style | DWT.EMBEDDED; //$NON-NLS-1$
+        if ("motif" == platform) return style | DWT.EMBEDDED; //$NON-NLS-1$
         return style;
     }
 
-    if ("win32".equals (platform)) { //$NON-NLS-1$
+    if ("win32" == platform) { //$NON-NLS-1$
         /*
         * For IE on win32 the border is supplied by the embedded browser, so remove
         * the style so that the parent Composite will not draw a second border.
         */
         return style & ~DWT.BORDER;
-    } else if ("motif".equals (platform)) { //$NON-NLS-1$
+    } else if ("motif" == platform) { //$NON-NLS-1$
         return style | DWT.EMBEDDED;
     }
     return style;
@@ -371,9 +356,10 @@
 }
 
 protected void checkSubclass () {
-    String name = getClass ().getName ();
-    int index = name.lastIndexOf ('.');
-    if (!name.substring (0, index + 1).equals (PACKAGE_PREFIX)) {
+    String name = this.classinfo.name;
+    
+    int index = tango.text.Util.locatePrior(name, '.');
+    if (!(name[0 .. index + 1] == PACKAGE_PREFIX)) {
         DWT.error (DWT.ERROR_INVALID_SUBCLASS);
     }
 }