Revision: 9684
Author: [email protected]
Date: Mon Feb  7 21:44:28 2011
Log: Update getGeckoVersion() to support beta versions of Firefox.

Previously, gecko versions of the form 2.0b10 would cause the regex to get mad because it is missing a second period. This change updates the gecko version detector to support gecko versions such as 1.2.3, 1.2, and 2.0b10.

Review at http://gwt-code-reviews.appspot.com/1343803

Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=9684

Modified:
 /trunk/user/src/com/google/gwt/dom/client/DOMImplMozilla.java

=======================================
--- /trunk/user/src/com/google/gwt/dom/client/DOMImplMozilla.java Fri Jan 28 12:43:16 2011 +++ /trunk/user/src/com/google/gwt/dom/client/DOMImplMozilla.java Mon Feb 7 21:44:28 2011
@@ -19,12 +19,12 @@
  * Mozilla implementation of StandardBrowser.
  */
 class DOMImplMozilla extends DOMImplStandard {
-
+
   private static native int getGeckoVersion() /*-{
- var result = /rv:([0-9]+)\.([0-9]+)\.([0-9]+)?/.exec(navigator.userAgent.toLowerCase()); + var result = /rv:([0-9]+)\.([0-9]+)(\.([0-9]+))?.*?/.exec(navigator.userAgent.toLowerCase());
     if (result && result.length >= 3) {
- var version = (parseInt(result[1]) * 1000000) + (parseInt(result[2]) * 1000) +
-        parseInt(result.length == 4 ? result[3] : 0);
+ var version = (parseInt(result[1]) * 1000000) + (parseInt(result[2]) * 1000) +
+        parseInt(result.length >= 5 && !isNaN(result[4]) ? result[4] : 0);
       return version;
     }
     return -1; // not gecko
@@ -40,7 +40,7 @@
     int geckoVersion = getGeckoVersion();
     return (geckoVersion != -1) && (geckoVersion <= 1009000);
   }
-
+
   /**
    * Return true if using Gecko 1.9.1 (Firefox 3.5) or earlier.
    *

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to