update for Firefox 26 / Linux

Change-Id: I832f70db03e755f4cc5ca92146e046758a7b0bcb
diff --git a/xpcom/FFSessionHandler.cpp b/xpcom/FFSessionHandler.cpp
index 84a02d1..d57e951 100755
--- a/xpcom/FFSessionHandler.cpp
+++ b/xpcom/FFSessionHandler.cpp
@@ -204,10 +204,16 @@
       << "FFSessionHandler::freeValue [ ";
   JSContext* ctx = getJSContext();
 
+// hoisted outside the loop because this might cut down on overhead
+#if GECKO_VERSION >= 26000
+    JS::Rooted<JS::Value> toRemove(ctx);
+#else
+    jsval toRemove;
+#endif
+
   for (int i = 0; i < idCount; ++i) {
     int objId = ids[i];
     dbg << objId << " ";
-    jsval toRemove;
     if (JS_GetElement(ctx, jsObjectsById, objId, &toRemove) && 
 #ifdef JSVAL_IS_OBJECT
        JSVAL_IS_OBJECT(toRemove)) {
@@ -271,12 +277,18 @@
     return true;
   }
 
+#if GECKO_VERSION >= 26000
+  JS::Rooted<JS::Value> jsThis(ctx);
+#else
   jsval jsThis;
+#endif
   if (thisObj.isNull()) {
     jsThis = OBJECT_TO_JSVAL(global);
     Debug::log(Debug::Debugging) << " using global object for this" << Debug::flush;
   } else {
-    makeJsvalFromValue(jsThis, ctx, thisObj);
+    jsval tmp;
+    makeJsvalFromValue(tmp, ctx, thisObj);
+    jsThis = tmp;
     if (Debug::level(Debug::Spam)) {
       Debug::log(Debug::Spam) << "  obj=" << dumpJsVal(ctx, jsThis)
           << Debug::flush;
@@ -309,7 +321,14 @@
       Debug::log(Debug::Spam) << "  arg[" << i << "] = " << dumpJsVal(ctx,
           jsargs[i]) << Debug::flush;
     }
-    if (!JS_SetElement(ctx, argsRoot.get(), i + 1, &jsargs[i])) {
+    // add the argument to argsRoot
+  #if GECKO_VERSION >= 26000
+    // Note: this might not work when copying GC is actually turned on in Firefox.
+    JS::MutableHandleValue argHandle = JS::MutableHandleValue::fromMarkedLocation(&jsargs[i]);
+  #else
+    jsval* argHandle = &jsargs[i];
+  #endif
+    if (!JS_SetElement(ctx, argsRoot.get(), i + 1, argHandle)) {
       Debug::log(Debug::Error)
           << "FFSessionhandler::invoke - could not set args[" << (i + 1) << "]"
           << Debug::flush;
@@ -533,7 +552,14 @@
       } else {
         // Allocate a new id
         int objId = ++jsObjectId;
-        JS_SetElement(ctx, jsObjectsById, objId, const_cast<jsval*>(&value));
+#if GECKO_VERSION >= 26000
+        // Note: this might not work when copying GC is actually turned on in Firefox.
+        JS::MutableHandleValue tmp = JS::MutableHandleValue::fromMarkedLocation(
+          const_cast<jsval*>(&value));
+#else
+        jsval* tmp = const_cast<jsval*>(&value);
+#endif
+        JS_SetElement(ctx, jsObjectsById, objId, tmp);
         jsIdsByObject[objKey] = objId;
         retVal.setJsObjectId(objId);
       }
@@ -606,9 +632,15 @@
     case gwt::Value::JS_OBJECT:
       {
         int jsId = value.getJsObjectId();
-        if (!JS_GetElement(ctx, jsObjectsById, jsId, &retVal)) {
+#if GECKO_VERSION >= 26000
+        JS::Rooted<JS::Value> tmp(ctx);
+#else
+        jsval tmp;
+#endif
+        if (!JS_GetElement(ctx, jsObjectsById, jsId, &tmp)) {
           Debug::log(Debug::Error) << "Error getting jsObject with id " << jsId << Debug::flush;
         }
+        retVal = tmp;
 #ifdef JSVAL_IS_OBJECT
         if (!JSVAL_IS_OBJECT(retVal)) {
 #else
diff --git a/xpcom/FFSessionHandler.h b/xpcom/FFSessionHandler.h
index f7941bf..4a6e3e1 100755
--- a/xpcom/FFSessionHandler.h
+++ b/xpcom/FFSessionHandler.h
@@ -65,7 +65,11 @@
 
   // Array of JSObjects exposed to the host
   JSObject* jsObjectsById;
+#if GECKO_VERSION >= 26000
+  const JSClass* stringObjectClass;
+#else
   JSClass* stringObjectClass;
+#endif
 
   std::map<void*, int> jsIdsByObject;
 };
diff --git a/xpcom/JSRunner.cpp b/xpcom/JSRunner.cpp
index 635a2fa..470efba 100755
--- a/xpcom/JSRunner.cpp
+++ b/xpcom/JSRunner.cpp
@@ -118,7 +118,7 @@
 
   uintN line_number_start = 0;
   jsval rval;
-  JSBool js_ok = JS_EvaluateScriptForPrincipals(ctx, object, jsprin,
+  bool js_ok = JS_EvaluateScriptForPrincipals(ctx, object, jsprin,
       script.c_str(), script.length(), virtual_filename.c_str(),
       line_number_start, &rval);
 
diff --git a/xpcom/JavaObject.cpp b/xpcom/JavaObject.cpp
index b014d35..49176c0 100644
--- a/xpcom/JavaObject.cpp
+++ b/xpcom/JavaObject.cpp
@@ -66,7 +66,7 @@
 
 int JavaObject::getObjectId(JSContext* ctx, JSObject* obj) {
   jsval val;
-  JSClass* jsClass = JS_GET_CLASS(ctx, obj);
+  const JSClass* jsClass = JS_GET_CLASS(ctx, obj);
   if (jsClass != &JavaObjectClass) {
     Debug::log(Debug::Error)
         << "JavaObject::getObjectId called on non-JavaObject: " << jsClass->name
@@ -537,7 +537,13 @@
     JS_SetPendingException(ctx, retJsVal);
     return false;
   }
-  if (!JS_SetElement(ctx, retval, 1, &retJsVal)) {
+#if GECKO_VERSION >= 26000
+        JS::Rooted<JS::Value> tmp(ctx);
+        tmp = retJsVal;
+#else
+        jsval tmp = retJsVal;
+#endif
+  if (!JS_SetElement(ctx, retval, 1, &tmp)) {
     Debug::log(Debug::Error) << "Error setting return value element in array"
         << Debug::flush;
     return false;
diff --git a/xpcom/JavaObject.h b/xpcom/JavaObject.h
index 4e7a910..3c856c2 100755
--- a/xpcom/JavaObject.h
+++ b/xpcom/JavaObject.h
@@ -35,6 +35,12 @@
 #define JS_EncodeString(ctx, str) JS_GetStringBytes(str)
 #endif
 
+#if GECKO_VERSION >= 26000
+#define JSBool bool
+#define JS_TRUE true
+#define JS_FALSE false
+#endif
+
 class JavaObject {
 public:
   static bool isJavaObject(JSContext* ctx, JSObject* obj);
diff --git a/xpcom/Makefile b/xpcom/Makefile
index 729efc5..a87f15a 100644
--- a/xpcom/Makefile
+++ b/xpcom/Makefile
@@ -238,6 +238,14 @@
 NSPR_DLLFLAGS = -lnss3
 endif
 else
+ifeq ($(BROWSER),ff260)
+GECKO_VERSION   = 26.0.0
+CFLAGS += -DGECKO_VERSION=26000
+GECKO_DLLFLAGS = -lxpcomglue_s
+ifeq ($(OS),mac)
+NSPR_DLLFLAGS = -lnss3
+endif
+else
 $(error Unrecognized BROWSER of $(BROWSER) - options are ff3, ff4, ff5, ...)
 endif
 endif
@@ -266,6 +274,7 @@
 endif
 endif
 endif
+endif
 
 CFLAGS += -fshort-wchar
 CXXFLAGS = $(CXXONLYFLAGS) $(CFLAGS)
diff --git a/xpcom/XpcomDebug.cpp b/xpcom/XpcomDebug.cpp
index eddc15b..4314663 100644
--- a/xpcom/XpcomDebug.cpp
+++ b/xpcom/XpcomDebug.cpp
@@ -50,7 +50,7 @@
       int oid = JavaObject::getObjectId(ctx, obj);
       snprintf(buf, sizeof(buf), "JavaObj(%d)", oid);
     } else {
-      JSClass* jsClass = JS_GET_CLASS(ctx, obj);
+      const JSClass* jsClass = JS_GET_CLASS(ctx, obj);
       const char* name = jsClass->name ? jsClass->name : "<null>";
       snprintf(buf, sizeof(buf), "Object(%.20s @ %p)", name, obj);
     }
diff --git a/xpcom/install-template.rdf b/xpcom/install-template.rdf
index ce18575..0e856eb 100644
--- a/xpcom/install-template.rdf
+++ b/xpcom/install-template.rdf
@@ -12,7 +12,7 @@
       <Description>
         <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
         <em:minVersion>3.0</em:minVersion>
-        <em:maxVersion>25.0.*</em:maxVersion>
+        <em:maxVersion>26.0.*</em:maxVersion>
       </Description>
 
     <!-- TODO: This seems to break Firefox 3.6. With this on, FF gets into a
diff --git a/xpcom/prebuilt/extension/chrome.manifest b/xpcom/prebuilt/extension/chrome.manifest
index 9a6a3f4..8ccf3ce 100644
--- a/xpcom/prebuilt/extension/chrome.manifest
+++ b/xpcom/prebuilt/extension/chrome.manifest
@@ -144,11 +144,11 @@
 binary-component lib/Darwin-gcc3/ff230/libgwt_dev_ff230.dylib ABI=Darwin_x86-gcc3 appversion<=23.0.*
 
 # Firefox 24
-binary-component lib/Linux_x86_64-gcc3/ff240/libgwt_dev_ff240.so ABI=Linux_x86_64-gcc3 appversion<=24.0.*
-binary-component lib/Linux_x86-gcc3/ff240/libgwt_dev_ff240.so ABI=Linux_x86-gcc3 appversion<=24.0.*
-binary-component lib/WINNT_x86-msvc/ff240/xpGwtDevPlugin.dll ABI=WINNT_x86-msvc appversion<=24.0.*
-binary-component lib/Darwin-gcc3/ff240/libgwt_dev_ff240.dylib ABI=Darwin_x86_64-gcc3 appversion<=24.0.*
-binary-component lib/Darwin-gcc3/ff240/libgwt_dev_ff240.dylib ABI=Darwin_x86-gcc3 appversion<=24.0.*
+binary-component lib/Linux_x86_64-gcc3/ff240/libgwt_dev_ff240.so ABI=Linux_x86_64-gcc3 appversion<=24.9.*
+binary-component lib/Linux_x86-gcc3/ff240/libgwt_dev_ff240.so ABI=Linux_x86-gcc3 appversion<=24.9.*
+binary-component lib/WINNT_x86-msvc/ff240/xpGwtDevPlugin.dll ABI=WINNT_x86-msvc appversion<=24.9.*
+binary-component lib/Darwin-gcc3/ff240/libgwt_dev_ff240.dylib ABI=Darwin_x86_64-gcc3 appversion<=24.9.*
+binary-component lib/Darwin-gcc3/ff240/libgwt_dev_ff240.dylib ABI=Darwin_x86-gcc3 appversion<=24.9.*
 
 # Firefox 25
 binary-component lib/Linux_x86_64-gcc3/ff250/libgwt_dev_ff250.so ABI=Linux_x86_64-gcc3 appversion<=25.0.0
@@ -164,6 +164,14 @@
 binary-component lib/Darwin-gcc3/ff251/libgwt_dev_ff251.dylib ABI=Darwin_x86_64-gcc3 appversion<=25.0.*
 binary-component lib/Darwin-gcc3/ff251/libgwt_dev_ff251.dylib ABI=Darwin_x86-gcc3 appversion<=25.0.*
 
+# Firefox 26
+binary-component lib/Linux_x86_64-gcc3/ff260/libgwt_dev_ff260.so ABI=Linux_x86_64-gcc3 appversion<=26.0.*
+binary-component lib/Linux_x86-gcc3/ff260/libgwt_dev_ff260.so ABI=Linux_x86-gcc3 appversion<=26.0.*
+binary-component lib/WINNT_x86-msvc/ff260/xpGwtDevPlugin.dll ABI=WINNT_x86-msvc appversion<=26.0.*
+binary-component lib/Darwin-gcc3/ff260/libgwt_dev_ff260.dylib ABI=Darwin_x86_64-gcc3 appversion<=26.0.*
+binary-component lib/Darwin-gcc3/ff260/libgwt_dev_ff260.dylib ABI=Darwin_x86-gcc3 appversion<=26.0.*
+
+
 
 interfaces components/IOOPHM.xpt
 contract @gwt.google.com/ExternalWrapper;1 {028DD88B-6D65-401D-AAFD-17E497D15D09}
diff --git a/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff260/libgwt_dev_ff260.so b/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff260/libgwt_dev_ff260.so
new file mode 100755
index 0000000..a5f62fe
--- /dev/null
+++ b/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff260/libgwt_dev_ff260.so
Binary files differ
diff --git a/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff260/libgwt_dev_ff260.so b/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff260/libgwt_dev_ff260.so
new file mode 100755
index 0000000..5198dba
--- /dev/null
+++ b/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff260/libgwt_dev_ff260.so
Binary files differ
diff --git a/xpcom/prebuilt/ff260/include/IOOPHM.h b/xpcom/prebuilt/ff260/include/IOOPHM.h
new file mode 100644
index 0000000..4a152ce
--- /dev/null
+++ b/xpcom/prebuilt/ff260/include/IOOPHM.h
@@ -0,0 +1,105 @@
+/*
+ * DO NOT EDIT.  THIS FILE IS GENERATED FROM IOOPHM.idl
+ */
+
+#ifndef __gen_IOOPHM_h__
+#define __gen_IOOPHM_h__
+
+
+#ifndef __gen_nsISupports_h__
+#include "nsISupports.h"
+#endif
+
+/* For IDL files that don't want to include root IDL files. */
+#ifndef NS_NO_VTABLE
+#define NS_NO_VTABLE
+#endif
+class nsIDOMWindow; /* forward declaration */
+
+
+/* starting interface:    IOOPHM */
+#define IOOPHM_IID_STR "90cef17b-c3fe-4251-af68-4381b3d938a0"
+
+#define IOOPHM_IID \
+  {0x90cef17b, 0xc3fe, 0x4251, \
+    { 0xaf, 0x68, 0x43, 0x81, 0xb3, 0xd9, 0x38, 0xa0 }}
+
+class NS_NO_VTABLE IOOPHM : public nsISupports {
+ public: 
+
+  NS_DECLARE_STATIC_IID_ACCESSOR(IOOPHM_IID)
+
+  /* boolean init (in nsIDOMWindow window); */
+  NS_IMETHOD Init(nsIDOMWindow *window, bool *_retval) = 0;
+
+  /* boolean connect (in ACString url, in ACString sessionKey, in ACString addr, in ACString moduleName, in ACString hostedHtmlVersion); */
+  NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, bool *_retval) = 0;
+
+};
+
+  NS_DEFINE_STATIC_IID_ACCESSOR(IOOPHM, IOOPHM_IID)
+
+/* Use this macro when declaring classes that implement this interface. */
+#define NS_DECL_IOOPHM \
+  NS_IMETHOD Init(nsIDOMWindow *window, bool *_retval); \
+  NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, bool *_retval); 
+
+/* Use this macro to declare functions that forward the behavior of this interface to another object. */
+#define NS_FORWARD_IOOPHM(_to) \
+  NS_IMETHOD Init(nsIDOMWindow *window, bool *_retval) { return _to Init(window, _retval); } \
+  NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, bool *_retval) { return _to Connect(url, sessionKey, addr, moduleName, hostedHtmlVersion, _retval); } 
+
+/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
+#define NS_FORWARD_SAFE_IOOPHM(_to) \
+  NS_IMETHOD Init(nsIDOMWindow *window, bool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Init(window, _retval); } \
+  NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, bool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Connect(url, sessionKey, addr, moduleName, hostedHtmlVersion, _retval); } 
+
+#if 0
+/* Use the code below as a template for the implementation class for this interface. */
+
+/* Header file */
+class _MYCLASS_ : public IOOPHM
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_IOOPHM
+
+  _MYCLASS_();
+
+private:
+  ~_MYCLASS_();
+
+protected:
+  /* additional members */
+};
+
+/* Implementation file */
+NS_IMPL_ISUPPORTS1(_MYCLASS_, IOOPHM)
+
+_MYCLASS_::_MYCLASS_()
+{
+  /* member initializers and constructor code */
+}
+
+_MYCLASS_::~_MYCLASS_()
+{
+  /* destructor code */
+}
+
+/* boolean init (in nsIDOMWindow window); */
+NS_IMETHODIMP _MYCLASS_::Init(nsIDOMWindow *window, bool *_retval)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* boolean connect (in ACString url, in ACString sessionKey, in ACString addr, in ACString moduleName, in ACString hostedHtmlVersion); */
+NS_IMETHODIMP _MYCLASS_::Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, bool *_retval)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* End of implementation class template. */
+#endif
+
+
+#endif /* __gen_IOOPHM_h__ */
diff --git a/xpcom/prebuilt/update.rdf b/xpcom/prebuilt/update.rdf
index a8f45a0..9130528 100644
--- a/xpcom/prebuilt/update.rdf
+++ b/xpcom/prebuilt/update.rdf
@@ -14,7 +14,7 @@
               <Description>
                 <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
                 <em:minVersion>3.0</em:minVersion>
-                <em:maxVersion>25.0.*</em:maxVersion>
+                <em:maxVersion>26.0.*</em:maxVersion>
                 <em:updateLink>https://dl-ssl.google.com/gwt/plugins/firefox/gwt-dev-plugin.xpi</em:updateLink>
                 <em:updateInfoURL>https://dl-ssl.google.com/gwt/plugins/firefox/gwt-dev-plugin-info.xhtml?locale=%APP_LOCALE%</em:updateInfoURL>