Merge the last green changeset of mozilla-inbound to mozilla-central
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 02 Sep 2011 11:26:17 -0400
changeset 77756 095e2524cad947afe60416e67fac3c13086f829b
parent 77706 0664108eb19df66e2449d0306cf46a2fb88a6ae3 (current diff)
parent 77755 12b7c9789d63a96cf9595be8d9872e0598779efb (diff)
child 77757 471f4fbc9c85853e3e91d351c9f57d53124ce22f
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge the last green changeset of mozilla-inbound to mozilla-central
content/xslt/build.mk
content/xslt/confvars.sh
content/xslt/src/base/txSimpleErrorObserver.cpp
content/xslt/src/base/txStringUtils.cpp
content/xslt/src/main/Makefile.in
content/xslt/src/main/testXalan.cpp
content/xslt/src/main/transformiix.cpp
content/xslt/src/main/txTestExpr.cpp
content/xslt/src/main/txXSLTMarkDriver.cpp
content/xslt/src/xml/txAttr.cpp
content/xslt/src/xml/txDocument.cpp
content/xslt/src/xml/txElement.cpp
content/xslt/src/xml/txNodeDefinition.cpp
content/xslt/src/xml/txProcessingInstruction.cpp
content/xslt/src/xpath/txStandaloneXPathTreeWalker.cpp
content/xslt/src/xslt/txHTMLOutput.cpp
content/xslt/src/xslt/txHTMLOutput.h
content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp
content/xslt/src/xslt/txStandaloneStylesheetCompiler.h
content/xslt/src/xslt/txStandaloneXSLTProcessor.cpp
content/xslt/src/xslt/txStandaloneXSLTProcessor.h
content/xslt/src/xslt/txTextOutput.cpp
content/xslt/src/xslt/txTextOutput.h
content/xslt/src/xslt/txXMLOutput.cpp
content/xslt/src/xslt/txXMLOutput.h
netwerk/build.mk
netwerk/confvars.sh
--- a/browser/base/content/browser-fullZoom.js
+++ b/browser/base/content/browser-fullZoom.js
@@ -63,21 +63,18 @@ var FullZoom = {
   },
 
   // browser.zoom.siteSpecific preference cache
   _siteSpecificPref: undefined,
 
   // browser.zoom.updateBackgroundTabs preference cache
   updateBackgroundTabs: undefined,
 
-  // whether we are in private browsing mode
-  _inPrivateBrowsing: false,
-
   get siteSpecific() {
-    return !this._inPrivateBrowsing && this._siteSpecificPref;
+    return this._siteSpecificPref;
   },
 
   //**************************************************************************//
   // nsISupports
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMEventListener,
                                          Ci.nsIObserver,
                                          Ci.nsIContentPrefObserver,
@@ -89,36 +86,26 @@ var FullZoom = {
 
   init: function FullZoom_init() {
     // Listen for scrollwheel events so we can save scrollwheel-based changes.
     window.addEventListener("DOMMouseScroll", this, false);
 
     // Register ourselves with the service so we know when our pref changes.
     Services.contentPrefs.addObserver(this.name, this);
 
-    // We disable site-specific preferences in Private Browsing mode, because the
-    // content preferences module is disabled
-    Services.obs.addObserver(this, "private-browsing", true);
-
-    // Retrieve the initial status of the Private Browsing mode.
-    this._inPrivateBrowsing = Cc["@mozilla.org/privatebrowsing;1"].
-                              getService(Ci.nsIPrivateBrowsingService).
-                              privateBrowsingEnabled;
-
     this._siteSpecificPref =
       gPrefService.getBoolPref("browser.zoom.siteSpecific");
     this.updateBackgroundTabs =
       gPrefService.getBoolPref("browser.zoom.updateBackgroundTabs");
     // Listen for changes to the browser.zoom branch so we can enable/disable
     // updating background tabs and per-site saving and restoring of zoom levels.
     gPrefService.addObserver("browser.zoom.", this, true);
   },
 
   destroy: function FullZoom_destroy() {
-    Services.obs.removeObserver(this, "private-browsing");
     gPrefService.removeObserver("browser.zoom.", this);
     Services.contentPrefs.removeObserver(this.name, this);
     window.removeEventListener("DOMMouseScroll", this, false);
   },
 
 
   //**************************************************************************//
   // Event Handlers
@@ -182,26 +169,16 @@ var FullZoom = {
               gPrefService.getBoolPref("browser.zoom.siteSpecific");
             break;
           case "browser.zoom.updateBackgroundTabs":
             this.updateBackgroundTabs =
               gPrefService.getBoolPref("browser.zoom.updateBackgroundTabs");
             break;
         }
         break;
-      case "private-browsing":
-        switch (aData) {
-          case "enter":
-            this._inPrivateBrowsing = true;
-            break;
-          case "exit":
-            this._inPrivateBrowsing = false;
-            break;
-        }
-        break;
     }
   },
 
   // nsIContentPrefObserver
 
   onContentPrefSet: function FullZoom_onContentPrefSet(aGroup, aName, aValue) {
     if (aGroup == Services.contentPrefs.grouper.group(gBrowser.currentURI))
       this._applyPrefToSetting(aValue);
@@ -316,24 +293,22 @@ var FullZoom = {
    * and perhaps the same is true for full zoom
    * (although DocumentViewerImpl::SetFullZoom doesn't mention it).
    *
    * So when we apply new zoom values to the browser, we simply set the zoom.
    * We don't check first to see if the new value is the same as the current
    * one.
    **/
   _applyPrefToSetting: function FullZoom__applyPrefToSetting(aValue, aBrowser) {
-    if ((!this.siteSpecific && !this._inPrivateBrowsing) ||
-        gInPrintPreviewMode)
+    if ((!this.siteSpecific) || gInPrintPreviewMode)
       return;
 
     var browser = aBrowser || (gBrowser && gBrowser.selectedBrowser);
     try {
-      if (browser.contentDocument instanceof Ci.nsIImageDocument ||
-          this._inPrivateBrowsing)
+      if (browser.contentDocument instanceof Ci.nsIImageDocument)
         ZoomManager.setZoomForBrowser(browser, 1);
       else if (typeof aValue != "undefined")
         ZoomManager.setZoomForBrowser(browser, this._ensureValid(aValue));
       else if (typeof this.globalValue != "undefined")
         ZoomManager.setZoomForBrowser(browser, this.globalValue);
       else
         ZoomManager.setZoomForBrowser(browser, 1);
     }
--- a/browser/branding/nightly/pref/firefox-branding.js
+++ b/browser/branding/nightly/pref/firefox-branding.js
@@ -1,13 +1,12 @@
 pref("startup.homepage_override_url","http://www.mozilla.org/projects/%APP%/%VERSION%/whatsnew/");
 pref("startup.homepage_welcome_url","http://www.mozilla.org/projects/%APP%/%VERSION%/firstrun/");
 // The time interval between checks for a new version (in seconds)
-// nightly=8 hours, official=24 hours
-pref("app.update.interval", 28800);
+pref("app.update.interval", 7200); // 2 hours
 // The time interval between the downloading of mar file chunks in the
 // background (in seconds)
 pref("app.update.download.backgroundInterval", 60);
 // URL user can browse to manually if for some reason all update installation
 // attempts fail.
 pref("app.update.url.manual", "http://nightly.mozilla.org/");
 // A default value for the "More information about this update" link
 // supplied in the "An update is available" page of the update wizard. 
--- a/browser/branding/unofficial/pref/firefox-branding.js
+++ b/browser/branding/unofficial/pref/firefox-branding.js
@@ -1,13 +1,12 @@
 pref("startup.homepage_override_url","http://www.mozilla.org/projects/%APP%/%VERSION%/whatsnew/");
 pref("startup.homepage_welcome_url","http://www.mozilla.org/projects/%APP%/%VERSION%/firstrun/");
 // The time interval between checks for a new version (in seconds)
-// nightly=8 hours, official=24 hours
-pref("app.update.interval", 28800);
+pref("app.update.interval", 86400); // 24 hours
 // The time interval between the downloading of mar file chunks in the
 // background (in seconds)
 pref("app.update.download.backgroundInterval", 60);
 // URL user can browse to manually if for some reason all update installation
 // attempts fail.
 pref("app.update.url.manual", "http://www.mozilla.org/products/%APP%/");
 // A default value for the "More information about this update" link
 // supplied in the "An update is available" page of the update wizard. 
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -246,17 +246,16 @@ MOZ_TREE_CAIRO = @MOZ_TREE_CAIRO@
 MOZ_TREE_PIXMAN = @MOZ_TREE_PIXMAN@
 
 MOZ_UPDATE_XTERM = @MOZ_UPDATE_XTERM@
 MOZ_PERMISSIONS = @MOZ_PERMISSIONS@
 MOZ_XTF = @MOZ_XTF@
 MOZ_SVG_DLISTS = @MOZ_SVG_DLISTS@
 MOZ_CAIRO_CFLAGS = @MOZ_CAIRO_CFLAGS@
 MOZ_SMIL = @MOZ_SMIL@
-MOZ_XSLT_STANDALONE = @MOZ_XSLT_STANDALONE@
 
 MOZ_PREF_EXTENSIONS = @MOZ_PREF_EXTENSIONS@
 
 MOZ_CAIRO_LIBS = @MOZ_CAIRO_LIBS@
 
 MOZ_ENABLE_GNOMEUI = @MOZ_ENABLE_GNOMEUI@
 MOZ_GNOMEUI_CFLAGS = @MOZ_GNOMEUI_CFLAGS@
 MOZ_GNOMEUI_LIBS = @MOZ_GNOMEUI_LIBS@
--- a/configure.in
+++ b/configure.in
@@ -4480,17 +4480,16 @@ MOZ_REFLOW_PERF=
 MOZ_SAFE_BROWSING=
 MOZ_HELP_VIEWER=
 MOZ_SPELLCHECK=1
 MOZ_SVG_DLISTS=
 MOZ_TOOLKIT_SEARCH=1
 MOZ_UI_LOCALE=en-US
 MOZ_UNIVERSALCHARDET=1
 MOZ_URL_CLASSIFIER=
-MOZ_XSLT_STANDALONE=
 MOZ_XTF=1
 MOZ_XUL=1
 MOZ_ZIPWRITER=1
 NS_PRINTING=1
 MOZ_PDF_PRINTING=
 MOZ_DISABLE_DOMCRYPTO=
 NSS_DISABLE_DBM=
 NECKO_WIFI=1
@@ -4536,18 +4535,16 @@ case "${target}" in
         ;;
 esac
 
 MOZ_ARG_ENABLE_STRING(application,
 [  --enable-application=APP
                           Options include:
                             browser (Firefox)
                             xulrunner
-                            content/xslt (Standalone Transformiix XSLT)
-                            netwerk (Standalone Necko)
                             tools/update-packaging (AUS-related packaging tools)],
 [ MOZ_BUILD_APP=$enableval ] )
 
 MOZ_ARG_WITH_STRING(xulrunner-stub-name,
 [  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name],
   XULRUNNER_STUB_NAME=$withval)
 
 if test -z "$XULRUNNER_STUB_NAME"; then
@@ -4611,21 +4608,16 @@ esac
 case "$MOZ_BUILD_APP" in
 browser)
   AC_DEFINE(MOZ_PHOENIX)
   ;;
 
 xulrunner)
   AC_DEFINE(MOZ_XULRUNNER)
   ;;
-
-content/xslt)
-  AC_DEFINE(TX_EXE)
-  ;;
-
 esac
 
 AC_SUBST(MOZ_BUILD_APP)
 AC_SUBST(MOZ_PHOENIX)
 AC_SUBST(MOZ_XULRUNNER)
 
 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
 
@@ -8538,17 +8530,16 @@ AC_SUBST(NS_USE_NATIVE)
 AC_SUBST(MOZ_WIDGET_TOOLKIT)
 AC_SUBST(MOZ_UPDATE_XTERM)
 AC_SUBST(MOZ_PLATFORM_MAEMO)
 AC_SUBST(MOZ_AUTH_EXTENSION)
 AC_SUBST(MOZ_PERMISSIONS)
 AC_SUBST(MOZ_XTF)
 AC_SUBST(MOZ_PREF_EXTENSIONS)
 AC_SUBST(MOZ_SMIL)
-AC_SUBST(MOZ_XSLT_STANDALONE)
 AC_SUBST(MOZ_JS_LIBS)
 AC_SUBST(MOZ_PSM)
 AC_SUBST(MOZ_DEBUG)
 AC_SUBST(MOZ_DEBUG_SYMBOLS)
 AC_SUBST(MOZ_DEBUG_ENABLE_DEFS)
 AC_SUBST(MOZ_DEBUG_DISABLE_DEFS)
 AC_SUBST(MOZ_DEBUG_FLAGS)
 AC_SUBST(MOZ_DEBUG_LDFLAGS)
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -1202,16 +1202,32 @@ DOMCI_DATA(WebGLExtension, WebGLExtensio
 
 NS_INTERFACE_MAP_BEGIN(WebGLExtension)
   NS_INTERFACE_MAP_ENTRY(WebGLExtension)
   NS_INTERFACE_MAP_ENTRY(nsIWebGLExtension)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(WebGLExtension)
 NS_INTERFACE_MAP_END
 
+/* readonly attribute WebGLsizei drawingBufferWidth; */
+NS_IMETHODIMP
+WebGLContext::GetDrawingBufferWidth(WebGLsizei *aWidth)
+{
+    *aWidth = mWidth;
+    return NS_OK;
+}
+
+/* readonly attribute WebGLsizei drawingBufferHeight; */
+NS_IMETHODIMP
+WebGLContext::GetDrawingBufferHeight(WebGLsizei *aHeight)
+{
+    *aHeight = mHeight;
+    return NS_OK;
+}
+
 /* [noscript] attribute WebGLint location; */
 NS_IMETHODIMP
 WebGLUniformLocation::GetLocation(WebGLint *aLocation)
 {
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -423,16 +423,26 @@ protected:
     void BindFakeBlackTextures();
     void UnbindFakeBlackTextures();
 
     int WhatDoesVertexAttrib0Need();
     void DoFakeVertexAttrib0(WebGLuint vertexCount);
     void UndoFakeVertexAttrib0();
     void InvalidateFakeVertexAttrib0();
 
+    static CheckedUint32 GetImageSize(WebGLsizei height, 
+                                      WebGLsizei width, 
+                                      PRUint32 pixelSize,
+                                      PRUint32 alignment);
+
+    // Returns x rounded to the next highest multiple of y.
+    static CheckedUint32 RoundedToNextMultipleOf(CheckedUint32 x, CheckedUint32 y) {
+        return ((x + y - 1) / y) * y;
+    }
+
     nsCOMPtr<nsIDOMHTMLCanvasElement> mCanvasElement;
     nsHTMLCanvasElement *HTMLCanvasElement() {
         return static_cast<nsHTMLCanvasElement*>(mCanvasElement.get());
     }
 
     nsRefPtr<gl::GLContext> gl;
 
     PRInt32 mWidth, mHeight;
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -196,18 +196,23 @@ WebGLContext::BindAttribLocation(nsIWebG
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::BindBuffer(WebGLenum target, nsIWebGLBuffer *bobj)
 {
     WebGLuint bufname;
     WebGLBuffer* buf;
-    PRBool isNull;
-    if (!GetConcreteObjectAndGLName("bindBuffer", bobj, &buf, &bufname, &isNull))
+    PRBool isNull; // allow null objects
+    PRBool isDeleted; // allow deleted objects
+    if (!GetConcreteObjectAndGLName("bindBuffer", bobj, &buf, &bufname, &isNull, &isDeleted))
+        return NS_OK;
+
+    // silently ignore a deleted buffer
+    if (isDeleted)
         return NS_OK;
 
     if (target != LOCAL_GL_ARRAY_BUFFER &&
         target != LOCAL_GL_ELEMENT_ARRAY_BUFFER)
     {
         return ErrorInvalidEnumInfo("bindBuffer: target", target);
     }
 
@@ -232,23 +237,28 @@ WebGLContext::BindBuffer(WebGLenum targe
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::BindFramebuffer(WebGLenum target, nsIWebGLFramebuffer *fbobj)
 {
     WebGLuint framebuffername;
-    PRBool isNull;
+    PRBool isNull; // allow null objects
+    PRBool isDeleted; // allow deleted objects
     WebGLFramebuffer *wfb;
 
     if (target != LOCAL_GL_FRAMEBUFFER)
         return ErrorInvalidEnum("BindFramebuffer: target must be GL_FRAMEBUFFER");
 
-    if (!GetConcreteObjectAndGLName("bindFramebuffer", fbobj, &wfb, &framebuffername, &isNull))
+    if (!GetConcreteObjectAndGLName("bindFramebuffer", fbobj, &wfb, &framebuffername, &isNull, &isDeleted))
+        return NS_OK;
+
+    // silently ignore a deleted frame buffer
+    if (isDeleted)
         return NS_OK;
 
     MakeContextCurrent();
 
     if (isNull) {
         gl->fBindFramebuffer(target, gl->GetOffscreenFBO());
     } else {
         gl->fBindFramebuffer(target, framebuffername);
@@ -259,23 +269,28 @@ WebGLContext::BindFramebuffer(WebGLenum 
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::BindRenderbuffer(WebGLenum target, nsIWebGLRenderbuffer *rbobj)
 {
     WebGLuint renderbuffername;
-    PRBool isNull;
+    PRBool isNull; // allow null objects
+    PRBool isDeleted; // allow deleted objects
     WebGLRenderbuffer *wrb;
 
     if (target != LOCAL_GL_RENDERBUFFER)
         return ErrorInvalidEnumInfo("bindRenderbuffer: target", target);
 
-    if (!GetConcreteObjectAndGLName("bindRenderBuffer", rbobj, &wrb, &renderbuffername, &isNull))
+    if (!GetConcreteObjectAndGLName("bindRenderBuffer", rbobj, &wrb, &renderbuffername, &isNull, &isDeleted))
+        return NS_OK;
+
+    // silently ignore a deleted buffer
+    if (isDeleted)
         return NS_OK;
 
     if (!isNull)
         wrb->SetHasEverBeenBound(PR_TRUE);
 
     MakeContextCurrent();
 
     gl->fBindRenderbuffer(target, renderbuffername);
@@ -285,18 +300,23 @@ WebGLContext::BindRenderbuffer(WebGLenum
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::BindTexture(WebGLenum target, nsIWebGLTexture *tobj)
 {
     WebGLuint texturename;
     WebGLTexture *tex;
-    PRBool isNull; // allow null object
-    if (!GetConcreteObjectAndGLName("bindTexture", tobj, &tex, &texturename, &isNull))
+    PRBool isNull; // allow null objects
+    PRBool isDeleted; // allow deleted objects
+    if (!GetConcreteObjectAndGLName("bindTexture", tobj, &tex, &texturename, &isNull, &isDeleted))
+        return NS_OK;
+
+    // silently ignore a deleted texture
+    if (isDeleted)
         return NS_OK;
 
     if (target == LOCAL_GL_TEXTURE_2D) {
         mBound2DTextures[mActiveTexture] = tex;
     } else if (target == LOCAL_GL_TEXTURE_CUBE_MAP) {
         mBoundCubeMapTextures[mActiveTexture] = tex;
     } else {
         return ErrorInvalidEnumInfo("bindTexture: target", target);
@@ -741,26 +761,18 @@ WebGLContext::CopyTexSubImage2D_base(Web
         /*** first, we initialize the texture as black ***/
 
         // first, compute the size of the buffer we should allocate to initialize the texture as black
 
         PRUint32 texelSize = 0;
         if (!ValidateTexFormatAndType(internalformat, LOCAL_GL_UNSIGNED_BYTE, -1, &texelSize, info))
             return NS_OK;
 
-        CheckedUint32 checked_plainRowSize = CheckedUint32(width) * texelSize;
-
-        PRUint32 unpackAlignment = mPixelStoreUnpackAlignment;
-
-        // alignedRowSize = row size rounded up to next multiple of packAlignment
-        CheckedUint32 checked_alignedRowSize
-            = ((checked_plainRowSize + unpackAlignment-1) / unpackAlignment) * unpackAlignment;
-
-        CheckedUint32 checked_neededByteLength
-            = (height-1) * checked_alignedRowSize + checked_plainRowSize;
+        CheckedUint32 checked_neededByteLength = 
+            GetImageSize(height, width, texelSize, mPixelStoreUnpackAlignment);
 
         if (!checked_neededByteLength.valid())
             return ErrorInvalidOperation("%s: integer overflow computing the needed buffer size", info);
 
         PRUint32 bytesNeeded = checked_neededByteLength.value();
 
         // now that the size is known, create the buffer
 
@@ -1058,16 +1070,19 @@ WebGLContext::DeleteFramebuffer(nsIWebGL
         return NS_OK;
 
     MakeContextCurrent();
 
     gl->fDeleteFramebuffers(1, &fbufname);
     fbuf->Delete();
     mMapFramebuffers.Remove(fbufname);
 
+    if (mBoundFramebuffer && mBoundFramebuffer->GLName() == fbufname)
+        mBoundFramebuffer = NULL;
+
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::DeleteRenderbuffer(nsIWebGLRenderbuffer *rbobj)
 {
     WebGLuint rbufname;
     WebGLRenderbuffer *rbuf;
@@ -1088,20 +1103,22 @@ WebGLContext::DeleteRenderbuffer(nsIWebG
             must be taken when deleting a renderbuffer object if the image of the renderbuffer
             is attached to a framebuffer object. In this case, if the deleted renderbuffer object is
             attached to the currently bound framebuffer object, it is 
             automatically detached.  However, attachments to any other framebuffer objects are the
             responsibility of the application.
     */
 
     gl->fDeleteRenderbuffers(1, &rbufname);
-
     rbuf->Delete();
     mMapRenderbuffers.Remove(rbufname);
 
+    if (mBoundRenderbuffer && mBoundRenderbuffer->GLName() == rbufname)
+        mBoundRenderbuffer = NULL;
+
     return NS_OK;
 }
 
 NS_IMETHODIMP
 WebGLContext::DeleteTexture(nsIWebGLTexture *tobj)
 {
     WebGLuint texname;
     WebGLTexture *tex;
@@ -2192,20 +2209,16 @@ WebGLContext::GetFramebufferAttachmentPa
                 return ErrorInvalidEnumInfo("GetFramebufferAttachmentParameter: pname", pname);
         }
     } else {
         switch (pname) {
             case LOCAL_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
                 wrval->SetAsInt32(LOCAL_GL_NONE);
                 break;
 
-            case LOCAL_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
-                wrval->SetAsEmpty();
-                break;
-
             default:
                 return ErrorInvalidEnumInfo("GetFramebufferAttachmentParameter: pname", pname);
         }
     }
 
     *retval = wrval.forget().get();
 
     return NS_OK;
@@ -2335,24 +2348,18 @@ WebGLContext::GetProgramParameter(nsIWeb
         }
             break;
         case LOCAL_GL_DELETE_STATUS:
         case LOCAL_GL_LINK_STATUS:
         case LOCAL_GL_VALIDATE_STATUS:
         {
             GLint i = 0;
 #ifdef XP_MACOSX
-            if (pname == LOCAL_GL_VALIDATE_STATUS &&
-                gl->Vendor() == gl::GLContext::VendorNVIDIA)
-            {
-                // See comment in ValidateProgram below.
-                i = 1;
-            } else {
-                gl->fGetProgramiv(progname, pname, &i);
-            }
+            // See comment in ValidateProgram below.
+            i = 1;
 #else
             gl->fGetProgramiv(progname, pname, &i);
 #endif
             wrval->SetAsBool(PRBool(i));
         }
             break;
 
         default:
@@ -2995,26 +3002,23 @@ WebGLContext::ReadPixels_base(WebGLint x
 
     if (badFormat && badType)
         return ErrorInvalidOperation("readPixels: bad format and type");
     if (badFormat)
         return ErrorInvalidEnumInfo("readPixels: format", format);
     if (badType)
         return ErrorInvalidEnumInfo("ReadPixels: type", type);
 
+    CheckedUint32 checked_neededByteLength =
+        GetImageSize(height, width, size, mPixelStorePackAlignment);
+
     CheckedUint32 checked_plainRowSize = CheckedUint32(width) * size;
 
-    PRUint32 packAlignment = mPixelStorePackAlignment;
-
-    // alignedRowSize = row size rounded up to next multiple of packAlignment
-    CheckedUint32 checked_alignedRowSize
-        = ((checked_plainRowSize + packAlignment-1) / packAlignment) * packAlignment;
-
-    CheckedUint32 checked_neededByteLength
-        = (height-1) * checked_alignedRowSize + checked_plainRowSize;
+    CheckedUint32 checked_alignedRowSize = 
+        RoundedToNextMultipleOf(checked_plainRowSize, mPixelStorePackAlignment);
 
     if (!checked_neededByteLength.valid())
         return ErrorInvalidOperation("ReadPixels: integer overflow computing the needed buffer size");
 
     if (checked_neededByteLength.value() > byteLength)
         return ErrorInvalidOperation("ReadPixels: buffer too small");
 
     MakeContextCurrent();
@@ -3065,18 +3069,19 @@ WebGLContext::ReadPixels_base(WebGLint x
             subrect_width > width || subrect_height > height)
             return ErrorInvalidOperation("ReadPixels: integer overflow computing clipped rect size");
 
         // now we know that subrect_width is in the [0..width] interval, and same for heights.
 
         // now, same computation as above to find the size of the intermediate buffer to allocate for the subrect
         // no need to check again for integer overflow here, since we already know the sizes aren't greater than before
         PRUint32 subrect_plainRowSize = subrect_width * size;
-        PRUint32 subrect_alignedRowSize = (subrect_plainRowSize + packAlignment-1) &
-            ~PRUint32(packAlignment-1);
+	// There are checks above to ensure that this doesn't overflow.
+        PRUint32 subrect_alignedRowSize = 
+            RoundedToNextMultipleOf(subrect_plainRowSize, mPixelStorePackAlignment).value();
         PRUint32 subrect_byteLength = (subrect_height-1)*subrect_alignedRowSize + subrect_plainRowSize;
 
         // create subrect buffer, call glReadPixels, copy pixels into destination buffer, delete subrect buffer
         GLubyte *subrect_data = new GLubyte[subrect_byteLength];
         gl->fReadPixels(subrect_x, subrect_y, subrect_width, subrect_height, format, type, subrect_data);
 
         // notice that this for loop terminates because we already checked that subrect_height is at most height
         for (GLint y_inside_subrect = 0; y_inside_subrect < subrect_height; ++y_inside_subrect) {
@@ -4285,17 +4290,17 @@ WebGLContext::TexImage2D_base(WebGLenum 
         case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
             if (width != height)
                 return ErrorInvalidValue("texImage2D: with cube map targets, width and height must be equal");
             break;
         default:
             return ErrorInvalidEnumInfo("texImage2D: target", target);
     }
 
-    switch (internalformat) {
+    switch (format) {
         case LOCAL_GL_RGB:
         case LOCAL_GL_RGBA:
         case LOCAL_GL_ALPHA:
         case LOCAL_GL_LUMINANCE:
         case LOCAL_GL_LUMINANCE_ALPHA:
             break;
         default:
             return ErrorInvalidEnumInfo("texImage2D: internal format", internalformat);
@@ -4326,26 +4331,23 @@ WebGLContext::TexImage2D_base(WebGLenum 
 
     if (border != 0)
         return ErrorInvalidValue("TexImage2D: border must be 0");
 
     PRUint32 texelSize = 0;
     if (!ValidateTexFormatAndType(format, type, jsArrayType, &texelSize, "texImage2D"))
         return NS_OK;
 
+    CheckedUint32 checked_neededByteLength = 
+        GetImageSize(height, width, texelSize, mPixelStoreUnpackAlignment); 
+
     CheckedUint32 checked_plainRowSize = CheckedUint32(width) * texelSize;
 
-    PRUint32 unpackAlignment = mPixelStoreUnpackAlignment;
-
-    // alignedRowSize = row size rounded up to next multiple of packAlignment
-    CheckedUint32 checked_alignedRowSize
-        = ((checked_plainRowSize + unpackAlignment-1) / unpackAlignment) * unpackAlignment;
-
-    CheckedUint32 checked_neededByteLength
-        = (height-1) * checked_alignedRowSize + checked_plainRowSize;
+    CheckedUint32 checked_alignedRowSize =
+        RoundedToNextMultipleOf(checked_plainRowSize.value(), mPixelStoreUnpackAlignment);
 
     if (!checked_neededByteLength.valid())
         return ErrorInvalidOperation("texImage2D: integer overflow computing the needed buffer size");
 
     PRUint32 bytesNeeded = checked_neededByteLength.value();
 
     if (byteLength && byteLength < bytesNeeded)
         return ErrorInvalidOperation("TexImage2D: not enough data for operation (need %d, have %d)",
@@ -4526,26 +4528,23 @@ WebGLContext::TexSubImage2D_base(WebGLen
 
     PRUint32 texelSize = 0;
     if (!ValidateTexFormatAndType(format, type, jsArrayType, &texelSize, "texSubImage2D"))
         return NS_OK;
 
     if (width == 0 || height == 0)
         return NS_OK; // ES 2.0 says it has no effect, we better return right now
 
+    CheckedUint32 checked_neededByteLength = 
+        GetImageSize(height, width, texelSize, mPixelStoreUnpackAlignment);
+
     CheckedUint32 checked_plainRowSize = CheckedUint32(width) * texelSize;
 
-    PRUint32 unpackAlignment = mPixelStoreUnpackAlignment;
-
-    // alignedRowSize = row size rounded up to next multiple of packAlignment
-    CheckedUint32 checked_alignedRowSize
-        = ((checked_plainRowSize + unpackAlignment-1) / unpackAlignment) * unpackAlignment;
-
-    CheckedUint32 checked_neededByteLength
-        = (height-1) * checked_alignedRowSize + checked_plainRowSize;
+    CheckedUint32 checked_alignedRowSize = 
+        RoundedToNextMultipleOf(checked_plainRowSize.value(), mPixelStoreUnpackAlignment);
 
     if (!checked_neededByteLength.valid())
         return ErrorInvalidOperation("texSubImage2D: integer overflow computing the needed buffer size");
 
     PRUint32 bytesNeeded = checked_neededByteLength.value();
  
     if (byteLength < bytesNeeded)
         return ErrorInvalidOperation("texSubImage2D: not enough data for operation (need %d, have %d)", bytesNeeded, byteLength);
@@ -4566,17 +4565,18 @@ WebGLContext::TexSubImage2D_base(WebGLen
 
     MakeContextCurrent();
 
     int dstFormat = GetWebGLTexelFormat(format, type);
     int actualSrcFormat = srcFormat == WebGLTexelFormat::Auto ? dstFormat : srcFormat;
     size_t srcStride = srcStrideOrZero ? srcStrideOrZero : checked_alignedRowSize.value();
 
     size_t dstPlainRowSize = texelSize * width;
-    size_t dstStride = ((dstPlainRowSize + unpackAlignment-1) / unpackAlignment) * unpackAlignment;
+    // There are checks above to ensure that this won't overflow.
+    size_t dstStride = RoundedToNextMultipleOf(dstPlainRowSize, mPixelStoreUnpackAlignment).value();
 
     if (actualSrcFormat == dstFormat &&
         srcPremultiplied == mPixelStorePremultiplyAlpha &&
         srcStride == dstStride &&
         !mPixelStoreFlipY)
     {
         // no conversion, no flipping, so we avoid copying anything and just pass the source pointer
         gl->fTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
--- a/content/canvas/src/WebGLContextUtils.cpp
+++ b/content/canvas/src/WebGLContextUtils.cpp
@@ -112,16 +112,34 @@ WebGLContext::LogMessageIfVerbose(const 
         LogMessage(fmt, ap);
     else if (firstTime)
         LogMessage("There are WebGL warnings or messages in this page, but they are hidden. To see them, "
                    "go to about:config, set the webgl.verbose preference, and reload this page.");
 
     firstTime = PR_FALSE;
 }
 
+CheckedUint32
+WebGLContext::GetImageSize(WebGLsizei height, 
+                           WebGLsizei width, 
+                           PRUint32 pixelSize,
+                           PRUint32 packOrUnpackAlignment)
+{
+    CheckedUint32 checked_plainRowSize = CheckedUint32(width) * pixelSize;
+
+    // alignedRowSize = row size rounded up to next multiple of packAlignment
+    CheckedUint32 checked_alignedRowSize = RoundedToNextMultipleOf(checked_plainRowSize, packOrUnpackAlignment);
+
+    // if height is 0, we don't need any memory to store this; without this check, we'll get an overflow
+    CheckedUint32 checked_neededByteLength
+        = height <= 0 ? 0 : (height-1) * checked_alignedRowSize + checked_plainRowSize;
+
+    return checked_neededByteLength;
+}
+
 nsresult
 WebGLContext::SynthesizeGLError(WebGLenum err)
 {
     // If there is already a pending error, don't overwrite it;
     // but if there isn't, then we need to check for a gl error
     // that may have occurred before this one and use that code
     // instead.
     
--- a/content/canvas/test/webgl/failing_tests_linux.txt
+++ b/content/canvas/test/webgl/failing_tests_linux.txt
@@ -1,26 +1,22 @@
-conformance/buffer-offscreen-test.html
 conformance/drawingbuffer-static-canvas-test.html
 conformance/drawingbuffer-test.html
 conformance/framebuffer-object-attachment.html
 conformance/shaders/glsl-features/../../glsl-features.html?feature=abs-frag&reffs=shaders/glsl-features/abs-ref.frag&testfs=shaders/glsl-features/abs.frag
 conformance/shaders/glsl-features/../../glsl-features.html?feature=abs-vert-vec2&refvs=shaders/glsl-features/abs-vec2-ref.vert&testvs=shaders/glsl-features/abs-vec2.vert
 conformance/shaders/glsl-features/../../glsl-features.html?feature=abs-vert-vec3&refvs=shaders/glsl-features/abs-vec3-ref.vert&testvs=shaders/glsl-features/abs-vec3.vert
 conformance/shaders/glsl-features/../../glsl-features.html?feature=abs-vert-vec4&refvs=shaders/glsl-features/abs-vec4-ref.vert&testvs=shaders/glsl-features/abs-vec4.vert
 conformance/shaders/glsl-features/../../glsl-features.html?feature=sign-frag-vec4&reffs=shaders/glsl-features/sign-vec4-ref.frag&testfs=shaders/glsl-features/sign-vec4.frag
 conformance/shaders/glsl-features/../../glsl-features.html?feature=sign-vert-vec4&refvs=shaders/glsl-features/sign-vec4-ref.vert&testvs=shaders/glsl-features/sign-vec4.vert
 conformance/gl-get-active-attribute.html
 conformance/gl-getshadersource.html
 conformance/gl-uniform-bool.html
 conformance/glsl-conformance.html
 conformance/glsl-long-variable-names.html
-conformance/object-deletion-behaviour.html
 conformance/premultiplyalpha-test.html
 conformance/read-pixels-test.html
 conformance/uninitialized-test.html
-conformance/webgl-specific.html
 conformance/more/conformance/quickCheckAPI.html
 conformance/more/functions/copyTexImage2D.html
 conformance/more/functions/copyTexSubImage2D.html
 conformance/more/functions/deleteBufferBadArgs.html
-conformance/more/functions/texImage2DBadArgs.html
 conformance/more/functions/uniformfArrayLen1.html
--- a/content/canvas/test/webgl/failing_tests_mac.txt
+++ b/content/canvas/test/webgl/failing_tests_mac.txt
@@ -1,23 +1,19 @@
-conformance/buffer-offscreen-test.html
 conformance/context-attributes-alpha-depth-stencil-antialias.html
 conformance/drawingbuffer-static-canvas-test.html
 conformance/drawingbuffer-test.html
 conformance/framebuffer-object-attachment.html
 conformance/gl-getshadersource.html
 conformance/gl-object-get-calls.html
 conformance/glsl-conformance.html
 conformance/glsl-long-variable-names.html
-conformance/object-deletion-behaviour.html
 conformance/premultiplyalpha-test.html
 conformance/program-test.html
 conformance/read-pixels-test.html
 conformance/tex-input-validation.html
 conformance/texture-npot.html
-conformance/webgl-specific.html
 conformance/more/conformance/quickCheckAPI.html
 conformance/more/functions/copyTexImage2D.html
 conformance/more/functions/copyTexSubImage2D.html
 conformance/more/functions/deleteBufferBadArgs.html
-conformance/more/functions/texImage2DBadArgs.html
 conformance/more/functions/uniformfBadArgs.html
 conformance/more/functions/uniformiBadArgs.html
--- a/content/canvas/test/webgl/failing_tests_windows.txt
+++ b/content/canvas/test/webgl/failing_tests_windows.txt
@@ -1,17 +1,13 @@
-conformance/buffer-offscreen-test.html
 conformance/drawingbuffer-static-canvas-test.html
 conformance/drawingbuffer-test.html
 conformance/framebuffer-object-attachment.html
 conformance/gl-getshadersource.html
 conformance/glsl-conformance.html
 conformance/glsl-long-variable-names.html
-conformance/object-deletion-behaviour.html
 conformance/premultiplyalpha-test.html
 conformance/read-pixels-test.html
-conformance/webgl-specific.html
 conformance/more/conformance/quickCheckAPI.html
 conformance/more/functions/copyTexImage2D.html
 conformance/more/functions/copyTexSubImage2D.html
 conformance/more/functions/deleteBufferBadArgs.html
-conformance/more/functions/texImage2DBadArgs.html
 conformance/more/functions/uniformfArrayLen1.html
--- a/content/canvas/test/webgl/test_webgl_conformance_test_suite.html
+++ b/content/canvas/test/webgl/test_webgl_conformance_test_suite.html
@@ -387,41 +387,45 @@ function start() {
 
 </script>
 </head>
 <body onload="start()">
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
-<table border="2">
-<tr style="height: 300px;">
-<td>
-<table>
-<tr><td><h4>WebGL Conformance Test Runner</h4>
-<tr><td>
-  <div style="border: 1px">
-    <b>Status:</b> <div><span id="status"></span></div><br />
-    <b>Results:</b>
-    <div><span id="results-default"></span></div>
-    <br />
-    <div><span id="expectedtofail"></span></div>
-    <br />
-    <div><span id="ignoredtests"></span></div>
-  </div>
-</td></tr>
-</table>
-</td>
-<td>
-<iframe id="testframe" scrolling="yes" width="100%" height="100%"></iframe>
-</td>
-</tr>
-<tr>
-<td colspan="2">
-<div style="text-align: left; width: 100%; height: 100%; overflow: auto;">
-<div><ul id="results"></ul></div>
-</div>
-</td>
-</tr>
+<table border="2px">
+  <tr style="height: 500px;">
+    <td style="width: 500px;">
+      <iframe id="testframe" scrolling="no" width="500px" height="500px"></iframe>
+    </td>
+    <td>
+      <table>
+        <tr>
+          <td><h4>WebGL Conformance Test Runner</h4></td>
+        </tr>
+        <tr>
+          <td>
+            <div style="border: 1px">
+              <b>Status:</b> <div><span id="status"></span></div><br />
+              <b>Results:</b>
+              <div><span id="results-default"></span></div>
+              <br />
+              <div><span id="expectedtofail"></span></div>
+              <br />
+              <div><span id="ignoredtests"></span></div>
+            </div>
+          </td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+  <tr>
+    <td colspan="2">
+      <div style="text-align: left; width: 100%; height: 100%; overflow: auto;">
+        <div><ul id="results"></ul></div>
+      </div>
+    </td>
+  </tr>
 </table>
 <canvas id="webglcheck-default" style="display: none;"></canvas>
 </body>
 </html>
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -99,18 +99,16 @@
 #include "nsIRadioGroupContainer.h"
 
 // input type=file
 #include "nsILocalFile.h"
 #include "nsNetUtil.h"
 #include "nsDOMFile.h"
 #include "nsIFilePicker.h"
 #include "nsDirectoryServiceDefs.h"
-#include "nsIPrivateBrowsingService.h"
-#include "nsIContentURIGrouper.h"
 #include "nsIContentPrefService.h"
 #include "nsIObserverService.h"
 #include "nsIPopupWindowManager.h"
 #include "nsGlobalWindow.h"
 
 // input type=image
 #include "nsImageLoadingContent.h"
 
@@ -448,58 +446,30 @@ NS_IMPL_ISUPPORTS2(UploadLastDir, nsIObs
 void
 nsHTMLInputElement::InitUploadLastDir() {
   gUploadLastDir = new UploadLastDir();
   NS_ADDREF(gUploadLastDir);
 
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
   if (observerService && gUploadLastDir) {
-    observerService->AddObserver(gUploadLastDir, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_TRUE);
     observerService->AddObserver(gUploadLastDir, "browser:purge-session-history", PR_TRUE);
   }
 }
 
 void 
 nsHTMLInputElement::DestroyUploadLastDir() {
   NS_IF_RELEASE(gUploadLastDir);
 }
 
-UploadLastDir::UploadLastDir():
-  mInPrivateBrowsing(PR_FALSE)
-{
-  nsCOMPtr<nsIPrivateBrowsingService> pbService =
-    do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
-  if (pbService) {
-    pbService->GetPrivateBrowsingEnabled(&mInPrivateBrowsing);
-  }
-
-  mUploadLastDirStore.Init();
-}
-
 nsresult
 UploadLastDir::FetchLastUsedDirectory(nsIURI* aURI, nsILocalFile** aFile)
 {
   NS_PRECONDITION(aURI, "aURI is null");
   NS_PRECONDITION(aFile, "aFile is null");
-  // Retrieve the data from memory if it's present during private browsing mode,
-  // otherwise fall through to check the CPS
-  if (mInPrivateBrowsing) {
-    nsCOMPtr<nsIContentURIGrouper> hostnameGrouperService =
-      do_GetService(NS_HOSTNAME_GROUPER_SERVICE_CONTRACTID);
-    if (!hostnameGrouperService)
-      return NS_ERROR_NOT_AVAILABLE;
-    nsString group;
-    hostnameGrouperService->Group(aURI, group);
-
-    if (mUploadLastDirStore.Get(group, aFile)) {
-      return NS_OK;
-    }
-  }
-
   // Attempt to get the CPS, if it's not present we'll just return
   nsCOMPtr<nsIContentPrefService> contentPrefService =
     do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID);
   if (!contentPrefService)
     return NS_ERROR_NOT_AVAILABLE;
   nsCOMPtr<nsIWritableVariant> uri = do_CreateInstance(NS_VARIANT_CONTRACTID);
   if (!uri)
     return NS_ERROR_OUT_OF_MEMORY;
@@ -531,28 +501,16 @@ UploadLastDir::StoreLastUsedDirectory(ns
   NS_PRECONDITION(aFile, "aFile is null");
   nsCOMPtr<nsIFile> parentFile;
   aFile->GetParent(getter_AddRefs(parentFile));
   if (!parentFile) {
     return NS_OK;
   }
   nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(parentFile);
 
-  // Store the data in memory instead of the CPS during private browsing mode
-  if (mInPrivateBrowsing) {
-    nsCOMPtr<nsIContentURIGrouper> hostnameGrouperService =
-      do_GetService(NS_HOSTNAME_GROUPER_SERVICE_CONTRACTID);
-    if (!hostnameGrouperService)
-      return NS_ERROR_NOT_AVAILABLE;
-    nsString group;
-    hostnameGrouperService->Group(aURI, group);
-
-    return mUploadLastDirStore.Put(group, localFile);
-  }
-
   // Attempt to get the CPS, if it's not present we'll just return
   nsCOMPtr<nsIContentPrefService> contentPrefService =
     do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID);
   if (!contentPrefService)
     return NS_ERROR_NOT_AVAILABLE;
   nsCOMPtr<nsIWritableVariant> uri = do_CreateInstance(NS_VARIANT_CONTRACTID);
   if (!uri)
     return NS_ERROR_OUT_OF_MEMORY;
@@ -568,29 +526,17 @@ UploadLastDir::StoreLastUsedDirectory(ns
     return NS_ERROR_OUT_OF_MEMORY;
   prefValue->SetAsAString(unicodePath);
   return contentPrefService->SetPref(uri, CPS_PREF_NAME, prefValue);
 }
 
 NS_IMETHODIMP
 UploadLastDir::Observe(nsISupports *aSubject, char const *aTopic, PRUnichar const *aData)
 {
-  if (strcmp(aTopic, NS_PRIVATE_BROWSING_SWITCH_TOPIC) == 0) {
-    if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_ENTER).Equals(aData)) {
-      mInPrivateBrowsing = PR_TRUE;
-    } else if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_LEAVE).Equals(aData)) {
-      mInPrivateBrowsing = PR_FALSE;
-      if (mUploadLastDirStore.IsInitialized()) {
-        mUploadLastDirStore.Clear();
-      }
-    }
-  } else if (strcmp(aTopic, "browser:purge-session-history") == 0) {
-    if (mUploadLastDirStore.IsInitialized()) {
-      mUploadLastDirStore.Clear();
-    }
+  if (strcmp(aTopic, "browser:purge-session-history") == 0) {
     nsCOMPtr<nsIContentPrefService> contentPrefService =
       do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID);
     if (contentPrefService)
       contentPrefService->RemovePrefsByName(CPS_PREF_NAME);
   }
   return NS_OK;
 }
 
--- a/content/html/content/src/nsHTMLInputElement.h
+++ b/content/html/content/src/nsHTMLInputElement.h
@@ -80,18 +80,16 @@ class nsIRadioGroupContainer;
 class nsIRadioGroupVisitor;
 class nsIRadioVisitor;
 
 class UploadLastDir : public nsIObserver, public nsSupportsWeakReference {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
-  UploadLastDir();
-
   /**
    * Fetch the last used directory for this location from the content
    * pref service, if it is available.
    *
    * @param aURI URI of the current page
    * @param aFile path to the last used directory
    */
   nsresult FetchLastUsedDirectory(nsIURI* aURI, nsILocalFile** aFile);
@@ -99,20 +97,16 @@ public:
   /**
    * Store the last used directory for this location using the
    * content pref service, if it is available
    * @param aURI URI of the current page
    * @param aFile file chosen by the user - the path to the parent of this
    *        file will be stored
    */
   nsresult StoreLastUsedDirectory(nsIURI* aURI, nsILocalFile* aFile);
-private:
-  // Directories are stored here during private browsing mode
-  nsInterfaceHashtable<nsStringHashKey, nsILocalFile> mUploadLastDirStore;
-  PRBool mInPrivateBrowsing;
 };
 
 class nsHTMLInputElement : public nsGenericHTMLFormElement,
                            public nsImageLoadingContent,
                            public nsIDOMHTMLInputElement,
                            public nsITextControlElement,
                            public nsIPhonetic,
                            public nsIDOMNSEditableElement,
--- a/content/html/document/src/MediaDocument.cpp
+++ b/content/html/document/src/MediaDocument.cpp
@@ -257,16 +257,35 @@ MediaDocument::CreateSyntheticDocument()
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   // Create a <head> so our title has somewhere to live
   nsRefPtr<nsGenericHTMLElement> head = NS_NewHTMLHeadElement(nodeInfo.forget());
   if (!head) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
+  nsCOMPtr<nsINodeInfo> nodeInfoMeta;
+  nodeInfoMeta = mNodeInfoManager->GetNodeInfo(nsGkAtoms::meta, nsnull,
+                                               kNameSpaceID_XHTML,
+                                               nsIDOMNode::ELEMENT_NODE);
+  NS_ENSURE_TRUE(nodeInfoMeta, NS_ERROR_OUT_OF_MEMORY);
+
+  nsRefPtr<nsGenericHTMLElement> metaContent = NS_NewHTMLMetaElement(nodeInfoMeta.forget());
+  if (!metaContent) {
+    return NS_ERROR_OUT_OF_MEMORY;
+  }
+  metaContent->SetAttr(kNameSpaceID_None, nsGkAtoms::name,
+                       NS_LITERAL_STRING("viewport"),
+                       PR_TRUE);
+
+  metaContent->SetAttr(kNameSpaceID_None, nsGkAtoms::content,
+                       NS_LITERAL_STRING("width=device-width; height=device-height;"),
+                       PR_TRUE);
+  head->AppendChildTo(metaContent, PR_FALSE);
+
   root->AppendChildTo(head, PR_FALSE);
 
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::body, nsnull,
                                            kNameSpaceID_XHTML,
                                            nsIDOMNode::ELEMENT_NODE);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   nsRefPtr<nsGenericHTMLElement> body = NS_NewHTMLBodyElement(nodeInfo.forget());
new file mode 100644
--- /dev/null
+++ b/content/smil/crashtests/678847-1.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<animate id="a" end="a.end+6s" />
+</svg>
new file mode 100644
--- /dev/null
+++ b/content/smil/crashtests/678938-1.svg
@@ -0,0 +1,11 @@
+<svg xmlns="http://www.w3.org/2000/svg" class="reftest-wait">
+<script>
+  window.addEventListener("load", function() {
+    setTimeout(function() {
+      document.documentElement.setCurrentTime(0);
+      document.documentElement.removeAttribute("class");
+    }, 0);
+  }, false);
+</script>
+<set id="c"/><set id="b" begin="c.begin; b.begin"/>
+</svg>
--- a/content/smil/crashtests/crashtests.list
+++ b/content/smil/crashtests/crashtests.list
@@ -32,11 +32,13 @@ load 606101-1.svg
 load 608549-1.svg
 load 608295-1.html
 load 611927-1.svg
 load 615002-1.svg
 load 615872-1.svg
 load 650732-1.svg
 load 665334-1.svg
 load 669225-1.svg
+load 669225-2.svg
 load 670313-1.svg
-load 669225-2.svg
 load 678822-1.svg
+load 678847-1.svg
+load 678938-1.svg
--- a/content/smil/nsSMILAnimationFunction.cpp
+++ b/content/smil/nsSMILAnimationFunction.cpp
@@ -473,16 +473,31 @@ nsSMILAnimationFunction::InterpolateResu
   }
 
   // Discrete-CalcMode case
   // Note: If interpolation failed (isn't supported for this type), the SVG
   // spec says to force discrete mode.
   if (calcMode == CALC_DISCRETE || NS_FAILED(rv)) {
     double scaledSimpleProgress =
       ScaleSimpleProgress(simpleProgress, CALC_DISCRETE);
+
+    // Floating-point errors can mean that, for example, a sample time of 29s in
+    // a 100s duration animation gives us a simple progress of 0.28999999999
+    // instead of the 0.29 we'd expect. Normally this isn't a noticeable
+    // problem, but when we have sudden jumps in animation values (such as is
+    // the case here with discrete animation) we can get unexpected results.
+    //
+    // To counteract this, before we perform a floor() on the animation
+    // progress, we add a tiny fudge factor to push us into the correct interval
+    // in cases where floating-point errors might cause us to fall short.
+    static const double kFloatingPointFudgeFactor = 1.0e-16;
+    if (scaledSimpleProgress + kFloatingPointFudgeFactor <= 1.0) {
+      scaledSimpleProgress += kFloatingPointFudgeFactor;
+    }
+
     if (IsToAnimation()) {
       // We don't follow SMIL 3, 12.6.4, where discrete to animations
       // are the same as <set> animations.  Instead, we treat it as a
       // discrete animation with two values (the underlying value and
       // the to="" value), and honor keyTimes="" as well.
       PRUint32 index = (PRUint32)floor(scaledSimpleProgress * 2);
       aResult = index == 0 ? aBaseValue : aValues[0];
     } else {
--- a/content/smil/nsSMILTimedElement.cpp
+++ b/content/smil/nsSMILTimedElement.cpp
@@ -753,20 +753,20 @@ nsSMILTimedElement::Rewind()
     mSeekState = mElementState == STATE_ACTIVE ?
                  SEEK_BACKWARD_FROM_ACTIVE :
                  SEEK_BACKWARD_FROM_INACTIVE;
   }
   NS_ABORT_IF_FALSE(mSeekState == SEEK_BACKWARD_FROM_INACTIVE ||
                     mSeekState == SEEK_BACKWARD_FROM_ACTIVE,
                     "Rewind in the middle of a forwards seek?");
 
+  // Putting us in the startup state will ensure we skip doing any interval
+  // updates
+  mElementState = STATE_STARTUP;
   ClearIntervals();
-  // ClearIntervals puts us in to the POSTACTIVE state but we're doing a full
-  // rewind so go back to the startup state
-  mElementState = STATE_STARTUP;
 
   UnsetBeginSpec(RemoveNonDynamic);
   UnsetEndSpec(RemoveNonDynamic);
 
   if (mClient) {
     mClient->Inactivate(PR_FALSE);
   }
 
@@ -779,16 +779,18 @@ nsSMILTimedElement::Rewind()
   if (mAnimationElement->HasAnimAttr(nsGkAtoms::end)) {
     nsAutoString attValue;
     mAnimationElement->GetAnimAttr(nsGkAtoms::end, attValue);
     SetEndSpec(attValue, &mAnimationElement->AsElement(), RemoveNonDynamic);
   }
 
   mPrevRegisteredMilestone = sMaxMilestone;
   RegisterMilestone();
+  NS_ABORT_IF_FALSE(!mCurrentInterval,
+                    "Current interval is set at end of rewind");
 }
 
 namespace
 {
   PRBool
   RemoveNonDOM(nsSMILInstanceTime* aInstanceTime)
   {
     return !aInstanceTime->FromDOM() && !aInstanceTime->ShouldPreserve();
@@ -1327,17 +1329,19 @@ nsSMILTimedElement::ClearSpecs(TimeValue
   aSpecs.Clear();
   RemoveByFunction removeByFunction(aRemove);
   RemoveInstanceTimes(aInstances, removeByFunction);
 }
 
 void
 nsSMILTimedElement::ClearIntervals()
 {
-  mElementState = STATE_POSTACTIVE;
+  if (mElementState != STATE_STARTUP) {
+    mElementState = STATE_POSTACTIVE;
+  }
   mCurrentRepeatIteration = 0;
   ResetCurrentInterval();
 
   // Remove old intervals
   for (PRInt32 i = mOldIntervals.Length() - 1; i >= 0; --i) {
     mOldIntervals[i]->Unlink();
   }
   mOldIntervals.Clear();
@@ -1679,24 +1683,25 @@ nsSMILTimedElement::GetNextInterval(cons
           prevIntervalWasZeroDur) {
         tempEnd = GetNextGreater(mEndInstances, tempBegin->Time(), endPos);
       }
 
       // If all the ends are before the beginning we have a bad interval UNLESS:
       // a) We never had any end attribute to begin with (and hence we should
       //    just use the active duration after allowing for the possibility of
       //    an end instance provided by a DOM call), OR
-      // b) We have an end attribute but no end instances--this is a special
-      //    case that is needed for syncbase timing so that animations of the
-      //    following sort: <animate id="a" end="a.begin+1s" ... /> can be
-      //    resolved (see SVGT 1.2 Test Suite animate-elem-221-t.svg) by first
-      //    establishing an interval of unresolved duration, OR
+      // b) We have no resolved (not incl. indefinite) end instances
+      //    (SMIL only says "if the instance list is empty"--but if we have
+      //    indefinite/unresolved instance times then there must be a good
+      //    reason we haven't used them (since they'll be >= tempBegin) such as
+      //    avoiding creating a self-referential loop. In any case, the interval
+      //    should be allowed to be open.), OR
       // c) We have end events which leave the interval open-ended.
       PRBool openEndedIntervalOk = mEndSpecs.IsEmpty() ||
-                                   mEndInstances.IsEmpty() ||
+                                   !HaveResolvedEndTimes() ||
                                    EndHasEventConditions();
       if (!tempEnd && !openEndedIntervalOk)
         return PR_FALSE; // Bad interval
 
       nsSMILTimeValue intervalEnd = tempEnd
                                   ? tempEnd->Time() : nsSMILTimeValue();
       nsSMILTimeValue activeEnd = CalcActiveEnd(tempBegin->Time(), intervalEnd);
 
@@ -2244,16 +2249,27 @@ const nsSMILInterval*
 nsSMILTimedElement::GetPreviousInterval() const
 {
   return mOldIntervals.IsEmpty()
     ? nsnull
     : mOldIntervals[mOldIntervals.Length()-1].get();
 }
 
 PRBool
+nsSMILTimedElement::HaveResolvedEndTimes() const
+{
+  if (mEndInstances.IsEmpty())
+    return PR_FALSE;
+
+  // mEndInstances is sorted so if the first time is not resolved then none of
+  // them are
+  return mEndInstances[0]->Time().IsResolved();
+}
+
+PRBool
 nsSMILTimedElement::EndHasEventConditions() const
 {
   for (PRUint32 i = 0; i < mEndSpecs.Length(); ++i) {
     if (mEndSpecs[i]->IsEventBased())
       return PR_TRUE;
   }
   return PR_FALSE;
 }
--- a/content/smil/nsSMILTimedElement.h
+++ b/content/smil/nsSMILTimedElement.h
@@ -520,16 +520,17 @@ protected:
   void              NotifyChangedInterval(nsSMILInterval* aInterval,
                                           PRBool aBeginObjectChanged,
                                           PRBool aEndObjectChanged);
 
   void              FireTimeEventAsync(PRUint32 aMsg, PRInt32 aDetail);
   const nsSMILInstanceTime* GetEffectiveBeginInstance() const;
   const nsSMILInterval* GetPreviousInterval() const;
   PRBool            HasPlayed() const { return !mOldIntervals.IsEmpty(); }
+  PRBool            HaveResolvedEndTimes() const;
   PRBool            EndHasEventConditions() const;
 
   // Reset the current interval by first passing ownership to a temporary
   // variable so that if Unlink() results in us receiving a callback,
   // mCurrentInterval will be nsnull and we will be in a consistent state.
   void ResetCurrentInterval()
   {
     if (mCurrentInterval) {
deleted file mode 100644
--- a/content/xslt/build.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is the Mozilla build system.
-#
-# The Initial Developer of the Original Code is
-# the Mozilla Foundation <http://www.mozilla.org/>.
-# Portions created by the Initial Developer are Copyright (C) 2006
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Benjamin Smedberg <benjamin@smedbergs.us> (Initial Code)
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-include $(topsrcdir)/config/nspr/build.mk
-include $(topsrcdir)/xpcom/build.mk
-
-TIERS += app
-
-tier_app_dirs += \
-	parser/expat \
-	content/xslt/src \
-	$(NULL)
deleted file mode 100755
--- a/content/xslt/confvars.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#! /bin/sh
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla Build System
-#
-# The Initial Developer of the Original Code is
-# Ben Turner <mozilla@songbirdnest.com>
-#
-# Portions created by the Initial Developer are Copyright (C) 2007
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-MOZ_APP_NAME=mozilla
-MOZ_EXTENSIONS_DEFAULT=""
-MOZ_XSLT_STANDALONE=1
-MOZ_APP_VERSION=$MOZILLA_VERSION
--- a/content/xslt/src/Makefile.in
+++ b/content/xslt/src/Makefile.in
@@ -39,13 +39,9 @@ DEPTH           = ../../..
 topsrcdir       = @top_srcdir@
 srcdir          = @srcdir@
 VPATH           = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 PARALLEL_DIRS   = base xml xpath xslt 
 
-ifdef MOZ_XSLT_STANDALONE
-PARALLEL_DIRS += main
-endif
-
 include $(topsrcdir)/config/rules.mk
--- a/content/xslt/src/base/Makefile.in
+++ b/content/xslt/src/base/Makefile.in
@@ -41,30 +41,22 @@ srcdir          = @srcdir@
 VPATH           = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = transformiix
 LIBRARY_NAME = txbase_s
 LIBXUL_LIBRARY = 1
 
-
-
 CPPSRCS	= txDouble.cpp \
 	txList.cpp \
 	txExpandedNameMap.cpp \
 	txNamespaceMap.cpp \
 	txURIUtils.cpp
 
-ifdef MOZ_XSLT_STANDALONE
-CPPSRCS += txSimpleErrorObserver.cpp \
-	txStringUtils.cpp \
-	txAtoms.cpp
-endif
-
 # we don't want the shared lib, but we want to force the creation of a
 # static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES += \
 	-I$(srcdir)/../../public \
--- a/content/xslt/src/base/txAtoms.h
+++ b/content/xslt/src/base/txAtoms.h
@@ -34,80 +34,15 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef TRANSFRMX_ATOMS_H
 #define TRANSFRMX_ATOMS_H
 
-#ifndef TX_EXE
-
 #include "nsGkAtoms.h"
 typedef class nsGkAtoms txXPathAtoms;
 typedef class nsGkAtoms txXMLAtoms;
 typedef class nsGkAtoms txXSLTAtoms;
 typedef class nsGkAtoms txHTMLAtoms;
 
-#else
-
-class nsIAtom;
-
-/*
- * Declare all atoms
- *
- * The atom names and values are stored in tx*AtomList.h and
- * are brought to you by the magic of C preprocessing.
- * Add new atoms to tx*AtomList.h and all support logic will
- * be auto-generated.
- */
-
-#define DOM_ATOMS                               \
-TX_ATOM(comment, "#comment")                    \
-TX_ATOM(document, "#document")                  \
-TX_ATOM(text, "#text")
-
-#define XML_ATOMS             \
-TX_ATOM(_empty, "")           \
-TX_ATOM(base, "base")         \
-TX_ATOM(_default, "default")  \
-TX_ATOM(lang, "lang")         \
-TX_ATOM(preserve, "preserve") \
-TX_ATOM(space, "space")       \
-TX_ATOM(xml, "xml")           \
-TX_ATOM(xmlns, "xmlns")       \
-DOM_ATOMS
-
-#define TX_ATOM(_name, _value) static nsIAtom* _name;
-
-class txXMLAtoms
-{
-public:
-    static void init();
-XML_ATOMS
-};
-
-class txXPathAtoms
-{
-public:
-    static void init();
-#include "txXPathAtomList.h"
-};
-
-class txXSLTAtoms
-{
-public:
-    static void init();
-#include "txXSLTAtomList.h"
-};
-
-class txHTMLAtoms
-{
-public:
-    static void init();
-#include "txHTMLAtomList.h"
-};
-
-#undef TX_ATOM
-
 #endif
-
-#endif
--- a/content/xslt/src/base/txErrorObserver.h
+++ b/content/xslt/src/base/txErrorObserver.h
@@ -35,19 +35,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef MITRE_ERROROBSERVER_H
 #define MITRE_ERROROBSERVER_H
 
 #include "txCore.h"
-#ifdef TX_EXE
-#include <iostream.h>
-#endif
 
 /**
  * A simple interface for observing errors
 **/
 class ErrorObserver {
 
 public:
 
@@ -69,44 +66,9 @@ public:
     {
         receiveError(errorMessage, NS_ERROR_FAILURE);
     }
 
         
 
 }; //-- ErrorObserver
 
-#ifdef TX_EXE
-/**
- * A simple ErrorObserver which allows printing error messages to a stream
-**/
-class SimpleErrorObserver : public ErrorObserver {
-
-public:
-
-    /**
-     * Creates a new SimpleErrorObserver.
-     * All errors will be printed to the console (cout).
-    **/
-    SimpleErrorObserver();
-
-    /**
-     * Creates a new SimpleErrorObserver.
-     * All errors will be printed to the given ostream.
-    **/
-    SimpleErrorObserver(ostream& errStream);
-
-    /**
-     *  Notifies this Error observer of a new error aRes
-    **/
-    void receiveError(const nsAString& errorMessage, nsresult aRes);
-
-    virtual void suppressWarnings(MBool suppress);
-
-private:
-
-    ostream* errStream;
-    MBool hideWarnings;
-}; //-- SimpleErrorObserver
 #endif
-
-#endif
-
deleted file mode 100644
--- a/content/xslt/src/base/txSimpleErrorObserver.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * The MITRE Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Keith Visco <kvisco@ziplink.net> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "txErrorObserver.h"
-#include "nsString.h"
-
-/**
- * Creates a new SimpleErrorObserver.
- * All errors will be printed to the console (cout).
-**/
-SimpleErrorObserver::SimpleErrorObserver() {
-#ifdef TX_EXE
-    errStream = &cout;
-#endif
-    hideWarnings = MB_FALSE;
-} //-- SimpleErrorObserver
-
-/**
- * Creates a new SimpleErrorObserver.
- * All errors will be printed to the given ostream.
-**/
-SimpleErrorObserver::SimpleErrorObserver(ostream& errStream) {
-    this->errStream = &errStream;
-    hideWarnings = MB_FALSE;
-} //-- SimpleErrorObserver
-
-/**
- *  Notifies this Error observer of a new error using the given error level
-**/
-void SimpleErrorObserver::receiveError(const nsAString& errorMessage,
-                                       nsresult aRes)
-{
-#ifdef TX_EXE
-    if (NS_FAILED(aRes)) {
-        *errStream << "error: ";
-    }
-
-    *errStream << NS_LossyConvertUTF16toASCII(errorMessage).get() << endl;
-    errStream->flush();
-#endif
-}
-
-void SimpleErrorObserver::suppressWarnings(MBool suppress) {
-    this->hideWarnings = suppress;
-} //-- suppressWarnings
deleted file mode 100644
--- a/content/xslt/src/base/txStringUtils.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Axel Hecht <axel@pike.org>
- *   Peter Van der Beken <peterv@propagandism.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "txStringUtils.h"
-#include "nsDependentString.h"
-
-int
-txCaseInsensitiveStringComparator::operator()(const char_type* lhs,
-                                              const char_type* rhs,
-                                              PRUint32 aLength ) const
-{
-  PRUnichar thisChar, otherChar;
-  PRUint32 compLoop = 0;
-  while (compLoop < aLength) {
-    thisChar = lhs[compLoop];
-    if ((thisChar >= 'A') && (thisChar <= 'Z')) {
-      thisChar += 32;
-    }
-    otherChar = rhs[compLoop];
-    if ((otherChar >= 'A') && (otherChar <= 'Z')) {
-      otherChar += 32;
-    }
-    if (thisChar != otherChar) {
-      return thisChar - otherChar;
-    }
-    ++compLoop;
-  }
-  return 0;
-
-}
-
-int
-txCaseInsensitiveStringComparator::operator()(char_type lhs,
-                                              char_type rhs) const
-{
-  if (lhs >= 'A' && lhs <= 'Z') {
-    lhs += 32;
-  }
-  if (rhs >= 'A' && rhs <= 'Z') {
-    rhs += 32;
-  }
-  return lhs - rhs;
-} 
-
-/**
- * A character sink for case conversion.
- */
-class ConvertToLowerCase
-{
-public:
-  typedef PRUnichar value_type;
-
-  void write( const PRUnichar* aSource, PRUint32 aSourceLength)
-  {
-    PRUnichar* cp = const_cast<PRUnichar*>(aSource);
-    const PRUnichar* end = aSource + aSourceLength;
-    while (cp != end) {
-      PRUnichar ch = *cp;
-      if ((ch >= 'A') && (ch <= 'Z'))
-        *cp = ch + ('a' - 'A');
-      ++cp;
-    }
-  }
-};
-
-void TX_ToLowerCase(nsAString& aString)
-{
-  nsAString::iterator fromBegin, fromEnd;
-  ConvertToLowerCase converter;
-  copy_string(aString.BeginWriting(fromBegin), aString.EndWriting(fromEnd),
-              converter);
-}
-
-/**
- * A character sink for copying with case conversion.
- */
-class CopyToLowerCase
-{
-public:
-  typedef PRUnichar value_type;
-
-  CopyToLowerCase(nsAString::iterator& aDestIter) : mIter(aDestIter)
-  {
-  }
-
-  void write(const PRUnichar* aSource, PRUint32 aSourceLength)
-  {
-    PRUint32 len = NS_MIN(PRUint32(mIter.size_forward()), aSourceLength);
-    PRUnichar* cp = mIter.get();
-    const PRUnichar* end = aSource + len;
-    while (aSource != end) {
-      PRUnichar ch = *aSource;
-      if ((ch >= 'A') && (ch <= 'Z'))
-        *cp = ch + ('a' - 'A');
-      else
-        *cp = ch;
-      ++aSource;
-      ++cp;
-    }
-    mIter.advance(len);
-  }
-
-protected:
-  nsAString::iterator& mIter;
-};
-
-void TX_ToLowerCase(const nsAString& aSource, nsAString& aDest)
-{
-  nsAString::const_iterator fromBegin, fromEnd;
-  nsAString::iterator toBegin;
-  if (!EnsureStringLength(aDest, aSource.Length()))
-    return; // XXX no way to signal out-of-memory
-  CopyToLowerCase converter(aDest.BeginWriting(toBegin));
-  copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd),
-              converter);
-}
--- a/content/xslt/src/base/txStringUtils.h
+++ b/content/xslt/src/base/txStringUtils.h
@@ -37,50 +37,31 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef txStringUtils_h__
 #define txStringUtils_h__
 
 #include "nsAString.h"
 #include "nsIAtom.h"
+#include "nsUnicharUtils.h"
+
+#define TX_ToLowerCase ToLowerCase
+
+typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator;
 
 /**
  * Check equality between a string and an atom containing ASCII.
  */
 inline PRBool
 TX_StringEqualsAtom(const nsASingleFragmentString& aString, nsIAtom* aAtom)
 {
   return aAtom->Equals(aString);
 }
 
-#ifndef TX_EXE
-
-#include "nsUnicharUtils.h"
-typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator;
-
-#define TX_ToLowerCase ToLowerCase
-
-#else
-
-// These only work for ASCII ranges!
-
-class txCaseInsensitiveStringComparator
-: public nsStringComparator
-{
-public:
-  virtual int operator()(const char_type*, const char_type*, PRUint32 aLength) const;
-  virtual int operator()(char_type, char_type) const;
-};
-
-void TX_ToLowerCase(nsAString& aString);
-void TX_ToLowerCase(const nsAString& aSource, nsAString& aDest);
-
-#endif
-
 inline already_AddRefed<nsIAtom>
 TX_ToLowerCaseAtom(nsIAtom* aAtom)
 {
   nsAutoString str;
   aAtom->ToString(str);
   TX_ToLowerCase(str);
   return do_GetAtom(str);
 }
--- a/content/xslt/src/base/txURIUtils.cpp
+++ b/content/xslt/src/base/txURIUtils.cpp
@@ -33,180 +33,54 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "txURIUtils.h"
-
-#ifndef TX_EXE
 #include "nsNetUtil.h"
 #include "nsIAttribute.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIContent.h"
 #include "nsIPrincipal.h"
 #include "nsINodeInfo.h"
-#endif
 
 /**
  * URIUtils
  * A set of utilities for handling URIs
 **/
 
-#ifdef TX_EXE
-//- Constants -/
-
-const char   URIUtils::HREF_PATH_SEP  = '/';
-
-/**
- * Implementation of utility functions for parsing URLs.
- * Just file paths for now.
- */
-void
-txParsedURL::init(const nsAFlatString& aSpec)
-{
-    mPath.Truncate();
-    mName.Truncate();
-    mRef.Truncate();
-    PRUint32 specLength = aSpec.Length();
-    if (!specLength) {
-        return;
-    }
-    const PRUnichar* start = aSpec.get();
-    const PRUnichar* end = start + specLength;
-    const PRUnichar* c = end - 1;
-
-    // check for #ref
-    for (; c >= start; --c) {
-        if (*c == '#') {
-            // we could eventually unescape this, too.
-            mRef = Substring(c + 1, end);
-            end = c;
-            --c;
-            if (c == start) {
-                // we're done,
-                return;
-            }
-            break;
-        }
-    }
-    for (c = end - 1; c >= start; --c) {
-        if (*c == '/') {
-            mName = Substring(c + 1, end);
-            mPath = Substring(start, c + 1);
-            return;
-        }
-    }
-    mName = Substring(start, end);
-}
-
-void
-txParsedURL::resolve(const txParsedURL& aRef, txParsedURL& aDest)
-{
-    /*
-     * No handling of absolute URLs now.
-     * These aren't really URLs yet, anyway, but paths with refs
-     */
-    aDest.mPath = mPath + aRef.mPath;
-
-    if (aRef.mName.IsEmpty() && aRef.mPath.IsEmpty()) {
-        // the relative URL is just a fragment identifier
-        aDest.mName = mName;
-        if (aRef.mRef.IsEmpty()) {
-            // and not even that, keep the base ref
-            aDest.mRef = mRef;
-            return;
-        }
-        aDest.mRef = aRef.mRef;
-        return;
-    }
-    aDest.mName = aRef.mName;
-    aDest.mRef = aRef.mRef;
-}
-
-/**
- * Returns an InputStream for the file represented by the href
- * argument
- * @param href the href of the file to get the input stream for.
- * @return an InputStream to the desired resource
- * @exception java.io.FileNotFoundException when the file could not be
- * found
-**/
-istream* URIUtils::getInputStream(const nsAString& href, nsAString& errMsg)
-{
-    return new ifstream(NS_LossyConvertUTF16toASCII(href).get(), ios::in);
-} //-- getInputStream
-
-/**
-    * Returns the document base of the href argument
-    * @return the document base of the given href
-**/
-void URIUtils::getDocumentBase(const nsAFlatString& href, nsAString& dest)
-{
-    if (href.IsEmpty()) {
-        return;
-    }
-
-    nsAFlatString::const_char_iterator temp;
-    href.BeginReading(temp);
-    PRUint32 iter = href.Length();
-    while (iter > 0) {
-        if (temp[--iter] == HREF_PATH_SEP) {
-            dest.Append(StringHead(href, iter));
-            break;
-        }
-    }
-}
-#endif
-
 /**
  * Resolves the given href argument, using the given documentBase
  * if necessary.
  * The new resolved href will be appended to the given dest String
 **/
 void URIUtils::resolveHref(const nsAString& href, const nsAString& base,
                            nsAString& dest) {
     if (base.IsEmpty()) {
         dest.Append(href);
         return;
     }
     if (href.IsEmpty()) {
         dest.Append(base);
         return;
     }
-
-#ifndef TX_EXE
     nsCOMPtr<nsIURI> pURL;
     nsAutoString resultHref;
     nsresult result = NS_NewURI(getter_AddRefs(pURL), base);
     if (NS_SUCCEEDED(result)) {
         NS_MakeAbsoluteURI(resultHref, href, pURL);
         dest.Append(resultHref);
     }
-#else
-    nsAutoString documentBase;
-    getDocumentBase(PromiseFlatString(base), documentBase);
-
-    //-- join document base + href
-    if (!documentBase.IsEmpty()) {
-        dest.Append(documentBase);
-        if (documentBase.CharAt(documentBase.Length()-1) != HREF_PATH_SEP)
-            dest.Append(PRUnichar(HREF_PATH_SEP));
-    }
-    dest.Append(href);
-
-#endif
 } //-- resolveHref
 
-#ifndef TX_EXE
-
 // static
 void
 URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode)
 {
     nsCOMPtr<nsINode> node = do_QueryInterface(aSourceNode);
     if (!node) {
         // XXXbz passing nsnull as the first arg to Reset is illegal
         aNewDoc->Reset(nsnull, nsnull);
@@ -240,10 +114,8 @@ URIUtils::ResetWithSource(nsIDocument *a
     aNewDoc->SetPrincipal(sourcePrincipal);
     aNewDoc->SetBaseURI(sourceDoc->GetDocBaseURI());
 
     // Copy charset
     aNewDoc->SetDocumentCharacterSetSource(
           sourceDoc->GetDocumentCharacterSetSource());
     aNewDoc->SetDocumentCharacterSet(sourceDoc->GetDocumentCharacterSet());
 }
-
-#endif /* TX_EXE */
--- a/content/xslt/src/base/txURIUtils.h
+++ b/content/xslt/src/base/txURIUtils.h
@@ -34,72 +34,33 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef TRANSFRMX_URIUTILS_H
 #define TRANSFRMX_URIUTILS_H
 
 #include "txCore.h"
-#ifdef TX_EXE
-#include <fstream.h>
-#include <iostream.h>
-#include "nsString.h"
-#else
+
 class nsIDocument;
 class nsIDOMNode;
 
-#endif
-
 /**
  * A utility class for URI handling
  * Not yet finished, only handles file URI at this point
 **/
 
-#ifdef TX_EXE
-class txParsedURL
-{
-public:
-    void init(const nsAFlatString& aSpec);
-    void resolve(const txParsedURL& aRef, txParsedURL& aDest);
-    void getFile(nsString& aResult) const
-    {
-        aResult = mPath + mName;
-    }
-    nsString mPath, mName, mRef;
-};
-#endif
-
 class URIUtils {
 public:
 
-#ifdef TX_EXE
-    /**
-     * the path separator for an URI
-    **/
-    static const char HREF_PATH_SEP;
-
-    static istream* getInputStream
-        (const nsAString& href, nsAString& errMsg);
-
-    /**
-     * Returns the document base of the href argument
-     * The document base will be appended to the given dest String
-    **/
-    static void getDocumentBase(const nsAFlatString& href, nsAString& dest);
-
-#else /* TX_EXE */
-
     /**
      * Reset the given document with the document of the source node
      */
     static void ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode);
 
-#endif /* TX_EXE */
-
     /**
      * Resolves the given href argument, using the given documentBase
      * if necessary.
      * The new resolved href will be appended to the given dest String
     **/
     static void resolveHref(const nsAString& href, const nsAString& base,
                             nsAString& dest);
 }; //-- URIUtils
deleted file mode 100644
--- a/content/xslt/src/main/Makefile.in
+++ /dev/null
@@ -1,80 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is TransforMiiX XSLT processor code.
-#
-# The Initial Developer of the Original Code is
-# Axel Hecht.
-# Portions created by the Initial Developer are Copyright (C) 2001
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Axel Hecht <axel@pike.org>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH           = ../../../..
-topsrcdir       = @top_srcdir@
-srcdir          = @srcdir@
-VPATH           = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MOZILLA_INTERNAL_API = 1
-SIMPLE_PROGRAMS = transformiix$(BIN_SUFFIX) testXalan$(BIN_SUFFIX) \
-                  txTestExpr$(BIN_SUFFIX)
-ifdef MARK_INC
-SIMPLE_PROGRAMS += txXSLTMarkDriver$(BIN_SUFFIX)
-endif
-
-
-CPP_PROG_LINK          = 1
-
-TX_LIBS = \
-	txxslt_s \
-	txxpath_s \
-	txxml_s \
-	txbase_s \
-	mozexpat_s \
-	$(NULL)
-
-LIBS = \
-	$(addprefix $(DIST)/lib/$(LIB_PREFIX),$(addsuffix .$(LIB_SUFFIX),$(TX_LIBS))) \
-	$(MOZ_COMPONENT_LIBS) \
-	$(NULL)
-
-ifdef MOZ_JPROF
-LIBS         += -ljprof
-endif
-
-include $(topsrcdir)/config/rules.mk
-
-INCLUDES += \
-	-I$(srcdir)/../base \
-	-I$(srcdir)/../xml \
-  -I$(srcdir)/../xpath \
-	-I$(srcdir)/../xslt \
-	$(MARK_INC) \
-	$(NULL)
deleted file mode 100644
--- a/content/xslt/src/main/testXalan.cpp
+++ /dev/null
@@ -1,423 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Axel Hecht.
- * Portions created by the Initial Developer are Copyright (C) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Axel Hecht <axel@pike.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "txStandaloneXSLTProcessor.h"
-#include "nsXPCOM.h"
-#include <fstream.h>
-#include "nsDoubleHashtable.h"
-#include "nsIComponentManager.h"
-#include "nsILocalFile.h"
-#include "nsISimpleEnumerator.h"
-#include "nsString.h"
-#include "prenv.h"
-#include "prsystem.h"
-#include "nsDirectoryServiceUtils.h"
-#include "nsDirectoryServiceDefs.h"
-
-#ifdef NS_TRACE_MALLOC
-#include "nsTraceMalloc.h"
-#endif
-#ifdef MOZ_JPROF
-#include "jprof.h"
-#endif
-
-/**
- * Prints the command line help screen to the console
- */
-void printHelp()
-{
-  cerr << "testXalan [-o output-file] [category]*" << endl << endl;
-  cerr << "Options:";
-  cerr << endl << endl;
-  cerr << "\t-o  specify output file (default: write to stdout)";
-  cerr << endl << endl;
-  cerr << "\t Specify XALAN_DIR in your environement." << endl;
-  cerr << endl;
-}
-
-/**
- * Helper class to report success and failure to RDF
- */
-class txRDFOut
-{
-public:
-    explicit txRDFOut(ostream* aOut)
-        : mOut(aOut), mSuccess(0), mFail(0), mParent(nsnull)
-    {
-    }
-    explicit txRDFOut(const nsACString& aName, txRDFOut* aParent)
-        : mName(aName), mOut(aParent->mOut), mSuccess(0), mFail(0),
-          mParent(aParent)
-    {
-    }
-    ~txRDFOut()
-    {
-        *mOut << "  <RDF:Description about=\"urn:x-buster:conf" <<
-            mName.get() <<
-            "\">\n" <<
-            "    <NC:orig_succCount NC:parseType=\"Integer\">" <<
-            mSuccess <<
-            "</NC:orig_succCount>\n" <<
-            "    <NC:orig_failCount NC:parseType=\"Integer\">" <<
-            mFail <<
-            "</NC:orig_failCount>\n" <<
-            "  </RDF:Description>" << endl;
-    }
-
-    void feed(const nsACString& aTest, PRBool aSuccess)
-    {
-        *mOut << "  <RDF:Description about=\"urn:x-buster:" <<
-            PromiseFlatCString(aTest).get() <<
-            "\"\n                   NC:orig_succ=\"";
-        if (aSuccess) {
-            *mOut << "yes";
-            succeeded();
-        }
-        else {
-            *mOut << "no";
-            failed();
-        }
-        *mOut << "\" />\n";
-    }
-
-    void succeeded()
-    {
-        if (mParent)
-            mParent->succeeded();
-        ++mSuccess;
-    }
-    void failed()
-    {
-        if (mParent)
-            mParent->failed();
-        ++mFail;
-    }
-private:
-    nsCAutoString mName;
-    ostream* mOut;
-    PRUint32 mSuccess, mFail;
-    txRDFOut* mParent;
-};
-
-static void
-readToString(istream& aIstream, nsACString& aString)
-{
-    static char buffer[1024];
-    int read = 0;
-    do {
-        aIstream.read(buffer, 1024);
-        read = aIstream.gcount();
-        aString.Append(Substring(buffer, buffer + read));
-    } while (!aIstream.eof());
-}
-
-/**
- * Get the XALAN_DIR environment variable and return a nsIFile for
- * the conf and the conf-gold subdirectory. Create a TEMP file, too.
- * Return an error if either does not exist.
- */
-static nsresult
-setupXalan(const char* aPath, nsIFile** aConf, nsIFile** aConfGold,
-           nsIFile** aTemp)
-{
-    nsresult rv;
-    nsCOMPtr<nsILocalFile> conf(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID,
-                                                  &rv));
-    NS_ENSURE_SUCCESS(rv, rv);
-    nsCOMPtr <nsIFile> tmpFile;
-    rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile));
-    NS_ENSURE_SUCCESS(rv, rv);
-    tmpFile->Append(NS_LITERAL_STRING("xalan.out"));
-    rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
-    rv = conf->InitWithNativePath(nsDependentCString(aPath));
-    NS_ENSURE_SUCCESS(rv, rv);
-    nsCOMPtr<nsIFile> gold;
-    rv = conf->Clone(getter_AddRefs(gold));
-    NS_ENSURE_SUCCESS(rv, rv);
-    rv = conf->Append(NS_LITERAL_STRING("conf"));
-    NS_ENSURE_SUCCESS(rv, rv);
-    PRBool isDir;
-    rv = conf->IsDirectory(&isDir);
-    if (NS_FAILED(rv) || !isDir) {
-        return NS_ERROR_FILE_NOT_DIRECTORY;
-    }
-    rv = gold->Append(NS_LITERAL_STRING("conf-gold"));
-    NS_ENSURE_SUCCESS(rv, rv);
-    rv = gold->IsDirectory(&isDir);
-    if (NS_FAILED(rv) || !isDir || !conf || !gold) {
-        return NS_ERROR_FILE_NOT_DIRECTORY;
-    }
-    // got conf and conf-gold subdirectories
-    *aConf = conf;
-    NS_ADDREF(*aConf);
-    *aConfGold = gold;
-    NS_ADDREF(*aConfGold);
-    *aTemp = tmpFile;
-    NS_ADDREF(*aTemp);
-    return NS_OK;
-}
-
-/**
- * Run a category of Xalan tests
- */
-void runCategory(nsIFile* aConfCat, nsIFile* aGoldCat, nsIFile* aRefTmp,
-                 txRDFOut* aOut)
-{
-    nsresult rv;
-    //clone the nsIFiles, so that we can return easily
-    nsCOMPtr<nsIFile> conf, gold;
-    aConfCat->Clone(getter_AddRefs(conf));
-    aGoldCat->Clone(getter_AddRefs(gold));
-    nsCAutoString catName, refTmp;
-    conf->GetNativeLeafName(catName);
-    aRefTmp->GetNativePath(refTmp);
-    txRDFOut results(catName, aOut);
-    nsCOMPtr<nsISimpleEnumerator> tests;
-    rv = conf->GetDirectoryEntries(getter_AddRefs(tests));
-    if (NS_FAILED(rv))
-        return;
-    PRBool hasMore, isFile;
-    nsCAutoString leaf;
-    NS_NAMED_LITERAL_CSTRING(xsl, ".xsl");
-    while (NS_SUCCEEDED(tests->HasMoreElements(&hasMore)) && hasMore) {
-        nsCOMPtr<nsILocalFile> test;
-        tests->GetNext(getter_AddRefs(test));
-        test->GetNativeLeafName(leaf);
-        if (xsl.Equals(Substring(leaf, leaf.Length()-4, 4))) {
-            // we have a stylesheet, let's look for source and reference
-            nsAFlatCString::char_iterator start, ext;
-            leaf.BeginWriting(start);
-            leaf.EndWriting(ext);
-            ext -= 2;
-            // overwrite extension with .xml
-            *ext = 'm'; // this one was easy
-            nsCOMPtr<nsIFile> source;
-            conf->Clone(getter_AddRefs(source));
-            rv = source->AppendNative(leaf);
-            if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(source->IsFile(&isFile)) &&
-                isFile) {
-                nsCOMPtr<nsIFile> reference;
-                gold->Clone(getter_AddRefs(reference));
-                // overwrite extension with .out
-                --ext;
-                nsCharTraits<char>::copy(ext, "out", 3);
-                rv = reference->AppendNative(leaf);
-                if (NS_SUCCEEDED(rv) &&
-                    NS_SUCCEEDED(reference->IsFile(&isFile)) &&
-                    isFile) {
-                    nsCAutoString src, style, refPath;
-                    test->GetNativePath(style);
-                    source->GetNativePath(src);
-                    reference->GetNativePath(refPath);
-                    if (PR_GetDirectorySeparator() =='\\') {
-                        src.ReplaceChar('\\','/');
-                        style.ReplaceChar('\\','/');
-                        refPath.ReplaceChar('\\','/');
-                    }
-                    SimpleErrorObserver obs;
-                    txStandaloneXSLTProcessor proc;
-                    fstream result(refTmp.get(),
-                                   ios::in | ios::out | ios::trunc);
-                    rv = proc.transform(src, style, result, obs);
-                    PRBool success = PR_FALSE;
-                    if (NS_SUCCEEDED(rv)) {
-                        result.flush();
-                        PRInt64 resultSize, refSize;
-                        aRefTmp->GetFileSize(&resultSize);
-                        reference->GetFileSize(&refSize);
-                        result.seekg(0);
-                        int toread = (int)resultSize;
-                        nsCString resContent, refContent;
-                        resContent.SetCapacity(toread);
-                        readToString(result, resContent);
-                        result.close();
-                        ifstream refStream(refPath.get());
-                        toread = (int)refSize;
-                        refContent.SetCapacity(toread);
-                        readToString(refStream, refContent);
-                        refStream.close();
-                        success = resContent.Equals(refContent);
-                    }
-                    ext--;
-                    results.feed(Substring(start, ext), success);
-                }
-            }
-        }
-    }
-}
-/**
- * The Xalan testcases app
- */
-int main(int argc, char** argv)
-{
-#ifdef NS_TRACE_MALLOC
-    NS_TraceMallocStartupArgs(argc, argv);
-#endif
-#ifdef MOZ_JPROF
-    setupProfilingStuff();
-#endif
-    char* xalan = PR_GetEnv("XALAN_DIR");
-    if (!xalan) {
-        printHelp();
-        return 1;
-    }
-    nsresult rv;
-    rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsCOMPtr<nsIFile> conf, gold, resFile;
-    rv = setupXalan(xalan, getter_AddRefs(conf), getter_AddRefs(gold),
-                    getter_AddRefs(resFile));
-    if (NS_FAILED(rv)) {
-        NS_ShutdownXPCOM(nsnull);
-        printHelp();
-        return -1;
-    }
-
-    //-- handle output stream
-    ostream* resultOutput = &cout;
-    ofstream resultFileStream;
-
-    int argn = 1;
-    // skip -- gnu style options
-    while (argn < argc) {
-        nsDependentCString opt(argv[argn]);
-        if (!Substring(opt, 0, 2).EqualsLiteral("--")) {
-            break;
-        }
-        ++argn;
-    }
-    if (argn < argc) {
-        nsDependentCString opt(argv[argn]);
-        if (Substring(opt, 0, 2).EqualsLiteral("-o")) {
-            if (opt.Length() > 2) {
-                const nsAFlatCString& fname = 
-                    PromiseFlatCString(Substring(opt, 2, opt.Length()-2));
-                resultFileStream.open(fname.get(), ios::out);
-            }
-            else {
-                ++argn;
-                if (argn < argc) {
-                    resultFileStream.open(argv[argn], ios::out);
-                }
-            }
-            if (!resultFileStream) {
-                cerr << "error opening output file" << endl;
-                PRBool exists;
-                if (NS_SUCCEEDED(resFile->Exists(&exists)) && exists)
-                    resFile->Remove(PR_FALSE);
-                NS_ShutdownXPCOM(nsnull);
-                return -1;
-            }
-            ++argn;
-            resultOutput = &resultFileStream;
-        }
-    }
-
-    if (!txXSLTProcessor::init()) {
-        PRBool exists;
-        if (NS_SUCCEEDED(resFile->Exists(&exists)) && exists)
-            resFile->Remove(PR_FALSE);
-        NS_ShutdownXPCOM(nsnull);
-        return 1;
-    }
-
-    *resultOutput << "<?xml version=\"1.0\"?>\n" << 
-        "<RDF:RDF xmlns:NC=\"http://home.netscape.com/NC-rdf#\"\n" <<
-        "         xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">" << endl;
-
-    txRDFOut* rdfOut = new txRDFOut(resultOutput);
-    nsCOMPtr<nsIFile> tempFile;
-    if (argn < argc) {
-        // categories are specified
-        while (argn < argc) {
-            nsDependentCString cat(argv[argn++]);
-            rv = conf->AppendNative(cat);
-            if (NS_SUCCEEDED(rv)) {
-                rv = gold->AppendNative(cat);
-                if (NS_SUCCEEDED(rv)) {
-                    runCategory(conf, gold, resFile, rdfOut);
-                    rv = gold->GetParent(getter_AddRefs(tempFile));
-                    NS_ASSERTION(NS_SUCCEEDED(rv), "can't go back?");
-                    gold = tempFile;
-                }
-                rv = conf->GetParent(getter_AddRefs(tempFile));
-                NS_ASSERTION(NS_SUCCEEDED(rv), "can't go back?");
-                conf = tempFile;
-            }
-        }
-    }
-    else {
-        // no category specified, do everything
-        nsCOMPtr<nsISimpleEnumerator> cats;
-        rv = conf->GetDirectoryEntries(getter_AddRefs(cats));
-        PRBool hasMore, isDir;
-        nsCAutoString leaf;
-        while (NS_SUCCEEDED(cats->HasMoreElements(&hasMore)) && hasMore) {
-            nsCOMPtr<nsILocalFile> cat;
-            cats->GetNext(getter_AddRefs(cat));
-            rv = cat->IsDirectory(&isDir);
-            if (NS_SUCCEEDED(rv) && isDir) {
-                rv = cat->GetNativeLeafName(leaf);
-                if (NS_SUCCEEDED(rv) && 
-                    !leaf.EqualsLiteral("CVS")) {
-                    rv = gold->AppendNative(leaf);
-                    if (NS_SUCCEEDED(rv)) {
-                        runCategory(cat, gold, resFile, rdfOut);
-                        rv = gold->GetParent(getter_AddRefs(tempFile));
-                        gold = tempFile;
-                    }
-                }
-            }
-        }
-    }
-    delete rdfOut;
-    rdfOut = nsnull;
-    *resultOutput << "</RDF:RDF>" << endl;
-    PRBool exists;
-    if (NS_SUCCEEDED(resFile->Exists(&exists)) && exists)
-        resFile->Remove(PR_FALSE);
-    resultFileStream.close();
-    txXSLTProcessor::shutdown();
-    rv = NS_ShutdownXPCOM(nsnull);
-#ifdef NS_TRACE_MALLOC
-    NS_TraceMallocShutdown();
-#endif
-    NS_ENSURE_SUCCESS(rv, rv);
-    return 0;
-}
deleted file mode 100644
--- a/content/xslt/src/main/transformiix.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * The MITRE Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "txStandaloneXSLTProcessor.h"
-#include "nsXPCOM.h"
-#include <fstream.h>
-#include "nsDoubleHashtable.h"
-#include "nsTArray.h"
-#ifdef MOZ_JPROF
-#include "jprof.h"
-#endif
-
-/**
- * Prints the command line help screen to the console
- */
-void printHelp()
-{
-  cerr << "transfrmx [-h] [-i xml-file] [-s xslt-file] [-o output-file]" << endl << endl;
-  cerr << "Options:";
-  cerr << endl << endl;
-  cerr << "\t-i  specify XML file to process" << endl;
-  cerr << "\t-s  specify XSLT file to use for processing (default: use stylesheet" << endl
-       << "\t\tspecified in XML file)" << endl;
-  cerr << "\t-o  specify output file (default: write to stdout)" << endl;
-  cerr << "\t-h  this help screen" << endl;
-  cerr << endl;
-  cerr << "You may use '-' in place of the output-file to explicitly specify" << endl;
-  cerr << "standard output." << endl;
-  cerr << endl;
-}
-
-/**
- * Prints the command line usage information to the console
- */
-void printUsage()
-{
-  cerr << "transfrmx [-h] [-i xml-file] [-s xslt-file] [-o output-file]" << endl << endl;
-  cerr << "For more infomation use the -h flag" << endl;
-}
-
-class txOptionEntry : public PLDHashCStringEntry
-{
-public:
-    txOptionEntry(const void* aKey) : PLDHashCStringEntry(aKey)
-    {
-    }
-    nsTArray<nsCString> mValues;
-};
-
-DECL_DHASH_WRAPPER(txOptions, txOptionEntry, nsACString&)
-DHASH_WRAPPER(txOptions, txOptionEntry, nsACString&)
-
-/**
- * Parses the command line
- */
-void parseCommandLine(int argc, char** argv, txOptions& aOptions)
-{
-    nsCAutoString flag;
-
-    for (int i = 1; i < argc; ++i) {
-        nsDependentCString arg(argv[i]);
-        if (*argv[i] == '-' && arg.Length() > 1) {
-            // clean up previous flag
-            if (!flag.IsEmpty()) {
-                aOptions.AddEntry(flag);
-                flag.Truncate();
-            }
-
-            // get next flag
-            flag = Substring(arg, 1, arg.Length() - 1);
-        }
-        else {
-            txOptionEntry* option = aOptions.AddEntry(flag);
-            if (option) {
-                option->mValues.AppendElement(nsCString(arg));
-            }
-            flag.Truncate();
-        }
-    }
-
-    if (!flag.IsEmpty()) {
-        aOptions.AddEntry(flag);
-    }
-}
-
-/**
- * The TransforMiiX command line interface
- */
-int main(int argc, char** argv)
-{
-    using namespace std;
-    nsresult rv;
-#ifdef MOZ_JPROF
-    setupProfilingStuff();
-#endif
-    rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    if (!txXSLTProcessor::init())
-        return 1;
-
-    txOptions options;
-    if (NS_FAILED(options.Init(4))) {
-        return 1;
-    }
-    parseCommandLine(argc, argv, options);
-
-    if (!options.GetEntry(NS_LITERAL_CSTRING("q"))) {
-        NS_NAMED_LITERAL_CSTRING(copyright, "(C) 1999 The MITRE Corporation, Keith Visco, and contributors");
-        cerr << "TransforMiiX ";
-        cerr << MOZILLA_VERSION << endl;
-        cerr << copyright.get() << endl;
-        //-- print banner line
-        PRUint32 fillSize = copyright.Length() + 1;
-        PRUint32 counter;
-        for (counter = 0; counter < fillSize; ++counter)
-            cerr << '-';
-        cerr << endl << endl;
-    }
-
-    if (options.GetEntry(NS_LITERAL_CSTRING("h"))) {
-        printHelp();
-        return 0;
-    }
-
-    //-- handle output stream
-    ostream* resultOutput = &cout;
-    ofstream resultFileStream;
-
-    txOptionEntry* option = options.GetEntry(NS_LITERAL_CSTRING("o"));
-    if (option &&
-        option->mValues.Length() > 0 &&
-        !option->mValues[0].EqualsLiteral("-")) {
-        resultFileStream.open(option->mValues[0].get(), ios::out);
-        if (!resultFileStream) {
-            cerr << "error opening output file: ";
-            cerr << option->mValues[0].get() << endl;
-            return -1;
-        }
-        resultOutput = &resultFileStream;
-    }
-
-    option = options.GetEntry(NS_LITERAL_CSTRING("i"));
-    if (!option || option->mValues.Length() == 0) {
-        cerr << "you must specify at least a source XML path" << endl;
-        printUsage();
-        return -1;
-    }
-
-    SimpleErrorObserver obs;
-    txStandaloneXSLTProcessor proc;
-
-    txOptionEntry* styleOption = options.GetEntry(NS_LITERAL_CSTRING("s"));
-    if (!styleOption || styleOption->mValues.Length() == 0) {
-        rv = proc.transform(option->mValues[0], *resultOutput, obs);
-    }
-    else {
-        // XXX TODO: Handle multiple stylesheets
-        rv = proc.transform(option->mValues[0], styleOption->mValues[0],
-                            *resultOutput, obs);
-    }
-
-    if (NS_FAILED(rv)) {
-        cerr << "transformation failed with " << hex << rv << endl;
-    }
-
-    resultFileStream.close();
-    txXSLTProcessor::shutdown();
-    rv = NS_ShutdownXPCOM(nsnull);
-    NS_ENSURE_SUCCESS(rv, rv);
-    return 0;
-}
deleted file mode 100644
--- a/content/xslt/src/main/txTestExpr.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Axel Hecht.
- * Portions created by the Initial Developer are Copyright (C) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Axel Hecht <axel@pike.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsXPCOM.h"
-#include "txStandaloneXSLTProcessor.h"
-#include "nsString.h"
-#include "nsTArray.h"
-#include "txExprParser.h"
-#include "txIXPathContext.h"
-
-/**
- * A ExprParser test exe
- */
-
-static const char* kTokens[] = {"(", "concat", "(", "foo", ",", "'", "bar",
-                                "'",")", "//", ".", "[", "preceding-sibling",
-                                "::", "bar", "]", "/", "*", "[", "23", "]",
-                                "|", "node", "(", ")", ")", "<", "3"};
-static const PRUint8 kCount = sizeof(kTokens)/sizeof(char*);
-
-class ParseContextImpl : public txIParseContext
-{
-public:
-    nsresult
-    resolveNamespacePrefix(nsIAtom* aPrefix, PRInt32& aID)
-    {
-        return NS_ERROR_FAILURE;
-    }
-    nsresult
-    resolveFunctionCall(nsIAtom* aName, PRInt32 aID, FunctionCall** aFunction)
-    {
-        return NS_ERROR_XPATH_UNKNOWN_FUNCTION;
-    }
-    PRBool
-    caseInsensitiveNameTests()
-    {
-        return PR_FALSE;
-    }
-    void
-    SetErrorOffset(PRUint32 aOffset)
-    {
-        mOff = aOffset;
-    }
-    PRUint32 mOff;
-};
-
-static void doTest(const nsASingleFragmentString& aExpr)
-{
-    ParseContextImpl ct;
-    nsAutoPtr<Expr> expression;
-    cout << NS_LossyConvertUTF16toASCII(aExpr).get() << endl;
-    ct.mOff = 0;
-    nsresult rv = txExprParser::createExpr(aExpr, &ct,
-                                           getter_Transfers(expression));
-
-    cout << "createExpr returned " << ios::hex << rv  << ios::dec;
-    cout << " at " << ct.mOff << endl;
-    if (NS_FAILED(rv)) {
-        NS_LossyConvertUTF16toASCII cstring(aExpr);
-        cout << NS_LossyConvertUTF16toASCII(StringHead(aExpr, ct.mOff)).get();
-        cout << " ^ ";
-        cout << NS_LossyConvertUTF16toASCII(StringTail(aExpr, aExpr.Length()-ct.mOff)).get();
-        cout << endl << endl;
-    }
-#ifdef TX_TO_STRING
-    else {
-        nsAutoString expr;
-        expression->toString(expr);
-        cout << "parsed expression: ";
-        cout << NS_LossyConvertUTF16toASCII(expr).get() << endl << endl;
-    }
-#endif
-}
-
-int main(int argc, char** argv)
-{
-    using namespace std;
-    nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    if (!txXSLTProcessor::init())
-        return 1;
-
-    nsAutoString exprOrig, expr;
-    nsTArray<nsString> exprHead, exprTail;
-    PRUint8 i, dropStart, dropEnd;
-    exprHead.AppendElement(NS_ConvertASCIItoUTF16(kTokens[0]));
-    exprTail.AppendiElement(NS_ConvertASCIItoUTF16(kTokens[kCount - 1]));
-    for (i = 2; i < kCount; ++i) {
-        exprHead.AppendElement(exprHead[i - 2] +
-                              NS_ConvertASCIItoUTF16(kTokens[i - 1]));
-        exprTail.AppendElement(NS_ConvertASCIItoUTF16(kTokens[kCount - i]) +
-                              exprTail[i - 2]);
-    }
-    exprOrig = NS_ConvertASCIItoUTF16(kTokens[0]) + exprTail[kCount - 2];
-    cout << NS_LossyConvertUTF16toASCII(exprOrig).get() << endl << endl;
-    for (dropStart = 0; dropStart < kCount - 2; ++dropStart) {
-        doTest(exprTail[kCount - 2 - dropStart]);
-        for (dropEnd = kCount - 3 - dropStart; dropEnd > 0; --dropEnd) {
-            expr = exprHead[dropStart] + exprTail[dropEnd];
-            doTest(expr);
-        }
-        doTest(exprHead[dropStart]);
-    }
-    doTest(exprHead[kCount - 2]);
-
-    txXSLTProcessor::shutdown();
-    rv = NS_ShutdownXPCOM(nsnull);
-    NS_ENSURE_SUCCESS(rv, rv);
-    return 0;
-}
deleted file mode 100644
--- a/content/xslt/src/main/txXSLTMarkDriver.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Axel Hecht <axel@pike.org> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/**
- * Driver for running XSLTMark on standalone
- *
- * See http://www.datapower.com/XSLTMark/
- */
-
-#include "txStandaloneStylesheetCompiler.h"
-#include "txStandaloneXSLTProcessor.h"
-#include "nsXPCOM.h"
-#include "xmExternalDriver.hpp"
-#ifdef MOZ_JPROF
-#include "jprof.h"
-#endif
-
-class txDriverProcessor : public txStandaloneXSLTProcessor,
-                          public xmExternalDriver
-{
-public:
-    txDriverProcessor() : mXML(0), mOut(0)
-    {
-    }
-
-    int loadStylesheet (char * filename)
-    {
-        txParsedURL url;
-        url.init(NS_ConvertASCIItoUTF16(filename));
-        nsresult rv =
-            TX_CompileStylesheetPath(url, getter_AddRefs(mStylesheet));
-        return NS_SUCCEEDED(rv) ? 0 : 1;
-    }
-    int setInputDocument (char * filename)
-    {
-        delete mXML;
-        mXML = parsePath(nsDependentCString(filename), mObserver);
-        return mXML ? 0 : 1;
-    }
-    int openOutput (char * outputFilename)
-    {
-        mOut = new ofstream(outputFilename);
-        return mXML ? 0 : 1;
-    }
-    int runTransform ()
-    {
-        if (!mXML || !mStylesheet || !mOut)
-            return 1;
-        nsresult rv = transform(*mXML, mStylesheet, *mOut, mObserver);
-        return NS_FAILED(rv);
-    }
-    int closeOutput ()
-    {
-        if (mOut)
-            mOut->close();
-        delete mOut;
-        mOut = 0;
-        return 0;
-    }
-    int terminate()
-    {
-        delete mXML;
-        mXML = 0;
-        if (mOut && mOut->is_open())
-            mOut->close();
-        delete mOut;
-        mOut = 0;
-        mStylesheet = 0;
-        return 0;
-    }
-    ~txDriverProcessor()
-    {
-        delete mXML;
-        delete mOut;
-    }
-private:
-    txXPathNode *mXML;
-    nsRefPtr<txStylesheet> mStylesheet;
-    SimpleErrorObserver mObserver;
-    ofstream* mOut;
-};
-
-int main (int argc, char ** argv)
-{
-    txDriverProcessor driver;
-#ifdef MOZ_JPROF
-    setupProfilingStuff();
-#endif
-    NS_InitXPCOM2(nsnull, nsnull, nsnull);
-    if (!txDriverProcessor::init())
-        return 1;
-    driver.main (argc, argv);
-    txDriverProcessor::shutdown();
-    NS_ShutdownXPCOM(nsnull);
-    return 0;
-}
--- a/content/xslt/src/xml/Makefile.in
+++ b/content/xslt/src/xml/Makefile.in
@@ -41,33 +41,21 @@ srcdir          = @srcdir@
 VPATH           = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = transformiix
 LIBRARY_NAME = txxml_s
 LIBXUL_LIBRARY = 1
 
-
-
 CPPSRCS	= \
 	txXMLUtils.cpp \
 	txXMLParser.cpp \
 	$(NULL)
 
-ifdef MOZ_XSLT_STANDALONE
-CPPSRCS += \
-	txAttr.cpp \
-	txDocument.cpp \
-	txElement.cpp \
-	txNodeDefinition.cpp \
-	txProcessingInstruction.cpp \
-	$(NULL)
-endif
-
 # we don't want the shared lib, but we want to force the creation of a
 # static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES += \
 	-I$(srcdir)/../base \
deleted file mode 100644
--- a/content/xslt/src/xml/txAttr.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * The MITRE Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// Tom Kneeland (3/29/99)
-//
-//  Implementation of the Document Object Model Level 1 Core
-//    Implementation of the Attr class
-//
-
-#include "txDOM.h"
-#include "txAtoms.h"
-#include "txXMLUtils.h"
-
-Attr::Attr(nsIAtom *aPrefix, nsIAtom *aLocalName, PRInt32 aNamespaceID,
-           Element *aOwnerElement, const nsAString &aValue) :
-    NodeDefinition(Node::ATTRIBUTE_NODE, aLocalName, aValue,
-                   aOwnerElement->getOwnerDocument()),
-    mPrefix(aPrefix),
-    mNamespaceID(aNamespaceID),
-    mOwnerElement(aOwnerElement)
-{
-}
-
-//
-//Not implemented anymore, return null as an error.
-//
-Node* Attr::appendChild(Node* newChild)
-{
-  NS_ERROR("not implemented");
-  return nsnull;
-}
-
-nsresult
-Attr::getNodeName(nsAString& aName) const
-{
-  if (mPrefix) {
-    mPrefix->ToString(aName);
-    aName.Append(PRUnichar(':'));
-  }
-  else {
-    aName.Truncate();
-  }
-
-  const char* ASCIIAtom;
-  mLocalName->GetUTF8String(&ASCIIAtom);
-  AppendUTF8toUTF16(ASCIIAtom, aName);
-
-  return NS_OK;
-}
-
-//
-//Return the attributes local (unprefixed) name atom.
-//
-MBool Attr::getLocalName(nsIAtom** aLocalName)
-{
-  if (!aLocalName)
-    return MB_FALSE;
-  *aLocalName = mLocalName;
-  NS_ADDREF(*aLocalName);
-  return MB_TRUE;
-}
-
-//
-//Return the namespace the attribute belongs to. If the attribute doesn't
-//have a prefix it doesn't belong to any namespace per the namespace spec,
-//and is handled in the constructor.
-//
-PRInt32 Attr::getNamespaceID()
-{
-  return mNamespaceID;
-}
-
-//
-//Return the attributes owning element
-//
-Node* Attr::getXPathParent()
-{
-  return mOwnerElement;
-}
deleted file mode 100644
--- a/content/xslt/src/xml/txDocument.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * The MITRE Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// Tom Kneeland (3/29/99)
-//
-//  Implementation of the Document Object Model Level 1 Core
-//    Implementation of the Document class
-//
-// Modification History:
-// Who  When        What
-// TK   03/29/99    Created
-// LF   08/06/1999  Removed Default argument initializer from
-//                  Document() constructor
-// LF   08/06/1999  fixed typo: defalut to default
-//
-
-#include "txDOM.h"
-#include "txAtoms.h"
-
-//
-//Construct a Document.  Currently no parameters are required, but the the
-//node constructor is called to identify the node type.
-//
-Document::Document() :
-  NodeDefinition(Node::DOCUMENT_NODE, txXMLAtoms::document, EmptyString(),
-                 nsnull),
-  documentElement(nsnull)
-{
-  mIDMap.Init(0);
-}
-
-//
-//Return the one and only element for this document
-//
-Element* Document::getDocumentElement()
-{
-  return documentElement;
-}
-
-Element*
-Document::createElementNS(nsIAtom *aPrefix, nsIAtom *aLocalName,
-                          PRInt32 aNamespaceID)
-{
-  return new Element(aPrefix, aLocalName, aNamespaceID, this);
-}
-
-//
-//Construct a text node with the given data
-//
-Node* Document::createTextNode(const nsAString& theData)
-{
-  return new NodeDefinition(Node::TEXT_NODE, txXMLAtoms::text, theData, this);
-}
-
-//
-//Construct a comment node with the given data
-//
-Node* Document::createComment(const nsAString& theData)
-{
-  return new NodeDefinition(Node::COMMENT_NODE, txXMLAtoms::comment, theData,
-                            this);
-}
-
-//
-//Construct a ProcessingInstruction node with the given targe and data.
-//
-ProcessingInstruction*
-  Document::createProcessingInstruction(nsIAtom *aTarget,
-                                        const nsAString& data)
-{
-  return new ProcessingInstruction(aTarget, data, this);
-}
-
-//
-//Return an Element by ID, introduced by DOM2
-//
-DHASH_WRAPPER(txIDMap, txIDEntry, nsAString&)
-
-Element* Document::getElementById(const nsAString& aID)
-{
-  txIDEntry* entry = mIDMap.GetEntry(aID);
-  if (entry)
-    return entry->mElement;
-  return nsnull;
-}
-
-/**
- * private setter for element ID
- */
-PRBool
-Document::setElementID(const nsAString& aID, Element* aElement)
-{
-  txIDEntry* id = mIDMap.AddEntry(aID);
-  // make sure IDs are unique
-  if (id->mElement) {
-    return PR_FALSE;
-  }
-  id->mElement = aElement;
-  id->mElement->setIDValue(aID);
-  return PR_TRUE;
-}
-
-Node* Document::appendChild(Node* newChild)
-{
-  unsigned short nodeType = newChild->getNodeType();
-
-  // Convert to a NodeDefinition Pointer
-  NodeDefinition* pNewChild = (NodeDefinition*)newChild;
-
-  if (pNewChild->parentNode == this)
-    {
-      pNewChild = implRemoveChild(pNewChild);
-      if (nodeType == Node::ELEMENT_NODE)
-        documentElement = nsnull;
-    }
-
-  switch (nodeType)
-    {
-      case Node::PROCESSING_INSTRUCTION_NODE :
-      case Node::COMMENT_NODE :
-      case Node::DOCUMENT_TYPE_NODE :
-        return implAppendChild(pNewChild);
-
-      case Node::ELEMENT_NODE :
-        if (!documentElement)
-          {
-            Node* returnVal = implAppendChild(pNewChild);
-            documentElement = (Element*)pNewChild;
-            return returnVal;
-          }
-
-      default:
-        break;
-    }
-
-  return nsnull;
-}
-
-nsresult Document::getBaseURI(nsAString& aURI)
-{
-  aURI = documentBaseURI;
-  return NS_OK;
-}
deleted file mode 100644
--- a/content/xslt/src/xml/txElement.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * The MITRE Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// Tom Kneeland (3/29/99)
-//
-//  Implementation of the Document Object Model Level 1 Core
-//    Implementation of the Element class
-//
-
-#include "txDOM.h"
-#include "txAtoms.h"
-#include "txXMLUtils.h"
-
-Element::Element(nsIAtom *aPrefix, nsIAtom *aLocalName, PRInt32 aNamespaceID,
-                 Document* aOwner) :
-  NodeDefinition(Node::ELEMENT_NODE, aLocalName, EmptyString(), aOwner),
-  mPrefix(aPrefix),
-  mNamespaceID(aNamespaceID)
-{
-}
-
-Node* Element::appendChild(Node* newChild)
-{
-  switch (newChild->getNodeType())
-    {
-      case Node::ELEMENT_NODE :
-      case Node::TEXT_NODE :
-      case Node::COMMENT_NODE :
-      case Node::PROCESSING_INSTRUCTION_NODE :
-        {
-          // Remove the "newChild" if it is already a child of this node
-          NodeDefinition* pNewChild = (NodeDefinition*)newChild;
-          if (pNewChild->getParentNode() == this)
-            pNewChild = implRemoveChild(pNewChild);
-
-          return implAppendChild(pNewChild);
-        }
-
-      default:
-        break;
-    }
-
-  return nsnull;
-}
-
-nsresult
-Element::getNodeName(nsAString& aName) const
-{
-  if (mPrefix) {
-    mPrefix->ToString(aName);
-    aName.Append(PRUnichar(':'));
-  }
-  else {
-    aName.Truncate();
-  }
-
-  const char* ASCIIAtom;
-  mLocalName->GetUTF8String(&ASCIIAtom);
-  AppendUTF8toUTF16(ASCIIAtom, aName);
-
-  return NS_OK;
-}
-
-//
-//Return the elements local (unprefixed) name.
-//
-MBool Element::getLocalName(nsIAtom** aLocalName)
-{
-  if (!aLocalName)
-    return MB_FALSE;
-  *aLocalName = mLocalName;
-  NS_ADDREF(*aLocalName);
-  return MB_TRUE;
-}
-
-//
-//Return the namespace the elements belongs to.
-//
-PRInt32 Element::getNamespaceID()
-{
-  return mNamespaceID;
-}
-
-nsresult
-Element::appendAttributeNS(nsIAtom *aPrefix, nsIAtom *aLocalName,
-                           PRInt32 aNamespaceID, const nsAString& aValue)
-{
-  nsAutoPtr<Attr> newAttribute;
-  newAttribute = new Attr(aPrefix, aLocalName, aNamespaceID, this, aValue);
-  if (!newAttribute) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  if (mFirstAttribute) {
-    Attr *lastAttribute = mFirstAttribute;
-    while (lastAttribute->mNextAttribute) {
-      lastAttribute = lastAttribute->mNextAttribute;
-    }
-    lastAttribute->mNextAttribute = newAttribute;
-  }
-  else {
-    mFirstAttribute = newAttribute;
-  }
-
-  return NS_OK;
-}
-
-//
-// Return true if the attribute specified by localname and nsID
-// exists, and sets aValue to the value of the attribute.
-// Return false, if the attribute does not exist.
-//
-MBool Element::getAttr(nsIAtom* aLocalName, PRInt32 aNSID,
-                       nsAString& aValue)
-{
-  aValue.Truncate();
-  Attr *attribute = mFirstAttribute;
-  while (attribute) {
-    if (attribute->equals(aLocalName, aNSID)) {
-      attribute->getNodeValue(aValue);
-
-      return PR_TRUE;
-    }
-
-    attribute = attribute->mNextAttribute;
-  }
-
-  return PR_FALSE;
-}
-
-//
-// Return true if the attribute specified by localname and nsID
-// exists. Return false otherwise.
-//
-MBool Element::hasAttr(nsIAtom* aLocalName, PRInt32 aNSID)
-{
-  Attr *attribute = mFirstAttribute;
-  while (attribute) {
-    if (attribute->equals(aLocalName, aNSID)) {
-      return PR_TRUE;
-    }
-
-    attribute = attribute->mNextAttribute;
-  }
-
-  return PR_FALSE;
-}
-
-/**
- * ID accessors. Getter used for id() patterns, private setter for parser
- */
-PRBool
-Element::getIDValue(nsAString& aValue)
-{
-  if (mIDValue.IsEmpty()) {
-    return PR_FALSE;
-  }
-  aValue = mIDValue;
-  return PR_TRUE;
-}
-
-void
-Element::setIDValue(const nsAString& aValue)
-{
-  mIDValue = aValue;
-}
deleted file mode 100644
--- a/content/xslt/src/xml/txNodeDefinition.cpp
+++ /dev/null
@@ -1,378 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * The MITRE Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// Tom Kneeland (3/29/99)
-//
-//  Implementation of the Document Object Model Level 1 Core
-//    Implementation of the NodeDefinition Class
-//
-// Modification History:
-// Who  When      What
-// TK   03/29/99  Created
-//
-
-#include "txDOM.h"
-#include "nsTArray.h"
-#include "txURIUtils.h"
-#include "txAtoms.h"
-#include <string.h>
-
-NodeDefinition::NodeDefinition(NodeType type, nsIAtom *aLocalName,
-                               const nsAString& value, Document* owner) :
-    mLocalName(aLocalName),
-    nodeValue(value),
-    nodeType(type),
-    parentNode(nsnull),
-    previousSibling(nsnull),
-    nextSibling(nsnull),
-    ownerDocument(owner),
-    length(0),
-    firstChild(nsnull),
-    lastChild(nsnull),
-    mOrderInfo(nsnull)
-{
-}
-
-//
-// This node is being destroyed, so loop through and destroy all the children.
-//
-NodeDefinition::~NodeDefinition()
-{
-  NodeDefinition* pCurrent = firstChild;
-  NodeDefinition* pDestroyer;
-
-  while (pCurrent)
-    {
-      pDestroyer = pCurrent;
-      pCurrent = pCurrent->nextSibling;
-      delete pDestroyer;
-    }
-
-  delete mOrderInfo;
-}
-
-nsresult NodeDefinition::getNodeName(nsAString& aName) const
-{
-  mLocalName->ToString(aName);
-  return NS_OK;
-}
-
-nsresult NodeDefinition::getNodeValue(nsAString& aValue)
-{
-  aValue = nodeValue;
-  return NS_OK;
-}
-
-unsigned short NodeDefinition::getNodeType() const
-{
-  return nodeType;
-}
-
-Node* NodeDefinition::getParentNode() const
-{
-  return parentNode;
-}
-
-Node* NodeDefinition::getFirstChild() const
-{
-  return firstChild;
-}
-
-Node* NodeDefinition::getLastChild() const
-{
-  return lastChild;
-}
-
-Node* NodeDefinition::getPreviousSibling() const
-{
-  return previousSibling;
-}
-
-Node* NodeDefinition::getNextSibling() const
-{
-  return nextSibling;
-}
-
-Document* NodeDefinition::getOwnerDocument() const
-{
-  return ownerDocument;
-}
-
-Node* NodeDefinition::appendChild(Node* newChild)
-{
-  return nsnull;
-}
-
-NodeDefinition* NodeDefinition::implAppendChild(NodeDefinition* newChild)
-{
-  // The new child should not be a child of any other node
-  if (!newChild->previousSibling && !newChild->nextSibling &&
-      !newChild->parentNode)
-    {
-      newChild->previousSibling = lastChild;
-
-      if (lastChild)
-        lastChild->nextSibling = newChild;
-
-      lastChild = newChild;
-
-      newChild->parentNode = this;
-
-      if (!newChild->previousSibling)
-        firstChild = newChild;
-
-      ++length;
-
-      return newChild;
-    }
-
-  return nsnull;
-}
-
-NodeDefinition* NodeDefinition::implRemoveChild(NodeDefinition* oldChild)
-{
-  if (oldChild != firstChild)
-    oldChild->previousSibling->nextSibling = oldChild->nextSibling;
-  else
-    firstChild = oldChild->nextSibling;
-
-  if (oldChild != lastChild)
-    oldChild->nextSibling->previousSibling = oldChild->previousSibling;
-  else
-    lastChild = oldChild->previousSibling;
-
-  oldChild->nextSibling = nsnull;
-  oldChild->previousSibling = nsnull;
-  oldChild->parentNode = nsnull;
-
-  --length;
-
-  return oldChild;
-}
-
-MBool NodeDefinition::hasChildNodes() const
-{
-  if (firstChild)
-    return MB_TRUE;
-  else
-    return MB_FALSE;
-}
-
-MBool NodeDefinition::getLocalName(nsIAtom** aLocalName)
-{
-  if (!aLocalName)
-    return MB_FALSE;
-  *aLocalName = 0;
-  return MB_TRUE;
-}
-
-nsresult NodeDefinition::getNamespaceURI(nsAString& aNSURI)
-{
-  return txStandaloneNamespaceManager::getNamespaceURI(getNamespaceID(),
-                                                       aNSURI);
-}
-
-PRInt32 NodeDefinition::getNamespaceID()
-{
-  return kNameSpaceID_None;
-}
-
-Node* NodeDefinition::getXPathParent()
-{
-  return parentNode;
-}
-
-//
-// Returns the base URI of the node. Acccounts for xml:base
-// attributes.
-//
-// @return base URI for the node
-//
-nsresult NodeDefinition::getBaseURI(nsAString& aURI)
-{
-  Node* node = this;
-  nsTArray<nsString> baseUrls;
-  nsAutoString url;
-
-  while (node) {
-    switch (node->getNodeType()) {
-      case Node::ELEMENT_NODE :
-        if (((Element*)node)->getAttr(txXMLAtoms::base, kNameSpaceID_XML,
-                                      url))
-          baseUrls.AppendElement(url);
-        break;
-
-      case Node::DOCUMENT_NODE :
-        node->getBaseURI(url);
-        baseUrls.AppendElement(url);
-        break;
-    
-      default:
-        break;
-    }
-    node = node->getXPathParent();
-  }
-
-  PRUint32 count = baseUrls.Length();
-  if (count) {
-    aURI = baseUrls[--count];
-
-    while (count > 0) {
-      nsAutoString dest;
-      URIUtils::resolveHref(baseUrls[--count], aURI, dest);
-      aURI = dest;
-    }
-  }
-  
-  return NS_OK;
-} // getBaseURI
-
-/*
- * Compares document position of this node relative to another node
- */
-PRInt32 NodeDefinition::compareDocumentPosition(Node* aOther)
-{
-  OrderInfo* myOrder = getOrderInfo();
-  OrderInfo* otherOrder = ((NodeDefinition*)aOther)->getOrderInfo();
-  if (!myOrder || !otherOrder)
-      return -1;
-
-  if (myOrder->mRoot == otherOrder->mRoot) {
-    int c = 0;
-    while (c < myOrder->mSize && c < otherOrder->mSize) {
-      if (myOrder->mOrder[c] < otherOrder->mOrder[c])
-        return -1;
-      if (myOrder->mOrder[c] > otherOrder->mOrder[c])
-        return 1;
-      ++c;
-    }
-    if (c < myOrder->mSize)
-      return 1;
-    if (c < otherOrder->mSize)
-      return -1;
-    return 0;
-  }
-
-  if (myOrder->mRoot < otherOrder->mRoot)
-    return -1;
-
-  return 1;
-}
-
-/*
- * Get order information for node
- */
-NodeDefinition::OrderInfo* NodeDefinition::getOrderInfo()
-{
-  if (mOrderInfo)
-    return mOrderInfo;
-
-  mOrderInfo = new OrderInfo;
-  if (!mOrderInfo)
-    return 0;
-
-  Node* parent = getXPathParent();
-  if (!parent) {
-    mOrderInfo->mOrder = 0;
-    mOrderInfo->mSize = 0;
-    mOrderInfo->mRoot = this;
-    return mOrderInfo;
-  }
-
-  OrderInfo* parentOrder = ((NodeDefinition*)parent)->getOrderInfo();
-  mOrderInfo->mSize = parentOrder->mSize + 1;
-  mOrderInfo->mRoot = parentOrder->mRoot;
-  mOrderInfo->mOrder = new PRUint32[mOrderInfo->mSize];
-  if (!mOrderInfo->mOrder) {
-    delete mOrderInfo;
-    mOrderInfo = 0;
-    return 0;
-  }
-  memcpy(mOrderInfo->mOrder,
-         parentOrder->mOrder,
-         parentOrder->mSize * sizeof(PRUint32*));
-
-  // Get childnumber of this node
-  int lastElem = parentOrder->mSize;
-  switch (getNodeType()) {
-    case Node::ATTRIBUTE_NODE:
-    {
-      NS_ASSERTION(parent->getNodeType() == Node::ELEMENT_NODE,
-                   "parent to attribute is not an element");
-
-      Element* elem = (Element*)parent;
-      Attr *attribute = elem->getFirstAttribute();
-      PRUint32 i = 0;
-      while (attribute) {
-        if (attribute == this) {
-          mOrderInfo->mOrder[lastElem] = i + kTxAttrIndexOffset;
-          return mOrderInfo;
-        }
-        attribute = attribute->getNextAttribute();
-        ++i;
-      }
-      break;
-    }
-    // XXX Namespace: need to take care of namespace nodes here
-    default:
-    {
-      PRUint32 i = 0;
-      Node * child = parent->getFirstChild();
-      while (child) {
-        if (child == this) {
-          mOrderInfo->mOrder[lastElem] = i + kTxChildIndexOffset;
-          return mOrderInfo;
-        }
-        ++i;
-        child = child->getNextSibling();
-      }
-      break;
-    }
-  }
-
-  NS_ERROR("unable to get childnumber");
-  mOrderInfo->mOrder[lastElem] = 0;
-  return mOrderInfo;
-}
-
-/*
- * OrderInfo destructor
- */
-NodeDefinition::OrderInfo::~OrderInfo()
-{
-    delete [] mOrder;
-}
deleted file mode 100644
--- a/content/xslt/src/xml/txProcessingInstruction.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * The MITRE Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// Tom Kneeland (3/29/99)
-//
-//  Implementation of the Document Object Model Level 1 Core
-//    Implementation of the ProcessingInstruction class
-//
-// Modification History:
-// Who  When      What
-// TK   03/29/99  Created
-//
-
-#include "txDOM.h"
-#include "nsIAtom.h"
-
-//
-//Construct a text object with the specified document owner and data
-//
-ProcessingInstruction::ProcessingInstruction(nsIAtom *theTarget,
-                                             const nsAString& theData,
-                                             Document* owner) :
-  NodeDefinition(Node::PROCESSING_INSTRUCTION_NODE, theTarget, theData, owner)
-{
-}
-
-//
-//ProcessingInstruction nodes can not have any children, so just return null
-//from all child manipulation functions.
-//
-
-MBool ProcessingInstruction::getLocalName(nsIAtom** aLocalName)
-{
-  if (!aLocalName)
-    return MB_FALSE;
-  *aLocalName = mLocalName;
-  NS_ADDREF(*aLocalName);
-  return MB_TRUE;
-}
--- a/content/xslt/src/xml/txXMLParser.cpp
+++ b/content/xslt/src/xml/txXMLParser.cpp
@@ -35,68 +35,28 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "txXMLParser.h"
 #include "txURIUtils.h"
 #include "txXPathTreeWalker.h"
 
-#ifndef TX_EXE
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsSyncLoadService.h"
 #include "nsNetUtil.h"
 #include "nsIPrincipal.h"
-#else
-#include "expat_config.h"
-#include "expat.h"
-#include "txXMLUtils.h"
-#endif
-
-#ifdef TX_EXE
-/**
- *  Implementation of an In-Memory DOM based XML parser.  The actual XML
- *  parsing is provided by EXPAT.
- */
-class txXMLParser
-{
-  public:
-    nsresult parse(istream& aInputStream, const nsAString& aUri,
-                   txXPathNode** aResultDoc);
-    const nsAString& getErrorString();
-
-    /**
-     * Expat handlers
-     */
-    int StartElement(const XML_Char *aName, const XML_Char **aAtts);
-    int EndElement(const XML_Char* aName);
-    void CharacterData(const XML_Char* aChars, int aLength);
-    void Comment(const XML_Char* aChars);
-    int ProcessingInstruction(const XML_Char *aTarget, const XML_Char *aData);
-    int ExternalEntityRef(const XML_Char *aContext, const XML_Char *aBase,
-                          const XML_Char *aSystemId,
-                          const XML_Char *aPublicId);
-
-  protected:
-    void createErrorString();
-    nsString  mErrorString;
-    Document* mDocument;
-    Node*  mCurrentNode;
-    XML_Parser mExpatParser;
-};
-#endif
 
 nsresult
 txParseDocumentFromURI(const nsAString& aHref, const txXPathNode& aLoader,
                        nsAString& aErrMsg, txXPathNode** aResult)
 {
     NS_ENSURE_ARG_POINTER(aResult);
     *aResult = nsnull;
-#ifndef TX_EXE
     nsCOMPtr<nsIURI> documentURI;
     nsresult rv = NS_NewURI(getter_AddRefs(documentURI), aHref);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsIDocument* loaderDocument = txXPathNativeNode::getDocument(aLoader);
 
     nsCOMPtr<nsILoadGroup> loadGroup = loaderDocument->GetDocumentLoadGroup();
 
@@ -118,316 +78,9 @@ txParseDocumentFromURI(const nsAString& 
 
     *aResult = txXPathNativeNode::createXPathNode(theDocument);
     if (!*aResult) {
         NS_RELEASE(theDocument);
         return NS_ERROR_FAILURE;
     }
 
     return NS_OK;
-#else
-    istream* xslInput = URIUtils::getInputStream(aHref, aErrMsg);
-    if (!xslInput) {
-        return NS_ERROR_FAILURE;
-    }
-    return txParseFromStream(*xslInput, aHref, aErrMsg, aResult);
-#endif
 }
-
-#ifdef TX_EXE
-nsresult
-txParseFromStream(istream& aInputStream, const nsAString& aUri,
-                  nsAString& aErrorString, txXPathNode** aResult)
-{
-    NS_ENSURE_ARG_POINTER(aResult);
-    txXMLParser parser;
-    nsresult rv = parser.parse(aInputStream, aUri, aResult);
-    aErrorString = parser.getErrorString();
-    return rv;
-}
-
-/**
- * expat C stub handlers
- */
-
-// shortcut macro for redirection into txXMLParser method calls
-#define TX_XMLPARSER(_userData) static_cast<txXMLParser*>(_userData)
-#define TX_ENSURE_DATA(_userData)                       \
-  PR_BEGIN_MACRO                                        \
-    if (!aUserData) {                                   \
-        NS_WARNING("no userData in comment handler");   \
-        return;                                         \
-    }                                                   \
-  PR_END_MACRO
-
-static void
-startElement(void *aUserData, const XML_Char *aName, const XML_Char **aAtts)
-{
-    TX_ENSURE_DATA(aUserData);
-    TX_XMLPARSER(aUserData)->StartElement(aName, aAtts);
-}
-
-static void
-endElement(void *aUserData, const XML_Char* aName)
-{
-    TX_ENSURE_DATA(aUserData);
-    TX_XMLPARSER(aUserData)->EndElement(aName);
-}
-
-static void
-charData(void* aUserData, const XML_Char* aChars, int aLength)
-{
-    TX_ENSURE_DATA(aUserData);
-    TX_XMLPARSER(aUserData)->CharacterData(aChars, aLength);
-}
-
-static void
-commentHandler(void* aUserData, const XML_Char* aChars)
-{
-    TX_ENSURE_DATA(aUserData);
-    TX_XMLPARSER(aUserData)->Comment(aChars);
-}
-
-static void
-piHandler(void *aUserData, const XML_Char *aTarget, const XML_Char *aData)
-{
-    TX_ENSURE_DATA(aUserData);
-    TX_XMLPARSER(aUserData)->ProcessingInstruction(aTarget, aData);
-}
-
-static int
-externalEntityRefHandler(XML_Parser aParser,
-                         const XML_Char *aContext,
-                         const XML_Char *aBase,
-                         const XML_Char *aSystemId,
-                         const XML_Char *aPublicId)
-{
-    // aParser is aUserData is the txXMLParser,
-    // we set that in txXMLParser::parse
-    NS_ENSURE_TRUE(aParser, XML_ERROR_NONE);
-    return ((txXMLParser*)aParser)->ExternalEntityRef(aContext, aBase,
-                                                      aSystemId, aPublicId);
-}
-
-
-/**
- *  Parses the given input stream and returns a DOM Document.
- *  A NULL pointer will be returned if errors occurred
- */
-nsresult
-txXMLParser::parse(istream& aInputStream, const nsAString& aUri,
-                   txXPathNode** aResultDoc)
-{
-    mErrorString.Truncate();
-    *aResultDoc = nsnull;
-    if (!aInputStream) {
-        mErrorString.AppendLiteral("unable to parse xml: invalid or unopen stream encountered.");
-        return NS_ERROR_FAILURE;
-    }
-
-    static const XML_Memory_Handling_Suite memsuite = {
-        (void *(*)(size_t))PR_Malloc,
-        (void *(*)(void *, size_t))PR_Realloc,
-        PR_Free
-    };
-    static const PRUnichar expatSeparator = kExpatSeparatorChar;
-    mExpatParser = XML_ParserCreate_MM(nsnull, &memsuite, &expatSeparator);
-    if (!mExpatParser) {
-        return NS_ERROR_OUT_OF_MEMORY;
-    }
-    mDocument = new Document();
-    if (!mDocument) {
-        XML_ParserFree(mExpatParser);
-        return NS_ERROR_OUT_OF_MEMORY;
-    }
-    mDocument->documentBaseURI = aUri;
-    mCurrentNode = mDocument;
-
-    XML_SetReturnNSTriplet(mExpatParser, XML_TRUE);
-    XML_SetUserData(mExpatParser, this);
-    XML_SetElementHandler(mExpatParser, startElement, endElement);
-    XML_SetCharacterDataHandler(mExpatParser, charData);
-    XML_SetProcessingInstructionHandler(mExpatParser, piHandler);
-    XML_SetCommentHandler(mExpatParser, commentHandler);
-#ifdef XML_DTD
-    XML_SetParamEntityParsing(mExpatParser, XML_PARAM_ENTITY_PARSING_ALWAYS);
-#endif
-    XML_SetExternalEntityRefHandler(mExpatParser, externalEntityRefHandler);
-    XML_SetExternalEntityRefHandlerArg(mExpatParser, this);
-    XML_SetBase(mExpatParser,
-                (const XML_Char*)(PromiseFlatString(aUri).get()));
-
-    const int bufferSize = 1024;
-    char buf[bufferSize];
-    PRBool done;
-    do {
-        aInputStream.read(buf, bufferSize);
-        done = aInputStream.eof();
-
-        if (!XML_Parse(mExpatParser, buf, aInputStream.gcount(), done)) {
-            createErrorString();
-            done = MB_TRUE;
-            delete mDocument;
-            mDocument = nsnull;
-        }
-    } while (!done);
-    aInputStream.clear();
-
-    // clean up
-    XML_ParserFree(mExpatParser);
-    // ownership to the caller
-    *aResultDoc = txXPathNativeNode::createXPathNode(mDocument);
-    mDocument = nsnull;
-    return *aResultDoc ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
-}
-
-const nsAString&
-txXMLParser::getErrorString()
-{
-    return mErrorString;
-}
-
-
-int
-txXMLParser::StartElement(const XML_Char *aName, const XML_Char **aAtts)
-{
-    nsCOMPtr<nsIAtom> prefix, localName;
-    PRInt32 nsID;
-    XMLUtils::splitExpatName(aName, getter_AddRefs(prefix),
-                             getter_AddRefs(localName), &nsID);
-    Element* newElement = mDocument->createElementNS(prefix, localName, nsID);
-    if (!newElement) {
-        return XML_ERROR_NO_MEMORY;
-    }
-
-    const XML_Char** theAtts = aAtts;
-    while (*theAtts) {
-        XMLUtils::splitExpatName(*theAtts++, getter_AddRefs(prefix),
-                                 getter_AddRefs(localName), &nsID);
-        nsDependentString attValue(*theAtts++);
-        nsresult rv = newElement->appendAttributeNS(prefix, localName, nsID,
-                                                    attValue);
-        if (NS_FAILED(rv)) {
-            return XML_ERROR_NO_MEMORY;
-        }
-    }
-
-    int idx;
-    if ((idx = XML_GetIdAttributeIndex(mExpatParser)) > -1) {
-        nsDependentString idName((const PRUnichar*)*(aAtts + idx));
-        nsDependentString idValue((const PRUnichar*)*(aAtts + idx + 1));
-        // make sure IDs are unique
-        if (!idValue.IsEmpty()) {
-            mDocument->setElementID(idValue, newElement);
-        }
-    }
-    mCurrentNode->appendChild(newElement);
-    mCurrentNode = newElement;
-
-    return XML_ERROR_NONE;
-}
-
-int
-txXMLParser::EndElement(const XML_Char* aName)
-{
-    if (mCurrentNode->getParentNode()) {
-        mCurrentNode = mCurrentNode->getParentNode();
-    }
-    return XML_ERROR_NONE;
-}
-
-void
-txXMLParser::CharacterData(const XML_Char* aChars, int aLength)
-{
-    Node* prevSib = mCurrentNode->getLastChild();
-    const PRUnichar* pChars = static_cast<const PRUnichar*>(aChars);
-    if (prevSib && prevSib->getNodeType() == Node::TEXT_NODE) {
-        static_cast<NodeDefinition*>(prevSib)->appendData(pChars, aLength);
-    }
-    else {
-        // aChars is not null-terminated so we use Substring here.
-        Node* node = mDocument->createTextNode(Substring(pChars,
-                                                         pChars + aLength));
-        mCurrentNode->appendChild(node);
-    }
-}
-
-void
-txXMLParser::Comment(const XML_Char* aChars)
-{
-    Node* node = mDocument->createComment(
-        nsDependentString(static_cast<const PRUnichar*>(aChars)));
-    mCurrentNode->appendChild(node);
-}
-
-int
-txXMLParser::ProcessingInstruction(const XML_Char *aTarget,
-                                   const XML_Char *aData)
-{
-    nsCOMPtr<nsIAtom> target = do_GetAtom(aTarget);
-    nsDependentString data((const PRUnichar*)aData);
-    Node* node = mDocument->createProcessingInstruction(target, data);
-    mCurrentNode->appendChild(node);
-
-    return XML_ERROR_NONE;
-}
-
-int
-txXMLParser::ExternalEntityRef(const XML_Char *aContext,
-                               const XML_Char *aBase,
-                               const XML_Char *aSystemId,
-                               const XML_Char *aPublicId)
-{
-    if (aPublicId) {
-        // not supported, this is "http://some.site.net/foo.dtd" stuff
-        return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-    }
-    nsAutoString absUrl;
-    URIUtils::resolveHref(nsDependentString((PRUnichar*)aSystemId),
-                          nsDependentString((PRUnichar*)aBase), absUrl);
-    istream* extInput = URIUtils::getInputStream(absUrl, mErrorString);
-    if (!extInput) {
-        return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-    }
-    XML_Parser parent = mExpatParser;
-    mExpatParser = 
-        XML_ExternalEntityParserCreate(mExpatParser, aContext, nsnull);
-    if (!mExpatParser) {
-        mExpatParser = parent;
-        delete extInput;
-        return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-    }
-    XML_SetBase(mExpatParser, absUrl.get());
-
-    const int bufSize = 1024;
-    char buffer[bufSize];
-    int result;
-    PRBool done;
-    do {
-        extInput->read(buffer, bufSize);
-        done = extInput->eof();
-        if (!(result =
-              XML_Parse(mExpatParser, buffer,  extInput->gcount(), done))) {
-            createErrorString();
-            mErrorString.Append(PRUnichar('\n'));
-            done = MB_TRUE;
-        }
-    } while (!done);
-
-    delete extInput;
-    XML_ParserFree(mExpatParser);
-
-    mExpatParser = parent;
-
-    return result;
-}
-
-void
-txXMLParser::createErrorString()
-{
-    XML_Error errCode = XML_GetErrorCode(mExpatParser);
-    mErrorString.AppendWithConversion(XML_ErrorString(errCode));
-    mErrorString.AppendLiteral(" at line ");
-    mErrorString.AppendInt(XML_GetCurrentLineNumber(mExpatParser));
-    mErrorString.AppendLiteral(" in ");
-    mErrorString.Append((const PRUnichar*)XML_GetBase(mExpatParser));
-}
-#endif
--- a/content/xslt/src/xml/txXMLParser.h
+++ b/content/xslt/src/xml/txXMLParser.h
@@ -36,36 +36,24 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef MITRE_XMLPARSER_H
 #define MITRE_XMLPARSER_H
 
 #include "txCore.h"
 
-#ifdef TX_EXE
-#include <iostream.h>
-#endif
-
 class txXPathNode;
 
 /**
  * API to load XML files into DOM datastructures.
  * Parsing is either done by expat, or by expat via the syncloaderservice
  */
 
 /**
  * Parse a document from the aHref location, with referrer URI on behalf
  * of the document aLoader.
  */
 extern "C" nsresult
 txParseDocumentFromURI(const nsAString& aHref, const txXPathNode& aLoader,
                        nsAString& aErrMsg, txXPathNode** aResult);
 
-#ifdef TX_EXE
-/**
- * Parse a document from the given stream
- */
-extern "C" nsresult
-txParseFromStream(istream& aInputStream, const nsAString& aUri,
-                  nsAString& aErrorString, txXPathNode** aResult);
 #endif
-#endif
--- a/content/xslt/src/xml/txXMLUtils.h
+++ b/content/xslt/src/xml/txXMLUtils.h
@@ -43,21 +43,18 @@
 #ifndef MITRE_XMLUTILS_H
 #define MITRE_XMLUTILS_H
 
 #include "txCore.h"
 #include "nsCOMPtr.h"
 #include "nsDependentSubstring.h"
 #include "nsIAtom.h"
 #include "txXPathNode.h"
-
-#ifndef TX_EXE
 #include "nsIParserService.h"
 #include "nsContentUtils.h"
-#endif
 
 #define kExpatSeparatorChar 0xFFFF
 
 class nsIAtom;
 class txNamespaceMap;
 
 class txExpandedName {
 public:
@@ -109,23 +106,16 @@ public:
         return ((mLocalName != rhs.mLocalName) ||
                 (mNamespaceID != rhs.mNamespaceID));
     }
 
     PRInt32 mNamespaceID;
     nsCOMPtr<nsIAtom> mLocalName;
 };
 
-#ifdef TX_EXE
-extern "C" int MOZ_XMLCheckQName(const char* ptr, const char* end,
-                                 int ns_aware, const char** colon);
-extern "C" int MOZ_XMLIsLetter(const char* ptr);
-extern "C" int MOZ_XMLIsNCNameChar(const char* ptr);
-#endif
-
 class XMLUtils {
 
 public:
     static nsresult splitExpatName(const PRUnichar *aExpatName,
                                    nsIAtom **aPrefix, nsIAtom **aLocalName,
                                    PRInt32* aNameSpaceID);
     static nsresult splitQName(const nsAString& aName, nsIAtom** aPrefix,
                                nsIAtom** aLocalName);
@@ -152,58 +142,36 @@ public:
     static void normalizePIValue(nsAString& attValue);
 
     /**
      * Returns true if the given string is a valid XML QName
      */
     static PRBool isValidQName(const nsAFlatString& aQName,
                                const PRUnichar** aColon)
     {
-#ifdef TX_EXE
-        const PRUnichar* end;
-        aQName.EndReading(end);
-
-        const char *colonPtr;
-        int result = MOZ_XMLCheckQName(reinterpret_cast<const char*>
-                                                       (aQName.get()),
-                                       reinterpret_cast<const char*>
-                                                       (end),
-                                       PR_TRUE, &colonPtr);
-        *aColon = reinterpret_cast<const PRUnichar*>(colonPtr);
-        return result == 0;
-#else
         nsIParserService* ps = nsContentUtils::GetParserService();
         return ps && NS_SUCCEEDED(ps->CheckQName(aQName, PR_TRUE, aColon));
-#endif
     }
 
     /**
      * Returns true if the given character represents an Alpha letter
      */
     static PRBool isLetter(PRUnichar aChar)
     {
-#ifdef TX_EXE
-        return MOZ_XMLIsLetter(reinterpret_cast<const char*>(&aChar));
-#else
         nsIParserService* ps = nsContentUtils::GetParserService();
         return ps && ps->IsXMLLetter(aChar);
-#endif
     }
 
     /**
      * Returns true if the given character is an allowable NCName character
      */
     static PRBool isNCNameChar(PRUnichar aChar)
     {
-#ifdef TX_EXE
-        return MOZ_XMLIsNCNameChar(reinterpret_cast<const char*>(&aChar));
-#else
         nsIParserService* ps = nsContentUtils::GetParserService();
         return ps && ps->IsXMLNCNameChar(aChar);
-#endif
     }
 
     /*
      * Walks up the document tree and returns true if the closest xml:space
      * attribute is "preserve"
      */
     static MBool getXMLSpacePreserve(const txXPathNode& aNode);
 };
--- a/content/xslt/src/xpath/Makefile.in
+++ b/content/xslt/src/xpath/Makefile.in
@@ -41,18 +41,16 @@ srcdir          = @srcdir@
 VPATH           = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = transformiix
 LIBRARY_NAME = txxpath_s
 LIBXUL_LIBRARY = 1
 
-
-
 CPPSRCS = \
         txBooleanExpr.cpp \
         txBooleanResult.cpp \
         txCoreFunctionCall.cpp \
         txExpr.cpp \
         txExprLexer.cpp \
         txExprParser.cpp \
         txFilterExpr.cpp \
@@ -74,28 +72,24 @@ CPPSRCS = \
         txNodeTypeTest.cpp \
         txForwardContext.cpp \
         txNodeSetContext.cpp \
         txResultRecycler.cpp \
         txUnionExpr.cpp \
         txUnionNodeTest.cpp \
         txUnaryExpr.cpp \
         txVariableRefExpr.cpp \
-        txXPathOptimizer.cpp
-ifndef MOZ_XSLT_STANDALONE
-CPPSRCS += nsXPathEvaluator.cpp \
-           nsXPathExpression.cpp \
-           nsXPathNSResolver.cpp \
-           nsXPathResult.cpp \
-           txMozillaXPathTreeWalker.cpp \
-           txNodeSetAdaptor.cpp \
-           txXPCOMExtensionFunction.cpp
-else
-CPPSRCS += txStandaloneXPathTreeWalker.cpp
-endif
+        txXPathOptimizer.cpp \
+        nsXPathEvaluator.cpp \
+        nsXPathExpression.cpp \
+        nsXPathNSResolver.cpp \
+        nsXPathResult.cpp \
+        txMozillaXPathTreeWalker.cpp \
+        txNodeSetAdaptor.cpp \
+        txXPCOMExtensionFunction.cpp
 
 # we don't want the shared lib, but we want to force the creation of a
 # static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES += \
--- a/content/xslt/src/xpath/txNameTest.cpp
+++ b/content/xslt/src/xpath/txNameTest.cpp
@@ -68,20 +68,18 @@ PRBool txNameTest::matches(const txXPath
     }
 
     // Totally wild?
     if (mLocalName == txXPathAtoms::_asterix && !mPrefix)
         return MB_TRUE;
 
     // Compare namespaces
     if (mNamespace != txXPathNodeUtils::getNamespaceID(aNode) 
-#ifndef TX_EXE
         && !(mNamespace == kNameSpaceID_None &&
              txXPathNodeUtils::isHTMLElementInHTMLDocument(aNode))
-#endif
        )
         return MB_FALSE;
 
     // Name wild?
     if (mLocalName == txXPathAtoms::_asterix)
         return MB_TRUE;
 
     // Compare local-names
deleted file mode 100644
--- a/content/xslt/src/xpath/txStandaloneXPathTreeWalker.cpp
+++ /dev/null
@@ -1,446 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Peter Van der Beken <peterv@propagandism.org>
- *   Axel Hecht <axel@pike.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "txXPathTreeWalker.h"
-#include "nsPrintfCString.h"
-#include "nsReadableUtils.h"
-#include "nsString.h"
-#include "txXMLUtils.h"
-
-txXPathTreeWalker::txXPathTreeWalker(const txXPathTreeWalker& aOther)
-    : mPosition(aOther.mPosition)
-{
-}
-
-txXPathTreeWalker::txXPathTreeWalker(const txXPathNode& aNode)
-    : mPosition(aNode)
-{
-}
-
-#define INNER mPosition.mInner
-
-void
-txXPathTreeWalker::moveToRoot()
-{
-    if (INNER->nodeType != Node::DOCUMENT_NODE) {
-        INNER = INNER->ownerDocument;
-    }
-}
-
-PRBool
-txXPathTreeWalker::moveToElementById(const nsAString& aID)
-{
-    Document* document;
-    if (INNER->nodeType == Node::DOCUMENT_NODE) {
-        document = static_cast<Document*>(INNER);
-    }
-    else {
-        document = INNER->ownerDocument;
-    }
-
-    Element* element =
-        document->getElementById(aID);
-    if (!element) {
-        return PR_FALSE;
-    }
-
-    INNER = element;
-
-    return PR_TRUE;
-}
-
-PRBool
-txXPathTreeWalker::moveToFirstAttribute()
-{
-    if (INNER->nodeType != Node::ELEMENT_NODE) {
-        return PR_FALSE;
-    }
-
-    Element* element = static_cast<Element*>(INNER);
-    Attr *attribute = element->getFirstAttribute();
-    while (attribute) {
-        if (attribute->getNamespaceID() != kNameSpaceID_XMLNS) {
-            INNER = attribute;
-
-            return PR_TRUE;
-        }
-
-        attribute = attribute->getNextAttribute();
-    }
-
-    return PR_FALSE;
-}
-
-PRBool
-txXPathTreeWalker::moveToNextAttribute()
-{
-    // XXX an assertion should be enough here with the current code
-    if (INNER->nodeType != Node::ATTRIBUTE_NODE) {
-        return PR_FALSE;
-    }
-
-    Element* element = static_cast<Element*>(INNER->getXPathParent());
-    Attr *attribute = element->getFirstAttribute();
-    while (attribute != INNER) {
-        attribute = attribute->getNextAttribute();
-    }
-    NS_ASSERTION(attribute, "Attr not attribute of it's owner?");
-
-    attribute = attribute->getNextAttribute();
-
-    while (attribute) {
-        if (attribute->getNamespaceID() != kNameSpaceID_XMLNS) {
-            INNER = attribute;
-
-            return PR_TRUE;
-        }
-
-        attribute = attribute->getNextAttribute();
-    }
-
-    return PR_FALSE;
-}
-
-PRBool
-txXPathTreeWalker::moveToNamedAttribute(nsIAtom* aLocalName, PRInt32 aNSID)
-{
-    if (INNER->nodeType != Node::ELEMENT_NODE) {
-        return PR_FALSE;
-    }
-
-    Element* element = static_cast<Element*>(INNER);
-    NamedNodeMap* attrs = element->getAttributes();
-    NodeListDefinition::ListItem* item = attrs->firstItem;
-    // find requested attribute
-    nsCOMPtr<nsIAtom> localName;
-    while (item && (item->node->getNamespaceID() != aNSID ||
-                    !item->node->getLocalName(getter_AddRefs(localName)) || 
-                    localName != aLocalName) {
-        item = item->next;
-    }
-    if (!item) {
-        return PR_FALSE;
-    }
-
-    INNER = static_cast<NodeDefinition*>(item->node);
-    return PR_TRUE;
-}
-
-PRBool
-txXPathTreeWalker::moveToFirstChild()
-{
-    if (!INNER->firstChild) {
-        return PR_FALSE;
-    }
-
-    INNER = INNER->firstChild;
-
-    return PR_TRUE;
-}
-
-PRBool
-txXPathTreeWalker::moveToLastChild()
-{
-    if (!INNER->lastChild) {
-        return PR_FALSE;
-    }
-
-    INNER = INNER->lastChild;
-
-    return PR_TRUE;
-}
-
-PRBool
-txXPathTreeWalker::moveToNextSibling()
-{
-    if (!INNER->nextSibling) {
-        return PR_FALSE;
-    }
-
-    INNER = INNER->nextSibling;
-
-    return PR_TRUE;
-}
-
-PRBool
-txXPathTreeWalker::moveToPreviousSibling()
-{
-    if (!INNER->previousSibling) {
-        return PR_FALSE;
-    }
-
-    INNER = INNER->previousSibling;
-
-    return PR_TRUE;
-}
-
-PRBool
-txXPathTreeWalker::moveToParent()
-{
-    if (INNER->nodeType == Node::ATTRIBUTE_NODE) {
-        INNER = static_cast<NodeDefinition*>(INNER->getXPathParent());
-        return PR_TRUE;
-    }
-
-    if (INNER->nodeType == Node::DOCUMENT_NODE) {
-        return PR_FALSE;
-    }
-
-    NS_ASSERTION(INNER->parentNode, "orphaned node shouldn't happen");
-
-    INNER = INNER->parentNode;
-
-    return PR_TRUE;
-}
-
-txXPathNode::txXPathNode(const txXPathNode& aNode)
-    : mInner(aNode.mInner)
-{
-}
-
-PRBool
-txXPathNode::operator==(const txXPathNode& aNode) const
-{
-    return (mInner == aNode.mInner);
-}
-
-/* static */
-PRBool
-txXPathNodeUtils::getAttr(const txXPathNode& aNode, nsIAtom* aLocalName,
-                          PRInt32 aNSID, nsAString& aValue)
-{
-    if (aNode.mInner->getNodeType() != Node::ELEMENT_NODE) {
-        return PR_FALSE;
-    }
-
-    Element* elem = static_cast<Element*>(aNode.mInner);
-    return elem->getAttr(aLocalName, aNSID, aValue);
-}
-
-/* static */
-already_AddRefed<nsIAtom>
-txXPathNodeUtils::getLocalName(const txXPathNode& aNode)
-{
-    nsIAtom* localName;
-    return aNode.mInner->getLocalName(&localName) ? localName : nsnull;
-}
-
-/* static */
-void
-txXPathNodeUtils::getLocalName(const txXPathNode& aNode, nsAString& aLocalName)
-{
-    nsCOMPtr<nsIAtom> localName;
-    PRBool hasName = aNode.mInner->getLocalName(getter_AddRefs(localName));
-    if (hasName && localName) {
-        localName->ToString(aLocalName);
-    }
-}
-
-/* static */
-void
-txXPathNodeUtils::getNodeName(const txXPathNode& aNode, nsAString& aName)
-{
-    aNode.mInner->getNodeName(aName);
-}
-
-/* static */
-PRInt32
-txXPathNodeUtils::getNamespaceID(const txXPathNode& aNode)
-{
-    return aNode.mInner->getNamespaceID();
-}
-
-/* static */
-void
-txXPathNodeUtils::getNamespaceURI(const txXPathNode& aNode, nsAString& aURI)
-{
-    aNode.mInner->getNamespaceURI(aURI);
-}
-
-/* static */
-PRUint16
-txXPathNodeUtils::getNodeType(const txXPathNode& aNode)
-{
-    return aNode.mInner->getNodeType();
-}
-
-/* static */
-void
-txXPathNodeUtils::appendNodeValueHelper(NodeDefinition* aNode,
-                                        nsAString& aResult)
-{
-
-    NodeDefinition* child = static_cast<NodeDefinition*>
-                                       (aNode->getFirstChild());
-    while (child) {
-        switch (child->getNodeType()) {
-            case Node::TEXT_NODE:
-            {
-                aResult.Append(child->nodeValue);
-            }
-            case Node::ELEMENT_NODE:
-            {
-                appendNodeValueHelper(child, aResult);
-            }
-        }
-        child = static_cast<NodeDefinition*>(child->getNextSibling());
-    }
-}
-
-/* static */
-void
-txXPathNodeUtils::appendNodeValue(const txXPathNode& aNode, nsAString& aResult)
-{
-    unsigned short type = aNode.mInner->getNodeType();
-    if (type == Node::ATTRIBUTE_NODE ||
-        type == Node::COMMENT_NODE ||
-        type == Node::PROCESSING_INSTRUCTION_NODE ||
-        type == Node::TEXT_NODE) {
-        aResult.Append(aNode.mInner->nodeValue);
-
-        return;
-    }
-
-    NS_ASSERTION(type == Node::ELEMENT_NODE || type == Node::DOCUMENT_NODE,
-                 "Element or Document expected");
-
-    appendNodeValueHelper(aNode.mInner, aResult);
-}
-
-/* static */
-PRBool
-txXPathNodeUtils::isWhitespace(const txXPathNode& aNode)
-{
-    NS_ASSERTION(aNode.mInner->nodeType == Node::TEXT_NODE, "Wrong type!");
-
-    return XMLUtils::isWhitespace(aNode.mInner->nodeValue);
-}
-
-/* static */
-txXPathNode*
-txXPathNodeUtils::getDocument(const txXPathNode& aNode)
-{
-    if (aNode.mInner->nodeType == Node::DOCUMENT_NODE) {
-        return new txXPathNode(aNode);
-    }
-
-    return new txXPathNode(aNode.mInner->ownerDocument);
-}
-
-/* static */
-txXPathNode*
-txXPathNodeUtils::getOwnerDocument(const txXPathNode& aNode)
-{
-    return getDocument(aNode);
-}
-
-#ifndef HAVE_64BIT_OS
-#define kFmtSize 13
-const char gPrintfFmt[] = "id0x%08p";
-#else
-#define kFmtSize 21
-const char gPrintfFmt[] = "id0x%016p";
-#endif
-
-/* static */
-nsresult
-txXPathNodeUtils::getXSLTId(const txXPathNode& aNode,
-                            nsAString& aResult)
-{
-    CopyASCIItoUTF16(nsPrintfCString(kFmtSize, gPrintfFmt, aNode.mInner),
-                    aResult);
-
-    return NS_OK;
-}
-
-/* static */
-void
-txXPathNodeUtils::getBaseURI(const txXPathNode& aNode, nsAString& aURI)
-{
-    aNode.mInner->getBaseURI(aURI);
-}
-
-/* static */
-PRIntn
-txXPathNodeUtils::comparePosition(const txXPathNode& aNode,
-                                  const txXPathNode& aOtherNode)
-{
-    // First check for equal nodes.
-    if (aNode == aOtherNode) {
-        return 0;
-    }
-    return aNode.mInner->compareDocumentPosition(aOtherNode.mInner);
-}
-
-/* static */
-txXPathNode*
-txXPathNativeNode::createXPathNode(Node* aNode)
-{
-    if (aNode != nsnull) {
-        return new txXPathNode(static_cast<NodeDefinition*>(aNode));
-    }
-    return nsnull;
-}
-
-/* static */
-nsresult
-txXPathNativeNode::getElement(const txXPathNode& aNode, Element** aResult)
-{
-    if (aNode.mInner->getNodeType() != Node::ELEMENT_NODE) {
-        return NS_ERROR_FAILURE;
-    }
-
-    *aResult = static_cast<Element*>(aNode.mInner);
-
-    return NS_OK;
-
-}
-
-/* static */
-nsresult
-txXPathNativeNode::getDocument(const txXPathNode& aNode, Document** aResult)
-{
-    if (aNode.mInner->getNodeType() != Node::DOCUMENT_NODE) {
-        return NS_ERROR_FAILURE;
-    }
-
-    *aResult = static_cast<Document*>(aNode.mInner);
-
-    return NS_OK;
-}
--- a/content/xslt/src/xpath/txXPathNode.h
+++ b/content/xslt/src/xpath/txXPathNode.h
@@ -34,32 +34,24 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef txXPathNode_h__
 #define txXPathNode_h__
 
-#ifdef TX_EXE
-#include "txDOM.h"
-#else
 #include "nsAutoPtr.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDOMNode.h"
 #include "nsINameSpaceManager.h"
 #include "nsContentUtils.h"
-#endif
 
-#ifdef TX_EXE
-typedef Node txXPathNodeType;
-#else
 typedef nsIDOMNode txXPathNodeType;
-#endif
 
 class txXPathNode
 {
 public:
     PRBool operator==(const txXPathNode& aNode) const;
     PRBool operator!=(const txXPathNode& aNode) const
     {
         return !(*this == aNode);
@@ -69,23 +61,16 @@ public:
 private:
     friend class txNodeSet;
     friend class txXPathNativeNode;
     friend class txXPathNodeUtils;
     friend class txXPathTreeWalker;
 
     txXPathNode(const txXPathNode& aNode);
 
-#ifdef TX_EXE
-    txXPathNode(NodeDefinition* aNode) : mInner(aNode)
-    {
-    }
-
-    NodeDefinition* mInner;
-#else
     txXPathNode(nsIDocument* aDocument) : mNode(aDocument),
                                           mRefCountRoot(0),
                                           mIndex(eDocument)
     {
         MOZ_COUNT_CTOR(txXPathNode);
     }
     txXPathNode(nsINode *aNode, PRUint32 aIndex, nsINode *aRoot)
         : mNode(aNode),
@@ -143,55 +128,42 @@ private:
     {
         eDocument = (1 << 30),
         eContent = eDocument - 1
     };
 
     nsINode* mNode;
     PRUint32 mRefCountRoot : 1;
     PRUint32 mIndex : 31;
-#endif
 };
 
 class txNamespaceManager
 {
 public:
     static PRInt32 getNamespaceID(const nsAString& aNamespaceURI);
     static nsresult getNamespaceURI(const PRInt32 aID, nsAString& aResult);
 };
 
 /* static */
 inline PRInt32
 txNamespaceManager::getNamespaceID(const nsAString& aNamespaceURI)
 {
-#ifdef TX_EXE
-    return txStandaloneNamespaceManager::getNamespaceID(aNamespaceURI);
-#else
     PRInt32 namespaceID = kNameSpaceID_Unknown;
     nsContentUtils::NameSpaceManager()->
         RegisterNameSpace(aNamespaceURI, namespaceID);
     return namespaceID;
-#endif
 }
 
 /* static */
 inline nsresult
 txNamespaceManager::getNamespaceURI(const PRInt32 aID, nsAString& aResult)
 {
-#ifdef TX_EXE
-    return txStandaloneNamespaceManager::getNamespaceURI(aID, aResult);
-#else
     return nsContentUtils::NameSpaceManager()->
         GetNameSpaceURI(aID, aResult);
-#endif
 }
 
 inline PRBool
 txXPathNode::operator==(const txXPathNode& aNode) const
 {
-#ifdef TX_EXE
-    return (mInner == aNode.mInner);
-#else
     return mIndex == aNode.mIndex && mNode == aNode.mNode;
-#endif
 }
 
 #endif /* txXPathNode_h__ */
--- a/content/xslt/src/xpath/txXPathTreeWalker.h
+++ b/content/xslt/src/xpath/txXPathTreeWalker.h
@@ -36,22 +36,21 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef txXPathTreeWalker_h__
 #define txXPathTreeWalker_h__
 
 #include "txCore.h"
 #include "txXPathNode.h"
+#include "nsINodeInfo.h"
+#include "nsTArray.h"
 
 class nsIAtom;
-
-#ifndef TX_EXE
-#include "nsINodeInfo.h"
-#include "nsTArray.h"
+class nsIDOMDocument;
 
 class txUint32Array : public nsTArray<PRUint32>
 {
 public:
     PRBool AppendValue(PRUint32 aValue)
     {
         return AppendElement(aValue) != nsnull;
     }
@@ -63,19 +62,16 @@ public:
         return PR_TRUE;
     }
     PRUint32 ValueAt(PRUint32 aIndex) const
     {
         return (aIndex < Length()) ? ElementAt(aIndex) : 0;
     }
 };
 
-class nsIDOMDocument;
-#endif
-
 class txXPathTreeWalker
 {
 public:
     txXPathTreeWalker(const txXPathTreeWalker& aOther);
     explicit txXPathTreeWalker(const txXPathNode& aNode);
 
     PRBool getAttr(nsIAtom* aLocalName, PRInt32 aNSID, nsAString& aValue) const;
     PRInt32 getNamespaceID() const;
@@ -98,23 +94,21 @@ public:
 
     PRBool isOnNode(const txXPathNode& aNode) const;
 
     const txXPathNode& getCurrentPosition() const;
 
 private:
     txXPathNode mPosition;
 
-#ifndef TX_EXE
     PRBool moveToValidAttribute(PRUint32 aStartIndex);
     PRBool moveToSibling(PRInt32 aDir);
 
     PRUint32 mCurrentIndex;
     txUint32Array mDescendants;
-#endif
 };
 
 class txXPathNodeUtils
 {
 public:
     static PRBool getAttr(const txXPathNode& aNode, nsIAtom* aLocalName,
                           PRInt32 aNSID, nsAString& aValue);
     static already_AddRefed<nsIAtom> getLocalName(const txXPathNode& aNode);
@@ -139,40 +133,26 @@ public:
     static PRBool localNameEquals(const txXPathNode& aNode,
                                   nsIAtom* aLocalName);
     static PRBool isRoot(const txXPathNode& aNode);
     static PRBool isElement(const txXPathNode& aNode);
     static PRBool isAttribute(const txXPathNode& aNode);
     static PRBool isProcessingInstruction(const txXPathNode& aNode);
     static PRBool isComment(const txXPathNode& aNode);
     static PRBool isText(const txXPathNode& aNode);
-#ifndef TX_EXE
     static inline PRBool isHTMLElementInHTMLDocument(const txXPathNode& aNode)
     {
       if (!aNode.isContent()) {
         return PR_FALSE;
       }
       nsIContent* content = aNode.Content();
       return content->IsHTML() && content->IsInHTMLDocument();
     }
-#else
-private:
-    static void appendNodeValueHelper(NodeDefinition* aNode, nsAString& aResult);
-#endif
 };
 
-#ifdef TX_EXE
-class txXPathNativeNode
-{
-public:
-    static txXPathNode* createXPathNode(Node* aNode);
-    static nsresult getElement(const txXPathNode& aNode, Element** aResult);
-    static nsresult getDocument(const txXPathNode& aNode, Document** aResult);
-};
-#else
 class txXPathNativeNode
 {
 public:
     static txXPathNode* createXPathNode(nsIDOMNode* aNode,
                                         PRBool aKeepRootAlive = PR_FALSE);
     static txXPathNode* createXPathNode(nsIContent* aContent,
                                         PRBool aKeepRootAlive = PR_FALSE);
     static txXPathNode* createXPathNode(nsIDOMDocument* aDocument);
@@ -185,18 +165,16 @@ public:
     }
     static void release(const txXPathNode& aNode)
     {
         nsINode *node = aNode.mNode;
         NS_RELEASE(node);
     }
 };
 
-#endif
-
 inline const txXPathNode&
 txXPathTreeWalker::getCurrentPosition() const
 {
     return mPosition;
 }
 
 inline PRBool
 txXPathTreeWalker::getAttr(nsIAtom* aLocalName, PRInt32 aNSID,
@@ -221,19 +199,16 @@ inline void
 txXPathTreeWalker::getNodeName(nsAString& aName) const
 {
     txXPathNodeUtils::getNodeName(mPosition, aName);
 }
 
 inline void
 txXPathTreeWalker::moveTo(const txXPathTreeWalker& aWalker)
 {
-#ifdef TX_EXE
-    mPosition.mInner = aWalker.mPosition.mInner;
-#else
     nsINode *root = nsnull;
     if (mPosition.mRefCountRoot) {
         root = mPosition.Root();
     }
     mPosition.mIndex = aWalker.mPosition.mIndex;
     mPosition.mRefCountRoot = aWalker.mPosition.mRefCountRoot;
     mPosition.mNode = aWalker.mPosition.mNode;
     nsINode *newRoot = nsnull;
@@ -242,135 +217,95 @@ txXPathTreeWalker::moveTo(const txXPathT
     }
     if (root != newRoot) {
         NS_IF_ADDREF(newRoot);
         NS_IF_RELEASE(root);
     }
 
     mCurrentIndex = aWalker.mCurrentIndex;
     mDescendants.Clear();
-#endif
 }
 
 inline PRBool
 txXPathTreeWalker::isOnNode(const txXPathNode& aNode) const
 {
     return (mPosition == aNode);
 }
 
 /* static */
 inline PRInt32
 txXPathNodeUtils::getUniqueIdentifier(const txXPathNode& aNode)
 {
-#ifdef TX_EXE
-    return NS_PTR_TO_INT32(aNode.mInner);
-#else
     NS_PRECONDITION(!aNode.isAttribute(),
                     "Not implemented for attributes.");
     return NS_PTR_TO_INT32(aNode.mNode);
-#endif
 }
 
 /* static */
 inline void
 txXPathNodeUtils::release(txXPathNode* aNode)
 {
-#ifdef TX_EXE
-    delete aNode->mInner;
-#else
     NS_RELEASE(aNode->mNode);
-#endif
 }
 
 /* static */
 inline PRBool
 txXPathNodeUtils::localNameEquals(const txXPathNode& aNode,
                                   nsIAtom* aLocalName)
 {
-#ifdef TX_EXE
-    nsCOMPtr<nsIAtom> localName;
-    aNode.mInner->getLocalName(getter_AddRefs(localName));
-
-    return localName == aLocalName;
-#else
     if (aNode.isContent() &&
         aNode.Content()->IsElement()) {
         return aNode.Content()->NodeInfo()->Equals(aLocalName);
     }
 
     nsCOMPtr<nsIAtom> localName = txXPathNodeUtils::getLocalName(aNode);
 
     return localName == aLocalName;
-#endif
 }
 
 /* static */
 inline PRBool
 txXPathNodeUtils::isRoot(const txXPathNode& aNode)
 {
-#ifdef TX_EXE
-    return aNode.mInner->getNodeType() == Node::DOCUMENT_NODE;
-#else
     return !aNode.isAttribute() && !aNode.mNode->GetNodeParent();
-#endif
 }
 
 /* static */
 inline PRBool
 txXPathNodeUtils::isElement(const txXPathNode& aNode)
 {
-#ifdef TX_EXE
-    return aNode.mInner->getNodeType() == Node::ELEMENT_NODE;
-#else
     return aNode.isContent() &&
            aNode.Content()->IsElement();
-#endif
 }
 
 
 /* static */
 inline PRBool
 txXPathNodeUtils::isAttribute(const txXPathNode& aNode)
 {
-#ifdef TX_EXE
-    return aNode.mInner->getNodeType() == Node::ATTRIBUTE_NODE;
-#else
     return aNode.isAttribute();
-#endif
 }
 
 /* static */
 inline PRBool
 txXPathNodeUtils::isProcessingInstruction(const txXPathNode& aNode)
 {
-#ifdef TX_EXE
-    return aNode.mInner->getNodeType() == Node::PROCESSING_INSTRUCTION_NODE;
-#else
     return aNode.isContent() &&
            aNode.Content()->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION);
-#endif
 }
 
 /* static */
 inline PRBool
 txXPathNodeUtils::isComment(const txXPathNode& aNode)
 {
-#ifdef TX_EXE
-    return aNode.mInner->getNodeType() == Node::COMMENT_NODE;
-#else
     return aNode.isContent() &&
            aNode.Content()->IsNodeOfType(nsINode::eCOMMENT);
-#endif
 }
 
 /* static */
 inline PRBool
 txXPathNodeUtils::isText(const txXPathNode& aNode)
 {
-#ifdef TX_EXE
-    return aNode.mInner->getNodeType() == Node::TEXT_NODE;
-#else
     return aNode.isContent() &&
            aNode.Content()->IsNodeOfType(nsINode::eTEXT);
-#endif
 }
 
 #endif /* txXPathTreeWalker_h__ */
--- a/content/xslt/src/xslt/Makefile.in
+++ b/content/xslt/src/xslt/Makefile.in
@@ -41,18 +41,16 @@ srcdir          = @srcdir@
 VPATH           = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = transformiix
 LIBRARY_NAME = txxslt_s
 LIBXUL_LIBRARY = 1
 
-
-
 CPPSRCS = \
         txNodeSorter.cpp \
         txXPathResultComparator.cpp \
         txBufferingHandler.cpp \
         txExecutionState.cpp \
         txEXSLTFunctions.cpp \
         txInstructions.cpp \
         txOutputFormat.cpp \
@@ -69,30 +67,21 @@ CPPSRCS = \
         txXSLTProcessor.cpp \
         txPatternParser.cpp \
         txUnknownHandler.cpp \
         txCurrentFunctionCall.cpp \
         txDocumentFunctionCall.cpp \
         txFormatNumberFunctionCall.cpp \
         txGenerateIdFunctionCall.cpp \
         txKeyFunctionCall.cpp \
-        txXSLTEnvironmentFunctionCall.cpp
-
-ifdef MOZ_XSLT_STANDALONE
-CPPSRCS += txHTMLOutput.cpp	\
-           txStandaloneXSLTProcessor.cpp \
-           txStandaloneStylesheetCompiler.cpp \
-           txTextOutput.cpp \
-           txXMLOutput.cpp
-else
-CPPSRCS += txMozillaStylesheetCompiler.cpp \
-           txMozillaTextOutput.cpp \
-           txMozillaXMLOutput.cpp \
-           txMozillaXSLTProcessor.cpp
-endif
+        txXSLTEnvironmentFunctionCall.cpp \
+        txMozillaStylesheetCompiler.cpp \
+        txMozillaTextOutput.cpp \
+        txMozillaXMLOutput.cpp \
+        txMozillaXSLTProcessor.cpp
 
 # For nsDependentJSString
 LOCAL_INCLUDES += \
   -I$(topsrcdir)/dom/base \
   $(NULL)
 
 # we don't want the shared lib, but we want to force the creation of a
 # static lib.
@@ -108,13 +97,9 @@ include $(topsrcdir)/config/rules.mk
 INCLUDES += \
 	-I$(srcdir) \
 	-I$(srcdir)/../base \
 	-I$(srcdir)/../xml \
 	-I$(srcdir)/../xpath \
 	-I$(srcdir)/../../../base/src \
 	$(NULL)
 
-ifdef MOZ_XSLT_STANDALONE
-DEFINES	 += -DXML_DTD -DXML_UNICODE
-else
 DEFINES += -D_IMPL_NS_LAYOUT
-endif
--- a/content/xslt/src/xslt/txEXSLTFunctions.cpp
+++ b/content/xslt/src/xslt/txEXSLTFunctions.cpp
@@ -42,25 +42,22 @@
 #include "txExecutionState.h"
 #include "txExpr.h"
 #include "txIXPathContext.h"
 #include "txNodeSet.h"
 #include "txOutputFormat.h"
 #include "txRtfHandler.h"
 #include "txXPathTreeWalker.h"
 #include "nsPrintfCString.h"
-
-#ifndef TX_EXE
 #include "nsComponentManagerUtils.h"
 #include "nsContentCID.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsIContent.h"
 #include "nsIDOMDocumentFragment.h"
 #include "txMozillaXMLOutput.h"
-#endif
 
 class txStylesheetCompilerState;
 
 // ------------------------------------------------------------------
 // Utility functions
 // ------------------------------------------------------------------
 
 static nsresult
@@ -71,19 +68,16 @@ convertRtfToNode(txIEvalContext *aContex
     if (!es) {
         NS_ERROR("Need txExecutionState!");
 
         return NS_ERROR_UNEXPECTED;
     }
 
     const txXPathNode& document = es->getSourceDocument();
 
-#ifdef TX_EXE
-    return NS_ERROR_NOT_IMPLEMENTED;
-#else
     nsIDocument *doc = txXPathNativeNode::getDocument(document);
     nsCOMPtr<nsIDOMDocumentFragment> domFragment;
     nsresult rv = NS_NewDocumentFragment(getter_AddRefs(domFragment),
                                          doc->NodeInfoManager());
     NS_ENSURE_SUCCESS(rv, rv);
 
     txOutputFormat format;
     txMozillaXMLOutput mozHandler(&format, domFragment, PR_TRUE);
@@ -97,52 +91,46 @@ convertRtfToNode(txIEvalContext *aContex
     // The txResultTreeFragment will own this.
     const txXPathNode* node = txXPathNativeNode::createXPathNode(domFragment,
                                                                  PR_TRUE);
     NS_ENSURE_TRUE(node, NS_ERROR_OUT_OF_MEMORY);
 
     aRtf->setNode(node);
 
     return NS_OK;
-#endif
 }
 
 static nsresult
 createTextNode(txIEvalContext *aContext, nsString& aValue,
                txXPathNode* *aResult)
 {
     txExecutionState* es = 
         static_cast<txExecutionState*>(aContext->getPrivateContext());
     if (!es) {
         NS_ERROR("Need txExecutionState!");
 
         return NS_ERROR_UNEXPECTED;
     }
 
     const txXPathNode& document = es->getSourceDocument();
 
-#ifdef TX_EXE
-    return NS_ERROR_NOT_IMPLEMENTED;
-#else
     nsIDocument *doc = txXPathNativeNode::getDocument(document);
     nsCOMPtr<nsIContent> text;
     nsresult rv = NS_NewTextNode(getter_AddRefs(text), doc->NodeInfoManager());
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = text->SetText(aValue, PR_FALSE);
     NS_ENSURE_SUCCESS(rv, rv);
 
     *aResult = txXPathNativeNode::createXPathNode(text, PR_TRUE);
     NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
 
     return NS_OK;
-#endif
 }
 
-#ifndef TX_EXE
 static nsresult
 createDocFragment(txIEvalContext *aContext, nsIContent** aResult)
 {
     txExecutionState* es = 
         static_cast<txExecutionState*>(aContext->getPrivateContext());
     if (!es) {
         NS_ERROR("Need txExecutionState!");
 
@@ -190,17 +178,16 @@ createAndAddToResult(nsIAtom* aName, con
     nsAutoPtr<txXPathNode> xpathNode(
           txXPathNativeNode::createXPathNode(elem, PR_TRUE));
     NS_ENSURE_TRUE(xpathNode, NS_ERROR_OUT_OF_MEMORY);
 
     aResultSet->append(*xpathNode);
 
     return NS_OK;
 }
-#endif
 
 // Need to update this array if types are added to the ResultType enum in
 // txAExprResult.
 static const char * const sTypes[] = {
   "node-set",
   "boolean",
   "number",
   "string",
deleted file mode 100644
--- a/content/xslt/src/xslt/txHTMLOutput.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Peter Van der Beken <peterv@propagandism.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "txHTMLOutput.h"
-#include "nsCOMArray.h"
-#include "nsStaticNameTable.h"
-#include "txAtoms.h"
-#include "txOutputFormat.h"
-#include "txStringUtils.h"
-#include "txXMLUtils.h"
-
-#define EMPTY_ELEMENTS_COUNT 13
-const char* const kHTMLEmptyTags[] =
-{
-    "area",
-    "base",
-    "basefont",
-    "br",
-    "col",
-    "frame",
-    "hr",
-    "img",
-    "input",
-    "isindex",
-    "link",
-    "meta",
-    "param"
-};
-
-#define SHORTHAND_ATTR_COUNT 12
-const char* const kHTMLEmptyAttributes[] =
-{
-    "checked",
-    "compact",
-    "declare",
-    "defer",
-    "disabled",
-    "ismap",
-    "multiple",
-    "noresize",
-    "noshade",
-    "nowrap",
-    "readonly",
-    "selected"
-};
-
-struct txEmptyAttributesMaps
-{
-    typedef nsCOMArray<nsIAtom> EmptyAttrBag;
-    EmptyAttrBag mMaps[SHORTHAND_ATTR_COUNT];
-};
-
-static PRInt32 gTableRefCount;
-static nsStaticCaseInsensitiveNameTable* gHTMLEmptyTagsTable;
-static nsStaticCaseInsensitiveNameTable* gHTMLEmptyAttributesTable;
-static txEmptyAttributesMaps* gHTMLEmptyAttributesMaps;
-
-/* static */
-nsresult
-txHTMLOutput::init()
-{
-    if (0 == gTableRefCount++) {
-        NS_ASSERTION(!gHTMLEmptyTagsTable, "pre existing array!");
-        gHTMLEmptyTagsTable = new nsStaticCaseInsensitiveNameTable();
-        if (!gHTMLEmptyTagsTable) {
-            return NS_ERROR_OUT_OF_MEMORY;
-        }
-
-        gHTMLEmptyTagsTable->Init(kHTMLEmptyTags, EMPTY_ELEMENTS_COUNT);
-
-        NS_ASSERTION(!gHTMLEmptyAttributesTable, "pre existing array!");
-        gHTMLEmptyAttributesTable = new nsStaticCaseInsensitiveNameTable();
-        if (!gHTMLEmptyAttributesTable) {
-            return NS_ERROR_OUT_OF_MEMORY;
-        }
-
-        gHTMLEmptyAttributesTable->Init(kHTMLEmptyAttributes,
-                                        SHORTHAND_ATTR_COUNT);
-
-        NS_ASSERTION(!gHTMLEmptyAttributesMaps, "pre existing map!");
-        gHTMLEmptyAttributesMaps = new txEmptyAttributesMaps();
-        if (!gHTMLEmptyAttributesMaps) {
-            return NS_ERROR_OUT_OF_MEMORY;
-        }
-
-        // checked
-        gHTMLEmptyAttributesMaps->mMaps[0].AppendObject(txHTMLAtoms::input);
-
-        // compact
-        gHTMLEmptyAttributesMaps->mMaps[1].AppendObject(txHTMLAtoms::dir);
-        gHTMLEmptyAttributesMaps->mMaps[1].AppendObject(txHTMLAtoms::dl);
-        gHTMLEmptyAttributesMaps->mMaps[1].AppendObject(txHTMLAtoms::menu);
-        gHTMLEmptyAttributesMaps->mMaps[1].AppendObject(txHTMLAtoms::ol);
-        gHTMLEmptyAttributesMaps->mMaps[1].AppendObject(txHTMLAtoms::ul);
-
-        // declare
-        gHTMLEmptyAttributesMaps->mMaps[2].AppendObject(txHTMLAtoms::object);
-
-        // defer
-        gHTMLEmptyAttributesMaps->mMaps[3].AppendObject(txHTMLAtoms::script);
-
-        // disabled
-        gHTMLEmptyAttributesMaps->mMaps[4].AppendObject(txHTMLAtoms::button);
-        gHTMLEmptyAttributesMaps->mMaps[4].AppendObject(txHTMLAtoms::input);
-        gHTMLEmptyAttributesMaps->mMaps[4].AppendObject(txHTMLAtoms::optgroup);
-        gHTMLEmptyAttributesMaps->mMaps[4].AppendObject(txHTMLAtoms::option);
-        gHTMLEmptyAttributesMaps->mMaps[4].AppendObject(txHTMLAtoms::select);
-        gHTMLEmptyAttributesMaps->mMaps[4].AppendObject(txHTMLAtoms::textarea);
-
-        // ismap
-        gHTMLEmptyAttributesMaps->mMaps[5].AppendObject(txHTMLAtoms::img);
-        gHTMLEmptyAttributesMaps->mMaps[5].AppendObject(txHTMLAtoms::input);
-
-        // multiple
-        gHTMLEmptyAttributesMaps->mMaps[6].AppendObject(txHTMLAtoms::select);
-
-        // noresize
-        gHTMLEmptyAttributesMaps->mMaps[7].AppendObject(txHTMLAtoms::frame);
-
-        // noshade
-        gHTMLEmptyAttributesMaps->mMaps[8].AppendObject(txHTMLAtoms::hr);
-
-        // nowrap
-        gHTMLEmptyAttributesMaps->mMaps[9].AppendObject(txHTMLAtoms::td);
-        gHTMLEmptyAttributesMaps->mMaps[9].AppendObject(txHTMLAtoms::th);
-
-        // readonly
-        gHTMLEmptyAttributesMaps->mMaps[10].AppendObject(txHTMLAtoms::input);
-        gHTMLEmptyAttributesMaps->mMaps[10].AppendObject(txHTMLAtoms::textarea);
-
-        // selected
-        gHTMLEmptyAttributesMaps->mMaps[11].AppendObject(txHTMLAtoms::option);
-    }
-
-    return NS_OK;
-}
-
-/* static */
-void
-txHTMLOutput::shutdown()
-{
-    if (0 == --gTableRefCount) {
-        if (gHTMLEmptyTagsTable) {
-            delete gHTMLEmptyTagsTable;
-            gHTMLEmptyTagsTable = nsnull;
-        }
-         if (gHTMLEmptyAttributesTable) {
-            delete gHTMLEmptyAttributesTable;
-            gHTMLEmptyAttributesTable = nsnull;
-        }
-        if (gHTMLEmptyAttributesMaps) {
-            delete gHTMLEmptyAttributesMaps;
-            gHTMLEmptyAttributesMaps = nsnull;
-        }
-   }
-}
-
-txHTMLOutput::txHTMLOutput(txOutputFormat* aFormat, ostream* aOut)
-    : txXMLOutput(aFormat, aOut)
-{
-    mUseEmptyElementShorthand = PR_FALSE;
-}
-
-nsresult
-txHTMLOutput::attribute(const nsAString& aName, const PRInt32 aNsID,
-                        const nsAString& aValue)
-{
-    if (!mStartTagOpen)
-        // XXX Signal this? (can't add attributes after element closed)
-        return;
-
-    MBool shortHand = MB_FALSE;
-    if (aNsID == kNameSpaceID_None) {
-        const nsAString& localPart = XMLUtils::getLocalPart(aName);
-        shortHand = isShorthandAttribute(localPart);
-        if (shortHand &&
-            localPart.Equals(aValue, txCaseInsensitiveStringComparator())) {
-            txListIterator iter(&mAttributes);
-            txOutAttr* setAtt = 0;
-            nsCOMPtr<nsIAtom> localName = do_GetAtom(localPart);
-            txExpandedName att(aNsID, localName);
-            while ((setAtt = (txOutAttr*)iter.next())) {
-                 if (setAtt->mName == att) {
-                     setAtt->mShorthand = MB_TRUE;
-                     break;
-                 }
-            }
-            if (!setAtt) {
-                setAtt = new txOutAttr(aNsID, localName, EmptyString());
-                setAtt->mShorthand = MB_TRUE;
-                mAttributes.add(setAtt);
-            }
-        }
-    }
-    if (!shortHand)
-        txXMLOutput::attribute(aName, aNsID, aValue);
-
-    return NS_OK;
-}
-
-nsresult
-txHTMLOutput::characters(const nsAString& aData, PRBool aDOE)
-{
-    if (aDOE) {
-        closeStartTag(MB_FALSE);
-        printUTF8Chars(aData);
-
-        return NS_OK;
-    }
-
-    // Special-case script and style
-    if (!mCurrentElements.isEmpty()) {
-        txExpandedName* currentElement = (txExpandedName*)mCurrentElements.peek();
-        if (currentElement->mNamespaceID == kNameSpaceID_None &&
-            (currentElement->mLocalName == txHTMLAtoms::script ||
-             currentElement->mLocalName == txHTMLAtoms::style)) {
-            closeStartTag(MB_FALSE);
-            printUTF8Chars(aData);
-
-            return NS_OK;
-        }
-    }
-    return txXMLOutput::characters(aData, aDOE);
-}
-
-nsresult
-txHTMLOutput::endElement(const nsAString& aName, const PRInt32 aNsID)
-{
-    nsresult rv = NS_OK;
-    const nsAString& localPart = XMLUtils::getLocalPart(aName);
-    if ((aNsID == kNameSpaceID_None) && isShorthandElement(localPart) &&
-        mStartTagOpen) {
-        MBool newLine = (mOutputFormat.mIndent == eTrue) &&
-                        mAfterEndTag;
-        closeStartTag(MB_FALSE);
-        if (newLine)
-            *mOut << endl;
-        if (mOutputFormat.mIndent == eTrue)
-            mIndentLevel -= DEFAULT_INDENT;
-        mAfterEndTag = MB_TRUE;
-    }
-    else {
-        rv = txXMLOutput::endElement(aName, aNsID);
-    }
-    delete (txExpandedName*)mCurrentElements.pop();
-
-    return rv;
-}
-
-nsresult
-txHTMLOutput::processingInstruction(const nsAString& aTarget,
-                                    const nsAString& aData)
-{
-    closeStartTag(MB_FALSE);
-    if (mOutputFormat.mIndent == eTrue) {
-        for (PRUint32 i = 0; i < mIndentLevel; i++)
-            *mOut << ' ';
-    }
-    *mOut << PI_START;
-    printUTF8Chars(aTarget);
-    *mOut << SPACE;
-    printUTF8Chars(aData);
-    *mOut << R_ANGLE_BRACKET;
-    if (mOutputFormat.mIndent == eTrue)
-        *mOut << endl;
-
-    return NS_OK;
-}
-
-nsresult
-txHTMLOutput::startDocument()
-{
-    // XXX Should be using mOutputFormat.getVersion
-    *mOut << DOCTYPE_START << "html " << PUBLIC;
-    *mOut << " \"-//W3C//DTD HTML 4.0 Transitional//EN\"";
-    *mOut << " \"http://www.w3.org/TR/REC-html40/loose.dtd\"";
-    *mOut << DOCTYPE_END << endl;
-
-    return NS_OK;
-}
-
-nsresult
-txHTMLOutput::startElement(const nsAString& aName, const PRInt32 aNsID)
-{
-    nsresult rv = txXMLOutput::startElement(aName, aNsID);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsCOMPtr<nsIAtom> localAtom;
-    if (aNsID == kNameSpaceID_None) {
-        nsAutoString localName;
-        TX_ToLowerCase(aName, localName);
-        localAtom = do_GetAtom(localName);
-    }
-    else {
-        localAtom = do_GetAtom(aName);
-    }
-    NS_ASSERTION(localAtom, "Can't get atom");
-    txExpandedName* currentElement = new txExpandedName(aNsID, localAtom);
-    NS_ASSERTION(currentElement, "Can't create currentElement");
-    if (currentElement)
-        mCurrentElements.push(currentElement);
-
-    return NS_OK;
-}
-
-void txHTMLOutput::closeStartTag(MBool aUseEmptyElementShorthand)
-{
-    txExpandedName* currentElement = mCurrentElements.isEmpty() ?
-        nsnull : (txExpandedName*)mCurrentElements.peek();
-    if (mStartTagOpen && currentElement &&
-        (currentElement->mNamespaceID == kNameSpaceID_None) &&
-        (currentElement->mLocalName == txHTMLAtoms::head)) {
-        txXMLOutput::closeStartTag(MB_FALSE);
-        if (mOutputFormat.mIndent == eTrue) {
-            *mOut << endl;
-            for (PRUint32 i = 0; i < mIndentLevel; i++)
-                *mOut << ' ';
-        }
-        *mOut << LT << "meta http-equiv=" << QUOTE << "Content-Type" << QUOTE;
-        *mOut << " content=" << QUOTE;
-        printUTF8Chars(mOutputFormat.mMediaType);
-        *mOut << "; charset=";
-        printUTF8Chars(mOutputFormat.mEncoding);
-        *mOut << QUOTE << GT;
-    }
-    else {
-        txXMLOutput::closeStartTag(aUseEmptyElementShorthand);
-    }
-}
-
-MBool txHTMLOutput::isShorthandElement(const nsAString& aLocalName)
-{
-    return (gHTMLEmptyTagsTable->Lookup(aLocalName) !=
-            nsStaticCaseInsensitiveNameTable::NOT_FOUND);
-}
-
-MBool txHTMLOutput::isShorthandAttribute(const nsAString& aLocalName)
-{
-    PRInt32 index = gHTMLEmptyTagsTable->Lookup(aLocalName);
-    if (index == nsStaticCaseInsensitiveNameTable::NOT_FOUND) {
-        return PR_FALSE;
-    }
-
-    txExpandedName* currentElement = (txExpandedName*)mCurrentElements.peek();
-    return (gHTMLEmptyAttributesMaps->mMaps[index].IndexOf(currentElement->mLocalName) > -1);
-}
deleted file mode 100644
--- a/content/xslt/src/xslt/txHTMLOutput.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Peter Van der Beken <peterv@propagandism.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef TRANSFRMX_HTML_OUTPUT_H
-#define TRANSFRMX_HTML_OUTPUT_H
-
-#include "txXMLOutput.h"
-
-class txHTMLOutput : public txXMLOutput
-{
-public:
-    txHTMLOutput(txOutputFormat* aFormat, ostream* aOut);
-
-    /**
-     * Init/release table with shorthands.
-     */
-    static nsresult init();
-    static void shutdown();
-
-    nsresult attribute(const nsAString& aName, const PRInt32 aNsID,
-                       const nsAString& aValue);
-    nsresult characters(const nsAString& aData, PRBool aDOE);
-    nsresult endElement(const nsAString& aName, const PRInt32 aNsID);
-    nsresult processingInstruction(const nsAString& aTarget,
-                                   const nsAString& aData);
-    nsresult startDocument();
-    nsresult startElement(const nsAString& aName, const PRInt32 aNsID);
-    TX_DECL_TXAOUTPUTXMLEVENTHANDLER
-
-private:
-    void closeStartTag(MBool aUseEmptyElementShorthand);
-    MBool isShorthandElement(const nsAString& aName);
-    MBool isShorthandAttribute(const nsAString& aLocalName);
-
-    txStack mCurrentElements;
-};
-
-#endif
deleted file mode 100644
--- a/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp
+++ /dev/null
@@ -1,364 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Axel Hecht.
- * Portions created by the Initial Developer are Copyright (C) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Axel Hecht <axel@pike.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "txStandaloneStylesheetCompiler.h"
-#include "txLog.h"
-#include "txStylesheetCompiler.h"
-#include "txURIUtils.h"
-#include "expat_config.h"
-#include "expat.h"
-#include "txXMLParser.h"
-
-/**
- *  Implementation of an In-Memory DOM based XML parser.  The actual XML
- *  parsing is provided by EXPAT.
- */
-class txDriver : public txACompileObserver
-{
-  public:
-    nsresult parse(istream& aInputStream, const nsAString& aUri);
-    const nsAString& getErrorString();
-
-    /**
-     * Expat handlers
-     */
-    void StartElement(const XML_Char *aName, const XML_Char **aAtts);
-    void EndElement(const XML_Char* aName);
-    void CharacterData(const XML_Char* aChars, int aLength);
-    int ExternalEntityRef(const XML_Char *aContext, const XML_Char *aBase,
-                          const XML_Char *aSystemId,
-                          const XML_Char *aPublicId);
-
-    TX_DECL_ACOMPILEOBSERVER
-    NS_INLINE_DECL_REFCOUNTING(txDriver)
-
-    nsRefPtr<txStylesheetCompiler> mCompiler;
-  protected:
-    void createErrorString();
-    nsString  mErrorString;
-    // keep track of the nsresult returned by the handlers, expat forgets them
-    nsresult mRV;
-    XML_Parser mExpatParser;
-};
-
-nsresult
-TX_CompileStylesheetPath(const txParsedURL& aURL, txStylesheet** aResult)
-{
-    *aResult = nsnull;
-    nsAutoString errMsg, filePath;
-
-    aURL.getFile(filePath);
-    PR_LOG(txLog::xslt, PR_LOG_ALWAYS,
-           ("TX_CompileStylesheetPath: %s\n",
-            NS_LossyConvertUTF16toASCII(filePath).get()));
-    istream* xslInput = URIUtils::getInputStream(filePath, errMsg);
-    if (!xslInput) {
-        return NS_ERROR_FAILURE;
-    }
-    nsRefPtr<txDriver> driver = new txDriver();
-    if (!driver) {
-        return NS_ERROR_OUT_OF_MEMORY;
-    }
-    nsAutoString spec = filePath;
-    if (!aURL.mRef.IsEmpty()) {
-        spec.Append(PRUnichar('#'));
-        spec.Append(aURL.mRef);
-    }
-    driver->mCompiler =  new txStylesheetCompiler(spec, driver);
-    if (!driver->mCompiler) {
-        return NS_ERROR_OUT_OF_MEMORY;
-    }
-    nsresult rv = driver->parse(*xslInput, filePath);
-    if (NS_FAILED(rv)) {
-        return rv;
-    };
-    *aResult = driver->mCompiler->getStylesheet();
-    NS_ADDREF(*aResult);
-    return NS_OK;
-}
-
-/**
- * expat C stub handlers
- */
-
-// shortcut macro for redirection into txDriver method calls
-#define TX_DRIVER(_userData) static_cast<txDriver*>(_userData)
-
-static void
-startElement(void *aUserData, const XML_Char *aName, const XML_Char **aAtts)
-{
-    if (!aUserData) {
-        NS_WARNING("no userData in startElement handler");
-        return;
-    }
-    TX_DRIVER(aUserData)->StartElement(aName, aAtts);
-}
-
-static void
-endElement(void *aUserData, const XML_Char* aName)
-{
-    if (!aUserData) {
-        NS_WARNING("no userData in endElement handler");
-        return;
-    }
-    TX_DRIVER(aUserData)->EndElement(aName);
-}
-
-static void
-charData(void* aUserData, const XML_Char* aChars, int aLength)
-{
-    if (!aUserData) {
-        NS_WARNING("no userData in charData handler");
-        return;
-    }
-    TX_DRIVER(aUserData)->CharacterData(aChars, aLength);
-}
-
-static int
-externalEntityRefHandler(XML_Parser aParser,
-                         const XML_Char *aContext,
-                         const XML_Char *aBase,
-                         const XML_Char *aSystemId,
-                         const XML_Char *aPublicId)
-{
-    // aParser is aUserData is the txDriver,
-    // we set that in txDriver::parse
-    NS_ENSURE_TRUE(aParser, XML_ERROR_NONE);
-    return ((txDriver*)aParser)->ExternalEntityRef(aContext, aBase,
-                                                   aSystemId, aPublicId);
-}
-
-
-/**
- *  Parses the given input stream and returns a DOM Document.
- *  A NULL pointer will be returned if errors occurred
- */
-nsresult
-txDriver::parse(istream& aInputStream, const nsAString& aUri)
-{
-    mErrorString.Truncate();
-    if (!aInputStream) {
-        mErrorString.AppendLiteral("unable to parse xml: invalid or unopen stream encountered.");
-        return NS_ERROR_FAILURE;
-    }
-
-    static const XML_Memory_Handling_Suite memsuite = {
-        (void *(*)(size_t))PR_Malloc,
-        (void *(*)(void *, size_t))PR_Realloc,
-        PR_Free
-    };
-    static const PRUnichar expatSeparator = kExpatSeparatorChar;
-    mExpatParser = XML_ParserCreate_MM(nsnull, &memsuite, &expatSeparator);
-    if (!mExpatParser) {
-        return NS_ERROR_OUT_OF_MEMORY;
-    }
-
-    XML_SetReturnNSTriplet(mExpatParser, XML_TRUE);
-    XML_SetUserData(mExpatParser, this);
-    XML_SetElementHandler(mExpatParser, startElement, endElement);
-    XML_SetCharacterDataHandler(mExpatParser, charData);
-#ifdef XML_DTD
-    XML_SetParamEntityParsing(mExpatParser, XML_PARAM_ENTITY_PARSING_ALWAYS);
-#endif
-    XML_SetExternalEntityRefHandler(mExpatParser, externalEntityRefHandler);
-    XML_SetExternalEntityRefHandlerArg(mExpatParser, this);
-    XML_SetBase(mExpatParser,
-                (const XML_Char*)(PromiseFlatString(aUri).get()));
-
-    const int bufferSize = 1024;
-    char buf[bufferSize];
-    PRBool done;
-    int success;
-    mRV = NS_OK;
-    do {
-        aInputStream.read(buf, bufferSize);
-        done = aInputStream.eof();
-        success = XML_Parse(mExpatParser, buf, aInputStream.gcount(), done);
-        // mRV is set in onDoneCompiling in case of an error
-        if (!success || NS_FAILED(mRV)) {
-            createErrorString();
-            done = MB_TRUE;
-        }
-    } while (!done);
-    aInputStream.clear();
-
-    // clean up
-    XML_ParserFree(mExpatParser);
-    mCompiler->doneLoading();
-    if (!success) {
-        return NS_ERROR_FAILURE;
-    }
-    return mRV;
-}
-
-const nsAString&
-txDriver::getErrorString()
-{
-    return mErrorString;
-}
-
-void
-txDriver::StartElement(const XML_Char *aName, const XML_Char **aAtts)
-{
-    PRInt32 attcount = 0;
-    const XML_Char** atts = aAtts;
-    while (*atts) {
-        ++atts;
-        ++attcount;
-    }
-    PRInt32 idOffset = XML_GetIdAttributeIndex(mExpatParser);
-    nsresult rv =
-        mCompiler->startElement(static_cast<const PRUnichar*>(aName), 
-                                static_cast<const PRUnichar**>(aAtts),
-                                attcount/2, idOffset);
-    if (NS_FAILED(rv)) {
-        PR_LOG(txLog::xslt, PR_LOG_ALWAYS, 
-               ("compile failed at %i with %x\n",
-                XML_GetCurrentLineNumber(mExpatParser), rv));
-        mCompiler->cancel(rv);
-    }
-}
-
-void
-txDriver::EndElement(const XML_Char* aName)
-{
-    nsresult rv = mCompiler->endElement();
-    if (NS_FAILED(rv)) {
-        mCompiler->cancel(rv);
-    }
-}
-
-void
-txDriver::CharacterData(const XML_Char* aChars, int aLength)
-{
-    const PRUnichar* pChars = static_cast<const PRUnichar*>(aChars);
-    // ignore rv, as this expat handler returns void
-    nsresult rv = mCompiler->characters(Substring(pChars, pChars + aLength));
-    if (NS_FAILED(rv)) {
-        mCompiler->cancel(rv);
-    }
-}
-
-int
-txDriver::ExternalEntityRef(const XML_Char *aContext, const XML_Char *aBase,
-                            const XML_Char *aSystemId,
-                            const XML_Char *aPublicId)
-{
-    if (aPublicId) {
-        // not supported, this is "http://some.site.net/foo.dtd" stuff
-        return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-    }
-    nsAutoString absUrl;
-    URIUtils::resolveHref(nsDependentString((PRUnichar*)aSystemId),
-                          nsDependentString((PRUnichar*)aBase), absUrl);
-    istream* extInput = URIUtils::getInputStream(absUrl, mErrorString);
-    if (!extInput) {
-        return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-    }
-    XML_Parser parent = mExpatParser;
-    mExpatParser = 
-        XML_ExternalEntityParserCreate(mExpatParser, aContext, nsnull);
-    if (!mExpatParser) {
-        mExpatParser = parent;
-        delete extInput;
-        return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
-    }
-    XML_SetBase(mExpatParser, absUrl.get());
-
-    const int bufSize = 1024;
-    char buffer[bufSize];
-    int result;
-    PRBool done;
-    do {
-        extInput->read(buffer, bufSize);
-        done = extInput->eof();
-        if (!(result =
-              XML_Parse(mExpatParser, buffer,  extInput->gcount(), done))) {
-            createErrorString();
-            mErrorString.Append(PRUnichar('\n'));
-            done = MB_TRUE;
-        }
-    } while (!done);
-
-    delete extInput;
-    XML_ParserFree(mExpatParser);
-
-    mExpatParser = parent;
-
-    return result;
-}
-
-void
-txDriver::createErrorString()
-{
-    XML_Error errCode = XML_GetErrorCode(mExpatParser);
-    mErrorString.AppendWithConversion(XML_ErrorString(errCode));
-    mErrorString.AppendLiteral(" at line ");
-    mErrorString.AppendInt(XML_GetCurrentLineNumber(mExpatParser));
-    mErrorString.AppendLiteral(" in ");
-    mErrorString.Append((const PRUnichar*)XML_GetBase(mExpatParser));
-}
-
-/**
- * txACompileObserver implementation
- */
-
-void
-txDriver::onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult,
-                          const PRUnichar *aErrorText, const PRUnichar *aParam)
-{
-    // store the nsresult as expat forgets about it
-    mRV = aResult;
-}
-
-nsresult
-txDriver::loadURI(const nsAString& aUri, const nsAString& aReferrerUri,
-                  txStylesheetCompiler* aCompiler)
-{
-    nsAutoString errMsg;
-    istream* xslInput = URIUtils::getInputStream(aUri, errMsg);
-    if (!xslInput) {
-        return NS_ERROR_FAILURE;
-    }
-    nsRefPtr<txDriver> driver = new txDriver();
-    if (!driver) {
-        return NS_ERROR_OUT_OF_MEMORY;
-    }
-    driver->mCompiler = aCompiler;
-    return driver->parse(*xslInput, aUri);
-}
deleted file mode 100644
--- a/content/xslt/src/xslt/txStandaloneStylesheetCompiler.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Axel Hecht.
- * Portions created by the Initial Developer are Copyright (C) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Axel Hecht <axel@pike.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef __TX_STANDALONE_STYLESHEET_COMPILER_H__
-#define __TX_STANDALONE_STYLESHEET_COMPILER_H__
-
-#include "txStylesheet.h"
-#include "txURIUtils.h"
-
-/**
- * API to load XML files into compiled stylesheets.
- * Parsing is done by expat.
- */
-
-/**
- * Parse a stylesheet from the aPath.
- */
-nsresult
-TX_CompileStylesheetPath(const txParsedURL& aURL, txStylesheet** aResult);
-
-#endif // __TX_STANDALONE_STYLESHEET_COMPILER_H__
deleted file mode 100644
--- a/content/xslt/src/xslt/txStandaloneXSLTProcessor.cpp
+++ /dev/null
@@ -1,374 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Peter Van der Beken <peterv@propagandism.org>
- *   Axel Hecht <axel@pike.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "txStandaloneXSLTProcessor.h"
-#include "txStandaloneStylesheetCompiler.h"
-#include "nsCRT.h"
-#include "nsReadableUtils.h"
-#include "txHTMLOutput.h"
-#include "txTextOutput.h"
-#include "txUnknownHandler.h"
-#include "txURIUtils.h"
-#include "txXMLParser.h"
-
-TX_IMPL_DOM_STATICS;
-
-/**
- * Output Handler Factory
- */
-class txStandaloneHandlerFactory : public txAOutputHandlerFactory
-{
-public:
-    txStandaloneHandlerFactory(txExecutionState* aEs,
-                               ostream* aStream)
-        : mEs(aEs), mStream(aStream)
-    {
-    }
-
-    TX_DECL_TXAOUTPUTHANDLERFACTORY
-
-private:
-    txExecutionState* mEs;
-    ostream* mStream;
-};
-
-nsresult
-txStandaloneHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
-                                              txAOutputXMLEventHandler** aHandler)
-{
-    *aHandler = 0;
-    switch (aFormat->mMethod) {
-        case eXMLOutput:
-            *aHandler = new txXMLOutput(aFormat, mStream);
-            break;
-
-        case eHTMLOutput:
-            *aHandler = new txHTMLOutput(aFormat, mStream);
-            break;
-
-        case eTextOutput:
-            *aHandler = new txTextOutput(mStream);
-            break;
-
-        case eMethodNotSet:
-            *aHandler = new txUnknownHandler(mEs);
-            break;
-    }
-    NS_ENSURE_TRUE(*aHandler, NS_ERROR_OUT_OF_MEMORY);
-    return NS_OK;
-}
-
-nsresult
-txStandaloneHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
-                                              const nsAString& aName,
-                                              PRInt32 aNsID,
-                                              txAOutputXMLEventHandler** aHandler)
-{
-    *aHandler = 0;
-    NS_ASSERTION(aFormat->mMethod != eMethodNotSet,
-                 "How can method not be known when root element is?");
-    NS_ENSURE_TRUE(aFormat->mMethod != eMethodNotSet, NS_ERROR_UNEXPECTED);
-    return createHandlerWith(aFormat, aHandler);
-}
-
-
-/**
- * txStandaloneXSLTProcessor
- */
-
-/**
- * Transform a XML document given by path.
- * The stylesheet is retrieved by a processing instruction,
- * or an error is returned.
- */
-nsresult
-txStandaloneXSLTProcessor::transform(nsACString& aXMLPath, ostream& aOut,
-                                     ErrorObserver& aErr)
-{
-    txXPathNode* xmlDoc = parsePath(aXMLPath, aErr);
-    if (!xmlDoc) {
-        return NS_ERROR_FAILURE;
-    }
-
-    // transform
-    nsresult rv = transform(*xmlDoc, aOut, aErr);
-
-    delete xmlDoc;
-
-    return rv;
-}
-
-/**
- * Transform a XML document given by path with the given
- * stylesheet.
- */
-nsresult
-txStandaloneXSLTProcessor::transform(nsACString& aXMLPath,
-                                     nsACString& aXSLPath, ostream& aOut,
-                                     ErrorObserver& aErr)
-{
-    txXPathNode* xmlDoc = parsePath(aXMLPath, aErr);
-    if (!xmlDoc) {
-        return NS_ERROR_FAILURE;
-    }
-    txParsedURL path;
-    path.init(NS_ConvertASCIItoUTF16(aXSLPath));
-    nsRefPtr<txStylesheet> style;
-    nsresult rv = TX_CompileStylesheetPath(path, getter_AddRefs(style));
-    if (NS_FAILED(rv)) {
-        delete xmlDoc;
-        return rv;
-    }
-    // transform
-    rv = transform(*xmlDoc, style, aOut, aErr);
-
-    delete xmlDoc;
-
-    return rv;
-}
-
-/**
- * Transform a XML document.
- * The stylesheet is retrieved by a processing instruction,
- * or an error is returned.
- */
-nsresult
-txStandaloneXSLTProcessor::transform(txXPathNode& aXMLDoc, ostream& aOut,
-                                     ErrorObserver& aErr)
-{
-    Document* xmlDoc;
-    nsresult rv = txXPathNativeNode::getDocument(aXMLDoc, &xmlDoc);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // get stylesheet path
-    nsAutoString stylePath, basePath;
-    xmlDoc->getBaseURI(basePath);
-    getHrefFromStylesheetPI(*xmlDoc, stylePath);
-    txParsedURL base, ref, resolved;
-    base.init(basePath);
-    ref.init(stylePath);
-    base.resolve(ref, resolved);
-
-    nsRefPtr<txStylesheet> style;
-    rv = TX_CompileStylesheetPath(resolved, getter_AddRefs(style));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // transform
-    rv = transform(aXMLDoc, style, aOut, aErr);
-
-    return rv;
-}
-
-/**
- * Processes the given XML Document using the given XSL document
- * and prints the results to the given ostream argument
- */
-nsresult
-txStandaloneXSLTProcessor::transform(txXPathNode& aSource,
-                                     txStylesheet* aStylesheet,
-                                     ostream& aOut, ErrorObserver& aErr)
-{
-    // Create a new txEvalState
-    txExecutionState es(aStylesheet);
-
-    // XXX todo es.addErrorObserver(aErr);
-
-    txStandaloneHandlerFactory handlerFactory(&es, &aOut);
-
-#ifndef XP_WIN
-    bool sync = aOut.sync_with_stdio(false);
-#endif
-    es.mOutputHandlerFactory = &handlerFactory;
-
-    es.init(aSource, nsnull);
-
-    // Process root of XML source document
-    nsresult rv = txXSLTProcessor::execute(es);
-    es.end(rv);
-
-#ifndef XP_WIN
-    aOut.sync_with_stdio(sync);
-#endif
-
-    return rv;
-}
-
-/**
- * Parses the XML Stylesheet PIs associated with the
- * given XML document. If a stylesheet PIs is found with type="text/xsl",
- * type="text/xml" or type="application/xml" the href pseudo attribute
- * value will be appended to the given href argument. If multiple XSLT
- * stylesheet PIs are found, the first one is used.
- */
-void txStandaloneXSLTProcessor::getHrefFromStylesheetPI(Document& xmlDocument,
-                                                        nsAString& href)
-{
-    Node* node = xmlDocument.getFirstChild();
-    nsAutoString type;
-    nsAutoString tmpHref;
-    while (node) {
-        if (node->getNodeType() == Node::PROCESSING_INSTRUCTION_NODE) {
-            nsAutoString target;
-            node->getNodeName(target);
-            if (target.EqualsLiteral("xml-stylesheet")) {
-                nsAutoString data;
-                node->getNodeValue(data);
-                type.Truncate();
-                tmpHref.Truncate();
-                parseStylesheetPI(data, type, tmpHref);
-                if (type.EqualsLiteral("text/xsl") ||
-                    type.EqualsLiteral("text/xml") ||
-                    type.EqualsLiteral("application/xml")) {
-                    href = tmpHref;
-                    return;
-                }
-            }
-        }
-        node = node->getNextSibling();
-    }
-}
-
-/**
- * Parses the contents of data, and returns the type and href pseudo attributes
- * (Based on code copied from nsParserUtils)
- */
-#define SKIP_WHITESPACE(iter, end_iter)                          \
-  while ((iter) != (end_iter) && nsCRT::IsAsciiSpace(*(iter))) { \
-    ++(iter);                                                    \
-  }                                                              \
-  if ((iter) == (end_iter))                                      \
-    break
-
-#define SKIP_ATTR_NAME(iter, end_iter)                            \
-  while ((iter) != (end_iter) && !nsCRT::IsAsciiSpace(*(iter)) && \
-         *(iter) != '=') {                                        \
-    ++(iter);                                                     \
-  }                                                               \
-  if ((iter) == (end_iter))                                       \
-    break
-
-void txStandaloneXSLTProcessor::parseStylesheetPI(const nsAFlatString& aData,
-                                                  nsAString& aType,
-                                                  nsAString& aHref)
-{
-  nsAFlatString::const_char_iterator start, end;
-  aData.BeginReading(start);
-  aData.EndReading(end);
-  nsAFlatString::const_char_iterator iter;
-  PRInt8 found = 0;
-
-  while (start != end) {
-    SKIP_WHITESPACE(start, end);
-    iter = start;
-    SKIP_ATTR_NAME(iter, end);
-
-    // Remember the attr name.
-    const nsAString & attrName = Substring(start, iter);
-
-    // Now check whether this is a valid name="value" pair.
-    start = iter;
-    SKIP_WHITESPACE(start, end);
-    if (*start != '=') {
-      // No '=', so this is not a name="value" pair.  We don't know
-      // what it is, and we have no way to handle it.
-      break;
-    }
-
-    // Have to skip the value.
-    ++start;
-    SKIP_WHITESPACE(start, end);
-    PRUnichar q = *start;
-    if (q != QUOTE && q != APOSTROPHE) {
-      // Not a valid quoted value, so bail.
-      break;
-    }
-
-    ++start;  // Point to the first char of the value.
-    iter = start;
-    while (iter != end && *iter != q) {
-      ++iter;
-    }
-    if (iter == end) {
-      // Oops, unterminated quoted string.
-      break;
-    }
-    
-    // At this point attrName holds the name of the "attribute" and
-    // the value is between start and iter.
-    if (attrName.EqualsLiteral("type")) {
-      aType = Substring(start, iter);
-      ++found;
-    }
-    else if (attrName.EqualsLiteral("href")) {
-      aHref = Substring(start, iter);
-      ++found;
-    }
-
-    // Stop if we found both attributes
-    if (found == 2) {
-      break;
-    }
-
-    // Resume scanning after the end of the attribute value.
-    start = iter;
-    ++start;  // To move past the quote char.
-  }
-}
-
-txXPathNode*
-txStandaloneXSLTProcessor::parsePath(const nsACString& aPath, ErrorObserver& aErr)
-{
-    NS_ConvertASCIItoUTF16 path(aPath);
-
-    ifstream xmlInput(PromiseFlatCString(aPath).get(), ios::in);
-    if (!xmlInput) {
-        aErr.receiveError(NS_LITERAL_STRING("Couldn't open ") + path);
-        return 0;
-    }
-    // parse source
-    txXPathNode* xmlDoc;
-    nsAutoString errors;
-    nsresult rv = txParseFromStream(xmlInput, path, errors, &xmlDoc);
-    xmlInput.close();
-    if (NS_FAILED(rv) || !xmlDoc) {
-        aErr.receiveError(NS_LITERAL_STRING("Parsing error \"") + errors +
-                          NS_LITERAL_STRING("\""));
-    }
-    return xmlDoc;
-}
deleted file mode 100644
--- a/content/xslt/src/xslt/txStandaloneXSLTProcessor.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Peter Van der Beken <peterv@propagandism.org>
- *   Axel Hecht <axel@pike.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef TRANSFRMX_TXSTANDALONEXSLTPROCESSOR_H
-#define TRANSFRMX_TXSTANDALONEXSLTPROCESSOR_H
-
-#include "txStylesheet.h"
-#include "txXSLTProcessor.h"
-#include "txErrorObserver.h"
-
-#ifndef __BORLANDC__
-#include <iostream.h>
-#include <fstream.h>
-#endif
-
-class txStreamXMLEventHandler;
-
-/**
- * txStandaloneXSLTProcessor
- *
- * Use of the standalone TransforMiiX API:
- *
- * The XSLT Processor need initialisation and shutdown
- * by
- *  txStandaloneXSLTProcessor::Init();
- * and
- *  txStandaloneXSLTProcessor::Shutdown();
- * Be sure to always call these functions in pairs.
- *
- * The API to transform documents consists of entry points
- * to transform either one or two documents.
- * If you provide one document, the stylesheet location is
- * computed from the processing instruction. If that cannot
- * be found, an error is issued.
- *
- * The result is output to a stream.
- *
- * Documents can be provided either by path or by DOM Document.
- *
- * Stylesheet parameters
- *  XXX TODO 
- * 
- */
-
-class txStandaloneXSLTProcessor : public txXSLTProcessor
-{
-public:
-    /**
-     * Methods that print the result to a stream
-     */
-
-    /**
-     * Transform a XML document given by path.
-     * The stylesheet is retrieved by a processing instruction,
-     * or an error is returned.
-     *
-     * @param aXMLPath path to the source document
-     * @param aOut     stream to which the result is feeded
-     * @param aErr     error observer
-     * @result NS_OK if transformation was successful
-     */
-    nsresult transform(nsACString& aXMLPath, ostream& aOut,
-                       ErrorObserver& aErr);
-
-    /**
-     * Transform a XML document given by path with the given
-     * stylesheet.
-     *
-     * @param aXMLPath path to the source document
-     * @param aXSLPath path to the style document
-     * @param aOut     stream to which the result is feeded
-     * @param aErr     error observer
-     * @result NS_OK if transformation was successful
-     */
-    nsresult transform(nsACString& aXMLPath, nsACString& aXSLPath,
-                       ostream& aOut, ErrorObserver& aErr);
-
-    /**
-     * Transform a XML document.
-     * The stylesheet is retrieved by a processing instruction,
-     * or an error is returned.
-     *
-     * @param aXMLDoc source document
-     * @param aOut    stream to which the result is feeded
-     * @param aErr    error observer
-     * @result NS_OK if transformation was successful
-     */
-    nsresult transform(txXPathNode& aXMLDoc, ostream& aOut, ErrorObserver& aErr);
-
-    /**
-     * Transform a XML document with the given stylesheet.
-     *
-     * @param aXMLDoc  source document
-     * @param aXSLNode style node
-     * @param aOut     stream to which the result is feeded
-     * @param aErr     error observer
-     * @result NS_OK if transformation was successful
-     */
-    nsresult transform(txXPathNode& aXMLDoc, txStylesheet* aXSLNode,
-                       ostream& aOut, ErrorObserver& aErr);
-
-protected:
-    /**
-     * Parses all XML Stylesheet PIs associated with the
-     * given XML document. If any stylesheet PIs are found with
-     * type="text/xsl" the href pseudo attribute value will be
-     * added to the given href argument. If multiple text/xsl stylesheet PIs
-     * are found, the one closest to the end of the document is used.
-     */
-    static void getHrefFromStylesheetPI(Document& xmlDocument, nsAString& href);
-
-    /**
-     * Parses the contents of data, returns the type and href pseudo attributes
-     */
-    static void parseStylesheetPI(const nsAFlatString& data,
-                                  nsAString& type,
-                                  nsAString& href);
-
-    /**
-     * Create a Document from a path.
-     *
-     * @param aPath path to the xml file
-     * @param aErr  ErrorObserver
-     * @result Document XML Document, or null on error
-     */
-    static txXPathNode* parsePath(const nsACString& aPath, ErrorObserver& aErr);
-};
-
-#endif
deleted file mode 100644
--- a/content/xslt/src/xslt/txTextOutput.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Peter Van der Beken <peterv@propagandism.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "txTextOutput.h"
-#include "nsString.h"
-
-txTextOutput::txTextOutput(ostream* aOut)
-    : mOut(aOut)
-{
-}
-
-nsresult
-txTextOutput::attribute(const nsAString& aName,
-                        const PRInt32 aNsID,
-                        const nsAString& aValue)
-{
-    return NS_OK;
-}
-
-nsresult
-txTextOutput::characters(const nsAString& aData, PRBool aDOE)
-{
-    *mOut << NS_ConvertUTF16toUTF8(aData).get();
-}
-
-nsresult
-txTextOutput::comment(const nsAString& aData)
-{
-    return NS_OK;
-}
-
-nsresult
-txTextOutput::endDocument(nsresult aResult)
-{
-    return NS_OK;
-}
-
-nsresult
-txTextOutput::endElement(const nsAString& aName, const PRInt32 aNsID)
-{
-    return NS_OK;
-}
-
-nsresult
-txTextOutput::processingInstruction(const nsAString& aTarget,
-                                    const nsAString& aData)
-{
-    return NS_OK;
-}
-
-nsresult
-txTextOutput::startDocument()
-{
-    return NS_OK;
-}
-
-nsresult
-txTextOutput::startElement(const nsAString& aName, const PRInt32 aNsID)
-{
-    return NS_OK;
-}
deleted file mode 100644
--- a/content/xslt/src/xslt/txTextOutput.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Peter Van der Beken <peterv@propagandism.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef TRANSFRMX_TEXT_OUTPUT_H
-#define TRANSFRMX_TEXT_OUTPUT_H
-
-#include "txXMLEventHandler.h"
-
-class txTextOutput : public txAOutputXMLEventHandler
-{
-public:
-    txTextOutput(ostream* aOut);
-
-    TX_DECL_TXAXMLEVENTHANDLER
-    TX_DECL_TXAOUTPUTXMLEVENTHANDLER
-
-private:
-    ostream* mOut;
-};
-
-#endif
--- a/content/xslt/src/xslt/txXMLEventHandler.h
+++ b/content/xslt/src/xslt/txXMLEventHandler.h
@@ -37,26 +37,21 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef TRANSFRMX_XML_EVENT_HANDLER_H
 #define TRANSFRMX_XML_EVENT_HANDLER_H
 
 #include "txCore.h"
 #include "nsIAtom.h"
 
-class txOutputFormat;
-
-#ifdef TX_EXE
-#include <iostream.h>
-#else
 #define kTXNameSpaceURI "http://www.mozilla.org/TransforMiix"
 #define kTXWrapper "transformiix:result"
 
+class txOutputFormat;
 class nsIDOMDocument;
-#endif
 
 /**
  * An interface for handling XML documents, loosely modeled
  * after Dave Megginson's SAX 1.0 API.
  */
 
 class txAXMLEventHandler
 {
@@ -174,34 +169,29 @@ public:
                                   nsIAtom* aLocalName,                       \
                                   nsIAtom* aLowercaseLocalName,              \
                                   PRInt32 aNsID);                            \
     virtual nsresult startElement(nsIAtom* aPrefix,                          \
                                   const nsSubstring& aName,                  \
                                   const PRInt32 aNsID);
 
 
-#ifdef TX_EXE
-typedef txAXMLEventHandler txAOutputXMLEventHandler;
-#define TX_DECL_TXAOUTPUTXMLEVENTHANDLER
-#else
 class txAOutputXMLEventHandler : public txAXMLEventHandler
 {
 public:
     /**
      * Gets the Mozilla output document
      *
      * @param aDocument the Mozilla output document
      */
     virtual void getOutputDocument(nsIDOMDocument** aDocument) = 0;
 };
 
 #define TX_DECL_TXAOUTPUTXMLEVENTHANDLER                        \
     virtual void getOutputDocument(nsIDOMDocument** aDocument);
-#endif
 
 /**
  * Interface used to create the appropriate outputhandler
  */
 class txAOutputHandlerFactory
 {
 public:
     virtual ~txAOutputHandlerFactory() {}
deleted file mode 100644
--- a/content/xslt/src/xslt/txXMLOutput.cpp
+++ /dev/null
@@ -1,378 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Peter Van der Beken <peterv@propagandism.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "txXMLOutput.h"
-
-const int txXMLOutput::DEFAULT_INDENT = 2;
-
-txOutAttr::txOutAttr(PRInt32 aNsID, nsIAtom* aLocalName,
-                         const nsAString& aValue) :
-    mName(aNsID, aLocalName),
-    mValue(aValue),
-    mShorthand(MB_FALSE)
-{
-}
-
-txXMLOutput::txXMLOutput(txOutputFormat* aFormat, ostream* aOut)
-    : mOut(aOut),
-      mUseEmptyElementShorthand(MB_TRUE),
-      mHaveDocumentElement(MB_FALSE),
-      mStartTagOpen(MB_FALSE),
-      mAfterEndTag(MB_FALSE),
-      mInCDATASection(MB_FALSE),
-      mIndentLevel(0)
-{
-    mOutputFormat.merge(*aFormat);
-    mOutputFormat.setFromDefaults();
-}
-
-nsresult
-txXMLOutput::attribute(const nsAString& aName,
-                       const PRInt32 aNsID,
-                       const nsAString& aValue)
-{
-    if (!mStartTagOpen) {
-        // XXX Signal this? (can't add attributes after element closed)
-        return NS_OK;
-    }
-
-    txListIterator iter(&mAttributes);
-    nsCOMPtr<nsIAtom> localName = do_GetAtom(XMLUtils::getLocalPart(aName));
-    txExpandedName att(aNsID, localName);
-
-    txOutAttr* setAtt = 0;
-    while ((setAtt = (txOutAttr*)iter.next())) {
-         if (setAtt->mName == att) {
-             setAtt->mValue = aValue;
-             break;
-         }
-    }
-    if (!setAtt) {
-        setAtt = new txOutAttr(aNsID, localName, aValue);
-        NS_ENSURE_TRUE(setAtt, NS_ERROR_OUT_OF_MEMORY);
-
-        nsresult rv = mAttributes.add(setAtt);
-        NS_ENSURE_SUCCESS(rv, rv);
-    }
-    
-    return NS_OK;
-}
-
-nsresult
-txXMLOutput::characters(const nsAString& aData, PRBool aDOE)
-{
-    closeStartTag(MB_FALSE);
-
-    if (aDOE) {
-        printUTF8Chars(aData);
-
-        return NS_OK;
-    }
-
-    if (mInCDATASection) {
-        PRUint32 length = aData.Length();
-
-        *mOut << CDATA_START;
-
-        if (length <= 3) {
-            printUTF8Chars(aData);
-        }
-        else {
-            PRUint32 j = 0;
-            nsAString::const_iterator iter;
-            aData.BeginReading(iter);
-            mBuffer[j++] = *(iter++);
-            mBuffer[j++] = *(iter++);
-            mBuffer[j++] = *(iter++);
-
-            nsAString::const_iterator end;
-            aData.EndReading(end);
-            while (iter != end) {
-                mBuffer[j++] = *(iter++);
-                if (mBuffer[(j - 1) % 4] == ']' &&
-                    mBuffer[j % 4] == ']' &&
-                    mBuffer[(j + 1) % 4] == '>') {
-                    *mOut << CDATA_END;
-                    *mOut << CDATA_START;
-                }
-                j = j % 4;
-                printUTF8Char(mBuffer[j]);
-            }
-
-            j = ++j % 4;
-            printUTF8Char(mBuffer[j]);
-            j = ++j % 4;
-            printUTF8Char(mBuffer[j]);
-            j = ++j % 4;
-            printUTF8Char(mBuffer[j]);
-        }
-
-        *mOut << CDATA_END;
-    }
-    else {
-        printWithXMLEntities(aData);
-    }
-
-    return NS_OK;
-}
-
-nsresult
-txXMLOutput::comment(const nsAString& aData)
-{
-    closeStartTag(MB_FALSE);
-
-    if (mOutputFormat.mIndent == eTrue) {
-        for (PRUint32 i = 0; i < mIndentLevel; i++)
-            *mOut << ' ';
-    }
-    *mOut << COMMENT_START;
-    printUTF8Chars(aData);
-    *mOut << COMMENT_END;
-    if (mOutputFormat.mIndent == eTrue)
-        *mOut << endl;
-
-    return NS_OK;
-}
-
-nsresult
-txXMLOutput::endDocument(nsresult aResult)
-{
-    return NS_OK;
-}
-
-nsresult
-txXMLOutput::endElement(const nsAString& aName,
-                             const PRInt32 aNsID)
-{
-    MBool newLine = (mOutputFormat.mIndent == eTrue) && mAfterEndTag;
-    MBool writeEndTag = !(mStartTagOpen && mUseEmptyElementShorthand);
-    closeStartTag(mUseEmptyElementShorthand);
-    if (newLine)
-        *mOut << endl;
-    if (mOutputFormat.mIndent == eTrue)
-        mIndentLevel -= DEFAULT_INDENT;
-    if (writeEndTag) {
-        if (newLine) {
-            for (PRUint32 i = 0; i < mIndentLevel; i++)
-                *mOut << ' ';
-        }
-        *mOut << L_ANGLE_BRACKET << FORWARD_SLASH;
-        printUTF8Chars(aName);
-        *mOut << R_ANGLE_BRACKET;
-    }
-    if (mOutputFormat.mIndent == eTrue)
-        *mOut << endl;
-    mAfterEndTag = MB_TRUE;
-    mInCDATASection = mCDATASections.pop() != 0;
-
-    return NS_OK;
-}
-
-nsresult
-txXMLOutput::processingInstruction(const nsAString& aTarget,
-                                   const nsAString& aData)
-{
-    closeStartTag(MB_FALSE);
-    if (mOutputFormat.mIndent == eTrue) {
-        for (PRUint32 i = 0; i < mIndentLevel; i++)
-            *mOut << ' ';
-    }
-    *mOut << PI_START;
-    printUTF8Chars(aTarget);
-    *mOut << SPACE;
-    printUTF8Chars(aData);
-    *mOut << PI_END;
-    if (mOutputFormat.mIndent == eTrue)
-        *mOut << endl;
-
-    return NS_OK;
-}
-
-nsresult
-txXMLOutput::startDocument()
-{
-    if (mOutputFormat.mMethod == eMethodNotSet) {
-        // XXX We should "cache" content until we have a 
-        //     document element
-    }
-    if (mOutputFormat.mMethod == eXMLOutput &&
-        mOutputFormat.mOmitXMLDeclaration != eTrue) {
-      *mOut << PI_START << XML_DECL << DOUBLE_QUOTE;
-      *mOut << XML_VERSION;
-      *mOut << DOUBLE_QUOTE << " encoding=\"UTF-8\"";
-      if (mOutputFormat.mStandalone != eNotSet) {
-        *mOut << " standalone=\"";
-        *mOut << (mOutputFormat.mStandalone == eFalse ? "no" : "yes") << "\"";
-      }
-      *mOut << PI_END << endl;
-      
-    }
-
-    return NS_OK;
-}
-
-nsresult
-txXMLOutput::startElement(const nsAString& aName,
-                          const PRInt32 aNsID)
-{
-    if (!mHaveDocumentElement) {
-        // XXX Output doc type and "cached" content
-        mHaveDocumentElement = MB_TRUE;
-    }
-
-    MBool newLine = mStartTagOpen || mAfterEndTag;
-    closeStartTag(MB_FALSE);
-
-    if (mOutputFormat.mIndent == eTrue) {
-        if (newLine) {
-            *mOut << endl;
-            for (PRUint32 i = 0; i < mIndentLevel; i++)
-                *mOut << ' ';
-        }
-    }
-    *mOut << L_ANGLE_BRACKET;
-    printUTF8Chars(aName);
-    mStartTagOpen = MB_TRUE;
-    if (mOutputFormat.mIndent == eTrue)
-        mIndentLevel += DEFAULT_INDENT;
-
-    mCDATASections.push((void*)mInCDATASection);
-    mInCDATASection = MB_FALSE;
-
-    nsCOMPtr<nsIAtom> localName = do_GetAtom(aName);
-    txExpandedName currentElement(aNsID, localName);
-    txListIterator iter(&(mOutputFormat.mCDATASectionElements));
-    while (iter.hasNext()) {
-        if (currentElement == *(txExpandedName*)iter.next()) {
-            mInCDATASection = MB_TRUE;
-            break;
-        }
-    }
-
-    return NS_OK;
-}
-
-void txXMLOutput::closeStartTag(MBool aUseEmptyElementShorthand)
-{
-    mAfterEndTag = aUseEmptyElementShorthand;
-    if (mStartTagOpen) {
-        txListIterator iter(&mAttributes);
-        txOutAttr* att;
-        while ((att = (txOutAttr*)iter.next())) {
-            *mOut << SPACE;
-            const char* attrVal;
-            att->mName.mLocalName->GetUTF8String(&attrVal);
-            *mOut << attrVal;
-            if (!att->mShorthand) {
-                *mOut << EQUALS << DOUBLE_QUOTE;
-                printWithXMLEntities(att->mValue, MB_TRUE);
-                *mOut << DOUBLE_QUOTE;
-            }
-            delete (txOutAttr*)iter.remove();
-        }
-
-        if (aUseEmptyElementShorthand)
-            *mOut << FORWARD_SLASH;
-        *mOut << R_ANGLE_BRACKET;
-        mStartTagOpen = MB_FALSE;
-    }
-}
-
-void txXMLOutput::printUTF8Char(PRUnichar& ch)
-{
-    // PRUnichar is 16-bits so we only need to cover up to 0xFFFF
-
-    // 0x0000-0x007F
-    if (ch < 128) {
-        *mOut << (char)ch;
-    }
-    // 0x0080-0x07FF
-    else if (ch < 2048) {
-        *mOut << (char) (192+(ch/64));        // 0xC0 + x/64
-        *mOut << (char) (128+(ch%64));        // 0x80 + x%64
-    }
-    // 0x800-0xFFFF
-    else {
-        *mOut << (char) (224+(ch/4096));      // 0xE0 + x/64^2
-        *mOut << (char) (128+((ch/64)%64));   // 0x80 + (x/64)%64
-        *mOut << (char) (128+(ch%64));        // 0x80 + x%64
-    }
-}
-
-void txXMLOutput::printUTF8Chars(const nsAString& aData)
-{
-    *mOut << NS_ConvertUTF16toUTF8(aData).get();
-}
-
-void txXMLOutput::printWithXMLEntities(const nsAString& aData,
-                                       MBool aAttribute)
-{
-    nsAString::const_iterator iter, end;
-    aData.EndReading(end);
-
-    for (aData.BeginReading(iter); iter != end; ++iter) {
-        PRUnichar currChar = *iter;
-        switch (currChar) {
-            case AMPERSAND:
-                *mOut << AMP_ENTITY;
-                break;
-            case APOSTROPHE:
-                if (aAttribute)
-                    *mOut << APOS_ENTITY;
-                else
-                    printUTF8Char(currChar);
-                break;
-            case GT:
-                *mOut << GT_ENTITY;
-                break;
-            case LT:
-                *mOut << LT_ENTITY;
-                break;
-            case QUOTE:
-                if (aAttribute)
-                    *mOut << QUOT_ENTITY;
-                else
-                    printUTF8Char(currChar);
-                break;
-            default:
-                printUTF8Char(currChar);
-                break;
-        }
-    }
-    *mOut << flush;
-}
deleted file mode 100644
--- a/content/xslt/src/xslt/txXMLOutput.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is TransforMiiX XSLT processor code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2001
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Peter Van der Beken <peterv@propagandism.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef TRANSFRMX_XML_OUTPUT_H
-#define TRANSFRMX_XML_OUTPUT_H
-
-#include "txXMLEventHandler.h"
-#include "txList.h"
-#include "txStack.h"
-#include "txOutputFormat.h"
-#include "txXMLUtils.h"
-
-#define DASH            '-'
-#define TX_CR           '\r'
-#define TX_LF           '\n'
-
-#define AMPERSAND       '&'
-#define APOSTROPHE      '\''
-#define GT              '>'
-#define LT              '<'
-#define QUOTE           '"'
-
-#define AMP_ENTITY      "&amp;"
-#define APOS_ENTITY     "&apos;"
-#define GT_ENTITY       "&gt;"
-#define LT_ENTITY       "&lt;"
-#define QUOT_ENTITY     "&quot;"
-#define HEX_ENTITY      "&#"
-
-#define CDATA_END       "]]>"
-#define CDATA_START     "<![CDATA["
-#define COMMENT_START   "<!--"
-#define COMMENT_END     "-->"
-#define DOCTYPE_START   "<!DOCTYPE "
-#define DOCTYPE_END     ">"
-#define DOUBLE_QUOTE    "\""
-#define EQUALS          "="
-#define FORWARD_SLASH   "/"
-#define L_ANGLE_BRACKET "<"
-#define PI_START        "<?"
-#define PI_END          "?>"
-#define PUBLIC          "PUBLIC"
-#define R_ANGLE_BRACKET ">"
-#define SEMICOLON       ";"
-#define SPACE           " "
-#define SYSTEM          "SYSTEM"
-#define XML_DECL        "xml version="
-#define XML_VERSION     "1.0"
-
-class txOutAttr {
-public:
-    txOutAttr(PRInt32 aNsID, nsIAtom* aLocalName, const nsAString& aValue);
-    txExpandedName mName;
-    nsString mValue;
-    MBool mShorthand;
-};
-
-class txXMLOutput : public txAOutputXMLEventHandler
-{
-public:
-    txXMLOutput(txOutputFormat* aFormat, ostream* aOut);
-
-    static const int DEFAULT_INDENT;
-
-    TX_DECL_TXAXMLEVENTHANDLER
-    TX_DECL_TXAOUTPUTXMLEVENTHANDLER
-
-protected:
-    virtual void closeStartTag(MBool aUseEmptyElementShorthand);
-    void printUTF8Char(PRUnichar& ch);
-    void printUTF8Chars(const nsAString& aData);
-    void printWithXMLEntities(const nsAString& aData,
-                              MBool aAttribute = MB_FALSE);
-
-    ostream* mOut;
-    txOutputFormat mOutputFormat;
-    MBool mUseEmptyElementShorthand;
-    MBool mHaveDocumentElement;
-    MBool mStartTagOpen;
-    MBool mAfterEndTag;
-    MBool mInCDATASection;
-    PRUint32 mIndentLevel;
-    txList mAttributes;
-    txStack mCDATASections;
-
-private:
-    PRUnichar mBuffer[4];
-};
-
-#endif
--- a/content/xslt/src/xslt/txXPathResultComparator.cpp
+++ b/content/xslt/src/xslt/txXPathResultComparator.cpp
@@ -35,47 +35,40 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "txXPathResultComparator.h"
 #include "txExpr.h"
 #include "txCore.h"
-#ifndef TX_EXE
 #include "nsCollationCID.h"
 #include "nsILocale.h"
 #include "nsILocaleService.h"
 #include "nsIServiceManager.h"
 #include "nsLocaleCID.h"
 #include "prmem.h"
-#else
-#include "txStringUtils.h"
-#endif
 
 #define kAscending (1<<0)
 #define kUpperFirst (1<<1)
 
 txResultStringComparator::txResultStringComparator(MBool aAscending,
                                                    MBool aUpperFirst,
                                                    const nsAFlatString& aLanguage)
 {
     mSorting = 0;
     if (aAscending)
         mSorting |= kAscending;
     if (aUpperFirst)
         mSorting |= kUpperFirst;
-#ifndef TX_EXE
     nsresult rv = init(aLanguage);
     if (NS_FAILED(rv))
         NS_ERROR("Failed to initialize txResultStringComparator");
-#endif
 }
 
-#ifndef TX_EXE
 nsresult txResultStringComparator::init(const nsAFlatString& aLanguage)
 {
     nsresult rv;
 
     nsCOMPtr<nsILocaleService> localeService =
                     do_GetService(NS_LOCALESERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -93,89 +86,59 @@ nsresult txResultStringComparator::init(
                     do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = colFactory->CreateCollation(locale, getter_AddRefs(mCollation));
     NS_ENSURE_SUCCESS(rv, rv);
 
     return NS_OK;
 }
-#endif
 
 nsresult
 txResultStringComparator::createSortableValue(Expr *aExpr,
                                               txIEvalContext *aContext,
                                               txObject *&aResult)
 {
     nsAutoPtr<StringValue> val(new StringValue);
     if (!val) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    nsresult rv;
-#ifdef TX_EXE
-    rv = aExpr->evaluateToString(aContext, val->mStr);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // We don't support case-order on standalone
-    TX_ToLowerCase(val->mStr);
-#else
     if (!mCollation)
         return NS_ERROR_FAILURE;
 
     val->mCaseKey = new nsString;
     if (!val->mCaseKey) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
     nsString& nsCaseKey = *(nsString *)val->mCaseKey;
-    rv = aExpr->evaluateToString(aContext, nsCaseKey);
+    nsresult rv = aExpr->evaluateToString(aContext, nsCaseKey);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (nsCaseKey.IsEmpty()) {
         aResult = val.forget();
 
         return NS_OK;
     }
 
     rv = mCollation->AllocateRawSortKey(nsICollation::kCollationCaseInSensitive,
                                         nsCaseKey, &val->mKey, &val->mLength);
     NS_ENSURE_SUCCESS(rv, rv);
-#endif
 
     aResult = val.forget();
 
     return NS_OK;
 }
 
 int txResultStringComparator::compareValues(TxObject* aVal1, TxObject* aVal2)
 {
     StringValue* strval1 = (StringValue*)aVal1;
     StringValue* strval2 = (StringValue*)aVal2;
-#ifdef TX_EXE
-    PRUint32 len1 = strval1->mStr.Length();
-    PRUint32 len2 = strval2->mStr.Length();
-    PRUint32 minLength = (len1 < len2) ? len1 : len2;
 
-    PRUint32 c = 0;
-    while (c < minLength) {
-        PRUnichar ch1 = strval1->mStr.CharAt(c);
-        PRUnichar ch2 = strval2->mStr.CharAt(c);
-        if (ch1 < ch2)
-            return ((mSorting & kAscending) ? 1 : -1) * -1;
-        if (ch2 < ch1)
-            return ((mSorting & kAscending) ? 1 : -1) * 1;
-        c++;
-    }
-
-    if (len1 == len2)
-        return 0;
-
-    return ((mSorting & kAscending) ? 1 : -1) * ((len1 < len2) ? -1 : 1);
-#else
     if (!mCollation)
         return -1;
 
     if (strval1->mLength == 0) {
         if (strval2->mLength == 0)
             return 0;
         return ((mSorting & kAscending) ? -1 : 1);
     }
@@ -229,36 +192,33 @@ int txResultStringComparator::compareVal
                                        &result);
     if (NS_FAILED(rv)) {
         // XXX ErrorReport
         return -1;
     }
 
     return ((mSorting & kAscending) ? 1 : -1) *
            ((mSorting & kUpperFirst) ? -1 : 1) * result;
-#endif
 }
 
-#ifndef TX_EXE
 txResultStringComparator::StringValue::StringValue() : mKey(0),
                                                        mCaseKey(0),
                                                        mLength(0),
                                                        mCaseLength(0)
 {
 }
 
 txResultStringComparator::StringValue::~StringValue()
 {
     PR_Free(mKey);
     if (mCaseLength > 0)
         PR_Free((PRUint8*)mCaseKey);
     else
         delete (nsString*)mCaseKey;
 }
-#endif
 
 txResultNumberComparator::txResultNumberComparator(MBool aAscending)
 {
     mAscending = aAscending ? 1 : -1;
 }
 
 nsresult
 txResultNumberComparator::createSortableValue(Expr *aExpr,
--- a/content/xslt/src/xslt/txXPathResultComparator.h
+++ b/content/xslt/src/xslt/txXPathResultComparator.h
@@ -36,20 +36,18 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef TRANSFRMX_XPATHRESULTCOMPARATOR_H
 #define TRANSFRMX_XPATHRESULTCOMPARATOR_H
 
 #include "txCore.h"
-#ifndef TX_EXE
 #include "nsCOMPtr.h"
 #include "nsICollation.h"
-#endif
 #include "nsString.h"
 
 class Expr;
 class txIEvalContext;
 
 /*
  * Result comparators
  */
@@ -81,39 +79,33 @@ class txResultStringComparator : public 
 public:
     txResultStringComparator(MBool aAscending, MBool aUpperFirst,
                              const nsAFlatString& aLanguage);
 
     int compareValues(TxObject* aVal1, TxObject* aVal2);
     nsresult createSortableValue(Expr *aExpr, txIEvalContext *aContext,
                                  TxObject *&aResult);
 private:
-#ifndef TX_EXE
     nsCOMPtr<nsICollation> mCollation;
     nsresult init(const nsAFlatString& aLanguage);
     nsresult createRawSortKey(const PRInt32 aStrength,
                               const nsString& aString,
                               PRUint8** aKey,
                               PRUint32* aLength);
-#endif
     int mSorting;
 
     class StringValue : public TxObject
     {
     public:
-#ifdef TX_EXE
-        nsString mStr;
-#else
         StringValue();
         ~StringValue();
 
         PRUint8* mKey;
         void* mCaseKey;
         PRUint32 mLength, mCaseLength;
-#endif
     };
 };
 
 /*
  * Compare results as numbers (data-type="number")
  */
 class txResultNumberComparator : public txXPathResultComparator
 {
--- a/content/xslt/src/xslt/txXSLTPatterns.cpp
+++ b/content/xslt/src/xslt/txXSLTPatterns.cpp
@@ -39,19 +39,17 @@
 #include "nsReadableUtils.h"
 #include "txExecutionState.h"
 #include "txXSLTPatterns.h"
 #include "txNodeSetContext.h"
 #include "txForwardContext.h"
 #include "txXMLUtils.h"
 #include "txXSLTFunctions.h"
 #include "nsWhitespaceTokenizer.h"
-#ifndef TX_EXE
 #include "nsIContent.h"
-#endif
 
 /*
  * Returns the default priority of this Pattern.
  * UnionPatterns don't like this.
  * This should be called on the simple patterns.
  */
 double txUnionPattern::getDefaultPriority()
 {
@@ -299,32 +297,20 @@ txIdPattern::txIdPattern(const nsSubstri
 
 MBool txIdPattern::matches(const txXPathNode& aNode, txIMatchContext* aContext)
 {
     if (!txXPathNodeUtils::isElement(aNode)) {
         return PR_FALSE;
     }
 
     // Get a ID attribute, if there is
-#ifdef TX_EXE
-    Element* elem;
-    nsresult rv = txXPathNativeNode::getElement(aNode, &elem);
-    NS_ASSERTION(NS_SUCCEEDED(rv), "So why claim it's an element above?");
-
-    nsAutoString value;
-    if (!elem->getIDValue(value)) {
-        return PR_FALSE;
-    }
-    nsCOMPtr<nsIAtom> id = do_GetAtom(value);
-#else
     nsIContent* content = txXPathNativeNode::getContent(aNode);
     NS_ASSERTION(content, "a Element without nsIContent");
 
     nsIAtom* id = content->GetID();
-#endif // TX_EXE
     return id && mIds.IndexOf(id) > -1;
 }
 
 double txIdPattern::getDefaultPriority()
 {
     return 0.5;
 }
 
--- a/content/xslt/src/xslt/txXSLTProcessor.cpp
+++ b/content/xslt/src/xslt/txXSLTProcessor.cpp
@@ -39,61 +39,39 @@
 #include "txXSLTProcessor.h"
 #include "txInstructions.h"
 #include "txAtoms.h"
 #include "txLog.h"
 #include "txStylesheetCompileHandlers.h"
 #include "txStylesheetCompiler.h"
 #include "txExecutionState.h"
 #include "txExprResult.h"
-#ifdef TX_EXE
-#include "txHTMLOutput.h"
-#endif
 
 TX_LG_IMPL
 
 /* static */
 MBool
 txXSLTProcessor::init()
 {
     TX_LG_CREATE;
 
-#ifdef TX_EXE
-    if (!txStandaloneNamespaceManager::init())
-        return MB_FALSE;
-
-    if (NS_FAILED(txHTMLOutput::init())) {
-        return MB_FALSE;
-    }
-
-    txXMLAtoms::init();
-    txXPathAtoms::init();
-    txXSLTAtoms::init();
-    txHTMLAtoms::init();
-#endif
-    
     if (!txHandlerTable::init())
         return MB_FALSE;
 
     extern PRBool TX_InitEXSLTFunction();
     if (!TX_InitEXSLTFunction())
         return MB_FALSE;
 
     return MB_TRUE;
 }
 
 /* static */
 void
 txXSLTProcessor::shutdown()
 {
-#ifdef TX_EXE
-    txStandaloneNamespaceManager::shutdown();
-    txHTMLOutput::shutdown();
-#endif
-
     txStylesheetCompilerState::shutdown();
     txHandlerTable::shutdown();
 }
 
 
 /* static */
 nsresult
 txXSLTProcessor::execute(txExecutionState& aEs)
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1839,17 +1839,17 @@ nsJSContext::CallEventHandler(nsISupport
     return NS_OK;
   }
 
 #ifdef NS_FUNCTION_TIMER
   {
     JSObject *obj = static_cast<JSObject *>(aHandler);
     if (obj->isFunctionProxy())
       obj = obj->unwrap(NULL);
-    JSString *id = JS_GetFunctionId(GET_FUNCTION_PRIVATE(mContext, obj));
+    JSString *id = JS_GetFunctionId(static_cast<JSFunction *>(JS_GetPrivate(mContext, obj)));
     JSAutoByteString bytes;
     const char *name = !id ? "anonymous" : bytes.encode(mContext, id) ? bytes.ptr() : "<error>";
     NS_TIME_FUNCTION_FMT(1.0, "%s (line %d) (function: %s)", MOZ_FUNCTION_NAME, __LINE__, name);
   }
 #endif
 
   JSAutoRequest ar(mContext);
   JSObject* target = nsnull;
--- a/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl
+++ b/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl
@@ -837,9 +837,12 @@ interface nsIDOMWebGLRenderingContext : 
   // the underlying renderer to the user.
   [noscript] DOMString mozGetUnderlyingParamString(in WebGLenum pname);
 
   // extensions
   nsIWebGLExtension getExtension(in DOMString name);
 
   nsIVariant getSupportedExtensions();
   WebGLboolean isContextLost();
+
+  readonly attribute WebGLsizei drawingBufferWidth;
+  readonly attribute WebGLsizei drawingBufferHeight;
 };
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -167,16 +167,18 @@ fix-cairo-win32-print-gdi-error.diff: Do
 pixman-image-transform.patch: Reset the transform on pixman images when using them as destinations.
 
 fix-cairo-surface-wrapper-flush-build-warning.patch: Ensures that _cairo_surface_wrapper_flush always returns a status, to silence the build warning
 
 fixup-unbounded.patch: Hack to work around bad assumption.
 
 quartz-get-image-performance: Make cairo_quartz_get_image faster in the failure case by not flushing unless we are going to succeed.
 
+lround-c99-only.patch: Only use lround in C99 programs.
+
 ==== pixman patches ====
 
 pixman-android-cpu-detect.patch: Add CPU detection support for Android, where we can't reliably access /proc/self/auxv.
 
 pixman-rename-and-endian.patch: include cairo-platform.h for renaming of external symbols and endian macros
 
 NOTE: we previously supported ARM assembler on MSVC, this has been removed because of the maintenance burden
 
--- a/gfx/cairo/cairo/src/cairo-misc.c
+++ b/gfx/cairo/cairo/src/cairo-misc.c
@@ -478,17 +478,17 @@ uint32_t
     case CAIRO_OPERATOR_IN:
     case CAIRO_OPERATOR_DEST_IN:
     case CAIRO_OPERATOR_DEST_ATOP:
 	return 0;
     }
 
 }
 
-#if DISABLE_SOME_FLOATING_POINT
+#if DISABLE_SOME_FLOATING_POINT || __STDC_VERSION__ < 199901L
 /* This function is identical to the C99 function lround(), except that it
  * performs arithmetic rounding (floor(d + .5) instead of away-from-zero rounding) and
  * has a valid input range of (INT_MIN, INT_MAX] instead of
  * [INT_MIN, INT_MAX]. It is much faster on both x86 and FPU-less systems
  * than other commonly used methods for rounding (lround, round, rint, lrint
  * or float (d + 0.5)).
  *
  * The reason why this function is much faster on x86 than other
--- a/gfx/cairo/cairo/src/cairoint.h
+++ b/gfx/cairo/cairo/src/cairoint.h
@@ -969,17 +969,17 @@ static inline double cairo_const
  * away from 0. _cairo_round rounds halfway cases toward negative infinity.
  * This matches the rounding behaviour of _cairo_lround. */
 static inline double cairo_const
 _cairo_round (double r)
 {
     return floor (r + .5);
 }
 
-#if DISABLE_SOME_FLOATING_POINT
+#if DISABLE_SOME_FLOATING_POINT || __STDC_VERSION__ < 199901L
 cairo_private int
 _cairo_lround (double d) cairo_const;
 #else
 #define _cairo_lround lround
 #endif
 
 cairo_private uint16_t
 _cairo_half_from_float (float f) cairo_const;
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/lround-c99-only.patch
@@ -0,0 +1,46 @@
+Only use lround in C99 programs.
+
+diff --git a/gfx/cairo/cairo/src/cairo-misc.c b/gfx/cairo/cairo/src/cairo-misc.c
+--- a/gfx/cairo/cairo/src/cairo-misc.c
++++ b/gfx/cairo/cairo/src/cairo-misc.c
+@@ -478,17 +478,17 @@ _cairo_operator_bounded_by_either (cairo
+     case CAIRO_OPERATOR_IN:
+     case CAIRO_OPERATOR_DEST_IN:
+     case CAIRO_OPERATOR_DEST_ATOP:
+ 	return 0;
+     }
+ 
+ }
+ 
+-#if DISABLE_SOME_FLOATING_POINT
++#if DISABLE_SOME_FLOATING_POINT || __STDC_VERSION__ < 199901L
+ /* This function is identical to the C99 function lround(), except that it
+  * performs arithmetic rounding (floor(d + .5) instead of away-from-zero rounding) and
+  * has a valid input range of (INT_MIN, INT_MAX] instead of
+  * [INT_MIN, INT_MAX]. It is much faster on both x86 and FPU-less systems
+  * than other commonly used methods for rounding (lround, round, rint, lrint
+  * or float (d + 0.5)).
+  *
+  * The reason why this function is much faster on x86 than other
+diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
+--- a/gfx/cairo/cairo/src/cairoint.h
++++ b/gfx/cairo/cairo/src/cairoint.h
+@@ -969,17 +969,17 @@ _cairo_restrict_value (double value, dou
+  * away from 0. _cairo_round rounds halfway cases toward negative infinity.
+  * This matches the rounding behaviour of _cairo_lround. */
+ static inline double cairo_const
+ _cairo_round (double r)
+ {
+     return floor (r + .5);
+ }
+ 
+-#if DISABLE_SOME_FLOATING_POINT
++#if DISABLE_SOME_FLOATING_POINT || __STDC_VERSION__ < 199901L
+ cairo_private int
+ _cairo_lround (double d) cairo_const;
+ #else
+ #define _cairo_lround lround
+ #endif
+ 
+ cairo_private uint16_t
+ _cairo_half_from_float (float f) cairo_const;
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -442,17 +442,17 @@ GCZeal(JSContext *cx,
 
 static JSBool
 DumpHeap(JSContext *cx,
          uintN argc,
          jsval *vp)
 {
     JSAutoByteString fileName;
     void* startThing = NULL;
-    uint32 startTraceKind = 0;
+    JSGCTraceKind startTraceKind = JSTRACE_OBJECT;
     void *thingToFind = NULL;
     size_t maxDepth = (size_t)-1;
     void *thingToIgnore = NULL;
     FILE *dumpFile;
     JSBool ok;
 
     jsval *argv = JS_ARGV(cx, vp);
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
--- a/js/jsd/jsd_xpc.cpp
+++ b/js/jsd/jsd_xpc.cpp
@@ -2855,17 +2855,17 @@ jsdService::DumpHeap(const nsACString &f
     return NS_ERROR_NOT_IMPLEMENTED;
 #else
     nsresult rv = NS_OK;
     FILE *file = !fileName.IsEmpty() ? fopen(PromiseFlatCString(fileName).get(), "w") : stdout;
     if (!file) {
         rv = NS_ERROR_FAILURE;
     } else {
         JSContext *cx = JSD_GetDefaultJSContext (mCx);
-        if (!JS_DumpHeap(cx, file, NULL, 0, NULL, (size_t)-1, NULL))
+        if (!JS_DumpHeap(cx, file, NULL, JSTRACE_OBJECT, NULL, (size_t)-1, NULL))
             rv = NS_ERROR_FAILURE;
         if (file != stdout)
             fclose(file);
     }
     return rv;
 #endif
 }
 
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -2187,36 +2187,33 @@ JS_SetExtraGCRoots(JSRuntime *rt, JSTrac
 
 JS_PUBLIC_API(void)
 JS_TraceRuntime(JSTracer *trc)
 {
     TraceRuntime(trc);
 }
 
 JS_PUBLIC_API(void)
-JS_CallTracer(JSTracer *trc, void *thing, uint32 kind)
+JS_CallTracer(JSTracer *trc, void *thing, JSGCTraceKind kind)
 {
     JS_ASSERT(thing);
-    JS_ASSERT(kind <= JSTRACE_LAST);
-    MarkKind(trc, thing, JSGCTraceKind(kind));
+    MarkKind(trc, thing, kind);
 }
 
 #ifdef DEBUG
 
 #ifdef HAVE_XPCONNECT
 #include "dump_xpc.h"
 #endif
 
 JS_PUBLIC_API(void)
-JS_PrintTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing, uint32 kindIndex,
-                       JSBool details)
-{
-    JS_ASSERT(kindIndex <= JSTRACE_LAST);
-    JSGCTraceKind kind = JSGCTraceKind(kindIndex);
-    const char *name;
+JS_PrintTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc, void *thing,
+                       JSGCTraceKind kind, JSBool details)
+{
+    const char *name = NULL; /* silence uninitialized warning */
     size_t n;
 
     if (bufsize == 0)
         return;
 
     switch (kind) {
       case JSTRACE_OBJECT:
       {
@@ -2331,17 +2328,17 @@ JS_PrintTraceThingInfo(char *buf, size_t
     }
     buf[bufsize - 1] = '\0';
 }
 
 typedef struct JSHeapDumpNode JSHeapDumpNode;
 
 struct JSHeapDumpNode {
     void            *thing;
-    uint32          kind;
+    JSGCTraceKind   kind;
     JSHeapDumpNode  *next;          /* next sibling */
     JSHeapDumpNode  *parent;        /* node with the thing that refer to thing
                                        from this node */
     char            edgeName[1];    /* name of the edge from parent->thing
                                        into thing */
 };
 
 typedef struct JSDumpingTracer {
@@ -2352,17 +2349,17 @@ typedef struct JSDumpingTracer {
     void                *thingToFind;
     void                *thingToIgnore;
     JSHeapDumpNode      *parentNode;
     JSHeapDumpNode      **lastNodep;
     char                buffer[200];
 } JSDumpingTracer;
 
 static void
-DumpNotify(JSTracer *trc, void *thing, uint32 kind)
+DumpNotify(JSTracer *trc, void *thing, JSGCTraceKind kind)
 {
     JSDumpingTracer *dtrc;
     JSContext *cx;
     JSDHashEntryStub *entry;
     JSHeapDumpNode *node;
     const char *edgeName;
     size_t edgeNameSize;
 
@@ -2496,17 +2493,17 @@ DumpNode(JSDumpingTracer *dtrc, FILE* fp
         prev = node;
         node = following;
     } while (node);
 
     return ok && putc('\n', fp) >= 0;
 }
 
 JS_PUBLIC_API(JSBool)
-JS_DumpHeap(JSContext *cx, FILE *fp, void* startThing, uint32 startKind,
+JS_DumpHeap(JSContext *cx, FILE *fp, void* startThing, JSGCTraceKind startKind,
             void *thingToFind, size_t maxDepth, void *thingToIgnore)
 {
     JSDumpingTracer dtrc;
     JSHeapDumpNode *node, *children, *next, *parent;
     size_t depth;
     JSBool thingToFindWasTraced;
 
     if (maxDepth == 0)
@@ -2522,17 +2519,17 @@ JS_DumpHeap(JSContext *cx, FILE *fp, voi
     dtrc.ok = JS_TRUE;
     dtrc.startThing = startThing;
     dtrc.thingToFind = thingToFind;
     dtrc.thingToIgnore = thingToIgnore;
     dtrc.parentNode = NULL;
     node = NULL;
     dtrc.lastNodep = &node;
     if (!startThing) {
-        JS_ASSERT(startKind == 0);
+        JS_ASSERT(startKind == JSTRACE_OBJECT);
         TraceRuntime(&dtrc.base);
     } else {
         JS_TraceChildren(&dtrc.base, startThing, startKind);
     }
 
     depth = 1;
     if (!node)
         goto dump_out;
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1605,18 +1605,18 @@ JS_SetExtraGCRoots(JSRuntime *rt, JSTrac
  */
 
 typedef enum {
     JSTRACE_OBJECT,
     JSTRACE_STRING,
     JSTRACE_SCRIPT,
 
     /*
-     * Trace kinds internal to the engine. JSTraceCallback implementation can
-     * only call JS_TraceChildren on them.
+     * Trace kinds internal to the engine. The embedding can only them if it
+     * implements JSTraceCallback.
      */ 
 #if JS_HAS_XML_SUPPORT
     JSTRACE_XML,
 #endif
     JSTRACE_SHAPE,
     JSTRACE_TYPE_OBJECT,
     JSTRACE_LAST = JSTRACE_TYPE_OBJECT
 } JSGCTraceKind;
@@ -1634,41 +1634,56 @@ JSVAL_IS_TRACEABLE(jsval v)
 }
 
 static JS_ALWAYS_INLINE void *
 JSVAL_TO_TRACEABLE(jsval v)
 {
     return JSVAL_TO_GCTHING(v);
 }
 
-static JS_ALWAYS_INLINE uint32
+static JS_ALWAYS_INLINE JSGCTraceKind
 JSVAL_TRACE_KIND(jsval v)
 {
     jsval_layout l;
     JS_ASSERT(JSVAL_IS_GCTHING(v));
     l.asBits = JSVAL_BITS(v);
-    return JSVAL_TRACE_KIND_IMPL(l);
+    return (JSGCTraceKind) JSVAL_TRACE_KIND_IMPL(l);
 }
 
+/*
+ * Tracer callback, called for each traceable thing directly referenced by a
+ * particular object or runtime structure. It is the callback responsibility
+ * to ensure the traversal of the full object graph via calling eventually
+ * JS_TraceChildren on the passed thing. In this case the callback must be
+ * prepared to deal with cycles in the traversal graph.
+ *
+ * kind argument is one of JSTRACE_OBJECT, JSTRACE_STRING or a tag denoting
+ * internal implementation-specific traversal kind. In the latter case the only
+ * operations on thing that the callback can do is to call JS_TraceChildren or
+ * DEBUG-only JS_PrintTraceThingInfo.
+ */
+typedef void
+(* JSTraceCallback)(JSTracer *trc, void *thing, JSGCTraceKind kind);
+
 struct JSTracer {
     JSContext           *context;
     JSTraceCallback     callback;
     JSTraceNamePrinter  debugPrinter;
     const void          *debugPrintArg;
     size_t              debugPrintIndex;
 };
 
 /*
  * The method to call on each reference to a traceable thing stored in a
  * particular JSObject or other runtime structure. With DEBUG defined the
  * caller before calling JS_CallTracer must initialize JSTracer fields
  * describing the reference using the macros below.
  */
 extern JS_PUBLIC_API(void)
-JS_CallTracer(JSTracer *trc, void *thing, uint32 kind);
+JS_CallTracer(JSTracer *trc, void *thing, JSGCTraceKind kind);
 
 /*
  * Set debugging information about a reference to a traceable thing to prepare
  * for the following call to JS_CallTracer.
  *
  * When printer is null, arg must be const char * or char * C string naming
  * the reference and index must be either (size_t)-1 indicating that the name
  * alone describes the reference or it must be an index into some array vector
@@ -1751,44 +1766,44 @@ JS_CallTracer(JSTracer *trc, void *thing
         (trc)->context = (cx_);                                               \
         (trc)->callback = (callback_);                                        \
         (trc)->debugPrinter = NULL;                                           \
         (trc)->debugPrintArg = NULL;                                          \
         (trc)->debugPrintIndex = (size_t)-1;                                  \
     JS_END_MACRO
 
 extern JS_PUBLIC_API(void)
-JS_TraceChildren(JSTracer *trc, void *thing, uint32 kind);
+JS_TraceChildren(JSTracer *trc, void *thing, JSGCTraceKind kind);
 
 extern JS_PUBLIC_API(void)
 JS_TraceRuntime(JSTracer *trc);
 
 #ifdef DEBUG
 
 extern JS_PUBLIC_API(void)
 JS_PrintTraceThingInfo(char *buf, size_t bufsize, JSTracer *trc,
-                       void *thing, uint32 kind, JSBool includeDetails);
+                       void *thing, JSGCTraceKind kind, JSBool includeDetails);
 
 /*
  * DEBUG-only method to dump the object graph of heap-allocated things.
  *
  * fp:              file for the dump output.
  * start:           when non-null, dump only things reachable from start
  *                  thing. Otherwise dump all things reachable from the
  *                  runtime roots.
- * startKind:       trace kind of start if start is not null. Must be 0 when
- *                  start is null.
+ * startKind:       trace kind of start if start is not null. Must be
+ *                  JSTRACE_OBJECT when start is null.
  * thingToFind:     dump only paths in the object graph leading to thingToFind
  *                  when non-null.
  * maxDepth:        the upper bound on the number of edges to descend from the
  *                  graph roots.
  * thingToIgnore:   thing to ignore during the graph traversal when non-null.
  */
 extern JS_PUBLIC_API(JSBool)
-JS_DumpHeap(JSContext *cx, FILE *fp, void* startThing, uint32 startKind,
+JS_DumpHeap(JSContext *cx, FILE *fp, void* startThing, JSGCTraceKind kind,
             void *thingToFind, size_t maxDepth, void *thingToIgnore);
 
 #endif
 
 /*
  * Garbage collector API.
  */
 extern JS_PUBLIC_API(void)
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -2353,17 +2353,17 @@ BindNameToSlot(JSContext *cx, JSCodeGene
         JS_ASSERT(cg->fun()->u.i.skipmin <= skip);
 
         /*
          * If op is a mutating opcode, this upvar's lookup skips too many levels,
          * or the function is heavyweight, we fall back on JSOP_*NAME*.
          */
         if (op != JSOP_NAME)
             return JS_TRUE;
-        if (level >= UpvarCookie::UPVAR_LEVEL_LIMIT)
+        if (skip >= UpvarCookie::UPVAR_LEVEL_LIMIT)
             return JS_TRUE;
         if (cg->flags & TCF_FUN_HEAVYWEIGHT)
             return JS_TRUE;
 
         if (!cg->fun()->isFlatClosure())
             return JS_TRUE;
 
         if (!cg->upvarIndices.ensureMap(cx))
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1615,17 +1615,17 @@ GCMarker::markDelayedChildren()
     }
     JS_ASSERT(!markLaterArenas);
 }
 
 } /* namespace js */
 
 #ifdef DEBUG
 static void
-EmptyMarkCallback(JSTracer *trc, void *thing, uint32 kind)
+EmptyMarkCallback(JSTracer *trc, void *thing, JSGCTraceKind kind)
 {
 }
 #endif
 
 static void
 gc_root_traversal(JSTracer *trc, const RootEntry &entry)
 {
 #ifdef DEBUG
--- a/js/src/jsgcmark.cpp
+++ b/js/src/jsgcmark.cpp
@@ -1006,23 +1006,20 @@ GCMarker::drainMarkStack()
     }
 
     rt->gcCheckCompartment = NULL;
 }
 
 } /* namespace js */
 
 JS_PUBLIC_API(void)
-JS_TraceChildren(JSTracer *trc, void *thing, uint32 kindIndex)
+JS_TraceChildren(JSTracer *trc, void *thing, JSGCTraceKind kind)
 {
-    JS_ASSERT(kindIndex <= JSTRACE_LAST);
-    JSGCTraceKind kind = JSGCTraceKind(kindIndex);
     switch (kind) {
-      default:
-        JS_ASSERT(kind == JSTRACE_OBJECT);
+      case JSTRACE_OBJECT:
 	MarkChildren(trc, static_cast<JSObject *>(thing));
         break;
 
       case JSTRACE_STRING:
 	MarkChildren(trc, static_cast<JSString *>(thing));
         break;
 
       case JSTRACE_SCRIPT:
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -1431,17 +1431,16 @@ js_DoIncDec(JSContext *cx, const JSCodeS
     return JS_TRUE;
 }
 
 const Value &
 js::GetUpvar(JSContext *cx, uintN closureLevel, UpvarCookie cookie)
 {
     JS_ASSERT(closureLevel >= cookie.level() && cookie.level() > 0);
     const uintN targetLevel = closureLevel - cookie.level();
-    JS_ASSERT(targetLevel < UpvarCookie::UPVAR_LEVEL_LIMIT);
 
     StackFrame *fp = FindUpvarFrame(cx, targetLevel);
     uintN slot = cookie.slot();
     const Value *vp;
 
     if (!fp->isFunctionFrame() || fp->isEvalFrame()) {
         vp = fp->slots() + fp->numFixed();
     } else if (slot < fp->numFormalArgs()) {
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -355,31 +355,16 @@ typedef JSBool
  * the traversal is a part of the marking phase through calling
  * JS_IsGCMarkingTracer and apply a special code like emptying caches or
  * marking its native structures.
  */
 typedef void
 (* JSTraceOp)(JSTracer *trc, JSObject *obj);
 
 /*
- * Tracer callback, called for each traceable thing directly referenced by a
- * particular object or runtime structure. It is the callback responsibility
- * to ensure the traversal of the full object graph via calling eventually
- * JS_TraceChildren on the passed thing. In this case the callback must be
- * prepared to deal with cycles in the traversal graph.
- *
- * kind argument is one of JSTRACE_OBJECT, JSTRACE_STRING or a tag denoting
- * internal implementation-specific traversal kind. In the latter case the only
- * operations on thing that the callback can do is to call JS_TraceChildren or
- * DEBUG-only JS_PrintTraceThingInfo.
- */
-typedef void
-(* JSTraceCallback)(JSTracer *trc, void *thing, uint32 kind);
-
-/*
  * DEBUG only callback that JSTraceOp implementation can provide to return
  * a string describing the reference traced with JS_CallTracer.
  */
 typedef void
 (* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize);
 
 typedef JSBool
 (* JSEqualityOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -17166,17 +17166,16 @@ LoopProfile::profileOperation(JSContext*
     } else if (op == JSOP_TYPEOF || op == JSOP_TYPEOFEXPR) {
         stackPush(StackValue(true));
     } else if (op == JSOP_EQ || op == JSOP_NE) {
         StackValue v1 = stackAt(-1);
         StackValue v2 = stackAt(-2);
         stackPush(StackValue(v1.isConst && v2.isConst));
     } else if (op == JSOP_AND) {
         bool b = !!js_ValueToBoolean(cx->regs().sp[-1]);
-        StackValue v = stackAt(-1);
         if (b)
             stackPop();
     } else {
         stackClear();
     }
 
     return ProfContinue;
 }
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1359,30 +1359,30 @@ ScheduleGC(JSContext *cx, uintN argc, js
     return JS_TRUE;
 }
 #endif /* JS_GC_ZEAL */
 
 typedef struct JSCountHeapNode JSCountHeapNode;
 
 struct JSCountHeapNode {
     void                *thing;
-    int32               kind;
+    JSGCTraceKind       kind;
     JSCountHeapNode     *next;
 };
 
 typedef struct JSCountHeapTracer {
     JSTracer            base;
     JSDHashTable        visited;
     JSBool              ok;
     JSCountHeapNode     *traceList;
     JSCountHeapNode     *recycleList;
 } JSCountHeapTracer;
 
 static void
-CountHeapNotify(JSTracer *trc, void *thing, uint32 kind)
+CountHeapNotify(JSTracer *trc, void *thing, JSGCTraceKind kind)
 {
     JSCountHeapTracer *countTracer;
     JSDHashEntryStub *entry;
     JSCountHeapNode *node;
 
     JS_ASSERT(trc->callback == CountHeapNotify);
     countTracer = (JSCountHeapTracer *)trc;
     if (!countTracer->ok)
@@ -1414,17 +1414,17 @@ CountHeapNotify(JSTracer *trc, void *thi
     node->next = countTracer->traceList;
     countTracer->traceList = node;
 }
 
 static JSBool
 CountHeap(JSContext *cx, uintN argc, jsval *vp)
 {
     void* startThing;
-    int32 startTraceKind;
+    JSGCTraceKind startTraceKind;
     jsval v;
     int32 traceKind, i;
     JSString *str;
     JSCountHeapTracer countTracer;
     JSCountHeapNode *node;
     size_t counter;
 
     static const struct {
@@ -1435,17 +1435,17 @@ CountHeap(JSContext *cx, uintN argc, jsv
         { "object",     JSTRACE_OBJECT      },
         { "string",     JSTRACE_STRING      },
 #if JS_HAS_XML_SUPPORT
         { "xml",        JSTRACE_XML         },
 #endif
     };
 
     startThing = NULL;
-    startTraceKind = 0;
+    startTraceKind = JSTRACE_OBJECT;
     if (argc > 0) {
         v = JS_ARGV(cx, vp)[0];
         if (JSVAL_IS_TRACEABLE(v)) {
             startThing = JSVAL_TO_TRACEABLE(v);
             startTraceKind = JSVAL_TRACE_KIND(v);
         } else if (!JSVAL_IS_NULL(v)) {
             JS_ReportError(cx,
                            "the first argument is not null or a heap-allocated "
@@ -2365,17 +2365,17 @@ DumpStats(JSContext *cx, uintN argc, jsv
     return JS_TRUE;
 }
 
 static JSBool
 DumpHeap(JSContext *cx, uintN argc, jsval *vp)
 {
     jsval v;
     void* startThing;
-    uint32 startTraceKind;
+    JSGCTraceKind startTraceKind;
     const char *badTraceArg;
     void *thingToFind;
     size_t maxDepth;
     void *thingToIgnore;
     FILE *dumpFile;
     JSBool ok;
 
     const char *fileName = NULL;
@@ -2391,17 +2391,17 @@ DumpHeap(JSContext *cx, uintN argc, jsva
             JS_ARGV(cx, vp)[0] = STRING_TO_JSVAL(str);
             if (!fileNameBytes.encode(cx, str))
                 return JS_FALSE;
             fileName = fileNameBytes.ptr();
         }
     }
 
     startThing = NULL;
-    startTraceKind = 0;
+    startTraceKind = JSTRACE_OBJECT;
     if (argc > 1) {
         v = JS_ARGV(cx, vp)[1];
         if (JSVAL_IS_TRACEABLE(v)) {
             startThing = JSVAL_TO_TRACEABLE(v);
             startTraceKind = JSVAL_TRACE_KIND(v);
         } else if (!JSVAL_IS_NULL(v)) {
             badTraceArg = "start";
             goto not_traceable_arg;
--- a/js/src/shell/jsheaptools.cpp
+++ b/js/src/shell/jsheaptools.cpp
@@ -82,33 +82,34 @@ using namespace js;
 class HeapReverser : public JSTracer {
   public:
     struct Edge;
 
     /* Metadata for a given Cell we have visited. */
     class Node {
       public:
         Node() { }
-        Node(uint32 kind) : kind(kind), incoming(), marked(false) { }
+        Node(JSGCTraceKind kind)
+          : kind(kind), incoming(), marked(false) { }
 
         /*
          * Move constructor and move assignment. These allow us to store our
          * incoming edge Vector in the hash table: Vectors support moves, but
          * not assignments or copy construction.
          */
         Node(MoveRef<Node> rhs)
           : kind(rhs->kind), incoming(Move(rhs->incoming)), marked(rhs->marked) { }
         Node &operator=(MoveRef<Node> rhs) {
             this->~Node();
             new(this) Node(rhs);
             return *this;
         }
 
         /* What kind of Cell this is. */
-        uint32 kind;
+        JSGCTraceKind kind;
 
         /*
          * A vector of this Cell's incoming edges.
          * This must use SystemAllocPolicy because HashMap requires its elements to
          * be constructible with no arguments.
          */
         Vector<Edge, 0, SystemAllocPolicy> incoming;
 
@@ -194,50 +195,50 @@ class HeapReverser : public JSTracer {
         }
       private:
         HeapReverser *reverser;
         void *savedParent;
     };
 
     /* A work item in the stack of nodes whose children we need to traverse. */
     struct Child {
-        Child(void *cell, uint32 kind) : cell(cell), kind(kind) { }
+        Child(void *cell, JSGCTraceKind kind) : cell(cell), kind(kind) { }
         void *cell;
-        uint32 kind;
+        JSGCTraceKind kind;
     };
 
     /*
      * A stack of work items. We represent the stack explicitly to avoid
      * overflowing the C++ stack when traversing long chains of objects.
      */
     Vector<Child> work; 
 
     /* When traverseEdge is called, the Cell and kind at which the edge originated. */
     void *parent;
 
     /* Traverse an edge. */
-    bool traverseEdge(void *cell, uint32 kind);
+    bool traverseEdge(void *cell, JSGCTraceKind kind);
 
     /*
      * JS_TraceRuntime and JS_TraceChildren don't propagate error returns,
      * and out-of-memory errors, by design, don't establish an exception in
      * |context|, so traverseEdgeWithThis uses this to communicate the
      * result of the traversal to reverseHeap.
      */
     bool traversalStatus;
 
     /* Static member function wrapping 'traverseEdge'. */
-    static void traverseEdgeWithThis(JSTracer *tracer, void *cell, uint32 kind) {
+    static void traverseEdgeWithThis(JSTracer *tracer, void *cell, JSGCTraceKind kind) {
         HeapReverser *reverser = static_cast<HeapReverser *>(tracer);
         reverser->traversalStatus = reverser->traverseEdge(cell, kind);
     }
 };
 
 bool
-HeapReverser::traverseEdge(void *cell, uint32 kind) {
+HeapReverser::traverseEdge(void *cell, JSGCTraceKind kind) {
     /* Capture this edge before the JSTracer members get overwritten. */
     char *edgeDescription = getEdgeDescription();
     if (!edgeDescription)
         return false;
     Edge e(edgeDescription, parent);
 
     Map::AddPtr a = map.lookupForAdd(cell);
     if (!a) {
--- a/js/src/tests/js1_8_5/regress/jstests.list
+++ b/js/src/tests/js1_8_5/regress/jstests.list
@@ -106,12 +106,13 @@ script regress-642247.js
 script regress-643222.js
 script regress-646820-1.js
 script regress-646820-2.js
 script regress-646820-3.js
 script regress-665355.js
 script regress-666599.js
 script regress-667047.js
 script regress-672892.js
+script regress-672893.js
 script regress-673070-1.js
 script regress-673070-2.js
 script regress-673070-3.js
 script regress-675581.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/js1_8_5/regress/regress-672893.js
@@ -0,0 +1,18 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+function f() {
+    return function () { return function () { return function () {
+    return function () { return function () { return function () {
+    return function () { return function () { return function () {
+    return function () { return function () { return function () {
+    return function () { return function () { return function (a) {
+        var v = a;
+	assertEq(v, 42);
+	return function() { return v; };
+    }; }; }; }; }; }; }; }; }; }; }; }; }; }; };
+};
+
+assertEq(f()()()()()()()()()()()()()()()(42)(), 42);
+
+reportCompare(0, 0, 'ok');
--- a/js/src/xpconnect/shell/xpcshell.cpp
+++ b/js/src/xpconnect/shell/xpcshell.cpp
@@ -571,17 +571,17 @@ GCZeal(JSContext *cx, uintN argc, jsval 
 #endif
 
 #ifdef DEBUG
 
 static JSBool
 DumpHeap(JSContext *cx, uintN argc, jsval *vp)
 {
     void* startThing = NULL;
-    uint32 startTraceKind = 0;
+    JSGCTraceKind startTraceKind = JSTRACE_OBJECT;
     void *thingToFind = NULL;
     size_t maxDepth = (size_t)-1;
     void *thingToIgnore = NULL;
     FILE *dumpFile;
     JSBool ok;
 
     jsval *argv = JS_ARGV(cx, vp);
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
--- a/js/src/xpconnect/src/nsXPConnect.cpp
+++ b/js/src/xpconnect/src/nsXPConnect.cpp
@@ -218,17 +218,17 @@ nsXPConnect::ReleaseXPConnectSingleton()
                 if(dumpName)
                 {
                     FILE* dumpFile = (*dumpName == '\0' ||
                                       strcmp(dumpName, "stdout") == 0)
                                      ? stdout
                                      : fopen(dumpName, "w");
                     if(dumpFile)
                     {
-                        JS_DumpHeap(ccx, dumpFile, nsnull, 0, nsnull,
+                        JS_DumpHeap(ccx, dumpFile, nsnull, JSTRACE_OBJECT, nsnull,
                                     static_cast<size_t>(-1), nsnull);
                         if(dumpFile != stdout)
                             fclose(dumpFile);
                     }
                 }
             }
         }
 #endif
@@ -614,17 +614,17 @@ xpc_GCThingIsGrayCCThing(void *thing)
  *
  * To prevent this badness, we unmark the gray bit of an object when it is
  * accessed by callers outside XPConnect. This would cause the object to go
  * black in step 2 above. This must be done on everything reachable from the
  * object being returned. The following code takes care of the recursive
  * re-coloring.
  */
 static void
-UnmarkGrayChildren(JSTracer *trc, void *thing, uint32 kind)
+UnmarkGrayChildren(JSTracer *trc, void *thing, JSGCTraceKind kind)
 {
     int stackDummy;
     if (!JS_CHECK_STACK_SIZE(trc->context->stackLimit, &stackDummy)) {
         /*
          * If we run out of stack, we take a more drastic measure: require that
          * we GC again before the next CC.
          */
         nsXPConnect* xpc = nsXPConnect::GetXPConnect();
@@ -670,17 +670,17 @@ struct TraversalTracer : public JSTracer
 {
     TraversalTracer(nsCycleCollectionTraversalCallback &aCb) : cb(aCb)
     {
     }
     nsCycleCollectionTraversalCallback &cb;
 };
 
 static void
-NoteJSChild(JSTracer *trc, void *thing, uint32 kind)
+NoteJSChild(JSTracer *trc, void *thing, JSGCTraceKind kind)
 {
     if(AddToCCKind(kind))
     {
         TraversalTracer *tracer = static_cast<TraversalTracer*>(trc);
 
         // There's no point in further traversing a non-gray object here unless
         // we explicitly want to see all traces.
         if(!xpc_IsGrayGCThing(thing) && !tracer->cb.WantAllTraces())
@@ -727,17 +727,17 @@ WrapperIsNotMainThreadOnly(XPCWrappedNat
     return NS_FAILED(CallQueryInterface(wrapper->Native(), &participant));
 }
 
 NS_IMETHODIMP
 nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb)
 {
     JSContext *cx = mCycleCollectionContext->GetJSContext();
 
-    uint32 traceKind = js_GetGCThingTraceKind(p);
+    JSGCTraceKind traceKind = js_GetGCThingTraceKind(p);
     JSObject *obj;
     js::Class *clazz;
 
     // We do not want to add wrappers to the cycle collector if they're not
     // explicitly marked as main thread only, because the cycle collector isn't
     // able to deal with objects that might be used off of the main thread. We
     // do want to explicitly mark them for cycle collection if the wrapper has
     // an external reference, because the wrapper would mark the JS object if
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/smil/anim-discrete-values-2.svg
@@ -0,0 +1,31 @@
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink"
+     class="reftest-wait"
+     onload="setTimeAndSnapshot(29, true)">
+  <script xlink:href="smil-util.js" type="text/javascript"/>
+  <title>Test discrete keyTimes are scaled correctly (Bug 681645)</title>
+  <rect x="15" y="15" width="200" height="200" fill="blue">
+    <animate attributeName="fill" begin="0" dur="100s"
+             calcMode="discrete"
+             values="red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;blue;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red"
+           keyTimes="0.00;0.01;0.02;0.03;0.04;0.05;0.06;0.07;0.08;0.09;
+                     0.10;0.11;0.12;0.13;0.14;0.15;0.16;0.17;0.18;0.19;
+                     0.20;0.21;0.22;0.23;0.24;0.25;0.26;0.27;0.28;0.29;
+                     0.30;0.31;0.32;0.33;0.34;0.35;0.36;0.37;0.38;0.39;
+                     0.40;0.41;0.42;0.43;0.44;0.45;0.46;0.47;0.48;0.49;
+                     0.50;0.51;0.52;0.53;0.54;0.55;0.56;0.57;0.58;0.59;
+                     0.60;0.61;0.62;0.63;0.64;0.65;0.66;0.67;0.68;0.69;
+                     0.70;0.71;0.72;0.73;0.74;0.75;0.76;0.77;0.78;0.79;
+                     0.80;0.81;0.82;0.83;0.84;0.85;0.86;0.87;0.88;0.89;
+                     0.90;0.91;0.92;0.93;0.94;0.95;0.96;0.97;0.98;0.99"/>
+  </rect>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/svg/smil/anim-discrete-values-3.svg
@@ -0,0 +1,21 @@
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink"
+     class="reftest-wait"
+     onload="setTimeAndSnapshot(29, true)">
+  <script xlink:href="smil-util.js" type="text/javascript"/>
+  <title>Test discrete keyTimes are scaled correctly (Bug 681645)</title>
+  <rect x="15" y="15" width="200" height="200" fill="blue">
+    <animate attributeName="fill" begin="0" dur="100s"
+             calcMode="discrete"
+             values="red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;blue;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red;
+                     red;red;red;red;red;red;red;red;red;red"/>
+  </rect>
+</svg>
--- a/layout/reftests/svg/smil/reftest.list
+++ b/layout/reftests/svg/smil/reftest.list
@@ -50,16 +50,18 @@ include syncbase/reftest.list
 # seek tests
 include seek/reftest.list
 
 # event tests
 include event/reftest.list
 
 # General tests
 == anim-discrete-values-1.svg      anim-standard-ref.svg
+== anim-discrete-values-2.svg      anim-standard-ref.svg
+== anim-discrete-values-3.svg      anim-standard-ref.svg
 == anim-discrete-replace-sum-1.svg anim-standard-ref.svg
 == anim-discrete-sum-none-1.svg    anim-standard-ref.svg
 == anim-discrete-sum-sum-1.svg     anim-standard-ref.svg
 
 == anim-discrete-to-1.svg          anim-standard-ref.svg
 == anim-discrete-to-2.svg          anim-standard-ref.svg
 == anim-discrete-to-3.svg          anim-standard-ref.svg
 == anim-discrete-to-4.svg          anim-standard-ref.svg
--- a/mobile/chrome/content/AppMenu.js
+++ b/mobile/chrome/content/AppMenu.js
@@ -1,9 +1,10 @@
 var AppMenu = {
+  offset: 10,
   get panel() {
     delete this.panel;
     return this.panel = document.getElementById("appmenu");
   },
 
   get popup() {
     delete this.popup;
     return this.popup = document.getElementById("appmenu-popup");
@@ -12,54 +13,61 @@ var AppMenu = {
   shouldShow: function appmenu_shouldShow(aElement) {
     return !aElement.hidden;
   },
 
   overflowMenu : [],
 
   show: function show() {
     let modals = document.getElementsByClassName("modal-block").length;
-    if (BrowserUI.activePanel || BrowserUI.isPanelVisible() || modals > 0 || BrowserUI.activeDialog)
+    if (AwesomeScreen.activePanel || BrowserUI.isPanelVisible() || modals > 0 || BrowserUI.activeDialog)
       return;
 
     // Figure if we should show a menu-list or a pop-up menu
     let menuButton = document.getElementById("tool-menu");
     let listFormat = (getComputedStyle(menuButton).visibility == "visible");
 
     addEventListener("keypress", this, true);
 
     if (listFormat) {
-      let listbox = document.getElementById("appmenu-popup-commands");
+      let listbox = document.getElementById("appmenu-popup-appcommands");
       while (listbox.firstChild)
         listbox.removeChild(listbox.firstChild);
 
+      let siteCommandsBox = document.getElementById("appmenu-popup-sitecommands");
+      while (siteCommandsBox.firstChild)
+        siteCommandsBox.removeChild(siteCommandsBox.firstChild);
+
       let childrenCount = this.panel.childElementCount;
       for (let i = 0; i < childrenCount; i++) {
         let child = this.panel.children[i];
 
         if (!this.shouldShow(child))
           continue;
 
         child.setAttribute("show", true);
 
         let item = document.createElement("richlistitem");
-        item.setAttribute("class", "appmenu-button");
+        item.setAttribute("class", child.className);
         item.onclick = function() { child.click(); }
 
         let label = document.createElement("label");
         label.setAttribute("value", child.label);
         item.appendChild(label);
 
-        listbox.appendChild(item);
+        if (item.classList.contains("appmenu-pageaction"))
+          siteCommandsBox.appendChild(item);
+        else
+          listbox.appendChild(item);
       }
 
       this.popup.top = menuButton.getBoundingClientRect().bottom;
 
       let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry);
-      this.popup.setAttribute(chromeReg.isLocaleRTL("global") ? "left" : "right", 0);
+      this.popup.setAttribute(chromeReg.isLocaleRTL("global") ? "left" : "right", this.offset);
 
       this.popup.hidden = false;
       this.popup.anchorTo(menuButton);
 
       BrowserUI.lockToolbar();
       BrowserUI.pushPopup(this, [this.popup, menuButton]);
     } else {
       let shown = 0;
--- a/mobile/chrome/content/AwesomePanel.js
+++ b/mobile/chrome/content/AwesomePanel.js
@@ -1,8 +1,156 @@
+var AwesomeScreen = {
+  offset: 0.25, // distance the popup will be offset from the left side of the window
+  get headers() {
+    delete this.headers;
+    return this.headers = document.getElementById("awesome-header");
+  },
+
+  get container() {
+    delete this.container;
+    return this.container = document.getElementById("awesome-panels");
+  },
+
+  _activePanel: null,
+  get activePanel() {
+    return this._activePanel;
+  },
+
+  get _targets() {
+    delete this._targets;
+    return this._targets = [
+      this.container,
+#ifdef MOZ_SERVICES_SYNC
+      document.getElementById("syncsetup-container"),
+#endif
+      document.getElementById("urlbar-container"),
+      document.getElementById("search-engines-popup")
+    ]
+  },
+
+  handleEvent: function(aEvent) {
+    switch (aEvent.type) {
+      case "TapDown" :
+        let target = aEvent.target;
+        while (target && this._targets.indexOf(target) == -1)
+          target = target.parentNode;
+        if (!target)
+          this.activePanel = null;
+        break;
+    }
+  },
+
+  set activePanel(aPanel) {
+    if (this._activePanel == aPanel)
+      return;
+
+    let willShowPanel = (!this._activePanel && aPanel);
+    if (willShowPanel) {
+      BrowserUI.pushDialog(this._activePanel);
+      BrowserUI._edit.attachController();
+      BrowserUI._editURI();
+      this.container.hidden = this.headers.hidden = false;
+      window.addEventListener("TapDown", this, false);
+    }
+
+    if (aPanel) {
+      aPanel.open();
+      if (BrowserUI._edit.value == "")
+        BrowserUI._showURI();
+    }
+
+    let willHidePanel = (this._activePanel && !aPanel);
+    if (willHidePanel) {
+      this.container.hidden = true;
+      this.headers.hidden = false;
+      BrowserUI._edit.reset();
+      BrowserUI._edit.detachController();
+      BrowserUI.popDialog();
+      window.removeEventListener("TapDown", this, false);
+    }
+
+    if (this._activePanel)
+      this._activePanel.close();
+
+    // If the keyboard will cover the full screen, we do not want to show it right away.
+    let isReadOnly = (aPanel != AllPagesList || BrowserUI._isKeyboardFullscreen() || (!willShowPanel && BrowserUI._edit.readOnly));
+    BrowserUI._edit.readOnly = isReadOnly;
+    if (isReadOnly)
+      BrowserUI._edit.blur();
+
+    this._activePanel = aPanel;
+    if (willHidePanel || willShowPanel) {
+      let event = document.createEvent("UIEvents");
+      event.initUIEvent("NavigationPanel" + (willHidePanel ? "Hidden" : "Shown"), true, true, window, false);
+      window.dispatchEvent(event);
+    }
+
+    // maemo can change what is shown in the urlbar. we need to resize to ensure
+    // that the awesomescreen and urlbar are the same width
+    this.doResize(ViewableAreaObserver.width, ViewableAreaObserver.height);
+  },
+
+  updateHeader: function updateHeader(aString) {
+    this.headers.hidden = (aString != "");
+
+    // During an awesome search we always show the popup_autocomplete/AllPagesList
+    // panel since this looks in every places and the rationale behind typing
+    // is to find something, whereever it is.
+    if (this.activePanel != AllPagesList) {
+      let inputField = BrowserUI._edit;
+      let oldClickSelectsAll = inputField.clickSelectsAll;
+      inputField.clickSelectsAll = false;
+
+      this.activePanel = AllPagesList;
+
+      // changing the searchString property call updateAwesomeHeader again
+      inputField.controller.searchString = aString;
+      inputField.readOnly = false;
+      inputField.clickSelectsAll = oldClickSelectsAll;
+      return;
+    }
+
+    let event = document.createEvent("Events");
+    event.initEvent("onsearchbegin", true, true);
+    BrowserUI._edit.dispatchEvent(event);
+  },
+
+  doResize: function(aWidth, aHeight) {
+    // awesomebar and related panels
+    let popup = document.getElementById("awesome-panels");
+    popup.top = BrowserUI.toolbarH;
+
+    if (Util.isTablet()) {
+      let urlbar = document.getElementById("urlbar-container");
+      let urlbarRect = urlbar.getBoundingClientRect();
+      let toolbar = document.getElementById("toolbar-main");
+      let toolbarRect = toolbar.getBoundingClientRect();
+
+      let dpi = Util.displayDPI;
+      let minHeight = 500;
+      if (dpi > 96)
+        minHeight = 3*dpi;
+
+      if (Util.localeDir > 0) {
+        popup.left = toolbarRect.left + this.offset*dpi;
+        popup.width = urlbarRect.right - toolbarRect.left - this.offset*dpi;
+      } else {
+        popup.left = urlbarRect.left;
+        popup.width = toolbarRect.right - urlbarRect.left - this.offset*dpi;
+      }
+      popup.height = Math.min(aHeight - BrowserUI.toolbarH, minHeight);
+    } else {
+      popup.width = aWidth;
+      popup.height = aHeight - BrowserUI.toolbarH;
+      popup.left = 0;
+    }
+  }
+}
+
 var AwesomePanel = function(aElementId, aCommandId) {
   let command = document.getElementById(aCommandId);
 
   this.panel = document.getElementById(aElementId),
 
   this.open = function aw_open() {
     command.setAttribute("checked", "true");
     this.panel.hidden = false;
--- a/mobile/chrome/content/Util.js
+++ b/mobile/chrome/content/Util.js
@@ -190,16 +190,24 @@ let Util = {
       return ViewableAreaObserver.isKeyboardOpened;
 
     return (sendSyncMessage("Content:IsKeyboardOpened", {}))[0];
   },
 
   get displayDPI() {
     delete this.displayDPI;
     return this.displayDPI = this.getWindowUtils(window).displayDPI;
+  },
+
+  LOCALE_DIR_RTL: -1,
+  LOCALE_DIR_LTR: 1,
+  get localeDir() {
+    // determine browser dir first to know which direction to snap to
+    let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry);
+    return chromeReg.isLocaleRTL("global") ? this.LOCALE_DIR_RTL : this.LOCALE_DIR_LTR;
   }
 };
 
 
 /**
  * Helper class to nsITimer that adds a little more pizazz.  Callback can be an
  * object with a notify method or a function.
  */
--- a/mobile/chrome/content/bindings.xml
+++ b/mobile/chrome/content/bindings.xml
@@ -158,17 +158,17 @@
             }
           };
 
           ContextHelper.showPopup(data);
         ]]>
       </handler>
     </handlers>
     <content orient="vertical">
-      <xul:hbox class="autocomplete-item-container" align="top" xbl:inherits="favorite,remote,search" mousethrough="always">
+      <xul:hbox class="autocomplete-item-container" xbl:inherits="favorite,remote,search" mousethrough="always">
         <xul:image xbl:inherits="src"/>
         <xul:vbox flex="1">
           <xul:label class="autocomplete-item-label" crop="center" xbl:inherits="value"/>
           <xul:label class="autocomplete-item-subtitle" xbl:inherits="value=subtitle" crop="center"/>
         </xul:vbox>
         <xul:vbox align="end">
           <xul:label class="autocomplete-item-tags" value="" xbl:inherits="value=tags"/>
           <xul:label class="autocomplete-item-badge" value="" xbl:inherits="value=badge"/>
--- a/mobile/chrome/content/bindings/arrowbox.xml
+++ b/mobile/chrome/content/bindings/arrowbox.xml
@@ -154,17 +154,17 @@
               if (!aAnchorNode) {
                 this._updateArrow(null, null, 0, 0);
                 return;
               }
 
               this.anchorNode = aAnchorNode;
 
               let anchorRect = aAnchorNode.getBoundingClientRect();
-              let popupRect = this.getBoundingClientRect();
+              let popupRect = this.firstChild.getBoundingClientRect();
               let offset = this.offset;
 
               let horizPos = (Math.round(popupRect.right) <= Math.round(anchorRect.left + offset)) ? -1 :
                              (Math.round(popupRect.left) >= Math.round(anchorRect.right - offset)) ? 1 : 0;
               let vertPos = (Math.round(popupRect.bottom) <= Math.round(anchorRect.top + offset)) ? -1 :
                             (Math.round(popupRect.top) >= Math.round(anchorRect.bottom - offset)) ? 1 : 0;
 
               this._updateArrow(popupRect, anchorRect, horizPos, vertPos);
--- a/mobile/chrome/content/browser-scripts.js
+++ b/mobile/chrome/content/browser-scripts.js
@@ -88,16 +88,17 @@ XPCOMUtils.defineLazyGetter(this, "Commo
 /**
  * Delay load some browser scripts
  */
 [
   ["AlertsHelper", "chrome://browser/content/AlertsHelper.js"],
   ["AnimatedZoom", "chrome://browser/content/AnimatedZoom.js"],
   ["AppMenu", "chrome://browser/content/AppMenu.js"],
   ["AwesomePanel", "chrome://browser/content/AwesomePanel.js"],
+  ["AwesomeScreen", "chrome://browser/content/AwesomePanel.js"],
   ["BookmarkHelper", "chrome://browser/content/BookmarkHelper.js"],
   ["BookmarkPopup", "chrome://browser/content/BookmarkPopup.js"],
   ["CommandUpdater", "chrome://browser/content/commandUtil.js"],
   ["ContextCommands", "chrome://browser/content/ContextCommands.js"],
   ["ConsoleView", "chrome://browser/content/console.js"],
   ["DownloadsView", "chrome://browser/content/downloads.js"],
   ["ExtensionsView", "chrome://browser/content/extensions.js"],
   ["MenuListHelperUI", "chrome://browser/content/MenuListHelperUI.js"],
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -156,17 +156,17 @@ var BrowserUI = {
     let forward = document.getElementById("cmd_forward");
 
     back.setAttribute("disabled", !aBrowser.canGoBack);
     forward.setAttribute("disabled", !aBrowser.canGoForward);
   },
 
   _updateToolbar: function _updateToolbar() {
     let mode = Elements.urlbarState.getAttribute("mode");
-    if (mode == "edit" && this.activePanel)
+    if (mode == "edit" && AwesomeScreen.activePanel)
       return;
 
     if (Browser.selectedTab.isLoading() && mode != "loading")
       Elements.urlbarState.setAttribute("mode", "loading");
     else if (mode != "view")
       Elements.urlbarState.setAttribute("mode", "view");
   },
 
@@ -197,17 +197,17 @@ var BrowserUI = {
       return;
 
     this._toolbarLocked--;
     if (!this._toolbarLocked)
       document.getElementById("toolbar-moveable-container").top = "";
   },
 
   _setURL: function _setURL(aURL) {
-    if (this.activePanel)
+    if (AwesomeScreen.activePanel)
       this._edit.defaultValue = aURL;
     else
       this._edit.value = aURL;
   },
 
   _editURI: function _editURI(aEdit) {
     Elements.urlbarState.setAttribute("mode", "edit");
     this._edit.defaultValue = this._edit.value;
@@ -223,102 +223,48 @@ var BrowserUI = {
   },
 
   updateAwesomeHeader: function updateAwesomeHeader(aString) {
     document.getElementById("awesome-header").hidden = (aString != "");
 
     // During an awesome search we always show the popup_autocomplete/AllPagesList
     // panel since this looks in every places and the rationale behind typing
     // is to find something, whereever it is.
-    if (this.activePanel != AllPagesList) {
+    if (AwesomeScreen.activePanel != AllPagesList) {
       let inputField = this._edit;
       let oldClickSelectsAll = inputField.clickSelectsAll;
       inputField.clickSelectsAll = false;
 
-      this.activePanel = AllPagesList;
+      AwesomeScreen.activePanel = AllPagesList;
 
       // changing the searchString property call updateAwesomeHeader again
       inputField.controller.searchString = aString;
       inputField.readOnly = false;
       inputField.clickSelectsAll = oldClickSelectsAll;
       return;
     }
 
     let event = document.createEvent("Events");
     event.initEvent("onsearchbegin", true, true);
     this._edit.dispatchEvent(event);
   },
 
   _closeOrQuit: function _closeOrQuit() {
     // Close active dialog, if we have one. If not then close the application.
-    if (this.activePanel) {
-      this.activePanel = null;
+    if (AwesomeScreen.activePanel) {
+      AwesomeScreen.activePanel = null;
     } else if (this.activeDialog) {
       this.activeDialog.close();
     } else {
       // Check to see if we should really close the window
       if (Browser.closing())
         window.close();
     }
   },
 
-  _activePanel: null,
-  get activePanel() {
-    return this._activePanel;
-  },
-
-  set activePanel(aPanel) {
-    if (this._activePanel == aPanel)
-      return;
-
-    let awesomePanel = document.getElementById("awesome-panels");
-    let awesomeHeader = document.getElementById("awesome-header");
-
-    let willHidePanel = (this._activePanel && !aPanel);
-    if (willHidePanel) {
-      awesomePanel.hidden = true;
-      awesomeHeader.hidden = false;
-      this._edit.reset();
-      this._edit.detachController();
-    }
-
-    if (this._activePanel) {
-      this.popDialog();
-      this._activePanel.close();
-    }
-
-    let willShowPanel = (!this._activePanel && aPanel);
-    if (willShowPanel) {
-      this._edit.attachController();
-      this._editURI();
-      awesomePanel.hidden = awesomeHeader.hidden = false;
-    };
-
-    if (aPanel) {
-      this.pushDialog(aPanel);
-      aPanel.open();
-
-      if (this._edit.value == "")
-        this._showURI();
-    }
-
-    // If the keyboard will cover the full screen, we do not want to show it right away.
-    let isReadOnly = (aPanel != AllPagesList || this._isKeyboardFullscreen() || (!willShowPanel && this._edit.readOnly));
-    this._edit.readOnly = isReadOnly;
-    if (isReadOnly)
-      this._edit.blur();
-
-    this._activePanel = aPanel;
-    if (willHidePanel || willShowPanel) {
-      let event = document.createEvent("UIEvents");
-      event.initUIEvent("NavigationPanel" + (willHidePanel ? "Hidden" : "Shown"), true, true, window, false);
-      window.dispatchEvent(event);
-    }
-  },
-
   get activeDialog() {
     // Return the topmost dialog
     if (this._dialogs.length)
       return this._dialogs[this._dialogs.length - 1];
     return null;
   },
 
   pushDialog: function pushDialog(aDialog) {
@@ -436,22 +382,17 @@ var BrowserUI = {
   get sidebarW() {
     delete this._sidebarW;
     return this._sidebarW = Elements.controls.getBoundingClientRect().width;
   },
 
   sizeControls: function(windowW, windowH) {
     // tabs
     document.getElementById("tabs").resize();
-
-    // awesomebar and related panels
-    let popup = document.getElementById("awesome-panels");
-    popup.top = this.toolbarH;
-    popup.height = windowH - this.toolbarH;
-    popup.width = windowW;
+    AwesomeScreen.doResize(windowW, windowH);
 
     // content navigator helper
     document.getElementById("content-navigator").contentHasChanged();
   },
 
   init: function() {
     this._edit = document.getElementById("urlbar-edit");
     this._title = document.getElementById("urlbar-title");
@@ -719,28 +660,28 @@ var BrowserUI = {
   showAutoComplete: function showAutoComplete() {
     if (this.isAutoCompleteOpen())
       return;
 
     this.hidePanel();
     this._hidePopup();
     if (this.activeDialog)
       this.activeDialog.close();
-    this.activePanel = AllPagesList;
+    AwesomeScreen.activePanel = AllPagesList;
   },
 
   closeAutoComplete: function closeAutoComplete() {
     if (this.isAutoCompleteOpen())
       this._edit.popup.closePopup();
 
-    this.activePanel = null;
+    AwesomeScreen.activePanel = null;
   },
 
   isAutoCompleteOpen: function isAutoCompleteOpen() {
-    return this.activePanel == AllPagesList;
+    return AwesomeScreen.activePanel == AllPagesList;
   },
 
   doOpenSearch: function doOpenSearch(aName) {
     // save the current value of the urlbar
     let searchValue = this._edit.value;
 
     // Give the new page lots of room
     Browser.hideSidebars();
@@ -815,17 +756,17 @@ var BrowserUI = {
   },
 
   closeTab: function closeTab(aTab) {
     // If no tab is passed in, assume the current tab
     Browser.closeTab(aTab || Browser.selectedTab);
   },
 
   selectTab: function selectTab(aTab) {
-    this.activePanel = null;
+    AwesomeScreen.activePanel = null;
     Browser.selectedTab = aTab;
   },
 
   undoCloseTab: function undoCloseTab(aIndex) {
     let tab = null;
     let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
     if (ss.getClosedTabCount(window) > (aIndex || 0)) {
       let chromeTab = ss.undoCloseTab(window, aIndex || 0);
@@ -836,18 +777,18 @@ var BrowserUI = {
 
   isTabsVisible: function isTabsVisible() {
     // The _1, _2 and _3 are to make the js2 emacs mode happy
     let [leftvis,_1,_2,_3] = Browser.computeSidebarVisibility();
     return (leftvis > 0.002);
   },
 
   showPanel: function showPanel(aPanelId) {
-    if (this.activePanel)
-      this.activePanel = null; // Hide the awesomescreen.
+    if (AwesomeScreen.activePanel)
+      AwesomeScreen.activePanel = null; // Hide the awesomescreen.
 
     Elements.panelUI.left = 0;
     Elements.panelUI.hidden = false;
     Elements.contentShowing.setAttribute("disabled", "true");
 
     this.switchPane(aPanelId);
   },
 
@@ -887,24 +828,24 @@ var BrowserUI = {
     // Check open popups
     if (this._popup) {
       this._hidePopup();
       return;
     }
 
     // Check open dialogs
     let dialog = this.activeDialog;
-    if (dialog && dialog != this.activePanel) {
+    if (dialog && dialog != AwesomeScreen.activePanel) {
       dialog.close();
       return;
     }
 
     // Check active panel
-    if (this.activePanel) {
-      this.activePanel = null;
+    if (AwesomeScreen.activePanel) {
+      AwesomeScreen.activePanel = null;
       return;
     }
 
     // Check open modal elements
     let modalElementsLength = document.getElementsByClassName("modal-block").length;
     if (modalElementsLength > 0)
       return;
 
@@ -987,17 +928,17 @@ var BrowserUI = {
         break;
       case "AppCommand":
         aEvent.stopPropagation();
         switch (aEvent.command) {
           case "Menu":
             this.doCommand("cmd_menu");
             break;
           case "Search":
-            if (!this.activePanel)
+            if (!AwesomeScreen.activePanel)
               AllPagesList.doCommand();
             else
               this.doCommand("cmd_opensearch");
             break;
           default:
             break;
         }
         break;
@@ -1251,43 +1192,43 @@ var BrowserUI = {
         }, this);
         break;
       }
       case "cmd_opensearch":
         this.blurFocusedElement();
         BrowserSearch.toggle();
         break;
       case "cmd_bookmarks":
-        this.activePanel = BookmarkList;
+        AwesomeScreen.activePanel = BookmarkList;
         break;
       case "cmd_history":
-        this.activePanel = HistoryList;
+        AwesomeScreen.activePanel = HistoryList;
         break;
       case "cmd_remoteTabs":
         if (Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED) {
           // We have to set activePanel before showing sync's dialog
           // to make the sure the dialog stacking is correct.
-          this.activePanel = RemoteTabsList;
+          AwesomeScreen.activePanel = RemoteTabsList;
           WeaveGlue.open();
         } else if (!Weave.Service.isLoggedIn && !Services.prefs.getBoolPref("browser.sync.enabled")) {
           // unchecked the relative command button
           document.getElementById("remotetabs-button").removeAttribute("checked");
 
           BrowserUI.showPanel("prefs-container");
           let prefsBox = document.getElementById("prefs-list");
           let syncArea = document.getElementById("prefs-sync");
           if (prefsBox && syncArea) {
             let prefsBoxY = prefsBox.firstChild.boxObject.screenY;
             let syncAreaY = syncArea.boxObject.screenY;
             setTimeout(function() {
               prefsBox.scrollBoxObject.scrollTo(0, syncAreaY - prefsBoxY);
             }, 0);
           }
         } else {
-          this.activePanel = RemoteTabsList;
+          AwesomeScreen.activePanel = RemoteTabsList;
         }
 
         break;
       case "cmd_quit":
         // Only close one window
         this._closeOrQuit();
         break;
       case "cmd_close":
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -177,16 +177,17 @@ var Browser = {
     // XXX change
 
     /* handles dispatching clicks on browser into clicks in content or zooms */
     Elements.browsers.customDragger = new Browser.MainDragger();
 
     /* handles web progress management for open browsers */
     Elements.browsers.webProgress = new Browser.WebProgress();
 
+    this.keyFilter = new KeyFilter(Elements.browsers);
     let mouseModule = new MouseModule();
     let gestureModule = new GestureModule(Elements.browsers);
     let scrollWheelModule = new ScrollwheelModule(Elements.browsers);
 
     ContentTouchHandler.init();
 
     // Warning, total hack ahead. All of the real-browser related scrolling code
     // lies in a pretend scrollbox here. Let's not land this as-is. Maybe it's time
@@ -1012,21 +1013,17 @@ var Browser = {
    *
    * @return scrollBy dx needed to make snap happen
    */
   snapSidebars: function snapSidebars() {
     let [leftvis, ritevis, leftw, ritew] = Browser.computeSidebarVisibility();
 
     let snappedX = 0;
 
-    // determine browser dir first to know which direction to snap to
-    let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"].
-                      getService(Ci.nsIXULChromeRegistry);
-    let dirVal = chromeReg.isLocaleRTL("global") ? -1 : 1;
-
+    let dirVal = Util.localeDir;
     if (leftvis != 0 && leftvis != 1) {
       if (leftvis >= 0.6666) {
         snappedX = -((1 - leftvis) * leftw) * dirVal;
       } else {
         snappedX = leftvis * leftw * dirVal;
       }
     }
     else if (ritevis != 0 && ritevis != 1) {
@@ -1224,24 +1221,29 @@ var Browser = {
         // a message for this particular tab
         setTimeout(function(self) {
           let tab = self.getTabForBrowser(browser);
           self._doCloseTab(tab);
         }, 0, this);
         break;
       }
 
-      case "Browser:KeyPress":
+      case "Browser:KeyPress": {
+        let keyset = document.getElementById("mainKeyset");
+        keyset.setAttribute("disabled", "false");
+        if (json.preventDefault)
+          break;
+
         let event = document.createEvent("KeyEvents");
         event.initKeyEvent("keypress", true, true, null,
                            json.ctrlKey, json.altKey, json.shiftKey, json.metaKey,
                            json.keyCode, json.charCode);
-        document.getElementById("mainKeyset").dispatchEvent(event);
+        keyset.dispatchEvent(event);
         break;
-
+      }
       case "Browser:ZoomToPoint:Return":
         if (json.zoomTo) {
           let rect = Rect.fromRect(json.zoomTo);
           this.zoomToPoint(json.x, json.y, rect);
         } else {
           this.zoomFromPoint(json.x, json.y);
         }
         break;
@@ -1464,17 +1466,17 @@ Browser.MainDragger.prototype = {
       // Vertical scrollbar is out of view when showing the tabs sidebar,
       // the 'solution' for now is to reposition it if needed
       let x = 0;
       if (Browser.floatedWhileDragging) {
         let [tabsVis, controlsVis, tabsW, controlsW] = Browser.computeSidebarVisibility();
         let [tabsSidebar, controlsSidebar] = [Elements.tabs.getBoundingClientRect(), Elements.controls.getBoundingClientRect()];
 
         // Check if the sidebars are inverted (rtl)
-        let direction = (tabsSidebar.left > controlsSidebar.left) ? 1 : -1;
+        let direction = -1 * Util.localeDir;
         x = Math.round(tabsW * tabsVis) * direction
       }
 
       this._verticalScrollbar.style.MozTransform = "translate(" + x + "px," + y + "px)";
     }
   },
 
   _showScrollbars: function _showScrollbars() {
@@ -1971,16 +1973,41 @@ const ContentTouchHandler = {
     this._dispatchMouseEvent("Browser:MouseLong", aX, aY);
   },
 
   toString: function toString() {
     return "[ContentTouchHandler] { }";
   }
 };
 
+
+/** Prevent chrome from consuming key events before remote content has a chance. */
+function KeyFilter(container) {
+  container.addEventListener("keypress", this, false);
+  container.addEventListener("keyup", this, false);
+  container.addEventListener("keydown", this, false);
+}
+
+KeyFilter.prototype = {
+  handleEvent: function handleEvent(aEvent) {
+    if (Elements.contentShowing.getAttribute("disabled") == "true")
+      return;
+
+    let browser = getBrowser();
+    if (browser && browser.active && browser.getAttribute("remote") == "true") {
+        document.getElementById("mainKeyset").setAttribute("disabled", "true");
+    }
+  },
+
+  toString: function toString() {
+    return "[KeyFilter] { }";
+  }
+};
+
+
 /**
  * Utility class to handle manipulations of the identity indicators in the UI
  */
 function IdentityHandler() {
   this._staticStrings = {};
   this._staticStrings[this.IDENTITY_MODE_DOMAIN_VERIFIED] = {
     encryption_label: Strings.browser.GetStringFromName("identity.encrypted2")
   };
@@ -2179,17 +2206,17 @@ IdentityHandler.prototype = {
 
     PageActions.updateSiteMenu();
   },
 
   show: function ih_show() {
     Elements.contentShowing.setAttribute("disabled", "true");
 
     // dismiss any dialog which hide the identity popup
-    BrowserUI.activePanel = null;
+    AwesomeScreen.activePanel = null;
     while (BrowserUI.activeDialog)
       BrowserUI.activeDialog.close();
 
     // Update the popup strings
     this.setPopupMessages(this._identityBox.getAttribute("mode") || this.IDENTITY_MODE_UNKNOWN);
 
     this._identityPopup.hidden = false;
     this._identityPopup.top = BrowserUI.toolbarH - this._identityPopup.offset;
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -243,17 +243,17 @@
                     <textbox id="urlbar-edit"
                              type="url"
                              mozactionhint="go"
                              class="uri-element"
                              autocompletesearch="history"
                              autocompletepopup="popup_autocomplete"
                              completeselectedindex="true"
                              minresultsforpopup="0"
-                             onsearchbegin="BrowserUI.updateAwesomeHeader(this.controller.searchString);"
+                             onsearchbegin="AwesomeScreen.updateHeader(this.controller.searchString);"
                              placeholder="&urlbar.emptytext;"
                              collapsed="true"
                              flex="1"
                              readonly="true"
                              ontextentered="BrowserUI.goToURI();"
                              clickSelectsAll="true"/>
                     <hbox id="urlbar-icons" class="urlbar-cap-button" observes="bcast_urlbarState">
                       <toolbarbutton id="tool-reload" oncommand="CommandUpdater.doCommand(event.shiftKey ? 'cmd_forceReload' : 'cmd_reload');"/>
@@ -387,17 +387,18 @@
         <scrollbox id="bookmark-form" align="start" class="prompt-message" flex="1"/>
         <hbox id="bookmark-form-buttons" pack="center" class="prompt-buttons">
           <button label="&editBookmarkDone.label;" class="prompt-button" oncommand="BookmarkHelper.save();"/>
         </hbox>
       </dialog>
     </box>
 
     <arrowbox id="appmenu-popup" hidden="true">
-      <richlistbox id="appmenu-popup-commands"/>
+      <box id="appmenu-popup-sitecommands"/>
+      <richlistbox id="appmenu-popup-appcommands"/>
     </arrowbox>
 
     <box id="panel-container" hidden="true" class="window-width window-height panel-dark"
          style="-moz-stack-sizing: ignore" left="10000">
       <box id="panel-container-inner" flex="1" class="panel-dark">
         <box id="panel-controls" class="panel-row-header" oncommand="BrowserUI.switchPane(event.target.getAttribute('linkedpanel'));">
           <toolbarbutton id="tool-preferences" label="&prefsHeader.label;" class="panel-row-button" type="radio" group="1" checked="true" linkedpanel="prefs-container"/>
           <toolbarbutton id="tool-downloads" label="&downloadsHeader.label;" class="panel-row-button" type="radio" group="1" linkedpanel="downloads-container"/>
@@ -534,21 +535,21 @@
         <toolbarbutton id="bookmarks-button" type="radio" group="awesome-header" label="&bookmarksHeader.label;" command="cmd_bookmarks" class="choice-bookmarks panel-row-button show-text"/>
         <toolbarbutton id="history-button" type="radio" group="awesome-header" label="&historyHeader.label;" command="cmd_history" class="choice-history panel-row-button show-text"/>
 #ifdef MOZ_SERVICES_SYNC
         <toolbarbutton id="remotetabs-button" type="radio" group="awesome-header" label="&desktopHeader.label;" command="cmd_remoteTabs" class="choice-remotetabs panel-row-button show-text"/>
 #endif
       </hbox>
 
       <!-- titlebar autocomplete results -->
-      <vbox id="popup_autocomplete" class="panel-dark" flex="1" onshow="BrowserUI._edit.showHistoryPopup();" hidden="true"/>
-      <placelist id="bookmarks-items" type="bookmarks" onopen="BookmarkList.openLink(event);" onhide="BrowserUI.updateStar();" flex="1" hidden="true"/>
-      <historylist id="history-items" onopen="HistoryList.openLink(event);" flex="1" hidden="true"/>
+      <vbox id="popup_autocomplete" class="panel-dark place-list" flex="1" onshow="BrowserUI._edit.showHistoryPopup();" hidden="true"/>
+      <placelist id="bookmarks-items" class="place-list" type="bookmarks" onopen="BookmarkList.openLink(event);" onhide="BrowserUI.updateStar();" flex="1" hidden="true"/>
+      <historylist id="history-items" class="place-list" onopen="HistoryList.openLink(event);" flex="1" hidden="true"/>
 #ifdef MOZ_SERVICES_SYNC
-      <remotetabslist id="remotetabs-items" onopen="RemoteTabsList.openLink(event)" flex="1" hidden="true"/>
+      <remotetabslist id="remotetabs-items" class="place-list" onopen="RemoteTabsList.openLink(event)" flex="1" hidden="true"/>
 #endif
     </vbox>
 
 #ifdef MOZ_SERVICES_SYNC
     <box id="syncsetup-container" class="perm-modal-block" hidden="true">
       <dialog id="syncsetup-dialog" class="content-dialog" flex="1">
         <hbox class="prompt-title">
           <description>&sync.setup.title;</description>
@@ -709,36 +710,36 @@
       </vbox>
     </hbox>
 
     <hbox id="appmenu-overflow" bottom="0" hidden="true" oncommand="AppMenu.hideOverflow();">
       <richlistbox id="appmenu-overflow-commands" flex="1"/>
     </hbox>
 
     <hbox id="appmenu" bottom="0" hidden="true" align="stretch" oncommand="AppMenu.hide();">
-      <toolbarbutton class="appmenu-site-button appmenu-button"
+      <toolbarbutton class="appmenu-site-button appmenu-button appmenu-pageaction"
         label="&appMenu.siteOptions;"
         oncommand="getIdentityHandler().show(); event.stopPropagation();"/>
       <toolbarbutton class="appmenu-preferences-button appmenu-button"
         label="&prefsHeader.label;"
         oncommand="BrowserUI.showPanel('prefs-container');"/>
       <toolbarbutton class="appmenu-addons-button appmenu-button"
         label="&addonsHeader.label;"
         oncommand="BrowserUI.showPanel('addons-container');"/>
-      <toolbarbutton class="appmenu-share-button appmenu-button"
+      <toolbarbutton class="appmenu-share-button appmenu-button appmenu-pageaction"
         label="&pageactions.share.page;"
         oncommand="SharingUI.show(getBrowser().currentURI.spec, getBrowser().contentTitle);"/>
-      <toolbarbutton class="appmenu-findinpage-button appmenu-button"
+      <toolbarbutton class="appmenu-findinpage-button appmenu-button appmenu-pageaction"
         label="&pageactions.findInPage;"
         oncommand="FindHelperUI.show();"/>
       <toolbarbutton class="appmenu-downloads-button appmenu-button"
         label="&downloadsHeader.label;"
         oncommand="BrowserUI.showPanel('downloads-container');"/>
 #ifdef NS_PRINTING
-      <toolbarbutton class="appmenu-saveas-button appmenu-button"
+      <toolbarbutton class="appmenu-saveas-button appmenu-button appmenu-pageaction"
         label="&pageactions.saveas.pdf;"
         oncommand="PageActions.savePageAsPDF();"/>
 #endif
       <toolbarbutton class="appmenu-quit-button appmenu-button"
         label="&pageactions.quit;"
         oncommand="Browser.quit();"/>
     </hbox>
   </stack>
--- a/mobile/chrome/content/common-ui.js
+++ b/mobile/chrome/content/common-ui.js
@@ -69,29 +69,46 @@ var BrowserSearch = {
   },
 
   show: function bs_show() {
     let popup = this._popup;
     let list = this._list;
     while (list.lastChild)
       list.removeChild(list.lastChild);
 
-    this.engines.forEach(function(aEngine) {
+    this.engines.forEach(function(aEngine, aIndex, aArray) {
       let button = document.createElement("button");
       button.className = "action-button";
       button.setAttribute("label", aEngine.name);
       button.setAttribute("crop", "end");
       button.setAttribute("pack", "start");
       button.setAttribute("image", aEngine.iconURI ? aEngine.iconURI.spec : "");
       list.appendChild(button);
     });
 
     popup.hidden = false;
     popup.top = BrowserUI.toolbarH - popup.offset;
-    popup.anchorTo(document.getElementById("tool-search"));
+    let searchButton = document.getElementById("tool-search");
+    if (Util.isTablet()) {
+      let width = list.getBoundingClientRect().width;
+      let searchButtonRect = searchButton.getBoundingClientRect();
+      let left = searchButtonRect.left;
+      if (Util.localeDir > 0) {
+        if (left + width > window.innerWidth)
+          left = window.innerWidth - width;
+      } else {
+        left = searchButtonRect.right - width;
+        if (left < 0)
+          left = 0;
+      }
+      popup.left = left;
+    } else if (popup.hasAttribute("left")) {
+      popup.removeAttribute("left");
+    }
+    popup.anchorTo(searchButton);
 
     document.getElementById("urlbar-icons").setAttribute("open", "true");
     BrowserUI.pushPopup(this, [popup, this._button]);
   },
 
   hide: function bs_hide() {
     this._popup.hidden = true;
     document.getElementById("urlbar-icons").removeAttribute("open");
@@ -805,16 +822,17 @@ var FormHelperUI = {
         }
 
         // If the focus is not on the browser element, the key will not be sent
         // to the content so do it ourself
         let focusedElement = gFocusManager.getFocusedElementForWindow(window, true, {});
         if (focusedElement && focusedElement.localName == "browser")
           return;
 
+        Browser.keyFilter.handleEvent(aEvent);
         break;
 
       case "SizeChanged":
         setTimeout(function(self) {
           SelectHelperUI.sizeToContent();
           self._zoom(self._currentElementRect, self._currentCaretRect);
         }, 0, this);
         break;
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -294,26 +294,24 @@ let Content = {
   },
 
   handleEvent: function handleEvent(aEvent) {
     switch (aEvent.type) {
       // If the keypress is a trusted event and has not been consume by content
       // let's send it back to the chrome process to have it handle shortcuts
       case "keypress":
         let timer = new Util.Timeout(function() {
-          if(aEvent.getPreventDefault())
-            return;
-
           let eventData = {
             ctrlKey: aEvent.ctrlKey,
             altKey: aEvent.altKey,
             shiftKey: aEvent.shiftKey,
             metaKey: aEvent.metaKey,
             keyCode: aEvent.keyCode,
-            charCode: aEvent.charCode
+            charCode: aEvent.charCode,
+            preventDefault: aEvent.getPreventDefault()
           };
           sendAsyncMessage("Browser:KeyPress", eventData);
         });
         timer.once(0);
         break;
 
       case "DOMActivate": {
         // In a local tab, open remote links in new tabs.
--- a/mobile/chrome/jar.mn
+++ b/mobile/chrome/jar.mn
@@ -15,17 +15,17 @@ chrome.jar:
   content/languages.properties         (content/languages.properties)
 * content/browser.xul                  (content/browser.xul)
 * content/browser.js                   (content/browser.js)
 * content/browser-ui.js                (content/browser-ui.js)
 * content/browser-scripts.js           (content/browser-scripts.js)
 * content/common-ui.js                 (content/common-ui.js)
 * content/AlertsHelper.js              (content/AlertsHelper.js)
   content/AppMenu.js                   (content/AppMenu.js)
-  content/AwesomePanel.js              (content/AwesomePanel.js)
+* content/AwesomePanel.js              (content/AwesomePanel.js)
   content/BookmarkHelper.js            (content/BookmarkHelper.js)
   content/BookmarkPopup.js             (content/BookmarkPopup.js)
   content/ContentPopupHelper.js        (content/ContentPopupHe