Merge the latest green changeset on mozilla-inbound to mozilla-central
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 09 Aug 2011 08:09:13 -0400
changeset 74055 08327218cb8bd31bd4b91993a63bde497a5f7842
parent 74008 87e3ea12ed5d1dbf2dedc6c9a73ab25fac29ee47 (current diff)
parent 74054 f1a3fea305ffb0bbc9664ea5329a76988a5f5cd9 (diff)
child 74056 fc0c60debaaea204df096d81668de3dac24ca070
child 75234 f189dd6316ebcf2aa3dd6ef82e1489282f019309
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone8.0a1
Merge the latest green changeset on mozilla-inbound to mozilla-central
browser/base/content/browser.xul
dom/base/nsDOMClassInfo.cpp
dom/public/coreEvents/Makefile.in
dom/public/coreEvents/nsIDOMCompositionListener.h
dom/public/coreEvents/nsIDOMContextMenuListener.h
dom/public/coreEvents/nsIDOMFocusListener.h
dom/public/coreEvents/nsIDOMFormListener.h
dom/public/coreEvents/nsIDOMKeyListener.h
dom/public/coreEvents/nsIDOMLoadListener.h
dom/public/coreEvents/nsIDOMMouseListener.h
dom/public/coreEvents/nsIDOMMouseMotionListener.h
dom/public/coreEvents/nsIDOMTextListener.h
dom/public/coreEvents/nsIDOMUIListener.h
embedding/android/GeckoAppShell.java
js/src/xpconnect/loader/ISO8601DateUtils.jsm
layout/reftests/backgrounds/background-size-no-intrinsic-height-image-ref.html
layout/reftests/backgrounds/background-size-no-intrinsic-height-image.html
layout/reftests/backgrounds/background-size-no-intrinsic-width-image-ref.html
layout/reftests/backgrounds/background-size-no-intrinsic-width-image.html
layout/reftests/backgrounds/no-intrinsic-size.svg
mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.xul
mobile/chrome/content/browser.xul
mobile/components/build/nsIPhoneSupport.idl
mobile/components/build/nsPhoneSupport.cpp
mobile/components/build/nsPhoneSupport.h
mobile/locales/en-US/chrome/feedback.dtd
toolkit/components/webapps/Makefile.in
toolkit/components/webapps/nsIWebappsSupport.idl
toolkit/components/webapps/nsWebappsSupport.cpp
toolkit/components/webapps/nsWebappsSupport.h
--- a/accessible/src/base/nsRootAccessible.h
+++ b/accessible/src/base/nsRootAccessible.h
@@ -44,18 +44,17 @@
 #include "nsIAccessibleDocument.h"
 #ifdef MOZ_XUL
 #include "nsXULTreeAccessible.h"
 #endif
 
 #include "nsHashtable.h"
 #include "nsCaretAccessible.h"
 #include "nsIDocument.h"
-#include "nsIDOMFocusListener.h"
-#include "nsIDOMFormListener.h"
+#include "nsIDOMEventListener.h"
 
 #define NS_ROOTACCESSIBLE_IMPL_CID                      \
 {  /* eaba2cf0-21b1-4e2b-b711-d3a89dcd5e1a */           \
   0xeaba2cf0,                                           \
   0x21b1,                                               \
   0x4e2b,                                               \
   { 0xb7, 0x11, 0xd3, 0xa8, 0x9d, 0xcd, 0x5e, 0x1a }    \
 }
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -1004,17 +1004,17 @@
       <svg:circle cx="-0.35" cy="0.5" r="0.58"/>
     </svg:mask>
   </svg:svg>
 #endif
 #ifdef XP_MACOSX
   <svg:svg height="0">
     <svg:mask id="pinstripe-keyhole-forward-mask" maskContentUnits="objectBoundingBox">
       <svg:rect x="0" y="0" width="1" height="1" fill="white"/>
-      <svg:circle cx="-0.46" cy="0.48" r="0.65"/>
+      <svg:circle cx="-0.41" cy="0.5" r="0.65"/>
     </svg:mask>
     <svg:mask id="pinstripe-tab-ontop-left-curve-mask" maskContentUnits="userSpaceOnUse">
       <svg:circle cx="9" cy="3" r="3" fill="white"/>
       <svg:rect x="9" y="0" width="3" height="3" fill="white"/>
       <svg:rect x="6" y="3" width="6" height="19" fill="white"/>
       <svg:rect x="1" y="17" width="5" height="5" fill="white"/>
       <svg:circle cx="1" cy="17" r="5"/>
       <svg:rect x="0" y="22" width="12" height="1" fill="white"/>
--- a/browser/installer/removed-files.in
+++ b/browser/installer/removed-files.in
@@ -221,16 +221,17 @@ extensions/testpilot@labs.mozilla.com/sk
 extensions/testpilot@labs.mozilla.com/skin/win/feedback.css
 extensions/testpilot@labs.mozilla.com/skin/win/notification-tail-down.png
 extensions/testpilot@labs.mozilla.com/skin/win/notification-tail-up.png
 extensions/testpilot@labs.mozilla.com/tests/test_data_store.js
 greprefs/all.js
 greprefs/security-prefs.js
 greprefs/xpinstall.js
 install.rdf
+modules/ISO8601DateUtils.jsm
 modules/JSON.jsm
 mozilla-runtime@BIN_SUFFIX@
 old-homepage-default.properties
 README.txt
 res/arrow.gif
 res/arrowd.gif
 res/broken-image.gif
 res/broken-image.png
@@ -936,17 +937,16 @@ xpicleanup@BIN_SUFFIX@
   #ifdef XP_WIN
     modules/DownloadTaskbarProgress.jsm
   #endif
   modules/DownloadUtils.jsm
   modules/FileUtils.jsm
   modules/Geometry.jsm
   modules/HUDService.jsm
   modules/InlineSpellChecker.jsm
-  modules/ISO8601DateUtils.jsm
   modules/LightweightThemeConsumer.jsm
   modules/LightweightThemeManager.jsm
   modules/Microformats.js
   modules/NetUtil.jsm
   modules/NetworkPrioritizer.jsm
   modules/openLocationLastURL.jsm
   modules/PerfMeasurement.jsm
   modules/PlacesDBUtils.jsm
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a65aa30ebae6c314bccd897862be400e27c7afab
GIT binary patch
literal 6479
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
--- a/browser/themes/pinstripe/browser/browser.css
+++ b/browser/themes/pinstripe/browser/browser.css
@@ -83,18 +83,18 @@
 }
 
 #nav-bar {
   padding-bottom: 4px !important;
 }
 
 #PersonalToolbar {
   -moz-appearance: none;
-  margin-top: -1px; /* overlay the bottom border of the toolbar above us */
-  padding-top: 0 !important;
+  margin-top: -2px; /* overlay the bottom border of the toolbar above us */
+  padding-top: 1px !important;
   background-color: -moz-mac-chrome-active;
   border-bottom: 1px solid rgba(0, 0, 0, 0.57);
 }
 
 #navigator-toolbox[tabsontop="true"] > #nav-bar,
 #navigator-toolbox[tabsontop="true"]:not([customizing]) > #nav-bar[collapsed="true"] + toolbar,
 #navigator-toolbox[tabsontop="true"]:not([customizing]) > #nav-bar[collapsed="true"] + #customToolbars + #PersonalToolbar {
   -moz-appearance: none;
@@ -288,31 +288,32 @@ toolbarbutton.bookmark-item > menupopup 
 
 /* ----- PRIMARY TOOLBAR BUTTONS ----- */
 
 .toolbarbutton-1:not([type="menu-button"]),
 .toolbarbutton-1 > .toolbarbutton-menubutton-button,
 .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker,
 #restore-button {
   -moz-box-orient: vertical;
-  padding: 0 3px;
+  -moz-appearance: toolbarbutton;
   height: 22px;
-  border: 1px solid @toolbarbuttonBorderColor@;
-  border-radius: @toolbarbuttonCornerRadius@;
-  box-shadow: 0 1px rgba(255, 255, 255, 0.2);
-  background: @toolbarbuttonBackground@;
-  background-origin: border-box;
+  padding: 0;
+  border: 0;
 }
 
 .toolbarbutton-1:not([type="menu-button"]):-moz-lwtheme,
 .toolbarbutton-1 > .toolbarbutton-menubutton-button:-moz-lwtheme,
 .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker:-moz-lwtheme,
 #restore-button:-moz-lwtheme {
-  border-color: rgba(0, 0, 0, 0.4);
-  background-image: -moz-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.2));
+  -moz-appearance: none;
+  padding: 0 3px;
+  border: 1px solid rgba(0, 0, 0, 0.4);
+  border-radius: @toolbarbuttonCornerRadius@;
+  background: -moz-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.2)) repeat-x;
+  background-origin: border-box;
   box-shadow: inset 0 1px rgba(255,255,255,0.3), 0 1px rgba(255,255,255,0.2);
 }
 
 .toolbarbutton-1:not([type="menu-button"]):-moz-lwtheme-darktext,
 .toolbarbutton-1 > .toolbarbutton-menubutton-button:-moz-lwtheme-darktext,
 .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker:-moz-lwtheme-darktext,
 #restore-button:-moz-lwtheme-darktext {
   background-image: -moz-linear-gradient(rgba(255,255,255,0.3), rgba(50,50,50,0.2) 50%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.13));
@@ -332,16 +333,17 @@ toolbarbutton.bookmark-item > menupopup 
   margin: 0 4px;
   list-style-image: url("chrome://browser/skin/Toolbar.png");
 }
 
 toolbar:not([mode="icons"]) .toolbarbutton-1:not([type="menu-button"]),
 toolbar:not([mode="icons"]) .toolbarbutton-1 > .toolbarbutton-menubutton-button,
 toolbar:not([mode="icons"]) .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker,
 toolbar:not([mode="icons"]) #restore-button {
+  -moz-appearance: none;
   padding: 0;
   height: auto;
   border: none;
   box-shadow: none;
   background: none;
 }
 
 .toolbarbutton-1:not([type="menu-button"]),
@@ -403,137 +405,132 @@ toolbar:not([mode="icons"]) .toolbarbutt
   opacity: .7;
 }
 
 .toolbarbutton-1 > .toolbarbutton-text,
 .toolbarbutton-1 > .toolbarbutton-menubutton-button > .toolbarbutton-text {
   margin: 2px 0 0;
 }
 
-toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"]):not([disabled="true"]):active:hover:not(:-moz-lwtheme),
-toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"])[open="true"]:not(:-moz-lwtheme),
-toolbar[mode="icons"] .toolbarbutton-1:not([disabled="true"]) > .toolbarbutton-menubutton-button:active:hover:not(:-moz-lwtheme),
-toolbar[mode="icons"] .toolbarbutton-1[open="true"] > .toolbarbutton-menubutton-dropmarker:not(:-moz-lwtheme),
-toolbar[mode="icons"] #restore-button:not([disabled="true"]):active:hover:not(:-moz-lwtheme) {
-  background: @toolbarbuttonPressedBackgroundColor@;
-  text-shadow: @loweredShadow@;
-  box-shadow: @toolbarbuttonPressedInnerShadow@, @loweredShadow@;
-}
-
 toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"]):not([disabled="true"]):active:hover:-moz-lwtheme,
 toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"])[open="true"]:-moz-lwtheme,
 toolbar[mode="icons"] .toolbarbutton-1:not([disabled="true"]) > .toolbarbutton-menubutton-button:active:hover:-moz-lwtheme,
 toolbar[mode="icons"] .toolbarbutton-1[open="true"] > .toolbarbutton-menubutton-dropmarker:-moz-lwtheme,
 toolbar[mode="icons"] #restore-button:not([disabled="true"]):active:hover:-moz-lwtheme {
   text-shadow: @loweredShadow@;
   background-color: rgba(0,0,0,0.2);
   box-shadow: inset 0 2px 5px rgba(0,0,0,0.6), 0 1px rgba(255,255,255,0.2);
 }
 
-toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"]):not(#fullscreen-button)[checked="true"]:not(:-moz-lwtheme) {
-  background: #606060;
-  box-shadow: inset #2A2A2A 0 3px 3.5px, @loweredShadow@;
-}
-
 toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"]):not(#fullscreen-button)[checked="true"]:-moz-lwtheme {
   background-color: rgba(0,0,0,0.4);
   box-shadow: inset 0 2px 5px rgba(0,0,0,0.7), 0 1px rgba(255,255,255,0.2);
 }
 
-toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"]):not(#fullscreen-button)[checked="true"]:not([disabled="true"]):active:hover:not(:-moz-lwtheme) {
-  background: #4E4E4E;
-  box-shadow: inset #1c1c1c 0 3px 3.5px;
-}
-
 toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"]):not(#fullscreen-button)[checked="true"]:not([disabled="true"]):active:hover:-moz-lwtheme {
   background-color: rgba(0, 0, 0, 0.6);
   box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8), 0 1px rgba(255, 255, 255, 0.2);
 }
 
-toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"]):-moz-window-inactive:not(:-moz-lwtheme),
-toolbar[mode="icons"] .toolbarbutton-1 > .toolbarbutton-menubutton-button:-moz-window-inactive:not(:-moz-lwtheme),
-toolbar[mode="icons"] .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker:-moz-window-inactive:not(:-moz-lwtheme),
-toolbar[mode="icons"] #restore-button:-moz-window-inactive:not(:-moz-lwtheme) {
-  border-color: @toolbarbuttonInactiveBorderColor@;
-  background-image: @toolbarbuttonInactiveBackgroundImage@;
-}
-
-toolbar[mode="icons"] .toolbarbutton-1:not([type="menu-button"]):not(#fullscreen-button)[checked="true"]:-moz-window-inactive {
-  background: #8E8E8E;
-  box-shadow: inset rgba(0, 0, 0, 0.5) 0 3px 3.5px, @loweredShadow@;
-}
-
 toolbar[mode="icons"] .toolbarbutton-1 > menupopup {
   margin-top: 1px;
 }
 
 #navigator-toolbox > toolbar {
   /* force iconsize="small" on these toolbars */
   counter-reset: smallicons;
 }
 
 /* unified back/forward button */
 
 #unified-back-forward-button {
   -moz-box-align: center;
 }
 
 #back-button,
-toolbar:not([mode="icons"]) #forward-button:-moz-locale-dir(rtl) {
+#forward-button:-moz-locale-dir(rtl),
+toolbar[mode="icons"] #back-button:-moz-locale-dir(rtl):-moz-lwtheme {
   -moz-image-region: rect(0, 40px, 20px, 20px);
 }
 
 #forward-button,
-toolbar:not([mode="icons"]) #back-button:-moz-locale-dir(rtl) {
+#back-button:-moz-locale-dir(rtl),
+#navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #forward-button:-moz-locale-dir(rtl),
+toolbar[mode="icons"] #forward-button:-moz-locale-dir(rtl):-moz-lwtheme {
   -moz-image-region: rect(0, 60px, 20px, 40px);
 }
 
+#navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #back-button:-moz-locale-dir(rtl),
+#navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #forward-button:-moz-locale-dir(rtl),
+toolbar[mode="icons"] #back-button:-moz-locale-dir(rtl):-moz-lwtheme,
+toolbar[mode="icons"] #forward-button:-moz-locale-dir(rtl):-moz-lwtheme {
+  -moz-transform: scaleX(-1);
+}
+
 #navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #back-button {
-  -moz-margin-end: -5px;
+  -moz-appearance: none;
+  -moz-margin-end: -7px;
   position: relative;
   z-index: 1;
   -moz-image-region: rect(0, 20px, 20px, 0);
   width: 30px;
   height: 30px;
   padding: 4px 5px 4px 3px;
   border-radius: 10000px;
 }
 
-toolbar[mode="icons"] #back-button:-moz-locale-dir(rtl),
-toolbar[mode="icons"] #forward-button:-moz-locale-dir(rtl) {
-  -moz-transform: scaleX(-1);
+#navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #back-button:not(:-moz-lwtheme) {
+  height: 31px;
+  padding: 4px 5px 5px 3px;
+  margin-bottom: -1px;
+  background: url(chrome://browser/skin/keyhole-circle.png) 0 0 no-repeat;
+}
+
+#navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #back-button:-moz-window-inactive:not(:-moz-lwtheme) {
+  background-position: -60px 0;
+}
+
+#navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #back-button:not([disabled="true"]):active:hover:not(:-moz-lwtheme),
+#navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #back-button[open="true"]:not(:-moz-lwtheme) {
+  background-position: -30px 0;
 }
 
 toolbar[mode="icons"] #forward-button {
   -moz-margin-start: 0;
 }
 
+#navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #forward-button > .toolbarbutton-icon {
+  /* shift the icon away from the back button */
+  margin-left: 3px;
+  margin-right: -1px;
+}
+
 #navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #forward-button {
-  /* 1px to the right */
-  padding-left: 4px;
-  padding-right: 2px;
-}
-
-#navigator-toolbox[iconsize="large"][mode="icons"] > #nav-bar #forward-button:-moz-lwtheme {
   mask: url(chrome://browser/content/browser.xul#pinstripe-keyhole-forward-mask);
 }
 
 #navigator-toolbox[iconsize="small"][mode="icons"] > #nav-bar #forward-button {
   width: 27px;
+}
+
+#navigator-toolbox[iconsize="small"][mode="icons"] > #nav-bar #forward-button:-moz-lwtheme {
   padding-left: 2px;
 }
 
-toolbar[mode="icons"] #forward-button {
+toolbar[mode="icons"] #forward-button:-moz-lwtheme {
   border-top-left-radius: 0;
   border-bottom-left-radius: 0;
 }
 
 #navigator-toolbox[iconsize="small"][mode="icons"] > #nav-bar #back-button {
   -moz-margin-end: 0;
   width: 26px;
+}
+
+#navigator-toolbox[iconsize="small"][mode="icons"] > #nav-bar #back-button:-moz-lwtheme {
   padding-right: 2px;
   border-right-width: 0;
   border-top-right-radius: 0;
   border-bottom-right-radius: 0;
 }
 
 .unified-nav-back[_moz-menuactive]:-moz-locale-dir(ltr),
 .unified-nav-forward[_moz-menuactive]:-moz-locale-dir(rtl) {
@@ -1771,44 +1768,45 @@ toolbarbutton.chevron > .toolbarbutton-m
 }
 
 #TabsToolbar {
   -moz-appearance: none;
   height: 26px;
   background-repeat: repeat-x;
 }
 
-#TabsToolbar:not(:-moz-lwtheme) {
-  background-color: -moz-mac-chrome-active;
-}
-
-#TabsToolbar:not(:-moz-lwtheme):-moz-window-inactive {
-  background-color: -moz-mac-chrome-inactive;
-}
-
 #TabsToolbar[tabsontop="false"] {
-  margin-top: -1px;
+  margin-top: -2px;
   padding-top: 2px;
 }
 
+/* For tabs-on-top, only fill the bottom 2px with the chrome background
+ * color, so that the borders in tabbar-top-bg-*.png can mix with it.
+ * In the top 24px the unified toolbar (from the ::before above) will show.
+ */
 #TabsToolbar[tabsontop="true"]:not(:-moz-lwtheme) {
   padding-bottom: 2px;
-  background-image: url(chrome://browser/skin/tabbrowser/tabbar-top-bg-active.png) ;
+  background: url(chrome://browser/skin/tabbrowser/tabbar-top-bg-active.png),
+              -moz-linear-gradient(bottom, -moz-mac-chrome-active 2px, transparent 2px);
 }
 
 #TabsToolbar[tabsontop="true"]:not(:-moz-lwtheme):-moz-window-inactive {
-  background-image: url(chrome://browser/skin/tabbrowser/tabbar-top-bg-inactive.png);
-}
-
+  background: url(chrome://browser/skin/tabbrowser/tabbar-top-bg-inactive.png),
+              -moz-linear-gradient(bottom, -moz-mac-chrome-inactive 2px, transparent 2px);
+}
+
+/* In tabs-on-bottom mode, fill the whole toolbar with the chrome
+ * background color.
+ */
 #TabsToolbar[tabsontop="false"]:not(:-moz-lwtheme) {
-  background-image: url(chrome://browser/skin/tabbrowser/tabbar-bottom-bg-active.png);
+  background: url(chrome://browser/skin/tabbrowser/tabbar-bottom-bg-active.png) -moz-mac-chrome-active;
 }
 
 #TabsToolbar[tabsontop="false"]:not(:-moz-lwtheme):-moz-window-inactive {
-  background-image: url(chrome://browser/skin/tabbrowser/tabbar-bottom-bg-inactive.png);
+  background: url(chrome://browser/skin/tabbrowser/tabbar-bottom-bg-inactive.png) -moz-mac-chrome-inactive;
 }
 
 #tabbrowser-tabs {
   -moz-box-align: stretch;
   height: 26px;
 }
 
 #tabbrowser-tabs[tabsontop="true"] > .tabbrowser-arrowscrollbox > .arrowscrollbox-scrollbox:not(:-moz-lwtheme) {
@@ -1950,21 +1948,22 @@ toolbarbutton.chevron > .toolbarbutton-m
 
 /**
  * Tabstrip & add-on bar toolbar buttons
  */
 
 :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1,
 :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1 > .toolbarbutton-menubutton-button,
 :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker {
-  margin: 0;
-  padding: 0;
-  border: none;
-  border-radius: 0;
+  -moz-appearance: none;
   /* !important flags needed because of bug 561154: */
+  margin: 0 !important;
+  padding: 0 !important;
+  border: none !important;
+  border-radius: 0 !important;
   background: none !important;
   box-shadow: none !important;
 }
 
 :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1:not([type="menu-button"]),
 :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1 > .toolbarbutton-menubutton-button,
 :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker {
   margin: 0;
--- a/browser/themes/pinstripe/browser/jar.mn
+++ b/browser/themes/pinstripe/browser/jar.mn
@@ -37,16 +37,17 @@ browser.jar:
   skin/classic/browser/reload-stop-go.png
   skin/classic/browser/searchbar-dropmarker.png
   skin/classic/browser/searchbar.css
   skin/classic/browser/Search.png
   skin/classic/browser/section_collapsed.png
   skin/classic/browser/section_collapsed-rtl.png
   skin/classic/browser/section_expanded.png
   skin/classic/browser/Secure-Glyph-White.png
+  skin/classic/browser/keyhole-circle.png
   skin/classic/browser/Toolbar.png
   skin/classic/browser/toolbarbutton-dropmarker.png
   skin/classic/browser/urlbar-arrow.png
   skin/classic/browser/urlbar-popup-blocked.png
   skin/classic/browser/feeds/subscribe.css                  (feeds/subscribe.css)
   skin/classic/browser/feeds/subscribe-ui.css               (feeds/subscribe-ui.css)
   skin/classic/browser/feeds/feedIcon.png                   (feeds/feedIcon.png)
   skin/classic/browser/feeds/feedIcon16.png                 (feeds/feedIcon16.png)
@@ -129,8 +130,13 @@ browser.jar:
   skin/classic/browser/sync-bg.png
   skin/classic/browser/sync-desktopIcon.png
   skin/classic/browser/sync-mobileIcon.png
   skin/classic/browser/sync-notification-24.png
   skin/classic/browser/syncSetup.css
   skin/classic/browser/syncCommon.css
   skin/classic/browser/syncQuota.css
 #endif
+  skin/classic/browser/lion/keyhole-circle.png              (keyhole-circle-lion.png)
+  skin/classic/browser/lion/Toolbar.png                     (Toolbar-lion.png)
+
+% override chrome://browser/skin/keyhole-circle.png chrome://browser/skin/lion/keyhole-circle.png os=Darwin osversion>=10.7
+% override chrome://browser/skin/Toolbar.png chrome://browser/skin/lion/Toolbar.png os=Darwin osversion>=10.7
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f164d498c351e2541fadcbfb9b1e7a8334a7e581
GIT binary patch
literal 2261
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
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c3ecea0315f6f42b06dc2fe869d6d0461fef0930
GIT binary patch
literal 2262
zc$@*&2r2i8P)<h;3K|Lk000e1NJLTq003G50018d1ONa4%`_5L00004XF*Lt006JZ
zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU)Xh}ptR9M5U
zn14`HR~E;^SpIPQXUDNPb&9h)<68e|t@}^^$f%>zK@1e3wxGjMVqvI*qKhI}FpUDD
zM2$R9AX=y_Ly2_3AE1EjhA0Y{1+B1B?X1#82u6&=G=bzj-*-=50s$eAIGfL$%(>^D
zGaT+a@7{AG5>5N;TabTHb|=ZWm5tyd_^oV`QFbT);JyVSFFxYM;&8ECd_jCi{Dine
znw%_)y@_Q4m`zL?Q_3_mcZp`w(#R4pXW;3;!;R5w2CC7G7qAj9NUKH$qS?cZrvqnA
z_yh6YwKq1s++vBfC33s?U3?-JYujSk^m6SD@m}!<vnITZNjh8KIB?%MU@@~C&+%q<
zz;fT%IB>R}Nn)1G5}K#j%I2dVV>8f?d~CDlDLf?XCyrgG4SyxI@1uY45VCQE$R;fV
z`yjQ4zgnji$BO-COxTZ!DyzR`(2w$%j(+r(p{$;XVrGh!zmwjTNULgvg|G@@b!p>t
zBM~y)g?ZCb4iL*W8e_-Ok%f~e!uKdg1yN2~5m~a3j@Yq{MzKsh?O`*EnAG~GeZRkk
zXZn7xf6AmXi{1#mFfX@zJBDF)@k)?aF3rs_LXq-V{?62t*C@hFJ2*L%l;n@7#T8sb
zBXNziTC#jkGji<U!c1!vQ`2S^6&}_+dtqlWJ1^{-XN8B~NPGX?P)caT3x**@hHi3U
ztdWPAl3(Z0npWa6nxMf=wBi=gN}7f&muaR5IY@p@Y0KS3!uS=YYo3`nJLbm3QQGN~
zisXnQ0fR6SF9h+7V^)s@9GR$Xacs!TBrXRkdR?zlimkYfc67LCr%@|euhOiF(oW(+
zUW#KUl8&kyFxbc79R_>d02Ad3JrNki>R`Zg!XSvjrMa1E*CC2M5$N18f?B__Wl=&u
zp#fT2-8M>eDs5!d((F&<m4&ZtL9Nc6gjrVJ@T+AM-t()ayur1TWHjYr$OC#o^e)ZK
zF=RA3V%Mi{HfN#`YO3FsiL!VTN13#chnhSyvDv&n-4T0ckM_9*zM*}7W{=2mlzhS7
z$AAY01sQZ{Ztmj?cHaW=;-Iz!dmheH)&7Ihx-kna<Z+oi^N?T<Y7;MJ0!o`7kDB2d
zk4H<J>A1-~xR>_e{|e$6r-$3GAA6B|aDAj?Bm<{u1+StR|D1zn@=}v`1|%cvBhQ4@
z=}qvRI{le2(SDr@PtYewpG%uQ9%tO%hqFl4Z9Eob&7lpgmMXRh*XN*#ylTli2T|6I
z$Ic#VA2Gsr+DFbF62%*@<3DdfGvbY(UWvCU=m@z)_1fSC*T}OR3dGw!y`rjmU>%0<
zJg};&M4z)=c=Q%@;d6FFcQU8M-)Q~nyrh=Al}P3`bQj(3V-4_~KDOw#NW%Bv7xW6^
z#%Xce$H#7Z5X!H8n#!M|<GO}c&^v0#`xH_s@^tS2KLp<y;7|8b(m&(h6Z8nu<I+5j
zdvK4EUN^X(SJDHo#^1f9n!J_RPmx6r`}qO*PCsAtP!!3w(FW!_ZHQ!pdUkUsP)gl}
z+Dm>U?-SU~1@)A4JYxIdJCE3s4pE%(BJNIbPY^dw%S>EEoKeykZ#zckTm|(O-cdo`
z$LK|rG@h&Nvi=6&>9U@y747L%q7(lTWIE0n_x$*{lPYs}*Or24YZjeyW%SU!ql~<>
z5N+L3P=35+<OzJIWu*MLC_6U^cjlx+kPesT_)bE0u5^2-DTDfD6+QGaFDNC?lXSR*
znxxy+u{A?)v(?rNsbfVq-rLMJP=)$N12(fa-czgy=}ffepn#G&=LIVA%t4|(q*Jj%
zyS(hCZq(O}RySI9Q@dOQzm%45g+`}!61OHg;#)J0zr|l$;0OPhyhw8f9Tx@EFBi{2
z5qT+Sog>XLdGLpSWp>^0FYt}J;mU0IQ_FOHRRnv%)z)YQapSbO?N03iBG~Jz9GzO$
zYKcy2JA~tOgDj-J!ZU^Bah&dqQkz7Vwb~KeEH2l!S{}fAS}o<;X0gzkVxGKsn{eaM
zP+OxBnj5D!GfmhAc`<~WBIYNgZ8GiT4pH}}q_h|h<kM^(rM#2dWJ*ZGd}nNRidwI;
z_rN=JcD24b#Tn}eU-(UT0^RAFy`T}n_~t$qj^9440Wrnl<~^_FI7&P4NlNb28z{+o
zf@bB|^E%udQ*52MCE5cj^J@*ATsP*XldCmU=G!OVFh~9r_ggUa28}M71aafEG?K?o
zB=?T~aq|7LVrBICaB~uuNt;<Nt*3&@z>R_|xiphWSFLb!^!bXFlVk6GR8dl6=&=8c
z+3B#?7%EEcel+D`3%{{tiQUoofjTh<R|UE1(#H7#(Maqz{TWk!gMfe4s+eMlDbAJ-
z84lC_aD>u4O5~E3LlznRgb-(wm|}{nRtc}sq}Y2OSLRpgHI{qujK)%>ugt&q@zhu$
zZ7j`Hea5EHxpjqB^or1xIW@<3B~tJio2kN5O#9gc{$qi=WD;G3Io_U%1GK6#d`HMg
zJAhQg+at^p-7eW!;IuzWv25VQ1Lw6Dhqa?!n2vVz;xNq~U}uPR)%NWTJ6poouc`iu
zsZ*$>u1rnZcla7%?9P_k8{D-#E%x2w5UDbxGt~5@RchP8?dEs$J2<KBOKYepq*JOa
z4#B&gW7~t(N6T)ihw4W();3nh>-aWSW33-i50Uj~d$8wNVJE?oC!ffbiCxjgFgBPE
z=0n+NV`7(F`Q#HU!93AyvGcK{ZcSQBj4G@tsAt{ay1}5Hu%;MQT1wp-ik&}KZ13v&
z<jR85OC=pe4~rg_bd+AIET~WJT|HOqc%l4(ieLp+;xEKX(w36NZ_YsBVPhfQ$8vm#
kRm6v+y-ybZ|8MO703C%2de`kFq5uE@07*qoM6N<$f+T@*r2qf`
--- a/browser/themes/pinstripe/browser/places/organizer.css
+++ b/browser/themes/pinstripe/browser/places/organizer.css
@@ -75,43 +75,19 @@
   min-width: 1px;
   width: 1px;
   background-image: none !important;       
 }
 
 #placesToolbar > toolbarbutton {
   list-style-image: url("chrome://browser/skin/places/toolbar.png");
   margin: 4px 4px 5px;
-  padding: 1px 3px;
-  border: 1px solid @toolbarbuttonBorderColor@;
-  border-radius: @toolbarbuttonCornerRadius@;
-  box-shadow: @loweredShadow@;
-  background: @toolbarbuttonBackground@;
-  background-origin: border-box;
-}
-
-#placesToolbar > toolbarbutton:not([disabled="true"]):active:hover,
-#placesToolbar > toolbarbutton[open="true"] {
-  background: @toolbarbuttonPressedBackgroundColor@;
-  text-shadow: @loweredShadow@;
-  box-shadow: @toolbarbuttonPressedInnerShadow@, @loweredShadow@;
-}
-
-#placesToolbar > toolbarbutton:-moz-focusring {
-  border-color: @toolbarbuttonFocusedBorderColorAqua@;
-  box-shadow: @focusRingShadow@;
-}
-
-#placesToolbar > toolbarbutton:-moz-system-metric(mac-graphite-theme):-moz-focusring {
-  border-color: @toolbarbuttonFocusedBorderColorGraphite@;
-}
-
-#placesToolbar > toolbarbutton:-moz-window-inactive {
-  border-color: @toolbarbuttonInactiveBorderColor@;
-  background-image: @toolbarbuttonInactiveBackgroundImage@;
+  padding: 0;
+  height: 22px;
+  -moz-appearance: toolbarbutton;
 }
 
 #placesToolbar > toolbarbutton[disabled="true"] > .toolbarbutton-icon {
   opacity: 0.5;
 }
 
 #placesToolbar > toolbarbutton > .toolbarbutton-icon {
   margin: 1px 4px;
@@ -131,27 +107,22 @@
 #placesToolbar > toolbarbutton > menupopup {
   margin-top: 1px;
 }
 
 /* back and forward button */
 #back-button:-moz-locale-dir(ltr),
 #forward-button:-moz-locale-dir(rtl) {
   -moz-image-region: rect(0px, 16px, 16px, 0px);
-  border-top-right-radius: 0;
-  border-bottom-right-radius: 0;
   margin-right: 0;
-  border-right: 0;
 }
 
 #forward-button:-moz-locale-dir(ltr),
 #back-button:-moz-locale-dir(rtl) {
   -moz-image-region: rect(0px, 32px, 16px, 16px);
-  border-top-left-radius: 0;
-  border-bottom-left-radius: 0;
   margin-left: 0;
 }
 
 #back-button > .toolbarbutton-icon {
   -moz-margin-start: 3px !important;
   -moz-margin-end: 2px !important;
 }
 
index 0e7f271a5d67058ca678b238595523806ba72ec4..fc7b3497d55e5b665e0308ccab26cae7598887fd
GIT binary patch
literal 121
zc%17D@N?(olHy`uVBq!ia0vp^B0wy~!3HF^H`mkxDF;s%$B>F!Z_jMxWKa+}av|7J
zAZLxtRo1(&kK8lr{lL7wH)nB@#9@hJA6`!LsOK^EVO_=*+`RIzNy01x-6?N<t-@Z;
VS4xWCe+Ot5gQu&X%Q~loCIFS#DhU7p
index 0c7a196de516f54cbd1ab19b06d46236c43ad206..c47147cbddb44e5f154c31d372b0de49c44de4db
GIT binary patch
literal 118
zc%17D@N?(olHy`uVBq!ia0vp^B0wy~!3HF^H`mkxDO*n$$B>F!Z!aF?WKiI7zPLhR
zM<DyFb$y{P`Ti@Zd|3BiC{*;6BfD(Lg@f@;dl@gcWFFj-XtkolBPhPslYjZ~i)+6v
S?3xBNh{4m<&t;ucLK6TKjwz%7
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -244,17 +244,17 @@ nsFrameMessageManager::SendSyncMessage()
       NS_ENSURE_SUCCESS(rv, rv);
       JSAutoRequest ar(ctx);
 
       PRUint32 len = retval.Length();
       JSObject* dataArray = JS_NewArrayObject(ctx, len, NULL);
       NS_ENSURE_TRUE(dataArray, NS_ERROR_OUT_OF_MEMORY);
 
       for (PRUint32 i = 0; i < len; ++i) {
-        if (!retval[i].Length())
+        if (retval[i].IsEmpty())
           continue;
 
         jsval ret = JSVAL_VOID;
         if (!JS_ParseJSON(ctx, (jschar*)retval[i].get(),
                           (uint32)retval[i].Length(), &ret)) {
           return NS_ERROR_UNEXPECTED;
         }
         NS_ENSURE_TRUE(JS_SetElement(ctx, dataArray, i, &ret), NS_ERROR_OUT_OF_MEMORY);
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -1122,36 +1122,16 @@ nsINode::DispatchDOMEvent(nsEvent* aEven
                           nsIDOMEvent* aDOMEvent,
                           nsPresContext* aPresContext,
                           nsEventStatus* aEventStatus)
 {
   return nsEventDispatcher::DispatchDOMEvent(this, aEvent, aDOMEvent,
                                              aPresContext, aEventStatus);
 }
 
-nsresult
-nsINode::AddEventListenerByIID(nsIDOMEventListener *aListener,
-                               const nsIID& aIID)
-{
-  nsEventListenerManager* elm = GetListenerManager(PR_TRUE);
-  NS_ENSURE_STATE(elm);
-  return elm->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
-}
-
-nsresult
-nsINode::RemoveEventListenerByIID(nsIDOMEventListener *aListener,
-                                  const nsIID& aIID)
-{
-  nsEventListenerManager* elm = GetListenerManager(PR_FALSE);
-  if (elm) {
-    elm->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
-  }
-  return NS_OK;
-}
-
 nsEventListenerManager*
 nsINode::GetListenerManager(PRBool aCreateIfNotFound)
 {
   return nsContentUtils::GetListenerManager(this, aCreateIfNotFound);
 }
 
 nsIScriptContext*
 nsINode::GetContextForEventHandlers(nsresult* aRv)
--- a/content/canvas/src/CanvasUtils.h
+++ b/content/canvas/src/CanvasUtils.h
@@ -157,17 +157,17 @@ JSValToDashArray(JSContext* cx, const js
             // Not an array-like thing
             return NS_ERROR_INVALID_ARG;
         } else if (length > MAX_NUM_DASHES) {
             // Too many dashes in the pattern
             return NS_ERROR_ILLEGAL_VALUE;
         }
 
         bool haveNonzeroElement = false;
-        for (jsint i = 0; i < jsint(length); ++i) {
+        for (uint32 i = 0; i < length; ++i) {
             jsval elt;
             double d;
             if (!JS_GetElement(cx, obj, i, &elt)) {
                 return NS_ERROR_FAILURE;
             }
             if (!(CoerceDouble(elt, &d) &&
                   FloatValidate(d) &&
                   d >= 0.0)) {
--- a/content/events/src/nsDOMEventTargetHelper.cpp
+++ b/content/events/src/nsDOMEventTargetHelper.cpp
@@ -201,36 +201,16 @@ nsDOMEventTargetHelper::GetListenerManag
 {
   if (!mListenerManager && aCreateIfNotFound) {
     mListenerManager = new nsEventListenerManager(this);
   }
 
   return mListenerManager;
 }
 
-nsresult
-nsDOMEventTargetHelper::AddEventListenerByIID(nsIDOMEventListener *aListener,
-                                              const nsIID& aIID)
-{
-  nsEventListenerManager* elm = GetListenerManager(PR_TRUE);
-  NS_ENSURE_STATE(elm);
-  return elm->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
-}
-
-nsresult
-nsDOMEventTargetHelper::RemoveEventListenerByIID(nsIDOMEventListener *aListener,
-                                                 const nsIID& aIID)
-{
-  nsEventListenerManager* elm = GetListenerManager(PR_FALSE);
-  if (elm) {
-    elm->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
-  }
-  return NS_OK;
-}
-
 nsIScriptContext*
 nsDOMEventTargetHelper::GetContextForEventHandlers(nsresult* aRv)
 {
   *aRv = CheckInnerWindowCorrectness();
   if (NS_FAILED(*aRv)) {
     return nsnull;
   }
   return mScriptContext;
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -37,26 +37,16 @@
 
 #include "nsISupports.h"
 #include "nsGUIEvent.h"
 #include "nsDOMEvent.h"
 #include "nsEventListenerManager.h"
 #include "nsCaret.h"
 #include "nsIDOMNSEvent.h"
 #include "nsIDOMEventListener.h"
-#include "nsIDOMMouseListener.h"
-#include "nsIDOMMouseMotionListener.h"
-#include "nsIDOMContextMenuListener.h"
-#include "nsIDOMKeyListener.h"
-#include "nsIDOMFocusListener.h"
-#include "nsIDOMFormListener.h"
-#include "nsIDOMLoadListener.h"
-#include "nsIDOMTextListener.h"
-#include "nsIDOMCompositionListener.h"
-#include "nsIDOMUIListener.h"
 #include "nsITextControlFrame.h"
 #include "nsGkAtoms.h"
 #include "nsPIDOMWindow.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIJSEventListener.h"
 #include "prmem.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptRuntime.h"
@@ -90,23 +80,19 @@
 #include "nsCOMArray.h"
 #include "nsEventListenerService.h"
 #include "nsDOMEvent.h"
 #include "nsIContentSecurityPolicy.h"
 
 using namespace mozilla::dom;
 
 #define EVENT_TYPE_EQUALS( ls, type, userType ) \
-  (ls->mEventType && ls->mEventType == type && \
+  (ls->mEventType == type && \
   (ls->mEventType != NS_USER_DEFINED_EVENT || ls->mTypeAtom == userType))
 
-#define EVENT_TYPE_DATA_EQUALS( type1, type2 ) \
-  (type1 && type2 && type1->iid && type2->iid && \
-   type1->iid->Equals(*(type2->iid)))
-
 static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
                      NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
 
 static const PRUint32 kAllMutationBits =
   NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED |
   NS_EVENT_BITS_MUTATION_NODEINSERTED |
   NS_EVENT_BITS_MUTATION_NODEREMOVED |
   NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT |
@@ -133,147 +119,16 @@ MutationBitForEventType(PRUint32 aEventT
     case NS_MUTATION_CHARACTERDATAMODIFIED:
       return NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED;
     default:
       break;
   }
   return 0;
 }
 
-typedef
-NS_STDCALL_FUNCPROTO(nsresult,
-                     GenericHandler,
-                     nsIDOMEventListener, HandleEvent, 
-                     (nsIDOMEvent*));
-
-/*
- * Things here are not as they appear.  Namely, |ifaceListener| below is
- * not really a pointer to the nsIDOMEventListener interface, and aMethod is
- * not really a pointer-to-member for nsIDOMEventListener.  They both
- * actually refer to the event-type-specific listener interface.  The casting
- * magic allows us to use a single dispatch method.  This relies on the
- * assumption that nsIDOMEventListener and the event type listener interfaces
- * have the same object layout and will therefore have compatible
- * pointer-to-member implementations.
- */
-
-static nsresult DispatchToInterface(nsIDOMEvent* aEvent,
-                                    nsIDOMEventListener* aListener,
-                                    GenericHandler aMethod,
-                                    const nsIID& aIID)
-{
-  nsIDOMEventListener* ifaceListener = nsnull;
-  nsresult rv = NS_OK;
-  aListener->QueryInterface(aIID, (void**) &ifaceListener);
-  NS_WARN_IF_FALSE(ifaceListener,
-                   "DispatchToInterface couldn't QI to the right interface");
-  if (ifaceListener) {
-    rv = (ifaceListener->*aMethod)(aEvent);
-    NS_RELEASE(ifaceListener);
-  }
-  return rv;
-}
-
-struct EventDispatchData
-{
-  PRUint32 message;
-  GenericHandler method;
-};
-
-struct EventTypeData
-{
-  const EventDispatchData* events;
-  int                      numEvents;
-  const nsIID*             iid;
-};
-
-#define HANDLER(x) reinterpret_cast<GenericHandler>(x)
-
-static const EventDispatchData sMouseEvents[] = {
-  { NS_MOUSE_BUTTON_DOWN,        HANDLER(&nsIDOMMouseListener::MouseDown)     },
-  { NS_MOUSE_BUTTON_UP,          HANDLER(&nsIDOMMouseListener::MouseUp)       },
-  { NS_MOUSE_CLICK,              HANDLER(&nsIDOMMouseListener::MouseClick)    },
-  { NS_MOUSE_DOUBLECLICK,        HANDLER(&nsIDOMMouseListener::MouseDblClick) },
-  { NS_MOUSE_ENTER_SYNTH,        HANDLER(&nsIDOMMouseListener::MouseOver)     },
-  { NS_MOUSE_EXIT_SYNTH,         HANDLER(&nsIDOMMouseListener::MouseOut)      }
-};
-
-static const EventDispatchData sMouseMotionEvents[] = {
-  { NS_MOUSE_MOVE, HANDLER(&nsIDOMMouseMotionListener::MouseMove) }
-};
-
-static const EventDispatchData sContextMenuEvents[] = {
-  { NS_CONTEXTMENU, HANDLER(&nsIDOMContextMenuListener::ContextMenu) }
-};
-
-static const EventDispatchData sCompositionEvents[] = {
-  { NS_COMPOSITION_START,
-    HANDLER(&nsIDOMCompositionListener::HandleStartComposition)  },
-  { NS_COMPOSITION_END,
-    HANDLER(&nsIDOMCompositionListener::HandleEndComposition)    }
-};
-
-static const EventDispatchData sTextEvents[] = {
-  { NS_TEXT_TEXT, HANDLER(&nsIDOMTextListener::HandleText) }
-};
-
-static const EventDispatchData sKeyEvents[] = {
-  { NS_KEY_UP,    HANDLER(&nsIDOMKeyListener::KeyUp)    },
-  { NS_KEY_DOWN,  HANDLER(&nsIDOMKeyListener::KeyDown)  },
-  { NS_KEY_PRESS, HANDLER(&nsIDOMKeyListener::KeyPress) }
-};
-
-static const EventDispatchData sFocusEvents[] = {
-  { NS_FOCUS_CONTENT, HANDLER(&nsIDOMFocusListener::Focus) },
-  { NS_BLUR_CONTENT,  HANDLER(&nsIDOMFocusListener::Blur)  }
-};
-
-static const EventDispatchData sFormEvents[] = {
-  { NS_FORM_SUBMIT,   HANDLER(&nsIDOMFormListener::Submit) },
-  { NS_FORM_RESET,    HANDLER(&nsIDOMFormListener::Reset)  },
-  { NS_FORM_CHANGE,   HANDLER(&nsIDOMFormListener::Change) },
-  { NS_FORM_SELECTED, HANDLER(&nsIDOMFormListener::Select) },
-  { NS_FORM_INPUT,    HANDLER(&nsIDOMFormListener::Input)  }
-};
-
-static const EventDispatchData sLoadEvents[] = {
-  { NS_LOAD,               HANDLER(&nsIDOMLoadListener::Load)         },
-  { NS_PAGE_UNLOAD,        HANDLER(&nsIDOMLoadListener::Unload)       },
-  { NS_LOAD_ERROR,         HANDLER(&nsIDOMLoadListener::Error)        },
-  { NS_BEFORE_PAGE_UNLOAD, HANDLER(&nsIDOMLoadListener::BeforeUnload) }
-};
-
-static const EventDispatchData sUIEvents[] = {
-  { NS_UI_ACTIVATE, HANDLER(&nsIDOMUIListener::Activate) },
-  { NS_UI_FOCUSIN,  HANDLER(&nsIDOMUIListener::FocusIn)  },
-  { NS_UI_FOCUSOUT, HANDLER(&nsIDOMUIListener::FocusOut) }
-};
-
-#define IMPL_EVENTTYPEDATA(type) \
-{ \
-  s##type##Events, \
-  NS_ARRAY_LENGTH(s##type##Events), \
-  &NS_GET_IID(nsIDOM##type##Listener) \
-}
- 
-// IMPORTANT: indices match up with eEventArrayType_ enum values
-
-static const EventTypeData sEventTypes[] = {
-  IMPL_EVENTTYPEDATA(Mouse),
-  IMPL_EVENTTYPEDATA(MouseMotion),
-  IMPL_EVENTTYPEDATA(ContextMenu),
-  IMPL_EVENTTYPEDATA(Key),
-  IMPL_EVENTTYPEDATA(Load),
-  IMPL_EVENTTYPEDATA(Focus),
-  IMPL_EVENTTYPEDATA(Form),
-  IMPL_EVENTTYPEDATA(Text),
-  IMPL_EVENTTYPEDATA(Composition),
-  IMPL_EVENTTYPEDATA(UI)
-};
-
 PRUint32 nsEventListenerManager::sCreatedCount = 0;
 
 nsEventListenerManager::nsEventListenerManager(nsISupports* aTarget) :
   mMayHavePaintEventListener(PR_FALSE),
   mMayHaveMutationListeners(PR_FALSE),
   mMayHaveCapturingListeners(PR_FALSE),
   mMayHaveSystemGroupListeners(PR_FALSE),
   mMayHaveAudioAvailableEventListener(PR_FALSE),
@@ -328,43 +183,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE
   }  
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(nsEventListenerManager)
   tmp->Disconnect();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 
-const EventTypeData*
-nsEventListenerManager::GetTypeDataForIID(const nsIID& aIID)
-{
-  for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(sEventTypes); ++i) {
-    if (aIID.Equals(*(sEventTypes[i].iid))) {
-      return &sEventTypes[i];
-    }
-  }
-  return nsnull;
-}
-
-const EventTypeData*
-nsEventListenerManager::GetTypeDataForEventName(nsIAtom* aName)
-{
-  PRUint32 event = nsContentUtils::GetEventId(aName);
-  if (event != NS_USER_DEFINED_EVENT) {
-    for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(sEventTypes); ++i) {
-      for (PRInt32 j = 0; j < sEventTypes[i].numEvents; ++j) {
-         if (event == sEventTypes[i].events[j].message) {
-           return &sEventTypes[i];
-         }
-      }
-    }
-  }
-  return nsnull;
-}
-
 nsPIDOMWindow*
 nsEventListenerManager::GetInnerWindowForTarget()
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(mTarget);
   if (node) {
     // XXX sXBL/XBL2 issue -- do we really want the owner here?  What
     // if that's the XBL document?
     nsIDocument* document = node->GetOwnerDoc();
@@ -380,62 +208,42 @@ nsEventListenerManager::GetInnerWindowFo
 
   return nsnull;
 }
 
 nsresult
 nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
                                          PRUint32 aType,
                                          nsIAtom* aTypeAtom,
-                                         const EventTypeData* aTypeData,
                                          PRInt32 aFlags)
 {
   NS_ENSURE_TRUE(aListener, NS_ERROR_FAILURE);
-  NS_ENSURE_TRUE(aType || aTypeData, NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(aType, NS_ERROR_FAILURE);
 
   nsRefPtr<nsIDOMEventListener> kungFuDeathGrip = aListener;
 
-  if (!aTypeData) {
-    // If we don't have type data, we can try to QI listener to the right
-    // interface and set mTypeData only if QI succeeds. This way we can save
-    // calls to DispatchToInterface (in HandleEvent) in those cases when QI
-    // would fail.
-    // @see also DispatchToInterface()
-    const EventTypeData* td = GetTypeDataForEventName(aTypeAtom);
-    if (td && td->iid) {
-      nsIDOMEventListener* ifaceListener = nsnull;
-      aListener->QueryInterface(*(td->iid), (void**) &ifaceListener);
-      if (ifaceListener) {
-        aTypeData = td;
-        NS_RELEASE(ifaceListener);
-      }
-    }
-  }
-
   nsListenerStruct* ls;
   PRUint32 count = mListeners.Length();
   for (PRUint32 i = 0; i < count; i++) {
     ls = &mListeners.ElementAt(i);
     if (ls->mListener == aListener && ls->mFlags == aFlags &&
-        (EVENT_TYPE_EQUALS(ls, aType, aTypeAtom) ||
-         EVENT_TYPE_DATA_EQUALS(aTypeData, ls->mTypeData))) {
+        EVENT_TYPE_EQUALS(ls, aType, aTypeAtom)) {
       return NS_OK;
     }
   }
 
   mNoListenerForEvent = NS_EVENT_TYPE_NULL;
   mNoListenerForEventAtom = nsnull;
 
   ls = mListeners.AppendElement();
   ls->mListener = aListener;
   ls->mEventType = aType;
   ls->mTypeAtom = aTypeAtom;
   ls->mFlags = aFlags;
   ls->mHandlerIsString = PR_FALSE;
-  ls->mTypeData = aTypeData;
 
   if (aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) {
     mMayHaveSystemGroupListeners = PR_TRUE;
   }
   if (aFlags & NS_EVENT_FLAG_CAPTURE) {
     mMayHaveCapturingListeners = PR_TRUE;
   }
 
@@ -486,90 +294,69 @@ nsEventListenerManager::AddEventListener
 
   return NS_OK;
 }
 
 void
 nsEventListenerManager::RemoveEventListener(nsIDOMEventListener *aListener, 
                                             PRUint32 aType,
                                             nsIAtom* aUserType,
-                                            const EventTypeData* aTypeData,
                                             PRInt32 aFlags)
 {
-  if (!aListener || !(aType || aTypeData)) {
+  if (!aListener || !aType) {
     return;
   }
 
   nsListenerStruct* ls;
   aFlags &= ~NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
 
   PRUint32 count = mListeners.Length();
   for (PRUint32 i = 0; i < count; ++i) {
     ls = &mListeners.ElementAt(i);
     if (ls->mListener == aListener &&
         ((ls->mFlags & ~NS_PRIV_EVENT_UNTRUSTED_PERMITTED) == aFlags) &&
-        (EVENT_TYPE_EQUALS(ls, aType, aUserType) ||
-         (!(ls->mEventType) &&
-          EVENT_TYPE_DATA_EQUALS(ls->mTypeData, aTypeData)))) {
+        EVENT_TYPE_EQUALS(ls, aType, aUserType)) {
       nsRefPtr<nsEventListenerManager> kungFuDeathGrip = this;
       mListeners.RemoveElementAt(i);
       mNoListenerForEvent = NS_EVENT_TYPE_NULL;
       mNoListenerForEventAtom = nsnull;
       break;
     }
   }
 }
 
-nsresult
-nsEventListenerManager::AddEventListenerByIID(nsIDOMEventListener *aListener, 
-                                              const nsIID& aIID,
-                                              PRInt32 aFlags)
-{
-  return AddEventListener(aListener, NS_EVENT_TYPE_NULL, nsnull,
-                          GetTypeDataForIID(aIID), aFlags);
-}
-
-void
-nsEventListenerManager::RemoveEventListenerByIID(nsIDOMEventListener *aListener, 
-                                                 const nsIID& aIID,
-                                                 PRInt32 aFlags)
+static inline PRBool
+ListenerCanHandle(nsListenerStruct* aLs, nsEvent* aEvent)
 {
-  RemoveEventListener(aListener, NS_EVENT_TYPE_NULL, nsnull,
-                      GetTypeDataForIID(aIID), aFlags);
-}
-
-PRBool
-nsEventListenerManager::ListenerCanHandle(nsListenerStruct* aLs,
-                                          nsEvent* aEvent)
-{
-  if (aEvent->message == NS_USER_DEFINED_EVENT) {
-    // We don't want to check aLs->mEventType here, bug 276846.
-    return (aEvent->userType && aLs->mTypeAtom == aEvent->userType);
-  }
-  return (aLs->mEventType == aEvent->message);
+  // This is slightly different from EVENT_TYPE_EQUALS in that it returns
+  // true even when aEvent->message == NS_USER_DEFINED_EVENT and
+  // aLs=>mEventType != NS_USER_DEFINED_EVENT as long as the atoms are the same
+  return aEvent->message == NS_USER_DEFINED_EVENT ?
+    (aLs->mTypeAtom == aEvent->userType) :
+    (aLs->mEventType == aEvent->message);
 }
 
 nsresult
 nsEventListenerManager::AddEventListenerByType(nsIDOMEventListener *aListener, 
                                                const nsAString& aType,
                                                PRInt32 aFlags)
 {
   nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aType);
   PRUint32 type = nsContentUtils::GetEventId(atom);
-  return AddEventListener(aListener, type, atom, nsnull, aFlags);
+  return AddEventListener(aListener, type, atom, aFlags);
 }
 
 void
 nsEventListenerManager::RemoveEventListenerByType(nsIDOMEventListener *aListener, 
                                                   const nsAString& aType,
                                                   PRInt32 aFlags)
 {
   nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aType);
   PRUint32 type = nsContentUtils::GetEventId(atom);
-  RemoveEventListener(aListener, type, atom, nsnull, aFlags);
+  RemoveEventListener(aListener, type, atom, aFlags);
 }
 
 nsListenerStruct*
 nsEventListenerManager::FindJSEventListener(PRUint32 aEventType,
                                             nsIAtom* aTypeAtom)
 {
   // Run through the listeners for this type and see if a script
   // listener is registered
@@ -598,17 +385,17 @@ nsEventListenerManager::SetJSEventListen
 
   if (!ls) {
     // If we didn't find a script listener or no listeners existed
     // create and add a new one.
     nsCOMPtr<nsIDOMEventListener> scriptListener;
     rv = NS_NewJSEventListener(aContext, aScopeObject, mTarget, aName,
                                getter_AddRefs(scriptListener));
     if (NS_SUCCEEDED(rv)) {
-      AddEventListener(scriptListener, eventType, aName, nsnull,
+      AddEventListener(scriptListener, eventType, aName,
                        NS_EVENT_FLAG_BUBBLE | NS_PRIV_EVENT_FLAG_SCRIPT);
 
       ls = FindJSEventListener(eventType, aName);
     }
   }
 
   if (NS_SUCCEEDED(rv) && ls) {
     // Set flag to indicate possible need for compilation later
@@ -1073,20 +860,16 @@ nsEventListenerManager::HandleEventSubTy
   if (NS_SUCCEEDED(result)) {
     // nsIDOMEvent::currentTarget is set in nsEventDispatcher.
     result = aListener->HandleEvent(aDOMEvent);
   }
 
   return result;
 }
 
-static PRUint32                 sLatestEventType = 0;
-static const EventTypeData*     sLatestEventTypeData = nsnull;
-static const EventDispatchData* sLatestEventDispData = nsnull;
-
 /**
 * Causes a check for event listeners and processing by them if they exist.
 * @param an event listener
 */
 
 void
 nsEventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
                                             nsEvent* aEvent,
@@ -1096,89 +879,49 @@ nsEventListenerManager::HandleEventInter
                                             nsEventStatus* aEventStatus,
                                             nsCxPusher* aPusher)
 {
   //Set the value of the internal PreventDefault flag properly based on aEventStatus
   if (*aEventStatus == nsEventStatus_eConsumeNoDefault) {
     aEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT;
   }
 
-  const EventTypeData* typeData = nsnull;
-  const EventDispatchData* dispData = nsnull;
-  if (aEvent->message != NS_USER_DEFINED_EVENT) {
-    // Check if this is the same type of event as what a listener manager
-    // handled last time.
-    if (aEvent->message == sLatestEventType) {
-      typeData = sLatestEventTypeData;
-      dispData = sLatestEventDispData;
-      goto found;
-    }
-    for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(sEventTypes); ++i) {
-     typeData = &sEventTypes[i];
-     for (PRInt32 j = 0; j < typeData->numEvents; ++j) {
-       dispData = &(typeData->events[j]);
-       if (aEvent->message == dispData->message) {
-         sLatestEventType = aEvent->message;
-         sLatestEventTypeData = typeData;
-         sLatestEventDispData = dispData;
-         goto found;
-       }
-     }
-     typeData = nsnull;
-     dispData = nsnull;
-    }
-  }
-
-found:
-
   nsAutoTObserverArray<nsListenerStruct, 2>::EndLimitedIterator iter(mListeners);
   nsAutoPopupStatePusher popupStatePusher(nsDOMEvent::GetEventPopupControlState(aEvent));
   PRBool hasListener = PR_FALSE;
   while (iter.HasMore()) {
     nsListenerStruct* ls = &iter.GetNext();
-    PRBool useTypeInterface =
-      EVENT_TYPE_DATA_EQUALS(ls->mTypeData, typeData);
-    PRBool useGenericInterface =
-      (!useTypeInterface && ListenerCanHandle(ls, aEvent));
-    // Don't fire the listener if it's been removed.
     // Check that the phase is same in event and event listener.
     // Handle only trusted events, except when listener permits untrusted events.
-    if (useTypeInterface || useGenericInterface) {
-      if (ls->mListener) {
-        hasListener = PR_TRUE;
-        // XXX The (mFlags & aFlags) test here seems fragile. Shouldn't we
-        // specifically only test the capture/bubble flags.
-        if ((ls->mFlags & aFlags & ~NS_EVENT_FLAG_SYSTEM_EVENT) &&
-            (ls->mFlags & NS_EVENT_FLAG_SYSTEM_EVENT) ==
-            (aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) &&
-            (NS_IS_TRUSTED_EVENT(aEvent) ||
-             ls->mFlags & NS_PRIV_EVENT_UNTRUSTED_PERMITTED)) {
-          if (!*aDOMEvent) {
-            nsEventDispatcher::CreateEvent(aPresContext, aEvent,
-                                           EmptyString(), aDOMEvent);
-          }
-          if (*aDOMEvent) {
+    if (ListenerCanHandle(ls, aEvent)) {
+      hasListener = PR_TRUE;
+      // XXX The (mFlags & aFlags) test here seems fragile. Shouldn't we
+      // specifically only test the capture/bubble flags.
+      if ((ls->mFlags & aFlags & ~NS_EVENT_FLAG_SYSTEM_EVENT) &&
+          (ls->mFlags & NS_EVENT_FLAG_SYSTEM_EVENT) ==
+          (aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) &&
+          (NS_IS_TRUSTED_EVENT(aEvent) ||
+           ls->mFlags & NS_PRIV_EVENT_UNTRUSTED_PERMITTED)) {
+        if (!*aDOMEvent) {
+          nsEventDispatcher::CreateEvent(aPresContext, aEvent,
+                                         EmptyString(), aDOMEvent);
+        }
+        if (*aDOMEvent) {
+          if (!aEvent->currentTarget) {
+            aEvent->currentTarget = aCurrentTarget->GetTargetForDOMEvent();
             if (!aEvent->currentTarget) {
-              aEvent->currentTarget = aCurrentTarget->GetTargetForDOMEvent();
-              if (!aEvent->currentTarget) {
-                break;
-              }
+              break;
             }
-            nsRefPtr<nsIDOMEventListener> kungFuDeathGrip = ls->mListener;
-            if (useTypeInterface) {
-              aPusher->Pop();
-              DispatchToInterface(*aDOMEvent, ls->mListener,
-                                  dispData->method, *typeData->iid);
-            } else if (useGenericInterface &&
-                       aPusher->RePush(aCurrentTarget)) {
-              if (NS_FAILED(HandleEventSubType(ls, ls->mListener, *aDOMEvent,
-                                               aCurrentTarget, aFlags,
-                                               aPusher))) {
-                aEvent->flags |= NS_EVENT_FLAG_EXCEPTION_THROWN;
-              }
+          }
+          nsRefPtr<nsIDOMEventListener> kungFuDeathGrip = ls->mListener;
+          if (aPusher->RePush(aCurrentTarget)) {
+            if (NS_FAILED(HandleEventSubType(ls, ls->mListener, *aDOMEvent,
+                                             aCurrentTarget, aFlags,
+                                             aPusher))) {
+              aEvent->flags |= NS_EVENT_FLAG_EXCEPTION_THROWN;
             }
           }
         }
       }
     }
   }
 
   aEvent->currentTarget = nsnull;
@@ -1262,40 +1005,21 @@ nsEventListenerManager::MutationListener
   }
   return bits;
 }
 
 PRBool
 nsEventListenerManager::HasListenersFor(const nsAString& aEventName)
 {
   nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aEventName);
-  PRUint32 type = nsContentUtils::GetEventId(atom);
-
-  const EventTypeData* typeData = nsnull;
-  const EventDispatchData* dispData = nsnull;
-  if (type != NS_USER_DEFINED_EVENT) {
-    for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(sEventTypes); ++i) {
-     typeData = &sEventTypes[i];
-     for (PRInt32 j = 0; j < typeData->numEvents; ++j) {
-       dispData = &(typeData->events[j]);
-       if (type == dispData->message) {
-         goto found;
-       }
-     }
-     typeData = nsnull;
-     dispData = nsnull;
-    }
-  }
-found:
 
   PRUint32 count = mListeners.Length();
   for (PRUint32 i = 0; i < count; ++i) {
     nsListenerStruct* ls = &mListeners.ElementAt(i);
-    if (ls->mTypeAtom == atom ||
-        EVENT_TYPE_DATA_EQUALS(ls->mTypeData, typeData)) {
+    if (ls->mTypeAtom == atom) {
       return PR_TRUE;
     }
   }
   return PR_FALSE;
 }
 
 PRBool
 nsEventListenerManager::HasListeners()
@@ -1324,64 +1048,32 @@ nsEventListenerManager::GetListenerInfo(
                                     jslistener->GetEventScope(),
                                     jslistener->GetEventTarget(),
                                     ls.mTypeAtom,
                                     const_cast<nsListenerStruct*>(&ls),
                                     mTarget,
                                     PR_TRUE);
       }
     }
-    if (ls.mTypeData) {
-      // Handle special event listener interfaces, like nsIDOMFocusListener.
-      for (PRInt32 j = 0; j < ls.mTypeData->numEvents; ++j) {
-        const EventDispatchData* dispData = &(ls.mTypeData->events[j]);
-        const char* eventName = nsDOMEvent::GetEventName(dispData->message);
-        if (eventName) {
-          NS_ConvertASCIItoUTF16 eventType(eventName);
-          nsRefPtr<nsEventListenerInfo> info =
-            new nsEventListenerInfo(eventType, ls.mListener, capturing,
-                                    allowsUntrusted, systemGroup);
-          NS_ENSURE_TRUE(info, NS_ERROR_OUT_OF_MEMORY);
-          aList->AppendObject(info);
-        }
-      }
-    } else if (ls.mEventType == NS_USER_DEFINED_EVENT) {
-      // Handle user defined event types.
-      if (ls.mTypeAtom) {
-        const nsDependentSubstring& eventType =
-          Substring(nsDependentAtomString(ls.mTypeAtom), 2);
-        nsRefPtr<nsEventListenerInfo> info =
-          new nsEventListenerInfo(eventType, ls.mListener, capturing,
-                                  allowsUntrusted, systemGroup);
-        NS_ENSURE_TRUE(info, NS_ERROR_OUT_OF_MEMORY);
-        aList->AppendObject(info);
-      }
-    } else {
-      // Handle normal events.
-      const char* eventName = nsDOMEvent::GetEventName(ls.mEventType);
-      if (eventName) {
-        NS_ConvertASCIItoUTF16 eventType(eventName);
-        nsRefPtr<nsEventListenerInfo> info =
-          new nsEventListenerInfo(eventType, ls.mListener, capturing,
-                                  allowsUntrusted, systemGroup);
-        NS_ENSURE_TRUE(info, NS_ERROR_OUT_OF_MEMORY);
-        aList->AppendObject(info);
-      }
-    }
+    const nsDependentSubstring& eventType =
+      Substring(nsDependentAtomString(ls.mTypeAtom), 2);
+    nsRefPtr<nsEventListenerInfo> info =
+      new nsEventListenerInfo(eventType, ls.mListener, capturing,
+                              allowsUntrusted, systemGroup);
+    NS_ENSURE_TRUE(info, NS_ERROR_OUT_OF_MEMORY);
+    aList->AppendObject(info);
   }
   return NS_OK;
 }
 
 PRBool
 nsEventListenerManager::HasUnloadListeners()
 {
   PRUint32 count = mListeners.Length();
   for (PRUint32 i = 0; i < count; ++i) {
     nsListenerStruct* ls = &mListeners.ElementAt(i);
     if (ls->mEventType == NS_PAGE_UNLOAD ||
-        ls->mEventType == NS_BEFORE_PAGE_UNLOAD ||
-        (ls->mTypeData && ls->mTypeData->iid &&
-         ls->mTypeData->iid->Equals(NS_GET_IID(nsIDOMLoadListener)))) {
+        ls->mEventType == NS_BEFORE_PAGE_UNLOAD) {
       return PR_TRUE;
     }
   }
   return PR_FALSE;
 }
--- a/content/events/src/nsEventListenerManager.h
+++ b/content/events/src/nsEventListenerManager.h
@@ -62,17 +62,16 @@ class nsCxPusher;
 class nsIEventListenerInfo;
 
 typedef struct {
   nsRefPtr<nsIDOMEventListener> mListener;
   PRUint32                      mEventType;
   nsCOMPtr<nsIAtom>             mTypeAtom;
   PRUint16                      mFlags;
   PRBool                        mHandlerIsString;
-  const EventTypeData*          mTypeData;
 } nsListenerStruct;
 
 /*
  * Event listener manager
  */
 
 class nsEventListenerManager
 {
@@ -92,20 +91,16 @@ public:
   void RemoveEventListener(const nsAString& aType,
                            nsIDOMEventListener* aListener,
                            PRBool aUseCapture);
 
   /**
   * Sets events listeners of all types. 
   * @param an event listener
   */
-  nsresult AddEventListenerByIID(nsIDOMEventListener *aListener,
-                                 const nsIID& aIID, PRInt32 aFlags);
-  void RemoveEventListenerByIID(nsIDOMEventListener *aListener,
-                                const nsIID& aIID, PRInt32 aFlags);
   nsresult AddEventListenerByType(nsIDOMEventListener *aListener,
                                   const nsAString& type,
                                   PRInt32 aFlags);
   void RemoveEventListenerByType(nsIDOMEventListener *aListener,
                                  const nsAString& type,
                                  PRInt32 aFlags);
   nsresult AddScriptEventListener(nsIAtom *aName,
                                   const nsAString& aFunc,
@@ -213,27 +208,24 @@ protected:
   nsListenerStruct* FindJSEventListener(PRUint32 aEventType, nsIAtom* aTypeAtom);
   nsresult SetJSEventListener(nsIScriptContext *aContext,
                               void *aScopeGlobal,
                               nsIAtom* aName, PRBool aIsString,
                               PRBool aPermitUntrustedEvents);
   nsresult AddEventListener(nsIDOMEventListener *aListener, 
                             PRUint32 aType,
                             nsIAtom* aTypeAtom,
-                            const EventTypeData* aTypeData,
                             PRInt32 aFlags);
   void RemoveEventListener(nsIDOMEventListener *aListener,
                            PRUint32 aType,
                            nsIAtom* aUserType,
-                           const EventTypeData* aTypeData,
                            PRInt32 aFlags);
   void RemoveAllListeners();
   const EventTypeData* GetTypeDataForIID(const nsIID& aIID);
   const EventTypeData* GetTypeDataForEventName(nsIAtom* aName);
-  PRBool ListenerCanHandle(nsListenerStruct* aLs, nsEvent* aEvent);
   nsPIDOMWindow* GetInnerWindowForTarget();
 
   PRUint32 mMayHavePaintEventListener : 1;
   PRUint32 mMayHaveMutationListeners : 1;
   PRUint32 mMayHaveCapturingListeners : 1;
   PRUint32 mMayHaveSystemGroupListeners : 1;
   PRUint32 mMayHaveAudioAvailableEventListener : 1;
   PRUint32 mMayHaveTouchEventListener : 1;
--- a/content/html/content/src/nsTextEditorState.cpp
+++ b/content/html/content/src/nsTextEditorState.cpp
@@ -31,16 +31,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "nsTextEditorState.h"
+
 #include "nsCOMPtr.h"
 #include "nsIPresShell.h"
 #include "nsIView.h"
 #include "nsCaret.h"
 #include "nsEditorCID.h"
 #include "nsLayoutCID.h"
 #include "nsITextControlFrame.h" 
 #include "nsIPlaintextEditor.h"
@@ -60,18 +62,16 @@
 #include "nsIDocumentEncoder.h"
 #include "nsISelectionPrivate.h"
 #include "nsPIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIEditor.h"
 #include "nsTextEditRules.h"
 #include "nsEventListenerManager.h"
 
-#include "nsTextEditorState.h"
-
 using namespace mozilla::dom;
 
 static NS_DEFINE_CID(kTextEditorCID, NS_TEXTEDITOR_CID);
 
 static nsINativeKeyBindings *sNativeInputBindings = nsnull;
 static nsINativeKeyBindings *sNativeTextAreaBindings = nsnull;
 
 class RestoreSelectionState : public nsRunnable {
--- a/content/html/content/src/nsTextEditorState.h
+++ b/content/html/content/src/nsTextEditorState.h
@@ -35,16 +35,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsTextEditorState_h__
 #define nsTextEditorState_h__
 
 #include "nsAutoPtr.h"
+#include "nsString.h"
 #include "nsITextControlElement.h"
 #include "nsITextControlFrame.h"
 #include "nsCycleCollectionParticipant.h"
 
 class nsTextInputListener;
 class nsTextControlFrame;
 class nsTextInputSelectionImpl;
 class nsAnonDivObserver;
--- a/content/xbl/src/nsXBLBinding.cpp
+++ b/content/xbl/src/nsXBLBinding.cpp
@@ -68,23 +68,17 @@
 #include "nsXBLService.h"
 #include "nsXBLInsertionPoint.h"
 #include "nsIXPConnect.h"
 #include "nsIScriptContext.h"
 #include "nsCRT.h"
 
 // Event listeners
 #include "nsEventListenerManager.h"
-#include "nsIDOMMouseListener.h"
-#include "nsIDOMMouseMotionListener.h"
-#include "nsIDOMLoadListener.h"
-#include "nsIDOMFocusListener.h"
-#include "nsIDOMKeyListener.h"
-#include "nsIDOMFormListener.h"
-#include "nsIDOMContextMenuListener.h"
+#include "nsIDOMEventListener.h"
 #include "nsAttrName.h"
 
 #include "nsGkAtoms.h"
 
 #include "nsIDOMAttr.h"
 #include "nsIDOMNamedNodeMap.h"
 
 #include "nsXBLPrototypeHandler.h"
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -61,23 +61,16 @@
 #include "nsIDOMEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsHashtable.h"
 #include "nsIAtom.h"
 #include "nsIBaseWindow.h"
 #include "nsIDOMAttr.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
-#include "nsIDOMMouseListener.h"
-#include "nsIDOMMouseMotionListener.h"
-#include "nsIDOMLoadListener.h"
-#include "nsIDOMFocusListener.h"
-#include "nsIDOMKeyListener.h"
-#include "nsIDOMFormListener.h"
-#include "nsIDOMContextMenuListener.h"
 #include "nsIDOMEventListener.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMXULCommandDispatcher.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDOMElementCSSInlineStyle.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsIDocument.h"
 #include "nsEventListenerManager.h"
--- a/content/xul/document/src/nsXULCommandDispatcher.h
+++ b/content/xul/document/src/nsXULCommandDispatcher.h
@@ -43,17 +43,16 @@
 
 */
 
 #ifndef nsXULCommandDispatcher_h__
 #define nsXULCommandDispatcher_h__
 
 #include "nsCOMPtr.h"
 #include "nsIDOMXULCommandDispatcher.h"
-#include "nsIDOMFocusListener.h"
 #include "nsWeakReference.h"
 #include "nsIDOMNode.h"
 #include "nsString.h"
 #include "nsCycleCollectionParticipant.h"
 
 class nsIDOMElement;
 class nsPIWindowRoot;
 
--- a/dom/Makefile.in
+++ b/dom/Makefile.in
@@ -66,17 +66,16 @@ DIRS = \
   interfaces/svg \
   $(NULL)
 
 ifdef MOZ_SMIL
 DIRS += interfaces/smil
 endif
 
 DIRS += \
-  public/coreEvents \
   base \
   src \
   locales \
   plugins/base \
   plugins/ipc \
   indexedDB \
   system \
   ipc \
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -5192,25 +5192,25 @@ nsWindowSH::InstallGlobalScopePolluter(J
   // invalidation).
   NS_ADDREF(doc);
 
   return NS_OK;
 }
 
 static
 already_AddRefed<nsIDOMWindow>
-GetChildFrame(nsGlobalWindow *win, jsid id)
+GetChildFrame(nsGlobalWindow *win, PRUint32 index)
 {
   nsCOMPtr<nsIDOMWindowCollection> frames;
   win->GetFrames(getter_AddRefs(frames));
 
   nsIDOMWindow *frame = nsnull;
 
   if (frames) {
-    frames->Item(JSID_TO_INT(id), &frame);
+    frames->Item(index, &frame);
   }
 
   return frame;
 }
 
 NS_IMETHODIMP
 nsWindowSH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                         JSObject *obj, jsid id, jsval *vp, PRBool *_retval)
@@ -5237,26 +5237,24 @@ nsWindowSH::GetProperty(nsIXPConnectWrap
     }
   }
 #endif
 
   // The order in which things are done in this method are a bit
   // whacky, that's because this method is *extremely* performace
   // critical. Don't touch this unless you know what you're doing.
 
-  if (JSID_IS_INT(id)) {
+  if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0) {
     // If we're accessing a numeric property we'll treat that as if
     // window.frames[n] is accessed (since window.frames === window),
     // if window.frames[n] is a child frame, wrap the frame and return
     // it without doing a security check.
-
-    nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, id);
+    PRUint32 index = PRUint32(JSID_TO_INT(id));
     nsresult rv = NS_OK;
-
-    if (frame) {
+    if (nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, index)) {
       // A numeric property accessed and the numeric property is a
       // child frame, wrap the child frame without doing a security
       // check and return.
 
       nsGlobalWindow *frameWin = (nsGlobalWindow *)frame.get();
       NS_ASSERTION(frameWin->IsOuterWindow(), "GetChildFrame gave us an inner?");
 
       frameWin->EnsureInnerWindow();
@@ -6507,29 +6505,27 @@ static JSNewResolveOp sOtherResolveFuncs
 NS_IMETHODIMP
 nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
                        JSObject *obj, jsid id, PRUint32 flags,
                        JSObject **objp, PRBool *_retval)
 {
   nsGlobalWindow *win = nsGlobalWindow::FromWrapper(wrapper);
 
   if (!JSID_IS_STRING(id)) {
-    if (JSID_IS_INT(id) && !(flags & JSRESOLVE_ASSIGNING)) {
+    if (JSID_IS_INT(id) && JSID_TO_INT(id) >= 0 && !(flags & JSRESOLVE_ASSIGNING)) {
       // If we're resolving a numeric property, treat that as if
       // window.frames[n] is resolved (since window.frames ===
       // window), if window.frames[n] is a child frame, define a
       // property for this index.
-
-      nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, id);
-
-      if (frame) {
+      PRUint32 index = PRUint32(JSID_TO_INT(id));
+      if (nsCOMPtr<nsIDOMWindow> frame = GetChildFrame(win, index)) {
         // A numeric property accessed and the numeric property is a
         // child frame. Define a property for this index.
 
-        *_retval = ::JS_DefineElement(cx, obj, JSID_TO_INT(id), JSVAL_VOID,
+        *_retval = ::JS_DefineElement(cx, obj, index, JSVAL_VOID,
                                       nsnull, nsnull, JSPROP_SHARED);
 
         if (*_retval) {
           *objp = obj;
         }
       }
     }
 
@@ -7911,18 +7907,19 @@ nsGenericArraySH::NewResolve(nsIXPConnec
     // get the length. We may want to consider asking our concrete
     // implementation for the length, and falling back onto the GetProperty if
     // it doesn't provide one.
 
     PRUint32 length;
     nsresult rv = GetLength(wrapper, cx, obj, &length);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    if ((PRUint32)n < length) {
-      *_retval = ::JS_DefineElement(cx, obj, n, JSVAL_VOID, nsnull, nsnull,
+    PRUint32 index = PRUint32(n);
+    if (index < length) {
+      *_retval = ::JS_DefineElement(cx, obj, index, JSVAL_VOID, nsnull, nsnull,
                                     JSPROP_ENUMERATE | JSPROP_SHARED);
       *objp = obj;
     }
   }
 
   return NS_OK;
 }
 
@@ -8938,22 +8935,17 @@ nsHTMLDocumentSH::DocumentAllNewResolve(
     if (!DocumentAllGetProperty(cx, obj, id, &v)) {
       return JS_FALSE;
     }
   }
 
   JSBool ok = JS_TRUE;
 
   if (v != JSVAL_VOID) {
-    if (JSID_IS_STRING(id)) {
-      ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
-    } else {
-      ok = ::JS_DefineElement(cx, obj, JSID_TO_INT(id), v, nsnull, nsnull, 0);
-    }
-
+    ok = ::JS_DefinePropertyById(cx, obj, id, v, nsnull, nsnull, 0);
     *objp = obj;
   }
 
   return ok;
 }
 
 // Finalize hook used by document related JS objects, but also by
 // sGlobalScopePolluterClass!
@@ -9486,17 +9478,17 @@ nsHTMLSelectElementSH::NewResolve(nsIXPC
     nsHTMLSelectElement *s =
       nsHTMLSelectElement::FromSupports(GetNative(wrapper, obj));
 
     nsHTMLOptionCollection *options = s->GetOptions();
     if (options) {
       nsISupports *node = options->GetNodeAt(n);
       if (node) {
         *objp = obj;
-        *_retval = JS_DefineElement(cx, obj, n, JSVAL_VOID, nsnull, nsnull,
+        *_retval = JS_DefineElement(cx, obj, PRUint32(n), JSVAL_VOID, nsnull, nsnull,
                                     JSPROP_ENUMERATE | JSPROP_SHARED);
 
         return NS_OK;
       }
     }
   }
 
   return nsElementSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
@@ -9836,34 +9828,24 @@ nsHTMLPluginObjElementSH::GetProperty(ns
   JSObject *pi_obj = ::JS_GetPrototype(cx, obj);
   if (NS_UNLIKELY(!pi_obj)) {
     return NS_OK;
   }
 
   JSBool found = PR_FALSE;
 
   if (!ObjectIsNativeWrapper(cx, obj)) {
-    if (JSID_IS_STRING(id)) {
-      *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
-    } else {
-      *_retval = ::JS_HasElement(cx, pi_obj, JSID_TO_INT(id), &found);
-    }
-
+    *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
     if (!*_retval) {
       return NS_ERROR_UNEXPECTED;
     }
   }
 
   if (found) {
-    if (JSID_IS_STRING(id)) {
-      *_retval = ::JS_GetPropertyById(cx, pi_obj, id, vp);
-    } else {
-      *_retval = ::JS_GetElement(cx, pi_obj, JSID_TO_INT(id), vp);
-    }
-
+    *_retval = ::JS_GetPropertyById(cx, pi_obj, id, vp);
     return *_retval ? NS_SUCCESS_I_DID_SOMETHING : NS_ERROR_FAILURE;
   }
 
   return nsElementSH::GetProperty(wrapper, cx, obj, id, vp, _retval);
 }
 
 NS_IMETHODIMP
 nsHTMLPluginObjElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
@@ -9875,34 +9857,24 @@ nsHTMLPluginObjElementSH::SetProperty(ns
   JSObject *pi_obj = ::JS_GetPrototype(cx, obj);
   if (NS_UNLIKELY(!pi_obj)) {
     return NS_OK;
   }
 
   JSBool found = PR_FALSE;
 
   if (!ObjectIsNativeWrapper(cx, obj)) {
-    if (JSID_IS_STRING(id)) {
-      *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
-    } else {
-      *_retval = ::JS_HasElement(cx, pi_obj, JSID_TO_INT(id), &found);
-    }
-
+    *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
     if (!*_retval) {
       return NS_ERROR_UNEXPECTED;
     }
   }
 
   if (found) {
-    if (JSID_IS_STRING(id)) {
-      *_retval = ::JS_SetPropertyById(cx, pi_obj, id, vp);
-    } else {
-      *_retval = ::JS_SetElement(cx, pi_obj, JSID_TO_INT(id), vp);
-    }
-
+    *_retval = ::JS_SetPropertyById(cx, pi_obj, id, vp);
     return *_retval ? NS_SUCCESS_I_DID_SOMETHING : NS_ERROR_FAILURE;
   }
 
   return nsElementSH::SetProperty(wrapper, cx, obj, id, vp, _retval);
 }
 
 NS_IMETHODIMP
 nsHTMLPluginObjElementSH::Call(nsIXPConnectWrappedNative *wrapper,
--- a/dom/base/nsDOMNavigationTiming.cpp
+++ b/dom/base/nsDOMNavigationTiming.cpp
@@ -86,16 +86,27 @@ nsDOMNavigationTiming::TimeStampToDOM(mo
     *aResult = 0;
     return NS_OK;
   }
   mozilla::TimeDuration duration = aStamp - mNavigationStartTimeStamp;
   *aResult = mNavigationStart + static_cast<PRInt32>(duration.ToMilliseconds());
   return NS_OK;
 }
 
+nsresult 
+nsDOMNavigationTiming::TimeStampToDOMOrFetchStart(mozilla::TimeStamp aStamp, 
+                                                  DOMTimeMilliSec* aResult)
+{
+  if (!aStamp.IsNull()) {
+    return TimeStampToDOM(aStamp, aResult);
+  } else {
+    return GetFetchStart(aResult);
+  }
+}
+
 DOMTimeMilliSec nsDOMNavigationTiming::DurationFromStart(){
   DOMTimeMilliSec result; 
   TimeStampToDOM(mozilla::TimeStamp::Now(), &result);
   return result;
 }
 
 void
 nsDOMNavigationTiming::NotifyNavigationStart()
--- a/dom/base/nsDOMNavigationTiming.h
+++ b/dom/base/nsDOMNavigationTiming.h
@@ -87,16 +87,18 @@ public:
   // Document changes state to 'loading' before connecting to timing
   void SetDOMLoadingTimeStamp(nsIURI* aURI, mozilla::TimeStamp aValue);
   void NotifyDOMLoading(nsIURI* aURI);
   void NotifyDOMInteractive(nsIURI* aURI);
   void NotifyDOMComplete(nsIURI* aURI);
   void NotifyDOMContentLoadedStart(nsIURI* aURI);
   void NotifyDOMContentLoadedEnd(nsIURI* aURI);
   nsresult TimeStampToDOM(mozilla::TimeStamp aStamp, DOMTimeMilliSec* aResult);
+  nsresult TimeStampToDOMOrFetchStart(mozilla::TimeStamp aStamp, 
+                                      DOMTimeMilliSec* aResult);
 
 private:
   nsDOMNavigationTiming(const nsDOMNavigationTiming &){};
   ~nsDOMNavigationTiming();
 
   void Clear();
   PRBool ReportRedirects();
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -5947,17 +5947,17 @@ class PostMessageEvent : public nsRunnab
     {
       NS_ASSERTION(!mMessage && mMessageLen == 0, "Don't call twice!");
       aBuffer.steal(&mMessage, &mMessageLen);
     }
 
   private:
     nsRefPtr<nsGlobalWindow> mSource;
     nsString mCallerOrigin;
-    uint64* mMessage;
+    JSUint64* mMessage;
     size_t mMessageLen;
     nsRefPtr<nsGlobalWindow> mTargetWindow;
     nsCOMPtr<nsIURI> mProvidedOrigin;
     PRBool mTrustedCaller;
 };
 
 NS_IMETHODIMP
 PostMessageEvent::Run()
@@ -7254,40 +7254,16 @@ nsGlobalWindow::AddEventListener(const n
   }
 
   nsEventListenerManager* manager = GetListenerManager(PR_TRUE);
   NS_ENSURE_STATE(manager);
   return manager->AddEventListener(aType, aListener, aUseCapture,
                                    aWantsUntrusted);
 }
 
-nsresult
-nsGlobalWindow::AddEventListenerByIID(nsIDOMEventListener* aListener,
-                                      const nsIID& aIID)
-{
-  nsEventListenerManager* manager = GetListenerManager(PR_TRUE);
-  NS_ENSURE_STATE(manager);
-  return manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
-}
-
-nsresult
-nsGlobalWindow::RemoveEventListenerByIID(nsIDOMEventListener* aListener,
-                                         const nsIID& aIID)
-{
-  FORWARD_TO_INNER(RemoveEventListenerByIID, (aListener, aIID),
-                   NS_ERROR_NOT_INITIALIZED);
-
-  if (mListenerManager) {
-    mListenerManager->RemoveEventListenerByIID(aListener, aIID,
-                                               NS_EVENT_FLAG_BUBBLE);
-    return NS_OK;
-  }
-  return NS_ERROR_FAILURE;
-}
-
 nsEventListenerManager*
 nsGlobalWindow::GetListenerManager(PRBool aCreateIfNotFound)
 {
   FORWARD_TO_INNER_CREATE(GetListenerManager, (aCreateIfNotFound), nsnull);
 
   if (!mListenerManager && aCreateIfNotFound) {
     mListenerManager =
       new nsEventListenerManager(static_cast<nsIDOMEventTarget*>(this));
--- a/dom/base/nsPerformance.cpp
+++ b/dom/base/nsPerformance.cpp
@@ -109,93 +109,93 @@ nsPerformanceTiming::GetFetchStart(DOMTi
 NS_IMETHODIMP
 nsPerformanceTiming::GetDomainLookupStart(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetDomainLookupStart(&stamp);
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetDomainLookupEnd(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetDomainLookupEnd(&stamp);
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetConnectStart(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetConnectStart(&stamp);
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetConnectEnd(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetConnectEnd(&stamp);
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetRequestStart(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetRequestStart(&stamp);
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetResponseStart(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetResponseStart(&stamp);
   mozilla::TimeStamp cacheStamp;
   mChannel->GetCacheReadStart(&cacheStamp);
   if (stamp.IsNull() || (!cacheStamp.IsNull() && cacheStamp < stamp)) {
     stamp = cacheStamp;
   }
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetResponseEnd(DOMTimeMilliSec* aTime)
 {
   if (!mChannel) {
     return GetFetchStart(aTime);
   }
   mozilla::TimeStamp stamp;
   mChannel->GetResponseEnd(&stamp);
   mozilla::TimeStamp cacheStamp;
   mChannel->GetCacheReadEnd(&cacheStamp);
   if (stamp.IsNull() || (!cacheStamp.IsNull() && cacheStamp < stamp)) {
     stamp = cacheStamp;
   }
-  return mDOMTiming->TimeStampToDOM(stamp, aTime);
+  return mDOMTiming->TimeStampToDOMOrFetchStart(stamp, aTime);
 }
 
 NS_IMETHODIMP
 nsPerformanceTiming::GetDomLoading(DOMTimeMilliSec* aTime)
 {
   return mDOMTiming->GetDomLoading(aTime);
 }
 
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -144,34 +144,16 @@ nsWindowRoot::AddEventListener(const nsA
                "aWantsUntrusted to PR_FALSE or make the aWantsUntrusted "
                "explicit by making optional_argc non-zero.");
 
   nsEventListenerManager* elm = GetListenerManager(PR_TRUE);
   NS_ENSURE_STATE(elm);
   return elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted);
 }
 
-nsresult
-nsWindowRoot::AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
-{
-  nsEventListenerManager* manager = GetListenerManager(PR_TRUE);
-  NS_ENSURE_STATE(manager);
-  return manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
-}
-  
-nsresult
-nsWindowRoot::RemoveEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID)
-{
-  nsEventListenerManager* manager = GetListenerManager(PR_TRUE);
-  if (manager) {
-    manager->RemoveEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
-  }
-  return NS_OK;
-}
-
 nsEventListenerManager*
 nsWindowRoot::GetListenerManager(PRBool aCreateIfNotFound)
 {
   if (!mListenerManager && aCreateIfNotFound) {
     mListenerManager =
       new nsEventListenerManager(static_cast<nsIDOMEventTarget*>(this));
   }
 
--- a/dom/indexedDB/AsyncConnectionHelper.cpp
+++ b/dom/indexedDB/AsyncConnectionHelper.cpp
@@ -93,18 +93,17 @@ ConvertCloneBuffersToArrayInternal(
   }
 
   if (!aBuffers.IsEmpty()) {
     if (!JS_SetArrayLength(aCx, array, jsuint(aBuffers.Length()))) {
       NS_WARNING("Failed to set array length!");
       return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
     }
 
-    jsint count = jsint(aBuffers.Length());
-    for (jsint index = 0; index < count; index++) {
+    for (uint32 index = 0, count = aBuffers.Length(); index < count; index++) {
       JSAutoStructuredCloneBuffer& buffer = aBuffers[index];
 
       jsval val;
       if (!IDBObjectStore::DeserializeValue(aCx, buffer, &val)) {
         NS_WARNING("Failed to decode!");
         return NS_ERROR_DOM_DATA_CLONE_ERR;
       }
 
--- a/dom/indexedDB/IDBIndex.cpp
+++ b/dom/indexedDB/IDBIndex.cpp
@@ -919,18 +919,17 @@ GetAllKeysHelper::GetSuccessResult(JSCon
   }
 
   if (!keys.IsEmpty()) {
     if (!JS_SetArrayLength(aCx, array, jsuint(keys.Length()))) {
       NS_WARNING("Failed to set array length!");
       return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
     }
 
-    jsint count = jsint(keys.Length());
-    for (jsint index = 0; index < count; index++) {
+    for (uint32 index = 0, count = keys.Length(); index < count; index++) {
       const Key& key = keys[index];
       NS_ASSERTION(!key.IsUnset(), "Bad key!");
 
       jsval value;
       nsresult rv = IDBObjectStore::GetJSValFromKey(key, aCx, &value);
       if (NS_FAILED(rv)) {
         NS_WARNING("Failed to get jsval for key!");
         return rv;
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -830,17 +830,17 @@ IDBObjectStore::GetStructuredCloneDataFr
   }
 #endif
 
   const PRUint8* data;
   PRUint32 dataLength;
   nsresult rv = aStatement->GetSharedBlob(aIndex, &dataLength, &data);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
 
-  return aBuffer.copy(reinterpret_cast<const uint64 *>(data), dataLength) ?
+  return aBuffer.copy(reinterpret_cast<const uint64_t *>(data), dataLength) ?
          NS_OK :
          NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
 }
 
 // static
 void
 IDBObjectStore::ClearStructuredCloneBuffer(JSAutoStructuredCloneBuffer& aBuffer)
 {
--- a/dom/interfaces/events/nsIDOMEventTarget.idl
+++ b/dom/interfaces/events/nsIDOMEventTarget.idl
@@ -249,29 +249,16 @@ interface nsIDOMEventTarget : nsISupport
    * on this node.
    * @param aMayCreate If PR_FALSE, returns a listener manager only if
    *                   one already exists.
    */
   [notxpcom, nostdcall]
   nsEventListenerManagerPtr GetListenerManager(in boolean aMayCreate);
 
   /**
-   * Add an event listener for nsIID.
-   */
-  [noscript, nostdcall]
-  void AddEventListenerByIID(in nsIDOMEventListener aListener,
-                             in nsIIDRef aIID);
-  /**
-   * Remove event listener for nsIID.
-   */
-  [noscript, nostdcall]
-  void RemoveEventListenerByIID(in nsIDOMEventListener aListener,
-                                in nsIIDRef aIID);
-
-  /**
    * Get the script context in which the event handlers should be run.
    * May return null.
    * @note Caller *must* check the value of aRv.
    */
   [notxpcom, nostdcall]
   nsIScriptContext GetContextForEventHandlers(out nsresult aRv);
 
   /**
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -65,17 +65,16 @@ enum { XKeyPress = KeyPress };
 using mozilla::DefaultXDisplay;
 #endif
 
 #include "nsPluginInstanceOwner.h"
 #include "nsIRunnable.h"
 #include "nsContentUtils.h"
 #include "nsRect.h"
 #include "nsSize.h"
-#include "nsIDOMContextMenuListener.h"
 #include "nsDisplayList.h"
 #include "ImageLayers.h"
 #include "nsIDOMEventTarget.h"
 #include "nsObjectFrame.h"
 #include "nsIPluginDocument.h"
 #include "nsIStringStream.h"
 #include "nsNetUtil.h"
 #include "mozilla/Preferences.h"
@@ -119,33 +118,28 @@ static NS_DEFINE_CID(kAppShellCID, NS_AP
 #include "gfxXlibNativeRenderer.h"
 #endif
 
 using namespace mozilla;
 
 // special class for handeling DOM context menu events because for
 // some reason it starves other mouse events if implemented on the
 // same class
-class nsPluginDOMContextMenuListener : public nsIDOMContextMenuListener
+class nsPluginDOMContextMenuListener : public nsIDOMEventListener
 {
 public:
   nsPluginDOMContextMenuListener();
   virtual ~nsPluginDOMContextMenuListener();
 
   NS_DECL_ISUPPORTS
-
-  NS_IMETHOD ContextMenu(nsIDOMEvent* aContextMenuEvent);
-  
+  NS_DECL_NSIDOMEVENTLISTENER
+
   nsresult Init(nsIContent* aContent);
   nsresult Destroy(nsIContent* aContent);
   
-  NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent)
-  {
-    return NS_OK;
-  }
   nsEventStatus ProcessEvent(const nsGUIEvent& anEvent)
   {
     return nsEventStatus_eConsumeNoDefault;
   }
 };
 
 class AsyncPaintWaitEvent : public nsRunnable
 {
@@ -380,29 +374,20 @@ nsPluginInstanceOwner::~nsPluginInstance
     mPluginWindow = nsnull;
   }
 
   if (mInstance) {
     mInstance->InvalidateOwner();
   }
 }
 
-NS_IMPL_ADDREF(nsPluginInstanceOwner)
-NS_IMPL_RELEASE(nsPluginInstanceOwner)
-
-NS_INTERFACE_MAP_BEGIN(nsPluginInstanceOwner)
-  NS_INTERFACE_MAP_ENTRY(nsIPluginInstanceOwner)
-  NS_INTERFACE_MAP_ENTRY(nsIPluginTagInfo)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMMouseMotionListener)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMMouseListener)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPluginInstanceOwner)
-NS_INTERFACE_MAP_END
+NS_IMPL_ISUPPORTS3(nsPluginInstanceOwner,
+                   nsIPluginInstanceOwner,
+                   nsIPluginTagInfo,
+                   nsIDOMEventListener)
 
 nsresult
 nsPluginInstanceOwner::SetInstance(nsNPAPIPluginInstance *aInstance)
 {
   NS_ASSERTION(!mInstance || !aInstance, "mInstance should only be set or unset!");
 
   // If we're going to null out mInstance after use, be sure to call
   // mInstance->InvalidateOwner() here, since it now won't be called
@@ -1668,29 +1653,16 @@ void nsPluginInstanceOwner::ScrollPositi
         mInstance->HandleEvent(&scrollEvent, nsnull);
       }
       pluginWidget->EndDrawPlugin();
     }
   }
 #endif
 }
 
-/*=============== nsIDOMFocusListener ======================*/
-nsresult nsPluginInstanceOwner::Focus(nsIDOMEvent * aFocusEvent)
-{
-  mContentFocused = PR_TRUE;
-  return DispatchFocusToPlugin(aFocusEvent);
-}
-
-nsresult nsPluginInstanceOwner::Blur(nsIDOMEvent * aFocusEvent)
-{
-  mContentFocused = PR_FALSE;
-  return DispatchFocusToPlugin(aFocusEvent);
-}
-
 nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
 {
 #ifndef XP_MACOSX
   if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow)) {
     // continue only for cases without child window
     return aFocusEvent->PreventDefault(); // consume event
   }
 #endif
@@ -1710,44 +1682,31 @@ nsresult nsPluginInstanceOwner::Dispatch
     }
     else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchFocusToPlugin failed, focusEvent null");   
   }
   else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchFocusToPlugin failed, privateEvent null");   
   
   return NS_OK;
 }    
 
-
-/*=============== nsIKeyListener ======================*/
-nsresult nsPluginInstanceOwner::KeyDown(nsIDOMEvent* aKeyEvent)
-{
-  return DispatchKeyToPlugin(aKeyEvent);
-}
-
-nsresult nsPluginInstanceOwner::KeyUp(nsIDOMEvent* aKeyEvent)
-{
-  return DispatchKeyToPlugin(aKeyEvent);
-}
-
 nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent)
 {
 #ifdef XP_MACOSX
 #ifndef NP_NO_CARBON
   if (GetEventModel() == NPEventModelCarbon) {
     // KeyPress events are really synthesized keyDown events.
     // Here we check the native message of the event so that
     // we won't send the plugin two keyDown events.
     nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aKeyEvent));
     if (privateEvent) {
       nsEvent *theEvent = privateEvent->GetInternalNSEvent();
-      const nsGUIEvent *guiEvent = (nsGUIEvent*)theEvent;
-      const EventRecord *ev = (EventRecord*)(guiEvent->pluginEvent); 
-      if (guiEvent &&
-          guiEvent->message == NS_KEY_PRESS &&
-          ev &&
+      const EventRecord *ev;
+      if (theEvent &&
+          theEvent->message == NS_KEY_PRESS &&
+          (ev = (EventRecord*)(((nsGUIEvent*)theEvent)->pluginEvent)) &&
           ev->what == keyDown)
         return aKeyEvent->PreventDefault(); // consume event
     }
 
     // Nasty hack to avoid recursive event dispatching with Java. Java can
     // dispatch key events to a TSM handler, which comes back and calls 
     // [ChildView insertText:] on the cocoa widget, which sends a key
     // event back down.
@@ -1784,65 +1743,32 @@ nsresult nsPluginInstanceOwner::Dispatch
   if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow))
     return aKeyEvent->PreventDefault(); // consume event
   // continue only for cases without child window
 #endif
 
   if (mInstance) {
     nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aKeyEvent));
     if (privateEvent) {
-      nsKeyEvent *keyEvent = (nsKeyEvent *) privateEvent->GetInternalNSEvent();
-      if (keyEvent) {
-        nsEventStatus rv = ProcessEvent(*keyEvent);
+      nsEvent *event = privateEvent->GetInternalNSEvent();
+      if (event && event->eventStructType == NS_KEY_EVENT) {
+        nsEventStatus rv = ProcessEvent(*static_cast<nsGUIEvent*>(event));
         if (nsEventStatus_eConsumeNoDefault == rv) {
           aKeyEvent->PreventDefault();
           aKeyEvent->StopPropagation();
         }
       }
       else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchKeyToPlugin failed, keyEvent null");   
     }
     else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchKeyToPlugin failed, privateEvent null");   
   }
 
   return NS_OK;
 }    
 
-/*=============== nsIDOMMouseMotionListener ======================*/
-
-nsresult
-nsPluginInstanceOwner::MouseMove(nsIDOMEvent* aMouseEvent)
-{
-#if !defined(XP_MACOSX)
-  if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow))
-    return aMouseEvent->PreventDefault(); // consume event
-  // continue only for cases without child window
-#endif
-
-  // don't send mouse events if we are hidden
-  if (!mWidgetVisible)
-    return NS_OK;
-
-  nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aMouseEvent));
-  if (privateEvent) {
-    nsMouseEvent* mouseEvent = (nsMouseEvent *) privateEvent->GetInternalNSEvent();
-    if (mouseEvent) {
-      nsEventStatus rv = ProcessEvent(*mouseEvent);
-      if (nsEventStatus_eConsumeNoDefault == rv) {
-        return aMouseEvent->PreventDefault(); // consume event
-      }
-    }
-    else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::MouseMove failed, mouseEvent null");   
-  }
-  else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::MouseMove failed, privateEvent null");   
-  
-  return NS_OK;
-}
-
-/*=============== nsIDOMMouseListener ======================*/
-
 nsresult
 nsPluginInstanceOwner::MouseDown(nsIDOMEvent* aMouseEvent)
 {
 #if !defined(XP_MACOSX)
   if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow))
     return aMouseEvent->PreventDefault(); // consume event
   // continue only for cases without child window
 #endif
@@ -1856,103 +1782,104 @@ nsPluginInstanceOwner::MouseDown(nsIDOME
     if (fm) {
       nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(mContent);
       fm->SetFocus(elem, 0);
     }
   }
 
   nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aMouseEvent));
   if (privateEvent) {
-    nsMouseEvent* mouseEvent = (nsMouseEvent *) privateEvent->GetInternalNSEvent();
-    if (mouseEvent) {
-      nsEventStatus rv = ProcessEvent(*mouseEvent);
+    nsEvent* event = privateEvent->GetInternalNSEvent();
+      if (event && event->eventStructType == NS_MOUSE_EVENT) {
+        nsEventStatus rv = ProcessEvent(*static_cast<nsGUIEvent*>(event));
       if (nsEventStatus_eConsumeNoDefault == rv) {
         return aMouseEvent->PreventDefault(); // consume event
       }
     }
     else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::MouseDown failed, mouseEvent null");   
   }
   else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::MouseDown failed, privateEvent null");   
   
   return NS_OK;
 }
 
-nsresult
-nsPluginInstanceOwner::MouseUp(nsIDOMEvent* aMouseEvent)
-{
-  // Don't send a mouse-up event to the plugin if it isn't focused.  This can
-  // happen if the previous mouse-down was sent to a DOM element above the
-  // plugin, the mouse is still above the plugin, and the mouse-down event
-  // caused the element to disappear.  See bug 627649.
-  if (!mContentFocused) {
-    aMouseEvent->PreventDefault();
-    return NS_OK;
-  }
-  return DispatchMouseToPlugin(aMouseEvent);
-}
-
-nsresult
-nsPluginInstanceOwner::MouseClick(nsIDOMEvent* aMouseEvent)
-{
-  return DispatchMouseToPlugin(aMouseEvent);
-}
-
-nsresult
-nsPluginInstanceOwner::MouseDblClick(nsIDOMEvent* aMouseEvent)
-{
-  return DispatchMouseToPlugin(aMouseEvent);
-}
-
-nsresult
-nsPluginInstanceOwner::MouseOver(nsIDOMEvent* aMouseEvent)
-{
-  return DispatchMouseToPlugin(aMouseEvent);
-}
-
-nsresult
-nsPluginInstanceOwner::MouseOut(nsIDOMEvent* aMouseEvent)
-{
-  return DispatchMouseToPlugin(aMouseEvent);
-}
-
 nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent)
 {
 #if !defined(XP_MACOSX)
   if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow))
     return aMouseEvent->PreventDefault(); // consume event
   // continue only for cases without child window
 #endif
   // don't send mouse events if we are hidden
   if (!mWidgetVisible)
     return NS_OK;
 
   nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aMouseEvent));
   if (privateEvent) {
-    nsMouseEvent* mouseEvent = (nsMouseEvent *) privateEvent->GetInternalNSEvent();
-    if (mouseEvent) {
-      nsEventStatus rv = ProcessEvent(*mouseEvent);
+    nsEvent* event = privateEvent->GetInternalNSEvent();
+    if (event && event->eventStructType == NS_MOUSE_EVENT) {
+      nsEventStatus rv = ProcessEvent(*static_cast<nsGUIEvent*>(event));
       if (nsEventStatus_eConsumeNoDefault == rv) {
         aMouseEvent->PreventDefault();
         aMouseEvent->StopPropagation();
       }
     }
     else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchMouseToPlugin failed, mouseEvent null");   
   }
   else NS_ASSERTION(PR_FALSE, "nsPluginInstanceOwner::DispatchMouseToPlugin failed, privateEvent null");   
   
   return NS_OK;
 }
 
 nsresult
 nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
 {
-  if (mInstance) {
+  nsAutoString eventType;
+  aEvent->GetType(eventType);
+  if (eventType.EqualsLiteral("focus")) {
+    mContentFocused = PR_TRUE;
+    return DispatchFocusToPlugin(aEvent);
+  }
+  if (eventType.EqualsLiteral("blur")) {
+    mContentFocused = PR_FALSE;
+    return DispatchFocusToPlugin(aEvent);
+  }
+  if (eventType.EqualsLiteral("mousedown")) {
+    return MouseDown(aEvent);
+  }
+  if (eventType.EqualsLiteral("mouseup")) {
+    // Don't send a mouse-up event to the plugin if it isn't focused.  This can
+    // happen if the previous mouse-down was sent to a DOM element above the
+    // plugin, the mouse is still above the plugin, and the mouse-down event
+    // caused the element to disappear.  See bug 627649.
+    if (!mContentFocused) {
+      aEvent->PreventDefault();
+      return NS_OK;
+    }
+    return DispatchMouseToPlugin(aEvent);
+  }
+  if (eventType.EqualsLiteral("mousemove") ||
+      eventType.EqualsLiteral("click") ||
+      eventType.EqualsLiteral("dblclick") ||
+      eventType.EqualsLiteral("mouseover") ||
+      eventType.EqualsLiteral("mouseout")) {
+    return DispatchMouseToPlugin(aEvent);
+  }
+  if (eventType.EqualsLiteral("keydown") ||
+      eventType.EqualsLiteral("keyup")) {
+    return DispatchKeyToPlugin(aEvent);
+  }
+  if (eventType.EqualsLiteral("keypress")) {
+    return KeyPress(aEvent);
+  }
+
+  nsCOMPtr<nsIDOMDragEvent> dragEvent(do_QueryInterface(aEvent));
+  if (dragEvent && mInstance) {
     nsCOMPtr<nsIPrivateDOMEvent> privateEvent(do_QueryInterface(aEvent));
-    nsCOMPtr<nsIDOMDragEvent> dragEvent(do_QueryInterface(aEvent));
-    if (privateEvent && dragEvent) {
+    if (privateEvent) {
       nsEvent* ievent = privateEvent->GetInternalNSEvent();
       if (ievent && NS_IS_TRUSTED_EVENT(ievent) &&
           (ievent->message == NS_DRAGDROP_ENTER || ievent->message == NS_DRAGDROP_OVER)) {
         // set the allowed effect to none here. The plugin should set it if necessary
         nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
         dragEvent->GetDataTransfer(getter_AddRefs(dataTransfer));
         if (dataTransfer)
           dataTransfer->SetEffectAllowed(NS_LITERAL_STRING("none"));
@@ -2501,48 +2428,38 @@ nsPluginInstanceOwner::Destroy()
 #endif
 
   // unregister context menu listener
   if (mCXMenuListener) {
     mCXMenuListener->Destroy(mContent);
     mCXMenuListener = nsnull;
   }
 
-  nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(mContent));
-  if (target) {
-
-    nsCOMPtr<nsIDOMEventListener> listener;
-    QueryInterface(NS_GET_IID(nsIDOMEventListener), getter_AddRefs(listener));
-
-    // Unregister focus event listener
-    mContent->RemoveEventListenerByIID(listener, NS_GET_IID(nsIDOMFocusListener));
-
-    // Unregister mouse event listener
-    mContent->RemoveEventListenerByIID(listener, NS_GET_IID(nsIDOMMouseListener));
-
-    // now for the mouse motion listener
-    mContent->RemoveEventListenerByIID(listener, NS_GET_IID(nsIDOMMouseMotionListener));
-
-    // Unregister key event listener;
-    target->RemoveEventListener(NS_LITERAL_STRING("keypress"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("keydown"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("keyup"), listener, PR_TRUE);
-
-    // Unregister drag event listener;
-    target->RemoveEventListener(NS_LITERAL_STRING("drop"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("dragdrop"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("drag"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("dragenter"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("dragover"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("dragexit"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("dragleave"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("dragstart"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("draggesture"), listener, PR_TRUE);
-    target->RemoveEventListener(NS_LITERAL_STRING("dragend"), listener, PR_TRUE);
-  }
+  mContent->RemoveEventListener(NS_LITERAL_STRING("focus"), this, PR_FALSE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("blur"), this, PR_FALSE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("mouseup"), this, PR_FALSE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("mousedown"), this, PR_FALSE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("mousemove"), this, PR_FALSE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("click"), this, PR_FALSE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("dblclick"), this, PR_FALSE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("mouseover"), this, PR_FALSE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("mouseout"), this, PR_FALSE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("keypress"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("keydown"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("keyup"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("drop"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("dragdrop"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("drag"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("dragenter"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("dragover"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("dragleave"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("dragexit"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("dragstart"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("draggesture"), this, PR_TRUE);
+  mContent->RemoveEventListener(NS_LITERAL_STRING("dragend"), this, PR_TRUE);
 
   if (mWidget) {
     nsCOMPtr<nsIPluginWidget> pluginWidget = do_QueryInterface(mWidget);
     if (pluginWidget)
       pluginWidget->SetPluginInstanceOwner(nsnull);
 
     if (mDestroyWidget)
       mWidget->Destroy();
@@ -2962,48 +2879,47 @@ nsresult nsPluginInstanceOwner::Init(nsP
   }
 
   // register context menu listener
   mCXMenuListener = new nsPluginDOMContextMenuListener();
   if (mCXMenuListener) {    
     mCXMenuListener->Init(aContent);
   }
 
-  nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(mContent));
-  if (target) {
-
-    nsCOMPtr<nsIDOMEventListener> listener;
-    QueryInterface(NS_GET_IID(nsIDOMEventListener), getter_AddRefs(listener));
-
-    // Register focus listener
-    mContent->AddEventListenerByIID(listener, NS_GET_IID(nsIDOMFocusListener));
-
-    // Register mouse listener
-    mContent->AddEventListenerByIID(listener, NS_GET_IID(nsIDOMMouseListener));
-
-    // now do the mouse motion listener
-    mContent->AddEventListenerByIID(listener, NS_GET_IID(nsIDOMMouseMotionListener));
-
-    // Register key listener
-    target->AddEventListener(NS_LITERAL_STRING("keypress"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("keydown"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("keyup"), listener, PR_TRUE);
-
-    // Register drag listener
-    target->AddEventListener(NS_LITERAL_STRING("drop"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("dragdrop"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("drag"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("dragenter"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("dragover"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("dragleave"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("dragexit"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("dragstart"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("draggesture"), listener, PR_TRUE);
-    target->AddEventListener(NS_LITERAL_STRING("dragend"), listener, PR_TRUE);
-  }
+  mContent->AddEventListener(NS_LITERAL_STRING("focus"), this, PR_FALSE,
+                             PR_FALSE);
+  mContent->AddEventListener(NS_LITERAL_STRING("blur"), this, PR_FALSE,
+                             PR_FALSE);
+  mContent->AddEventListener(NS_LITERAL_STRING("mouseup"), this, PR_FALSE,
+                             PR_FALSE);
+  mContent->AddEventListener(NS_LITERAL_STRING("mousedown"), this, PR_FALSE,
+                             PR_FALSE);
+  mContent->AddEventListener(NS_LITERAL_STRING("mousemove"), this, PR_FALSE,
+                             PR_FALSE);
+  mContent->AddEventListener(NS_LITERAL_STRING("click"), this, PR_FALSE,
+                             PR_FALSE);
+  mContent->AddEventListener(NS_LITERAL_STRING("dblclick"), this, PR_FALSE,
+                             PR_FALSE);
+  mContent->AddEventListener(NS_LITERAL_STRING("mouseover"), this, PR_FALSE,
+                             PR_FALSE);
+  mContent->AddEventListener(NS_LITERAL_STRING("mouseout"), this, PR_FALSE,
+                             PR_FALSE);
+  mContent->AddEventListener(NS_LITERAL_STRING("keypress"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("keydown"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("keyup"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("drop"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("dragdrop"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("drag"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("dragenter"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("dragover"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("dragleave"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("dragexit"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("dragstart"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("draggesture"), this, PR_TRUE);
+  mContent->AddEventListener(NS_LITERAL_STRING("dragend"), this, PR_TRUE);
   
   // Register scroll position listeners
   // We need to register a scroll position listener on every scrollable
   // frame up to the top
   for (nsIFrame* f = mObjectFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
     nsIScrollableFrame* sf = do_QueryFrame(f);
     if (sf) {
       sf->AddScrollPositionListener(this);
@@ -3388,24 +3304,23 @@ void nsPluginInstanceOwner::FixUpURLS(co
 nsPluginDOMContextMenuListener::nsPluginDOMContextMenuListener()
 {
 }
 
 nsPluginDOMContextMenuListener::~nsPluginDOMContextMenuListener()
 {
 }
 
-NS_IMPL_ISUPPORTS2(nsPluginDOMContextMenuListener,
-                   nsIDOMContextMenuListener,
+NS_IMPL_ISUPPORTS1(nsPluginDOMContextMenuListener,
                    nsIDOMEventListener)
 
 NS_IMETHODIMP
-nsPluginDOMContextMenuListener::ContextMenu(nsIDOMEvent* aContextMenuEvent)
+nsPluginDOMContextMenuListener::HandleEvent(nsIDOMEvent* aEvent)
 {
-  aContextMenuEvent->PreventDefault(); // consume event
+  aEvent->PreventDefault(); // consume event
   
   return NS_OK;
 }
 
 nsresult nsPluginDOMContextMenuListener::Init(nsIContent* aContent)
 {
   nsCOMPtr<nsIDOMEventTarget> receiver(do_QueryInterface(aContent));
   if (receiver) {
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -47,25 +47,27 @@
 #ifndef nsPluginInstanceOwner_h_
 #define nsPluginInstanceOwner_h_
 
 #include "prtypes.h"
 #include "npapi.h"
 #include "nsCOMPtr.h"
 #include "nsIPluginInstanceOwner.h"
 #include "nsIPluginTagInfo.h"
-#include "nsIDOMMouseListener.h"
-#include "nsIDOMMouseMotionListener.h"
-#include "nsIDOMKeyListener.h"
-#include "nsIDOMFocusListener.h"
+#include "nsIDOMEventListener.h"
 #include "nsIScrollPositionListener.h"
 #include "nsPluginHost.h"
 #include "nsPluginNativeWindow.h"
 #include "gfxRect.h"
 
+// X.h defines KeyPress
+#ifdef KeyPress
+#undef KeyPress
+#endif
+
 #ifdef XP_MACOSX
 #include "nsCoreAnimationSupport.h"
 #include <ApplicationServices/ApplicationServices.h>
 #endif
 
 class nsIInputStream;
 class nsIntRect;
 class nsPluginDOMContextMenuListener;
@@ -85,22 +87,24 @@ class gfxXlibSurface;
 #endif
 
 #ifdef XP_OS2
 #define INCL_PM
 #define INCL_GPI
 #include <os2.h>
 #endif
 
+// X.h defines KeyPress
+#ifdef KeyPress
+#undef KeyPress
+#endif
+
 class nsPluginInstanceOwner : public nsIPluginInstanceOwner,
                               public nsIPluginTagInfo,
-                              public nsIDOMMouseListener,
-                              public nsIDOMMouseMotionListener,
-                              public nsIDOMKeyListener,
-                              public nsIDOMFocusListener,
+                              public nsIDOMEventListener,
                               public nsIScrollPositionListener
 {
 public:
   nsPluginInstanceOwner();
   virtual ~nsPluginInstanceOwner();
   
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPLUGININSTANCEOWNER
@@ -114,38 +118,22 @@ public:
   NPError    ShowNativeContextMenu(NPMenu* menu, void* event);
   
   NPBool     ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
                           double *destX, double *destY, NPCoordinateSpace destSpace);
   
   //nsIPluginTagInfo interface
   NS_DECL_NSIPLUGINTAGINFO
   
-  // nsIDOMMouseListener interfaces 
-  NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);     
+  // nsIDOMEventListener interfaces 
+  NS_DECL_NSIDOMEVENTLISTENER
   
-  // nsIDOMMouseMotionListener interfaces
-  NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent) { return NS_OK; }
-  
-  // nsIDOMKeyListener interfaces
-  NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
-  NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
-  NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
-  
-  // nsIDOMFocusListener interfaces
-  NS_IMETHOD Focus(nsIDOMEvent * aFocusEvent);
-  NS_IMETHOD Blur(nsIDOMEvent * aFocusEvent);
-  
+  nsresult MouseDown(nsIDOMEvent* aKeyEvent);
+  nsresult KeyPress(nsIDOMEvent* aKeyEvent);
+
   nsresult Destroy();  
   
   void PrepareToStop(PRBool aDelayedStop);
   
 #ifdef XP_WIN
   void Paint(const RECT& aDirty, HDC aDC);
 #elif defined(XP_MACOSX)
   void Paint(const gfxRect& aDirtyRect, CGContextRef cgContext);  
deleted file mode 100644
--- a/dom/public/coreEvents/Makefile.in
+++ /dev/null
@@ -1,61 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH		= ../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE		= dom
-
-EXPORTS =				\
-	nsIDOMFocusListener.h		\
-	nsIDOMFormListener.h		\
-	nsIDOMKeyListener.h		\
-	nsIDOMLoadListener.h		\
-	nsIDOMMouseListener.h		\
-	nsIDOMMouseMotionListener.h	\
-	nsIDOMTextListener.h		\
-	nsIDOMCompositionListener.h	\
-	nsIDOMContextMenuListener.h	\
-	nsIDOMUIListener.h		\
-	$(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
deleted file mode 100644
--- a/dom/public/coreEvents/nsIDOMCompositionListener.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsIDOMCompositionListener_h__
-#define nsIDOMCompositionListener_h__
-
-#include "nsIDOMEvent.h"
-#include "nsIDOMEventListener.h"
-
-/*
- * Key pressed / released / typed listener interface.
- */
-// {47F158C0-C534-43a1-8415-8B17706E2FBC}
-#define NS_IDOMCOMPOSITIONLISTENER_IID	\
-{ 0x47f158c0, 0xc534, 0x43a1, \
-{ 0x84, 0x15, 0x8b, 0x17, 0x70, 0x6e, 0x2f, 0xbc } }
-
-
-class nsIDOMCompositionListener : public nsIDOMEventListener {
-
-public:
-
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMCOMPOSITIONLISTENER_IID)
-
-  NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent) = 0;
-  NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent) = 0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMCompositionListener,
-                              NS_IDOMCOMPOSITIONLISTENER_IID)
-
-#endif // nsIDOMCompositionListener_h__
deleted file mode 100644
--- a/dom/public/coreEvents/nsIDOMContextMenuListener.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#ifndef nsIDOMContextMenuListener_h__
-#define nsIDOMContextMenuListener_h__
-
-#include "nsIDOMEvent.h"
-#include "nsIDOMEventListener.h"
-
-/*
- * Context menu event listener
- *
- */
-#define NS_IDOMCONTEXTMENULISTENER_IID \
-{ /* 162b3480-ded6-11d1-bd85-00805f8ae3f7 */ \
-0x162b3480, 0xded6, 0x11d1, \
-{0xbd, 0x85, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf7} }
-
-class nsIDOMContextMenuListener : public nsIDOMEventListener {
-
-public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMCONTEXTMENULISTENER_IID)
-  /**
-  * Processes a context menu event
-  * @param aContextMenuEvent @see nsIDOMEvent.h 
-  * @returns whether the event was consumed or ignored. @see nsresult
-  */
-  NS_IMETHOD ContextMenu(nsIDOMEvent* aContextMenuEvent) = 0;
-
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMContextMenuListener,
-                              NS_IDOMCONTEXTMENULISTENER_IID)
-
-#endif // nsIDOMContextMenuListener_h__
deleted file mode 100644
--- a/dom/public/coreEvents/nsIDOMFocusListener.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#ifndef nsIDOMFocusListener_h__
-#define nsIDOMFocusListener_h__
-
-#include "nsIDOMEvent.h"
-#include "nsIDOMEventListener.h"
-
-/*
- * Mouse up/down/move event listener
- *
- */
-#define NS_IDOMFOCUSLISTENER_IID \
-{ /* 80974670-ded6-11d1-bd85-00805f8ae3f4 */ \
-0x80974670, 0xded6, 0x11d1, \
-{0xbd, 0x85, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
-
-class nsIDOMFocusListener : public nsIDOMEventListener
-{
-public:
-
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMFOCUSLISTENER_IID)
-
-  /**
-  * Processes a focus event
-  * @param aMouseEvent @see nsIDOMEvent.h 
-  * @returns whether the event was consumed or ignored. @see nsresult
-  */
-  NS_IMETHOD Focus(nsIDOMEvent* aEvent) = 0;
-
-  /**
-   * Processes a blur event
-   * @param aMouseEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD Blur(nsIDOMEvent* aEvent) = 0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMFocusListener, NS_IDOMFOCUSLISTENER_IID)
-
-#endif // nsIDOMFocusListener_h__
deleted file mode 100644
--- a/dom/public/coreEvents/nsIDOMFormListener.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#ifndef nsIDOMFormListener_h__
-#define nsIDOMFormListener_h__
-
-#include "nsIDOMEvent.h"
-#include "nsIDOMEventListener.h"
-
-/*
- * Form submit/reset listener
- *
- */
-#define NS_IDOMFORMLISTENER_IID \
-{ /* 566c3f80-28ab-11d2-bd89-00805f8ae3f4 */ \
-0x566c3f80, 0x28ab, 0x11d2, \
-{0xbd, 0x89, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
-
-class nsIDOMFormListener : public nsIDOMEventListener {
-
-public:
-   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMFORMLISTENER_IID)
-  /**
-  * Processes a form submit event
-  * @param aEvent @see nsIDOMEvent.h 
-  * @returns whether the event was consumed or ignored. @see nsresult
-  */
-  NS_IMETHOD Submit(nsIDOMEvent* aEvent) = 0;
-
-  /**
-   * Processes a form reset event
-   * @param aEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD Reset(nsIDOMEvent* aEvent) = 0;
-
-  /**
-   * Processes a form change event
-   * @param aEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD Change(nsIDOMEvent* aEvent) = 0;
-
-  /**
-   * Processes a form select event
-   * @param aEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD Select(nsIDOMEvent* aEvent) = 0;
-  
-  /**
-   * Processes a form input event
-   * @param aEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD Input(nsIDOMEvent* aEvent) = 0;
-
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMFormListener, NS_IDOMFORMLISTENER_IID)
-
-#endif // nsIDOMFormListener_h__
deleted file mode 100644
--- a/dom/public/coreEvents/nsIDOMKeyListener.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsIDOMKeyListener_h__
-#define nsIDOMKeyListener_h__
-
-#include "nsIDOMEvent.h"
-#include "nsIDOMEventListener.h"
-
-// X.h defines KeyPress
-#ifdef KeyPress
-#undef KeyPress
-#endif
-
-/*
- * Key pressed / released / typed listener interface.
- */
-#define NS_IDOMKEYLISTENER_IID \
-{ /* 35f0d080-da38-11d1-bd85-00805f8ae3f4 */ \
-0x35f0d080, 0xda38, 0x11d1, \
-{0xbd, 0x85, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
-
-class nsIDOMKeyListener : public nsIDOMEventListener {
-
-public:
-
-     NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMKEYLISTENER_IID)
-    
-    /**
-     * Processes a key pressed event
-     * @param aKeyEvent @see nsIDOMEvent.h 
-     * @returns whether the event was consumed or ignored. @see nsresult
-     */
-    NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent) = 0;
-
-    /**
-     * Processes a key release event
-     * @param aKeyEvent @see nsIDOMEvent.h 
-     * @returns whether the event was consumed or ignored. @see nsresult
-     */
-    NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent) = 0;
-
-    /**
-     * Processes a key typed event
-     * @param aKeyEvent @see nsIDOMEvent.h 
-     * @returns whether the event was consumed or ignored. @see nsresult
-     *
-     */
-    NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent) = 0;
-
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMKeyListener, NS_IDOMKEYLISTENER_IID)
-
-#endif // nsIDOMKeyListener_h__
deleted file mode 100644
--- a/dom/public/coreEvents/nsIDOMLoadListener.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#ifndef nsIDOMLoadListener_h__
-#define nsIDOMLoadListener_h__
-
-#include "nsIDOMEvent.h"
-#include "nsIDOMEventListener.h"
-
-/*
- * Document load related event listener
- *
- */
-#define NS_IDOMLOADLISTENER_IID \
-{ /* d1810238-14f8-4cab-9b96-96bedb9de7be */ \
-0xd1810238, 0x14f8, 0x4cab, \
-{0x9b, 0x96, 0x96, 0xbe, 0xdb, 0x9d, 0xe7, 0xbe} }
-
-class nsIDOMLoadListener : public nsIDOMEventListener {
-
-public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMLOADLISTENER_IID)
-  /**
-  * Processes a page or image load event
-  * @param aMouseEvent @see nsIDOMEvent.h 
-  * @returns whether the event was consumed or ignored. @see nsresult
-  */
-  NS_IMETHOD Load(nsIDOMEvent* aEvent) = 0;
-
-  /**
-   * Processes a page beforeUnload event
-   * @param aMouseEvent @see nsIDOMEvent.h
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD BeforeUnload(nsIDOMEvent* aEvent) = 0;
-
-  /**
-   * Processes a page unload event
-   * @param aMouseEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD Unload(nsIDOMEvent* aEvent) = 0;
-
-  /**
-   * Processes a load abort event
-   * @param aMouseEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   *
-   */
-  NS_IMETHOD Abort(nsIDOMEvent* aEvent) = 0;
-
-  /**
-   * Processes an load error event
-   * @param aMouseEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD Error(nsIDOMEvent* aEvent) = 0;
-
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMLoadListener, NS_IDOMLOADLISTENER_IID)
-
-#endif // nsIDOMLoadListener_h__
deleted file mode 100644
--- a/dom/public/coreEvents/nsIDOMMouseListener.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#ifndef nsIDOMMouseListener_h__
-#define nsIDOMMouseListener_h__
-
-#include "nsIDOMEvent.h"
-#include "nsIDOMEventListener.h"
-
-/*
- * Mouse up/down/move event listener
- *
- */
-#define NS_IDOMMOUSELISTENER_IID \
-{ /* ccd7fa30-da37-11d1-bd85-00805f8ae3f4 */ \
-0xccd7fa30, 0xda37, 0x11d1, \
-{0xbd, 0x85, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
-
-class nsIDOMMouseListener : public nsIDOMEventListener {
-
-public:
-
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMMOUSELISTENER_IID)
-
-  /**
-  * Processes a mouse down event
-  * @param aMouseEvent @see nsIDOMEvent.h 
-  * @returns whether the event was consumed or ignored. @see nsresult
-  */
-  NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent) = 0;
-
-  /**
-   * Processes a mouse up event
-   * @param aMouseEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent) = 0;
-
-  /**
-   * Processes a mouse click event
-   * @param aMouseEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   *
-   */
-  NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent) = 0;
-
-  /**
-   * Processes a mouse click event
-   * @param aMouseEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   *
-   */
-  NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent) = 0;
-
-  /**
-   * Processes a mouse enter event
-   * @param aMouseEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent) = 0;
-
-  /**
-   * Processes a mouse leave event
-   * @param aMouseEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent) = 0;
-
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMMouseListener, NS_IDOMMOUSELISTENER_IID)
-
-#endif // nsIDOMMouseListener_h__
deleted file mode 100644
--- a/dom/public/coreEvents/nsIDOMMouseMotionListener.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-
-#ifndef nsIDOMMouseMotionListener_h__
-#define nsIDOMMouseMotionListener_h__
-
-#include "nsIDOMEvent.h"
-#include "nsIDOMEventListener.h"
-
-/*
- * Mouse motion event listener
- *
- */
-#define NS_IDOMMOUSEMOTIONLISTENER_IID \
-{ /* 162b3480-ded6-11d1-bd85-00805f8ae3f4 */ \
-0x162b3480, 0xded6, 0x11d1, \
-{0xbd, 0x85, 0x00, 0x80, 0x5f, 0x8a, 0xe3, 0xf4} }
-
-class nsIDOMMouseMotionListener : public nsIDOMEventListener {
-
-public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMMOUSEMOTIONLISTENER_IID)
-  /**
-  * Processes a mouse move event
-  * @param aMouseEvent @see nsIDOMEvent.h 
-  * @returns whether the event was consumed or ignored. @see nsresult
-  */
-  NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent) = 0;
-
-  /**
-   * Processes a drag move event
-   * @param aMouseEvent @see nsIDOMEvent.h 
-   * @returns whether the event was consumed or ignored. @see nsresult
-   */
-  NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent) = 0;
-
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMMouseMotionListener,
-                              NS_IDOMMOUSEMOTIONLISTENER_IID)
-
-#endif // nsIDOMMouseMotionListener_h__
deleted file mode 100644
--- a/dom/public/coreEvents/nsIDOMTextListener.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsIDOMTextListener_h__
-#define nsIDOMTextListener_h__
-
-#include "nsIDOMEvent.h"
-#include "nsIDOMEventListener.h"
-
-/*
- * Key pressed / released / typed listener interface.
- */
-// {C6296E81-D823-11d2-9E7F-0060089FE59B}
-#define NS_IDOMTEXTLISTENER_IID \
-{ 0xc6296e81, 0xd823, 0x11d2, { 0x9e, 0x7f, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b } }
-
-
-class nsIDOMTextListener : public nsIDOMEventListener
-{
-public:
-
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMTEXTLISTENER_IID)
-
-  NS_IMETHOD HandleText(nsIDOMEvent* aTextEvent) = 0;
-
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMTextListener, NS_IDOMTEXTLISTENER_IID)
-
-#endif // nsIDOMTextListener_h__
deleted file mode 100644
--- a/dom/public/coreEvents/nsIDOMUIListener.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * IBM Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Brian Ryner <bryner@brianryner.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
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsIDOMUIListener_h__
-#define nsIDOMUIListener_h__
-
-#include "nsIDOMEventListener.h"
-
-class nsIDOMEvent;
-
-/*
- * UI event listener interface.
- */
-// {5cb5527a-512f-4163-9393-ca95ceddbc13}
-#define NS_IDOMUILISTENER_IID \
-{ 0x5cb5527a, 0x512f, 0x4163, { 0x93, 0x93, 0xca, 0x95, 0xce, 0xdd, 0xbc, 0x13 } }
-
-class nsIDOMUIListener : public nsIDOMEventListener {
- public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMUILISTENER_IID)
-
-  NS_IMETHOD Activate(nsIDOMEvent* aEvent) = 0;
-  NS_IMETHOD FocusIn(nsIDOMEvent* aEvent) = 0;
-  NS_IMETHOD FocusOut(nsIDOMEvent* aEvent) = 0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMUIListener, NS_IDOMUILISTENER_IID)
-
-#endif // nsIDOMUIListener_h__
--- a/dom/src/events/nsJSEventListener.h
+++ b/dom/src/events/nsJSEventListener.h
@@ -35,17 +35,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsJSEventListener_h__
 #define nsJSEventListener_h__
 
 #include "nsIDOMKeyEvent.h"
 #include "nsIJSEventListener.h"
-#include "nsIDOMMouseListener.h"
+#include "nsIDOMEventListener.h"
 #include "jsapi.h"
 #include "nsCOMPtr.h"
 #include "nsIAtom.h"
 #include "nsIScriptContext.h"
 #include "nsCycleCollectionParticipant.h"
 
 // nsJSEventListener interface
 // misnamed - JS no longer has exclusive rights over this interface!
--- a/dom/src/storage/nsDOMStorageDBWrapper.cpp
+++ b/dom/src/storage/nsDOMStorageDBWrapper.cpp
@@ -37,16 +37,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsCOMPtr.h"
 #include "nsDOMError.h"
 #include "nsDOMStorage.h"
 #include "nsDOMStorageDBWrapper.h"
 #include "nsIFile.h"
+#include "nsIURL.h"
 #include "nsIVariant.h"
 #include "nsIEffectiveTLDService.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "mozStorageCID.h"
 #include "mozStorageHelper.h"
 #include "mozIStorageService.h"
 #include "mozIStorageValueArray.h"
 #include "mozIStorageFunction.h"
@@ -349,25 +350,32 @@ nsDOMStorageDBWrapper::CreateDomainScope
 
   nsCAutoString domainScope;
   rv = aUri->GetAsciiHost(domainScope);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (domainScope.IsEmpty()) {
     // About pages have an empty host but a valid path.  Since they are handled
     // internally by our own redirector, we can trust them and use path as key.
-    PRBool isAboutUrl = PR_FALSE;
-    if ((NS_SUCCEEDED(aUri->SchemeIs("about", &isAboutUrl)) && isAboutUrl) ||
-        (NS_SUCCEEDED(aUri->SchemeIs("moz-safe-about", &isAboutUrl)) && isAboutUrl)) {
+    // if file:/// protocol, let's make the exact directory the domain
+    PRBool isScheme = PR_FALSE;
+    if ((NS_SUCCEEDED(aUri->SchemeIs("about", &isScheme)) && isScheme) ||
+        (NS_SUCCEEDED(aUri->SchemeIs("moz-safe-about", &isScheme)) && isScheme)) {
       rv = aUri->GetPath(domainScope);
       NS_ENSURE_SUCCESS(rv, rv);
       // While the host is always canonicalized to lowercase, the path is not,
       // thus need to force the casing.
       ToLowerCase(domainScope);
     }
+    else if (NS_SUCCEEDED(aUri->SchemeIs("file", &isScheme)) && isScheme) {
+      nsCOMPtr<nsIURL> url = do_QueryInterface(aUri, &rv);
+      NS_ENSURE_SUCCESS(rv, rv);
+      rv = url->GetDirectory(domainScope);
+      NS_ENSURE_SUCCESS(rv, rv);
+    }
   }
 
   rv = CreateDomainScopeDBKey(domainScope, aKey);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -286,26 +286,26 @@ CreateJSContextForWorker(WorkerPrivate* 
     JS_SetVersion(workerCx, JSVERSION_LATEST);
   }
 
   return workerCx;
 }
 
 class WorkerMemoryReporter : public nsIMemoryMultiReporter
 {
-  JSRuntime* mRuntime;
+  WorkerPrivate* mWorkerPrivate;
   nsCString mPathPrefix;
 
 public:
   NS_DECL_ISUPPORTS
 
-  WorkerMemoryReporter(WorkerPrivate* aWorkerPrivate, JSRuntime* aRuntime)
-  : mRuntime(aRuntime)
+  WorkerMemoryReporter(WorkerPrivate* aWorkerPrivate)
+  : mWorkerPrivate(aWorkerPrivate)
   {
-    NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
+    aWorkerPrivate->AssertIsOnWorkerThread();
 
     nsCString escapedDomain(aWorkerPrivate->Domain());
     escapedDomain.ReplaceChar('/', '\\');
 
     NS_ConvertUTF16toUTF8 escapedURL(aWorkerPrivate->ScriptURL());
     escapedURL.ReplaceChar('/', '\\');
 
     // 64bit address plus '0x' plus null terminator.
@@ -326,20 +326,18 @@ public:
   }
 
   NS_IMETHOD
   CollectReports(nsIMemoryMultiReporterCallback* aCallback,
                  nsISupports* aClosure)
   {
     AssertIsOnMainThread();
 
-    JS_TriggerAllOperationCallbacks(mRuntime);
-
     IterateData data;
-    if (!CollectCompartmentStatsForRuntime(mRuntime, &data)) {
+    if (!mWorkerPrivate->BlockAndCollectRuntimeStats(&data)) {
       return NS_ERROR_FAILURE;
     }
 
     ReportJSRuntimeStats(data, mPathPrefix, aCallback, aClosure);
 
     return NS_OK;
   }
 };
@@ -367,34 +365,37 @@ public:
 
     JSContext* cx = CreateJSContextForWorker(workerPrivate);
     if (!cx) {
       // XXX need to fire an error at parent.
       NS_ERROR("Failed to create runtime and context!");
       return NS_ERROR_FAILURE;
     }
 
-    JSRuntime* rt = JS_GetRuntime(cx);
-
     nsRefPtr<WorkerMemoryReporter> reporter =
-      new WorkerMemoryReporter(workerPrivate, rt);
+      new WorkerMemoryReporter(workerPrivate);
     if (NS_FAILED(NS_RegisterMemoryMultiReporter(reporter))) {
       NS_WARNING("Failed to register memory reporter!");
       reporter = nsnull;
     }
 
-    workerPrivate->DoRunLoop(cx);
+    {
+      JSAutoRequest ar(cx);
+      workerPrivate->DoRunLoop(cx);
+    }
 
     if (reporter) {
       if (NS_FAILED(NS_UnregisterMemoryMultiReporter(reporter))) {
         NS_WARNING("Failed to unregister memory reporter!");
       }
       reporter = nsnull;
     }
 
+    JSRuntime* rt = JS_GetRuntime(cx);
+
     // XXX Bug 666963 - CTypes can create another JSContext for use with
     // closures, and then it holds that context in a reserved slot on the CType
     // prototype object. We have to destroy that context before we can destroy
     // the runtime, and we also have to make sure that it isn't the last context
     // to be destroyed (otherwise it will assert). To accomplish this we create
     // an unused dummy context, destroy our real context, and then destroy the
     // dummy. Once this bug is resolved we can remove this nastiness and simply
     // call JS_DestroyContextNoGC on our context.
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -59,16 +59,17 @@
 #include "nsContentUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsDOMJSUtils.h"
 #include "nsGUIEvent.h"
 #include "nsJSEnvironment.h"
 #include "nsJSUtils.h"
 #include "nsNetUtil.h"
 #include "nsThreadUtils.h"
+#include "xpcpublic.h"
 
 #include "Events.h"
 #include "Exceptions.h"
 #include "Principal.h"
 #include "RuntimeService.h"
 #include "ScriptLoader.h"
 #include "WorkerFeature.h"
 #include "WorkerScope.h"
@@ -78,16 +79,17 @@
 #if 0 // Define to run GC more often.
 #define EXTRA_GC
 #endif
 
 using mozilla::MutexAutoLock;
 using mozilla::TimeDuration;
 using mozilla::TimeStamp;
 using mozilla::dom::workers::exceptions::ThrowDOMExceptionForCode;
+using mozilla::xpconnect::memory::IterateData;
 
 USING_WORKERS_NAMESPACE
 
 namespace {
 
 const char gErrorChars[] = "error";
 const char gMessageChars[] = "message";
 
@@ -1065,16 +1067,70 @@ public:
   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
   {
     aWorkerPrivate->UpdateGCZealInternal(aCx, mGCZeal);
     return true;
   }
 };
 #endif
 
+class CollectRuntimeStatsRunnable : public WorkerControlRunnable
+{
+  typedef mozilla::Mutex Mutex;
+  typedef mozilla::CondVar CondVar;
+
+  Mutex* mMutex;
+  CondVar* mCondVar;
+  volatile bool* mDoneFlag;
+  IterateData* mData;
+  volatile bool* mSucceeded;
+
+public:
+  CollectRuntimeStatsRunnable(WorkerPrivate* aWorkerPrivate, Mutex* aMutex,
+                              CondVar* aCondVar, volatile bool* aDoneFlag,
+                              IterateData* aData, volatile bool* aSucceeded)
+  : WorkerControlRunnable(aWorkerPrivate, WorkerThread, UnchangedBusyCount),
+    mMutex(aMutex), mCondVar(aCondVar), mDoneFlag(aDoneFlag), mData(aData),
+    mSucceeded(aSucceeded)
+  { }
+
+  bool
+  PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
+  {
+    AssertIsOnMainThread();
+    return true;
+  }
+
+  void
+  PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate,
+               bool aDispatchResult)
+  {
+    AssertIsOnMainThread();
+  }
+
+  bool
+  WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
+  {
+    JSAutoSuspendRequest asr(aCx);
+
+    *mSucceeded = CollectCompartmentStatsForRuntime(JS_GetRuntime(aCx), mData);
+
+    {
+      MutexAutoLock lock(*mMutex);
+
+      NS_ASSERTION(!*mDoneFlag, "Should be false!");
+
+      *mDoneFlag = true;
+      mCondVar->Notify();
+    }
+
+    return true;
+  }
+};
+
 } /* anonymous namespace */
 
 #ifdef DEBUG
 void
 mozilla::dom::workers::AssertIsOnMainThread()
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 }
@@ -2037,32 +2093,28 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
 
       while (!mControlQueue.Pop(event) && !mQueue.Pop(event)) {
         mCondVar.Wait();
       }
 
       {
         MutexAutoUnlock unlock(mMutex);
 
-        JSAutoRequest ar(aCx);
-
 #ifdef EXTRA_GC
         // Find GC bugs...
         JS_GC(aCx);
 #endif
 
         event->Run();
         NS_RELEASE(event);
       }
 
       currentStatus = mStatus;
     }
 
-    JSAutoRequest ar(aCx);
-
 #ifdef EXTRA_GC
     // Find GC bugs...
     JS_GC(aCx);
 #endif
 
     if (currentStatus != Running && !HasActiveFeatures()) {
       // If the close handler has finished and all features are done then we can
       // kill this thread.
@@ -2092,18 +2144,16 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
   NS_NOTREACHED("Shouldn't get here!");
 }
 
 bool
 WorkerPrivate::OperationCallback(JSContext* aCx)
 {
   AssertIsOnWorkerThread();
 
-  JS_YieldRequest(aCx);
-
   bool mayContinue = true;
 
   for (;;) {
     // Run all control events now.
     for (;;) {
       nsIRunnable* event;
       {
         MutexAutoLock lock(mMutex);
@@ -2128,17 +2178,16 @@ WorkerPrivate::OperationCallback(JSConte
     JS_GC(aCx);
 
     while ((mayContinue = MayContinueRunning())) {
       MutexAutoLock lock(mMutex);
       if (!mControlQueue.IsEmpty()) {
         break;
       }
 
-      JSAutoSuspendRequest asr(aCx);
       mCondVar.Wait(PR_MillisecondsToInterval(RemainingRunTimeMS()));
     }
   }
 
   if (!mayContinue) {
     // We want only uncatchable exceptions here.
     NS_ASSERTION(!JS_IsExceptionPending(aCx),
                  "Should not have an exception set here!");
@@ -2180,16 +2229,46 @@ WorkerPrivate::ScheduleDeletion(bool aWa
       new TopLevelWorkerFinishedRunnable(this, currentThread);
     if (NS_FAILED(NS_DispatchToMainThread(runnable, NS_DISPATCH_NORMAL))) {
       NS_WARNING("Failed to dispatch runnable!");
     }
   }
 }
 
 bool
+WorkerPrivate::BlockAndCollectRuntimeStats(IterateData* aData)
+{
+  AssertIsOnMainThread();
+  mMutex.AssertNotCurrentThreadOwns();
+  NS_ASSERTION(aData, "Null data!");
+
+  mozilla::Mutex mutex("BlockAndCollectRuntimeStats mutex");
+  mozilla::CondVar condvar(mutex, "BlockAndCollectRuntimeStats condvar");
+  volatile bool doneFlag = false;
+  volatile bool succeeded = false;
+
+  nsRefPtr<CollectRuntimeStatsRunnable> runnable =
+    new CollectRuntimeStatsRunnable(this, &mutex, &condvar, &doneFlag, aData,
+                                    &succeeded);
+  if (!runnable->Dispatch(nsnull)) {
+    NS_WARNING("Failed to dispatch runnable!");
+    return false;
+  }
+
+  {
+    MutexAutoLock lock(mutex);
+    while (!doneFlag) {
+      condvar.Wait();
+    }
+  }
+
+  return succeeded;
+}
+
+bool
 WorkerPrivate::Dispatch(WorkerRunnable* aEvent, EventQueue* aQueue)
 {
   nsRefPtr<WorkerRunnable> event(aEvent);
 
   {
     MutexAutoLock lock(mMutex);
 
     if (mStatus == Dead) {
@@ -2483,17 +2562,16 @@ WorkerPrivate::RunSyncLoop(JSContext* aC
   SyncQueue* syncQueue = mSyncQueues[aSyncLoopKey].get();
 
   for (;;) {
     nsIRunnable* event;
     {
       MutexAutoLock lock(mMutex);
 
       while (!mControlQueue.Pop(event) && !syncQueue->mQueue.Pop(event)) {
-        JSAutoSuspendRequest asr(aCx);
         mCondVar.Wait();
       }
     }
 
 #ifdef EXTRA_GC
     // Find GC bugs...
     JS_GC(mJSContext);
 #endif
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -63,16 +63,26 @@
 class JSAutoStructuredCloneBuffer;
 class nsIDocument;
 class nsIPrincipal;
 class nsIScriptContext;
 class nsIURI;
 class nsPIDOMWindow;
 class nsITimer;
 
+namespace mozilla {
+namespace xpconnect {
+namespace memory {
+
+struct IterateData;
+
+} // namespace memory
+} // namespace xpconnect
+} // namespace mozilla
+
 BEGIN_WORKERS_NAMESPACE
 
 class WorkerPrivate;
 
 class WorkerRunnable : public nsIRunnable
 {
 public:
   enum Target { ParentThread, WorkerThread };
@@ -635,16 +645,19 @@ public:
   }
 
   void
   UpdateJSContextOptionsInternal(JSContext* aCx, PRUint32 aOptions);
 
   void
   ScheduleDeletion(bool aWasPending);
 
+  bool
+  BlockAndCollectRuntimeStats(mozilla::xpconnect::memory::IterateData* aData);
+
 #ifdef JS_GC_ZEAL
   void
   UpdateGCZealInternal(JSContext* aCx, PRUint8 aGCZeal);
 #endif
 
   JSContext*
   GetJSContext() const
   {
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -46,18 +46,16 @@
 #include "nsIDOMText.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMAttr.h"
 #include "nsIDocument.h"
 #include "nsIDOMEventTarget.h" 
 #include "nsIDOMNSEvent.h"
 #include "nsIDOMKeyEvent.h"
-#include "nsIDOMKeyListener.h" 
-#include "nsIDOMMouseListener.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMComment.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "nsISelectionController.h"
 #include "nsIFileChannel.h"
--- a/editor/libeditor/html/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/html/nsHTMLEditorStyle.cpp
@@ -39,18 +39,16 @@
 #include "nsUnicharUtils.h"
 
 #include "nsHTMLEditor.h"
 #include "nsHTMLEditRules.h"
 #include "nsTextEditUtils.h"
 #include "nsHTMLEditUtils.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMAttr.h"
-#include "nsIDOMKeyListener.h" 
-#include "nsIDOMMouseListener.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "nsISelectionController.h"
 #include "nsIDocumentObserver.h"
 #include "TypeInState.h"
 
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -43,17 +43,16 @@
 #include "nsTextEditUtils.h"
 #include "nsTextEditRules.h"
 #include "nsIEditActionListener.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 #include "nsIDOMEventTarget.h" 
 #include "nsIDOMKeyEvent.h"
-#include "nsIDOMMouseListener.h"
 #include "nsISelection.h"
 #include "nsISelectionPrivate.h"
 #include "nsISelectionController.h"
 #include "nsGUIEvent.h"
 #include "nsCRT.h"
 
 #include "nsIEnumerator.h"
 #include "nsIContent.h"
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -65,16 +65,17 @@ import android.telephony.*;
 
 abstract public class GeckoApp
     extends Activity
 {
     public static final String ACTION_ALERT_CLICK = "org.mozilla.gecko.ACTION_ALERT_CLICK";
     public static final String ACTION_ALERT_CLEAR = "org.mozilla.gecko.ACTION_ALERT_CLEAR";
     public static final String ACTION_WEBAPP      = "org.mozilla.gecko.WEBAPP";
     public static final String ACTION_DEBUG       = "org.mozilla.gecko.DEBUG";
+    public static final String ACTION_BOOKMARK    = "org.mozilla.gecko.BOOKMARK";
 
     public static FrameLayout mainLayout;
     public static GeckoSurfaceView surfaceView;
     public static GeckoApp mAppContext;
     public static boolean mFullscreen = false;
     public static File sGREDir = null;
     static Thread mLibLoadThread = null;
     public Handler mMainHandler;
@@ -312,30 +313,35 @@ abstract public class GeckoApp
                 }
             });
             mainLayout.addView(launchButton, 300, 200);
             return;
         }
         if (checkLaunchState(LaunchState.WaitButton) || launch(intent))
             return;
 
-        if (Intent.ACTION_VIEW.equals(action)) {
+        if (Intent.ACTION_MAIN.equals(action)) {
+            Log.i("GeckoApp", "Intent : ACTION_MAIN");
+            GeckoAppShell.sendEventToGecko(new GeckoEvent(""));
+        }
+        else if (Intent.ACTION_VIEW.equals(action)) {
             String uri = intent.getDataString();
             GeckoAppShell.sendEventToGecko(new GeckoEvent(uri));
             Log.i("GeckoApp","onNewIntent: "+uri);
         }
-        else if (Intent.ACTION_MAIN.equals(action)) {
-            Log.i("GeckoApp", "Intent : ACTION_MAIN");
-            GeckoAppShell.sendEventToGecko(new GeckoEvent(""));
-        }
         else if (ACTION_WEBAPP.equals(action)) {
             String uri = intent.getStringExtra("args");
             GeckoAppShell.sendEventToGecko(new GeckoEvent(uri));
             Log.i("GeckoApp","Intent : WEBAPP - " + uri);
         }
+        else if (ACTION_BOOKMARK.equals(action)) {
+            String args = intent.getStringExtra("args");
+            GeckoAppShell.sendEventToGecko(new GeckoEvent(args));
+            Log.i("GeckoApp","Intent : BOOKMARK - " + args);
+        }
     }
 
     @Override
     public void onPause()
     {
         Log.i("GeckoApp", "pause");
         GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.ACTIVITY_PAUSING));
         // The user is navigating away from this activity, but nothing
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -677,24 +677,30 @@ public class GeckoAppShell
         System.exit(0);
     }
     static void scheduleRestart() {
         Log.i("GeckoAppJava", "scheduling restart");
         gRestartScheduled = true;
     }
 
     // "Installs" an application by creating a shortcut
-    static void installWebApplication(String aURI, String aTitle, String aIconData) {
-        Log.w("GeckoAppJava", "installWebApplication for " + aURI + " [" + aTitle + "]");
+    static void createShortcut(String aTitle, String aURI, String aIconData, String aType) {
+        Log.w("GeckoAppJava", "createShortcut for " + aURI + " [" + aTitle + "]");
 
         // the intent to be launched by the shortcut
-        Intent shortcutIntent = new Intent("org.mozilla.gecko.WEBAPP");
+        Intent shortcutIntent = new Intent();
+        if (aType == "webapp") {
+            shortcutIntent.setAction("org.mozilla.gecko.WEBAPP");
+            shortcutIntent.putExtra("args", "--webapp=" + aURI);
+        } else {
+            shortcutIntent.setAction("org.mozilla.gecko.BOOKMARK");
+            shortcutIntent.putExtra("args", "--url=" + aURI);
+        }
         shortcutIntent.setClassName(GeckoApp.mAppContext,
                                     GeckoApp.mAppContext.getPackageName() + ".App");
-        shortcutIntent.putExtra("args", "--webapp=" + aURI);
 
         Intent intent = new Intent();
         intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
         intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, aTitle);
         byte[] raw = Base64.decode(aIconData.substring(22), Base64.DEFAULT);
         Bitmap bitmap = BitmapFactory.decodeByteArray(raw, 0, raw.length);
         intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);
         intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
--- a/embedding/android/GeckoSurfaceView.java
+++ b/embedding/android/GeckoSurfaceView.java
@@ -594,16 +594,17 @@ class GeckoSurfaceView
                     event = new KeyEvent(event.getAction(), KeyEvent.KEYCODE_TAB);
                 break;
             default:
                 break;
         }
         // KeyListener returns true if it handled the event for us.
         if (mIMEState == IME_STATE_DISABLED ||
             keyCode == KeyEvent.KEYCODE_ENTER ||
+            keyCode == KeyEvent.KEYCODE_DEL ||
             (event.getFlags() & KeyEvent.FLAG_SOFT_KEYBOARD) != 0 ||
             !mKeyListener.onKeyDown(this, mEditable, keyCode, event))
             GeckoAppShell.sendEventToGecko(new GeckoEvent(event));
         return true;
     }
 
     @Override
     public boolean onKeyUp(int keyCode, KeyEvent event) {
@@ -612,16 +613,17 @@ class GeckoSurfaceView
                 if (!event.isTracking() || event.isCanceled())
                     return false;
                 break;
             default:
                 break;
         }
         if (mIMEState == IME_STATE_DISABLED ||
             keyCode == KeyEvent.KEYCODE_ENTER ||
+            keyCode == KeyEvent.KEYCODE_DEL ||
             (event.getFlags() & KeyEvent.FLAG_SOFT_KEYBOARD) != 0 ||
             !mKeyListener.onKeyUp(this, mEditable, keyCode, event))
             GeckoAppShell.sendEventToGecko(new GeckoEvent(event));
         return true;
     }
 
     @Override
     public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
--- a/gfx/src/nsScriptableRegion.cpp
+++ b/gfx/src/nsScriptableRegion.cpp
@@ -179,17 +179,17 @@ NS_IMETHODIMP nsScriptableRegion::GetRec
 
   rv = ncc->GetJSContext(&cx);
   NS_ENSURE_SUCCESS(rv, rv);
 
   JSObject *destArray = JS_NewArrayObject(cx, numRects*4, NULL);
   *retvalPtr = OBJECT_TO_JSVAL(destArray);
   ncc->SetReturnValueWasSet(PR_TRUE);
 
-  int n = 0;
+  uint32 n = 0;
   nsIntRegionRectIterator iter(mRegion);
   const nsIntRect *rect;
 
   while ((rect = iter.Next())) {
     // This will contain bogus data if values don't fit in 31 bit
     JS_DefineElement(cx, destArray, n, INT_TO_JSVAL(rect->x), NULL, NULL, JSPROP_ENUMERATE);
     JS_DefineElement(cx, destArray, n+1, INT_TO_JSVAL(rect->y), NULL, NULL, JSPROP_ENUMERATE);
     JS_DefineElement(cx, destArray, n+2, INT_TO_JSVAL(rect->width), NULL, NULL, JSPROP_ENUMERATE);
--- a/js/src/jit-test/tests/basic/bug619004.js
+++ b/js/src/jit-test/tests/basic/bug619004.js
@@ -1,4 +1,3 @@
-// don't crash
-gczeal(2)
-evalcx('split')
-
+// don't crash
+gczeal(2);
+evalcx('lazy');
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3235,19 +3235,23 @@ JS_LookupPropertyById(JSContext *cx, JSO
 {
     JSObject *obj2;
     JSProperty *prop;
     return LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop) &&
            LookupResult(cx, obj, obj2, id, prop, Valueify(vp));
 }
 
 JS_PUBLIC_API(JSBool)
-JS_LookupElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp)
-{
-    return JS_LookupPropertyById(cx, obj, INT_TO_JSID(index), vp);
+JS_LookupElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp)
+{
+    CHECK_REQUEST(cx);
+    jsid id;
+    if (!IndexToId(cx, index, &id))
+        return false;
+    return JS_LookupPropertyById(cx, obj, id, vp);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_LookupProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp)
 {
     JSAtom *atom = js_Atomize(cx, name, strlen(name));
     return atom && JS_LookupPropertyById(cx, obj, ATOM_TO_JSID(atom), vp);
 }
@@ -3289,19 +3293,23 @@ JS_HasPropertyById(JSContext *cx, JSObje
     JSProperty *prop;
     JSBool ok = LookupPropertyById(cx, obj, id, JSRESOLVE_QUALIFIED | JSRESOLVE_DETECTING,
                                    &obj2, &prop);
     *foundp = (prop != NULL);
     return ok;
 }
 
 JS_PUBLIC_API(JSBool)
-JS_HasElement(JSContext *cx, JSObject *obj, jsint index, JSBool *foundp)
-{
-    return JS_HasPropertyById(cx, obj, INT_TO_JSID(index), foundp);
+JS_HasElement(JSContext *cx, JSObject *obj, uint32 index, JSBool *foundp)
+{
+    CHECK_REQUEST(cx);
+    jsid id;
+    if (!IndexToId(cx, index, &id))
+        return false;
+    return JS_HasPropertyById(cx, obj, id, foundp);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_HasProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp)
 {
     JSAtom *atom = js_Atomize(cx, name, strlen(name));
     return atom && JS_HasPropertyById(cx, obj, ATOM_TO_JSID(atom), foundp);
 }
@@ -3331,19 +3339,23 @@ JS_AlreadyHasOwnPropertyById(JSContext *
         return JS_TRUE;
     }
 
     *foundp = obj->nativeContains(id);
     return JS_TRUE;
 }
 
 JS_PUBLIC_API(JSBool)
-JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, jsint index, JSBool *foundp)
-{
-    return JS_AlreadyHasOwnPropertyById(cx, obj, INT_TO_JSID(index), foundp);
+JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, uint32 index, JSBool *foundp)
+{
+    CHECK_REQUEST(cx);
+    jsid id;
+    if (!IndexToId(cx, index, &id))
+        return false;
+    return JS_AlreadyHasOwnPropertyById(cx, obj, id, foundp);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_AlreadyHasOwnProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp)
 {
     JSAtom *atom = js_Atomize(cx, name, strlen(name));
     return atom && JS_AlreadyHasOwnPropertyById(cx, obj, ATOM_TO_JSID(atom), foundp);
 }
@@ -3382,20 +3394,24 @@ JS_PUBLIC_API(JSBool)
 JS_DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value,
                       JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs)
 {
     return DefinePropertyById(cx, obj, id, Valueify(value), Valueify(getter),
                               Valueify(setter), attrs, 0, 0);
 }
 
 JS_PUBLIC_API(JSBool)
-JS_DefineElement(JSContext *cx, JSObject *obj, jsint index, jsval value,
+JS_DefineElement(JSContext *cx, JSObject *obj, uint32 index, jsval value,
                  JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs)
 {
-    return DefinePropertyById(cx, obj, INT_TO_JSID(index), Valueify(value),
+    CHECK_REQUEST(cx);
+    jsid id;
+    if (!IndexToId(cx, index, &id))
+        return false;
+    return DefinePropertyById(cx, obj, id, Valueify(value),
                               Valueify(getter), Valueify(setter), attrs, 0, 0);
 }
 
 static JSBool
 DefineProperty(JSContext *cx, JSObject *obj, const char *name, const Value &value,
                PropertyOp getter, StrictPropertyOp setter, uintN attrs,
                uintN flags, intN tinyid)
 {
@@ -3693,19 +3709,23 @@ JS_GetPropertyById(JSContext *cx, JSObje
 
 JS_PUBLIC_API(JSBool)
 JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, jsval *vp)
 {
     return GetPropertyDefault(cx, obj, id, Valueify(def), Valueify(vp));
 }
 
 JS_PUBLIC_API(JSBool)
-JS_GetElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp)
-{
-    return JS_GetPropertyById(cx, obj, INT_TO_JSID(index), vp);
+JS_GetElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp)
+{
+    CHECK_REQUEST(cx);
+    jsid id;
+    if (!IndexToId(cx, index, &id))
+        return false;
+    return JS_GetPropertyById(cx, obj, id, vp);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp)
 {
     JSAtom *atom = js_Atomize(cx, name, strlen(name));
     return atom && JS_GetPropertyById(cx, obj, ATOM_TO_JSID(atom), vp);
 }
@@ -3748,18 +3768,22 @@ JS_SetPropertyById(JSContext *cx, JSObje
 {
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, obj, id);
     JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING);
     return obj->setProperty(cx, id, Valueify(vp), false);
 }
 
 JS_PUBLIC_API(JSBool)
-JS_SetElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp)
-{
+JS_SetElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp)
+{
+    CHECK_REQUEST(cx);
+    jsid id;
+    if (!IndexToId(cx, index, &id))
+        return false;
     return JS_SetPropertyById(cx, obj, INT_TO_JSID(index), vp);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_SetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp)
 {
     JSAtom *atom = js_Atomize(cx, name, strlen(name));
     return atom && JS_SetPropertyById(cx, obj, ATOM_TO_JSID(atom), vp);
@@ -3777,19 +3801,23 @@ JS_DeletePropertyById2(JSContext *cx, JS
 {
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, obj, id);
     JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED);
     return obj->deleteProperty(cx, id, Valueify(rval), false);
 }
 
 JS_PUBLIC_API(JSBool)
-JS_DeleteElement2(JSContext *cx, JSObject *obj, jsint index, jsval *rval)
-{
-    return JS_DeletePropertyById2(cx, obj, INT_TO_JSID(index), rval);
+JS_DeleteElement2(JSContext *cx, JSObject *obj, uint32 index, jsval *rval)
+{
+    CHECK_REQUEST(cx);
+    jsid id;
+    if (!IndexToId(cx, index, &id))
+        return false;
+    return JS_DeletePropertyById2(cx, obj, id, rval);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name, jsval *rval)
 {
     JSAtom *atom = js_Atomize(cx, name, strlen(name));
     return atom && JS_DeletePropertyById2(cx, obj, ATOM_TO_JSID(atom), rval);
 }
@@ -3804,17 +3832,17 @@ JS_DeleteUCProperty2(JSContext *cx, JSOb
 JS_PUBLIC_API(JSBool)
 JS_DeletePropertyById(JSContext *cx, JSObject *obj, jsid id)
 {
     jsval junk;
     return JS_DeletePropertyById2(cx, obj, id, &junk);
 }
 
 JS_PUBLIC_API(JSBool)
-JS_DeleteElement(JSContext *cx, JSObject *obj, jsint index)
+JS_DeleteElement(JSContext *cx, JSObject *obj, uint32 index)
 {
     jsval junk;
     return JS_DeleteElement2(cx, obj, index, &junk);
 }
 
 JS_PUBLIC_API(JSBool)
 JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name)
 {
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2481,40 +2481,39 @@ JS_IsArrayObject(JSContext *cx, JSObject
 
 extern JS_PUBLIC_API(JSBool)
 JS_GetArrayLength(JSContext *cx, JSObject *obj, jsuint *lengthp);
 
 extern JS_PUBLIC_API(JSBool)
 JS_SetArrayLength(JSContext *cx, JSObject *obj, jsuint length);
 
 extern JS_PUBLIC_API(JSBool)
-JS_DefineElement(JSContext *cx, JSObject *obj, jsint index, jsval value,
+JS_DefineElement(JSContext *cx, JSObject *obj, uint32 index, jsval value,
                  JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs);
 
 extern JS_PUBLIC_API(JSBool)
-JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, jsint index,
-                        JSBool *foundp);
+JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, uint32 index, JSBool *foundp);
 
 extern JS_PUBLIC_API(JSBool)
-JS_HasElement(JSContext *cx, JSObject *obj, jsint index, JSBool *foundp);
+JS_HasElement(JSContext *cx, JSObject *obj, uint32 index, JSBool *foundp);
 
 extern JS_PUBLIC_API(JSBool)
-JS_LookupElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp);
+JS_LookupElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp);
 
 extern JS_PUBLIC_API(JSBool)
-JS_GetElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp);
+JS_GetElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp);
 
 extern JS_PUBLIC_API(JSBool)
-JS_SetElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp);
+JS_SetElement(JSContext *cx, JSObject *obj, uint32 index, jsval *vp);
 
 extern JS_PUBLIC_API(JSBool)
-JS_DeleteElement(JSContext *cx, JSObject *obj, jsint index);
+JS_DeleteElement(JSContext *cx, JSObject *obj, uint32 index);
 
 extern JS_PUBLIC_API(JSBool)
-JS_DeleteElement2(JSContext *cx, JSObject *obj, jsint index, jsval *rval);
+JS_DeleteElement2(JSContext *cx, JSObject *obj, uint32 index, jsval *rval);
 
 extern JS_PUBLIC_API(void)
 JS_ClearScope(JSContext *cx, JSObject *obj);
 
 extern JS_PUBLIC_API(JSIdArray *)
 JS_Enumerate(JSContext *cx, JSObject *obj);
 
 /*
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -2049,17 +2049,17 @@ ethogram_getAllEvents(JSContext *cx, uin
     JSObject *rarray = JS_NewArrayObject(cx, 0, NULL);
     if (rarray == NULL) {
         JS_SET_RVAL(cx, vp, JSVAL_NULL);
         return JS_TRUE;
     }
 
     JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(rarray));
 
-    for (int i = 0; !p->isEmpty(); i++) {
+    for (uint32 i = 0; !p->isEmpty(); i++) {
 
         JSObject *x = JS_NewObject(cx, NULL, NULL, NULL);
         if (x == NULL)
             return JS_FALSE;
 
         EthogramEvent *e = p->pop();
 
         jsval state = INT_TO_JSVAL(e->s);
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -70,16 +70,18 @@
 #include "jsscript.h"
 #include "jsstaticcheck.h"
 #include "jsvector.h"
 
 #if JS_HAS_XML_SUPPORT
 #include "jsxml.h"
 #endif
 
+#include "vm/GlobalObject.h"
+
 #include "jsobjinlines.h"
 
 #include "vm/Stack-inl.h"
 #include "vm/String-inl.h"
 
 using namespace js;
 using namespace js::gc;
 
@@ -1401,37 +1403,86 @@ static JSFunctionSpec generator_methods[
     JS_FN(js_send_str,      generator_send,     1,JSPROP_ROPERM),
     JS_FN(js_throw_str,     generator_throw,    1,JSPROP_ROPERM),
     JS_FN(js_close_str,     generator_close,    0,JSPROP_ROPERM),
     JS_FS_END
 };
 
 #endif /* JS_HAS_GENERATORS */
 
+static bool
+InitIteratorClass(JSContext *cx, GlobalObject *global)
+{
+    JSObject *iteratorProto = global->createBlankPrototype(cx, &js_IteratorClass);
+    if (!iteratorProto)
+        return false;
+
+    JSFunction *ctor = global->createConstructor(cx, Iterator, &js_IteratorClass,
+                                                 CLASS_ATOM(cx, Iterator), 2);
+    if (!ctor)
+        return false;
+
+    if (!LinkConstructorAndPrototype(cx, ctor, iteratorProto))
+        return false;
+
+    if (!DefinePropertiesAndBrand(cx, iteratorProto, NULL, iterator_methods))
+        return false;
+
+    return DefineConstructorAndPrototype(cx, global, JSProto_Iterator, ctor, iteratorProto);
+}
+
+static bool
+InitGeneratorClass(JSContext *cx, GlobalObject *global)
+{
+#if JS_HAS_GENERATORS
+    JSObject *proto = global->createBlankPrototype(cx, &js_GeneratorClass);
+    if (!proto)
+        return false;
+
+    if (!DefinePropertiesAndBrand(cx, proto, NULL, generator_methods))
+        return false;
+
+    /* This should use a non-JSProtoKey'd slot, but this is easier for now. */
+    return DefineConstructorAndPrototype(cx, global, JSProto_Generator, proto, proto);
+#else
+    return true;
+#endif
+}
+
+static JSObject *
+InitStopIterationClass(JSContext *cx, GlobalObject *global)
+{
+    JSObject *proto = global->createBlankPrototype(cx, &js_StopIterationClass);
+    if (!proto || !proto->freeze(cx))
+        return NULL;
+
+    /* This should use a non-JSProtoKey'd slot, but this is easier for now. */
+    if (!DefineConstructorAndPrototype(cx, global, JSProto_StopIteration, proto, proto))
+        return NULL;
+
+    MarkStandardClassInitializedNoProto(global, &js_StopIterationClass);
+
+    return proto;
+}
+
 JSObject *
 js_InitIteratorClasses(JSContext *cx, JSObject *obj)
 {
-    JSObject *proto, *stop;
+    JS_ASSERT(obj->isNative());
 
-    /* Idempotency required: we initialize several things, possibly lazily. */
-    if (!js_GetClassObject(cx, obj, JSProto_StopIteration, &stop))
-        return NULL;
-    if (stop)
-        return stop;
-
-    proto = js_InitClass(cx, obj, NULL, &js_IteratorClass, Iterator, 2,
-                         NULL, iterator_methods, NULL, NULL);
-    if (!proto)
-        return NULL;
+    GlobalObject *global = obj->asGlobal();
 
-#if JS_HAS_GENERATORS
-    /* Initialize the generator internals if configured. */
-    if (!js_InitClass(cx, obj, NULL, &js_GeneratorClass, NULL, 0,
-                      NULL, generator_methods, NULL, NULL)) {
+    /*
+     * Bail if Iterator has already been initialized.  We test for Iterator
+     * rather than for StopIteration because if js_InitIteratorClasses recurs,
+     * as happens when the StopIteration object is frozen, initializing the
+     * Iterator class a second time will assert.
+     */
+    JSObject *iter;
+    if (!js_GetClassObject(cx, global, JSProto_Iterator, &iter))
         return NULL;
-    }
-#endif
+    if (iter)
+        return iter;
 
-    MarkStandardClassInitializedNoProto(obj, &js_StopIterationClass);
-
-    return js_InitClass(cx, obj, NULL, &js_StopIterationClass, NULL, 0,
-                        NULL, NULL, NULL, NULL);
+    if (!InitIteratorClass(cx, global) || !InitGeneratorClass(cx, global))
+        return NULL;
+    return InitStopIterationClass(cx, global);
 }
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -4478,28 +4478,29 @@ js_PurgeScopeChainHelper(JSContext *cx, 
 
 const Shape *
 js_AddNativeProperty(JSContext *cx, JSObject *obj, jsid id,
                      PropertyOp getter, StrictPropertyOp setter, uint32 slot,
                      uintN attrs, uintN flags, intN shortid)
 {
     JS_ASSERT(!(flags & Shape::METHOD));
 
+    /* Convert string indices to integers if appropriate. */
+    id = js_CheckForStringIndex(id);
+
     /*
      * Purge the property cache of now-shadowed id in obj's scope chain. Do
      * this optimistically (assuming no failure below) before locking obj, so
      * we can lock the shadowed scope.
      */
     js_PurgeScopeChain(cx, obj, id);
 
     if (!obj->ensureClassReservedSlots(cx))
         return NULL;
 
-    /* Convert string indices to integers if appropriate. */
-    id = js_CheckForStringIndex(id);
     return obj->putProperty(cx, id, getter, setter, slot, attrs, flags, shortid);
 }
 
 const Shape *
 js_ChangeNativePropertyAttrs(JSContext *cx, JSObject *obj,
                              const Shape *shape, uintN attrs, uintN mask,
                              PropertyOp getter, StrictPropertyOp setter)
 {
--- a/js/src/jsobjinlines.h
+++ b/js/src/jsobjinlines.h
@@ -1368,17 +1368,17 @@ CopyInitializerObject(JSContext *cx, JSO
     obj->lastProp = baseobj->lastProp;
     obj->objShape = baseobj->objShape;
 
     return obj;
 }
 
 inline bool
 DefineConstructorAndPrototype(JSContext *cx, GlobalObject *global,
-                              JSProtoKey key, JSFunction *ctor, JSObject *proto)
+                              JSProtoKey key, JSObject *ctor, JSObject *proto)
 {
     JS_ASSERT(!global->nativeEmpty()); /* reserved slots already allocated */
     JS_ASSERT(ctor);
     JS_ASSERT(proto);
 
     jsid id = ATOM_TO_JSID(cx->runtime->atomState.classAtoms[key]);
     JS_ASSERT(!global->nativeLookup(id));
 
--- a/js/src/jsval.h
+++ b/js/src/jsval.h
@@ -312,16 +312,17 @@ typedef union jsval_layout
         union {
             int32          i32;
             uint32         u32;
             JSWhyMagic     why;
         } payload;
     } s;
     double asDouble;
     void *asPtr;
+    jsuword asWord;
 } jsval_layout;
 # endif  /* JS_BITS_PER_WORD */
 #else   /* defined(IS_LITTLE_ENDIAN) */
 # if JS_BITS_PER_WORD == 32
 typedef union jsval_layout
 {
     uint64 asBits;
     struct {
@@ -353,16 +354,17 @@ typedef union jsval_layout
         union {
             int32          i32;
             uint32         u32;
             JSWhyMagic     why;
         } payload;
     } s;
     double asDouble;
     void *asPtr;
+    jsuword asWord;
 } jsval_layout;
 # endif /* JS_BITS_PER_WORD */
 #endif  /* defined(IS_LITTLE_ENDIAN) */
 
 JS_STATIC_ASSERT(sizeof(jsval_layout) == 8);
 
 #if JS_BITS_PER_WORD == 32
 
--- a/js/src/jsvalue.h
+++ b/js/src/jsvalue.h
@@ -290,17 +290,16 @@ static JS_ALWAYS_INLINE JSValueTag
 JSVAL_EXTRACT_NON_DOUBLE_TAG_IMPL(jsval_layout l)
 {
     uint64 tag = l.asBits >> JSVAL_TAG_SHIFT;
     JS_ASSERT(tag > JSVAL_TAG_MAX_DOUBLE);
     return (JSValueTag)tag;
 }
 
 #ifdef __cplusplus
-JS_STATIC_ASSERT(offsetof(jsval_layout, s.payload) == 0);
 JS_STATIC_ASSERT((JSVAL_TYPE_NONFUNOBJ & 0xF) == JSVAL_TYPE_OBJECT);
 JS_STATIC_ASSERT((JSVAL_TYPE_FUNOBJ & 0xF) == JSVAL_TYPE_OBJECT);
 #endif
 
 static JS_ALWAYS_INLINE jsval_layout
 BOX_NON_DOUBLE_JSVAL(JSValueType type, uint64 *slot)
 {
     /* N.B. for 32-bit payloads, the high 32 bits of the slot are trash. */
@@ -739,19 +738,19 @@ class Value
 
     JS_ALWAYS_INLINE
     void *toUnmarkedPtr() const {
         return data.asPtr;
     }
 
     const jsuword *payloadWord() const {
 #if JS_BITS_PER_WORD == 32
-        return reinterpret_cast<const jsuword *>(&data.s.payload.word);
+        return &data.s.payload.word;
 #elif JS_BITS_PER_WORD == 64
-        return reinterpret_cast<const jsuword *>(&data.asBits);
+        return &data.asWord;
 #endif
     }
 
   private:
     void staticAssertions() {
         JS_STATIC_ASSERT(sizeof(JSValueType) == 1);
         JS_STATIC_ASSERT(sizeof(JSValueTag) == 4);
         JS_STATIC_ASSERT(sizeof(JSBool) == 4);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -222,19 +222,16 @@ static JSContext *
 NewContext(JSRuntime *rt);
 
 static void
 DestroyContext(JSContext *cx, bool withGC);
 
 static const JSErrorFormatString *
 my_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber);
 
-static JSObject *
-split_setup(JSContext *cx, JSBool evalcx);
-
 #ifdef EDITLINE
 JS_BEGIN_EXTERN_C
 JS_EXTERN_API(char)    *readline(const char *prompt);
 JS_EXTERN_API(void)     add_history(char *line);
 JS_END_EXTERN_C
 #endif
 
 static void
@@ -2469,17 +2466,17 @@ DumpStack(JSContext *cx, uintN argc, Val
     JSString *globalStr = JS_NewStringCopyZ(cx, "global-code");
     if (!globalStr)
         return false;
 
     StackIter iter(cx);
     JS_ASSERT(iter.nativeArgs().callee().getFunctionPrivate()->native() == DumpStack);
     ++iter;
 
-    jsint index = 0;
+    uint32 index = 0;
     for (; !iter.done(); ++index, ++iter) {
         Value v;
         if (iter.isScript()) {
             if (iter.fp()->isNonEvalFunctionFrame()) {
                 if (!iter.fp()->getValidCalleeObject(cx, &v))
                     return false;
             } else if (iter.fp()->isEvalFrame()) {
                 v = StringValue(evalStr);
@@ -2696,17 +2693,16 @@ Clone(JSContext *cx, uintN argc, jsval *
 
 static JSBool
 GetPDA(JSContext *cx, uintN argc, jsval *vp)
 {
     JSObject *vobj, *aobj, *pdobj;
     JSBool ok;
     JSPropertyDescArray pda;
     JSPropertyDesc *pd;
-    uint32 i;
     jsval v;
 
     if (!JS_ValueToObject(cx, argc == 0 ? JSVAL_VOID : vp[2], &vobj))
         return JS_FALSE;
     if (!vobj) {
         *vp = JSVAL_VOID;
         return JS_TRUE;
     }
@@ -2715,17 +2711,17 @@ GetPDA(JSContext *cx, uintN argc, jsval 
     if (!aobj)
         return JS_FALSE;
     *vp = OBJECT_TO_JSVAL(aobj);
 
     ok = JS_GetPropertyDescArray(cx, vobj, &pda);
     if (!ok)
         return JS_FALSE;
     pd = pda.array;
-    for (i = 0; i < pda.length; i++, pd++) {
+    for (uint32 i = 0; i < pda.length; i++, pd++) {
         pdobj = JS_NewObject(cx, NULL, NULL, NULL);
         if (!pdobj) {
             ok = JS_FALSE;
             break;
         }
 
         /* Protect pdobj from GC by setting it as an element of aobj now */
         v = OBJECT_TO_JSVAL(pdobj);
@@ -2829,389 +2825,16 @@ ThrowError(JSContext *cx, uintN argc, js
 /* A class for easily testing the inner/outer object callbacks. */
 typedef struct ComplexObject {
     JSBool isInner;
     JSBool frozen;
     JSObject *inner;
     JSObject *outer;
 } ComplexObject;
 
-static JSObject *
-split_create_outer(JSContext *cx);
-
-static JSObject *
-split_create_inner(JSContext *cx, JSObject *outer);
-
-static ComplexObject *
-split_get_private(JSContext *cx, JSObject *obj);
-
-static JSBool
-split_addProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
-{
-    ComplexObject *cpx;
-
-    cpx = split_get_private(cx, obj);
-    if (!cpx)
-        return JS_TRUE;
-    if (!cpx->isInner && cpx->inner) {
-        /* Make sure to define this property on the inner object. */
-        return JS_DefinePropertyById(cx, cpx->inner, id, *vp, NULL, NULL, JSPROP_ENUMERATE);
-    }
-    return JS_TRUE;
-}
-
-static JSBool
-split_getProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
-{
-    ComplexObject *cpx;
-
-    cpx = split_get_private(cx, obj);
-    if (!cpx)
-        return JS_TRUE;
-
-    if (JSID_IS_ATOM(id) && JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(id), "isInner")) {
-        *vp = BOOLEAN_TO_JSVAL(cpx->isInner);
-        return JS_TRUE;
-    }
-
-    if (!cpx->isInner && cpx->inner) {
-        if (JSID_IS_ATOM(id)) {
-            JSString *str = JSID_TO_STRING(id);
-
-            size_t length;
-            const jschar *chars = JS_GetStringCharsAndLength(cx, str, &length);
-            if (!chars)
-                return false;
-
-            return JS_GetUCProperty(cx, cpx->inner, chars, length, vp);
-        }
-        if (JSID_IS_INT(id))
-            return JS_GetElement(cx, cpx->inner, JSID_TO_INT(id), vp);
-        return JS_TRUE;
-    }
-
-    return JS_TRUE;
-}
-
-static JSBool
-split_setProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
-{
-    ComplexObject *cpx;
-
-    cpx = split_get_private(cx, obj);
-    if (!cpx)
-        return true;
-    if (!cpx->isInner && cpx->inner) {
-        if (JSID_IS_ATOM(id)) {
-            JSString *str = JSID_TO_STRING(id);
-
-            size_t length;
-            const jschar *chars = JS_GetStringCharsAndLength(cx, str, &length);
-            if (!chars)
-                return false;
-
-            return JS_SetUCProperty(cx, cpx->inner, chars, length, vp);
-        }
-        if (JSID_IS_INT(id))
-            return JS_SetElement(cx, cpx->inner, JSID_TO_INT(id), vp);
-        return true;
-    }
-
-    return true;
-}
-
-static JSBool
-split_delProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
-{
-    ComplexObject *cpx;
-    jsid asId;
-
-    cpx = split_get_private(cx, obj);
-    if (!cpx)
-        return JS_TRUE;
-    if (!cpx->isInner && cpx->inner) {
-        /* Make sure to define this property on the inner object. */
-        if (!JS_ValueToId(cx, *vp, &asId))
-            return JS_FALSE;
-        return cpx->inner->deleteProperty(cx, asId, Valueify(vp), true);
-    }
-    return JS_TRUE;
-}
-
-static JSBool
-split_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
-                jsval *statep, jsid *idp)
-{
-    ComplexObject *cpx;
-    JSObject *iterator;
-
-    switch (enum_op) {
-      case JSENUMERATE_INIT:
-      case JSENUMERATE_INIT_ALL:
-        cpx = (ComplexObject *) JS_GetPrivate(cx, obj);
-
-        if (!cpx->isInner && cpx->inner)
-            obj = cpx->inner;
-
-        iterator = JS_NewPropertyIterator(cx, obj);
-        if (!iterator)
-            return JS_FALSE;
-
-        *statep = OBJECT_TO_JSVAL(iterator);
-        if (idp)
-            *idp = INT_TO_JSID(0);
-        break;
-
-      case JSENUMERATE_NEXT:
-        iterator = (JSObject*)JSVAL_TO_OBJECT(*statep);
-        if (!JS_NextProperty(cx, iterator, idp))
-            return JS_FALSE;
-
-        if (!JSID_IS_VOID(*idp))
-            break;
-        /* Fall through. */
-
-      case JSENUMERATE_DESTROY:
-        /* Let GC at our iterator object. */
-        *statep = JSVAL_NULL;
-        break;
-    }
-
-    return JS_TRUE;
-}
-
-static JSBool
-split_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
-{
-    ComplexObject *cpx;
-
-    if (JSID_IS_ATOM(id) && JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(id), "isInner")) {
-        *objp = obj;
-        return JS_DefinePropertyById(cx, obj, id, JSVAL_VOID, NULL, NULL, JSPROP_SHARED);
-    }
-
-    cpx = split_get_private(cx, obj);
-    if (!cpx)
-        return JS_TRUE;
-    if (!cpx->isInner && cpx->inner) {
-        JSProperty *prop;
-        return cpx->inner->lookupProperty(cx, id, objp, &prop);
-    }
-
-#ifdef LAZY_STANDARD_CLASSES
-    if (!(flags & JSRESOLVE_ASSIGNING)) {
-        JSBool resolved;
-
-        if (!JS_ResolveStandardClass(cx, obj, id, &resolved))
-            return JS_FALSE;
-
-        if (resolved) {
-            *objp = obj;
-            return JS_TRUE;
-        }
-    }
-#endif
-
-    /* XXX For additional realism, let's resolve some random property here. */
-    return JS_TRUE;
-}
-
-static void
-split_finalize(JSContext *cx, JSObject *obj)
-{
-    JS_free(cx, JS_GetPrivate(cx, obj));
-}
-
-static void
-split_trace(JSTracer *trc, JSObject *obj)
-{
-    ComplexObject *cpx;
-
-    cpx = (ComplexObject *) JS_GetPrivate(trc->context, obj);
-
-    if (!cpx)
-        return; /* The object is not fully constructed. */
-
-    if (!cpx->isInner && cpx->inner) {
-        /* Mark the inner object. */
-        JS_CALL_TRACER(trc, cpx->inner, JSTRACE_OBJECT, "ComplexObject.inner");
-    }
-
-    if (cpx->isInner && cpx->outer) {
-        /* Mark the inner object. */
-        JS_CALL_TRACER(trc, cpx->outer, JSTRACE_OBJECT, "ComplexObject.outer");
-    }
-}
-
-static JSObject *
-split_outerObject(JSContext *cx, JSObject *obj)
-{
-    ComplexObject *cpx;
-
-    cpx = (ComplexObject *) JS_GetPrivate(cx, obj);
-    return cpx->isInner ? cpx->outer : obj;
-}
-
-static JSObject *
-split_thisObject(JSContext *cx, JSObject *obj)
-{
-    OBJ_TO_OUTER_OBJECT(cx, obj);
-    if (!obj)
-        return NULL;
-    return obj;
-}
-
-
-static JSBool
-split_equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
-
-static JSObject *
-split_innerObject(JSContext *cx, JSObject *obj)
-{
-    ComplexObject *cpx;
-
-    cpx = (ComplexObject *) JS_GetPrivate(cx, obj);
-    if (cpx->frozen) {
-        JS_ASSERT(!cpx->isInner);
-        return obj;
-    }
-    return !cpx->isInner ? cpx->inner : obj;
-}
-
-static Class split_global_class = {
-    "split_global",
-    JSCLASS_NEW_RESOLVE | JSCLASS_NEW_ENUMERATE | JSCLASS_HAS_PRIVATE | JSCLASS_GLOBAL_FLAGS,
-    Valueify(split_addProperty),
-    Valueify(split_delProperty),
-    Valueify(split_getProperty),
-    Valueify(split_setProperty),
-    (JSEnumerateOp)split_enumerate,
-    (JSResolveOp)split_resolve,
-    ConvertStub,
-    split_finalize,
-    NULL,           /* reserved0   */
-    NULL,           /* checkAccess */
-    NULL,           /* call        */
-    NULL,           /* construct   */
-    NULL,           /* xdrObject   */
-    NULL,           /* hasInstance */
-    split_trace,
-    {
-        Valueify(split_equality),
-        split_outerObject,
-        split_innerObject,
-        NULL, /* iteratorObject */
-        NULL, /* wrappedObject  */
-    },
-    {
-        NULL, /* lookupProperty */
-        NULL, /* defineProperty */
-        NULL, /* getProperty    */
-        NULL, /* setProperty    */
-        NULL, /* getAttributes  */
-        NULL, /* setAttributes  */
-        NULL, /* deleteProperty */
-        NULL, /* enumerate      */
-        NULL, /* typeOf         */
-        NULL, /* fix            */
-        split_thisObject,
-        NULL, /* clear          */
-    },
-};
-
-static JSBool
-split_equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp)
-{
-    *bp = JS_FALSE;
-    if (JSVAL_IS_PRIMITIVE(*v))
-        return JS_TRUE;
-
-    JSObject *obj2 = JSVAL_TO_OBJECT(*v);
-    if (obj2->getClass() != &split_global_class)
-        return JS_TRUE;
-
-    ComplexObject *cpx = (ComplexObject *) JS_GetPrivate(cx, obj2);
-    JS_ASSERT(!cpx->isInner);
-
-    ComplexObject *ourCpx = (ComplexObject *) JS_GetPrivate(cx, obj);
-    JS_ASSERT(!ourCpx->isInner);
-
-    *bp = (cpx == ourCpx);
-    return JS_TRUE;
-}
-
-JSObject *
-split_create_outer(JSContext *cx)
-{
-    ComplexObject *cpx;
-    JSObject *obj;
-
-    cpx = (ComplexObject *) JS_malloc(cx, sizeof *obj);
-    if (!cpx)
-        return NULL;
-    cpx->isInner = JS_FALSE;
-    cpx->frozen = JS_TRUE;
-    cpx->inner = NULL;
-    cpx->outer = NULL;
-
-    obj = JS_NewGlobalObject(cx, Jsvalify(&split_global_class));
-    if (!obj) {
-        JS_free(cx, cpx);
-        return NULL;
-    }
-
-    if (!JS_SetPrivate(cx, obj, cpx)) {
-        JS_free(cx, cpx);
-        return NULL;
-    }
-
-    return obj;
-}
-
-static JSObject *
-split_create_inner(JSContext *cx, JSObject *outer)
-{
-    ComplexObject *cpx, *outercpx;
-    JSObject *obj;
-
-    JS_ASSERT(outer->getClass() == &split_global_class);
-
-    cpx = (ComplexObject *) JS_malloc(cx, sizeof *cpx);
-    if (!cpx)
-        return NULL;
-    cpx->isInner = JS_TRUE;
-    cpx->frozen = JS_FALSE;
-    cpx->inner = NULL;
-    cpx->outer = outer;
-
-    obj = JS_NewGlobalObject(cx, Jsvalify(&split_global_class));
-    if (!obj || !JS_SetPrivate(cx, obj, cpx)) {
-        JS_free(cx, cpx);
-        return NULL;
-    }
-
-    outercpx = (ComplexObject *) JS_GetPrivate(cx, outer);
-    outercpx->inner = obj;
-    outercpx->frozen = JS_FALSE;
-
-    return obj;
-}
-
-static ComplexObject *
-split_get_private(JSContext *cx, JSObject *obj)
-{
-    do {
-        if (obj->getClass() == &split_global_class)
-            return (ComplexObject *) JS_GetPrivate(cx, obj);
-        obj = JS_GetParent(cx, obj);
-    } while (obj);
-
-    return NULL;
-}
-
 static JSBool
 sandbox_enumerate(JSContext *cx, JSObject *obj)
 {
     jsval v;
     JSBool b;
 
     if (!JS_GetProperty(cx, obj, "lazy", &v))
         return JS_FALSE;
@@ -3249,41 +2872,33 @@ static JSClass sandbox_class = {
     JS_PropertyStub,   JS_PropertyStub,
     JS_PropertyStub,   JS_StrictPropertyStub,
     sandbox_enumerate, (JSResolveOp)sandbox_resolve,
     JS_ConvertStub,    NULL,
     JSCLASS_NO_OPTIONAL_MEMBERS
 };
 
 static JSObject *
-NewSandbox(JSContext *cx, bool lazy, bool split)
+NewSandbox(JSContext *cx, bool lazy)
 {
     JSObject *obj = JS_NewCompartmentAndGlobalObject(cx, &sandbox_class, NULL);
     if (!obj)
         return NULL;
 
     {
         JSAutoEnterCompartment ac;
         if (!ac.enter(cx, obj))
             return NULL;
 
-        if (split) {
-            obj = split_setup(cx, JS_TRUE);
-            if (!obj)
-                return NULL;
-        }
         if (!lazy && !JS_InitStandardClasses(cx, obj))
             return NULL;
 
         AutoValueRooter root(cx, BooleanValue(lazy));
         if (!JS_SetProperty(cx, obj, "lazy", root.jsval_addr()))
             return NULL;
-
-        if (split)
-            obj = split_outerObject(cx, obj);
     }
 
     AutoObjectRooter objroot(cx, obj);
     if (!cx->compartment->wrap(cx, objroot.addr()))
         return NULL;
     return objroot.object();
 }
 
@@ -3295,31 +2910,26 @@ EvalInContext(JSContext *cx, uintN argc,
     if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S / o", &str, &sobj))
         return false;
 
     size_t srclen;
     const jschar *src = JS_GetStringCharsAndLength(cx, str, &srclen);
     if (!src)
         return false;
 
-    bool split = false, lazy = false;
+    bool lazy = false;
     if (srclen == 4) {
         if (src[0] == 'l' && src[1] == 'a' && src[2] == 'z' && src[3] == 'y') {
             lazy = true;
             srclen = 0;
         }
-    } else if (srclen == 5) {
-        if (src[0] == 's' && src[1] == 'p' && src[2] == 'l' && src[3] == 'i' && src[4] == 't') {
-            split = lazy = true;
-            srclen = 0;
-        }
     }
 
     if (!sobj) {
-        sobj = NewSandbox(cx, lazy, split);
+        sobj = NewSandbox(cx, lazy);
         if (!sobj)
             return false;
     }
 
     if (srclen == 0) {
         JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(sobj));
         return true;
     }
@@ -3742,17 +3352,17 @@ Scatter(JSContext *cx, uintN argc, jsval
     for (i = 0; i < n; i++) {
         sd.threads[i].index = i;
         sd.threads[i].shared = &sd;
         sd.threads[i].thr = NULL;
         sd.threads[i].cx = NULL;
         sd.threads[i].fn = JSVAL_NULL;
 
         ok = JS_AddValueRoot(cx, &sd.threads[i].fn);
-        if (ok && !JS_GetElement(cx, inArr, (jsint) i, &sd.threads[i].fn)) {
+        if (ok && !JS_GetElement(cx, inArr, i, &sd.threads[i].fn)) {
             JS_RemoveValueRoot(cx, &sd.threads[i].fn);
             ok = JS_FALSE;
         }
         if (!ok) {
             while (i-- > 0)
                 JS_RemoveValueRoot(cx, &sd.threads[i].fn);
             free(sd.threads);
             sd.threads = NULL;
@@ -4679,18 +4289,17 @@ static const char *const shell_help_mess
 "intern(str)              Internalize str in the atom table",
 "clone(fun[, scope])      Clone function object",
 "getpda(obj)              Get the property descriptors for obj",
 "getslx(obj)              Get script line extent",
 "toint32(n)               Testing hook for JS_ValueToInt32",
 "evalcx(s[, o])\n"
 "  Evaluate s in optional sandbox object o\n"
 "  if (s == '' && !o) return new o with eager standard classes\n"
-"  if (s == 'lazy' && !o) return new o with lazy standard classes\n"
-"  if (s == 'split' && !o) return new split-object o with lazy standard classes",
+"  if (s == 'lazy' && !o) return new o with lazy standard classes",
 "evalInFrame(n,str,save)  Evaluate 'str' in the nth up frame.\n"
 "                         If 'save' (default false), save the frame chain",
 "shapeOf(obj)             Get the shape of obj (an implementation detail)",
 "resolver(src[, proto])   Create object with resolve hook that copies properties\n"
 "                         from src. If proto is omitted, use Object.prototype.",
 "pauseProfilers()         Pause all profilers that can be paused",
 "resumeProfilers()        Resume profilers if they are paused",
 #ifdef MOZ_CALLGRIND
@@ -4842,57 +4451,16 @@ Help(JSContext *cx, uintN argc, jsval *v
                 putc('\n', gErrFile);
             }
         }
     }
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
     return JS_TRUE;
 }
 
-static JSObject *
-split_setup(JSContext *cx, JSBool evalcx)
-{
-    JSObject *outer, *inner, *arguments;
-
-    outer = split_create_outer(cx);
-    if (!outer)
-        return NULL;
-    AutoObjectRooter root(cx, outer);
-    if (!evalcx)
-        JS_SetGlobalObject(cx, outer);
-
-    inner = split_create_inner(cx, outer);
-    if (!inner)
-        return NULL;
-
-    if (!evalcx) {
-        if (!JS_DefineFunctions(cx, inner, shell_functions) ||
-            !JS_DefineProfilingFunctions(cx, inner)) {
-            return NULL;
-        }
-
-        /* Create a dummy arguments object. */
-        arguments = JS_NewArrayObject(cx, 0, NULL);
-        if (!arguments ||
-            !JS_DefineProperty(cx, inner, "arguments", OBJECT_TO_JSVAL(arguments),
-                               NULL, NULL, 0)) {
-            return NULL;
-        }
-    }
-
-    JS_ClearScope(cx, outer);
-
-#ifndef LAZY_STANDARD_CLASSES
-    if (!JS_InitStandardClasses(cx, inner))
-        return NULL;
-#endif
-
-    return inner;
-}
-
 /*
  * Define a JS object called "it".  Give it class operations that printf why
  * they're being called for tutorial purposes.
  */
 enum its_tinyid {
     ITS_COLOR, ITS_HEIGHT, ITS_WIDTH, ITS_FUNNY, ITS_ARRAY, ITS_RDONLY,
     ITS_CUSTOM, ITS_CUSTOMRDONLY
 };
--- a/js/src/tests/js1_8_1/extensions/regress-520572.js
+++ b/js/src/tests/js1_8_1/extensions/regress-520572.js
@@ -19,17 +19,17 @@ test();
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
 
   if ("evalcx" in this) {
       // shell
-      let s = evalcx("split");
+      let s = evalcx("lazy");
       s.n = 0;
       evalcx('this.watch("x", function(){ n++; }); this.x = 4; x = 6', s);
       actual = s.n;
       reportCompare(expect, actual, summary);
   } else {
       // browser
       this.watch('x', function(){ actual++; });
       this.x = 4;
--- a/js/src/tests/js1_8_5/regress/jstests.list
+++ b/js/src/tests/js1_8_5/regress/jstests.list
@@ -70,45 +70,46 @@ script regress-597945-1.js
 script regress-597945-2.js
 script regress-598176.js
 script regress-600067.js
 script regress-600137.js
 script regress-601399.js
 script regress-602621.js
 fails-if(!xulRuntime.shell) script regress-607799.js
 fails-if(!xulRuntime.shell) script regress-607863.js
+script regress-609617.js
 script regress-610026.js
-script regress-609617.js
+script regress-614714.js
 script regress-617405-1.js
 script regress-617405-2.js
 script regress-618572.js
 skip-if(!xulRuntime.shell) script regress-618576.js  # uses evalcx
 fails-if(!xulRuntime.shell) script regress-618652.js
 script regress-619003-1.js
 script regress-619003-2.js
 skip-if(Android) script regress-620376-1.js
 script regress-620376-2.js
+script regress-620750.js
 script regress-621814.js
-script regress-620750.js
 script regress-624199.js
 script regress-624547.js
 script regress-624968.js
 script regress-626436.js
 script regress-633741.js
 script regress-634210-1.js
 script regress-634210-2.js
 script regress-634210-3.js
 script regress-634210-4.js
 script regress-635195.js
 script regress-636394.js
 script regress-636364.js
 script regress-640075.js
+script regress-643222.js
 script regress-646820-1.js
 script regress-646820-2.js
 script regress-646820-3.js
-script regress-643222.js
-script regress-614714.js
 script regress-665355.js
+script regress-666599.js
 script regress-667047.js
-script regress-666599.js
 script regress-673070-1.js
 script regress-673070-2.js
 script regress-673070-3.js
+script regress-675581.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/js1_8_5/regress/regress-675581.js
@@ -0,0 +1,7 @@
+// Any copyright is dedicated to the Public Domain.
+// http://creativecommons.org/licenses/publicdomain/
+
+x=<x/>
+x.(-0 in x)
+
+reportCompare(0, 0, 'ok');
deleted file mode 100644
--- a/js/src/xpconnect/loader/ISO8601DateUtils.jsm
+++ /dev/null
@@ -1,176 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is Robert Sayre.
- * Portions created by the Initial Developer are Copyright (C) 2006
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Flock Inc. <erwan@flock.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
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-const HOURS_TO_MINUTES = 60;
-const MINUTES_TO_SECONDS = 60;
-const SECONDS_TO_MILLISECONDS = 1000;
-const MINUTES_TO_MILLISECONDS = MINUTES_TO_SECONDS * SECONDS_TO_MILLISECONDS;
-const HOURS_TO_MILLISECONDS = HOURS_TO_MINUTES * MINUTES_TO_MILLISECONDS;
-
-var EXPORTED_SYMBOLS = ["ISO8601DateUtils"];
-
-debug("*** loading ISO8601DateUtils\n");
-
-var ISO8601DateUtils = {
-
-  /**
-  * XXX Thunderbird's W3C-DTF function
-  *
-  * Converts a W3C-DTF (subset of ISO 8601) date string to a Javascript
-  * date object. W3C-DTF is described in this note:
-  * http://www.w3.org/TR/NOTE-datetime IETF is obtained via the Date
-  * object's toUTCString() method.  The object's toString() method is
-  * insufficient because it spells out timezones on Win32
-  * (f.e. "Pacific Standard Time" instead of "PST"), which Mail doesn't
-  * grok.  For info, see
-  * http://lxr.mozilla.org/mozilla/source/js/src/jsdate.c#1526.
-  */
-  parse: function ISO8601_parse(aDateString) {
-    var dateString = aDateString;
-    if (!dateString.match('-')) {
-      // Workaround for server sending
-      // dates such as: 20030530T11:18:50-08:00
-      // instead of: 2003-05-30T11:18:50-08:00
-      var year = dateString.slice(0, 4);
-      var month = dateString.slice(4, 6);
-      var rest = dateString.slice(6, dateString.length);
-      dateString = year + "-" + month + "-" + rest;
-    }
-
-    var parts = dateString.match(/(\d{4})(-(\d{2,3}))?(-(\d{2}))?(T(\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|([+-])(\d{2}):(\d{2}))?)?/);
-
-    // Here's an example of a W3C-DTF date string and what .match returns for it.
-    //
-    // date: 2003-05-30T11:18:50.345-08:00
-    // date.match returns array values:
-    //
-    //   0: 2003-05-30T11:18:50-08:00,
-    //   1: 2003,
-    //   2: -05,
-    //   3: 05,
-    //   4: -30,
-    //   5: 30,
-    //   6: T11:18:50-08:00,
-    //   7: 11,
-    //   8: 18,
-    //   9: :50,
-    //   10: 50,
-    //   11: .345,
-    //   12: 345,
-    //   13: -08:00,
-    //   14: -,
-    //   15: 08,
-    //   16: 00
-
-    // Create a Date object from the date parts.  Note that the Date
-    // object apparently can't deal with empty string parameters in lieu
-    // of numbers, so optional values (like hours, minutes, seconds, and
-    // milliseconds) must be forced to be numbers.
-    var date = new Date(parts[1], parts[3] - 1, parts[5], parts[7] || 0,
-      parts[8] || 0, parts[10] || 0, parts[12] || 0);
-
-    // We now have a value that the Date object thinks is in the local
-    // timezone but which actually represents the date/time in the
-    // remote timezone (f.e. the value was "10:00 EST", and we have
-    // converted it to "10:00 PST" instead of "07:00 PST").  We need to
-    // correct that.  To do so, we're going to add the offset between
-    // the remote timezone and UTC (to convert the value to UTC), then
-    // add the offset between UTC and the local timezone //(to convert
-    // the value to the local timezone).
-
-    // Ironically, W3C-DTF gives us the offset between UTC and the
-    // remote timezone rather than the other way around, while the
-    // getTimezoneOffset() method of a Date object gives us the offset
-    // between the local timezone and UTC rather than the other way
-    // around.  Both of these are the additive inverse (i.e. -x for x)
-    // of what we want, so we have to invert them to use them by
-    // multipying by -1 (f.e. if "the offset between UTC and the remote
-    // timezone" is -5 hours, then "the offset between the remote
-    // timezone and UTC" is -5*-1 = 5 hours).
-
-    // Note that if the timezone portion of the date/time string is
-    // absent (which violates W3C-DTF, although ISO 8601 allows it), we
-    // assume the value to be in UTC.
-
-    // The offset between the remote timezone and UTC in milliseconds.
-    var remoteToUTCOffset = 0;
-    if (parts[13] && parts[13] != "Z") {
-      var direction = (parts[14] == "+" ? 1 : -1);
-      if (parts[15])
-        remoteToUTCOffset += direction * parts[15] * HOURS_TO_MILLISECONDS;
-      if (parts[16])
-        remoteToUTCOffset += direction * parts[16] * MINUTES_TO_MILLISECONDS;
-    }
-    remoteToUTCOffset = remoteToUTCOffset * -1; // invert it
-
-    // The offset between UTC and the local timezone in milliseconds.
-    var UTCToLocalOffset = date.getTimezoneOffset() * MINUTES_TO_MILLISECONDS;
-    UTCToLocalOffset = UTCToLocalOffset * -1; // invert it
-    date.setTime(date.getTime() + remoteToUTCOffset + UTCToLocalOffset);
-
-    return date;
-  },
-
-  create: function ISO8601_create(aDate) {
-    function zeropad (s, l) {
-      s = s.toString(); // force it to a string
-      while (s.length < l) {
-        s = '0' + s;
-      }
-      return s;
-    }
-
-    var myDate;
-    // if d is a number, turn it into a date
-    if (typeof aDate == 'number') {
-      myDate = new Date()
-      myDate.setTime(aDate);
-    } else {
-      myDate = aDate;
-    }
-
-    // YYYY-MM-DDThh:mm:ssZ
-    var result = zeropad(myDate.getUTCFullYear (), 4) +
-                 zeropad(myDate.getUTCMonth () + 1, 2) +
-                 zeropad(myDate.getUTCDate (), 2) + 'T' +
-                 zeropad(myDate.getUTCHours (), 2) + ':' +
-                 zeropad(myDate.getUTCMinutes (), 2) + ':' +
-                 zeropad(myDate.getUTCSeconds (), 2) + 'Z';
-
-    return result;
-  }
-}
--- a/js/src/xpconnect/loader/Makefile.in
+++ b/js/src/xpconnect/loader/Makefile.in
@@ -44,13 +44,13 @@ include $(DEPTH)/config/autoconf.mk
 MODULE		= jsloader
 LIBRARY_NAME	= jsloader_s
 FORCE_STATIC_LIB = 1
 LIBXUL_LIBRARY = 1
 LOCAL_INCLUDES += -I$(srcdir)/../src
 
 CPPSRCS		= mozJSComponentLoader.cpp mozJSSubScriptLoader.cpp mozJSLoaderUtils.cpp
 
-EXTRA_JS_MODULES = XPCOMUtils.jsm ISO8601DateUtils.jsm
+EXTRA_JS_MODULES = XPCOMUtils.jsm
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES		+= -DJSFILE -DJS_THREADSAFE
--- a/js/src/xpconnect/shell/xpcshell.cpp
+++ b/js/src/xpconnect/shell/xpcshell.cpp
@@ -1147,17 +1147,17 @@ usage(void)
 
 extern JSClass global_class;
 
 static int
 ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
 {
     const char rcfilename[] = "xpcshell.js";
     FILE *rcfile;
-    int i, j, length;
+    int i;
     JSObject *argsObj;
     char *filename = NULL;
     JSBool isInteractive = JS_TRUE;
     JSBool forceTTY = JS_FALSE;
 
     rcfile = fopen(rcfilename, "r");
     if (rcfile) {
         printf("[loading '%s'...]\n", rcfilename);
@@ -1193,18 +1193,17 @@ ProcessArgs(JSContext *cx, JSObject *obj
     argsObj = JS_NewArrayObject(cx, 0, NULL);
     if (!argsObj)
         return 1;
     if (!JS_DefineProperty(cx, obj, "arguments", OBJECT_TO_JSVAL(argsObj),
                            NULL, NULL, 0)) {
         return 1;
     }
 
-    length = argc - i;
-    for (j = 0; j < length; j++) {
+    for (size_t j = 0, length = argc - i; j < length; j++) {
         JSString *str = JS_NewStringCopyZ(cx, argv[i++]);
         if (!str)
             return 1;
         if (!JS_DefineElement(cx, argsObj, j, STRING_TO_JSVAL(str),
                               NULL, NULL, JSPROP_ENUMERATE)) {
             return 1;
         }
     }
--- a/js/src/xpconnect/src/xpcjsruntime.cpp
+++ b/js/src/xpconnect/src/xpcjsruntime.cpp
@@ -1318,18 +1318,18 @@ GetCompartmentTjitDataAllocatorsReserveS
 #endif  // JS_TRACER
 
 void
 CompartmentCallback(JSContext *cx, void *vdata, JSCompartment *compartment)
 {
     // Append a new CompartmentStats to the vector.
     IterateData *data = static_cast<IterateData *>(vdata);
     CompartmentStats compartmentStats(cx, compartment);
-    data->compartmentStatsVector.infallibleAppend(compartmentStats);
-    CompartmentStats *curr = data->compartmentStatsVector.end() - 1;
+    CompartmentStats *curr =
+        data->compartmentStatsVector.AppendElement(compartmentStats);
     data->currCompartmentStats = curr;
 
     // Get the compartment-level numbers.
     curr->scripts = GetCompartmentScriptsSize(compartment);
 #ifdef JS_METHODJIT
     curr->mjitCode = GetCompartmentMjitCodeSize(compartment);
     curr->mjitData = GetCompartmentMjitDataSize(compartment);
 #endif
@@ -1605,18 +1605,17 @@ CollectCompartmentStatsForRuntime(JSRunt
     {
         NS_ERROR("couldn't create context for memory tracing");
         return false;
     }
 
     {
         JSAutoRequest ar(cx);
 
-        if (!data->compartmentStatsVector.reserve(rt->compartments.length()))
-            return false;
+        data->compartmentStatsVector.SetCapacity(rt->compartments.length());
 
         data->gcHeapChunkCleanUnused =
             PRInt64(JS_GetGCParameter(rt, JSGC_UNUSED_CHUNKS)) *
             js::GC_CHUNK_SIZE;
         data->gcHeapChunkTotal =
             PRInt64(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) *
             js::GC_CHUNK_SIZE;
 
@@ -1630,27 +1629,29 @@ CollectCompartmentStatsForRuntime(JSRunt
     JS_DestroyContextNoGC(cx);
 
     // This is initialized to all bytes stored in used chunks, and then we
     // subtract used space from it each time around the loop.
     data->gcHeapChunkDirtyUnused = data->gcHeapChunkTotal -
                                    data->gcHeapChunkCleanUnused;
     data->gcHeapArenaUnused = 0;
 
-    for(CompartmentStats *stats = data->compartmentStatsVector.begin();
-        stats != data->compartmentStatsVector.end();
-        ++stats)
+    for(PRUint32 index = 0;
+        index < data->compartmentStatsVector.Length();
+        index++)
     {
+        CompartmentStats &stats = data->compartmentStatsVector[index];
+
         data->gcHeapChunkDirtyUnused -=
-            stats->gcHeapArenaHeaders + stats->gcHeapArenaPadding +
-            stats->gcHeapArenaUnused +
-            stats->gcHeapObjects + stats->gcHeapStrings +
-            stats->gcHeapShapes + stats->gcHeapXml;
+            stats.gcHeapArenaHeaders + stats.gcHeapArenaPadding +
+            stats.gcHeapArenaUnused +
+            stats.gcHeapObjects + stats.gcHeapStrings +
+            stats.gcHeapShapes + stats.gcHeapXml;
         
-        data->gcHeapArenaUnused += stats->gcHeapArenaUnused;
+        data->gcHeapArenaUnused += stats.gcHeapArenaUnused;
     }
 
     size_t numDirtyChunks = (data->gcHeapChunkTotal -
                              data->gcHeapChunkCleanUnused) /
                             js::GC_CHUNK_SIZE;
     PRInt64 perChunkAdmin =
         sizeof(js::gc::Chunk) - (sizeof(js::gc::Arena) * js::gc::ArenasPerChunk);
     data->gcHeapChunkAdmin = numDirtyChunks * perChunkAdmin;
@@ -1803,21 +1804,22 @@ ReportCompartmentStats(const Compartment
 #endif
 }
 
 void
 ReportJSRuntimeStats(const IterateData &data, const nsACString &pathPrefix,
                      nsIMemoryMultiReporterCallback *callback,
                      nsISupports *closure)
 {
-    for(const CompartmentStats *stats = data.compartmentStatsVector.begin();
-        stats != data.compartmentStatsVector.end();
-        ++stats)
+    for(PRUint32 index = 0;
+        index < data.compartmentStatsVector.Length();
+        index++)
     {
-        ReportCompartmentStats(*stats, pathPrefix, callback, closure);
+        ReportCompartmentStats(data.compartmentStatsVector[index], pathPrefix,
+                               callback, closure);
     }
 
     ReportMemoryBytes(pathPrefix + NS_LITERAL_CSTRING("stack"),
                       nsIMemoryReporter::KIND_NONHEAP, data.stackSize,
     "Memory used for the JavaScript stack.  This is the committed portion "
     "of the stack; any uncommitted portion is not measured because it "
     "hardly costs anything.",
                       callback, closure);
--- a/js/src/xpconnect/src/xpcpublic.h
+++ b/js/src/xpconnect/src/xpcpublic.h
@@ -44,16 +44,17 @@
 #include "jsobj.h"
 #include "jsgc.h"
 #include "jspubtd.h"
 
 #include "nsISupports.h"
 #include "nsIPrincipal.h"
 #include "nsWrapperCache.h"
 #include "nsStringGlue.h"
+#include "nsTArray.h"
 
 class nsIPrincipal;
 
 static const uint32 XPC_GC_COLOR_BLACK = 0;
 static const uint32 XPC_GC_COLOR_GRAY = 1;
 
 nsresult
 xpc_CreateGlobalObject(JSContext *cx, JSClass *clasp,
@@ -237,17 +238,17 @@ struct IterateData
     PRInt64 stackSize;
     PRInt64 gcHeapChunkTotal;
     PRInt64 gcHeapChunkCleanUnused;
     PRInt64 gcHeapChunkDirtyUnused;
     PRInt64 gcHeapArenaUnused;
     PRInt64 gcHeapChunkAdmin;
     PRInt64 gcHeapUnusedPercentage;
 
-    js::Vector<CompartmentStats, 0, js::SystemAllocPolicy> compartmentStatsVector;
+    nsTArray<CompartmentStats> compartmentStatsVector;
     CompartmentStats *currCompartmentStats;
 };
 
 JSBool
 CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data);
 
 void
 ReportJSRuntimeStats(const IterateData &data, const nsACString &pathPrefix,
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -103,41 +103,66 @@ public:
   ~ImageRenderer();
   /**
    * Populates member variables to get ready for rendering.
    * @return PR_TRUE iff the image is ready, and there is at least a pixel to
    * draw.
    */
   PRBool PrepareImage();
   /**
-   * @return the image size in appunits. CSS gradient images don't have an
-   * intrinsic size so we have to pass in a default that they will use.
+   * @return the image size in appunits when rendered, after accounting for the
+   * background positioning area, background-size, and the image's intrinsic
+   * dimensions (if any).
    */
-  nsSize ComputeSize(const nsSize& aDefault);
+  nsSize ComputeSize(const nsStyleBackground::Size& aLayerSize,
+                     const nsSize& aBgPositioningArea);
   /**
    * Draws the image to the target rendering context.
    * @see nsLayoutUtils::DrawImage() for other parameters
    */
   void Draw(nsPresContext*       aPresContext,
             nsRenderingContext& aRenderingContext,
             const nsRect&        aDest,
             const nsRect&        aFill,
             const nsPoint&       aAnchor,
             const nsRect&        aDirty);
 
 private:
+  /*
+   * Compute the "unscaled" dimensions of the image in aUnscaled{Width,Height}
+   * and aRatio.  Whether the image has a height and width are indicated by
+   * aHaveWidth and aHaveHeight.  If the image doesn't have a ratio, aRatio will
+   * be (0, 0).
+   */
+  void ComputeUnscaledDimensions(const nsSize& aBgPositioningArea,
+                                 nscoord& aUnscaledWidth, bool& aHaveWidth,
+                                 nscoord& aUnscaledHeight, bool& aHaveHeight,
+                                 nsSize& aRatio);
+
+  /*
+   * Using the previously-computed unscaled width and height (if each are
+   * valid, as indicated by aHaveWidth/aHaveHeight), compute the size at which
+   * the image should actually render.
+   */
+  nsSize
+  ComputeDrawnSize(const nsStyleBackground::Size& aLayerSize,
+                   const nsSize& aBgPositioningArea,
+                   nscoord aUnscaledWidth, bool aHaveWidth,
+                   nscoord aUnscaledHeight, bool aHaveHeight,
+                   const nsSize& aIntrinsicRatio);
+
   nsIFrame*                 mForFrame;
   const nsStyleImage*       mImage;
   nsStyleImageType          mType;
   nsCOMPtr<imgIContainer>   mImageContainer;
   nsRefPtr<nsStyleGradient> mGradientData;
   nsIFrame*                 mPaintServerFrame;
   nsLayoutUtils::SurfaceFromElementResult mImageElementSurface;
   PRBool                    mIsReady;
-  nsSize                    mSize;
+  nsSize                    mSize; // unscaled size of the image, in app units
   PRUint32                  mFlags;
 };
 
 // To avoid storing this data on nsInlineFrame (bloat) and to avoid
 // recalculating this for each frame in a continuation (perf), hold
 // a cache of various coordinate information that we need in order
 // to paint inline backgrounds.
 struct InlineBackgroundData
@@ -2427,37 +2452,16 @@ nsCSSRendering::PaintBackgroundWithSC(ns
                                     state.mAnchor + aBorderArea.TopLeft(),
                                     clipState.mDirtyRect);
         }
       }
     }
   }
 }
 
-static inline float
-ScaleDimension(const nsStyleBackground::Size::Dimension& aDimension,
-               PRUint8 aType,
-               nscoord aLength, nscoord aAvailLength)
-{
-  switch (aType) {
-    case nsStyleBackground::Size::eLengthPercentage:
-      // negative values could result from calc()
-      return NS_MAX(double(aDimension.mPercent) * double(aAvailLength) +
-                      double(aDimension.mLength),
-                    0.0) /
-             double(aLength);
-    default:
-      NS_ABORT_IF_FALSE(PR_FALSE, "bad aDimension.mType");
-      return 1.0f;
-    case nsStyleBackground::Size::eAuto:
-      NS_ABORT_IF_FALSE(PR_FALSE, "aDimension.mType == eAuto isn't handled");
-      return 1.0f;
-  }
-}
-
 static inline PRBool
 IsTransformed(nsIFrame* aForFrame, nsIFrame* aTopFrame)
 {
   for (nsIFrame* f = aForFrame; f != aTopFrame; f = f->GetParent()) {
     if (f->IsTransformed()) {
       return PR_TRUE;
     }
   }
@@ -2642,62 +2646,22 @@ PrepareBackgroundLayer(nsPresContext* aP
       // always clipped to the viewport when we draw to the screen. (But it's
       // not a pure optimization since it can affect the values of pixels at the
       // edge of the viewport --- whether they're sampled from a putative "next
       // tile" or not.)
       bgClipRect.IntersectRect(bgClipRect, bgPositioningArea + aBorderArea.TopLeft());
     }
   }
 
-  nsSize imageSize = state.mImageRenderer.ComputeSize(bgPositioningArea.Size());
-  if (imageSize.width <= 0 || imageSize.height <= 0)
-    return state;
-
   // Scale the image as specified for background-size and as required for
   // proper background positioning when background-position is defined with
   // percentages.
-  float scaleX, scaleY;
-  switch (aLayer.mSize.mWidthType) {
-    case nsStyleBackground::Size::eContain:
-    case nsStyleBackground::Size::eCover: {
-      float scaleFitX = double(bgPositioningArea.width) / imageSize.width;
-      float scaleFitY = double(bgPositioningArea.height) / imageSize.height;
-      if (aLayer.mSize.mWidthType == nsStyleBackground::Size::eCover) {
-        scaleX = scaleY = NS_MAX(scaleFitX, scaleFitY);
-      } else {
-        scaleX = scaleY = NS_MIN(scaleFitX, scaleFitY);
-      }
-      break;
-    }
-    default: {
-      if (aLayer.mSize.mWidthType == nsStyleBackground::Size::eAuto) {
-        if (aLayer.mSize.mHeightType == nsStyleBackground::Size::eAuto) {
-          scaleX = scaleY = 1.0f;
-        } else {
-          scaleX = scaleY =
-            ScaleDimension(aLayer.mSize.mHeight, aLayer.mSize.mHeightType,
-                           imageSize.height, bgPositioningArea.height);
-        }
-      } else {
-        if (aLayer.mSize.mHeightType == nsStyleBackground::Size::eAuto) {
-          scaleX = scaleY =
-            ScaleDimension(aLayer.mSize.mWidth, aLayer.mSize.mWidthType,
-                           imageSize.width, bgPositioningArea.width);
-        } else {
-          scaleX = ScaleDimension(aLayer.mSize.mWidth, aLayer.mSize.mWidthType,
-                                  imageSize.width, bgPositioningArea.width);
-          scaleY = ScaleDimension(aLayer.mSize.mHeight, aLayer.mSize.mHeightType,
-                                  imageSize.height, bgPositioningArea.height);
-        }
-      }
-      break;
-    }
-  }
-  imageSize.width = NSCoordSaturatingNonnegativeMultiply(imageSize.width, scaleX);
-  imageSize.height = NSCoordSaturatingNonnegativeMultiply(imageSize.height, scaleY);
+  nsSize imageSize = state.mImageRenderer.ComputeSize(aLayer.mSize, bgPositioningArea.Size());
+  if (imageSize.width <= 0 || imageSize.height <= 0)
+    return state;
 
   // Compute the position of the background now that the background's size is
   // determined.
   ComputeBackgroundAnchorPoint(aLayer, bgPositioningArea.Size(), imageSize,
                                &imageTopLeft, &state.mAnchor);
   imageTopLeft += bgPositioningArea.TopLeft();
   state.mAnchor += bgPositioningArea.TopLeft();
 
@@ -3856,74 +3820,297 @@ ImageRenderer::PrepareImage()
     case eStyleImageType_Null:
     default:
       break;
   }
 
   return mIsReady;
 }
 
-nsSize
-ImageRenderer::ComputeSize(const nsSize& aDefault)
+enum FitType { CONTAIN, COVER };
+
+static nsSize
+ComputeContainCoverSizeFromRatio(const nsSize& aBgPositioningArea,
+                                 const nsSize& aRatio, FitType fitType)
+{
+  NS_ABORT_IF_FALSE(aRatio.width > 0, "width division by zero");
+  NS_ABORT_IF_FALSE(aRatio.height > 0, "height division by zero");
+
+  float scaleX = double(aBgPositioningArea.width) / aRatio.width;
+  float scaleY = double(aBgPositioningArea.height) / aRatio.height;
+  nsSize size;
+  if ((fitType == CONTAIN) == (scaleX < scaleY)) {
+    size.width = aBgPositioningArea.width;
+    size.height = NSCoordSaturatingNonnegativeMultiply(aRatio.height, scaleX);
+  } else {
+    size.width = NSCoordSaturatingNonnegativeMultiply(aRatio.width, scaleY);
+    size.height = aBgPositioningArea.height;
+  }
+  return size;
+}
+
+void
+ImageRenderer::ComputeUnscaledDimensions(const nsSize& aBgPositioningArea,
+                                         nscoord& aUnscaledWidth, bool& aHaveWidth,
+                                         nscoord& aUnscaledHeight, bool& aHaveHeight,
+                                         nsSize& aRatio)
 {
   NS_ASSERTION(mIsReady, "Ensure PrepareImage() has returned true "
                          "before calling me");
 
   switch (mType) {
     case eStyleImageType_Image:
     {
       nsIntSize imageIntSize;
-      PRBool gotHeight, gotWidth;
       nsLayoutUtils::ComputeSizeForDrawing(mImageContainer, imageIntSize,
-                                           gotWidth, gotHeight);
-
-      mSize.width = gotWidth ?
-        nsPresContext::CSSPixelsToAppUnits(imageIntSize.width) :
-        aDefault.width;
-
-      mSize.height = gotHeight ?
-        nsPresContext::CSSPixelsToAppUnits(imageIntSize.height) :
-        aDefault.height;
-
-      break;
+                                           aRatio, aHaveWidth, aHaveHeight);
+      if (aHaveWidth) {
+        aUnscaledWidth = nsPresContext::CSSPixelsToAppUnits(imageIntSize.width);
+      }
+      if (aHaveHeight) {
+        aUnscaledHeight = nsPresContext::CSSPixelsToAppUnits(imageIntSize.height);
+      }
+      return;
     }
     case eStyleImageType_Gradient:
-      mSize = aDefault;
-      break;
+      // Per <http://dev.w3.org/csswg/css3-images/#gradients>, gradients have no
+      // intrinsic dimensions.
+      aHaveWidth = aHaveHeight = false;
+      aRatio = nsSize(0, 0);
+      return;
     case eStyleImageType_Element:
     {
+      // XXX element() should have the width/height of the referenced element,
+      //     and that element's ratio, if it matches.  If it doesn't match, it
+      //     should have no width/height or ratio.  See element() in CSS3:
+      //     <http://dev.w3.org/csswg/css3-images/#element-reference>.
+      //     Make sure to change nsStyleBackground::Size::DependsOnFrameSize
+      //     when fixing this!
+      aHaveWidth = aHaveHeight = true;
+      nsSize size;
       if (mPaintServerFrame) {
         if (mPaintServerFrame->IsFrameOfType(nsIFrame::eSVG)) {
-          mSize = aDefault;
+          size = aBgPositioningArea;
         } else {
           // The intrinsic image size for a generic nsIFrame paint server is
           // the frame's bbox size rounded to device pixels.
           PRInt32 appUnitsPerDevPixel =
             mForFrame->PresContext()->AppUnitsPerDevPixel();
           nsRect rect =
             nsSVGIntegrationUtils::GetNonSVGUserSpace(mPaintServerFrame);
-          nsRect size = rect - rect.TopLeft();
-          nsIntRect rounded = size.ToNearestPixels(appUnitsPerDevPixel);
-          mSize = rounded.ToAppUnits(appUnitsPerDevPixel).Size();
+          nsRect rectSize = rect - rect.TopLeft();
+          nsIntRect rounded = rectSize.ToNearestPixels(appUnitsPerDevPixel);
+          size = rounded.ToAppUnits(appUnitsPerDevPixel).Size();
         }
       } else {
         NS_ASSERTION(mImageElementSurface.mSurface, "Surface should be ready.");
-        gfxIntSize size = mImageElementSurface.mSize;
-        mSize.width = nsPresContext::CSSPixelsToAppUnits(size.width);
-        mSize.height = nsPresContext::CSSPixelsToAppUnits(size.height);
+        gfxIntSize surfaceSize = mImageElementSurface.mSize;
+        size.width = nsPresContext::CSSPixelsToAppUnits(surfaceSize.width);
+        size.height = nsPresContext::CSSPixelsToAppUnits(surfaceSize.height);
       }
-      break;
+      aRatio = size;
+      aUnscaledWidth = size.width;
+      aUnscaledHeight = size.height;
+      return;
     }
     case eStyleImageType_Null:
     default:
-      mSize.SizeTo(0, 0);
-      break;
+      aHaveWidth = aHaveHeight = true;
+      aUnscaledWidth = aUnscaledHeight = 0;
+      aRatio = nsSize(0, 0);
+      return;
+  }
+}
+
+nsSize
+ImageRenderer::ComputeDrawnSize(const nsStyleBackground::Size& aLayerSize,
+                                const nsSize& aBgPositioningArea,
+                                nscoord aUnscaledWidth, bool aHaveWidth,
+                                nscoord aUnscaledHeight, bool aHaveHeight,
+                                const nsSize& aIntrinsicRatio)
+{
+  NS_ABORT_IF_FALSE(aIntrinsicRatio.width >= 0,
+                    "image ratio with nonsense width");
+  NS_ABORT_IF_FALSE(aIntrinsicRatio.height >= 0,
+                    "image ratio with nonsense height");
+
+  // Bail early if the image is empty.
+  if ((aHaveWidth && aUnscaledWidth <= 0) ||
+      (aHaveHeight && aUnscaledHeight <= 0)) {
+    return nsSize(0, 0);
+  }
+
+  // If the image has an intrinsic ratio but either component of it is zero,
+  // then the image would eventually scale to nothingness, so again we can bail.
+  bool haveRatio = aIntrinsicRatio != nsSize(0, 0);
+  if (haveRatio &&
+      (aIntrinsicRatio.width == 0 || aIntrinsicRatio.height == 0)) {
+    return nsSize(0, 0);
+  }
+
+  // Easiest case: background-size completely specifies the size.
+  if (aLayerSize.mWidthType == nsStyleBackground::Size::eLengthPercentage &&
+      aLayerSize.mHeightType == nsStyleBackground::Size::eLengthPercentage) {
+    return nsSize(aLayerSize.ResolveWidthLengthPercentage(aBgPositioningArea),
+                  aLayerSize.ResolveHeightLengthPercentage(aBgPositioningArea));
+  }
+
+  // The harder cases: contain/cover.
+  if (aLayerSize.mWidthType == nsStyleBackground::Size::eContain ||
+      aLayerSize.mWidthType == nsStyleBackground::Size::eCover) {
+    FitType fitType = aLayerSize.mWidthType == nsStyleBackground::Size::eCover
+                    ? COVER
+                    : CONTAIN;
+    if (!haveRatio) {
+      // If we don't have an intrinsic ratio, then proportionally scaling to
+      // either largest-fitting or smallest-covering size means scaling to the
+      // background positioning area's size.
+      return aBgPositioningArea;
+    }
+
+    return ComputeContainCoverSizeFromRatio(aBgPositioningArea, aIntrinsicRatio,
+                                            fitType);
   }
 
-  return mSize;
+  // Harder case: all-auto.
+  if (aLayerSize.mWidthType == nsStyleBackground::Size::eAuto &&
+      aLayerSize.mHeightType == nsStyleBackground::Size::eAuto) {
+    // If the image has all its dimensions, we're done.
+    if (aHaveWidth && aHaveHeight)
+      return nsSize(aUnscaledWidth, aUnscaledHeight);
+
+    // If the image has no dimensions, treat it as if for contain.
+    if (!aHaveWidth && !aHaveHeight) {
+      if (!haveRatio) {
+        // As above, max-contain without a ratio means the whole area.
+        return aBgPositioningArea;
+      }
+
+      // Otherwise determine size using the intrinsic ratio.
+      return ComputeContainCoverSizeFromRatio(aBgPositioningArea,
+                                              aIntrinsicRatio, CONTAIN);
+    }
+
+    NS_ABORT_IF_FALSE(aHaveWidth != aHaveHeight, "logic error");
+
+    if (haveRatio) {
+      // Resolve missing dimensions using the intrinsic ratio.
+      nsSize size;
+      if (aHaveWidth) {
+        size.width = aUnscaledWidth;
+        size.height =
+          NSCoordSaturatingNonnegativeMultiply(size.width,
+                                               double(aIntrinsicRatio.height) /
+                                               aIntrinsicRatio.width);
+      } else {
+        size.height = aUnscaledHeight;
+        size.width =
+          NSCoordSaturatingNonnegativeMultiply(size.height,
+                                               double(aIntrinsicRatio.width) /
+                                               aIntrinsicRatio.height);
+      }
+
+      return size;
+    }
+
+    // Without a ratio we must fall back to the relevant dimension of the
+    // area to determine the missing dimension.
+    return aHaveWidth ? nsSize(aUnscaledWidth, aBgPositioningArea.height)
+                      : nsSize(aBgPositioningArea.width, aUnscaledHeight);
+  }
+
+  // Hardest case: only one auto.  Prepare to negotiate amongst intrinsic
+  // dimensions, intrinsic ratio, *and* a specific background-size!
+  NS_ABORT_IF_FALSE((aLayerSize.mWidthType == nsStyleBackground::Size::eAuto) !=
+                    (aLayerSize.mHeightType == nsStyleBackground::Size::eAuto),
+                    "logic error");
+
+  bool isAutoWidth = aLayerSize.mWidthType == nsStyleBackground::Size::eAuto;
+
+  if (haveRatio) {
+    // Use the specified dimension, and compute the other from the ratio.
+    NS_ABORT_IF_FALSE(aIntrinsicRatio.width > 0,
+                      "ratio width out of sync with width?");
+    NS_ABORT_IF_FALSE(aIntrinsicRatio.height > 0,
+                      "ratio height out of sync with width?");
+    nsSize size;
+    if (isAutoWidth) {
+      size.height = aLayerSize.ResolveHeightLengthPercentage(aBgPositioningArea);
+      size.width =
+        NSCoordSaturatingNonnegativeMultiply(size.height,
+                                             double(aIntrinsicRatio.width) /
+                                             aIntrinsicRatio.height);
+    } else {
+      size.width = aLayerSize.ResolveWidthLengthPercentage(aBgPositioningArea);
+      size.height =
+        NSCoordSaturatingNonnegativeMultiply(size.width,
+                                             double(aIntrinsicRatio.height) /
+                                             aIntrinsicRatio.width);
+    }
+
+    return size;
+  }
+
+  NS_ABORT_IF_FALSE(!(aHaveWidth && aHaveHeight),
+                    "if we have width and height, we must have had a ratio");
+
+  // We have a specified dimension and an auto dimension, with no ratio to
+  // preserve.  A specified dimension trumps all, so use that.  For the other
+  // dimension, resolve auto to the intrinsic dimension (if present) or to 100%.
+  nsSize size;
+  if (isAutoWidth) {
+    size.width = aHaveWidth ? aUnscaledWidth : aBgPositioningArea.width;
+    size.height = aLayerSize.ResolveHeightLengthPercentage(aBgPositioningArea);
+  } else {
+    size.width = aLayerSize.ResolveWidthLengthPercentage(aBgPositioningArea);
+    size.height = aHaveHeight ? aUnscaledHeight : aBgPositioningArea.height;
+  }
+
+  return size;
+}
+
+/*
+ * The size returned by this method differs from the value of mSize, which this
+ * method also computes, in that mSize is the image's "preferred" size for this
+ * particular rendering, while the size returned here is the actual rendered
+ * size after accounting for background-size.  The preferred size is most often
+ * the image's intrinsic dimensions.  But for images with incomplete intrinsic
+ * dimensions, the preferred size varies, depending on the background
+ * positioning area, the specified background-size, and the intrinsic ratio and
+ * dimensions of the image (if it has them).
+ *
+ * This distinction is necessary because the components of a vector image are
+ * specified with respect to its preferred size for a rendering situation, not
+ * to its actual rendered size after background-size is applied.  For example,
+ * consider a 4px wide vector image with no height which contains a left-aligned
+ * 2px wide black rectangle with height 100%.  If the background-size width is
+ * auto (or 4px), the vector image will render 4px wide, and the black rectangle
+ * will be 2px wide.  If the background-size width is 8px, the vector image will
+ * render 8px wide, and the black rectangle will be 4px wide -- *not* 2px wide.
+ * In both cases mSize.width will be 4px; but in the first case the returned
+ * width will be 4px, while in the second case the returned width will be 8px.
+ */
+nsSize
+ImageRenderer::ComputeSize(const nsStyleBackground::Size& aLayerSize,
+                           const nsSize& aBgPositioningArea)
+{
+  bool haveWidth, haveHeight;
+  nsSize ratio;
+  nscoord unscaledWidth, unscaledHeight;
+  ComputeUnscaledDimensions(aBgPositioningArea,
+                            unscaledWidth, haveWidth,
+                            unscaledHeight, haveHeight,
+                            ratio);
+  nsSize drawnSize = ComputeDrawnSize(aLayerSize, aBgPositioningArea,
+                                      unscaledWidth, haveWidth,
+                                      unscaledHeight, haveHeight,
+                                      ratio);
+  mSize.width = haveWidth ? unscaledWidth : drawnSize.width;
+  mSize.height = haveHeight ? unscaledHeight : drawnSize.height;
+  return drawnSize;
 }
 
 void
 ImageRenderer::Draw(nsPresContext*       aPresContext,
                          nsRenderingContext& aRenderingContext,
                          const nsRect&        aDest,
                          const nsRect&        aFill,
                          const nsPoint&       aAnchor,
@@ -3942,17 +4129,19 @@ ImageRenderer::Draw(nsPresContext*      
     nsLayoutUtils::GetGraphicsFilterForFrame(mForFrame);
 
   switch (mType) {
     case eStyleImageType_Image:
     {
       PRUint32 drawFlags = (mFlags & FLAG_SYNC_DECODE_IMAGES)
                              ? (PRUint32) imgIContainer::FLAG_SYNC_DECODE
                              : (PRUint32) imgIContainer::FLAG_NONE;
-      nsLayoutUtils::DrawImage(&aRenderingContext, mImageContainer,
+      nsLayoutUtils::DrawBackgroundImage(&aRenderingContext, mImageContainer,
+          nsIntSize(nsPresContext::AppUnitsToIntCSSPixels(mSize.width),
+                    nsPresContext::AppUnitsToIntCSSPixels(mSize.height)),
           graphicsFilter,
           aDest, aFill, aAnchor, aDirty, drawFlags);
       break;
     }
     case eStyleImageType_Gradient:
       nsCSSRendering::PaintGradient(aPresContext, aRenderingContext,
           mGradientData, aDirty, aDest, aFill);
       break;
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1018,22 +1018,25 @@ static PRBool RoundedRectContainsRect(co
 }
 
 void
 nsDisplayBackground::HitTest(nsDisplayListBuilder* aBuilder,
                              const nsRect& aRect,
                              HitTestState* aState,
                              nsTArray<nsIFrame*> *aOutFrames)
 {
-  // For theme backgrounds, assume that any point in our bounds is a hit.
-  // We don't know the true hit region of the theme background.
-  if (!mIsThemed &&
-      !RoundedBorderIntersectsRect(mFrame, ToReferenceFrame(), aRect)) {
-    // aRect doesn't intersect our border-radius curve.
-    return;
+  if (mIsThemed) {
+    // For theme backgrounds, assume that any point in our border rect is a hit.
+    if (!nsRect(ToReferenceFrame(), mFrame->GetSize()).Intersects(aRect))
+      return;
+  } else {
+    if (!RoundedBorderIntersectsRect(mFrame, ToReferenceFrame(), aRect)) {
+      // aRect doesn't intersect our border-radius curve.
+      return;
+    }
   }
 
   aOutFrames->AppendElement(mFrame);
 }
 
 PRBool
 nsDisplayBackground::ComputeVisibility(nsDisplayListBuilder* aBuilder,
                                        nsRegion* aVisibleRegion,
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3564,71 +3564,94 @@ nsLayoutUtils::DrawSingleImage(nsRenderi
   fill.IntersectRect(aDest, dest);
   return DrawImageInternal(aRenderingContext, aImage, aGraphicsFilter, dest, fill,
                            fill.TopLeft(), aDirty, imageSize, aImageFlags);
 }
 
 /* static */ void
 nsLayoutUtils::ComputeSizeForDrawing(imgIContainer *aImage,
                                      nsIntSize&     aImageSize, /*outparam*/
-                                     PRBool&        aGotWidth,  /*outparam*/
-                                     PRBool&        aGotHeight  /*outparam*/)
+                                     nsSize&        aIntrinsicRatio, /*outparam*/
+                                     bool&          aGotWidth,  /*outparam*/
+                                     bool&          aGotHeight  /*outparam*/)
 {
   aGotWidth  = NS_SUCCEEDED(aImage->GetWidth(&aImageSize.width));
   aGotHeight = NS_SUCCEEDED(aImage->GetHeight(&aImageSize.height));
 
-  if ((aGotWidth && aGotHeight) ||    // Trivial success!
-      (!aGotWidth && !aGotHeight)) {  // Trivial failure!
+  if (aGotWidth && aGotHeight) {
+    aIntrinsicRatio = nsSize(aImageSize.width, aImageSize.height);
     return;
   }
 
-  // If we get here, we succeeded at querying *either* the width *or* the
-  // height, but not both.
-  NS_ASSERTION(aImage->GetType() == imgIContainer::TYPE_VECTOR,
-               "GetWidth and GetHeight should only fail for vector images");
-
-  nsIFrame* rootFrame = aImage->GetRootLayoutFrame();
-  NS_ASSERTION(rootFrame,
-               "We should have a VectorImage, which should have a rootFrame");
-
-  // This falls back on failure, if we somehow end up without a rootFrame.
-  nsSize ratio = rootFrame ? rootFrame->GetIntrinsicRatio() : nsSize(0,0);
-  if (!aGotWidth) { // Have height, missing width
-    if (ratio.height != 0) { // don't divide by zero
-      aImageSize.width = NSToCoordRound(aImageSize.height *
-                                        float(ratio.width) /
-                                        float(ratio.height));
-      aGotWidth = PR_TRUE;
-    }
-  } else { // Have width, missing height
-    if (ratio.width != 0) { // don't divide by zero
-      aImageSize.height = NSToCoordRound(aImageSize.width *
-                                         float(ratio.height) /
-                                         float(ratio.width));
-      aGotHeight = PR_TRUE;
-    }
+  // If we failed to get width or height, we either have a vector image and
+  // should return its intrinsic ratio, or we hit an error (say, because the
+  // image failed to load or couldn't be decoded) and should return zero size.
+  if (nsIFrame* rootFrame = aImage->GetRootLayoutFrame()) {
+    aIntrinsicRatio = rootFrame->GetIntrinsicRatio();
+  } else {
+    aGotWidth = aGotHeight = true;
+    aImageSize = nsIntSize(0, 0);
+    aIntrinsicRatio = nsSize(0, 0);
   }
 }
 
 
 /* static */ nsresult
+nsLayoutUtils::DrawBackgroundImage(nsRenderingContext* aRenderingContext,
+                                   imgIContainer*      aImage,
+                                   const nsIntSize&    aImageSize,
+                                   GraphicsFilter      aGraphicsFilter,
+                                   const nsRect&       aDest,
+                                   const nsRect&       aFill,
+                                   const nsPoint&      aAnchor,
+                                   const nsRect&       aDirty,
+                                   PRUint32            aImageFlags)
+{
+  return DrawImageInternal(aRenderingContext, aImage, aGraphicsFilter,
+                           aDest, aFill, aAnchor, aDirty,
+                           aImageSize, aImageFlags);
+}
+
+/* static */ nsresult
 nsLayoutUtils::DrawImage(nsRenderingContext* aRenderingContext,
                          imgIContainer*       aImage,
                          GraphicsFilter       aGraphicsFilter,
                          const nsRect&        aDest,
                          const nsRect&        aFill,
                          const nsPoint&       aAnchor,
                          const nsRect&        aDirty,
                          PRUint32             aImageFlags)
 {
   nsIntSize imageSize;
-  PRBool gotHeight, gotWidth;
-  ComputeSizeForDrawing(aImage, imageSize, gotWidth, gotHeight);
-
-  // fallback size based on aFill.
+  nsSize imageRatio;
+  bool gotHeight, gotWidth;
+  ComputeSizeForDrawing(aImage, imageSize, imageRatio, gotWidth, gotHeight);
+
+  // XXX Dimensionless images shouldn't fall back to filled-area size -- the
+  //     caller should provide the image size, a la DrawBackgroundImage.
+  if (gotWidth != gotHeight) {
+    if (!gotWidth) {
+      if (imageRatio.height != 0) {
+        imageSize.width =
+          NSCoordSaturatingNonnegativeMultiply(imageSize.height,
+                                               float(imageRatio.width) /
+                                               float(imageRatio.height));
+        gotWidth = true;
+      }
+    } else {
+      if (imageRatio.width != 0) {
+        imageSize.height =
+          NSCoordSaturatingNonnegativeMultiply(imageSize.width,
+                                               float(imageRatio.height) /
+                                               float(imageRatio.width));
+        gotHeight = true;
+      }
+    }
+  }
+
   if (!gotWidth) {
     imageSize.width = nsPresContext::AppUnitsToIntCSSPixels(aFill.width);
   }
   if (!gotHeight) {
     imageSize.height = nsPresContext::AppUnitsToIntCSSPixels(aFill.height);
   }
 
   return DrawImageInternal(aRenderingContext, aImage, aGraphicsFilter,
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -1044,16 +1044,48 @@ public:
    */
   static GraphicsFilter GetGraphicsFilterForFrame(nsIFrame* aFrame);
 
   /* N.B. The only difference between variants of the Draw*Image
    * functions below is the type of the aImage argument.
    */
 
   /**
+   * Draw a background image.  The image's dimensions are as specified in aDest;
+   * the image itself is not consulted to determine a size.
+   * See https://wiki.mozilla.org/Gecko:Image_Snapping_and_Rendering
+   *   @param aRenderingContext Where to draw the image, set up with an
+   *                            appropriate scale and transform for drawing in
+   *                            app units.
+   *   @param aImage            The image.
+   *   @param aImageSize        The unscaled size of the image being drawn.
+   *                            (This might be the image's size if no scaling
+   *                            occurs, or it might be the image's size if
+   *                            the image is a vector image being rendered at
+   *                            that size.)
+   *   @param aDest             The position and scaled area where one copy of
+   *                            the image should be drawn.
+   *   @param aFill             The area to be filled with copies of the
+   *                            image.
+   *   @param aAnchor           A point in aFill which we will ensure is
+   *                            pixel-aligned in the output.
+   *   @param aDirty            Pixels outside this area may be skipped.
+   *   @param aImageFlags       Image flags of the imgIContainer::FLAG_* variety
+   */
+  static nsresult DrawBackgroundImage(nsRenderingContext* aRenderingContext,
+                                      imgIContainer*      aImage,
+                                      const nsIntSize&    aImageSize,
+                                      GraphicsFilter      aGraphicsFilter,
+                                      const nsRect&       aDest,
+                                      const nsRect&       aFill,
+                                      const nsPoint&      aAnchor,
+                                      const nsRect&       aDirty,
+                                      PRUint32            aImageFlags);
+
+  /**
    * Draw an image.
    * See https://wiki.mozilla.org/Gecko:Image_Snapping_and_Rendering
    *   @param aRenderingContext Where to draw the image, set up with an
    *                            appropriate scale and transform for drawing in
    *                            app units.
    *   @param aImage            The image.
    *   @param aDest             Where one copy of the image should mapped to.
    *   @param aFill             The area to be filled with copies of the
@@ -1147,30 +1179,33 @@ public:
                                   const nsRect&        aDirty,
                                   PRUint32             aImageFlags,
                                   const nsRect*        aSourceArea = nsnull);
 
   /**
    * Given an imgIContainer, this method attempts to obtain an intrinsic
    * px-valued height & width for it.  If the imgIContainer has a non-pixel
    * value for either height or width, this method tries to generate a pixel
-   * value for that dimension using the intrinsic ratio (if available).
+   * value for that dimension using the intrinsic ratio (if available).  The
+   * intrinsic ratio will be assigned to aIntrinsicRatio; if there's no
+   * intrinsic ratio then (0, 0) will be assigned.
    *
    * This method will always set aGotWidth and aGotHeight to indicate whether
    * we were able to successfully obtain (or compute) a value for each
    * dimension.
    *
    * NOTE: This method is similar to ComputeSizeWithIntrinsicDimensions.  The
    * difference is that this one is simpler and is suited to places where we
    * have less information about the frame tree.
    */
   static void ComputeSizeForDrawing(imgIContainer* aImage,
                                     nsIntSize&     aImageSize,
-                                    PRBool&        aGotWidth,
-                                    PRBool&        aGotHeight);
+                                    nsSize&        aIntrinsicRatio,
+                                    bool&          aGotWidth,
+                                    bool&          aGotHeight);
 
   /**
    * Given a source area of an image (in appunits) and a destination area
    * that we want to map that source area too, computes the area that
    * would be covered by the whole image. This is useful for passing to
    * the aDest parameter of DrawImage, when we want to draw a subimage
    * of an overall image.
    */
--- a/layout/build/nsContentDLF.cpp
+++ b/layout/build/nsContentDLF.cpp
@@ -92,16 +92,17 @@ static const char* const gHTMLTypes[] = 
   TEXT_HTML,
   TEXT_PLAIN,
   TEXT_CSS,
   TEXT_JAVASCRIPT,
   TEXT_ECMASCRIPT,
   APPLICATION_JAVASCRIPT,
   APPLICATION_ECMASCRIPT,
   APPLICATION_XJAVASCRIPT,
+  APPLICATION_JSON,
   VIEWSOURCE_CONTENT_TYPE,
   APPLICATION_XHTML_XML,
   0
 };
   
 static const char* const gXMLTypes[] = {
   TEXT_XML,
   APPLICATION_XML,
--- a/layout/build/nsContentDLF.h
+++ b/layout/build/nsContentDLF.h
@@ -102,16 +102,17 @@ NS_NewContentDocumentLoaderFactory(nsIDo
     { "Gecko-Content-Viewers", TEXT_HTML, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", TEXT_PLAIN, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", TEXT_CSS, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", TEXT_JAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", TEXT_ECMASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", APPLICATION_JAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", APPLICATION_ECMASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", APPLICATION_XJAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \
+    { "Gecko-Content-Viewers", APPLICATION_JSON, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", APPLICATION_XHTML_XML, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", TEXT_XML, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", APPLICATION_XML, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", APPLICATION_RDF_XML, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", TEXT_RDF, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", TEXT_XUL, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", APPLICATION_CACHED_XUL, "@mozilla.org/content/document-loader-factory;1" }, \
     { "Gecko-Content-Viewers", VIEWSOURCE_CONTENT_TYPE, "@mozilla.org/content/document-loader-factory;1" }, \
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -84,33 +84,31 @@
 #include "nsIDocument.h" //observe documents to send onchangenotifications
 #include "nsIStyleSheet.h"//observe documents to send onchangenotifications
 #include "nsIStyleRule.h"//observe documents to send onchangenotifications
 #include "nsIDOMEventListener.h"//observe documents to send onchangenotifications
 #include "nsGUIEvent.h"
 #include "nsIDOMNSEvent.h"
 #include "nsIDOMNSUIEvent.h"
 
-#include "nsIDOMFocusListener.h" //onchange events
 #include "nsIDOMCharacterData.h" //for selection setting helper func
 #include "nsIDOMNodeList.h" //for selection setting helper func
 #include "nsIDOMRange.h" //for selection setting helper func
 #include "nsPIDOMWindow.h" //needed for notify selection changed to update the menus ect.
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
 #include "nsIServiceManager.h"
 #include "nsIDOMNode.h"
 
 #include "nsIEditorObserver.h"
 #include "nsITransactionManager.h"
 #include "nsIDOMText.h" //for multiline getselection
 #include "nsNodeInfoManager.h"
 #include "nsContentCreatorFunctions.h"
-#include "nsIDOMKeyListener.h"
 #include "nsINativeKeyBindings.h"
 #include "nsIJSContextStack.h"
 #include "nsFocusManager.h"
 #include "nsTextEditRules.h"
 #include "nsIDOMNSHTMLElement.h"
 #include "nsPresState.h"
 
 #include "mozilla/FunctionTimer.h"
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -50,17 +50,17 @@
 
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsWidgetsCID.h"
 #include "nsIView.h"
 #include "nsIViewManager.h"
-#include "nsIDOMKeyListener.h"
+#include "nsIDOMEventListener.h"
 #include "nsIDOMDragEvent.h"
 #include "nsPluginHost.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "prmem.h"
 #include "nsGkAtoms.h"
 #include "nsIAppShell.h"
 #include "nsIDocument.h"
@@ -79,20 +79,16 @@
 #include "nsDocShellCID.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMHTMLObjectElement.h"
 #include "nsIDOMHTMLEmbedElement.h"
 #include "nsIDOMHTMLAppletElement.h"
 #include "nsIDOMWindow.h"
-#include "nsIDOMMouseListener.h"
-#include "nsIDOMMouseMotionListener.h"
-#include "nsIDOMFocusListener.h"
-#include "nsIDOMContextMenuListener.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOMNSEvent.h"
 #include "nsIPrivateDOMEvent.h"
 #include "nsIDocumentEncoder.h"
 #include "nsXPIDLString.h"
 #include "nsIDOMRange.h"
 #include "nsIPluginWidget.h"
 #include "nsGUIEvent.h"
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -96,17 +96,16 @@ static const char kPrintingPromptService
 // Printing Timer
 #include "nsPagePrintTimer.h"
 
 // FrameSet
 #include "nsIDocument.h"
 
 // Focus
 #include "nsIDOMEventTarget.h"
-#include "nsIDOMFocusListener.h"
 #include "nsISelectionController.h"
 
 // Misc
 #include "nsISupportsUtils.h"
 #include "nsIFrame.h"
 #include "nsIScriptContext.h"
 #include "nsILinkHandler.h"
 #include "nsIDOMDocument.h"
deleted file mode 100644
--- a/layout/reftests/backgrounds/background-size-no-intrinsic-height-image-ref.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>background-size: 32px auto; for image with no intrinsic height reference</title>
-  <style type="text/css">
-#outer
-{
-  border: 1px solid black;
-  width: 64px;
-  height: 128px;
-}
-#inner
-{
-  width: 32px;
-  height: 128px;
-  background-color: lime;
-}
-  </style>
-</head>
-<body>
-<div id="outer"><div id="inner"></div></div>
-</body>
-</html>
deleted file mode 100644
--- a/layout/reftests/backgrounds/background-size-no-intrinsic-height-image.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>background-size: 32px auto; for image with no intrinsic height</title>
-  <style type="text/css">
-#outer
-{
-  border: 1px solid black;
-  width: 64px;
-  height: 128px;
-}
-#inner
-{
-  width: 64px;
-  height: 128px;
-  background-image: url(no-intrinsic-size.svg);
-  background-repeat: no-repeat;
-  background-size: 32px auto;
-}
-  </style>
-</head>
-<body>
-<div id="outer"><div id="inner"></div></div>
-</body>
-</html>
deleted file mode 100644
--- a/layout/reftests/backgrounds/background-size-no-intrinsic-width-image-ref.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>background-size: 32px auto; for image with no intrinsic size reference</title>
-  <style type="text/css">
-#outer
-{
-  border: 1px solid black;
-  width: 64px;
-  height: 128px;
-}
-#inner
-{
-  width: 64px;
-  height: 32px;
-  background-color: lime;
-}
-  </style>
-</head>
-<body>
-<div id="outer"><div id="inner"></div></div>
-</body>
-</html>
deleted file mode 100644
--- a/layout/reftests/backgrounds/background-size-no-intrinsic-width-image.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <title>background-size: auto 32px; for image with no intrinsic width</title>
-  <style type="text/css">
-#outer
-{
-  border: 1px solid black;
-  width: 64px;
-  height: 128px;
-}
-#inner
-{
-  width: 64px;
-  height: 128px;
-  background-image: url(no-intrinsic-size.svg);
-  background-repeat: no-repeat;
-  background-size: auto 32px;
-}
-  </style>
-</head>
-<body>
-<div id="outer"><div id="inner"></div></div>
-</body>
-</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/gradient/reftest.list
@@ -0,0 +1,1 @@
+== scaled-color-stop-position.html scaled-color-stop-position-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/gradient/scaled-color-stop-position-ref.html
@@ -0,0 +1,27 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Color stop positioning for scaled gradients as backgrounds reference</title>
+  <style type="text/css">
+#outer
+{
+  border: 1px solid black;
+  width: 600px; height: 300px;
+}
+#inner
+{
+  width: 400px; height: 300px;
+  /* 250px stop is halfway along 500px diagonal */
+  background-image: -moz-linear-gradient(top left, lime 0%, teal 250px, black 100%);
+  background-image: linear-gradient(top left, lime 0%, teal 250px, black 100%);
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/gradient/scaled-color-stop-position.html
@@ -0,0 +1,25 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Color stop positioning for scaled gradients as backgrounds</title>
+  <style type="text/css">
+#outer
+{
+  border: 1px solid black;
+  width: 600px; height: 300px;
+  /* 250px stop is halfway along 500px diagonal */
+  background-image: -moz-linear-gradient(top left, lime 0%, teal 250px, black 100%);
+  background-image: linear-gradient(top left, lime 0%, teal 250px, black 100%);
+  background-size: 400px auto;
+  background-repeat: no-repeat;
+}
+  </style>
+</head>
+<body>
+<div id="outer"></div>
+</body>
+</html>
deleted file mode 100644
--- a/layout/reftests/backgrounds/no-intrinsic-size.svg
+++ /dev/null
@@ -1,8 +0,0 @@
-<!--
-     Any copyright is dedicated to the Public Domain.
-     http://creativecommons.org/licenses/publicdomain/
--->
-<svg xmlns="http://www.w3.org/2000/svg">
-  <title>Image with no intrinsic size</title>
-  <rect width="100%" height="100%" fill="lime"/>
-</svg>
--- a/layout/reftests/backgrounds/reftest.list
+++ b/layout/reftests/backgrounds/reftest.list
@@ -1,8 +1,11 @@
+include gradient/reftest.list
+include vector/reftest.list
+
 == layers-stacking-order.xhtml layers-stacking-order-ref.xhtml
 == layers-layer-count-cascade-1.xhtml layers-layer-count-1-ref.xhtml
 == layers-layer-count-inheritance-1.xhtml layers-layer-count-1-ref.xhtml
 == layers-layer-count-cascade-2.xhtml layers-layer-count-2-ref.xhtml
 == layers-layer-count-inheritance-2.xhtml layers-layer-count-2-ref.xhtml
 == viewport-translucent-color-1.html viewport-translucent-color-ref.html
 fails-if(Android) == viewport-translucent-color-2.html viewport-translucent-color-ref.html
 fails-if(Android) == viewport-translucent-color-3.html viewport-translucent-color-ref.html
@@ -96,22 +99,15 @@ fails-if(Android) == viewport-translucen
 
 # There seems to be a pixel-snapping problem here, where the repeated background
 # image isn't being snapped at its boundaries.  Note that the boundaries within
 # the image aren't the issue, because they're being obscured to avoid sampling
 # algorithm dependencies (at least assuming the sampling algorithm in use
 # doesn't sample too far astray from the boundaries).
 fails == background-size-zoom-repeat.html background-size-zoom-repeat-ref.html
 
-# background-size affects images without intrinsic dimensions specially; we may
-# not support such image formats right now, but when we do, we want
-# background-size to be changed accordingly, and hopefully these tests should
-# start failing when we do.
-fails == background-size-no-intrinsic-width-image.html background-size-no-intrinsic-width-image-ref.html
-fails == background-size-no-intrinsic-height-image.html background-size-no-intrinsic-height-image-ref.html
-
 # -moz-default-background-color and -moz-default-color (bug 591341)
 == background-moz-default-background-color.html background-moz-default-background-color-ref.html
 
 == fixed-bg-with-transform-outside-viewport-1.html fixed-bg-with-transform-outside-viewport-ref.html
 
 HTTP == root-background-1.html root-background-ref.html
 HTTP != root-background-1.html about:blank
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/diagonal-percentage-vector-background-ref.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Scaled vector image without intrinsic dimensions as background, with rendering dependent on the diagonal</title>
+  <style type="text/css">
+#outer
+{
+  width: 256px; height: 768px;
+  border: 1px solid black;
+}
+#inner
+{
+  width: 100px; height: 700px;
+  background-image: url(diagonal-scaled-fixed.svg);
+  background-repeat: no-repeat;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/diagonal-percentage-vector-background.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>Scaled vector image without intrinsic dimensions as background, with rendering dependent on the diagonal</title>
+  <style type="text/css">
+#outer
+{
+  width: 256px; height: 768px;
+  border: 1px solid black;
+}
+#inner
+{
+  width: 100px; height: 700px;
+  background-image: url(diagonal-scaled.svg);
+  background-repeat: no-repeat;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/diagonal-scaled-fixed.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg" width="100px" height="700px">
+  <title>Vector image with intrinsic dimensions, reference for diagonal-scaled.svg</title>
+  <rect y="0" width="100px" height="350px" fill="lime"/>
+  <rect y="350px" width="100px" height="350px" fill="aqua"/>
+  <rect y="175px" width="50px" height="350px" fill="fuchsia"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/diagonal-scaled.svg
@@ -0,0 +1,21 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg">
+  <title>Vector image without intrinsic dimensions with percentage stroke-width (proportional to the diagonal)</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+  <!--
+    A percent stroke-width is resolved with respect to:
+
+      d = sqrt(vh**2 + vw**2) / sqrt(2)
+
+    where vh/vw are the image viewport width/height.  Because this image has no
+    intrinsic dimensions or ratio, it expands to fill the entire background
+    positioning area, so its width is 100px and its height is 700px.  For those
+    carefully-chosen dimensions, d = 500px, so 10% of that creates a 50px-wide
+    rectangle, vertically centered and horizontally left-aligned in the image.
+  -->
+  <line x1="25%" y1="25%" x2="25%" y2="75%" stroke="fuchsia" stroke-width="10%"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/intrinsic-ratio-no-dimensions.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     viewBox="0 0 8 0"
+     preserveAspectRatio="none">
+  <title>Image with zero-width ratio, no dimensions</title>
+  <rect y="0" width="100%" height="100%" fill="lime"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/intrinsic-ratio-zero-height.svg
@@ -0,0 +1,11 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="8px"
+     viewBox="0 0 8 0"
+     preserveAspectRatio="none">
+  <title>Image with zero-height ratio, width</title>
+  <rect y="0" width="100%" height="100%" fill="lime"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/intrinsic-ratio-zero-width.svg
@@ -0,0 +1,11 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="8px"
+     viewBox="0 0 0 8"
+     preserveAspectRatio="none">
+  <title>Image with zero-width ratio, width</title>
+  <rect y="0" width="100%" height="100%" fill="lime"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/nonpercent-width-omitted-height-extreme-viewbox.svg
@@ -0,0 +1,11 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="8px"
+     viewBox="0 0 2147483647 1"
+     preserveAspectRatio="none">
+  <title>Image with non-percent width, omitted height, extreme viewbox</title>
+  <rect y="0" width="100%" height="100%" fill="lime"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/omitted-width-nonpercent-height-extreme-viewbox.svg
@@ -0,0 +1,11 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     height="8px"
+     viewBox="0 0 1 2147483647"
+     preserveAspectRatio="none">
+  <title>Image with omitted width, non-percent height, extreme viewbox</title>
+  <rect y="0" width="100%" height="100%" fill="lime"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/ref-tall-empty.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, empty</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+  </style>
+</head>
+<body>
+<div id="outer"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/ref-tall-lime.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, lime fill</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background: lime;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/ref-wide-empty.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, empty</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+  border: 1px solid black;
+}
+  </style>
+</head>
+<body>
+<div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/ref-wide-lime.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, empty</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background: lime;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/reftest.list
@@ -0,0 +1,30 @@
+== tall--contain--height.html ref-tall-empty.html
+== tall--contain--width.html ref-tall-empty.html
+== wide--contain--height.html ref-wide-empty.html
+== wide--contain--width.html ref-wide-empty.html
+
+# Either OS X 32-bit or 10.5, judging from imprecise Tinderbox results, renders
+# these tests as empty boxes, not filled boxes.  We don't really care about this
+# extreme edge case (the test exists more to test for safety against division by
+# zero), so there is no bug has been filed to fix it, although a patch would
+# probably be accepted.
+random-if(cocoaWidget) == tall--cover--height.html ref-tall-lime.html
+random-if(cocoaWidget) == tall--cover--width.html ref-tall-lime.html
+random-if(cocoaWidget) == wide--cover--height.html ref-wide-lime.html
+random-if(cocoaWidget) == wide--cover--width.html ref-wide-lime.html
+
+== zero-height-ratio-contain.html ref-tall-empty.html
+== zero-height-ratio-cover.html ref-tall-empty.html
+== zero-height-ratio-auto-auto.html ref-tall-empty.html
+== zero-height-ratio-auto-5px.html ref-tall-empty.html
+== zero-height-ratio-5px-auto.html ref-tall-empty.html
+== zero-width-ratio-contain.html ref-tall-empty.html
+== zero-width-ratio-cover.html ref-tall-empty.html
+== zero-width-ratio-auto-auto.html ref-tall-empty.html
+== zero-width-ratio-auto-5px.html ref-tall-empty.html
+== zero-width-ratio-5px-auto.html ref-tall-empty.html
+== zero-ratio-no-dimensions-contain.html ref-tall-empty.html
+== zero-ratio-no-dimensions-cover.html ref-tall-empty.html
+== zero-ratio-no-dimensions-auto-5px.html ref-tall-empty.html
+== zero-ratio-no-dimensions-5px-auto.html ref-tall-empty.html
+== zero-ratio-no-dimensions-auto-auto.html ref-tall-empty.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/tall--contain--height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: contain; for nonpercent-width-omitted-height-extreme-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(nonpercent-width-omitted-height-extreme-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: contain;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/tall--contain--width.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: contain; for omitted-width-nonpercent-height-extreme-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(omitted-width-nonpercent-height-extreme-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: contain;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/tall--cover--height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: cover; for nonpercent-width-omitted-height-extreme-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(nonpercent-width-omitted-height-extreme-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: cover;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/tall--cover--width.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: cover; for omitted-width-nonpercent-height-extreme-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(omitted-width-nonpercent-height-extreme-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: cover;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/wide--contain--height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide background-size: contain; for nonpercent-width-omitted-height-extreme-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(nonpercent-width-omitted-height-extreme-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: contain;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/wide--contain--width.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide background-size: contain; for omitted-width-nonpercent-height-extreme-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(omitted-width-nonpercent-height-extreme-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: contain;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/wide--cover--height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide background-size: cover; for nonpercent-width-omitted-height-extreme-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(nonpercent-width-omitted-height-extreme-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: cover;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/wide--cover--width.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide background-size: cover; for omitted-width-nonpercent-height-extreme-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(omitted-width-nonpercent-height-extreme-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: cover;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-height-ratio-5px-auto.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero height ratio, 5px auto</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-zero-height.svg);
+  background-repeat: no-repeat;
+  background-size: 5px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-height-ratio-auto-5px.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero height ratio, auto 5px</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-zero-height.svg);
+  background-repeat: no-repeat;
+  background-size: auto 5px;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-height-ratio-auto-auto.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero height ratio, auto auto</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-zero-height.svg);
+  background-repeat: no-repeat;
+  background-size: auto auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-height-ratio-contain.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero height ratio, contain</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-zero-height.svg);
+  background-repeat: no-repeat;
+  background-size: contain;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-height-ratio-cover.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero height ratio, cover</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-zero-height.svg);
+  background-repeat: no-repeat;
+  background-size: cover;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-ratio-no-dimensions-5px-auto.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero ratio, no dimensions, 5px auto</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-no-dimensions.svg);
+  background-repeat: no-repeat;
+  background-size: 5px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-ratio-no-dimensions-auto-5px.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero ratio, no dimensions, auto 5px</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-no-dimensions.svg);
+  background-repeat: no-repeat;
+  background-size: auto 5px;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-ratio-no-dimensions-auto-auto.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero ratio, no dimensions, auto auto</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-no-dimensions.svg);
+  background-repeat: no-repeat;
+  background-size: auto auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-ratio-no-dimensions-contain.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero ratio, no dimensions, contain</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-no-dimensions.svg);
+  background-repeat: no-repeat;
+  background-size: contain;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-ratio-no-dimensions-cover.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero ratio, no dimensions, cover</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-no-dimensions.svg);
+  background-repeat: no-repeat;
+  background-size: cover;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-width-ratio-5px-auto.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero height ratio, 5px auto</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-zero-width.svg);
+  background-repeat: no-repeat;
+  background-size: 5px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-width-ratio-auto-5px.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero height ratio, auto 5px</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-zero-width.svg);
+  background-repeat: no-repeat;
+  background-size: auto 5px;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-width-ratio-auto-auto.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero width ratio, auto auto</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-zero-width.svg);
+  background-repeat: no-repeat;
+  background-size: auto auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-width-ratio-contain.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero width ratio, contain</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-zero-width.svg);
+  background-repeat: no-repeat;
+  background-size: contain;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/empty/zero-width-ratio-cover.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>zero width ratio, cover</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(intrinsic-ratio-zero-width.svg);
+  background-repeat: no-repeat;
+  background-size: cover;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/nonpercent-width-nonpercent-height-viewbox.svg
@@ -0,0 +1,12 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="8px" height="32px"
+     viewBox="0 0 4 64"
+     preserveAspectRatio="none">
+  <title>Image with non-percent width, non-percent height, viewbox</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/nonpercent-width-nonpercent-height.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="8px" height="32px">
+  <title>Image with non-percentage dimensions</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/nonpercent-width-omitted-height-viewbox.svg
@@ -0,0 +1,12 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="8px"
+     viewBox="0 0 4 64"
+     preserveAspectRatio="none">
+  <title>Image with non-percent width, omitted height, viewbox</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/nonpercent-width-omitted-height.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="8px">
+  <title>Image with non-percent width, omitted height</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/nonpercent-width-percent-height-viewbox.svg
@@ -0,0 +1,12 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="8px" height="50%"
+     viewBox="0 0 4 64"
+     preserveAspectRatio="none">
+  <title>Image with non-percent width, percent height, viewbox</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/nonpercent-width-percent-height.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="8px" height="50%">
+  <title>Image with non-percent width, percent height</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/omitted-width-nonpercent-height-viewbox.svg
@@ -0,0 +1,12 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     height="32px"
+     viewBox="0 0 4 64"
+     preserveAspectRatio="none">
+  <title>Image with omitted width, non-percent height, viewbox</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/omitted-width-nonpercent-height.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     height="32px">
+  <title>Image with omitted width, non-percent height</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/omitted-width-omitted-height-viewbox.svg
@@ -0,0 +1,11 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     viewBox="0 0 4 64"
+     preserveAspectRatio="none">
+  <title>Image with omitted width, omitted height, viewbox</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/omitted-width-omitted-height.svg
@@ -0,0 +1,9 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg">
+  <title>Image with omitted width, omitted height</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/omitted-width-percent-height-viewbox.svg
@@ -0,0 +1,12 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     height="50%"
+     viewBox="0 0 4 64"
+     preserveAspectRatio="none">
+  <title>Image with omitted width, percent height, viewbox</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/omitted-width-percent-height.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     height="50%">
+  <title>Image with omitted width, percent height</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/percent-width-nonpercent-height-viewbox.svg
@@ -0,0 +1,12 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="50%" height="32px"
+     viewBox="0 0 4 64"
+     preserveAspectRatio="none">
+  <title>Image with percent width, non-percent height, viewbox</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/percent-width-nonpercent-height.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="50%" height="32px">
+  <title>Image with percent width, non-percent height</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/percent-width-omitted-height-viewbox.svg
@@ -0,0 +1,12 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="50%"
+     viewBox="0 0 4 64"
+     preserveAspectRatio="none">
+  <title>Image with percent width, omitted height, viewbox</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/percent-width-omitted-height.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="50%">
+  <title>Image with percent width, omitted height</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/percent-width-percent-height-viewbox.svg
@@ -0,0 +1,12 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="25%" height="50%"
+     viewBox="0 0 4 64"
+     preserveAspectRatio="none">
+  <title>Image with percent width, percent height, viewbox</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/percent-width-percent-height.svg
@@ -0,0 +1,10 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<svg xmlns="http://www.w3.org/2000/svg"
+     width="25%" height="50%">
+  <title>Image with percent width, percent height</title>
+  <rect y="0" width="100%" height="50%" fill="lime"/>
+  <rect y="50%" width="100%" height="50%" fill="aqua"/>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime192x384-aqua192x384.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 192x384 lime, 192x384 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 192px; height: 768px;
+}
+#inner > div { width: 192px; height: 384px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime256x16-aqua256x16.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 256x16 lime, 256x16 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 256px; height: 32px;
+}
+#inner > div { width: 256px; height: 16px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime256x384-aqua256x384.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 256x384 lime, 256x384 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 256px; height: 768px;
+}
+#inner > div { width: 256px; height: 384px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime256x512-aqua256x256.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 256x512 lime, 256x256 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 256px; height: 768px;
+}
+#inner > div { width: 256px; }
+#top { background-color: lime; height: 512px; }
+#bottom { background-color: aqua; height: 256px; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime256x768.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 256x512 lime, 256x256 aqua</title>
+  <style type="text/css">
+#outer
+{
+  width: 256px; height: 768px;
+  background-color: lime;
+  border: 1px solid black;
+}
+  </style>
+</head>
+<body>
+<div id="outer"></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime2x16-aqua2x16.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 2x16 lime, 2x16 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 2px; height: 32px;
+}
+#inner > div { width: 2px; height: 16px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime32x128-aqua32x128.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 32x128 lime, 32x128 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 32px; height: 256px;
+}
+#inner > div { width: 32px; height: 128px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime32x16-aqua32x16.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 32x16 lime, 32x16 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 32px; height: 32px;
+}
+#inner > div { width: 32px; height: 16px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime32x256-aqua32x256.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 32x256 lime, 32x256 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 32px; height: 512px;
+}
+#inner > div { width: 32px; height: 256px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime32x384-aqua32x384.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 32x384 lime, 32x384 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 32px; height: 768px;
+}
+#inner > div { width: 32px; height: 384px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime32x64-aqua32x64.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 32x64 lime, 32x64 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 32px; height: 128px;
+}
+#inner > div { width: 32px; height: 64px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime48x384-aqua48x384.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 48x384 lime, 48x384 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 48px; height: 768px;
+}
+#inner > div { width: 48px; height: 384px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime4x16-aqua4x16.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 4x16 lime, 4x16 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 4px; height: 32px;
+}
+#inner > div { width: 4px; height: 16px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime8x16-aqua8x16.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 8x16 lime, 8x16 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 8px; height: 32px;
+}
+#inner > div { width: 8px; height: 16px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime8x32-aqua8x32.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 8x32 lime, 8x32 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 8px; height: 64px;
+}
+#inner > div { width: 8px; height: 32px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime8x384-aqua8x384.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 8x384 lime, 8x384 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 8px; height: 768px;
+}
+#inner > div { width: 8px; height: 384px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-tall-lime8x64-aqua8x64.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall reference, 8x64 lime, 8x64 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 8px; height: 128px;
+}
+#inner > div { width: 8px; height: 64px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime12x128-aqua12x128.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 12x128 lime, 12x128 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 12px; height: 256px;
+}
+#inner > div { width: 12px; height: 128px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime12x16-aqua12x16.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 12x16 lime, 12x16 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 12px; height: 32px;
+}
+#inner > div { width: 12px; height: 16px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime12x24-aqua12x24.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 12x24 lime, 12x24 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 12px; height: 48px;
+}
+#inner > div { width: 12px; height: 24px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime12x96-aqua12x96.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 12x96 lime, 12x96 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 12px; height: 192px;
+}
+#inner > div { width: 12px; height: 96px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime16x128-aqua16x128.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 16x128 lime, 16x128 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 16px; height: 256px;
+}
+#inner > div { width: 16px; height: 128px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime2x16-aqua2x16.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 2x16 lime, 2x16 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 2px; height: 32px;
+}
+#inner > div { width: 2px; height: 16px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime64x128-aqua64x128.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 64x128 lime, 64x128 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 64px; height: 256px;
+}
+#inner > div { width: 64px; height: 128px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime768x128-aqua768x128.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 768x128 lime, 768x128 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 768px; height: 256px;
+}
+#inner > div { width: 768px; height: 128px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime768x16-aqua768x16.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 768x16 lime, 768x16 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 768px; height: 32px;
+}
+#inner > div { width: 768px; height: 16px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime768x256.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 768x256 lime</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 768px; height: 256px;
+  background-color: lime;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime8x128-aqua8x128.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 8x128 lime, 8x128 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 8px; height: 256px;
+}
+#inner > div { width: 8px; height: 128px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime8x16-aqua8x16.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 8x16 lime, 8x16 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 8px; height: 32px;
+}
+#inner > div { width: 8px; height: 16px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/ref-wide-lime8x64-aqua8x64.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>wide reference, 8x64 lime, 8x64 aqua</title>
+  <style type="text/css">
+div
+{
+  width: 768px; height: 256px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  width: 8px; height: 128px;
+}
+#inner > div { width: 8px; height: 64px; }
+#top { background-color: lime; }
+#bottom { background-color: aqua; }
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"><div id="top"></div><div id="bottom"></div></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/reftest.list
@@ -0,0 +1,208 @@
+include empty/reftest.list
+
+################################################################################
+# For reference (although the wide--32px-auto* tests/names were changed to
+# avoid viewBox-directed scaling to make the scaled height less than the wide-
+# tests height):
+#
+# for ORIENTATION in tall wide; do for SIZE in 32px-auto auto-32px auto contain cover; do for VIMAGE in *.svg; do cat template.html | sed -e "s/SIZE/$(echo $SIZE | sed -e 's/-/ /')/g" | sed -e "s/VIMAGE/$VIMAGE/g" | sed -e "s/TALLWIDE/$ORIENTATION/g" | sed -e "s/ORIENTATION/$(if [ "$ORIENTATION" = "tall" ]; then echo 'width: 256px; height: 768px'; else echo 'width: 768px; height: 256px'; fi)/g" > $ORIENTATION--$SIZE--$(echo $VIMAGE | sed -e 's/.svg//').html; echo "== $ORIENTATION--$SIZE--$(echo $VIMAGE | sed -e 's/.svg//').html ###" >> reftest.list; done; echo >> reftest.list; done; done
+#
+################################################################################
+
+== tall--32px-auto--nonpercent-width-nonpercent-height.html ref-tall-lime32x64-aqua32x64.html
+== tall--32px-auto--nonpercent-width-nonpercent-height-viewbox.html ref-tall-lime32x64-aqua32x64.html
+== tall--32px-auto--nonpercent-width-omitted-height.html ref-tall-lime32x384-aqua32x384.html
+== tall--32px-auto--nonpercent-width-omitted-height-viewbox.html ref-tall-lime32x256-aqua32x256.html
+== tall--32px-auto--nonpercent-width-percent-height.html ref-tall-lime32x384-aqua32x384.html
+== tall--32px-auto--nonpercent-width-percent-height-viewbox.html ref-tall-lime32x256-aqua32x256.html
+== tall--32px-auto--omitted-width-nonpercent-height.html ref-tall-lime32x16-aqua32x16.html
+== tall--32px-auto--omitted-width-nonpercent-height-viewbox.html ref-tall-lime32x256-aqua32x256.html
+== tall--32px-auto--omitted-width-omitted-height.html ref-tall-lime32x384-aqua32x384.html
+== tall--32px-auto--omitted-width-omitted-height-viewbox.html ref-tall-lime32x256-aqua32x256.html
+== tall--32px-auto--omitted-width-percent-height.html ref-tall-lime32x384-aqua32x384.html
+== tall--32px-auto--omitted-width-percent-height-viewbox.html ref-tall-lime32x256-aqua32x256.html
+== tall--32px-auto--percent-width-nonpercent-height.html ref-tall-lime32x16-aqua32x16.html
+== tall--32px-auto--percent-width-nonpercent-height-viewbox.html ref-tall-lime32x256-aqua32x256.html
+== tall--32px-auto--percent-width-omitted-height.html ref-tall-lime32x384-aqua32x384.html
+== tall--32px-auto--percent-width-omitted-height-viewbox.html ref-tall-lime32x256-aqua32x256.html
+== tall--32px-auto--percent-width-percent-height.html ref-tall-lime32x384-aqua32x384.html
+== tall--32px-auto--percent-width-percent-height-viewbox.html ref-tall-lime32x256-aqua32x256.html
+
+== tall--auto-32px--nonpercent-width-nonpercent-height.html ref-tall-lime8x16-aqua8x16.html
+== tall--auto-32px--nonpercent-width-nonpercent-height-viewbox.html ref-tall-lime8x16-aqua8x16.html
+== tall--auto-32px--nonpercent-width-omitted-height.html ref-tall-lime8x16-aqua8x16.html
+== tall--auto-32px--nonpercent-width-omitted-height-viewbox.html ref-tall-lime2x16-aqua2x16.html
+== tall--auto-32px--nonpercent-width-percent-height.html ref-tall-lime8x16-aqua8x16.html
+== tall--auto-32px--nonpercent-width-percent-height-viewbox.html ref-tall-lime2x16-aqua2x16.html
+== tall--auto-32px--omitted-width-nonpercent-height.html ref-tall-lime256x16-aqua256x16.html
+== tall--auto-32px--omitted-width-nonpercent-height-viewbox.html ref-tall-lime2x16-aqua2x16.html
+== tall--auto-32px--omitted-width-omitted-height.html ref-tall-lime256x16-aqua256x16.html
+== tall--auto-32px--omitted-width-omitted-height-viewbox.html ref-tall-lime2x16-aqua2x16.html
+== tall--auto-32px--omitted-width-percent-height.html ref-tall-lime256x16-aqua256x16.html
+== tall--auto-32px--omitted-width-percent-height-viewbox.html ref-tall-lime2x16-aqua2x16.html
+== tall--auto-32px--percent-width-nonpercent-height.html ref-tall-lime256x16-aqua256x16.html
+== tall--auto-32px--percent-width-nonpercent-height-viewbox.html ref-tall-lime2x16-aqua2x16.html
+== tall--auto-32px--percent-width-omitted-height.html ref-tall-lime256x16-aqua256x16.html
+== tall--auto-32px--percent-width-omitted-height-viewbox.html ref-tall-lime2x16-aqua2x16.html
+== tall--auto-32px--percent-width-percent-height.html ref-tall-lime256x16-aqua256x16.html
+== tall--auto-32px--percent-width-percent-height-viewbox.html ref-tall-lime2x16-aqua2x16.html
+
+== tall--auto--nonpercent-width-nonpercent-height.html ref-tall-lime8x16-aqua8x16.html
+== tall--auto--nonpercent-width-nonpercent-height-viewbox.html ref-tall-lime8x16-aqua8x16.html
+== tall--auto--nonpercent-width-omitted-height.html ref-tall-lime8x384-aqua8x384.html
+== tall--auto--nonpercent-width-omitted-height-viewbox.html ref-tall-lime8x64-aqua8x64.html
+== tall--auto--nonpercent-width-percent-height.html ref-tall-lime8x384-aqua8x384.html
+== tall--auto--nonpercent-width-percent-height-viewbox.html ref-tall-lime8x64-aqua8x64.html
+== tall--auto--omitted-width-nonpercent-height.html ref-tall-lime256x16-aqua256x16.html
+== tall--auto--omitted-width-nonpercent-height-viewbox.html ref-tall-lime2x16-aqua2x16.html
+== tall--auto--omitted-width-omitted-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--auto--omitted-width-omitted-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+== tall--auto--omitted-width-percent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--auto--omitted-width-percent-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+== tall--auto--percent-width-nonpercent-height.html ref-tall-lime256x16-aqua256x16.html
+== tall--auto--percent-width-nonpercent-height-viewbox.html ref-tall-lime2x16-aqua2x16.html
+== tall--auto--percent-width-omitted-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--auto--percent-width-omitted-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+== tall--auto--percent-width-percent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--auto--percent-width-percent-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+
+== tall--contain--nonpercent-width-nonpercent-height.html ref-tall-lime192x384-aqua192x384.html
+== tall--contain--nonpercent-width-nonpercent-height-viewbox.html ref-tall-lime192x384-aqua192x384.html
+== tall--contain--nonpercent-width-omitted-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--contain--nonpercent-width-omitted-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+== tall--contain--nonpercent-width-percent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--contain--nonpercent-width-percent-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+== tall--contain--omitted-width-nonpercent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--contain--omitted-width-nonpercent-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+== tall--contain--omitted-width-omitted-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--contain--omitted-width-omitted-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+== tall--contain--omitted-width-percent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--contain--omitted-width-percent-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+== tall--contain--percent-width-nonpercent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--contain--percent-width-nonpercent-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+== tall--contain--percent-width-omitted-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--contain--percent-width-omitted-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+== tall--contain--percent-width-percent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--contain--percent-width-percent-height-viewbox.html ref-tall-lime48x384-aqua48x384.html
+
+# We smear the background image when scaling it in these two tests...
+fails == tall--cover--nonpercent-width-nonpercent-height.html ref-tall-lime256x512-aqua256x256.html
+fails == tall--cover--nonpercent-width-nonpercent-height-viewbox.html ref-tall-lime256x512-aqua256x256.html
+
+# ...but we don't in identical tests with image-rendering: -moz-crisp-edges.
+== tall--cover--nonpercent-width-nonpercent-height--crisp.html ref-tall-lime256x512-aqua256x256.html
+== tall--cover--nonpercent-width-nonpercent-height-viewbox--crisp.html ref-tall-lime256x512-aqua256x256.html
+
+== tall--cover--nonpercent-width-omitted-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--cover--nonpercent-width-omitted-height-viewbox.html ref-tall-lime256x768.html
+== tall--cover--nonpercent-width-percent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--cover--nonpercent-width-percent-height-viewbox.html ref-tall-lime256x768.html
+== tall--cover--omitted-width-nonpercent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--cover--omitted-width-nonpercent-height-viewbox.html ref-tall-lime256x768.html
+== tall--cover--omitted-width-omitted-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--cover--omitted-width-omitted-height-viewbox.html ref-tall-lime256x768.html
+== tall--cover--omitted-width-percent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--cover--omitted-width-percent-height-viewbox.html ref-tall-lime256x768.html
+== tall--cover--percent-width-nonpercent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--cover--percent-width-nonpercent-height-viewbox.html ref-tall-lime256x768.html
+== tall--cover--percent-width-omitted-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--cover--percent-width-omitted-height-viewbox.html ref-tall-lime256x768.html
+== tall--cover--percent-width-percent-height.html ref-tall-lime256x384-aqua256x384.html
+== tall--cover--percent-width-percent-height-viewbox.html ref-tall-lime256x768.html
+
+== wide--12px-auto--nonpercent-width-nonpercent-height.html ref-wide-lime12x24-aqua12x24.html
+== wide--12px-auto--nonpercent-width-nonpercent-height-viewbox.html ref-wide-lime12x24-aqua12x24.html
+== wide--12px-auto--nonpercent-width-omitted-height.html ref-wide-lime12x128-aqua12x128.html
+== wide--12px-auto--nonpercent-width-omitted-height-viewbox.html ref-wide-lime12x96-aqua12x96.html
+== wide--12px-auto--nonpercent-width-percent-height.html ref-wide-lime12x128-aqua12x128.html
+== wide--12px-auto--nonpercent-width-percent-height-viewbox.html ref-wide-lime12x96-aqua12x96.html
+== wide--12px-auto--omitted-width-nonpercent-height.html ref-wide-lime12x16-aqua12x16.html
+== wide--12px-auto--omitted-width-nonpercent-height-viewbox.html ref-wide-lime12x96-aqua12x96.html
+== wide--12px-auto--omitted-width-omitted-height.html ref-wide-lime12x128-aqua12x128.html
+== wide--12px-auto--omitted-width-omitted-height-viewbox.html ref-wide-lime12x96-aqua12x96.html
+== wide--12px-auto--omitted-width-percent-height.html ref-wide-lime12x128-aqua12x128.html
+== wide--12px-auto--omitted-width-percent-height-viewbox.html ref-wide-lime12x96-aqua12x96.html
+== wide--12px-auto--percent-width-nonpercent-height.html ref-wide-lime12x16-aqua12x16.html
+== wide--12px-auto--percent-width-nonpercent-height-viewbox.html ref-wide-lime12x96-aqua12x96.html
+== wide--12px-auto--percent-width-omitted-height.html ref-wide-lime12x128-aqua12x128.html
+== wide--12px-auto--percent-width-omitted-height-viewbox.html ref-wide-lime12x96-aqua12x96.html
+== wide--12px-auto--percent-width-percent-height.html ref-wide-lime12x128-aqua12x128.html
+== wide--12px-auto--percent-width-percent-height-viewbox.html ref-wide-lime12x96-aqua12x96.html
+
+== wide--auto-32px--nonpercent-width-nonpercent-height.html ref-wide-lime8x16-aqua8x16.html
+== wide--auto-32px--nonpercent-width-nonpercent-height-viewbox.html ref-wide-lime8x16-aqua8x16.html
+== wide--auto-32px--nonpercent-width-omitted-height.html ref-wide-lime8x16-aqua8x16.html
+== wide--auto-32px--nonpercent-width-omitted-height-viewbox.html ref-wide-lime2x16-aqua2x16.html
+== wide--auto-32px--nonpercent-width-percent-height.html ref-wide-lime8x16-aqua8x16.html
+== wide--auto-32px--nonpercent-width-percent-height-viewbox.html ref-wide-lime2x16-aqua2x16.html
+== wide--auto-32px--omitted-width-nonpercent-height.html ref-wide-lime768x16-aqua768x16.html
+== wide--auto-32px--omitted-width-nonpercent-height-viewbox.html ref-wide-lime2x16-aqua2x16.html
+== wide--auto-32px--omitted-width-omitted-height.html ref-wide-lime768x16-aqua768x16.html
+== wide--auto-32px--omitted-width-omitted-height-viewbox.html ref-wide-lime2x16-aqua2x16.html
+== wide--auto-32px--omitted-width-percent-height.html ref-wide-lime768x16-aqua768x16.html
+== wide--auto-32px--omitted-width-percent-height-viewbox.html ref-wide-lime2x16-aqua2x16.html
+== wide--auto-32px--percent-width-nonpercent-height.html ref-wide-lime768x16-aqua768x16.html
+== wide--auto-32px--percent-width-nonpercent-height-viewbox.html ref-wide-lime2x16-aqua2x16.html
+== wide--auto-32px--percent-width-omitted-height.html ref-wide-lime768x16-aqua768x16.html
+== wide--auto-32px--percent-width-omitted-height-viewbox.html ref-wide-lime2x16-aqua2x16.html
+== wide--auto-32px--percent-width-percent-height.html ref-wide-lime768x16-aqua768x16.html
+== wide--auto-32px--percent-width-percent-height-viewbox.html ref-wide-lime2x16-aqua2x16.html
+
+== wide--auto--nonpercent-width-nonpercent-height.html ref-wide-lime8x16-aqua8x16.html
+== wide--auto--nonpercent-width-nonpercent-height-viewbox.html ref-wide-lime8x16-aqua8x16.html
+== wide--auto--nonpercent-width-omitted-height.html ref-wide-lime8x128-aqua8x128.html
+== wide--auto--nonpercent-width-omitted-height-viewbox.html ref-wide-lime8x64-aqua8x64.html
+== wide--auto--nonpercent-width-percent-height.html ref-wide-lime8x128-aqua8x128.html
+== wide--auto--nonpercent-width-percent-height-viewbox.html ref-wide-lime8x64-aqua8x64.html
+== wide--auto--omitted-width-nonpercent-height.html ref-wide-lime768x16-aqua768x16.html
+== wide--auto--omitted-width-nonpercent-height-viewbox.html ref-wide-lime2x16-aqua2x16.html
+== wide--auto--omitted-width-omitted-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--auto--omitted-width-omitted-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+== wide--auto--omitted-width-percent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--auto--omitted-width-percent-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+== wide--auto--percent-width-nonpercent-height.html ref-wide-lime768x16-aqua768x16.html
+== wide--auto--percent-width-nonpercent-height-viewbox.html ref-wide-lime2x16-aqua2x16.html
+== wide--auto--percent-width-omitted-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--auto--percent-width-omitted-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+== wide--auto--percent-width-percent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--auto--percent-width-percent-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+
+== wide--contain--nonpercent-width-nonpercent-height.html ref-wide-lime64x128-aqua64x128.html
+== wide--contain--nonpercent-width-nonpercent-height-viewbox.html ref-wide-lime64x128-aqua64x128.html
+== wide--contain--nonpercent-width-omitted-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--contain--nonpercent-width-omitted-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+== wide--contain--nonpercent-width-percent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--contain--nonpercent-width-percent-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+== wide--contain--omitted-width-nonpercent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--contain--omitted-width-nonpercent-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+== wide--contain--omitted-width-omitted-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--contain--omitted-width-omitted-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+== wide--contain--omitted-width-percent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--contain--omitted-width-percent-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+== wide--contain--percent-width-nonpercent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--contain--percent-width-nonpercent-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+== wide--contain--percent-width-omitted-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--contain--percent-width-omitted-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+== wide--contain--percent-width-percent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--contain--percent-width-percent-height-viewbox.html ref-wide-lime16x128-aqua16x128.html
+
+== wide--cover--nonpercent-width-nonpercent-height.html ref-wide-lime768x256.html
+== wide--cover--nonpercent-width-nonpercent-height-viewbox.html ref-wide-lime768x256.html
+== wide--cover--nonpercent-width-omitted-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--cover--nonpercent-width-omitted-height-viewbox.html ref-wide-lime768x256.html
+== wide--cover--nonpercent-width-percent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--cover--nonpercent-width-percent-height-viewbox.html ref-wide-lime768x256.html
+== wide--cover--omitted-width-nonpercent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--cover--omitted-width-nonpercent-height-viewbox.html ref-wide-lime768x256.html
+== wide--cover--omitted-width-omitted-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--cover--omitted-width-omitted-height-viewbox.html ref-wide-lime768x256.html
+== wide--cover--omitted-width-percent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--cover--omitted-width-percent-height-viewbox.html ref-wide-lime768x256.html
+== wide--cover--percent-width-nonpercent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--cover--percent-width-nonpercent-height-viewbox.html ref-wide-lime768x256.html
+== wide--cover--percent-width-omitted-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--cover--percent-width-omitted-height-viewbox.html ref-wide-lime768x256.html
+== wide--cover--percent-width-percent-height.html ref-wide-lime768x128-aqua768x128.html
+== wide--cover--percent-width-percent-height-viewbox.html ref-wide-lime768x256.html
+
+== diagonal-percentage-vector-background.html diagonal-percentage-vector-background-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--nonpercent-width-nonpercent-height-viewbox.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for nonpercent-width-nonpercent-height-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(nonpercent-width-nonpercent-height-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--nonpercent-width-nonpercent-height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for nonpercent-width-nonpercent-height.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(nonpercent-width-nonpercent-height.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--nonpercent-width-omitted-height-viewbox.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for nonpercent-width-omitted-height-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(nonpercent-width-omitted-height-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--nonpercent-width-omitted-height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for nonpercent-width-omitted-height.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(nonpercent-width-omitted-height.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--nonpercent-width-percent-height-viewbox.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for nonpercent-width-percent-height-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(nonpercent-width-percent-height-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--nonpercent-width-percent-height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for nonpercent-width-percent-height.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(nonpercent-width-percent-height.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--omitted-width-nonpercent-height-viewbox.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for omitted-width-nonpercent-height-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(omitted-width-nonpercent-height-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--omitted-width-nonpercent-height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for omitted-width-nonpercent-height.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(omitted-width-nonpercent-height.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--omitted-width-omitted-height-viewbox.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for omitted-width-omitted-height-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(omitted-width-omitted-height-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--omitted-width-omitted-height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for omitted-width-omitted-height.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(omitted-width-omitted-height.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--omitted-width-percent-height-viewbox.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for omitted-width-percent-height-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(omitted-width-percent-height-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--omitted-width-percent-height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for omitted-width-percent-height.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(omitted-width-percent-height.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--percent-width-nonpercent-height-viewbox.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for percent-width-nonpercent-height-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(percent-width-nonpercent-height-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--percent-width-nonpercent-height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for percent-width-nonpercent-height.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(percent-width-nonpercent-height.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--percent-width-omitted-height-viewbox.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for percent-width-omitted-height-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(percent-width-omitted-height-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--percent-width-omitted-height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for percent-width-omitted-height.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(percent-width-omitted-height.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--percent-width-percent-height-viewbox.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for percent-width-percent-height-viewbox.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(percent-width-percent-height-viewbox.svg);
+  background-repeat: no-repeat;
+  background-size: 32px auto;
+}
+  </style>
+</head>
+<body>
+<div id="outer"><div id="inner"></div></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/backgrounds/vector/tall--32px-auto--percent-width-percent-height.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>tall background-size: 32px auto; for percent-width-percent-height.svg</title>
+  <style type="text/css">
+div
+{
+  width: 256px; height: 768px;
+}
+#outer
+{
+  border: 1px solid black;
+}
+#inner
+{
+  background-image: url(percent-width-percent-height.svg);
+  background-repeat: no-repeat;