Merge mozilla-central into services-central.
authorRichard Newman <rnewman@mozilla.com>
Wed, 06 Apr 2011 17:32:40 -0700
changeset 67769 d08e1abcb4e564f8287f1786b6a5bb9c700c7df5
parent 67768 f5be32f40901a67806c9dcc23627a7735e56631c (current diff)
parent 67592 d256fbc66a37ca36f0d6d07c72a4e8e287b2fe16 (diff)
child 67770 d4505c71053eba68f3d827ead50ae7ed782ef527
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.2a1pre
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 mozilla-central into services-central.
intl/uconv/native/Makefile.in
intl/uconv/native/nsINativeUConvService.idl
intl/uconv/native/nsNativeUConvService.cpp
intl/uconv/native/nsNativeUConvService.h
intl/uconv/native/nsWinCEUConvService.cpp
intl/uconv/public/nsICharsetAlias.h
intl/uconv/public/nsIPlatformCharset.h
intl/uconv/src/charsetalias.properties
intl/uconv/src/maccharset.properties
intl/uconv/src/nsCharsetAlias.h
intl/uconv/src/nsCharsetAliasImp.cpp
intl/uconv/src/nsMacCharset.cpp
intl/uconv/src/nsOS2Charset.cpp
intl/uconv/src/nsPlatformCharset.h
intl/uconv/src/nsUConvPropertySearch.cpp
intl/uconv/src/nsUConvPropertySearch.h
intl/uconv/src/nsUNIXCharset.cpp
intl/uconv/src/nsWinCharset.cpp
intl/uconv/src/os2charset.properties
intl/uconv/src/props2arrays.py
intl/uconv/src/unixcharset.properties
intl/uconv/src/wincharset.properties
layout/style/nsCSSRule.h
layout/style/nsICSSGroupRule.h
xpcom/ds/nsInt64.h
--- a/.hgtags
+++ b/.hgtags
@@ -52,8 +52,12 @@ 138f593553b66c9f815e8f57870c19d6347f7702
 0327e126ea245112c0aa7283fee154e084866fb5 bsmedberg-static-xpcom-registration-base
 0327e126ea245112c0aa7283fee154e084866fb5 bsmedberg-static-xpcom-registration-base
 2f83edbbeef0de7dd901411d270da61106c8afae bsmedberg-static-xpcom-registration-base
 138f593553b66c9f815e8f57870c19d6347f7702 UPDATE_PACKAGING_R12
 138f593553b66c9f815e8f57870c19d6347f7702 UPDATE_PACKAGING_R13
 138f593553b66c9f815e8f57870c19d6347f7702 UPDATE_PACKAGING_R11_1_MU
 e56ecd8b3a68c158025207c5fd081d043e28f5ce GECKO_2_0_BASE
 e273946b74c8d631ed86bd74ba9afe0e67b12378 GECKO_2_1_BASE
+b70744835d94e54eec97b8fd186c96da5708a506 PRE_MOBILE_MERGE
+b70744835d94e54eec97b8fd186c96da5708a506 PRE_MOBILE_MERGE_20110406
+a71bd564ebf5bf4f93d13e84114f759c263130b0 MOBILE_MERGE_DONE
+a71bd564ebf5bf4f93d13e84114f759c263130b0 MOBILE_MERGE_DONE_20110406
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -943,20 +943,18 @@ pref("toolbar.customization.usesheet", f
 // (Turning it on in a no-IPC build will have no effect.)
 #ifdef XP_MACOSX
 // i386 ipc preferences
 pref("dom.ipc.plugins.enabled.i386", false);
 pref("dom.ipc.plugins.enabled.i386.flash player.plugin", true);
 pref("dom.ipc.plugins.enabled.i386.javaplugin2_npapi.plugin", true);
 // x86_64 ipc preferences
 pref("dom.ipc.plugins.enabled.x86_64", true);
-#elifdef MOZ_IPC
+#else
 pref("dom.ipc.plugins.enabled", true);
-#else
-pref("dom.ipc.plugins.enabled", false);
 #endif
 
 #ifdef XP_WIN
 #ifndef WINCE
 pref("browser.taskbar.previews.enable", false);
 pref("browser.taskbar.previews.max", 20);
 pref("browser.taskbar.previews.cachetime", 5);
 pref("browser.taskbar.lists.enabled", true);
--- a/browser/base/content/tabview/groupitems.js
+++ b/browser/base/content/tabview/groupitems.js
@@ -244,19 +244,16 @@ function GroupItem(listOfEls, options) {
 
   // ___ Undo Close
   this.$undoContainer = null;
   this._undoButtonTimeoutId = null;
 
   // ___ Superclass initialization
   this._init($container[0]);
 
-  if (this.$debug)
-    this.$debug.css({zIndex: -1000});
-
   // ___ Children
   Array.prototype.forEach.call(listOfEls, function(el) {
     self.add(el, options);
   });
 
   // ___ Finish Up
   this._addHandlers($container);
 
@@ -595,33 +592,29 @@ GroupItem.prototype = Utils.extend(new I
     }
 
     if (css.width) {      
       this.adjustTitleSize();
     }
 
     UI.clearShouldResizeItems();
 
-    this._updateDebugBounds();
     this.setTrenches(rect);
 
     this.save();
   },
 
   // ----------
   // Function: setZ
   // Set the Z order for the groupItem's container, as well as its children.
   setZ: function GroupItem_setZ(value) {
     this.zIndex = value;
 
     iQ(this.container).css({zIndex: value});
 
-    if (this.$debug)
-      this.$debug.css({zIndex: value + 1});
-
     var count = this._children.length;
     if (count) {
       var topZIndex = value + count + 1;
       var zIndex = topZIndex;
       var self = this;
       this._children.forEach(function(child) {
         if (child == self.topChild)
           child.setZ(topZIndex + 1);
@@ -710,27 +703,20 @@ GroupItem.prototype = Utils.extend(new I
   // Make the closest tab external to this group active.
   // Used when closing the group.
   _makeClosestTabActive: function GroupItem__makeClosestTabActive() {
     let closeCenter = this.getBounds().center();
     // Find closest tab to make active
     let closestTabItem = UI.getClosestTab(closeCenter);
     UI.setActiveTab(closestTabItem);
 
-    // set the active group or orphan tabitem.
-    if (closestTabItem) {
-      if (closestTabItem.parent) {
-        GroupItems.setActiveGroupItem(closestTabItem.parent);
-      } else {
-        GroupItems.setActiveOrphanTab(closestTabItem);
-      }
-    } else {
+    if (closestTabItem && closestTabItem.parent)
+      GroupItems.setActiveGroupItem(closestTabItem.parent);
+    else
       GroupItems.setActiveGroupItem(null);
-      GroupItems.setActiveOrphanTab(null);
-    }
   },
 
   // ----------
   // Function: closeIfEmpty
   // Closes the group if it's empty, has no title, is closable, and
   // autoclose is enabled (see pauseAutoclose()). Returns true if the close
   // occurred and false otherwise.
   closeIfEmpty: function() {
@@ -911,18 +897,18 @@ GroupItem.prototype = Utils.extend(new I
         complete: function() {
           self._sendToSubscribers("groupHidden", { groupItemId: self.id });
         }
       });
     }, 50);
 
     // add click handlers
     this.$undoContainer.click(function(e) {
-      // Only do this for clicks on this actual element.
-      if (e.target.nodeName != self.$undoContainer[0].nodeName)
+      // don't do anything if the close button is clicked.
+      if (e.target == undoClose[0])
         return;
 
       self.$undoContainer.fadeOut(function() { self._unhide(); });
     });
 
     undoClose.click(function() {
       self.$undoContainer.fadeOut(function() { self.closeHidden(); });
     });
@@ -2258,17 +2244,17 @@ let GroupItems = {
     // 6. At this point there should be no groups or tabs (except for app tabs and the
     // tab in question): make a new group
 
     if (activeGroupItem) {
       activeGroupItem.add(tabItem, options);
       return;
     }
 
-    let orphanTabItem = this.getActiveOrphanTab();
+    let orphanTabItem = UI.getActiveOrphanTab();
     if (!orphanTabItem) {
       let targetGroupItem;
       // find first visible non-app tab in the tabbar.
       gBrowser.visibleTabs.some(function(tab) {
         if (!tab.pinned && tab != tabItem.tab) {
           if (tab._tabViewTabItem) {
             if (!tab._tabViewTabItem.parent) {
               // the first visible tab is an orphan tab, set the orphan tab, and 
@@ -2349,75 +2335,54 @@ let GroupItems = {
   //          (which means we have an orphaned tab selected)
   setActiveGroupItem: function GroupItems_setActiveGroupItem(groupItem) {
     if (this._activeGroupItem)
       iQ(this._activeGroupItem.container).removeClass('activeGroupItem');
 
     if (groupItem !== null) {
       if (groupItem)
         iQ(groupItem.container).addClass('activeGroupItem');
-      // if a groupItem is active, we surely are not in an orphaned tab.
-      this.setActiveOrphanTab(null);
     }
 
     this._activeGroupItem = groupItem;
     this._save();
   },
 
   // ----------
-  // Function: getActiveOrphanTab
-  // Returns the active orphan tab, in cases when there is no active groupItem.
-  getActiveOrphanTab: function GroupItems_getActiveOrphanTab() {
-    return this._activeOrphanTab;
-  },
-
-  // ----------
-  // Function: setActiveOrphanTab
-  // In cases where an orphan tab (not in a groupItem) is active by itself,
-  // this function is called and the "active orphan tab" is set.
-  //
-  // Paramaters:
-  //  groupItem - the active <TabItem> or <null>
-  setActiveOrphanTab: function GroupItems_setActiveOrphanTab(tabItem) {
-    if (tabItem !== null)
-      this.setActiveGroupItem(null);
-    this._activeOrphanTab = tabItem;
-  },
-
-  // ----------
   // Function: _updateTabBar
   // Hides and shows tabs in the tab bar based on the active groupItem or
   // currently active orphan tabItem
   _updateTabBar: function GroupItems__updateTabBar() {
     if (!window.UI)
       return; // called too soon
-      
-    if (!this._activeGroupItem && !this._activeOrphanTab) {
-      Utils.assert(false, "There must be something to show in the tab bar!");
-      return;
+
+    let activeOrphanTab;
+    if (!this._activeGroupItem) {
+      activeOrphanTab = UI.getActiveOrphanTab();
+      if (!activeOrphanTab) {
+        Utils.assert(false, "There must be something to show in the tab bar!");
+        return;
+      }
     }
 
     let tabItems = this._activeGroupItem == null ?
-      [this._activeOrphanTab] : this._activeGroupItem._children;
+      [activeOrphanTab] : this._activeGroupItem._children;
     gBrowser.showOnlyTheseTabs(tabItems.map(function(item) item.tab));
   },
 
   // ----------
   // Function: updateActiveGroupItemAndTabBar
   // Sets active TabItem and GroupItem, and updates tab bar appropriately.
   updateActiveGroupItemAndTabBar: function GroupItems_updateActiveGroupItemAndTabBar(tabItem) {
     Utils.assertThrow(tabItem && tabItem.isATabItem, "tabItem must be a TabItem");
 
     let groupItem = tabItem.parent;
-
-    if (groupItem) {
-      this.setActiveGroupItem(groupItem);
+    this.setActiveGroupItem(groupItem);
+    if (groupItem)
       groupItem.setActiveTab(tabItem);
-    } else
-      this.setActiveOrphanTab(tabItem);
 
     this._updateTabBar();
   },
 
   // ----------
   // Function: getOrphanedTabs
   // Returns an array of all tabs that aren't in a groupItem.
   getOrphanedTabs: function GroupItems_getOrphanedTabs() {
@@ -2431,17 +2396,17 @@ let GroupItems = {
   // ----------
   // Function: getNextGroupItemTab
   // Paramaters:
   //  reverse - the boolean indicates the direction to look for the next groupItem.
   // Returns the <tabItem>. If nothing is found, return null.
   getNextGroupItemTab: function GroupItems_getNextGroupItemTab(reverse) {
     var groupItems = Utils.copy(GroupItems.groupItems);
     var activeGroupItem = GroupItems.getActiveGroupItem();
-    var activeOrphanTab = GroupItems.getActiveOrphanTab();
+    var activeOrphanTab = UI.getActiveOrphanTab();
     var tabItem = null;
 
     if (reverse)
       groupItems = groupItems.reverse();
 
     if (!activeGroupItem) {
       if (groupItems.length > 0) {
         groupItems.some(function(groupItem) {
--- a/browser/base/content/tabview/items.js
+++ b/browser/base/content/tabview/items.js
@@ -67,25 +67,16 @@ function Item() {
   // The position and size of this Item, represented as a <Rect>.
   // This should never be modified without using setBounds()
   this.bounds = null;
 
   // Variable: zIndex
   // The z-index for this item.
   this.zIndex = 0;
 
-  // Variable: debug
-  // When set to true, displays a rectangle on the screen that corresponds with bounds.
-  // May be used for additional debugging features in the future.
-  this.debug = false;
-
-  // Variable: $debug
-  // If <debug> is true, this will be the iQ object for the visible rectangle.
-  this.$debug = null;
-
   // Variable: container
   // The outermost DOM element that describes this item on screen.
   this.container = null;
 
   // Variable: parent
   // The groupItem that this item is a child of
   this.parent = null;
 
@@ -149,26 +140,16 @@ Item.prototype = {
     Utils.assert(typeof this.close == 'function', 'Subclass must provide close');
     Utils.assert(typeof this.save == 'function', 'Subclass must provide save');
     Utils.assert(Utils.isPoint(this.defaultSize), 'Subclass must provide defaultSize');
     Utils.assert(Utils.isRect(this.bounds), 'Subclass must provide bounds');
 
     this.container = container;
     this.$container = iQ(container);
 
-    if (this.debug) {
-      this.$debug = iQ('<div>')
-        .css({
-          border: '2px solid green',
-          zIndex: -10,
-          position: 'absolute'
-        })
-        .appendTo('body');
-    }
-
     iQ(this.container).data('item', this);
 
     // ___ drag
     this.dragOptions = {
       cancelClass: 'close stackExpander',
       start: function(e, ui) {
         if (this.isAGroupItem) {
           GroupItems.setActiveGroupItem(this);
@@ -506,26 +487,16 @@ Item.prototype = {
       var bounds = data.bounds;
       if (!bounds.equals(data.startBounds)) {
         item.setBounds(bounds, immediately);
       }
     });
   },
 
   // ----------
-  // Function: _updateDebugBounds
-  // Called by a subclass when its bounds change, to update the debugging rectangles on screen.
-  // This functionality is enabled only by the debug property.
-  _updateDebugBounds: function Item__updateDebugBounds() {
-    if (this.$debug) {
-      this.$debug.css(this.bounds);
-    }
-  },
-
-  // ----------
   // Function: setTrenches
   // Sets up/moves the trenches for snapping to this item.
   setTrenches: function Item_setTrenches(rect) {
     if (this.parent !== null)
       return;
 
     if (!this.borderTrenches)
       this.borderTrenches = Trenches.registerWithItem(this,"border");
--- a/browser/base/content/tabview/tabitems.js
+++ b/browser/base/content/tabview/tabitems.js
@@ -197,17 +197,16 @@ function TabItem(tab, options) {
     } else {
       if (!Items.item(this).isDragging)
         self.zoomIn();
     }
   });
 
   this.setResizable(true, options.immediately);
   this.droppable(true);
-  this._updateDebugBounds();
 
   TabItems.register(this);
 
   // ___ reconnect to data from Storage
   if (!TabItems.reconnectingPaused())
     this._reconnect();
 };
 
@@ -519,17 +518,16 @@ TabItem.prototype = Utils.extend(new Ite
        "border-color": "rgba(0,0,0,"+ alphaRange.scale(proportion) +")",
       });
     }
 
     this._hasBeenDrawn = true;
 
     UI.clearShouldResizeItems();
 
-    this._updateDebugBounds();
     rect = this.getBounds(); // ensure that it's a <Rect>
 
     if (!Utils.isRect(this.bounds))
       Utils.trace('TabItem.setBounds: this.bounds is not a real rectangle!', this.bounds);
 
     if (!this.parent && this.tab.parentNode != null)
       this.setTrenches(rect);
 
@@ -640,21 +638,17 @@ TabItem.prototype = Utils.extend(new Ite
     if (this.parent && this.parent.hidden)
       return;
 
     let self = this;
     let $tabEl = this.$container;
     let $canvas = this.$canvas;
 
     UI.setActiveTab(this);
-    if (this.parent) {
-      GroupItems.setActiveGroupItem(this.parent);
-    } else {
-      GroupItems.setActiveOrphanTab(this);
-    }
+    GroupItems.setActiveGroupItem(this.parent);
 
     TabItems._update(this.tab, {force: true});
 
     // Zoom in!
     let tab = this.tab;
 
     function onZoomDone() {
       $canvas.css({ '-moz-transform': null });
@@ -710,18 +704,16 @@ TabItem.prototype = Utils.extend(new Ite
   zoomOut: function TabItem_zoomOut(complete) {
     let $tab = this.$container, $canvas = this.$canvas;
     var self = this;
     
     let onZoomDone = function onZoomDone() {
       $tab.removeClass("front");
       $canvas.css("-moz-transform", null);
 
-      GroupItems.setActiveOrphanTab(null);
-
       if (typeof complete == "function")
         complete();
     };
 
     UI.setActiveTab(this);
     TabItems._update(this.tab, {force: true});
 
     $tab.addClass("front");
@@ -1090,18 +1082,18 @@ let TabItems = {
   // Function: unlink
   // Takes in a xul:tab and destroys the TabItem associated with it. 
   unlink: function TabItems_unlink(tab) {
     try {
       Utils.assertThrow(tab, "tab");
       Utils.assertThrow(tab._tabViewTabItem, "should already be linked");
       // note that it's ok to unlink an app tab; see .handleTabUnpin
 
-      if (tab._tabViewTabItem == GroupItems.getActiveOrphanTab())
-        GroupItems.setActiveOrphanTab(null);
+      if (tab._tabViewTabItem == UI.getActiveOrphanTab())
+        UI.setActiveTab(null);
 
       this.unregister(tab._tabViewTabItem);
       tab._tabViewTabItem._sendToSubscribers("close");
       tab._tabViewTabItem.$container.remove();
       tab._tabViewTabItem.removeTrenches();
       Items.unsquish(null, tab._tabViewTabItem);
 
       tab._tabViewTabItem = null;
--- a/browser/base/content/tabview/ui.js
+++ b/browser/base/content/tabview/ui.js
@@ -201,17 +201,17 @@ let UI = {
               gBrowser.loadOneTab("about:blank", { inBackground: true });
 
             let box = 
               new Rect(e.clientX - Math.floor(TabItems.tabWidth/2),
                        e.clientY - Math.floor(TabItems.tabHeight/2),
                        TabItems.tabWidth, TabItems.tabHeight);
             newTab._tabViewTabItem.setBounds(box, true);
             newTab._tabViewTabItem.pushAway(true);
-            GroupItems.setActiveOrphanTab(newTab._tabViewTabItem);
+            UI.setActiveTab(newTab._tabViewTabItem);
 
             TabItems.creatingNewOrphanTab = false;
             newTab._tabViewTabItem.zoomIn(true);
 
             self._lastClick = 0;
             self._lastClickPositions = null;
             gTabView.firstUseExperienced = true;
           } else {
@@ -351,19 +351,19 @@ let UI = {
     items.forEach(function(item) {
       if (item.parent)
         item.parent.remove(item);
       groupItem.add(item, {immediately: true});
     });
     GroupItems.setActiveGroupItem(groupItem);
   },
 
+  // ----------
   // Function: blurAll
   // Blurs any currently focused element
-  //
   blurAll: function UI_blurAll() {
     iQ(":focus").each(function(element) {
       element.blur();
     });
   },
 
   // ----------
   // Function: isIdle
@@ -375,17 +375,16 @@ let UI = {
     let time = Date.now();
     let maxEvent = Math.max(drag.lastMoveTime, resize.lastMoveTime);
     return (time - maxEvent) > this._maxInteractiveWait;
   },
 
   // ----------
   // Function: getActiveTab
   // Returns the currently active tab as a <TabItem>
-  //
   getActiveTab: function UI_getActiveTab() {
     return this._activeTab;
   },
 
   // ----------
   // Function: setActiveTab
   // Sets the currently active tab. The idea of a focused tab is useful
   // for keyboard navigation and returning to the last zoomed-in tab.
@@ -411,16 +410,23 @@ let UI = {
           self.setActiveTab(null);
       });
 
       this._activeTab.makeActive();
     }
   },
 
   // ----------
+  // Function: getActiveOrphanTab
+  // Returns the currently active orphan tab as a <TabItem>
+  getActiveOrphanTab: function UI_getActiveOrphanTab() {
+    return (this._activeTab && !this._activeTab.parent) ? this._activeTab : null;
+  },
+
+  // ----------
   // Function: isTabViewVisible
   // Returns true if the TabView UI is currently shown.
   isTabViewVisible: function UI_isTabViewVisible() {
     return gTabViewDeck.selectedIndex == 1;
   },
 
   // ---------
   // Function: _initPageDirection
@@ -471,17 +477,17 @@ let UI = {
 
     Storage.saveVisibilityData(gWindow, "true");
 
     // Close the active group if it was empty. This will happen when the
     // user returns to Panorama after looking at an app tab, having
     // closed all other tabs. (If the user is looking at an orphan tab, then
     // there is no active group for the purposes of this check.)
     let activeGroupItem = null;
-    if (!GroupItems.getActiveOrphanTab()) {
+    if (!UI.getActiveOrphanTab()) {
       activeGroupItem = GroupItems.getActiveGroupItem();
       if (activeGroupItem && activeGroupItem.closeIfEmpty())
         activeGroupItem = null;
     }
 
     if (zoomOut && currentTab && currentTab._tabViewTabItem) {
       item = currentTab._tabViewTabItem;
       // If there was a previous currentTab we want to animate
@@ -858,32 +864,28 @@ let UI = {
       if (!TabItems.reconnectingPaused()) {
         newItem = tab._tabViewTabItem;
         GroupItems.updateActiveGroupItemAndTabBar(newItem);
       }
     } else {
       // No tabItem; must be an app tab. Base the tab bar on the current group.
       // If no current group or orphan tab, figure it out based on what's
       // already in the tab bar.
-      if (!GroupItems.getActiveGroupItem() && !GroupItems.getActiveOrphanTab()) {
+      if (!GroupItems.getActiveGroupItem() && !UI.getActiveOrphanTab()) {
         for (let a = 0; a < gBrowser.tabs.length; a++) {
           let theTab = gBrowser.tabs[a]; 
           if (!theTab.pinned) {
             let tabItem = theTab._tabViewTabItem; 
-            if (tabItem.parent) 
-              GroupItems.setActiveGroupItem(tabItem.parent);
-            else 
-              GroupItems.setActiveOrphanTab(tabItem); 
-              
+            GroupItems.setActiveGroupItem(tabItem.parent);
             break;
           }
         }
       }
 
-      if (GroupItems.getActiveGroupItem() || GroupItems.getActiveOrphanTab())
+      if (GroupItems.getActiveGroupItem() || UI.getActiveOrphanTab())
         GroupItems._updateTabBar();
     }
   },
 
   // ----------
   // Function: setReorderTabsOnHide
   // Sets the groupItem which the tab items' tabs should be re-ordered when
   // switching to the main browser UI.
--- a/browser/base/content/test/tabview/browser_tabview_bug622872.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug622872.js
@@ -57,17 +57,17 @@ function part1(win) {
     ok(win.TabView.isVisible(), "Tab View is visible.");
 
     is(win.gBrowser.tabs.length, 1, "Only one tab again.");
     is(win.gBrowser.tabs[0], originalTab, "That one tab is the original tab.");
 
     let groupItems = contentWindow.GroupItems.groupItems;
     is(groupItems.length, 1, "Only one group");
 
-    ok(!contentWindow.GroupItems.getActiveOrphanTab(), "There is no active orphan tab.");
+    ok(!contentWindow.UI.getActiveOrphanTab(), "There is no active orphan tab.");
     ok(win.TabView.isVisible(), "Tab View is visible.");
 
     win.gBrowser.tabContainer.addEventListener("TabSelect", function() {
       win.gBrowser.tabContainer.removeEventListener("TabSelect", arguments.callee, false);
       executeSoon(part4);
     }, false);
     win.document.getElementById("cmd_newNavigatorTab").doCommand();
   }
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -562,17 +562,25 @@ nsBrowserContentHandler.prototype = {
 
         searchParam = param.substr(2);
         doSearch(searchParam, cmdLine);
       }
     }
 #endif
   },
 
-  helpInfo : "  -browser           Open a browser window.\n",
+  helpInfo : "  -browser           Open a browser window.\n" +
+             "  -new-window  <url> Open <url> in a new window.\n" +
+             "  -new-tab     <url> Open <url> in a new tab.\n" +
+#ifdef XP_WIN
+             "  -preferences       Open Options dialog.\n" +
+#else
+             "  -preferences       Open Preferences dialog.\n" +
+#endif
+             "  -search     <term> Search <term> with your default search engine.\n",
 
   /* nsIBrowserHandler */
 
   get defaultArgs() {
     var prefb = Components.classes["@mozilla.org/preferences-service;1"]
                           .getService(nsIPrefBranch);
 
     var overridePage = "";
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1461,21 +1461,16 @@ ContentPermissionPrompt.prototype = {
     var mainAction = {
       label: browserBundle.GetStringFromName("geolocation.shareLocation"),
       accessKey: browserBundle.GetStringFromName("geolocation.shareLocation.accesskey"),
       callback: function(notification) {
         request.allow();
       },
     };
 
-    // XXX Bug 573536
-    // browserBundle.GetStringFromName("geolocation.learnMore")
-    //var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter);
-    //link.href = formatter.formatURLPref("browser.geolocation.warning.infoURL");
-
     var message;
     var secondaryActions = [];
 
     // Different message/options if it is a local file
     if (requestingURI.schemeIs("file")) {
       message = browserBundle.formatStringFromName("geolocation.fileWantsToKnow",
                                                    [requestingURI.path], 1);
     } else {
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -469,18 +469,22 @@
           else {
             var newTabPref = textBox._prefBranch.getBoolPref("browser.search.openintab");
             if ((aEvent && aEvent.altKey) ^ newTabPref)
               where = "tab";
           }
 
           // Save the current value in the form history
           if (textValue) {
-            textBox._formHistSvc.addEntry(textBox.getAttribute("autocompletesearchparam"),
-                                          textValue);
+            try {
+              textBox._formHistSvc.addEntry(textBox.getAttribute("autocompletesearchparam"),
+                                            textValue);
+            } catch (ex) {
+              Components.utils.reportError("Saving search to form history failed: " + ex);
+            }
           }
 
           this.doSearch(textValue, where);
         ]]></body>
       </method>
 
       <method name="doSearch">
         <parameter name="aData"/>
--- a/browser/installer/Makefile.in
+++ b/browser/installer/Makefile.in
@@ -89,17 +89,16 @@ DEFINES += -DJAREXT=
 endif
 
 ifdef MOZ_ANGLE
 DEFINES += -DMOZ_ANGLE=$(MOZ_ANGLE)
 DEFINES += -DMOZ_D3DX9_DLL=$(MOZ_D3DX9_DLL)
 DEFINES += -DMOZ_D3DCOMPILER_DLL=$(MOZ_D3DCOMPILER_DLL)
 endif
 
-# Don't ifdef MOZ_IPC this because mac ppc needs it too.
 include $(topsrcdir)/ipc/app/defs.mk
 DEFINES += -DMOZ_CHILD_PROCESS_NAME=$(MOZ_CHILD_PROCESS_NAME)
 
 ifdef MOZ_PKG_MANIFEST_P
 MOZ_PKG_MANIFEST = package-manifest
 
 $(MOZ_PKG_MANIFEST): $(MOZ_PKG_MANIFEST_P)
 	$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $< > $@
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -46,23 +46,21 @@
 @BINPATH@/@DLL_PREFIX@xpcom@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@mozalloc@DLL_SUFFIX@
 #ifdef XP_MACOSX
 @BINPATH@/XUL
 #else
 @BINPATH@/@DLL_PREFIX@xul@DLL_SUFFIX@
 #endif
-#ifdef MOZ_IPC
 #ifdef XP_MACOSX
 @BINPATH@/@MOZ_CHILD_PROCESS_NAME@.app/
 #else
 @BINPATH@/@MOZ_CHILD_PROCESS_NAME@
 #endif
-#endif
 #ifdef WINCE
 @BINPATH@/mozce_shunt.dll
 #elifdef XP_WIN32
 #ifndef MOZ_MEMORY
 #if _MSC_VER == 1400
 @BINPATH@/Microsoft.VC80.CRT.manifest
 @BINPATH@/msvcm80.dll
 @BINPATH@/msvcp80.dll
@@ -236,19 +234,16 @@
 @BINPATH@/components/spellchecker.xpt
 @BINPATH@/components/storage.xpt
 @BINPATH@/components/toolkitprofile.xpt
 #ifdef MOZ_ENABLE_XREMOTE
 @BINPATH@/components/toolkitremote.xpt
 #endif
 @BINPATH@/components/txtsvc.xpt
 @BINPATH@/components/txmgr.xpt
-#ifdef MOZ_USE_NATIVE_UCONV
-@BINPATH@/components/ucnative.xpt
-#endif
 @BINPATH@/components/uconv.xpt
 @BINPATH@/components/unicharutil.xpt
 @BINPATH@/components/update.xpt
 @BINPATH@/components/uriloader.xpt
 @BINPATH@/components/urlformatter.xpt
 @BINPATH@/components/webBrowser_core.xpt
 @BINPATH@/components/webbrowserpersist.xpt
 @BINPATH@/components/webshell_idls.xpt
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -1,11 +1,9 @@
-nv_done=Done
 nv_timeout=Timed Out
-nv_stopped=Stopped
 openFile=Open File
 
 droponhometitle=Set Home Page
 droponhomemsg=Do you want this document to be your new home page?
 
 # context menu strings
 
 # LOCALIZATION NOTE (contextMenuSearchText): %1$S is the search engine,
--- a/browser/locales/en-US/chrome/overrides/appstrings.properties
+++ b/browser/locales/en-US/chrome/overrides/appstrings.properties
@@ -58,8 +58,9 @@ externalProtocolTitle=External Protocol 
 externalProtocolPrompt=An external application must be launched to handle %1$S: links.\n\n\nRequested link:\n\n%2$S\n\nApplication: %3$S\n\n\nIf you were not expecting this request it may be an attempt to exploit a weakness in that other program. Cancel this request unless you are sure it is not malicious.\n
 #LOCALIZATION NOTE (externalProtocolUnknown): The following string is shown if the application name can't be determined
 externalProtocolUnknown=<Unknown>
 externalProtocolChkMsg=Remember my choice for all links of this type.
 externalProtocolLaunchBtn=Launch application
 malwareBlocked=The site at %S has been reported as an attack site and has been blocked based on your security preferences.
 phishingBlocked=The web site at %S has been reported as a web forgery designed to trick users into sharing personal or financial information.
 cspFrameAncestorBlocked=This page has a content security policy that prevents it from being embedded in this way.
+remoteXUL=This page uses an unsupported technology that is no longer available by default in Firefox.
--- a/browser/locales/en-US/chrome/overrides/netError.dtd
+++ b/browser/locales/en-US/chrome/overrides/netError.dtd
@@ -181,8 +181,11 @@ button is included here (instead of netE
 functionality specific to firefox. -->
 
 <!ENTITY securityOverride.warningContent "
 <p>You should not add an exception if you are using an internet connection that you do not trust completely or if you are not used to seeing a warning for this server.</p>
 
 <button id='getMeOutOfHereButton'>&securityOverride.getMeOutOfHereButton;</button>
 <button id='exceptionDialogButton'>&securityOverride.exceptionButtonLabel;</button>
 ">
+
+<!ENTITY remoteXUL.title "Remote XUL">
+<!ENTITY remoteXUL.longDesc "<p><ul><li>Please contact the website owners to inform them of this problem.</li></ul></p>">
--- a/chrome/src/Makefile.in
+++ b/chrome/src/Makefile.in
@@ -53,22 +53,19 @@ EXPORTS_NAMESPACES = mozilla/chrome
 EXPORTS_mozilla/chrome = \
 		RegistryMessageUtils.h \
 		$(NULL)
 
 CPPSRCS		= \
 		nsChromeRegistry.cpp \
 		nsChromeRegistryChrome.cpp \
 		nsChromeProtocolHandler.cpp \
+		nsChromeRegistryContent.cpp \
 		$(NULL)
 
-ifdef MOZ_IPC
-CPPSRCS += nsChromeRegistryContent.cpp
-endif
-
 EXTRA_DSO_LDOPTS = \
                 $(MOZ_UNICHARUTIL_LIBS) \
                 $(MOZ_COMPONENT_LIBS) \
                 $(NULL)
 
 ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
 EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS)
 endif
--- a/chrome/src/nsChromeRegistry.cpp
+++ b/chrome/src/nsChromeRegistry.cpp
@@ -36,19 +36,17 @@
  * 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 "nsChromeRegistry.h"
 #include "nsChromeRegistryChrome.h"
-#ifdef MOZ_IPC
 #include "nsChromeRegistryContent.h"
-#endif
 
 #include <string.h>
 
 #include "prio.h"
 #include "prprf.h"
 
 #include "nsCOMPtr.h"
 #include "nsDOMError.h"
@@ -672,20 +670,18 @@ already_AddRefed<nsChromeRegistry>
 nsChromeRegistry::GetSingleton()
 {
   if (gChromeRegistry) {
     NS_ADDREF(gChromeRegistry);
     return gChromeRegistry;
   }
 
   nsRefPtr<nsChromeRegistry> cr;
-#ifdef MOZ_IPC
   if (GeckoProcessType_Content == XRE_GetProcessType())
     cr = new nsChromeRegistryContent();
   else
-#endif
     cr = new nsChromeRegistryChrome();
 
   if (NS_FAILED(cr->Init()))
     return NULL;
 
   return cr.forget();
 }
--- a/chrome/src/nsChromeRegistryChrome.cpp
+++ b/chrome/src/nsChromeRegistryChrome.cpp
@@ -31,21 +31,19 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "mozilla/dom/PContentParent.h"
 #include "RegistryMessageUtils.h"
 #include "nsResProtocolHandler.h"
-#endif
 
 #include "nsChromeRegistryChrome.h"
 
 #if defined(XP_WIN)
 #include <windows.h>
 #elif defined(XP_MACOSX)
 #include <CoreServices/CoreServices.h>
 #elif defined(MOZ_WIDGET_GTK2)
@@ -438,17 +436,16 @@ void nsChromeRegistryChrome::UpdateSelec
         mozilla::services::GetObserverService();
       NS_ASSERTION(obsSvc, "Couldn't get observer service.");
       obsSvc->NotifyObservers((nsIChromeRegistry*) this,
                               "selected-locale-has-changed", nsnull);
     }
   }
 }
 
-#ifdef MOZ_IPC
 static void
 SerializeURI(nsIURI* aURI,
              SerializedURI& aSerializedURI)
 {
   if (!aURI)
     return;
 
   aURI->GetSpec(aSerializedURI.spec);
@@ -536,17 +533,16 @@ nsChromeRegistryChrome::CollectPackages(
     contentURI,
     localeURI,
     skinURI,
     package->flags
   };
   args->packages.AppendElement(chromePackage);
   return (PLDHashOperator)PL_DHASH_NEXT;
 }
-#endif
 
 static PRBool
 CanLoadResource(nsIURI* aResourceURI)
 {
   PRBool isLocalResource = PR_FALSE;
   (void)NS_URIChainHasFlags(aResourceURI,
                             nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
                             &isLocalResource);
--- a/chrome/src/nsChromeRegistryChrome.h
+++ b/chrome/src/nsChromeRegistryChrome.h
@@ -70,26 +70,22 @@ class nsChromeRegistryChrome : public ns
 
 #ifdef MOZ_XUL
   NS_OVERRIDE NS_IMETHOD GetXULOverlays(nsIURI *aURI,
                                         nsISimpleEnumerator **_retval);
   NS_OVERRIDE NS_IMETHOD GetStyleOverlays(nsIURI *aURI,
                                           nsISimpleEnumerator **_retval);
 #endif
   
-#ifdef MOZ_IPC
   void SendRegisteredChrome(mozilla::dom::PContentParent* aChild);
-#endif
 
  private:
-#ifdef MOZ_IPC
   static PLDHashOperator CollectPackages(PLDHashTable *table,
                                          PLDHashEntryHdr *entry,
                                          PRUint32 number, void *arg);
-#endif
 
   nsresult SelectLocaleFromPref(nsIPrefBranch* prefs);
   NS_OVERRIDE void UpdateSelectedLocale();
   NS_OVERRIDE nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
                                              const nsCString& aProvider,
                                              const nsCString& aPath);
   NS_OVERRIDE nsresult GetFlagsFromPackage(const nsCString& aPackage,
                                            PRUint32* aFlags);
--- a/chrome/test/Makefile.in
+++ b/chrome/test/Makefile.in
@@ -42,16 +42,14 @@ relativesrcdir = chrome/test
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = test_chrome
 
 XPCSHELL_TESTS = unit \
                  $(NULL)
-ifdef MOZ_IPC
 # FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 ifneq ($(OS_ARCH),Darwin)
 XPCSHELL_TESTS += unit_ipc
 endif
-endif
 
 include $(topsrcdir)/config/rules.mk
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -97,17 +97,16 @@ MOZ_JS_LIBS		   = @MOZ_JS_LIBS@
 MOZ_DEBUG	= @MOZ_DEBUG@
 MOZ_DEBUG_SYMBOLS = @MOZ_DEBUG_SYMBOLS@
 MOZ_DEBUG_ENABLE_DEFS		= @MOZ_DEBUG_ENABLE_DEFS@
 MOZ_DEBUG_DISABLE_DEFS	= @MOZ_DEBUG_DISABLE_DEFS@
 MOZ_DEBUG_FLAGS	= @MOZ_DEBUG_FLAGS@
 MOZ_DEBUG_LDFLAGS=@MOZ_DEBUG_LDFLAGS@
 MOZ_EXTENSIONS  = @MOZ_EXTENSIONS@
 MOZ_JSDEBUGGER  = @MOZ_JSDEBUGGER@
-MOZ_IPC 	= @MOZ_IPC@
 MOZ_IPDL_TESTS 	= @MOZ_IPDL_TESTS@
 MOZ_LEAKY	= @MOZ_LEAKY@
 MOZ_MEMORY      = @MOZ_MEMORY@
 MOZ_PROFILING   = @MOZ_PROFILING@
 MOZ_JPROF       = @MOZ_JPROF@
 MOZ_SHARK       = @MOZ_SHARK@
 MOZ_CALLGRIND   = @MOZ_CALLGRIND@
 MOZ_VTUNE       = @MOZ_VTUNE@
@@ -122,17 +121,16 @@ INCREMENTAL_LINKER = @INCREMENTAL_LINKER
 MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
 MOZ_MAIL_NEWS	= @MOZ_MAIL_NEWS@
 BUILD_STATIC_LIBS = @BUILD_STATIC_LIBS@
 MOZ_ENABLE_LIBXUL = @MOZ_ENABLE_LIBXUL@
 ENABLE_TESTS	= @ENABLE_TESTS@
 IBMBIDI = @IBMBIDI@
 MOZ_UNIVERSALCHARDET = @MOZ_UNIVERSALCHARDET@
 ACCESSIBILITY = @ACCESSIBILITY@
-MOZ_USE_NATIVE_UCONV = @MOZ_USE_NATIVE_UCONV@
 MOZ_BRANDING_DIRECTORY = @MOZ_BRANDING_DIRECTORY@
 XPCOM_USE_LEA = @XPCOM_USE_LEA@
 MOZ_INSTALLER	= @MOZ_INSTALLER@
 MOZ_UPDATER	= @MOZ_UPDATER@
 MOZ_UPDATE_CHANNEL	= @MOZ_UPDATE_CHANNEL@
 MOZ_UPDATE_PACKAGING	= @MOZ_UPDATE_PACKAGING@
 MOZ_NO_ACTIVEX_SUPPORT = @MOZ_NO_ACTIVEX_SUPPORT@
 MOZ_ACTIVEX_SCRIPTING_SUPPORT = @MOZ_ACTIVEX_SCRIPTING_SUPPORT@
--- a/configure.in
+++ b/configure.in
@@ -4945,17 +4945,16 @@ MOZ_ARG_HEADER(Application)
 
 BUILD_STATIC_LIBS=
 ENABLE_TESTS=1
 MOZ_ACTIVEX_SCRIPTING_SUPPORT=
 MOZ_BRANDING_DIRECTORY=
 MOZ_OFFICIAL_BRANDING=
 MOZ_FEEDS=1
 MOZ_INSTALLER=1
-MOZ_IPC=1
 MOZ_JAVAXPCOM=
 MOZ_JSDEBUGGER=1
 MOZ_MATHML=1
 MOZ_MORK=
 MOZ_MORKREADER=1
 MOZ_AUTH_EXTENSION=1
 MOZ_NO_ACTIVEX_SUPPORT=1
 MOZ_NO_FAST_LOAD=
@@ -4995,17 +4994,16 @@ MOZ_SPLASHSCREEN=
 MOZ_STORAGE=1
 MOZ_SVG=1
 MOZ_THUMB2=
 MOZ_TIMELINE=
 MOZ_TOOLKIT_SEARCH=1
 MOZ_UI_LOCALE=en-US
 MOZ_UNIVERSALCHARDET=1
 MOZ_URL_CLASSIFIER=
-MOZ_USE_NATIVE_UCONV=
 MOZ_XSLT_STANDALONE=
 MOZ_XTF=1
 MOZ_XUL=1
 MOZ_ZIPWRITER=1
 NS_PRINTING=1
 MOZ_PDF_PRINTING=
 MOZ_DISABLE_DOMCRYPTO=
 NSS_DISABLE_DBM=
@@ -5641,16 +5639,21 @@ then
 
     AC_SUBST(MOZ_ENABLE_GIO)
     AC_SUBST(MOZ_GIO_CFLAGS)
     AC_SUBST(MOZ_GIO_LIBS)
    
     dnl ========================================================
     dnl = GConf support module
     dnl ========================================================
+    MOZ_ARG_DISABLE_BOOL(gconf,
+    [  --disable-gconf      Disable Gconf support ],
+        MOZ_ENABLE_GCONF=,
+        MOZ_ENABLE_GCONF=force)
+
     if test "$MOZ_ENABLE_GCONF"
     then
         PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
             MOZ_GCONF_LIBS=`echo $MOZ_GCONF_LIBS | sed 's/-llinc\>//'`
             MOZ_ENABLE_GCONF=1
         ],[
             if test "$MOZ_ENABLE_GCONF" = "force"
             then
@@ -5817,31 +5820,16 @@ dnl = JS Debugger XPCOM component (js/js
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(jsd,
 [  --disable-jsd           Disable JavaScript debug library],
     MOZ_JSDEBUGGER=,
     MOZ_JSDEBUGGER=1)
 
 
 dnl ========================================================
-dnl = Disable IPC support for tabs and plugins
-dnl ========================================================
-MOZ_ARG_DISABLE_BOOL(ipc,
-[  --disable-ipc           Disable IPC for tabs and plugins (not supported)],
-    MOZ_IPC=,
-    MOZ_IPC=1)
-
-if test -z "$MOZ_IPC"; then
-  AC_MSG_ERROR([--disable-ipc is no longer supported.])
-fi
-
-AC_DEFINE(MOZ_IPC)
-AC_SUBST(MOZ_IPC)
-
-dnl ========================================================
 dnl = Enable IPDL's "expensive" unit tests
 dnl ========================================================
 MOZ_IPDL_TESTS=
 
 MOZ_ARG_ENABLE_BOOL(ipdl-tests,
 [  --enable-ipdl-tests     Enable expensive IPDL tests],
     MOZ_IPDL_TESTS=1,
     MOZ_IPDL_TESTS=)
@@ -5896,30 +5884,16 @@ MOZ_ARG_DISABLE_BOOL(printing,
 [  --disable-printing      Disable printing support],
     NS_PRINTING=,
     NS_PRINTING=1)
 
 if test "$NS_PRINTING"; then
     AC_DEFINE(NS_PRINTING)
     AC_DEFINE(NS_PRINT_PREVIEW)
 fi
-dnl ========================================================
-dnl use native unicode converters
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(native-uconv,
-[  --enable-native-uconv   Enable iconv support],
-    MOZ_USE_NATIVE_UCONV=1,
-    MOZ_USE_NATIVE_UCONV= )
-if test "$MOZ_USE_NATIVE_UCONV"; then
-    AC_DEFINE(MOZ_USE_NATIVE_UCONV)
-fi
-if test "$OS_ARCH" != "WINCE" -a "$OS_ARCH" != "WINNT" -a "$MOZ_USE_NATIVE_UCONV" -a "$ac_cv_func_iconv" != "yes"; then
-    AC_MSG_ERROR([iconv() not found.  Cannot enable native uconv support.])
-fi
-
 
 dnl ========================================================
 dnl = Disable Fast Load
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(xpcom-fastload,
 [  --disable-xpcom-fastload
                           Disable XPCOM fastload support],
     MOZ_NO_FAST_LOAD=1,
@@ -6480,17 +6454,17 @@ if test -n "$MOZ_LIBJPEG_TURBO"; then
     LIBJPEG_TURBO_ASFLAGS="-f macho64 -rnasm -pnasm -D__x86_64__ -DPIC -DMACHO"
     LIBJPEG_TURBO_X64_ASM=1
   ;;
   WINNT:x86|WINNT:i?86)
     LIBJPEG_TURBO_ASFLAGS="-f win32 -rnasm -pnasm -DPIC -DWIN32"
     LIBJPEG_TURBO_X86_ASM=1
   ;;
   WINNT:x86_64)
-    LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64"
+    LIBJPEG_TURBO_ASFLAGS="-f win64 -rnasm -pnasm -D__x86_64__ -DPIC -DWIN64 -DMSVC"
     LIBJPEG_TURBO_X64_ASM=1
   ;;
   esac
 
 fi
 
 dnl If we're on a system which supports libjpeg-turbo's asm routines and
 dnl --disable-libjpeg-turbo wasn't passed, check for yasm, and error out if it
@@ -8926,17 +8900,17 @@ if test "$NECKO_WIFI" -a \
         "$OS_ARCH" != "WINCE"; then
   AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use --disable-necko-wifi])
 fi
 
 if test -z "$SKIP_LIBRARY_CHECKS" -a "$NECKO_WIFI" -a "$OS_ARCH" = "Linux"
 then
   MOZ_CHECK_HEADER([iwlib.h])
   if test "$ac_cv_header_iwlib_h" != "yes"; then
-    AC_MSG_ERROR([Can't find header iwlib.h for Necko WiFi scanning (might be in package libiw-dev (Ubuntu) or wireless-tools-devel (Fedora)); use --disable-necko-wifi to disable])
+    AC_MSG_ERROR([Can't find header iwlib.h for Necko WiFi scanning (might be in package libiw-dev (Ubuntu) or wireless-tools-devel (Fedora) or libiw-devel (openSUSE)); use --disable-necko-wifi to disable])
   fi
 fi
 
 if test "$NECKO_WIFI"; then
   AC_DEFINE(NECKO_WIFI)
 fi
 AC_SUBST(NECKO_WIFI)
 
@@ -9051,17 +9025,16 @@ AC_SUBST(MOZ_EXTENSIONS)
 AC_SUBST(MOZ_JSDEBUGGER)
 AC_SUBST(MOZ_LOG_REFCNT)
 AC_SUBST(MOZ_LEAKY)
 AC_SUBST(MOZ_JPROF)
 AC_SUBST(MOZ_SHARK)
 AC_SUBST(MOZ_CALLGRIND)
 AC_SUBST(MOZ_VTUNE)
 AC_SUBST(MOZ_PROFILING)
-AC_SUBST(MOZ_USE_NATIVE_UCONV)
 AC_SUBST(MOZ_QUANTIFY)
 AC_SUBST(LIBICONV)
 AC_SUBST(MOZ_PLACES)
 AC_SUBST(MOZ_PLACES_BOOKMARKS)
 AC_SUBST(MOZ_STORAGE)
 AC_SUBST(MOZ_TOOLKIT_SEARCH)
 AC_SUBST(MOZ_FEEDS)
 AC_SUBST(NS_PRINTING)
@@ -9346,17 +9319,17 @@ if test "$MOZ_X11"; then
     fi
 
 fi # MOZ_X11
 
 dnl Check for headers, etc. needed by WebGL.
 if test -n "$MOZ_WEBGL_GLX"; then
     MOZ_CHECK_HEADER(GL/glx.h)
     if test "$ac_cv_header_GL_glx_h" != "yes"; then
-        AC_MSG_ERROR([Can't find header GL/glx.h for WebGL (install mesa-common-dev (Ubuntu), mesa-libGL-devel (Fedora), or Mesa (SuSE))])
+        AC_MSG_ERROR([Can't find header GL/glx.h for WebGL (install mesa-common-dev (Ubuntu), mesa-libGL-devel (Fedora), or Mesa-devel (openSUSE))])
     fi
 fi # MOZ_WEBGL_GLX
 fi # COMPILE_ENVIRONMENT
 
 if test "$USE_FC_FREETYPE"; then
     if test "$COMPILE_ENVIRONMENT"; then
     	_SAVE_CPPFLAGS="$CPPFLAGS"
     	CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
--- a/content/base/src/Makefile.in
+++ b/content/base/src/Makefile.in
@@ -173,24 +173,19 @@ FORCE_STATIC_LIB = 1
 
 EXTRA_COMPONENTS = \
 		$(srcdir)/nsBadCertHandler.js \
 		nsBadCertHandler.manifest \
 		contentSecurityPolicy.js \
 		contentSecurityPolicy.manifest \
 		contentAreaDropListener.js \
 		contentAreaDropListener.manifest \
-		$(NULL)
-
-ifdef MOZ_IPC
-EXTRA_COMPONENTS += \
 		messageWakeupService.js \
 		messageWakeupService.manifest \
 		$(NULL)
-endif
 
 EXTRA_JS_MODULES = \
 		CSPUtils.jsm \
 		$(NULL)
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -2133,21 +2133,27 @@ nsContentUtils::GenerateStateKey(nsICont
       nsAutoString name;
       aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
       KeyAppendString(name, aKey);
     }
   }
 
   if (!generatedUniqueKey) {
     // Either we didn't have a form control or we aren't in an HTML document so
-    // we can't figure out form info.  First append a character that is not "d"
-    // or "f" to disambiguate from the case when we were a form control in an
-    // HTML document.
-    KeyAppendString(NS_LITERAL_CSTRING("o"), aKey);
-    
+    // we can't figure out form info.  Append the tag name if it's an element
+    // to avoid restoring state for one type of element on another type.
+    if (aContent->IsElement()) {
+      KeyAppendString(nsDependentAtomString(aContent->Tag()), aKey);
+    }
+    else {
+      // Append a character that is not "d" or "f" to disambiguate from
+      // the case when we were a form control in an HTML document.
+      KeyAppendString(NS_LITERAL_CSTRING("o"), aKey);
+    }
+
     // Now start at aContent and append the indices of it and all its ancestors
     // in their containers.  That should at least pin down its position in the
     // DOM...
     nsINode* parent = aContent->GetNodeParent();
     nsINode* content = aContent;
     while (parent) {
       KeyAppendInt(parent->IndexOf(content), aKey);
       content = parent;
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -8345,22 +8345,20 @@ PLDHashOperator UnlockEnumerator(imgIReq
   aKey->UnlockImage();
   return PL_DHASH_NEXT;
 }
 
 
 nsresult
 nsDocument::SetImageLockingState(PRBool aLocked)
 {
-#ifdef MOZ_IPC
   if (XRE_GetProcessType() == GeckoProcessType_Content &&
       !nsContentUtils::GetBoolPref("content.image.allow_locking", PR_TRUE)) {
     return NS_OK;
   }
-#endif // MOZ_IPC
 
   // If there's no change, there's nothing to do.
   if (mLockingImages == aLocked)
     return NS_OK;
 
   // Otherwise, iterate over our images and perform the appropriate action.
   mImageTracker.EnumerateRead(aLocked ? LockEnumerator
                                       : UnlockEnumerator,
--- a/content/base/src/nsFrameLoader.cpp
+++ b/content/base/src/nsFrameLoader.cpp
@@ -39,19 +39,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /*
  * Class for managing loading of a subframe (creation of the docshell,
  * handling of loads in it, recursion-checking).
  */
 
-#ifdef MOZ_IPC
-#  include "base/basictypes.h"
-#endif
+#include "base/basictypes.h"
 
 #include "prenv.h"
 
 #include "nsIDOMHTMLIFrameElement.h"
 #include "nsIDOMHTMLFrameElement.h"
 #include "nsIDOMWindow.h"
 #include "nsIPresShell.h"
 #include "nsIContent.h"
@@ -107,25 +105,22 @@
 
 #include "nsIDOMChromeWindow.h"
 #include "nsInProcessTabChildGlobal.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/unused.h"
 
 #include "Layers.h"
 
-#ifdef MOZ_IPC
 #include "ContentParent.h"
 #include "TabParent.h"
 #include "mozilla/layout/RenderFrameParent.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
-#endif
-
 using namespace mozilla::layers;
 typedef FrameMetrics::ViewID ViewID;
 
 #include "jsapi.h"
 
 class nsAsyncDocShellDestroyer : public nsRunnable
 {
 public:
@@ -319,23 +314,21 @@ nsFrameLoader::nsFrameLoader(nsIContent 
   , mDepthTooGreat(PR_FALSE)
   , mIsTopLevelContent(PR_FALSE)
   , mDestroyCalled(PR_FALSE)
   , mNeedsAsyncDestroy(PR_FALSE)
   , mInSwap(PR_FALSE)
   , mInShow(PR_FALSE)
   , mHideCalled(PR_FALSE)
   , mNetworkCreated(aNetworkCreated)
-#ifdef MOZ_IPC
   , mDelayRemoteDialogs(PR_FALSE)
   , mRemoteBrowserShown(PR_FALSE)
   , mRemoteFrame(false)
   , mCurrentRemoteFrame(nsnull)
   , mRemoteBrowser(nsnull)
-#endif
   , mRenderMode(RENDER_MODE_DEFAULT)
 {
 }
 
 nsFrameLoader*
 nsFrameLoader::Create(nsIContent* aOwner, PRBool aNetworkCreated)
 {
   NS_ENSURE_TRUE(aOwner, nsnull);
@@ -443,32 +436,30 @@ nsFrameLoader::ReallyStartLoadingInterna
 {
   NS_ENSURE_STATE(mURIToLoad && mOwnerContent && mOwnerContent->IsInDoc());
 
   nsresult rv = MaybeCreateDocShell();
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-#ifdef MOZ_IPC
   if (mRemoteFrame) {
     if (!mRemoteBrowser) {
       TryRemoteBrowser();
 
       if (!mRemoteBrowser) {
         NS_WARNING("Couldn't create child process for iframe.");
         return NS_ERROR_FAILURE;
       }
     }
 
     // FIXME get error codes from child
     mRemoteBrowser->LoadURL(mURIToLoad);
     return NS_OK;
   }
-#endif
 
   NS_ASSERTION(mDocShell,
                "MaybeCreateDocShell succeeded with a null mDocShell");
 
   // Just to be safe, recheck uri.
   rv = CheckURILoad(mURIToLoad);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -529,42 +520,38 @@ nsFrameLoader::CheckURILoad(nsIURI* aURI
     return rv; // We're not
   }
 
   // Bail out if this is an infinite recursion scenario
   rv = MaybeCreateDocShell();
   if (NS_FAILED(rv)) {
     return rv;
   }
-#ifdef MOZ_IPC
   if (mRemoteFrame) {
     return NS_OK;
   }
-#endif
   return CheckForRecursiveLoad(aURI);
 }
 
 NS_IMETHODIMP
 nsFrameLoader::GetDocShell(nsIDocShell **aDocShell)
 {
   *aDocShell = nsnull;
 
   // If we have an owner, make sure we have a docshell and return
   // that. If not, we're most likely in the middle of being torn down,
   // then we just return null.
   if (mOwnerContent) {
     nsresult rv = MaybeCreateDocShell();
     if (NS_FAILED(rv))
       return rv;
-#ifdef MOZ_IPC
     if (mRemoteFrame) {
       NS_WARNING("No docshells for remote frames!");
       return NS_ERROR_NOT_AVAILABLE;
     }
-#endif
     NS_ASSERTION(mDocShell,
                  "MaybeCreateDocShell succeeded, but null mDocShell");
   }
 
   *aDocShell = mDocShell;
   NS_IF_ADDREF(*aDocShell);
 
   return NS_OK;
@@ -771,20 +758,17 @@ nsFrameLoader::Show(PRInt32 marginWidth,
   AutoResetInShow resetInShow(this);
   mInShow = PR_TRUE;
 
   nsresult rv = MaybeCreateDocShell();
   if (NS_FAILED(rv)) {
     return PR_FALSE;
   }
 
-#ifdef MOZ_IPC
-  if (!mRemoteFrame)
-#endif
-  {
+  if (!mRemoteFrame) {
     if (!mDocShell)
       return PR_FALSE;
     nsCOMPtr<nsIPresShell> presShell;
     mDocShell->GetPresShell(getter_AddRefs(presShell));
     if (presShell)
       return PR_TRUE;
 
     mDocShell->SetMarginWidth(marginWidth);
@@ -798,21 +782,19 @@ nsFrameLoader::Show(PRInt32 marginWidth,
                                          scrollbarPrefY);
     }
   }
 
   nsIView* view = frame->EnsureInnerView();
   if (!view)
     return PR_FALSE;
 
-#ifdef MOZ_IPC
   if (mRemoteFrame) {
     return ShowRemoteFrame(GetSubDocumentSize(frame));
   }
-#endif
 
   nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(mDocShell);
   NS_ASSERTION(baseWindow, "Found a nsIDocShell that isn't a nsIBaseWindow.");
   nsIntSize size;
   if (!(frame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
     // We have a useful size already; use it, since we might get no
     // more size updates.
     size = GetSubDocumentSize(frame);
@@ -875,17 +857,16 @@ nsFrameLoader::Show(PRInt32 marginWidth,
   if (mHideCalled) {
     mHideCalled = PR_FALSE;
     Hide();
     return PR_FALSE;
   }
   return PR_TRUE;
 }
 
-#ifdef MOZ_IPC
 bool
 nsFrameLoader::ShowRemoteFrame(const nsIntSize& size)
 {
   NS_ASSERTION(mRemoteFrame, "ShowRemote only makes sense on remote frames.");
 
   if (!mRemoteBrowser) {
     TryRemoteBrowser();
 
@@ -904,17 +885,16 @@ nsFrameLoader::ShowRemoteFrame(const nsI
 
     EnsureMessageManager();
   } else {
     mRemoteBrowser->Move(size);
   }
 
   return true;
 }
-#endif
 
 void
 nsFrameLoader::Hide()
 {
   if (mHideCalled) {
     return;
   }
   if (mInShow) {
@@ -1229,23 +1209,21 @@ nsFrameLoader::SwapWithOtherLoader(nsFra
 
   mInSwap = aOther->mInSwap = PR_FALSE;
   return NS_OK;
 }
 
 void
 nsFrameLoader::DestroyChild()
 {
-#ifdef MOZ_IPC
   if (mRemoteBrowser) {
     mRemoteBrowser->SetOwnerElement(nsnull);
     mRemoteBrowser->Destroy();
     mRemoteBrowser = nsnull;
   }
-#endif
 }
 
 NS_IMETHODIMP
 nsFrameLoader::Destroy()
 {
   if (mDestroyCalled) {
     return NS_OK;
   }
@@ -1322,24 +1300,21 @@ nsFrameLoader::GetDepthTooGreat(PRBool* 
   *aDepthTooGreat = mDepthTooGreat;
   return NS_OK;
 }
 
 void
 nsFrameLoader::SetOwnerContent(nsIContent* aContent)
 {
   mOwnerContent = aContent;
-#ifdef MOZ_IPC
   if (RenderFrameParent* rfp = GetCurrentRemoteFrame()) {
     rfp->OwnerContentChanged(aContent);
   }
-#endif
 }
 
-#ifdef MOZ_IPC
 bool
 nsFrameLoader::ShouldUseRemoteProcess()
 {
   // Check for *disabled* multi-process first: environment, prefs, attribute
   // Then check for *enabled* multi-process pref: attribute, prefs
   // Default is not-remote.
 
   if (PR_GetEnv("MOZ_DISABLE_OOP_TABS")) {
@@ -1365,37 +1340,32 @@ nsFrameLoader::ShouldUseRemoteProcess()
   case 1:
     return true;
   }
 
   PRBool remoteEnabled = nsContentUtils::GetBoolPref("dom.ipc.tabs.enabled",
                                                      PR_FALSE);
   return (bool) remoteEnabled;
 }
-#endif
 
 nsresult
 nsFrameLoader::MaybeCreateDocShell()
 {
   if (mDocShell) {
     return NS_OK;
   }
-#ifdef MOZ_IPC
   if (mRemoteFrame) {
     return NS_OK;
   }
-#endif
   NS_ENSURE_STATE(!mDestroyCalled);
 
-#ifdef MOZ_IPC
   if (ShouldUseRemoteProcess()) {
     mRemoteFrame = true;
     return NS_OK;
   }
-#endif
 
   // Get our parent docshell off the document of mOwnerContent
   // XXXbz this is such a total hack.... We really need to have a
   // better setup for doing this.
   nsIDocument* doc = mOwnerContent->GetOwnerDoc();
   if (!doc || !(doc->IsStaticDocument() || mOwnerContent->IsInDoc())) {
     return NS_ERROR_UNEXPECTED;
   }
@@ -1534,20 +1504,18 @@ nsFrameLoader::CheckForRecursiveLoad(nsI
 {
   nsresult rv;
 
   mDepthTooGreat = PR_FALSE;
   rv = MaybeCreateDocShell();
   if (NS_FAILED(rv)) {
     return rv;
   }
-#ifdef MOZ_IPC
   NS_ASSERTION(!mRemoteFrame,
                "Shouldn't call CheckForRecursiveLoad on remote frames.");
-#endif
   if (!mDocShell) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(mDocShell);
   NS_ASSERTION(treeItem, "docshell must be a treeitem!");
 
   // Check that we're still in the docshell tree.
@@ -1637,25 +1605,23 @@ nsFrameLoader::CheckForRecursiveLoad(nsI
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFrameLoader::UpdatePositionAndSize(nsIFrame *aIFrame)
 {
-#ifdef MOZ_IPC
   if (mRemoteFrame) {
     if (mRemoteBrowser) {
       nsIntSize size = GetSubDocumentSize(aIFrame);
       mRemoteBrowser->Move(size);
     }
     return NS_OK;
   }
-#endif
   return UpdateBaseWindowPositionAndSize(aIFrame);
 }
 
 nsresult
 nsFrameLoader::UpdateBaseWindowPositionAndSize(nsIFrame *aIFrame)
 {
   nsCOMPtr<nsIDocShell> docShell;
   GetDocShell(getter_AddRefs(docShell));
@@ -1713,17 +1679,16 @@ nsFrameLoader::GetSubDocumentSize(const 
     docSizeAppUnits = aIFrame->GetSize();
   } else {
     docSizeAppUnits = aIFrame->GetContentRect().Size();
   }
   return nsIntSize(presContext->AppUnitsToDevPixels(docSizeAppUnits.width),
                    presContext->AppUnitsToDevPixels(docSizeAppUnits.height));
 }
 
-#ifdef MOZ_IPC
 bool
 nsFrameLoader::TryRemoteBrowser()
 {
   NS_ASSERTION(!mRemoteBrowser, "TryRemoteBrowser called with a remote browser already?");
 
   nsIDocument* doc = mOwnerContent->GetDocument();
   if (!doc) {
     return false;
@@ -1793,110 +1758,93 @@ nsFrameLoader::TryRemoteBrowser()
     nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
     rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
     mRemoteBrowser->SetBrowserDOMWindow(browserDOMWin);
     
     mChildHost = parent;
   }
   return true;
 }
-#endif
 
-#ifdef MOZ_IPC
 mozilla::dom::PBrowserParent*
 nsFrameLoader::GetRemoteBrowser()
 {
   return mRemoteBrowser;
 }
-#endif
 
 NS_IMETHODIMP
 nsFrameLoader::ActivateRemoteFrame() {
-#ifdef MOZ_IPC
   if (mRemoteBrowser) {
     mRemoteBrowser->Activate();
     return NS_OK;
   }
-#endif
   return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP
 nsFrameLoader::SendCrossProcessMouseEvent(const nsAString& aType,
                                           float aX,
                                           float aY,
                                           PRInt32 aButton,
                                           PRInt32 aClickCount,
                                           PRInt32 aModifiers,
                                           PRBool aIgnoreRootScrollFrame)
 {
-#ifdef MOZ_IPC
   if (mRemoteBrowser) {
     mRemoteBrowser->SendMouseEvent(aType, aX, aY, aButton,
                                    aClickCount, aModifiers,
                                    aIgnoreRootScrollFrame);
     return NS_OK;
   }
-#endif
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsFrameLoader::ActivateFrameEvent(const nsAString& aType,
                                   PRBool aCapture)
 {
-#ifdef MOZ_IPC
   if (mRemoteBrowser) {
     return mRemoteBrowser->SendActivateFrameEvent(nsString(aType), aCapture) ?
       NS_OK : NS_ERROR_NOT_AVAILABLE;
   }
-#endif
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsFrameLoader::SendCrossProcessKeyEvent(const nsAString& aType,
                                         PRInt32 aKeyCode,
                                         PRInt32 aCharCode,
                                         PRInt32 aModifiers,
                                         PRBool aPreventDefault)
 {
-#ifdef MOZ_IPC
   if (mRemoteBrowser) {
     mRemoteBrowser->SendKeyEvent(aType, aKeyCode, aCharCode, aModifiers,
                                  aPreventDefault);
     return NS_OK;
   }
-#endif
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsFrameLoader::GetDelayRemoteDialogs(PRBool* aRetVal)
 {
-#ifdef MOZ_IPC
   *aRetVal = mDelayRemoteDialogs;
-#else
-  *aRetVal = PR_FALSE;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFrameLoader::SetDelayRemoteDialogs(PRBool aDelay)
 {
-#ifdef MOZ_IPC
   if (mRemoteBrowser && mDelayRemoteDialogs && !aDelay) {
     nsRefPtr<nsIRunnable> ev =
       NS_NewRunnableMethod(mRemoteBrowser,
                            &mozilla::dom::TabParent::HandleDelayedDialogs);
     NS_DispatchToCurrentThread(ev);
   }
   mDelayRemoteDialogs = aDelay;
-#endif
   return NS_OK;
 }
 
 nsresult
 nsFrameLoader::CreateStaticClone(nsIFrameLoader* aDest)
 {
   nsFrameLoader* dest = static_cast<nsFrameLoader*>(aDest);
   dest->MaybeCreateDocShell();
@@ -1917,23 +1865,21 @@ nsFrameLoader::CreateStaticClone(nsIFram
   nsCOMPtr<nsIDOMDocument> clonedDOMDoc = do_QueryInterface(clonedDoc);
 
   viewer->SetDOMDocument(clonedDOMDoc);
   return NS_OK;
 }
 
 bool LoadScript(void* aCallbackData, const nsAString& aURL)
 {
-#ifdef MOZ_IPC
   mozilla::dom::PBrowserParent* tabParent =
     static_cast<nsFrameLoader*>(aCallbackData)->GetRemoteBrowser();
   if (tabParent) {
     return tabParent->SendLoadRemoteScript(nsString(aURL));
   }
-#endif
   nsFrameLoader* fl = static_cast<nsFrameLoader*>(aCallbackData);
   nsRefPtr<nsInProcessTabChildGlobal> tabChild =
     static_cast<nsInProcessTabChildGlobal*>(fl->GetTabChildGlobalAsEventTarget());
   if (tabChild) {
     tabChild->LoadFrameScript(aURL);
   }
   return true;
 }
@@ -1960,23 +1906,21 @@ public:
   nsString mMessage;
   nsString mJSON;
 };
 
 bool SendAsyncMessageToChild(void* aCallbackData,
                              const nsAString& aMessage,
                              const nsAString& aJSON)
 {
-#ifdef MOZ_IPC
   mozilla::dom::PBrowserParent* tabParent =
     static_cast<nsFrameLoader*>(aCallbackData)->GetRemoteBrowser();
   if (tabParent) {
     return tabParent->SendAsyncMessage(nsString(aMessage), nsString(aJSON));
   }
-#endif
   nsRefPtr<nsIRunnable> ev =
     new nsAsyncMessageToChild(static_cast<nsFrameLoader*>(aCallbackData),
                               aMessage, aJSON);
   NS_DispatchToCurrentThread(ev);
   return true;
 }
 
 NS_IMETHODIMP
@@ -1991,17 +1935,16 @@ nsFrameLoader::GetMessageManager(nsIChro
 
 NS_IMETHODIMP
 nsFrameLoader::GetContentViewsIn(float aXPx, float aYPx,
                                  float aTopSize, float aRightSize,
                                  float aBottomSize, float aLeftSize,
                                  PRUint32* aLength,
                                  nsIContentView*** aResult)
 {
-#ifdef MOZ_IPC
   nscoord x = nsPresContext::CSSPixelsToAppUnits(aXPx - aLeftSize);
   nscoord y = nsPresContext::CSSPixelsToAppUnits(aYPx - aTopSize);
   nscoord w = nsPresContext::CSSPixelsToAppUnits(aLeftSize + aRightSize) + 1;
   nscoord h = nsPresContext::CSSPixelsToAppUnits(aTopSize + aBottomSize) + 1;
   nsRect target(x, y, w, h);
 
   nsIFrame* frame = GetPrimaryFrameOfOwningContent();
 
@@ -2019,96 +1962,79 @@ nsFrameLoader::GetContentViewsIn(float a
   for (PRUint32 i = 0; i < ids.Length(); i++) {
     nsIContentView* view = GetCurrentRemoteFrame()->GetContentView(ids[i]);
     NS_ABORT_IF_FALSE(view, "Retrieved ID from RenderFrameParent, it should be valid!");
     nsRefPtr<nsIContentView>(view).forget(&result[i]);
   }
 
   *aResult = result;
   *aLength = ids.Length();
-#else
-  *aResult = nsnull;
-  *aLength = 0;
-#endif
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsFrameLoader::GetRootContentView(nsIContentView** aContentView)
 {
-#ifdef MOZ_IPC
   RenderFrameParent* rfp = GetCurrentRemoteFrame();
   if (!rfp) {
     *aContentView = nsnull;
     return NS_OK;
   }
 
   nsContentView* view = rfp->GetContentView();
   NS_ABORT_IF_FALSE(view, "Should always be able to create root scrollable!");
   nsRefPtr<nsIContentView>(view).forget(aContentView);
 
   return NS_OK;
-#else
-  return NS_ERROR_NOT_IMPLEMENTED;
-#endif
-
 }
 
 nsresult
 nsFrameLoader::EnsureMessageManager()
 {
   NS_ENSURE_STATE(mOwnerContent);
 
   nsresult rv = MaybeCreateDocShell();
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  if (!mIsTopLevelContent
-#ifdef MOZ_IPC
-      && !mRemoteFrame
-#endif
-      ) {
+  if (!mIsTopLevelContent && !mRemoteFrame) {
     return NS_OK;
   }
 
   if (mMessageManager) {
-#ifdef MOZ_IPC
     if (ShouldUseRemoteProcess()) {
       mMessageManager->SetCallbackData(mRemoteBrowserShown ? this : nsnull);
     }
-#endif
     return NS_OK;
   }
 
   nsIScriptContext* sctx = mOwnerContent->GetContextForEventHandlers(&rv);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_STATE(sctx);
   JSContext* cx = static_cast<JSContext*>(sctx->GetNativeContext());
   NS_ENSURE_STATE(cx);
 
   nsCOMPtr<nsIDOMChromeWindow> chromeWindow =
     do_QueryInterface(mOwnerContent->GetOwnerDoc()->GetWindow());
   NS_ENSURE_STATE(chromeWindow);
   nsCOMPtr<nsIChromeFrameMessageManager> parentManager;
   chromeWindow->GetMessageManager(getter_AddRefs(parentManager));
 
-#ifdef MOZ_IPC
   if (ShouldUseRemoteProcess()) {
     mMessageManager = new nsFrameMessageManager(PR_TRUE,
                                                 nsnull,
                                                 SendAsyncMessageToChild,
                                                 LoadScript,
                                                 mRemoteBrowserShown ? this : nsnull,
                                                 static_cast<nsFrameMessageManager*>(parentManager.get()),
                                                 cx);
     NS_ENSURE_TRUE(mMessageManager, NS_ERROR_OUT_OF_MEMORY);
   } else
-#endif
   {
 
     mMessageManager = new nsFrameMessageManager(PR_TRUE,
                                                 nsnull,
                                                 SendAsyncMessageToChild,
                                                 LoadScript,
                                                 nsnull,
                                                 static_cast<nsFrameMessageManager*>(parentManager.get()),
--- a/content/base/src/nsFrameLoader.h
+++ b/content/base/src/nsFrameLoader.h
@@ -56,17 +56,16 @@
 
 class nsIContent;
 class nsIURI;
 class nsSubDocumentFrame;
 class nsIView;
 class nsIInProcessContentFrameMessageManager;
 class AutoResetInShow;
 
-#ifdef MOZ_IPC
 namespace mozilla {
 namespace dom {
 class PBrowserParent;
 class TabParent;
 }
 
 namespace layout {
 class RenderFrameParent;
@@ -74,17 +73,16 @@ class RenderFrameParent;
 }
 
 #ifdef MOZ_WIDGET_GTK2
 typedef struct _GtkWidget GtkWidget;
 #endif
 #ifdef MOZ_WIDGET_QT
 class QX11EmbedContainer;
 #endif
-#endif
 
 /**
  * Defines a target configuration for this <browser>'s content
  * document's view.  If the content document's actual view
  * doesn't match this nsIContentView, then on paints its pixels
  * are transformed to compensate for the difference.
  *
  * Used to support asynchronous re-paints of content pixels; see
@@ -162,21 +160,19 @@ private:
   ViewConfig mConfig;
 };
 
 
 class nsFrameLoader : public nsIFrameLoader,
                       public nsIContentViewManager
 {
   friend class AutoResetInShow;
-#ifdef MOZ_IPC
   typedef mozilla::dom::PBrowserParent PBrowserParent;
   typedef mozilla::dom::TabParent TabParent;
   typedef mozilla::layout::RenderFrameParent RenderFrameParent;
-#endif
 
 protected:
   nsFrameLoader(nsIContent *aOwner, PRBool aNetworkCreated);
 
 public:
   ~nsFrameLoader() {
     mNeedsAsyncDestroy = PR_TRUE;
     if (mMessageManager) {
@@ -241,17 +237,16 @@ public:
 
   /** 
    * Return the document that owns this, or null if we don't have
    * an owner.
    */
   nsIDocument* GetOwnerDoc() const
   { return mOwnerContent ? mOwnerContent->GetOwnerDoc() : nsnull; }
 
-#ifdef MOZ_IPC
   PBrowserParent* GetRemoteBrowser();
 
   /**
    * The "current" render frame is the one on which the most recent
    * remote layer-tree transaction was executed.  If no content has
    * been drawn yet, or the remote browser doesn't have any drawn
    * content for whatever reason, return NULL.  The returned render
    * frame has an associated shadow layer tree.
@@ -272,27 +267,24 @@ public:
    * |aFrame| can be null.  If non-null, it must be the remote frame
    * on which the most recent layer transaction completed for this's
    * <browser>.
    */
   void SetCurrentRemoteFrame(RenderFrameParent* aFrame)
   {
     mCurrentRemoteFrame = aFrame;
   }
-#endif
   nsFrameMessageManager* GetFrameMessageManager() { return mMessageManager; }
 
   nsIContent* GetOwnerContent() { return mOwnerContent; }
   void SetOwnerContent(nsIContent* aContent);
 
 private:
 
-#ifdef MOZ_IPC
   bool ShouldUseRemoteProcess();
-#endif
 
   /**
    * If we are an IPC frame, set mRemoteFrame. Otherwise, create and
    * initialize mDocShell.
    */
   nsresult MaybeCreateDocShell();
   nsresult EnsureMessageManager();
   NS_HIDDEN_(void) GetURL(nsString& aURL);
@@ -302,23 +294,21 @@ private:
 
   // Updates the subdocument position and size. This gets called only
   // when we have our own in-process DocShell.
   NS_HIDDEN_(nsresult) UpdateBaseWindowPositionAndSize(nsIFrame *aIFrame);
   nsresult CheckURILoad(nsIURI* aURI);
   void FireErrorEvent();
   nsresult ReallyStartLoadingInternal();
 
-#ifdef MOZ_IPC
   // Return true if remote browser created; nothing else to do
   bool TryRemoteBrowser();
 
   // Tell the remote browser that it's now "virtually visible"
   bool ShowRemoteFrame(const nsIntSize& size);
-#endif
 
   nsCOMPtr<nsIDocShell> mDocShell;
   nsCOMPtr<nsIURI> mURIToLoad;
   nsIContent *mOwnerContent; // WEAK
 public:
   // public because a callback needs these.
   nsRefPtr<nsFrameMessageManager> mMessageManager;
   nsCOMPtr<nsIInProcessContentFrameMessageManager> mChildMessageManager;
@@ -330,25 +320,23 @@ private:
   PRPackedBool mInSwap : 1;
   PRPackedBool mInShow : 1;
   PRPackedBool mHideCalled : 1;
   // True when the object is created for an element which the parser has
   // created using NS_FROM_PARSER_NETWORK flag. If the element is modified,
   // it may lose the flag.
   PRPackedBool mNetworkCreated : 1;
 
-#ifdef MOZ_IPC
   PRPackedBool mDelayRemoteDialogs : 1;
   PRPackedBool mRemoteBrowserShown : 1;
   bool mRemoteFrame;
   // XXX leaking
   nsCOMPtr<nsIObserver> mChildHost;
   RenderFrameParent* mCurrentRemoteFrame;
   TabParent* mRemoteBrowser;
-#endif
 
   // See nsIFrameLoader.idl.  Short story, if !(mRenderMode &
   // RENDER_MODE_ASYNC_SCROLL), all the fields below are ignored in
   // favor of what content tells.
   PRUint32 mRenderMode;
 };
 
 #endif
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -30,20 +30,18 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "ContentChild.h"
 #include "ContentParent.h"
-#endif
 #include "jscntxt.h"
 #include "nsFrameMessageManager.h"
 #include "nsContentUtils.h"
 #include "nsIXPConnect.h"
 #include "jsapi.h"
 #include "jsarray.h"
 #include "jsinterp.h"
 #include "nsJSUtils.h"
@@ -645,30 +643,23 @@ nsFrameScriptExecutor::LoadFrameScriptIn
   NS_NewChannel(getter_AddRefs(channel), uri);
   if (!channel) {
     return;
   }
 
   nsCOMPtr<nsIInputStream> input;
   channel->Open(getter_AddRefs(input));
   nsString dataString;
-  if (input) {
-    const PRUint32 bufferSize = 8192;
-    char buffer[bufferSize];
-    nsCString data;
-    PRUint32 avail = 0;
-    input->Available(&avail);
-    PRUint32 read = 0;
-    if (avail) {
-      while (NS_SUCCEEDED(input->Read(buffer, bufferSize, &read)) && read) {
-        data.Append(buffer, read);
-        read = 0;
-      }
+  PRUint32 avail = 0;
+  if (input && NS_SUCCEEDED(input->Available(&avail)) && avail) {
+    nsCString buffer;
+    if (NS_FAILED(NS_ReadInputStreamToString(input, buffer, avail))) {
+      return;
     }
-    nsScriptLoader::ConvertToUTF16(channel, (PRUint8*)data.get(), data.Length(),
+    nsScriptLoader::ConvertToUTF16(channel, (PRUint8*)buffer.get(), avail,
                                    EmptyString(), nsnull, dataString);
   }
 
   if (!dataString.IsEmpty()) {
     nsContentUtils::ThreadJSContextStack()->Push(mCx);
     {
       // Need to scope JSAutoRequest to happen after Push but before Pop,
       // at least for now. See bug 584673.
@@ -724,17 +715,16 @@ nsFrameScriptExecutor::Traverse(nsFrameS
   nsContentUtils::XPConnect()->NoteJSContext(tmp->mCx, cb);
 }
 
 NS_IMPL_ISUPPORTS1(nsScriptCacheCleaner, nsIObserver)
 
 nsFrameMessageManager* nsFrameMessageManager::sChildProcessManager = nsnull;
 nsFrameMessageManager* nsFrameMessageManager::sParentProcessManager = nsnull;
 
-#ifdef MOZ_IPC
 bool SendAsyncMessageToChildProcess(void* aCallbackData,
                                     const nsAString& aMessage,
                                     const nsAString& aJSON)
 {
   mozilla::dom::ContentParent* cp =
     mozilla::dom::ContentParent::GetSingleton(PR_FALSE);
   NS_WARN_IF_FALSE(cp, "No child process!");
   if (cp) {
@@ -764,58 +754,48 @@ bool SendAsyncMessageToParentProcess(voi
   mozilla::dom::ContentChild* cc =
     mozilla::dom::ContentChild::GetSingleton();
   if (cc) {
     return cc->SendAsyncMessage(nsString(aMessage), nsString(aJSON));
   }
   return true;
 }
 
-#endif
-
 nsresult
 NS_NewParentProcessMessageManager(nsIFrameMessageManager** aResult)
 {
   NS_ASSERTION(!nsFrameMessageManager::sParentProcessManager,
                "Re-creating sParentProcessManager");
-#ifdef MOZ_IPC
   NS_ENSURE_TRUE(IsChromeProcess(), NS_ERROR_NOT_AVAILABLE);
   nsFrameMessageManager* mm = new nsFrameMessageManager(PR_TRUE,
                                                         nsnull,
                                                         SendAsyncMessageToChildProcess,
                                                         nsnull,
                                                         &nsFrameMessageManager::sParentProcessManager,
                                                         nsnull,
                                                         nsnull,
                                                         PR_FALSE,
                                                         PR_TRUE);
   NS_ENSURE_TRUE(mm, NS_ERROR_OUT_OF_MEMORY);
   nsFrameMessageManager::sParentProcessManager = mm;
   return CallQueryInterface(mm, aResult);
-#else
-  return NS_ERROR_NOT_AVAILABLE;
-#endif
 }
 
 
 nsresult
 NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult)
 {
   NS_ASSERTION(!nsFrameMessageManager::sChildProcessManager,
                "Re-creating sChildProcessManager");
-#ifdef MOZ_IPC
   NS_ENSURE_TRUE(!IsChromeProcess(), NS_ERROR_NOT_AVAILABLE);
   nsFrameMessageManager* mm = new nsFrameMessageManager(PR_FALSE,
                                                         SendSyncMessageToParentProcess,
                                                         SendAsyncMessageToParentProcess,
                                                         nsnull,
                                                         &nsFrameMessageManager::sChildProcessManager,
                                                         nsnull,
                                                         nsnull,
                                                         PR_FALSE,
                                                         PR_TRUE);
   NS_ENSURE_TRUE(mm, NS_ERROR_OUT_OF_MEMORY);
   nsFrameMessageManager::sChildProcessManager = mm;
   return CallQueryInterface(mm, aResult);
-#else
-  return NS_ERROR_NOT_AVAILABLE;
-#endif
 }
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -2614,17 +2614,16 @@ nsGenericElement::RemoveAttributeNS(cons
     nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI);
 
   if (nsid == kNameSpaceID_Unknown) {
     // Unknown namespace means no attr...
 
     return NS_OK;
   }
 
-  nsAutoString tmp;
   UnsetAttr(nsid, name, PR_TRUE);
 
   return NS_OK;
 }
 
 nsresult
 nsGenericElement::GetAttributeNodeNS(const nsAString& aNamespaceURI,
                                      const nsAString& aLocalName,
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -1377,185 +1377,285 @@ GK_ATOM(_moz_math_fontstyle_, "_moz-math
 GK_ATOM(_moz_math_rowalign_, "_moz-math-rowalign")
 GK_ATOM(_moz_math_rowline_, "_moz-math-rowline")
 
 GK_ATOM(abs_, "abs")
 GK_ATOM(accent_, "accent")
 GK_ATOM(accentunder_, "accentunder")
 GK_ATOM(actiontype_, "actiontype")
 GK_ATOM(alignmentscope_, "alignmentscope")
+GK_ATOM(altimg_, "altimg")
+GK_ATOM(altimg_height_, "altimg-height")
+GK_ATOM(altimg_valign_, "altimg-valign")
+GK_ATOM(altimg_width_, "altimg-width")
 GK_ATOM(annotation_, "annotation")
+GK_ATOM(annotation_xml_, "annotation-xml")
 GK_ATOM(apply_, "apply")
+GK_ATOM(approx_, "approx")
 GK_ATOM(arccos_, "arccos")
+GK_ATOM(arccosh_, "arccosh")
+GK_ATOM(arccot_, "arccot")
+GK_ATOM(arccoth_, "arccoth")
+GK_ATOM(arccsc_, "arccsc")
+GK_ATOM(arccsch_, "arccsch")
+GK_ATOM(arcsec_, "arcsec")
+GK_ATOM(arcsech_, "arcsech")
 GK_ATOM(arcsin_, "arcsin")
+GK_ATOM(arcsinh_, "arcsinh")
 GK_ATOM(arctan_, "arctan")
+GK_ATOM(arctanh_, "arctanh")
+GK_ATOM(arg_, "arg")
 GK_ATOM(bevelled_, "bevelled")
+GK_ATOM(bind_, "bind")
 GK_ATOM(bvar_, "bvar")
+GK_ATOM(card_, "card")
+GK_ATOM(cartesianproduct_, "cartesianproduct")
+GK_ATOM(cbytes_, "cbytes")
+GK_ATOM(cd_, "cd")
+GK_ATOM(cdgroup_, "cdgroup")
+GK_ATOM(cerror_, "cerror")
+GK_ATOM(charalign_, "charalign")
 GK_ATOM(ci_, "ci")
+GK_ATOM(closure_, "closure")
 GK_ATOM(cn_, "cn")
+GK_ATOM(codomain_, "codomain")
 GK_ATOM(columnalign_, "columnalign")
+GK_ATOM(columnalignment_, "columnalignment")
 GK_ATOM(columnlines_, "columnlines")
 GK_ATOM(columnspacing_, "columnspacing")
 GK_ATOM(columnspan_, "columnspan")
 GK_ATOM(columnwidth_, "columnwidth")
+GK_ATOM(complexes_, "complexes")
 GK_ATOM(compose_, "compose")
 GK_ATOM(condition_, "condition")
 GK_ATOM(conjugate_, "conjugate")
 GK_ATOM(cos_, "cos")
 GK_ATOM(cosh_, "cosh")
 GK_ATOM(cot_, "cot")
 GK_ATOM(coth_, "coth")
+GK_ATOM(crossout_, "crossout")
 GK_ATOM(csc_, "csc")
 GK_ATOM(csch_, "csch")
+GK_ATOM(cs_, "cs")
+GK_ATOM(csymbol_, "csymbol")
+GK_ATOM(curl_, "curl")
+GK_ATOM(decimalpoint_, "decimalpoint")
+GK_ATOM(definitionURL_, "definitionURL")
 GK_ATOM(degree_, "degree")
 GK_ATOM(denomalign_, "denomalign")
 GK_ATOM(depth_, "depth")
 GK_ATOM(determinant_, "determinant")
 GK_ATOM(diff_, "diff")
 GK_ATOM(displaystyle_, "displaystyle")
+GK_ATOM(divergence_, "divergence")
 GK_ATOM(divide_, "divide")
+GK_ATOM(domain_, "domain")
+GK_ATOM(domainofapplication_, "domainofapplication")
 GK_ATOM(edge_, "edge")
+GK_ATOM(el_, "el")
+GK_ATOM(emptyset_, "emptyset")
 GK_ATOM(eq_, "eq")
 GK_ATOM(equalcolumns_, "equalcolumns")
 GK_ATOM(equalrows_, "equalrows")
+GK_ATOM(equivalent_, "equivalent")
+GK_ATOM(eulergamma_, "eulergamma")
 GK_ATOM(exists_, "exists")
 GK_ATOM(exp_, "exp")
+GK_ATOM(exponentiale_, "exponentiale")
 GK_ATOM(factorial_, "factorial")
+GK_ATOM(factorof_, "factorof")
 GK_ATOM(fence_, "fence")
 GK_ATOM(fn_, "fn")
 GK_ATOM(fontfamily_, "fontfamily")
 GK_ATOM(fontsize_, "fontsize")
 GK_ATOM(fontstyle_, "fontstyle")
 GK_ATOM(fontweight_, "fontweight")
 GK_ATOM(forall_, "forall")
 GK_ATOM(framespacing_, "framespacing")
+GK_ATOM(gcd_, "gcd")
 GK_ATOM(geq_, "geq")
 GK_ATOM(groupalign_, "groupalign")
 GK_ATOM(gt_, "gt")
 GK_ATOM(ident_, "ident")
+GK_ATOM(imaginaryi_, "imaginaryi")
+GK_ATOM(imaginary_, "imaginary")
 GK_ATOM(implies_, "implies")
-GK_ATOM(int_, "int")
+GK_ATOM(indentalignfirst_, "indentalignfirst")
+GK_ATOM(indentalign_, "indentalign")
+GK_ATOM(indentalignlast_, "indentalignlast")
+GK_ATOM(indentshiftfirst_, "indentshiftfirst")
+GK_ATOM(indentshift_, "indentshift")
+GK_ATOM(indenttarget_, "indenttarget")
+GK_ATOM(integers_, "integers")
 GK_ATOM(intersect_, "intersect")
 GK_ATOM(interval_, "interval")
+GK_ATOM(int_, "int")
 GK_ATOM(inverse_, "inverse")
 GK_ATOM(lambda_, "lambda")
+GK_ATOM(laplacian_, "laplacian")
 GK_ATOM(largeop_, "largeop")
+GK_ATOM(lcm_, "lcm")
 GK_ATOM(leq_, "leq")
 GK_ATOM(limit_, "limit")
 GK_ATOM(linebreak_, "linebreak")
+GK_ATOM(linebreakmultchar_, "linebreakmultchar")
+GK_ATOM(linebreakstyle_, "linebreakstyle")
 GK_ATOM(linethickness_, "linethickness")
 GK_ATOM(list_, "list")
 GK_ATOM(ln_, "ln")
+GK_ATOM(location_, "location")
+GK_ATOM(logbase_, "logbase")
 GK_ATOM(log_, "log")
-GK_ATOM(logbase_, "logbase")
+GK_ATOM(longdivstyle_, "longdivstyle")
 GK_ATOM(lowlimit_, "lowlimit")
 GK_ATOM(lquote_, "lquote")
 GK_ATOM(lspace_, "lspace")
 GK_ATOM(lt_, "lt")
 GK_ATOM(maction_, "maction")
 GK_ATOM(maligngroup_, "maligngroup")
+GK_ATOM(malign_, "malign")
 GK_ATOM(malignmark_, "malignmark")
+GK_ATOM(malignscope_, "malignscope")
 GK_ATOM(mathbackground_, "mathbackground")
 GK_ATOM(mathcolor_, "mathcolor")
 GK_ATOM(mathsize_, "mathsize")
 GK_ATOM(mathvariant_, "mathvariant")
 GK_ATOM(matrixrow_, "matrixrow")
 GK_ATOM(maxsize_, "maxsize")
 GK_ATOM(mean_, "mean")
 GK_ATOM(median_, "median")
 GK_ATOM(mediummathspace_, "mediummathspace")
 GK_ATOM(menclose_, "menclose")
 GK_ATOM(merror_, "merror")
 GK_ATOM(mfenced_, "mfenced")
 GK_ATOM(mfrac_, "mfrac")
+GK_ATOM(mfraction_, "mfraction")
+GK_ATOM(mglyph_, "mglyph")
 GK_ATOM(mi_, "mi")
 GK_ATOM(minlabelspacing_, "minlabelspacing")
 GK_ATOM(minsize_, "minsize")
 GK_ATOM(minus_, "minus")
 GK_ATOM(mlabeledtr_, "mlabeledtr")
+GK_ATOM(mlongdiv_, "mlongdiv")
 GK_ATOM(mmultiscripts_, "mmultiscripts")
 GK_ATOM(mn_, "mn")
+GK_ATOM(momentabout_, "momentabout")
+GK_ATOM(moment_, "moment")
 GK_ATOM(mo_, "mo")
-GK_ATOM(moment_, "moment")
+GK_ATOM(monospaced_, "monospaced")
 GK_ATOM(movablelimits_, "movablelimits")
 GK_ATOM(mover_, "mover")
 GK_ATOM(mpadded_, "mpadded")
 GK_ATOM(mphantom_, "mphantom")
 GK_ATOM(mprescripts_, "mprescripts")
 GK_ATOM(mroot_, "mroot")
 GK_ATOM(mrow_, "mrow")
+GK_ATOM(mscarries_, "mscarries")
+GK_ATOM(mscarry_, "mscarry")
+GK_ATOM(msgroup_, "msgroup")
+GK_ATOM(msline_, "msline")
 GK_ATOM(ms_, "ms")
 GK_ATOM(mspace_, "mspace")
 GK_ATOM(msqrt_, "msqrt")
+GK_ATOM(msrow_, "msrow")
+GK_ATOM(mstack_, "mstack")
 GK_ATOM(mstyle_, "mstyle")
 GK_ATOM(msub_, "msub")
 GK_ATOM(msubsup_, "msubsup")
 GK_ATOM(msup_, "msup")
 GK_ATOM(mtable_, "mtable")
 GK_ATOM(mtd_, "mtd")
 GK_ATOM(mtext_, "mtext")
 GK_ATOM(mtr_, "mtr")
 GK_ATOM(munder_, "munder")
 GK_ATOM(munderover_, "munderover")
+GK_ATOM(naturalnumbers_, "naturalnumbers")
+GK_ATOM(negativemediummathspace_, "negativemediummathspace")
+GK_ATOM(negativethickmathspace_, "negativethickmathspace")
+GK_ATOM(negativethinmathspace_, "negativethinmathspace")
+GK_ATOM(negativeverythickmathspace_, "negativeverythickmathspace")
+GK_ATOM(negativeverythinmathspace_, "negativeverythinmathspace")
+GK_ATOM(negativeveryverythickmathspace_, "negativeveryverythickmathspace")
+GK_ATOM(negativeveryverythinmathspace_, "negativeveryverythinmathspace")
 GK_ATOM(neq_, "neq")
+GK_ATOM(notanumber_, "notanumber")
 GK_ATOM(notation_, "notation")
+GK_ATOM(note_, "note")
 GK_ATOM(notin_, "notin")
 GK_ATOM(notprsubset_, "notprsubset")
 GK_ATOM(notsubset_, "notsubset")
 GK_ATOM(numalign_, "numalign")
 GK_ATOM(other_, "other")
+GK_ATOM(outerproduct_, "outerproduct")
 GK_ATOM(partialdiff_, "partialdiff")
+GK_ATOM(piece_, "piece")
+GK_ATOM(piecewise_, "piecewise")
+GK_ATOM(pi_, "pi")
 GK_ATOM(plus_, "plus")
 GK_ATOM(power_, "power")
+GK_ATOM(primes_, "primes")
 GK_ATOM(product_, "product")
 GK_ATOM(prsubset_, "prsubset")
 GK_ATOM(quotient_, "quotient")
+GK_ATOM(rationals_, "rationals")
+GK_ATOM(real_, "real")
+GK_ATOM(reals_, "reals")
 GK_ATOM(reln_, "reln")
 GK_ATOM(root_, "root")
 GK_ATOM(rowalign_, "rowalign")
 GK_ATOM(rowlines_, "rowlines")
 GK_ATOM(rowspacing_, "rowspacing")
 GK_ATOM(rquote_, "rquote")
 GK_ATOM(rspace_, "rspace")
+GK_ATOM(scalarproduct_, "scalarproduct")
+GK_ATOM(schemaLocation_, "schemaLocation")
 GK_ATOM(scriptlevel_, "scriptlevel")
 GK_ATOM(scriptminsize_, "scriptminsize")
 GK_ATOM(scriptsizemultiplier_, "scriptsizemultiplier")
+GK_ATOM(scriptsize_, "scriptsize")
 GK_ATOM(sdev_, "sdev")
-GK_ATOM(sec_, "sec")
 GK_ATOM(sech_, "sech")
+GK_ATOM(sec_, "sec")
 GK_ATOM(selection_, "selection")
+GK_ATOM(selector_, "selector")
 GK_ATOM(semantics_, "semantics")
-GK_ATOM(sep_, "sep")
 GK_ATOM(separator_, "separator")
 GK_ATOM(separators_, "separators")
+GK_ATOM(sep_, "sep")
+GK_ATOM(setdiff_, "setdiff")
 GK_ATOM(set_, "set")
-GK_ATOM(setdiff_, "setdiff")
+GK_ATOM(share_, "share")
+GK_ATOM(shift_, "shift")
 GK_ATOM(side_, "side")
+GK_ATOM(sinh_, "sinh")
 GK_ATOM(sin_, "sin")
-GK_ATOM(sinh_, "sinh")
+GK_ATOM(stackalign_, "stackalign")
 GK_ATOM(stretchy_, "stretchy")
 GK_ATOM(subscriptshift_, "subscriptshift")
 GK_ATOM(subset_, "subset")
 GK_ATOM(superscriptshift_, "superscriptshift")
 GK_ATOM(symmetric_, "symmetric")
+GK_ATOM(tanh_, "tanh")
 GK_ATOM(tan_, "tan")
-GK_ATOM(tanh_, "tanh")
 GK_ATOM(tendsto_, "tendsto")
 GK_ATOM(thickmathspace_, "thickmathspace")
 GK_ATOM(thinmathspace_, "thinmathspace")
 GK_ATOM(times_, "times")
 GK_ATOM(transpose_, "transpose")
 GK_ATOM(union_, "union")
 GK_ATOM(uplimit_, "uplimit")
-GK_ATOM(var_, "var")
+GK_ATOM(variance_, "variance")
+GK_ATOM(vectorproduct_, "vectorproduct")
 GK_ATOM(vector_, "vector")
 GK_ATOM(verythickmathspace_, "verythickmathspace")
 GK_ATOM(verythinmathspace_, "verythinmathspace")
 GK_ATOM(veryverythickmathspace_, "veryverythickmathspace")
 GK_ATOM(veryverythinmathspace_, "veryverythinmathspace")
+GK_ATOM(voffset_, "voffset")
+GK_ATOM(xref_, "xref")
 GK_ATOM(math, "math") // the only one without an underscore
 #endif
 
 #if defined(MOZ_SVG) || defined(MOZ_MATHML)
 GK_ATOM(xor_, "xor")
 #endif
 
 #ifndef DISABLE_XFORMS_HOOKS
--- a/content/canvas/src/CustomQS_Canvas2D.h
+++ b/content/canvas/src/CustomQS_Canvas2D.h
@@ -11,22 +11,24 @@
  * 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 Gecko code.
  *
  * The Initial Developer of the Original Code is
- *   Mozilla Corporation
+ * the Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2010
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com> (original author)
+ *   Ms2ger <ms2ger@gmail.com>
+ *   Yury <async.processingjs@yahoo.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of 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
@@ -34,16 +36,18 @@
  * 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 "nsDOMError.h"
 #include "nsIDOMCanvasRenderingContext2D.h"
+#include "CheckedInt.h"
+#include "nsMathUtils.h"
 
 typedef nsresult (NS_STDCALL nsIDOMCanvasRenderingContext2D::*CanvasStyleSetterType)(const nsAString &, nsISupports *);
 typedef nsresult (NS_STDCALL nsIDOMCanvasRenderingContext2D::*CanvasStyleGetterType)(nsAString &, nsISupports **, PRInt32 *);
 
 static JSBool
 Canvas2D_SetStyleHelper(JSContext *cx, JSObject *obj, jsid id, jsval *vp,
                         CanvasStyleSetterType setfunc)
 {
@@ -148,142 +152,206 @@ nsIDOMCanvasRenderingContext2D_SetFillSt
 }
 
 static JSBool
 nsIDOMCanvasRenderingContext2D_GetFillStyle(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
 {
     return Canvas2D_GetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::GetFillStyle_multi);
 }
 
+static bool
+CreateImageData(JSContext* cx,
+                uint32 w,
+                uint32 h,
+                nsIDOMCanvasRenderingContext2D* self,
+                int32 x,
+                int32 y,
+                jsval* vp)
+{
+    using mozilla::CheckedInt;
+
+    if (w == 0)
+        w = 1;
+    if (h == 0)
+        h = 1;
+
+    CheckedInt<uint32> len = CheckedInt<uint32>(w) * h * 4;
+    if (!len.valid()) {
+        return xpc_qsThrow(cx, NS_ERROR_DOM_INDEX_SIZE_ERR);
+    }
+
+    // Create the fast typed array; it's initialized to 0 by default.
+    JSObject* darray =
+      js_CreateTypedArray(cx, js::TypedArray::TYPE_UINT8_CLAMPED, len.value());
+    js::AutoObjectRooter rd(cx, darray);
+    if (!darray) {
+        return false;
+    }
+
+    if (self) {
+        js::TypedArray* tdest = js::TypedArray::fromJSObject(darray);
+
+        // make the call
+        nsresult rv =
+            self->GetImageData_explicit(x, y, w, h,
+                                        static_cast<PRUint8*>(tdest->data),
+                                        tdest->byteLength);
+        if (NS_FAILED(rv)) {
+            return xpc_qsThrowMethodFailed(cx, rv, vp);
+        }
+    }
+
+    // Do JS_NewObject after CreateTypedArray, so that gc will get
+    // triggered here if necessary
+    JSObject* result = JS_NewObject(cx, NULL, NULL, NULL);
+    js::AutoObjectRooter rr(cx, result);
+    if (!result) {
+        return false;
+    }
+
+    if (!JS_DefineProperty(cx, result, "width", INT_TO_JSVAL(w), NULL, NULL,
+                           JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT) ||
+        !JS_DefineProperty(cx, result, "height", INT_TO_JSVAL(h), NULL, NULL,
+                           JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT) ||
+        !JS_DefineProperty(cx, result, "data", OBJECT_TO_JSVAL(darray), NULL, NULL,
+                           JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT)) {
+        return false;
+    }
+
+    *vp = OBJECT_TO_JSVAL(result);
+    return true;
+}
+
+static bool
+GetImageDataDimensions(JSContext *cx, JSObject *dataObject, uint32 *width, uint32 *height)
+{
+    jsval temp;
+    int32 wi, hi;
+    
+    // Need to check that dataObject is ImageData object. That's hard for the moment 
+    // because they're just vanilla objects in our implementation.
+    // Let's guess, if the object has valid width and height then it's suitable
+    // for this operation.
+    if (!JS_GetProperty(cx, dataObject, "width", &temp) ||
+        !JS_ValueToECMAInt32(cx, temp, &wi))
+        return false;
+
+    if (!JS_GetProperty(cx, dataObject, "height", &temp) ||
+        !JS_ValueToECMAInt32(cx, temp, &hi))
+        return false;
+
+    if (wi <= 0 || hi <= 0)
+        return xpc_qsThrow(cx, NS_ERROR_DOM_INDEX_SIZE_ERR);
+
+    *width = (uint32)wi;
+    *height = (uint32)hi;
+    return true;
+}
+
 static JSBool
 nsIDOMCanvasRenderingContext2D_CreateImageData(JSContext *cx, uintN argc, jsval *vp)
 {
     XPC_QS_ASSERT_CONTEXT_OK(cx);
 
     /* Note: this doesn't need JS_THIS_OBJECT */
 
-    if (argc < 2)
+    if (argc < 1)
         return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
 
     jsval *argv = JS_ARGV(cx, vp);
 
-    int32 wi, hi;
-    if (!JS_ValueToECMAInt32(cx, argv[0], &wi) ||
-        !JS_ValueToECMAInt32(cx, argv[1], &hi))
-        return JS_FALSE;
+    if (argc == 1) {
+        // The specification asks to throw NOT_SUPPORTED if first argument is NULL,
+        // An object is expected, so throw an exception for all primitives.
+        if (JSVAL_IS_PRIMITIVE(argv[0]))
+            return xpc_qsThrow(cx, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
 
-    if (wi <= 0 || hi <= 0)
-        return xpc_qsThrow(cx, NS_ERROR_DOM_INDEX_SIZE_ERR);
+        JSObject *dataObject = JSVAL_TO_OBJECT(argv[0]);
+
+        uint32 data_width, data_height;
+        if (!GetImageDataDimensions(cx, dataObject, &data_width, &data_height))
+            return false;
 
-    uint32 w = (uint32) wi;
-    uint32 h = (uint32) hi;
+        return CreateImageData(cx, data_width, data_height, NULL, 0, 0, vp);
+    }
 
-    /* Sanity check w * h here */
-    uint32 len0 = w * h;
-    if (len0 / w != (uint32) h)
-        return xpc_qsThrow(cx, NS_ERROR_DOM_INDEX_SIZE_ERR);
+    jsdouble width, height;
+    if (!JS_ValueToNumber(cx, argv[0], &width) ||
+        !JS_ValueToNumber(cx, argv[1], &height))
+        return false;
 
-    uint32 len = len0 * 4;
-    if (len / 4 != len0)
+    if (!NS_finite(width) || !NS_finite(height))
+        return xpc_qsThrow(cx, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+
+    if (!width || !height)
         return xpc_qsThrow(cx, NS_ERROR_DOM_INDEX_SIZE_ERR);
 
-    // create the fast typed array; it's initialized to 0 by default
-    JSObject *darray = js_CreateTypedArray(cx, js::TypedArray::TYPE_UINT8_CLAMPED, len);
-    js::AutoObjectRooter rd(cx, darray);
-    if (!darray)
-        return JS_FALSE;
+    int32 wi = JS_DoubleToInt32(width);
+    int32 hi = JS_DoubleToInt32(height);
 
-    // Do JS_NewObject after CreateTypedArray, so that gc will get
-    // triggered here if necessary
-    JSObject *result = JS_NewObject(cx, NULL, NULL, NULL);
-    js::AutoObjectRooter rr(cx, result);
-    if (!result)
-        return JS_FALSE;
-
-    if (!JS_DefineProperty(cx, result, "width", INT_TO_JSVAL(w), NULL, NULL, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT) ||
-        !JS_DefineProperty(cx, result, "height", INT_TO_JSVAL(h), NULL, NULL, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT) ||
-        !JS_DefineProperty(cx, result, "data", OBJECT_TO_JSVAL(darray), NULL, NULL, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT))
-        return JS_FALSE;
-
-    *vp = OBJECT_TO_JSVAL(result);
-    return JS_TRUE;
+    uint32 w = PR_ABS(wi);
+    uint32 h = PR_ABS(hi);
+    return CreateImageData(cx, w, h, NULL, 0, 0, vp);
 }
 
 static JSBool
 nsIDOMCanvasRenderingContext2D_GetImageData(JSContext *cx, uintN argc, jsval *vp)
 {
     XPC_QS_ASSERT_CONTEXT_OK(cx);
 
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
-    nsresult rv;
-
     nsIDOMCanvasRenderingContext2D *self;
     xpc_qsSelfRef selfref;
     js::AutoValueRooter tvr(cx);
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.jsval_addr(), nsnull))
         return JS_FALSE;
 
     if (argc < 4)
         return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
 
     jsval *argv = JS_ARGV(cx, vp);
 
-    int32 x, y;
-    int32 wi, hi;
-    if (!JS_ValueToECMAInt32(cx, argv[0], &x) ||
-        !JS_ValueToECMAInt32(cx, argv[1], &y) ||
-        !JS_ValueToECMAInt32(cx, argv[2], &wi) ||
-        !JS_ValueToECMAInt32(cx, argv[3], &hi))
-        return JS_FALSE;
-
-    if (wi <= 0 || hi <= 0)
-        return xpc_qsThrow(cx, NS_ERROR_DOM_INDEX_SIZE_ERR);
+    jsdouble xd, yd, width, height;
+    if (!JS_ValueToNumber(cx, argv[0], &xd) ||
+        !JS_ValueToNumber(cx, argv[1], &yd) ||
+        !JS_ValueToNumber(cx, argv[2], &width) ||
+        !JS_ValueToNumber(cx, argv[3], &height))
+        return false;
 
-    uint32 w = (uint32) wi;
-    uint32 h = (uint32) hi;
+    if (!NS_finite(xd) || !NS_finite(yd) ||
+        !NS_finite(width) || !NS_finite(height))
+        return xpc_qsThrow(cx, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
 
-    // Sanity check w * h here
-    uint32 len0 = w * h;
-    if (len0 / w != (uint32) h)
-        return xpc_qsThrow(cx, NS_ERROR_DOM_INDEX_SIZE_ERR);
-
-    uint32 len = len0 * 4;
-    if (len / 4 != len0)
+    if (!width || !height)
         return xpc_qsThrow(cx, NS_ERROR_DOM_INDEX_SIZE_ERR);
 
-    // create the fast typed array
-    JSObject *darray = js_CreateTypedArray(cx, js::TypedArray::TYPE_UINT8_CLAMPED, len);
-    js::AutoObjectRooter rd(cx, darray);
-    if (!darray)
-        return JS_FALSE;
-
-    js::TypedArray *tdest = js::TypedArray::fromJSObject(darray);
-
-    // make the call
-    rv = self->GetImageData_explicit(x, y, w, h, (PRUint8*) tdest->data, tdest->byteLength);
-    if (NS_FAILED(rv))
-        return xpc_qsThrowMethodFailed(cx, rv, vp);
+    int32 x = JS_DoubleToInt32(xd);
+    int32 y = JS_DoubleToInt32(yd);
+    int32 wi = JS_DoubleToInt32(width);
+    int32 hi = JS_DoubleToInt32(height);
 
-    // Do JS_NewObject after CreateTypedArray, so that gc will get
-    // triggered here if necessary
-    JSObject *result = JS_NewObject(cx, NULL, NULL, NULL);
-    js::AutoObjectRooter rr(cx, result);
-    if (!result)
-        return JS_FALSE;
-
-    if (!JS_DefineProperty(cx, result, "width", INT_TO_JSVAL(w), NULL, NULL, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT) ||
-        !JS_DefineProperty(cx, result, "height", INT_TO_JSVAL(h), NULL, NULL, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT) ||
-        !JS_DefineProperty(cx, result, "data", OBJECT_TO_JSVAL(darray), NULL, NULL, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT))
-        return JS_FALSE;
-
-    *vp = OBJECT_TO_JSVAL(result);
-    return JS_TRUE;
+    // Handle negative width and height by flipping the rectangle over in the
+    // relevant direction.
+    uint32 w, h;
+    if (width < 0) {
+        w = -wi;
+        x -= w;
+    } else {
+        w = wi;
+    }
+    if (height < 0) {
+        h = -hi;
+        y -= h;
+    } else {
+        h = hi;
+    }
+    return CreateImageData(cx, w, h, self, x, y, vp);
 }
 
 static JSBool
 nsIDOMCanvasRenderingContext2D_PutImageData(JSContext *cx, uintN argc, jsval *vp)
 {
     XPC_QS_ASSERT_CONTEXT_OK(cx);
 
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
@@ -307,36 +375,25 @@ nsIDOMCanvasRenderingContext2D_PutImageD
         return xpc_qsThrow(cx, NS_ERROR_DOM_TYPE_MISMATCH_ERR);
 
     JSObject *dataObject = JSVAL_TO_OBJECT(argv[0]);
     int32 x, y;
     if (!JS_ValueToECMAInt32(cx, argv[1], &x) ||
         !JS_ValueToECMAInt32(cx, argv[2], &y))
         return JS_FALSE;
 
-    int32 wi, hi;
+    uint32 w, h;
     JSObject *darray;
 
     // grab width, height, and the dense array from the dataObject
     js::AutoValueRooter tv(cx);
 
-    if (!JS_GetProperty(cx, dataObject, "width", tv.jsval_addr()) ||
-        !JS_ValueToECMAInt32(cx, tv.jsval_value(), &wi))
-        return JS_FALSE;
-
-    if (!JS_GetProperty(cx, dataObject, "height", tv.jsval_addr()) ||
-        !JS_ValueToECMAInt32(cx, tv.jsval_value(), &hi))
+    if (!GetImageDataDimensions(cx, dataObject, &w, &h))
         return JS_FALSE;
 
-    if (wi <= 0 || hi <= 0)
-        return xpc_qsThrow(cx, NS_ERROR_DOM_INDEX_SIZE_ERR);
-
-    uint32 w = (uint32) wi;
-    uint32 h = (uint32) hi;
-
     // the optional dirty rect
     PRBool hasDirtyRect = PR_FALSE;
     int32 dirtyX = 0,
           dirtyY = 0,
           dirtyWidth = w,
           dirtyHeight = h;
 
     if (argc >= 7) {
--- a/content/canvas/src/Makefile.in
+++ b/content/canvas/src/Makefile.in
@@ -50,24 +50,19 @@ EXPORTS = \
 	CustomQS_Canvas2D.h \
 	CustomQS_WebGL.h \
 	$(NULL)
 
 CPPSRCS	= \
 	CanvasImageCache.cpp \
 	CanvasUtils.cpp \
 	nsCanvasRenderingContext2D.cpp \
-	$(NULL)
-
-ifdef MOZ_IPC
-CPPSRCS += \
 	DocumentRendererParent.cpp \
 	DocumentRendererChild.cpp \
 	$(NULL)
-endif
 
 # Canvas 3D Pieces
 
 ifdef MOZ_WEBGL
 
 CPPSRCS += \
 	WebGLContext.cpp \
 	WebGLContextGL.cpp \
--- a/content/canvas/src/nsCanvasRenderingContext2D.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp
@@ -33,42 +33,34 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
-#  include "base/basictypes.h"
-#endif
+#include "base/basictypes.h"
 
 #include "nsIDOMXULElement.h"
 
-#ifdef _MSC_VER
-#define _USE_MATH_DEFINES
-#endif
-#include <math.h>
-#if defined(XP_WIN) || defined(XP_OS2)
-#include <float.h>
-#endif
-
 #include "prmem.h"
 #include "prenv.h"
 
 #include "nsIServiceManager.h"
+#include "nsMathUtils.h"
 
 #include "nsContentUtils.h"
 
 #include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 #include "nsIDOMCanvasRenderingContext2D.h"
 #include "nsICanvasRenderingContextInternal.h"
 #include "nsHTMLCanvasElement.h"
+#include "nsSVGEffects.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIVariant.h"
 
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIFrame.h"
 #include "nsDOMError.h"
 #include "nsIScriptError.h"
@@ -115,61 +107,33 @@
 #include "nsFrameLoader.h"
 #include "nsBidiPresUtils.h"
 #include "Layers.h"
 #include "CanvasUtils.h"
 #include "nsIMemoryReporter.h"
 #include "nsStyleUtil.h"
 #include "CanvasImageCache.h"
 
-#ifdef MOZ_IPC
-#  include <algorithm>
-#  include "mozilla/dom/ContentParent.h"
-#  include "mozilla/ipc/PDocumentRendererParent.h"
-#  include "mozilla/dom/PBrowserParent.h"
-#  include "mozilla/ipc/DocumentRendererParent.h"
+#include <algorithm>
+#include "mozilla/dom/ContentParent.h"
+#include "mozilla/ipc/PDocumentRendererParent.h"
+#include "mozilla/dom/PBrowserParent.h"
+#include "mozilla/ipc/DocumentRendererParent.h"
 
 // windows.h (included by chromium code) defines this, in its infinite wisdom
-#  undef DrawText
+#undef DrawText
 
 using namespace mozilla::ipc;
-#endif
-
-#ifdef MOZ_SVG
-#include "nsSVGEffects.h"
-#endif
 
 using namespace mozilla;
 using namespace mozilla::layers;
 using namespace mozilla::dom;
 
-#ifndef M_PI
-#define M_PI		3.14159265358979323846
-#define M_PI_2		1.57079632679489661923
-#endif
-
 /* Float validation stuff */
-
-static inline bool
-DoubleIsFinite(double d)
-{
-#ifdef WIN32
-    // NOTE: '!!' casts an int to bool without spamming MSVC warning C4800.
-    return !!_finite(d);
-#else
-    return finite(d);
-#endif
-}
-
-#define VALIDATE(_f)  if (!DoubleIsFinite(_f)) return PR_FALSE
-
-/* These must take doubles as args, because JSDOUBLE_IS_FINITE expects
- * to take the address of its argument; we can't cast/convert in the
- * macro.
- */
+#define VALIDATE(_f)  if (!NS_finite(_f)) return PR_FALSE
 
 static PRBool FloatValidate (double f1) {
     VALIDATE(f1);
     return PR_TRUE;
 }
 
 static PRBool FloatValidate (double f1, double f2) {
     VALIDATE(f1); VALIDATE(f2);
@@ -1232,33 +1196,29 @@ nsCanvasRenderingContext2D::SetIsOpaque(
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::SetIsIPC(PRBool isIPC)
 {
-#ifdef MOZ_IPC
     if (isIPC == mIPC)
         return NS_OK;
 
     mIPC = isIPC;
 
     if (mValid) {
         /* If we've already been created, let SetDimensions take care of
          * recreating our surface
          */
         return SetDimensions(mWidth, mHeight);
     }
 
     return NS_OK;
-#else
-    return NS_ERROR_NOT_IMPLEMENTED;
-#endif
 }
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::Render(gfxContext *ctx, gfxPattern::GraphicsFilter aFilter)
 {
     nsresult rv = NS_OK;
 
     if (!mValid || !mSurface ||
@@ -1425,27 +1385,27 @@ nsCanvasRenderingContext2D::Rotate(float
     mThebes->Rotate(angle);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::Translate(float x, float y)
 {
     if (!FloatValidate(x,y))
-        return NS_ERROR_DOM_SYNTAX_ERR;
+        return NS_OK;
 
     mThebes->Translate(gfxPoint(x, y));
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::Transform(float m11, float m12, float m21, float m22, float dx, float dy)
 {
     if (!FloatValidate(m11,m12,m21,m22,dx,dy))
-        return NS_ERROR_DOM_SYNTAX_ERR;
+        return NS_OK;
 
     gfxMatrix matrix(m11, m12, m21, m22, dx, dy);
     mThebes->Multiply(matrix);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -1652,16 +1612,19 @@ nsCanvasRenderingContext2D::CreateLinear
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::CreateRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1,
                                                  nsIDOMCanvasGradient **_retval)
 {
     if (!FloatValidate(x0,y0,r0,x1,y1,r1))
         return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
 
+    if (r0 < 0.0 || r1 < 0.0)
+        return NS_ERROR_DOM_INDEX_SIZE_ERR;
+
     nsRefPtr<gfxPattern> gradpat = new gfxPattern(x0, y0, r0, x1, y1, r1);
     if (!gradpat)
         return NS_ERROR_OUT_OF_MEMORY;
 
     nsRefPtr<nsIDOMCanvasGradient> grad = new nsCanvasGradient(gradpat);
     if (!grad)
         return NS_ERROR_OUT_OF_MEMORY;
 
@@ -1669,16 +1632,19 @@ nsCanvasRenderingContext2D::CreateRadial
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::CreatePattern(nsIDOMHTMLElement *image,
                                           const nsAString& repeat,
                                           nsIDOMCanvasPattern **_retval)
 {
+    if (!image) {
+        return NS_ERROR_DOM_TYPE_MISMATCH_ERR;
+    }
     gfxPattern::GraphicsExtend extend;
 
     if (repeat.IsEmpty() || repeat.EqualsLiteral("repeat")) {
         extend = gfxPattern::EXTEND_REPEAT;
     } else if (repeat.EqualsLiteral("repeat-x")) {
         // XX
         extend = gfxPattern::EXTEND_REPEAT;
     } else if (repeat.EqualsLiteral("repeat-y")) {
@@ -2067,39 +2033,39 @@ nsCanvasRenderingContext2D::Clip()
     mThebes->Clip();
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::MoveTo(float x, float y)
 {
     if (!FloatValidate(x,y))
-        return NS_ERROR_DOM_SYNTAX_ERR;
+        return NS_OK;
 
     mHasPath = PR_TRUE;
     mThebes->MoveTo(gfxPoint(x, y));
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::LineTo(float x, float y)
 {
     if (!FloatValidate(x,y))
-        return NS_ERROR_DOM_SYNTAX_ERR;
+        return NS_OK;
 
     mHasPath = PR_TRUE;
     mThebes->LineTo(gfxPoint(x, y));
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::QuadraticCurveTo(float cpx, float cpy, float x, float y)
 {
     if (!FloatValidate(cpx,cpy,x,y))
-        return NS_ERROR_DOM_SYNTAX_ERR;
+        return NS_OK;
 
     // we will always have a current point, since beginPath forces
     // a moveto(0,0)
     gfxPoint c = mThebes->CurrentPoint();
     gfxPoint p(x,y);
     gfxPoint cp(cpx, cpy);
 
     mHasPath = PR_TRUE;
@@ -2201,17 +2167,17 @@ nsCanvasRenderingContext2D::Arc(float x,
         mThebes->Arc(p, r, startAngle, endAngle);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::Rect(float x, float y, float w, float h)
 {
     if (!FloatValidate(x,y,w,h))
-        return NS_ERROR_DOM_SYNTAX_ERR;
+        return NS_OK;
 
     mHasPath = PR_TRUE;
     mThebes->Rectangle(gfxRect(x, y, w, h));
     return NS_OK;
 }
 
 //
 // text
@@ -3360,17 +3326,19 @@ bitblt(gfxImageSurface *s, int src_x, in
 //   -- render the region defined by (sx,sy,sw,wh) in image-local space into the region (dx,dy,dw,dh) on the canvas
 
 NS_IMETHODIMP
 nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
                                       float a2, float a3, float a4, float a5,
                                       float a6, float a7, float a8,
                                       PRUint8 optional_argc)
 {
-    NS_ENSURE_ARG(imgElt);
+    if (!imgElt) {
+        return NS_ERROR_DOM_TYPE_MISMATCH_ERR;
+    }
 
     double sx,sy,sw,sh;
     double dx,dy,dw,dh;
 
     gfxMatrix matrix;
     nsRefPtr<gfxPattern> pattern;
     gfxIntSize imgSize;
     nsRefPtr<gfxASurface> imgsurf =
@@ -3762,17 +3730,16 @@ nsCanvasRenderingContext2D::AsyncDrawXUL
     nsCOMPtr<nsIFrameLoaderOwner> loaderOwner = do_QueryInterface(aElem);
     if (!loaderOwner)
         return NS_ERROR_FAILURE;
 
     nsRefPtr<nsFrameLoader> frameloader = loaderOwner->GetFrameLoader();
     if (!frameloader)
         return NS_ERROR_FAILURE;
 
-#ifdef MOZ_IPC
     PBrowserParent *child = frameloader->GetRemoteBrowser();
     if (!child) {
         nsCOMPtr<nsIDOMWindow> window =
             do_GetInterface(frameloader->GetExistingDocShell());
         if (!window)
             return NS_ERROR_FAILURE;
 
         return DrawWindow(window, aX, aY, aW, aH, aBGColor, flags);
@@ -3810,24 +3777,16 @@ nsCanvasRenderingContext2D::AsyncDrawXUL
 
         DocumentRendererParent *docrender =
             static_cast<DocumentRendererParent *>(pdocrender);
 
         docrender->SetCanvasContext(this, mThebes);
     }
 
     return NS_OK;
-#else
-    nsCOMPtr<nsIDOMWindow> window =
-        do_GetInterface(frameloader->GetExistingDocShell());
-    if (!window)
-        return NS_ERROR_FAILURE;
-
-    return DrawWindow(window, aX, aY, aW, aH, aBGColor, flags);
-#endif
 }
 
 //
 // device pixel getting/setting
 //
 
 void
 nsCanvasRenderingContext2D::EnsureUnpremultiplyTable() {
--- a/content/canvas/test/test_canvas.html
+++ b/content/canvas/test/test_canvas.html
@@ -3492,17 +3492,17 @@ isPixel(ctx, 55,25, 0,255,0,255, 2);
 
 function test_2d_drawImage_null() {
 
 var canvas = document.getElementById('c121');
 var ctx = canvas.getContext('2d');
 
 var _thrown = undefined; try {
   ctx.drawImage(null, 0, 0);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
 
 
 }
 </script>
 
 <!-- [[[ test_2d.drawImage.outsidesource.html ]]] -->
 
 <p>Canvas test: 2d.drawImage.outsidesource</p>
@@ -3664,17 +3664,17 @@ function test_2d_drawImage_wrongtype() {
 
 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
 var canvas = document.getElementById('c127');
 var ctx = canvas.getContext('2d');
 
 var _thrown = undefined; try {
   ctx.drawImage(undefined, 0, 0);
-} catch (e) { _thrown = e }; ok(_thrown && _thrown.result == Components.results.NS_ERROR_INVALID_ARG, "should throw NS_ERROR_INVALID_ARG");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
 var _thrown = undefined; try {
   ctx.drawImage(0, 0, 0);
 } catch (e) { _thrown = e }; ok(_thrown && _thrown.result == Components.results.NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL, "should throw NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL");
 var _thrown = undefined; try {
   ctx.drawImage("", 0, 0);
 } catch (e) { _thrown = e }; ok(_thrown && _thrown.result == Components.results.NS_ERROR_XPC_BAD_CONVERT_JS, "should throw NS_ERROR_XPC_BAD_CONVERT_JS");
 var _thrown = undefined; try {
   ctx.drawImage(document.createElement('p'), 0, 0);
@@ -6642,23 +6642,23 @@ isPixel(ctx, 98,48, 0,255,0,255, 0);
 
 function test_2d_gradient_radial_negative() {
 
 var canvas = document.getElementById('c243');
 var ctx = canvas.getContext('2d');
 
 var _thrown = undefined; try {
   ctx.createRadialGradient(0, 0, -0.1, 0, 0, 1);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
 var _thrown = undefined; try {
   ctx.createRadialGradient(0, 0, 1, 0, 0, -0.1);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
 var _thrown = undefined; try {
   ctx.createRadialGradient(0, 0, -0.1, 0, 0, -0.1);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
 
 
 }
 </script>
 
 <!-- [[[ test_2d.gradient.radial.nonfinite.html ]]] -->
 
 <p>Canvas test: 2d.gradient.radial.nonfinite</p>
@@ -7225,16 +7225,34 @@ var canvas = document.getElementById('c2
 var ctx = canvas.getContext('2d');
 
 ok(ctx.createImageData(1, 1) !== null, "ctx.createImageData(1, 1) !== null");
 
 
 }
 </script>
 
+<!-- [[[ test_2d.imageData.create1.basic.html ]]] -->
+
+<p>Canvas test: 2d.imageData.create1.basic - bug 630040</p>
+<!-- Testing: createImageData(imgdata) exists and returns something -->
+<canvas id="c254a" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
+<script>
+
+function test_2d_imageData_create1_basic() {
+
+var canvas = document.getElementById('c254a');
+var ctx = canvas.getContext('2d');
+
+ok(ctx.createImageData(ctx.createImageData(1, 1)) != null, "ctx.createImageData(ctx.createImageData(1, 1)) != null");
+
+
+}
+</script>
+
 <!-- [[[ test_2d.imageData.create.initial.html ]]] -->
 
 <p>Canvas test: 2d.imageData.create.initial - bug 433004</p>
 <!-- Testing: createImageData() returns transparent black data of the right size -->
 <canvas id="c255" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
 <script>
 
 function test_2d_imageData_create_initial() {
@@ -7251,16 +7269,45 @@ for (var i = 0; i < imgdata.data.length;
     if (imgdata.data[i] !== 0)
         isTransparentBlack = false;
 ok(isTransparentBlack, "isTransparentBlack");
 
 
 }
 </script>
 
+<!-- [[[ test_2d.imageData.create1.initial.html ]]] -->
+
+<p>Canvas test: 2d.imageData.create1.initial - bug 630040</p>
+<!-- Testing: createImageData(imgdata) returns transparent black data of the right size -->
+<canvas id="c255a" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
+<script>
+
+function test_2d_imageData_create1_initial() {
+
+var canvas = document.getElementById('c255a');
+var ctx = canvas.getContext('2d');
+
+ctx.fillStyle = '#0f0';
+ctx.fillRect(0, 0, 100, 50);
+var imgdata1 = ctx.getImageData(0, 0, 10, 20);
+var imgdata2 = ctx.createImageData(imgdata1);
+ok(imgdata2.data.length == imgdata1.data.length, "imgdata2.data.length == imgdata1.data.length");
+ok(imgdata2.width == imgdata1.width, "imgdata2.width == imgdata1.width");
+ok(imgdata2.height == imgdata1.height, "imgdata2.height == imgdata1.height");
+var isTransparentBlack = true;
+for (var i = 0; i < imgdata2.data.length; ++i)
+    if (imgdata2.data[i] !== 0)
+        isTransparentBlack = false;
+ok(isTransparentBlack, "isTransparentBlack");
+
+
+}
+</script>
+
 <!-- [[[ test_2d.imageData.create.large.html ]]] -->
 
 <p>Canvas test: 2d.imageData.create.large - bug 433004</p>
 <!-- Testing: createImageData() works for sizes much larger than the canvas -->
 <canvas id="c256" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
 <script>
 
 function test_2d_imageData_create_large() {
@@ -7305,17 +7352,17 @@ var imgdata3 = ctx.createImageData(10, -
 var imgdata4 = ctx.createImageData(-10, -20);
 ok(imgdata1.data.length == imgdata2.data.length, "imgdata1.data.length == imgdata2.data.length");
 ok(imgdata2.data.length == imgdata3.data.length, "imgdata2.data.length == imgdata3.data.length");
 ok(imgdata3.data.length == imgdata4.data.length, "imgdata3.data.length == imgdata4.data.length");
 
 } catch (e) {
     _thrown_outer = true;
 }
-todo(!_thrown_outer, 'should not throw exception');
+ok(!_thrown_outer, 'should not throw exception');
 
 
 }
 </script>
 
 <!-- [[[ test_2d.imageData.create.nonfinite.html ]]] -->
 
 <p>Canvas test: 2d.imageData.create.nonfinite - bug 433004</p>
@@ -7325,35 +7372,56 @@ todo(!_thrown_outer, 'should not throw e
 
 function test_2d_imageData_create_nonfinite() {
 
 var canvas = document.getElementById('c258');
 var ctx = canvas.getContext('2d');
 
 var _thrown = undefined; try {
   ctx.createImageData(Infinity, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.createImageData(-Infinity, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.createImageData(NaN, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.createImageData(10, Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.createImageData(10, -Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.createImageData(10, NaN);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.createImageData(Infinity, Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.createImageData({valueOf:function() Infinity}, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.createImageData({valueOf:function() -Infinity}, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.createImageData({valueOf:function() NaN}, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.createImageData(10, {valueOf:function() Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.createImageData(10, {valueOf:function() -Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.createImageData(10, {valueOf:function() NaN});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.createImageData({valueOf:function() Infinity}, {valueOf:function() Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 
 
 }
 </script>
 
 <!-- [[[ test_2d.imageData.create.round.html ]]] -->
 
 <p>Canvas test: 2d.imageData.create.round - bug 433004</p>
@@ -7400,17 +7468,17 @@ var isTransparentBlack = true;
 for (var i = 0; i < imgdata.data.length; ++i)
     if (imgdata.data[i] !== 0)
         isTransparentBlack = false;
 ok(isTransparentBlack, "isTransparentBlack");
 
 } catch (e) {
     _thrown_outer = true;
 }
-todo(!_thrown_outer, 'should not throw exception');
+ok(!_thrown_outer, 'should not throw exception');
 
 
 }
 </script>
 
 <!-- [[[ test_2d.imageData.create.type.html ]]] -->
 
 <p>Canvas test: 2d.imageData.create.type - bug 433004</p>
@@ -7438,16 +7506,48 @@ ok(imgdata.data.thisImplementsCanvasPixe
     _thrown_outer = true;
 }
 todo(!_thrown_outer, 'should not throw exception');
 
 
 }
 </script>
 
+<!-- [[[ test_2d.imageData.create1.type.html ]]] -->
+
+<p>Canvas test: 2d.imageData.create1.type - bug 630040</p>
+<!-- Testing: createImageData(imgdata) returns an ImageData object containing a CanvasPixelArray object -->
+<canvas id="c261a" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
+<script>
+
+function test_2d_imageData_create1_type() {
+
+var canvas = document.getElementById('c261a');
+var ctx = canvas.getContext('2d');
+
+var _thrown_outer = false;
+try {
+
+todo(window.ImageData !== undefined, "window.ImageData !== undefined");
+todo(window.CanvasPixelArray !== undefined, "window.CanvasPixelArray !== undefined");
+window.ImageData.prototype.thisImplementsImageData = true;
+window.CanvasPixelArray.prototype.thisImplementsCanvasPixelArray = true;
+var imgdata = ctx.createImageData(ctx.createImageData(1, 1));
+todo(imgdata.thisImplementsImageData, "imgdata.thisImplementsImageData");
+todo(imgdata.data.thisImplementsCanvasPixelArray, "imgdata.data.thisImplementsCanvasPixelArray");
+
+} catch (e) {
+    _thrown_outer = true;
+}
+todo(!_thrown_outer, 'should not throw exception');
+
+
+}
+</script>
+
 <!-- [[[ test_2d.imageData.create.zero.html ]]] -->
 
 <p>Canvas test: 2d.imageData.create.zero - bug 433004</p>
 <!-- Testing: createImageData() throws INDEX_SIZE_ERR if size is zero -->
 <canvas id="c262" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
 <script>
 
 function test_2d_imageData_create_zero() {
@@ -7464,16 +7564,36 @@ var _thrown = undefined; try {
 var _thrown = undefined; try {
   ctx.createImageData(0, 0);
 } catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INDEX_SIZE_ERR, "should throw INDEX_SIZE_ERR");
 
 
 }
 </script>
 
+<!-- [[[ test_2d.imageData.create1.zero.html ]]] -->
+
+<p>Canvas test: 2d.imageData.create1.zero - bug 630040</p>
+<!-- Testing: createImageData(null) throws NOT_SUPPORTED_ERR -->
+<canvas id="c262a" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
+<script>
+
+function test_2d_imageData_create1_zero() {
+
+var canvas = document.getElementById('c262a');
+var ctx = canvas.getContext('2d');
+
+var _thrown = undefined; try {
+  ctx.createImageData(null);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+
+
+}
+</script>
+
 <!-- [[[ test_2d.imageData.get.basic.html ]]] -->
 
 <p>Canvas test: 2d.imageData.get.basic</p>
 <!-- Testing: getImageData() exists and returns something -->
 <canvas id="c263" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
 <script>
 
 function test_2d_imageData_get_basic() {
@@ -7525,83 +7645,152 @@ ok(imgdata2.data[2] === 255, "imgdata2.d
 
 function test_2d_imageData_get_nonfinite() {
 
 var canvas = document.getElementById('c265');
 var ctx = canvas.getContext('2d');
 
 var _thrown = undefined; try {
   ctx.getImageData(Infinity, 10, 10, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(-Infinity, 10, 10, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(NaN, 10, 10, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, Infinity, 10, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, -Infinity, 10, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, NaN, 10, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, 10, Infinity, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, 10, -Infinity, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, 10, NaN, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, 10, 10, Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, 10, 10, -Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, 10, 10, NaN);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(Infinity, Infinity, 10, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(Infinity, Infinity, Infinity, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(Infinity, Infinity, Infinity, Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(Infinity, Infinity, 10, Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(Infinity, 10, Infinity, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(Infinity, 10, Infinity, Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(Infinity, 10, 10, Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, Infinity, Infinity, 10);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, Infinity, Infinity, Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, Infinity, 10, Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 var _thrown = undefined; try {
   ctx.getImageData(10, 10, Infinity, Infinity);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData({valueOf:function() Infinity}, 10, 10, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData({valueOf:function() -Infinity}, 10, 10, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData({valueOf:function() NaN}, 10, 10, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, {valueOf:function() Infinity}, 10, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, {valueOf:function() -Infinity}, 10, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, {valueOf:function() NaN}, 10, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, 10, {valueOf:function() Infinity}, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, 10, {valueOf:function() -Infinity}, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, 10, {valueOf:function() NaN}, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, 10, 10, {valueOf:function() Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, 10, 10, {valueOf:function() -Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, 10, 10, {valueOf:function() NaN});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData({valueOf:function() Infinity}, {valueOf:function() Infinity}, 10, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData({valueOf:function() Infinity}, {valueOf:function() Infinity}, {valueOf:function() Infinity}, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData({valueOf:function() Infinity}, {valueOf:function() Infinity}, {valueOf:function() Infinity}, {valueOf:function() Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData({valueOf:function() Infinity}, {valueOf:function() Infinity}, 10, {valueOf:function() Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData({valueOf:function() Infinity}, 10, {valueOf:function() Infinity}, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData({valueOf:function() Infinity}, 10, {valueOf:function() Infinity}, {valueOf:function() Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData({valueOf:function() Infinity}, 10, 10, {valueOf:function() Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, {valueOf:function() Infinity}, {valueOf:function() Infinity}, 10);
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, {valueOf:function() Infinity}, {valueOf:function() Infinity}, {valueOf:function() Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, {valueOf:function() Infinity}, 10, {valueOf:function() Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+var _thrown = undefined; try {
+  ctx.getImageData(10, 10, {valueOf:function() Infinity}, {valueOf:function() Infinity});
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 
 
 }
 </script>
 
 <!-- [[[ test_2d.imageData.get.nonpremul.html ]]] -->
 
 <p>Canvas test: 2d.imageData.get.nonpremul</p>
@@ -7763,25 +7952,29 @@ var ctx = canvas.getContext('2d');
 var _thrown_outer = false;
 try {
 
 ctx.fillStyle = '#000';
 ctx.fillRect(0, 0, 100, 50);
 ctx.fillStyle = '#fff';
 ctx.fillRect(20, 10, 60, 10);
 
-var imgdata1 = ctx.getImageData(85, 25, -10, -10);
-ok(imgdata1.data[0] === 255, "imgdata1.data[\""+(0)+"\"] === 255");
-ok(imgdata1.data[1] === 255, "imgdata1.data[\""+(1)+"\"] === 255");
-ok(imgdata1.data[2] === 255, "imgdata1.data[\""+(2)+"\"] === 255");
-ok(imgdata1.data[3] === 255, "imgdata1.data[\""+(3)+"\"] === 255");
-ok(imgdata1.data[imgdata1.data.length-4+0] === 0, "imgdata1.data[imgdata1.data.length-4+0] === 0");
-ok(imgdata1.data[imgdata1.data.length-4+1] === 0, "imgdata1.data[imgdata1.data.length-4+1] === 0");
-ok(imgdata1.data[imgdata1.data.length-4+2] === 0, "imgdata1.data[imgdata1.data.length-4+2] === 0");
-ok(imgdata1.data[imgdata1.data.length-4+3] === 255, "imgdata1.data[imgdata1.data.length-4+3] === 255");
+try {
+  var imgdata1 = ctx.getImageData(85, 25, -10, -10);
+  ok(imgdata1.data[0] === 255, "imgdata1.data[\""+(0)+"\"] === 255");
+  ok(imgdata1.data[1] === 255, "imgdata1.data[\""+(1)+"\"] === 255");
+  ok(imgdata1.data[2] === 255, "imgdata1.data[\""+(2)+"\"] === 255");
+  ok(imgdata1.data[3] === 255, "imgdata1.data[\""+(3)+"\"] === 255");
+  ok(imgdata1.data[imgdata1.data.length-4+0] === 0, "imgdata1.data[imgdata1.data.length-4+0] === 0");
+  ok(imgdata1.data[imgdata1.data.length-4+1] === 0, "imgdata1.data[imgdata1.data.length-4+1] === 0");
+  ok(imgdata1.data[imgdata1.data.length-4+2] === 0, "imgdata1.data[imgdata1.data.length-4+2] === 0");
+  ok(imgdata1.data[imgdata1.data.length-4+3] === 255, "imgdata1.data[imgdata1.data.length-4+3] === 255");
+} catch (e) {
+  ok(false, "Unexpected exception in first part of test_2d_imageData_get_source_negative()", e);
+}
 
 var imgdata2 = ctx.getImageData(0, 0, -1, -1);
 ok(imgdata2.data[0] === 0, "imgdata2.data[\""+(0)+"\"] === 0");
 ok(imgdata2.data[1] === 0, "imgdata2.data[\""+(1)+"\"] === 0");
 ok(imgdata2.data[2] === 0, "imgdata2.data[\""+(2)+"\"] === 0");
 ok(imgdata2.data[3] === 0, "imgdata2.data[\""+(3)+"\"] === 0");
 
 } catch (e) {
@@ -7883,17 +8076,17 @@ try {
 var imgdata = ctx.getImageData(0, 0, 0.0001, 0.0001);
 ok(imgdata.data.length == imgdata.width*imgdata.height*4, "imgdata.data.length == imgdata.width*imgdata.height*4");
 ok(imgdata.width == 1, "imgdata.width == 1");
 ok(imgdata.height == 1, "imgdata.height == 1");
 
 } catch (e) {
     _thrown_outer = true;
 }
-todo(!_thrown_outer, 'should not throw exception');
+ok(!_thrown_outer, 'should not throw exception');
 
 
 }
 </script>
 
 <!-- [[[ test_2d.imageData.get.type.html ]]] -->
 
 <p>Canvas test: 2d.imageData.get.type</p>
@@ -10453,17 +10646,17 @@ var _thrown = undefined; try {
 // or too few for another overload, or too many for another
 // overload - what should happen?
 if (ctx.createImageData) {
     var _thrown = undefined; try {
   ctx.createImageData();
 } catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
     var _thrown = undefined; try {
   ctx.createImageData(1);
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
 }
 if (ctx.getImageData) {
     var _thrown = undefined; try {
   ctx.getImageData();
 } catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
     var _thrown = undefined; try {
   ctx.getImageData(0);
 } catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.NOT_SUPPORTED_ERR, "should throw NOT_SUPPORTED_ERR");
@@ -13215,17 +13408,17 @@ ctx.lineTo(0, 50);
 ctx.fillStyle = '#0f0';
 ctx.fill();
 isPixel(ctx, 50,25, 0,255,0,255, 0);
 isPixel(ctx, 90,45, 0,255,0,255, 0);
 
 } catch (e) {
     _thrown_outer = true;
 }
-todo(!_thrown_outer, 'should not throw exception');
+ok(!_thrown_outer, 'should not throw exception');
 
 
 }
 </script>
 
 <!-- [[[ test_2d.path.moveTo.basic.html ]]] -->
 
 <p>Canvas test: 2d.path.moveTo.basic</p>
@@ -13330,17 +13523,17 @@ ctx.lineTo(100, 50);
 ctx.lineTo(0, 50);
 ctx.fillStyle = '#0f0';
 ctx.fill();
 isPixel(ctx, 50,25, 0,255,0,255, 0);
 
 } catch (e) {
     _thrown_outer = true;
 }
-todo(!_thrown_outer, 'should not throw exception');
+ok(!_thrown_outer, 'should not throw exception');
 
 
 }
 </script>
 
 <!-- [[[ test_2d.path.quadraticCurveTo.basic.html ]]] -->
 
 <p>Canvas test: 2d.path.quadraticCurveTo.basic</p>
@@ -13436,17 +13629,17 @@ ctx.lineTo(0, 50);
 ctx.fillStyle = '#0f0';
 ctx.fill();
 isPixel(ctx, 50,25, 0,255,0,255, 0);
 isPixel(ctx, 90,45, 0,255,0,255, 0);
 
 } catch (e) {
     _thrown_outer = true;
 }
-todo(!_thrown_outer, 'should not throw exception');
+ok(!_thrown_outer, 'should not throw exception');
 
 
 }
 </script>
 
 <!-- [[[ test_2d.path.quadraticCurveTo.scaled.html ]]] -->
 
 <p>Canvas test: 2d.path.quadraticCurveTo.scaled</p>
@@ -13700,17 +13893,17 @@ ctx.lineTo(0, 50);
 ctx.fillStyle = '#0f0';
 ctx.fill();
 isPixel(ctx, 50,25, 0,255,0,255, 0);
 isPixel(ctx, 90,45, 0,255,0,255, 0);
 
 } catch (e) {
     _thrown_outer = true;
 }
-todo(!_thrown_outer, 'should not throw exception');
+ok(!_thrown_outer, 'should not throw exception');
 
 
 }
 </script>
 
 <!-- [[[ test_2d.path.rect.selfintersect.html ]]] -->
 
 <p>Canvas test: 2d.path.rect.selfintersect</p>
@@ -14763,17 +14956,17 @@ var _thrown = undefined; try {
 
 function test_2d_pattern_image_null() {
 
 var canvas = document.getElementById('c467');
 var ctx = canvas.getContext('2d');
 
 var _thrown = undefined; try {
   ctx.createPattern(null, 'repeat');
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
 
 
 }
 </script>
 
 <!-- [[[ test_2d.pattern.image.string.html ]]] -->
 
 <p>Canvas test: 2d.pattern.image.string</p>
@@ -14801,17 +14994,17 @@ var _thrown = undefined; try {
 
 function test_2d_pattern_image_undefined() {
 
 var canvas = document.getElementById('c469');
 var ctx = canvas.getContext('2d');
 
 var _thrown = undefined; try {
   ctx.createPattern(undefined, 'repeat');
-} catch (e) { _thrown = e }; todo(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
+} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.TYPE_MISMATCH_ERR, "should throw TYPE_MISMATCH_ERR");
 
 
 }
 </script>
 
 <!-- [[[ test_2d.pattern.modify.canvas1.html ]]] -->
 
 <p>Canvas test: 2d.pattern.modify.canvas1</p>
@@ -18911,17 +19104,17 @@ ctx.transform(0, 0, 0, 0, Infinity, Infi
 ctx.fillStyle = '#0f0';
 ctx.fillRect(-100, -10, 100, 50);
 
 isPixel(ctx, 50,25, 0,255,0,255, 0);
 
 } catch (e) {
     _thrown_outer = true;
 }
-todo(!_thrown_outer, 'should not throw exception');
+ok(!_thrown_outer, 'should not throw exception');
 
 
 }
 </script>
 
 <!-- [[[ test_2d.transformation.transform.skewed.html ]]] -->
 
 <p>Canvas test: 2d.transformation.transform.skewed</p>
@@ -19025,17 +19218,17 @@ ctx.translate(Infinity, Infinity);
 ctx.fillStyle = '#0f0';
 ctx.fillRect(-100, -10, 100, 50);
 
 isPixel(ctx, 50,25, 0,255,0,255, 0);
 
 } catch (e) {
     _thrown_outer = true;
 }
-todo(!_thrown_outer, 'should not throw exception');
+ok(!_thrown_outer, 'should not throw exception');
 
 
 }
 </script>
 
 <!-- [[[ test_2d.type.exists.html ]]] -->
 
 <p>Canvas test: 2d.type.exists</p>
@@ -22138,21 +22331,31 @@ function runTests() {
   ok(false, "unexpected exception thrown in: test_2d_gradient_radial_transform_3");
  }
  try {
   test_2d_imageData_create_basic();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_2d_imageData_create_basic");
  }
  try {
+  test_2d_imageData_create1_basic();
+ } catch (e) {
+  ok(false, "unexpected exception thrown in: test_2d_imageData_create1_basic");
+ }
+ try {
   test_2d_imageData_create_initial();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_2d_imageData_create_initial");
  }
  try {
+  test_2d_imageData_create1_initial();
+ } catch (e) {
+  ok(false, "unexpected exception thrown in: test_2d_imageData_create1_initial");
+ }
+ try {
   test_2d_imageData_create_large();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_2d_imageData_create_large");
  }
  try {
   test_2d_imageData_create_negative();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_2d_imageData_create_negative");
@@ -22173,21 +22376,31 @@ function runTests() {
   ok(false, "unexpected exception thrown in: test_2d_imageData_create_tiny");
  }
  try {
   test_2d_imageData_create_type();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_2d_imageData_create_type");
  }
  try {
+  test_2d_imageData_create1_type();
+ } catch (e) {
+  ok(false, "unexpected exception thrown in: test_2d_imageData_create1_type");
+ }
+ try {
   test_2d_imageData_create_zero();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_2d_imageData_create_zero");
  }
  try {
+  test_2d_imageData_create1_zero();
+ } catch (e) {
+  ok(false, "unexpected exception thrown in: test_2d_imageData_create1_zero");
+ }
+ try {
   test_2d_imageData_get_basic();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_2d_imageData_get_basic");
  }
  try {
   test_2d_imageData_get_clamp();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_2d_imageData_get_clamp");
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -32,20 +32,18 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "base/basictypes.h"
 #include "IPC/IPCMessageUtils.h"
-#endif
 #include "nsCOMPtr.h"
 #include "nsDOMEvent.h"
 #include "nsEventStateManager.h"
 #include "nsIFrame.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
 #include "nsIDOMEventTarget.h"
@@ -1365,17 +1363,16 @@ nsDOMEvent::GetPreventDefault(PRBool* aR
   NS_ENSURE_ARG_POINTER(aReturn);
   *aReturn = mEvent && (mEvent->flags & NS_EVENT_FLAG_NO_DEFAULT);
   return NS_OK;
 }
 
 void
 nsDOMEvent::Serialize(IPC::Message* aMsg, PRBool aSerializeInterfaceType)
 {
-#ifdef MOZ_IPC
   if (aSerializeInterfaceType) {
     IPC::WriteParam(aMsg, NS_LITERAL_STRING("event"));
   }
 
   nsString type;
   GetType(type);
   IPC::WriteParam(aMsg, type);
 
@@ -1387,23 +1384,21 @@ nsDOMEvent::Serialize(IPC::Message* aMsg
   GetCancelable(&cancelable);
   IPC::WriteParam(aMsg, cancelable);
 
   PRBool trusted = PR_FALSE;
   GetIsTrusted(&trusted);
   IPC::WriteParam(aMsg, trusted);
 
   // No timestamp serialization for now!
-#endif
 }
 
 PRBool
 nsDOMEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
 {
-#ifdef MOZ_IPC
   nsString type;
   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &type), PR_FALSE);
 
   PRBool bubbles = PR_FALSE;
   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &bubbles), PR_FALSE);
 
   PRBool cancelable = PR_FALSE;
   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &cancelable), PR_FALSE);
@@ -1411,19 +1406,16 @@ nsDOMEvent::Deserialize(const IPC::Messa
   PRBool trusted = PR_FALSE;
   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &trusted), PR_FALSE);
 
   nsresult rv = InitEvent(type, bubbles, cancelable);
   NS_ENSURE_SUCCESS(rv, PR_FALSE);
   SetTrusted(trusted);
 
   return PR_TRUE;
-#else
-  return PR_FALSE;
-#endif
 }
 
 
 nsresult NS_NewDOMEvent(nsIDOMEvent** aInstancePtrResult,
                         nsPresContext* aPresContext,
                         nsEvent *aEvent) 
 {
   nsDOMEvent* it = new nsDOMEvent(aPresContext, aEvent);
--- a/content/events/src/nsDOMNotifyPaintEvent.cpp
+++ b/content/events/src/nsDOMNotifyPaintEvent.cpp
@@ -31,20 +31,18 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "base/basictypes.h"
 #include "IPC/IPCMessageUtils.h"
-#endif
 #include "nsDOMNotifyPaintEvent.h"
 #include "nsContentUtils.h"
 #include "nsClientRect.h"
 #include "nsPaintRequest.h"
 #include "nsIFrame.h"
 
 nsDOMNotifyPaintEvent::nsDOMNotifyPaintEvent(nsPresContext* aPresContext,
                                              nsEvent* aEvent,
@@ -143,17 +141,16 @@ nsDOMNotifyPaintEvent::GetPaintRequests(
     r->SetRequest(mInvalidateRequests[i]);
     requests->Append(r);
   }
 
   requests.forget(aResult);
   return NS_OK;
 }
 
-#ifdef MOZ_IPC
 void
 nsDOMNotifyPaintEvent::Serialize(IPC::Message* aMsg,
                                  PRBool aSerializeInterfaceType)
 {
   if (aSerializeInterfaceType) {
     IPC::WriteParam(aMsg, NS_LITERAL_STRING("notifypaintevent"));
   }
 
@@ -185,17 +182,16 @@ nsDOMNotifyPaintEvent::Deserialize(const
     NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req.mRect.width), PR_FALSE);
     NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req.mRect.height), PR_FALSE);
     NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req.mFlags), PR_FALSE);
     mInvalidateRequests.AppendElement(req);
   }
 
   return PR_TRUE;
 }
-#endif
 
 nsresult NS_NewDOMNotifyPaintEvent(nsIDOMEvent** aInstancePtrResult,
                                    nsPresContext* aPresContext,
                                    nsEvent *aEvent,
                                    PRUint32 aEventType,
                                    nsInvalidateRequestList* aInvalidateRequests) 
 {
   nsDOMNotifyPaintEvent* it =
--- a/content/events/src/nsDOMNotifyPaintEvent.h
+++ b/content/events/src/nsDOMNotifyPaintEvent.h
@@ -56,19 +56,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMNOTIFYPAINTEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMEVENT
 
-#ifdef MOZ_IPC
   virtual void Serialize(IPC::Message* aMsg, PRBool aSerializeInterfaceType);
   virtual PRBool Deserialize(const IPC::Message* aMsg, void** aIter);
-#endif
 private:
   nsRegion GetRegion();
 
   nsTArray<nsInvalidateRequestList::Request> mInvalidateRequests;
 };
 
 #endif // nsDOMNotifyPaintEvent_h_
--- a/content/events/src/nsDOMScrollAreaEvent.cpp
+++ b/content/events/src/nsDOMScrollAreaEvent.cpp
@@ -30,20 +30,18 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "base/basictypes.h"
 #include "IPC/IPCMessageUtils.h"
-#endif
 
 #include "nsDOMScrollAreaEvent.h"
 #include "nsGUIEvent.h"
 #include "nsClientRect.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIClassInfo.h"
 #include "nsIXPCScriptable.h"
 
@@ -111,17 +109,16 @@ nsDOMScrollAreaEvent::InitScrollAreaEven
   nsresult rv = nsDOMUIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mClientArea.SetRect(aX, aY, aWidth, aHeight);
 
   return NS_OK;
 }
 
-#ifdef MOZ_IPC
 void
 nsDOMScrollAreaEvent::Serialize(IPC::Message* aMsg,
                                 PRBool aSerializeInterfaceType)
 {
   if (aSerializeInterfaceType) {
     IPC::WriteParam(aMsg, NS_LITERAL_STRING("scrollareaevent"));
   }
 
@@ -147,17 +144,16 @@ nsDOMScrollAreaEvent::Deserialize(const 
   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &x), PR_FALSE);
   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &y), PR_FALSE);
   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &width), PR_FALSE);
   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &height), PR_FALSE);
   mClientArea.SetRect(x, y, width, height);
 
   return PR_TRUE;
 }
-#endif
 
 nsresult
 NS_NewDOMScrollAreaEvent(nsIDOMEvent **aInstancePtrResult,
                          nsPresContext *aPresContext,
                          nsScrollAreaEvent *aEvent)
 {
   nsDOMScrollAreaEvent *ev = new nsDOMScrollAreaEvent(aPresContext, aEvent);
 
--- a/content/events/src/nsDOMScrollAreaEvent.h
+++ b/content/events/src/nsDOMScrollAreaEvent.h
@@ -53,18 +53,16 @@ public:
   virtual ~nsDOMScrollAreaEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMSCROLLAREAEVENT
 
   NS_FORWARD_TO_NSDOMUIEVENT
 
-#ifdef MOZ_IPC
     virtual void Serialize(IPC::Message* aMsg, PRBool aSerializeInterfaceType);
     virtual PRBool Deserialize(const IPC::Message* aMsg, void** aIter);
-#endif
 
 protected:
   nsClientRect mClientArea;
 };
 
 #endif // nsDOMScrollAreaEvent_h__
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -32,20 +32,18 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "base/basictypes.h"
 #include "IPC/IPCMessageUtils.h"
-#endif
 #include "nsCOMPtr.h"
 #include "nsDOMUIEvent.h"
 #include "nsIPresShell.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDOMWindowInternal.h"
 #include "nsIDOMNode.h"
 #include "nsIContent.h"
 #include "nsContentUtils.h"
@@ -389,17 +387,16 @@ nsDOMUIEvent::DuplicatePrivateData()
   nsIntPoint screenPoint = GetScreenPoint();
   nsresult rv = nsDOMEvent::DuplicatePrivateData();
   if (NS_SUCCEEDED(rv)) {
     mEvent->refPoint = screenPoint;
   }
   return rv;
 }
 
-#ifdef MOZ_IPC
 void
 nsDOMUIEvent::Serialize(IPC::Message* aMsg, PRBool aSerializeInterfaceType)
 {
   if (aSerializeInterfaceType) {
     IPC::WriteParam(aMsg, NS_LITERAL_STRING("uievent"));
   }
 
   nsDOMEvent::Serialize(aMsg, PR_FALSE);
@@ -411,17 +408,16 @@ nsDOMUIEvent::Serialize(IPC::Message* aM
 
 PRBool
 nsDOMUIEvent::Deserialize(const IPC::Message* aMsg, void** aIter)
 {
   NS_ENSURE_TRUE(nsDOMEvent::Deserialize(aMsg, aIter), PR_FALSE);
   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &mDetail), PR_FALSE);
   return PR_TRUE;
 }
-#endif
 
 nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult,
                           nsPresContext* aPresContext,
                           nsGUIEvent *aEvent) 
 {
   nsDOMUIEvent* it = new nsDOMUIEvent(aPresContext, aEvent);
   if (nsnull == it) {
     return NS_ERROR_OUT_OF_MEMORY;
--- a/content/events/src/nsDOMUIEvent.h
+++ b/content/events/src/nsDOMUIEvent.h
@@ -57,20 +57,18 @@ public:
   // nsIDOMUIEvent Interface
   NS_DECL_NSIDOMUIEVENT
 
   // nsIDOMNSUIEvent Interface
   NS_DECL_NSIDOMNSUIEVENT
 
   // nsIPrivateDOMEvent interface
   NS_IMETHOD DuplicatePrivateData();
-#ifdef MOZ_IPC
   virtual void Serialize(IPC::Message* aMsg, PRBool aSerializeInterfaceType);
   virtual PRBool Deserialize(const IPC::Message* aMsg, void** aIter);
-#endif
   
   // Forward to nsDOMEvent
   NS_FORWARD_TO_NSDOMEVENT
 
   NS_FORWARD_NSIDOMNSEVENT(nsDOMEvent::)
 protected:
 
   // Internal helper functions
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -39,19 +39,17 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "mozilla/dom/TabParent.h"
-#endif
 
 #include "nsCOMPtr.h"
 #include "nsEventStateManager.h"
 #include "nsEventListenerManager.h"
 #include "nsIMEStateManager.h"
 #include "nsContentEventHandler.h"
 #include "nsIContent.h"
 #include "nsINodeInfo.h"
@@ -159,19 +157,17 @@
 #include "nsICommandParams.h"
 #include "mozilla/Services.h"
 #include "mozAutoDocUpdate.h"
 
 #ifdef XP_MACOSX
 #import <ApplicationServices/ApplicationServices.h>
 #endif
 
-#ifdef MOZ_IPC
 using namespace mozilla::dom;
-#endif
 
 //#define DEBUG_DOCSHELL_FOCUS
 
 #define NS_USER_INTERACTION_INTERVAL 5000 // ms
 
 static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
 
 static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
@@ -1333,30 +1329,26 @@ nsEventStateManager::PreHandleEvent(nsPr
       if ((msEvent->scrollFlags & nsMouseScrollEvent::kIsHorizontal) ?
            mLastLineScrollConsumedX : mLastLineScrollConsumedY) {
         *aStatus = nsEventStatus_eConsumeNoDefault;
       }
     }
     break;
   case NS_QUERY_SELECTED_TEXT:
     {
-#ifdef MOZ_IPC
       if (RemoteQueryContentEvent(aEvent))
         break;
-#endif
       nsContentEventHandler handler(mPresContext);
       handler.OnQuerySelectedText((nsQueryContentEvent*)aEvent);
     }
     break;
   case NS_QUERY_TEXT_CONTENT:
     {
-#ifdef MOZ_IPC
       if (RemoteQueryContentEvent(aEvent))
         break;
-#endif
       nsContentEventHandler handler(mPresContext);
       handler.OnQueryTextContent((nsQueryContentEvent*)aEvent);
     }
     break;
   case NS_QUERY_CARET_RECT:
     {
       // XXX remote event
       nsContentEventHandler handler(mPresContext);
@@ -1402,26 +1394,24 @@ nsEventStateManager::PreHandleEvent(nsPr
     {
       // XXX remote event
       nsContentEventHandler handler(mPresContext);
       handler.OnQueryDOMWidgetHittest(static_cast<nsQueryContentEvent*>(aEvent));
     }
     break;
   case NS_SELECTION_SET:
     {
-#ifdef MOZ_IPC
       nsSelectionEvent *selectionEvent =
           static_cast<nsSelectionEvent*>(aEvent);
       if (IsTargetCrossProcess(selectionEvent)) {
         // Will not be handled locally, remote the event
         if (GetCrossProcessTarget()->SendSelectionEvent(*selectionEvent))
           selectionEvent->mSucceeded = PR_TRUE;
         break;
       }
-#endif
       nsContentEventHandler handler(mPresContext);
       handler.OnSelectionEvent((nsSelectionEvent*)aEvent);
     }
     break;
   case NS_CONTENT_COMMAND_CUT:
   case NS_CONTENT_COMMAND_COPY:
   case NS_CONTENT_COMMAND_PASTE:
   case NS_CONTENT_COMMAND_DELETE:
@@ -1432,17 +1422,16 @@ nsEventStateManager::PreHandleEvent(nsPr
       DoContentCommandEvent(static_cast<nsContentCommandEvent*>(aEvent));
     }
     break;
   case NS_CONTENT_COMMAND_SCROLL:
     {
       DoContentCommandScrollEvent(static_cast<nsContentCommandEvent*>(aEvent));
     }
     break;
-#ifdef MOZ_IPC
   case NS_TEXT_TEXT:
     {
       nsTextEvent *textEvent = static_cast<nsTextEvent*>(aEvent);
       if (IsTargetCrossProcess(textEvent)) {
         // Will not be handled locally, remote the event
         if (GetCrossProcessTarget()->SendTextEvent(*textEvent)) {
           // Cancel local dispatching
           aEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
@@ -1459,17 +1448,16 @@ nsEventStateManager::PreHandleEvent(nsPr
         // Will not be handled locally, remote the event
         if (GetCrossProcessTarget()->SendCompositionEvent(*compositionEvent)) {
           // Cancel local dispatching
           aEvent->flags |= NS_EVENT_FLAG_STOP_DISPATCH;
         }
       }
     }
     break;
-#endif // MOZ_IPC
   }
   return NS_OK;
 }
 
 static PRInt32
 GetAccessModifierMask(nsISupports* aDocShell)
 {
   nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(aDocShell));
@@ -3332,17 +3320,16 @@ nsEventStateManager::PostHandleEvent(nsP
 
   //Reset target frame to null to avoid mistargeting after reentrant event
   mCurrentTarget = nsnull;
   mCurrentTargetContent = nsnull;
 
   return ret;
 }
 
-#ifdef MOZ_IPC
 PRBool
 nsEventStateManager::RemoteQueryContentEvent(nsEvent *aEvent)
 {
   nsQueryContentEvent *queryEvent =
       static_cast<nsQueryContentEvent*>(aEvent);
   if (!IsTargetCrossProcess(queryEvent)) {
     return PR_FALSE;
   }
@@ -3362,17 +3349,16 @@ nsEventStateManager::IsTargetCrossProces
 {
   // Check to see if there is a focused, editable content in chrome,
   // in that case, do not forward IME events to content
   nsIContent *focusedContent = GetFocusedContent();
   if (focusedContent && focusedContent->IsEditable())
     return PR_FALSE;
   return TabParent::GetIMETabParent() != nsnull;
 }
-#endif
 
 NS_IMETHODIMP
 nsEventStateManager::NotifyDestroyPresContext(nsPresContext* aPresContext)
 {
   nsIMEStateManager::OnDestroyPresContext(aPresContext);
   return NS_OK;
 }
 
--- a/content/events/src/nsEventStateManager.h
+++ b/content/events/src/nsEventStateManager.h
@@ -344,21 +344,19 @@ protected:
    * BeginTrackingDragGesture). aEvent->widget must be
    * mCurrentTarget->GetNearestWidget().
    */
   void FillInEventFromGestureDown(nsMouseEvent* aEvent);
 
   nsresult DoContentCommandEvent(nsContentCommandEvent* aEvent);
   nsresult DoContentCommandScrollEvent(nsContentCommandEvent* aEvent);
 
-#ifdef MOZ_IPC
   PRBool RemoteQueryContentEvent(nsEvent *aEvent);
   mozilla::dom::TabParent *GetCrossProcessTarget();
   PRBool IsTargetCrossProcess(nsGUIEvent *aEvent);
-#endif
 
   PRInt32     mLockCursor;
 
   nsWeakFrame mCurrentTarget;
   nsCOMPtr<nsIContent> mCurrentTargetContent;
   nsWeakFrame mLastMouseOverFrame;
   nsCOMPtr<nsIContent> mLastMouseOverElement;
   nsWeakFrame mLastDragOverFrame;
--- a/content/html/content/src/Makefile.in
+++ b/content/html/content/src/Makefile.in
@@ -45,24 +45,19 @@ include $(DEPTH)/config/autoconf.mk
 MODULE		= content
 LIBRARY_NAME	= gkconhtmlcon_s
 LIBXUL_LIBRARY	= 1
 
 
 EXPORTS		= \
 		nsImageMapUtils.h \
 		nsClientRect.h \
+		nsHTMLDNSPrefetch.h \
 		$(NULL)
 
-ifdef MOZ_IPC
-EXPORTS        += \
-                nsHTMLDNSPrefetch.h \
-                $(NULL)
-endif
-
 CPPSRCS		= \
 		nsClientRect.cpp \
 		nsHTMLDNSPrefetch.cpp \
 		nsGenericHTMLElement.cpp \
 		nsFormSubmission.cpp \
 		nsImageMapUtils.cpp \
 		nsTextEditorState.cpp \
 		nsHTMLElement.cpp \
--- a/content/html/content/src/nsHTMLCanvasElement.cpp
+++ b/content/html/content/src/nsHTMLCanvasElement.cpp
@@ -548,17 +548,16 @@ nsHTMLCanvasElement::GetContext(const ns
   NS_ADDREF (*aContext = mCurrentContext);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId,
                                       nsISupports **aContext)
 {
-#ifdef MOZ_IPC
   if(!nsContentUtils::IsCallerTrustedForRead()) {
     // XXX ERRMSG we need to report an error to developers here! (bug 329026)
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   // We only support 2d shmem contexts for now.
   if (!aContextId.Equals(NS_LITERAL_STRING("2d")))
     return NS_ERROR_INVALID_ARG;
@@ -583,19 +582,16 @@ nsHTMLCanvasElement::MozGetIPCContext(co
     mCurrentContextId.Assign(aContextId);
   } else if (!mCurrentContextId.Equals(aContextId)) {
     //XXX eventually allow for more than one active context on a given canvas
     return NS_ERROR_INVALID_ARG;
   }
 
   NS_ADDREF (*aContext = mCurrentContext);
   return NS_OK;
-#else
-  return NS_ERROR_NOT_IMPLEMENTED;
-#endif
 }
 
 nsresult
 nsHTMLCanvasElement::UpdateContext(nsIPropertyBag *aNewContextOptions)
 {
   if (!mCurrentContext)
     return NS_OK;
 
--- a/content/html/content/src/nsHTMLDNSPrefetch.cpp
+++ b/content/html/content/src/nsHTMLDNSPrefetch.cpp
@@ -31,22 +31,20 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "base/basictypes.h"
 #include "mozilla/net/NeckoCommon.h"
 #include "mozilla/net/NeckoChild.h"
 #include "nsURLHelper.h"
-#endif
 
 #include "nsHTMLDNSPrefetch.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 
 #include "nsNetUtil.h"
 
 #include "nsIDNSListener.h"
@@ -103,20 +101,18 @@ nsHTMLDNSPrefetch::Initialize()
   sDisablePrefetchHTTPSPref = 
     nsContentUtils::GetBoolPref("network.dns.disablePrefetchFromHTTPS", PR_TRUE);
   
   NS_IF_RELEASE(sDNSService);
   nsresult rv;
   rv = CallGetService(kDNSServiceCID, &sDNSService);
   if (NS_FAILED(rv)) return rv;
   
-#ifdef MOZ_IPC
   if (IsNeckoChild())
     NeckoChild::InitNeckoChild();
-#endif
 
   sInitialized = PR_TRUE;
   return NS_OK;
 }
 
 nsresult
 nsHTMLDNSPrefetch::Shutdown()
 {
@@ -137,28 +133,26 @@ nsHTMLDNSPrefetch::IsAllowed (nsIDocumen
 {
   // There is no need to do prefetch on non UI scenarios such as XMLHttpRequest.
   return aDocument->IsDNSPrefetchAllowed() && aDocument->GetWindow();
 }
 
 nsresult
 nsHTMLDNSPrefetch::Prefetch(Link *aElement, PRUint16 flags)
 {
-#ifdef MOZ_IPC
   if (IsNeckoChild()) {
     // Instead of transporting the Link object to the other process
     // we are using the hostname based function here, too. Compared to the 
     // IPC the performance hit should be negligible.
     nsAutoString hostname;
     nsresult rv = aElement->GetHostname(hostname);
     NS_ENSURE_SUCCESS(rv,rv);
 
     return Prefetch(hostname, flags);
   }
-#endif
 
   if (!(sInitialized && sPrefetches && sDNSService && sDNSListener))
     return NS_ERROR_NOT_AVAILABLE;
 
   return sPrefetches->Add(flags, aElement);
 }
 
 nsresult
@@ -177,27 +171,25 @@ nsresult
 nsHTMLDNSPrefetch::PrefetchHigh(Link *aElement)
 {
   return Prefetch(aElement, 0);
 }
 
 nsresult
 nsHTMLDNSPrefetch::Prefetch(nsAString &hostname, PRUint16 flags)
 {
-#ifdef MOZ_IPC
   if (IsNeckoChild()) {
     // We need to check IsEmpty() because net_IsValidHostName()
     // considers empty strings to be valid hostnames
     if (!hostname.IsEmpty() &&
         net_IsValidHostName(NS_ConvertUTF16toUTF8(hostname))) {
       gNeckoChild->SendHTMLDNSPrefetch(nsAutoString(hostname), flags);
     }
     return NS_OK;
   }
-#endif
 
   if (!(sInitialized && sDNSService && sPrefetches && sDNSListener))
     return NS_ERROR_NOT_AVAILABLE;
 
   nsCOMPtr<nsICancelable> tmpOutstanding;
   return sDNSService->AsyncResolve(NS_ConvertUTF16toUTF8(hostname), flags | nsIDNSService::RESOLVE_SPECULATE,
                                    sDNSListener, nsnull, getter_AddRefs(tmpOutstanding));
 }
--- a/content/html/content/src/nsHTMLDNSPrefetch.h
+++ b/content/html/content/src/nsHTMLDNSPrefetch.h
@@ -138,14 +138,12 @@ public:
     
     struct deferred_entry
     {
       PRUint16                         mFlags;
       nsWeakPtr                        mElement;
     } mEntries[sMaxDeferred];
   };
 
-#ifdef MOZ_IPC
   friend class mozilla::net::NeckoParent;
-#endif
 };
 
 #endif 
--- a/content/html/content/src/nsTextEditorState.cpp
+++ b/content/html/content/src/nsTextEditorState.cpp
@@ -87,16 +87,19 @@ public:
       mWeakFrame(aFrame),
       mStart(aStart),
       mEnd(aEnd)
   {
   }
 
   NS_IMETHOD Run() {
     if (mWeakFrame.IsAlive()) {
+      // SetSelectionRange leads to Selection::AddRange which flushes Layout -
+      // need to block script to avoid nested PrepareEditor calls (bug 642800).
+      nsAutoScriptBlocker scriptBlocker;
       mFrame->SetSelectionRange(mStart, mEnd);
     }
     return NS_OK;
   }
 
 private:
   nsTextControlFrame* mFrame;
   nsWeakFrame mWeakFrame;
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -55,17 +55,16 @@
 #include "nsIContentViewer.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsINodeInfo.h"
 #include "nsHTMLTokens.h"
 #include "nsIAppShell.h"
 #include "nsCRT.h"
 #include "prtime.h"
 #include "prlog.h"
-#include "nsInt64.h"
 #include "nsNodeUtils.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Element.h"
 
 #include "nsGenericHTMLElement.h"
 
 #include "nsIDOMText.h"
 #include "nsIDOMComment.h"
--- a/content/media/nsAudioStream.cpp
+++ b/content/media/nsAudioStream.cpp
@@ -32,24 +32,22 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/PAudioChild.h"
 #include "mozilla/dom/AudioChild.h"
 #include "mozilla/Monitor.h"
 #include "nsXULAppAPI.h"
 using namespace mozilla::dom;
-#endif
 
 #include <stdio.h>
 #include <math.h>
 #include "prlog.h"
 #include "prmem.h"
 #include "nsAutoPtr.h"
 #include "nsAudioStream.h"
 #include "nsAlgorithm.h"
@@ -60,17 +58,17 @@ extern "C" {
 #include "nsThreadUtils.h"
 
 #if defined(XP_MACOSX)
 #define SA_PER_STREAM_VOLUME 1
 #endif
 
 // Android's audio backend is not available in content processes, so audio must
 // be remoted to the parent chrome process.
-#if defined(ANDROID) && defined(MOZ_IPC)
+#if defined(ANDROID)
 #define REMOTE_AUDIO 1
 #endif
 
 using mozilla::TimeStamp;
 
 #ifdef PR_LOGGING
 PRLogModuleInfo* gAudioStreamLog = nsnull;
 #endif
@@ -117,17 +115,16 @@ class nsAudioStreamLocal : public nsAudi
   // PR_TRUE if this audio stream is paused.
   PRPackedBool mPaused;
 
   // PR_TRUE if this stream has encountered an error.
   PRPackedBool mInError;
 
 };
 
-#ifdef MOZ_IPC
 class nsAudioStreamRemote : public nsAudioStream
 {
  public:
   NS_DECL_ISUPPORTS
 
   nsAudioStreamRemote();
   ~nsAudioStreamRemote();
 
@@ -289,17 +286,16 @@ class AudioShutdownEvent : public nsRunn
   {
     if (mAudioChild->IsIPCOpen())
       mAudioChild->SendShutdown();
     return NS_OK;
   }
   
   nsRefPtr<AudioChild> mAudioChild;
 };
-#endif // MOZ_IPC
 
 
 void nsAudioStream::InitLibrary()
 {
 #ifdef PR_LOGGING
   gAudioStreamLog = PR_NewLogModule("nsAudioStream");
 #endif
 }
@@ -592,18 +588,16 @@ PRInt32 nsAudioStreamLocal::GetMinWriteS
   if (r == SA_ERROR_NOT_SUPPORTED)
     return 1;
   else if (r != SA_SUCCESS || samples > PR_INT32_MAX)
     return -1;
 
   return static_cast<PRInt32>(samples);
 }
 
-#ifdef MOZ_IPC
-
 nsAudioStreamRemote::nsAudioStreamRemote()
  : mAudioChild(NULL),
    mFormat(FORMAT_S16_LE),
    mRate(0),
    mChannels(0),
    mBytesPerSample(1),
    mPaused(PR_FALSE)
 {}
@@ -745,10 +739,8 @@ nsAudioStreamRemote::GetSampleOffset()
   return result;
 }
 
 PRBool
 nsAudioStreamRemote::IsPaused()
 {
   return mPaused;
 }
-
-#endif // MOZ_IPC
--- a/content/media/nsAudioStream.h
+++ b/content/media/nsAudioStream.h
@@ -59,24 +59,23 @@ public:
   // Initialize Audio Library. Some Audio backends require initializing the
   // library before using it. 
   static void InitLibrary();
 
   // Shutdown Audio Library. Some Audio backends require shutting down the
   // library after using it.
   static void ShutdownLibrary();
 
-  // Thread, usually for MOZ_IPC handling, that is shared between audio streams.
+  // Thread that is shared between audio streams.
   // This may return null in the child process
   nsIThread *GetThread();
 
   // AllocateStream will return either a local stream or a remoted stream
-  // depending on where you call it from.  If MOZ_IPC is enabled, and you
-  // call this from a child process, you may recieve an implementation which
-  // forwards to a compositing process.
+  // depending on where you call it from.  If you call this from a child process,
+  // you may receive an implementation which forwards to a compositing process.
   static nsAudioStream* AllocateStream();
 
   // Initialize the audio stream. aNumChannels is the number of audio channels 
   // (1 for mono, 2 for stereo, etc) and aRate is the frequency of the sound 
   // samples (22050, 44100, etc).
   virtual nsresult Init(PRInt32 aNumChannels, PRInt32 aRate, SampleFormat aFormat) = 0;
 
   // Closes the stream. All future use of the stream is an error.
--- a/content/media/raw/nsRawReader.cpp
+++ b/content/media/raw/nsRawReader.cpp
@@ -182,17 +182,17 @@ PRBool nsRawReader::DecodeVideoFrame(PRB
   nsMediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
 
   if (!mFrameSize)
     return PR_FALSE; // Metadata read failed.  We should refuse to play.
 
   PRInt64 currentFrameTime = 1000 * mCurrentFrame / mFrameRate;
   PRUint32 length = mFrameSize - sizeof(nsRawPacketHeader);
 
-  nsAutoPtr<PRUint8> buffer(new PRUint8[length]);
+  nsAutoArrayPtr<PRUint8> buffer(new PRUint8[length]);
   nsMediaStream* stream = mDecoder->GetCurrentStream();
   NS_ASSERTION(stream, "Decoder has no media stream");
 
   // We're always decoding one frame when called
   while(true) {
     nsRawPacketHeader header;
 
     // Read in a packet header and validate
--- a/content/smil/nsSMILAnimationController.cpp
+++ b/content/smil/nsSMILAnimationController.cpp
@@ -146,21 +146,17 @@ nsSMILAnimationController::Resume(PRUint
   // Update mCurrentSampleTime so that calls to GetParentTime--used for
   // calculating parent offsets--are accurate
   mCurrentSampleTime = mozilla::TimeStamp::Now();
 
   nsSMILTimeContainer::Resume(aType);
 
   if (wasPaused && !mPauseState && mChildContainerTable.Count()) {
     Sample(); // Run the first sample manually
-    if (mAnimationElementTable.Count()) {
-      StartSampling(GetRefreshDriverForDoc(mDocument));
-    } else {
-      mDeferredStartSampling = PR_TRUE;
-    }
+    MaybeStartSampling(GetRefreshDriverForDoc(mDocument));
   }
 }
 
 nsSMILTime
 nsSMILAnimationController::GetParentTime() const
 {
   return (nsSMILTime)(mCurrentSampleTime - mStartTime).ToMilliseconds();
 }
@@ -294,18 +290,18 @@ nsSMILAnimationController::Unlink()
 
 //----------------------------------------------------------------------
 // Refresh driver lifecycle related methods
 
 void
 nsSMILAnimationController::NotifyRefreshDriverCreated(
     nsRefreshDriver* aRefreshDriver)
 {
-  if (!mPauseState && !mDeferredStartSampling) {
-    StartSampling(aRefreshDriver);
+  if (!mPauseState) {
+    MaybeStartSampling(aRefreshDriver);
   }
 }
 
 void
 nsSMILAnimationController::NotifyRefreshDriverDestroying(
     nsRefreshDriver* aRefreshDriver)
 {
   if (!mPauseState && !mDeferredStartSampling) {
@@ -341,16 +337,32 @@ nsSMILAnimationController::StopSampling(
     // (and RefreshDriver), which would make GetRefreshDriverForDoc return null.
     NS_ABORT_IF_FALSE(!GetRefreshDriverForDoc(mDocument) ||
                       aRefreshDriver == GetRefreshDriverForDoc(mDocument),
                       "Stopping sampling with wrong refresh driver");
     aRefreshDriver->RemoveRefreshObserver(this, Flush_Style);
   }
 }
 
+void
+nsSMILAnimationController::MaybeStartSampling(nsRefreshDriver* aRefreshDriver)
+{
+  if (mDeferredStartSampling) {
+    // We've received earlier 'MaybeStartSampling' calls, and we're
+    // deferring until we get a registered animation.
+    return;
+  }
+
+  if (mAnimationElementTable.Count()) {
+    StartSampling(aRefreshDriver);
+  } else {
+    mDeferredStartSampling = PR_TRUE;
+  }
+}
+
 //----------------------------------------------------------------------
 // Sample-related methods and callbacks
 
 PR_CALLBACK PLDHashOperator
 TransferCachedBaseValue(nsSMILCompositor* aCompositor,
                         void* aData)
 {
   nsSMILCompositorTable* lastCompositorTable =
@@ -815,25 +827,21 @@ nsSMILAnimationController::GetTargetIden
 
 //----------------------------------------------------------------------
 // Add/remove child time containers
 
 nsresult
 nsSMILAnimationController::AddChild(nsSMILTimeContainer& aChild)
 {
   TimeContainerPtrKey* key = mChildContainerTable.PutEntry(&aChild);
-  NS_ENSURE_TRUE(key,NS_ERROR_OUT_OF_MEMORY);
+  NS_ENSURE_TRUE(key, NS_ERROR_OUT_OF_MEMORY);
 
   if (!mPauseState && mChildContainerTable.Count() == 1) {
     Sample(); // Run the first sample manually
-    if (mAnimationElementTable.Count()) {
-      StartSampling(GetRefreshDriverForDoc(mDocument));
-    } else {
-      mDeferredStartSampling = PR_TRUE;
-    }
+    MaybeStartSampling(GetRefreshDriverForDoc(mDocument));
   }
 
   return NS_OK;
 }
 
 void
 nsSMILAnimationController::RemoveChild(nsSMILTimeContainer& aChild)
 {
--- a/content/smil/nsSMILAnimationController.h
+++ b/content/smil/nsSMILAnimationController.h
@@ -157,16 +157,19 @@ protected:
   // Cycle-collection implementation helpers
   PR_STATIC_CALLBACK(PLDHashOperator) CompositorTableEntryTraverse(
       nsSMILCompositor* aCompositor, void* aArg);
 
   // Methods for controlling whether we're sampling
   void StartSampling(nsRefreshDriver* aRefreshDriver);
   void StopSampling(nsRefreshDriver* aRefreshDriver);
 
+  // Wrapper for StartSampling that defers if no animations are registered.
+  void MaybeStartSampling(nsRefreshDriver* aRefreshDriver);
+
   // Sample-related callbacks and implementation helpers
   virtual void DoSample();
   void DoSample(PRBool aSkipUnchangedContainers);
 
   void RewindElements();
   PR_STATIC_CALLBACK(PLDHashOperator) RewindNeeded(
       TimeContainerPtrKey* aKey, void* aData);
   PR_STATIC_CALLBACK(PLDHashOperator) RewindAnimation(
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -1209,17 +1209,17 @@ MappedAttrParser::ParseMappedAttrValue(n
 
 already_AddRefed<css::StyleRule>
 MappedAttrParser::CreateStyleRule()
 {
   if (!mDecl) {
     return nsnull; // No mapped attributes were parsed
   }
 
-  nsRefPtr<css::StyleRule> rule = NS_NewCSSStyleRule(nsnull, mDecl);
+  nsRefPtr<css::StyleRule> rule = new css::StyleRule(nsnull, mDecl);
   mDecl = nsnull; // We no longer own the declaration -- drop our pointer to it
   return rule.forget();
 }
 
 } // anonymous namespace
 
 //----------------------------------------------------------------------
 // Implementation Helpers:
--- a/content/xul/document/src/nsXULDocument.h
+++ b/content/xul/document/src/nsXULDocument.h
@@ -318,29 +318,16 @@ protected:
     // Maintains the template builders that have been attached to
     // content elements
     typedef nsInterfaceHashtable<nsISupportsHashKey, nsIXULTemplateBuilder>
         BuilderTable;
     BuilderTable* mTemplateBuilderTable;
 
     PRUint32 mPendingSheets;
 
-    /*
-     * XXX dr
-     * ------
-     * We used to have two pointers into the content model: mPopupNode and
-     * mTooltipNode, which were used to retrieve the objects triggering a
-     * popup or tooltip. You need that access because your reference has
-     * disappeared by the time you click on a popup item or do whatever
-     * with a tooltip. These were owning references (no cycles, as pinkerton
-     * pointed out, since we're still parent-child).
-     */
-
-    nsCOMPtr<nsIDOMNode>    mTooltipNode;          // [OWNER] element triggering the tooltip
-
     /**
      * document lightweight theme for use with :-moz-lwtheme, :-moz-lwtheme-brighttext
      * and :-moz-lwtheme-darktext
      */
     DocumentTheme                         mDocLWTheme;
 
     /**
      * Context stack, which maintains the state of the Builder and allows
--- a/docshell/base/IHistory.h
+++ b/docshell/base/IHistory.h
@@ -66,17 +66,17 @@ public:
      * SetLinkState called on themselves.  This function is guaranteed to run to
      * completion before aLink is notified.  After the node is notified, it will
      * be unregistered.
      *
      * @note SetLinkState must not call RegisterVisitedCallback or
      *       UnregisterVisitedCallback.
      *
      * @pre aURI must not be null.
-     * @pre aLink may be null only in the MOZ_IPC parent process.
+     * @pre aLink may be null only in the parent (chrome) process.
      *
      * @param aURI
      *        The URI to check.
      * @param aLink
      *        The link to update whenever the history status changes.  The
      *        implementation will only hold onto a raw pointer, so if this
      *        object should be destroyed, be sure to call
      *        UnregisterVistedCallback first.
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -224,19 +224,17 @@ static NS_DEFINE_CID(kAppShellCID, NS_AP
 //#define DEBUG_DOCSHELL_FOCUS
 #define DEBUG_PAGE_CACHE
 #endif
 
 #include "nsContentErrors.h"
 #include "nsIChannelPolicy.h"
 #include "nsIContentSecurityPolicy.h"
 
-#ifdef MOZ_IPC
 #include "nsXULAppAPI.h"
-#endif
 
 using namespace mozilla;
 
 // Number of documents currently loading
 static PRInt32 gNumberOfDocumentsLoading = 0;
 
 // Global count of existing docshells.
 static PRInt32 gDocShellCount = 0;
@@ -3930,41 +3928,16 @@ nsDocShell::DisplayLoadError(nsresult aE
             break;
         case NS_ERROR_INVALID_CONTENT_ENCODING:
             // Bad Content Encoding.
             error.AssignLiteral("contentEncodingError");
             break;
         case NS_ERROR_REMOTE_XUL:
         {
             error.AssignLiteral("remoteXUL");
-
-            /**
-             * We want to set an hardcoded messageStr which uses the
-             * brandShortName.
-             */
-            nsCOMPtr<nsIStringBundleService> stringBundleService =
-                mozilla::services::GetStringBundleService();
-            if (!stringBundleService) {
-                return NS_ERROR_FAILURE;
-            }
-
-            nsCOMPtr<nsIStringBundle> brandBundle;
-            rv = stringBundleService->CreateBundle(kBrandBundleURL,
-                                                   getter_AddRefs(brandBundle));
-            NS_ENSURE_SUCCESS(rv, rv);
-
-            nsXPIDLString brandName;
-            rv = brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
-                                                getter_Copies(brandName));
-
-            // We could use something like nsTextFormatter::smprintf.
-            messageStr.AssignLiteral("This page uses an unsupported technology "
-                                     "that is no longer available by default in ");
-            messageStr.Append(brandName);
-            messageStr.AppendLiteral(".");
             break;
         }
         case NS_ERROR_UNSAFE_CONTENT_TYPE:
             // Channel refused to load from an unrecognized content type.
             error.AssignLiteral("unsafeContentType");
             break;
         }
     }
@@ -6011,22 +5984,20 @@ nsDocShell::OnRedirectStateChange(nsICha
         // here.  OnNewURI will do that, so we will cache it.
         SaveLastVisit(aNewChannel, oldURI, aRedirectFlags);
     }
 
     // check if the new load should go through the application cache.
     nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
         do_QueryInterface(aNewChannel);
     if (appCacheChannel) {
-#ifdef MOZ_IPC
         // Permission will be checked in the parent process.
         if (GeckoProcessType_Default != XRE_GetProcessType())
             appCacheChannel->SetChooseApplicationCache(PR_TRUE);
         else
-#endif
             appCacheChannel->SetChooseApplicationCache(ShouldCheckAppCache(newURI));
     }
 
     if (!(aRedirectFlags & nsIChannelEventSink::REDIRECT_INTERNAL) && 
         mLoadType & (LOAD_CMD_RELOAD | LOAD_CMD_HISTORY)) {
         mLoadType = LOAD_NORMAL_REPLACE;
         SetHistoryEntry(&mLSHE, nsnull);
     }
@@ -8731,22 +8702,20 @@ nsDocShell::DoURILoad(nsIURI * aURI,
     nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
         do_QueryInterface(channel);
     if (appCacheChannel) {
         // Any document load should not inherit application cache.
         appCacheChannel->SetInheritApplicationCache(PR_FALSE);
 
         // Loads with the correct permissions should check for a matching
         // application cache.
-#ifdef MOZ_IPC
         // Permission will be checked in the parent process
         if (GeckoProcessType_Default != XRE_GetProcessType())
             appCacheChannel->SetChooseApplicationCache(PR_TRUE);
         else
-#endif
             appCacheChannel->SetChooseApplicationCache(
                 ShouldCheckAppCache(aURI));
     }
 
     // Make sure to give the caller a channel if we managed to create one
     // This is important for correct error page/session history interaction
     if (aRequest)
         NS_ADDREF(*aRequest = channel);
--- a/docshell/resources/content/netError.xhtml
+++ b/docshell/resources/content/netError.xhtml
@@ -323,17 +323,17 @@
         <h1 id="et_proxyResolveFailure">&proxyResolveFailure.title;</h1>
         <h1 id="et_proxyConnectFailure">&proxyConnectFailure.title;</h1>
         <h1 id="et_contentEncodingError">&contentEncodingError.title;</h1>
         <h1 id="et_unsafeContentType">&unsafeContentType.title;</h1>
         <h1 id="et_nssFailure2">&nssFailure2.title;</h1>
         <h1 id="et_nssBadCert">&nssBadCert.title;</h1>
         <h1 id="et_malwareBlocked">&malwareBlocked.title;</h1>
         <h1 id="et_cspFrameAncestorBlocked">&cspFrameAncestorBlocked.title;</h1>
-        <h1 id="et_remoteXUL">Remote XUL</h1>
+        <h1 id="et_remoteXUL">&remoteXUL.title;</h1>
       </div>
       <div id="errorDescriptionsContainer">
         <div id="ed_generic">&generic.longDesc;</div>
         <div id="ed_dnsNotFound">&dnsNotFound.longDesc;</div>
         <div id="ed_fileNotFound">&fileNotFound.longDesc;</div>
         <div id="ed_malformedURI">&malformedURI.longDesc;</div>
         <div id="ed_protocolNotFound">&protocolNotFound.longDesc;</div>
         <div id="ed_connectionFailure">&connectionFailure.longDesc;</div>
@@ -347,17 +347,17 @@
         <div id="ed_proxyResolveFailure">&proxyResolveFailure.longDesc;</div>
         <div id="ed_proxyConnectFailure">&proxyConnectFailure.longDesc;</div>
         <div id="ed_contentEncodingError">&contentEncodingError.longDesc;</div>
         <div id="ed_unsafeContentType">&unsafeContentType.longDesc;</div>
         <div id="ed_nssFailure2">&nssFailure2.longDesc;</div>
         <div id="ed_nssBadCert">&nssBadCert.longDesc2;</div>
         <div id="ed_malwareBlocked">&malwareBlocked.longDesc;</div>
         <div id="ed_cspFrameAncestorBlocked">&cspFrameAncestorBlocked.longDesc;</div>
-        <div id="ed_remoteXUL"><ul><li>Please contact the website owners to inform them of this problem.</li></ul></div>
+        <div id="ed_remoteXUL">&remoteXUL.longDesc;</div>
       </div>
     </div>
 
     <!-- PAGE CONTAINER (for styling purposes only) -->
     <div id="errorPageContainer">
     
       <!-- Error Title -->
       <div id="errorTitle">
--- a/dom/Makefile.in
+++ b/dom/Makefile.in
@@ -78,22 +78,17 @@ endif
 DIRS += \
   public/coreEvents \
   base \
   src \
   locales \
   plugins \
   indexedDB \
   system \
-  $(NULL)
-
-ifdef MOZ_IPC
-DIRS += \
   ipc \
   $(NULL)
-endif
 
 ifdef ENABLE_TESTS
 DIRS += tests
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/dom/base/Makefile.in
+++ b/dom/base/Makefile.in
@@ -78,16 +78,17 @@ EXPORTS = \
   nsIScriptObjectOwner.h \
   nsIScriptObjectPrincipal.h \
   nsIScriptRuntime.h \
   nsIScriptTimeoutHandler.h \
   nsPIDOMWindow.h \
   nsPIWindowRoot.h \
   nsFocusManager.h \
   nsWrapperCache.h \
+  nsContentPermissionHelper.h \
   $(NULL)
 
 CPPSRCS =			\
 	nsBarProps.cpp          \
 	nsDOMException.cpp 	\
 	nsDOMWindowUtils.cpp 	\
 	nsJSEnvironment.cpp	\
 	nsJSTimeoutHandler.cpp	\
@@ -101,37 +102,27 @@ CPPSRCS =			\
 	nsHistory.cpp		\
 	nsMimeTypeArray.cpp	\
 	nsPluginArray.cpp	\
 	nsWindowRoot.cpp	\
 	nsDOMClassInfo.cpp	\
 	nsScriptNameSpaceManager.cpp \
 	nsDOMScriptObjectFactory.cpp \
 	nsQueryContentEventResult.cpp \
+	nsContentPermissionHelper.cpp \
 	$(NULL)
 
-ifdef MOZ_IPC
-EXPORTS += \
-  nsContentPermissionHelper.h \
-  $(NULL)
-CPPSRCS += \
-  nsContentPermissionHelper.cpp \
-  $(NULL)
-endif
-
 include $(topsrcdir)/dom/dom-config.mk
 
 ifdef MOZ_JSDEBUGGER
 DEFINES += -DMOZ_JSDEBUGGER
 endif
 
-ifdef MOZ_IPC
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
-endif
 
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES += \
 		-I$(srcdir)/../../js/src/xpconnect/src \
 		-I$(srcdir)/../../js/src/xpconnect/wrappers \
 		$(NULL)
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -41,19 +41,17 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "base/basictypes.h"
-#endif
 
 // Local Includes
 #include "nsGlobalWindow.h"
 #include "nsScreen.h"
 #include "nsHistory.h"
 #include "nsBarProps.h"
 #include "nsDOMStorage.h"
 #include "nsDOMOfflineResourceList.h"
@@ -8729,49 +8727,48 @@ nsGlobalWindow::SetTimeoutOrInterval(nsI
                    NS_ERROR_NOT_INITIALIZED);
 
   // If we don't have a document (we could have been unloaded since
   // the call to setTimeout was made), do nothing.
   if (!mDocument) {
     return NS_OK;
   }
 
-  PRUint32 nestingLevel = sNestingLevel + 1;
-  if (aIsInterval || nestingLevel >= DOM_CLAMP_TIMEOUT_NESTING_LEVEL) {
-    // Don't allow timeouts less than DOMMinTimeoutValue() from
-    // now...
-    interval = NS_MAX(interval, DOMMinTimeoutValue());
-  }
-  else if (interval < 0) {
-    // Clamp negative intervals to 0.
-    interval = 0;
-  }
-
-  NS_ASSERTION(interval >= 0, "DOMMinTimeoutValue() lies");
-  PRUint32 realInterval = interval;
-
-  // Make sure we don't proceed with a interval larger than our timer
+  // Disallow negative intervals.  If aIsInterval also disallow 0,
+  // because we use that as a "don't repeat" flag.
+  interval = NS_MAX(aIsInterval ? 1 : 0, interval);
+
+  // Make sure we don't proceed with an interval larger than our timer
   // code can handle.
-  if (realInterval > PR_IntervalToMilliseconds(DOM_MAX_TIMEOUT_VALUE)) {
-    realInterval = PR_IntervalToMilliseconds(DOM_MAX_TIMEOUT_VALUE);
+  if (interval > PR_IntervalToMilliseconds(DOM_MAX_TIMEOUT_VALUE)) {
+    interval = PR_IntervalToMilliseconds(DOM_MAX_TIMEOUT_VALUE);
   }
 
   nsTimeout *timeout = new nsTimeout();
   if (!timeout)
     return NS_ERROR_OUT_OF_MEMORY;
 
   // Increment the timeout's reference count to represent this function's hold
   // on the timeout.
   timeout->AddRef();
 
   if (aIsInterval) {
-    timeout->mInterval = realInterval;
+    timeout->mInterval = interval;
   }
   timeout->mScriptHandler = aHandler;
 
+  // Now clamp the actual interval we will use for the timer based on
+  PRUint32 nestingLevel = sNestingLevel + 1;
+  PRInt32 realInterval = interval;
+  if (aIsInterval || nestingLevel >= DOM_CLAMP_TIMEOUT_NESTING_LEVEL) {
+    // Don't allow timeouts less than DOMMinTimeoutValue() from
+    // now...
+    realInterval = NS_MAX(realInterval, DOMMinTimeoutValue());
+  }
+
   // Get principal of currently executing code, save for execution of timeout.
   // If our principals subsume the subject principal then use the subject
   // principal. Otherwise, use our principal to avoid running script in
   // elevated principals.
 
   nsCOMPtr<nsIPrincipal> subjectPrincipal;
   nsresult rv;
   rv = nsContentUtils::GetSecurityManager()->
@@ -8852,16 +8849,19 @@ nsGlobalWindow::SetTimeoutOrInterval(nsI
     // This timeout is *not* set from another timeout and it's set
     // while popups are enabled. Propagate the state to the timeout if
     // its delay (interval) is equal to or less than what
     // "dom.disable_open_click_delay" is set to (in ms).
 
     PRInt32 delay =
       nsContentUtils::GetIntPref("dom.disable_open_click_delay");
 
+    // This is checking |interval|, not realInterval, on purpose,
+    // because our lower bound for |realInterval| could be pretty high
+    // in some cases.
     if (interval <= delay) {
       timeout->mPopupState = gPopupControlState;
     }
   }
 
   InsertTimeoutIntoList(timeout);
 
   timeout->mPublicId = ++mTimeoutPublicIdCounter;
--- a/dom/ipc/AudioParent.cpp
+++ b/dom/ipc/AudioParent.cpp
@@ -33,16 +33,17 @@
  * 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 "mozilla/dom/AudioParent.h"
+#include "mozilla/unused.h"
 #include "nsThreadUtils.h"
 
 // C++ file contents
 namespace mozilla {
 namespace dom {
 
 class AudioWriteEvent : public nsRunnable
 {
@@ -154,17 +155,17 @@ AudioParent::Notify(nsITimer* timer)
 {
   if (!mIPCOpen) {
     timer->Cancel();
     return NS_ERROR_FAILURE;
   }
 
   NS_ASSERTION(mStream, "AudioStream not initialized.");
   PRInt64 offset = mStream->GetSampleOffset();
-  SendSampleOffsetUpdate(offset, PR_IntervalNow());
+  unused << SendSampleOffsetUpdate(offset, PR_IntervalNow());
   return NS_OK;
 }
 
 bool
 AudioParent::RecvWrite(
         const nsCString& data,
         const PRUint32& count)
 {
@@ -217,17 +218,17 @@ AudioParent::RecvResume()
   thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
   return true;
 }
 
 bool
 AudioParent::RecvShutdown()
 {
   Shutdown();
-  PAudioParent::Send__delete__(this);
+  unused << PAudioParent::Send__delete__(this);
   return true;
 }
 
 bool
 AudioParent::SendDrainDone()
 {
   if (mIPCOpen)
     return PAudioParent::SendDrainDone();
--- a/dom/locales/en-US/chrome/appstrings.properties
+++ b/dom/locales/en-US/chrome/appstrings.properties
@@ -57,8 +57,9 @@ externalProtocolTitle=External Protocol 
 externalProtocolPrompt=An external application must be launched to handle %1$S: links.\n\n\nRequested link:\n\n%2$S\n\nApplication: %3$S\n\n\nIf you were not expecting this request it may be an attempt to exploit a weakness in that other program. Cancel this request unless you are sure it is not malicious.\n
 #LOCALIZATION NOTE (externalProtocolUnknown): The following string is shown if the application name can't be determined
 externalProtocolUnknown=<Unknown>
 externalProtocolChkMsg=Remember my choice for all links of this type.
 externalProtocolLaunchBtn=Launch application
 malwareBlocked=The site at %S has been reported as an attack site and has been blocked based on your security preferences.
 phishingBlocked=The web site at %S has been reported as a web forgery designed to trick users into sharing personal or financial information.
 cspFrameAncestorBlocked=This page has a content security policy that prevents it from being embedded in this way.
+remoteXUL=This page uses an unsupported technology that is no longer available by default.
--- a/dom/locales/en-US/chrome/netError.dtd
+++ b/dom/locales/en-US/chrome/netError.dtd
@@ -84,8 +84,11 @@
 <!ENTITY cspFrameAncestorBlocked.title "Blocked by Content Security Policy">
 <!ENTITY cspFrameAncestorBlocked.longDesc "<p>The browser prevented this page from loading in this way because the page has a content security policy that disallows it.</p>">
 
 <!-- Include app-specific error messages - do not change this in localization!
      Some applications might override netErrorApp.dtd with their specific version,
      this inclusion needs to be intact for that approach to work correctly. -->
 <!ENTITY % netErrorAppDTD SYSTEM "chrome://global/locale/netErrorApp.dtd">
 %netErrorAppDTD;
+
+<!ENTITY remoteXUL.title "Remote XUL">
+<!ENTITY remoteXUL.longDesc "<p><ul><li>Please contact the website owners to inform them of this problem.</li></ul></p>">
--- a/dom/plugins/Makefile.in
+++ b/dom/plugins/Makefile.in
@@ -45,18 +45,16 @@ include $(DEPTH)/config/autoconf.mk
 MODULE = dom
 
 EXPORTS_NAMESPACES = mozilla
 
 EXPORTS_mozilla = \
   PluginLibrary.h \
   $(NULL)
 
-ifdef MOZ_IPC
-
 EXPORTS_NAMESPACES = mozilla mozilla/plugins
 
 EXPORTS_mozilla/plugins = \
   BrowserStreamChild.h \
   BrowserStreamParent.h \
   ChildAsyncCall.h \
   ChildTimer.h \
   NPEventOSX.h \
@@ -146,15 +144,14 @@ endif
 LOCAL_INCLUDES = \
   -I$(topsrcdir)/modules/plugin/base/public/ \
   -I$(topsrcdir)/modules/plugin/base/src/ \
   -I$(topsrcdir)/xpcom/base/ \
   $(NULL)
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
-endif
 
 include $(topsrcdir)/config/rules.mk
 
 CXXFLAGS += $(TK_CFLAGS)
 
 DEFINES += -DFORCE_PR_LOG
--- a/dom/src/geolocation/Makefile.in
+++ b/dom/src/geolocation/Makefile.in
@@ -78,17 +78,15 @@ LOCAL_INCLUDES  += $(MOZ_PLATFORM_MAEMO_
                    $(NULL)
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),android)
 LOCAL_INCLUDES  += -I$(topsrcdir)/dom/system/android \
                    $(NULL)
 endif
 
-ifdef MOZ_IPC
 EXPORTS         += nsGeoPositionIPCSerialiser.h
-endif
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -D_IMPL_NS_LAYOUT
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -29,17 +29,16 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "nsContentPermissionHelper.h"
 #include "nsXULAppAPI.h"
 
 #include "mozilla/dom/PBrowserChild.h"
 #include "mozilla/dom/PBrowserParent.h"
 #include "mozilla/dom/ContentChild.h"
 #include "nsNetUtil.h"
 
@@ -48,17 +47,16 @@
 #include "nsIFrameLoader.h"
 
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIWebProgressListener2.h"
 
 #include "nsDOMEventTargetHelper.h"
 #include "TabChild.h"
-#endif
 
 #include "nsGeolocation.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMWindow.h"
 #include "nsDOMClassInfo.h"
 #include "nsComponentManagerUtils.h"
 #include "nsICategoryManager.h"
@@ -473,26 +471,24 @@ nsGeolocationRequest::Shutdown()
     mTimeoutTimer->Cancel();
     mTimeoutTimer = nsnull;
   }
   mCleared = PR_TRUE;
   mCallback = nsnull;
   mErrorCallback = nsnull;
 }
 
-#ifdef MOZ_IPC
 bool nsGeolocationRequest::Recv__delete__(const bool& allow)
 {
   if (allow)
     (void) Allow();
   else
     (void) Cancel();
   return true;
 }
-#endif
 ////////////////////////////////////////////////////
 // nsGeolocationService
 ////////////////////////////////////////////////////
 NS_INTERFACE_MAP_BEGIN(nsGeolocationService)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIGeolocationUpdate)
   NS_INTERFACE_MAP_ENTRY(nsIGeolocationUpdate)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
 NS_INTERFACE_MAP_END
@@ -672,23 +668,21 @@ nsGeolocationService::StartDevice()
   if (!sGeoEnabled)
     return NS_ERROR_NOT_AVAILABLE;
 
   // we do not want to keep the geolocation devices online
   // indefinitely.  Close them down after a reasonable period of
   // inactivivity
   SetDisconnectTimer();
 
-#ifdef MOZ_IPC
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     ContentChild* cpc = ContentChild::GetSingleton();
     cpc->SendAddGeolocationListener();
     return NS_OK;
   }
-#endif
 
   // Start them up!
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (!obs)
     return NS_ERROR_FAILURE;
 
   for (PRInt32 i = 0; i < mProviders.Count(); i++) {
     mProviders[i]->Startup();
@@ -717,23 +711,21 @@ nsGeolocationService::SetDisconnectTimer
 void 
 nsGeolocationService::StopDevice()
 {
   if(mDisconnectTimer) {
     mDisconnectTimer->Cancel();
     mDisconnectTimer = nsnull;
   }
 
-#ifdef MOZ_IPC
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     ContentChild* cpc = ContentChild::GetSingleton();
     cpc->SendRemoveGeolocationListener();
     return; // bail early
   }
-#endif
 
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (!obs)
     return;
 
   for (PRInt32 i = 0; i < mProviders.Count(); i++) {
     mProviders[i]->Shutdown();
     obs->NotifyObservers(mProviders[i],
@@ -1044,17 +1036,16 @@ nsGeolocation::WindowOwnerStillExists()
   }
 
   return PR_TRUE;
 }
 
 bool
 nsGeolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request)
 {
-#ifdef MOZ_IPC
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mOwner);
     if (!window)
       return true;
 
     // because owner implements nsITabChild, we can assume that it is
     // the one and only TabChild.
     TabChild* child = GetTabChildFrom(window->GetDocShell());
@@ -1066,17 +1057,16 @@ nsGeolocation::RegisterRequestWithPrompt
     request->AddRef();
 
     nsCString type = NS_LITERAL_CSTRING("geolocation");
     child->SendPContentPermissionRequestConstructor(request, type, IPC::URI(mURI));
     
     request->Sendprompt();
     return true;
   }
-#endif
 
   if (nsContentUtils::GetBoolPref("geo.prompt.testing", PR_FALSE))
   {
     nsCOMPtr<nsIRunnable> ev  = new RequestAllowEvent(nsContentUtils::GetBoolPref("geo.prompt.testing.allow", PR_FALSE), request);
     NS_DispatchToMainThread(ev);
     return true;
   }
 
--- a/dom/src/geolocation/nsGeolocation.h
+++ b/dom/src/geolocation/nsGeolocation.h
@@ -32,21 +32,19 @@
  * 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 nsGeoLocation_h
 #define nsGeoLocation_h
 
-#ifdef MOZ_IPC
 #include "mozilla/dom/PContentPermissionRequestChild.h"
 // Microsoft's API Name hackery sucks
 #undef CreateEvent
-#endif
 
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsCOMArray.h"
 #include "nsTArray.h"
 #include "nsITimer.h"
 #include "nsIObserver.h"
 #include "nsIURI.h"
@@ -62,29 +60,25 @@
 #include "nsIDOMGeoPositionOptions.h"
 #include "nsIDOMNavigatorGeolocation.h"
 
 #include "nsPIDOMWindow.h"
 
 #include "nsIGeolocationProvider.h"
 #include "nsIContentPermissionPrompt.h"
 
-#ifdef MOZ_IPC
 #include "PCOMContentPermissionRequestChild.h"
-#endif
 
 class nsGeolocationService;
 class nsGeolocation;
 
 class nsGeolocationRequest
  : public nsIContentPermissionRequest
  , public nsITimerCallback
-#ifdef MOZ_IPC
  , public PCOMContentPermissionRequestChild
-#endif
 {
  public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_NSICONTENTPERMISSIONREQUEST
   NS_DECL_NSITIMERCALLBACK
 
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsGeolocationRequest, nsIContentPermissionRequest)
 
@@ -102,20 +96,18 @@ class nsGeolocationRequest
   void SendLocation(nsIDOMGeoPosition* location);
   void MarkCleared();
   PRBool IsActive() {return !mCleared;}
   PRBool Allowed() {return mAllowed;}
   void SetTimeoutTimer();
 
   ~nsGeolocationRequest();
 
-#ifdef MOZ_IPC
   bool Recv__delete__(const bool& allow);
   void IPDLRelease() { Release(); }
-#endif
 
  private:
 
   void NotifyError(PRInt16 errorCode);
   PRPackedBool mAllowed;
   PRPackedBool mCleared;
   PRPackedBool mIsWatchPositionRequest;
 
--- a/dom/src/json/nsJSON.cpp
+++ b/dom/src/json/nsJSON.cpp
@@ -292,17 +292,17 @@ nsJSON::EncodeInternal(nsJSONWriter *wri
 nsJSONWriter::nsJSONWriter() : mStream(nsnull),
                                mBuffer(nsnull),
                                mBufferCount(0),
                                mDidWrite(PR_FALSE),
                                mEncoder(nsnull)
 {
 }
 
-nsJSONWriter::nsJSONWriter(nsIOutputStream *aStream) : mStream(nsnull),
+nsJSONWriter::nsJSONWriter(nsIOutputStream *aStream) : mStream(aStream),
                                                        mBuffer(nsnull),
                                                        mBufferCount(0),
                                                        mDidWrite(PR_FALSE),
                                                        mEncoder(nsnull)
 {
 }
 
 nsJSONWriter::~nsJSONWriter()
--- a/dom/src/json/test/unit/test_encode.js
+++ b/dom/src/json/test/unit/test_encode.js
@@ -133,21 +133,22 @@ function testOutputStreams() {
 
       // all ascii with no BOMs, so this will work
       do_check_eq(utf16LEFile.fileSize / 2, utf8File.fileSize);
       do_check_eq(utf16LEFile.fileSize, utf16BEFile.fileSize);
     }
   }
 
   // check BOMs
-  var f = writeToFile({},"UTF-8", true);
+  // the clone() calls are there to work around -- bug 410005
+  var f = writeToFile({},"UTF-8", true).clone();
   do_check_eq(f.fileSize, 5);
-  var f = writeToFile({},"UTF-16LE", true);
+  var f = writeToFile({},"UTF-16LE", true).clone();
   do_check_eq(f.fileSize, 6);
-  var f = writeToFile({},"UTF-16BE", true);
+  var f = writeToFile({},"UTF-16BE", true).clone();
   do_check_eq(f.fileSize, 6);
   
   outputDir.remove(true);
 }
 
 function throwingToJSON() {
   var a = {
     "b": 1,
@@ -158,12 +159,11 @@ function throwingToJSON() {
     var y = nativeJSON.encode(a);
   } catch (ex) {}
 }
 
 function run_test() {
   testStringEncode();
   throwingToJSON();
   
-  // failing on windows -- bug 410005
-  // testOutputStreams();
+  testOutputStreams();
   
 }
--- a/dom/src/notification/nsDesktopNotification.cpp
+++ b/dom/src/notification/nsDesktopNotification.cpp
@@ -31,25 +31,23 @@
  * 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 "nsDesktopNotification.h"
 
-#ifdef MOZ_IPC
 #include "nsContentPermissionHelper.h"
 #include "nsXULAppAPI.h"
 
 #include "mozilla/dom/PBrowserChild.h"
 #include "TabChild.h"
 
 using namespace mozilla::dom;
-#endif
 
 /* ------------------------------------------------------------------------ */
 /* AlertServiceObserver                                                     */
 /* ------------------------------------------------------------------------ */
 
 NS_IMPL_ISUPPORTS1(AlertServiceObserver, nsIObserver)
 
 /* ------------------------------------------------------------------------ */
@@ -124,17 +122,16 @@ nsDOMDesktopNotification::nsDOMDesktopNo
       nsContentUtils::GetBoolPref("notification.prompt.testing.allow", PR_TRUE)) {
     mAllow = PR_TRUE;
     return;
   }
 
   nsRefPtr<nsDesktopNotificationRequest> request = new nsDesktopNotificationRequest(this);
 
   // if we are in the content process, then remote it to the parent.
-#ifdef MOZ_IPC
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
 
     // if for some reason mOwner is null, just silently
     // bail.  The user will not see a notification, and that
     // is fine.
     if (!mOwner)
       return;
 
@@ -147,17 +144,16 @@ nsDOMDesktopNotification::nsDOMDesktopNo
     request->AddRef();
 
     nsCString type = NS_LITERAL_CSTRING("desktop-notification");
     child->SendPContentPermissionRequestConstructor(request, type, IPC::URI(mURI));
     
     request->Sendprompt();
     return;
   }
-#endif
 
   // otherwise, dispatch it
   NS_DispatchToMainThread(request);
 
 }
 
 nsDOMDesktopNotification::~nsDOMDesktopNotification()
 {
--- a/dom/src/notification/nsDesktopNotification.h
+++ b/dom/src/notification/nsDesktopNotification.h
@@ -32,20 +32,17 @@
  * 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 nsDesktopNotification_h
 #define nsDesktopNotification_h
 
-#ifdef MOZ_IPC
 #include "PCOMContentPermissionRequestChild.h"
-#endif
-
 
 #include "nsDOMClassInfo.h"
 #include "nsIJSContextStack.h"
 
 #include "nsIAlertsService.h"
 
 #include "nsIDOMDesktopNotification.h"
 #include "nsIDOMEventTarget.h"
@@ -150,20 +147,18 @@ protected:
   PRBool mAllow;
   PRBool mShowHasBeenCalled;
 };
 
 /*
  * Simple Request
  */
 class nsDesktopNotificationRequest : public nsIContentPermissionRequest,
-                                     public nsRunnable
-#ifdef MOZ_IPC
- , public PCOMContentPermissionRequestChild
-#endif
+                                     public nsRunnable, 
+                                     public PCOMContentPermissionRequestChild
 
 {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSICONTENTPERMISSIONREQUEST
 
   nsDesktopNotificationRequest(nsDOMDesktopNotification* notification)
     : mDesktopNotification(notification) {}
@@ -177,28 +172,25 @@ class nsDesktopNotificationRequest : pub
     }
     return NS_OK;
   }
 
   ~nsDesktopNotificationRequest()
   {
   }
 
-#ifdef MOZ_IPC
-
  bool Recv__delete__(const bool& allow)
  {
    if (allow)
      (void) Allow();
    else
      (void) Cancel();
    return true;
  }
  void IPDLRelease() { Release(); }
-#endif
 
   nsRefPtr<nsDOMDesktopNotification> mDesktopNotification;
 };
 
 class AlertServiceObserver: public nsIObserver
 {
  public:
   NS_DECL_ISUPPORTS
--- a/dom/src/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/src/offline/nsDOMOfflineResourceList.cpp
@@ -52,24 +52,19 @@
 #include "nsContentUtils.h"
 #include "nsIJSContextStack.h"
 #include "nsEventDispatcher.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIObserverService.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIWebNavigation.h"
 
-#ifdef MOZ_IPC
 #include "nsXULAppAPI.h"
 #define IS_CHILD_PROCESS() \
     (GeckoProcessType_Default != XRE_GetProcessType())
-#else
-#define IS_CHILD_PROCESS() \
-    (false)
-#endif
 
 // Event names
 
 #define CHECKING_STR    "checking"
 #define ERROR_STR       "error"
 #define NOUPDATE_STR    "noupdate"
 #define DOWNLOADING_STR "downloading"
 #define PROGRESS_STR    "progress"
--- a/dom/src/storage/Makefile.in
+++ b/dom/src/storage/Makefile.in
@@ -50,23 +50,21 @@ LIBXUL_LIBRARY = 1
 
 CPPSRCS =                  \
        nsDOMStorage.cpp    \
        $(NULL)
 
 ifdef MOZ_STORAGE
 CPPSRCS += nsDOMStorageDBWrapper.cpp nsDOMStoragePersistentDB.cpp nsDOMStorageMemoryDB.cpp
 
-ifdef MOZ_IPC
 CPPSRCS += StorageChild.cpp StorageParent.cpp
 
 EXPORTS_NAMESPACES = mozilla/dom
 EXPORTS_mozilla/dom = StorageChild.h StorageParent.h
 endif
-endif
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 LOCAL_INCLUDES = \
                 -I$(topsrcdir)/dom/base \
 		-I$(topsrcdir)/content/events/src
 
--- a/dom/src/storage/nsDOMStorage.cpp
+++ b/dom/src/storage/nsDOMStorage.cpp
@@ -35,22 +35,20 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "StorageChild.h"
 #include "StorageParent.h"
 #include "nsXULAppAPI.h"
 using mozilla::dom::StorageChild;
-#endif
 
 #include "prnetdb.h"
 #include "nsCOMPtr.h"
 #include "nsDOMError.h"
 #include "nsDOMClassInfo.h"
 #include "nsUnicharUtils.h"
 #include "nsIDocument.h"
 #include "nsDOMStorage.h"
@@ -266,21 +264,19 @@ nsDOMStorageManager::Initialize()
   if (!gStorageManager->mStorages.Init()) {
     delete gStorageManager;
     gStorageManager = nsnull;
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   NS_ADDREF(gStorageManager);
 
-#ifdef MOZ_IPC
   // No observers needed in non-chrome
   if (XRE_GetProcessType() != GeckoProcessType_Default)
     return NS_OK;
-#endif
 
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (!os)
     return NS_OK;
 
   os->AddObserver(gStorageManager, "cookie-changed", PR_FALSE);
   os->AddObserver(gStorageManager, "offline-app-removed", PR_FALSE);
   os->AddObserver(gStorageManager, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_FALSE);
@@ -1350,37 +1346,32 @@ DOMStorageImpl::Clear(bool aCallerSecure
 }
 
 nsDOMStorage::nsDOMStorage()
   : mStorageType(nsPIDOMStorage::Unknown)
   , mEventBroadcaster(nsnull)
 {
   mSecurityChecker = this;
 
-#ifdef MOZ_IPC
   if (XRE_GetProcessType() != GeckoProcessType_Default)
     mStorageImpl = new StorageChild(this);
   else
-#endif
-  mStorageImpl = new DOMStorageImpl(this);
+    mStorageImpl = new DOMStorageImpl(this);
 }
 
 nsDOMStorage::nsDOMStorage(nsDOMStorage& aThat)
   : mStorageType(aThat.mStorageType)
   , mEventBroadcaster(nsnull)
 {
   mSecurityChecker = this;
 
-#ifdef MOZ_IPC
   if (XRE_GetProcessType() != GeckoProcessType_Default) {
     StorageChild* other = static_cast<StorageChild*>(aThat.mStorageImpl.get());
     mStorageImpl = new StorageChild(this, *other);
-  } else
-#endif
-  {
+  } else {
     DOMStorageImpl* other = static_cast<DOMStorageImpl*>(aThat.mStorageImpl.get());
     mStorageImpl = new DOMStorageImpl(this, *other);
   }
 }
 
 nsDOMStorage::~nsDOMStorage()
 {
 }
--- a/dom/src/threads/test/WorkerTest.jsm
+++ b/dom/src/threads/test/WorkerTest.jsm
@@ -47,10 +47,11 @@ XPCOMUtils.defineLazyServiceGetter(this,
                                    "nsIWorkerFactory");
 
 const WorkerTest = {
   go: function(message, messageCallback, errorCallback) {
     let worker = workerFactory.newChromeWorker("WorkerTest_worker.js");
     worker.onmessage = messageCallback;
     worker.onerror = errorCallback;
     worker.postMessage(message);
+    return worker;
   }
 };
--- a/dom/src/threads/test/test_chromeWorkerJSM.xul
+++ b/dom/src/threads/test/test_chromeWorkerJSM.xul
@@ -49,29 +49,38 @@
 
   <script type="application/javascript">
   <![CDATA[
 
     function test()
     {
       SimpleTest.waitForExplicitFinish();
 
+      var worker;
+
+      function done()
+      {
+        worker = null;
+        SimpleTest.finish();
+      }
+
       function messageCallback(event) {
         is(event.data, "Done", "Correct message");
-        SimpleTest.finish();
+        done();
       }
 
       function errorCallback(event) {
         ok(false, "Worker had an error: " + event.message);
-        SimpleTest.finish();
+        done();
       }
 
       Components.utils.import("resource://gre/modules/WorkerTest.jsm");
 
-      WorkerTest.go(window.location.href, messageCallback, errorCallback);
+      worker = WorkerTest.go(window.location.href, messageCallback,
+                             errorCallback);
     }
 
   ]]>
   </script>
 
   <body xmlns="http://www.w3.org/1999/xhtml">
     <p id="display"></p>
     <div id="content" style="display:none;"></div>
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -4754,47 +4754,48 @@ nsEditor::CreateTxnForDeleteCharacter(ns
                                       PRUint32              aOffset,
                                       nsIEditor::EDirection aDirection,
                                       DeleteTextTxn       **aTxn)
 {
   NS_ASSERTION(aDirection == eNext || aDirection == ePrevious,
                "invalid direction");
   nsAutoString data;
   aData->GetData(data);
-  PRUint32 segOffset, segLength = 1;
+  PRUint32 segOffset = aOffset, segLength = 1;
   if (aDirection == eNext) {
-    segOffset = aOffset;
     if (segOffset + 1 < data.Length() &&
         NS_IS_HIGH_SURROGATE(data[segOffset]) &&
         NS_IS_LOW_SURROGATE(data[segOffset+1])) {
       // delete both halves of the surrogate pair
       ++segLength;
     }
-  } else {
-    segOffset = aOffset - 1;
+  } else if (aOffset > 0) {
+    --segOffset;
     if (segOffset > 0 &&
-        NS_IS_LOW_SURROGATE(data[segOffset]) &&
-        NS_IS_HIGH_SURROGATE(data[segOffset-1])) {
+      NS_IS_LOW_SURROGATE(data[segOffset]) &&
+      NS_IS_HIGH_SURROGATE(data[segOffset-1])) {
       ++segLength;
       --segOffset;
     }
+  } else {
+    return NS_ERROR_FAILURE;
   }
   return CreateTxnForDeleteText(aData, segOffset, segLength, aTxn);
 }
 
 //XXX: currently, this doesn't handle edge conditions because GetNext/GetPrior are not implemented
 NS_IMETHODIMP
 nsEditor::CreateTxnForDeleteInsertionPoint(nsIDOMRange          *aRange, 
                                            nsIEditor::EDirection aAction,
                                            EditAggregateTxn     *aTxn,
                                            nsIDOMNode          **aNode,
                                            PRInt32              *aOffset,
                                            PRInt32              *aLength)
 {
-  NS_ASSERTION(aAction == eNext || aAction == ePrevious, "invalid action");
+  NS_ASSERTION(aAction != eNone, "invalid action");
 
   // get the node and offset of the insertion point
   nsCOMPtr<nsIDOMNode> node;
   nsresult result = aRange->GetStartContainer(getter_AddRefs(node));
   NS_ENSURE_SUCCESS(result, result);
 
   PRInt32 offset;
   result = aRange->GetStartOffset(&offset);
--- a/editor/libeditor/base/tests/Makefile.in
+++ b/editor/libeditor/base/tests/Makefile.in
@@ -48,11 +48,18 @@ include $(topsrcdir)/config/rules.mk
 		test_bug502673.html \
 		test_selection_move_commands.xul \
 		test_bug514156.html \
 		test_bug567213.html \
 		file_bug586662.html \
 		test_bug586662.html \
 		$(NULL)
 
+_CHROME_TEST_FILES = \
+		test_bug646194.xul \
+		$(NULL)
+
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
+libs:: $(_CHROME_TEST_FILES)
+	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
+
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/base/tests/test_bug646194.xul
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin"
+                 type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+                 type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=646194
+-->
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        title="Mozilla Bug 646194" onload="runTest();">
+  <script type="application/javascript"
+          src="chrome://mochikit/content/MochiKit/packed.js"/>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=646194"
+     target="_blank">Mozilla Bug 646194</a>
+  <p/>
+  <iframe id="i" src="data:text/html,&lt;div contenteditable=true id=t&gt;test me now&lt;/div&gt;"/>
+  <p/>
+  <pre id="test">
+  </pre>
+  </body>
+  <script class="testbody" type="application/javascript">
+  <![CDATA[
+
+function runTest() {
+  function doCommand(aCmd) {
+    var controller = top.document.commandDispatcher
+                     .getControllerForCommand(aCmd);
+    ok((controller && controller.isCommandEnabled(aCmd)), "command available");
+    controller.doCommand(aCmd);
+  }
+
+  var i = document.getElementById("i");
+  i.focus();
+  var doc = i.contentDocument;
+  var t = doc.getElementById("t");
+  t.focus();
+  // put the caret at the end
+  getSelection().collapse(t.firstChild, 11);
+
+  // Simulate pression Option+Delete on Mac
+  // We do things this way because not every platform can invoke this
+  // command using the available key bindings.
+  doCommand("cmd_wordPrevious");
+  doCommand("cmd_wordPrevious");
+  doCommand("cmd_deleteWordBackward");
+  doCommand("cmd_deleteWordBackward");
+
+  // If we reach here, we haven't crashed.  Phew!
+  // But let's check the value too, now that we're here.
+  is(t.textContent, "me now", "The command has worked correctly");
+
+  SimpleTest.finish();
+}
+
+SimpleTest.waitForExplicitFinish();
+]]>
+</script>
+</window>
--- a/embedding/browser/webBrowser/nsWebBrowser.cpp
+++ b/embedding/browser/webBrowser/nsWebBrowser.cpp
@@ -1224,20 +1224,17 @@ NS_IMETHODIMP nsWebBrowser::Create()
    // that always gets called (even for subframes) for any bubbling event.
 
     if (!mInitInfo->sessionHistory) {
         mInitInfo->sessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID, &rv);
         NS_ENSURE_SUCCESS(rv, rv);
     }
    mDocShellAsNav->SetSessionHistory(mInitInfo->sessionHistory);
 
-#ifdef MOZ_IPC
-   if (XRE_GetProcessType() == GeckoProcessType_Default)
-#endif
-   {
+   if (XRE_GetProcessType() == GeckoProcessType_Default) {
        // Hook up global history. Do not fail if we can't - just warn.
        rv = EnableGlobalHistory(mShouldEnableHistory);
        NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "EnableGlobalHistory() failed");
    }
 
    NS_ENSURE_SUCCESS(mDocShellAsWin->Create(), NS_ERROR_FAILURE);
 
     // Hook into the OnSecurityChange() notification for lock/unlock icon
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
+++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
@@ -57,17 +57,16 @@
 #include "nsIUploadChannel.h"
 #include "nsICachingChannel.h"
 #include "nsIFileChannel.h"
 #include "nsEscape.h"
 #include "nsUnicharUtils.h"
 #include "nsIStringEnumerator.h"
 #include "nsCRT.h"
 #include "nsSupportsArray.h"
-#include "nsInt64.h"
 #include "nsContentCID.h"
 #include "nsStreamUtils.h"
 
 #include "nsCExternalHandlerService.h"
 
 #include "nsIURL.h"
 #include "nsIFileURL.h"
 #include "nsIDocument.h"
@@ -163,18 +162,18 @@ struct URIData
 };
 
 // Information about the output stream
 struct OutputData
 {
     nsCOMPtr<nsIURI> mFile;
     nsCOMPtr<nsIURI> mOriginalLocation;
     nsCOMPtr<nsIOutputStream> mStream;
-    nsInt64 mSelfProgress;
-    nsInt64 mSelfProgressMax;
+    PRInt64 mSelfProgress;
+    PRInt64 mSelfProgressMax;
     PRPackedBool mCalcFileExt;
 
     OutputData(nsIURI *aFile, nsIURI *aOriginalLocation, PRBool aCalcFileExt) :
         mFile(aFile),
         mOriginalLocation(aOriginalLocation),
         mSelfProgress(0),
         mSelfProgressMax(10000),
         mCalcFileExt(aCalcFileExt)
@@ -187,18 +186,18 @@ struct OutputData
             mStream->Close();
         }
     }
 };
 
 struct UploadData
 {
     nsCOMPtr<nsIURI> mFile;
-    nsInt64 mSelfProgress;
-    nsInt64 mSelfProgressMax;
+    PRInt64 mSelfProgress;
+    PRInt64 mSelfProgressMax;
 
     UploadData(nsIURI *aFile) :
         mFile(aFile),
         mSelfProgress(0),
         mSelfProgressMax(10000)
     {
     }
 };
@@ -239,16 +238,18 @@ nsWebBrowserPersist::nsWebBrowserPersist
     mJustStartedLoading(PR_TRUE),
     mCompleted(PR_FALSE),
     mStartSaving(PR_FALSE),
     mReplaceExisting(PR_TRUE),
     mSerializingOutput(PR_FALSE),
     mPersistFlags(kDefaultPersistFlags),
     mPersistResult(NS_OK),
     mWrapColumn(72),
+    mTotalCurrentProgress(0),
+    mTotalMaxProgress(0),
     mEncodingFlags(0)
 {
 }
 
 nsWebBrowserPersist::~nsWebBrowserPersist()
 {
     Cleanup();
 }
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h
+++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.h
@@ -53,17 +53,16 @@
 #include "nsIDocumentEncoder.h"
 #include "nsITransport.h"
 #include "nsIProgressEventSink.h"
 #include "nsILocalFile.h"
 #include "nsIWebProgressListener2.h"
 
 #include "nsHashtable.h"
 #include "nsTArray.h"
-#include "nsInt64.h"
 
 #include "nsCWebBrowserPersist.h"
 
 class nsEncoderNodeFixup;
 class nsIStorageStream;
 
 struct URIData;
 struct CleanupData;
@@ -235,18 +234,18 @@ private:
     PRPackedBool              mCancel;
     PRPackedBool              mJustStartedLoading;
     PRPackedBool              mCompleted;
     PRPackedBool              mStartSaving;
     PRPackedBool              mReplaceExisting;
     PRPackedBool              mSerializingOutput;
     PRUint32                  mPersistFlags;
     PRUint32                  mPersistResult;
-    nsInt64                   mTotalCurrentProgress;
-    nsInt64                   mTotalMaxProgress;
+    PRInt64                   mTotalCurrentProgress;
+    PRInt64                   mTotalMaxProgress;
     PRInt16                   mWrapColumn;
     PRUint32                  mEncodingFlags;
     nsString                  mContentType;
 };
 
 // Helper class does node fixup during persistence
 class nsEncoderNodeFixup : public nsIDocumentEncoderNodeFixup
 {
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -32,21 +32,19 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/unused.h"
-#endif
 #include "nsPermissionManager.h"
 #include "nsPermission.h"
 #include "nsCRT.h"
 #include "nsNetUtil.h"
 #include "nsCOMArray.h"
 #include "nsArrayEnumerator.h"
 #include "nsTArray.h"
 #include "nsReadableUtils.h"
@@ -58,17 +56,16 @@
 #include "mozIStorageStatement.h"
 #include "mozIStorageConnection.h"
 #include "mozStorageHelper.h"
 #include "mozStorageCID.h"
 #include "nsXULAppAPI.h"
 
 static nsPermissionManager *gPermissionManager = nsnull;
 
-#ifdef MOZ_IPC
 using mozilla::dom::ContentParent;
 using mozilla::dom::ContentChild;
 using mozilla::unused; // ha!
 
 static PRBool
 IsChildProcess()
 {
   return XRE_GetProcessType() == GeckoProcessType_Content;
@@ -103,17 +100,16 @@ ParentProcess()
     ContentParent* cpc = ContentParent::GetSingleton();
     if (!cpc)
       NS_RUNTIMEABORT("Content Process is NULL!");
     return cpc;
   }
 
   return nsnull;
 }
-#endif
 
 #define ENSURE_NOT_CHILD_PROCESS_(onError) \
   PR_BEGIN_MACRO \
   if (IsChildProcess()) { \
     NS_ERROR("Cannot perform action in content process!"); \
     onError \
   } \
   PR_END_MACRO
@@ -169,19 +165,17 @@ static const char kPermissionsFileName[]
 static const char kHostpermFileName[] = "hostperm.1";
 
 static const char kPermissionChangeNotification[] = PERM_CHANGE_NOTIFICATION;
 
 NS_IMPL_ISUPPORTS3(nsPermissionManager, nsIPermissionManager, nsIObserver, nsISupportsWeakReference)
 
 nsPermissionManager::nsPermissionManager()
  : mLargestID(0)
-#ifdef MOZ_IPC
  , mUpdateChildProcess(PR_FALSE)
-#endif
 {
 }
 
 nsPermissionManager::~nsPermissionManager()
 {
   RemoveAllFromMemory();
 }
 
@@ -228,32 +222,30 @@ nsPermissionManager::Init()
   }
 
   mObserverService = do_GetService("@mozilla.org/observer-service;1", &rv);
   if (NS_SUCCEEDED(rv)) {
     mObserverService->AddObserver(this, "profile-before-change", PR_TRUE);
     mObserverService->AddObserver(this, "profile-do-change", PR_TRUE);
   }
 
-#ifdef MOZ_IPC
   if (IsChildProcess()) {
     // Get the permissions from the parent process
     InfallibleTArray<IPC::Permission> perms;
     ChildProcess()->SendReadPermissions(&perms);
 
     for (PRUint32 i = 0; i < perms.Length(); i++) {
       const IPC::Permission &perm = perms[i];
       AddInternal(perm.host, perm.type, perm.capability, 0, perm.expireType,
                   perm.expireTime, eNotify, eNoDBOperation);
     }
 
     // Stop here; we don't need the DB in the child process
     return NS_OK;
   }
-#endif
 
   // ignore failure here, since it's non-fatal (we can run fine without
   // persistent storage - e.g. if there's no profile).
   // XXX should we tell the user about this?
   InitDB(PR_FALSE);
 
   return NS_OK;
 }
@@ -435,19 +427,17 @@ nsPermissionManager::CreateTable()
 
 NS_IMETHODIMP
 nsPermissionManager::Add(nsIURI     *aURI,
                          const char *aType,
                          PRUint32    aPermission,
                          PRUint32    aExpireType,
                          PRInt64     aExpireTime)
 {
-#ifdef MOZ_IPC
   ENSURE_NOT_CHILD_PROCESS;
-#endif
 
   NS_ENSURE_ARG_POINTER(aURI);
   NS_ENSURE_ARG_POINTER(aType);
   NS_ENSURE_TRUE(aExpireType == nsIPermissionManager::EXPIRE_NEVER ||
                  aExpireType == nsIPermissionManager::EXPIRE_TIME ||
                  aExpireType == nsIPermissionManager::EXPIRE_SESSION,
                  NS_ERROR_INVALID_ARG);
 
@@ -471,27 +461,25 @@ nsPermissionManager::AddInternal(const n
                                  const nsAFlatCString &aType,
                                  PRUint32              aPermission,
                                  PRInt64               aID,
                                  PRUint32              aExpireType,
                                  PRInt64               aExpireTime,
                                  NotifyOperationType   aNotifyOperation,
                                  DBOperationType       aDBOperation)
 {
-#ifdef MOZ_IPC
   if (!IsChildProcess()) {
     // In the parent, send the update now, if the child is ready
     if (mUpdateChildProcess) {
       IPC::Permission permission((aHost),
                                  (aType),
                                  aPermission, aExpireType, aExpireTime);
       unused << ParentProcess()->SendAddPermission(permission);
     }
   }
-#endif
 
   if (!gHostArena) {
     gHostArena = new PLArenaPool;
     if (!gHostArena)
       return NS_ERROR_OUT_OF_MEMORY;    
     PL_INIT_ARENA_POOL(gHostArena, "PermissionHostArena", HOST_ARENA_SIZE);
   }
 
@@ -622,19 +610,17 @@ nsPermissionManager::AddInternal(const n
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPermissionManager::Remove(const nsACString &aHost,
                             const char       *aType)
 {
-#ifdef MOZ_IPC
   ENSURE_NOT_CHILD_PROCESS;
-#endif
 
   NS_ENSURE_ARG_POINTER(aType);
 
   // AddInternal() handles removal, just let it do the work
   return AddInternal(PromiseFlatCString(aHost),
                      nsDependentCString(aType),
                      nsIPermissionManager::UNKNOWN_ACTION,
                      0,
@@ -642,19 +628,17 @@ nsPermissionManager::Remove(const nsACSt
                      0,
                      eNotify,
                      eWriteToDB);
 }
 
 NS_IMETHODIMP
 nsPermissionManager::RemoveAll()
 {
-#ifdef MOZ_IPC
   ENSURE_NOT_CHILD_PROCESS;
-#endif
 
   nsresult rv = RemoveAllInternal();
   NotifyObservers(nsnull, NS_LITERAL_STRING("cleared").get());
   return rv;
 }
 
 nsresult
 nsPermissionManager::RemoveAllInternal()
@@ -801,34 +785,30 @@ AddPermissionsToList(nsHostEntry *entry,
     data->array->AppendObject(perm);
   }
 
   return PL_DHASH_NEXT;
 }
 
 NS_IMETHODIMP nsPermissionManager::GetEnumerator(nsISimpleEnumerator **aEnum)
 {
-#ifdef MOZ_IPC
   ENSURE_NOT_CHILD_PROCESS;
-#endif
 
   // roll an nsCOMArray of all our permissions, then hand out an enumerator
   nsCOMArray<nsIPermission> array;
   nsGetEnumeratorData data(&array, &mTypeArray);
 
   mHostTable.EnumerateEntries(AddPermissionsToList, &data);
 
   return NS_NewArrayEnumerator(aEnum, array);
 }
 
 NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
 {
-#ifdef MOZ_IPC
   ENSURE_NOT_CHILD_PROCESS;
-#endif
 
   if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
     // The profile is about to change,
     // or is going away because the application is shutting down.
     if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get())) {
       // clear the permissions file
       RemoveAllInternal();
     } else {
@@ -915,19 +895,17 @@ nsPermissionManager::NotifyObservers(nsI
     mObserverService->NotifyObservers(aPermission,
                                       kPermissionChangeNotification,
                                       aData);
 }
 
 nsresult
 nsPermissionManager::Read()
 {
-#ifdef MOZ_IPC
   ENSURE_NOT_CHILD_PROCESS;
-#endif
 
   nsresult rv;
 
   // delete expired permissions before we read in the db
   {
     // this deletion has its own scope so the write lock is released when done.
     nsCOMPtr<mozIStorageStatement> stmtDeleteExpired;
     rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
@@ -985,19 +963,17 @@ nsPermissionManager::Read()
   return NS_OK;
 }
 
 static const char kMatchTypeHost[] = "host";
 
 nsresult
 nsPermissionManager::Import()
 {
-#ifdef MOZ_IPC
   ENSURE_NOT_CHILD_PROCESS;
-#endif
 
   nsresult rv;
 
   nsCOMPtr<nsIFile> permissionsFile;
   rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(permissionsFile));
   if (NS_FAILED(rv)) return rv;
 
   rv = permissionsFile->AppendNative(NS_LITERAL_CSTRING(kHostpermFileName));
@@ -1093,19 +1069,17 @@ nsPermissionManager::UpdateDB(OperationT
                               mozIStorageStatement* aStmt,
                               PRInt64               aID,
                               const nsACString     &aHost,
                               const nsACString     &aType,
                               PRUint32              aPermission,
                               PRUint32              aExpireType,
                               PRInt64               aExpireTime)
 {
-#ifdef MOZ_IPC
   ENSURE_NOT_CHILD_PROCESS_NORET;
-#endif
 
   nsresult rv;
 
   // no statement is ok - just means we don't have a profile
   if (!aStmt)
     return;
 
   switch (aOp) {
--- a/extensions/cookie/nsPermissionManager.h
+++ b/extensions/cookie/nsPermissionManager.h
@@ -246,27 +246,25 @@ private:
 
   nsTHashtable<nsHostEntry>    mHostTable;
   // a unique, monotonically increasing id used to identify each database entry
   PRInt64                      mLargestID;
 
   // An array to store the strings identifying the different types.
   nsTArray<nsCString>          mTypeArray;
 
-#ifdef MOZ_IPC
   // Whether we should update the child process with every change to a
   // permission. This is set to true once the child is ready to receive
   // such updates.
   PRBool                       mUpdateChildProcess;
 
 public:
   void ChildRequestPermissions()
   {
     mUpdateChildProcess = PR_TRUE;
   }
-#endif
 };
 
 // {4F6B5E00-0C36-11d5-A535-0010A401EB10}
 #define NS_PERMISSIONMANAGER_CID \
 { 0x4f6b5e00, 0xc36, 0x11d5, { 0xa5, 0x35, 0x0, 0x10, 0xa4, 0x1, 0xeb, 0x10 } }
 
 #endif /* nsPermissionManager_h__ */
--- a/extensions/cookie/test/Makefile.in
+++ b/extensions/cookie/test/Makefile.in
@@ -91,17 +91,15 @@ MODULE          = test_cookies
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
 libs:: $(_BROWSER_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
 
 XPCSHELL_TESTS = unit
 
-ifdef MOZ_IPC
 # FIXME/bug 575918: out-of-process xpcshell is broken on OS X
 ifneq ($(OS_ARCH),Darwin)
 XPCSHELL_TESTS += unit_ipc
 endif
-endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/gfx/Makefile.in
+++ b/gfx/Makefile.in
@@ -54,23 +54,19 @@ endif
 # be built first so the order is reversed.
 ifndef BUILD_STATIC_LIBS
 DIRS		+= ycbcr
 endif
 
 DIRS		+= angle
 
 
-DIRS		+= src qcms layers harfbuzz/src ots/src thebes
+DIRS		+= src qcms layers harfbuzz/src ots/src thebes ipc
 
 ifdef BUILD_STATIC_LIBS
 DIRS		+= ycbcr
 endif
 
-ifdef MOZ_IPC
-DIRS		+= ipc
-endif
-
 ifdef ENABLE_TESTS
 TOOL_DIRS	+= tests
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/gfx/ipc/Makefile.in
+++ b/gfx/ipc/Makefile.in
@@ -37,18 +37,16 @@
 
 DEPTH       = ../..
 topsrcdir   = @top_srcdir@
 srcdir      = @srcdir@
 VPATH       = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-ifdef MOZ_IPC
-
 MODULE             = gfxipc
 LIBRARY_NAME       = gfxipc_s
 FORCE_STATIC_LIB   = 1
 LIBXUL_LIBRARY     = 1
 EXPORT_LIBRARY     = 1
 
 EXPORTS_NAMESPACES = mozilla/gfx
 
@@ -68,13 +66,11 @@ CPPSRCS += \
   SharedDIBWin.cpp \
   SharedDIBSurface.cpp \
   $(NULL)
 endif
 
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 
-endif
-
 include $(topsrcdir)/config/rules.mk
 
 CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -33,19 +33,17 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
-# include "mozilla/layers/ShadowLayers.h"
-#endif  // MOZ_IPC
+#include "mozilla/layers/ShadowLayers.h"
 
 #include "ImageLayers.h"
 #include "Layers.h"
 #include "gfxPlatform.h"
 #include "ReadbackLayer.h"
 #include "gfxUtils.h"
 
 using namespace mozilla::layers;
@@ -236,17 +234,16 @@ Layer::CanUseOpaqueSurface()
   // doesn't need an alpha channel, we can use an opaque surface for this
   // layer too. Any transparent areas must be covered by something else
   // in the container.
   ContainerLayer* parent = GetParent();
   return parent && parent->GetFirstChild() == this &&
     parent->CanUseOpaqueSurface();
 }
 
-#ifdef MOZ_IPC
 // NB: eventually these methods will be defined unconditionally, and
 // can be moved into Layers.h
 const nsIntRect*
 Layer::GetEffectiveClipRect()
 {
   if (ShadowLayer* shadow = AsShadowLayer()) {
     return shadow->GetShadowClipRect();
   }
@@ -257,23 +254,16 @@ const nsIntRegion&
 Layer::GetEffectiveVisibleRegion()
 {
   if (ShadowLayer* shadow = AsShadowLayer()) {
     return shadow->GetShadowVisibleRegion();
   }
   return GetVisibleRegion();
 }
 
-#else
-
-const nsIntRect* Layer::GetEffectiveClipRect() { return GetClipRect(); }
-const nsIntRegion& Layer::GetEffectiveVisibleRegion() { return GetVisibleRegion(); }
-
-#endif  // MOZ_IPC
-
 gfx3DMatrix
 Layer::SnapTransform(const gfx3DMatrix& aTransform,
                      const gfxRect& aSnapRect,
                      gfxMatrix* aResidualTransform)
 {
   if (aResidualTransform) {
     *aResidualTransform = gfxMatrix();
   }
@@ -356,20 +346,18 @@ Layer::CalculateScissorRect(bool aInterm
                "Attempting to scissor out of bounds!");
 
   return scissorRect;
 }
 
 const gfx3DMatrix&
 Layer::GetLocalTransform()
 {
-#ifdef MOZ_IPC
   if (ShadowLayer* shadow = AsShadowLayer())
     return shadow->GetShadowTransform();
-#endif
   return mTransform;
 }
 
 float
 Layer::GetEffectiveOpacity()
 {
   float opacity = GetOpacity();
   for (ContainerLayer* c = GetParent(); c && !c->UseIntermediateSurface();
@@ -697,17 +685,16 @@ LayerManager::InitLog()
 /*static*/ bool
 LayerManager::IsLogEnabled()
 {
   NS_ABORT_IF_FALSE(!!sLog,
                     "layer manager must be created before logging is allowed");
   return PR_LOG_TEST(sLog, PR_LOG_DEBUG);
 }
 
-# ifdef MOZ_IPC
 static nsACString&
 PrintInfo(nsACString& aTo, ShadowLayer* aShadowLayer)
 {
   if (!aShadowLayer) {
     return aTo;
   }
   if (const nsIntRect* clipRect = aShadowLayer->GetShadowClipRect()) {
     AppendToString(aTo, *clipRect, " [shadow-clip=", "]");
@@ -715,22 +702,16 @@ PrintInfo(nsACString& aTo, ShadowLayer* 
   if (!aShadowLayer->GetShadowTransform().IsIdentity()) {
     AppendToString(aTo, aShadowLayer->GetShadowTransform(), " [shadow-transform=", "]");
   }
   if (!aShadowLayer->GetShadowVisibleRegion().IsEmpty()) {
     AppendToString(aTo, aShadowLayer->GetShadowVisibleRegion(), " [shadow-visible=", "]");
   }
   return aTo;
 }
-# else
-static nsACString& PrintInfo(nsACString& aTo, ShadowLayer* aShadowLayer)
-{
-  return aTo;
-}
-# endif  // MOZ_IPC
 
 #else  // !MOZ_LAYERS_HAVE_LOG
 
 void Layer::Dump(FILE* aFile, const char* aPrefix) {}
 void Layer::DumpSelf(FILE* aFile, const char* aPrefix) {}
 void Layer::Log(const char* aPrefix) {}
 void Layer::LogSelf(const char* aPrefix) {}
 nsACString&
--- a/gfx/layers/Makefile.in
+++ b/gfx/layers/Makefile.in
@@ -39,24 +39,21 @@ DEPTH       = ../..
 topsrcdir   = @top_srcdir@
 srcdir      = @srcdir@
 VPATH       = \
   $(srcdir) \
   $(srcdir)/basic \
   $(srcdir)/opengl \
   $(srcdir)/d3d9 \
   $(srcdir)/d3d10 \
+  $(srcdir)/ipc \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 
-ifdef MOZ_IPC
-VPATH       += $(srcdir)/ipc
-endif
-
 MODULE         = thebes
 LIBRARY_NAME   = layers
 LIBXUL_LIBRARY = 1
 FORCE_STATIC_LIB = 1
 
 DEFINES += -DIMPL_THEBES
 ifdef MOZ_DEBUG
 DEFINES += -DD3D_DEBUG_INFO
@@ -122,17 +119,16 @@ CPPSRCS += \
         ImageLayerD3D10.cpp \
         ColorLayerD3D10.cpp \
         CanvasLayerD3D10.cpp \
         ReadbackManagerD3D10.cpp \
         $(NULL)
 endif
 endif
 
-ifdef MOZ_IPC #{
 EXPORTS_NAMESPACES = IPC mozilla/layers
 EXPORTS_IPC = ShadowLayerUtils.h
 EXPORTS_mozilla/layers =\
         ShadowLayers.h \
         ShadowLayersChild.h \
         ShadowLayersParent.h \
         $(NULL)
 
@@ -144,30 +140,26 @@ CPPSRCS += \
         ShadowLayersParent.cpp \
         $(NULL)
 
 ifdef MOZ_X11 #{
 EXPORTS_mozilla/layers += ShadowLayerUtilsX11.h
 CPPSRCS += ShadowLayerUtilsX11.cpp
 endif #}
 
-endif #}
-
 # Enable GLES2.0 under maemo
 ifdef MOZ_X11
 ifdef MOZ_PLATFORM_MAEMO
 DEFINES += -DUSE_GLES2
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
 
-ifdef MOZ_IPC
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
-endif
 
 CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
 
 LayerManagerOGLShaders.h: LayerManagerOGLShaders.txt genshaders.py $(GLOBAL_DEPS)
 	$(PYTHON) $(srcdir)/opengl/genshaders.py $< $@
 
 LayerManagerOGL.$(OBJ_SUFFIX): LayerManagerOGLShaders.h
 
--- a/gfx/layers/ThebesLayerBuffer.cpp
+++ b/gfx/layers/ThebesLayerBuffer.cpp
@@ -340,16 +340,17 @@ ThebesLayerBuffer::BeginPaint(ThebesLaye
           MovePixels(mBuffer, srcRect, dest, curXRes, curYRes);
           result.mDidSelfCopy = PR_TRUE;
           // Don't set destBuffer; we special-case self-copies, and
           // just did the necessary work above.
           mBufferRect = destBufferRect;
         } else {
           // We can't do a real self-copy because the buffer is rotated.
           // So allocate a new buffer for the destination.
+          destBufferRect = neededRegion.GetBounds();
           bufferDimsChanged = PR_TRUE;
           destBuffer = CreateBuffer(contentType, destBufferDims, bufferFlags);
           if (!destBuffer)
             return result;
         }
       } else {
         mBufferRect = destBufferRect;
         mBufferRotation = newRotation;
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -31,24 +31,22 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
-#  include "gfxSharedImageSurface.h"
-
-#  include "mozilla/layers/PLayerChild.h"
-#  include "mozilla/layers/PLayersChild.h"
-#  include "mozilla/layers/PLayersParent.h"
-#  include "ipc/ShadowLayerChild.h"
-#endif
+#include "gfxSharedImageSurface.h"
+
+#include "mozilla/layers/PLayerChild.h"
+#include "mozilla/layers/PLayersChild.h"
+#include "mozilla/layers/PLayersParent.h"
+#include "ipc/ShadowLayerChild.h"
 
 #include "BasicLayers.h"
 #include "ImageLayers.h"
 
 #include "nsTArray.h"
 #include "nsGUIEvent.h"
 #include "nsIRenderingContext.h"
 #include "gfxContext.h"
@@ -1599,18 +1597,16 @@ BasicLayerManager::CreateCanvasLayer()
 already_AddRefed<ReadbackLayer>
 BasicLayerManager::CreateReadbackLayer()
 {
   NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
   nsRefPtr<ReadbackLayer> layer = new BasicReadbackLayer(this);
   return layer.forget();
 }
 
-#ifdef MOZ_IPC
-
 class BasicShadowableThebesLayer;
 class BasicShadowableLayer : public ShadowableLayer
 {
 public:
   BasicShadowableLayer()
   {
     MOZ_COUNT_CTOR(BasicShadowableLayer);
   }
@@ -2881,12 +2877,11 @@ BasicShadowLayerManager::Hold(Layer* aLa
 
 PRBool
 BasicShadowLayerManager::IsCompositingCheap()
 {
   // Whether compositing is cheap depends on the parent backend.
   return mShadowManager &&
          LayerManager::IsCompositingCheap(GetParentBackendType());
 }
-#endif  // MOZ_IPC
 
 }
 }
--- a/gfx/layers/basic/BasicLayers.h
+++ b/gfx/layers/basic/BasicLayers.h
@@ -40,19 +40,17 @@
 
 #include "Layers.h"
 
 #include "gfxContext.h"
 #include "gfxCachedTempSurface.h"
 #include "nsAutoRef.h"
 #include "nsThreadUtils.h"
 
-#ifdef MOZ_IPC
 #include "mozilla/layers/ShadowLayers.h"
-#endif
 
 class nsIWidget;
 
 namespace mozilla {
 namespace layers {
 
 class BasicShadowableLayer;
 class ShadowThebesLayer;
@@ -66,21 +64,17 @@ class ReadbackProcessor;
  * This is a cairo/Thebes-only, main-thread-only implementation of layers.
  * 
  * In each transaction, the client sets up the layer tree and then during
  * the drawing phase, each ThebesLayer is painted directly into the target
  * context (with appropriate clipping and Push/PopGroups performed
  * between layers).
  */
 class THEBES_API BasicLayerManager :
-#ifdef MOZ_IPC
     public ShadowLayerManager
-#else
-    public LayerManager
-#endif
 {
 public:
   /**
    * Construct a BasicLayerManager which will have no default
    * target context. SetDefaultTarget or BeginTransactionWithTarget
    * must be called for any rendering to happen. ThebesLayers will not
    * be retained.
    */
@@ -230,17 +224,16 @@ protected:
   gfxCachedTempSurface mCachedSurface;
 
   BufferMode   mDoubleBuffering;
   PRPackedBool mUsingDefaultTarget;
   bool         mTransactionIncomplete;
 };
  
 
-#ifdef MOZ_IPC
 class BasicShadowLayerManager : public BasicLayerManager,
                                 public ShadowLayerForwarder
 {
   typedef nsTArray<nsRefPtr<Layer> > LayerRefArray;
 
 public:
   BasicShadowLayerManager(nsIWidget* aWidget);
   virtual ~BasicShadowLayerManager();
@@ -279,17 +272,16 @@ public:
 private:
   /**
    * Forward transaction results to the parent context.
    */
   void ForwardTransaction();
 
   LayerRefArray mKeepAlive;
 };
-#endif  // MOZ_IPC
 
 }
 }
 
 /**
  * We need to be able to hold a reference to a gfxASurface from Image
  * subclasses. This is potentially a problem since Images can be addrefed
  * or released off the main thread. We can ensure that we never AddRef
--- a/gfx/layers/opengl/CanvasLayerOGL.cpp
+++ b/gfx/layers/opengl/CanvasLayerOGL.cpp
@@ -30,19 +30,17 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
-# include "gfxSharedImageSurface.h"
-#endif
+#include "gfxSharedImageSurface.h"
 
 #include "CanvasLayerOGL.h"
 
 #include "gfxImageSurface.h"
 #include "gfxContext.h"
 #include "GLContextProvider.h"
 
 #ifdef XP_WIN
@@ -240,18 +238,16 @@ CanvasLayerOGL::RenderLayer(int aPreviou
   mOGLManager->BindAndDrawQuad(program, mNeedsYFlip ? true : false);
 
   if (useGLContext) {
     gl()->UnbindTex2DOffscreen(mCanvasGLContext);
   }
 }
 
 
-#ifdef MOZ_IPC
-
 ShadowCanvasLayerOGL::ShadowCanvasLayerOGL(LayerManagerOGL* aManager)
   : ShadowCanvasLayer(aManager, nsnull)
   , LayerOGL(aManager)
 {
   mImplData = static_cast<LayerOGL*>(this);
 }
  
 ShadowCanvasLayerOGL::~ShadowCanvasLayerOGL()
@@ -329,10 +325,8 @@ ShadowCanvasLayerOGL::RenderLayer(int aP
   program->SetLayerQuadRect(nsIntRect(nsIntPoint(0, 0), mTexImage->GetSize()));
   program->SetLayerTransform(GetEffectiveTransform());
   program->SetLayerOpacity(GetEffectiveOpacity());
   program->SetRenderOffset(aOffset);
   program->SetTextureUnit(0);
 
   mOGLManager->BindAndDrawQuad(program);
 }
-
-#endif  // MOZ_IPC
--- a/gfx/layers/opengl/CanvasLayerOGL.h
+++ b/gfx/layers/opengl/CanvasLayerOGL.h
@@ -33,20 +33,18 @@
  * 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 GFX_CANVASLAYEROGL_H
 #define GFX_CANVASLAYEROGL_H
 
-#ifdef MOZ_IPC
-# include "mozilla/layers/PLayers.h"
-# include "mozilla/layers/ShadowLayers.h"
-#endif  // MOZ_IPC
+#include "mozilla/layers/PLayers.h"
+#include "mozilla/layers/ShadowLayers.h"
 
 #include "LayerManagerOGL.h"
 #include "gfxASurface.h"
 
 namespace mozilla {
 namespace layers {
 
 class THEBES_API CanvasLayerOGL :
@@ -83,17 +81,16 @@ protected:
   void MakeTexture();
   GLuint mTexture;
 
   PRPackedBool mDelayedUpdates;
   PRPackedBool mGLBufferIsPremultiplied;
   PRPackedBool mNeedsYFlip;
 };
 
-#ifdef MOZ_IPC
 // NB: eventually we'll have separate shadow canvas2d and shadow
 // canvas3d layers, but currently they look the same from the
 // perspective of the compositor process
 class ShadowCanvasLayerOGL : public ShadowCanvasLayer,
                              public LayerOGL
 {
   typedef gl::TextureImage TextureImage;
 
@@ -124,13 +121,12 @@ private:
   nsRefPtr<TextureImage> mTexImage;
 
 
   // XXX FIXME holding to free
   nsRefPtr<gfxSharedImageSurface> mDeadweight;
 
 
 };
-#endif  // MOZ_IPC
 
 } /* layers */
 } /* mozilla */
 #endif /* GFX_IMAGELAYEROGL_H */
--- a/gfx/layers/opengl/ColorLayerOGL.cpp
+++ b/gfx/layers/opengl/ColorLayerOGL.cpp
@@ -75,20 +75,18 @@ RenderColorLayer(ColorLayer* aLayer, Lay
 
 void
 ColorLayerOGL::RenderLayer(int,
                            const nsIntPoint& aOffset)
 {
   return RenderColorLayer(this, mOGLManager, aOffset);
 }
 
-#ifdef MOZ_IPC
 void
 ShadowColorLayerOGL::RenderLayer(int,
                                  const nsIntPoint& aOffset)
 {
   return RenderColorLayer(this, mOGLManager, aOffset);
 }
-#endif  // MOZ_IPC
 
 
 } /* layers */
 } /* mozilla */
--- a/gfx/layers/opengl/ColorLayerOGL.h
+++ b/gfx/layers/opengl/ColorLayerOGL.h
@@ -33,20 +33,18 @@
  * 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 GFX_COLORLAYEROGL_H
 #define GFX_COLORLAYEROGL_H
 
-#ifdef MOZ_IPC
-# include "mozilla/layers/PLayers.h"
-# include "mozilla/layers/ShadowLayers.h"
-#endif  // MOZ_IPC
+#include "mozilla/layers/PLayers.h"
+#include "mozilla/layers/ShadowLayers.h"
 
 #include "LayerManagerOGL.h"
 
 namespace mozilla {
 namespace layers {
 
 class THEBES_API ColorLayerOGL : public ColorLayer,
                                  public LayerOGL
@@ -64,17 +62,16 @@ public:
   virtual Layer* GetLayer() { return this; }
 
   virtual void Destroy() { mDestroyed = PR_TRUE; }
 
   virtual void RenderLayer(int aPreviousFrameBuffer,
                            const nsIntPoint& aOffset);
 };
 
-#ifdef MOZ_IPC
 class ShadowColorLayerOGL : public ShadowColorLayer,
                             public LayerOGL
 {
 public:
   ShadowColorLayerOGL(LayerManagerOGL *aManager)
     : ShadowColorLayer(aManager, NULL)
     , LayerOGL(aManager)
   { 
@@ -85,13 +82,12 @@ public:
   // LayerOGL Implementation
   virtual Layer* GetLayer() { return this; }
 
   virtual void Destroy() { mDestroyed = PR_TRUE; }
 
   virtual void RenderLayer(int aPreviousFrameBuffer,
                            const nsIntPoint& aOffset);
 };
-#endif  // MOZ_IPC
 
 } /* layers */
 } /* mozilla */
 #endif /* GFX_COLORLAYEROGL_H */
--- a/gfx/layers/opengl/ContainerLayerOGL.cpp
+++ b/gfx/layers/opengl/ContainerLayerOGL.cpp
@@ -338,18 +338,16 @@ ContainerLayerOGL::GetFirstChildOGL()
 void
 ContainerLayerOGL::RenderLayer(int aPreviousFrameBuffer,
                                const nsIntPoint& aOffset)
 {
   ContainerRender(this, aPreviousFrameBuffer, aOffset, mOGLManager);
 }
 
 
-#ifdef MOZ_IPC
-
 ShadowContainerLayerOGL::ShadowContainerLayerOGL(LayerManagerOGL *aManager)
   : ShadowContainerLayer(aManager, NULL)
   , LayerOGL(aManager)
 {
   mImplData = static_cast<LayerOGL*>(this);
 }
  
 ShadowContainerLayerOGL::~ShadowContainerLayerOGL()
@@ -386,13 +384,11 @@ ShadowContainerLayerOGL::GetFirstChildOG
  
 void
 ShadowContainerLayerOGL::RenderLayer(int aPreviousFrameBuffer,
                                      const nsIntPoint& aOffset)
 {
   ContainerRender(this, aPreviousFrameBuffer, aOffset, mOGLManager);
 }
 
-#endif  // MOZ_IPC
-
 
 } /* layers */
 } /* mozilla */
--- a/gfx/layers/opengl/ContainerLayerOGL.h
+++ b/gfx/layers/opengl/ContainerLayerOGL.h
@@ -33,20 +33,18 @@
  * 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 GFX_CONTAINERLAYEROGL_H
 #define GFX_CONTAINERLAYEROGL_H
 
-#ifdef MOZ_IPC
-# include "mozilla/layers/PLayers.h"
-# include "mozilla/layers/ShadowLayers.h"
-#endif
+#include "mozilla/layers/PLayers.h"
+#include "mozilla/layers/ShadowLayers.h"
 
 #include "Layers.h"
 #include "LayerManagerOGL.h"
 
 namespace mozilla {
 namespace layers {
 
 template<class Container>
@@ -95,17 +93,16 @@ public:
                            const nsIntPoint& aOffset);
 
   virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
   {
     DefaultComputeEffectiveTransforms(aTransformToSurface);
   }
 };
 
-#ifdef MOZ_IPC
 class ShadowContainerLayerOGL : public ShadowContainerLayer,
                                 public LayerOGL
 {
   template<class Container>
   friend void ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter);
   template<class Container>
   friend void ContainerRemoveChild(Container* aContainer, Layer* aChild);
   template<class Container>
@@ -134,14 +131,13 @@ public:
   virtual void RenderLayer(int aPreviousFrameBuffer,
                            const nsIntPoint& aOffset);
 
   virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
   {
     DefaultComputeEffectiveTransforms(aTransformToSurface);
   }
 };
-#endif  // MOZ_IPC
 
 } /* layers */
 } /* mozilla */
 
 #endif /* GFX_CONTAINERLAYEROGL_H */
--- a/gfx/layers/opengl/ImageLayerOGL.cpp
+++ b/gfx/layers/opengl/ImageLayerOGL.cpp
@@ -31,19 +31,17 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
-# include "gfxSharedImageSurface.h"
-#endif
+#include "gfxSharedImageSurface.h"
 
 #include "ImageLayerOGL.h"
 #include "gfxImageSurface.h"
 #include "yuv_convert.h"
 #include "GLContextProvider.h"
 #include "MacIOSurfaceImageOGL.h"
 
 using namespace mozilla::gl;
@@ -740,18 +738,16 @@ CairoImageOGL::SetData(const CairoImage:
   mSize = aData.mSize;
 
   mLayerProgram =
     gl->UploadSurfaceToTexture(aData.mSurface,
                                nsIntRect(0,0, mSize.width, mSize.height),
                                tex);
 }
 
-#ifdef MOZ_IPC
-
 ShadowImageLayerOGL::ShadowImageLayerOGL(LayerManagerOGL* aManager)
   : ShadowImageLayer(aManager, nsnull)
   , LayerOGL(aManager)
 {
   mImplData = static_cast<LayerOGL*>(this);
 }  
 
 ShadowImageLayerOGL::~ShadowImageLayerOGL()
@@ -832,13 +828,11 @@ ShadowImageLayerOGL::RenderLayer(int aPr
   program->SetLayerTransform(GetEffectiveTransform());
   program->SetLayerOpacity(GetEffectiveOpacity());
   program->SetRenderOffset(aOffset);
   program->SetTextureUnit(0);
 
   mOGLManager->BindAndDrawQuad(program);
 }
 
-#endif  // MOZ_IPC
-
 
 } /* layers */
 } /* mozilla */
--- a/gfx/layers/opengl/ImageLayerOGL.h
+++ b/gfx/layers/opengl/ImageLayerOGL.h
@@ -33,20 +33,18 @@
  * 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 GFX_IMAGELAYEROGL_H
 #define GFX_IMAGELAYEROGL_H
 
-#ifdef MOZ_IPC
-# include "mozilla/layers/PLayers.h"
-# include "mozilla/layers/ShadowLayers.h"
-#endif  // MOZ_IPC
+#include "mozilla/layers/PLayers.h"
+#include "mozilla/layers/ShadowLayers.h"
 
 #include "LayerManagerOGL.h"
 #include "ImageLayers.h"
 #include "yuv_convert.h"
 #include "mozilla/Mutex.h"
 
 namespace mozilla {
 namespace layers {
@@ -229,17 +227,16 @@ public:
 
   void SetData(const Data &aData);
 
   GLTexture mTexture;
   gfxIntSize mSize;
   gl::ShaderProgramType mLayerProgram;
 };
 
-#ifdef MOZ_IPC
 class ShadowImageLayerOGL : public ShadowImageLayer,
                             public LayerOGL
 {
   typedef gl::TextureImage TextureImage;
 
 public:
   ShadowImageLayerOGL(LayerManagerOGL* aManager);
   virtual ~ShadowImageLayerOGL();
@@ -266,13 +263,12 @@ private:
   nsRefPtr<TextureImage> mTexImage;
 
 
   // XXX FIXME holding to free
   nsRefPtr<gfxSharedImageSurface> mDeadweight;
 
 
 };
-#endif
 
 } /* layers */
 } /* mozilla */
 #endif /* GFX_IMAGELAYEROGL_H */
--- a/gfx/layers/opengl/LayerManagerOGL.cpp
+++ b/gfx/layers/opengl/LayerManagerOGL.cpp
@@ -32,19 +32,17 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
-# include "mozilla/layers/PLayers.h"
-#endif  // MOZ_IPC
+#include "mozilla/layers/PLayers.h"
 
 #include "LayerManagerOGL.h"
 #include "ThebesLayerOGL.h"
 #include "ContainerLayerOGL.h"
 #include "ImageLayerOGL.h"
 #include "ColorLayerOGL.h"
 #include "CanvasLayerOGL.h"
 
@@ -965,18 +963,16 @@ void LayerOGL::ApplyFilter(gfxPattern::G
     if (aFilter != gfxPattern::FILTER_GOOD) {
       NS_WARNING("Unsupported filter type!");
     }
     gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
     gl()->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
   }
 }
 
-#ifdef MOZ_IPC
-
 already_AddRefed<ShadowThebesLayer>
 LayerManagerOGL::CreateShadowThebesLayer()
 {
   if (LayerManagerOGL::mDestroyed) {
     NS_WARNING("Call on destroyed layer manager");
     return nsnull;
   }
   return nsRefPtr<ShadowThebesLayerOGL>(new ShadowThebesLayerOGL(this)).forget();
@@ -1017,25 +1013,11 @@ LayerManagerOGL::CreateShadowCanvasLayer
 {
   if (LayerManagerOGL::mDestroyed) {
     NS_WARNING("Call on destroyed layer manager");
     return nsnull;
   }
   return nsRefPtr<ShadowCanvasLayerOGL>(new ShadowCanvasLayerOGL(this)).forget();
 }
 
-#else
-
-already_AddRefed<ShadowThebesLayer>
-LayerManagerOGL::CreateShadowThebesLayer() { return nsnull; }
-already_AddRefed<ShadowContainerLayer>
-LayerManagerOGL::CreateShadowContainerLayer() { return nsnull; }
-already_AddRefed<ShadowImageLayer>
-LayerManagerOGL::CreateShadowImageLayer() { return nsnull; }
-already_AddRefed<ShadowColorLayer>
-LayerManagerOGL::CreateShadowColorLayer() { return nsnull; }
-already_AddRefed<ShadowCanvasLayer>
-LayerManagerOGL::CreateShadowCanvasLayer() { return nsnull; }
-
-#endif  // MOZ_IPC
 
 } /* layers */
 } /* mozilla */
--- a/gfx/layers/opengl/LayerManagerOGL.h
+++ b/gfx/layers/opengl/LayerManagerOGL.h
@@ -37,19 +37,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef GFX_LAYERMANAGEROGL_H
 #define GFX_LAYERMANAGEROGL_H
 
 #include "Layers.h"
 
-#ifdef MOZ_IPC
 #include "mozilla/layers/ShadowLayers.h"
-#endif
 
 #ifdef XP_WIN
 #include <windows.h>
 #endif
 
 /**
  * We don't include GLDefs.h here since we don't want to drag in all defines
  * in for all our users.
@@ -79,21 +77,17 @@ class ShadowImageLayer;
 class ShadowCanvasLayer;
 class ShadowColorLayer;
 
 /**
  * This is the LayerManager used for OpenGL 2.1. For now this will render on
  * the main thread.
  */
 class THEBES_API LayerManagerOGL :
-#ifdef MOZ_IPC
     public ShadowLayerManager
-#else
-    public LayerManager
-#endif
 {
   typedef mozilla::gl::GLContext GLContext;
   typedef mozilla::gl::ShaderProgramType ProgramType;
 
 public:
   LayerManagerOGL(nsIWidget *aWidget);
   virtual ~LayerManagerOGL();
 
--- a/gfx/layers/opengl/ThebesLayerOGL.cpp
+++ b/gfx/layers/opengl/ThebesLayerOGL.cpp
@@ -31,20 +31,18 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
-# include "mozilla/layers/PLayers.h"
-# include "mozilla/layers/ShadowLayers.h"
-#endif
+#include "mozilla/layers/PLayers.h"
+#include "mozilla/layers/ShadowLayers.h"
 
 #include "ThebesLayerBuffer.h"
 #include "ThebesLayerOGL.h"
 #include "gfxUtils.h"
 #include "gfxTeeSurface.h"
 
 namespace mozilla {
 namespace layers {
@@ -572,16 +570,17 @@ BasicBufferOGL::BeginPaint(ContentType a
           (drawBounds.y < yBoundary && yBoundary < drawBounds.YMost()) ||
           (newRotation != nsIntPoint(0,0) && !canHaveRotation)) {
         // The stuff we need to redraw will wrap around an edge of the
         // buffer, so we will need to do a self-copy
         // If mBufferRotation == nsIntPoint(0,0) we could do a real
         // self-copy but we're not going to do that in GL yet.
         // We can't do a real self-copy because the buffer is rotated.
         // So allocate a new buffer for the destination.
+        destBufferRect = neededRegion.GetBounds();
         destBuffer = CreateClampOrRepeatTextureImage(gl(), destBufferDims, contentType, bufferFlags);
         if (!destBuffer)
           return result;
         if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
           destBufferOnWhite =
             CreateClampOrRepeatTextureImage(gl(), destBufferDims, contentType, bufferFlags);
           if (!destBufferOnWhite)
             return result;
@@ -860,18 +859,16 @@ ThebesLayerOGL::GetLayer()
 
 PRBool
 ThebesLayerOGL::IsEmpty()
 {
   return !mBuffer;
 }
 
 
-#ifdef MOZ_IPC
-
 class ShadowBufferOGL : public ThebesLayerBufferOGL
 {
 public:
   ShadowBufferOGL(ShadowThebesLayerOGL* aLayer)
     : ThebesLayerBufferOGL(aLayer, aLayer)
   {}
 
   virtual PaintState BeginPaint(ContentType aContentType,
@@ -1029,13 +1026,10 @@ ShadowThebesLayerOGL::RenderLayer(int aP
 
   mOGLManager->MakeCurrent();
   gl()->fActiveTexture(LOCAL_GL_TEXTURE0);
 
   gl()->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, aPreviousFrameBuffer);
   mBuffer->RenderTo(aOffset, mOGLManager, 0);
 }
 
-#endif  // MOZ_IPC
-
-
 } /* layers */
 } /* mozilla */
--- a/gfx/layers/opengl/ThebesLayerOGL.h
+++ b/gfx/layers/opengl/ThebesLayerOGL.h
@@ -33,20 +33,18 @@
  * 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 GFX_THEBESLAYEROGL_H
 #define GFX_THEBESLAYEROGL_H
 
-#ifdef MOZ_IPC
-# include "mozilla/layers/PLayers.h"
-# include "mozilla/layers/ShadowLayers.h"
-#endif
+#include "mozilla/layers/PLayers.h"
+#include "mozilla/layers/ShadowLayers.h"
 
 #include "Layers.h"
 #include "LayerManagerOGL.h"
 #include "gfxImageSurface.h"
 #include "GLContext.h"
 
 
 namespace mozilla {
@@ -81,17 +79,16 @@ public:
 private:
   friend class BasicBufferOGL;
 
   PRBool CreateSurface();
 
   nsRefPtr<Buffer> mBuffer;
 };
 
-#ifdef MOZ_IPC
 class ShadowThebesLayerOGL : public ShadowThebesLayer,
                              public LayerOGL
 {
 public:
   ShadowThebesLayerOGL(LayerManagerOGL *aManager);
   virtual ~ShadowThebesLayerOGL();
 
   // ShadowThebesLayer impl
@@ -112,13 +109,12 @@ public:
   Layer* GetLayer();
   virtual PRBool IsEmpty();
   virtual void RenderLayer(int aPreviousFrameBuffer,
                            const nsIntPoint& aOffset);
 
 private:
   nsRefPtr<ShadowBufferOGL> mBuffer;
 };
-#endif  // MOZ_IPC
 
 } /* layers */
 } /* mozilla */
 #endif /* GFX_THEBESLAYEROGL_H */
--- a/gfx/thebes/GLContext.h
+++ b/gfx/thebes/GLContext.h
@@ -2062,16 +2062,19 @@ public:
     nsTArray<NamedResource> mTrackedBuffers;
 #endif
 
 };
 
 inline PRBool
 DoesVendorStringMatch(const char* aVendorString, const char *aWantedVendor)
 {
+    if (!aVendorString || !aWantedVendor)
+        return PR_FALSE;
+
     const char *occurrence = strstr(aVendorString, aWantedVendor);
 
     // aWantedVendor not found
     if (!occurrence)
         return PR_FALSE;
 
     // aWantedVendor preceded by alpha character
     if (occurrence != aVendorString && isalpha(*(occurrence-1)))
--- a/gfx/thebes/Makefile.in
+++ b/gfx/thebes/Makefile.in
@@ -42,23 +42,18 @@ EXPORTS	= \
 	gfxUserFontSet.h \
 	GLDefs.h \
 	GLContext.h \
 	GLContextSymbols.h \
 	GLContextProvider.h \
 	GLContextProviderImpl.h \
 	nsCoreAnimationSupport.h \
 	EGLUtils.h \
-	$(NULL)
-
-ifdef MOZ_IPC
-EXPORTS	+= \
 	gfxSharedImageSurface.h \
 	$(NULL)
-endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),android)
 EXPORTS += \
 	gfxAndroidPlatform.h \
 	gfxFT2Fonts.h \
 	gfxFT2FontBase.h \
 	$(NULL)
 endif
@@ -180,16 +175,17 @@ CPPSRCS	= \
 	gfxTextRunWordCache.cpp \
 	gfxUserFontSet.cpp \
 	gfxUtils.cpp \
 	gfxUnicodeProperties.cpp \
 	gfxScriptItemizer.cpp \
 	gfxHarfBuzzShaper.cpp \
 	GLContext.cpp \
 	GLContextProviderOSMesa.cpp \
+	gfxSharedImageSurface.cpp \
 	$(NULL)
 
 # Are we targeting x86 or x64?  If so, build gfxAlphaRecoverySSE2.cpp.
 # The file uses SSE2 intrinsics, so it needs special compile flags on some
 # compilers.
 ifneq (,$(INTEL_ARCHITECTURE))
 CPPSRCS += gfxAlphaRecoverySSE2.cpp
 
@@ -198,22 +194,16 @@ gfxAlphaRecoverySSE2.$(OBJ_SUFFIX): CXXF
 endif
 
 ifdef SOLARIS_SUNPRO_CXX
 gfxAlphaRecoverySSE2.$(OBJ_SUFFIX): OS_CXXFLAGS += -xarch=sse2 -xO4
 endif
 
 endif
 
-ifdef MOZ_IPC
-CPPSRCS += \
-	gfxSharedImageSurface.cpp \
-	$(NULL)
-endif
-
 SHARED_LIBRARY_LIBS += \
 	../layers/$(LIB_PREFIX)layers.$(LIB_SUFFIX) \
 	$(NULL)
 
 
 ifndef MOZ_ENABLE_LIBXUL
 EXTRA_DSO_LIBS	= gkgfx ycbcr
 ifeq (,$(filter-out WINNT WINCE OS2,$(OS_ARCH)))
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -30,20 +30,18 @@
  * 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 ***** */
-#ifdef MOZ_IPC
 #include "mozilla/dom/ContentChild.h"
 #include "nsXULAppAPI.h"
-#endif
 
 #include <android/log.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dirent.h>
 
 #include "gfxAndroidPlatform.h"
@@ -168,20 +166,18 @@ public:
             PL_DHashClearEntryStub,
             PL_DHashFinalizeStub,
             NULL};
         if (!PL_DHashTableInit(&mMap, &ops, nsnull,
                                sizeof(FNCMapEntry), 0)) {
             mMap.ops = nsnull;
             LOG("initializing the map failed");
         }
-#ifdef MOZ_IPC
         NS_ABORT_IF_FALSE(XRE_GetProcessType() == GeckoProcessType_Default,
                           "StartupCacheFontNameCache should only be used in chrome procsess");
-#endif
         mCache = mozilla::scache::StartupCache::GetSingleton();
         Init();
     }
 
     void Init()
     {
         if (!mMap.ops || !mCache)
             return;
@@ -564,17 +560,18 @@ gfxAndroidPlatform::CreatePlatformFontLi
 PRBool
 gfxAndroidPlatform::IsFontFormatSupported(nsIURI *aFontURI, PRUint32 aFormatFlags)
 {
     // check for strange format flags
     NS_ASSERTION(!(aFormatFlags & gfxUserFontSet::FLAG_FORMAT_NOT_USED),
                  "strange font format hint set");
 
     // accept supported formats
-    if (aFormatFlags & (gfxUserFontSet::FLAG_FORMAT_OPENTYPE | 
+    if (aFormatFlags & (gfxUserFontSet::FLAG_FORMAT_OPENTYPE |
+                        gfxUserFontSet::FLAG_FORMAT_WOFF |
                         gfxUserFontSet::FLAG_FORMAT_TRUETYPE)) {
         return PR_TRUE;
     }
 
     // reject all other formats, known and unknown
     if (aFormatFlags != 0) {
         return PR_FALSE;
     }
--- a/intl/build/nsI18nModule.cpp
+++ b/intl/build/nsI18nModule.cpp
@@ -84,16 +84,18 @@ NS_DEFINE_NAMED_CID(NS_ENTITYCONVERTER_C
 NS_DEFINE_NAMED_CID(NS_SAVEASCHARSET_CID);
 NS_DEFINE_NAMED_CID(NS_UNICODE_NORMALIZER_CID);
 NS_DEFINE_NAMED_CID(NS_STRINGBUNDLESERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_STRINGBUNDLETEXTOVERRIDE_CID);
 NS_DEFINE_NAMED_CID(NS_LOCALESERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_COLLATIONFACTORY_CID);
 NS_DEFINE_NAMED_CID(NS_SCRIPTABLEDATEFORMAT_CID);
 NS_DEFINE_NAMED_CID(NS_LANGUAGEATOMSERVICE_CID);
+NS_DEFINE_NAMED_CID(NS_CHARSETALIAS_CID);
+NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID);
 #ifdef XP_WIN
 NS_DEFINE_NAMED_CID(NS_WIN32LOCALE_CID);
 NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
 NS_DEFINE_NAMED_CID(NS_DATETIMEFORMAT_CID);
 #endif
 #ifdef USE_UNIX_LOCALE
 NS_DEFINE_NAMED_CID(NS_POSIXLOCALE_CID);
 NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
@@ -120,16 +122,18 @@ static const mozilla::Module::CIDEntry k
     { &kNS_SAVEASCHARSET_CID, false, NULL, nsSaveAsCharsetConstructor },
     { &kNS_UNICODE_NORMALIZER_CID, false, NULL, nsUnicodeNormalizerConstructor },
     { &kNS_STRINGBUNDLESERVICE_CID, false, NULL, nsStringBundleServiceConstructor },
     { &kNS_STRINGBUNDLETEXTOVERRIDE_CID, false, NULL, nsStringBundleTextOverrideConstructor },
     { &kNS_LOCALESERVICE_CID, false, NULL, CreateLocaleService },
     { &kNS_COLLATIONFACTORY_CID, false, NULL, nsCollationFactoryConstructor },
     { &kNS_SCRIPTABLEDATEFORMAT_CID, false, NULL, NS_NewScriptableDateFormat },
     { &kNS_LANGUAGEATOMSERVICE_CID, false, NULL, nsLanguageAtomServiceConstructor },
+    { &kNS_CHARSETALIAS_CID, false, NULL, nsCharsetAlias2Constructor },
+    { &kNS_PLATFORMCHARSET_CID, false, NULL, nsPlatformCharsetConstructor },
 #ifdef XP_WIN
     { &kNS_WIN32LOCALE_CID, false, NULL, nsIWin32LocaleImplConstructor },
     { &kNS_COLLATION_CID, false, NULL, nsCollationWinConstructor },
     { &kNS_DATETIMEFORMAT_CID, false, NULL, nsDateTimeFormatWinConstructor },
 #endif
 #ifdef USE_UNIX_LOCALE
     { &kNS_POSIXLOCALE_CID, false, NULL, nsPosixLocaleConstructor },
     { &kNS_COLLATION_CID, false, NULL, nsCollationUnixConstructor },
@@ -158,16 +162,18 @@ static const mozilla::Module::ContractID
     { NS_SAVEASCHARSET_CONTRACTID, &kNS_SAVEASCHARSET_CID },
     { NS_UNICODE_NORMALIZER_CONTRACTID, &kNS_UNICODE_NORMALIZER_CID },
     { NS_STRINGBUNDLE_CONTRACTID, &kNS_STRINGBUNDLESERVICE_CID },
     { NS_STRINGBUNDLETEXTOVERRIDE_CONTRACTID, &kNS_STRINGBUNDLETEXTOVERRIDE_CID },
     { NS_LOCALESERVICE_CONTRACTID, &kNS_LOCALESERVICE_CID },
     { NS_COLLATIONFACTORY_CONTRACTID, &kNS_COLLATIONFACTORY_CID },
     { NS_SCRIPTABLEDATEFORMAT_CONTRACTID, &kNS_SCRIPTABLEDATEFORMAT_CID },
     { NS_LANGUAGEATOMSERVICE_CONTRACTID, &kNS_LANGUAGEATOMSERVICE_CID },
+    { NS_CHARSETALIAS_CONTRACTID, &kNS_CHARSETALIAS_CID },
+    { NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID },
 #ifdef XP_WIN
     { NS_WIN32LOCALE_CONTRACTID, &kNS_WIN32LOCALE_CID },
     { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
     { NS_DATETIMEFORMAT_CONTRACTID, &kNS_DATETIMEFORMAT_CID },
 #endif
 #ifdef USE_UNIX_LOCALE
     { NS_POSIXLOCALE_CONTRACTID, &kNS_POSIXLOCALE_CID },
     { NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },
--- a/intl/locale/public/Makefile.in
+++ b/intl/locale/public/Makefile.in
@@ -48,13 +48,15 @@ EXPORTS		= \
 		nsCollationCID.h \
 		nsDateTimeFormatCID.h \
 		nsIDateTimeFormat.h \
 		nsILanguageAtomService.h \
 		nsIMacLocale.h \
 		nsIPosixLocale.h \
 		nsIOS2Locale.h \
 		nsIWin32Locale.h \
+		nsICharsetAlias.h \
+		nsIPlatformCharset.h \
 		nsLocaleCID.h \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
rename from intl/uconv/public/nsICharsetAlias.h
rename to intl/locale/public/nsICharsetAlias.h
rename from intl/uconv/public/nsIPlatformCharset.h
rename to intl/locale/public/nsIPlatformCharset.h
--- a/intl/locale/src/Makefile.in
+++ b/intl/locale/src/Makefile.in
@@ -62,16 +62,18 @@ OS_INCLUDES	+= $(MOZ_QT_CFLAGS)
 endif
 
 CPPSRCS		= \
 		nsCollation.cpp \
 		nsScriptableDateFormat.cpp \
 		nsLanguageAtomService.cpp \
 		nsLocale.cpp \
 		nsLocaleService.cpp \
+		nsCharsetAliasImp.cpp \
+		nsUConvPropertySearch.cpp \
 		$(NULL)
 
 EXPORTS		= \
 		nsCollation.h \
 		$(NULL)
 
 EXPORT_RESOURCE = \
 		$(srcdir)/langGroups.properties \
@@ -82,13 +84,22 @@ EXTRA_JS_MODULES = \
   PluralForm.jsm \
   $(NULL)
 
 # 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
 
+nsCharsetAliasImp.$(OBJ_SUFFIX): charsetalias.properties.h
+
+charsetalias.properties.h: props2arrays.py charsetalias.properties
+	$(PYTHON) $^ $@
+
+GARBAGE += \
+	charsetalias.properties.h \
+	$(NULL)
+
 libs::
 	$(INSTALL) $(EXPORT_RESOURCE) $(DIST)/bin/res
 
 install::
 	$(SYSINSTALL) $(IFLAGS1) $(EXPORT_RESOURCE) $(DESTDIR)$(mozappdir)/res
rename from intl/uconv/src/charsetalias.properties
rename to intl/locale/src/charsetalias.properties
--- a/intl/locale/src/mac/Makefile.in
+++ b/intl/locale/src/mac/Makefile.in
@@ -47,13 +47,23 @@ LIBRARY_NAME	= platlocale_s
 FORCE_STATIC_LIB	= 1
 LIBXUL_LIBRARY  = 1
 
 
 CPPSRCS		= \
 		nsCollationMacUC.cpp \
 		nsDateTimeFormatMac.cpp \
 		nsMacLocale.cpp \
+		nsMacCharset.cpp \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= -I$(srcdir)/..
+
+nsMacCharset.$(OBJ_SUFFIX): maccharset.properties.h
+
+maccharset.properties.h: $(srcdir)/../props2arrays.py maccharset.properties
+	$(PYTHON) $^ $@
+
+GARBAGE += \
+	maccharset.properties.h \
+	$(NULL)
rename from intl/uconv/src/maccharset.properties
rename to intl/locale/src/mac/maccharset.properties
rename from intl/uconv/src/nsMacCharset.cpp
rename to intl/locale/src/mac/nsMacCharset.cpp
--- a/intl/uconv/src/nsMacCharset.cpp
+++ b/intl/locale/src/mac/nsMacCharset.cpp
@@ -34,17 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <Carbon/Carbon.h>
 #include "nsIPlatformCharset.h"
 #include "pratom.h"
 #include "nsUConvPropertySearch.h"
-#include "nsUConvDll.h"
 #include "nsCOMPtr.h"
 #include "nsIServiceManager.h"
 #include "nsIMacLocale.h"
 #include "nsLocaleCID.h"
 #include "nsReadableUtils.h"
 #include "nsPlatformCharset.h"
 #include "nsEncoderDecoderUtils.h"
 
rename from intl/uconv/src/nsCharsetAlias.h
rename to intl/locale/src/nsCharsetAlias.h
rename from intl/uconv/src/nsCharsetAliasImp.cpp
rename to intl/locale/src/nsCharsetAliasImp.cpp
--- a/intl/uconv/src/nsCharsetAliasImp.cpp
+++ b/intl/locale/src/nsCharsetAliasImp.cpp
@@ -37,17 +37,16 @@
 
 
 #include "nsICharsetAlias.h"
 #include "pratom.h"
 
 // for NS_IMPL_IDS only
 #include "nsIPlatformCharset.h"
 
-#include "nsUConvDll.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsUConvPropertySearch.h"
 #include "nsITimelineService.h"
 #include "nsCharsetAlias.h"
 
 //--------------------------------------------------------------
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsCharsetAlias2, nsICharsetAlias)
@@ -104,15 +103,15 @@ nsCharsetAlias2::Equals(const nsACString
 
    *oResult = PR_FALSE;
    nsCAutoString name1;
    nsCAutoString name2;
    res = this->GetPreferred(aCharset1, name1);
    if(NS_SUCCEEDED(res)) {
       res = this->GetPreferred(aCharset2, name2);
       if(NS_SUCCEEDED(res)) {
-        *oResult = name1.Equals(name2, nsCaseInsensitiveCStringComparator());
+        *oResult = name1.Equals(name2);
       }
    }
    
    return res;
 }
 
--- a/intl/locale/src/nsLocaleConstructors.h
+++ b/intl/locale/src/nsLocaleConstructors.h
@@ -41,16 +41,18 @@
 
 #include "nsCollationCID.h"
 #include "nsDateTimeFormatCID.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsILocaleService.h"
 #include "nsIScriptableDateFormat.h"
 #include "nsIServiceManager.h"
 #include "nsLanguageAtomService.h"
+#include "nsCharsetAlias.h"
+#include "nsPlatformCharset.h"
 #include "nsLocaleCID.h"
 
 #if defined(XP_MACOSX)
 #define USE_MAC_LOCALE
 #endif
 
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
 #define USE_UNIX_LOCALE
@@ -96,17 +98,18 @@ ctor_(nsISupports* aOuter, REFNSIID aIID
   return rv;                                              \
 }
 
 
 NSLOCALE_MAKE_CTOR(CreateLocaleService, nsILocaleService, NS_NewLocaleService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationFactory)
 //NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableDateTimeFormat)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsLanguageAtomService)
-
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetAlias2)
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init)
 
 #ifdef XP_WIN
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIWin32LocaleImpl)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationWin)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDateTimeFormatWin)
 #endif
 
 #ifdef USE_UNIX_LOCALE
rename from intl/uconv/src/nsPlatformCharset.h
rename to intl/locale/src/nsPlatformCharset.h
rename from intl/uconv/src/nsUConvPropertySearch.cpp
rename to intl/locale/src/nsUConvPropertySearch.cpp
rename from intl/uconv/src/nsUConvPropertySearch.h
rename to intl/locale/src/nsUConvPropertySearch.h
--- a/intl/locale/src/os2/Makefile.in
+++ b/intl/locale/src/os2/Makefile.in
@@ -48,15 +48,24 @@ EXPORT_LIBRARY = 1
 FORCE_STATIC_LIB	= 1
 LIBXUL_LIBRARY  = 1
 
 
 CPPSRCS		= \
 		nsOS2Locale.cpp \
 		nsCollationOS2.cpp \
 		nsDateTimeFormatOS2.cpp \
+		nsOS2Charset.cpp \
 		$(NULL)
 
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= -I$(srcdir)/..
 
+nsOS2Charset.$(OBJ_SUFFIX): os2charset.properties.h
+
+os2charset.properties.h: $(srcdir)/../props2arrays.py os2charset.properties
+	$(PYTHON) $^ $@
+
+GARBAGE += \
+	os2charset.properties.h \
+	$(NULL)
rename from intl/uconv/src/nsOS2Charset.cpp
rename to intl/locale/src/os2/nsOS2Charset.cpp
--- a/intl/uconv/src/nsOS2Charset.cpp
+++ b/intl/locale/src/os2/nsOS2Charset.cpp
@@ -38,17 +38,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #include "nsIPlatformCharset.h"
 #include "nsUConvPropertySearch.h"
 #include "pratom.h"
 #define INCL_WIN
 #include <os2.h>
-#include "nsUConvDll.h"
 #include "nsIOS2Locale.h"
 #include "nsCOMPtr.h"
 #include "nsReadableUtils.h"
 #include "nsLocaleCID.h"
 #include "nsIServiceManager.h"
 #include "nsITimelineService.h"
 #include "nsPlatformCharset.h"
 
rename from intl/uconv/src/os2charset.properties
rename to intl/locale/src/os2/os2charset.properties
rename from intl/uconv/src/props2arrays.py
rename to intl/locale/src/props2arrays.py
--- a/intl/locale/src/unix/Makefile.in
+++ b/intl/locale/src/unix/Makefile.in
@@ -49,16 +49,33 @@ LIBXUL_LIBRARY  = 1
 
 
 CPPSRCS		= \
 		nsCollationUnix.cpp \
 		nsDateTimeFormatUnix.cpp \
 		nsPosixLocale.cpp \
 		$(NULL)
 
+CPPSRCS		+= nsUNIXCharset.cpp
+
 ifdef ENABLE_TESTS
 DIRS		+= tests
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= -I$(srcdir)/..
 
+# CODESET is not automatically defined on some older versions of Redhat.
+# Define _XOPEN_SOURCE so CODESET will get defined and thus allow
+# nl_langinfo(CODESET) to compile on these systems.
+ifeq ($(OS_ARCH), Linux)
+DEFINES		+= -D_XOPEN_SOURCE=500
+endif
+
+nsUNIXCharset.$(OBJ_SUFFIX): unixcharset.properties.h
+
+unixcharset.properties.h: $(srcdir)/../props2arrays.py unixcharset.properties
+	$(PYTHON) $^ $@
+
+GARBAGE += \
+	unixcharset.properties.h \
+	$(NULL)
rename from intl/uconv/src/nsUNIXCharset.cpp
rename to intl/locale/src/unix/nsUNIXCharset.cpp
--- a/intl/uconv/src/nsUNIXCharset.cpp
+++ b/intl/locale/src/unix/nsUNIXCharset.cpp
@@ -37,17 +37,16 @@
 
 #include <locale.h>
 #include "nsIPlatformCharset.h"
 #include "pratom.h"
 #include "nsUConvPropertySearch.h"
 #include "nsCOMPtr.h"
 #include "nsReadableUtils.h"
 #include "nsLocaleCID.h"
-#include "nsUConvDll.h"
 #include "nsIComponentManager.h"
 #include "nsIServiceManager.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsIUnicodeEncoder.h"
 #include "nsICharsetConverterManager.h"
 #include "nsEncoderDecoderUtils.h"
 #if HAVE_GNU_LIBC_VERSION_H
 #include <gnu/libc-version.h>
rename from intl/uconv/src/unixcharset.properties
rename to intl/locale/src/unix/unixcharset.properties
--- a/intl/locale/src/windows/Makefile.in
+++ b/intl/locale/src/windows/Makefile.in
@@ -47,13 +47,23 @@ LIBRARY_NAME	= platlocale_s
 FORCE_STATIC_LIB	= 1
 LIBXUL_LIBRARY  = 1
 
 
 CPPSRCS		= \
 		nsCollationWin.cpp \
 		nsDateTimeFormatWin.cpp \
 		nsIWin32LocaleImpl.cpp \
+		nsWinCharset.cpp \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= -I$(srcdir)/..
+
+nsWinCharset.$(OBJ_SUFFIX): wincharset.properties.h
+
+wincharset.properties.h: $(srcdir)/../props2arrays.py wincharset.properties
+	$(PYTHON) $^ $@
+
+GARBAGE += \
+	wincharset.properties.h \
+	$(NULL)
rename from intl/uconv/src/nsWinCharset.cpp
rename to intl/locale/src/windows/nsWinCharset.cpp
--- a/intl/uconv/src/nsWinCharset.cpp
+++ b/intl/locale/src/windows/nsWinCharset.cpp
@@ -34,17 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIPlatformCharset.h"
 #include "nsUConvPropertySearch.h"
 #include "pratom.h"
 #include <windows.h>
-#include "nsUConvDll.h"
 #include "nsIWin32Locale.h"
 #include "nsCOMPtr.h"
 #include "nsReadableUtils.h"
 #include "nsLocaleCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsITimelineService.h"
 #include "nsPlatformCharset.h"
 
rename from intl/uconv/src/wincharset.properties
rename to intl/locale/src/windows/wincharset.properties
--- a/intl/uconv/Makefile.in
+++ b/intl/uconv/Makefile.in
@@ -52,24 +52,16 @@ DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= uconv
 
-DIRS		= idl public util
-
-ifdef MOZ_USE_NATIVE_UCONV
-DIRS		+= native
-else
-DIRS		+= ucvja ucvcn ucvlatin ucvtw ucvtw2 ucvko ucvibm
-endif
-
-DIRS		+= src
+DIRS		= idl public util ucvja ucvcn ucvlatin ucvtw ucvtw2 ucvko ucvibm src
 
 ifdef ENABLE_TESTS
 TOOL_DIRS += tests
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/intl/uconv/directory.txt
+++ b/intl/uconv/directory.txt
@@ -1,13 +1,12 @@
 Directory Structure :
 ================================
 
 idl        - public .idl files
-native     - support for native platform charset conversion
 public     - public header file
 src        - source directory of charset converter manager and utilities, and
              charset converters for ISO-8859-1, CP1252, MacRoman and UTF-8
 tests      - tests program and application for charset converter 
 tests/unit - xpcshell tests
 tools      - tools to build the tables used by the converters
 util       - utility functions used by the converters
 
deleted file mode 100644
--- a/intl/uconv/native/Makefile.in
+++ /dev/null
@@ -1,64 +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 mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of 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
-
-MODULE		= ucnative
-
-LIBRARY_NAME	= ucnative_s
-FORCE_STATIC_LIB=1
-LIBXUL_LIBRARY = 1
-
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
-CPPSRCS		= nsWinCEUConvService.cpp
-else
-CPPSRCS		= nsNativeUConvService.cpp
-endif
-
-XPIDLSRCS	= \
-		nsINativeUConvService.idl \
-		$(NULL)
-
-LOCAL_INCLUDES = -I$(srcdir)/../util -I$(srcdir)/../src
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/intl/uconv/native/nsINativeUConvService.idl
+++ /dev/null
@@ -1,51 +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 a Native UCONV interface.
- *
- * 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):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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 "nsISupports.idl"
-
-/*
- * Returns an object that implements the following interfaces:
- *  
- *  nsIUnicodeDecoder 
- *  nsIUnicodeEncoder 
- */
-[uuid(c60097ba-c79d-461b-9116-80a66404c0b0)]
-interface nsINativeUConvService : nsISupports
-{
-  nsISupports getNativeConverter(in string from, in string to);
-};
deleted file mode 100644
--- a/intl/uconv/native/nsNativeUConvService.cpp
+++ /dev/null
@@ -1,393 +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 mozilla.org 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):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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 ***** */
-
-
-#ifdef MOZ_USE_NATIVE_UCONV
-#include "nsString.h"
-#include "nsIGenericFactory.h"
-
-#include "nsINativeUConvService.h"
-
-#include "nsIUnicodeDecoder.h"
-#include "nsIUnicodeEncoder.h"
-
-#include "nsNativeUConvService.h"
-#include "nsAutoPtr.h"
-
-#include <nl_types.h> // CODESET
-#include <langinfo.h> // nl_langinfo
-#include <iconv.h>    // iconv_open, iconv, iconv_close
-#include <errno.h>
-
-
-class IConvAdaptor : public nsIUnicodeDecoder, 
-                     public nsIUnicodeEncoder 
-{
-public:
-    IConvAdaptor();
-    virtual ~IConvAdaptor();
-    
-    nsresult Init(const char* from, const char* to);
-    
-    NS_DECL_ISUPPORTS
-    
-    // Decoder methods:
-    
-    NS_IMETHOD Convert(const char * aSrc, 
-                       PRInt32 * aSrcLength, 
-                       PRUnichar * aDest, 
-                       PRInt32 * aDestLength);
-    
-    NS_IMETHOD GetMaxLength(const char * aSrc, 
-                            PRInt32 aSrcLength, 
-                            PRInt32 * aDestLength);
-    NS_IMETHOD Reset();
-
-    virtual void SetInputErrorBehavior(PRInt32 aBehavior);
-
-    virtual PRUnichar GetCharacterForUnMapped();
-    
-    // Encoder methods:
-    
-    NS_IMETHOD Convert(const PRUnichar * aSrc, 
-                       PRInt32 * aSrcLength, 
-                       char * aDest, 
-                       PRInt32 * aDestLength);
-    
-    
-    NS_IMETHOD Finish(char * aDest, PRInt32 * aDestLength);
-    
-    NS_IMETHOD GetMaxLength(const PRUnichar * aSrc, 
-                            PRInt32 aSrcLength, 
-                            PRInt32 * aDestLength);
-    
-    // defined by the Decoder:  NS_IMETHOD Reset();
-    
-    NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior, 
-                                      nsIUnicharEncoder * aEncoder, 
-                                      PRUnichar aChar);
-    
-    
-private:
-    nsresult ConvertInternal(void * aSrc, 
-                             PRInt32 * aSrcLength, 
-                             PRInt32 aSrcCharSize,
-                             void * aDest, 
-                             PRInt32 * aDestLength,
-                             PRInt32 aDestCharSize);
-    
-    
-    iconv_t mConverter;
-    PRBool    mReplaceOnError;
-    PRUnichar mReplaceChar;
-
-#ifdef DEBUG
-    nsCString mFrom, mTo;
-#endif
-};
-
-NS_IMPL_ISUPPORTS2(IConvAdaptor, 
-                   nsIUnicodeEncoder, 
-                   nsIUnicodeDecoder)
-
-IConvAdaptor::IConvAdaptor()
-{
-    mConverter = 0;
-    mReplaceOnError = PR_FALSE;
-}
-
-IConvAdaptor::~IConvAdaptor()
-{
-    if (mConverter)
-        iconv_close(mConverter);
-}
-
-nsresult 
-IConvAdaptor::Init(const char* from, const char* to)
-{
-#ifdef DEBUG
-    mFrom = from;
-    mTo = to;
-#endif
-
-    mConverter = iconv_open(to, from);
-    if (mConverter == (iconv_t) -1 )    
-    {
-#ifdef DEBUG
-        printf(" * IConvAdaptor - FAILED Initing: %s ==> %s\n", from, to);
-#endif
-        mConverter = nsnull;
-        return NS_ERROR_FAILURE;
-    }
-    return NS_OK;
-}
-
-// From some charset to ucs2
-nsresult 
-IConvAdaptor::Convert(const char * aSrc, 
-                     PRInt32 * aSrcLength, 
-                     PRUnichar * aDest, 
-                     PRInt32 * aDestLength)
-{
-    return ConvertInternal( (void*) aSrc, 
-                            aSrcLength, 
-                            1,
-                            (void*) aDest, 
-                            aDestLength,
-                            2);
-}
-
-nsresult
-IConvAdaptor::GetMaxLength(const char * aSrc, 
-                          PRInt32 aSrcLength, 
-                          PRInt32 * aDestLength)
-{
-    if (!mConverter)
-        return NS_ERROR_UENC_NOMAPPING;
-
-    *aDestLength = aSrcLength*4; // sick
-#ifdef DEBUG
-    printf(" * IConvAdaptor - - GetMaxLength %d ( %s -> %s )\n", *aDestLength, mFrom.get(), mTo.get());
-#endif
-    return NS_OK;
-}
-
-
-nsresult 
-IConvAdaptor::Reset()
-{
-    const char *zero_char_in_ptr  = NULL;
-    char       *zero_char_out_ptr = NULL;
-    size_t      zero_size_in      = 0,
-                zero_size_out     = 0;
-
-    iconv(mConverter, 
-          (char **)&zero_char_in_ptr,
-          &zero_size_in,
-          &zero_char_out_ptr,
-          &zero_size_out);
-
-#ifdef DEBUG
-    printf(" * IConvAdaptor - - Reset\n");
-#endif
-    return NS_OK;
-}
-
-
-void
-IConvAdaptor::SetInputErrorBehavior(PRInt32 aBehavior)
-{
-}
-
-
-PRUnichar
-IConvAdaptor::GetCharacterForUnMapped()
-{
-    return PRUnichar(0xfffd); // Unicode REPLACEMENT CHARACTER
-}
-
-// convert unicode data into some charset.
-nsresult 
-IConvAdaptor::Convert(const PRUnichar * aSrc, 
-                     PRInt32 * aSrcLength, 
-                     char * aDest, 
-                     PRInt32 * aDestLength)
-{
-    return ConvertInternal( (void*) aSrc, 
-                            aSrcLength, 
-                            2,
-                            (void*) aDest, 
-                            aDestLength,
-                            1);
-}
-
-
-nsresult 
-IConvAdaptor::Finish(char * aDest, PRInt32 * aDestLength)
-{
-    *aDestLength = 0;
-    return NS_OK;
-}
-
-nsresult 
-IConvAdaptor::GetMaxLength(const PRUnichar * aSrc, 
-                          PRInt32 aSrcLength, 
-                          PRInt32 * aDestLength)
-{
-    if (!mConverter)
-        return NS_ERROR_UENC_NOMAPPING;
-
-    *aDestLength = aSrcLength*4; // sick
-
-    return NS_OK;
-}
-
-
-nsresult 
-IConvAdaptor::SetOutputErrorBehavior(PRInt32 aBehavior, 
-                                    nsIUnicharEncoder * aEncoder, 
-                                    PRUnichar aChar)
-{
-    if (aBehavior == nsIUnicodeEncoder::kOnError_Signal) {
-        mReplaceOnError = PR_FALSE;
-        return NS_OK;
-    }
-    else if (aBehavior == nsIUnicodeEncoder::kOnError_Replace) {
-        mReplaceOnError = PR_TRUE;
-        mReplaceChar = aChar;
-        return NS_OK;
-    }
-
-    NS_WARNING("Uconv Error Behavior not support");
-    return NS_ERROR_FAILURE;
-}
-
-
-nsresult 
-IConvAdaptor::ConvertInternal(void * aSrc, 
-                             PRInt32 * aSrcLength, 
-                             PRInt32 aSrcCharSize,
-                             void * aDest, 
-                             PRInt32 * aDestLength,
-                             PRInt32 aDestCharSize)
-{
-    if (!mConverter) {
-        NS_WARNING("Converter Not Initialize");
-        return NS_ERROR_NOT_INITIALIZED;
-    }
-    size_t res = 0;
-    size_t inLeft = (size_t) *aSrcLength * aSrcCharSize;
-    size_t outLeft = (size_t) *aDestLength * aDestCharSize;
-    size_t outputAvail = outLeft;
-
-    while (true){
-
-        res = iconv(mConverter, 
-                    (char**)&aSrc, 
-                    &inLeft, 
-                    (char**)&aDest, 
-                    &outLeft);
-        
-        if (res == (size_t) -1) {
-            // on some platforms (e.g., linux) iconv will fail with
-            // E2BIG if it cannot convert _all_ of its input.  it'll
-            // still adjust all of the in/out params correctly, so we
-            // can ignore this error.  the assumption is that we will
-            // be called again to complete the conversion.
-            if ((errno == E2BIG) && (outLeft < outputAvail)) {
-                res = 0;
-                break;
-            }
-            
-            if (errno == EILSEQ) {
-
-                if (mReplaceOnError) {
-                    if (aDestCharSize == 1) {
-                        (*(char*)aDest) = (char)mReplaceChar;
-                        aDest = (char*)aDest + sizeof(char);
-                    }
-                    else
-                    {
-                        (*(PRUnichar*)aDest) = (PRUnichar)mReplaceChar;
-                        aDest = (PRUnichar*)aDest + sizeof(PRUnichar);
-                    
-                    }
-                    inLeft -= aSrcCharSize;
-                    outLeft -= aDestCharSize;
-
-#ifdef DEBUG
-                    printf(" * IConvAdaptor - replacing char in output  ( %s -> %s )\n", 
-                           mFrom.get(), mTo.get());
-
-#endif
-                    res = 0;
-                }
-            }
-
-            if (res == -1) {
-#ifdef DEBUG
-                printf(" * IConvAdaptor - Bad input ( %s -> %s )\n", mFrom.get(), mTo.get());
-#endif
-                return NS_ERROR_UENC_NOMAPPING;
-            }
-        }
-
-        if (inLeft <= 0 || outLeft <= 0 || res == -1)
-            break;
-    }
-
-
-    if (res != (size_t) -1) {
-
-        // xp_iconv deals with how much is remaining in a given buffer
-        // but what uconv wants how much we read/written already.  So
-        // we fix it up here.
-        *aSrcLength  -= (inLeft  / aSrcCharSize);
-        *aDestLength -= (outLeft / aDestCharSize);
-        return NS_OK;
-    }
-    
-#ifdef DEBUG
-    printf(" * IConvAdaptor - - xp_iconv error( %s -> %s )\n", mFrom.get(), mTo.get());
-#endif
-    Reset();    
-    return NS_ERROR_UENC_NOMAPPING;
-}
-
-NS_IMPL_ISUPPORTS1(NativeUConvService, nsINativeUConvService)
-
-NS_IMETHODIMP 
-NativeUConvService::GetNativeConverter(const char* from,
-                                       const char* to,
-                                       nsISupports** aResult) 
-{
-    *aResult = nsnull;
-
-    //nsRefPtr<IConvAdaptor> ucl = new IConvAdaptor();
-    IConvAdaptor *adaptor=new IConvAdaptor();
-    nsCOMPtr<nsISupports> ucl(static_cast<nsIUnicodeDecoder*>(adaptor));
-    if (!ucl)
-        return NS_ERROR_OUT_OF_MEMORY;
-
-    //nsresult rv = ucl->Init(from, to);
-    nsresult rv=adaptor->Init(from,to);   
-    if (NS_SUCCEEDED(rv))
-        NS_ADDREF(*aResult = ucl);
-
-    return rv;
-}
-#endif
deleted file mode 100644
--- a/intl/uconv/native/nsNativeUConvService.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 a Native UCONV interface.
- *
- * 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):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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 ***** */
-
-#define NS_NATIVE_UCONV_SERVICE_CONTRACT_ID "@mozilla.org/uconv/native-service"
-
-#define NS_NATIVE_UCONV_SERVICE_CID \
-{ 0xbd3e94ba, 0xd46f, 0x4026, \
-{ 0xa1, 0xc3, 0x6e, 0xd0, 0xc1, 0x6e, 0xa0, 0x22 } }
-
-#include "nsINativeUConvService.h"
-
-class NativeUConvService : public nsINativeUConvService
-{
-public:
-
-    NativeUConvService() {};
-    virtual ~NativeUConvService() {};
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSINATIVEUCONVSERVICE
-};
-
deleted file mode 100644
--- a/intl/uconv/native/nsWinCEUConvService.cpp
+++ /dev/null
@@ -1,442 +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 WinCEUConvAdapter for Windows CE
- *
- * The Initial Developer of the Original Code is
- * Doug Turner <dougt@meer.net>.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * 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 <windows.h>
-
-#include "nsNativeUConvService.h"
-#include "nsIUnicodeDecoder.h"
-#include "nsIUnicodeEncoder.h"
-#include "nsIPlatformCharset.h"
-#include "nsIServiceManager.h"
-
-#include "nsUCSupport.h"
-#include "nsUTF8ToUnicode.h"
-#include "nsUnicodeToUTF8.h"
-
-#ifdef ALERT_DBG
-void DisplayLastError(const char * msg)
-{
-  int flags = MB_APPLMODAL | MB_TOPMOST | MB_SETFOREGROUND;
-    int error = GetLastError();
-    switch (error)
-    {
-    case ERROR_NO_UNICODE_TRANSLATION:
-      MessageBox(0, "ERROR_NO_UNICODE_TRANSLATION", msg, flags);
-      break;
-    case ERROR_INVALID_PARAMETER:
-      MessageBox(0, "ERROR_INVALID_PARAMETER", msg, flags);
-      break;
-    case ERROR_INVALID_FLAGS:
-      MessageBox(0, "ERROR_INVALID_FLAGS", msg, flags);
-      break;
-    case ERROR_INSUFFICIENT_BUFFER:
-      MessageBox(0, "ERROR_INSUFFICIENT_BUFFER", msg, flags);
-      break;
-    default:
-      MessageBox(0, "other...", msg, flags);
-    }
-}
-#endif
-
-
-class WinCEUConvAdapter : public nsIUnicodeDecoder,
-                          public nsIUnicodeEncoder
-{
-public:
-  
-  WinCEUConvAdapter();
-  virtual ~WinCEUConvAdapter();
-  
-  nsresult Init(const char* from, const char* to);
-  
-  NS_DECL_ISUPPORTS;
-  
-  // Decoder methods:
-  
-  NS_IMETHOD Convert(const char * aSrc, 
-                     PRInt32 * aSrcLength, 
-                     PRUnichar * aDest, 
-                     PRInt32 * aDestLength);
-  
-  NS_IMETHOD GetMaxLength(const char * aSrc, 
-                          PRInt32 aSrcLength, 
-                          PRInt32 * aDestLength);
-  NS_IMETHOD Reset();
-  
-  virtual void SetInputErrorBehavior(PRInt32 aBehavior);
-  virtual PRUnichar GetCharacterForUnMapped();
-
-  // Encoder methods:
-  
-  NS_IMETHOD Convert(const PRUnichar * aSrc, 
-                     PRInt32 * aSrcLength, 
-                     char * aDest, 
-                     PRInt32 * aDestLength);
-  
-  
-  NS_IMETHOD Finish(char * aDest, PRInt32 * aDestLength);
-  
-  NS_IMETHOD GetMaxLength(const PRUnichar * aSrc, 
-                          PRInt32 aSrcLength, 
-                          PRInt32 * aDestLength);
-  
-  // defined by the Decoder:  NS_IMETHOD Reset();
-  
-  NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior, 
-                                    nsIUnicharEncoder * aEncoder, 
-                                    PRUnichar aChar);
-  
-  PRUint32 mCodepage;
-};
-
-NS_IMPL_ISUPPORTS2(WinCEUConvAdapter,
-                   nsIUnicodeDecoder,
-                   nsIUnicodeEncoder)
-
-WinCEUConvAdapter::WinCEUConvAdapter()
-{
-  mCodepage = -1;
-}
-
-WinCEUConvAdapter::~WinCEUConvAdapter()
-{
-}
-
-typedef struct CharsetCodePageMap {
-  char      charset[32];
-  PRUint16  codepage;
-} CsCpMap;
-
-
-static CsCpMap theCsCPMap[] = {
-  {"Big5",    950},
-  {"EUC-JP", 51932},     
-  {"EUC-KR", 949},  
-  {"GB2312", 936},  
-  {"HZ-GB-2312    ", 52936},     
-  {"IBM850", 850},   
-  {"IBM852", 852},   
-  {"IBM855", 855},   
-  {"IBM857", 857},   
-  {"IBM862", 862},   
-  {"IBM866", 866},   
-  {"IBM869", 869},   
-  {"ISO-2022-JP", 50220},     
-  {"ISO-2022-KR", 50225},     
-  {"ISO-8859-15", 28605},     
-  {"ISO-8859-1", 28591},     
-  {"ISO-8859-2", 28592},     
-  {"ISO-8859-3", 28593},     
-  {"ISO-8859-4", 28594},     
-  {"ISO-8859-5", 28595},     
-  {"ISO-8859-6", 28596},     
-  {"ISO-8859-7", 28597},     
-  {"ISO-8859-8", 28598},     
-  {"ISO-8859-8-I", 1255},      
-  {"ISO-8859-9", 28599},     
-  {"Shift_JIS", 932},       
-  {"TIS-620", 874},       
-  {"UTF-16", 1200},      
-  {"UTF-7", 65000},     
-  {"UTF-8", 65001},     
-  {"gb_2312-80", 936},       
-  {"ks_c_5601-1987", 949},       
-  {"us-ascii", 20127},     
-  {"windows-1250", 1250},      
-  {"windows-1251", 1251},      
-  {"windows-1252", 1252},      
-  {"windows-1253", 1253},      
-  {"windows-1254", 1254},      
-  {"windows-1255", 1255},      
-  {"windows-1256", 1256},      
-  {"windows-1257", 1257},      
-  {"windows-1258", 1258},      
-  {"windows-874", 874},       
-  {"windows-936", 936},       
-  {"x-mac-arabic", 10004},     
-  {"x-mac-ce", 10029},     
-  {"x-mac-cyrillic", 10007},     
-  {"x-mac-greek", 10006},     
-  {"x-mac-hebrew", 10005},     
-  {"x-mac-icelandi", 10079},     
-  {"x-x-big5", 950},       
-  {nsnull, 0}
-};
-
-
-nsresult
-WinCEUConvAdapter::Init(const char* from, const char* to)
-{
-  const char* cpstring = nsnull;
-  
-  if (!strcmp(from, "UCS-2"))
-  {
-    cpstring = to;
-  }
-  else
-  {
-    cpstring = from;
-  }
-  
-  int i = 0;
-  while (1)
-  {
-    if (theCsCPMap[i].charset[0] == nsnull)
-      break;
-    
-    if (!strcmp(theCsCPMap[i].charset, cpstring))
-    {
-      mCodepage = theCsCPMap[i].codepage;
-      break;
-    }
-    i++;
-  }
-  
-  if (mCodepage == -1)
-    return NS_ERROR_FAILURE;
-  
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WinCEUConvAdapter::Convert(const char * aSrc, 
-                           PRInt32 * aSrcLength, 
-                           PRUnichar * aDest, 
-                           PRInt32 * aDestLength)
-{
-  if (mCodepage == -1)
-    return NS_ERROR_FAILURE;
-  
-  int count = MultiByteToWideChar(mCodepage,
-                                  0,
-                                  aSrc,
-                                  *aSrcLength,
-                                  aDest,
-                                  *aDestLength);
-  
-  if (count == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
-  {
-    // fall back on the current system Windows "ANSI" code page
-    count = MultiByteToWideChar(CP_ACP,
-                                0,
-                                aSrc,
-                                *aSrcLength,
-                                aDest,
-                                *aDestLength);
-  }
-  
-#ifdef ALERT_DBG
-  if (count == 0)
-    DisplayLastError("MultiByteToWideChar");
-#endif
-  
-  *aDestLength = count;
-  *aSrcLength  = count;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WinCEUConvAdapter::GetMaxLength(const char * aSrc, 
-                                PRInt32 aSrcLength, 
-                                PRInt32 * aDestLength)
-{
-  if (mCodepage == -1 || aSrc == nsnull )
-    return NS_ERROR_FAILURE;
-  
-  int count = MultiByteToWideChar(mCodepage,
-                                  MB_PRECOMPOSED,
-                                  aSrc,
-                                  aSrcLength,
-                                  NULL,
-                                  NULL);
-  
-  if (count == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
-  {
-    // fall back on the current system Windows "ANSI" code page
-    
-    count = MultiByteToWideChar(CP_ACP,
-                                MB_PRECOMPOSED,
-                                aSrc,
-                                aSrcLength,
-                                NULL,
-                                NULL);
-  }
-  
-#ifdef ALERT_DBG  
-  if (count == 0)
-    DisplayLastError("MultiByteToWideChar (0)");
-#endif
-  
-  *aDestLength = count;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WinCEUConvAdapter::Reset()
-{
-  return NS_OK;
-}
-
-void
-WinCEUConvAdapter::SetInputErrorBehavior(PRInt32 aBehavior)
-{
-}
-
-PRUnichar
-WinCEUConvAdapter::GetCharacterForUnMapped()
-{
-  return PRUnichar(0xfffd); // Unicode REPLACEMENT CHARACTER
-}
-
-// Encoder methods:
-
-NS_IMETHODIMP
-WinCEUConvAdapter::Convert(const PRUnichar * aSrc, 
-                           PRInt32 * aSrcLength, 
-                           char * aDest, 
-                           PRInt32 * aDestLength)
-{
-  if (mCodepage == -1)
-    return NS_ERROR_FAILURE;
-  
-  char * defaultChar = "?";
-  int count = WideCharToMultiByte(mCodepage,
-                                  0,
-                                  aSrc,
-                                  *aSrcLength,
-                                  aDest,
-                                  *aDestLength,
-                                  defaultChar,
-                                  NULL);
-  
-#ifdef ALERT_DBG
-  if (count == 0)
-    DisplayLastError("WideCharToMultiByte");
-#endif
-  
-  *aSrcLength = count;
-  *aDestLength = count;
-  
-  return NS_OK;
-}
-
-
-NS_IMETHODIMP
-WinCEUConvAdapter::Finish(char * aDest, PRInt32 * aDestLength)
-{
-  *aDestLength = 0;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-WinCEUConvAdapter::GetMaxLength(const PRUnichar * aSrc, 
-                                PRInt32 aSrcLength, 
-                                PRInt32 * aDestLength)
-{
-  if (mCodepage == -1)
-    return NS_ERROR_FAILURE;
-  
-  int count = WideCharToMultiByte(mCodepage,
-                                  0,
-                                  aSrc,
-                                  aSrcLength,
-                                  NULL,
-                                  NULL,
-                                  NULL,
-                                  NULL);
-#ifdef ALERT_DBG
-  if (count == 0)
-    DisplayLastError("WideCharToMultiByte (0)");
-#endif
-  
-  *aDestLength = count;
-  return NS_OK;
-}
-
-// defined by the Decoder:  NS_IMETHOD Reset();
-
-NS_IMETHODIMP
-WinCEUConvAdapter::SetOutputErrorBehavior(PRInt32 aBehavior, 
-                                          nsIUnicharEncoder * aEncoder, 
-                                          PRUnichar aChar)
-{
-  return NS_OK;
-}
-
-// NativeUConvService
-
-NS_IMPL_ISUPPORTS1(NativeUConvService, 
-                   nsINativeUConvService);
-
-NS_IMETHODIMP 
-NativeUConvService::GetNativeConverter(const char* from,
-                                       const char* to,
-                                       nsISupports** aResult) 
-{
-  *aResult = nsnull;
-  
-  
-  
-  if (!strcmp(from, "UCS-2") && 
-      !strcmp(to,   "UTF-8") )
-  {
-    nsUnicodeToUTF8 * inst = new nsUnicodeToUTF8();
-    inst->AddRef();
-    *aResult = inst;
-    return NS_OK;
-  }
-  
-  if (!strcmp(from, "UTF-8") &&
-      !strcmp(to,   "UCS-2") )
-  {
-    nsUTF8ToUnicode * inst = new nsUTF8ToUnicode();
-    inst->AddRef();
-    *aResult = (nsIUnicodeDecoder*) inst;
-    return NS_OK;
-  }
-  
-  WinCEUConvAdapter* ucl = new WinCEUConvAdapter();
-  if (!ucl)
-    return NS_ERROR_OUT_OF_MEMORY;
-  
-  nsresult rv = ucl->Init(from, to);
-  
-  if (NS_SUCCEEDED(rv)) {
-    NS_ADDREF(*aResult = (nsISupports*)(nsIUnicharEncoder*)ucl);
-  }
-  
-  return rv;
-}
--- a/intl/uconv/public/Makefile.in
+++ b/intl/uconv/public/Makefile.in
@@ -40,18 +40,16 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= uconv
 
 EXPORTS		= \
-		nsICharsetAlias.h \
-		nsIPlatformCharset.h \
 		nsIUnicodeDecoder.h \
 		nsIUnicodeEncoder.h \
 		uconvutil.h \
 		nsEncoderDecoderUtils.h \
 		nsUConvCID.h \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/intl/uconv/src/Makefile.in
+++ b/intl/uconv/src/Makefile.in
@@ -49,38 +49,31 @@ IS_COMPONENT	= 1
 MODULE_NAME	= nsUConvModule
 GRE_MODULE	= 1
 LIBXUL_LIBRARY = 1
 # To avoid conflict with OS/2 system uconv.dll
 SHORT_LIBNAME  = mozuconv
 
 CPPSRCS		= \
 		nsUConvModule.cpp \
-		nsCharsetAliasImp.cpp \
 		nsConverterInputStream.cpp \
 		nsConverterOutputStream.cpp \
 		nsTextToSubURI.cpp \
 		nsCharsetConverterManager.cpp \
 		nsUTF8ConverterService.cpp \
 		nsUTF8ToUnicode.cpp \
 		nsUnicodeToUTF8.cpp \
 		nsScriptableUConv.cpp \
-		nsUConvPropertySearch.cpp \
-		$(NULL)
-
-ifndef MOZ_USE_NATIVE_UCONV
-CPPSRCS         += \
 		nsISO88591ToUnicode.cpp \
 		nsCP1252ToUnicode.cpp \
 		nsMacRomanToUnicode.cpp \
 		nsUnicodeToISO88591.cpp \
 		nsUnicodeToCP1252.cpp \
 		nsUnicodeToMacRoman.cpp \
 		$(NULL)
-endif
 
 # Are we targeting x86-32 or x86-64?  If so, we want to include the SSE2
 # version of nsUTF8ToUnicodeSSE2.cpp.
 ifneq (,$(INTEL_ARCHITECTURE))
 CPPSRCS			+= nsUTF8ToUnicodeSSE2.cpp
 
 # nsUTF8ToUnicodeSSE2.cpp uses SSE2 intrinsics, so we need to pass -msse2 if
 # we're using gcc. (See bug 585538 comment 12.)
@@ -88,30 +81,16 @@ ifdef GNU_CC
 nsUTF8ToUnicodeSSE2.$(OBJ_SUFFIX): CXXFLAGS+=-msse2
 endif
 
 ifdef SOLARIS_SUNPRO_CXX
 nsUTF8ToUnicodeSSE2.$(OBJ_SUFFIX): OS_CXXFLAGS += -xarch=sse2 -xO4
 endif
 endif
 
-ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
-CPPSRCS			+= nsOS2Charset.cpp
-else
-ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
-CPPSRCS			+= nsWinCharset.cpp
-else
-ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-CPPSRCS			+= nsMacCharset.cpp
-else
-CPPSRCS			+= nsUNIXCharset.cpp
-endif
-endif
-endif
-
 EXTRA_DSO_LDOPTS = \
 		../util/$(LIB_PREFIX)ucvutil_s.$(LIB_SUFFIX) \
 		$(MOZ_UNICHARUTIL_LIBS) \
 		$(MOZ_NECKO_UTIL_LIBS) \
 		$(MOZ_COMPONENT_LIBS) \
 		$(NULL)
 
 LOCAL_INCLUDES	= -I$(srcdir)/../util
@@ -123,68 +102,21 @@ endif
 LOCAL_INCLUDES	= -I$(srcdir)/../util \
 		  -I$(srcdir)/../ucvlatin \
 		  -I$(srcdir)/../ucvibm \
 		  -I$(srcdir)/../ucvja \
 		  -I$(srcdir)/../ucvtw2 \
 		  -I$(srcdir)/../ucvtw \
 		  -I$(srcdir)/../ucvko \
 		  -I$(srcdir)/../ucvcn \
-		  -I$(srcdir)/../native \
 		  $(NULL)
 
-ifndef MOZ_USE_NATIVE_UCONV
 SHARED_LIBRARY_LIBS += \
 	../ucvlatin/$(LIB_PREFIX)ucvlatin_s.$(LIB_SUFFIX) \
 	../ucvibm/$(LIB_PREFIX)ucvibm_s.$(LIB_SUFFIX) \
 	../ucvja/$(LIB_PREFIX)ucvja_s.$(LIB_SUFFIX) \
 	../ucvtw2/$(LIB_PREFIX)ucvtw2_s.$(LIB_SUFFIX) \
 	../ucvtw/$(LIB_PREFIX)ucvtw_s.$(LIB_SUFFIX) \
 	../ucvko/$(LIB_PREFIX)ucvko_s.$(LIB_SUFFIX) \
 	../ucvcn/$(LIB_PREFIX)ucvcn_s.$(LIB_SUFFIX) \
 	$(NULL)
-else
-SHARED_LIBRARY_LIBS += \
-	../native/$(LIB_PREFIX)ucnative_s.$(LIB_SUFFIX) \
-	$(NULL)
-endif
 
 include $(topsrcdir)/config/rules.mk
-
-# CODESET is not automatically defined on some older versions of Redhat.
-# Define _XOPEN_SOURCE so CODESET will get defined and thus allow 
-# nl_langinfo(CODESET) to compile on these systems.
-ifeq ($(OS_ARCH), Linux)
-DEFINES         += -D_XOPEN_SOURCE=500
-endif
-
-nsCharsetAliasImp.$(OBJ_SUFFIX): charsetalias.properties.h
-
-nsMacCharset.$(OBJ_SUFFIX): maccharset.properties.h
-
-nsOS2Charset.$(OBJ_SUFFIX): os2charset.properties.h
-
-nsWinCharset.$(OBJ_SUFFIX): wincharset.properties.h
-
-nsUNIXCharset.$(OBJ_SUFFIX): unixcharset.properties.h
-
-charsetalias.properties.h: props2arrays.py charsetalias.properties
-	$(PYTHON) $^ $@
-
-maccharset.properties.h: props2arrays.py maccharset.properties
-	$(PYTHON) $^ $@
-
-os2charset.properties.h: props2arrays.py os2charset.properties
-	$(PYTHON) $^ $@
-
-wincharset.properties.h: props2arrays.py wincharset.properties
-	$(PYTHON) $^ $@
-
-unixcharset.properties.h: props2arrays.py unixcharset.properties
-	$(PYTHON) $^ $@
-
-GARBAGE += \
-	charsetalias.properties.h \
-	maccharset.properties.h \
-	os2charset.properties.h \
-	unixcharset.properties.h \
-	wincharset.properties.h \
-	$(NULL)
--- a/intl/uconv/src/nsCharsetConverterManager.cpp
+++ b/intl/uconv/src/nsCharsetConverterManager.cpp
@@ -56,20 +56,16 @@
 
 #include "nsXPCOM.h"
 #include "nsComponentManagerUtils.h"
 #include "nsISupportsPrimitives.h"
 
 // just for CONTRACTIDs
 #include "nsCharsetConverterManager.h"
 
-#ifdef MOZ_USE_NATIVE_UCONV
-#include "nsNativeUConvService.h"
-#endif
-
 // Class nsCharsetConverterManager [implementation]
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsCharsetConverterManager,
                               nsICharsetConverterManager)
 
 nsCharsetConverterManager::nsCharsetConverterManager() 
   : mDataBundle(NULL)
   , mTitleBundle(NULL)
@@ -149,31 +145,16 @@ nsCharsetConverterManager::GetUnicodeEnc
 
 NS_IMETHODIMP
 nsCharsetConverterManager::GetUnicodeEncoderRaw(const char * aDest, 
                                                 nsIUnicodeEncoder ** aResult)
 {
   *aResult= nsnull;
   nsCOMPtr<nsIUnicodeEncoder> encoder;
 
-#ifdef MOZ_USE_NATIVE_UCONV
-  if (mNativeUC) {
-    nsCOMPtr<nsISupports> supports;
-    mNativeUC->GetNativeConverter("UCS-2", 
-                                  aDest,
-                                  getter_AddRefs(supports));
-
-    encoder = do_QueryInterface(supports);
-
-    if (encoder) {
-      NS_ADDREF(*aResult = encoder);
-      return NS_OK;
-    }
-  }
-#endif  
   nsresult rv = NS_OK;
 
   nsCAutoString
     contractid(NS_LITERAL_CSTRING(NS_UNICODEENCODER_CONTRACTID_BASE) +
                nsDependentCString(aDest));
 
   // Always create an instance since encoders hold state.
   encoder = do_CreateInstance(contractid.get(), &rv);
@@ -232,31 +213,16 @@ nsCharsetConverterManager::GetUnicodeDec
 
 NS_IMETHODIMP
 nsCharsetConverterManager::GetUnicodeDecoderRawInternal(const char * aSrc, 
                                                         nsIUnicodeDecoder ** aResult)
 {
   *aResult= nsnull;
   nsCOMPtr<nsIUnicodeDecoder> decoder;
 
-#ifdef MOZ_USE_NATIVE_UCONV
-  if (mNativeUC) {
-    nsCOMPtr<nsISupports> supports;
-    mNativeUC->GetNativeConverter(aSrc,
-                                  "UCS-2", 
-                                  getter_AddRefs(supports));
-    
-    decoder = do_QueryInterface(supports);
-
-    if (decoder) {
-      NS_ADDREF(*aResult = decoder);
-      return NS_OK;
-    }
-  }
-#endif
   nsresult rv = NS_OK;
 
   NS_NAMED_LITERAL_CSTRING(contractbase, NS_UNICODEDECODER_CONTRACTID_BASE);
   nsDependentCString src(aSrc);
   
   decoder = do_CreateInstance(PromiseFlatCString(contractbase + src).get(),
                               &rv);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_UCONV_NOCONV);
--- a/intl/uconv/src/nsCharsetConverterManager.h
+++ b/intl/uconv/src/nsCharsetConverterManager.h
@@ -38,39 +38,31 @@
 #define nsCharsetConverterManager_h__
 
 #include "nsISupports.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIStringBundle.h"
 #include "nsInterfaceHashtable.h"
 #include "mozilla/Mutex.h"
 
-#ifdef MOZ_USE_NATIVE_UCONV
-#include "nsINativeUConvService.h"
-#endif
-
 class nsCharsetConverterManager : public nsICharsetConverterManager
 {
   NS_DECL_ISUPPORTS
   NS_DECL_NSICHARSETCONVERTERMANAGER
 
 public:
 
   nsCharsetConverterManager();
   virtual ~nsCharsetConverterManager();
 
 private:
 
   nsIStringBundle * mDataBundle;
   nsIStringBundle * mTitleBundle;
 
-#ifdef MOZ_USE_NATIVE_UCONV
-  nsCOMPtr<nsINativeUConvService> mNativeUC;
-#endif
-
   nsresult LoadExtensibleBundle(const char * aRegistryKey, 
       nsIStringBundle ** aResult);
 
   nsresult GetBundleValue(nsIStringBundle * aBundle,
                           const char * aName, 
                           const nsAFlatString& aProp, PRUnichar ** aResult);
   nsresult GetBundleValue(nsIStringBundle * aBundle,
                           const char * aName, 
--- a/intl/uconv/src/nsScriptableUConv.cpp
+++ b/intl/uconv/src/nsScriptableUConv.cpp
@@ -43,18 +43,16 @@
 #include "nsIServiceManager.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIScriptableUConv.h"
 #include "nsScriptableUConv.h"
 #include "nsIStringStream.h"
 #include "nsCRT.h"
 #include "nsComponentManagerUtils.h"
 
-#include "nsIPlatformCharset.h"
-
 static PRInt32          gInstanceCount = 0;
 
 /* Implementation file */
 NS_IMPL_ISUPPORTS1(nsScriptableUnicodeConverter, nsIScriptableUnicodeConverter)
 
 nsScriptableUnicodeConverter::nsScriptableUnicodeConverter()
 : mIsInternal(PR_FALSE)
 {
--- a/intl/uconv/src/nsUConvModule.cpp
+++ b/intl/uconv/src/nsUConvModule.cpp
@@ -40,32 +40,27 @@
 #include "nsCRT.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsIComponentManager.h"
 #include "nsICategoryManager.h"
 #include "nsICharsetConverterManager.h"
 #include "nsEncoderDecoderUtils.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsIUnicodeEncoder.h"
-#include "nsICharsetAlias.h"
 #include "nsIServiceManager.h"
 
 
 #include "nsUConvCID.h"
 #include "nsCharsetConverterManager.h"
-#include "nsCharsetAlias.h"
 #include "nsTextToSubURI.h"
 #include "nsUTF8ConverterService.h"
 #include "nsConverterInputStream.h"
 #include "nsConverterOutputStream.h"
-#include "nsPlatformCharset.h"
 #include "nsScriptableUConv.h"
 
-#ifndef MOZ_USE_NATIVE_UCONV
-#include "nsIPlatformCharset.h"
 #include "nsITextToSubURI.h"
 
 #include "nsUConvDll.h"
 #include "nsIFile.h"
 
 #include "nsCRT.h"
 
 #include "nsUCSupport.h"
@@ -561,44 +556,28 @@ const PRUint16 g_ucvko_AsciiMapping[] = 
 const PRUint16 g_HangulNullMapping[] ={
   0x0001, 0x0004, 0x0005, 0x0008, 0x0000, 0xAC00, 0xD7A3, 0xAC00
 };
 
 const PRUint16 g_ufJohabJamoMapping[] ={   
 #include "johabjamo.uf"
 };
 
-#else // MOZ_USE_NATIVE_UCONV
-
-#include "nsINativeUConvService.h"
-#include "nsNativeUConvService.h"
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(NativeUConvService)
-
-#endif // #ifndef MOZ_USE_NATIVE_UCONV
-
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetConverterManager)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextToSubURI)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsUTF8ConverterService)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetAlias2)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsConverterInputStream)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsConverterOutputStream)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableUnicodeConverter)
 
 NS_DEFINE_NAMED_CID(NS_ICHARSETCONVERTERMANAGER_CID);
-NS_DEFINE_NAMED_CID(NS_CHARSETALIAS_CID);
 NS_DEFINE_NAMED_CID(NS_TEXTTOSUBURI_CID);
-NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID);
 NS_DEFINE_NAMED_CID(NS_CONVERTERINPUTSTREAM_CID);
 NS_DEFINE_NAMED_CID(NS_CONVERTEROUTPUTSTREAM_CID);
 NS_DEFINE_NAMED_CID(NS_ISCRIPTABLEUNICODECONVERTER_CID);
-#ifdef MOZ_USE_NATIVE_UCONV
-NS_DEFINE_NAMED_CID(NS_NATIVE_UCONV_SERVICE_CID);
-#else
 NS_DEFINE_NAMED_CID(NS_UTF8CONVERTERSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_ISO88591TOUNICODE_CID);
 NS_DEFINE_NAMED_CID(NS_CP1252TOUNICODE_CID);
 NS_DEFINE_NAMED_CID(NS_MACROMANTOUNICODE_CID);
 NS_DEFINE_NAMED_CID(NS_UTF8TOUNICODE_CID);
 NS_DEFINE_NAMED_CID(NS_UNICODETOISO88591_CID);
 NS_DEFINE_NAMED_CID(NS_UNICODETOCP1252_CID);
 NS_DEFINE_NAMED_CID(NS_UNICODETOMACROMAN_CID);
@@ -775,29 +754,23 @@ NS_DEFINE_NAMED_CID(NS_CP936TOUNICODE_CI
 NS_DEFINE_NAMED_CID(NS_UNICODETOCP936_CID);
 NS_DEFINE_NAMED_CID(NS_GBKTOUNICODE_CID);
 NS_DEFINE_NAMED_CID(NS_UNICODETOGBK_CID);
 NS_DEFINE_NAMED_CID(NS_HZTOUNICODE_CID);
 NS_DEFINE_NAMED_CID(NS_UNICODETOHZ_CID);
 NS_DEFINE_NAMED_CID(NS_GB18030TOUNICODE_CID);
 NS_DEFINE_NAMED_CID(NS_UNICODETOGB18030_CID);
 NS_DEFINE_NAMED_CID(NS_ISO2022CNTOUNICODE_CID);
-#endif
 
 static const mozilla::Module::CIDEntry kUConvCIDs[] = {
   { &kNS_ICHARSETCONVERTERMANAGER_CID, false, NULL, nsCharsetConverterManagerConstructor },
-  { &kNS_CHARSETALIAS_CID, false, NULL, nsCharsetAlias2Constructor },
   { &kNS_TEXTTOSUBURI_CID, false, NULL, nsTextToSubURIConstructor },
-  { &kNS_PLATFORMCHARSET_CID, false, NULL, nsPlatformCharsetConstructor },
   { &kNS_CONVERTERINPUTSTREAM_CID, false, NULL, nsConverterInputStreamConstructor },
   { &kNS_CONVERTEROUTPUTSTREAM_CID, false, NULL, nsConverterOutputStreamConstructor },
   { &kNS_ISCRIPTABLEUNICODECONVERTER_CID, false, NULL, nsScriptableUnicodeConverterConstructor },
-#ifdef MOZ_USE_NATIVE_ICONV
-  { &kNS_NATIVE_UCONV_SERVICE_CID, false, NULL, NativeUConvServiceConstructor },
-#else
   { &kNS_UTF8CONVERTERSERVICE_CID, false, NULL, nsUTF8ConverterServiceConstructor },
   { &kNS_ISO88591TOUNICODE_CID, false, NULL, nsISO88591ToUnicodeConstructor },
   { &kNS_CP1252TOUNICODE_CID, false, NULL, nsCP1252ToUnicodeConstructor },
   { &kNS_MACROMANTOUNICODE_CID, false, NULL, nsMacRomanToUnicodeConstructor },
   { &kNS_UTF8TOUNICODE_CID, false, NULL, nsUTF8ToUnicodeConstructor },
   { &kNS_UNICODETOISO88591_CID, false, NULL, nsUnicodeToISO88591Constructor },
   { &kNS_UNICODETOCP1252_CID, false, NULL, nsUnicodeToCP1252Constructor },
   { &kNS_UNICODETOMACROMAN_CID, false, NULL, nsUnicodeToMacRomanConstructor },
@@ -974,31 +947,25 @@ static const mozilla::Module::CIDEntry k
   { &kNS_UNICODETOCP936_CID, false, NULL, nsUnicodeToCP936Constructor },
   { &kNS_GBKTOUNICODE_CID, false, NULL, nsGBKToUnicodeConstructor },
   { &kNS_UNICODETOGBK_CID, false, NULL, nsUnicodeToGBKConstructor },
   { &kNS_HZTOUNICODE_CID, false, NULL, nsHZToUnicodeConstructor },
   { &kNS_UNICODETOHZ_CID, false, NULL, nsUnicodeToHZConstructor },
   { &kNS_GB18030TOUNICODE_CID, false, NULL, nsGB18030ToUnicodeConstructor },
   { &kNS_UNICODETOGB18030_CID, false, NULL, nsUnicodeToGB18030Constructor },
   { &kNS_ISO2022CNTOUNICODE_CID, false, NULL, nsISO2022CNToUnicodeConstructor },
-#endif
   { NULL },
 };
 
 static const mozilla::Module::ContractIDEntry kUConvContracts[] = {
   { NS_CHARSETCONVERTERMANAGER_CONTRACTID, &kNS_ICHARSETCONVERTERMANAGER_CID },
-  { NS_CHARSETALIAS_CONTRACTID, &kNS_CHARSETALIAS_CID },
   { NS_ITEXTTOSUBURI_CONTRACTID, &kNS_TEXTTOSUBURI_CID },
-  { NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID },
   { NS_CONVERTERINPUTSTREAM_CONTRACTID, &kNS_CONVERTERINPUTSTREAM_CID },
   { "@mozilla.org/intl/converter-output-stream;1", &kNS_CONVERTEROUTPUTSTREAM_CID },
   { NS_ISCRIPTABLEUNICODECONVERTER_CONTRACTID, &kNS_ISCRIPTABLEUNICODECONVERTER_CID },
-#ifdef MOZ_USE_NATIVE_ICONV
-  { NS_NATIVE_UCONV_SERVICE_CONTRACT_ID, &kNS_NATIVE_UCONV_SERVICE_CID },
-#else
   { NS_UTF8CONVERTERSERVICE_CONTRACTID, &kNS_UTF8CONVERTERSERVICE_CID },
   { NS_ISO88591TOUNICODE_CONTRACTID, &kNS_ISO88591TOUNICODE_CID },
   { NS_CP1252TOUNICODE_CONTRACTID, &kNS_CP1252TOUNICODE_CID },
   { NS_MACROMANTOUNICODE_CONTRACTID, &kNS_MACROMANTOUNICODE_CID },
   { NS_UTF8TOUNICODE_CONTRACTID, &kNS_UTF8TOUNICODE_CID },
   { NS_UNICODETOISO88591_CONTRACTID, &kNS_UNICODETOISO88591_CID },
   { NS_UNICODETOCP1252_CONTRACTID, &kNS_UNICODETOCP1252_CID },
   { NS_UNICODETOMACROMAN_CONTRACTID, &kNS_UNICODETOMACROMAN_CID },
@@ -1175,17 +1142,16 @@ static const mozilla::Module::ContractID
   { NS_UNICODEENCODER_CONTRACTID_BASE "windows-936", &kNS_UNICODETOCP936_CID },
   { NS_UNICODEDECODER_CONTRACTID_BASE "gbk", &kNS_GBKTOUNICODE_CID },
   { NS_UNICODEENCODER_CONTRACTID_BASE "gbk", &kNS_UNICODETOGBK_CID },
   { NS_UNICODEDECODER_CONTRACTID_BASE "HZ-GB-2312", &kNS_HZTOUNICODE_CID },
   { NS_UNICODEENCODER_CONTRACTID_BASE "HZ-GB-2312", &kNS_UNICODETOHZ_CID },
   { NS_UNICODEDECODER_CONTRACTID_BASE "gb18030", &kNS_GB18030TOUNICODE_CID },
   { NS_UNICODEENCODER_CONTRACTID_BASE "gb18030", &kNS_UNICODETOGB18030_CID },
   { NS_UNICODEDECODER_CONTRACTID_BASE "ISO-2022-CN", &kNS_ISO2022CNTOUNICODE_CID },
-#endif
   { NULL }
 };
 
 static const mozilla::Module kUConvModule = {
   mozilla::Module::kVersion,
   kUConvCIDs,
   kUConvContracts,
   kUConvCategories
--- a/ipc/chromium/chromium-config.mk
+++ b/ipc/chromium/chromium-config.mk
@@ -41,18 +41,16 @@ endif
 ifdef CHROMIUM_CONFIG_INCLUDED
 $(error Must not include chromium-config.mk twice.)
 endif
 
 CHROMIUM_CONFIG_INCLUDED = 1
 
 EXTRA_DEPS += $(topsrcdir)/ipc/chromium/chromium-config.mk
 
-ifdef MOZ_IPC # {
-
 DEFINES += \
   -DEXCLUDE_SKIA_DEPENDENCIES \
   -DCHROMIUM_MOZILLA_BUILD \
   $(NULL)
 
 LOCAL_INCLUDES += \
   -I$(topsrcdir)/ipc/chromium/src \
   -I$(topsrcdir)/ipc/glue \
@@ -103,9 +101,8 @@ DEFINES += \
   $(NULL)
 
 # NB: to stop gcc warnings about exporting template instantiation
 OS_CXXFLAGS := $(filter-out -pedantic,$(OS_CXXFLAGS))
 
 endif # }
 endif # }
 
-endif # }
\ No newline at end of file
--- a/js/src/xpconnect/shell/xpcshell.cpp
+++ b/js/src/xpconnect/shell/xpcshell.cpp
@@ -673,18 +673,16 @@ Clear(JSContext *cx, uintN argc, jsval *
     } else {
         JS_ReportError(cx, "'clear' requires an object");
         return JS_FALSE;
     }
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
     return JS_TRUE;
 }
 
-#ifdef MOZ_IPC
-
 static JSBool
 SendCommand(JSContext* cx,
             uintN argc,
             jsval* vp)
 {
     if (argc == 0) {
         JS_ReportError(cx, "Function takes at least one argument!");
         return JS_FALSE;
@@ -719,18 +717,16 @@ GetChildGlobalObject(JSContext* cx,
     JSObject* global;
     if (XRE_GetChildGlobalObject(cx, &global)) {
         JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(global));
         return JS_TRUE;
     }
     return JS_FALSE;
 }
 
-#endif // MOZ_IPC
-
 /*
  * JSContext option name to flag map. The option names are in alphabetical
  * order for better reporting.
  */
 static const struct {
     const char  *name;
     uint32      flag;
 } js_options[] = {
@@ -855,20 +851,18 @@ static JSFunctionSpec glob_functions[] =
     {"gczeal",          GCZeal,         1,0},
 #endif
     {"clear",           Clear,          1,0},
     {"options",         Options,        0,0},
     JS_FN("parent",     Parent,         1,0),
 #ifdef DEBUG
     {"dumpHeap",        DumpHeap,       5,0},
 #endif
-#ifdef MOZ_IPC
     {"sendCommand",     SendCommand,    1,0},
     {"getChildGlobalObject", GetChildGlobalObject, 0,0},
-#endif
 #ifdef MOZ_CALLGRIND
     {"startCallgrind",  js_StartCallgrind,  0,0},
     {"stopCallgrind",   js_StopCallgrind,   0,0},
     {"dumpCallgrind",   js_DumpCallgrind,   1,0},
 #endif
     {nsnull,nsnull,0,0}
 };
 
@@ -2014,20 +2008,18 @@ main(int argc, char **argv)
             cxstack->Pop(&oldcx);
             NS_ASSERTION(oldcx == cx, "JS thread context push/pop mismatch");
             cxstack = nsnull;
             JS_GC(cx);
         } //this scopes the JSAutoCrossCompartmentCall
         JS_DestroyContext(cx);
     } // this scopes the nsCOMPtrs
 
-#ifdef MOZ_IPC
     if (!XRE_ShutdownTestShell())
         NS_ERROR("problem shutting down testshell");
-#endif
 
 #ifdef MOZ_CRASHREPORTER
     // Get the crashreporter service while XPCOM is still active.
     // This is a special exception: it will remain usable after NS_ShutdownXPCOM().
     nsCOMPtr<nsICrashReporter> crashReporter =
         do_GetService("@mozilla.org/toolkit/crash-reporter;1");
 #endif
 
--- a/layout/Makefile.in
+++ b/layout/Makefile.in
@@ -47,26 +47,23 @@ MODULE		= layout
 PARALLEL_DIRS = \
 		style \
 		base \
 		generic \
 		forms \
 		tables \
 		xul/base/public \
 		xul/base/src \
+		ipc \
 		$(NULL)
 
 ifdef NS_PRINTING
 PARALLEL_DIRS += printing
 endif
 
-ifdef MOZ_IPC
-PARALLEL_DIRS += ipc
-endif
-
 ifdef MOZ_MATHML
 PARALLEL_DIRS += \
   mathml \
   $(NULL)
 endif
 
 ifdef MOZ_SVG
 PARALLEL_DIRS += svg/base/src
--- a/layout/base/Makefile.in
+++ b/layout/base/Makefile.in
@@ -143,19 +143,17 @@ CPPSRCS		+= \
 		nsBidi.cpp \
 		$(NULL)
 endif                
 
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
-ifdef MOZ_IPC
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
-endif
 
 LOCAL_INCLUDES += \
 		-I$(srcdir) \
 		-I$(srcdir)/../style \
 		-I$(srcdir)/../generic \
 		-I$(srcdir)/../forms \
 		-I$(srcdir)/../tables \
 		-I$(srcdir)/../printing \
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/640272-ref.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html><head>
+    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+    <title>Testcase for bug 640272</title>
+<style>
+#waBackButton {
+	border: 1px solid blue;
+}
+</style>
+</head>
+<body>
+      <a href="index.html" id="waBackButton">Indietro</a>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/640272.html
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML>
+<html><head>
+    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+    <title>Testcase for bug 640272</title>
+<style>
+#waBackButton {
+	border: 1px solid blue;
+	-moz-border-image: url(640272-empty.html) 0 10 0 15;
+}
+</style>
+</head>
+<body>
+      <a href="index.html" id="waBackButton">Indietro</a>
+</body>
+</html>
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -321,8 +321,9 @@ load 595039-1.html
 load 606432-1.html
 load 609821-1.xhtml
 load 615146-1.html
 load 615781-1.xhtml
 load 616495-single-side-composite-color-border.html
 load 629035-1.html
 load 629908-1.html
 load 635329.html
+== 640272.html 640272-ref.html
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -2734,46 +2734,39 @@ nsCSSRendering::GetBackgroundLayerRect(n
 static void
 DrawBorderImage(nsPresContext*       aPresContext,
                 nsIRenderingContext& aRenderingContext,
                 nsIFrame*            aForFrame,
                 const nsRect&        aBorderArea,
                 const nsStyleBorder& aStyleBorder,
                 const nsRect&        aDirtyRect)
 {
+  NS_PRECONDITION(aStyleBorder.IsBorderImageLoaded(),
+                  "drawing border image that isn't successfully loaded");
+
   if (aDirtyRect.IsEmpty())
     return;
 
   // Ensure we get invalidated for loads and animations of the image.
   // We need to do this here because this might be the only code that
   // knows about the association of the style data with the frame.
   // XXX We shouldn't really... since if anybody is passing in a
   // different style, they'll potentially have the wrong size for the
   // border too.
   aPresContext->SetupBorderImageLoaders(aForFrame, &aStyleBorder);
 
   imgIRequest *req = aStyleBorder.GetBorderImage();
 
-#ifdef DEBUG
-  {
-    PRUint32 status = imgIRequest::STATUS_ERROR;
-    if (req)
-      req->GetImageStatus(&status);
-
-    NS_ASSERTION(req && (status & imgIRequest::STATUS_LOAD_COMPLETE),
-                 "no image to draw");
-  }
-#endif
-
   // Get the actual image, and determine where the split points are.
   // Note that mBorderImageSplit is in image pixels, not necessarily
   // CSS pixels.
 
   nsCOMPtr<imgIContainer> imgContainer;
   req->GetImage(getter_AddRefs(imgContainer));
+  NS_ASSERTION(imgContainer, "no image to draw");
 
   nsIntSize imageSize;
   if (NS_FAILED(imgContainer->GetWidth(&imageSize.width))) {
     imageSize.width =
       nsPresContext::AppUnitsToIntCSSPixels(aBorderArea.width);
   }
   if (NS_FAILED(imgContainer->GetHeight(&imageSize.height))) {
     imageSize.height =
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1696,18 +1696,16 @@ nsDisplayOwnLayer::~nsDisplayOwnLayer() 
 already_AddRefed<Layer>
 nsDisplayOwnLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
                               LayerManager* aManager) {
   nsRefPtr<Layer> layer = aBuilder->LayerBuilder()->
     BuildContainerLayerFor(aBuilder, aManager, mFrame, this, mList);
   return layer.forget();
 }
 
-#ifdef MOZ_IPC
-
 nsDisplayScrollLayer::nsDisplayScrollLayer(nsDisplayListBuilder* aBuilder,
                                            nsDisplayList* aList,
                                            nsIFrame* aForFrame,
                                            nsIFrame* aViewportFrame)
   : nsDisplayOwnLayer(aBuilder, aForFrame, aList)
   , mViewportFrame(aViewportFrame)
 {
 #ifdef NS_BUILD_REFCNT_LOGGING
@@ -1777,18 +1775,16 @@ nsDisplayScrollLayer::ComputeVisibility(
 
 #ifdef NS_BUILD_REFCNT_LOGGING
 nsDisplayScrollLayer::~nsDisplayScrollLayer()
 {
   MOZ_COUNT_DTOR(nsDisplayScrollLayer);
 }
 #endif
 
-#endif
-
 nsDisplayClip::nsDisplayClip(nsDisplayListBuilder* aBuilder,
                              nsIFrame* aFrame, nsDisplayItem* aItem,
                              const nsRect& aRect)
    : nsDisplayWrapList(aBuilder, aFrame, aItem) {
   MOZ_COUNT_CTOR(nsDisplayClip);
   mClip = SnapBounds(aBuilder->IsSnappingEnabled() && !aBuilder->IsInTransform(),
                      aBuilder->CurrentPresContext(), aRect);
 }
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -1764,17 +1764,16 @@ public:
   virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem)
   {
     // Don't allow merging, each sublist must have its own layer
     return PR_FALSE;
   }
   NS_DISPLAY_DECL_NAME("OwnLayer", TYPE_OWN_LAYER)
 };
 
-#ifdef MOZ_IPC
 /**
  * This creates a layer for the given list of items, whose visibility is
  * determined by the displayport for the given frame instead of what is
  * passed in to ComputeVisibility.
  *
  * Here in content, we can use this to render more content than is actually
  * visible. Then, the compositing process can manipulate the generated layer
  * through transformations so that asynchronous scrolling can be implemented.
@@ -1812,17 +1811,16 @@ public:
   {
     // Force this as a layer so we can scroll asynchronously.
     // This causes incorrect rendering for rounded clips!
     return mozilla::LAYER_ACTIVE_FORCE;
   }
 private:
   nsIFrame* mViewportFrame;
 };
-#endif
 
 /**
  * nsDisplayClip can clip a list of items, but we take a single item
  * initially and then later merge other items into it when we merge
  * adjacent matching nsDisplayClips
  */
 class nsDisplayClip : public nsDisplayWrapList {
 public:
--- a/layout/base/nsPresArena.cpp
+++ b/layout/base/nsPresArena.cpp
@@ -77,18 +77,16 @@
 #  ifdef MAP_ANONYMOUS
 #   define MAP_ANON MAP_ANONYMOUS
 #  else
 #   error "Don't know how to get anonymous memory"
 #  endif
 # endif
 #endif
 
-#ifndef DEBUG_TRACEMALLOC_PRESARENA
-
 // Size to use for PLArena block allocations.
 static const size_t ARENA_PAGE_SIZE = 4096;
 
 // Freed memory is filled with a poison value, which we arrange to
 // form a pointer either to an always-unmapped region of the address
 // space, or to a page that has been reserved and rendered
 // inaccessible via OS primitives.  See tests/TestPoisonArea.cpp for
 // extensive discussion of the requirements for this page.  The code
@@ -270,16 +268,17 @@ ARENA_POISON_init()
                             nsPrintfCString(17, "%.16llx", PRUint64(rgnbase)));
     cr->AnnotateCrashReport(NS_LITERAL_CSTRING("FramePoisonSize"),
                             nsPrintfCString("%lu", PRUint32(rgnsize)));
   }
 #endif
   return PR_SUCCESS;
 }
 
+#ifndef DEBUG_TRACEMALLOC_PRESARENA
 
 // All keys to this hash table fit in 32 bits (see below) so we do not
 // bother actually hashing them.
 
 namespace {
 
 class FreeList : public PLDHashEntryHdr
 {
@@ -400,20 +399,27 @@ nsPresArena::Size()
     arena = arena->next;
   }
 
   return result;
 }
 
 #else
 // Stub implementation that forwards everything to malloc and does not
-// poison.
+// poison allocations (it still initializes the poison value though,
+// for external use through GetPoisonValue()).
 
 struct nsPresArena::State
 {
+
+  State()
+  {
+    PR_CallOnce(&ARENA_POISON_guard, ARENA_POISON_init);
+  }
+
   void* Allocate(PRUint32 /* unused */, size_t aSize)
   {
     return PR_Malloc(aSize);
   }
 
   void Free(PRUint32 /* unused */, void* aPtr)
   {
     PR_Free(aPtr);
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2806,16 +2806,26 @@ nsRootPresContext::RootForgetUpdatePlugi
 {
   if (aFrame == mUpdatePluginGeometryForFrame) {
     mUpdatePluginGeometryForFrame->PresContext()->
       SetContainsUpdatePluginGeometryFrame(PR_FALSE);
     mUpdatePluginGeometryForFrame = nsnull;
   }
 }
 
+void
+nsRootPresContext::RootForgetUpdatePluginGeometryFrameForPresContext(
+  nsPresContext* aPresContext)
+{
+  if (aPresContext->GetContainsUpdatePluginGeometryFrame()) {
+    aPresContext->SetContainsUpdatePluginGeometryFrame(PR_FALSE);
+    mUpdatePluginGeometryForFrame = nsnull;
+  }
+}
+
 static void
 NotifyDidPaintForSubtreeCallback(nsITimer *aTimer, void *aClosure)
 {
   nsPresContext* presContext = (nsPresContext*)aClosure;
   nsAutoScriptBlocker blockScripts;
   presContext->NotifyDidPaintForSubtree();
 }
 
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -977,16 +977,21 @@ public:
   }
 
   void NotifyDestroyingFrame(nsIFrame* aFrame)
   {
     PropertyTable()->DeleteAllFor(aFrame);
   }
   inline void ForgetUpdatePluginGeometryFrame(nsIFrame* aFrame);
 
+  PRBool GetContainsUpdatePluginGeometryFrame()
+  {
+    return mContainsUpdatePluginGeometryFrame;
+  }
+
   void SetContainsUpdatePluginGeometryFrame(PRBool aValue)
   {
     mContainsUpdatePluginGeometryFrame = aValue;
   }
 
   PRBool MayHaveFixedBackgroundFrames() { return mMayHaveFixedBackgroundFrames; }
   void SetHasFixedBackgroundFrame() { mMayHaveFixedBackgroundFrames = PR_TRUE; }
 
@@ -1294,16 +1299,24 @@ public:
 
   /**
    * Call this when a frame is being destroyed and
    * mContainsUpdatePluginGeometryFrame is set in the frame's prescontext.
    */
   void RootForgetUpdatePluginGeometryFrame(nsIFrame* aFrame);
 
   /**
+   * Call this when a document is going to no longer be valid for plugin updates
+   * (say by going into the bfcache). If mContainsUpdatePluginGeometryFrame is
+   * set in the prescontext then it will be cleared along with
+   * mUpdatePluginGeometryForFrame.
+   */
+  void RootForgetUpdatePluginGeometryFrameForPresContext(nsPresContext* aPresContext);
+
+  /**
    * Increment DOM-modification generation counter to indicate that
    * the DOM has changed in a way that might lead to style changes/
    * reflows/frame creation and destruction.
    */
   void IncrementDOMGeneration() { mDOMGeneration++; }
 
   /**
    * Get the current DOM generation counter.
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -2767,21 +2767,24 @@ PresShell::InitialReflow(nscoord aWidth,
   }
 
   // For printing, we just immediately unsuppress.
   if (!mPresContext->IsPaginated()) {
     // Kick off a one-shot timer based off our pref value.  When this timer
     // fires, if painting is still locked down, then we will go ahead and
     // trigger a full invalidate and allow painting to proceed normally.
     mPaintingSuppressed = PR_TRUE;
-    mPaintSuppressionTimer = do_CreateInstance("@mozilla.org/timer;1");
-    if (!mPaintSuppressionTimer)
-      // Uh-oh.  We must be out of memory.  No point in keeping painting locked down.
+    // Don't suppress painting if the document isn't loading.
+    nsIDocument::ReadyState readyState = mDocument->GetReadyStateEnum();
+    if (readyState != nsIDocument::READYSTATE_COMPLETE) {
+      mPaintSuppressionTimer = do_CreateInstance("@mozilla.org/timer;1");
+    }
+    if (!mPaintSuppressionTimer) {
       mPaintingSuppressed = PR_FALSE;
-    else {
+    } else {
       // Initialize the timer.
 
       // Default to PAINTLOCK_EVENT_DELAY if we can't get the pref value.
       PRInt32 delay =
         nsContentUtils::GetIntPref("nglayout.initialpaint.delay",
                                    PAINTLOCK_EVENT_DELAY);
 
       mPaintSuppressionTimer->InitWithFuncCallback(sPaintSuppressionCallback,
@@ -7462,16 +7465,24 @@ PresShell::Freeze()
   }
 
   nsPresContext* presContext = GetPresContext();
   if (presContext &&
       presContext->RefreshDriver()->PresContext() == presContext) {
     presContext->RefreshDriver()->Freeze();
   }
 
+  if (presContext) {
+    nsRootPresContext* rootPresContext = presContext->GetRootPresContext();
+    if (rootPresContext) {
+      rootPresContext->
+        RootForgetUpdatePluginGeometryFrameForPresContext(mPresContext);
+    }
+  }
+
   mFrozen = PR_TRUE;
   if (mDocument) {
     UpdateImageLockingState();
   }
 }
 
 void
 PresShell::FireOrClearDelayedEvents(PRBool aFireEvents)
--- a/layout/build/Makefile.in
+++ b/layout/build/Makefile.in
@@ -73,27 +73,21 @@ CPPSRCS		= \
 		$(NULL)
 
 EXPORTS		= \
 		nsLayoutCID.h \
 		nsContentDLF.h \
 		nsLayoutStatics.h \
 		$(NULL)
 
-ifdef MOZ_IPC
-GKIPCLIB=../ipc/$(LIB_PREFIX)gkipc_s.$(LIB_SUFFIX)
-else
-GKIPCLIB=$(NULL)
-endif
-
 SHARED_LIBRARY_LIBS = \
 	../base/$(LIB_PREFIX)gkbase_s.$(LIB_SUFFIX) \
 	../forms/$(LIB_PREFIX)gkforms_s.$(LIB_SUFFIX) \
 	../generic/$(LIB_PREFIX)gkgeneric_s.$(LIB_SUFFIX) \
-	$(GKIPCLIB) \
+	../ipc/$(LIB_PREFIX)gkipc_s.$(LIB_SUFFIX) \
 	../style/$(LIB_PREFIX)gkstyle_s.$(LIB_SUFFIX) \
 	../tables/$(LIB_PREFIX)gktable_s.$(LIB_SUFFIX) \
 	../xul/base/src/$(LIB_PREFIX)gkxulbase_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/base/src/$(LIB_PREFIX)gkconbase_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/canvas/src/$(LIB_PREFIX)gkconcvs_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/events/src/$(LIB_PREFIX)gkconevents_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/html/content/src/$(LIB_PREFIX)gkconhtmlcon_s.$(LIB_SUFFIX) \
 	$(DEPTH)/content/html/document/src/$(LIB_PREFIX)gkconhtmldoc_s.$(LIB_SUFFIX) \
@@ -295,20 +289,18 @@ ifeq ($(OS_ARCH),Darwin)
 OS_LIBS += -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework Carbon -framework IOKit
 endif
 endif
 
 ifdef MOZ_NATIVE_LIBVPX
 EXTRA_DSO_LDOPTS += $(MOZ_LIBVPX_LIBS)
 endif
 
-ifdef MOZ_IPC
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
-endif
 
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES	+= -I$(srcdir)/../base \
 		   -I$(srcdir)/../generic \
 		   -I$(srcdir)/../forms \
 		   -I$(srcdir)/../tables \
 		   -I$(srcdir)/../style \
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -31,19 +31,17 @@
  * 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 ***** */
 
-#ifdef MOZ_IPC
 #include "base/basictypes.h"
-#endif
 
 #include "xpcmodule.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsLayoutStatics.h"
 #include "nsContentCID.h"
 #include "nsContentDLF.h"
 #include "nsContentPolicyUtils.h"
 #include "nsDataDocumentContentPolicy.h"
new file mode 100644
--- /dev/null
+++ b/layout/forms/crashtests/639733.xhtml
@@ -0,0 +1,26 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<script>
+<![CDATA[
+
+function remove(n)
+{
+  n.parentNode.removeChild(n);
+}
+
+function boom()
+{
+  
+  document.documentElement.offsetHeight;
+  remove(document.getElementById("s"));
+  remove(document.getElementById("e"));
+  document.documentElement.offsetHeight;
+}
+
+]]>
+</script>
+</head>
+<body onload="boom();">
+<embed id="e" src="data:text/html,A"></embed><span id="s"><div></div></span><isindex/>
+</body>
+</html>
--- a/layout/forms/crashtests/crashtests.list
+++ b/layout/forms/crashtests/crashtests.list
@@ -40,8 +40,9 @@ load 457537-2.html
 load 478219-1.xhtml
 load 513113-1.html
 load 538062-1.xhtml
 load 570624-1.html
 load 498698-1.html
 asserts(1) load 578604-1.html # bug 584564
 asserts(5) load 590302-1.xhtml # bug 584564
 load 626014.xhtml
+load 639733.xhtml
--- a/layout/forms/nsIsIndexFrame.cpp
+++ b/layout/forms/nsIsIndexFrame.cpp
@@ -522,21 +522,22 @@ nsIsIndexFrame::URLEncode(const nsString
 //----------------------------------------------------------------------
 // nsIStatefulFrame
 //----------------------------------------------------------------------
 NS_IMETHODIMP
 nsIsIndexFrame::SaveState(SpecialStateID aStateID, nsPresState** aState)
 {
   NS_ENSURE_ARG_POINTER(aState);
 
+  *aState = nsnull;
+
   // Get the value string
   nsAutoString stateString;
   GetInputValue(stateString);
 
-  nsresult res = NS_OK;
   if (! stateString.IsEmpty()) {
 
     // Construct a pres state and store value in it.
     *aState = new nsPresState();
     if (!*aState)
       return NS_ERROR_OUT_OF_MEMORY;
 
     nsCOMPtr<nsISupportsString> state
@@ -544,26 +545,31 @@ nsIsIndexFrame::SaveState(SpecialStateID
 
     if (!state)
       return NS_ERROR_OUT_OF_MEMORY;
 
     state->SetData(stateString);
     (*aState)->SetStateProperty(state);
   }
 
-  return res;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIsIndexFrame::RestoreState(nsPresState* aState)
 {
   NS_ENSURE_ARG_POINTER(aState);
 
   // Set the value to the stored state.
   nsCOMPtr<nsISupportsString> stateString
     (do_QueryInterface(aState->GetStateProperty()));
-  
+
+  if (!stateString) {
+    NS_ERROR("Not a <isindex> state!");
+    return NS_ERROR_FAILURE;
+  }
+
   nsAutoString data;
   stateString->GetData(data);
   SetInputValue(data);
 
   return NS_OK;
 }
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -6731,30 +6731,30 @@ nsBlockFrame::RenumberListsFor(nsPresCon
   NS_PRECONDITION(aPresContext && aKid && aOrdinal, "null params are immoral!");
 
   // add in a sanity check for absurdly deep frame trees.  See bug 42138
   if (MAX_DEPTH_FOR_LIST_RENUMBERING < aDepth)
     return PR_FALSE;
 
   // if the frame is a placeholder, then get the out of flow frame
   nsIFrame* kid = nsPlaceholderFrame::GetRealFrameFor(aKid);
+  const nsStyleDisplay* display = kid->GetStyleDisplay();
 
   // drill down through any wrappers to the real frame
   kid = kid->GetContentInsertionFrame();
 
   // possible there is no content insertion frame
   if (!kid)
     return PR_FALSE;
 
   PRBool kidRenumberedABullet = PR_FALSE;
 
   // If the frame is a list-item and the frame implements our
   // block frame API then get its bullet and set the list item
   // ordinal.
-  const nsStyleDisplay* display = kid->GetStyleDisplay();
   if (NS_STYLE_DISPLAY_LIST_ITEM == display->mDisplay) {
     // Make certain that the frame is a block frame in case
     // something foreign has crept in.
     nsBlockFrame* listItem = nsLayoutUtils::GetAsBlock(kid);
     if (listItem) {
       if (nsnull != listItem->mBullet) {
         PRBool changed;
         *aOrdinal = listItem->mBullet->SetListItemOrdinal(*aOrdinal,
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -50,19 +50,17 @@
 #include <QWidget>
 #include <QKeyEvent>
 #ifdef MOZ_X11
 #include <QX11Info>
 #endif
 #undef slots
 #endif
 
-#ifdef MOZ_IPC
 #include "mozilla/plugins/PluginMessageUtils.h"
-#endif
 
 #ifdef MOZ_X11
 #include <cairo-xlib.h>
 #include "gfxXlibSurface.h"
 /* X headers suck */
 enum { XKeyPress = KeyPress };
 #ifdef KeyPress
 #undef KeyPress
@@ -235,19 +233,17 @@ using mozilla::DefaultXDisplay;
 static PRLogModuleInfo *nsObjectFrameLM = PR_NewLogModule("nsObjectFrame");
 #endif /* PR_LOGGING */
 
 #if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
 #define MAC_CARBON_PLUGINS
 #endif
 
 using namespace mozilla;
-#ifdef MOZ_IPC
 using namespace mozilla::plugins;
-#endif
 using namespace mozilla::layers;
 
 // special class for handeling DOM context menu events because for
 // some reason it starves other mouse events if implemented on the
 // same class
 class nsPluginDOMContextMenuListener : public nsIDOMContextMenuListener
 {
 public:
@@ -533,16 +529,17 @@ private:
 #ifdef XP_MACOSX
   NP_CGContext                              mCGPluginPortCopy;
 #ifndef NP_NO_QUICKDRAW
   NP_Port                                   mQDPluginPortCopy;
 #endif
   PRInt32                                   mInCGPaintLevel;
   nsIOSurface                              *mIOSurface;
   nsCARenderer                              mCARenderer;
+  CGColorSpaceRef                           mColorProfile;
   static nsCOMPtr<nsITimer>                *sCATimer;
   static nsTArray<nsPluginInstanceOwner*>  *sCARefreshListeners;
   PRBool                                    mSentInitialTopLevelWindowEvent;
 #endif
 
   // Initially, the event loop nesting level we were created on, it's updated
   // if we detect the appshell is on a lower level as long as we're not stopped.
   // We delay DoStopPlugin() until the appshell reaches this level or lower.
@@ -2350,29 +2347,27 @@ nsObjectFrame::PaintPlugin(nsDisplayList
     NPWindow *window;
     mInstanceOwner->GetWindow(window);
 
     if (window->type == NPWindowTypeDrawable) {
       // the offset of the DC
       nsPoint origin;
 
       gfxWindowsNativeDrawing nativeDraw(ctx, frameGfxRect);
-#ifdef MOZ_IPC
       if (nativeDraw.IsDoublePass()) {
         // OOP plugin specific: let the shim know before we paint if we are doing a
         // double pass render. If this plugin isn't oop, the register window message
         // will be ignored.
         NPEvent pluginEvent;
         pluginEvent.event = DoublePassRenderingEvent();
         pluginEvent.wParam = 0;
         pluginEvent.lParam = 0;
         if (pluginEvent.event)
           inst->HandleEvent(&pluginEvent, nsnull);
       }
-#endif
       do {
         HDC hdc = nativeDraw.BeginNativeDrawing();
         if (!hdc)
           return;
 
         RECT dest;
         nativeDraw.TransformToNativeRect(frameGfxRect, dest);
         RECT dirty;
@@ -3176,16 +3171,17 @@ nsPluginInstanceOwner::nsPluginInstanceO
 #ifdef XP_MACOSX
   memset(&mCGPluginPortCopy, 0, sizeof(NP_CGContext));
 #ifndef NP_NO_QUICKDRAW
   memset(&mQDPluginPortCopy, 0, sizeof(NP_Port));
 #endif
   mInCGPaintLevel = 0;
   mSentInitialTopLevelWindowEvent = PR_FALSE;
   mIOSurface = nsnull;
+  mColorProfile = nsnull;
   mPluginPortChanged = PR_FALSE;
 #endif
   mContentFocused = PR_FALSE;
   mWidgetVisible = PR_TRUE;
   mPluginWindowVisible = PR_FALSE;
   mNumCachedAttrs = 0;
   mNumCachedParams = 0;
   mCachedAttrParamNames = nsnull;
@@ -4377,18 +4373,18 @@ void nsPluginInstanceOwner::SetupCARefre
 
 void nsPluginInstanceOwner::RenderCoreAnimation(CGContextRef aCGContext, 
                                                 int aWidth, int aHeight)
 {
   if (aWidth == 0 || aHeight == 0)
     return;
 
   if (!mIOSurface || 
-     (mIOSurface->GetWidth() != (size_t)aWidth || 
-      mIOSurface->GetHeight() != (size_t)aHeight)) {
+      (mIOSurface->GetWidth() != (size_t)aWidth || 
+       mIOSurface->GetHeight() != (size_t)aHeight)) {
     if (mIOSurface) {
       delete mIOSurface;
     }
 
     // If the renderer is backed by an IOSurface, resize it as required.
     mIOSurface = nsIOSurface::CreateIOSurface(aWidth, aHeight);
     if (mIOSurface) {
       nsIOSurface *attachSurface = nsIOSurface::LookupSurface(
@@ -4399,16 +4395,20 @@ void nsPluginInstanceOwner::RenderCoreAn
         NS_ERROR("IOSurface attachment failed");
         delete attachSurface;
         delete mIOSurface;
         mIOSurface = NULL;
       }
     }
   }
 
+  if (!mColorProfile) {
+    mColorProfile = CreateSystemColorSpace();
+  }
+
   if (mCARenderer.isInit() == false) {
     void *caLayer = NULL;
     nsresult rv = mInstance->GetValueFromPlugin(NPPVpluginCoreAnimationLayer, &caLayer);
     if (NS_FAILED(rv) || !caLayer) {
       return;
     }
 
     mCARenderer.SetupRenderer(caLayer, aWidth, aHeight);
@@ -4416,18 +4416,18 @@ void nsPluginInstanceOwner::RenderCoreAn
     // Setting up the CALayer requires resetting the painting otherwise we
     // get garbage for the first few frames.
     FixUpPluginWindow(ePluginPaintDisable);
     FixUpPluginWindow(ePluginPaintEnable);
   }
 
   CGImageRef caImage = NULL;
   nsresult rt = mCARenderer.Render(aWidth, aHeight, &caImage);
-  if (rt == NS_OK && mIOSurface) {
-    nsCARenderer::DrawSurfaceToCGContext(aCGContext, mIOSurface, CreateSystemColorSpace(),
+  if (rt == NS_OK && mIOSurface && mColorProfile) {
+    nsCARenderer::DrawSurfaceToCGContext(aCGContext, mIOSurface, mColorProfile,
                                          0, 0, aWidth, aHeight);
   } else if (rt == NS_OK && caImage != NULL) {
     // Significant speed up by resetting the scaling
     ::CGContextSetInterpolationQuality(aCGContext, kCGInterpolationNone );
     ::CGContextTranslateCTM(aCGContext, 0, aHeight);
     ::CGContextScaleCTM(aCGContext, 1.0, -1.0);
 
     ::CGContextDrawImage(aCGContext, CGRectMake(0,0,aWidth,aHeight), caImage);
@@ -5749,16 +5749,18 @@ nsPluginInstanceOwner::Destroy()
 #ifdef MAC_CARBON_PLUGINS
   // stop the timer explicitly to reduce reference count.
   CancelTimer();
 #endif
 #ifdef XP_MACOSX
   RemoveFromCARefreshTimer(this);
   if (mIOSurface)
     delete mIOSurface;
+  if (mColorProfile)
+    ::CGColorSpaceRelease(mColorProfile);  
 #endif
 
   // unregister context menu listener
   if (mCXMenuListener) {
     mCXMenuListener->Destroy(mContent);
     mCXMenuListener = nsnull;
   }
 
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -38,20 +38,18 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /*
  * rendering object for replaced elements that contain a document, such
  * as <frame>, <iframe>, and some <object>s
  */
 
-#ifdef MOZ_IPC
 #include "mozilla/layout/RenderFrameParent.h"
 using mozilla::layout::RenderFrameParent;
-#endif
 
 #include "nsSubDocumentFrame.h"
 #include "nsCOMPtr.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeNode.h"
@@ -272,25 +270,23 @@ nsSubDocumentFrame::BuildDisplayList(nsD
     return NS_OK;
 
   nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!mInnerView)
     return NS_OK;
 
-#ifdef MOZ_IPC
   nsFrameLoader* frameLoader = FrameLoader();
   if (frameLoader) {
     RenderFrameParent* rfp = frameLoader->GetCurrentRemoteFrame();
     if (rfp) {
       return rfp->BuildDisplayList(aBuilder, this, aDirtyRect, aLists);
     }
   }
-#endif
 
   nsIView* subdocView = mInnerView->GetFirstChild();
   if (!subdocView)
     return NS_OK;
 
   nsCOMPtr<nsIPresShell> presShell = nsnull;
 
   nsIFrame* subdocRootFrame =
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/642800-iframe.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        @media only screen and (max-width: 480px) {
+            .overflow-hidden 
+            {
+                overflow: hidden;
+            }
+            
+            .float-left
+            {
+                float: left;
+                background: #f0f;
+            }
+        }
+    </style>
+</head>
+<body>
+    <h1>Iframe content</h1>
+    <div class="float-left">
+        <textarea>This text should be visible when window is resized </textarea>
+
+    </div>
+    <div class="overflow-hidden">
+        <textarea>This text should be visible when window is resized </textarea>
+    </div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/642800-ref.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<body>
+    <iframe onload="document.documentElement.className=''" src="642800-iframe.html" id="iframe" style="width: 500px; height: 200px"></iframe>
+</body>
+</html>
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/editor/642800.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+    <script type="text/javascript">
+        function reframe(node) {
+            node.style.display = "none";
+            document.body.offsetWidth;
+            node.style.display = "block";
+            document.documentElement.className='';
+        }
+    </script>
+</head>
+<body>
+    <iframe onload="reframe(this)" src="642800-iframe.html" id="iframe" style="width: 500px; height: 200px"></iframe>
+
+</body>
+</html>
+
--- a/layout/reftests/editor/reftest.list
+++ b/layout/reftests/editor/reftest.list
@@ -54,8 +54,9 @@ fails-if(Android) != spellcheck-hyphen-i
 == spellcheck-space-valid.html spellcheck-space-valid-ref.html
 == spellcheck-comma-valid.html spellcheck-comma-valid-ref.html
 == spellcheck-hyphen-multiple-valid.html spellcheck-hyphen-multiple-valid-ref.html
 fails-if(Android) != spellcheck-hyphen-multiple-invalid.html spellcheck-hyphen-multiple-invalid-ref.html