Cache Gecko version to lower CPU usage on FireFox

Bug: #9644
Bug-Link: https://github.com/gwtproject/gwt/issues/9644
Change-Id: Ifdb57f5b18ced91a7b7a35b601d2a24fea1d068b
diff --git a/user/src/com/google/gwt/dom/client/DOMImplMozilla.java b/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
index d246e85..c582597 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
@@ -20,7 +20,16 @@
  */
 class DOMImplMozilla extends DOMImplStandard {
 
-  private static native int getGeckoVersion() /*-{
+  private static int cachedGeckoVersion = -2;
+
+  private static int getGeckoVersion() {
+    if (cachedGeckoVersion == -2) {
+      cachedGeckoVersion = getNativeGeckoVersion();
+    }
+    return cachedGeckoVersion;
+  }
+
+  private static native int getNativeGeckoVersion() /*-{
     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) +