Merge.
authorRobert Sayre <sayrer@gmail.com>
Tue, 22 Dec 2009 12:08:43 -0500
changeset 36544 10050c1a0b32bdc2debdb55f7c423345a2dd23fa
parent 36543 876a1db26a288ac8324e87eca65d927def05d593 (current diff)
parent 36542 195db4224a601cda5f8a07d23b0175c647759766 (diff)
child 36565 570cd13958e2ece42f441bdb535da365ce9de974
child 46487 5a9385b5235398264e43a15ef19cbd43f5fb12a9
push idunknown
push userunknown
push dateunknown
milestone1.9.3a1pre
Merge.
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -779,16 +779,22 @@ pref("browser.sessionstore.max_tabs_undo
 pref("browser.sessionstore.max_windows_undo", 3);
 // number of crashes that can occur before the about:sessionrestore page is displayed
 // (this pref has no effect if more than 6 hours have passed since the last crash)
 pref("browser.sessionstore.max_resumed_crashes", 1);
 
 // allow META refresh by default
 pref("accessibility.blockautorefresh", false);
 
+// The percentage of system memory that the Places database can use.  Out of the
+// allowed cache size it will at most use the size of the database file.
+// Changes to this value are effective after an application restart.
+// Acceptable values are between 0 and 50.
+pref("places.database.cache_to_memory_percentage", 6);
+
 // the (maximum) number of the recent visits to sample
 // when calculating frecency
 pref("places.frecency.numVisits", 10);
 
 // buckets (in days) for frecency calculation
 pref("places.frecency.firstBucketCutoff", 4);
 pref("places.frecency.secondBucketCutoff", 14);
 pref("places.frecency.thirdBucketCutoff", 31);
--- a/browser/base/content/NetworkPrioritizer.jsm
+++ b/browser/base/content/NetworkPrioritizer.jsm
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Paul O’Shannessy <paul@oshannessy.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/browser/base/content/test/browser_NetworkPrioritizer.js
+++ b/browser/base/content/test/browser_NetworkPrioritizer.js
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Paul O’Shannessy <paul@oshannessy.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/browser/branding/nightly/Makefile.in
+++ b/browser/branding/nightly/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2009
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Justin Dolske <dolske@mozilla.com> (original author)
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/browser/branding/unofficial/Makefile.in
+++ b/browser/branding/unofficial/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2009
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Justin Dolske <dolske@mozilla.com> (original author)
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/browser/components/dirprovider/nsBrowserDirectoryServiceDefs.h
+++ b/browser/components/dirprovider/nsBrowserDirectoryServiceDefs.h
@@ -8,17 +8,17 @@
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is the Mozilla Firefox browser.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  *
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Myk Melez <myk@mozilla.org>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/browser/components/places/content/bookmarksPanel.js
+++ b/browser/components/places/content/bookmarksPanel.js
@@ -9,17 +9,17 @@
 #
 # 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 Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2007
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Dan Mills <thunder@mozilla.com> (Original Author)
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/browser/components/places/content/moveBookmarks.js
+++ b/browser/components/places/content/moveBookmarks.js
@@ -9,17 +9,17 @@
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is the Places Move Bookmarks Dialog.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Asaf Romano <mano@mozilla.com>
  *   Sungjoon Steve Won <stevewon@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/browser/components/places/public/nsIPlacesTransactionsService.idl
+++ b/browser/components/places/public/nsIPlacesTransactionsService.idl
@@ -9,17 +9,17 @@
  *
  * 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 Places.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  *
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Sungjoon Steve Won <stevewon@gmail.com> (Original Author)
  *   Asaf Romano <mano@mozilla.com>
  *
--- a/browser/components/sessionstore/test/browser/browser_480148.js
+++ b/browser/components/sessionstore/test/browser/browser_480148.js
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Paul O’Shannessy <poshannessy@mozilla.com> (primary author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/browser/components/sessionstore/test/browser/browser_514751.js
+++ b/browser/components/sessionstore/test/browser/browser_514751.js
@@ -8,17 +8,17 @@
  *
  * 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 sessionstore test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  * Paul O’Shannessy <paul@oshannessy.com>
  *
  * 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
--- a/browser/fuel/Makefile.in
+++ b/browser/fuel/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 FUEL.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2006
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Mark Finkle <mfinkle@mozilla.com>
 #   John Resig  <jresig@mozilla.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
--- a/browser/fuel/public/Makefile.in
+++ b/browser/fuel/public/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 FUEL.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2006
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Mark Finkle <mfinkle@mozilla.com>
 #   John Resig  <jresig@mozilla.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
--- a/browser/fuel/public/fuelIApplication.idl
+++ b/browser/fuel/public/fuelIApplication.idl
@@ -8,17 +8,17 @@
  *
  * 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 FUEL.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Mark Finkle <mfinkle@mozilla.com> (Original Author)
  *  John Resig  <jresig@mozilla.com> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/browser/fuel/src/Makefile.in
+++ b/browser/fuel/src/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 FUEL.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2006
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Mark Finkle <mfinkle@mozilla.com>
 #   John Resig  <jresig@mozilla.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
--- a/browser/fuel/src/fuelApplication.js
+++ b/browser/fuel/src/fuelApplication.js
@@ -8,17 +8,17 @@
  *
  * 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 FUEL.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Mark Finkle <mfinkle@mozilla.com> (Original Author)
  *  John Resig  <jresig@mozilla.com> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/browser/fuel/test/Makefile.in
+++ b/browser/fuel/test/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 FUEL.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2006
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Mark Finkle <mfinkle@mozilla.com>
 #   John Resig  <jresig@mozilla.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
--- a/browser/themes/gnomestripe/browser/preferences/applications.css
+++ b/browser/themes/gnomestripe/browser/preferences/applications.css
@@ -8,17 +8,17 @@
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is the Firefox Preferences System.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2005
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Florian Queze <florian@mozilla.com>
  *
  * 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
--- a/browser/themes/pinstripe/browser/preferences/applications.css
+++ b/browser/themes/pinstripe/browser/preferences/applications.css
@@ -8,17 +8,17 @@
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is the Firefox Preferences System.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2005
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Florian Queze <florian@mozilla.com>
  *
  * 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
--- a/browser/themes/winstripe/browser/preferences/applications.css
+++ b/browser/themes/winstripe/browser/preferences/applications.css
@@ -8,17 +8,17 @@
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is the Firefox Preferences System.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2005
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Florian Queze <florian@mozilla.com>
  *
  * 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
--- a/configure.in
+++ b/configure.in
@@ -6180,16 +6180,85 @@ MOZ_NATIVE_SQLITE=1,
 MOZ_NATIVE_SQLITE= )
 
 if test -z "$MOZ_NATIVE_SQLITE"
 then
     SQLITE_CFLAGS=
     SQLITE_LIBS='$(call EXPAND_LIBNAME_PATH,mozsqlite3,$(DIST)/lib)'
 else
     PKG_CHECK_MODULES(SQLITE, sqlite3 >= $SQLITE_VERSION)
+    dnl ===================================
+    dnl === SQLITE_SECURE_DELETE checks ===
+    dnl ===================================
+    dnl check to see if the system sqlite package is compiled with
+    dnl SQLITE_SECURE_DELETE enabled.
+    AC_MSG_CHECKING(for SQLITE_SECURE_DELETE support in system sqlite)
+    _SAVE_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $SQLITE_CFLAGS"
+    _SAVE_LIBS="$LIBS"
+    LIBS="$LIBS $SQLITE_LIBS"
+    AC_CACHE_VAL(ac_cv_sqlite_secure_delete,[
+        AC_TRY_RUN([
+            #include "sqlite3.h"
+            #include <stdio.h>
+            #include <assert.h>
+
+            int main(int argc, char **argv){
+              sqlite3 *db;
+              sqlite3_uint64 r;
+              char *zFilename;
+              FILE *in;
+              int i;
+              int rc;
+              char *zBuf;
+
+              zBuf = malloc(1024*3*sizeof(char));
+              assert( zBuf );
+              rc = sqlite3_open(":memory:", &db);
+              assert( rc==SQLITE_OK );
+              sqlite3_close(db);
+              sqlite3_randomness(sizeof(r), &r);
+              zFilename = sqlite3_mprintf("test_db_%llu.sqlite", r);
+              rc = sqlite3_open(zFilename, &db);
+              assert( rc==SQLITE_OK );
+              rc = sqlite3_exec(db, 
+                "BEGIN;"
+                "CREATE TABLE t1(x);"
+                "INSERT INTO t1 VALUES(zeroblob(1000)||'abcdefghijklmnopqrstuvwxyz');"
+                "COMMIT;"
+                "DELETE FROM t1;",
+                0, 0, 0
+              );
+              assert( rc==SQLITE_OK );
+              sqlite3_close(db);
+              in = fopen(zFilename, "r");
+              assert( in!=0 );
+              rc = fread(zBuf, 1, sizeof(zBuf), in);
+              assert( rc==sizeof(zBuf) );
+              fclose(in);
+              unlink(zFilename);
+              free( zBuf );
+              for(i=0; i<sizeof(zBuf)-11; i++){
+                if( *(zBuf+i)=='h' && memcmp(zBuf+i, "hijklmnopq", 10)==0 ){
+                  return 1;
+                }
+              }
+              return 0;
+            }],
+            ac_cv_sqlite_secure_delete=yes,
+            ac_cv_sqlite_secure_delete=no,
+            ac_cv_sqlite_secure_delete=no
+        )
+    ])
+    AC_MSG_RESULT($ac_cv_sqlite_secure_delete)
+    CFLAGS="$_SAVE_CFLAGS"
+    LIBS="$_SAVE_LIBS"
+    if test "x$ac_cv_sqlite_secure_delete" = "xno"; then
+        AC_MSG_ERROR([System Sqlite library is not compiled with SQLITE_SECURE_DELETE.])
+    fi
 fi
 
 AC_SUBST(MOZ_NATIVE_SQLITE)
 
 dnl ========================================================
 dnl = Enable help viewer (off by default)
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(help-viewer,
--- a/content/base/src/nsNoDataProtocolContentPolicy.cpp
+++ b/content/base/src/nsNoDataProtocolContentPolicy.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *         Jonas Sicking <jonas@sicking.cc> (Original Author)
  *
  * 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"),
--- a/content/base/src/nsNoDataProtocolContentPolicy.h
+++ b/content/base/src/nsNoDataProtocolContentPolicy.h
@@ -9,17 +9,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *         Jonas Sicking <jonas@sicking.cc> (Original Author)
  *
  * 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"),
--- a/content/base/src/nsNodeUtils.cpp
+++ b/content/base/src/nsNodeUtils.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *         Jonas Sicking <jonas@sicking.cc> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/content/base/src/nsNodeUtils.h
+++ b/content/base/src/nsNodeUtils.h
@@ -9,17 +9,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *         Jonas Sicking <jonas@sicking.cc> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/content/events/src/nsDOMScrollAreaEvent.cpp
+++ b/content/events/src/nsDOMScrollAreaEvent.cpp
@@ -9,17 +9,17 @@
  *
  * 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 code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Roy Frostig <froystig@cs.stanford.edu>
  *
  * 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"),
--- a/content/events/src/nsDOMScrollAreaEvent.h
+++ b/content/events/src/nsDOMScrollAreaEvent.h
@@ -9,17 +9,17 @@
  *
  * 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 code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Roy Frostig <froystig@cs.stanford.edu>
  *
  * 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"),
--- a/content/html/content/public/nsIHTMLCollection.h
+++ b/content/html/content/public/nsIHTMLCollection.h
@@ -9,17 +9,17 @@
  *
  * 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 DOM code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *         Peter Van der Beken <peterv@propagandism.org> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/content/smil/test/test_smilTextZoom.xhtml
+++ b/content/smil/test/test_smilTextZoom.xhtml
@@ -60,16 +60,18 @@ function main()
     // * Correct behavior is for the computed values of 'font-size' to be
     // exactly twice as large as their corresponding specified values.
     // (Mozilla's SVG code divides out the textZoom factor from these computed
     // values when rendering, to obtain the correct font-size.)
     // * I also include tests for an identical animation of the "stroke-width"
     // property, which should _not_ be affected by textZoom.
     var text = document.getElementsByTagName("text")[0];
     var rect = document.getElementsByTagName("rect")[0];
+
+    svg.setCurrentTime(0);
     verifyStyle(text, "font-size",    "10px");
     verifyStyle(rect, "stroke-width", "5px");
     svg.setCurrentTime(1);
     verifyStyle(text, "font-size",    "40px");
     verifyStyle(rect, "stroke-width", "20px");
     svg.setCurrentTime(1.5);
     verifyStyle(text, "font-size",    "60px");
     verifyStyle(rect, "stroke-width", "30px");
--- a/content/xslt/public/nsIXSLTProcessorPrivate.idl
+++ b/content/xslt/public/nsIXSLTProcessorPrivate.idl
@@ -9,17 +9,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Jonas Sicking <jonas@sicking.cc> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/content/xslt/src/base/txOwningArray.h
+++ b/content/xslt/src/base/txOwningArray.h
@@ -10,17 +10,17 @@
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is TransforMiiX XSLT processor.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Jonas Sicking <jonas@sicking.cc>
  *
  * 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
--- a/content/xslt/src/xpath/txUnionNodeTest.cpp
+++ b/content/xslt/src/xpath/txUnionNodeTest.cpp
@@ -10,17 +10,17 @@
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is TransforMiiX XSLT processor.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Jonas Sicking <jonas@sicking.cc>
  *
  * 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
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -9,17 +9,17 @@
  *
  * 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 mozila.org code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * 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"),
--- a/dom/base/nsFocusManager.h
+++ b/dom/base/nsFocusManager.h
@@ -9,17 +9,17 @@
  *
  * 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 mozila.org code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * 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"),
--- a/dom/interfaces/base/nsIFocusManager.idl
+++ b/dom/interfaces/base/nsIFocusManager.idl
@@ -9,17 +9,17 @@
  *
  * 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 Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * 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"),
--- a/dom/interfaces/events/nsIDOMScrollAreaEvent.idl
+++ b/dom/interfaces/events/nsIDOMScrollAreaEvent.idl
@@ -9,17 +9,17 @@
  *
  * 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 code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Roy Frostig <froystig@cs.stanford.edu>
  *
  * 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"),
--- a/dom/interfaces/geolocation/Makefile.in
+++ b/dom/interfaces/geolocation/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 build system.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation
+# The Initial Developer of the Original Code is Mozilla Foundation
 # Portions created by the Initial Developer are Copyright (C) 2008
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #  Doug Turner <dougt@meer.net>
 #
 # 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
--- a/dom/interfaces/geolocation/nsIDOMGeoGeolocation.idl
+++ b/dom/interfaces/geolocation/nsIDOMGeoGeolocation.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/interfaces/geolocation/nsIDOMGeoPosition.idl
+++ b/dom/interfaces/geolocation/nsIDOMGeoPosition.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl
+++ b/dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/interfaces/geolocation/nsIDOMGeoPositionCallback.idl
+++ b/dom/interfaces/geolocation/nsIDOMGeoPositionCallback.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/interfaces/geolocation/nsIDOMGeoPositionCoords.idl
+++ b/dom/interfaces/geolocation/nsIDOMGeoPositionCoords.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/interfaces/geolocation/nsIDOMGeoPositionError.idl
+++ b/dom/interfaces/geolocation/nsIDOMGeoPositionError.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/interfaces/geolocation/nsIDOMGeoPositionErrorCallback.idl
+++ b/dom/interfaces/geolocation/nsIDOMGeoPositionErrorCallback.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/interfaces/geolocation/nsIDOMGeoPositionOptions.idl
+++ b/dom/interfaces/geolocation/nsIDOMGeoPositionOptions.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/interfaces/geolocation/nsIDOMNavigatorGeolocation.idl
+++ b/dom/interfaces/geolocation/nsIDOMNavigatorGeolocation.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/interfaces/geolocation/nsIGeolocationProvider.idl
+++ b/dom/interfaces/geolocation/nsIGeolocationProvider.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/interfaces/json/Makefile.in
+++ b/dom/interfaces/json/Makefile.in
@@ -9,17 +9,17 @@
 #
 # 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 Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2007
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Robert Sayre <sayrer@gmail.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"),
--- a/dom/interfaces/threads/Makefile.in
+++ b/dom/interfaces/threads/Makefile.in
@@ -9,17 +9,17 @@
 #
 # 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 Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2007
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Vladimir Vukicevic <vladimir@pobox.com> (Original Author)
 #   Ben Turner <bent.mozilla@gmail.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
--- a/dom/src/geolocation/GPSDGeolocationProvider.js
+++ b/dom/src/geolocation/GPSDGeolocationProvider.js
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Martin McNickle <mmcnickle@gmail.com>
  *
  * Based on static_geolocation_provider.js by:
  *  Doug Turner <dougt@meer.net>
--- a/dom/src/geolocation/Makefile.in
+++ b/dom/src/geolocation/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 build system.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation
+# The Initial Developer of the Original Code is Mozilla Foundation
 # Portions created by the Initial Developer are Copyright (C) 2008
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #  Doug Turner <dougt@meer.net>
 #
 # 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
--- a/dom/src/geolocation/WinMobileLocationProvider.cpp
+++ b/dom/src/geolocation/WinMobileLocationProvider.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *  Nino D'Aversa <ninodaversa@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/dom/src/geolocation/WinMobileLocationProvider.h
+++ b/dom/src/geolocation/WinMobileLocationProvider.h
@@ -9,17 +9,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *  Nino D'Aversa <ninodaversa@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/src/geolocation/nsGeolocation.h
+++ b/dom/src/geolocation/nsGeolocation.h
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/dom/src/json/Makefile.in
+++ b/dom/src/json/Makefile.in
@@ -9,17 +9,17 @@
 #
 # 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 Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2007
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Robert Sayre <sayrer@gmail.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"),
--- a/dom/src/json/test/Makefile.in
+++ b/dom/src/json/test/Makefile.in
@@ -9,17 +9,17 @@
 #
 # 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 Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2007
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Robert Sayre <sayrer@gmail.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"),
--- a/dom/tests/mochitest/geolocation/Makefile.in
+++ b/dom/tests/mochitest/geolocation/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 build system.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation
+# The Initial Developer of the Original Code is Mozilla Foundation
 # Portions created by the Initial Developer are Copyright (C) 2008
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #  Doug Turner <dougt@meer.net>
 #
 # 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
--- a/gfx/cairo/cairo/src/cairo-fixed-private.h
+++ b/gfx/cairo/cairo/src/cairo-fixed-private.h
@@ -23,17 +23,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  *
  * Contributor(s):
  *	Vladimir Vukicevic <vladimir@pobox.com>
  */
 
 #ifndef CAIRO_FIXED_PRIVATE_H
 #define CAIRO_FIXED_PRIVATE_H
 
--- a/gfx/cairo/cairo/src/cairo-fixed-type-private.h
+++ b/gfx/cairo/cairo/src/cairo-fixed-type-private.h
@@ -23,17 +23,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  *
  * Contributor(s):
  *	Vladimir Vukicevic <vladimir@pobox.com>
  */
 
 #ifndef CAIRO_FIXED_TYPE_PRIVATE_H
 #define CAIRO_FIXED_TYPE_PRIVATE_H
 
--- a/gfx/cairo/cairo/src/cairo-malloc-private.h
+++ b/gfx/cairo/cairo/src/cairo-malloc-private.h
@@ -23,17 +23,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  *
  * Contributor(s):
  *	Vladimir Vukicevic <vladimir@pobox.com>
  */
 
 #ifndef CAIRO_MALLOC_PRIVATE_H
 #define CAIRO_MALLOC_PRIVATE_H
 
--- a/gfx/cairo/cairo/src/cairo-qpainter-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-qpainter-surface.cpp
@@ -23,17 +23,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  *
  * Contributor(s):
  *      Vladimir Vukicevic <vladimir@mozilla.com>
  */
 
 /* Get INT16_MIN etc. as per C99 */
 #define __STDC_LIMIT_MACROS
 
--- a/gfx/cairo/cairo/src/cairo-qpainter.h
+++ b/gfx/cairo/cairo/src/cairo-qpainter.h
@@ -23,17 +23,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  *
  * Contributor(s):
  *      Vladimir Vukicevic <vladimir@mozilla.com>
  */
 
 #ifndef CAIRO_QPAINTER_H
 #define CAIRO_QPAINTER_H
 
--- a/gfx/cairo/cairo/src/cairo-quartz-font.c
+++ b/gfx/cairo/cairo/src/cairo-quartz-font.c
@@ -23,17 +23,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  *
  * Contributor(s):
  *	Vladimir Vukicevic <vladimir@mozilla.com>
  */
 
 #include "cairoint.h"
 
 #include <dlfcn.h>
--- a/gfx/cairo/cairo/src/cairo-quartz-image-surface.c
+++ b/gfx/cairo/cairo/src/cairo-quartz-image-surface.c
@@ -23,17 +23,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  *
  * Contributor(s):
  *	Vladimir Vukicevic <vladimir@mozilla.com>
  */
 
 #include "cairoint.h"
 
 #include "cairo-quartz-image.h"
--- a/gfx/cairo/cairo/src/cairo-quartz-image.h
+++ b/gfx/cairo/cairo/src/cairo-quartz-image.h
@@ -22,17 +22,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  *
  * Contributor(s):
  *      Vladimir Vukicevic <vladimir@mozilla.com>
  */
 
 #ifndef CAIRO_QUARTZ_IMAGE_H
 #define CAIRO_QUARTZ_IMAGE_H
 
--- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
+++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
@@ -23,17 +23,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  *
  * Contributor(s):
  *	Vladimir Vukicevic <vladimir@mozilla.com>
  */
 
 #define _GNU_SOURCE /* required for RTLD_DEFAULT */
 #include "cairoint.h"
 
--- a/gfx/cairo/cairo/src/cairo-quartz.h
+++ b/gfx/cairo/cairo/src/cairo-quartz.h
@@ -22,17 +22,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  *
  * Contributor(s):
  *      Vladimir Vukicevic <vladimir@mozilla.com>
  */
 
 #ifndef CAIRO_QUARTZ_H
 #define CAIRO_QUARTZ_H
 
--- a/gfx/cairo/cairo/src/cairo-region-private.h
+++ b/gfx/cairo/cairo/src/cairo-region-private.h
@@ -23,17 +23,17 @@
  * http://www.mozilla.org/MPL/
  *
  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  * the specific language governing rights and limitations.
  *
  * The Original Code is the cairo graphics library.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  *
  * Contributor(s):
  *	Vladimir Vukicevic <vladimir@pobox.com>
  */
 
 #ifndef CAIRO_REGION_PRIVATE_H
 #define CAIRO_REGION_PRIVATE_H
 
--- a/gfx/src/thebes/nsSystemFontsMac.h
+++ b/gfx/src/thebes/nsSystemFontsMac.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/src/thebes/nsSystemFontsMac.mm
+++ b/gfx/src/thebes/nsSystemFontsMac.mm
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006-2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *   Jonathan Kew <jfkthame@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/gfx/thebes/public/gfxAlphaRecovery.h
+++ b/gfx/thebes/public/gfxAlphaRecovery.h
@@ -9,17 +9,17 @@
  *
  * 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 Thebes gfx.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/public/gfxAtsuiFonts.h
+++ b/gfx/thebes/public/gfxAtsuiFonts.h
@@ -9,17 +9,17 @@
  *
  * 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 thebes gfx code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006-2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *   Masayuki Nakano <masayuki@d-toybox.com>
  *   John Daggett <jdaggett@mozilla.com>
  *   Jonathan Kew <jfkthame@gmail.com>
--- a/gfx/thebes/public/gfxBlur.h
+++ b/gfx/thebes/public/gfxBlur.h
@@ -9,17 +9,17 @@
  *
  * 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 gfx thebes code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Eric Butler <zantifon@gmail.com>
  *
  * 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
--- a/gfx/thebes/public/gfxCoreTextFonts.h
+++ b/gfx/thebes/public/gfxCoreTextFonts.h
@@ -9,17 +9,17 @@
  *
  * 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 thebes gfx code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006-2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *   Masayuki Nakano <masayuki@d-toybox.com>
  *   John Daggett <jdaggett@mozilla.com>
  *   Jonathan Kew <jfkthame@gmail.com>
--- a/gfx/thebes/public/gfxDirectFBSurface.h
+++ b/gfx/thebes/public/gfxDirectFBSurface.h
@@ -9,17 +9,17 @@
  *
  * 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 DirectFB Thebes code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/public/gfxFontTest.h
+++ b/gfx/thebes/public/gfxFontTest.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/public/gfxQPainterSurface.h
+++ b/gfx/thebes/public/gfxQPainterSurface.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/public/gfxQuartzImageSurface.h
+++ b/gfx/thebes/public/gfxQuartzImageSurface.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/public/gfxQuartzNativeDrawing.h
+++ b/gfx/thebes/public/gfxQuartzNativeDrawing.h
@@ -9,17 +9,17 @@
  *
  * 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 Thebes gfx.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Matthew Gregan <kinetik@flim.org>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/gfx/thebes/public/gfxQuartzPDFSurface.h
+++ b/gfx/thebes/public/gfxQuartzPDFSurface.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Stuart Parmenter <stuart@mozilla.com>
  *
  * 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
--- a/gfx/thebes/public/gfxQuartzSurface.h
+++ b/gfx/thebes/public/gfxQuartzSurface.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Stuart Parmenter <pavlov@pavlov.net>
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/gfx/thebes/public/gfxUtils.h
+++ b/gfx/thebes/public/gfxUtils.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Robert O'Callahan <robert@ocallahan.org>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/gfx/thebes/public/gfxWindowsNativeDrawing.h
+++ b/gfx/thebes/public/gfxWindowsNativeDrawing.h
@@ -9,17 +9,17 @@
  *
  * 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 Thebes gfx.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/src/gfxAlphaRecovery.cpp
+++ b/gfx/thebes/src/gfxAlphaRecovery.cpp
@@ -10,17 +10,17 @@
  *
  * 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 Thebes gfx.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/src/gfxAtsuiFonts.cpp
+++ b/gfx/thebes/src/gfxAtsuiFonts.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006-2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *   Masayuki Nakano <masayuki@d-toybox.com>
  *   John Daggett <jdaggett@mozilla.com>
  *   Jonathan Kew <jfkthame@gmail.com>
--- a/gfx/thebes/src/gfxBlur.cpp
+++ b/gfx/thebes/src/gfxBlur.cpp
@@ -9,17 +9,17 @@
  *
  * 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 gfx thebes code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Eric Butler <zantifon@gmail.com>
  *
  * 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
--- a/gfx/thebes/src/gfxCoreTextFonts.cpp
+++ b/gfx/thebes/src/gfxCoreTextFonts.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006-2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *   Masayuki Nakano <masayuki@d-toybox.com>
  *   John Daggett <jdaggett@mozilla.com>
  *   Jonathan Kew <jfkthame@gmail.com>
--- a/gfx/thebes/src/gfxDirectFBSurface.cpp
+++ b/gfx/thebes/src/gfxDirectFBSurface.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/src/gfxFontMissingGlyphs.cpp
+++ b/gfx/thebes/src/gfxFontMissingGlyphs.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Robert O'Callahan <robert@ocallahan.org>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/gfx/thebes/src/gfxFontMissingGlyphs.h
+++ b/gfx/thebes/src/gfxFontMissingGlyphs.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Robert O'Callahan <robert@ocallahan.org>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/gfx/thebes/src/gfxFontUtils.cpp
+++ b/gfx/thebes/src/gfxFontUtils.cpp
@@ -9,17 +9,17 @@
  *
  * 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 thebes gfx code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007-2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Stuart Parmenter <stuart@mozilla.com>
  *   John Daggett <jdaggett@mozilla.com>
  *   Jonathan Kew <jfkthame@gmail.com>
  *
@@ -312,23 +312,23 @@ gfxFontUtils::ReadCMAPTableFormat4(PRUin
     const PRUint16 *startCounts = endCounts + 1 /* skip one uint16 for reservedPad */ + segCount;
     const PRUint16 *idDeltas = startCounts + segCount;
     const PRUint16 *idRangeOffsets = idDeltas + segCount;
     PRUint16 prevEndCount = 0;
     for (PRUint16 i = 0; i < segCount; i++) {
         const PRUint16 endCount = ReadShortAt16(endCounts, i);
         const PRUint16 startCount = ReadShortAt16(startCounts, i);
         const PRUint16 idRangeOffset = ReadShortAt16(idRangeOffsets, i);
-        
+
         // sanity-check range
-        NS_ENSURE_TRUE((startCount > prevEndCount || i == 0) && 
+        NS_ENSURE_TRUE((startCount > prevEndCount || i == 0 || startCount == 0xFFFF) &&
                        startCount <= endCount,
                        NS_ERROR_GFX_CMAP_MALFORMED);
         prevEndCount = endCount;
-        
+
         if (idRangeOffset == 0) {
             aCharacterMap.SetRange(startCount, endCount);
         } else {
             // const PRUint16 idDelta = ReadShortAt16(idDeltas, i); // Unused: self-documenting.
             for (PRUint32 c = startCount; c <= endCount; ++c) {
                 if (c == 0xFFFF)
                     break;
 
--- a/gfx/thebes/src/gfxMacPlatformFontList.h
+++ b/gfx/thebes/src/gfxMacPlatformFontList.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006-2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *   Masayuki Nakano <masayuki@d-toybox.com>
  *   John Daggett <jdaggett@mozilla.com>
  *   Jonathan Kew <jfkthame@gmail.com>
--- a/gfx/thebes/src/gfxPattern.cpp
+++ b/gfx/thebes/src/gfxPattern.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Stuart Parmenter <stuart@mozilla.com>
  *
  * 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
--- a/gfx/thebes/src/gfxPlatformFontList.cpp
+++ b/gfx/thebes/src/gfxPlatformFontList.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006-2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Jonathan Kew <jfkthame@gmail.com>
  *
  * 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
--- a/gfx/thebes/src/gfxPlatformFontList.h
+++ b/gfx/thebes/src/gfxPlatformFontList.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008-2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Jonathan Kew <jfkthame@gmail.com>
  *
  * 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
--- a/gfx/thebes/src/gfxPlatformMac.cpp
+++ b/gfx/thebes/src/gfxPlatformMac.cpp
@@ -9,17 +9,17 @@
  *
  * 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 thebes gfx code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *   Masayuki Nakano <masayuki@d-toybox.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/gfx/thebes/src/gfxQPainterSurface.cpp
+++ b/gfx/thebes/src/gfxQPainterSurface.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/src/gfxQuartzImageSurface.cpp
+++ b/gfx/thebes/src/gfxQuartzImageSurface.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/src/gfxQuartzNativeDrawing.cpp
+++ b/gfx/thebes/src/gfxQuartzNativeDrawing.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Thebes gfx.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Matthew Gregan <kinetik@flim.org>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/gfx/thebes/src/gfxQuartzPDFSurface.cpp
+++ b/gfx/thebes/src/gfxQuartzPDFSurface.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Stuart Parmenter <stuart@mozilla.com>
  *
  * 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
--- a/gfx/thebes/src/gfxQuartzSurface.cpp
+++ b/gfx/thebes/src/gfxQuartzSurface.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2005
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/src/gfxUserFontSet.cpp
+++ b/gfx/thebes/src/gfxUserFontSet.cpp
@@ -9,17 +9,17 @@
  *
  * 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 thebes gfx code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008-2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   John Daggett <jdaggett@mozilla.com>
  *   Jonathan Kew <jfkthame@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/gfx/thebes/src/gfxWindowsNativeDrawing.cpp
+++ b/gfx/thebes/src/gfxWindowsNativeDrawing.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Thebes gfx.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/src/woff-private.h
+++ b/gfx/thebes/src/woff-private.h
@@ -9,17 +9,17 @@
  *
  * 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 WOFF font packaging code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Jonathan Kew <jfkthame@gmail.com>
  *
  * 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
--- a/gfx/thebes/src/woff.c
+++ b/gfx/thebes/src/woff.c
@@ -9,17 +9,17 @@
  *
  * 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 WOFF font packaging code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Jonathan Kew <jfkthame@gmail.com>
  *
  * 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
--- a/gfx/thebes/src/woff.h
+++ b/gfx/thebes/src/woff.h
@@ -9,17 +9,17 @@
  *
  * 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 WOFF font packaging code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Jonathan Kew <jfkthame@gmail.com>
  *
  * 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
--- a/gfx/thebes/test/gfxFontSelectionTest.cpp
+++ b/gfx/thebes/test/gfxFontSelectionTest.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/test/gfxFontSelectionTests.h
+++ b/gfx/thebes/test/gfxFontSelectionTests.h
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/test/gfxTextRunPerfTest.cpp
+++ b/gfx/thebes/test/gfxTextRunPerfTest.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/test/gfxWordCacheTest.cpp
+++ b/gfx/thebes/test/gfxWordCacheTest.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Corporation code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *
  * 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
--- a/gfx/thebes/test/process-textruns.pl
+++ b/gfx/thebes/test/process-textruns.pl
@@ -10,17 +10,17 @@
 #
 # 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 Corportation code.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2007
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Robert O'Callahan <robert@ocallahan.org>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/intl/locale/src/unix/nsPosixLocale.cpp
+++ b/intl/locale/src/unix/nsPosixLocale.cpp
@@ -111,16 +111,22 @@ nsPosixLocale::GetXPLocale(const char* p
     }
     if (!ParseLocaleString(posixLocale,lang_code,country_code,extra,'_')) {
 //      * locale = "x-user-defined";
       // use posix if parse failed
       CopyASCIItoUTF16(nsDependentCString(posixLocale), locale);
       return NS_OK;
     }
 
+    // Special case: substitute "nb" (Norwegian Bokmal) for macrolanguage
+    // code "no" (Norwegian)
+    if (nsDependentCString(lang_code).LowerCaseEqualsLiteral("no")) {
+      lang_code[1] = 'b';
+    }
+
     if (*country_code) {
       PR_snprintf(posix_locale,sizeof(posix_locale),"%s-%s",lang_code,country_code);
     } 
     else {
       PR_snprintf(posix_locale,sizeof(posix_locale),"%s",lang_code);
     }
 
     CopyASCIItoUTF16(nsDependentCString(posix_locale), locale);
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -254,17 +254,23 @@ nsPresContext::nsPresContext(nsIDocument
 nsPresContext::~nsPresContext()
 {
   for (PRUint32 i = 0; i < IMAGE_LOAD_TYPE_COUNT; ++i)
     mImageLoaders[i].Enumerate(destroy_loads, nsnull);
 
   NS_PRECONDITION(!mShell, "Presshell forgot to clear our mShell pointer");
   SetShell(nsnull);
 
-  delete mTransitionManager;
+  if (mRefreshDriver) {
+    mRefreshDriver->Disconnect();
+  }
+
+  if (mTransitionManager) {
+    mTransitionManager->Disconnect();
+  }
 
   if (mEventManager) {
     // unclear if these are needed, but can't hurt
     mEventManager->NotifyDestroyPresContext(this);
     mEventManager->SetPresContext(nsnull);
 
     NS_RELEASE(mEventManager);
   }
@@ -868,16 +874,22 @@ nsPresContext::Init(nsIDeviceContext* aD
 
   mEventManager = new nsEventStateManager();
   if (!mEventManager)
     return NS_ERROR_OUT_OF_MEMORY;
 
   NS_ADDREF(mEventManager);
 
   mTransitionManager = new nsTransitionManager(this);
+  if (!mTransitionManager)
+    return NS_ERROR_OUT_OF_MEMORY;
+
+  mRefreshDriver = new nsRefreshDriver(this);
+  if (!mRefreshDriver)
+    return NS_ERROR_OUT_OF_MEMORY;
 
   mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
 
   // Register callbacks so we're notified when the preferences change
   nsContentUtils::RegisterPrefCallback("font.",
                                        nsPresContext::PrefChangedCallback,
                                        this);
   nsContentUtils::RegisterPrefCallback("browser.display.",
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -67,17 +67,16 @@
 #include "gfxRect.h"
 #include "nsRegion.h"
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
 #include "nsThreadUtils.h"
 #include "nsContentUtils.h"
 #include "nsIWidget.h"
 #include "mozilla/TimeStamp.h"
-#include "nsRefreshDriver.h"
 
 class nsImageLoader;
 #ifdef IBMBIDI
 class nsBidiPresUtils;
 #endif // IBMBIDI
 
 struct nsRect;
 
@@ -98,16 +97,17 @@ class nsIAtom;
 struct nsStyleBackground;
 struct nsStyleBorder;
 class nsIRunnable;
 class gfxUserFontSet;
 class nsUserFontSet;
 struct nsFontFaceRuleContainer;
 class nsObjectFrame;
 class nsTransitionManager;
+class nsRefreshDriver;
 class imgIContainer;
 
 #ifdef MOZ_REFLOW_PERF
 class nsIRenderingContext;
 #endif
 
 enum nsWidgetType {
   eWidgetType_Button  	= 1,
@@ -228,23 +228,17 @@ public:
 #ifdef _IMPL_NS_LAYOUT
   nsStyleSet* StyleSet() { return GetPresShell()->StyleSet(); }
 
   nsFrameManager* FrameManager()
     { return GetPresShell()->FrameManager(); } 
 
   nsTransitionManager* TransitionManager() { return mTransitionManager; }
 
-  nsRefreshDriver* RefreshDriver() { return &mRefreshDriver; }
-
-  static nsPresContext* FromRefreshDriver(nsRefreshDriver* aRefreshDriver) {
-    return reinterpret_cast<nsPresContext*>(
-             reinterpret_cast<char*>(aRefreshDriver) -
-             offsetof(nsPresContext, mRefreshDriver));
-  }
+  nsRefreshDriver* RefreshDriver() { return mRefreshDriver; }
 #endif
 
   /**
    * Rebuilds all style data by throwing out the old rule tree and
    * building a new one, and additionally applying aExtraHint (which
    * must not contain nsChangeHint_ReconstructFrame) to the root frame.
    * Also rebuild the user font set.
    */
@@ -952,18 +946,18 @@ protected:
   nsCOMPtr<nsIDocument> mDocument;
   nsIDeviceContext*     mDeviceContext; // [STRONG] could be weak, but
                                         // better safe than sorry.
                                         // Cannot reintroduce cycles
                                         // since there is no dependency
                                         // from gfx back to layout.
   nsIEventStateManager* mEventManager;  // [STRONG]
   nsILookAndFeel*       mLookAndFeel;   // [STRONG]
-  nsRefreshDriver       mRefreshDriver;
-  nsTransitionManager*  mTransitionManager; // owns; it aggregates our refcount
+  nsRefPtr<nsRefreshDriver> mRefreshDriver;
+  nsRefPtr<nsTransitionManager> mTransitionManager;
   nsIAtom*              mMedium;        // initialized by subclass ctors;
                                         // weak pointer to static atom
 
   nsILinkHandler*       mLinkHandler;   // [WEAK]
   nsIAtom*              mLangGroup;     // [STRONG]
 
   nsRefPtrHashtable<nsVoidPtrHashKey, nsImageLoader>
                         mImageLoaders[IMAGE_LOAD_TYPE_COUNT];
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -39,29 +39,31 @@
  * Code to notify things that animate before a refresh, at an appropriate
  * refresh rate.  (Perhaps temporary, until replaced by compositor.)
  */
 
 #include "nsRefreshDriver.h"
 #include "nsPresContext.h"
 #include "nsComponentManagerUtils.h"
 #include "prlog.h"
+#include "nsAutoPtr.h"
 
 /*
  * TODO:
  * Once this is hooked in to suppressing updates when the presentation
  * is not visible, we need to hook it up to FlushPendingNotifications so
  * that we flush when necessary.
  */
 
 #define REFRESH_INTERVAL_MILLISECONDS 20
 
 using mozilla::TimeStamp;
 
-nsRefreshDriver::nsRefreshDriver()
+nsRefreshDriver::nsRefreshDriver(nsPresContext *aPresContext)
+  : mPresContext(aPresContext)
 {
 }
 
 nsRefreshDriver::~nsRefreshDriver()
 {
   NS_ABORT_IF_FALSE(ObserverCount() == 0,
                     "observers should have unregistered");
   NS_ABORT_IF_FALSE(!mTimer, "timer should be gone");
@@ -165,43 +167,55 @@ nsRefreshDriver::ArrayFor(mozFlushType a
       return *static_cast<ObserverArray*>(nsnull);
   }
 }
 
 /*
  * nsISupports implementation
  */
 
-NS_IMPL_ADDREF_USING_AGGREGATOR(nsRefreshDriver,
-                                nsPresContext::FromRefreshDriver(this))
-NS_IMPL_RELEASE_USING_AGGREGATOR(nsRefreshDriver,
-                                 nsPresContext::FromRefreshDriver(this))
-NS_IMPL_QUERY_INTERFACE1(nsRefreshDriver, nsITimerCallback)
+NS_IMPL_ISUPPORTS1(nsRefreshDriver, nsITimerCallback)
 
 /*
  * nsITimerCallback implementation
  */
 
 NS_IMETHODIMP
 nsRefreshDriver::Notify(nsITimer *aTimer)
 {
   UpdateMostRecentRefresh();
 
-  nsPresContext *presContext = nsPresContext::FromRefreshDriver(this);
-  nsCOMPtr<nsIPresShell> presShell = presContext->GetPresShell();
+  if (!mPresContext) {
+    // Things are being destroyed.
+    NS_ABORT_IF_FALSE(!mTimer, "timer should have been stopped");
+    return NS_OK;
+  }
+  nsCOMPtr<nsIPresShell> presShell = mPresContext->GetPresShell();
   if (!presShell) {
     // Things are being destroyed.
     StopTimer();
     return NS_OK;
   }
 
+  /*
+   * The timer holds a reference to |this| while calling |Notify|.
+   * However, implementations of |WillRefresh| are permitted to destroy
+   * the pres context, which will cause our |mPresContext| to become
+   * null.  If this happens, we must stop notifying observers.
+   */
   for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(mObservers); ++i) {
     ObserverArray::EndLimitedIterator etor(mObservers[i]);
     while (etor.HasMore()) {
-      etor.GetNext()->WillRefresh(mMostRecentRefresh);
+      nsRefPtr<nsARefreshObserver> obs = etor.GetNext();
+      obs->WillRefresh(mMostRecentRefresh);
+      
+      if (!mPresContext || !mPresContext->GetPresShell()) {
+        StopTimer();
+        return NS_OK;
+      }
     }
     if (i == 0) {
       // This is the Flush_Style case.
       // FIXME: Maybe we should only flush if the WillRefresh calls did
       // something?  It's probably ok as-is, though, especially as we
       // hook up more things here (or to the replacement of this class).
       // FIXME: We should probably flush for other sets of observers
       // too.  But we should only flush layout once nsRefreshDriver is
--- a/layout/base/nsRefreshDriver.h
+++ b/layout/base/nsRefreshDriver.h
@@ -44,36 +44,48 @@
 #define nsRefreshDriver_h_
 
 #include "mozilla/TimeStamp.h"
 #include "mozFlushType.h"
 #include "nsITimer.h"
 #include "nsCOMPtr.h"
 #include "nsTObserverArray.h"
 
+class nsPresContext;
+
 /**
  * An abstract base class to be implemented by callers wanting to be
  * notified at refresh times.  When nothing needs to be painted, callers
  * may not be notified.
  */
 class nsARefreshObserver {
 public:
+  // AddRef and Release signatures that match nsISupports.  Implementors
+  // must implement reference counting, and those that do implement
+  // nsISupports will already have methods with the correct signature.
+  //
+  // The refresh driver does NOT hold references to refresh observers
+  // except while it is notifying them.  
+  NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
+  NS_IMETHOD_(nsrefcnt) Release(void) = 0;
+
   virtual void WillRefresh(mozilla::TimeStamp aTime) = 0;
 };
 
-/*
- * nsRefreshDriver MUST ONLY be constructed as a sub-object of
- * nsPresContext (since its reference counting methods forward to the
- * pres context of which it is an mRefreshDriver)
- */
-class nsRefreshDriver : private nsITimerCallback {
+class nsRefreshDriver : public nsITimerCallback {
 public:
-  nsRefreshDriver();
+  nsRefreshDriver(nsPresContext *aPresContext);
   ~nsRefreshDriver();
 
+  // nsISupports implementation
+  NS_DECL_ISUPPORTS
+
+  // nsITimerCallback implementation
+  NS_DECL_NSITIMERCALLBACK
+
   /**
    * Return the time of the most recent refresh.  This is intended to be
    * used by callers who want to start an animation now and want to know
    * what time to consider the start of the animation.  (This helps
    * ensure that multiple animations started during the same event off
    * the main event loop have the same start time.)
    */
   mozilla::TimeStamp MostRecentRefresh() const;
@@ -85,36 +97,47 @@ public:
    * The flush type affects:
    *   + the order in which the observers are notified (lowest flush
    *     type to highest, in order registered)
    *   + (in the future) which observers are suppressed when the display
    *     doesn't require current position data or isn't currently
    *     painting, and, correspondingly, which get notified when there
    *     is a flush during such suppression
    * and it must be either Flush_Style, Flush_Layout, or Flush_Display.
+   *
+   * The refresh driver does NOT own a reference to these observers;
+   * they must remove themselves before they are destroyed.
    */
   PRBool AddRefreshObserver(nsARefreshObserver *aObserver,
                             mozFlushType aFlushType);
   PRBool RemoveRefreshObserver(nsARefreshObserver *aObserver,
                                mozFlushType aFlushType);
-private:
-  // nsISupports implementation
-  NS_DECL_ISUPPORTS_INHERITED
 
-  // nsITimerCallback implementation
-  NS_IMETHOD Notify(nsITimer *aTimer);
+  /**
+   * Tell the refresh driver that it is done driving refreshes and
+   * should stop its timer and forget about its pres context.  This may
+   * be called from within a refresh.
+   */
+  void Disconnect() {
+    StopTimer();
+    mPresContext = nsnull;
+  }
 
+private:
   typedef nsTObserverArray<nsARefreshObserver*> ObserverArray;
 
   void EnsureTimerStarted();
   void StopTimer();
   PRUint32 ObserverCount() const;
   void UpdateMostRecentRefresh();
   ObserverArray& ArrayFor(mozFlushType aFlushType);
 
   nsCOMPtr<nsITimer> mTimer;
   mozilla::TimeStamp mMostRecentRefresh; // only valid when mTimer non-null
 
+  nsPresContext *mPresContext; // weak; pres context passed in constructor
+                               // and unset in Disconnect
+
   // separate arrays for each flush type we support
   ObserverArray mObservers[3];
 };
 
 #endif /* !defined(nsRefreshDriver_h_) */
--- a/layout/generic/nsTextFrameTextRunCache.h
+++ b/layout/generic/nsTextFrameTextRunCache.h
@@ -9,17 +9,17 @@
  *
  * 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 code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   robert@ocallahan.org
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
new file mode 100644
--- /dev/null
+++ b/layout/reftests/font-face/534352-1-extra-cmap-sentinel-ref.html
@@ -0,0 +1,12 @@
+<html>
+<head>
+<style type="text/css">
+body {
+  font-family: serif;
+}
+</style>
+</head>
+<body>
+This should NOT be in the default serif font.
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/font-face/534352-1-extra-cmap-sentinel.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+<!-- font Prototype.ttf (see bug 496573 comment #25 and bug 534352)
+     has a redundant [0xFFFF,0xFFFF] sentinel value in the cmap -->
+<style type="text/css">
+@font-face {
+  font-family: test;
+  src: url(../fonts/Prototype.ttf);
+}
+
+body {
+  font-family: test, serif;
+}
+</style>
+</head>
+<body>
+This should NOT be in the default serif font.
+</body>
+</html>
--- a/layout/reftests/font-face/reftest.list
+++ b/layout/reftests/font-face/reftest.list
@@ -113,8 +113,11 @@ HTTP(..) != 507960-1-bad-sfnt-version-wo
 HTTP(..) != 507960-1-bad-woff-sig.html 507960-1-ref.html
 HTTP(..) != 507960-1-bad-offset-woff.html 507960-1-ref.html
 HTTP(..) != 507960-1-woff-bad-hint.html 507960-1-ref.html
 
 # Bug 523717
 HTTP(..) == underline-offset-change-1.html underline-offset-change-1-ref.html
 HTTP(..) == underline-offset-change-2.html underline-offset-change-2-ref.html
 fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") fails-if(MOZ_WIDGET_TOOLKIT=="windows") HTTP(..) != underline-offset-change-1-ref.html underline-offset-change-2-ref.html # Bug 534132
+
+# Bug 534352
+HTTP(..) != 534352-1-extra-cmap-sentinel.html 534352-1-extra-cmap-sentinel-ref.html
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c70bf00f47201e79fdf14cb5483302fe6ff8ffaf
GIT binary patch
literal 29592
zc$~Gp2Vfk<**88j+wSIiZ_@RqUQTzXW=WPMxy!v^<KDpy+ki~~gDIxj^aKc<&@m8N
zupyz>(0lI?LJJ`Q@<M#~Ju|y^l8qtxzW4u^?tVKvJ3Hl>nWxR{9>NGA6FLqFX!4|K
z4b4;Ee)9u}c?-USGy5jaUT;0}EQD|^LehIn)+}0YX*qofLW&U~;er*5Hm*ks{3H51
zNN-%RddqV8)Him*`K<^YL{~0bwDkGPEu#@yaxYxZt%L|=t0=(vKjA#Sa?PgAf8Fby
zhtN_l<oD8{%Qmd793RXhwBidWuVVGOC5zTPe&X8*t<gapzF4zp^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-Df<U(%bL0;s8Q5ZlKppOPYj|_t*6a#%Hfs*|9nyOGW=pwbCLDYlJ!0OZt
zQoRM_Zw@47D{6yQb)ZiE+e9Fvpsjr%6$XGJW6)UO_v2yYPXw+#3EDCR=r#>ahw(oX
zIP7fTpmWe%m;v+nuL&&#3N1!UpjVdhUkF--4nc<kh1stIv2k%2@99lI^&_CyHUmA5
z;=c=Y3_6zoqS5ha8#)1<h)zN$qwVMvm^G)N)6p4d2il3wLT96M(XY{O_-`Uzj;=sg
zq2Hlv&<*HDbQ9Xef5GVY+AkR0$$zitZnOv8gZ_yA1eWT9=ppnldIUX&9!F1TzdrOd
zXvyps&|XHbfc^P8*cR`gGhud~ht7vtdLg<9{T5w}u143Q-RNG>^xr~nqj%AJV0XO8
ze;?@<7(Z8{>p{cr1}pYa82cZAz4IyhD`@hcqc6~x=qtp2N$LaiA!Zi%C+IKeGISk!
h0gGVsvR`PzQvKS)SFa{xrt4O$-m-pWQ)3pP{{t}GU<v>L
--- a/layout/reftests/svg/reftest.list
+++ b/layout/reftests/svg/reftest.list
@@ -98,16 +98,17 @@ fails == inline-in-xul-basic-01.xul pass
 == objectBoundingBox-and-mask.svg pass.svg
 == objectBoundingBox-and-pattern-01a.svg objectBoundingBox-and-pattern-01-ref.svg
 == objectBoundingBox-and-pattern-01b.svg objectBoundingBox-and-pattern-01-ref.svg
 == objectBoundingBox-and-pattern-01c.svg objectBoundingBox-and-pattern-01-ref.svg
 # skip the next test on cocoa, since behaviour depends on the -minor- version of the 10.4 OS.
 # See bugs 379610 and 432298.
 random-if(MOZ_WIDGET_TOOLKIT=="cocoa") == opacity-and-gradient-01.svg pass.svg
 == opacity-and-pattern-01.svg pass.svg
+== path-01.svg path-01-ref.svg
 == pattern-live-01a.svg pattern-live-01-ref.svg
 == pattern-live-01b.svg pattern-live-01-ref.svg
 == pattern-live-01c.svg pattern-live-01-ref.svg
 == pseudo-classes-01.svg pass.svg
 == pseudo-classes-02.svg pseudo-classes-02-ref.svg
 == radialGradient-basic-01.svg pass.svg
 == radialGradient-basic-02.svg pass.svg
 == radialGradient-basic-03.svg radialGradient-basic-03-ref.svg
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -516,17 +516,17 @@ CSS_PROP_BACKGROUND(
     BackgroundPosition,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
         CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
     Color,
     mBackPosition,
     eCSSType_ValuePairList,
     kBackgroundPositionKTable,
     CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    eStyleAnimType_Custom)
 CSS_PROP_BACKGROUND(
     background-repeat,
     background_repeat,
     BackgroundRepeat,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
         CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
     Color,
     mBackRepeat,
@@ -540,17 +540,17 @@ CSS_PROP_BACKGROUND(
     MozBackgroundSize,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
         CSS_PROPERTY_VALUE_LIST_USES_COMMAS,
     Color,
     mBackSize,
     eCSSType_ValuePairList,
     kBackgroundSizeKTable,
     CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    eStyleAnimType_Custom)
 CSS_PROP_DISPLAY(
     -moz-binding,
     binding,
     MozBinding,
     0,
     Display,
     mBinding,
     eCSSType_Value,
@@ -1185,18 +1185,18 @@ CSS_PROP_DISPLAY(
     clip,
     clip,
     Clip,
     0,
     Display,
     mClip,
     eCSSType_Rect,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleDisplay, mClip),
+    eStyleAnimType_Custom)
 CSS_PROP_COLOR(
     color,
     color,
     Color,
     CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE |
         CSS_PROPERTY_IGNORED_WHEN_COLORS_DISABLED,
     Color,
     mColor,
@@ -1518,18 +1518,18 @@ CSS_PROP_LIST(
     -moz-image-region,
     image_region,
     MozImageRegion,
     0,
     List,
     mImageRegion,
     eCSSType_Rect,
     nsnull,
-    CSS_PROP_NO_OFFSET,
-    eStyleAnimType_None)
+    offsetof(nsStyleList, mImageRegion),
+    eStyleAnimType_Custom)
 CSS_PROP_UIRESET(
     ime-mode,
     ime_mode,
     ImeMode,
     0,
     UserInterface,
     mIMEMode,
     eCSSType_Value,
--- a/layout/style/nsCSSStyleRule.cpp
+++ b/layout/style/nsCSSStyleRule.cpp
@@ -874,17 +874,17 @@ CSSImportantRule::MapRuleInfoInto(nsRule
 
 #ifdef DEBUG
 NS_IMETHODIMP
 CSSImportantRule::List(FILE* out, PRInt32 aIndent) const
 {
   // Indent
   for (PRInt32 index = aIndent; --index >= 0; ) fputs("  ", out);
 
-  fprintf(out, "! Important rule block=%p\n", mImportantBlock);
+  fprintf(out, "! Important rule block=%p\n", mImportantBlock.get());
   return NS_OK;
 }
 #endif
 
 // --------------------------------------------------------
 
 class DOMCSSStyleRuleImpl;
 
--- a/layout/style/nsICSSRuleList.h
+++ b/layout/style/nsICSSRuleList.h
@@ -9,17 +9,17 @@
  *
  * 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 layout code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *         Peter Van der Beken <peterv@propagandism.org> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/layout/style/nsStyleAnimation.cpp
+++ b/layout/style/nsStyleAnimation.cpp
@@ -140,16 +140,24 @@ nsStyleAnimation::ComputeDistance(nsCSSP
           aDistance = PR_ABS(endInt - startInt);
           break;
         }
         default:
           success = PR_FALSE;
           break;
       }
       break;
+   case eUnit_Visibility: {
+      PRInt32 startVal =
+        aStartValue.GetIntValue() == NS_STYLE_VISIBILITY_VISIBLE;
+      PRInt32 endVal =
+        aEndValue.GetIntValue() == NS_STYLE_VISIBILITY_VISIBLE;
+      aDistance = PR_ABS(startVal - endVal);
+      break;
+    }
     case eUnit_Integer: {
       PRInt32 startInt = aStartValue.GetIntValue();
       PRInt32 endInt = aEndValue.GetIntValue();
       aDistance = PR_ABS(endInt - startInt);
       break;
     }
     case eUnit_Coord: {
       nscoord startCoord = aStartValue.GetCoordValue();
@@ -239,16 +247,52 @@ nsStyleAnimation::ComputeDistance(nsCSSP
             return PR_FALSE;
         }
         squareDistance += diff * diff;
       }
 
       aDistance = sqrt(squareDistance);
       break;
     }
+    case eUnit_CSSRect: {
+      const nsCSSRect *rect1 = aStartValue.GetCSSRectValue();
+      const nsCSSRect *rect2 = aEndValue.GetCSSRectValue();
+      if (rect1->mTop.GetUnit() != rect2->mTop.GetUnit() ||
+          rect1->mRight.GetUnit() != rect2->mRight.GetUnit() ||
+          rect1->mBottom.GetUnit() != rect2->mBottom.GetUnit() ||
+          rect1->mLeft.GetUnit() != rect2->mLeft.GetUnit()) {
+        // At least until we have calc()
+        return PR_FALSE;
+      }
+
+      double squareDistance = 0.0;
+      for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(nsCSSRect::sides); ++i) {
+        nsCSSValue nsCSSRect::*member = nsCSSRect::sides[i];
+        NS_ABORT_IF_FALSE((rect1->*member).GetUnit() ==
+                            (rect2->*member).GetUnit(),
+                          "should have returned above");
+        double diff;
+        switch ((rect1->*member).GetUnit()) {
+          case eCSSUnit_Pixel:
+            diff = (rect1->*member).GetFloatValue() -
+                   (rect2->*member).GetFloatValue();
+            break;
+          case eCSSUnit_Auto:
+            diff = 0;
+            break;
+          default:
+            NS_ABORT_IF_FALSE(PR_FALSE, "unexpected unit");
+            return PR_FALSE;
+        }
+        squareDistance += diff * diff;
+      }
+
+      aDistance = sqrt(squareDistance);
+      break;
+    }
     case eUnit_Dasharray: {
       // NOTE: This produces results on substantially different scales
       // for length values and percentage values, which might even be
       // mixed in the same property value.  This means the result isn't
       // particularly useful for paced animation.
 
       // Call AddWeighted to make us lists of the same length.
       Value normValue1, normValue2;
@@ -353,24 +397,79 @@ nsStyleAnimation::ComputeDistance(nsCSSP
 
         shadow1 = shadow1->mNext;
         shadow2 = shadow2->mNext;
         NS_ABORT_IF_FALSE(!shadow1 == !shadow2, "lists should be same length");
       }
       aDistance = sqrt(squareDistance);
       break;
     }
+    case eUnit_CSSValuePairList: {
+      const nsCSSValuePairList *list1 = aStartValue.GetCSSValuePairListValue();
+      const nsCSSValuePairList *list2 = aEndValue.GetCSSValuePairListValue();
+      double squareDistance = 0.0f;
+      do {
+        static nsCSSValue nsCSSValuePairList::* const pairListValues[] = {
+          &nsCSSValuePairList::mXValue,
+          &nsCSSValuePairList::mYValue,
+        };
+        for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(pairListValues); ++i) {
+          const nsCSSValue &v1 = list1->*(pairListValues[i]);
+          const nsCSSValue &v2 = list2->*(pairListValues[i]);
+          if (v1.GetUnit() != v2.GetUnit()) {
+            success = PR_FALSE;
+            break; // to failure case
+          }
+          double diff = 0.0;
+          switch (v1.GetUnit()) {
+            case eCSSUnit_Pixel:
+              diff = v1.GetFloatValue() - v2.GetFloatValue();
+              break;
+            case eCSSUnit_Percent:
+              diff = v1.GetPercentValue() - v2.GetPercentValue();
+              break;
+            default:
+              if (v1 != v2) {
+                success = PR_FALSE;
+              }
+              break;
+          }
+          squareDistance += diff * diff;
+        }
+        if (!success) {
+          break; // to failure case
+        }
+
+        list1 = list1->mNext;
+        list2 = list2->mNext;
+      } while (list1 && list2);
+      if (list1 || list2) {
+        // We can't interpolate lists of different lengths.  (Also,
+        // failure cases above break to here.)
+        success = PR_FALSE;
+      } else {
+        aDistance = sqrt(squareDistance);
+      }
+      break;
+    }
     default:
       NS_NOTREACHED("Can't compute distance using the given common unit");
       success = PR_FALSE;
       break;
   }
   return success;
 }
 
+inline void
+nscoordToCSSValue(nscoord aCoord, nsCSSValue& aCSSValue)
+{
+  aCSSValue.SetFloatValue(nsPresContext::AppUnitsToFloatCSSPixels(aCoord),
+                          eCSSUnit_Pixel);
+}
+
 #define MAX_PACKED_COLOR_COMPONENT 255
 
 inline PRUint8 ClampColor(double aColor)
 {
   if (aColor >= MAX_PACKED_COLOR_COMPONENT)
     return MAX_PACKED_COLOR_COMPONENT;
   if (aColor <= 0.0)
     return 0;
@@ -472,16 +571,25 @@ nsStyleAnimation::AddWeighted(nsCSSPrope
           aResultValue.SetIntValue(result, eUnit_Enumerated);
           break;
         }
         default:
           success = PR_FALSE;
           break;
       }
       break;
+    case eUnit_Visibility: {
+      PRInt32 val1 = aValue1.GetIntValue() == NS_STYLE_VISIBILITY_VISIBLE;
+      PRInt32 val2 = aValue2.GetIntValue() == NS_STYLE_VISIBILITY_VISIBLE;
+      double interp = aCoeff1 * val1 + aCoeff2 * val2;
+      PRInt32 result = interp > 0.0 ? NS_STYLE_VISIBILITY_VISIBLE
+                                    : NS_STYLE_VISIBILITY_HIDDEN;
+      aResultValue.SetIntValue(result, eUnit_Visibility);
+      break;
+    }
     case eUnit_Integer: {
       // http://dev.w3.org/csswg/css3-transitions/#animation-of-property-types-
       // says we should use floor
       PRInt32 result = NS_floor(aCoeff1 * double(aValue1.GetIntValue()) +
                                 aCoeff2 * double(aValue2.GetIntValue()));
       if (aProperty == eCSSProperty_font_weight) {
         NS_ASSERTION(result > 0, "unexpected value");
         result -= result % 100;
@@ -581,16 +689,60 @@ nsStyleAnimation::AddWeighted(nsCSSPrope
             return PR_FALSE;
         }
       }
 
       aResultValue.SetAndAdoptCSSValuePairValue(result.forget(),
                                                 eUnit_CSSValuePair);
       break;
     }
+    case eUnit_CSSRect: {
+      const nsCSSRect *rect1 = aValue1.GetCSSRectValue();
+      const nsCSSRect *rect2 = aValue2.GetCSSRectValue();
+      if (rect1->mTop.GetUnit() != rect2->mTop.GetUnit() ||
+          rect1->mRight.GetUnit() != rect2->mRight.GetUnit() ||
+          rect1->mBottom.GetUnit() != rect2->mBottom.GetUnit() ||
+          rect1->mLeft.GetUnit() != rect2->mLeft.GetUnit()) {
+        // At least until we have calc()
+        return PR_FALSE;
+      }
+
+      nsAutoPtr<nsCSSRect> result(new nsCSSRect);
+      if (!result) {
+        return PR_FALSE;
+      }
+      for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(nsCSSRect::sides); ++i) {
+        nsCSSValue nsCSSRect::*member = nsCSSRect::sides[i];
+        NS_ABORT_IF_FALSE((rect1->*member).GetUnit() ==
+                            (rect2->*member).GetUnit(),
+                          "should have returned above");
+        switch ((rect1->*member).GetUnit()) {
+          case eCSSUnit_Pixel:
+            (result->*member).SetFloatValue(
+              aCoeff1 * (rect1->*member).GetFloatValue() +
+              aCoeff2 * (rect2->*member).GetFloatValue(),
+              eCSSUnit_Pixel);
+            break;
+          case eCSSUnit_Auto:
+            if (float(aCoeff1 + aCoeff2) != 1.0f) {
+              // Interpolating between two auto values makes sense;
+              // adding in other ratios does not.
+              return PR_FALSE;
+            }
+            (result->*member).SetAutoValue();
+            break;
+          default:
+            NS_ABORT_IF_FALSE(PR_FALSE, "unexpected unit");
+            return PR_FALSE;
+        }
+      }
+
+      aResultValue.SetAndAdoptCSSRectValue(result.forget(), eUnit_CSSRect);
+      break;
+    }
     case eUnit_Dasharray: {
       const nsCSSValueList *list1 = aValue1.GetCSSValueListValue();
       const nsCSSValueList *list2 = aValue2.GetCSSValueListValue();
 
       PRUint32 len1 = 0, len2 = 0;
       for (const nsCSSValueList *v = list1; v; v = v->mNext) {
         ++len1;
       }
@@ -694,16 +846,76 @@ nsStyleAnimation::AddWeighted(nsCSSPrope
           }
 
           longShadow = longShadow->mNext;
         }
       }
       aResultValue.SetAndAdoptCSSValueListValue(result.forget(), eUnit_Shadow);
       break;
     }
+    case eUnit_CSSValuePairList: {
+      const nsCSSValuePairList *list1 = aValue1.GetCSSValuePairListValue();
+      const nsCSSValuePairList *list2 = aValue2.GetCSSValuePairListValue();
+      nsAutoPtr<nsCSSValuePairList> result;
+      nsCSSValuePairList **resultTail = getter_Transfers(result);
+      do {
+        nsCSSValuePairList *item = new nsCSSValuePairList;
+        if (!item) {
+          break; // to failure case
+        }
+        *resultTail = item;
+        resultTail = &item->mNext;
+
+        static nsCSSValue nsCSSValuePairList::* const pairListValues[] = {
+          &nsCSSValuePairList::mXValue,
+          &nsCSSValuePairList::mYValue,
+        };
+        for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(pairListValues); ++i) {
+          const nsCSSValue &v1 = list1->*(pairListValues[i]);
+          const nsCSSValue &v2 = list2->*(pairListValues[i]);
+          nsCSSValue &vr = item->*(pairListValues[i]);
+          if (v1.GetUnit() != v2.GetUnit()) {
+            success = PR_FALSE;
+            break; // to failure case
+          }
+          switch (v1.GetUnit()) {
+            case eCSSUnit_Pixel:
+              vr.SetFloatValue(aCoeff1 * v1.GetFloatValue() +
+                               aCoeff2 * v2.GetFloatValue(),
+                               eCSSUnit_Pixel);
+              break;
+            case eCSSUnit_Percent:
+              vr.SetPercentValue(aCoeff1 * v1.GetPercentValue() +
+                                 aCoeff2 * v2.GetPercentValue());
+              break;
+            default:
+              if (v1 == v2) {
+                vr = v1;
+              } else {
+                success = PR_FALSE;
+              }
+              break;
+          }
+        }
+        if (!success) {
+          break; // to failure case
+        }
+
+        list1 = list1->mNext;
+        list2 = list2->mNext;
+      } while (list1 && list2);
+      if (list1 || list2) {
+        // We can't interpolate lists of different lengths.  (Also,
+        // failure cases above break to here.)
+        success = PR_FALSE;
+      } else {
+        aResultValue.SetAndAdoptCSSValuePairListValue(result.forget());
+      }
+      break;
+    }
     default:
       NS_NOTREACHED("Can't interpolate using the given common unit");
       success = PR_FALSE;
       break;
   }
   return success;
 }
 
@@ -877,34 +1089,33 @@ nsStyleAnimation::UncomputeValue(nsCSSPr
           SetBothValuesTo(nsCSSValue(eCSSUnit_None));
       } else {
         NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
                           "type mismatch");
         static_cast<nsCSSValue*>(aSpecifiedValue)->SetNoneValue();
       }
       break;
     case eUnit_Enumerated:
+    case eUnit_Visibility:
       NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
                         "type mismatch");
       static_cast<nsCSSValue*>(aSpecifiedValue)->
         SetIntValue(aComputedValue.GetIntValue(), eCSSUnit_Enumerated);
       break;
     case eUnit_Integer:
       NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
                         "type mismatch");
       static_cast<nsCSSValue*>(aSpecifiedValue)->
         SetIntValue(aComputedValue.GetIntValue(), eCSSUnit_Integer);
       break;
     case eUnit_Coord: {
       NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
                         "type mismatch");
-      float pxVal = aPresContext->AppUnitsToFloatCSSPixels(
-                                    aComputedValue.GetCoordValue());
-      static_cast<nsCSSValue*>(aSpecifiedValue)->
-        SetFloatValue(pxVal, eCSSUnit_Pixel);
+      nscoordToCSSValue(aComputedValue.GetCoordValue(),
+                        *static_cast<nsCSSValue*>(aSpecifiedValue));
       break;
     }
     case eUnit_Percent:
       NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] == eCSSType_Value,
                         "type mismatch");
       static_cast<nsCSSValue*>(aSpecifiedValue)->
         SetPercentValue(aComputedValue.GetPercentValue());
       break;
@@ -931,23 +1142,35 @@ nsStyleAnimation::UncomputeValue(nsCSSPr
       }
       break;
     case eUnit_CSSValuePair:
       NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] ==
                           eCSSType_ValuePair, "type mismatch");
       *static_cast<nsCSSValuePair*>(aSpecifiedValue) =
         *aComputedValue.GetCSSValuePairValue();
       break;
+    case eUnit_CSSRect:
+      NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] ==
+                          eCSSType_Rect, "type mismatch");
+      *static_cast<nsCSSRect*>(aSpecifiedValue) =
+        *aComputedValue.GetCSSRectValue();
+      break;
     case eUnit_Dasharray:
     case eUnit_Shadow:
       NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] ==
                           eCSSType_ValueList, "type mismatch");
       *static_cast<nsCSSValueList**>(aSpecifiedValue) =
         aComputedValue.GetCSSValueListValue();
       break;
+    case eUnit_CSSValuePairList:
+      NS_ABORT_IF_FALSE(nsCSSProps::kTypeTable[aProperty] ==
+                          eCSSType_ValuePairList, "type mismatch");
+      *static_cast<nsCSSValuePairList**>(aSpecifiedValue) =
+        aComputedValue.GetCSSValuePairListValue();
+      break;
     default:
       return PR_FALSE;
   }
   return PR_TRUE;
 }
 
 PRBool
 nsStyleAnimation::UncomputeValue(nsCSSProperty aProperty,
@@ -1058,19 +1281,17 @@ StyleCoordToValue(const nsStyleCoord& aC
   return PR_TRUE;
 }
 
 static void
 StyleCoordToCSSValue(const nsStyleCoord& aCoord, nsCSSValue& aCSSValue)
 {
   switch (aCoord.GetUnit()) {
     case eStyleUnit_Coord:
-      aCSSValue.SetFloatValue(nsPresContext::AppUnitsToFloatCSSPixels(
-                                aCoord.GetCoordValue()),
-                              eCSSUnit_Pixel);
+      nscoordToCSSValue(aCoord.GetCoordValue(), aCSSValue);
       break;
     case eStyleUnit_Percent:
       aCSSValue.SetPercentValue(aCoord.GetPercentValue());
       break;
     default:
       NS_ABORT_IF_FALSE(PR_FALSE, "unexpected unit");
   }
 }
@@ -1159,24 +1380,18 @@ nsStyleAnimation::ExtractComputedValue(n
 
         case eCSSProperty_border_spacing: {
           const nsStyleTableBorder *styleTableBorder =
             static_cast<const nsStyleTableBorder*>(styleStruct);
           nsCSSValuePair *pair = new nsCSSValuePair;
           if (!pair) {
             return PR_FALSE;
           }
-          pair->mXValue.SetFloatValue(
-            nsPresContext::AppUnitsToFloatCSSPixels(
-              styleTableBorder->mBorderSpacingX),
-            eCSSUnit_Pixel);
-          pair->mYValue.SetFloatValue(
-            nsPresContext::AppUnitsToFloatCSSPixels(
-              styleTableBorder->mBorderSpacingY),
-            eCSSUnit_Pixel);
+          nscoordToCSSValue(styleTableBorder->mBorderSpacingX, pair->mXValue);
+          nscoordToCSSValue(styleTableBorder->mBorderSpacingY, pair->mYValue);
           aComputedValue.SetAndAdoptCSSValuePairValue(pair,
                                                       eUnit_CSSValuePair);
           break;
         }
 
         case eCSSProperty__moz_transform_origin: {
           const nsStyleDisplay *styleDisplay =
             static_cast<const nsStyleDisplay*>(styleStruct);
@@ -1265,16 +1480,160 @@ nsStyleAnimation::ExtractComputedValue(n
             static_cast<const nsStyleFont*>(styleStruct)->mFont.weight;
           if (weight % 100 != 0) {
             return PR_FALSE;
           }
           aComputedValue.SetIntValue(weight, eUnit_Integer);
           return PR_TRUE;
         }
 
+        case eCSSProperty_image_region: {
+          const nsStyleList *list =
+            static_cast<const nsStyleList*>(styleStruct);
+          const nsRect &srect = list->mImageRegion;
+          if (srect.IsEmpty()) {
+            aComputedValue.SetAutoValue();
+            break;
+          }
+
+          nsCSSRect *vrect = new nsCSSRect;
+          if (!vrect) {
+            return PR_FALSE;
+          }
+          nscoordToCSSValue(srect.x, vrect->mLeft);
+          nscoordToCSSValue(srect.y, vrect->mTop);
+          nscoordToCSSValue(srect.XMost(), vrect->mRight);
+          nscoordToCSSValue(srect.YMost(), vrect->mBottom);
+          aComputedValue.SetAndAdoptCSSRectValue(vrect, eUnit_CSSRect);
+          break;
+        }
+
+        case eCSSProperty_clip: {
+          const nsStyleDisplay *display =
+            static_cast<const nsStyleDisplay*>(styleStruct);
+          if (!(display->mClipFlags & NS_STYLE_CLIP_RECT)) {
+            aComputedValue.SetAutoValue();
+            break;
+          }
+
+          nsCSSRect *vrect = new nsCSSRect;
+          if (!vrect) {
+            return PR_FALSE;
+          }
+          const nsRect &srect = display->mClip;
+          if (display->mClipFlags & NS_STYLE_CLIP_TOP_AUTO) {
+            vrect->mTop.SetAutoValue();
+          } else {
+            nscoordToCSSValue(srect.y, vrect->mTop);
+          }
+          if (display->mClipFlags & NS_STYLE_CLIP_RIGHT_AUTO) {
+            vrect->mRight.SetAutoValue();
+          } else {
+            nscoordToCSSValue(srect.XMost(), vrect->mRight);
+          }
+          if (display->mClipFlags & NS_STYLE_CLIP_BOTTOM_AUTO) {
+            vrect->mBottom.SetAutoValue();
+          } else {
+            nscoordToCSSValue(srect.YMost(), vrect->mBottom);
+          }
+          if (display->mClipFlags & NS_STYLE_CLIP_LEFT_AUTO) {
+            vrect->mLeft.SetAutoValue();
+          } else {
+            nscoordToCSSValue(srect.x, vrect->mLeft);
+          }
+          aComputedValue.SetAndAdoptCSSRectValue(vrect, eUnit_CSSRect);
+          break;
+        }
+
+        case eCSSProperty_background_position: {
+          const nsStyleBackground *bg =
+            static_cast<const nsStyleBackground*>(styleStruct);
+          nsCSSValuePairList *result = nsnull;
+          nsCSSValuePairList **resultTail = &result;
+          NS_ABORT_IF_FALSE(bg->mPositionCount > 0, "unexpected count");
+          for (PRUint32 i = 0, i_end = bg->mPositionCount; i != i_end; ++i) {
+            nsCSSValuePairList *item = new nsCSSValuePairList;
+            if (!item) {
+              delete result;
+              return PR_FALSE;
+            }
+            *resultTail = item;
+            resultTail = &item->mNext;
+            
+            const nsStyleBackground::Position &pos = bg->mLayers[i].mPosition;
+            if (pos.mXIsPercent) {
+              item->mXValue.SetPercentValue(pos.mXPosition.mFloat);
+            } else {
+              nscoordToCSSValue(pos.mXPosition.mCoord, item->mXValue);
+            }
+            if (pos.mYIsPercent) {
+              item->mYValue.SetPercentValue(pos.mYPosition.mFloat);
+            } else {
+              nscoordToCSSValue(pos.mYPosition.mCoord, item->mYValue);
+            }
+          }
+
+          aComputedValue.SetAndAdoptCSSValuePairListValue(result);
+          break;
+        }
+
+        case eCSSProperty__moz_background_size: {
+          const nsStyleBackground *bg =
+            static_cast<const nsStyleBackground*>(styleStruct);
+          nsCSSValuePairList *result = nsnull;
+          nsCSSValuePairList **resultTail = &result;
+          NS_ABORT_IF_FALSE(bg->mSizeCount > 0, "unexpected count");
+          for (PRUint32 i = 0, i_end = bg->mSizeCount; i != i_end; ++i) {
+            nsCSSValuePairList *item = new nsCSSValuePairList;
+            if (!item) {
+              delete result;
+              return PR_FALSE;
+            }
+            *resultTail = item;
+            resultTail = &item->mNext;
+            
+            const nsStyleBackground::Size &size = bg->mLayers[i].mSize;
+            switch (size.mWidthType) {
+              case nsStyleBackground::Size::eContain:
+              case nsStyleBackground::Size::eCover:
+                item->mXValue.SetIntValue(size.mWidthType,
+                                          eCSSUnit_Enumerated);
+                break;
+              case nsStyleBackground::Size::ePercentage:
+                item->mXValue.SetPercentValue(size.mWidth.mFloat);
+                break;
+              case nsStyleBackground::Size::eAuto:
+                item->mXValue.SetAutoValue();
+                break;
+              case nsStyleBackground::Size::eLength:
+                nscoordToCSSValue(size.mWidth.mCoord, item->mXValue);
+                break;
+            }
+
+            switch (size.mHeightType) {
+              case nsStyleBackground::Size::eContain:
+              case nsStyleBackground::Size::eCover:
+                // leave it null
+                break;
+              case nsStyleBackground::Size::ePercentage:
+                item->mYValue.SetPercentValue(size.mHeight.mFloat);
+                break;
+              case nsStyleBackground::Size::eAuto:
+                item->mYValue.SetAutoValue();
+                break;
+              case nsStyleBackground::Size::eLength:
+                nscoordToCSSValue(size.mHeight.mCoord, item->mYValue);
+                break;
+            }
+          }
+
+          aComputedValue.SetAndAdoptCSSValuePairListValue(result);
+          break;
+        }
+
         default:
           NS_ABORT_IF_FALSE(PR_FALSE, "missing property implementation");
           return PR_FALSE;
       };
       return PR_TRUE;
     case eStyleAnimType_Coord:
       return StyleCoordToValue(*static_cast<const nsStyleCoord*>(
         StyleDataAtOffset(styleStruct, ssOffset)), aComputedValue);
@@ -1371,30 +1730,22 @@ nsStyleAnimation::ExtractComputedValue(n
         return PR_TRUE;
       }
       nsAutoPtr<nsCSSValueList> result;
       nsCSSValueList **resultTail = getter_Transfers(result);
       for (PRUint32 i = 0, i_end = shadowArray->Length(); i < i_end; ++i) {
         const nsCSSShadowItem *shadow = shadowArray->ShadowAt(i);
         // X, Y, Radius, Spread, Color, Inset
         nsRefPtr<nsCSSValue::Array> arr = nsCSSValue::Array::Create(6);
-        arr->Item(0).SetFloatValue(
-          nsPresContext::AppUnitsToFloatCSSPixels(shadow->mXOffset),
-          eCSSUnit_Pixel);
-        arr->Item(1).SetFloatValue(
-          nsPresContext::AppUnitsToFloatCSSPixels(shadow->mYOffset),
-          eCSSUnit_Pixel);
-        arr->Item(2).SetFloatValue(
-          nsPresContext::AppUnitsToFloatCSSPixels(shadow->mRadius),
-          eCSSUnit_Pixel);
+        nscoordToCSSValue(shadow->mXOffset, arr->Item(0));
+        nscoordToCSSValue(shadow->mYOffset, arr->Item(1));
+        nscoordToCSSValue(shadow->mRadius, arr->Item(2));
         // NOTE: This code sometimes stores mSpread: 0 even when
         // the parser would be required to leave it null.
-        arr->Item(3).SetFloatValue(
-          nsPresContext::AppUnitsToFloatCSSPixels(shadow->mSpread),
-          eCSSUnit_Pixel);
+        nscoordToCSSValue(shadow->mSpread, arr->Item(3));
         if (shadow->mHasColor) {
           arr->Item(4).SetColorValue(shadow->mColor);
         }
         if (shadow->mInset) {
           arr->Item(5).SetIntValue(NS_STYLE_BOX_SHADOW_INSET,
                                    eCSSUnit_Enumerated);
         }
 
@@ -1456,16 +1807,17 @@ nsStyleAnimation::Value::operator=(const
   mUnit = aOther.mUnit;
   switch (mUnit) {
     case eUnit_Null:
     case eUnit_Normal:
     case eUnit_Auto:
     case eUnit_None:
       break;
     case eUnit_Enumerated:
+    case eUnit_Visibility:
     case eUnit_Integer:
       mValue.mInt = aOther.mValue.mInt;
       break;
     case eUnit_Coord:
       mValue.mCoord = aOther.mValue.mCoord;
       break;
     case eUnit_Percent:
     case eUnit_Float:
@@ -1477,29 +1829,44 @@ nsStyleAnimation::Value::operator=(const
     case eUnit_CSSValuePair:
       NS_ABORT_IF_FALSE(aOther.mValue.mCSSValuePair,
                         "value pairs may not be null");
       mValue.mCSSValuePair = new nsCSSValuePair(*aOther.mValue.mCSSValuePair);
       if (!mValue.mCSSValuePair) {
         mUnit = eUnit_Null;
       }
       break;
+    case eUnit_CSSRect:
+      NS_ABORT_IF_FALSE(aOther.mValue.mCSSRect, "rects may not be null");
+      mValue.mCSSRect = new nsCSSRect(*aOther.mValue.mCSSRect);
+      if (!mValue.mCSSRect) {
+        mUnit = eUnit_Null;
+      }
+      break;
     case eUnit_Dasharray:
     case eUnit_Shadow:
       NS_ABORT_IF_FALSE(mUnit != eUnit_Dasharray || aOther.mValue.mCSSValueList,
                         "dasharrays may not be null");
       if (aOther.mValue.mCSSValueList) {
         mValue.mCSSValueList = aOther.mValue.mCSSValueList->Clone();
         if (!mValue.mCSSValueList) {
           mUnit = eUnit_Null;
         }
       } else {
         mValue.mCSSValueList = nsnull;
       }
       break;
+    case eUnit_CSSValuePairList:
+      NS_ABORT_IF_FALSE(aOther.mValue.mCSSValuePairList,
+                        "value pair lists may not be null");
+      mValue.mCSSValuePairList = aOther.mValue.mCSSValuePairList->Clone();
+      if (!mValue.mCSSValuePairList) {
+        mUnit = eUnit_Null;
+      }
+      break;
     case eUnit_UnparsedString:
       NS_ABORT_IF_FALSE(aOther.mValue.mString, "expecting non-null string");
       mValue.mString = aOther.mValue.mString;
       mValue.mString->AddRef();
       break;
   }
 
   return *this;
@@ -1587,34 +1954,58 @@ nsStyleAnimation::Value::SetAndAdoptCSSV
   FreeValue();
   NS_ABORT_IF_FALSE(IsCSSValuePairUnit(aUnit), "bad unit");
   NS_ABORT_IF_FALSE(aValuePair != nsnull, "value pairs may not be null");
   mUnit = aUnit;
   mValue.mCSSValuePair = aValuePair; // take ownership
 }
 
 void
+nsStyleAnimation::Value::SetAndAdoptCSSRectValue(nsCSSRect *aRect, Unit aUnit)
+{
+  FreeValue();
+  NS_ABORT_IF_FALSE(IsCSSRectUnit(aUnit), "bad unit");
+  NS_ABORT_IF_FALSE(aRect != nsnull, "value pairs may not be null");
+  mUnit = aUnit;
+  mValue.mCSSRect = aRect; // take ownership
+}
+
+void
 nsStyleAnimation::Value::SetAndAdoptCSSValueListValue(
                            nsCSSValueList *aValueList, Unit aUnit)
 {
   FreeValue();
   NS_ABORT_IF_FALSE(IsCSSValueListUnit(aUnit), "bad unit");
   NS_ABORT_IF_FALSE(aUnit != eUnit_Dasharray || aValueList != nsnull,
                     "dasharrays may not be null");
   mUnit = aUnit;
   mValue.mCSSValueList = aValueList; // take ownership
 }
 
 void
+nsStyleAnimation::Value::SetAndAdoptCSSValuePairListValue(
+                           nsCSSValuePairList *aValuePairList)
+{
+  FreeValue();
+  NS_ABORT_IF_FALSE(aValuePairList, "may not be null");
+  mUnit = eUnit_CSSValuePairList;
+  mValue.mCSSValuePairList = aValuePairList; // take ownership
+}
+
+void
 nsStyleAnimation::Value::FreeValue()
 {
   if (IsCSSValueListUnit(mUnit)) {
     delete mValue.mCSSValueList;
   } else if (IsCSSValuePairUnit(mUnit)) {
     delete mValue.mCSSValuePair;
+  } else if (IsCSSRectUnit(mUnit)) {
+    delete mValue.mCSSRect;
+  } else if (IsCSSValuePairListUnit(mUnit)) {
+    delete mValue.mCSSValuePairList;
   } else if (IsStringUnit(mUnit)) {
     NS_ABORT_IF_FALSE(mValue.mString, "expecting non-null string");
     mValue.mString->Release();
   }
 }
 
 PRBool
 nsStyleAnimation::Value::operator==(const Value& aOther) const
@@ -1625,31 +2016,37 @@ nsStyleAnimation::Value::operator==(cons
 
   switch (mUnit) {
     case eUnit_Null:
     case eUnit_Normal:
     case eUnit_Auto:
     case eUnit_None:
       return PR_TRUE;
     case eUnit_Enumerated:
+    case eUnit_Visibility:
     case eUnit_Integer:
       return mValue.mInt == aOther.mValue.mInt;
     case eUnit_Coord:
       return mValue.mCoord == aOther.mValue.mCoord;
     case eUnit_Percent:
     case eUnit_Float:
       return mValue.mFloat == aOther.mValue.mFloat;
     case eUnit_Color:
       return mValue.mColor == aOther.mValue.mColor;
     case eUnit_CSSValuePair:
       return *mValue.mCSSValuePair == *aOther.mValue.mCSSValuePair;
+    case eUnit_CSSRect:
+      return *mValue.mCSSRect == *aOther.mValue.mCSSRect;
     case eUnit_Dasharray:
     case eUnit_Shadow:
       return nsCSSValueList::Equal(mValue.mCSSValueList,
                                    aOther.mValue.mCSSValueList);
+    case eUnit_CSSValuePairList:
+      return nsCSSValuePairList::Equal(mValue.mCSSValuePairList,
+                                       aOther.mValue.mCSSValuePairList);
     case eUnit_UnparsedString:
       return (NS_strcmp(GetStringBufferValue(),
                         aOther.GetStringBufferValue()) == 0);
   }
 
   NS_NOTREACHED("incomplete case");
   return PR_FALSE;
 }
--- a/layout/style/nsStyleAnimation.h
+++ b/layout/style/nsStyleAnimation.h
@@ -51,16 +51,18 @@
 #include "nsColor.h"
 
 class nsCSSDeclaration;
 class nsIContent;
 class nsPresContext;
 class nsStyleContext;
 struct nsCSSValueList;
 struct nsCSSValuePair;
+struct nsCSSValuePairList;
+struct nsCSSRect;
 
 /**
  * Utility class to handle animated style values
  */
 class nsStyleAnimation {
 public:
   class Value;
 
@@ -223,37 +225,43 @@ public:
    * The types and values for the values that we extract and animate.
    */
   enum Unit {
     eUnit_Null, // not initialized
     eUnit_Normal,
     eUnit_Auto,
     eUnit_None,
     eUnit_Enumerated,
+    eUnit_Visibility, // special case for transitions (which converts
+                      // Enumerated to Visibility as needed)
     eUnit_Integer,
     eUnit_Coord,
     eUnit_Percent,
     eUnit_Float,
     eUnit_Color,
     eUnit_CSSValuePair, // nsCSSValuePair* (never null)
+    eUnit_CSSRect, // nsCSSRect* (never null)
     eUnit_Dasharray, // nsCSSValueList* (never null)
     eUnit_Shadow, // nsCSSValueList* (may be null)
+    eUnit_CSSValuePairList, // nsCSSValuePairList* (never null)
     eUnit_UnparsedString // nsStringBuffer* (never null)
   };
 
   class Value {
   private:
     Unit mUnit;
     union {
       PRInt32 mInt;
       nscoord mCoord;
       float mFloat;
       nscolor mColor;
       nsCSSValuePair* mCSSValuePair;
+      nsCSSRect* mCSSRect;
       nsCSSValueList* mCSSValueList;
+      nsCSSValuePairList* mCSSValuePairList;
       nsStringBuffer* mString;
     } mValue;
   public:
     Unit GetUnit() const {
       NS_ASSERTION(mUnit != eUnit_Null, "uninitialized");
       return mUnit;
     }
 
@@ -282,20 +290,28 @@ public:
     nscolor GetColorValue() const {
       NS_ASSERTION(mUnit == eUnit_Color, "unit mismatch");
       return mValue.mColor;
     }
     nsCSSValuePair* GetCSSValuePairValue() const {
       NS_ASSERTION(IsCSSValuePairUnit(mUnit), "unit mismatch");
       return mValue.mCSSValuePair;
     }
+    nsCSSRect* GetCSSRectValue() const {
+      NS_ASSERTION(IsCSSRectUnit(mUnit), "unit mismatch");
+      return mValue.mCSSRect;
+    }
     nsCSSValueList* GetCSSValueListValue() const {
       NS_ASSERTION(IsCSSValueListUnit(mUnit), "unit mismatch");
       return mValue.mCSSValueList;
     }
+    nsCSSValuePairList* GetCSSValuePairListValue() const {
+      NS_ASSERTION(IsCSSValuePairListUnit(mUnit), "unit mismatch");
+      return mValue.mCSSValuePairList;
+    }
     const PRUnichar* GetStringBufferValue() const {
       NS_ASSERTION(IsStringUnit(mUnit), "unit mismatch");
       return GetBufferValue(mValue.mString);
     }
 
     void GetStringValue(nsAString& aBuffer) const {
       NS_ASSERTION(IsStringUnit(mUnit), "unit mismatch");
       aBuffer.Truncate();
@@ -329,40 +345,49 @@ public:
     void SetCoordValue(nscoord aCoord);
     void SetPercentValue(float aPercent);
     void SetFloatValue(float aFloat);
     void SetColorValue(nscolor aColor);
     void SetUnparsedStringValue(const nsString& aString);
 
     // These setters take ownership of |aValue|, and are therefore named
     // "SetAndAdopt*".
+    void SetAndAdoptCSSValuePairValue(nsCSSValuePair *aValue, Unit aUnit);
+    void SetAndAdoptCSSRectValue(nsCSSRect *aValue, Unit aUnit);
     void SetAndAdoptCSSValueListValue(nsCSSValueList *aValue, Unit aUnit);
-    void SetAndAdoptCSSValuePairValue(nsCSSValuePair *aValue, Unit aUnit);
+    void SetAndAdoptCSSValuePairListValue(nsCSSValuePairList *aValue);
 
     Value& operator=(const Value& aOther);
 
     PRBool operator==(const Value& aOther) const;
     PRBool operator!=(const Value& aOther) const
       { return !(*this == aOther); }
 
   private:
     void FreeValue();
 
     static const PRUnichar* GetBufferValue(nsStringBuffer* aBuffer) {
       return static_cast<PRUnichar*>(aBuffer->Data());
     }
 
     static PRBool IsIntUnit(Unit aUnit) {
-      return aUnit == eUnit_Enumerated || aUnit == eUnit_Integer;
+      return aUnit == eUnit_Enumerated || aUnit == eUnit_Visibility ||
+             aUnit == eUnit_Integer;
     }
     static PRBool IsCSSValuePairUnit(Unit aUnit) {
       return aUnit == eUnit_CSSValuePair;
     }
+    static PRBool IsCSSRectUnit(Unit aUnit) {
+      return aUnit == eUnit_CSSRect;
+    }
     static PRBool IsCSSValueListUnit(Unit aUnit) {
       return aUnit == eUnit_Dasharray || aUnit == eUnit_Shadow;
     }
+    static PRBool IsCSSValuePairListUnit(Unit aUnit) {
+      return aUnit == eUnit_CSSValuePairList;
+    }
     static PRBool IsStringUnit(Unit aUnit) {
       return aUnit == eUnit_UnparsedString;
     }
   };
 };
 
 #endif
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -1297,24 +1297,17 @@ struct nsStyleDisplay {
 #ifdef DEBUG
   static nsChangeHint MaxDifference();
 #endif
   static PRBool ForceCompare() { return PR_TRUE; }
 
   // We guarantee that if mBinding is non-null, so are mBinding->mURI and
   // mBinding->mOriginPrincipal.
   nsRefPtr<nsCSSValue::URL> mBinding;    // [reset]
-#if 0
-  // XXX This is how it is defined in the CSS2 spec, but the errata
-  // changed it to be consistent with the positioning draft and how
-  // Nav and IE implement it
-  nsMargin  mClip;              // [reset] offsets from respective edge
-#else
   nsRect    mClip;              // [reset] offsets from upper-left border edge
-#endif
   float   mOpacity;             // [reset]
   PRUint8 mDisplay;             // [reset] see nsStyleConsts.h NS_STYLE_DISPLAY_*
   PRUint8 mOriginalDisplay;     // [reset] saved mDisplay for position:absolute/fixed
   PRUint8 mAppearance;          // [reset]
   PRUint8 mPosition;            // [reset] see nsStyleConsts.h
   PRUint8 mFloats;              // [reset] see nsStyleConsts.h NS_STYLE_FLOAT_*
   PRUint8 mBreakType;           // [reset] see nsStyleConsts.h NS_STYLE_CLEAR_*
   PRPackedBool mBreakBefore;    // [reset] 
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -337,16 +337,34 @@ nsTransitionManager::~nsTransitionManage
   // Content nodes might outlive the transition manager.
   while (!PR_CLIST_IS_EMPTY(&mElementTransitions)) {
     ElementTransitions *head = static_cast<ElementTransitions*>(
                                  PR_LIST_HEAD(&mElementTransitions));
     head->Destroy();
   }
 }
 
+static PRBool
+TransExtractComputedValue(nsCSSProperty aProperty,
+                          nsStyleContext* aStyleContext,
+                          nsStyleAnimation::Value& aComputedValue)
+{
+  PRBool result =
+    nsStyleAnimation::ExtractComputedValue(aProperty, aStyleContext,
+                                           aComputedValue);
+  if (aProperty == eCSSProperty_visibility) {
+    NS_ABORT_IF_FALSE(aComputedValue.GetUnit() ==
+                        nsStyleAnimation::eUnit_Enumerated,
+                      "unexpected unit");
+    aComputedValue.SetIntValue(aComputedValue.GetIntValue(),
+                               nsStyleAnimation::eUnit_Visibility);
+  }
+  return result;
+}
+
 already_AddRefed<nsIStyleRule>
 nsTransitionManager::StyleContextChanged(nsIContent *aElement,
                                          nsStyleContext *aOldStyleContext,
                                          nsStyleContext *aNewStyleContext)
 {
   NS_PRECONDITION(aOldStyleContext->GetPseudo() ==
                       aNewStyleContext->GetPseudo(),
                   "pseudo type mismatch");
@@ -358,34 +376,33 @@ nsTransitionManager::StyleContextChanged
                       aNewStyleContext->HasPseudoElementData(),
                   "pseudo type mismatch");
 
   // NOTE: Things in this function (and ConsiderStartingTransition)
   // should never call PeekStyleData because we don't preserve gotten
   // structs across reframes.
 
   // Return sooner (before the startedAny check below) for the most
-  // common case: no transitions specified.
+  // common case: no transitions specified or running.
   const nsStyleDisplay *disp = aNewStyleContext->GetStyleDisplay();
-  const nsStyleDisplay *oldDisp = aOldStyleContext->GetStyleDisplay();
-  if (disp->mTransitionPropertyCount == 1 &&
-      oldDisp->mTransitionPropertyCount == 1 &&
+  nsCSSPseudoElements::Type pseudoType = aNewStyleContext->GetPseudoType();
+  ElementTransitions *et =
+      GetElementTransitions(aElement, pseudoType, PR_FALSE);
+  if (!et &&
+      disp->mTransitionPropertyCount == 1 &&
       disp->mTransitions[0].GetDelay() == 0.0f &&
-      disp->mTransitions[0].GetDuration() == 0.0f &&
-      oldDisp->mTransitions[0].GetProperty() ==
-        disp->mTransitions[0].GetProperty()) {
+      disp->mTransitions[0].GetDuration() == 0.0f) {
     return nsnull;
   }      
 
 
   if (aNewStyleContext->PresContext()->IsProcessingAnimationStyleChange()) {
     return nsnull;
   }
   
-  nsCSSPseudoElements::Type pseudoType = aNewStyleContext->GetPseudoType();
   if (pseudoType != nsCSSPseudoElements::ePseudo_NotPseudoElement &&
       pseudoType != nsCSSPseudoElements::ePseudo_before &&
       pseudoType != nsCSSPseudoElements::ePseudo_after) {
     return nsnull;
   }
   if (aNewStyleContext->GetParent() &&
       aNewStyleContext->GetParent()->HasPseudoElementData()) {
     // Ignore transitions on things that inherit properties from
@@ -395,18 +412,16 @@ nsTransitionManager::StyleContextChanged
   }
 
   // Per http://lists.w3.org/Archives/Public/www-style/2009Aug/0109.html
   // I'll consider only the transitions from the number of items in
   // 'transition-property' on down, and later ones will override earlier
   // ones (tracked using |whichStarted|).
   PRBool startedAny = PR_FALSE;
   nsCSSPropertySet whichStarted;
-  ElementTransitions *et =
-    GetElementTransitions(aElement, pseudoType, PR_FALSE);
   for (PRUint32 i = disp->mTransitionPropertyCount; i-- != 0; ) {
     const nsTransition& t = disp->mTransitions[i];
     // Check delay and duration first, since they default to zero, and
     // when they're both zero, we can ignore the transition.
     if (t.GetDelay() != 0.0f || t.GetDuration() != 0.0f) {
       // We might have something to transition.  See if any of the
       // properties in question changed and are animatable.
       // FIXME: Would be good to find a way to share code between this
@@ -434,49 +449,64 @@ nsTransitionManager::StyleContextChanged
                                    aOldStyleContext, aNewStyleContext,
                                    &startedAny, &whichStarted);
       }
     }
   }
 
   // Stop any transitions for properties that are no longer in
   // 'transition-property'.
-  if (et && disp->mTransitions[0].GetProperty() !=
-            eCSSPropertyExtra_all_properties) {
+  // Also stop any transitions for properties that just changed (and are
+  // still in the set of properties to transition), but we didn't just
+  // start the transition because delay and duration are both zero.
+  if (et) {
+    PRBool checkProperties =
+      disp->mTransitions[0].GetProperty() != eCSSPropertyExtra_all_properties;
     nsCSSPropertySet allTransitionProperties;
-    for (PRUint32 i = disp->mTransitionPropertyCount; i-- != 0; ) {
-      const nsTransition& t = disp->mTransitions[i];
-      // FIXME: Would be good to find a way to share code between this
-      // interpretation of transition-property and the one above.
-      nsCSSProperty property = t.GetProperty();
-      if (property == eCSSPropertyExtra_no_properties ||
-          property == eCSSProperty_UNKNOWN) {
-        // Nothing to do, but need to exclude this from cases below.
-      } else if (property == eCSSPropertyExtra_all_properties) {
-        for (nsCSSProperty p = nsCSSProperty(0); 
-             p < eCSSProperty_COUNT_no_shorthands;
-             p = nsCSSProperty(p + 1)) {
-          allTransitionProperties.AddProperty(p);
+    if (checkProperties) {
+      for (PRUint32 i = disp->mTransitionPropertyCount; i-- != 0; ) {
+        const nsTransition& t = disp->mTransitions[i];
+        // FIXME: Would be good to find a way to share code between this
+        // interpretation of transition-property and the one above.
+        nsCSSProperty property = t.GetProperty();
+        if (property == eCSSPropertyExtra_no_properties ||
+            property == eCSSProperty_UNKNOWN) {
+          // Nothing to do, but need to exclude this from cases below.
+        } else if (property == eCSSPropertyExtra_all_properties) {
+          for (nsCSSProperty p = nsCSSProperty(0); 
+               p < eCSSProperty_COUNT_no_shorthands;
+               p = nsCSSProperty(p + 1)) {
+            allTransitionProperties.AddProperty(p);
+          }
+        } else if (nsCSSProps::IsShorthand(property)) {
+          CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, property) {
+            allTransitionProperties.AddProperty(*subprop);
+          }
+        } else {
+          allTransitionProperties.AddProperty(property);
         }
-      } else if (nsCSSProps::IsShorthand(property)) {
-        CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, property) {
-          allTransitionProperties.AddProperty(*subprop);
-        }
-      } else {
-        allTransitionProperties.AddProperty(property);
       }
     }
 
     nsTArray<ElementPropertyTransition> &pts = et->mPropertyTransitions;
     PRUint32 i = pts.Length();
     NS_ABORT_IF_FALSE(i != 0, "empty transitions list?");
+    nsStyleAnimation::Value currentValue;
     do {
       --i;
       ElementPropertyTransition &pt = pts[i];
-      if (!allTransitionProperties.HasProperty(pt.mProperty)) {
+          // properties no longer in 'transition-property'
+      if ((checkProperties &&
+           !allTransitionProperties.HasProperty(pt.mProperty)) ||
+          // properties whose computed values changed but delay and
+          // duration are both zero
+          !TransExtractComputedValue(pt.mProperty, aNewStyleContext,
+                                     currentValue) ||
+          currentValue != pt.mEndValue) {
+        // stop the transition
         pts.RemoveElementAt(i);
       }
     } while (i != 0);
 
     if (pts.IsEmpty()) {
       et->Destroy();
       et = nsnull;
     }
@@ -547,20 +577,18 @@ nsTransitionManager::ConsiderStartingTra
 
   if (nsCSSProps::kAnimTypeTable[aProperty] == eStyleAnimType_None) {
     return;
   }
 
   ElementPropertyTransition pt;
   nsStyleAnimation::Value dummyValue;
   PRBool shouldAnimate =
-    nsStyleAnimation::ExtractComputedValue(aProperty, aOldStyleContext,
-                                           pt.mStartValue) &&
-    nsStyleAnimation::ExtractComputedValue(aProperty, aNewStyleContext,
-                                           pt.mEndValue) &&
+    TransExtractComputedValue(aProperty, aOldStyleContext, pt.mStartValue) &&
+    TransExtractComputedValue(aProperty, aNewStyleContext, pt.mEndValue) &&
     pt.mStartValue != pt.mEndValue &&
     // Check that we can interpolate between these values
     // (If this is ever a performance problem, we could add a
     // CanInterpolate method, but it seems fine for now.)
     nsStyleAnimation::Interpolate(aProperty, pt.mStartValue, pt.mEndValue,
                                   0.5, dummyValue);
 
   PRUint32 currentIndex = nsTArray<ElementPropertyTransition>::NoIndex;
@@ -691,27 +719,33 @@ nsTransitionManager::ConsiderStartingTra
   aWhichStarted->AddProperty(aProperty);
 }
 
 ElementTransitions*
 nsTransitionManager::GetElementTransitions(nsIContent *aElement,
                                            nsCSSPseudoElements::Type aPseudoType,
                                            PRBool aCreateIfNeeded)
 {
+  if (!aCreateIfNeeded && PR_CLIST_IS_EMPTY(&mElementTransitions)) {
+    // Early return for the most common case.
+    return nsnull;
+  }
+
   nsIAtom *propName;
-  if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
+  if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
+    propName = nsGkAtoms::transitionsProperty;
+  } else if (aPseudoType == nsCSSPseudoElements::ePseudo_before) {
     propName = nsGkAtoms::transitionsOfBeforeProperty;
   } else if (aPseudoType == nsCSSPseudoElements::ePseudo_after) {
     propName = nsGkAtoms::transitionsOfAfterProperty;
   } else {
-    NS_ASSERTION(aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
-		 !aCreateIfNeeded,
+    NS_ASSERTION(!aCreateIfNeeded,
                  "should never try to create transitions for pseudo "
                  "other than :before or :after");
-    propName = nsGkAtoms::transitionsProperty;
+    return nsnull;
   }
   ElementTransitions *et = static_cast<ElementTransitions*>(
                              aElement->GetProperty(propName));
   if (!et && aCreateIfNeeded) {
     // FIXME: Consider arena-allocating?
     et = new ElementTransitions(aElement, propName, this);
     if (!et) {
       NS_WARNING("out of memory");
@@ -742,19 +776,17 @@ nsTransitionManager::AddElementTransitio
 
   PR_INSERT_BEFORE(aElementTransitions, &mElementTransitions);
 }
 
 /*
  * nsISupports implementation
  */
 
-NS_IMPL_ADDREF_USING_AGGREGATOR(nsTransitionManager, mPresContext)
-NS_IMPL_RELEASE_USING_AGGREGATOR(nsTransitionManager, mPresContext)
-NS_IMPL_QUERY_INTERFACE1(nsTransitionManager, nsIStyleRuleProcessor)
+NS_IMPL_ISUPPORTS1(nsTransitionManager, nsIStyleRuleProcessor)
 
 /*
  * nsIStyleRuleProcessor implementation
  */
 
 nsresult
 nsTransitionManager::WalkTransitionRule(RuleProcessorData* aData,
                                         nsCSSPseudoElements::Type aPseudoType)
@@ -846,16 +878,20 @@ nsTransitionManager::MediumFeaturesChang
 {
   *aRulesChanged = PR_FALSE;
   return NS_OK;
 }
 
 /* virtual */ void
 nsTransitionManager::WillRefresh(mozilla::TimeStamp aTime)
 {
+  NS_ABORT_IF_FALSE(mPresContext,
+                    "refresh driver should not notify additional observers "
+                    "after pres context has been destroyed");
+
   // Trim transitions that have completed, and post restyle events for
   // frames that are still transitioning.
   {
     PRCList *next = PR_LIST_HEAD(&mElementTransitions);
     while (next != &mElementTransitions) {
       ElementTransitions *et = static_cast<ElementTransitions*>(next);
       next = PR_NEXT_LINK(next);
 
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -47,27 +47,30 @@
 #include "nsCSSPseudoElements.h"
 
 class nsStyleContext;
 class nsPresContext;
 class nsCSSPropertySet;
 struct nsTransition;
 struct ElementTransitions;
 
-/**
- * Must be created only as a sub-object of an nsPresContext (since its
- * reference counting methods assume that).
- */
 class nsTransitionManager : public nsIStyleRuleProcessor,
                             public nsARefreshObserver {
 public:
   nsTransitionManager(nsPresContext *aPresContext);
   ~nsTransitionManager();
 
   /**
+   * Notify the transition manager that the pres context is going away.
+   */
+  void Disconnect() {
+    mPresContext = nsnull;
+  }
+
+  /**
    * StyleContextChanged 
    *
    * To be called from nsFrameManager::ReResolveStyleContext when the
    * style of an element has changed, to initiate transitions from that
    * style change.
    *
    * It may return a "cover rule" (see CoverTransitionStartStyleRule) to
    * cover up some of the changes for the duration of the restyling of
@@ -77,17 +80,17 @@ public:
    * returned cover rule as the most specific rule.
    */
   already_AddRefed<nsIStyleRule>
     StyleContextChanged(nsIContent *aElement,
                         nsStyleContext *aOldStyleContext,
                         nsStyleContext *aNewStyleContext);
 
   // nsISupports
-  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_ISUPPORTS
 
   // nsIStyleRuleProcessor
   NS_IMETHOD RulesMatching(ElementRuleProcessorData* aData);
   NS_IMETHOD RulesMatching(PseudoElementRuleProcessorData* aData);
   NS_IMETHOD RulesMatching(AnonBoxRuleProcessorData* aData);
 #ifdef MOZ_XUL
   NS_IMETHOD RulesMatching(XULTreeRuleProcessorData* aData);
 #endif
@@ -115,12 +118,12 @@ private:
                                             nsCSSPseudoElements::Type aPseudoType,
                                             PRBool aCreateIfNeeded);
   void AddElementTransitions(ElementTransitions* aElementTransitions);
   void TransitionsRemoved();
   nsresult WalkTransitionRule(RuleProcessorData* aData,
 			      nsCSSPseudoElements::Type aPseudoType);
 
   PRCList mElementTransitions;
-  nsPresContext *mPresContext;
+  nsPresContext *mPresContext; // weak (non-null from ctor to Disconnect)
 };
 
 #endif /* !defined(nsTransitionManager_h_) */
--- a/layout/style/test/test_transitions_dynamic_changes.html
+++ b/layout/style/test/test_transitions_dynamic_changes.html
@@ -35,12 +35,26 @@ p.style.MozTransitionDelay = "0s";
 is(cs.textIndent, "50px", "changing delay doesn't change transitioning");
 p.style.MozTransitionProperty = "text-indent";
 is(cs.textIndent, "50px",
    "irrelevant change to transition property doesn't change transitioning");
 p.style.MozTransitionProperty = "font";
 is(cs.textIndent, "0px",
    "relevant change to transition property does change transitioning");
 
+/** Test for Bug 522643 */
+p.style.MozTransitionDuration = "4s";
+p.style.MozTransitionDelay = "-2s";
+p.style.MozTransitionProperty = "text-indent";
+p.style.textIndent = "100px";
+is(cs.textIndent, "50px", "transition is halfway");
+p.style.MozTransitionDuration = "0s";
+p.style.MozTransitionDelay = "0s";
+is(cs.textIndent, "50px",
+   "changing duration and delay doesn't change transitioning");
+p.style.textIndent = "0px";
+is(cs.textIndent, "0px",
+   "changing property after changing duration and delay stops transition");
+
 </script>
 </pre>
 </body>
 </html>
--- a/layout/style/test/test_transitions_per_property.html
+++ b/layout/style/test/test_transitions_per_property.html
@@ -42,45 +42,49 @@ function has_num(str)
 }
 
 function any_unit_to_num(str)
 {
     return Number(String(str).match(/^([\d.]+)/)[1]);
 }
 
 var supported_properties = {
+    "-moz-background-size": [ test_background_size_transition ],
     "-moz-border-radius-bottomleft": [ test_radius_transition ],
     "-moz-border-radius-bottomright": [ test_radius_transition ],
     "-moz-border-radius-topleft": [ test_radius_transition ],
     "-moz-border-radius-topright": [ test_radius_transition ],
     "-moz-box-flex": [ test_float_zeroToOne_transition,
                        test_float_aboveOne_transition ],
     "-moz-box-shadow": [ test_shadow_transition ],
     "-moz-column-count": [ test_pos_integer_or_auto_transition ],
     "-moz-column-gap": [ test_length_transition ],
     "-moz-column-rule-color": [ test_color_transition ],
     "-moz-column-rule-width": [ test_length_transition ],
     "-moz-column-width": [ test_length_transition ],
+    "-moz-image-region": [ test_rect_transition ],
     "-moz-outline-radius-bottomleft": [ test_radius_transition ],
     "-moz-outline-radius-bottomright": [ test_radius_transition ],
     "-moz-outline-radius-topleft": [ test_radius_transition ],
     "-moz-outline-radius-topright": [ test_radius_transition ],
     "-moz-transform-origin": [ test_length_pair_transition,
                                test_length_percent_pair_transition ],
     "background-color": [ test_color_transition ],
+    "background-position": [ test_background_position_transition ],
     "border-bottom-color": [ test_color_transition ],
     "border-bottom-width": [ test_length_transition ],
     "border-left-color": [ test_color_transition ],
     "border-left-width": [ test_length_transition ],
     "border-right-color": [ test_color_transition ],
     "border-right-width": [ test_length_transition ],
     "border-spacing": [ test_length_pair_transition ],
     "border-top-color": [ test_color_transition ],
     "border-top-width": [ test_length_transition ],
     "bottom": [ test_length_transition, test_percent_transition ],
+    "clip": [ test_rect_transition ],
     "color": [ test_color_transition ],
     "fill": [ test_color_transition ],
     "fill-opacity" : [ test_float_zeroToOne_transition ],
     "flood-color": [ test_color_transition ],
     "flood-opacity" : [ test_float_zeroToOne_transition ],
     "font-size": [ test_length_transition, test_percent_transition ],
     "font-size-adjust": [ test_float_zeroToOne_transition,
                           test_float_aboveOne_transition ],
@@ -116,16 +120,17 @@ var supported_properties = {
     "stroke-dashoffset": [ test_length_transition, test_percent_transition ],
     "stroke-miterlimit": [ test_float_aboveOne_transition ],
     "stroke-opacity" : [ test_float_zeroToOne_transition ],
     "stroke-width": [ test_length_transition, test_percent_transition ],
     "text-indent": [ test_length_transition, test_percent_transition ],
     "text-shadow": [ test_shadow_transition ],
     "top": [ test_length_transition, test_percent_transition ],
     "vertical-align": [ test_length_transition, test_percent_transition ],
+    "visibility": [ test_visibility_transition ],
     "width": [ test_length_transition, test_percent_transition ],
     "word-spacing": [ test_length_transition ],
     "z-index": [ test_zindex_transition, test_pos_integer_or_auto_transition ],
 };
 
 var div = document.getElementById("display");
 var cs = getComputedStyle(div, "");
 
@@ -521,12 +526,91 @@ function test_length_percent_pair_transi
   is(cs.getPropertyValue(prop), "4px 50%",
      "length-valued property " + prop + ": computed value before transition");
   div.style.setProperty("-moz-transition-property", prop, "");
   div.style.setProperty(prop, "12px 70%", "");
   is(cs.getPropertyValue(prop), "8px 60%",
      "length-valued property " + prop + ": interpolation of lengths");
 }
 
+function test_rect_transition(prop) {
+  div.style.setProperty("-moz-transition-property", "none", "");
+  div.style.setProperty(prop, "rect(4px, 16px, 12px, 8px)", "");
+  is(cs.getPropertyValue(prop), "rect(4px, 16px, 12px, 8px)",
+     "rect-valued property " + prop + ": computed value before transition");
+  div.style.setProperty("-moz-transition-property", prop, "");
+  div.style.setProperty(prop, "rect(0px, 6px, 4px, 2px)", "");
+  is(cs.getPropertyValue(prop), "rect(2px, 11px, 8px, 5px)",
+     "rect-valued property " + prop + ": interpolation of rects");
+  if (prop == "clip") {
+    div.style.setProperty(prop, "rect(0px, 6px, 4px, auto)", "");
+    is(cs.getPropertyValue(prop), "rect(0px, 6px, 4px, auto)",
+       "rect-valued property " + prop + ": can't interpolate auto components");
+    div.style.setProperty(prop, "rect(0px, 6px, 4px, 2px)", "");
+  }
+  div.style.setProperty(prop, "auto", "");
+  is(cs.getPropertyValue(prop), "auto",
+     "rect-valued property " + prop + ": can't interpolate auto components");
+}
+
+function test_visibility_transition(prop) {
+  div.style.setProperty("-moz-transition-property", "none", "");
+  div.style.setProperty(prop, "visible", "");
+  is(cs.getPropertyValue(prop), "visible",
+     "visibility property " + prop + ": computed value before transition");
+  div.style.setProperty("-moz-transition-property", prop, "");
+  div.style.setProperty(prop, "hidden", "");
+  is(cs.getPropertyValue(prop), "visible",
+     "visibility property " + prop + ": interpolation of visibility");
+}
+
+function test_background_size_transition(prop) {
+  div.style.setProperty("-moz-transition-property", "none", "");
+  div.style.setProperty(prop, "50% 80%", "");
+  is(cs.getPropertyValue(prop), "50% 80%",
+     "property " + prop + ": computed value before transition");
+  div.style.setProperty("-moz-transition-property", prop, "");
+  div.style.setProperty(prop, "100% 100%", "");
+  is(cs.getPropertyValue(prop), "75% 90%",
+     "property " + prop + ": interpolation of percents");
+  div.style.setProperty(prop, "contain", "");
+  is(cs.getPropertyValue(prop), "contain",
+     "property " + prop + ": can't interpolate 'contain'");
+  test_background_position_size_common(prop);
+}
+
+function test_background_position_transition(prop) {
+  div.style.setProperty("-moz-transition-property", "none", "");
+  div.style.setProperty(prop, "center 80%", "");
+  is(cs.getPropertyValue(prop), "50% 80%",
+     "property " + prop + ": computed value before transition");
+  div.style.setProperty("-moz-transition-property", prop, "");
+  div.style.setProperty(prop, "bottom right", "");
+  is(cs.getPropertyValue(prop), "75% 90%",
+     "property " + prop + ": interpolation of percents");
+  test_background_position_size_common(prop);
+}
+
+function test_background_position_size_common(prop) {
+  div.style.setProperty(prop, "10px 40px", "");
+  is(cs.getPropertyValue(prop), "10px 40px",
+     "property " + prop + ": computed value before transition");
+  div.style.setProperty(prop, "50px 0", "");
+  is(cs.getPropertyValue(prop), "30px 20px",
+     "property " + prop + ": interpolation of lengths");
+  div.style.setProperty(prop, "10px 40px, 50px 50px, 30px 20px", "");
+  is(cs.getPropertyValue(prop), "10px 40px, 50px 50px, 30px 20px",
+     "property " + prop + ": computed value before transition");
+  div.style.setProperty(prop, "50px 20px, 70px 50px, 30px 40px", "");
+  is(cs.getPropertyValue(prop), "30px 30px, 60px 50px, 30px 30px",
+     "property " + prop + ": interpolation of lists of lengths");
+  div.style.setProperty(prop, "10px 40%, 50% 50px, 30% 20%", "");
+  is(cs.getPropertyValue(prop), "10px 40%, 50% 50px, 30% 20%",
+     "property " + prop + ": computed value before transition");
+  div.style.setProperty(prop, "50px 20%, 70% 50px, 30% 40%", "");
+  is(cs.getPropertyValue(prop), "30px 30%, 60% 50px, 30% 30%",
+     "property " + prop + ": interpolation of lists of lengths and percents");
+}
+
 </script>
 </pre>
 </body>
 </html>
--- a/layout/svg/base/src/nsSVGFilterPaintCallback.h
+++ b/layout/svg/base/src/nsSVGFilterPaintCallback.h
@@ -9,17 +9,17 @@
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is the Mozilla SVG project.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * 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"),
--- a/layout/svg/base/src/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/base/src/nsSVGPathGeometryFrame.cpp
@@ -265,16 +265,26 @@ nsSVGPathGeometryFrame::UpdateCoveredReg
   //
   // # Due to stroke dashing, in certain cases the fill extents could actually
   //   extend outside the stroke extents.
   // # If the stroke is very thin, cairo won't paint any stroke, and so the
   //   stroke bounds that it will return will be empty.
 
   if (HasStroke()) {
     SetupCairoStrokeGeometry(&context);
+    if (extent.Width() <= 0 && extent.Height() <= 0) {
+      // If 'extent' is empty, its position will not be set. Although
+      // GetUserStrokeExtent gets the extents wrong we can still use it
+      // to get the device space position of zero length stroked paths.
+      extent = context.GetUserStrokeExtent();
+      extent.pos.x += extent.size.width / 2;
+      extent.pos.y += extent.size.height / 2;
+      extent.size.width = 0;
+      extent.size.height = 0;
+    }
     extent = nsSVGUtils::PathExtentsToMaxStrokeExtents(extent, this);
   } else if (GetStyleSVG()->mFill.mType == eStyleSVGPaintType_None) {
     extent = gfxRect(0, 0, 0, 0);
   }
 
   if (!extent.IsEmpty()) {
     mRect = nsSVGUtils::ToAppPixelRect(PresContext(), extent);
   }
--- a/layout/svg/base/src/nsSVGUtils.cpp
+++ b/layout/svg/base/src/nsSVGUtils.cpp
@@ -1481,20 +1481,16 @@ nsSVGUtils::WritePPM(const char *fname, 
   fclose(f);
 }
 #endif
 
 /*static*/ gfxRect
 nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
                                           nsSVGGeometryFrame* aFrame)
 {
-  if (aPathExtents.Width() == 0 && aPathExtents.Height() == 0) {
-    return gfxRect(0, 0, 0, 0);
-  }
-
   // The logic here comes from _cairo_stroke_style_max_distance_from_path
 
   double style_expansion = 0.5;
 
   const nsStyleSVG* style = aFrame->GetStyleSVG();
 
   if (style->mStrokeLinecap == NS_STYLE_STROKE_LINECAP_SQUARE) {
     style_expansion = M_SQRT1_2;
--- a/modules/libpr0n/public/imgITools.idl
+++ b/modules/libpr0n/public/imgITools.idl
@@ -10,17 +10,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/modules/libpr0n/src/imgFrame.cpp
+++ b/modules/libpr0n/src/imgFrame.cpp
@@ -10,17 +10,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Joe Drew <joe@drew.ca> (original author)
  *
  * 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"),
--- a/modules/libpr0n/src/imgFrame.h
+++ b/modules/libpr0n/src/imgFrame.h
@@ -10,17 +10,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Joe Drew <joe@drew.ca> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/modules/libpr0n/src/imgTools.cpp
+++ b/modules/libpr0n/src/imgTools.cpp
@@ -10,17 +10,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/modules/libpr0n/src/imgTools.h
+++ b/modules/libpr0n/src/imgTools.h
@@ -10,17 +10,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/netwerk/system/wince/nsNotifyAddrListener.cpp
+++ b/netwerk/system/wince/nsNotifyAddrListener.cpp
@@ -8,17 +8,17 @@
  *
  * 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 Windows CE Link Monitoring.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/netwerk/system/wince/nsNotifyAddrListener.h
+++ b/netwerk/system/wince/nsNotifyAddrListener.h
@@ -8,17 +8,17 @@
  *
  * 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 Windows CE Link Monitoring.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/netwerk/wifi/Makefile.in
+++ b/netwerk/wifi/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 build system.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation
+# The Initial Developer of the Original Code is Mozilla Foundation
 # Portions created by the Initial Developer are Copyright (C) 2008
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #  Doug Turner <dougt@meer.net>
 #
 # 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
--- a/netwerk/wifi/public/Makefile.in
+++ b/netwerk/wifi/public/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 build system.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation
+# The Initial Developer of the Original Code is Mozilla Foundation
 # Portions created by the Initial Developer are Copyright (C) 2009
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #  Doug Turner <dougt@meer.net>
 #
 # 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
--- a/netwerk/wifi/public/nsIWifiAccessPoint.idl
+++ b/netwerk/wifi/public/nsIWifiAccessPoint.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/netwerk/wifi/public/nsIWifiListener.idl
+++ b/netwerk/wifi/public/nsIWifiListener.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/netwerk/wifi/public/nsIWifiMonitor.idl
+++ b/netwerk/wifi/public/nsIWifiMonitor.idl
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/netwerk/wifi/src/Makefile.in
+++ b/netwerk/wifi/src/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 build system.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation
+# The Initial Developer of the Original Code is Mozilla Foundation
 # Portions created by the Initial Developer are Copyright (C) 2009
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #  Doug Turner <dougt@meer.net>
 #
 # 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
--- a/netwerk/wifi/src/nsWifiAccessPoint.cpp
+++ b/netwerk/wifi/src/nsWifiAccessPoint.cpp
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * This is a derivative of work done by Google under a BSD style License.
  * See: http://gears.googlecode.com/svn/trunk/gears/geolocation/
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
--- a/netwerk/wifi/src/nsWifiAccessPoint.h
+++ b/netwerk/wifi/src/nsWifiAccessPoint.h
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * This is a derivative of work done by Google under a BSD style License.
  * See: http://gears.googlecode.com/svn/trunk/gears/geolocation/
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
--- a/netwerk/wifi/src/nsWifiMonitor.cpp
+++ b/netwerk/wifi/src/nsWifiMonitor.cpp
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * This is a derivative of work done by Google under a BSD style License.
  * See: http://gears.googlecode.com/svn/trunk/gears/geolocation/
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
--- a/netwerk/wifi/src/nsWifiMonitor.h
+++ b/netwerk/wifi/src/nsWifiMonitor.h
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * This is a derivative of work done by Google under a BSD style License.
  * See: http://gears.googlecode.com/svn/trunk/gears/geolocation/
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
--- a/netwerk/wifi/src/nsWifiScannerMac.cpp
+++ b/netwerk/wifi/src/nsWifiScannerMac.cpp
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * This is a derivative of work done by Google under a BSD style License.
  * See: http://gears.googlecode.com/svn/trunk/gears/geolocation/
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
--- a/netwerk/wifi/src/nsWifiScannerUnix.cpp
+++ b/netwerk/wifi/src/nsWifiScannerUnix.cpp
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * This is a derivative of work done by Google under a BSD style License.
  * See: http://gears.googlecode.com/svn/trunk/gears/geolocation/
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
--- a/netwerk/wifi/src/nsWifiScannerWin.cpp
+++ b/netwerk/wifi/src/nsWifiScannerWin.cpp
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * This is a derivative of work done by Google under a BSD style License.
  * See: http://gears.googlecode.com/svn/trunk/gears/geolocation/
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
--- a/netwerk/wifi/src/osx_corewlan.mm
+++ b/netwerk/wifi/src/osx_corewlan.mm
@@ -8,17 +8,17 @@
  *
  * 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 Geolocation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/other-licenses/branding/firefox/Makefile.in
+++ b/other-licenses/branding/firefox/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2009
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Justin Dolske <dolske@mozilla.com> (original author)
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/autocomplete/tests/unit/test_330578.js
+++ b/toolkit/components/autocomplete/tests/unit/test_330578.js
@@ -10,17 +10,17 @@
  *
  * 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 Bug 330578 unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Asaf Romano <mano@mozilla.com>
  *
  * 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
--- a/toolkit/components/exthelper/Makefile.in
+++ b/toolkit/components/exthelper/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 FUEL.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2006
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Mark Finkle <mfinkle@mozilla.com>
 #   John Resig  <jresig@mozilla.com>
 #
 # Alternatively, the contents of this file may be used under the terms of
--- a/toolkit/components/exthelper/extApplication.js
+++ b/toolkit/components/exthelper/extApplication.js
@@ -8,17 +8,17 @@
  *
  * 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 FUEL.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Mark Finkle <mfinkle@mozilla.com> (Original Author)
  *  John Resig  <jresig@mozilla.com> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/toolkit/components/exthelper/extIApplication.idl
+++ b/toolkit/components/exthelper/extIApplication.idl
@@ -8,17 +8,17 @@
  *
  * 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 FUEL.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Joey Minta  <jminta@gmail.com> (Original Author)
  *  Mark Finkle <mfinkle@mozilla.com>
  *  John Resig  <jresig@mozilla.com>
  *
--- a/toolkit/components/passwordmgr/public/Makefile.in
+++ b/toolkit/components/passwordmgr/public/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2007
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #  Justin Dolske <dolske@mozilla.com> (original author)
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/public/nsILoginInfo.idl
+++ b/toolkit/components/passwordmgr/public/nsILoginInfo.idl
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/public/nsILoginManager.idl
+++ b/toolkit/components/passwordmgr/public/nsILoginManager.idl
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/public/nsILoginManagerCrypto.idl
+++ b/toolkit/components/passwordmgr/public/nsILoginManagerCrypto.idl
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/public/nsILoginManagerIEMigrationHelper.idl
+++ b/toolkit/components/passwordmgr/public/nsILoginManagerIEMigrationHelper.idl
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/public/nsILoginManagerPrompter.idl
+++ b/toolkit/components/passwordmgr/public/nsILoginManagerPrompter.idl
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/public/nsILoginManagerStorage.idl
+++ b/toolkit/components/passwordmgr/public/nsILoginManagerStorage.idl
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/public/nsILoginMetaInfo.idl
+++ b/toolkit/components/passwordmgr/public/nsILoginMetaInfo.idl
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/src/Makefile.in
+++ b/toolkit/components/passwordmgr/src/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 Mozilla Corporation.
+# The Initial Developer of the Original Code is Mozilla Foundation.
 # Portions created by the Initial Developer are Copyright (C) 2007
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Justin Dolske <dolske@mozilla.com> (original author)
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/src/crypto-SDR.js
+++ b/toolkit/components/passwordmgr/src/crypto-SDR.js
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/src/nsLoginInfo.js
+++ b/toolkit/components/passwordmgr/src/nsLoginInfo.js
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/src/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/src/nsLoginManager.js
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *  Ehsan Akhgari <ehsan.akhgari@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/src/nsLoginManagerPrompter.js
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *  Ehsan Akhgari <ehsan.akhgari@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/toolkit/components/passwordmgr/src/storage-Legacy.js
+++ b/toolkit/components/passwordmgr/src/storage-Legacy.js
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/passwordmgr/src/storage-mozStorage.js
+++ b/toolkit/components/passwordmgr/src/storage-mozStorage.js
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Paul O'Shannessy <poshannessy@mozilla.com> (primary author)
  *  Mrinal Kant <mrinal.kant@gmail.com> (original sqlite related changes)
  *  Justin Dolske <dolske@mozilla.com> (encryption/decryption functions are
  *                                     a lift from Justin's storage-Legacy.js)
--- a/toolkit/components/places/src/nsLivemarkService.js
+++ b/toolkit/components/places/src/nsLivemarkService.js
@@ -9,17 +9,17 @@
  *
  * Software distributed under the License is distributed on an "AS IS"
  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  * the License for the specific language governing rights and
  * limitations under the License.
  *
  * The Original Code is the Places JS Livemark Service.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Annie Sullivan <annie.sullivan@gmail.com> (C++ author)
  *   Joe Hughes <joe@retrovirus.com>
  *   Vladimir Vukicevic <vladimir@pobox.com>
  *   Masayuki Nakano <masayuki@d-toybox.com>
--- a/toolkit/components/places/src/nsNavHistory.cpp
+++ b/toolkit/components/places/src/nsNavHistory.cpp
@@ -83,35 +83,36 @@
 #include "nsIAutoCompletePopup.h"
 #endif
 
 using namespace mozilla::places;
 
 // Microsecond timeout for "recent" events such as typed and bookmark following.
 // If you typed it more than this time ago, it's not recent.
 // This is 15 minutes           m    s/m  us/s
-#define RECENT_EVENT_THRESHOLD (15 * 60 * PR_USEC_PER_SEC)
+#define RECENT_EVENT_THRESHOLD ((PRInt64)15 * 60 * PR_USEC_PER_SEC)
 
 // Microseconds ago to look for redirects when updating bookmarks. Used to
 // compute the threshold for nsNavBookmarks::AddBookmarkToHash
-#define BOOKMARK_REDIRECT_TIME_THRESHOLD (2 * 60 * PR_USEC_PER_SEC)
+#define BOOKMARK_REDIRECT_TIME_THRESHOLD ((PRInt64)2 * 60 * PR_USEC_PER_SEC)
 
 // The maximum number of things that we will store in the recent events list
 // before calling ExpireNonrecentEvents. This number should be big enough so it
 // is very difficult to get that many unconsumed events (for example, typed but
 // never visited) in the RECENT_EVENT_THRESHOLD. Otherwise, we'll start
 // checking each one for every page visit, which will be somewhat slower.
 #define RECENT_EVENT_QUEUE_MAX_LENGTH 128
 
 // preference ID strings
 #define PREF_BRANCH_BASE                        "browser."
+
 #define PREF_BROWSER_HISTORY_EXPIRE_DAYS_MIN    "history_expire_days_min"
 #define PREF_BROWSER_HISTORY_EXPIRE_DAYS_MAX    "history_expire_days"
 #define PREF_BROWSER_HISTORY_EXPIRE_SITES       "history_expire_sites"
-#define PREF_DB_CACHE_PERCENTAGE                "history_cache_percentage"
+
 #define PREF_FRECENCY_NUM_VISITS                "places.frecency.numVisits"
 #define PREF_FRECENCY_FIRST_BUCKET_CUTOFF       "places.frecency.firstBucketCutoff"
 #define PREF_FRECENCY_SECOND_BUCKET_CUTOFF      "places.frecency.secondBucketCutoff"
 #define PREF_FRECENCY_THIRD_BUCKET_CUTOFF       "places.frecency.thirdBucketCutoff"
 #define PREF_FRECENCY_FOURTH_BUCKET_CUTOFF      "places.frecency.fourthBucketCutoff"
 #define PREF_FRECENCY_FIRST_BUCKET_WEIGHT       "places.frecency.firstBucketWeight"
 #define PREF_FRECENCY_SECOND_BUCKET_WEIGHT      "places.frecency.secondBucketWeight"
 #define PREF_FRECENCY_THIRD_BUCKET_WEIGHT       "places.frecency.thirdBucketWeight"
@@ -122,47 +123,63 @@ using namespace mozilla::places;
 #define PREF_FRECENCY_TYPED_VISIT_BONUS         "places.frecency.typedVisitBonus"
 #define PREF_FRECENCY_BOOKMARK_VISIT_BONUS      "places.frecency.bookmarkVisitBonus"
 #define PREF_FRECENCY_DOWNLOAD_VISIT_BONUS      "places.frecency.downloadVisitBonus"
 #define PREF_FRECENCY_PERM_REDIRECT_VISIT_BONUS "places.frecency.permRedirectVisitBonus"
 #define PREF_FRECENCY_TEMP_REDIRECT_VISIT_BONUS "places.frecency.tempRedirectVisitBonus"
 #define PREF_FRECENCY_DEFAULT_VISIT_BONUS       "places.frecency.defaultVisitBonus"
 #define PREF_FRECENCY_UNVISITED_BOOKMARK_BONUS  "places.frecency.unvisitedBookmarkBonus"
 #define PREF_FRECENCY_UNVISITED_TYPED_BONUS     "places.frecency.unvisitedTypedBonus"
+
 #define PREF_LAST_VACUUM                        "places.last_vacuum"
 
-// Default (integer) value of PREF_DB_CACHE_PERCENTAGE from 0-100
+#define PREF_CACHE_TO_MEMORY_PERCENTAGE         "places.database.cache_to_memory_percentage"
+
+// Default integer value for PREF_CACHE_TO_MEMORY_PERCENTAGE.
 // This is 6% of machine memory, giving 15MB for a user with 256MB of memory.
-// The most that will be used is the size of the DB file. Normal history sizes
-// look like 10MB would be a high average for a typical user, so the maximum
-// should not normally be required.
-#define DEFAULT_DB_CACHE_PERCENTAGE 6
+// Out of this cache, SQLite will use at most the size of the database file.
+#define DATABASE_DEFAULT_CACHE_TO_MEMORY_PERCENTAGE 6
+
+// This is the schema version, update it at any schema change and add a
+// corresponding migrateVxx method below.
+#define DATABASE_SCHEMA_VERSION 10
 
 // We set the default database page size to be larger. sqlite's default is 1K.
 // This gives good performance when many small parts of the file have to be
 // loaded for each statement. Because we try to keep large chunks of the file
 // in memory, a larger page size should give better I/O performance. 32K is
 // sqlite's default max page size.
-#define DEFAULT_DB_PAGE_SIZE 4096
-
-// the value of mLastNow expires every 3 seconds
-#define HISTORY_EXPIRE_NOW_TIMEOUT (3 * PR_MSEC_PER_SEC)
-
-// see bug #319004 -- clamp title and URL to generously-large but not too large
-// length
-#define HISTORY_URI_LENGTH_MAX 65536
-#define HISTORY_TITLE_LENGTH_MAX 4096
-
-// db file name
-#define DB_FILENAME NS_LITERAL_STRING("places.sqlite")
-
-// db backup file name
-#define DB_CORRUPT_FILENAME NS_LITERAL_STRING("places.sqlite.corrupt")
-
-// Lazy adding
+#define DATABASE_PAGE_SIZE 4096
+
+// Filename of the database.
+#define DATABASE_FILENAME NS_LITERAL_STRING("places.sqlite")
+
+// Filename used to backup corrupt databases.
+#define DATABASE_CORRUPT_FILENAME NS_LITERAL_STRING("places.sqlite.corrupt")
+
+// We use the TRUNCATE journal mode to reduce the number of fsyncs.  Without
+// this setting we had a Ts hit on Linux.  See bug 460315 for details.
+#define DATABASE_JOURNAL_MODE "TRUNCATE"
+
+// Fraction of free pages in the database to force a vacuum between
+// DATABASE_MAX_TIME_BEFORE_VACUUM and DATABASE_MIN_TIME_BEFORE_VACUUM.
+#define DATABASE_VACUUM_FREEPAGES_THRESHOLD 0.1
+// This is the maximum time (in microseconds) that can pass between 2 VACUUM
+// operations.
+#define DATABASE_MAX_TIME_BEFORE_VACUUM (PRInt64)60 * 24 * 60 * 60 * 1000 * 1000
+// This is the minimum time (in microseconds) that should pass between 2 VACUUM
+// operations.
+#define DATABASE_MIN_TIME_BEFORE_VACUUM (PRInt64)30 * 24 * 60 * 60 * 1000 * 1000
+
+// In order to avoid calling PR_now() too often we use a cached "now" value
+// for repeating stuff.  These are milliseconds between "now" cache refreshes.
+#define RENEW_CACHED_NOW_TIMEOUT ((PRInt32)3 * PR_MSEC_PER_SEC)
+
+// USECS_PER_DAY == PR_USEC_PER_SEC * 60 * 60 * 24;
+static const PRInt64 USECS_PER_DAY = LL_INIT(20, 500654080);
 
 #ifdef LAZY_ADD
 
 // time that we'll wait before committing messages
 #define LAZY_MESSAGE_TIMEOUT (3 * PR_MSEC_PER_SEC)
 
 // the maximum number of times we'll postpone a lazy timer before committing
 // See StartLazyTimer()
@@ -171,37 +188,38 @@ using namespace mozilla::places;
 #endif // LAZY_ADD
 
 // Limit the number of items in the history for performance reasons
 #define EXPIRATION_CAP_SITES 40000
 
 // character-set annotation
 #define CHARSET_ANNO NS_LITERAL_CSTRING("URIProperties/characterSet")
 
-// We use the TRUNCATE journal mode to reduce the number of fsyncs.  Without
-// this setting we had a Ts hit on Linux.  See bug 460315 for details.
-#define DEFAULT_JOURNAL_MODE "TRUNCATE"
-
 // These macros are used when splitting history by date.
 // These are the day containers and catch-all final container.
-#define ADDITIONAL_DATE_CONT_NUM 3
+#define HISTORY_ADDITIONAL_DATE_CONT_NUM 3
 // We use a guess of the number of months considering all of them 30 days
 // long, but we split only the last 6 months.
-#define DATE_CONT_NUM(_expireDays) \
-  (ADDITIONAL_DATE_CONT_NUM + NS_MIN(6, (_expireDays/30)))
-
-// fraction of free pages in the database to force a vacuum between
-// MAX_TIME_BEFORE_VACUUM and MIN_TIME_BEFORE_VACUUM.
-#define VACUUM_FREEPAGES_THRESHOLD 0.1
-// This is the maximum time (in microseconds) that can pass between 2 VACUUM
-// operations.
-#define MAX_TIME_BEFORE_VACUUM (PRInt64)60 * 24 * 60 * 60 * 1000 * 1000
-// This is the minimum time (in microseconds) that should pass between 2 VACUUM
-// operations.
-#define MIN_TIME_BEFORE_VACUUM (PRInt64)30 * 24 * 60 * 60 * 1000 * 1000
+#define HISTORY_DATE_CONT_NUM(_daysFromOldestVisit) \
+  (HISTORY_ADDITIONAL_DATE_CONT_NUM + \
+   NS_MIN(6, (PRInt32)NS_ceilf((float)_daysFromOldestVisit/30)))
+// Max number of containers, used to initialize the params hash.
+#define HISTORY_DATE_CONT_MAX 10
+
+#ifdef MOZ_XUL
+#define TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING "autocomplete-will-enter-text"
+#define TOPIC_AUTOCOMPLETE_FEEDBACK_UPDATED "places-autocomplete-feedback-updated"
+#endif
+#define TOPIC_XPCOM_SHUTDOWN "xpcom-shutdown"
+#define TOPIC_IDLE_DAILY "idle-daily"
+#define TOPIC_DATABASE_VACUUM_STARTING "places-vacuum-starting"
+#define TOPIC_DATABASE_LOCKED "places-database-locked"
+#define TOPIC_PLACES_INIT_COMPLETE "places-init-complete"
+#define TOPIC_PREF_CHANGED "nsPref:changed"
+
 
 NS_IMPL_THREADSAFE_ADDREF(nsNavHistory)
 NS_IMPL_THREADSAFE_RELEASE(nsNavHistory)
 
 NS_INTERFACE_MAP_BEGIN(nsNavHistory)
   NS_INTERFACE_MAP_ENTRY(nsINavHistoryService)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIGlobalHistory2, nsIGlobalHistory3)
   NS_INTERFACE_MAP_ENTRY(nsIGlobalHistory3)
@@ -221,31 +239,35 @@ NS_IMPL_CI_INTERFACE_GETTER5(
   nsNavHistory
 , nsINavHistoryService
 , nsIGlobalHistory3
 , nsIGlobalHistory2
 , nsIDownloadHistory
 , nsIBrowserHistory
 )
 
+namespace {
+
 static nsresult GetReversedHostname(nsIURI* aURI, nsAString& host);
 static void GetReversedHostname(const nsString& aForward, nsAString& aReversed);
 static PRInt64 GetSimpleBookmarksQueryFolder(
     const nsCOMArray<nsNavHistoryQuery>& aQueries,
     nsNavHistoryQueryOptions* aOptions);
 static void ParseSearchTermsFromQueries(const nsCOMArray<nsNavHistoryQuery>& aQueries,
                                         nsTArray<nsTArray<nsString>*>* aTerms);
 
 inline void ReverseString(const nsString& aInput, nsAString& aReversed)
 {
   aReversed.Truncate(0);
   for (PRInt32 i = aInput.Length() - 1; i >= 0; i --)
     aReversed.Append(aInput[i]);
 }
 
+} // anonymous namespace
+
 namespace mozilla {
   namespace places {
 
     bool hasRecentCorruptDB()
     {
       nsCOMPtr<nsIFile> profDir;
       nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
                                            getter_AddRefs(profDir));
@@ -259,18 +281,18 @@ namespace mozilla {
         rv = entries->GetNext(getter_AddRefs(next));
         NS_ENSURE_SUCCESS(rv, false);
         nsCOMPtr<nsIFile> currFile = do_QueryInterface(next, &rv);
         NS_ENSURE_SUCCESS(rv, false);
 
         nsAutoString leafName;
         rv = currFile->GetLeafName(leafName);
         NS_ENSURE_SUCCESS(rv, false);
-        if (leafName.Length() >= DB_CORRUPT_FILENAME.Length() &&
-            leafName.Find(".corrupt", DB_FILENAME.Length()) != -1) {
+        if (leafName.Length() >= DATABASE_CORRUPT_FILENAME.Length() &&
+            leafName.Find(".corrupt", DATABASE_FILENAME.Length()) != -1) {
           PRInt64 lastMod;
           rv = currFile->GetLastModifiedTime(&lastMod);
           NS_ENSURE_SUCCESS(rv, false);
           if (PR_Now() - lastMod > (PRInt64)24 * 60 * 60 * 1000 * 1000)
            return true;
         }
       }
       return false;
@@ -297,24 +319,26 @@ namespace mozilla {
                 "ORDER BY t_t.title COLLATE NOCASE ASC "
               ") "
              ")"));
       }
 
       _sqlFragment.AppendLiteral(" AS tags ");
     }
 
-  }
-}
-
-// UpdateBatchScoper
-//
-//    This just sets begin/end of batch updates to correspond to C++ scopes so
-//    we can be sure end always gets called.
-
+  } // namespace places
+} // namespace mozilla
+
+
+namespace {
+
+/**
+ * This class sets begin/end of batch updates to correspond to C++ scopes so
+ * we can be sure end always gets called.
+ */
 class UpdateBatchScoper
 {
 public:
   UpdateBatchScoper(nsNavHistory& aNavHistory) : mNavHistory(aNavHistory)
   {
     mNavHistory.BeginUpdateBatch();
   }
   ~UpdateBatchScoper()
@@ -327,103 +351,87 @@ protected:
 
 class PlacesEvent : public nsRunnable {
   public:
   PlacesEvent(const char* aTopic) {
     mTopic = aTopic;
   }
 
   NS_IMETHOD Run() {
-    nsresult rv;
     nsCOMPtr<nsIObserverService> observerService =
-      do_GetService("@mozilla.org/observer-service;1", &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = observerService->NotifyObservers(nsnull, mTopic, nsnull);
-    NS_ENSURE_SUCCESS(rv, rv);
+      do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
+    if (observerService)
+      (void)observerService->NotifyObservers(nsnull, mTopic, nsnull);
 
     return NS_OK;
   }
   protected:
   const char* mTopic;
 };
 
-// if adding a new one, be sure to update nsNavBookmarks statements and
-// its kGetChildrenIndex_* constants
+} // anonymouse namespace
+
+
+// Queries rows indexes to bind or get values, if adding a new one, be sure to
+// update nsNavBookmarks statements and its kGetChildrenIndex_* constants
 const PRInt32 nsNavHistory::kGetInfoIndex_PageID = 0;
 const PRInt32 nsNavHistory::kGetInfoIndex_URL = 1;
 const PRInt32 nsNavHistory::kGetInfoIndex_Title = 2;
 const PRInt32 nsNavHistory::kGetInfoIndex_RevHost = 3;
 const PRInt32 nsNavHistory::kGetInfoIndex_VisitCount = 4;
 const PRInt32 nsNavHistory::kGetInfoIndex_VisitDate = 5;
 const PRInt32 nsNavHistory::kGetInfoIndex_FaviconURL = 6;
 const PRInt32 nsNavHistory::kGetInfoIndex_SessionId = 7;
 const PRInt32 nsNavHistory::kGetInfoIndex_ItemId = 8;
 const PRInt32 nsNavHistory::kGetInfoIndex_ItemDateAdded = 9;
 const PRInt32 nsNavHistory::kGetInfoIndex_ItemLastModified = 10;
 const PRInt32 nsNavHistory::kGetInfoIndex_ItemParentId = 11;
 const PRInt32 nsNavHistory::kGetInfoIndex_ItemTags = 12;
 
 
-static const char* gXpcomShutdown = "xpcom-shutdown";
-static const char* gAutoCompleteFeedback = "autocomplete-will-enter-text";
-static const char* gIdleDaily = "idle-daily";
-
-// annotation names
-const char nsNavHistory::kAnnotationPreviousEncoding[] = "history/encoding";
-
-// code borrowed from mozilla/xpfe/components/history/src/nsGlobalHistory.cpp
-// pass in a pre-normalized now and a date, and we'll find
-// the difference since midnight on each of the days.
-//
-// USECS_PER_DAY == PR_USEC_PER_SEC * 60 * 60 * 24;
-static const PRInt64 USECS_PER_DAY = LL_INIT(20, 500654080);
-
 PLACES_FACTORY_SINGLETON_IMPLEMENTATION(nsNavHistory, gHistoryService)
 
-// nsNavHistory::nsNavHistory
-
-nsNavHistory::nsNavHistory() : mBatchLevel(0),
-                               mBatchHasTransaction(PR_FALSE),
-                               mNowValid(PR_FALSE),
-                               mExpireNowTimer(nsnull),
-                               mExpireDaysMin(0),
-                               mExpireDaysMax(0),
-                               mExpireSites(0),
-                               mNumVisitsForFrecency(10),
-                               mTagsFolder(-1),
-                               mInPrivateBrowsing(PRIVATEBROWSING_NOTINITED),
-                               mDatabaseStatus(DATABASE_STATUS_OK),
-                               mCanNotify(true),
-                               mCacheObservers("history-observers")
+
+nsNavHistory::nsNavHistory()
+: mBatchLevel(0)
+, mBatchHasTransaction(PR_FALSE)
+, mCachedNow(0)
+, mExpireNowTimer(nsnull)
+, mLastSessionID(0)
+, mExpireDaysMin(0)
+, mExpireDaysMax(0)
+, mExpireSites(0)
+, mNumVisitsForFrecency(10)
+, mTagsFolder(-1)
+, mInPrivateBrowsing(PRIVATEBROWSING_NOTINITED)
+, mDatabaseStatus(DATABASE_STATUS_OK)
+, mCanNotify(true)
+, mCacheObservers("history-observers")
 {
 #ifdef LAZY_ADD
   mLazyTimerSet = PR_TRUE;
   mLazyTimerDeferments = 0;
 #endif
   NS_ASSERTION(!gHistoryService,
                "Attempting to create two instances of the service!");
   gHistoryService = this;
 }
 
-// nsNavHistory::~nsNavHistory
 
 nsNavHistory::~nsNavHistory()
 {
   // remove the static reference to the service. Check to make sure its us
   // in case somebody creates an extra instance of the service.
   NS_ASSERTION(gHistoryService == this,
                "Deleting a non-singleton instance of the service");
   if (gHistoryService == this)
     gHistoryService = nsnull;
 }
 
 
-// nsNavHistory::Init
-
 nsresult
 nsNavHistory::Init()
 {
   nsresult rv;
 
   // prefs (must be before DB init, which uses the pref service)
   nsCOMPtr<nsIPrefService> prefService =
     do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
@@ -462,131 +470,111 @@ nsNavHistory::Init()
   // Initialize expiration.  There's no need to do this before, since just now
   // we have a valid database and a working connection.
   mExpire = new nsNavHistoryExpire();
 
   // Notify we have finished database initialization.
   // Enqueue the notification, so if we init another service that requires
   // nsNavHistoryService we don't recursive try to get it.
   nsRefPtr<PlacesEvent> completeEvent =
-    new PlacesEvent(PLACES_INIT_COMPLETE_TOPIC);
+    new PlacesEvent(TOPIC_PLACES_INIT_COMPLETE);
   rv = NS_DispatchToMainThread(completeEvent);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // extract the last session ID so we know where to pick up. There is no index
-  // over sessions so the naive statement "SELECT MAX(session) FROM
-  // moz_historyvisits" won't have good performance.
-  // This is long before we use our temporary tables, so we do not have to join
-  // on moz_historyvisits_temp to get the right result here.
-  {
-    nsCOMPtr<mozIStorageStatement> selectSession;
-    rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
-        "SELECT session FROM moz_historyvisits "
-        "ORDER BY visit_date DESC LIMIT 1"),
-      getter_AddRefs(selectSession));
-    NS_ENSURE_SUCCESS(rv, rv);
-    PRBool hasSession;
-    if (NS_SUCCEEDED(selectSession->ExecuteStep(&hasSession)) && hasSession)
-      mLastSessionID = selectSession->AsInt64(0);
-    else
-      mLastSessionID = 1;
-  }
-
   // recent events hash tables
   NS_ENSURE_TRUE(mRecentTyped.Init(128), NS_ERROR_OUT_OF_MEMORY);
   NS_ENSURE_TRUE(mRecentBookmark.Init(128), NS_ERROR_OUT_OF_MEMORY);
   NS_ENSURE_TRUE(mRecentRedirects.Init(128), NS_ERROR_OUT_OF_MEMORY);
 
   /*****************************************************************************
    *** IMPORTANT NOTICE!
    ***
    *** Nothing after these add observer calls should return anything but NS_OK.
    *** If a failure code is returned, this nsNavHistory object will be held onto
    *** by the observer service and the preference service. 
    ****************************************************************************/
 
-  nsCOMPtr<nsIObserverService> observerService =
-    do_GetService("@mozilla.org/observer-service;1", &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   nsCOMPtr<nsIPrefBranch2> pbi = do_QueryInterface(mPrefBranch);
   if (pbi) {
     pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_DAYS_MAX, this, PR_FALSE);
     pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_DAYS_MIN, this, PR_FALSE);
     pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_SITES, this, PR_FALSE);
   }
 
-  observerService->AddObserver(this, gXpcomShutdown, PR_FALSE);
-  observerService->AddObserver(this, gAutoCompleteFeedback, PR_FALSE);
-  observerService->AddObserver(this, gIdleDaily, PR_FALSE);
-  observerService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_FALSE);
+  nsCOMPtr<nsIObserverService> obsSvc =
+    do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
+  if (obsSvc) {
+    (void)obsSvc->AddObserver(this, TOPIC_XPCOM_SHUTDOWN, PR_FALSE);
+    (void)obsSvc->AddObserver(this, TOPIC_IDLE_DAILY, PR_FALSE);
+    (void)obsSvc->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_FALSE);
+#ifdef MOZ_XUL
+    (void)obsSvc->AddObserver(this, TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING, PR_FALSE);
+#endif
+  }
+
   // In case we've either imported or done a migration from a pre-frecency
   // build, we will calculate the first cutoff period's frecencies once the rest
   // of the places infrastructure has been initialized.
   if (mDatabaseStatus == DATABASE_STATUS_CREATE ||
       mDatabaseStatus == DATABASE_STATUS_UPGRADED) {
-    (void)observerService->AddObserver(this, PLACES_INIT_COMPLETE_TOPIC,
-                                       PR_FALSE);
-  }
-
-  /*****************************************************************************
-   *** IMPORTANT NOTICE!
-   ***
-   *** NO CODE SHOULD GO BEYOND THIS POINT THAT WOULD PROPAGATE AN ERROR.  IN
-   *** OTHER WORDS, THE ONLY THING THAT SHOULD BE RETURNED AFTER THIS POINT IS
-   *** NS_OK.
-   ****************************************************************************/
-
-  if (mDatabaseStatus == DATABASE_STATUS_CREATE) {
-    nsCOMPtr<nsIFile> historyFile;
-    rv = NS_GetSpecialDirectory(NS_APP_HISTORY_50_FILE,
-                                getter_AddRefs(historyFile));
-    if (NS_SUCCEEDED(rv) && historyFile) {
-      (void)ImportHistory(historyFile);
+    if (mDatabaseStatus == DATABASE_STATUS_CREATE) {
+      // Check if we should import old history from history.dat
+      nsCOMPtr<nsIFile> historyFile;
+      rv = NS_GetSpecialDirectory(NS_APP_HISTORY_50_FILE,
+                                  getter_AddRefs(historyFile));
+      if (NS_SUCCEEDED(rv) && historyFile) {
+        (void)ImportHistory(historyFile);
+      }
     }
+
+    // In case we've either imported or done a migration from a pre-frecency
+    // build, we will calculate the first cutoff period's frecencies once the
+    // rest of the places infrastructure has been initialized.
+    if (obsSvc)
+      (void)obsSvc->AddObserver(this, TOPIC_PLACES_INIT_COMPLETE, PR_FALSE);
   }
 
   // Don't add code that can fail here! Do it up above, before we add our
   // observers.
 
   return NS_OK;
 }
 
-// nsNavHistory::InitDBFile
+
 nsresult
 nsNavHistory::InitDBFile(PRBool aForceInit)
 {
   if (aForceInit) {
     NS_ASSERTION(mDBConn,
                  "When forcing initialization, a database connection must exist!");
     NS_ASSERTION(mDBService,
                  "When forcing initialization, the database service must exist!");
   }
 
-  // get profile dir, file
+  // Get database file handle.
   nsCOMPtr<nsIFile> profDir;
   nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
                                        getter_AddRefs(profDir));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = profDir->Clone(getter_AddRefs(mDBFile));
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = mDBFile->Append(DB_FILENAME);
+  rv = mDBFile->Append(DATABASE_FILENAME);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (aForceInit) {
     // If forcing initialization, backup and remove the old file.  If we have
     // already failed in the last 24 hours avoid to create another corrupt file,
     // since doing so, in some situation, could cause us to create a new corrupt
     // file at every try to access any Places service.  That is bad because it
     // would quickly fill the user's disk space without any notice.
     if (!hasRecentCorruptDB()) {
       // backup the database
       nsCOMPtr<nsIFile> backup;
-      rv = mDBService->BackupDatabaseFile(mDBFile, DB_CORRUPT_FILENAME, profDir,
-                                          getter_AddRefs(backup));
+      rv = mDBService->BackupDatabaseFile(mDBFile, DATABASE_CORRUPT_FILENAME,
+                                          profDir, getter_AddRefs(backup));
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     // Close database connection if open.
     // If there's any not finalized statement or this fails for any reason
     // we won't be able to remove the database.
     rv = mDBConn->Close();
     NS_ENSURE_SUCCESS(rv, rv);
@@ -596,258 +584,251 @@ nsNavHistory::InitDBFile(PRBool aForceIn
     if (NS_FAILED(rv)) {
       // If the file is still in use this will fail and we won't be able to
       // start with a clean database.  The process of backing up a corrupt
       // database will loop on the same database file at any next service
       // request.
       // We can't do much at this point, so fire a locked event so that user is
       // notified that we can't ensure Places to work.
       nsRefPtr<PlacesEvent> lockedEvent =
-        new PlacesEvent(PLACES_DB_LOCKED_TOPIC);
+        new PlacesEvent(TOPIC_DATABASE_LOCKED);
       (void)NS_DispatchToMainThread(lockedEvent);
     }
     NS_ENSURE_SUCCESS(rv, rv);
 
     // If aForceInit is true we were unable to initialize or upgrade the current
     // database, so it was corrupt.
     mDatabaseStatus = DATABASE_STATUS_CORRUPT;
   }
   else {
-    // file exists?
+    // Check if database file exists.
     PRBool dbExists = PR_TRUE;
     rv = mDBFile->Exists(&dbExists);
     NS_ENSURE_SUCCESS(rv, rv);
     // If the database didn't previously exist, we create it.
     if (!dbExists)
       mDatabaseStatus = DATABASE_STATUS_CREATE;
   }
 
-  // open the database
+  // Open the database file.  If it does not exist a new one will be created.
   mDBService = do_GetService(MOZ_STORAGE_SERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
+  // Open un unshared connection, both for safety and speed.
   rv = mDBService->OpenUnsharedDatabase(mDBFile, getter_AddRefs(mDBConn));
   if (rv == NS_ERROR_FILE_CORRUPTED) {
-    // The database is corrupt, we create a new one.
+    // The database is corrupt, try to create a new one.
     mDatabaseStatus = DATABASE_STATUS_CORRUPT;
 
-    // backup file
+    // Backup and remove old corrupt database file.
     nsCOMPtr<nsIFile> backup;
-    rv = mDBService->BackupDatabaseFile(mDBFile, DB_CORRUPT_FILENAME, profDir,
-                                        getter_AddRefs(backup));
-    NS_ENSURE_SUCCESS(rv, rv);
- 
-    // remove existing file 
+    rv = mDBService->BackupDatabaseFile(mDBFile, DATABASE_CORRUPT_FILENAME,
+                                        profDir, getter_AddRefs(backup));
+    NS_ENSURE_SUCCESS(rv, rv);
     rv = mDBFile->Remove(PR_FALSE);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    // and try again
+    // Try again to initialize the database file.
     rv = profDir->Clone(getter_AddRefs(mDBFile));
     NS_ENSURE_SUCCESS(rv, rv);
-    rv = mDBFile->Append(DB_FILENAME);
+    rv = mDBFile->Append(DATABASE_FILENAME);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = mDBService->OpenUnsharedDatabase(mDBFile, getter_AddRefs(mDBConn));
   }
  
   if (rv != NS_OK && rv != NS_ERROR_FILE_CORRUPTED) {
     // If the database cannot be opened for any reason other than corruption,
     // send out a notification and do not continue initialization.
     // Note: We swallow errors here, since we want service init to fail anyway.
     nsRefPtr<PlacesEvent> lockedEvent =
-      new PlacesEvent(PLACES_DB_LOCKED_TOPIC);
+      new PlacesEvent(TOPIC_DATABASE_LOCKED);
     (void)NS_DispatchToMainThread(lockedEvent);
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
-// nsNavHistory::InitDB
-//
-
-#define PLACES_SCHEMA_VERSION 10
 
 nsresult
 nsNavHistory::InitDB()
 {
-  PRInt32 pageSize = DEFAULT_DB_PAGE_SIZE;
-
-  // Get the places schema version, which we store in the user_version PRAGMA.
-  PRInt32 DBSchemaVersion = 0;
-  nsresult rv = mDBConn->GetSchemaVersion(&DBSchemaVersion);
-  NS_ENSURE_SUCCESS(rv, rv);
-  bool databaseInitialized = (DBSchemaVersion > 0);
+  PRInt32 pageSize = DATABASE_PAGE_SIZE;
+
+  // Get the database schema version.
+  PRInt32 currentSchemaVersion = 0;
+  nsresult rv = mDBConn->GetSchemaVersion(&currentSchemaVersion);
+  NS_ENSURE_SUCCESS(rv, rv);
+  bool databaseInitialized = (currentSchemaVersion > 0);
 
   if (!databaseInitialized) {
-    // IMPORTANT NOTE:
-    // setting page_size must happen first, see bug #401985 for details
-    //
-    // Set the database page size.
-    // This will only have any effect on empty files, so must be done before
-    // anything else. If the file already exists, we'll get that file's page
-    // size and this would have no effect.
+    // First of all we must set page_size since it will only have effect on
+    // empty files.  For existing databases we could get a different page size,
+    // trying to change it would be uneffective.
+    // See bug 401985 for details.
     nsCAutoString pageSizePragma("PRAGMA page_size = ");
     pageSizePragma.AppendInt(pageSize);
     rv = mDBConn->ExecuteSimpleSQL(pageSizePragma);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   else {
     // Get the page size.  This may be different than the default if the
     // database file already existed with a different page size.
     nsCOMPtr<mozIStorageStatement> statement;
-    rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
-        "PRAGMA page_size"),
-      getter_AddRefs(statement));
+    rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING("PRAGMA page_size"),
+                                  getter_AddRefs(statement));
     NS_ENSURE_SUCCESS(rv, rv);
 
     PRBool hasResult;
     rv = statement->ExecuteStep(&hasResult);
-    NS_ENSURE_SUCCESS(rv, rv);
-    NS_ENSURE_TRUE(hasResult, NS_ERROR_FAILURE);
+    NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && hasResult, NS_ERROR_FAILURE);
     pageSize = statement->AsInt32(0);
   }
 
   // Ensure that temp tables are held in memory, not on disk.  We use temp
   // tables mainly for fsync and I/O reduction.
   rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
       "PRAGMA temp_store = MEMORY"));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Set pragma synchronous to FULL to ensure maximum data integrity, even in
   // case of crashes or unclean shutdowns.
-  // The suggested setting from SQLite is FULL, but Storage defaults to NORMAL.
+  // The suggested setting for SQLite is FULL, but Storage defaults to NORMAL.
   rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
       "PRAGMA synchronous = FULL"));
   NS_ENSURE_SUCCESS(rv, rv);
 
-
-  // Compute the size of the database cache.
+  // Compute the size of the database cache using the device's memory size.
+  // We don't use PRAGMA default_cache_size, since the database could be moved
+  // among different devices and the value would adapt accordingly.
+  nsCOMPtr<nsIPrefBranch> prefs =
+    do_GetService("@mozilla.org/preferences-service;1");
+  NS_WARN_IF_FALSE(prefs, "Unable to get the preferences service");
   PRInt32 cachePercentage;
-  if (NS_FAILED(mPrefBranch->GetIntPref(PREF_DB_CACHE_PERCENTAGE,
-                                        &cachePercentage)))
-    cachePercentage = DEFAULT_DB_CACHE_PERCENTAGE;
+  if (!prefs || NS_FAILED(prefs->GetIntPref(PREF_CACHE_TO_MEMORY_PERCENTAGE,
+                                            &cachePercentage)))
+    cachePercentage = DATABASE_DEFAULT_CACHE_TO_MEMORY_PERCENTAGE;
+  // Sanity checks, we allow values between 0 (disable cache) and 50%.
   if (cachePercentage > 50)
-    cachePercentage = 50; // sanity check, don't take too much
+    cachePercentage = 50;
   if (cachePercentage < 0)
     cachePercentage = 0;
   PRInt64 cacheSize = PR_GetPhysicalMemorySize() * cachePercentage / 100;
+
+  // Compute number of cached pages, this will be our cache size.
   PRInt64 cachePages = cacheSize / pageSize;
-
-  // Set the cache size.  We don't use default_cache_size so the database can
-  // be moved between computers and the value will change dynamically.
   nsCAutoString pageSizePragma("PRAGMA cache_size = ");
   pageSizePragma.AppendInt(cachePages);
   rv = mDBConn->ExecuteSimpleSQL(pageSizePragma);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // Lock the db file.  This is done partly to avoid third party applications
-  // to access the database while it's in use, partly for performance reasons.
-  // http://www.sqlite.org/pragma.html#pragma_locking_mode
+  // Lock the database file.  This is done partly to avoid third party
+  // applications to access it while it's in use, partly for performance.
   rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
       "PRAGMA locking_mode = EXCLUSIVE"));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
-      "PRAGMA journal_mode = " DEFAULT_JOURNAL_MODE));
+      "PRAGMA journal_mode = " DATABASE_JOURNAL_MODE));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // We are going to initialize tables, so everything from now on should be in
   // a transaction for performances.
   mozStorageTransaction transaction(mDBConn, PR_FALSE);
 
-  // Initialize the other places services' database tables. We do this before
-  // creating our statements. Some of our statements depend on these external
-  // tables, such as the bookmarks or favicon tables.
+  // Initialize the other Places services' database tables before creating our
+  // statements. Some of our statements depend on these external tables, such as
+  // the bookmarks or favicon tables.
   rv = nsNavBookmarks::InitTables(mDBConn);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = nsFaviconService::InitTables(mDBConn);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = nsAnnotationService::InitTables(mDBConn);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!databaseInitialized) {
     // This is the first run, so we set schema version to the latest one, since
     // we don't need to migrate anything.  We will create tables from scratch.
     rv = UpdateSchemaVersion();
     NS_ENSURE_SUCCESS(rv, rv);
-    DBSchemaVersion = PLACES_SCHEMA_VERSION;
-  }
-
-  if (PLACES_SCHEMA_VERSION != DBSchemaVersion) {
+    currentSchemaVersion = DATABASE_SCHEMA_VERSION;
+  }
+
+  if (DATABASE_SCHEMA_VERSION != currentSchemaVersion) {
     // Migration How-to:
     //
     // 1. increment PLACES_SCHEMA_VERSION.
     // 2. implement a method that performs up/sidegrade to your version
     //    from the current version.
     //
     // NOTE: We don't support downgrading back to History-only Places.
     // If you want to go from newer schema version back to V0, you'll need to
     // blow away your sqlite file. Subsequent up/downgrades have backwards and
     // forward migration code.
     //
     // XXX Backup places.sqlite to places-{version}.sqlite when doing db migration?
     
-    if (DBSchemaVersion < PLACES_SCHEMA_VERSION) {
-      // Upgrading
+    if (currentSchemaVersion < DATABASE_SCHEMA_VERSION) {
+      // Upgrading.
       mDatabaseStatus = DATABASE_STATUS_UPGRADED;
 
       // Migrate anno tables up to V3
-      if (DBSchemaVersion < 3) {
+      if (currentSchemaVersion < 3) {
         rv = MigrateV3Up(mDBConn);
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
       // Migrate bookmarks tables up to V5
-      if (DBSchemaVersion < 5) {
+      if (currentSchemaVersion < 5) {
         rv = ForceMigrateBookmarksDB(mDBConn);
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
       // Migrate anno tables up to V6
-      if (DBSchemaVersion < 6) {
+      if (currentSchemaVersion < 6) {
         rv = MigrateV6Up(mDBConn);
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
       // Migrate historyvisits and bookmarks up to V7
-      if (DBSchemaVersion < 7) {
+      if (currentSchemaVersion < 7) {
         rv = MigrateV7Up(mDBConn);
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
       // Migrate historyvisits up to V8
-      if (DBSchemaVersion < 8) {
+      if (currentSchemaVersion < 8) {
         rv = MigrateV8Up(mDBConn);
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
       // Migrate places up to V9
-      if (DBSchemaVersion < 9) {
+      if (currentSchemaVersion < 9) {
         rv = MigrateV9Up(mDBConn);
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
       // Migrate places up to V10
-      if (DBSchemaVersion < 10) {
+      if (currentSchemaVersion < 10) {
         rv = MigrateV10Up(mDBConn);
         NS_ENSURE_SUCCESS(rv, rv);
       }
 
       // Schema Upgrades must add migration code here.
 
     } else {
       // Downgrading
 
       // XXX Need to prompt user or otherwise notify of 
       // potential dataloss when downgrading.
 
       // XXX Downgrades from >V6 must add migration code here.
 
       // Downgrade v1,2,4,5
       // v3,6 have no backwards incompatible changes.
-      if (DBSchemaVersion > 2 && DBSchemaVersion < 6) {
+      if (currentSchemaVersion > 2 && currentSchemaVersion < 6) {
         // perform downgrade to v2
         rv = ForceMigrateBookmarksDB(mDBConn);
         NS_ENSURE_SUCCESS(rv, rv);
       }
     }
 
     // Update schema version to the current one.
     rv = UpdateSchemaVersion();
@@ -904,52 +885,55 @@ nsNavHistory::InitDB()
   // ANY FAILURE IN THIS METHOD WILL CAUSE US TO MARK THE DATABASE AS CORRUPT
   // AND TRY TO REPLACE IT.
   // DO NOT PUT HERE ANYTHING THAT IS NOT RELATED TO INITIALIZATION OR MODIFYING
   // THE DISK DATABASE.
 
   return NS_OK;
 }
 
+
 nsresult
 nsNavHistory::InitAdditionalDBItems()
 {
   nsresult rv = InitTempTables();
   NS_ENSURE_SUCCESS(rv, rv);
   rv = InitViews();
   NS_ENSURE_SUCCESS(rv, rv);
   rv = InitFunctions();
   NS_ENSURE_SUCCESS(rv, rv);
   rv = InitStatements();
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
+
 NS_IMETHODIMP
 nsNavHistory::GetDatabaseStatus(PRUint16 *aDatabaseStatus)
 {
   NS_ENSURE_ARG_POINTER(aDatabaseStatus);
   *aDatabaseStatus = mDatabaseStatus;
   return NS_OK;
 }
 
-// nsNavHistory::UpdateSchemaVersion
-//
-// Called by the individual services' InitTables()
+
+/**
+ * Called by the individual services' InitTables().
+ */
 nsresult
 nsNavHistory::UpdateSchemaVersion()
 {
-  return mDBConn->SetSchemaVersion(PLACES_SCHEMA_VERSION);
-}
-
-// nsNavHistory::InitFunctions
-//
-//    Called after InitDB, this creates our own functions
-
+  return mDBConn->SetSchemaVersion(DATABASE_SCHEMA_VERSION);
+}
+
+
+/**
+ * Called after InitDB, this creates our own functions
+ */
 class mozStorageFunctionGetUnreversedHost: public mozIStorageFunction
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_MOZISTORAGEFUNCTION
 };
 
 NS_IMPL_ISUPPORTS1(mozStorageFunctionGetUnreversedHost, mozIStorageFunction)
@@ -1071,20 +1055,20 @@ nsNavHistory::InitFunctions()
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = MatchAutoCompleteFunction::create(mDBConn);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
-// nsNavHistory::InitStatements
-//
-//    Called after InitDB, this creates our stored statements
-
+
+/**
+ * Called after InitDB, this creates our stored statements.
+ */
 nsresult
 nsNavHistory::InitStatements()
 {
   // mDBGetURLPageInfo
   // We are not checking for duplicated ids into the unified table
   // for perf reasons, LIMIT 1 will discard duplicates faster since we
   // have unique urls.
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
@@ -1327,24 +1311,25 @@ nsNavHistory::InitStatements()
         "(SELECT COUNT(*) FROM moz_historyvisits_temp WHERE place_id = ?1 "
             "AND id NOT IN (SELECT id FROM moz_historyvisits))"),
     getter_AddRefs(mDBFullVisitCount));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
-// nsNavHistory::ForceMigrateBookmarksDB
-//
-//    This dumps all bookmarks-related tables, and recreates them,
-//    forcing a re-import of bookmarks.html.
-//
-//    NOTE: This may cause data-loss if downgrading!
-//    Only use this for migration if you're sure that bookmarks.html
-//    and the target version support all bookmarks fields.
+
+/**
+ * This dumps all bookmarks-related tables, and recreates them,
+ * forcing a re-import of bookmarks.html.
+ *
+ * @note This may cause data-loss if downgrading!
+ *       Only use this for migration if you're sure that bookmarks.html
+ *       and the target version support all bookmarks fields.
+ */
 nsresult
 nsNavHistory::ForceMigrateBookmarksDB(mozIStorageConnection* aDBConn) 
 {
   // drop bookmarks tables
   nsresult rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
       "DROP TABLE IF EXISTS moz_bookmarks"));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
@@ -1364,17 +1349,17 @@ nsNavHistory::ForceMigrateBookmarksDB(mo
   // We have done a new database init, so we mark this as if the database has
   // been created now, so the frontend can distinguish this status and import
   // if needed.
   mDatabaseStatus = DATABASE_STATUS_CREATE;
 
   return NS_OK;
 }
 
-// nsNavHistory::MigrateV3Up
+
 nsresult
 nsNavHistory::MigrateV3Up(mozIStorageConnection* aDBConn) 
 {
   // if type col is already there, then a partial update occurred.
   // return, making no changes, and allowing db version to be updated.
   nsCOMPtr<mozIStorageStatement> statement;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
       "SELECT type from moz_annos"),
@@ -1392,17 +1377,17 @@ nsNavHistory::MigrateV3Up(mozIStorageCon
     NS_ENSURE_SUCCESS(rv, rv);
     rv = nsAnnotationService::InitTables(mDBConn);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
 
-// nsNavHistory::MigrateV6Up
+
 nsresult
 nsNavHistory::MigrateV6Up(mozIStorageConnection* aDBConn) 
 {
   mozStorageTransaction transaction(aDBConn, PR_FALSE);
 
   // if dateAdded & lastModified cols are already there, then a partial update occurred,
   // and so we should not attempt to add these cols.
   nsCOMPtr<mozIStorageStatement> statement;
@@ -1522,17 +1507,17 @@ nsNavHistory::MigrateV6Up(mozIStorageCon
     rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
         "DROP TABLE moz_places_backup"));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return transaction.Commit();
 }
 
-// nsNavHistory::MigrateV7Up
+
 nsresult
 nsNavHistory::MigrateV7Up(mozIStorageConnection* aDBConn) 
 {
   mozStorageTransaction transaction(aDBConn, PR_FALSE);
 
   // We need an index on lastModified to catch quickly last modified bookmark
   // title for tag container's children. This will be useful for sync too.
   PRBool lastModIndexExists = PR_FALSE;
@@ -1685,16 +1670,17 @@ nsNavHistory::MigrateV7Up(mozIStorageCon
     // Now we create our trigger
     rv = aDBConn->ExecuteSimpleSQL(CREATE_KEYWORD_VALIDITY_TRIGGER);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return transaction.Commit();
 }
 
+
 nsresult
 nsNavHistory::MigrateV8Up(mozIStorageConnection *aDBConn)
 {
   mozStorageTransaction transaction(aDBConn, PR_FALSE);
 
   nsresult rv = aDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
       "DROP TRIGGER IF EXISTS moz_historyvisits_afterinsert_v1_trigger"));
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1735,16 +1721,17 @@ nsNavHistory::MigrateV8Up(mozIStorageCon
     // create new item annos index
     rv = mDBConn->ExecuteSimpleSQL(CREATE_IDX_MOZ_ITEMSANNOS_PLACEATTRIBUTE);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return transaction.Commit();
 }
 
+
 nsresult
 nsNavHistory::MigrateV9Up(mozIStorageConnection *aDBConn)
 {
   mozStorageTransaction transaction(aDBConn, PR_FALSE);
   // Added in Bug 488966.  The last_visit_date column caches the last
   // visit date, this enhances SELECT performances when we
   // need to sort visits by visit date.
   // The cached value is synced by INSERT and DELETE triggers on
@@ -1780,23 +1767,24 @@ nsNavHistory::MigrateV9Up(mozIStorageCon
         "UPDATE moz_places SET last_visit_date = "
           "(SELECT MAX(visit_date) "
            "FROM moz_historyvisits "
            "WHERE place_id = moz_places.id)"));
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Restore the default journal mode.
     rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
-        "PRAGMA journal_mode = " DEFAULT_JOURNAL_MODE));
+        "PRAGMA journal_mode = " DATABASE_JOURNAL_MODE));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return transaction.Commit();
 }
 
+
 nsresult
 nsNavHistory::MigrateV10Up(mozIStorageConnection *aDBConn)
 {
   // LastModified is set to the same value as dateAdded on item creation.
   // This way we can use lastModified index to sort.
   nsresult rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
       "UPDATE moz_bookmarks SET lastModified = dateAdded "
       "WHERE lastModified IS NULL"));
@@ -1869,17 +1857,17 @@ nsNavHistory::InternalAddNewPage(nsIURI*
   NS_ENSURE_SUCCESS(rv, rv);
 
   // title
   if (aTitle.IsVoid()) {
     rv = mDBAddNewPage->BindNullParameter(1);
   }
   else {
     rv = mDBAddNewPage->BindStringParameter(1,
-        StringHead(aTitle, HISTORY_TITLE_LENGTH_MAX));
+        StringHead(aTitle, TITLE_LENGTH_MAX));
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   // host (reversed with trailing period)
   nsAutoString revHost;
   rv = GetReversedHostname(aURI, revHost);
   // Not all URI types have hostnames, so this is optional.
   if (NS_SUCCEEDED(rv)) {
@@ -2037,18 +2025,16 @@ PRBool nsNavHistory::IsURIStringVisited(
 
   PRBool hasMore = PR_FALSE;
   rv = mDBIsPageVisited->ExecuteStep(&hasMore);
   NS_ENSURE_SUCCESS(rv, PR_FALSE);
   return hasMore;
 }
 
 
-// nsNavHistory::LoadPrefs
-
 nsresult
 nsNavHistory::LoadPrefs(PRBool aInitializing)
 {
   if (! mPrefBranch)
     return NS_OK;
 
   mPrefBranch->GetIntPref(PREF_BROWSER_HISTORY_EXPIRE_DAYS_MAX, &mExpireDaysMax);
   mPrefBranch->GetIntPref(PREF_BROWSER_HISTORY_EXPIRE_DAYS_MIN, &mExpireDaysMin);
@@ -2103,50 +2089,98 @@ nsNavHistory::LoadPrefs(PRBool aInitiali
       &mFourthBucketWeight);
     prefs->GetIntPref(PREF_FRECENCY_DEFAULT_BUCKET_WEIGHT, 
       &mDefaultWeight);
   }
   return NS_OK;
 }
 
 
-// nsNavHistory::GetNow
-//
-//    This is a hack to avoid calling PR_Now() too often, as is the case when
-//    we're asked the ageindays of many history entries in a row. A timer is
-//    set which will clear our valid flag after a short timeout.
+PRInt64
+nsNavHistory::GetNewSessionID()
+{
+  // Use cached value if already initialized.
+  if (mLastSessionID)
+    return ++mLastSessionID;
+
+  // Extract the last session ID, so we know where to pick up. There is no
+  // index over sessions so we use the visit_date index.
+  // This happens on the first visit, so we don't care about temp tables.
+  nsCOMPtr<mozIStorageStatement> selectSession;
+  nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
+      "SELECT session FROM moz_historyvisits "
+      "ORDER BY visit_date DESC LIMIT 1"),
+    getter_AddRefs(selectSession));
+  NS_ENSURE_SUCCESS(rv, rv);
+  PRBool hasSession;
+  if (NS_SUCCEEDED(selectSession->ExecuteStep(&hasSession)) && hasSession)
+    mLastSessionID = selectSession->AsInt64(0) + 1;
+  else
+    mLastSessionID = 1;
+
+  return mLastSessionID;
+}
+
+
+PRInt32
+nsNavHistory::GetDaysOfHistory() {
+  PRInt32 daysOfHistory = 0;
+  nsCOMPtr<mozIStorageStatement> statement;
+  nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
+      "SELECT ROUND(( "
+        "strftime('%s','now','localtime','utc') - "
+        "( "
+          "SELECT visit_date FROM moz_historyvisits "
+          "UNION ALL "
+          "SELECT visit_date FROM moz_historyvisits_temp "
+          "ORDER BY visit_date ASC LIMIT 1 "
+        ")/1000000 "
+      ")/86400) AS daysOfHistory "),
+    getter_AddRefs(statement));
+  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to create statement.");
+  NS_ENSURE_SUCCESS(rv, 0);
+  PRBool hasResult;
+  if (NS_SUCCEEDED(statement->ExecuteStep(&hasResult)) && hasResult)
+    statement->GetInt32(0, &daysOfHistory);
+
+  return daysOfHistory;
+}
+
 
 PRTime
 nsNavHistory::GetNow()
 {
-  if (!mNowValid) {
-    mLastNow = PR_Now();
-    mNowValid = PR_TRUE;
+  if (!mCachedNow) {
+    mCachedNow = PR_Now();
     if (!mExpireNowTimer)
       mExpireNowTimer = do_CreateInstance("@mozilla.org/timer;1");
-
     if (mExpireNowTimer)
       mExpireNowTimer->InitWithFuncCallback(expireNowTimerCallback, this,
-                                            HISTORY_EXPIRE_NOW_TIMEOUT,
+                                            RENEW_CACHED_NOW_TIMEOUT,
                                             nsITimer::TYPE_ONE_SHOT);
   }
-
-  return mLastNow;
-}
-
-
-// nsNavHistory::expireNowTimerCallback
+  return mCachedNow;
+}
+
 
 void nsNavHistory::expireNowTimerCallback(nsITimer* aTimer, void* aClosure)
 {
   nsNavHistory *history = static_cast<nsNavHistory *>(aClosure);
-  history->mNowValid = PR_FALSE;
-  history->mExpireNowTimer = nsnull;
-}
-
+  if (history) {
+    history->mCachedNow = 0;
+    history->mExpireNowTimer = 0;
+  }
+}
+
+
+/**
+ * Code borrowed from mozilla/xpfe/components/history/src/nsGlobalHistory.cpp
+ * Pass in a pre-normalized now and a date, and we'll find the difference since
+ * midnight on each of the days.
+ */
 static PRTime
 NormalizeTimeRelativeToday(PRTime aTime)
 {
   // round to midnight this morning
   PRExplodedTime explodedTime;
   PR_ExplodeTime(aTime, PR_LocalTimeParameters, &explodedTime);
 
   // set to midnight (0:00)
@@ -2770,17 +2804,17 @@ nsNavHistory::AddVisit(nsIURI* aURI, PRT
 
   // Normally docshell sends the link visited observer notification for us (this
   // will tell all the documents to update their visited link coloring).
   // However, for redirects (since we implement nsIGlobalHistory3) and downloads
   // (since we implement nsIDownloadHistory) this will not happen and we need to
   // send it ourselves.
   if (newItem && (aIsRedirect || aTransitionType == TRANSITION_DOWNLOAD)) {
     nsCOMPtr<nsIObserverService> obsService =
-      do_GetService("@mozilla.org/observer-service;1");
+      do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
     if (obsService)
       obsService->NotifyObservers(aURI, NS_LINK_VISITED_EVENT_TOPIC, nsnull);
   }
 
   return NS_OK;
 }
 
 
@@ -3052,28 +3086,28 @@ private:
   nsNavHistory::StringHash& mAddParams;
 };
 
 PlacesSQLQueryBuilder::PlacesSQLQueryBuilder(
     const nsCString& aConditions, 
     nsNavHistoryQueryOptions* aOptions, 
     PRBool aUseLimit,
     nsNavHistory::StringHash& aAddParams,
-    PRBool aHasSearchTerms) :
-  mConditions(aConditions),
-  mUseLimit(aUseLimit),
-  mResultType(aOptions->ResultType()),
-  mQueryType(aOptions->QueryType()),
-  mIncludeHidden(aOptions->IncludeHidden()),
-  mRedirectsMode(aOptions->RedirectsMode()),
-  mSortingMode(aOptions->SortingMode()),
-  mMaxResults(aOptions->MaxResults()),
-  mSkipOrderBy(PR_FALSE),
-  mAddParams(aAddParams),
-  mHasSearchTerms(aHasSearchTerms)
+    PRBool aHasSearchTerms)
+: mConditions(aConditions)
+, mUseLimit(aUseLimit)
+, mHasSearchTerms(aHasSearchTerms)
+, mResultType(aOptions->ResultType())
+, mQueryType(aOptions->QueryType())
+, mIncludeHidden(aOptions->IncludeHidden())
+, mRedirectsMode(aOptions->RedirectsMode())
+, mSortingMode(aOptions->SortingMode())
+, mMaxResults(aOptions->MaxResults())
+, mSkipOrderBy(PR_FALSE)
+, mAddParams(aAddParams)
 {
   mHasDateColumns = (mQueryType == nsINavHistoryQueryOptions::QUERY_TYPE_BOOKMARKS);
 }
 
 nsresult
 PlacesSQLQueryBuilder::GetQueryString(nsCString& aQueryString)
 {
   nsresult rv = Select();
@@ -3351,35 +3385,36 @@ PlacesSQLQueryBuilder::SelectAsDay()
   // Sort child queries based on sorting mode if it's provided, otherwise
   // fallback to default sort by title ascending.
   PRUint16 sortingMode = nsINavHistoryQueryOptions::SORT_BY_TITLE_ASCENDING;
   if (mSortingMode != nsINavHistoryQueryOptions::SORT_BY_NONE &&
       mResultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_QUERY)
     sortingMode = mSortingMode;
 
   PRUint16 resultType =
-    mResultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_QUERY ?
-                   nsINavHistoryQueryOptions::RESULTS_AS_URI :
-                   nsINavHistoryQueryOptions::RESULTS_AS_SITE_QUERY;
+    (mResultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_QUERY) ?
+      nsINavHistoryQueryOptions::RESULTS_AS_URI :
+      nsINavHistoryQueryOptions::RESULTS_AS_SITE_QUERY;
 
   // beginTime will become the node's time property, we don't use endTime
   // because it could overlap, and we use time to sort containers and find
   // insert position in a result.
   mQueryString = nsPrintfCString(1024,
      "SELECT null, "
        "'place:type=%ld&sort=%ld&beginTime='||beginTime||'&endTime='||endTime, "
       "dayTitle, null, null, beginTime, null, null, null, null, null, null "
      "FROM (", // TOUTER BEGIN
      resultType,
      sortingMode);
  
    nsNavHistory *history = nsNavHistory::GetHistoryService();
    NS_ENSURE_STATE(history);
 
-  for (PRInt32 i = 0; i <= DATE_CONT_NUM(history->mExpireDaysMax); i++) {
+  PRInt32 daysOfHistory = history->GetDaysOfHistory();
+  for (PRInt32 i = 0; i <= HISTORY_DATE_CONT_NUM(daysOfHistory); i++) {
     nsCAutoString dateName;
     // Timeframes are calculated as BeginTime <= container < EndTime.
     // Notice times can't be relative to now, since to recognize a query we
     // must ensure it won't change based on the time it is built.
     // So, to select till now, we really select till start of tomorrow, that is
     // a fixed timestamp.
     // These are used as limits for the inside containers.
     nsCAutoString sqlFragmentContainerBeginTime, sqlFragmentContainerEndTime;
@@ -3442,32 +3477,32 @@ PlacesSQLQueryBuilder::SelectAsDay()
           "(strftime('%s','now','localtime','start of day','+1 day','utc')*1000000)");
         // This is an overlapped container, but we show it only if there are
         // visits older than 7 days ago.
         sqlFragmentSearchBeginTime = sqlFragmentContainerBeginTime;
         sqlFragmentSearchEndTime = NS_LITERAL_CSTRING(
           "(strftime('%s','now','localtime','start of day','-7 days','utc')*1000000)");
          break;
        default:
-        if (i == ADDITIONAL_DATE_CONT_NUM + 6) {
+        if (i == HISTORY_ADDITIONAL_DATE_CONT_NUM + 6) {
           // Older than 6 months
           history->GetAgeInDaysString(6,
             NS_LITERAL_STRING("finduri-AgeInMonths-isgreater").get(), dateName);
           // From start of epoch
           sqlFragmentContainerBeginTime = NS_LITERAL_CSTRING(
             "(datetime(0, 'unixepoch')*1000000)");
           // To start of 6 months ago ( 5 months + this month).
           sqlFragmentContainerEndTime = NS_LITERAL_CSTRING(
             "(strftime('%s','now','localtime','start of month','-5 months','utc')*1000000)");
           // Search for the same timeframe.
           sqlFragmentSearchBeginTime = sqlFragmentContainerBeginTime;
           sqlFragmentSearchEndTime = sqlFragmentContainerEndTime;
           break;
         }
-        PRInt32 MonthIndex = i - ADDITIONAL_DATE_CONT_NUM;
+        PRInt32 MonthIndex = i - HISTORY_ADDITIONAL_DATE_CONT_NUM;
         // Previous months' titles are month's name if inside this year,
         // month's name and year for previous years.
         PRExplodedTime tm;
         PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &tm);
         PRUint16 currentYear = tm.tm_year;
         // Set day before month, setting month without day could cause issues.
         // For example setting month to February when today is 30, since
         // February has not 30 days, will return March instead.
@@ -3527,18 +3562,18 @@ PlacesSQLQueryBuilder::SelectAsDay()
       sqlFragmentSearchEndTime.get(),
        nsINavHistoryService::TRANSITION_EMBED,
       sqlFragmentSearchBeginTime.get(),
       sqlFragmentSearchEndTime.get(),
       nsINavHistoryService::TRANSITION_EMBED);
 
     mQueryString.Append(dayRange);
 
-    if (i < DATE_CONT_NUM(history->mExpireDaysMax))
-        mQueryString.Append(NS_LITERAL_CSTRING(" UNION ALL "));
+    if (i < HISTORY_DATE_CONT_NUM(daysOfHistory))
+      mQueryString.Append(NS_LITERAL_CSTRING(" UNION ALL "));
   }
 
   mQueryString.Append(NS_LITERAL_CSTRING(") ")); // TOUTER END
 
   return NS_OK;
 }
 
 nsresult
@@ -4109,17 +4144,17 @@ nsNavHistory::GetQueryResults(nsNavHisto
   NS_ENSURE_ARG_POINTER(aOptions);
   NS_ASSERTION(aResults->Count() == 0, "Initial result array must be empty");
   if (! aQueries.Count())
     return NS_ERROR_INVALID_ARG;
 
   nsCString queryString;
   PRBool paramsPresent = PR_FALSE;
   nsNavHistory::StringHash addParams;
-  addParams.Init(DATE_CONT_NUM(mExpireDaysMax));
+  addParams.Init(HISTORY_DATE_CONT_MAX);
   nsresult rv = ConstructQueryString(aQueries, aOptions, queryString, 
                                      paramsPresent, addParams);
   NS_ENSURE_SUCCESS(rv,rv);
 
   // create statement
   nsCOMPtr<mozIStorageStatement> statement;
   rv = mDBConn->CreateStatement(queryString, getter_AddRefs(statement));
 #ifdef DEBUG
@@ -5406,17 +5441,18 @@ nsNavHistory::AddDownload(nsIURI* aSourc
 NS_IMETHODIMP
 nsNavHistory::GetDBConnection(mozIStorageConnection **_DBConnection)
 {
   NS_ENSURE_ARG_POINTER(_DBConnection);
   NS_ADDREF(*_DBConnection = mDBConn);
   return NS_OK;
 }
 
-NS_HIDDEN_(nsresult)
+
+nsresult
 nsNavHistory::FinalizeInternalStatements()
 {
   NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
 
   // nsNavHistory
   nsresult rv = FinalizeStatements();
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -5461,40 +5497,42 @@ nsNavHistory::NotifyOnPageExpired(nsIURI
 // nsIObserver *****************************************************************
 
 NS_IMETHODIMP
 nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic,
                     const PRUnichar *aData)
 {
   NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
 
-  if (strcmp(aTopic, gXpcomShutdown) == 0) {
+  if (strcmp(aTopic, TOPIC_XPCOM_SHUTDOWN) == 0) {
     nsCOMPtr<nsIObserverService> os =
-      do_GetService("@mozilla.org/observer-service;1");
+      do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
     if (os) {
-      os->RemoveObserver(this, gAutoCompleteFeedback);
       os->RemoveObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC);
-      os->RemoveObserver(this, gIdleDaily);
-      os->RemoveObserver(this, gXpcomShutdown);
+      os->RemoveObserver(this, TOPIC_IDLE_DAILY);
+      os->RemoveObserver(this, TOPIC_XPCOM_SHUTDOWN);
+#ifdef MOZ_XUL
+      os->RemoveObserver(this, TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING);
+#endif
     }
 
     // If xpcom-shutdown is called in the same scope as the service init, we
-    // should Immediately serve topics we generated, this way they won't try to
-    // access the database later.
+    // should immediately serve the places-init topic, this way topic observers
+    // won't try to access the database after xpcom-shutdown.
     nsCOMPtr<nsISimpleEnumerator> e;
-    nsresult rv = os->EnumerateObservers(PLACES_INIT_COMPLETE_TOPIC,
+    nsresult rv = os->EnumerateObservers(TOPIC_PLACES_INIT_COMPLETE,
                                          getter_AddRefs(e));
     if (NS_SUCCEEDED(rv) && e) {
       nsCOMPtr<nsIObserver> observer;
       PRBool loop = PR_TRUE;
       while(NS_SUCCEEDED(e->HasMoreElements(&loop)) && loop)
       {
         e->GetNext(getter_AddRefs(observer));
         rv = observer->Observe(observer,
-                               PLACES_INIT_COMPLETE_TOPIC,
+                               TOPIC_PLACES_INIT_COMPLETE,
                                nsnull);
       }
     }
 
     nsCOMPtr<nsIPrefService> prefService =
       do_GetService(NS_PREFSERVICE_CONTRACTID);
     if (prefService)
       prefService->SavePrefFile(nsnull);
@@ -5517,17 +5555,17 @@ nsNavHistory::Observe(nsISupports *aSubj
     // Finalize all statements.
     rv = FinalizeInternalStatements();
     NS_ENSURE_SUCCESS(rv, rv);
 
     // NOTE: We don't close the connection because the sync service could still
     // need it for a final flush.
   }
 #ifdef MOZ_XUL
-  else if (strcmp(aTopic, gAutoCompleteFeedback) == 0) {
+  else if (strcmp(aTopic, TOPIC_AUTOCOMPLETE_FEEDBACK_INCOMING) == 0) {
     nsCOMPtr<nsIAutoCompleteInput> input = do_QueryInterface(aSubject);
     if (!input)
       return NS_OK;
 
     nsCOMPtr<nsIAutoCompletePopup> popup;
     input->GetPopup(getter_AddRefs(popup));
     if (!popup)
       return NS_OK;
@@ -5550,26 +5588,26 @@ nsNavHistory::Observe(nsISupports *aSubj
     NS_ENSURE_SUCCESS(rv, rv);
     if (selectedIndex == -1)
       return NS_OK;
 
     rv = AutoCompleteFeedback(selectedIndex, controller);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 #endif
-  else if (strcmp(aTopic, "nsPref:changed") == 0) {
+  else if (strcmp(aTopic, TOPIC_PREF_CHANGED) == 0) {
     PRInt32 oldDaysMin = mExpireDaysMin;
     PRInt32 oldDaysMax = mExpireDaysMax;
     PRInt32 oldVisits = mExpireSites;
     LoadPrefs(PR_FALSE);
     if (oldDaysMin != mExpireDaysMin || oldDaysMax != mExpireDaysMax ||
         oldVisits != mExpireSites)
       mExpire->OnExpirationChanged();
   }
-  else if (strcmp(aTopic, gIdleDaily) == 0) {
+  else if (strcmp(aTopic, TOPIC_IDLE_DAILY) == 0) {
     // Ensure our connection is still alive.  The idle-daily observer is removed
     // on xpcom-shutdown, but we could have closed the connection earlier due
     // to errors or during normal shutdown process.
     NS_ENSURE_TRUE(mDBConn, NS_OK);
 
     (void)DecayFrecency();
     (void)VacuumDatabase();
   }
@@ -5592,31 +5630,32 @@ nsNavHistory::Observe(nsISupports *aSubj
       // added before leaving the private browsing mode, and is going to be
       // scheduled to be processed after leaving the private browsing mode.
       CommitLazyMessages();
 #endif
 
       mInPrivateBrowsing = PR_FALSE;
     }
   }
-  else if (strcmp(aTopic, PLACES_INIT_COMPLETE_TOPIC) == 0) {
+  else if (strcmp(aTopic, TOPIC_PLACES_INIT_COMPLETE) == 0) {
     nsCOMPtr<nsIObserverService> os =
-      do_GetService("@mozilla.org/observer-service;1");
+      do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
     NS_ENSURE_TRUE(os, NS_ERROR_FAILURE);
-    (void)os->RemoveObserver(this, PLACES_INIT_COMPLETE_TOPIC);
+    (void)os->RemoveObserver(this, TOPIC_PLACES_INIT_COMPLETE);
 
     // This code is only called if we've either imported or done a migration
     // from a pre-frecency build, so we will calculate all their frecencies.
     (void)FixInvalidFrecencies();
   }
 
   return NS_OK;
 }
 
-NS_HIDDEN_(nsresult)
+
+nsresult
 nsNavHistory::VacuumDatabase()
 {
   // SQLite cannot give us a real value for fragmentation percentage,
   // we could analyze the database file page by page, and count fragmented
   // space, but that would be slow and not maintainable across different SQLite
   // versions.
   // For this reason we just take a guess using the freelist count.
   // This way we know how much pages are unused, but we don't know anything
@@ -5632,18 +5671,18 @@ nsNavHistory::VacuumDatabase()
   if (NS_SUCCEEDED(prefSvc->GetIntPref(PREF_LAST_VACUUM, &lastVacuumPref))) {
     // Value are seconds till epoch, convert it to microseconds.
     lastVacuumTime = (PRInt64)lastVacuumPref * PR_USEC_PER_SEC;
   }
 
   nsresult rv;
   float freePagesRatio = 0;
   if (!lastVacuumTime ||
-      (lastVacuumTime < (PR_Now() - MIN_TIME_BEFORE_VACUUM) &&
-       lastVacuumTime > (PR_Now() - MAX_TIME_BEFORE_VACUUM))) {
+      (lastVacuumTime < (PR_Now() - DATABASE_MIN_TIME_BEFORE_VACUUM) &&
+       lastVacuumTime > (PR_Now() - DATABASE_MAX_TIME_BEFORE_VACUUM))) {
     // This is the first vacuum, or we are in the timeframe where vacuum could
     // happen.  Calculate the vacuum ratio and vacuum if it is less then
     // threshold.
     nsCOMPtr<mozIStorageStatement> statement;
     rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING("PRAGMA page_count"),
                                   getter_AddRefs(statement));
     NS_ENSURE_SUCCESS(rv, rv);
     PRBool hasResult = PR_FALSE;
@@ -5659,30 +5698,30 @@ nsNavHistory::VacuumDatabase()
     rv = statement->ExecuteStep(&hasResult);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_TRUE(hasResult, NS_ERROR_FAILURE);
     PRInt32 freelistCount = statement->AsInt32(0);
 
     freePagesRatio = (float)(freelistCount / pageCount);
   }
   
-  if (freePagesRatio > VACUUM_FREEPAGES_THRESHOLD ||
-      lastVacuumTime < (PR_Now() - MAX_TIME_BEFORE_VACUUM)) {
+  if (freePagesRatio > DATABASE_VACUUM_FREEPAGES_THRESHOLD ||
+      lastVacuumTime < (PR_Now() - DATABASE_MAX_TIME_BEFORE_VACUUM)) {
     // We vacuum in 2 cases:
     //  - We are in the valid vacuum timeframe and vacuum ratio is high.
     //  - Last vacuum has been executed a lot of time ago.
 
     // Notify we are about to vacuum.  This is mostly for testability.
     nsCOMPtr<nsIObserverService> observerService =
-      do_GetService("@mozilla.org/observer-service;1", &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-    rv = observerService->NotifyObservers(nsnull,
-                                          PLACES_VACUUM_STARTING_TOPIC,
-                                          nsnull);
-    NS_ENSURE_SUCCESS(rv, rv);
+      do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
+    if (observerService) {
+      (void)observerService->NotifyObservers(nsnull,
+                                             TOPIC_DATABASE_VACUUM_STARTING,
+                                             nsnull);
+    }
 
     // Actually vacuuming a database is a slow operation, since it could take
     // seconds.  Part of the time is spent in updating the journal file on disk
     // and this is particularly bad on devices with slow I/O.  Temporary
     // moving the journal to memory could increase a bit the possibility of
     // corruption if we crash during this time, but makes the process really
     // faster.
     nsCOMPtr<mozIStorageStatement> journalToMemory;
@@ -5693,17 +5732,17 @@ nsNavHistory::VacuumDatabase()
 
     nsCOMPtr<mozIStorageStatement> vacuum;
     rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING("VACUUM"),
                                   getter_AddRefs(vacuum));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<mozIStorageStatement> journalToDefault;
     rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
-        "PRAGMA journal_mode = " DEFAULT_JOURNAL_MODE),
+        "PRAGMA journal_mode = " DATABASE_JOURNAL_MODE),
       getter_AddRefs(journalToDefault));
     NS_ENSURE_SUCCESS(rv, rv);
 
     mozIStorageStatement *stmts[] = {
       journalToMemory,
       vacuum,
       journalToDefault
     };
@@ -5715,17 +5754,17 @@ nsNavHistory::VacuumDatabase()
     rv = prefSvc->SetIntPref(PREF_LAST_VACUUM,
                              (PRInt32)(PR_Now() / PR_USEC_PER_SEC));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
 
-NS_HIDDEN_(nsresult)
+nsresult
 nsNavHistory::DecayFrecency()
 {
   // Update frecency values.
   nsresult rv = FixInvalidFrecencies();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Globally decay places frecency rankings to estimate reduced frecency
   // values of pages that haven't been visited for a while, i.e., they do
@@ -5844,17 +5883,17 @@ nsNavHistory::LazyTimerCallback(nsITimer
   nsNavHistory* that = static_cast<nsNavHistory*>(aClosure);
   that->mLazyTimerSet = PR_FALSE;
   that->mLazyTimerDeferments = 0;
   that->CommitLazyMessages();
 }
 
 // nsNavHistory::CommitLazyMessages
 
-NS_HIDDEN_(void)
+void
 nsNavHistory::CommitLazyMessages(PRBool aIsShutdown)
 {
   mozStorageTransaction transaction(mDBConn, PR_TRUE);
   for (PRUint32 i = 0; i < mLazyMessages.Length(); i ++) {
     LazyMessage& message = mLazyMessages[i];
     switch (message.type) {
       case LazyMessage::Type_AddURI:
         AddURIInternal(message.uri, message.time, message.isRedirect,
@@ -6175,17 +6214,17 @@ nsNavHistory::BindQueryClauseParameters(
   // URI
   if (aQuery->Uri()) {
     BindStatementURI(statement, index.For("uri"), aQuery->Uri());
     if (aQuery->UriIsPrefix()) {
       nsCAutoString uriString;
       aQuery->Uri()->GetSpec(uriString);
       uriString.Append(char(0x7F)); // MAX_UTF8
       rv = statement->BindUTF8StringParameter(index.For("uri_upper"),
-        StringHead(uriString, HISTORY_URI_LENGTH_MAX));
+        StringHead(uriString, URI_LENGTH_MAX));
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   // annotation
   if (!aQuery->Annotation().IsEmpty()) {
     rv = statement->BindUTF8StringParameter(index.For("anno"), 
                                             aQuery->Annotation());
@@ -6993,17 +7032,17 @@ nsNavHistory::SetPageTitleInternal(nsIUR
   if ((aTitle.IsVoid() && title.IsVoid()) || aTitle == title)
     return NS_OK;
 
   mozStorageStatementScoper scoper(mDBSetPlaceTitle);
   // title
   if (aTitle.IsVoid())
     rv = mDBSetPlaceTitle->BindNullParameter(0);
   else
-    rv = mDBSetPlaceTitle->BindStringParameter(0, StringHead(aTitle, HISTORY_TITLE_LENGTH_MAX));
+    rv = mDBSetPlaceTitle->BindStringParameter(0, StringHead(aTitle, TITLE_LENGTH_MAX));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // url
   rv = BindStatementURI(mDBSetPlaceTitle, 1, aURI);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mDBSetPlaceTitle->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
@@ -7212,18 +7251,18 @@ nsNavHistory::RemoveDuplicateURIs()
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   rv = transaction.Commit();
   NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
 
-// Local function **************************************************************
-
+
+namespace {
 
 // GetReversedHostname
 //
 //    This extracts the hostname from the URI and reverses it in the
 //    form that we use (always ending with a "."). So
 //    "http://microsoft.com/" becomes "moc.tfosorcim."
 //
 //    The idea behind this is that we can create an index over the items in
@@ -7365,33 +7404,35 @@ void ParseSearchTermsFromQueries(const n
       // last word
       if (lastBegin >= 0)
         queryTerms->AppendElement(Substring(searchTerms, lastBegin));
     }
     aTerms->AppendElement(queryTerms);
   }
 }
 
-// BindStatementURI
-//
-//    Binds the specified URI as the parameter 'index' for the statment.
-//    URIs are always bound as UTF8
-
+} // anonymous namespace
+
+
+/**
+ * Binds the specified URI as the parameter 'index' for the statment.
+ * URIs are always bound as UTF8
+ */
 nsresult
 BindStatementURI(mozIStorageStatement* statement, PRInt32 index, nsIURI* aURI)
 {
   NS_ASSERTION(statement, "Must have non-null statement");
   NS_ASSERTION(aURI, "Must have non-null uri");
 
   nsCAutoString utf8URISpec;
   nsresult rv = aURI->GetSpec(utf8URISpec);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = statement->BindUTF8StringParameter(index,
-      StringHead(utf8URISpec, HISTORY_URI_LENGTH_MAX));
+      StringHead(utf8URISpec, URI_LENGTH_MAX));
   NS_ENSURE_SUCCESS(rv, rv);
   return NS_OK;
 }
 
 nsresult
 nsNavHistory::UpdateFrecency(PRInt64 aPlaceId, PRBool aIsBookmarked)
 {
   mozStorageStatementScoper statsScoper(mDBGetPlaceVisitStats);
@@ -7447,17 +7488,17 @@ nsNavHistory::UpdateFrecencyInternal(PRI
 
   // save ourselves the UPDATE if the frecency hasn't changed
   // One way this can happen is with livemarks.
   // when we added the livemark, the frecency was 0.  
   // On refresh, when we remove and then add the livemark items,
   // the frecency (for a given moz_places) will not have changed
   // (if we've never visited that place).
   // Additionally, don't bother overwriting a valid frecency with an invalid one
-  if (newFrecency == aOldFrecency || aOldFrecency && newFrecency < 0)
+  if ((newFrecency == aOldFrecency) || (aOldFrecency && newFrecency < 0))
     return NS_OK;
 
   mozStorageStatementScoper updateScoper(mDBUpdateFrecencyAndHidden);
   rv = mDBUpdateFrecencyAndHidden->BindInt64Parameter(0, aPlaceId);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mDBUpdateFrecencyAndHidden->BindInt32Parameter(1, newFrecency);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -7722,24 +7763,23 @@ NS_IMPL_ISUPPORTS1(AutoCompleteStatement
                    mozIStorageStatementCallback)
 
 NS_IMETHODIMP
 AutoCompleteStatementCallbackNotifier::HandleCompletion(PRUint16 aReason)
 {
   if (aReason != mozIStorageStatementCallback::REASON_FINISHED)
     return NS_ERROR_UNEXPECTED;
 
-  nsresult rv;
   nsCOMPtr<nsIObserverService> observerService =
-    do_GetService("@mozilla.org/observer-service;1", &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = observerService->NotifyObservers(nsnull,
-                                        PLACES_AUTOCOMPLETE_FEEDBACK_UPDATED_TOPIC,
-                                        nsnull);
-  NS_ENSURE_SUCCESS(rv, rv);
+    do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
+  if (observerService) {
+    (void)observerService->NotifyObservers(nsnull,
+                                           TOPIC_AUTOCOMPLETE_FEEDBACK_UPDATED,
+                                           nsnull);
+  }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 AutoCompleteStatementCallbackNotifier::HandleResult(mozIStorageResultSet *aResultSet)
 {
   NS_ASSERTION(PR_FALSE, "You cannot use AutoCompleteStatementCallbackNotifier to get async statements resultset");
@@ -7957,17 +7997,17 @@ nsNavHistory::GetDBBookmarkToUrlResult()
       "WHERE b.id = ?1 "
       "LIMIT 1"),
     getter_AddRefs(mDBBookmarkToUrlResult));
   NS_ENSURE_SUCCESS(rv, nsnull);
 
   return mDBBookmarkToUrlResult;
 }
 
-NS_HIDDEN_(nsresult)
+nsresult
 nsNavHistory::FinalizeStatements() {
   mozIStorageStatement* stmts[] = {
 #ifdef MOZ_XUL
     mDBFeedbackIncrease,
 #endif
     mDBGetURLPageInfo,
     mDBGetIdPageInfo,
     mDBRecentVisitOfURL,
--- a/toolkit/components/places/src/nsNavHistory.h
+++ b/toolkit/components/places/src/nsNavHistory.h
@@ -78,20 +78,21 @@
 #define QUERYUPDATE_COMPLEX 2
 #define QUERYUPDATE_COMPLEX_WITH_BOOKMARKS 3
 #define QUERYUPDATE_HOST 4
 
 // This magic number specified an uninitialized value for the
 // mInPrivateBrowsing member
 #define PRIVATEBROWSING_NOTINITED (PRBool(0xffffffff))
 
-#define PLACES_INIT_COMPLETE_TOPIC "places-init-complete"
-#define PLACES_DB_LOCKED_TOPIC "places-database-locked"
-#define PLACES_AUTOCOMPLETE_FEEDBACK_UPDATED_TOPIC "places-autocomplete-feedback-updated"
-#define PLACES_VACUUM_STARTING_TOPIC "places-vacuum-starting"
+// Clamp title and URL to generously large, but not too large, length.
+// See bug 319004 for details.
+#define URI_LENGTH_MAX 65536
+#define TITLE_LENGTH_MAX 4096
+
 
 class mozIAnnotationService;
 class nsNavHistory;
 class nsNavBookmarks;
 class QueryKeyValuePair;
 class nsIEffectiveTLDService;
 class nsIIDNService;
 class PlacesSQLQueryBuilder;
@@ -267,21 +268,20 @@ public:
                                   nsNavHistoryQueryOptions* aOptions,
                                   nsNavHistoryResultNode** aResult);
 
   // used by other places components to send history notifications (for example,
   // when the favicon has changed)
   void SendPageChangedNotification(nsIURI* aURI, PRUint32 aWhat,
                                    const nsAString& aValue);
 
-  // current time optimization
-  PRTime GetNow();
-
-  // well-known annotations used by the history and bookmarks systems
-  static const char kAnnotationPreviousEncoding[];
+  /**
+   * Returns current number of days stored in history.
+   */
+  PRInt32 GetDaysOfHistory();
 
   // used by query result nodes to update: see comment on body of CanLiveUpdateQuery
   static PRUint32 GetUpdateRequirements(const nsCOMArray<nsNavHistoryQuery>& aQueries,
                                         nsNavHistoryQueryOptions* aOptions,
                                         PRBool* aHasSearchTerms);
   PRBool EvaluateQueryForNode(const nsCOMArray<nsNavHistoryQuery>& aQueries,
                               nsNavHistoryQueryOptions* aOptions,
                               nsNavHistoryResultNode* aNode);
@@ -408,32 +408,32 @@ protected:
   mozIStorageStatement *GetDBVisitToVisitResult();
   nsCOMPtr<mozIStorageStatement> mDBVisitToVisitResult; // kGetInfoIndex_* results
   mozIStorageStatement *GetDBBookmarkToUrlResult();
   nsCOMPtr<mozIStorageStatement> mDBBookmarkToUrlResult; // kGetInfoIndex_* results
 
   /**
    * Finalize all internal statements.
    */
-  NS_HIDDEN_(nsresult) FinalizeStatements();
+  nsresult FinalizeStatements();
 
   /**
    * Analyzes the database and VACUUM it, if needed.
    */
-  NS_HIDDEN_(nsresult) DecayFrecency();
+  nsresult DecayFrecency();
   /**
    * Decays frecency and inputhistory values.
    */
-  NS_HIDDEN_(nsresult) VacuumDatabase();
+  nsresult VacuumDatabase();
 
   /**
    * Finalizes all Places internal statements, allowing to safely close the
    * database connection.
    */
-  NS_HIDDEN_(nsresult) FinalizeInternalStatements();
+  nsresult FinalizeInternalStatements();
 
   // nsICharsetResolver
   NS_DECL_NSICHARSETRESOLVER
 
   nsresult CalculateFrecency(PRInt64 aPageID, PRInt32 aTyped, PRInt32 aVisitCount, nsCAutoString &aURL, PRInt32 *aFrecency);
   nsresult CalculateFrecencyInternal(PRInt64 aPageID, PRInt32 aTyped, PRInt32 aVisitCount, PRBool aIsBookmarked, PRInt32 *aFrecency);
   nsCOMPtr<mozIStorageStatement> mDBVisitsForFrecency;
   nsCOMPtr<mozIStorageStatement> mDBUpdateFrecencyAndHidden;
@@ -502,20 +502,28 @@ protected:
    * This loads all of the preferences that we use into member variables.
    * NOTE:  If mPrefBranch is NULL, this does nothing.
    *
    * @param aInitializing
    *        Indicates if the autocomplete queries should be regenerated or not.
    */
   nsresult LoadPrefs(PRBool aInitializing);
 
-  // Current time optimization
-  PRTime mLastNow;
-  PRBool mNowValid;
+  /**
+   * Calculates and returns value for mCachedNow.
+   * This is an hack to avoid calling PR_Now() too often, as is the case when
+   * we're asked the ageindays of many history entries in a row.  A timer is
+   * set which will clear our valid flag after a short timeout.
+   */
+  PRTime GetNow();
+  PRTime mCachedNow;
   nsCOMPtr<nsITimer> mExpireNowTimer;
+  /**
+   * Called when the cached now value is expired and needs renewal.
+   */
   static void expireNowTimerCallback(nsITimer* aTimer, void* aClosure);
 
   // expiration
   friend class nsNavHistoryExpire;
   nsNavHistoryExpire *mExpire;
 
 #ifdef LAZY_ADD
   // lazy add committing
@@ -561,17 +569,17 @@ protected:
   };
   nsTArray<LazyMessage> mLazyMessages;
   nsCOMPtr<nsITimer> mLazyTimer;
   PRBool mLazyTimerSet;
   PRUint32 mLazyTimerDeferments; // see StartLazyTimer
   nsresult StartLazyTimer();
   nsresult AddLazyMessage(const LazyMessage& aMessage);
   static void LazyTimerCallback(nsITimer* aTimer, void* aClosure);
-  NS_HIDDEN_(void) CommitLazyMessages(PRBool aIsShutdown = PR_FALSE);
+  void CommitLazyMessages(PRBool aIsShutdown = PR_FALSE);
 #endif
 
   nsresult ConstructQueryString(const nsCOMArray<nsNavHistoryQuery>& aQueries, 
                                 nsNavHistoryQueryOptions* aOptions,
                                 nsCString& queryString,
                                 PRBool& aParamsPresent,
                                 StringHash& aAddParams);
 
@@ -630,34 +638,34 @@ protected:
   };
   typedef nsDataHashtable<nsCStringHashKey, RedirectInfo> RedirectHash;
   RedirectHash mRecentRedirects;
   static PLDHashOperator ExpireNonrecentRedirects(
       nsCStringHashKey::KeyType aKey, RedirectInfo& aData, void* aUserArg);
   PRBool GetRedirectFor(const nsACString& aDestination, nsACString& aSource,
                         PRTime* aTime, PRUint32* aRedirectType);
 
-  // session tracking
+  // Sessions tracking.
   PRInt64 mLastSessionID;
-  PRInt64 GetNewSessionID() { mLastSessionID ++; return mLastSessionID; }
+  PRInt64 GetNewSessionID();
 
 #ifdef MOZ_XUL
   // AutoComplete stuff
   mozIStorageStatement *GetDBFeedbackIncrease();
   nsCOMPtr<mozIStorageStatement> mDBFeedbackIncrease;
 
   nsresult AutoCompleteFeedback(PRInt32 aIndex,
                                 nsIAutoCompleteController *aController);
 #endif
 
   PRInt32 mExpireDaysMin;
   PRInt32 mExpireDaysMax;
   PRInt32 mExpireSites;
 
-  // frecency prefs
+  // Frecency preferences.
   PRInt32 mNumVisitsForFrecency;
   PRInt32 mFirstBucketCutoffInDays;
   PRInt32 mSecondBucketCutoffInDays;
   PRInt32 mThirdBucketCutoffInDays;
   PRInt32 mFourthBucketCutoffInDays;
   PRInt32 mFirstBucketWeight;
   PRInt32 mSecondBucketWeight;
   PRInt32 mThirdBucketWeight;
--- a/toolkit/components/places/src/nsNavHistoryResult.cpp
+++ b/toolkit/components/places/src/nsNavHistoryResult.cpp
@@ -3995,23 +3995,23 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsINavHistoryResult)
   NS_INTERFACE_MAP_STATIC_AMBIGUOUS(nsNavHistoryResult)
   NS_INTERFACE_MAP_ENTRY(nsINavHistoryResult)
   NS_INTERFACE_MAP_ENTRY(nsINavBookmarkObserver)
   NS_INTERFACE_MAP_ENTRY(nsINavHistoryObserver)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END
 
-nsNavHistoryResult::nsNavHistoryResult(nsNavHistoryContainerResultNode* aRoot) :
-  mRootNode(aRoot),
-  mIsHistoryObserver(PR_FALSE),
-  mIsBookmarkFolderObserver(PR_FALSE),
-  mIsAllBookmarksObserver(PR_FALSE),
-  mBatchInProgress(PR_FALSE),
-  mNeedsToApplySortingMode(PR_FALSE)
+nsNavHistoryResult::nsNavHistoryResult(nsNavHistoryContainerResultNode* aRoot)
+: mRootNode(aRoot)
+, mIsHistoryObserver(PR_FALSE)
+, mIsBookmarkFolderObserver(PR_FALSE)
+, mIsAllBookmarksObserver(PR_FALSE)
+, mNeedsToApplySortingMode(PR_FALSE)
+, mBatchInProgress(PR_FALSE)
 {
   mRootNode->mResult = this;
 }
 
 nsNavHistoryResult::~nsNavHistoryResult()
 {
   // delete all bookmark folder observer arrays which are allocated on the heap
   mBookmarkFolderObservers.Enumerate(&RemoveBookmarkFolderObserversCallback, nsnull);
--- a/toolkit/components/places/src/nsPlacesMacros.h
+++ b/toolkit/components/places/src/nsPlacesMacros.h
@@ -9,17 +9,17 @@
  *
  * 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 Places.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Mark Finkle <mfinkle@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/places/tests/autocomplete/test_autocomplete_on_value_removed_479089.js
+++ b/toolkit/components/places/tests/autocomplete/test_autocomplete_on_value_removed_479089.js
@@ -10,17 +10,17 @@
  *
  * 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 Places unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   David Dahl <ddahl@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/bookmarks/test_360134.js
+++ b/toolkit/components/places/tests/bookmarks/test_360134.js
@@ -10,17 +10,17 @@
  *
  * 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 Bug 360134 (item guids) unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Dan Mills <thunder@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/bookmarks/test_388695.js
+++ b/toolkit/components/places/tests/bookmarks/test_388695.js
@@ -10,17 +10,17 @@
  *
  * 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 Bug 388695 unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Asaf Romano <mano@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/bookmarks/test_395593.js
+++ b/toolkit/components/places/tests/bookmarks/test_395593.js
@@ -10,17 +10,17 @@
  *
  * 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 bug 395593 unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Asaf Romano <mano@mozilla.com> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/places/tests/bookmarks/test_changeBookmarkURI.js
+++ b/toolkit/components/places/tests/bookmarks/test_changeBookmarkURI.js
@@ -10,17 +10,17 @@
  *
  * 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 Places unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Dietrich Ayala <dietrich@mozilla.com> (Original Author)
  *  Drew Willcoxon <adw@mozilla.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/toolkit/components/places/tests/queries/head_queries.js
+++ b/toolkit/components/places/tests/queries/head_queries.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Test Code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Clint Talbert <ctalbert@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/queries/test_415716.js
+++ b/toolkit/components/places/tests/queries/test_415716.js
@@ -10,17 +10,17 @@
  *
  * 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 Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Clint Talbert <ctalbert@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/queries/test_abstime-annotation-domain.js
+++ b/toolkit/components/places/tests/queries/test_abstime-annotation-domain.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Test Code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Clint Talbert <ctalbert@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/queries/test_abstime-annotation-uri.js
+++ b/toolkit/components/places/tests/queries/test_abstime-annotation-uri.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Test Code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Clint Talbert <ctalbert@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/queries/test_onlyBookmarked.js
+++ b/toolkit/components/places/tests/queries/test_onlyBookmarked.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Test Code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  * Dietrich Ayala <dietrich@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/queries/test_redirectsMode.js
+++ b/toolkit/components/places/tests/queries/test_redirectsMode.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Test Code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Marco Bonardo <mak77@bonardo.net> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/places/tests/queries/test_results-as-visit.js
+++ b/toolkit/components/places/tests/queries/test_results-as-visit.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Clint Talbert <ctalbert@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/queries/test_searchterms-domain.js
+++ b/toolkit/components/places/tests/queries/test_searchterms-domain.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Test Code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Clint Talbert <ctalbert@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/queries/test_searchterms-uri.js
+++ b/toolkit/components/places/tests/queries/test_searchterms-uri.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Clint Talbert <ctalbert@mozilla.com>
  *
  * 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
--- a/toolkit/components/places/tests/queries/test_sorting.js
+++ b/toolkit/components/places/tests/queries/test_sorting.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Test Code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Marco Bonardo <mak77@bonardo.net> (Original Author)
  *   Drew Willcoxon <adw@mozilla.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/toolkit/components/places/tests/unit/nsDummyObserver.js
+++ b/toolkit/components/places/tests/unit/nsDummyObserver.js
@@ -8,17 +8,17 @@
  *
  * 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 Places unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Mark Finkle <mfinkle@mozilla.com> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/places/tests/unit/nsDynamicContainerServiceSample.js
+++ b/toolkit/components/places/tests/unit/nsDynamicContainerServiceSample.js
@@ -9,17 +9,17 @@
  *
  * 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 Places Dynamic Containers unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Asaf Romano <mano@mozilla.com> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the
  * terms of either the GNU General Public License Version 2 or later
--- a/toolkit/components/places/tests/unit/test_457698_crash.js
+++ b/toolkit/components/places/tests/unit/test_457698_crash.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Dynamic Containers unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Marco Bonardo <mak77@bonardo.net> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/places/tests/unit/test_486978_sort_by_date_queries.js
+++ b/toolkit/components/places/tests/unit/test_486978_sort_by_date_queries.js
@@ -10,17 +10,17 @@
  *
  * 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 Places unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Marco Bonardo <mak77@bonardo.net> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/places/tests/unit/test_bookmark_catobs.js
+++ b/toolkit/components/places/tests/unit/test_bookmark_catobs.js
@@ -8,17 +8,17 @@
  *
  * 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 Places unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Mark Finkle <mfinkle@mozilla.com> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/places/tests/unit/test_dynamic_containers.js
+++ b/toolkit/components/places/tests/unit/test_dynamic_containers.js
@@ -10,17 +10,17 @@
  *
  * 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 Places Dynamic Containers unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Asaf Romano <mano@mozilla.com> (Original Author)
  *   Marco Bonardo <mak77@bonardo.net>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/toolkit/components/places/tests/unit/test_empty_tags.js
+++ b/toolkit/components/places/tests/unit/test_empty_tags.js
@@ -6,17 +6,17 @@
 * 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 Places Test Code.
 *
-* The Initial Developer of the Original Code is Mozilla Corporation.
+* The Initial Developer of the Original Code is Mozilla Foundation.
 * Portions created by the Initial Developer are Copyright (C) 2009 the Initial
 * Developer. All Rights Reserved.
 *
 * Contributor(s):
 *  Edward Lee <edilee@mozilla.com> (original author)
 *
 * Alternatively, the contents of this file may be used under the terms of either
 * the GNU General Public License Version 2 or later (the "GPL"), or the GNU
--- a/toolkit/components/places/tests/unit/test_history_catobs.js
+++ b/toolkit/components/places/tests/unit/test_history_catobs.js
@@ -8,17 +8,17 @@
  *
  * 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 Places unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Mark Finkle <mfinkle@mozilla.com> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/places/tests/unit/test_lastModified.js
+++ b/toolkit/components/places/tests/unit/test_lastModified.js
@@ -10,17 +10,17 @@
  *
  * 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 Places unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Marco Bonardo <mak77@bonardo.net>
  *
  * 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
--- a/toolkit/components/places/tests/unit/test_migrateFrecency.js
+++ b/toolkit/components/places/tests/unit/test_migrateFrecency.js
@@ -8,17 +8,17 @@
  *
  * 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 Places Test Code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Edward Lee <edilee@mozilla.com> (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/places/tests/unit/test_null_interfaces.js
+++ b/toolkit/components/places/tests/unit/test_null_interfaces.js
@@ -6,17 +6,17 @@
 * 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 Places Test Code.
 *
-* The Initial Developer of the Original Code is Mozilla Corporation.
+* The Initial Developer of the Original Code is Mozilla Foundation.
 * Portions created by the Initial Developer are Copyright (C) 2009 the Initial
 * Developer. All Rights Reserved.
 *
 * Contributor(s):
 *  Edward Lee <edilee@mozilla.com> (original author)
 *
 * Alternatively, the contents of this file may be used under the terms of either
 * the GNU General Public License Version 2 or later (the "GPL"), or the GNU
--- a/toolkit/components/places/tests/unit/test_placeURIs.js
+++ b/toolkit/components/places/tests/unit/test_placeURIs.js
@@ -10,17 +10,17 @@
  *
  * 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 Bug 376798 unit test code.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Asaf Romano <mano@mozilla.com>
  *
  * 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
--- a/toolkit/components/satchel/public/nsIFormAutoComplete.idl
+++ b/toolkit/components/satchel/public/nsIFormAutoComplete.idl
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/components/satchel/src/nsFormAutoComplete.js
+++ b/toolkit/components/satchel/src/nsFormAutoComplete.js
@@ -8,17 +8,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Justin Dolske <dolske@mozilla.com> (original author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/content/license.html
+++ b/toolkit/content/license.html
@@ -159,24 +159,28 @@
        and version you choose.)
     </p>
     
     <ul>
       <li><a href="about:license#apple-mozilla">Apple/Mozilla NPRuntime License</a></li>
       <li><a href="about:license#breakpad">Breakpad License</a></li>
       <li><a href="about:license#bspatch">bspatch License</a></li>
       <li><a href="about:license#cairo">Cairo Component Licenses</a></li>
+      <li><a href="about:license#chromium">Chromium License</a></li>
       <li><a href="about:license#csiro">CSIRO Australia License</a></li>
       <li><a href="about:license#hunspell-nl">Dutch Spellchecking Dictionary License</a></li>
       <li><a href="about:license#expat">Expat License</a></li>
+      <li><a href="about:license#gfx-font-list">gfxFontList License</a></li>
       <li><a href="about:license#gears">Google Gears License</a></li>
       <li><a href="about:license#gears-istumbler">Google Gears/iStumbler License</a></li>
       <li><a href="about:license#growl">Growl License</a></li>
       <li><a href="about:license#jpnic">Japan Network Information Center License</a></li>
       <li><a href="about:license#jemalloc">jemalloc License</a></li>
+      <li><a href="about:license#libevent">libevent License</a></li>
+      <li><a href="about:license#libffi">libffi License</a></li>
       <li><a href="about:license#hunspell-lt">Lithuanian Spellchecking Dictionary License</a></li>
       <li><a href="about:license#openvision">OpenVision License</a></li>
       <li><a href="about:license#qcms">qcms License</a></li>
       <li><a href="about:license#xdg">Red Hat xdg_user_dir_lookup License</a></li>
       <li><a href="about:license#hunspell-ru">Russian Spellchecking Dictionary License</a></li>
       <li><a href="about:license#sparkle">Sparkle License</a></li>
       <li><a href="about:license#sunsoft">SunSoft License</a></li>
       <li><a href="about:license#ucal">University of California License</a></li>      
@@ -2077,16 +2081,54 @@ INCLUDING ALL IMPLIED WARRANTIES OF MERC
 NO EVENT SHALL &lt;COPYRIGHT HOLDER&gt; BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 </pre>
 
 
+    <hr>
+
+    <h1><a name="chromium"></a>Chromium License</h1>
+
+    <p class="correctme">This license applies to some files in the directory
+      <span class="path">ipc/chromium/</span>.
+    </p>
+
+<pre>
+Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+   * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+   * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+   * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+
 
     <hr>
 
     <h1><a name="csiro"></a>CSIRO Australia License</h1>
 
     <p class="correctme">This license applies to files in the directories:
       <ul>
         <li><span class="path">media/libfishsound/</span></li>  
@@ -2202,16 +2244,55 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETH
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 </pre>
 
 
 
     <hr>
 
+    <h1><a name="gfx-font-list"></a>gfxFontList License</h1>
+
+    <p class="correctme">This license applies to the files 
+    <span class="path">gfx/thebes/src/gfxMacPlatformFontList.mm</span> and
+    <span class="path">gfx/thebes/src/gfxPlatformFontList.cpp</span>.
+    </p>
+
+<pre>
+Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1.  Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+2.  Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+    its contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+
+
+
+    <hr>
+
     <h1><a name="gears"></a>Google Gears</h1>
 
     <p class="correctme">This license applies to the file 
     <span class="path">netwerk/wifi/wlanapi.h</span>.</p>
 
 <pre>
 Copyright 2008, Google Inc.
 
@@ -2433,19 +2514,89 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NO
 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 </pre>
 
 
+    <hr>
+    
+
+    <h1><a name="libevent"></a>libevent License</h1>
+
+    <p class="correctme">This license applies to files in the directory
+    <span class="path">ipc/chromium/src/third_party/libevent/</span>.
+    </p>
+
+<pre>
+Copyright 2000-2002 Niels Provos &lt;provos@citi.umich.edu&gt;
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+</pre>
+
 
     <hr>
 
+    <h1><a name="libffi"></a>libffi License</h1>
+
+    <p class="correctme">This license applies to files in the directories
+    <span class="path">js/ctypes/libffi/</span> and
+    <span class="path">js/ctypes/libffi_msvc/</span>.
+    </p>
+
+<pre>
+libffi - Copyright (c) 1996-2008 Red Hat, Inc and others.  
+See source files for details.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+``Software''), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+</pre>
+
+
+    <hr>
+    
     <h1><a name="hunspell-lt"></a>Lithuanian Spellchecking Dictionary License</h1>
 
     <p class="correctme">This license applies to certain files in the directory
       <span class="path">l10n/lt/extensions/spellcheck/hunspell/</span>. (This
       code only ships in some localized versions of this product.)</p>
 
 <pre>
 The project has been sponsored by the Information Society Development
--- a/toolkit/content/tests/unit/test_contentAreaUtils.js
+++ b/toolkit/content/tests/unit/test_contentAreaUtils.js
@@ -9,17 +9,17 @@
  *
  * 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 bug 342485 unit test.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Asaf Romano <mano@mozilla.com>
  *
  * 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
--- a/toolkit/content/widgets/datetimepicker.xml
+++ b/toolkit/content/widgets/datetimepicker.xml
@@ -10,17 +10,17 @@
    -
    - 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 Mozilla Corporation.
+   - The Initial Developer of the Original Code is Mozilla Foundation.
    - Portions created by the Initial Developer are Copyright (C) 2006
    - the Initial Developer. All Rights Reserved.
    -
    - Contributor(s):
    -   Neil Deakin <enndeakin@sympatico.ca> (Original Author)
    -
    - 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"),
--- a/toolkit/mozapps/downloads/tests/unit/test_lowMinutes.js
+++ b/toolkit/mozapps/downloads/tests/unit/test_lowMinutes.js
@@ -6,17 +6,17 @@
 * 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 DownloadUtils Test Code.
 *
-* The Initial Developer of the Original Code is Mozilla Corporation.
+* The Initial Developer of the Original Code is Mozilla Foundation.
 * Portions created by the Initial Developer are Copyright (C) 2009 the Initial
 * Developer. All Rights Reserved.
 *
 * Contributor(s):
 *  Edward Lee <edilee@mozilla.com> (original author)
 *
 * Alternatively, the contents of this file may be used under the terms of either
 * the GNU General Public License Version 2 or later (the "GPL"), or the GNU
--- a/toolkit/spatial-navigation/Makefile.in
+++ b/toolkit/spatial-navigation/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 build system.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation
+# The Initial Developer of the Original Code is Mozilla Foundation
 # Portions created by the Initial Developer are Copyright (C) 2008
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #  Doug Turner <dougt@meer.net>
 #
 # 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
--- a/toolkit/spatial-navigation/SpatialNavigation.js
+++ b/toolkit/spatial-navigation/SpatialNavigation.js
@@ -8,17 +8,17 @@
  *
  * 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 Spatial Navigation.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation
+ * The Initial Developer of the Original Code is Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Doug Turner <dougt@meer.net>  (Original Author)
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/toolkit/spatial-navigation/tests/Makefile.in
+++ b/toolkit/spatial-navigation/tests/Makefile.in
@@ -8,17 +8,17 @@
 #
 # 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 build system.
 #
-# The Initial Developer of the Original Code is Mozilla Corporation
+# The Initial Developer of the Original Code is Mozilla Foundation
 # Portions created by the Initial Developer are Copyright (C) 2008
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #  Doug Turner <dougt@meer.net>
 #
 # 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
--- a/tools/codesighs/codesighs.c
+++ b/tools/codesighs/codesighs.c
@@ -222,49 +222,59 @@ void trimWhite(char* inString)
         }
         else
         {
             break;
         }
     }
 }
 
-
 int codesighs(Options* inOptions)
 /*
 **  Output a simplistic report based on our options.
 */
 {
     int retval = 0;
     char lineBuffer[0x1000];
     int scanRes = 0;
     unsigned long size;
-    char segClass[0x10];
-    char scope[0x10];
-    char module[0x100];
-    char segment[0x40];
-    char object[0x100];
+    #define SEGCLASS_CHARS 15
+    char segClass[SEGCLASS_CHARS + 1];
+    #define SCOPE_CHARS 15
+    char scope[SCOPE_CHARS + 1];
+    #define MODULE_CHARS 255
+    char module[MODULE_CHARS + 1];
+    #define SEGMENT_CHARS 63
+    char segment[SEGMENT_CHARS + 1];
+    #define OBJECT_CHARS 255
+    char object[OBJECT_CHARS + 1];
     char* symbol;
     SizeStats overall;
     ModuleStats* modules = NULL;
     unsigned moduleCount = 0;
 
     memset(&overall, 0, sizeof(overall));
 
     /*
     **  Read the file line by line, regardless of number of fields.
     **  We assume tab separated value formatting, at least 7 lead values:
     **      size class scope module segment object symbol ....
     */
     while(0 == retval && NULL != fgets(lineBuffer, sizeof(lineBuffer), inOptions->mInput))
     {
         trimWhite(lineBuffer);
 
+#define STRINGIFY(s_) STRINGIFY2(s_)
+#define STRINGIFY2(s_) #s_
+
         scanRes = sscanf(lineBuffer,
-            "%x\t%s\t%s\t%s\t%s\t%s\t",
+            "%x\t%" STRINGIFY(SEGCLASS_CHARS) "s\t%"
+            STRINGIFY(SCOPE_CHARS) "s\t%" STRINGIFY(MODULE_CHARS)
+            "s\t%" STRINGIFY(SEGMENT_CHARS) "s\t%"
+            STRINGIFY(OBJECT_CHARS) "s\t",
             (unsigned*)&size,
             segClass,
             scope,
             module,
             segment,
             object);
 
         if(6 == scanRes)
--- a/tools/codesighs/maptsvdifftool.c
+++ b/tools/codesighs/maptsvdifftool.c
@@ -381,37 +381,49 @@ int difftool(Options* inOptions)
         trimWhite(lineBuffer);
 
         if(('<' == lineBuffer[0] || '>' == lineBuffer[0]) && ' ' == lineBuffer[1])
         {
             int additive = 0;
             char* theLine = &lineBuffer[2];
             int scanRes = 0;
             int size;
-            char segClass[0x10];
-            char scope[0x10];
-            char module[0x100];
-            char segment[0x40];
-            char object[0x100];
+            #define SEGCLASS_CHARS 15
+            char segClass[SEGCLASS_CHARS + 1];
+            #define SCOPE_CHARS 15
+            char scope[SCOPE_CHARS + 1];
+            #define MODULE_CHARS 255
+            char module[MODULE_CHARS + 1];
+            #define SEGMENT_CHARS 63
+            char segment[SEGMENT_CHARS + 1];
+            #define OBJECT_CHARS 255
+            char object[OBJECT_CHARS + 1];
             char* symbol = NULL;
 
             /*
             **  Figure out if the line adds or subtracts from something.
             */
             if('>' == lineBuffer[0])
             {
                 additive = __LINE__;
             }
 
 
             /*
             **  Scan the line for information.
             */
+
+#define STRINGIFY(s_) STRINGIFY2(s_)
+#define STRINGIFY2(s_) #s_
+
             scanRes = sscanf(theLine,
-                "%x\t%s\t%s\t%s\t%s\t%s\t",
+                "%x\t%" STRINGIFY(SEGCLASS_CHARS) "s\t%"
+                STRINGIFY(SCOPE_CHARS) "s\t%" STRINGIFY(MODULE_CHARS)
+                "s\t%" STRINGIFY(SEGMENT_CHARS) "s\t%"
+                STRINGIFY(OBJECT_CHARS) "s\t",
                 (unsigned*)&size,
                 segClass,
                 scope,
                 module,
                 segment,
                 object);
 
             if(6 == scanRes)
--- a/tools/codesighs/msmap2tsv.c
+++ b/tools/codesighs/msmap2tsv.c
@@ -63,16 +63,19 @@
 #define DEMANGLE_STATE_START 9
 #define DEMANGLE_STATE_STOP 10
 #define DEMANGLE_SAFE_CHAR(eval)  (isprint(eval) ? eval : ' ')
 
 #else
 #define F_DEMANGLE 0
 #endif /* WIN32 */
 
+#define STRINGIFY(s_) STRINGIFY2(s_)
+#define STRINGIFY2(s_) #s_
+#define SYMBOL_BUF_CHARS 511
 
 #define ERROR_REPORT(num, val, msg)   fprintf(stderr, "error(%d):\t\"%s\"\t%s\n", (num), (val), (msg));
 #define CLEANUP(ptr)    do { if(NULL != ptr) { free(ptr); ptr = NULL; } } while(0)
 
 
 typedef struct __struct_SymDB_Size
 /*
 **  The size of the symbol.
@@ -1191,26 +1194,26 @@ int readmap(Options* inOptions, MSMap_Mo
                                             }
                                         }
                                         
                                         if(0 == retval && inModule->mSymbolCapacity > inModule->mSymbolCount)
                                         {
                                             MSMap_Symbol* theSymbol = NULL;
                                             unsigned index = 0;
                                             int scanRes = 0;
-                                            char symbolBuf[0x200];
+                                            char symbolBuf[SYMBOL_BUF_CHARS + 1];
                                             
                                             index = inModule->mSymbolCount;
                                             inModule->mSymbolCount++;
                                             theSymbol = (inModule->mSymbols + index);
                                             
                                             memset(theSymbol, 0, sizeof(MSMap_Symbol));
                                             theSymbol->mScope = STATIC;
                                             
-                                            scanRes = sscanf(current, "%x:%x %s %x", (unsigned*)&(theSymbol->mPrefix), (unsigned*)&(theSymbol->mOffset), symbolBuf, (unsigned*)&(theSymbol->mRVABase));
+                                            scanRes = sscanf(current, "%x:%x %" STRINGIFY(SYMBOL_BUF_CHARS) "s %x", (unsigned*)&(theSymbol->mPrefix), (unsigned*)&(theSymbol->mOffset), symbolBuf, (unsigned*)&(theSymbol->mRVABase));
                                             if(4 == scanRes)
                                             {
                                                 theSymbol->mSymbol = symdup(symbolBuf);
 
                                                 if(0 == retval)
                                                 {
                                                     if(NULL != theSymbol->mSymbol)
                                                     {
@@ -1316,26 +1319,26 @@ int readmap(Options* inOptions, MSMap_Mo
                                         }
                                     }
                                     
                                     if(0 == retval && inModule->mSymbolCapacity > inModule->mSymbolCount)
                                     {
                                         MSMap_Symbol* theSymbol = NULL;
                                         unsigned index = 0;
                                         int scanRes = 0;
-                                        char symbolBuf[0x200];
+                                        char symbolBuf[SYMBOL_BUF_CHARS + 1];
                                         
                                         index = inModule->mSymbolCount;
                                         inModule->mSymbolCount++;
                                         theSymbol = (inModule->mSymbols + index);
                                         
                                         memset(theSymbol, 0, sizeof(MSMap_Symbol));
                                         theSymbol->mScope = PUBLIC;
                                         
-                                        scanRes = sscanf(current, "%x:%x %s %x", (unsigned*)&(theSymbol->mPrefix), (unsigned*)&(theSymbol->mOffset), symbolBuf, (unsigned *)&(theSymbol->mRVABase));
+                                        scanRes = sscanf(current, "%x:%x %" STRINGIFY(SYMBOL_BUF_CHARS) "s %x", (unsigned*)&(theSymbol->mPrefix), (unsigned*)&(theSymbol->mOffset), symbolBuf, (unsigned *)&(theSymbol->mRVABase));
                                         if(4 == scanRes)
                                         {
                                             theSymbol->mSymbol = symdup(symbolBuf);
 
                                             if(NULL != theSymbol->mSymbol)
                                             {
                                                 char *last = lastWord(current);
                                                 
@@ -1411,27 +1414,29 @@ int readmap(Options* inOptions, MSMap_Mo
                                         ERROR_REPORT(retval, inModule->mModule, "Unable to grow segments.");
                                     }
                                 }
                                 
                                 if(0 == retval && inModule->mSegmentCapacity > inModule->mSegmentCount)
                                 {
                                     MSMap_Segment* theSegment = NULL;
                                     unsigned index = 0;
-                                    char classBuf[0x10];
-                                    char nameBuf[0x20];
+                                    #define CLASS_BUF_CHARS 15
+                                    char classBuf[CLASS_BUF_CHARS + 1];
+                                    #define NAME_BUF_CHARS 31
+                                    char nameBuf[NAME_BUF_CHARS + 1];
                                     int scanRes = 0;
                                     
                                     index = inModule->mSegmentCount;
                                     inModule->mSegmentCount++;
                                     theSegment = (inModule->mSegments + index);
                                     
                                     memset(theSegment, 0, sizeof(MSMap_Segment));
                                     
-                                    scanRes = sscanf(current, "%x:%x %xH %s %s", (unsigned*)&(theSegment->mPrefix), (unsigned*)&(theSegment->mOffset), (unsigned*)&(theSegment->mLength), nameBuf, classBuf);
+                                    scanRes = sscanf(current, "%x:%x %xH %" STRINGIFY(NAME_BUF_CHARS) "s %" STRINGIFY(CLASS_BUF_CHARS) "s", (unsigned*)&(theSegment->mPrefix), (unsigned*)&(theSegment->mOffset), (unsigned*)&(theSegment->mLength), nameBuf, classBuf);
                                     if(5 == scanRes)
                                     {
                                         if('.' == nameBuf[0])
                                         {
                                             theSegment->mSegment = strdup(&nameBuf[1]);
                                         }
                                         else
                                         {
--- a/tools/update-packaging/make_incremental_updates.py
+++ b/tools/update-packaging/make_incremental_updates.py
@@ -32,17 +32,21 @@ class PatchInfo:
         
     def append_add_instruction(self, filename):
         """ Appends an add instruction for this patch.   
             if the filename starts with extensions/ adds an add-if instruction
             to test the existence of the subdirectory.  This was ported from
             mozilla/tools/update-packaging/common.sh/make_add_instruction
         """
         if filename.startswith("extensions/"):
-            testdir = "extensions/"+filename.split("/")[1]  # Dir immediately following extensions is used for the test
+            # Dir immediately following extensions is used for the test
+            testdir = "extensions/"+filename.split("/")[1]
+            self.manifest.append('add-if "'+testdir+'" "'+filename+'"')
+        elif filename.startswith("Contents/MacOS/extensions/"):
+            testdir = "Contents/MacOS/extensions/"+filename.split("/")[3]
             self.manifest.append('add-if "'+testdir+'" "'+filename+'"')
         else:
             self.manifest.append('add "'+filename+'"')
            
     def append_patch_instruction(self, filename, patchname):
         """ Appends an patch instruction for this patch.   
             
             filename = file to patch
@@ -52,17 +56,21 @@ class PatchInfo:
             to test the existence of the subdirectory.  
             if the filename starts with searchplugins/ add a add-if instruction for the filename
             This was ported from
             mozilla/tools/update-packaging/common.sh/make_patch_instruction
         """
         if filename.startswith("extensions/"):
             testdir = "extensions/"+filename.split("/")[1]
             self.manifest.append('patch-if "'+testdir+'" "'+patchname+'" "'+filename+'"')
-        elif filename.startswith("searchplugins/"):
+        elif filename.startswith("Contents/MacOS/extensions/"):
+            testdir = "Contents/MacOS/extensions/"+filename.split("/")[3]
+            self.manifest.append('patch-if "'+testdir+'" "'+patchname+'" "'+filename+'"')
+        elif (filename.startswith("searchplugins/") or
+             filename.startswith("Contents/MacOS/searchplugins/")):
             self.manifest.append('patch-if "'+filename+'" "'+patchname+'" "'+filename+'"')
         else:
             self.manifest.append('patch "'+patchname+'" "'+filename+'"')
                 
     def append_remove_instruction(self, filename):
         """ Appends an remove instruction for this patch.   
             This was ported from
             mozilla/tools/update-packaging/common.sh/make_remove_instruction
--- a/widget/src/gtk2/nsPrintSettingsGTK.cpp
+++ b/widget/src/gtk2/nsPrintSettingsGTK.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Michael Ventnor <m.ventnor@gmail.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"),
--- a/widget/src/gtk2/nsPrintSettingsGTK.h
+++ b/widget/src/gtk2/nsPrintSettingsGTK.h
@@ -10,17 +10,17 @@
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  * for the specific language governing rights and limitations under the
  * License.
  *
  * The Original Code is the Mozilla browser.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Michael Ventnor <m.ventnor@gmail.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"),
--- a/widget/src/windows/nsDataObj.cpp
+++ b/widget/src/windows/nsDataObj.cpp
@@ -92,26 +92,16 @@ MakeRandomString(char *buf, PRInt32 bufL
 
 // XXX for older version of PSDK where IAsyncOperation and related stuff is not available
 // but this should be removed when parocles config is updated
 // IAsyncOperation interface GUID
 #ifndef __IAsyncOperation_INTERFACE_DEFINED__
   const IID IID_IAsyncOperation = {0x3D8B0590, 0xF691, 0x11d2, {0x8E, 0xA9, 0x00, 0x60, 0x97, 0xDF, 0x5B, 0xD4}};
 #endif
 
-#if 0
-#define PRNTDEBUG(_x) printf(_x);
-#define PRNTDEBUG2(_x1, _x2) printf(_x1, _x2);
-#define PRNTDEBUG3(_x1, _x2, _x3) printf(_x1, _x2, _x3);
-#else
-#define PRNTDEBUG(_x) // printf(_x);
-#define PRNTDEBUG2(_x1, _x2) // printf(_x1, _x2);
-#define PRNTDEBUG3(_x1, _x2, _x3) // printf(_x1, _x2, _x3);
-#endif
-
 //-----------------------------------------------------------------------------
 // CStream implementation
 nsDataObj::CStream::CStream() : mRefCount(1)
 {
 }
 
 //-----------------------------------------------------------------------------
 nsDataObj::CStream::~CStream()
@@ -145,17 +135,17 @@ STDMETHODIMP nsDataObj::CStream::QueryIn
   }
 
   if (NULL != *ppvResult)
   {
     ((LPUNKNOWN)*ppvResult)->AddRef();
     return S_OK;
   }
 
-  return ResultFromScode(E_NOINTERFACE);
+  return E_NOINTERFACE;
 }
 
 //-----------------------------------------------------------------------------
 STDMETHODIMP_(ULONG) nsDataObj::CStream::AddRef(void)
 {
   return ++mRefCount;
 }
 
@@ -421,35 +411,33 @@ STDMETHODIMP nsDataObj::QueryInterface(R
 		AddRef();
 		return S_OK;
   } else if (IID_IAsyncOperation == riid) {
     *ppv = static_cast<IAsyncOperation*>(this);
     AddRef();
     return S_OK;
   }
 
-	return ResultFromScode(E_NOINTERFACE);
+	return E_NOINTERFACE;
 }
 
 //-----------------------------------------------------
 STDMETHODIMP_(ULONG) nsDataObj::AddRef()
 {
 	++m_cRef;
 	NS_LOG_ADDREF(this, m_cRef, "nsDataObj", sizeof(*this));
-  //PRNTDEBUG3("nsDataObj::AddRef  >>>>>>>>>>>>>>>>>> %d on %p\n", (m_cRef+1), this);
 	return m_cRef;
 }
 
 
 //-----------------------------------------------------
 STDMETHODIMP_(ULONG) nsDataObj::Release()
 {
-  //PRNTDEBUG3("nsDataObj::Release >>>>>>>>>>>>>>>>>> %d on %p\n", (m_cRef-1), this);
-
 	--m_cRef;
+	
 	NS_LOG_RELEASE(this, m_cRef, "nsDataObj");
 	if (0 != m_cRef)
 		return m_cRef;
 
   // We have released our last ref on this object and need to delete the
   // temp file. External app acting as drop target may still need to open the
   // temp file. Addref a timer so it can delay deleting file and destroying
   // this object. Delete file anyway and destroy this obj if there's a problem.
@@ -468,299 +456,266 @@ STDMETHODIMP_(ULONG) nsDataObj::Release(
 	delete this;
 
 	return 0;
 }
 
 //-----------------------------------------------------
 BOOL nsDataObj::FormatsMatch(const FORMATETC& source, const FORMATETC& target) const
 {
-	if ((source.cfFormat == target.cfFormat) &&
-		 (source.dwAspect  & target.dwAspect)  &&
-		 (source.tymed     & target.tymed))       {
-		return TRUE;
-	} else {
-		return FALSE;
-	}
+  if ((source.cfFormat == target.cfFormat) &&
+      (source.dwAspect & target.dwAspect) &&
+      (source.tymed & target.tymed)) {
+    return TRUE;
+  } else {
+    return FALSE;
+  }
 }
 
 //-----------------------------------------------------
 // IDataObject methods
 //-----------------------------------------------------
-STDMETHODIMP nsDataObj::GetData(LPFORMATETC pFE, LPSTGMEDIUM pSTM)
+STDMETHODIMP nsDataObj::GetData(LPFORMATETC aFormat, LPSTGMEDIUM pSTM)
 {
-  PRNTDEBUG("nsDataObj::GetData\n");
-  PRNTDEBUG3("  format: %d  Text: %d\n", pFE->cfFormat, CF_HDROP);
-  if ( !mTransferable )
-	  return ResultFromScode(DATA_E_FORMATETC);
+  if (!mTransferable)
+    return DV_E_FORMATETC;
 
   PRUint32 dfInx = 0;
 
   static CLIPFORMAT fileDescriptorFlavorA = ::RegisterClipboardFormat( CFSTR_FILEDESCRIPTORA ); 
   static CLIPFORMAT fileDescriptorFlavorW = ::RegisterClipboardFormat( CFSTR_FILEDESCRIPTORW ); 
   static CLIPFORMAT uniformResourceLocatorA = ::RegisterClipboardFormat( CFSTR_INETURLA );
   static CLIPFORMAT uniformResourceLocatorW = ::RegisterClipboardFormat( CFSTR_INETURLW );
   static CLIPFORMAT fileFlavor = ::RegisterClipboardFormat( CFSTR_FILECONTENTS ); 
   static CLIPFORMAT PreferredDropEffect = ::RegisterClipboardFormat( CFSTR_PREFERREDDROPEFFECT );
 
-  // Arbitrary system formats
+  // Arbitrary system formats are used for image feedback during drag
+  // and drop. We are responsible for storing these internally during
+  // drag operations.
   LPDATAENTRY pde;
-  HRESULT hres = FindFORMATETC(pFE, &pde, FALSE);
-  if (SUCCEEDED(hres)) {
-      return AddRefStgMedium(&pde->stgm, pSTM, FALSE);
+  if (LookupArbitraryFormat(aFormat, &pde, FALSE)) {
+    return CopyMediumData(pSTM, &pde->stgm, aFormat, FALSE);
   }
 
   // Firefox internal formats
   ULONG count;
   FORMATETC fe;
   m_enumFE->Reset();
   while (NOERROR == m_enumFE->Next(1, &fe, &count)
          && dfInx < mDataFlavors.Length()) {
     nsCString& df = mDataFlavors.ElementAt(dfInx);
-    if (FormatsMatch(fe, *pFE)) {
+    if (FormatsMatch(fe, *aFormat)) {
       pSTM->pUnkForRelease = NULL;        // caller is responsible for deleting this data
-      CLIPFORMAT format = pFE->cfFormat;
+      CLIPFORMAT format = aFormat->cfFormat;
       switch(format) {
 
       // Someone is asking for plain or unicode text
       case CF_TEXT:
       case CF_UNICODETEXT:
-      return GetText(df, *pFE, *pSTM);
+      return GetText(df, *aFormat, *pSTM);
 
       // Some 3rd party apps that receive drag and drop files from the browser
       // window require support for this.
       case CF_HDROP:
-        return GetFile(*pFE, *pSTM);
+        return GetFile(*aFormat, *pSTM);
 
       // Someone is asking for an image
       case CF_DIB:
-        return GetDib(df, *pFE, *pSTM);
-
-      // ... not yet implemented ...
-      //case CF_BITMAP:
-      //  return GetBitmap(*pFE, *pSTM);
-      //case CF_METAFILEPICT:
-      //  return GetMetafilePict(*pFE, *pSTM);
+        return GetDib(df, *aFormat, *pSTM);
 
       default:
         if ( format == fileDescriptorFlavorA )
-          return GetFileDescriptor ( *pFE, *pSTM, PR_FALSE );
+          return GetFileDescriptor ( *aFormat, *pSTM, PR_FALSE );
         if ( format == fileDescriptorFlavorW )
-          return GetFileDescriptor ( *pFE, *pSTM, PR_TRUE);
+          return GetFileDescriptor ( *aFormat, *pSTM, PR_TRUE);
         if ( format == uniformResourceLocatorA )
-          return GetUniformResourceLocator( *pFE, *pSTM, PR_FALSE);
+          return GetUniformResourceLocator( *aFormat, *pSTM, PR_FALSE);
         if ( format == uniformResourceLocatorW )
-          return GetUniformResourceLocator( *pFE, *pSTM, PR_TRUE);
+          return GetUniformResourceLocator( *aFormat, *pSTM, PR_TRUE);
         if ( format == fileFlavor )
-          return GetFileContents ( *pFE, *pSTM );
+          return GetFileContents ( *aFormat, *pSTM );
         if ( format == PreferredDropEffect )
-          return GetPreferredDropEffect( *pFE, *pSTM );
-        PRNTDEBUG2("***** nsDataObj::GetData - Unknown format %u\n", format);
-        return GetText(df, *pFE, *pSTM);
+          return GetPreferredDropEffect( *aFormat, *pSTM );
+        //printf("***** nsDataObj::GetData - Unknown format %u\n", format);
+        return GetText(df, *aFormat, *pSTM);
       } //switch
     } // if
     dfInx++;
   } // while
 
-  return ResultFromScode(DATA_E_FORMATETC);
+  return DATA_E_FORMATETC;
 }
 
 //-----------------------------------------------------
 STDMETHODIMP nsDataObj::GetDataHere(LPFORMATETC pFE, LPSTGMEDIUM pSTM)
 {
-  PRNTDEBUG("nsDataObj::GetDataHere\n");
-		return ResultFromScode(E_FAIL);
+  return E_FAIL;
 }
 
 
 //-----------------------------------------------------
 // Other objects querying to see if we support a 
 // particular format
 //-----------------------------------------------------
 STDMETHODIMP nsDataObj::QueryGetData(LPFORMATETC pFE)
 {
-  PRNTDEBUG("nsDataObj::QueryGetData  ");
-  PRNTDEBUG2("format: %d\n", pFE->cfFormat);
-
-  // Arbitrary system formats
+  // Arbitrary system formats are used for image feedback during drag
+  // and drop. We are responsible for storing these internally during
+  // drag operations.
   LPDATAENTRY pde;
-  if (SUCCEEDED(FindFORMATETC(pFE, &pde, FALSE)))
+  if (LookupArbitraryFormat(pFE, &pde, FALSE))
     return S_OK;
 
   // Firefox internal formats
   ULONG count;
   FORMATETC fe;
   m_enumFE->Reset();
   while (NOERROR == m_enumFE->Next(1, &fe, &count)) {
     if (fe.cfFormat == pFE->cfFormat) {
       return S_OK;
     }
   }
-
-  PRNTDEBUG2("***** nsDataObj::QueryGetData - Unknown format %d\n", pFE->cfFormat);
-	return ResultFromScode(E_FAIL);
+  return E_FAIL;
 }
 
 //-----------------------------------------------------
 STDMETHODIMP nsDataObj::GetCanonicalFormatEtc
 	 (LPFORMATETC pFEIn, LPFORMATETC pFEOut)
 {
-  PRNTDEBUG("nsDataObj::GetCanonicalFormatEtc\n");
-		return ResultFromScode(E_FAIL);
-}
-
-HGLOBAL nsDataObj::GlobalClone(HGLOBAL hglobIn)
-{
-  HGLOBAL hglobOut = NULL;
-
-  LPVOID pvIn = GlobalLock(hglobIn);
-  if (pvIn) {
-    SIZE_T cb = GlobalSize(hglobIn);
-    HGLOBAL hglobOut = GlobalAlloc(GMEM_FIXED, cb);
-    if (hglobOut) {
-      CopyMemory(hglobOut, pvIn, cb);
-    }
-    GlobalUnlock(hglobIn);
-  }
-  return hglobOut;
-}
-
-IUnknown* nsDataObj::GetCanonicalIUnknown(IUnknown *punk)
-{
-  IUnknown *punkCanonical;
-  if (punk && SUCCEEDED(punk->QueryInterface(IID_IUnknown,
-                                             (LPVOID*)&punkCanonical))) {
-    punkCanonical->Release();
-  } else {
-    punkCanonical = punk;
-  }
-  return punkCanonical;
+  return E_FAIL;
 }
 
 //-----------------------------------------------------
-STDMETHODIMP nsDataObj::SetData(LPFORMATETC pFE, LPSTGMEDIUM pSTM, BOOL fRelease)
+STDMETHODIMP nsDataObj::SetData(LPFORMATETC aFormat, LPSTGMEDIUM aMedium, BOOL shouldRel)
 {
-  PRNTDEBUG("nsDataObj::SetData\n");
-  // Store arbitrary system formats
+  // Arbitrary system formats are used for image feedback during drag
+  // and drop. We are responsible for storing these internally during
+  // drag operations.
   LPDATAENTRY pde;
-  HRESULT hres = FindFORMATETC(pFE, &pde, TRUE); // add
-  if (SUCCEEDED(hres)) {
+  if (LookupArbitraryFormat(aFormat, &pde, TRUE)) {
+    // Release the old data the lookup handed us for this format. This
+    // may have been set in CopyMediumData when we originally stored the
+    // data.
     if (pde->stgm.tymed) {
       ReleaseStgMedium(&pde->stgm);
-      ZeroMemory(&pde->stgm, sizeof(STGMEDIUM));
+      memset(&pde->stgm, 0, sizeof(STGMEDIUM));
     }
 
-    if (fRelease) {
-      pde->stgm = *pSTM;
-      hres = S_OK;
+    PRBool result = PR_TRUE;
+    if (shouldRel) {
+      // If shouldRel is TRUE, the data object called owns the storage medium
+      // after the call returns. Store the incoming data in our data array for
+      // release when we are destroyed. This is the common case with arbitrary
+      // data from explorer.
+      pde->stgm = *aMedium;
     } else {
-      hres = AddRefStgMedium(pSTM, &pde->stgm, TRUE);
+      // Copy the incoming data into our data array. (AFAICT, this never gets
+      // called with arbitrary formats for drag images.)
+      result = CopyMediumData(&pde->stgm, aMedium, aFormat, TRUE);
     }
     pde->fe.tymed = pde->stgm.tymed;
 
-    // Break circular reference loop (see msdn)
-    if (GetCanonicalIUnknown(pde->stgm.pUnkForRelease) ==
-        GetCanonicalIUnknown(static_cast<IDataObject*>(this))) {
-      pde->stgm.pUnkForRelease->Release();
-      pde->stgm.pUnkForRelease = NULL;
-    }
-    return hres;
+    return result ? S_OK : DV_E_TYMED;
   }
 
-  if (fRelease)
-    ReleaseStgMedium(pSTM);
+  if (shouldRel)
+    ReleaseStgMedium(aMedium);
 
-  return ResultFromScode(S_OK);
+  return S_OK;
 }
 
-HRESULT
-nsDataObj::FindFORMATETC(FORMATETC *pfe, LPDATAENTRY *ppde, BOOL fAdd)
+PRBool
+nsDataObj::LookupArbitraryFormat(FORMATETC *aFormat, LPDATAENTRY *aDataEntry, BOOL aAddorUpdate)
 {
-  *ppde = NULL;
+  *aDataEntry = NULL;
 
-  if (pfe->ptd != NULL) return DV_E_DVTARGETDEVICE;
+  if (aFormat->ptd != NULL)
+    return PR_FALSE;
 
-  // See if it's in our list
+  // See if it's already in our list. If so return the data entry.
   for (PRUint32 idx = 0; idx < mDataEntryList.Length(); idx++) {
-    if (mDataEntryList[idx]->fe.cfFormat == pfe->cfFormat &&
-        mDataEntryList[idx]->fe.dwAspect == pfe->dwAspect &&
-        mDataEntryList[idx]->fe.lindex == pfe->lindex) {
-      if (fAdd || (mDataEntryList[idx]->fe.tymed & pfe->tymed)) {
-        *ppde = mDataEntryList[idx];
-        return S_OK;
+    if (mDataEntryList[idx]->fe.cfFormat == aFormat->cfFormat &&
+        mDataEntryList[idx]->fe.dwAspect == aFormat->dwAspect &&
+        mDataEntryList[idx]->fe.lindex == aFormat->lindex) {
+      if (aAddorUpdate || (mDataEntryList[idx]->fe.tymed & aFormat->tymed)) {
+        // If the caller requests we update, or if the 
+        // medium type matches, return the entry. 
+        *aDataEntry = mDataEntryList[idx];
+        return PR_TRUE;
       } else {
-        return DV_E_TYMED;
+        // Medium does not match, not found.
+        return PR_FALSE;
       }
     }
   }
 
-  if (!fAdd)
-    return DV_E_FORMATETC;
+  if (!aAddorUpdate)
+    return PR_FALSE;
 
-  LPDATAENTRY pde = (LPDATAENTRY)CoTaskMemAlloc(sizeof(DATAENTRY));
-  if (pde) {
-    pde->fe = *pfe;
-    *ppde = pde;
-    ZeroMemory(&pde->stgm, sizeof(STGMEDIUM));
+  // Add another entry to mDataEntryList
+  LPDATAENTRY dataEntry = (LPDATAENTRY)CoTaskMemAlloc(sizeof(DATAENTRY));
+  if (!dataEntry)
+    return PR_FALSE;
+  
+  dataEntry->fe = *aFormat;
+  *aDataEntry = dataEntry;
+  memset(&dataEntry->stgm, 0, sizeof(STGMEDIUM));
 
-    m_enumFE->AddFormatEtc(pfe);
-    mDataEntryList.AppendElement(pde);
+  // Add this to our IEnumFORMATETC impl. so we can return it when
+  // it's requested.
+  m_enumFE->AddFormatEtc(aFormat);
 
-    return S_OK;
-  } else {
-    return E_OUTOFMEMORY;
-  }
+  // Store a copy internally in the arbitrary formats array.
+  mDataEntryList.AppendElement(dataEntry);
+
+  return PR_TRUE;
 }
 
-HRESULT
-nsDataObj::AddRefStgMedium(STGMEDIUM *pstgmIn, STGMEDIUM *pstgmOut, BOOL fCopyIn)
+PRBool
+nsDataObj::CopyMediumData(STGMEDIUM *aMediumDst, STGMEDIUM *aMediumSrc, LPFORMATETC aFormat, BOOL aSetData)
 {
-  HRESULT hres = S_OK;
-  STGMEDIUM stgmOut = *pstgmIn;
-
-  if (pstgmIn->pUnkForRelease == NULL &&
-      !(pstgmIn->tymed & (TYMED_ISTREAM | TYMED_ISTORAGE))) {
-    if (fCopyIn) {
-      // Object needs to be cloned
-      if (pstgmIn->tymed == TYMED_HGLOBAL) {
-        stgmOut.hGlobal = GlobalClone(pstgmIn->hGlobal);
-        if (!stgmOut.hGlobal) {
-          hres = E_OUTOFMEMORY;
+  STGMEDIUM stgmOut = *aMediumSrc;
+  
+  switch (stgmOut.tymed) {
+    case TYMED_ISTREAM:
+      stgmOut.pstm->AddRef();
+    break;
+    case TYMED_ISTORAGE:
+      stgmOut.pstg->AddRef();
+    break;
+    case TYMED_HGLOBAL:
+      if (!aMediumSrc->pUnkForRelease) {
+        if (aSetData) {
+          if (aMediumSrc->tymed != TYMED_HGLOBAL)
+            return PR_FALSE;
+          stgmOut.hGlobal = OleDuplicateData(aMediumSrc->hGlobal, aFormat->cfFormat, 0);
+          if (!stgmOut.hGlobal)
+            return PR_FALSE;
+        } else {
+          // We are returning this data from LookupArbitraryFormat, indicate to the
+          // shell we hold it and will free it.
+          stgmOut.pUnkForRelease = static_cast<IDataObject*>(this);
         }
-      } else {
-        hres = DV_E_TYMED;
       }
-    } else {
-      stgmOut.pUnkForRelease = static_cast<IDataObject*>(this);
-    }
+    break;
+    default:
+      return PR_FALSE;
   }
 
-  if (SUCCEEDED(hres)) {
-    switch (stgmOut.tymed) {
-    case TYMED_ISTREAM:
-      stgmOut.pstm->AddRef();
-      break;
-    case TYMED_ISTORAGE:
-      stgmOut.pstg->AddRef();
-      break;
-    }
-    if (stgmOut.pUnkForRelease) {
-      stgmOut.pUnkForRelease->AddRef();
-    }
-    *pstgmOut = stgmOut;
-  }
+  if (stgmOut.pUnkForRelease)
+    stgmOut.pUnkForRelease->AddRef();
 
-  return hres;
+  *aMediumDst = stgmOut;
+
+  return PR_TRUE;
 }
 
 //-----------------------------------------------------
 STDMETHODIMP nsDataObj::EnumFormatEtc(DWORD dwDir, LPENUMFORMATETC *ppEnum)
 {
-  PRNTDEBUG("nsDataObj::EnumFormatEtc\n");
-
   switch (dwDir) {
     case DATADIR_GET:
       m_enumFE->Clone(ppEnum);
       break;
     case DATADIR_SET:
       // fall through
     default:
       *ppEnum = NULL;
@@ -772,33 +727,30 @@ STDMETHODIMP nsDataObj::EnumFormatEtc(DW
   // Clone already AddRefed the result so don't addref it again.
   return NOERROR;
 }
 
 //-----------------------------------------------------
 STDMETHODIMP nsDataObj::DAdvise(LPFORMATETC pFE, DWORD dwFlags,
 										            LPADVISESINK pIAdviseSink, DWORD* pdwConn)
 {
-  PRNTDEBUG("nsDataObj::DAdvise\n");
-	return ResultFromScode(E_FAIL);
+  return E_FAIL;
 }
 
 
 //-----------------------------------------------------
 STDMETHODIMP nsDataObj::DUnadvise(DWORD dwConn)
 {
-  PRNTDEBUG("nsDataObj::DUnadvise\n");
-	return ResultFromScode(E_FAIL);
+  return E_FAIL;
 }
 
 //-----------------------------------------------------
 STDMETHODIMP nsDataObj::EnumDAdvise(LPENUMSTATDATA *ppEnum)
 {
-  PRNTDEBUG("nsDataObj::EnumDAdvise\n");
-	return ResultFromScode(E_FAIL);
+  return E_FAIL;
 }
 
 // IAsyncOperation methods
 STDMETHODIMP nsDataObj::EndOperation(HRESULT hResult,
                                      IBindCtx *pbcReserved,
                                      DWORD dwEffects)
 {
   mIsInOperation = FALSE;
@@ -838,46 +790,34 @@ STDMETHODIMP nsDataObj::StartOperation(I
   return S_OK;
 }
 
 //-----------------------------------------------------
 // GetData and SetData helper functions
 //-----------------------------------------------------
 HRESULT nsDataObj::AddSetFormat(FORMATETC& aFE)
 {
-  PRNTDEBUG("nsDataObj::AddSetFormat\n");
-	return ResultFromScode(S_OK);
+  return S_OK;
 }
 
 //-----------------------------------------------------
 HRESULT nsDataObj::AddGetFormat(FORMATETC& aFE)
 {
-  PRNTDEBUG("nsDataObj::AddGetFormat\n");
-	return ResultFromScode(S_OK);
+  return S_OK;
 }
 
-//-----------------------------------------------------
-HRESULT 
-nsDataObj::GetBitmap ( const nsACString& , FORMATETC&, STGMEDIUM& )
-{
-  PRNTDEBUG("nsDataObj::GetBitmap\n");
-	return ResultFromScode(E_NOTIMPL);
-}
-
-
 //
 // GetDIB
 //
 // Someone is asking for a bitmap. The data in the transferable will be a straight
 // imgIContainer, so just QI it.
 //
 HRESULT 
 nsDataObj :: GetDib ( const nsACString& inFlavor, FORMATETC &, STGMEDIUM & aSTG )
 {
-  PRNTDEBUG("nsDataObj::GetDib\n");
   ULONG result = E_FAIL;
   PRUint32 len = 0;
   nsCOMPtr<nsISupports> genericDataWrapper;
   mTransferable->GetTransferData(PromiseFlatCString(inFlavor).get(), getter_AddRefs(genericDataWrapper), &len);
   nsCOMPtr<imgIContainer> image ( do_QueryInterface(genericDataWrapper) );
   if ( !image ) {
     // Check if the image was put in an nsISupportsInterfacePointer wrapper.
     // This might not be necessary any more, but could be useful for backwards
@@ -1406,17 +1346,17 @@ HRESULT nsDataObj::DropFile(FORMATETC& a
 
   nsAutoString path;
   rv = file->GetPath(path);
   if (NS_FAILED(rv))
     return E_FAIL;
 
   PRUint32 allocLen = path.Length() + 2;
   HGLOBAL hGlobalMemory = NULL;
-  PRUnichar *dest, *dest2;
+  PRUnichar *dest;
 
   hGlobalMemory = GlobalAlloc(GMEM_MOVEABLE, sizeof(DROPFILES) +
                                              allocLen * sizeof(PRUnichar));
   if (!hGlobalMemory)
     return E_FAIL;
 
   DROPFILES* pDropFile = (DROPFILES*)GlobalLock(hGlobalMemory);
 
@@ -1683,29 +1623,29 @@ HRESULT nsDataObj::DropTempFile(FORMATET
   aSTG.hGlobal = hGlobalMemory;
 
   return S_OK;
 }
 
 //-----------------------------------------------------
 HRESULT nsDataObj::GetMetafilePict(FORMATETC&, STGMEDIUM&)
 {
-	return ResultFromScode(E_NOTIMPL);
+	return E_NOTIMPL;
 }
 
 //-----------------------------------------------------
 HRESULT nsDataObj::SetBitmap(FORMATETC&, STGMEDIUM&)
 {
-	return ResultFromScode(E_NOTIMPL);
+	return E_NOTIMPL;
 }
 
 //-----------------------------------------------------
 HRESULT nsDataObj::SetDib(FORMATETC&, STGMEDIUM&)
 {
-	return ResultFromScode(E_FAIL);
+	return E_FAIL;
 }
 
 //-----------------------------------------------------
 HRESULT nsDataObj::SetText  (FORMATETC& aFE, STGMEDIUM& aSTG)
 {
   if (aFE.cfFormat == CF_TEXT && aFE.tymed ==  TYMED_HGLOBAL) {
 		HGLOBAL hString = (HGLOBAL)aSTG.hGlobal;
 		if(hString == NULL)
@@ -1715,23 +1655,23 @@ HRESULT nsDataObj::SetText  (FORMATETC& 
 		char *  pString = (char *) GlobalLock(hString);    
 		if(!pString)
 			return(FALSE);
 
 		GlobalUnlock(hString);
     nsAutoString str; str.AssignWithConversion(pString);
 
   }
-	return ResultFromScode(E_FAIL);
+	return E_FAIL;
 }
 
 //-----------------------------------------------------
 HRESULT nsDataObj::SetMetafilePict(FORMATETC&, STGMEDIUM&)
 {
-	return ResultFromScode(E_FAIL);
+	return E_FAIL;
 }
 
 
 
 //-----------------------------------------------------
 //-----------------------------------------------------
 CLSID nsDataObj::GetClassID() const
 {
--- a/widget/src/windows/nsDataObj.h
+++ b/widget/src/windows/nsDataObj.h
@@ -214,57 +214,56 @@ class nsDataObj : public IDataObject,
 
 	public: // other methods
 
     // Gets the filename from the kFilePromiseURLMime flavour
     nsresult GetDownloadDetails(nsIURI **aSourceURI,
                                 nsAString &aFilename);
 
 	protected:
-	  // help determine the kind of drag
+    // help determine the kind of drag
     PRBool IsFlavourPresent(const char *inFlavour);
 
-		virtual HRESULT AddSetFormat(FORMATETC&  FE);
-		virtual HRESULT AddGetFormat(FORMATETC&  FE);
+    virtual HRESULT AddSetFormat(FORMATETC&  FE);
+    virtual HRESULT AddGetFormat(FORMATETC&  FE);
 
-		virtual HRESULT GetFile ( FORMATETC& aFE, STGMEDIUM& aSTG );
-		virtual HRESULT GetText ( const nsACString& aDF, FORMATETC& aFE, STGMEDIUM & aSTG );
-		virtual HRESULT GetBitmap ( const nsACString& inFlavor, FORMATETC&  FE, STGMEDIUM&  STM);
-		virtual HRESULT GetDib ( const nsACString& inFlavor, FORMATETC &, STGMEDIUM & aSTG );
-		virtual HRESULT GetMetafilePict(FORMATETC&  FE, STGMEDIUM&  STM);
+    virtual HRESULT GetFile ( FORMATETC& aFE, STGMEDIUM& aSTG );
+    virtual HRESULT GetText ( const nsACString& aDF, FORMATETC& aFE, STGMEDIUM & aSTG );
+    virtual HRESULT GetDib ( const nsACString& inFlavor, FORMATETC &, STGMEDIUM & aSTG );
+    virtual HRESULT GetMetafilePict(FORMATETC&  FE, STGMEDIUM&  STM);
         
-        virtual HRESULT DropImage( FORMATETC& aFE, STGMEDIUM& aSTG );
-        virtual HRESULT DropFile( FORMATETC& aFE, STGMEDIUM& aSTG );
-        virtual HRESULT DropTempFile( FORMATETC& aFE, STGMEDIUM& aSTG );
+    virtual HRESULT DropImage( FORMATETC& aFE, STGMEDIUM& aSTG );
+    virtual HRESULT DropFile( FORMATETC& aFE, STGMEDIUM& aSTG );
+    virtual HRESULT DropTempFile( FORMATETC& aFE, STGMEDIUM& aSTG );
 
     virtual HRESULT GetUniformResourceLocator ( FORMATETC& aFE, STGMEDIUM& aSTG, PRBool aIsUnicode ) ;
     virtual HRESULT ExtractUniformResourceLocatorA ( FORMATETC& aFE, STGMEDIUM& aSTG ) ;
     virtual HRESULT ExtractUniformResourceLocatorW ( FORMATETC& aFE, STGMEDIUM& aSTG ) ;
     virtual HRESULT GetFileDescriptor ( FORMATETC& aFE, STGMEDIUM& aSTG, PRBool aIsUnicode ) ;
     virtual HRESULT GetFileContents ( FORMATETC& aFE, STGMEDIUM& aSTG ) ;
     virtual HRESULT GetPreferredDropEffect ( FORMATETC& aFE, STGMEDIUM& aSTG );
-   
-		virtual HRESULT SetBitmap(FORMATETC&  FE, STGMEDIUM&  STM);
-		virtual HRESULT SetDib   (FORMATETC&  FE, STGMEDIUM&  STM);
-		virtual HRESULT SetText  (FORMATETC&  FE, STGMEDIUM&  STM);
-		virtual HRESULT SetMetafilePict(FORMATETC&  FE, STGMEDIUM&  STM);
+
+    virtual HRESULT SetBitmap(FORMATETC&  FE, STGMEDIUM&  STM);
+    virtual HRESULT SetDib   (FORMATETC&  FE, STGMEDIUM&  STM);
+    virtual HRESULT SetText  (FORMATETC&  FE, STGMEDIUM&  STM);
+    virtual HRESULT SetMetafilePict(FORMATETC&  FE, STGMEDIUM&  STM);
 
       // Provide the structures needed for an internet shortcut by the shell
     virtual HRESULT GetFileDescriptorInternetShortcutA ( FORMATETC& aFE, STGMEDIUM& aSTG ) ;
     virtual HRESULT GetFileDescriptorInternetShortcutW ( FORMATETC& aFE, STGMEDIUM& aSTG ) ;
     virtual HRESULT GetFileContentsInternetShortcut ( FORMATETC& aFE, STGMEDIUM& aSTG ) ;
 
     // IStream implementation
     virtual HRESULT GetFileDescriptor_IStreamA ( FORMATETC& aFE, STGMEDIUM& aSTG ) ;
     virtual HRESULT GetFileDescriptor_IStreamW ( FORMATETC& aFE, STGMEDIUM& aSTG ) ;
     virtual HRESULT GetFileContents_IStream ( FORMATETC& aFE, STGMEDIUM& aSTG ) ;
 
     nsresult ExtractShortcutURL ( nsString & outURL ) ;
     nsresult ExtractShortcutTitle ( nsString & outTitle ) ;
-    
+
       // munge our HTML data to win32's CF_HTML spec. Will null terminate
     nsresult BuildPlatformHTML ( const char* inOurHTML, char** outPlatformHTML ) ;
 
     // Used for the SourceURL part of CF_HTML
     nsCString mSourceURL;
 
     BOOL FormatsMatch(const FORMATETC& source, const FORMATETC& target) const;
 
@@ -318,28 +317,25 @@ class nsDataObj : public IDataObject,
       STDMETHOD(UnlockRegion)(ULARGE_INTEGER nStart, ULARGE_INTEGER nBytes, DWORD dwFlags);
       STDMETHOD(Write)(const void* pvBuffer, ULONG nBytesToRead, ULONG* nBytesRead);
     };
 
     HRESULT CreateStream(IStream **outStream);
 
   private:
 
-    // Drag and drop helper data for implementing drag and drop image support 
+    // Drag and drop helper data for implementing drag and drop image support
     typedef struct {
       FORMATETC   fe;
       STGMEDIUM   stgm;
     } DATAENTRY, *LPDATAENTRY;
 
     nsTArray <LPDATAENTRY> mDataEntryList;
+    nsCOMPtr<nsITimer> mTimer;
 
-    HRESULT FindFORMATETC(FORMATETC *pfe, LPDATAENTRY *ppde, BOOL fAdd);
-    HRESULT AddRefStgMedium(STGMEDIUM *pstgmIn, STGMEDIUM *pstgmOut,
-                            BOOL fCopyIn);
-    IUnknown* GetCanonicalIUnknown(IUnknown *punk);
-    HGLOBAL GlobalClone(HGLOBAL hglobIn);
+    PRBool LookupArbitraryFormat(FORMATETC *aFormat, LPDATAENTRY *aDataEntry, BOOL aAddorUpdate);
+    PRBool CopyMediumData(STGMEDIUM *aMediumDst, STGMEDIUM *aMediumSrc, LPFORMATETC aFormat, BOOL aSetData);
     static void RemoveTempFile(nsITimer* aTimer, void* aClosure);
-    nsCOMPtr<nsITimer> mTimer;
 };
 
 
 #endif  // _NSDATAOBJ_H_
 
--- a/xpcom/glue/nsTObserverArray.cpp
+++ b/xpcom/glue/nsTObserverArray.cpp
@@ -9,17 +9,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Jonas Sicking <jonas@sicking.cc> (Original Author)
  *   Daniel Witte <dwitte@stanford.edu>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/xpcom/glue/nsTObserverArray.h
+++ b/xpcom/glue/nsTObserverArray.h
@@ -9,17 +9,17 @@
  *
  * 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 Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Jonas Sicking <jonas@sicking.cc> (Original Author)
  *   Daniel Witte <dwitte@stanford.edu>
  *
  * Alternatively, the contents of this file may be used under the terms of
--- a/xpcom/glue/nsTPtrArray.h
+++ b/xpcom/glue/nsTPtrArray.h
@@ -10,17 +10,17 @@
  *
  * 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 C++ pointer array template.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2006
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *  Jonas Sicking <jonas@sicking.cc>
  *
  * 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
--- a/xpcom/tests/TestExpirationTracker.cpp
+++ b/xpcom/tests/TestExpirationTracker.cpp
@@ -10,17 +10,17 @@
  *
  * 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 ExpirationTracker tests.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2007
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Robert O'Callahan <robert@ocallahan.org>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
--- a/xpcom/tests/TestTimeStamp.cpp
+++ b/xpcom/tests/TestTimeStamp.cpp
@@ -9,17 +9,17 @@
  *
  * 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 XPCOM TimeStamp tests.
  *
- * The Initial Developer of the Original Code is Mozilla Corporation.
+ * The Initial Developer of the Original Code is Mozilla Foundation.
  * Portions created by the Initial Developer are Copyright (C) 2009
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   robert@ocallahan.org
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or