Merge last green changeset on m-c to mozilla-inbound
authorMatt Brubeck <mbrubeck@mozilla.com>
Mon, 08 Aug 2011 14:21:41 -0700
changeset 74041 f37a51e43d5a94d5945682e177812b35991169cc
parent 74002 36989c74b287e7f7d132e3ecb80c02b54a88c6bd (current diff)
parent 74040 6030c9f7b3ca6aee5b87507743e40ededb87849b (diff)
child 74042 d7db60b35edc8044d7f9cfdf037a6705d940a498
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone8.0a1
Merge last green changeset on m-c to mozilla-inbound
browser/base/content/browser.xul
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
--- 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"/>
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
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
--- 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/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
@@ -5184,25 +5184,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)
@@ -5229,26 +5229,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();
@@ -6499,29 +6497,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;
         }
       }
     }
 
@@ -7902,18 +7898,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;
 }
 
@@ -8929,22 +8926,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!
@@ -9477,17 +9469,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);
@@ -9827,34 +9819,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,
@@ -9866,34 +9848,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
@@ -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/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/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/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/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/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');
--- 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/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/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"
new file mode 100644
--- /dev/null
+++ b/layout/reftests/native-theme/676387-1-ref.xul
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<window id="window676387-1-ref"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <hbox><button id="button" label="SUCCESS"/></hbox>
+</window>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/native-theme/676387-1.xul
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<window id="window676387-1"
+        class="reftest-wait"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        onload="var button = document.getElementById('button');
+                var r = button.getBoundingClientRect();
+                if (document.elementFromPoint(r.right, r.top) == button.parentNode)
+                  button.label = 'SUCCESS';
+                document.documentElement.className = '';">
+  <hbox><button id="button" label="FAIL"/></hbox>
+</window>
--- a/layout/reftests/native-theme/reftest.list
+++ b/layout/reftests/native-theme/reftest.list
@@ -73,8 +73,10 @@ skip-if(!winWidget) == scroll-thumb-mini
 
 == checkbox-dynamic-1.html checkbox-dynamic-1-ref.html
 
 # These tests have been written to test the overflow of the window widget
 # (bug 568825) but we can't test it on Windows and Cocoa because they have
 # animated progress bars.
 skip-if(cocoaWidget) skip-if(winWidget) == progress-overflow.html progress-overflow-ref.html
 skip-if(cocoaWidget) skip-if(winWidget) != progress-overflow-small.html progress-nobar.html
+
+== 676387-1.xul 676387-1-ref.xul
--- a/netwerk/mime/nsMimeTypes.h
+++ b/netwerk/mime/nsMimeTypes.h
@@ -61,16 +61,17 @@
 #define APPLICATION_GZIP                    "application/x-gzip"
 #define APPLICATION_GZIP2                   "application/gzip"
 #define APPLICATION_GZIP3                   "application/x-gunzip"
 #define APPLICATION_ZIP                     "application/zip"
 #define APPLICATION_HTTP_INDEX_FORMAT       "application/http-index-format"
 #define APPLICATION_ECMASCRIPT              "application/ecmascript"
 #define APPLICATION_JAVASCRIPT              "application/javascript"
 #define APPLICATION_XJAVASCRIPT             "application/x-javascript"
+#define APPLICATION_JSON                    "application/json"
 #define APPLICATION_NETSCAPE_REVOCATION     "application/x-netscape-revocation"
 #define APPLICATION_NS_PROXY_AUTOCONFIG     "application/x-ns-proxy-autoconfig"
 #define APPLICATION_NS_JAVASCRIPT_AUTOCONFIG        "application/x-javascript-config"
 #define APPLICATION_OCTET_STREAM            "application/octet-stream"
 #define APPLICATION_PGP                     "application/pgp"
 #define APPLICATION_PGP2                    "application/x-pgp-message"
 #define APPLICATION_POSTSCRIPT              "application/postscript"
 #define APPLICATION_PDF                     "application/pdf"
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -855,17 +855,17 @@ HttpChannelChild::CompleteRedirectSetup(
 NS_IMETHODIMP
 HttpChannelChild::OnRedirectVerifyCallback(nsresult result)
 {
   nsCOMPtr<nsIHttpChannel> newHttpChannel =
       do_QueryInterface(mRedirectChannelChild);
 
   if (newHttpChannel) {
     // Must not be called until after redirect observers called.
-    newHttpChannel->SetOriginalURI(mRedirectOriginalURI);
+    newHttpChannel->SetOriginalURI(mOriginalURI);
   }
 
   RequestHeaderTuples emptyHeaders;
   RequestHeaderTuples* headerTuples = &emptyHeaders;
 
   nsCOMPtr<nsIHttpChannelChild> newHttpChannelChild =
       do_QueryInterface(mRedirectChannelChild);
   if (newHttpChannelChild && NS_SUCCEEDED(result)) {
--- a/netwerk/protocol/http/HttpChannelChild.h
+++ b/netwerk/protocol/http/HttpChannelChild.h
@@ -154,17 +154,16 @@ protected:
   bool RecvDeleteSelf();
 
   bool GetAssociatedContentSecurity(nsIAssociatedContentSecurity** res = nsnull);
   virtual void DoNotifyListenerCleanup();
 
 private:
   RequestHeaderTuples mRequestHeaders;
   nsCOMPtr<nsIChildChannel> mRedirectChannelChild;
-  nsCOMPtr<nsIURI> mRedirectOriginalURI;
   nsCOMPtr<nsISupports> mSecurityInfo;
 
   PRPackedBool mIsFromCache;
   PRPackedBool mCacheEntryAvailable;
   PRUint32     mCacheExpirationTime;
   nsCString    mCachedCharset;
 
   // If ResumeAt is called before AsyncOpen, we need to send extra data upstream
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -1352,16 +1352,17 @@ DetermineParseMode(const nsString& aBuff
                    eParserDocType& aDocType, const nsACString& aMimeType)
 {
   if (aMimeType.EqualsLiteral(TEXT_HTML)) {
     DetermineHTMLParseMode(aBuffer, aParseMode, aDocType);
   } else if (aMimeType.EqualsLiteral(TEXT_PLAIN) ||
              aMimeType.EqualsLiteral(TEXT_CSS) ||
              aMimeType.EqualsLiteral(APPLICATION_JAVASCRIPT) ||
              aMimeType.EqualsLiteral(APPLICATION_XJAVASCRIPT) ||
+             aMimeType.EqualsLiteral(APPLICATION_JSON) ||
              aMimeType.EqualsLiteral(TEXT_ECMASCRIPT) ||
              aMimeType.EqualsLiteral(APPLICATION_ECMASCRIPT) ||
              aMimeType.EqualsLiteral(TEXT_JAVASCRIPT)) {
     aDocType = ePlainText;
     aParseMode = eDTDMode_quirks;
   } else { // Some form of XML
     aDocType = eXML;
     aParseMode = eDTDMode_full_standards;
new file mode 100644
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/test_bug667533.html
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=667533
+-->
+<head>
+  <title>Test for Bug 667533</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=667533">Mozilla Bug 667533</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<script type="application/javascript">
+SimpleTest.waitForExplicitFinish();
+
+function loaded(iframe) {
+  is(iframe.contentWindow.location.href, iframe.src, "should load correct URL");
+  is(iframe.contentDocument.body.textContent, '{"<p>Hello</p>": null}', "application/json should be treated as text");
+  SimpleTest.finish();
+}
+</script>
+<iframe src="data:application/json,{&quot;<p>Hello</p>&quot;:%20null}" onload="loaded(this);"></iframe>
+</body>
+</html>
--- a/toolkit/components/satchel/nsFormFillController.h
+++ b/toolkit/components/satchel/nsFormFillController.h
@@ -50,16 +50,21 @@
 #include "nsISupportsArray.h"
 #include "nsDataHashtable.h"
 #include "nsIDocShell.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMHTMLInputElement.h"
 #include "nsILoginManager.h"
 #include "nsIMutationObserver.h"
 
+// X.h defines KeyPress
+#ifdef KeyPress
+#undef KeyPress
+#endif
+
 class nsFormHistory;
 
 class nsFormFillController : public nsIFormFillController,
                              public nsIAutoCompleteInput,
                              public nsIAutoCompleteSearch,
                              public nsIDOMEventListener,
                              public nsIMutationObserver
 {
--- a/toolkit/content/widgets/toolbarbutton.xml
+++ b/toolkit/content/widgets/toolbarbutton.xml
@@ -61,17 +61,17 @@
 
     <content>
       <children includes="observes|template|menupopup|panel|tooltip"/>
       <xul:toolbarbutton class="box-inherit toolbarbutton-menubutton-button"
                          anonid="button" flex="1" allowevents="true"
                          xbl:inherits="disabled,crop,image,label,accesskey,command,
                                        align,dir,pack,orient"/>
       <xul:dropmarker type="menu-button" class="toolbarbutton-menubutton-dropmarker"
-                      xbl:inherits="align,dir,pack,orient,disabled,label"/>
+                      xbl:inherits="align,dir,pack,orient,disabled,label,open"/>
     </content>
   </binding>
 
   <binding id="toolbarbutton-image"
            extends="chrome://global/content/bindings/toolbarbutton.xml#toolbarbutton">
     <content>
       <xul:image class="toolbarbutton-icon" xbl:inherits="src=image"/>
     </content>
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -147,16 +147,17 @@ DEFINES += -DIMPL_XREAPI
 EXTRA_DSO_LDOPTS += $(NSPR_LIBS) $(MOZALLOC_LIB)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 CXXFLAGS	+= $(TK_CFLAGS)
 OS_LIBS += \
 	-framework SystemConfiguration \
 	-framework QuickTime \
 	-framework IOKit \
+	-F/System/Library/PrivateFrameworks -framework CoreUI \
 	$(TK_LIBS) \
 	$(NULL)
 endif
 
 ifeq ($(OS_ARCH),Darwin)
 ifdef MOZ_SYDNEYAUDIO
 EXTRA_DSO_LDOPTS += \
 	-framework Carbon \
--- a/toolkit/themes/pinstripe/global/console/console.css
+++ b/toolkit/themes/pinstripe/global/console/console.css
@@ -198,29 +198,14 @@ toolbarseparator {
 
 #ToolbarMode toolbarbutton > .toolbarbutton-icon {
   display: none;
 }
 
 #Console\:clear {
   -moz-box-orient: vertical;
   -moz-box-align: center;
+  -moz-appearance: toolbarbutton;
   font: menu;
   text-shadow: @loweredShadow@;
   margin: 4px 0 9px;
-  padding: 0 4px;
-  border: 1px solid @toolbarbuttonBorderColor@;
-  border-radius: @toolbarbuttonCornerRadius@;
-  box-shadow: @loweredShadow@;
-  background: @toolbarbuttonBackground@;
-  background-origin: border-box;
+  padding: 0 1px;
 }
-
-#Console\:clear:active:hover {
-  background: @toolbarbuttonPressedBackgroundColor@;
-  text-shadow: @loweredShadow@;
-  box-shadow: @toolbarbuttonPressedInnerShadow@, @loweredShadow@;
-}
-
-#Console\:clear:-moz-window-inactive {
-  border-color: @toolbarbuttonInactiveBorderColor@;
-  background-image: @toolbarbuttonInactiveBackgroundImage@;
-}
--- a/toolkit/themes/pinstripe/global/shared.inc
+++ b/toolkit/themes/pinstripe/global/shared.inc
@@ -19,17 +19,12 @@
 %define sidebarItemFocusedBackground -moz-linear-gradient(top, #6494D4, #2559AC) repeat-x
 %define sidebarItemGraphiteBorderTop 1px solid #97A4B1
 %define sidebarItemGraphiteBackground -moz-linear-gradient(top, #AAB7C4, #8393A4) repeat-x
 %define sidebarItemGraphiteFocusedBorderTop 1px solid #6B798D
 %define sidebarItemGraphiteFocusedBackground -moz-linear-gradient(top, #8293A6, #425972) repeat-x
 %define sidebarItemInactiveBorderTop 1px solid #979797
 %define sidebarItemInactiveBackground -moz-linear-gradient(top, #B4B4B4, #8A8A8A) repeat-x
 
-%define toolbarbuttonBorderColor rgba(59, 59, 59, 0.9)
 %define toolbarbuttonCornerRadius 3px
 %define toolbarbuttonBackground -moz-linear-gradient(top, #FFF, #ADADAD) repeat-x
-%define toolbarbuttonFocusedBorderColorAqua rgba(102, 122, 155, 0.9)
-%define toolbarbuttonFocusedBorderColorGraphite rgba(59, 59, 59, 0.7)
 %define toolbarbuttonPressedInnerShadow inset rgba(0, 0, 0, 0.3) 0 -6px 10px, inset #000 0 1px 3px, inset rgba(0, 0, 0, 0.2) 0 1px 3px
-%define toolbarbuttonPressedBackgroundColor #B5B5B5
 %define toolbarbuttonInactiveBorderColor rgba(146, 146, 146, 0.84)
-%define toolbarbuttonInactiveBackgroundImage -moz-linear-gradient(top, #FFF, #CCC)
--- a/toolkit/themes/pinstripe/global/toolbarbutton.css
+++ b/toolkit/themes/pinstripe/global/toolbarbutton.css
@@ -81,23 +81,25 @@ toolbarbutton[checked="true"] {
 
 /* ::::: toolbarbutton menu ::::: */
 
 .toolbarbutton-menu-dropmarker {
   -moz-appearance: none !important;
   border: none !important;
   background-color: transparent !important;
   list-style-image: url("chrome://global/skin/arrow/arrow-dn.png");
-  padding: 0 0 0 2px;
+  padding: 0;
+  -moz-padding-start: 2px;
   width: auto;
 }
 
 .toolbarbutton-menu-dropmarker[disabled="true"] {
   list-style-image: url("chrome://global/skin/arrow/arrow-dn-dis.png");
-  padding: 0 0 0 2px !important;
+  padding: 0;
+  -moz-padding-start: 2px;
 }
 
 /* ::::: toolbarbutton menu-button ::::: */
 
 toolbarbutton[type="menu-button"] {
   -moz-box-align: stretch;
   -moz-box-orient: horizontal !important;
 }
@@ -117,17 +119,17 @@ toolbarbutton[type="menu-button"][disabl
   -moz-box-pack: center;
   -moz-box-orient: vertical;
   text-shadow: inherit;
 }
 
 /* .......... dropmarker .......... */
 
 .toolbarbutton-menubutton-dropmarker {
-  -moz-appearance: none !important;
+  -moz-appearance: none;
   border: none;
   background-color: transparent !important;
   list-style-image: url("chrome://global/skin/arrow/arrow-dn.png");
   width: auto;
   padding: 0;
 }
 
 .toolbarbutton-menubutton-dropmarker[disabled="true"] {
--- a/toolkit/themes/pinstripe/global/viewbuttons.css
+++ b/toolkit/themes/pinstripe/global/viewbuttons.css
@@ -41,90 +41,28 @@
 }
 
 .viewGroupWrapper {
   -moz-box-align: center;
   -moz-box-pack: center;
 }
 
 #viewGroup {
-  background-color: rgba(0, 0, 0, 0.55);
-  padding: 1px;
-  border-radius: @toolbarbuttonCornerRadius@;
-  box-shadow: @loweredShadow@;
   margin: 4px 0 9px;
 }
 
 #viewGroup > radio,
 #viewGroup > toolbarbutton {
   -moz-box-orient: vertical;
   -moz-box-align: center;
-  -moz-appearance: none;
+  -moz-appearance: toolbarbutton;
   font: menu;
   text-shadow: @loweredShadow@;
   margin: 0;
-  padding: 0 4px;
-  border: none;
-  border-left: 1px solid rgba(0, 0, 0, 0.8);
-  background: @toolbarbuttonBackground@;
-}
-
-#viewGroup > radio:active:hover,
-#viewGroup > toolbarbutton:active:hover {
-  background: @toolbarbuttonPressedBackgroundColor@;
-  text-shadow: @loweredShadow@;
-  box-shadow: @toolbarbuttonPressedInnerShadow@;
+  padding: 0 1px;
+  height: 22px;
 }
 
 #viewGroup > radio[selected=true],
 #viewGroup > toolbarbutton[checked=true] {
   color: #FFF !important;
   text-shadow: rgba(0, 0, 0, 0.4) 0 1px;
-  background: #606060;
-  box-shadow: inset #2A2A2A 0 3px 3.5px;
 }
-
-#viewGroup > radio[selected=true]:active:hover,
-#viewGroup > toolbarbutton[checked=true]:active:hover {
-  background-color: #4E4E4E;
-  box-shadow: inset #1c1c1c 0 3px 3.5px;
-}
-
-#viewGroup:-moz-window-inactive {
-  background-color: rgba(0, 0, 0, 0.25);
-}
-
-#viewGroup > radio:-moz-window-inactive,
-#viewGroup > toolbarbutton:-moz-window-inactive {
-  border-color: rgba(0, 0, 0, 0.4);
-  background-image: @toolbarbuttonInactiveBackgroundImage@;
-}
-
-#viewGroup > radio[selected=true]:-moz-window-inactive,
-#viewGroup > toolbarbutton[checked=true]:-moz-window-inactive {
-  background: #8E8E8E;
-  box-shadow: inset rgba(0, 0, 0, 0.5) 0 3px 3.5px;
-}
-
-#viewGroup > radio:-moz-locale-dir(ltr):first-child,
-#viewGroup > radio:-moz-locale-dir(ltr)[first-visible],
-#viewGroup > radio:-moz-locale-dir(rtl):last-child,
-#viewGroup > radio:-moz-locale-dir(rtl)[last-visible],
-#viewGroup > toolbarbutton:-moz-locale-dir(ltr):first-child,
-#viewGroup > toolbarbutton:-moz-locale-dir(ltr)[first-visible],
-#viewGroup > toolbarbutton:-moz-locale-dir(rtl):last-child,
-#viewGroup > toolbarbutton:-moz-locale-dir(rtl)[last-visible] {
-  border-top-left-radius: 2px;
-  border-bottom-left-radius: 2px;
-  border-left: none !important;
-}
-
-#viewGroup > radio:-moz-locale-dir(ltr):last-child,
-#viewGroup > radio:-moz-locale-dir(ltr)[last-visible],
-#viewGroup > radio:-moz-locale-dir(rtl):first-child,
-#viewGroup > radio:-moz-locale-dir(rtl)[first-visible],
-#viewGroup > toolbarbutton:-moz-locale-dir(ltr):last-child,
-#viewGroup > toolbarbutton:-moz-locale-dir(ltr)[last-visible],
-#viewGroup > toolbarbutton:-moz-locale-dir(rtl):first-child,
-#viewGroup > toolbarbutton:-moz-locale-dir(rtl)[first-visible] {
-  border-top-right-radius: 2px;
-  border-bottom-right-radius: 2px;
-}
--- a/toolkit/themes/pinstripe/mozapps/downloads/downloads.css
+++ b/toolkit/themes/pinstripe/mozapps/downloads/downloads.css
@@ -106,40 +106,14 @@ richlistitem[type="download"] button {
 
 #search {
   -moz-box-pack: end;
   -moz-padding-end: 4px;
   -moz-appearance: statusbar;
 }
 
 #clearListButton {
-  -moz-appearance: none;
+  -moz-appearance: toolbarbutton;
   min-height: 18px;
   min-width: 0;
   margin: 0 6px;
-  padding: 0 2px;
   text-shadow: @loweredShadow@;
-  border: 1px solid @toolbarbuttonBorderColor@;
-  border-radius: @toolbarbuttonCornerRadius@;
-  box-shadow: @loweredShadow@;
-  background: @toolbarbuttonBackground@;
-  background-origin: border-box;
-}
-
-#clearListButton:hover:active:not([disabled="true"]) {
-  background: @toolbarbuttonPressedBackgroundColor@;
-  text-shadow: @loweredShadow@;
-  box-shadow: @toolbarbuttonPressedInnerShadow@, @loweredShadow@;
 }
-
-#clearListButton:-moz-focusring {
-  border-color: @toolbarbuttonFocusedBorderColorAqua@;
-  box-shadow: @focusRingShadow@;
-}
-
-#clearListButton:-moz-system-metric(mac-graphite-theme):-moz-focusring {
-  border-color: @toolbarbuttonFocusedBorderColorGraphite@;
-}
-
-#clearListButton:-moz-window-inactive {
-  border-color: @toolbarbuttonInactiveBorderColor@;
-  background-image: @toolbarbuttonInactiveBackgroundImage@;
-}
--- a/toolkit/themes/pinstripe/mozapps/update/updates.css
+++ b/toolkit/themes/pinstripe/mozapps/update/updates.css
@@ -34,46 +34,21 @@ wizardpage {
 
 /* Don't use top margin - it can cause a scrollbar on the incompatible page */
 .wizard-buttons {
   padding: 0;
   -moz-appearance: statusbar;
 }
 
 .wizard-buttons button {
-  -moz-appearance: none;
+  -moz-appearance: toolbarbutton;
   min-height: 22px;
   margin: 0 6px;
-  padding: 0 2px;
-  text-shadow: @loweredShadow@;
-  border: 1px solid @toolbarbuttonBorderColor@;
-  border-radius: @toolbarbuttonCornerRadius@;
-  box-shadow: @loweredShadow@;
-  background: @toolbarbuttonBackground@;
-  background-origin: border-box;
-}
-
-.wizard-buttons button:hover:active:not([disabled="true"]) {
-  background: @toolbarbuttonPressedBackgroundColor@;
+  padding: 0;
   text-shadow: @loweredShadow@;
-  box-shadow: @toolbarbuttonPressedInnerShadow@, @loweredShadow@;
-}
-
-.wizard-buttons button:-moz-focusring {
-  border-color: @toolbarbuttonFocusedBorderColorAqua@;
-  box-shadow: @focusRingShadow@;
-}
-
-.wizard-buttons button:-moz-system-metric(mac-graphite-theme):-moz-focusring {
-  border-color: @toolbarbuttonFocusedBorderColorGraphite@;
-}
-
-.wizard-buttons button:-moz-window-inactive {
-  border-color: @toolbarbuttonInactiveBorderColor@;
-  background-image: @toolbarbuttonInactiveBackgroundImage@;
 }
 
 .loadingBox {
   padding: 3px 5px 3px 5px;
 }
 
 .remoteLoadingThrobber {
   margin-top: 3px;
--- a/widget/src/cocoa/Makefile.in
+++ b/widget/src/cocoa/Makefile.in
@@ -138,9 +138,10 @@ export::
 LOCAL_INCLUDES	= \
 	$(TK_CFLAGS) \
 	-I$(srcdir)/../xpwidgets \
 	$(NULL)
 
 LDFLAGS	+= \
 	-framework QuickTime \
 	-framework IOKit \
+	-F/System/Library/PrivateFrameworks -framework CoreUI \
 	$(NULL)
--- a/widget/src/cocoa/nsChildView.h
+++ b/widget/src/cocoa/nsChildView.h
@@ -289,26 +289,26 @@ extern "C" long TSMProcessRawKeyEvent(Ev
 @end
 
 class ChildViewMouseTracker {
 
 public:
 
   static void MouseMoved(NSEvent* aEvent);
   static void OnDestroyView(ChildView* aView);
+  static void OnDestroyWindow(NSWindow* aWindow);
   static BOOL WindowAcceptsEvent(NSWindow* aWindow, NSEvent* aEvent,
                                  ChildView* aView, BOOL isClickThrough = NO);
+  static void MouseExitedWindow(NSEvent* aEvent);
+  static void MouseEnteredWindow(NSEvent* aEvent);
   static void ReEvaluateMouseEnterState(NSEvent* aEvent = nil);
   static ChildView* ViewForEvent(NSEvent* aEvent);
 
   static ChildView* sLastMouseEventView;
-
-private:
-
-  static NSWindow* WindowForEvent(NSEvent* aEvent);
+  static NSWindow* sWindowUnderMouse;
 };
 
 //-------------------------------------------------------------------------
 //
 // nsChildView
 //
 //-------------------------------------------------------------------------
 
--- a/widget/src/cocoa/nsChildView.mm
+++ b/widget/src/cocoa/nsChildView.mm
@@ -107,37 +107,30 @@ using namespace mozilla;
 #ifdef PR_LOGGING
 PRLogModuleInfo* sCocoaLog = nsnull;
 #endif
 
 extern "C" {
   CG_EXTERN void CGContextResetCTM(CGContextRef);
   CG_EXTERN void CGContextSetCTM(CGContextRef, CGAffineTransform);
   CG_EXTERN void CGContextResetClip(CGContextRef);
-
-  // CGSPrivate.h
-  typedef NSInteger CGSConnection;
-  typedef NSInteger CGSWindow;
-  extern CGSConnection _CGSDefaultConnection();
-  extern CGError CGSGetScreenRectForWindow(const CGSConnection cid, CGSWindow wid, CGRect *outRect);
-  extern CGError CGSGetWindowLevel(const CGSConnection cid, CGSWindow wid, CGWindowLevel *level);
-  extern CGError CGSGetWindowAlpha(const CGSConnection cid, const CGSWindow wid, float* alpha);
 }
 
 // defined in nsMenuBarX.mm
 extern NSMenu* sApplicationMenu; // Application menu shared by all menubars
 
 // these are defined in nsCocoaWindow.mm
 extern PRBool gConsumeRollupEvent;
 
 PRBool gChildViewMethodsSwizzled = PR_FALSE;
 
 extern nsISupportsArray *gDraggedTransferables;
 
 ChildView* ChildViewMouseTracker::sLastMouseEventView = nil;
+NSWindow* ChildViewMouseTracker::sWindowUnderMouse = nil;
 
 #ifdef INVALIDATE_DEBUGGING
 static void blinkRect(Rect* r);
 static void blinkRgn(RgnHandle rgn);
 #endif
 
 nsIRollupListener * gRollupListener = nsnull;
 nsIMenuRollup     * gMenuRollup = nsnull;
@@ -1231,16 +1224,34 @@ nsresult nsChildView::SynthesizeNativeMo
                                        context:nil
                                    eventNumber:0
                                     clickCount:1
                                       pressure:0.0];
 
   if (!event)
     return NS_ERROR_FAILURE;
 
+  if ([[mView window] isKindOfClass:[BaseWindow class]]) {
+    // Tracking area events don't end up in their tracking areas when sent
+    // through [NSApp sendEvent:], so pass them directly to the right methods.
+    BaseWindow* window = (BaseWindow*)[mView window];
+    if (aNativeMessage == NSMouseEntered) {
+      [window mouseEntered:event];
+      return NS_OK;
+    }
+    if (aNativeMessage == NSMouseExited) {
+      [window mouseExited:event];
+      return NS_OK;
+    }
+    if (aNativeMessage == NSMouseMoved) {
+      [window mouseMoved:event];
+      return NS_OK;
+    }
+  }
+
   [NSApp sendEvent:event];
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 // First argument has to be an NSMenu representing the application's top-level
 // menu bar. The returned item is *not* retained.
@@ -3229,21 +3240,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
   }
 
   event.exit = aType;
 
   nsEventStatus status; // ignored
   mGeckoChild->DispatchEvent(&event, status);
 }
 
-- (void)mouseMoved:(NSEvent*)aEvent
-{
-  ChildViewMouseTracker::MouseMoved(aEvent);
-}
-
 - (void)handleMouseMoved:(NSEvent*)theEvent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (!mGeckoChild)
     return;
 
   nsMouseEvent geckoEvent(PR_TRUE, NS_MOUSE_MOVE, nsnull, nsMouseEvent::eReal);
@@ -4751,18 +4757,43 @@ NSEvent* gLastDragMouseDownEvent = nil;
 
 @end
 
 #pragma mark -
 
 void
 ChildViewMouseTracker::OnDestroyView(ChildView* aView)
 {
-  if (sLastMouseEventView == aView)
+  if (sLastMouseEventView == aView) {
     sLastMouseEventView = nil;
+  }
+}
+
+void
+ChildViewMouseTracker::OnDestroyWindow(NSWindow* aWindow)
+{
+  if (sWindowUnderMouse == aWindow) {
+    sWindowUnderMouse = nil;
+  }
+}
+
+void
+ChildViewMouseTracker::MouseEnteredWindow(NSEvent* aEvent)
+{
+  sWindowUnderMouse = [aEvent window];
+  ReEvaluateMouseEnterState(aEvent);
+}
+
+void
+ChildViewMouseTracker::MouseExitedWindow(NSEvent* aEvent)
+{
+  if (sWindowUnderMouse == [aEvent window]) {
+    sWindowUnderMouse = nil;
+    ReEvaluateMouseEnterState(aEvent);
+  }
 }
 
 void
 ChildViewMouseTracker::ReEvaluateMouseEnterState(NSEvent* aEvent)
 {
   ChildView* oldView = sLastMouseEventView;
   sLastMouseEventView = ViewForEvent(aEvent);
   if (sLastMouseEventView != oldView) {
@@ -4776,136 +4807,39 @@ ChildViewMouseTracker::ReEvaluateMouseEn
     }
     [sLastMouseEventView sendMouseEnterOrExitEvent:aEvent enter:YES type:type];
   }
 }
 
 void
 ChildViewMouseTracker::MouseMoved(NSEvent* aEvent)
 {
-  ReEvaluateMouseEnterState(aEvent);
+  MouseEnteredWindow(aEvent);
   [sLastMouseEventView handleMouseMoved:aEvent];
 }
 
 ChildView*
 ChildViewMouseTracker::ViewForEvent(NSEvent* aEvent)
 {
-  NSWindow* window = WindowForEvent(aEvent);
+  NSWindow* window = sWindowUnderMouse;
   if (!window)
     return nil;
 
   NSPoint windowEventLocation = nsCocoaUtils::EventLocationForWindow(aEvent, window);
   NSView* view = [[[window contentView] superview] hitTest:windowEventLocation];
-  NS_ASSERTION(view, "How can the mouse be over a window but not over a view in that window?");
   if (![view isKindOfClass:[ChildView class]])
     return nil;
 
   ChildView* childView = (ChildView*)view;
   // If childView is being destroyed return nil.
   if (![childView widget])
     return nil;
   return WindowAcceptsEvent(window, aEvent, childView) ? childView : nil;
 }
 
-static CGWindowLevel kDockWindowLevel = 0;
-static CGWindowLevel kPopupWindowLevel = 0;
-
-static BOOL WindowNumberIsUnderPoint(NSInteger aWindowNumber, NSPoint aPoint) {
-  NSWindow* window = [NSApp windowWithWindowNumber:aWindowNumber];
-  if (window) {
-    // This is one of our own windows.
-    return NSMouseInRect(aPoint, [window frame], NO);
-  }
-
-  CGSConnection cid = _CGSDefaultConnection();
-
-  if (!kDockWindowLevel) {
-    // These constants are in fact function calls, so cache them.
-    kDockWindowLevel = kCGDockWindowLevel;
-    kPopupWindowLevel = kCGPopUpMenuWindowLevel;
-  }
-
-  // Some things put transparent windows on top of everything. Ignore them.
-  CGWindowLevel level;
-  if ((kCGErrorSuccess == CGSGetWindowLevel(cid, aWindowNumber, &level)) &&
-      (level == kDockWindowLevel ||     // Transparent layer, spanning the whole screen
-       level > kPopupWindowLevel))      // Snapz Pro X while recording a screencast
-    return false;
-
-  // Ignore transparent windows.
-  float alpha;
-  if ((kCGErrorSuccess == CGSGetWindowAlpha(cid, aWindowNumber, &alpha)) &&
-      alpha < 0.1f)
-    return false;
-
-  CGRect rect;
-  if (kCGErrorSuccess != CGSGetScreenRectForWindow(cid, aWindowNumber, &rect))
-    return false;
-
-  CGPoint point = { aPoint.x, nsCocoaUtils::FlippedScreenY(aPoint.y) };
-  return CGRectContainsPoint(rect, point);
-}
-
-// Find the window number of the window under the given point, regardless of
-// which app the window belongs to. Returns 0 if no window was found.
-static NSInteger WindowNumberAtPoint(NSPoint aPoint) {
-  // We'd like to use the new windowNumberAtPoint API on 10.6 but we can't rely
-  // on it being up-to-date. For example, if we've just opened a window,
-  // windowNumberAtPoint might not know about it yet, so we'd send events to the
-  // wrong window. See bug 557986.
-  // So we'll have to find the right window manually by iterating over all
-  // windows on the screen and testing whether the mouse is inside the window's
-  // rect. We do this using private CGS functions.
-  // Another way of doing it would be to use tracking rects, but those are
-  // view-controlled, so they need to be reset whenever an NSView changes its
-  // size or position, which is expensive. See bug 300904 comment 20.
-  // A problem with using the CGS functions is that we only look at the windows'
-  // rects, not at the transparency of the actual pixel the mouse is over. This
-  // means that we won't treat transparent pixels as transparent to mouse
-  // events, which is a disadvantage over using tracking rects and leads to the
-  // crummy window level workarounds in WindowNumberIsUnderPoint.
-  // But speed is more important.
-
-  // Get the window list.
-  NSInteger windowCount;
-  NSCountWindows(&windowCount);
-  NSInteger* windowList = (NSInteger*)malloc(sizeof(NSInteger) * windowCount);
-  if (!windowList)
-    return nil;
-
-  // The list we get back here is in order from front to back.
-  NSWindowList(windowCount, windowList);
-  for (NSInteger i = 0; i < windowCount; i++) {
-    NSInteger windowNumber = windowList[i];
-    if (WindowNumberIsUnderPoint(windowNumber, aPoint)) {
-      free(windowList);
-      return windowNumber;
-    }
-  }
-
-  free(windowList);
-  return 0;
-}
-
-// Find Gecko window under the mouse. Returns nil if the mouse isn't over
-// any of our windows.
-NSWindow*
-ChildViewMouseTracker::WindowForEvent(NSEvent* anEvent)
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
-
-  NSPoint screenPoint = nsCocoaUtils::ScreenLocationForEvent(anEvent);
-  NSInteger windowNumber = WindowNumberAtPoint(screenPoint);
-
-  // This will return nil if windowNumber belongs to a window that we don't own.
-  return [NSApp windowWithWindowNumber:windowNumber];
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
-}
-
 BOOL
 ChildViewMouseTracker::WindowAcceptsEvent(NSWindow* aWindow, NSEvent* aEvent,
                                           ChildView* aView, BOOL aIsClickThrough)
 {
   // Right mouse down events may get through to all windows, even to a top level
   // window with an open sheet.
   if (!aWindow || [aEvent type] == NSRightMouseDown)
     return YES;
--- a/widget/src/cocoa/nsCocoaWindow.h
+++ b/widget/src/cocoa/nsCocoaWindow.h
@@ -76,29 +76,37 @@ typedef struct _nsCocoaWindowList {
 
   // Shadow
   BOOL mScheduledShadowInvalidation;
 
   // DPI cache. Getting the physical screen size (CGDisplayScreenSize)
   // is ridiculously slow, so we cache it in the toplevel window for all
   // descendants to use.
   float mDPI;
+
+  NSTrackingArea* mTrackingArea;
 }
 
 - (void)importState:(NSDictionary*)aState;
 - (NSMutableDictionary*)exportState;
 - (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
 - (BOOL)drawsContentsIntoWindowFrame;
 - (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive;
 - (NSColor*)titlebarColorForActiveWindow:(BOOL)aActive;
 
 - (void)deferredInvalidateShadow;
 - (void)invalidateShadow;
 - (float)getDPI;
 
+- (void)mouseEntered:(NSEvent*)aEvent;
+- (void)mouseExited:(NSEvent*)aEvent;
+- (void)mouseMoved:(NSEvent*)aEvent;
+- (void)updateTrackingArea;
+- (NSView*)trackingAreaView;
+
 @end
 
 @interface NSWindow (Undocumented)
 
 // If a window has been explicitly removed from the "window cache" (to
 // deactivate it), it's sometimes necessary to "reset" it to reactivate it
 // (and put it back in the "window cache").  One way to do this, which Apple
 // often uses, is to set the "window number" to '-1' and then back to its
@@ -288,18 +296,16 @@ public:
     nsMenuBarX *GetMenuBar();
 
     // nsIKBStateControl interface
     NS_IMETHOD ResetInputState();
     
     NS_IMETHOD BeginSecureKeyboardInput();
     NS_IMETHOD EndSecureKeyboardInput();
 
-    static void UnifiedShading(void* aInfo, const CGFloat* aIn, CGFloat* aOut);
-
     void SetPopupWindowLevel();
 
     PRBool IsChildInFailingLeftClickThrough(NSView *aChild);
     PRBool ShouldFocusPlugin();
 
     NS_IMETHOD         ReparentNativeWidget(nsIWidget* aNewParent);
 protected:
 
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -637,32 +637,30 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool
       // this sheet can be displayed. Leave the parent mSheetNeedsShow alone,
       // that is only used to handle sibling sheet contention. The parent will
       // return once there are no more child sheets.
       PRBool parentIsSheet = PR_FALSE;
       if (NS_SUCCEEDED(piParentWidget->GetIsSheet(&parentIsSheet)) &&
           parentIsSheet) {
         piParentWidget->GetSheetWindowParent(&topNonSheetWindow);
         [NSApp endSheet:nativeParentWindow];
-        [nativeParentWindow setAcceptsMouseMovedEvents:NO];
       }
 
       nsCocoaWindow* sheetShown = nsnull;
       if (NS_SUCCEEDED(piParentWidget->GetChildSheet(PR_TRUE, &sheetShown)) &&
           (!sheetShown || sheetShown == this)) {
         // If this sheet is already the sheet actually being shown, don't
         // tell it to show again. Otherwise the number of calls to
         // [NSApp beginSheet...] won't match up with [NSApp endSheet...].
         if (![mWindow isVisible]) {
           mSheetNeedsShow = PR_FALSE;
           mSheetWindowParent = topNonSheetWindow;
           // Only set contextInfo if our parent isn't a sheet.
           NSWindow* contextInfo = parentIsSheet ? nil : mSheetWindowParent;
           [TopLevelWindowData deactivateInWindow:mSheetWindowParent];
-          [mWindow setAcceptsMouseMovedEvents:YES];
           [NSApp beginSheet:mWindow
              modalForWindow:mSheetWindowParent
               modalDelegate:mDelegate
              didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
                 contextInfo:contextInfo];
           [TopLevelWindowData activateInWindow:mWindow];
           SendSetZLevelEvent();
         }
@@ -679,17 +677,16 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool
       // for it to receive any mouse events aside from mouse-moved events
       // (because it was removed from the "window cache" when it was hidden
       // -- see below).  Setting the window number to -1 and then back to its
       // original value seems to accomplish this.  The idea was "borrowed"
       // from the Java Embedding Plugin.
       NSInteger windowNumber = [mWindow windowNumber];
       [mWindow _setWindowNumber:-1];
       [mWindow _setWindowNumber:windowNumber];
-      [mWindow setAcceptsMouseMovedEvents:YES];
       // For reasons that aren't yet clear, calls to [NSWindow orderFront:] or
       // [NSWindow makeKeyAndOrderFront:] can sometimes trigger "Error (1000)
       // creating CGSWindow", which in turn triggers an internal inconsistency
       // NSException.  These errors shouldn't be fatal.  So we need to wrap
       // calls to ...orderFront: in LOGONLY blocks.  See bmo bug 470864.
       NS_OBJC_BEGIN_TRY_LOGONLY_BLOCK;
       [mWindow orderFront:nil];
       NS_OBJC_END_TRY_LOGONLY_BLOCK;
@@ -711,17 +708,16 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool
       // appear above the parent and move when the parent does. Setting this
       // needs to happen after the _setWindowNumber calls above, otherwise the
       // window doesn't focus properly.
       if (nativeParentWindow && mPopupLevel == ePopupLevelParent)
         [nativeParentWindow addChildWindow:mWindow
                             ordered:NSWindowAbove];
     }
     else {
-      [mWindow setAcceptsMouseMovedEvents:YES];
       NS_OBJC_BEGIN_TRY_LOGONLY_BLOCK;
       [mWindow makeKeyAndOrderFront:nil];
       NS_OBJC_END_TRY_LOGONLY_BLOCK;
       SendSetZLevelEvent();
     }
   }
   else {
     // roll up any popups if a top-level window is going away
@@ -738,18 +734,16 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool
       }
       else {
         // get sheet's parent *before* hiding the sheet (which breaks the linkage)
         NSWindow* sheetParent = mSheetWindowParent;
         
         // hide the sheet
         [NSApp endSheet:mWindow];
         
-        [mWindow setAcceptsMouseMovedEvents:NO];
-
         [TopLevelWindowData deactivateInWindow:mWindow];
 
         nsCocoaWindow* siblingSheetToShow = nsnull;
         PRBool parentIsSheet = PR_FALSE;
 
         if (nativeParentWindow && piParentWidget &&
             NS_SUCCEEDED(piParentWidget->GetChildSheet(PR_FALSE, &siblingSheetToShow)) &&
             siblingSheetToShow) {
@@ -769,30 +763,28 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool
             if (piGrandparentWidget && NS_SUCCEEDED(piGrandparentWidget->GetIsSheet(&grandparentIsSheet)) &&
                 grandparentIsSheet) {
                 contextInfo = nil;
             }
           }
           // If there are no sibling sheets, but the parent is a sheet, restore
           // it.  It wasn't sent any deactivate events when it was hidden, so
           // don't call through Show, just let the OS put it back up.
-          [nativeParentWindow setAcceptsMouseMovedEvents:YES];
           [NSApp beginSheet:nativeParentWindow
              modalForWindow:sheetParent
               modalDelegate:[nativeParentWindow delegate]
              didEndSelector:@selector(didEndSheet:returnCode:contextInfo:)
                 contextInfo:contextInfo];
         }
         else {
           // Sheet, that was hard.  No more siblings or parents, going back
           // to a real window.
           NS_OBJC_BEGIN_TRY_LOGONLY_BLOCK;
           [sheetParent makeKeyAndOrderFront:nil];
           NS_OBJC_END_TRY_LOGONLY_BLOCK;
-          [sheetParent setAcceptsMouseMovedEvents:YES];
         }
         SendSetZLevelEvent();
       }
     }
     else {
       // If the window is a popup window with a parent window we need to
       // unhook it here before ordering it out. When you order out the child
       // of a window it hides the parent window.
@@ -808,20 +800,16 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool
       // surely an Apple bug.  The "window cache" is an undocumented subsystem,
       // all of whose methods are included in the NSWindowCache category of
       // the NSApplication class (in header files generated using class-dump).
       // This workaround was "borrowed" from the Java Embedding Plugin (which
       // uses it for a different purpose).
       if (mWindowType == eWindowType_popup)
         [NSApp _removeWindowFromCache:mWindow];
 
-      // it's very important to turn off mouse moved events when hiding a window, otherwise
-      // the windows' tracking rects will interfere with each other. (bug 356528)
-      [mWindow setAcceptsMouseMovedEvents:NO];
-
       // If our popup window is a non-native context menu, tell the OS (and
       // other programs) that a menu has closed.
       if ([mWindow isKindOfClass:[PopupWindow class]] &&
           [(PopupWindow*) mWindow isContextMenu]) {
         [[NSDistributedNotificationCenter defaultCenter]
           postNotificationName:@"com.apple.HIToolbox.endMenuTrackingNotification"
                         object:@"org.mozilla.gecko.PopupWindow"];
       }
@@ -1412,17 +1400,16 @@ void nsCocoaWindow::SetMenuBar(nsMenuBar
 }
 
 NS_IMETHODIMP nsCocoaWindow::SetFocus(PRBool aState)
 {
   if (mPopupContentView) {
     mPopupContentView->SetFocus(aState);
   }
   else if (aState && ([mWindow isVisible] || [mWindow isMiniaturized])) {
-    [mWindow setAcceptsMouseMovedEvents:YES];
     [mWindow makeKeyAndOrderFront:nil];
     SendSetZLevelEvent();
   }
 
   return NS_OK;
 }
 
 nsIntPoint nsCocoaWindow::WidgetToScreenOffset()
@@ -1644,36 +1631,16 @@ NS_IMETHODIMP nsCocoaWindow::EndSecureKe
   if (NS_SUCCEEDED(rv)) {
     ::DisableSecureEventInput();
   }
   return rv;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
-// Callback used by the default titlebar and toolbar shading.
-// *aIn == 0 at the top of the titlebar/toolbar, *aIn == 1 at the bottom
-/* static */ void
-nsCocoaWindow::UnifiedShading(void* aInfo, const CGFloat* aIn, CGFloat* aOut)
-{
-  UnifiedGradientInfo* info = (UnifiedGradientInfo*)aInfo;
-  // The gradient percentage at the bottom of the titlebar / top of the toolbar
-  float start = info->titlebarHeight / (info->titlebarHeight + info->toolbarHeight - 1);
-  const float startGrey = NativeGreyColorAsFloat(headerStartGrey, info->windowIsMain);
-  const float endGrey = NativeGreyColorAsFloat(headerEndGrey, info->windowIsMain);
-  // *aIn is the gradient percentage of the titlebar or toolbar gradient,
-  // a is the gradient percentage of the whole unified gradient.
-  float a = info->drawTitlebar ? *aIn * start : start + *aIn * (1 - start);
-  float result = (1.0f - a) * startGrey + a * endGrey;
-  aOut[0] = result;
-  aOut[1] = result;
-  aOut[2] = result;
-  aOut[3] = 1.0f;
-}
-
 void nsCocoaWindow::SetPopupWindowLevel()
 {
   // Floating popups are at the floating level and hide when the window is
   // deactivated.
   if (mPopupLevel == ePopupLevelFloating) {
     [mWindow setLevel:NSFloatingWindowLevel];
     [mWindow setHidesOnDeactivate:YES];
   }
@@ -1781,16 +1748,19 @@ PRBool nsCocoaWindow::ShouldFocusPlugin(
 {
   RollUpPopups();
   
   return proposedFrameSize;
 }
 
 - (void)windowDidResize:(NSNotification *)aNotification
 {
+  BaseWindow* window = [aNotification object];
+  [window updateTrackingArea];
+
   if (!mGeckoWindow)
     return;
 
   // Resizing might have changed our zoom state.
   mGeckoWindow->DispatchSizeModeEvent();
   mGeckoWindow->ReportSizeEvent();
 }
 
@@ -1988,35 +1958,44 @@ GetDPI(NSWindow* aWindow)
   // Currently we don't do our own scaling to take account
   // of userSpaceScaleFactor, so every "pixel" we draw is actually
   // userSpaceScaleFactor screen pixels. So divide the screen height
   // by userSpaceScaleFactor to get the number of "device pixels"
   // available.
   return (heightPx / scaleFactor) / (heightMM / MM_PER_INCH_FLOAT);
 }
 
+@interface BaseWindow(Private)
+- (void)removeTrackingArea;
+- (void)cursorUpdated:(NSEvent*)aEvent;
+@end
+
 @implementation BaseWindow
 
 - (id)initWithContentRect:(NSRect)aContentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)aBufferingType defer:(BOOL)aFlag
 {
   [super initWithContentRect:aContentRect styleMask:aStyle backing:aBufferingType defer:aFlag];
   mState = nil;
   mDrawsIntoWindowFrame = NO;
   mActiveTitlebarColor = nil;
   mInactiveTitlebarColor = nil;
   mScheduledShadowInvalidation = NO;
   mDPI = GetDPI(self);
+  mTrackingArea = nil;
+  [self updateTrackingArea];
 
   return self;
 }
 
 - (void)dealloc
 {
   [mActiveTitlebarColor release];
   [mInactiveTitlebarColor release];
+  [self removeTrackingArea];
+  ChildViewMouseTracker::OnDestroyWindow(self);
   [super dealloc];
 }
 
 static const NSString* kStateTitleKey = @"title";
 static const NSString* kStateDrawsContentsIntoWindowFrameKey = @"drawsContentsIntoWindowFrame";
 static const NSString* kStateActiveTitlebarColorKey = @"activeTitlebarColor";
 static const NSString* kStateInactiveTitlebarColorKey = @"inactiveTitlebarColor";
 static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
@@ -2092,16 +2071,65 @@ static const NSString* kStateShowsToolba
   mScheduledShadowInvalidation = NO;
 }
 
 - (float)getDPI
 {
   return mDPI;
 }
 
+- (NSView*)trackingAreaView
+{
+  NSView* contentView = [self contentView];
+  return [contentView superview] ? [contentView superview] : contentView;
+}
+
+- (void)removeTrackingArea
+{
+  if (mTrackingArea) {
+    [[self trackingAreaView] removeTrackingArea:mTrackingArea];
+    [mTrackingArea release];
+    mTrackingArea = nil;
+  }
+}
+
+- (void)updateTrackingArea
+{
+  [self removeTrackingArea];
+
+  NSView* view = [self trackingAreaView];
+  const NSTrackingAreaOptions options =
+    NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveAlways;
+  mTrackingArea = [[NSTrackingArea alloc] initWithRect:[view bounds]
+                                               options:options
+                                                 owner:self
+                                              userInfo:nil];
+  [view addTrackingArea:mTrackingArea];
+}
+
+- (void)mouseEntered:(NSEvent*)aEvent
+{
+  ChildViewMouseTracker::MouseEnteredWindow(aEvent);
+}
+
+- (void)mouseExited:(NSEvent*)aEvent
+{
+  ChildViewMouseTracker::MouseExitedWindow(aEvent);
+}
+
+- (void)mouseMoved:(NSEvent*)aEvent
+{
+  ChildViewMouseTracker::MouseMoved(aEvent);
+}
+
+- (void)cursorUpdated:(NSEvent*)aEvent
+{
+  // Nothing to do here, but NSTrackingArea wants us to implement this method.
+}
+
 - (BOOL)respondsToSelector:(SEL)aSelector
 {
   // Claim the window doesn't respond to this so that the system
   // doesn't steal keyboard equivalents for it. Bug 613710.
   if (aSelector == @selector(cancelOperation:)) {
     return NO;
   }
 
@@ -2372,103 +2400,89 @@ static const NSString* kStateShowsToolba
 - (id)initWithWindow:(ToolbarWindow*)aWindow
 {
   if ((self = [super init])) {
     mWindow = aWindow; // weak ref to avoid a cycle
   }
   return self;
 }
 
-// Our pattern width is 1 pixel. CoreGraphics can cache and tile for us.
-static const float sPatternWidth = 1.0f;
-
 static void
-DrawTitlebarGradient(CGContextRef aContext, float aTitlebarHeight,
-                     float aTitlebarOrigin, float aToolbarHeight, BOOL aIsMain)
+DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
+                   float aToolbarHeight, BOOL aIsMain)
 {
-  // Create and draw a CGShading that uses nsCocoaWindow::UnifiedShading() as its callback.
-  CGFunctionCallbacks callbacks = {0, nsCocoaWindow::UnifiedShading, NULL};
-  UnifiedGradientInfo info = { aTitlebarHeight, aToolbarHeight, aIsMain, YES };
-  CGFunctionRef function = CGFunctionCreate(&info, 1, NULL, 4, NULL, &callbacks);
-  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-  CGShadingRef shading = CGShadingCreateAxial(colorSpace,
-                                              CGPointMake(0.0f, aTitlebarOrigin + aTitlebarHeight),
-                                              CGPointMake(0.0f, aTitlebarOrigin),
-                                              function, NO, NO);
-  CGColorSpaceRelease(colorSpace);
-  CGFunctionRelease(function);
-  CGContextDrawShading(aContext, shading);
-  CGShadingRelease(shading);
-  // Draw the one pixel border at the bottom of the titlebar.
-  if (aToolbarHeight == 0) {
-    CGRect borderRect = CGRectMake(0.0f, aTitlebarOrigin, sPatternWidth, 1.0f);
-    DrawNativeGreyColorInRect(aContext, headerBorderGrey, borderRect, aIsMain);
-  }
+  int unifiedHeight = aTitlebarRect.size.height + aToolbarHeight;
+  CUIDraw([NSWindow coreUIRenderer], aTitlebarRect, aContext,
+          (CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
+            @"kCUIWidgetWindowFrame", @"widget",
+            @"regularwin", @"windowtype",
+            (aIsMain ? @"normal" : @"inactive"), @"state",
+            [NSNumber numberWithInt:unifiedHeight], @"kCUIWindowFrameUnifiedTitleBarHeightKey",
+            [NSNumber numberWithBool:YES], @"kCUIWindowFrameDrawTitleSeparatorKey",
+            nil],
+          nil);
+
+  // At some window widths the call to CUIDraw doesn't draw the top pixel strip.
+  // We don't want to have a flickering transparent line, so we overdraw it.
+  CGContextSetRGBFillColor(aContext, 0.95, 0.95, 0.95, 1);
+  CGContextFillRect(aContext, CGRectMake(0, CGRectGetMaxY(aTitlebarRect) - 1,
+                                         aTitlebarRect.size.width, 1));
 }
 
 // Pattern draw callback for standard titlebar gradients and solid titlebar colors
 static void
-RepeatedPatternDrawCallback(void* aInfo, CGContextRef aContext)
+TitlebarDrawCallback(void* aInfo, CGContextRef aContext)
 {
   ToolbarWindow *window = (ToolbarWindow*)aInfo;
 
   // Remember: this context is NOT flipped, so the origin is in the bottom left.
+  float titlebarWidth = [window frame].size.width;
   float titlebarHeight = [window titlebarHeight];
   float titlebarOrigin = [window frame].size.height - titlebarHeight;
+  NSRect titlebarRect = NSMakeRect(0, titlebarOrigin, titlebarWidth, titlebarHeight);
 
   [NSGraphicsContext saveGraphicsState];
   [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:aContext flipped:NO]];
 
-  BOOL isMain = [window isMainWindow];
-  NSColor *titlebarColor = [window titlebarColorForActiveWindow:isMain];
-  if (!titlebarColor) {
-    // If the titlebar color is nil, draw the default titlebar shading.
-    DrawTitlebarGradient(aContext, titlebarHeight, titlebarOrigin,
-                         [window unifiedToolbarHeight], isMain);
+  if ([window drawsContentsIntoWindowFrame]) {
+    NSView* view = [[[window contentView] subviews] lastObject];
+    if (!view || ![view isKindOfClass:[ChildView class]])
+      return;
+
+    // Gecko drawing assumes flippedness, but the current context isn't flipped
+    // (because we're painting into the window's border view, which is not a
+    // ChildView, so it isn't flpped).
+    // So we need to set a flip transform.
+    CGContextScaleCTM(aContext, 1.0f, -1.0f);
+    CGContextTranslateCTM(aContext, 0.0f, -[window frame].size.height);
+
+    NSRect flippedTitlebarRect = NSMakeRect(0, 0, titlebarWidth, titlebarHeight);
+    [(ChildView*)view drawRect:flippedTitlebarRect inTitlebarContext:aContext];
   } else {
-    // If the titlebar color is not nil, just set and draw it normally.
-    [titlebarColor set];
-    NSRectFill(NSMakeRect(0.0f, titlebarOrigin, sPatternWidth, titlebarHeight));
+    BOOL isMain = [window isMainWindow];
+    NSColor *titlebarColor = [window titlebarColorForActiveWindow:isMain];
+    if (!titlebarColor) {
+      // If the titlebar color is nil, draw the default titlebar shading.
+      DrawNativeTitlebar(aContext, NSRectToCGRect(titlebarRect),
+                         [window unifiedToolbarHeight], isMain);
+    } else {
+      // If the titlebar color is not nil, just set and draw it normally.
+      [titlebarColor set];
+      NSRectFill(titlebarRect);
+    }
   }
 
-  // Draw the background color of the window everywhere but where the titlebar is.
-  [[window windowBackgroundColor] set];
-  NSRectFill(NSMakeRect(0.0f, 0.0f, 1.0f, titlebarOrigin));
-
   [NSGraphicsContext restoreGraphicsState];
 }
 
-// Pattern draw callback for "drawsContentsIntoWindowFrame" windows
-static void
-ContentPatternDrawCallback(void* aInfo, CGContextRef aContext)
-{
-  ToolbarWindow *window = (ToolbarWindow*)aInfo;
-
-  NSView* view = [[[window contentView] subviews] lastObject];
-  if (!view || ![view isKindOfClass:[ChildView class]])
-    return;
-
-  // Gecko drawing assumes flippedness, but the current context isn't flipped
-  // (because we're painting into the window's border view, which is not a
-  // ChildView, so it isn't flpped).
-  // So we need to set a flip transform.
-  CGContextScaleCTM(aContext, 1.0f, -1.0f);
-  CGContextTranslateCTM(aContext, 0.0f, -[window frame].size.height);
-
-  NSRect titlebarRect = NSMakeRect(0, 0, [window frame].size.width, [window titlebarHeight]);
-  [(ChildView*)view drawRect:titlebarRect inTitlebarContext:aContext];
-}
-
 - (void)setFill
 {
-  CGPatternDrawPatternCallback cb = [mWindow drawsContentsIntoWindowFrame] ?
-                                      &ContentPatternDrawCallback : &RepeatedPatternDrawCallback;
-  float patternWidth = [mWindow drawsContentsIntoWindowFrame] ? [mWindow frame].size.width : sPatternWidth;
-
-  CGPatternCallbacks callbacks = {0, cb, NULL};
+  float patternWidth = [mWindow frame].size.width;
+
+  CGPatternCallbacks callbacks = {0, &TitlebarDrawCallback, NULL};
   CGPatternRef pattern = CGPatternCreate(mWindow, CGRectMake(0.0f, 0.0f, patternWidth, [mWindow frame].size.height), 
                                          CGAffineTransformIdentity, patternWidth, [mWindow frame].size.height,
                                          kCGPatternTilingConstantSpacing, true, &callbacks);
 
   // Set the pattern as the fill, which is what we were asked to do. All our
   // drawing will take place in the patternDraw callback.
   CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(NULL);
   CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
@@ -2488,97 +2502,16 @@ ContentPatternDrawCallback(void* aInfo, 
 {
   return NSDeviceRGBColorSpace;
 }
 
 @end
 
 @implementation PopupWindow
 
-// The OS treats our custom popup windows very strangely -- many mouse events
-// sent to them never reach their target NSView objects.  (That these windows
-// are borderless and of level NSPopUpMenuWindowLevel may have something to do
-// with it.)  The best solution is to pre-empt the OS, as follows.  (All
-// events for a given NSWindow object go through its sendEvent: method.)
-- (void)sendEvent:(NSEvent *)anEvent
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  NSView *target = nil;
-  NSView *contentView = nil;
-  NSEventType type = [anEvent type];
-  NSPoint windowLocation = NSZeroPoint;
-  switch (type) {
-    case NSScrollWheel:
-    case NSLeftMouseDown:
-    case NSLeftMouseUp:
-    case NSRightMouseDown:
-    case NSRightMouseUp:
-    case NSOtherMouseDown:
-    case NSOtherMouseUp:
-    case NSMouseMoved:
-    case NSLeftMouseDragged:
-    case NSRightMouseDragged:
-    case NSOtherMouseDragged:
-      if ((contentView = [self contentView])) {
-        // Since [anEvent window] might not be us, we can't use [anEvent locationInWindow].
-        windowLocation = nsCocoaUtils::EventLocationForWindow(anEvent, self);
-        target = [contentView hitTest:[contentView convertPoint:windowLocation fromView:nil]];
-        // If the hit test failed, the event is targeted here but is not over the window.
-        // Send it to our content view.
-        if (!target)
-          target = contentView;
-      }
-      break;
-    default:
-      break;
-  }
-  if (target) {
-    switch (type) {
-      case NSScrollWheel:
-        [target scrollWheel:anEvent];
-        break;
-      case NSLeftMouseUp:
-        [target mouseUp:anEvent];
-        break;
-      case NSRightMouseDown:
-        [target rightMouseDown:anEvent];
-        break;
-      case NSRightMouseUp:
-        [target rightMouseUp:anEvent];
-        break;
-      case NSOtherMouseDown:
-        [target otherMouseDown:anEvent];
-        break;
-      case NSOtherMouseUp:
-        [target otherMouseUp:anEvent];
-        break;
-      case NSMouseMoved:
-        [target mouseMoved:anEvent];
-        break;
-      case NSLeftMouseDragged:
-        [target mouseDragged:anEvent];
-        break;
-      case NSRightMouseDragged:
-        [target rightMouseDragged:anEvent];
-        break;
-      case NSOtherMouseDragged:
-        [target otherMouseDragged:anEvent];
-        break;
-      default:
-        [super sendEvent:anEvent];
-        break;
-    }
-  } else {
-    [super sendEvent:anEvent];
-  }
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask
       backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   mIsContextMenu = false;
   return [super initWithContentRect:contentRect styleMask:styleMask
           backing:bufferingType defer:deferCreation];
--- a/widget/src/cocoa/nsLookAndFeel.mm
+++ b/widget/src/cocoa/nsLookAndFeel.mm
@@ -242,17 +242,17 @@ nsresult nsLookAndFeel::NativeGetColor(c
     case eColor__moz_html_cellhighlighttext:
       aColor = GetColorFromNSColor([NSColor controlTextColor]);
       break;
     case eColor__moz_dragtargetzone:
       aColor = GetColorFromNSColor([NSColor selectedControlColor]);
       break;
     case eColor__moz_mac_chrome_active:
     case eColor__moz_mac_chrome_inactive: {
-      int grey = NativeGreyColorAsInt(headerEndGrey, (aID == eColor__moz_mac_chrome_active));
+      int grey = NativeGreyColorAsInt(toolbarFillGrey, (aID == eColor__moz_mac_chrome_active));
       aColor = NS_RGB(grey, grey, grey);
     }
       break;
     case eColor__moz_mac_focusring:
       aColor = GetColorFromNSColor([NSColor keyboardFocusIndicatorColor]);
       break;
     case eColor__moz_mac_menushadow:
       aColor = NS_RGB(0xA3,0xA3,0xA3);
--- a/widget/src/cocoa/nsNativeThemeCocoa.h
+++ b/widget/src/cocoa/nsNativeThemeCocoa.h
@@ -46,16 +46,17 @@
 #include "nsIAtom.h"
 #include "nsILookAndFeel.h"
 #include "nsNativeTheme.h"
 #include "gfxASurface.h"
 
 @class CellDrawView;
 @class NSProgressBarCell;
 class nsDeviceContext;
+struct SegmentedControlRenderSettings;
 
 class nsNativeThemeCocoa : private nsNativeTheme,
                            public nsITheme
 {
 public:
   nsNativeThemeCocoa();
   virtual ~nsNativeThemeCocoa();
 
@@ -91,30 +92,34 @@ public:
   PRBool ThemeDrawsFocusForWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType);
   PRBool ThemeNeedsComboboxDropmarker();
   virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, PRUint8 aWidgetType);
 
 protected:  
 
   nsresult GetSystemColor(PRUint8 aWidgetType, nsILookAndFeel::nsColorID& aColorID);
   nsIntMargin RTLAwareMargin(const nsIntMargin& aMargin, nsIFrame* aFrame);
+  nsIFrame* SeparatorResponsibility(nsIFrame* aBefore, nsIFrame* aAfter);
+  CGRect SeparatorAdjustedRect(CGRect aRect, nsIFrame* aLeft,
+                               nsIFrame* aCurrent, nsIFrame* aRight);
 
   // Helpers for progressbar.
   double GetProgressValue(nsIFrame* aFrame);
   double GetProgressMaxValue(nsIFrame* aFrame);
 
   // HITheme drawing routines
   void DrawFrame(CGContextRef context, HIThemeFrameKind inKind,
                  const HIRect& inBoxRect, PRBool inReadOnly,
                  nsEventStates inState);
   void DrawProgress(CGContextRef context, const HIRect& inBoxRect,
                     PRBool inIsIndeterminate, PRBool inIsHorizontal,
                     double inValue, double inMaxValue, nsIFrame* aFrame);
-  void DrawTab(CGContextRef context, HIRect inBoxRect, nsEventStates inState,
-               nsIFrame* aFrame);
+  void DrawSegment(CGContextRef cgContext, const HIRect& inBoxRect,
+                   nsEventStates inState, nsIFrame* aFrame,
+                   const SegmentedControlRenderSettings& aSettings);
   void DrawTabPanel(CGContextRef context, const HIRect& inBoxRect, nsIFrame* aFrame);
   void DrawScale(CGContextRef context, const HIRect& inBoxRect,
                  nsEventStates inState, PRBool inDirection,
                  PRBool inIsReverse, PRInt32 inCurrentValue, PRInt32 inMinValue,
                  PRInt32 inMaxValue, nsIFrame* aFrame);
   void DrawCheckboxOrRadio(CGContextRef cgContext, PRBool inCheckbox,
                            const HIRect& inBoxRect, PRBool inSelected,
                            nsEventStates inState, nsIFrame* aFrame);
--- a/widget/src/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/src/cocoa/nsNativeThemeCocoa.mm
@@ -284,16 +284,26 @@ static NSControlSize CocoaSizeForEnum(PR
   if (enumControlSize == miniControlSize)
     return NSMiniControlSize;
   else if (enumControlSize == smallControlSize)
     return NSSmallControlSize;
   else
     return NSRegularControlSize;
 }
 
+static NSString* CUIControlSizeForCocoaSize(NSControlSize aControlSize)
+{
+  if (aControlSize == NSRegularControlSize)
+    return @"regular";
+  else if (aControlSize == NSSmallControlSize)
+    return @"small";
+  else
+    return @"mini";
+}
+
 static void InflateControlRect(NSRect* rect, NSControlSize cocoaControlSize, const float marginSet[][3][4])
 {
   if (!marginSet)
     return;
 
   static int osIndex = leopardOS;
   int controlSize = EnumSizeForCocoaSize(cocoaControlSize);
   const float* buttonMargins = marginSet[osIndex][controlSize];
@@ -333,16 +343,25 @@ static BOOL FrameIsInActiveWindow(nsIFra
   topLevelWidget->GetWindowType(windowType);
   if (windowType == eWindowType_popup)
     return YES;
   if ([win isSheet])
     return [win isKeyWindow];
   return [win isMainWindow] && ![win attachedSheet];
 }
 
+// Toolbar controls and content controls respond to different window
+// activeness states.
+static BOOL IsActive(nsIFrame* aFrame, BOOL aIsToolbarControl)
+{
+  if (aIsToolbarControl)
+    return [NativeWindowForFrame(aFrame) isMainWindow] || ![NSView focusView];
+  return FrameIsInActiveWindow(aFrame);
+}
+
 NS_IMPL_ISUPPORTS_INHERITED1(nsNativeThemeCocoa, nsNativeTheme, nsITheme)
 
 
 nsNativeThemeCocoa::nsNativeThemeCocoa()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   // provide a local autorelease pool, as this is called during startup
@@ -569,17 +588,17 @@ struct CellRenderSettings {
  * This is a helper method that returns the required NSControlSize given a size
  * and the size of the three controls plus a tolerance.
  * size - The width or the height of the element to draw.
  * sizes - An array with the all the width/height of the element for its
  *         different sizes.
  * tolerance - The tolerance as passed to DrawCellWithSnapping.
  * NOTE: returns NSRegularControlSize if all values in 'sizes' are zero.
  */
-static NSControlSize FindControlSize(CGFloat size, CGFloat* sizes, CGFloat tolerance)
+static NSControlSize FindControlSize(CGFloat size, const CGFloat* sizes, CGFloat tolerance)
 {
   for (PRUint32 i = miniControlSize; i <= regularControlSize; ++i) {
     if (sizes[i] == 0) {
       continue;
     }
 
     CGFloat next = 0;
     // Find next value.
@@ -1339,96 +1358,117 @@ nsNativeThemeCocoa::DrawScale(CGContextR
   tdi.trackInfo.slider.thumbDir = kThemeThumbPlain;
   tdi.trackInfo.slider.pressState = 0;
 
   HIThemeDrawTrack(&tdi, NULL, cgContext, HITHEME_ORIENTATION);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-#define NATURAL_MINI_TAB_BUTTON_HEIGHT    17
-#define NATURAL_SMALL_TAB_BUTTON_HEIGHT   20
-#define NATURAL_REGULAR_TAB_BUTTON_HEIGHT 23
+nsIFrame*
+nsNativeThemeCocoa::SeparatorResponsibility(nsIFrame* aBefore, nsIFrame* aAfter)
+{
+  // Usually a separator is drawn by the segment to the right of the
+  // separator, but pressed and selected segments have higher priority.
+  if (!aBefore || !aAfter)
+    return nsnull;
+  if (IsSelectedButton(aAfter))
+    return aAfter;
+  if (IsSelectedButton(aBefore) || IsPressedButton(aBefore))
+    return aBefore;
+  return aAfter;
+}
+
+CGRect
+nsNativeThemeCocoa::SeparatorAdjustedRect(CGRect aRect, nsIFrame* aLeft,
+                                          nsIFrame* aCurrent, nsIFrame* aRight)
+{
+  // A separator between two segments should always be located in the leftmost
+  // pixel column of the segment to the right of the separator, regardless of
+  // who ends up drawing it.
+  // CoreUI draws the separators inside the drawing rect.
+  if (aLeft && SeparatorResponsibility(aLeft, aCurrent) == aLeft) {
+    // The left button draws the separator, so we need to make room for it.
+    aRect.origin.x += 1;
+    aRect.size.width -= 1;
+  }
+  if (SeparatorResponsibility(aCurrent, aRight) == aCurrent) {
+    // We draw the right separator, so we need to extend the draw rect into the
+    // segment to our right.
+    aRect.size.width += 1;
+  }
+  return aRect;
+}
+
+static NSString* ToolbarButtonPosition(BOOL aIsFirst, BOOL aIsLast)
+{
+  if (aIsFirst) {
+    if (aIsLast)
+      return @"kCUISegmentPositionOnly";
+    return @"kCUISegmentPositionFirst";
+  }
+  if (aIsLast)
+    return @"kCUISegmentPositionLast";
+  return @"kCUISegmentPositionMiddle";
+}
+
+struct SegmentedControlRenderSettings {
+  const CGFloat* heights;
+  const NSString* widgetName;
+  const BOOL ignoresPressedWhenSelected;
+  const BOOL isToolbarControl;
+};
+
+static const CGFloat tabHeights[3] = { 17, 20, 23 };
+
+static const SegmentedControlRenderSettings tabRenderSettings = {
+  tabHeights, @"tab", YES, NO
+};
+
+static const CGFloat toolbarButtonHeights[3] = { 15, 18, 22 };
+
+static const SegmentedControlRenderSettings toolbarButtonRenderSettings = {
+  toolbarButtonHeights, @"kCUIWidgetButtonSegmentedSCurve", NO, YES
+};
 
 void
-nsNativeThemeCocoa::DrawTab(CGContextRef cgContext, HIRect inBoxRect,
-                            nsEventStates inState, nsIFrame* aFrame)
+nsNativeThemeCocoa::DrawSegment(CGContextRef cgContext, const HIRect& inBoxRect,
+                                nsEventStates inState, nsIFrame* aFrame,
+                                const SegmentedControlRenderSettings& aSettings)
 {
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  HIThemeTabDrawInfo tdi;
-  tdi.version = 1;
-  tdi.kind = kHIThemeTabKindNormal;
-
-  PRBool isSelected = IsSelectedTab(aFrame);
-  PRBool isDisabled = IsDisabled(aFrame, inState);
-
-  if (isSelected) {
-    if (isDisabled)
-      tdi.style = kThemeTabFrontUnavailable;
-    else
-      tdi.style = FrameIsInActiveWindow(aFrame) ? kThemeTabFront : kThemeTabFrontInactive;
-  } else {
-    if (isDisabled)
-      tdi.style = kThemeTabNonFrontUnavailable;
-    else if (inState.HasAllStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_HOVER))
-      tdi.style = kThemeTabNonFrontPressed;
-    else
-      tdi.style = FrameIsInActiveWindow(aFrame) ? kThemeTabNonFront : kThemeTabNonFrontInactive;
+  BOOL isActive = IsActive(aFrame, aSettings.isToolbarControl);
+  BOOL isFocused = inState.HasState(NS_EVENT_STATE_FOCUS);
+  BOOL isSelected = IsSelectedButton(aFrame);
+  BOOL isPressed = IsPressedButton(aFrame);
+  if (isSelected && aSettings.ignoresPressedWhenSelected) {
+    isPressed = NO;
   }
 
-  tdi.direction = kThemeTabNorth;
-  tdi.size = kHIThemeTabSizeNormal;
-  if (inBoxRect.size.height < NATURAL_REGULAR_TAB_BUTTON_HEIGHT)
-    tdi.size = kHIThemeTabSizeSmall;
-  if (inBoxRect.size.height < NATURAL_SMALL_TAB_BUTTON_HEIGHT)
-    tdi.size = kHIThemeTabSizeMini;
-
-  PRBool isRTL = IsFrameRTL(aFrame);
-  PRBool isFirst = isRTL ? IsLastTab(aFrame) : IsFirstTab(aFrame);
-  PRBool isLast = isRTL ? IsFirstTab(aFrame) : IsLastTab(aFrame);
-
-  if (isFirst && isLast)
-    tdi.position = kHIThemeTabPositionOnly;
-  else if (isFirst)
-    tdi.position = kHIThemeTabPositionFirst;
-  else if (isLast)
-    tdi.position = kHIThemeTabPositionLast;
-  else
-    tdi.position = kHIThemeTabPositionMiddle;
-
-  // Tab separator management:
-  // Normal tabs only draw their left separator, in the leftmost pixel row of
-  // their frame. Selected tabs additionally draw their right separator, outside
-  // of their frame. To prevent overlapping, the tab to the right of the
-  // selected tab shouldn't draw its left separator.
-  tdi.adornment = kHIThemeTabAdornmentNone;
-  if (isRTL ? IsBeforeSelectedTab(aFrame) : IsAfterSelectedTab(aFrame)) {
-    // On Leopard, the tab's left edge must be shifted 1px to the right.
-    // On Tiger, this happens automatically when no leading separator is drawn.
-    inBoxRect.origin.x += 1;
-    inBoxRect.size.width -= 1;
-  }
-  else {
-    tdi.adornment = kHIThemeTabAdornmentLeadingSeparator;
-  }
-
-  if (isSelected && !isLast) {
-    tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator;
-    // On Tiger, the right separator is drawn outside of the frame.
-    // On Leopard, the right edge must be shifted 1px to the right.
-    inBoxRect.size.width += 1;
-  }
-  
-  if (inState.HasState(NS_EVENT_STATE_FOCUS))
-    tdi.adornment |= kThemeAdornmentFocus;
-
-  HIThemeDrawTab(&inBoxRect, &tdi, cgContext, HITHEME_ORIENTATION, NULL);
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
+  BOOL isRTL = IsFrameRTL(aFrame);
+  nsIFrame* left = GetAdjacentSiblingFrameWithSameAppearance(aFrame, isRTL);
+  nsIFrame* right = GetAdjacentSiblingFrameWithSameAppearance(aFrame, !isRTL);
+  CGRect drawRect = SeparatorAdjustedRect(inBoxRect, left, aFrame, right);
+  BOOL drawLeftSeparator = SeparatorResponsibility(left, aFrame) == aFrame;
+  BOOL drawRightSeparator = SeparatorResponsibility(aFrame, right) == aFrame;
+  NSControlSize controlSize = FindControlSize(drawRect.size.height, aSettings.heights, 4.0f);
+
+  CUIDraw([NSWindow coreUIRenderer], drawRect, cgContext,
+          (CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
+            aSettings.widgetName, @"widget",
+            ToolbarButtonPosition(!left, !right), @"kCUIPositionKey",
+            [NSNumber numberWithBool:drawLeftSeparator], @"kCUISegmentLeadingSeparatorKey",
+            [NSNumber numberWithBool:drawRightSeparator], @"kCUISegmentTrailingSeparatorKey",
+            [NSNumber numberWithBool:isSelected], @"value",
+            (isPressed ? @"pressed" : (isActive ? @"normal" : @"inactive")), @"state",
+            [NSNumber numberWithBool:isFocused], @"focus",
+            CUIControlSizeForCocoaSize(controlSize), @"size",
+            [NSNumber numberWithBool:YES], @"is.flipped",
+            @"up", @"direction",
+            nil],
+          nil);
 }
 
 static inline UInt8
 ConvertToPressState(nsEventStates aButtonState, UInt8 aPressState)
 {
   // If the button is pressed, return the press state passed in. Otherwise, return 0.
   return aButtonState.HasAllStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_HOVER) ? aPressState : 0;
 }
@@ -1591,106 +1631,71 @@ ToolbarCanBeUnified(CGContextRef cgConte
 
 void
 nsNativeThemeCocoa::DrawUnifiedToolbar(CGContextRef cgContext, const HIRect& inBoxRect,
                                        NSWindow* aWindow)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   float titlebarHeight = [(ToolbarWindow*)aWindow titlebarHeight];
+  float unifiedHeight = titlebarHeight + inBoxRect.size.height;
 
   BOOL isMain = [aWindow isMainWindow] || ![NSView focusView];
 
-  // Draw the gradient
-  UnifiedGradientInfo info = { titlebarHeight, inBoxRect.size.height, isMain, NO };
-  struct CGFunctionCallbacks callbacks = { 0, nsCocoaWindow::UnifiedShading, NULL };
-  CGFunctionRef function = CGFunctionCreate(&info, 1,  NULL, 4, NULL, &callbacks);
-  float srcY = inBoxRect.origin.y;
-  float dstY = srcY + inBoxRect.size.height - 1;
-  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-  CGShadingRef shading = CGShadingCreateAxial(colorSpace,
-                                              CGPointMake(0, srcY),
-                                              CGPointMake(0, dstY), function,
-                                              NO, NO);
-  CGColorSpaceRelease(colorSpace);
-  CGFunctionRelease(function);
+  CGContextSaveGState(cgContext);
   CGContextClipToRect(cgContext, inBoxRect);
-  CGContextDrawShading(cgContext, shading);
-  CGShadingRelease(shading);
-
-  // Draw the border at the bottom of the toolbar.
-  CGRect borderRect = CGRectMake(inBoxRect.origin.x, inBoxRect.origin.y +
-                                 inBoxRect.size.height - 1.0f,
-                                 inBoxRect.size.width, 1.0f);
-  DrawNativeGreyColorInRect(cgContext, headerBorderGrey, borderRect, isMain);
+
+  CGRect drawRect = CGRectOffset(inBoxRect, 0, -titlebarHeight);
+  CUIDraw([NSWindow coreUIRenderer], drawRect, cgContext,
+          (CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
+            @"kCUIWidgetWindowFrame", @"widget",
+            @"regularwin", @"windowtype",
+            (isMain ? @"normal" : @"inactive"), @"state",
+            [NSNumber numberWithInt:unifiedHeight], @"kCUIWindowFrameUnifiedTitleBarHeightKey",
+            [NSNumber numberWithBool:YES], @"kCUIWindowFrameDrawTitleSeparatorKey",
+            [NSNumber numberWithBool:YES], @"is.flipped",
+            nil],
+          nil);
+
+  CGContextRestoreGState(cgContext);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-struct GreyGradientInfo {
-  float startGrey;
-  float endGrey;
-};
-
-static void GreyGradientCallback(void* aInfo, const CGFloat* aIn, CGFloat* aOut)
-{
-  GreyGradientInfo* info = static_cast<GreyGradientInfo*>(aInfo);
-  CGFloat result = (1.0f - *aIn) * info->startGrey + *aIn * info->endGrey;
-  aOut[0] = result;
-  aOut[1] = result;
-  aOut[2] = result;
-  aOut[3] = 1.0f;
-}
-
-static void DrawGreyGradient(CGContextRef cgContext, const HIRect& rect,
-                             float startGrey, float endGrey)
-{
-  if (rect.size.height <= 0.0f)
-    return;
-
-  GreyGradientInfo info = { startGrey, endGrey };
-  struct CGFunctionCallbacks callbacks = { 0, GreyGradientCallback, NULL };
-  CGFunctionRef function = CGFunctionCreate(&info, 1,  NULL, 4, NULL, &callbacks);
-  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-  CGShadingRef shading = CGShadingCreateAxial(colorSpace,
-                                              CGPointMake(0, CGRectGetMinY(rect)),
-                                              CGPointMake(0, CGRectGetMaxY(rect)),
-                                              function, false, false);
-  CGColorSpaceRelease(colorSpace);
-  CGFunctionRelease(function);
-  CGContextSaveGState(cgContext);
-  CGContextClipToRect(cgContext, rect);
-  CGContextDrawShading(cgContext, shading);
-  CGContextRestoreGState(cgContext);
-  CGShadingRelease(shading);
-}
-
 void
 nsNativeThemeCocoa::DrawStatusBar(CGContextRef cgContext, const HIRect& inBoxRect,
                                   nsIFrame *aFrame)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if (inBoxRect.size.height < 2.0f)
     return;
 
-  BOOL isMain = [NativeWindowForFrame(aFrame) isMainWindow] || ![NSView focusView];
-
-  // Draw the borders at the top of the statusbar.
-  CGRect rect = CGRectMake(inBoxRect.origin.x, inBoxRect.origin.y,
-                           inBoxRect.size.width, 1.0f);
-  DrawNativeGreyColorInRect(cgContext, statusbarFirstTopBorderGrey, rect, isMain);
-  rect.origin.y += 1.0f;
-  DrawNativeGreyColorInRect(cgContext, statusbarSecondTopBorderGrey, rect, isMain);
-
-  // Draw the gradient.
-  DrawGreyGradient(cgContext, CGRectMake(inBoxRect.origin.x, inBoxRect.origin.y + 2.0f,
-                                         inBoxRect.size.width, inBoxRect.size.height - 2.0f),
-                   NativeGreyColorAsFloat(statusbarGradientStartGrey, isMain),
-                   NativeGreyColorAsFloat(statusbarGradientEndGrey, isMain));
+  CGContextSaveGState(cgContext);
+  CGContextClipToRect(cgContext, inBoxRect);
+
+  // kCUIWidgetWindowFrame draws a complete window frame with both title bar
+  // and bottom bar. We only want the bottom bar, so we extend the draw rect
+  // upwards to make space for the title bar, and then we clip it away.
+  CGRect drawRect = inBoxRect;
+  const int extendUpwards = 40;
+  drawRect.origin.y -= extendUpwards;
+  drawRect.size.height += extendUpwards;
+  CUIDraw([NSWindow coreUIRenderer], drawRect, cgContext,
+          (CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
+            @"kCUIWidgetWindowFrame", @"widget",
+            @"regularwin", @"windowtype",
+            (IsActive(aFrame, YES) ? @"normal" : @"inactive"), @"state",
+            [NSNumber numberWithInt:inBoxRect.size.height], @"kCUIWindowFrameBottomBarHeightKey",
+            [NSNumber numberWithBool:YES], @"kCUIWindowFrameDrawBottomBarSeparatorKey",
+            [NSNumber numberWithBool:YES], @"is.flipped",
+            nil],
+          nil);
+
+  CGContextRestoreGState(cgContext);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 static void
 RenderResizer(CGContextRef cgContext, const HIRect& aRenderRect, void* aData)
 {
   HIThemeGrowBoxDrawInfo* drawInfo = (HIThemeGrowBoxDrawInfo*)aData;
@@ -1888,19 +1893,17 @@ nsNativeThemeCocoa::DrawWidgetBackground
       }
 
       DrawSpinButtons(cgContext, kThemeIncDecButton, macRect, state,
                       kThemeAdornmentNone, eventState, aFrame);
     }
       break;
 
     case NS_THEME_TOOLBAR_BUTTON:
-      DrawButton(cgContext, kThemePushButton, macRect,
-                 IsDefaultButton(aFrame), kThemeButtonOn, kThemeAdornmentNone,
-                 eventState, aFrame);
+      DrawSegment(cgContext, macRect, eventState, aFrame, toolbarButtonRenderSettings);
       break;
 
     case NS_THEME_TOOLBAR_SEPARATOR: {
       HIThemeSeparatorDrawInfo sdi = { 0, kThemeStateActive };
       HIThemeDrawSeparator(&macRect, &sdi, cgContext, HITHEME_ORIENTATION);
     }
       break;
 
@@ -1916,22 +1919,22 @@ nsNativeThemeCocoa::DrawWidgetBackground
 
       // top border
       drawRect.size.height = 1.0f;
       DrawNativeGreyColorInRect(cgContext, toolbarTopBorderGrey, drawRect, isMain);
 
       // background
       drawRect.origin.y += drawRect.size.height;
       drawRect.size.height = macRect.size.height - 2.0f;
-      DrawNativeGreyColorInRect(cgContext, headerEndGrey, drawRect, isMain);
+      DrawNativeGreyColorInRect(cgContext, toolbarFillGrey, drawRect, isMain);
 
       // bottom border
       drawRect.origin.y += drawRect.size.height;
       drawRect.size.height = 1.0f;
-      DrawNativeGreyColorInRect(cgContext, headerBorderGrey, drawRect, isMain);
+      DrawNativeGreyColorInRect(cgContext, toolbarBottomBorderGrey, drawRect, isMain);
     }
       break;
 
     case NS_THEME_TOOLBOX: {
       HIThemeHeaderDrawInfo hdi = { 0, kThemeStateActive, kHIThemeHeaderKindWindow };
       HIThemeDrawHeader(&macRect, &hdi, cgContext, HITHEME_ORIENTATION);
     }
       break;
@@ -2137,17 +2140,17 @@ nsNativeThemeCocoa::DrawWidgetBackground
       CGContextSetRGBFillColor(cgContext, 0.745, 0.745, 0.745, 1.0);
       CGContextFillRect(cgContext, CGRectMake(x, y + 1, 1, h - 1));
       CGContextFillRect(cgContext, CGRectMake(x + w - 1, y + 1, 1, h - 1));
       CGContextFillRect(cgContext, CGRectMake(x + 1, y + h - 1, w - 2, 1));
     }
       break;
     
     case NS_THEME_TAB:
-      DrawTab(cgContext, macRect, eventState, aFrame);
+      DrawSegment(cgContext, macRect, eventState, aFrame, tabRenderSettings);
       break;
 
     case NS_THEME_TAB_PANELS:
       DrawTabPanel(cgContext, macRect, aFrame);
       break;
 
     case NS_THEME_RESIZER:
       DrawResizer(cgContext, macRect, aFrame);
@@ -2190,16 +2193,22 @@ nsNativeThemeCocoa::GetWidgetBorder(nsDe
       if (IsButtonTypeMenu(aFrame)) {
         *aResult = RTLAwareMargin(kAquaDropdownBorder, aFrame);
       } else {
         aResult->SizeTo(7, 1, 7, 3);
       }
       break;
     }
 
+    case NS_THEME_TOOLBAR_BUTTON:
+    {
+      aResult->SizeTo(4, 1, 4, 1);
+      break;
+    }
+
     case NS_THEME_CHECKBOX:
     case NS_THEME_RADIO:
     {
       // nsFormControlFrame::GetIntrinsicWidth and nsFormControlFrame::GetIntrinsicHeight
       // assume a border width of 2px.
       aResult->SizeTo(2, 2, 2, 2);
       break;
     }
@@ -2306,16 +2315,17 @@ nsNativeThemeCocoa::GetWidgetPadding(nsD
 }
 
 PRBool
 nsNativeThemeCocoa::GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame,
                                       PRUint8 aWidgetType, nsRect* aOverflowRect)
 {
   switch (aWidgetType) {
     case NS_THEME_BUTTON:
+    case NS_THEME_TOOLBAR_BUTTON:
     case NS_THEME_TEXTFIELD:
     case NS_THEME_TEXTFIELD_MULTILINE:
     case NS_THEME_SEARCHFIELD:
     case NS_THEME_LISTBOX:
     case NS_THEME_DROPDOWN:
     case NS_THEME_DROPDOWN_BUTTON:
     case NS_THEME_DROPDOWN_TEXTFIELD:
     case NS_THEME_CHECKBOX:
@@ -2356,16 +2366,22 @@ nsNativeThemeCocoa::GetMinimumWidgetSize
   switch (aWidgetType) {
     case NS_THEME_BUTTON:
     {
       aResult->SizeTo(pushButtonSettings.minimumSizes[miniControlSize].width,
                       pushButtonSettings.naturalSizes[miniControlSize].height);
       break;
     }
 
+    case NS_THEME_TOOLBAR_BUTTON:
+    {
+      aResult->SizeTo(0, toolbarButtonHeights[miniControlSize]);
+      break;
+    }
+
     case NS_THEME_SPINNER:
     {
       SInt32 buttonHeight = 0, buttonWidth = 0;
       ::GetThemeMetric(kThemeMetricLittleArrowsWidth, &buttonWidth);
       ::GetThemeMetric(kThemeMetricLittleArrowsHeight, &buttonHeight);
       aResult->SizeTo(buttonWidth, buttonHeight);
       *aIsOverridable = PR_FALSE;
       break;
@@ -2416,17 +2432,17 @@ nsNativeThemeCocoa::GetMinimumWidgetSize
       SInt32 headerHeight = 0;
       ::GetThemeMetric(kThemeMetricListHeaderHeight, &headerHeight);
       aResult->SizeTo(0, headerHeight - 1); // We don't need the top border.
       break;
     }
 
     case NS_THEME_TAB:
     {
-      aResult->SizeTo(0, NATURAL_MINI_TAB_BUTTON_HEIGHT);
+      aResult->SizeTo(0, tabHeights[miniControlSize]);
       break;
     }
 
     case NS_THEME_SCALE_HORIZONTAL:
     {
       SInt32 scaleHeight = 0;
       ::GetThemeMetric(kThemeMetricHSliderHeight, &scaleHeight);
       aResult->SizeTo(scaleHeight, scaleHeight);
@@ -2539,17 +2555,16 @@ NS_IMETHODIMP
 nsNativeThemeCocoa::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType, 
                                      nsIAtom* aAttribute, PRBool* aShouldRepaint)
 {
   // Some widget types just never change state.
   switch (aWidgetType) {
     case NS_THEME_TOOLBOX:
     case NS_THEME_TOOLBAR:
     case NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR:
-    case NS_THEME_TOOLBAR_BUTTON:
     case NS_THEME_SCROLLBAR_TRACK_VERTICAL: 
     case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
     case NS_THEME_STATUSBAR:
     case NS_THEME_STATUSBAR_PANEL:
     case NS_THEME_STATUSBAR_RESIZER_PANEL:
     case NS_THEME_TOOLTIP:
     case NS_THEME_TAB_PANELS:
     case NS_THEME_TAB_PANEL:
@@ -2625,16 +2640,17 @@ nsNativeThemeCocoa::ThemeSupportsWidget(
     
     case NS_THEME_CHECKBOX:
     case NS_THEME_CHECKBOX_CONTAINER:
     case NS_THEME_RADIO:
     case NS_THEME_RADIO_CONTAINER:
     case NS_THEME_GROUPBOX:
     case NS_THEME_BUTTON:
     case NS_THEME_BUTTON_BEVEL:
+    case NS_THEME_TOOLBAR_BUTTON:
     case NS_THEME_SPINNER:
     case NS_THEME_TOOLBAR:
     case NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR:
     case NS_THEME_STATUSBAR:
     case NS_THEME_TEXTFIELD:
     case NS_THEME_TEXTFIELD_MULTILINE:
     case NS_THEME_SEARCHFIELD:
     //case NS_THEME_TOOLBOX:
--- a/widget/src/cocoa/nsNativeThemeColors.h
+++ b/widget/src/cocoa/nsNativeThemeColors.h
@@ -36,58 +36,61 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsNativeThemeColors_h_
 #define nsNativeThemeColors_h_
 
 #include "nsToolkit.h"
 #import <Cocoa/Cocoa.h>
 
+extern "C" {
+  typedef CFTypeRef CUIRendererRef;
+  void CUIDraw(CUIRendererRef r, CGRect rect, CGContextRef ctx, CFDictionaryRef options, CFDictionaryRef* result);
+}
+
+@interface NSWindow(CoreUIRendererPrivate)
++ (CUIRendererRef)coreUIRenderer;
+@end
+
 enum ColorName {
-  headerStartGrey,
-  headerEndGrey,
-  headerBorderGrey,
   toolbarTopBorderGrey,
-  statusbarFirstTopBorderGrey,
-  statusbarSecondTopBorderGrey,
-  statusbarGradientStartGrey,
-  statusbarGradientEndGrey
+  toolbarFillGrey,
+  toolbarBottomBorderGrey,
 };
 
 static const int sLeopardThemeColors[][2] = {
   /* { active window, inactive window } */
-  // titlebar and toolbar:
-  { 0xC5, 0xE9 }, // start grey
-  { 0x96, 0xCA }, // end grey
-  { 0x42, 0x89 }, // bottom separator line
+  // toolbar:
   { 0xC0, 0xE2 }, // top separator line
-  // statusbar:
-  { 0x42, 0x86 }, // first top border
-  { 0xD8, 0xEE }, // second top border
-  { 0xBD, 0xE4 }, // gradient start
-  { 0x96, 0xCF }  // gradient end
+  { 0x96, 0xCA }, // fill color
+  { 0x42, 0x89 }, // bottom separator line
 };
 
 static const int sSnowLeopardThemeColors[][2] = {
   /* { active window, inactive window } */
-  // titlebar and toolbar:
-  { 0xD1, 0xEE }, // start grey
-  { 0xA7, 0xD8 }, // end grey
-  { 0x51, 0x99 }, // bottom separator line
+  // toolbar:
   { 0xD0, 0xF1 }, // top separator line
-  // statusbar:
-  { 0x51, 0x99 }, // first top border
-  { 0xE8, 0xF6 }, // second top border
-  { 0xCB, 0xEA }, // gradient start
-  { 0xA7, 0xDE }  // gradient end
+  { 0xA7, 0xD8 }, // fill color
+  { 0x51, 0x99 }, // bottom separator line
+};
+
+static const int sLionThemeColors[][2] = {
+  /* { active window, inactive window } */
+  // toolbar:
+  { 0xD0, 0xF0 }, // top separator line
+  { 0xB2, 0xE1 }, // fill color
+  { 0x59, 0x87 }, // bottom separator line
 };
 
 __attribute__((unused))
 static int NativeGreyColorAsInt(ColorName name, BOOL isMain)
 {
+  if (nsToolkit::OnLionOrLater())
+    return sLionThemeColors[name][isMain ? 0 : 1];
+
   if (nsToolkit::OnSnowLeopardOrLater())
     return sSnowLeopardThemeColors[name][isMain ? 0 : 1];
 
   return sLeopardThemeColors[name][isMain ? 0 : 1];
 }
 
 __attribute__((unused))
 static float NativeGreyColorAsFloat(ColorName name, BOOL isMain)
--- a/widget/src/cocoa/nsToolkit.h
+++ b/widget/src/cocoa/nsToolkit.h
@@ -78,16 +78,15 @@ protected:
 
 protected:
 
   bool               mInited;
 
   CFRunLoopSourceRef mSleepWakeNotificationRLS;
   io_object_t        mPowerNotifier;
 
-  EventHandlerRef    mEventMonitorHandler;
   CFMachPortRef      mEventTapPort;
   CFRunLoopSourceRef mEventTapRLS;
 };
 
 extern nsToolkit* NS_CreateToolkitInstance();
 
 #endif // nsToolkit_h_
--- a/widget/src/cocoa/nsToolkit.mm
+++ b/widget/src/cocoa/nsToolkit.mm
@@ -82,17 +82,16 @@ static io_connect_t gRootPort = MACH_POR
 
 // Static thread local storage index of the Toolkit 
 // object associated with a given thread...
 static PRUintn gToolkitTLSIndex = 0;
 
 nsToolkit::nsToolkit()
 : mInited(false)
 , mSleepWakeNotificationRLS(nsnull)
-, mEventMonitorHandler(nsnull)
 , mEventTapPort(nsnull)
 , mEventTapRLS(nsnull)
 {
 }
 
 nsToolkit::~nsToolkit()
 {
   RemoveSleepWakeNotifcations();
@@ -197,28 +196,16 @@ nsToolkit::RemoveSleepWakeNotifcations()
                             kCFRunLoopDefaultMode);
 
     mSleepWakeNotificationRLS = nsnull;
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-// This is the callback used in RegisterForAllProcessMouseEvents.
-static OSStatus EventMonitorHandler(EventHandlerCallRef aCaller, EventRef aEvent, void* aRefcon)
-{
-  // Up to Mac OS 10.4 (or when building with the 10.4 SDK), installing a Carbon
-  // event handler like this one caused the OS to post the equivalent Cocoa
-  // events to [NSApp sendEvent:]. When using the 10.5 SDK, this doesn't happen
-  // any more, so we need to do it manually.
-  [NSApp sendEvent:[NSEvent eventWithEventRef:aEvent]];
-
-  return eventNotHandledErr;
-}
-
 // Converts aPoint from the CoreGraphics "global display coordinate" system
 // (which includes all displays/screens and has a top-left origin) to its
 // (presumed) Cocoa counterpart (assumed to be the same as the "screen
 // coordinates" system), which has a bottom-left origin.
 static NSPoint ConvertCGGlobalToCocoaScreen(CGPoint aPoint)
 {
   NSPoint cocoaPoint;
   cocoaPoint.x = aPoint.x;
@@ -270,22 +257,16 @@ nsToolkit::RegisterForAllProcessMouseEve
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   // Don't do this for apps that (like Camino) use native context menus.
 #ifdef MOZ_USE_NATIVE_POPUP_WINDOWS
   return;
 #endif /* MOZ_USE_NATIVE_POPUP_WINDOWS */
 
-  if (!mEventMonitorHandler) {
-    EventTypeSpec kEvents[] = {{kEventClassMouse, kEventMouseMoved}};
-    InstallEventHandler(GetEventMonitorTarget(), EventMonitorHandler,
-                        GetEventTypeCount(kEvents), kEvents, 0,
-                        &mEventMonitorHandler);
-  }
   if (!mEventTapRLS) {
     // Using an event tap for mouseDown events (instead of installing a
     // handler for them on the EventMonitor target) works around an Apple
     // bug that causes OS menus (like the Clock menu) not to work properly
     // on OS X 10.4.X and below (bmo bug 381448).
     // We install our event tap "listen only" to get around yet another Apple
     // bug -- when we install it as an event filter on any kind of mouseDown
     // event, that kind of event stops working in the main menu, and usually
@@ -315,20 +296,16 @@ nsToolkit::RegisterForAllProcessMouseEve
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 void
 nsToolkit::UnregisterAllProcessMouseEventHandlers()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
-  if (mEventMonitorHandler) {
-    RemoveEventHandler(mEventMonitorHandler);
-    mEventMonitorHandler = nsnull;
-  }
   if (mEventTapRLS) {
     CFRunLoopRemoveSource(CFRunLoopGetCurrent(), mEventTapRLS,
                           kCFRunLoopDefaultMode);
     CFRelease(mEventTapRLS);
     mEventTapRLS = nsnull;
   }
   if (mEventTapPort) {
     // mEventTapPort must be invalidated as well as released.  Otherwise the
--- a/widget/src/xpwidgets/nsNativeTheme.cpp
+++ b/widget/src/xpwidgets/nsNativeTheme.cpp
@@ -203,16 +203,28 @@ nsNativeTheme::IsButtonTypeMenu(nsIFrame
     return PR_FALSE;
 
   nsIContent* content = aFrame->GetContent();
   return content->AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::type,
                               NS_LITERAL_STRING("menu"), eCaseMatters);
 }
 
 PRBool
+nsNativeTheme::IsPressedButton(nsIFrame* aFrame)
+{
+  nsEventStates eventState = GetContentState(aFrame, NS_THEME_TOOLBAR_BUTTON);
+  if (IsDisabled(aFrame, eventState))
+    return PR_FALSE;
+
+  return IsOpenButton(aFrame) ||
+         eventState.HasAllStates(NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_HOVER);
+}
+
+
+PRBool
 nsNativeTheme::GetIndeterminate(nsIFrame* aFrame)
 {
   if (!aFrame)
     return PR_FALSE;
 
   nsIContent* content = aFrame->GetContent();
 
   if (content->IsXUL()) {
@@ -405,29 +417,16 @@ nsNativeTheme::IsFirstTab(nsIFrame* aFra
     if (first->GetRect().width > 0 && first->GetContent()->Tag() == nsWidgetAtoms::tab)
       return (first == aFrame);
     first = first->GetNextSibling();
   }
   return PR_FALSE;
 }
 
 PRBool
-nsNativeTheme::IsLastTab(nsIFrame* aFrame)
-{
-  if (!aFrame)
-    return PR_FALSE;
-
-  while ((aFrame = aFrame->GetNextSibling())) {
-    if (aFrame->GetRect().width > 0 && aFrame->GetContent()->Tag() == nsWidgetAtoms::tab)
-      return PR_FALSE;
-  }
-  return PR_TRUE;
-}
-
-PRBool
 nsNativeTheme::IsHorizontal(nsIFrame* aFrame)
 {
   if (!aFrame)
     return PR_FALSE;
     
   return !aFrame->GetContent()->AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::orient,
                                             nsWidgetAtoms::vertical, 
                                             eCaseMatters);
@@ -584,8 +583,30 @@ nsNativeTheme::Notify(nsITimer* aTimer)
       frame->InvalidateOverflowRect();
     }
   }
 
   mAnimatedContentList.Clear();
   mAnimatedContentTimeout = PR_UINT32_MAX;
   return NS_OK;
 }
+
+nsIFrame*
+nsNativeTheme::GetAdjacentSiblingFrameWithSameAppearance(nsIFrame* aFrame,
+                                                         PRBool aNextSibling)
+{
+  if (!aFrame)
+    return nsnull;
+
+  // Find the next visible sibling.
+  nsIFrame* sibling = aFrame;
+  do {
+    sibling = aNextSibling ? sibling->GetNextSibling() : sibling->GetPrevSibling();
+  } while (sibling && sibling->GetRect().width == 0);
+
+  // Check same appearance and adjacency.
+  if (!sibling ||
+      sibling->GetStyleDisplay()->mAppearance != aFrame->GetStyleDisplay()->mAppearance ||
+      (sibling->GetRect().XMost() != aFrame->GetRect().x &&
+       aFrame->GetRect().XMost() != sibling->GetRect().x))
+    return nsnull;
+  return sibling;
+}
--- a/widget/src/xpwidgets/nsNativeTheme.h
+++ b/widget/src/xpwidgets/nsNativeTheme.h
@@ -140,28 +140,34 @@ class nsNativeTheme : public nsITimerCal
     return IsFrameRTL(aFrame) ? IsBeforeSelectedTab(aFrame) : IsAfterSelectedTab(aFrame);
   }
 
   // button / toolbarbutton:
   PRBool IsCheckedButton(nsIFrame* aFrame) {
     return CheckBooleanAttr(aFrame, nsWidgetAtoms::checked);
   }
 
+  PRBool IsSelectedButton(nsIFrame* aFrame) {
+    return CheckBooleanAttr(aFrame, nsWidgetAtoms::checked) ||
+           CheckBooleanAttr(aFrame, nsWidgetAtoms::selected);
+  }
+
   PRBool IsOpenButton(nsIFrame* aFrame) {
     return CheckBooleanAttr(aFrame, nsWidgetAtoms::open);
   }
 
+  PRBool IsPressedButton(nsIFrame* aFrame);
+
   // treeheadercell:
   TreeSortDirection GetTreeSortDirection(nsIFrame* aFrame);
   PRBool IsLastTreeHeaderCell(nsIFrame* aFrame);
 
   // tab:
   PRBool IsBottomTab(nsIFrame* aFrame);
   PRBool IsFirstTab(nsIFrame* aFrame);
-  PRBool IsLastTab(nsIFrame* aFrame);
   
   PRBool IsHorizontal(nsIFrame* aFrame);
 
   // progressbar:
   PRBool IsIndeterminateProgress(nsIFrame* aFrame, nsEventStates aEventStates);
   PRBool IsVerticalProgress(nsIFrame* aFrame);
 
   // textfield:
@@ -182,13 +188,16 @@ class nsNativeTheme : public nsITimerCal
   PRBool CheckBooleanAttr(nsIFrame* aFrame, nsIAtom* aAtom);
 
   PRBool GetCheckedOrSelected(nsIFrame* aFrame, PRBool aCheckSelected);
   PRBool GetIndeterminate(nsIFrame* aFrame);
 
   PRBool QueueAnimatedContentForRefresh(nsIContent* aContent,
                                         PRUint32 aMinimumFrameRate);
 
+  nsIFrame* GetAdjacentSiblingFrameWithSameAppearance(nsIFrame* aFrame,
+                                                      PRBool aNextSibling);
+
  private:
   PRUint32 mAnimatedContentTimeout;
   nsCOMPtr<nsITimer> mAnimatedContentTimer;
   nsAutoTArray<nsCOMPtr<nsIContent>, 20> mAnimatedContentList;
 };
--- a/widget/tests/native_mouse_mac_window.xul
+++ b/widget/tests/native_mouse_mac_window.xul
@@ -67,22 +67,24 @@
       window.opener.wrappedJSObject.SimpleTest.todo(condition, message);
     }
 
     function todo_is(a, b, message) {
       window.opener.wrappedJSObject.SimpleTest.todo_is(a, b, message);
     }
 
     function onTestsFinished() {
+      clearTimeout(gAfterLoopExecution);
       observe(window, eventMonitor, false);
       observe(gRightWindow, eventMonitor, false);
       observe(gPopup, eventMonitor, false);
       gRightWindow.close();
+      var openerSimpleTest = window.opener.wrappedJSObject.SimpleTest;
       window.close();
-      window.opener.wrappedJSObject.SimpleTest.finish();
+      openerSimpleTest.finish();
     }
 
     const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
     const xulWin = 'data:application/vnd.mozilla.xul+xml,<?xml version="1.0"?><?xml-stylesheet href="chrome://global/skin" type="text/css"?><window xmlns="' + XUL_NS + '"/>';
 
     const NSLeftMouseDown      = 1,
           NSLeftMouseUp        = 2,
           NSRightMouseDown     = 3,
@@ -123,33 +125,37 @@
           NSFunctionKeyMask   = 1 << 23;
 
     const gDebug = false;
 
     function printDebug(msg) { if (gDebug) dump(msg); }
 
     var gExpectedEvents = [];
     var gRightWindow = null, gPopup = null;
+    var gCurrentMouseX = 0, gCurrentMouseY = 0;
+    var gAfterLoopExecution = 0;
 
     function testMouse(x, y, msg, elem, win, exp, flags, callback) {
       clearExpectedEvents();
       exp.forEach(function (expEv) {
         expEv.screenX = x;
         expEv.screenY = y;
         gExpectedEvents.push(expEv);
       });
       printDebug("sending event: " + x + ", " + y + " (" + msg + ")\n");
+      gCurrentMouseX = x;
+      gCurrentMouseY = y;
       netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
       var utils = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
                                      getInterface(Components.interfaces.nsIDOMWindowUtils);
       utils.sendNativeMouseEvent(x, y, msg, flags || 0, elem);
-      SimpleTest.executeSoon(function () {
+      gAfterLoopExecution = setTimeout(function () {
         clearExpectedEvents();
         callback();
-      });
+      }, 0);
     }
 
     function eventListenOnce(elem, name, callback) {
       elem.addEventListener(name, function(e) {
         elem.removeEventListener(name, arguments.callee, false);
         callback(e);
       }, false);
     }
@@ -177,20 +183,25 @@
     var gEventNum = 0;
 
     function eventMonitor(e) {
       printDebug("got event: " + eventToString(e) + "\n");
       processEvent(e);
     }
 
     function processEvent(e) {
+      if (e.screenX != gCurrentMouseX || e.screenY != gCurrentMouseY) {
+        todo(false, "Oh no! Received a stray event from a confused tracking area. Aborting test.");
+        onTestsFinished();
+        return;
+      }
       var expectedEvent = gExpectedEvents.shift();
       if (!expectedEvent) {
         ok(false, "received event I didn't expect: " + eventToString(e));
-        return true;
+        return;
       }
       if (e.type != expectedEvent.type) {
         // Didn't get expectedEvent.
         var errFun = expectedEvent.shouldFireButDoesnt ? todo : ok;
         errFun(false, "Didn't receive expected event: " + eventToString(expectedEvent));
         return processEvent(e);
       }
       gEventNum++;
@@ -301,16 +312,20 @@
         [410, 150, NSLeftMouseDragged, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
         // Let go of the mouse.
         [410, 150, NSLeftMouseUp, null, right, [
           { type: "mouseup", target: rightElem },
           { type: "click", target: rightElem },
         ]],
+        // Move the mouse back over the left window, which is inactive.
+        [150, 170, NSMouseMoved, null, left, [
+          { type: "mouseout", target: rightElem },
+        ]],
         // Now we're being sneaky. The left window is inactive, but *right*-clicks to it
         // should still get through. Test that.
         // Ideally we'd be bracketing that event with over and out events, too, but it
         // probably doesn't matter too much.
         [150, 170, NSRightMouseDown, null, left, [
           { type: "mouseover", target: leftElem, shouldFireButDoesnt: true },
           { type: "mousedown", target: leftElem },
           { type: "mouseout", target: leftElem, shouldFireButDoesnt: true },
@@ -322,17 +337,16 @@
           { type: "click", target: leftElem },
           { type: "mouseout", target: leftElem, shouldFireButDoesnt: true },
         ]],
         // Right clicking hasn't focused it, so the window is still inactive.
         // Let's focus it; this time without the mouse, for variaton's sake.
         // Still, mouseout and mouseover events should fire.
         function raiseLeftWindow(callback) {
           clearExpectedEvents();
-          gExpectedEvents.push({ screenX: 150, screenY: 170, type: "mouseout", target: rightElem });
           gExpectedEvents.push({ screenX: 150, screenY: 170, type: "mouseover", target: leftElem });
           focusAndThen(left, function () { SimpleTest.executeSoon(callback); });
         },
         // It's active, so it should respond to mousemove events now.
         [150, 170, NSMouseMoved, null, left, [
           { type: "mousemove", target: leftElem },
         ]],
         // This was boring... let's introduce a popup. It will overlap both the left
@@ -386,35 +400,30 @@
           { type: "mouseup", target: rightElem },
           { type: "click", target: rightElem },
         ]],
 
         // Time for our next trick: a tooltip!
         // Install the tooltip, but don't show it yet.
         function setTooltip(callback) {
           rightElem.setAttribute("tooltip", "tip");
-          callback();
+          gExpectedEvents.push({ screenX: 410, screenY: 180, type: "mousemove", target: rightElem });
+          eventListenOnce(rightElem, "popupshown", callback);
+          gCurrentMouseX = 410;
+          gCurrentMouseY = 180;
+          var utils = right.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
+                               getInterface(Components.interfaces.nsIDOMWindowUtils);
+          utils.sendNativeMouseEvent(410, 180, NSMouseMoved, 0, null);
         },
-        // Move the mouse to trigger the appearance of the tooltip.
-        [410, 180, NSMouseMoved, null, right, [
+        // Now the tooltip is visible.
+        // Move the mouse a little to the right.
+        [411, 180, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
-        // Wait for the tooltip to appear.
-        function (callback) {
-          eventListenOnce(rightElem, "popupshown", callback);
-        },
-        // Now the tooltip is visible.
-        // Move the mouse a little to the right, but send the event to the tooltip's
-        // widget, even though the mouse is not over the tooltip, because that's what
-        // Mac OS X does.
-        [411, 180, NSMouseMoved, tooltip, right, [
-          { type: "mousemove", target: rightElem },
-        ]],
-        // Move another pixel. This time send the event to the right widget.
-        // However, that must not make a difference.
+        // Move another pixel.
         [412, 180, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
         // Move up and click to make the tooltip go away.
         [412, 80, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
         [412, 80, NSLeftMouseDown, null, right, [
@@ -429,51 +438,50 @@
           eventListenOnce(panel, "popupshown", callback);
           panel.openPopupAtScreen(150, 150, false);
         },
         // The panel is parented, so it will be z-ordered over its parent but
         // under the active window.
         // Now we move the mouse over the part where the panel rect intersects the
         // right window's rect. Since the panel is under the window, all the events
         // should target the right window.
-        // Try with sending to three different targets.
         [390, 170, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
-        [390, 171, NSMouseMoved, null, left, [
+        [390, 171, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
-        [391, 171, NSMouseMoved, panel, left, [
+        [391, 171, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
         // Now move off the right window, so that the mouse is directly over the
         // panel.
-        [260, 170, NSMouseMoved, null, left, [
+        [260, 170, NSMouseMoved, panel, left, [
           { type: "mouseout", target: rightElem },
         ]],
-        [260, 171, NSMouseMoved, null, left, [
+        [260, 171, NSMouseMoved, panel, left, [
         ]],
         [261, 171, NSMouseMoved, panel, left, [
         ]],
         // Let's be evil and click it.
         [261, 171, NSLeftMouseDown, panel, left, [
         ]],
         [261, 171, NSLeftMouseUp, panel, left, [
         ]],
         // This didn't focus the window, unfortunately, so let's do it ourselves.
         function raiseLeftWindowTakeTwo(callback) {
           focusAndThen(left, callback);
         },
         // Now mouse events should get through to the panel (which is now over the
         // right window).
-        [387, 170, NSMouseMoved, null, right, [
+        [387, 170, NSMouseMoved, panel, left, [
           { type: "mouseover", target: panel },
           { type: "mousemove", target: panel },
         ]],
-        [387, 171, NSMouseMoved, null, left, [
+        [387, 171, NSMouseMoved, panel, left, [
           { type: "mousemove", target: panel },
         ]],
         [388, 171, NSMouseMoved, panel, left, [
           { type: "mousemove", target: panel },
         ]],
         // Click the panel.
         [388, 171, NSLeftMouseDown, panel, left, [
           { type: "mousedown", target: panel }
@@ -481,22 +489,22 @@
         [388, 171, NSLeftMouseUp, panel, left, [
           { type: "mouseup", target: panel },
           { type: "click", target: panel },
         ]],
 
         // Last test for this part: Hit testing in the Canyon of Nowhere -
         // the pixel row directly south of the panel, over the left window.
         // Before bug 515003 we wrongly thought the mouse wasn't over any window.
-        [173, 200, NSMouseMoved, panel, left, [
+        [173, 200, NSMouseMoved, null, left, [
           { type: "mouseout", target: panel },
           { type: "mouseover", target: leftElem },
           { type: "mousemove", target: leftElem },
         ]],
-        [173, 201, NSMouseMoved, panel, left, [
+        [173, 201, NSMouseMoved, null, left, [
           { type: "mousemove", target: leftElem },
         ]],
 
         // Part 2: Allow click-through
 
         function hideThatPanel(callback) {
           eventListenOnce(panel, "popuphidden", callback);
           panel.hidePopup();
@@ -562,42 +570,38 @@
         [410, 150, NSLeftMouseDragged, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
         // Let go of the mouse.
         [410, 150, NSLeftMouseUp, null, right, [
           { type: "mouseup", target: rightElem },
           { type: "click", target: rightElem },
         ]],
-        // Now we're being sneaky. The left window is inactive, but *right*-clicks to it
-        // should still get through. Test that.
-        // Ideally we'd be bracketing that event with over and out events, too, but it
-        // probably doesn't matter too much.
+        // Move the mouse back over the left window, which is inactive.
+        [150, 170, NSMouseMoved, null, left, [
+          { type: "mouseout", target: rightElem },
+          { type: "mouseover", target: leftElem },
+          { type: "mousemove", target: leftElem },
+        ]],
+        // Right-click it.
         [150, 170, NSRightMouseDown, null, left, [
-          { type: "mouseover", target: leftElem, shouldFireButDoesnt: true },
           { type: "mousedown", target: leftElem },
-          { type: "mouseout", target: leftElem, shouldFireButDoesnt: true },
         ]],
         // Let go of the mouse.
         [150, 170, NSRightMouseUp, null, left, [
-          { type: "mouseover", target: leftElem, shouldFireButDoesnt: true },
           { type: "mouseup", target: leftElem },
           { type: "click", target: leftElem },
-          { type: "mouseout", target: leftElem, shouldFireButDoesnt: true },
         ]],
         // Right clicking hasn't focused it, so the window is still inactive.
         // Let's focus it; this time without the mouse, for variaton's sake.
-        // Still, mouseout and mouseover events should fire.
         function raiseLeftWindow(callback) {
           clearExpectedEvents();
-          gExpectedEvents.push({ screenX: 150, screenY: 170, type: "mouseout", target: rightElem });
-          gExpectedEvents.push({ screenX: 150, screenY: 170, type: "mouseover", target: leftElem });
           focusAndThen(left, function () { SimpleTest.executeSoon(callback); });
         },
-        // It's active, so it should respond to mousemove events now.
+        // It's active and should still respond to mousemove events.
         [150, 170, NSMouseMoved, null, left, [
           { type: "mousemove", target: leftElem },
         ]],
 
         // This was boring... let's introduce a popup. It will overlap both the left
         // and the right window.
         function openPopupInLeftWindow(callback) {
           eventListenOnce(gPopup, "popupshown", callback);
@@ -648,37 +652,32 @@
         ]],
         [400, 180, NSLeftMouseUp, null, right, [
           { type: "mouseup", target: rightElem },
           { type: "click", target: rightElem },
         ]],
 
         // Time for our next trick: a tooltip!
         // Install the tooltip, but don't show it yet.
-        function setTooltip(callback) {
+        function setTooltip2(callback) {
           rightElem.setAttribute("tooltip", "tip");
-          callback();
+          gExpectedEvents.push({ screenX: 410, screenY: 180, type: "mousemove", target: rightElem });
+          eventListenOnce(rightElem, "popupshown", callback);
+          gCurrentMouseX = 410;
+          gCurrentMouseY = 180;
+          var utils = right.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
+                               getInterface(Components.interfaces.nsIDOMWindowUtils);
+          utils.sendNativeMouseEvent(410, 180, NSMouseMoved, 0, null);
         },
-        // Move the mouse to trigger the appearance of the tooltip.
-        [410, 180, NSMouseMoved, null, right, [
+        // Now the tooltip is visible.
+        // Move the mouse a little to the right.
+        [411, 180, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
-        // Wait for the tooltip to appear.
-        function (callback) {
-          eventListenOnce(rightElem, "popupshown", callback);
-        },
-        // Now the tooltip is visible.
-        // Move the mouse a little to the right, but send the event to the tooltip's
-        // widget, even though the mouse is not over the tooltip, because that's what
-        // Mac OS X does.
-        [411, 180, NSMouseMoved, tooltip, right, [
-          { type: "mousemove", target: rightElem },
-        ]],
-        // Move another pixel. This time send the event to the right widget.
-        // However, that must not make a difference.
+        // Move another pixel.
         [412, 180, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
         // Move up and click to make the tooltip go away.
         [412, 80, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
         [412, 80, NSLeftMouseDown, null, right, [
@@ -693,34 +692,33 @@
           eventListenOnce(panel, "popupshown", callback);
           panel.openPopupAtScreen(150, 150, false);
         },
         // The panel is parented, so it will be z-ordered over its parent but
         // under the active window.
         // Now we move the mouse over the part where the panel rect intersects the
         // right window's rect. Since the panel is under the window, all the events
         // should target the right window.
-        // Try with sending to three different targets.
         [390, 170, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
-        [390, 171, NSMouseMoved, null, left, [
+        [390, 171, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
-        [391, 171, NSMouseMoved, panel, left, [
+        [391, 171, NSMouseMoved, null, right, [
           { type: "mousemove", target: rightElem },
         ]],
         // Now move off the right window, so that the mouse is directly over the
         // panel.
-        [260, 170, NSMouseMoved, null, left, [
+        [260, 170, NSMouseMoved, panel, left, [
           { type: "mouseout", target: rightElem },
           { type: "mouseover", target: panel },
           { type: "mousemove", target: panel },
         ]],
-        [260, 171, NSMouseMoved, null, left, [
+        [260, 171, NSMouseMoved, panel, left, [
           { type: "mousemove", target: panel },
         ]],
         [261, 171, NSMouseMoved, panel, left, [
           { type: "mousemove", target: panel },
         ]],
         // Let's be evil and click it.
         [261, 171, NSLeftMouseDown, panel, left, [
           { type: "mousedown", target: panel },
@@ -728,20 +726,20 @@
         [261, 171, NSLeftMouseUp, panel, left, [
           { type: "mouseup", target: panel },
           { type: "click", target: panel },
         ]],
         // This didn't focus the window, unfortunately, so let's do it ourselves.
         function raiseLeftWindowTakeTwo(callback) {
           focusAndThen(left, callback);
         },
-        [387, 170, NSMouseMoved, null, right, [
+        [387, 170, NSMouseMoved, panel, left, [
           { type: "mousemove", target: panel },
         ]],
-        [387, 171, NSMouseMoved, null, left, [
+        [387, 171, NSMouseMoved, panel, left, [
           { type: "mousemove", target: panel },
         ]],
         [388, 171, NSMouseMoved, panel, left, [
           { type: "mousemove", target: panel },
         ]],
         // Click the panel.
         [388, 171, NSLeftMouseDown, panel, left, [
           { type: "mousedown", target: panel }
@@ -749,22 +747,22 @@
         [388, 171, NSLeftMouseUp, panel, left, [
           { type: "mouseup", target: panel },
           { type: "click", target: panel },
         ]],
 
         // Last test for today: Hit testing in the Canyon of Nowhere -
         // the pixel row directly south of the panel, over the left window.
         // Before bug 515003 we wrongly thought the mouse wasn't over any window.
-        [173, 200, NSMouseMoved, panel, left, [
+        [173, 200, NSMouseMoved, null, left, [
           { type: "mouseout", target: panel },
           { type: "mouseover", target: leftElem },
           { type: "mousemove", target: leftElem },
         ]],
-        [173, 201, NSMouseMoved, panel, left, [
+        [173, 201, NSMouseMoved, null, left, [
           { type: "mousemove", target: leftElem },
         ]],
       ];
       function runNextTest() {
         if (!tests.length)
           return onTestsFinished();
 
         var test = tests.shift();
--- a/xpfe/appshell/src/nsWebShellWindow.cpp
+++ b/xpfe/appshell/src/nsWebShellWindow.cpp
@@ -51,17 +51,16 @@
 #include "nsNetCID.h"
 #include "nsIStringBundle.h"
 #include "nsReadableUtils.h"
 
 #include "nsEscape.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIPrivateDOMEvent.h"
-#include "nsIDOMFocusListener.h"
 #include "nsIWebNavigation.h"
 #include "nsIWindowWatcher.h"
 
 #include "nsIDOMXULElement.h"
 
 #include "nsGUIEvent.h"
 #include "nsWidgetsCID.h"
 #include "nsIWidget.h"