Merge from mozilla-central.
authorDavid Anderson <danderson@mozilla.com>
Tue, 20 Mar 2012 14:43:39 -0700
changeset 112299 cea47dfc3fb7a47fd12e48fd7305a703f637788c
parent 112298 3e4a9ba45f2bad8102d96d59468a16550472a254 (current diff)
parent 93129 4bdae514b9be7faa5630710a9bf02b52dfab0a47 (diff)
child 112300 c223b4370b3ada9227632136a9b51511cb5d0524
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge from mozilla-central.
accessible/src/atk/nsAccessibleWrap.cpp
accessible/src/atk/nsMaiInterfaceAction.h
accessible/src/atk/nsMaiInterfaceComponent.h
accessible/src/atk/nsMaiInterfaceDocument.h
accessible/src/atk/nsMaiInterfaceEditableText.h
accessible/src/atk/nsMaiInterfaceHyperlinkImpl.h
accessible/src/atk/nsMaiInterfaceHypertext.h
accessible/src/atk/nsMaiInterfaceImage.h
accessible/src/atk/nsMaiInterfaceSelection.h
accessible/src/atk/nsMaiInterfaceTable.cpp
accessible/src/atk/nsMaiInterfaceTable.h
accessible/src/atk/nsMaiInterfaceText.h
accessible/src/atk/nsMaiInterfaceValue.h
accessible/src/base/nsAccessNode.cpp
accessible/src/base/nsAccessible.cpp
accessible/src/base/nsCoreUtils.cpp
accessible/src/base/nsCoreUtils.h
accessible/src/html/nsHTMLSelectAccessible.cpp
accessible/src/html/nsHTMLSelectAccessible.h
b2g/installer/package-manifest.in
browser/components/tabview/groupitems.js
build/mobile/devicemanagerADB.py
build/mobile/devicemanagerSUT.py
caps/include/nsScriptSecurityManager.h
caps/src/nsJSPrincipals.cpp
caps/src/nsScriptSecurityManager.cpp
config/autoconf.mk.in
configure.in
content/base/src/nsImageLoadingContent.cpp
content/base/src/nsImageLoadingContent.h
content/base/src/nsTreeSanitizer.cpp
content/events/src/nsContentEventHandler.cpp
content/events/src/nsDOMMouseEvent.cpp
content/events/src/nsDOMUIEvent.cpp
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsHTMLMediaElement.cpp
content/media/MediaResource.cpp
content/media/MediaResource.h
content/media/nsMediaCache.cpp
content/media/nsMediaCache.h
content/smil/nsSMILAnimationFunction.cpp
content/smil/nsSMILTimedElement.cpp
content/svg/content/src/nsSVGFilters.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsFocusManager.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsJSEnvironment.cpp
dom/indexedDB/IDBObjectStore.cpp
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/workers/Events.cpp
dom/workers/Exceptions.cpp
dom/workers/File.cpp
dom/workers/Location.cpp
dom/workers/Navigator.cpp
dom/workers/WorkerScope.cpp
editor/libeditor/base/nsEditor.cpp
editor/libeditor/base/nsEditorEventListener.cpp
editor/libeditor/base/nsEditorEventListener.h
embedding/android/GeckoAppShell.java
gfx/layers/basic/BasicLayers.cpp
gfx/layers/opengl/ThebesLayerOGL.cpp
gfx/layers/opengl/ThebesLayerOGL.h
gfx/thebes/gfxASurface.cpp
gfx/thebes/gfxDWriteFonts.cpp
gfx/thebes/gfxDWriteFonts.h
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxGDIFontList.cpp
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
js/src/configure.in
js/src/ctypes/Library.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsarray.cpp
js/src/jsdbgapi.cpp
js/src/jsdbgapi.h
js/src/jsgc.cpp
js/src/jsscript.cpp
js/src/jstypedarray.cpp
js/src/jsxdrapi.h
js/src/jsxml.cpp
js/src/shell/js.cpp
js/xpconnect/idl/nsIXPConnect.idl
js/xpconnect/loader/mozJSComponentLoader.cpp
js/xpconnect/loader/mozJSSubScriptLoader.cpp
js/xpconnect/src/Makefile.in
js/xpconnect/src/XPCQuickStubs.cpp
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/wrappers/XrayWrapper.cpp
layout/base/FrameLayerBuilder.cpp
layout/base/crashtests/crashtests.list
layout/base/nsBidiPresUtils.cpp
layout/base/nsBidiPresUtils.h
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsCSSFrameConstructor.h
layout/base/nsDocumentViewer.cpp
layout/base/nsIPresShell.h
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
layout/generic/nsHTMLReflowMetrics.h
layout/generic/nsIFrame.h
layout/generic/nsImageFrame.cpp
layout/generic/nsImageFrame.h
layout/generic/nsSelection.cpp
layout/generic/nsTextFrameThebes.cpp
layout/inspector/src/inFlasher.cpp
layout/reftests/bugs/reftest.list
layout/reftests/scrolling/reftest.list
layout/svg/base/src/nsSVGOuterSVGFrame.h
layout/xul/base/src/nsMenuPopupFrame.cpp
layout/xul/base/src/nsScrollBoxObject.cpp
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoAppShell.java
mobile/android/base/Makefile.in
mobile/android/base/resources/layout/abouthome_content.xml
mobile/android/components/CapturePicker.js
parser/html/nsHtml5TreeBuilderCppSupplement.h
startupcache/test/TestStartupCache.cpp
testing/mochitest/runtestsremote.py
testing/xpcshell/xpcshell.ini
toolkit/components/aboutmemory/content/aboutMemory.js
toolkit/components/feeds/test/xml/rfc4287/feed_accessible.xml
toolkit/components/feeds/test/xml/rfc4287/feed_roleatt.xml
toolkit/components/places/tests/favicons/test_favicons.js
toolkit/components/places/tests/head_common.js
toolkit/components/places/tests/unit/expected-favicon-big16.ico.png
toolkit/components/places/tests/unit/expected-favicon-big32.jpg.png
toolkit/components/places/tests/unit/expected-favicon-big4.jpg.png
toolkit/components/places/tests/unit/expected-favicon-big48.ico.png
toolkit/components/places/tests/unit/expected-favicon-big64.png.png
toolkit/components/places/tests/unit/expected-favicon-scale160x3.jpg.png
toolkit/components/places/tests/unit/expected-favicon-scale3x160.jpg.png
toolkit/components/places/tests/unit/favicon-big16.ico
toolkit/components/places/tests/unit/favicon-big32.jpg
toolkit/components/places/tests/unit/favicon-big4.jpg
toolkit/components/places/tests/unit/favicon-big48.ico
toolkit/components/places/tests/unit/favicon-big64.png
toolkit/components/places/tests/unit/favicon-normal16.png
toolkit/components/places/tests/unit/favicon-normal32.png
toolkit/components/places/tests/unit/favicon-scale160x3.jpg
toolkit/components/places/tests/unit/favicon-scale3x160.jpg
toolkit/components/places/tests/unit/test_404630.js
toolkit/components/places/tests/unit/test_451499.js
toolkit/components/places/tests/unit/test_doReplaceFaviconData.js
toolkit/components/places/tests/unit/test_doReplaceFaviconDataFromDataURL.js
toolkit/components/places/tests/unit/test_doSetAndLoadFaviconForPage.js
toolkit/components/places/tests/unit/test_doSetAndLoadFaviconForPage_failures.js
toolkit/components/places/tests/unit/test_faviconService_expireAllFavicons.js
toolkit/components/places/tests/unit/test_favicons.js
toolkit/components/places/tests/unit/test_moz-anno_favicon_mime_type.js
toolkit/components/satchel/nsFormFillController.cpp
toolkit/components/telemetry/Telemetry.cpp
widget/android/AndroidBridge.cpp
widget/android/AndroidBridge.h
widget/android/nsWindow.cpp
widget/nsGUIEvent.h
widget/qt/nsWindow.cpp
widget/windows/nsDragService.cpp
xpcom/idl-parser/xpidl.py
--- a/accessible/src/atk/AtkSocketAccessible.cpp
+++ b/accessible/src/atk/AtkSocketAccessible.cpp
@@ -34,137 +34,121 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <atk/atk.h>
 #include "AtkSocketAccessible.h"
+
+#include "InterfaceInitFuncs.h"
 #include "nsMai.h"
-#include "nsMaiInterfaceComponent.h"
 
-void (*AtkSocketAccessible::g_atk_socket_embed) (AtkSocket*, gchar*) = NULL;
+AtkSocketEmbedType AtkSocketAccessible::g_atk_socket_embed = NULL;
 GType AtkSocketAccessible::g_atk_socket_type = G_TYPE_INVALID;
 const char* AtkSocketAccessible::sATKSocketEmbedSymbol = "atk_socket_embed";
 const char* AtkSocketAccessible::sATKSocketGetTypeSymbol = "atk_socket_get_type";
 
 bool AtkSocketAccessible::gCanEmbed = FALSE;
 
+extern "C" void mai_atk_component_iface_init(AtkComponentIface* aIface);
+extern "C" GType mai_atk_socket_get_type(void);
+
 /* MaiAtkSocket */
 
 #define MAI_TYPE_ATK_SOCKET              (mai_atk_socket_get_type ())
 #define MAI_ATK_SOCKET(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
                                           MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
 #define MAI_IS_ATK_SOCKET(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
                                           MAI_TYPE_ATK_SOCKET))
 #define MAI_ATK_SOCKET_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass),\
                                           MAI_TYPE_ATK_SOCKET,\
                                           MaiAtkSocketClass))
 #define MAI_IS_ATK_SOCKET_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass),\
                                           MAI_TYPE_ATK_SOCKET))
 #define MAI_ATK_SOCKET_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj),\
                                           MAI_TYPE_ATK_SOCKET,\
                                           MaiAtkSocketClass))
 
-typedef struct _MaiAtkSocket             MaiAtkSocket;
-typedef struct _MaiAtkSocketClass        MaiAtkSocketClass;
-
-struct _MaiAtkSocket
+typedef struct _MaiAtkSocket
 {
   AtkSocket parent;
 
   nsAccessibleWrap* accWrap;
-};
+} MaiAtkSocket;
 
-struct _MaiAtkSocketClass
+typedef struct _MaiAtkSocketClass
 {
   AtkSocketClass parent_class;
-};
-
-G_BEGIN_DECLS
-
-GType mai_atk_socket_get_type(void);
-AtkObject* mai_atk_socket_new(nsAccessibleWrap* aAccWrap);
-
-void mai_atk_component_iface_init(AtkComponentIface* aIface);
-AtkObject* mai_atk_socket_ref_accessible_at_point(AtkComponent *aComponent,
-                                                  gint aAccX,
-                                                  gint aAccY,
-                                                  AtkCoordType aCoordType);
-void mai_atk_socket_get_extents(AtkComponent* aComponent,
-                                gint* aAccX,
-                                gint* aAccY,
-                                gint* aAccWidth,
-                                gint* aAccHeight,
-                                AtkCoordType aCoordType);
-
-G_END_DECLS
+} MaiAtkSocketClass;
 
 G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket,
                        AtkSocketAccessible::g_atk_socket_type, 0,
                        G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
                                              mai_atk_component_iface_init))
 
 void
 mai_atk_socket_class_init(MaiAtkSocketClass* aAcc)
 {
 }
 
 void
 mai_atk_socket_init(MaiAtkSocket* aAcc)
 {
 }
 
-AtkObject*
+static AtkObject*
 mai_atk_socket_new(nsAccessibleWrap* aAccWrap)
 {
   NS_ENSURE_TRUE(aAccWrap, NULL);
 
   MaiAtkSocket* acc = nsnull;
   acc = static_cast<MaiAtkSocket*>(g_object_new(MAI_TYPE_ATK_SOCKET, NULL));
   NS_ENSURE_TRUE(acc, NULL);
 
   acc->accWrap = aAccWrap;
   return ATK_OBJECT(acc);
 }
 
-void
-mai_atk_component_iface_init(AtkComponentIface* aIface)
-{
-  NS_ASSERTION(aIface, "Invalid Interface");
-
-  aIface->ref_accessible_at_point = mai_atk_socket_ref_accessible_at_point;
-  aIface->get_extents = mai_atk_socket_get_extents;
-}
-
-AtkObject*
-mai_atk_socket_ref_accessible_at_point(AtkComponent* aComponent,
-                                       gint aX, gint aY,
-                                       AtkCoordType aCoordType)
+extern "C" {
+static AtkObject*
+RefAccessibleAtPoint(AtkComponent* aComponent, gint aX, gint aY,
+                     AtkCoordType aCoordType)
 {
   NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nsnull);
 
   return refAccessibleAtPointHelper(MAI_ATK_SOCKET(aComponent)->accWrap,
                                     aX, aY, aCoordType);
 }
 
-void
-mai_atk_socket_get_extents(AtkComponent* aComponent,
-                           gint* aX, gint* aY, gint* aWidth, gint* aHeight,
-                           AtkCoordType aCoordType)
+static void
+GetExtents(AtkComponent* aComponent, gint* aX, gint* aY, gint* aWidth,
+           gint* aHeight, AtkCoordType aCoordType)
 {
   *aX = *aY = *aWidth = *aHeight = 0;
 
   if (!MAI_IS_ATK_SOCKET(aComponent))
     return;
 
   getExtentsHelper(MAI_ATK_SOCKET(aComponent)->accWrap,
                    aX, aY, aWidth, aHeight, aCoordType);
 }
+}
+
+void
+mai_atk_component_iface_init(AtkComponentIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid Interface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->ref_accessible_at_point = RefAccessibleAtPoint;
+  aIface->get_extents = GetExtents;
+}
 
 AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
                                          nsDocAccessible* aDoc,
                                          const nsCString& aPlugId) :
   nsAccessibleWrap(aContent, aDoc)
 {
   mAtkObject = mai_atk_socket_new(this);
   if (!mAtkObject)
--- a/accessible/src/atk/AtkSocketAccessible.h
+++ b/accessible/src/atk/AtkSocketAccessible.h
@@ -40,19 +40,19 @@
 #ifndef _AtkSocketAccessible_H_
 #define _AtkSocketAccessible_H_
 
 #include "nsAccessibleWrap.h"
 
 // This file gets included by nsAccessibilityService.cpp, which can't include
 // atk.h (or glib.h), so we can't rely on it being included.
 #ifdef __ATK_H__
-typedef void (*AtkSocketEmbedType) (AtkSocket*, gchar*);
+extern "C" typedef void (*AtkSocketEmbedType) (AtkSocket*, gchar*);
 #else
-typedef void (*AtkSocketEmbedType) (void*, void*);
+extern "C" typedef void (*AtkSocketEmbedType) (void*, void*);
 #endif
 
 /**
  * Provides a nsAccessibleWrap wrapper around AtkSocket for out-of-process
  * accessibles.
  */
 class AtkSocketAccessible: public nsAccessibleWrap
 {
new file mode 100644
--- /dev/null
+++ b/accessible/src/atk/InterfaceInitFuncs.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ *  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ *   * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef ATK_INTERFACE_INIT_FUNCS_H_
+#define ATK_INTERFACE_INIT_FUNCS_H_
+
+#include <atk/atk.h>
+
+class nsAccessibleWrap;
+
+extern "C" {
+void actionInterfaceInitCB(AtkActionIface* aIface);
+void componentInterfaceInitCB(AtkComponentIface* aIface);
+void documentInterfaceInitCB(AtkDocumentIface *aIface);
+void editableTextInterfaceInitCB(AtkEditableTextIface* aIface);
+void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface);
+void hypertextInterfaceInitCB(AtkHypertextIface* aIface);
+void imageInterfaceInitCB(AtkImageIface* aIface);
+void selectionInterfaceInitCB(AtkSelectionIface* aIface);
+void tableInterfaceInitCB(AtkTableIface *aIface);
+void textInterfaceInitCB(AtkTextIface* aIface);
+void valueInterfaceInitCB(AtkValueIface *aIface);
+}
+
+/**
+ * XXX these should live in a file of utils for atk.
+ */
+AtkObject* refAccessibleAtPointHelper(nsAccessibleWrap* aAccWrap,
+                                      gint aX, gint aY, AtkCoordType aCoordType);
+void getExtentsHelper(nsAccessibleWrap* aAccWrap,
+                      gint* aX, gint* aY, gint* aWidth, gint* aHeight,
+                      AtkCoordType aCoordType);
+
+#endif // ATK_INTERFACE_INIT_FUNCS_H_
--- a/accessible/src/atk/nsAccessNodeWrap.cpp
+++ b/accessible/src/atk/nsAccessNodeWrap.cpp
@@ -34,17 +34,16 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsAccessNodeWrap.h"
 #include "nsApplicationAccessibleWrap.h"
-#include "nsMaiInterfaceText.h"
 
 /* For documentation of the accessibility architecture, 
  * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
  */
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessNodeWrap
--- a/accessible/src/atk/nsAccessibleWrap.cpp
+++ b/accessible/src/atk/nsAccessibleWrap.cpp
@@ -38,43 +38,35 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
 
 #include "nsAccessible.h"
 #include "nsAccessibleWrap.h"
 
+#include "InterfaceInitFuncs.h"
 #include "nsAccUtils.h"
 #include "nsApplicationAccessibleWrap.h"
 #include "nsIAccessibleRelation.h"
 #include "nsRootAccessible.h"
 #include "nsDocAccessibleWrap.h"
 #include "nsIAccessibleValue.h"
+#include "nsMai.h"
+#include "nsMaiHyperlink.h"
 #include "nsString.h"
 #include "nsAutoPtr.h"
 #include "prprf.h"
 #include "nsRoleMap.h"
 #include "nsStateMap.h"
 #include "Relation.h"
 #include "States.h"
 
-#include "nsMaiInterfaceComponent.h"
-#include "nsMaiInterfaceAction.h"
-#include "nsMaiInterfaceText.h"
-#include "nsMaiInterfaceEditableText.h"
-#include "nsMaiInterfaceSelection.h"
-#include "nsMaiInterfaceValue.h"
-#include "nsMaiInterfaceHypertext.h"
-#include "nsMaiInterfaceHyperlinkImpl.h"
-#include "nsMaiInterfaceTable.h"
 #include "nsXPCOMStrings.h"
 #include "nsComponentManagerUtils.h"
-#include "nsMaiInterfaceDocument.h"
-#include "nsMaiInterfaceImage.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
 
 nsAccessibleWrap::EAvailableAtkSignals nsAccessibleWrap::gAvailableAtkSignals =
   eUnknown;
 
 //defined in nsApplicationAccessibleWrap.cpp
--- a/accessible/src/atk/nsMaiInterfaceAction.cpp
+++ b/accessible/src/atk/nsMaiInterfaceAction.cpp
@@ -32,86 +32,72 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceAction.h"
+#include "InterfaceInitFuncs.h"
 
-#include "nsAccUtils.h"
-#include "nsRoleMap.h"
-#include "nsString.h"
+#include "nsMai.h"
 #include "Role.h"
 
-#include "nsIDOMDOMStringList.h"
+#include "nsString.h"
 
 using namespace mozilla::a11y;
 
-void
-actionInterfaceInitCB(AtkActionIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid aIface");
-    if (!aIface)
-        return;
+extern "C" {
 
-    aIface->do_action = doActionCB;
-    aIface->get_n_actions = getActionCountCB;
-    aIface->get_description = getActionDescriptionCB;
-    aIface->get_keybinding = getKeyBindingCB;
-    aIface->get_name = getActionNameCB;
-}
-
-gboolean
+static gboolean
 doActionCB(AtkAction *aAction, gint aActionIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
     if (!accWrap)
         return FALSE;
  
     nsresult rv = accWrap->DoAction(aActionIndex);
     return (NS_FAILED(rv)) ? FALSE : TRUE;
 }
 
-gint
+static gint
 getActionCountCB(AtkAction *aAction)
 {
   nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
   return accWrap ? accWrap->ActionCount() : 0;
 }
 
-const gchar *
+static const gchar*
 getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
     if (!accWrap)
         return nsnull;
 
     nsAutoString description;
     nsresult rv = accWrap->GetActionDescription(aActionIndex, description);
     NS_ENSURE_SUCCESS(rv, nsnull);
     return nsAccessibleWrap::ReturnString(description);
 }
 
-const gchar *
+static const gchar*
 getActionNameCB(AtkAction *aAction, gint aActionIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
     if (!accWrap)
         return nsnull;
 
     nsAutoString autoStr;
     nsresult rv = accWrap->GetActionName(aActionIndex, autoStr);
     NS_ENSURE_SUCCESS(rv, nsnull);
     return nsAccessibleWrap::ReturnString(autoStr);
 }
 
-const gchar *
+static const gchar*
 getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
 {
   nsAccessibleWrap* acc = GetAccessibleWrap(ATK_OBJECT(aAction));
   if (!acc)
     return nsnull;
 
   // Return all key bindings including access key and keyboard shortcut.
   nsAutoString keyBindingsStr;
@@ -151,8 +137,23 @@ getKeyBindingCB(AtkAction *aAction, gint
   keyBindingsStr.Append(';');
   keyBinding = acc->KeyboardShortcut();
   if (!keyBinding.IsEmpty()) {
     keyBinding.AppendToString(keyBindingsStr, KeyBinding::eAtkFormat);
   }
 
   return nsAccessibleWrap::ReturnString(keyBindingsStr);
 }
+}
+
+void
+actionInterfaceInitCB(AtkActionIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid aIface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->do_action = doActionCB;
+  aIface->get_n_actions = getActionCountCB;
+  aIface->get_description = getActionDescriptionCB;
+  aIface->get_keybinding = getKeyBindingCB;
+  aIface->get_name = getActionNameCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceAction.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.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 __MAI_INTERFACE_ACTION_H__
-#define __MAI_INTERFACE_ACTION_H__
-
-#include "nsMai.h"
-
-G_BEGIN_DECLS
-
-/* action interface callbacks */
-void actionInterfaceInitCB(AtkActionIface *aIface);
-gboolean doActionCB(AtkAction *aAction, gint aActionIndex);
-gint getActionCountCB(AtkAction *aAction);
-const gchar *getActionDescriptionCB(AtkAction *aAction, gint aActionIndex);
-const gchar *getActionNameCB(AtkAction *aAction, gint aActionIndex);
-const gchar *getKeyBindingCB(AtkAction *aAction, gint aActionIndex);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_ACTION_H__ */
--- a/accessible/src/atk/nsMaiInterfaceComponent.cpp
+++ b/accessible/src/atk/nsMaiInterfaceComponent.cpp
@@ -32,64 +32,52 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceComponent.h"
+#include "InterfaceInitFuncs.h"
 
 #include "nsAccessibleWrap.h"
 #include "nsAccUtils.h"
 #include "nsCoreUtils.h"
-
-void
-componentInterfaceInitCB(AtkComponentIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid Interface");
-    if(!aIface)
-        return;
+#include "nsMai.h"
 
-    /*
-     * Use default implementation in atk for contains, get_position,
-     * and get_size
-     */
-    aIface->ref_accessible_at_point = refAccessibleAtPointCB;
-    aIface->get_extents = getExtentsCB;
-    aIface->grab_focus = grabFocusCB;
-}
+extern "C" {
 
-AtkObject*
+static AtkObject*
 refAccessibleAtPointCB(AtkComponent* aComponent, gint aAccX, gint aAccY,
                        AtkCoordType aCoordType)
 {
   return refAccessibleAtPointHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
                                     aAccX, aAccY, aCoordType);
 }
 
-void
+static void
 getExtentsCB(AtkComponent* aComponent, gint* aX, gint* aY,
              gint* aWidth, gint* aHeight, AtkCoordType aCoordType)
 {
   getExtentsHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
                    aX, aY, aWidth, aHeight, aCoordType);
 }
 
-gboolean
+static gboolean
 grabFocusCB(AtkComponent* aComponent)
 {
   nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
   if (!accWrap)
     return FALSE;
 
   nsresult rv = accWrap->TakeFocus();
   return (NS_FAILED(rv)) ? FALSE : TRUE;
 }
+}
 
 AtkObject*
 refAccessibleAtPointHelper(nsAccessibleWrap* aAccWrap, gint aX, gint aY,
                            AtkCoordType aCoordType)
 {
   if (!aAccWrap || aAccWrap->IsDefunct() || nsAccUtils::MustPrune(aAccWrap))
     return nsnull;
 
@@ -135,8 +123,24 @@ getExtentsHelper(nsAccessibleWrap* aAccW
     y -= winCoords.y;
   }
 
   *aX = x;
   *aY = y;
   *aWidth = width;
   *aHeight = height;
 }
+
+void
+componentInterfaceInitCB(AtkComponentIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid Interface");
+  if(NS_UNLIKELY(!aIface))
+    return;
+
+  /*
+   * Use default implementation in atk for contains, get_position,
+   * and get_size
+   */
+  aIface->ref_accessible_at_point = refAccessibleAtPointCB;
+  aIface->get_extents = getExtentsCB;
+  aIface->grab_focus = grabFocusCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceComponent.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.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 __MAI_INTERFACE_COMPONENT_H__
-#define __MAI_INTERFACE_COMPONENT_H__
-
-#include "nsMai.h"
-
-G_BEGIN_DECLS
-
-/* component interface callbacks */
-void componentInterfaceInitCB(AtkComponentIface* aIface);
-AtkObject* refAccessibleAtPointCB(AtkComponent* aComponent,
-                                  gint aX, gint aY,
-                                  AtkCoordType aCoordType);
-void getExtentsCB(AtkComponent* aComponent,
-                  gint* aX, gint* aY, gint* aWidth, gint* aHeight,
-                  AtkCoordType aCoordType);
-/* the "contains", "get_position", "get_size" can take advantage of
- * "get_extents", there is no need to implement them now.
- */
-gboolean grabFocusCB(AtkComponent* aComponent);
-
-/* what are missing now for atk component:
- *
- * add_focus_handler
- * remove_focus_handler
- * set_extents
- * set_position
- * set_size
- * get_layer
- * get_mdi_zorder
- */
-
-AtkObject* refAccessibleAtPointHelper(nsAccessibleWrap* aAccWrap,
-                                      gint aX, gint aY, AtkCoordType aCoordType);
-void getExtentsHelper(nsAccessibleWrap* aAccWrap,
-                      gint* aX, gint* aY, gint* aWidth, gint* aHeight,
-                      AtkCoordType aCoordType);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_COMPONENT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceDocument.cpp
+++ b/accessible/src/atk/nsMaiInterfaceDocument.cpp
@@ -32,20 +32,21 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceDocument.h"
+#include "InterfaceInitFuncs.h"
 
 #include "nsAccessibleWrap.h"
 #include "nsDocAccessible.h"
+#include "nsMai.h"
 
 static const char* const kDocTypeName = "W3C-doctype";
 static const char* const kDocUrlName = "DocURL";
 static const char* const kMimeTypeName = "MimeType";
 
 // below functions are vfuncs on an ATK  interface so they need to be C call
 extern "C" {
 
@@ -53,17 +54,17 @@ static const gchar* getDocumentLocaleCB(
 static AtkAttributeSet* getDocumentAttributesCB(AtkDocument* aDocument);
 static const gchar* getDocumentAttributeValueCB(AtkDocument* aDocument,
                                                 const gchar* aAttrName);
 
 void
 documentInterfaceInitCB(AtkDocumentIface *aIface)
 {
     NS_ASSERTION(aIface, "Invalid Interface");
-    if(!aIface)
+    if(NS_UNLIKELY(!aIface))
         return;
 
     /*
      * We don't support get_document or set_attribute right now.
      * get_document_type is deprecated, we return DocType in
      * get_document_attribute_value and get_document_attributes instead.
      */
     aIface->get_document_attributes = getDocumentAttributesCB;
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceDocument.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Evan Yan (evan.yan@sun.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 __MAI_INTERFACE_DOCUMENT_H__
-#define __MAI_INTERFACE_DOCUMENT_H__
-
-#include "nsMai.h"
-
-G_BEGIN_DECLS
-
-/* document interface callbacks */
-void documentInterfaceInitCB(AtkDocumentIface *aIface);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_DOCUMENT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceEditableText.cpp
+++ b/accessible/src/atk/nsMaiInterfaceEditableText.cpp
@@ -32,41 +32,28 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsString.h"
-#include "nsMaiInterfaceEditableText.h"
+#include "InterfaceInitFuncs.h"
 
-void
-editableTextInterfaceInitCB(AtkEditableTextIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid aIface");
-    if (!aIface)
-        return;
+#include "nsHyperTextAccessible.h"
+#include "nsMai.h"
 
-    aIface->set_run_attributes = setRunAttributesCB;
-    aIface->set_text_contents = setTextContentsCB;
-    aIface->insert_text = insertTextCB;
-    aIface->copy_text = copyTextCB;
-    aIface->cut_text = cutTextCB;
-    aIface->delete_text = deleteTextCB;
-    aIface->paste_text = pasteTextCB;
-}
+#include "nsString.h"
 
-/* static, callbacks for atkeditabletext virutal functions */
+extern "C" {
 
-gboolean
+static gboolean
 setRunAttributesCB(AtkEditableText *aText, AtkAttributeSet *aAttribSet,
                    gint aStartOffset, gint aEndOffset)
-
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
                             getter_AddRefs(accText));
@@ -75,17 +62,17 @@ setRunAttributesCB(AtkEditableText *aTex
     nsCOMPtr<nsISupports> attrSet;
     /* how to insert attributes into nsISupports ??? */
 
     nsresult rv = accText->SetAttributes(aStartOffset, aEndOffset,
                                          attrSet);
     return NS_FAILED(rv) ? FALSE : TRUE;
 }
 
-void
+static void
 setTextContentsCB(AtkEditableText *aText, const gchar *aString)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
@@ -94,17 +81,17 @@ setTextContentsCB(AtkEditableText *aText
         return;
 
     MAI_LOG_DEBUG(("EditableText: setTextContentsCB, aString=%s", aString));
 
     NS_ConvertUTF8toUTF16 strContent(aString);
     accText->SetTextContents(strContent);
 }
 
-void
+static void
 insertTextCB(AtkEditableText *aText,
              const gchar *aString, gint aLength, gint *aPosition)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
@@ -122,17 +109,17 @@ insertTextCB(AtkEditableText *aText,
     // *aPosition = pos;
 
     accText->InsertText(strContent, *aPosition);
 
     MAI_LOG_DEBUG(("EditableText: insert aString=%s, aLength=%d, aPosition=%d",
                    aString, aLength, *aPosition));
 }
 
-void
+static void
 copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
@@ -140,34 +127,34 @@ copyTextCB(AtkEditableText *aText, gint 
     if (!accText)
         return;
 
     MAI_LOG_DEBUG(("EditableText: copyTextCB, aStartPos=%d, aEndPos=%d",
                    aStartPos, aEndPos));
     accText->CopyText(aStartPos, aEndPos);
 }
 
-void
+static void
 cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
                             getter_AddRefs(accText));
     if (!accText)
         return;
     MAI_LOG_DEBUG(("EditableText: cutTextCB, aStartPos=%d, aEndPos=%d",
                    aStartPos, aEndPos));
     accText->CutText(aStartPos, aEndPos);
 }
 
-void
+static void
 deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
@@ -175,24 +162,41 @@ deleteTextCB(AtkEditableText *aText, gin
     if (!accText)
         return;
 
     MAI_LOG_DEBUG(("EditableText: deleteTextCB, aStartPos=%d, aEndPos=%d",
                    aStartPos, aEndPos));
     accText->DeleteText(aStartPos, aEndPos);
 }
 
-void
+static void
 pasteTextCB(AtkEditableText *aText, gint aPosition)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleEditableText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
                             getter_AddRefs(accText));
     if (!accText)
         return;
 
     MAI_LOG_DEBUG(("EditableText: pasteTextCB, aPosition=%d", aPosition));
     accText->PasteText(aPosition);
 }
+}
+
+void
+editableTextInterfaceInitCB(AtkEditableTextIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid aIface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->set_run_attributes = setRunAttributesCB;
+  aIface->set_text_contents = setTextContentsCB;
+  aIface->insert_text = insertTextCB;
+  aIface->copy_text = copyTextCB;
+  aIface->cut_text = cutTextCB;
+  aIface->delete_text = deleteTextCB;
+  aIface->paste_text = pasteTextCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceEditableText.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.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 __MAI_INTERFACE_EDITABLETEXT_H__
-#define __MAI_INTERFACE_EDITABLETEXT_H__
-
-#include "nsMai.h"
-#include "nsIAccessibleEditableText.h"
-
-G_BEGIN_DECLS
-
-void editableTextInterfaceInitCB(AtkEditableTextIface *aIface);
-
-/* editabletext interface callbacks */
-gboolean setRunAttributesCB(AtkEditableText *aText,
-                            AtkAttributeSet *aAttribSet,
-                            gint aStartOffset,
-                            gint aEndOffset);
-void setTextContentsCB(AtkEditableText *aText, const gchar *aString);
-void insertTextCB(AtkEditableText *aText,
-                  const gchar *aString, gint aLength, gint *aPosition);
-void copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos);
-void cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos);
-void deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos);
-void pasteTextCB(AtkEditableText *aText, gint aPosition);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_EDITABLETEXT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.cpp
+++ b/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.cpp
@@ -32,32 +32,37 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceHyperlinkImpl.h"
+#include "InterfaceInitFuncs.h"
+
 #include "nsMaiHyperlink.h"
 
-void
-hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface)
-{
-    g_return_if_fail(aIface != NULL);
-
-    aIface->get_hyperlink = getHyperlinkCB;
-}
-
-AtkHyperlink*
+extern "C" {
+static AtkHyperlink*
 getHyperlinkCB(AtkHyperlinkImpl* aImpl)
 {
   nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImpl));
   if (!accWrap)
     return nsnull;
 
   NS_ENSURE_TRUE(accWrap->IsLink(), nsnull);
 
   MaiHyperlink* maiHyperlink = accWrap->GetMaiHyperlink();
   NS_ENSURE_TRUE(maiHyperlink, nsnull);
   return maiHyperlink->GetAtkHyperlink();
 }
+}
+
+void
+hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface)
+{
+  NS_ASSERTION(aIface, "no interface!");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->get_hyperlink = getHyperlinkCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Neo Liu(nian.liu@sun.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 __MAI_INTERFACE_HYPERLINKIMPL_H__
-#define __MAI_INTERFACE_HYPERLINKIMPL_H__
-
-#include "nsMai.h"
-
-G_BEGIN_DECLS
-
-void hyperlinkImplInterfaceInitCB(AtkHyperlinkImplIface *aIface);
-
-/* hyperlinkImpl interface callbacks */
-AtkHyperlink  *getHyperlinkCB (AtkHyperlinkImpl *aImpl);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_HYPERLINKIMPL_H__ */
-
--- a/accessible/src/atk/nsMaiInterfaceHypertext.cpp
+++ b/accessible/src/atk/nsMaiInterfaceHypertext.cpp
@@ -32,30 +32,25 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceHypertext.h"
-#include "nsHyperTextAccessible.h"
+#include "InterfaceInitFuncs.h"
 
-void
-hypertextInterfaceInitCB(AtkHypertextIface *aIface)
-{
-    g_return_if_fail(aIface != NULL);
+#include "nsHyperTextAccessible.h"
+#include "nsMai.h"
+#include "nsMaiHyperlink.h"
 
-    aIface->get_link = getLinkCB;
-    aIface->get_n_links = getLinkCountCB;
-    aIface->get_link_index = getLinkIndexCB;
-}
+extern "C" {
 
-AtkHyperlink *
+static AtkHyperlink*
 getLinkCB(AtkHypertext *aText, gint aLinkIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
     nsHyperTextAccessible* hyperText = accWrap->AsHyperText();
     NS_ENSURE_TRUE(hyperText, nsnull);
@@ -68,37 +63,50 @@ getLinkCB(AtkHypertext *aText, gint aLin
     nsAccessibleWrap *accChild = GetAccessibleWrap(hyperLinkAtkObj);
     NS_ENSURE_TRUE(accChild, nsnull);
 
     MaiHyperlink *maiHyperlink = accChild->GetMaiHyperlink();
     NS_ENSURE_TRUE(maiHyperlink, nsnull);
     return maiHyperlink->GetAtkHyperlink();
 }
 
-gint
+static gint
 getLinkCountCB(AtkHypertext *aText)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return -1;
 
     nsHyperTextAccessible* hyperText = accWrap->AsHyperText();
     NS_ENSURE_TRUE(hyperText, -1);
 
     return hyperText->GetLinkCount();
 }
 
-gint
+static gint
 getLinkIndexCB(AtkHypertext *aText, gint aCharIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return -1;
 
     nsHyperTextAccessible* hyperText = accWrap->AsHyperText();
     NS_ENSURE_TRUE(hyperText, -1);
 
     PRInt32 index = -1;
     nsresult rv = hyperText->GetLinkIndexAtOffset(aCharIndex, &index);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return index;
 }
+}
+
+void
+hypertextInterfaceInitCB(AtkHypertextIface* aIface)
+{
+  NS_ASSERTION(aIface, "no interface!");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->get_link = getLinkCB;
+  aIface->get_n_links = getLinkCountCB;
+  aIface->get_link_index = getLinkIndexCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceHypertext.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.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 __MAI_INTERFACE_HYPERTEXT_H__
-#define __MAI_INTERFACE_HYPERTEXT_H__
-
-#include "nsMai.h"
-#include "nsMaiHyperlink.h"
-#include "nsIAccessibleHyperText.h"
-
-G_BEGIN_DECLS
-
-void hypertextInterfaceInitCB(AtkHypertextIface *aIface);
-
-/* hypertext interface callbacks */
-AtkHyperlink *getLinkCB(AtkHypertext *aText, gint aLinkIndex);
-gint getLinkCountCB(AtkHypertext *aText);
-gint getLinkIndexCB(AtkHypertext *aText, gint aCharIndex);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_HYPERTEXT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceImage.cpp
+++ b/accessible/src/atk/nsMaiInterfaceImage.cpp
@@ -32,57 +32,61 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceImage.h"
+#include "InterfaceInitFuncs.h"
 
 #include "nsAccessibleWrap.h"
 #include "nsHTMLImageAccessible.h"
-
-extern "C" const gchar* getDescriptionCB(AtkObject* aAtkObj);
-
-void
-imageInterfaceInitCB(AtkImageIface *aIface)
-{
-    g_return_if_fail(aIface != NULL);
+#include "nsMai.h"
 
-    aIface->get_image_position = getImagePositionCB;
-    aIface->get_image_description = getImageDescriptionCB;
-    aIface->get_image_size = getImageSizeCB;
+extern "C" {
+const gchar* getDescriptionCB(AtkObject* aAtkObj);
 
-}
-
-void
+static void
 getImagePositionCB(AtkImage *aImage, gint *aAccX, gint *aAccY,
                    AtkCoordType aCoordType)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
     if (!accWrap || !accWrap->IsImageAccessible())
       return;
 
     nsHTMLImageAccessible* image = accWrap->AsImage();
     PRUint32 geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
       nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
       nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
     // Returned in screen coordinates
     image->GetImagePosition(geckoCoordType, aAccX, aAccY);
 }
 
-const gchar *
+static const gchar*
 getImageDescriptionCB(AtkImage *aImage)
 {
    return getDescriptionCB(ATK_OBJECT(aImage));
 }
 
-void
+static void
 getImageSizeCB(AtkImage *aImage, gint *aAccWidth, gint *aAccHeight)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
     if (!accWrap || !accWrap->IsImageAccessible())
       return;
 
     accWrap->AsImage()->GetImageSize(aAccWidth, aAccHeight);
 }
+}
+
+void
+imageInterfaceInitCB(AtkImageIface* aIface)
+{
+  NS_ASSERTION(aIface, "no interface!");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->get_image_position = getImagePositionCB;
+  aIface->get_image_description = getImageDescriptionCB;
+  aIface->get_image_size = getImageSizeCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceImage.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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) 2006
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Gao, Ming (gaoming@cn.ibm.com)
- *   Neo Liu(nian.liu@sun.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 __MAI_INTERFACE_IMAGE_H__
-#define __MAI_INTERFACE_IMAGE_H__
-
-#include "nsMai.h"
-#include "nsIAccessibleImage.h"
-
-G_BEGIN_DECLS
-
-void imageInterfaceInitCB(AtkImageIface *aIface);
-
-/* image interface callbacks */
-void getImagePositionCB(AtkImage *aImage,
-                        gint *aAccX,
-                        gint *aAccY,
-                        AtkCoordType aCoordType);
-const gchar* getImageDescriptionCB(AtkImage *aImage);
-void getImageSizeCB(AtkImage *aImage,
-                    gint *aAccWidth,
-                    gint *aAccHeight);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_DOCUMENT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceSelection.cpp
+++ b/accessible/src/atk/nsMaiInterfaceSelection.cpp
@@ -32,55 +32,46 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceSelection.h"
+#include "InterfaceInitFuncs.h"
 
-void
-selectionInterfaceInitCB(AtkSelectionIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid aIface");
-    if (!aIface)
-        return;
+#include "nsAccessibleWrap.h"
+#include "nsMai.h"
 
-    aIface->add_selection = addSelectionCB;
-    aIface->clear_selection = clearSelectionCB;
-    aIface->ref_selection = refSelectionCB;
-    aIface->get_selection_count = getSelectionCountCB;
-    aIface->is_child_selected = isChildSelectedCB;
-    aIface->remove_selection = removeSelectionCB;
-    aIface->select_all_selection = selectAllSelectionCB;
-}
+#include <atk/atk.h>
 
-gboolean
+extern "C" {
+
+static gboolean
 addSelectionCB(AtkSelection *aSelection, gint i)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return FALSE;
 
     return accWrap->AddItemToSelection(i);
 }
 
-gboolean
+static gboolean
 clearSelectionCB(AtkSelection *aSelection)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return FALSE;
 
     return accWrap->UnselectAll();
 }
 
-AtkObject *
+static AtkObject*
 refSelectionCB(AtkSelection *aSelection, gint i)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return nsnull;
 
     nsAccessible* selectedItem = accWrap->GetSelectedItem(i);
     if (!selectedItem)
@@ -88,47 +79,64 @@ refSelectionCB(AtkSelection *aSelection,
 
     AtkObject* atkObj = nsAccessibleWrap::GetAtkObject(selectedItem);
     if (atkObj) {
         g_object_ref(atkObj);
     }
     return atkObj;
 }
 
-gint
+static gint
 getSelectionCountCB(AtkSelection *aSelection)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return -1;
 
     return accWrap->SelectedItemCount();
 }
 
-gboolean
+static gboolean
 isChildSelectedCB(AtkSelection *aSelection, gint i)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return FALSE;
 
     return accWrap->IsItemSelected(i);
 }
 
-gboolean
+static gboolean
 removeSelectionCB(AtkSelection *aSelection, gint i)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return FALSE;
 
     return accWrap->RemoveItemFromSelection(i);
 }
 
-gboolean
+static gboolean
 selectAllSelectionCB(AtkSelection *aSelection)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     if (!accWrap || !accWrap->IsSelect())
         return FALSE;
 
     return accWrap->SelectAll();
 }
+}
+
+void
+selectionInterfaceInitCB(AtkSelectionIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid aIface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->add_selection = addSelectionCB;
+  aIface->clear_selection = clearSelectionCB;
+  aIface->ref_selection = refSelectionCB;
+  aIface->get_selection_count = getSelectionCountCB;
+  aIface->is_child_selected = isChildSelectedCB;
+  aIface->remove_selection = removeSelectionCB;
+  aIface->select_all_selection = selectAllSelectionCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceSelection.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Silvia Zhao (silvia.zhao@sun.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 __MAI_INTERFACE_SELECTION_H__
-#define __MAI_INTERFACE_SELECTION_H__
-
-#include "nsMai.h"
-
-G_BEGIN_DECLS
-
-/* selection interface callbacks */
-
-void selectionInterfaceInitCB(AtkSelectionIface *aIface);
-gboolean addSelectionCB(AtkSelection *aSelection, gint i);
-gboolean clearSelectionCB(AtkSelection *aSelection);
-AtkObject *refSelectionCB(AtkSelection *aSelection, gint i);
-gint getSelectionCountCB(AtkSelection *aSelection);
-gboolean isChildSelectedCB(AtkSelection *aSelection, gint i);
-gboolean removeSelectionCB(AtkSelection *aSelection, gint i);
-gboolean selectAllSelectionCB(AtkSelection *aSelection);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_SELECTION_H__ */
--- a/accessible/src/atk/nsMaiInterfaceTable.cpp
+++ b/accessible/src/atk/nsMaiInterfaceTable.cpp
@@ -32,51 +32,28 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceTable.h"
+#include "InterfaceInitFuncs.h"
 
+#include "nsAccessibleWrap.h"
 #include "nsAccUtils.h"
+#include "nsIAccessibleTable.h"
+#include "nsMai.h"
 
 #include "nsArrayUtils.h"
 
-void
-tableInterfaceInitCB(AtkTableIface *aIface)
-
-{
-    g_return_if_fail(aIface != NULL);
+extern "C" {
 
-    aIface->ref_at = refAtCB;
-    aIface->get_index_at = getIndexAtCB;
-    aIface->get_column_at_index = getColumnAtIndexCB;
-    aIface->get_row_at_index = getRowAtIndexCB;
-    aIface->get_n_columns = getColumnCountCB;
-    aIface->get_n_rows = getRowCountCB;
-    aIface->get_column_extent_at = getColumnExtentAtCB;
-    aIface->get_row_extent_at = getRowExtentAtCB;
-    aIface->get_caption = getCaptionCB;
-    aIface->get_column_description = getColumnDescriptionCB;
-    aIface->get_column_header = getColumnHeaderCB;
-    aIface->get_row_description = getRowDescriptionCB;
-    aIface->get_row_header = getRowHeaderCB;
-    aIface->get_summary = getSummaryCB;
-    aIface->get_selected_columns = getSelectedColumnsCB;
-    aIface->get_selected_rows = getSelectedRowsCB;
-    aIface->is_column_selected = isColumnSelectedCB;
-    aIface->is_row_selected = isRowSelectedCB;
-    aIface->is_selected = isCellSelectedCB;
-}
-
-/* static */
-AtkObject*
+static AtkObject*
 refAtCB(AtkTable *aTable, gint aRow, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -90,17 +67,17 @@ refAtCB(AtkTable *aTable, gint aRow, gin
 
     AtkObject *cellAtkObj = nsAccessibleWrap::GetAtkObject(cell);
     if (cellAtkObj) {
         g_object_ref(cellAtkObj);
     }
     return cellAtkObj;
 }
 
-gint
+static gint
 getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -109,17 +86,17 @@ getIndexAtCB(AtkTable *aTable, gint aRow
 
     PRInt32 index;
     nsresult rv = accTable->GetCellIndexAt(aRow, aColumn, &index);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(index);
 }
 
-gint
+static gint
 getColumnAtIndexCB(AtkTable *aTable, gint aIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -128,17 +105,17 @@ getColumnAtIndexCB(AtkTable *aTable, gin
 
     PRInt32 col;
     nsresult rv = accTable->GetColumnIndexAt(aIndex, &col);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(col);
 }
 
-gint
+static gint
 getRowAtIndexCB(AtkTable *aTable, gint aIndex)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -147,17 +124,17 @@ getRowAtIndexCB(AtkTable *aTable, gint a
 
     PRInt32 row;
     nsresult rv = accTable->GetRowIndexAt(aIndex, &row);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(row);
 }
 
-gint
+static gint
 getColumnCountCB(AtkTable *aTable)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -166,17 +143,17 @@ getColumnCountCB(AtkTable *aTable)
 
     PRInt32 count;
     nsresult rv = accTable->GetColumnCount(&count);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(count);
 }
 
-gint
+static gint
 getRowCountCB(AtkTable *aTable)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -185,17 +162,17 @@ getRowCountCB(AtkTable *aTable)
 
     PRInt32 count;
     nsresult rv = accTable->GetRowCount(&count);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(count);
 }
 
-gint
+static gint
 getColumnExtentAtCB(AtkTable *aTable,
                     gint aRow, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
@@ -205,17 +182,17 @@ getColumnExtentAtCB(AtkTable *aTable,
 
     PRInt32 extent;
     nsresult rv = accTable->GetColumnExtentAt(aRow, aColumn, &extent);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(extent);
 }
 
-gint
+static gint
 getRowExtentAtCB(AtkTable *aTable,
                  gint aRow, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return -1;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
@@ -225,17 +202,17 @@ getRowExtentAtCB(AtkTable *aTable,
 
     PRInt32 extent;
     nsresult rv = accTable->GetRowExtentAt(aRow, aColumn, &extent);
     NS_ENSURE_SUCCESS(rv, -1);
 
     return static_cast<gint>(extent);
 }
 
-AtkObject*
+static AtkObject*
 getCaptionCB(AtkTable *aTable)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -245,17 +222,17 @@ getCaptionCB(AtkTable *aTable)
     nsCOMPtr<nsIAccessible> caption;
     nsresult rv = accTable->GetCaption(getter_AddRefs(caption));
     if (NS_FAILED(rv) || !caption)
         return nsnull;
 
     return nsAccessibleWrap::GetAtkObject(caption);
 }
 
-const gchar*
+static const gchar*
 getColumnDescriptionCB(AtkTable *aTable, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -264,17 +241,17 @@ getColumnDescriptionCB(AtkTable *aTable,
 
     nsAutoString autoStr;
     nsresult rv = accTable->GetColumnDescription(aColumn, autoStr);
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     return nsAccessibleWrap::ReturnString(autoStr);
 }
 
-AtkObject*
+static AtkObject*
 getColumnHeaderCB(AtkTable *aTable, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -306,17 +283,17 @@ getColumnHeaderCB(AtkTable *aTable, gint
 
             return nsAccessibleWrap::GetAtkObject(accHeaderCell);
         }
     }
 
     return nsnull;
 }
 
-const gchar*
+static const gchar*
 getRowDescriptionCB(AtkTable *aTable, gint aRow)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -325,17 +302,17 @@ getRowDescriptionCB(AtkTable *aTable, gi
 
     nsAutoString autoStr;
     nsresult rv = accTable->GetRowDescription(aRow, autoStr);
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     return nsAccessibleWrap::ReturnString(autoStr);
 }
 
-AtkObject*
+static AtkObject*
 getRowHeaderCB(AtkTable *aTable, gint aRow)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -367,27 +344,27 @@ getRowHeaderCB(AtkTable *aTable, gint aR
 
         return nsAccessibleWrap::GetAtkObject(accHeaderCell);
       }
     }
 
     return nsnull;
 }
 
-AtkObject*
+static AtkObject*
 getSummaryCB(AtkTable *aTable)
 {
     // Neither html:table nor xul:tree nor ARIA grid/tree have an ability to
     // link an accessible object to specify a summary. There is closes method
     // in nsIAccessibleTable::summary to get a summary as a string which is not
     // mapped directly to ATK.
     return nsnull;
 }
 
-gint
+static gint
 getSelectedColumnsCB(AtkTable *aTable, gint **aSelected)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return 0;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -412,17 +389,17 @@ getSelectedColumnsCB(AtkTable *aTable, g
     for (PRUint32 index = 0; index < size; ++index)
         atkColumns[index] = static_cast<gint>(columns[index]);
     nsMemory::Free(columns);
 
     *aSelected = atkColumns;
     return size;
 }
 
-gint
+static gint
 getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return 0;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@@ -447,58 +424,87 @@ getSelectedRowsCB(AtkTable *aTable, gint
     for (PRUint32 index = 0; index < size; ++index)
         atkRows[index] = static_cast<gint>(rows[index]);
     nsMemory::Free(rows);
 
     *aSelected = atkRows;
     return size;
 }
 
-gboolean
+static gboolean
 isColumnSelectedCB(AtkTable *aTable, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
                             getter_AddRefs(accTable));
     NS_ENSURE_TRUE(accTable, FALSE);
 
     bool outValue;
     nsresult rv = accTable->IsColumnSelected(aColumn, &outValue);
     return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
 }
 
-gboolean
+static gboolean
 isRowSelectedCB(AtkTable *aTable, gint aRow)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
                             getter_AddRefs(accTable));
     NS_ENSURE_TRUE(accTable, FALSE);
 
     bool outValue;
     nsresult rv = accTable->IsRowSelected(aRow, &outValue);
     return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
 }
 
-gboolean
+static gboolean
 isCellSelectedCB(AtkTable *aTable, gint aRow, gint aColumn)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleTable> accTable;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
                             getter_AddRefs(accTable));
     NS_ENSURE_TRUE(accTable, FALSE);
 
     bool outValue;
     nsresult rv = accTable->IsCellSelected(aRow, aColumn, &outValue);
     return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
 }
+}
+
+void
+tableInterfaceInitCB(AtkTableIface* aIface)
+{
+  NS_ASSERTION(aIface, "no interface!");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->ref_at = refAtCB;
+  aIface->get_index_at = getIndexAtCB;
+  aIface->get_column_at_index = getColumnAtIndexCB;
+  aIface->get_row_at_index = getRowAtIndexCB;
+  aIface->get_n_columns = getColumnCountCB;
+  aIface->get_n_rows = getRowCountCB;
+  aIface->get_column_extent_at = getColumnExtentAtCB;
+  aIface->get_row_extent_at = getRowExtentAtCB;
+  aIface->get_caption = getCaptionCB;
+  aIface->get_column_description = getColumnDescriptionCB;
+  aIface->get_column_header = getColumnHeaderCB;
+  aIface->get_row_description = getRowDescriptionCB;
+  aIface->get_row_header = getRowHeaderCB;
+  aIface->get_summary = getSummaryCB;
+  aIface->get_selected_columns = getSelectedColumnsCB;
+  aIface->get_selected_rows = getSelectedRowsCB;
+  aIface->is_column_selected = isColumnSelectedCB;
+  aIface->is_row_selected = isRowSelectedCB;
+  aIface->is_selected = isCellSelectedCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceTable.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.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 __MAI_INTERFACE_TABLE_H__
-#define __MAI_INTERFACE_TABLE_H__
-
-#include "nsMai.h"
-#include "nsIAccessibleTable.h"
-
-G_BEGIN_DECLS
-
-/* table interface callbacks */
-void tableInterfaceInitCB(AtkTableIface *aIface);
-AtkObject* refAtCB(AtkTable *aTable, gint aRow, gint aColumn);
-gint getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn);
-gint getColumnAtIndexCB(AtkTable *aTable, gint aIndex);
-gint getRowAtIndexCB(AtkTable *aTable, gint aIndex);
-gint getColumnCountCB(AtkTable *aTable);
-gint getRowCountCB(AtkTable *aTable);
-gint getColumnExtentAtCB(AtkTable *aTable, gint aRow, gint aColumn);
-gint getRowExtentAtCB(AtkTable *aTable, gint aRow, gint aColumn);
-AtkObject* getCaptionCB(AtkTable *aTable);
-const gchar* getColumnDescriptionCB(AtkTable *aTable, gint aColumn);
-AtkObject* getColumnHeaderCB(AtkTable *aTable, gint aColumn);
-const gchar* getRowDescriptionCB(AtkTable *aTable, gint aRow);
-AtkObject* getRowHeaderCB(AtkTable *aTable, gint aRow);
-AtkObject* getSummaryCB(AtkTable *aTable);
-gint getSelectedColumnsCB(AtkTable *aTable, gint **aSelected);
-gint getSelectedRowsCB(AtkTable *aTable, gint **aSelected);
-gboolean isColumnSelectedCB(AtkTable *aTable, gint aColumn);
-gboolean isRowSelectedCB(AtkTable *aTable, gint aRow);
-gboolean isCellSelectedCB(AtkTable *aTable, gint aRow, gint aColumn);
-
-/* what are missing now for atk table */
-
-/* ==================================================
-   void              (* set_caption)              (AtkTable      *aTable,
-   AtkObject     *caption);
-   void              (* set_column_description)   (AtkTable      *aTable,
-   gint          aColumn,
-   const gchar   *description);
-   void              (* set_column_header)        (AtkTable      *aTable,
-   gint          aColumn,
-   AtkObject     *header);
-   void              (* set_row_description)      (AtkTable      *aTable,
-   gint          aRow,
-   const gchar   *description);
-   void              (* set_row_header)           (AtkTable      *aTable,
-   gint          aRow,
-   AtkObject     *header);
-   void              (* set_summary)              (AtkTable      *aTable,
-   AtkObject     *accessible);
-   gboolean          (* add_row_selection)        (AtkTable      *aTable,
-   gint          aRow);
-   gboolean          (* remove_row_selection)     (AtkTable      *aTable,
-   gint          aRow);
-   gboolean          (* add_column_selection)     (AtkTable      *aTable,
-   gint          aColumn);
-   gboolean          (* remove_column_selection)  (AtkTable      *aTable,
-   gint          aColumn);
-
-   ////////////////////////////////////////
-   // signal handlers
-   //
-   void              (* row_inserted)           (AtkTable      *aTable,
-   gint          aRow,
-   gint          num_inserted);
-   void              (* column_inserted)        (AtkTable      *aTable,
-   gint          aColumn,
-   gint          num_inserted);
-   void              (* row_deleted)              (AtkTable      *aTable,
-   gint          aRow,
-   gint          num_deleted);
-   void              (* column_deleted)           (AtkTable      *aTable,
-   gint          aColumn,
-   gint          num_deleted);
-   void              (* row_reordered)            (AtkTable      *aTable);
-   void              (* column_reordered)         (AtkTable      *aTable);
-   void              (* model_changed)            (AtkTable      *aTable);
-
-   * ==================================================
-   */
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_TABLE_H__ */
--- a/accessible/src/atk/nsMaiInterfaceText.cpp
+++ b/accessible/src/atk/nsMaiInterfaceText.cpp
@@ -33,66 +33,40 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceText.h"
+#include "InterfaceInitFuncs.h"
 
 #include "nsHyperTextAccessible.h"
+#include "nsMai.h"
 #include "nsRoleMap.h"
 
 #include "nsIPersistentProperties2.h"
 
 AtkAttributeSet* ConvertToAtkAttributeSet(nsIPersistentProperties* aAttributes);
 
-void
-textInterfaceInitCB(AtkTextIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid aIface");
-    if (!aIface)
-        return;
-
-    aIface->get_text = getTextCB;
-    aIface->get_text_after_offset = getTextAfterOffsetCB;
-    aIface->get_text_at_offset = getTextAtOffsetCB;
-    aIface->get_character_at_offset = getCharacterAtOffsetCB;
-    aIface->get_text_before_offset = getTextBeforeOffsetCB;
-    aIface->get_caret_offset = getCaretOffsetCB;
-    aIface->get_run_attributes = getRunAttributesCB;
-    aIface->get_default_attributes = getDefaultAttributesCB;
-    aIface->get_character_extents = getCharacterExtentsCB;
-    aIface->get_range_extents = getRangeExtentsCB;
-    aIface->get_character_count = getCharacterCountCB;
-    aIface->get_offset_at_point = getOffsetAtPointCB;
-    aIface->get_n_selections = getTextSelectionCountCB;
-    aIface->get_selection = getTextSelectionCB;
-
-    // set methods
-    aIface->add_selection = addTextSelectionCB;
-    aIface->remove_selection = removeTextSelectionCB;
-    aIface->set_selection = setTextSelectionCB;
-    aIface->set_caret_offset = setCaretOffsetCB;
-}
-
-
-void ConvertTexttoAsterisks(nsAccessibleWrap* accWrap, nsAString& aString)
+static void
+ConvertTexttoAsterisks(nsAccessibleWrap* accWrap, nsAString& aString)
 {
     // convert each char to "*" when it's "password text" 
     PRUint32 atkRole = atkRoleMap[accWrap->NativeRole()];
     if (atkRole == ATK_ROLE_PASSWORD_TEXT) {
         for (PRUint32 i = 0; i < aString.Length(); i++)
             aString.Replace(i, 1, NS_LITERAL_STRING("*"));
     }
 }
 
-gchar *
+extern "C" {
+
+static gchar*
 getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@@ -105,17 +79,17 @@ getTextCB(AtkText *aText, gint aStartOff
 
     ConvertTexttoAsterisks(accWrap, autoStr);
     NS_ConvertUTF16toUTF8 cautoStr(autoStr);
 
     //copy and return, libspi will free it.
     return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
 }
 
-gchar *
+static gchar*
 getTextAfterOffsetCB(AtkText *aText, gint aOffset,
                      AtkTextBoundary aBoundaryType,
                      gint *aStartOffset, gint *aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
@@ -134,17 +108,17 @@ getTextAfterOffsetCB(AtkText *aText, gin
 
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     ConvertTexttoAsterisks(accWrap, autoStr);
     NS_ConvertUTF16toUTF8 cautoStr(autoStr);
     return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
 }
 
-gchar *
+static gchar*
 getTextAtOffsetCB(AtkText *aText, gint aOffset,
                   AtkTextBoundary aBoundaryType,
                   gint *aStartOffset, gint *aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
@@ -163,17 +137,17 @@ getTextAtOffsetCB(AtkText *aText, gint a
 
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     ConvertTexttoAsterisks(accWrap, autoStr);
     NS_ConvertUTF16toUTF8 cautoStr(autoStr);
     return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
 }
 
-gunichar
+static gunichar
 getCharacterAtOffsetCB(AtkText *aText, gint aOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return 0;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@@ -189,17 +163,17 @@ getCharacterAtOffsetCB(AtkText *aText, g
     // convert char to "*" when it's "password text" 
     PRUint32 atkRole = atkRoleMap[accWrap->NativeRole()];
     if (atkRole == ATK_ROLE_PASSWORD_TEXT)
         uniChar = '*';
 
     return (NS_FAILED(rv)) ? 0 : static_cast<gunichar>(uniChar);
 }
 
-gchar *
+static gchar*
 getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
                       AtkTextBoundary aBoundaryType,
                       gint *aStartOffset, gint *aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
@@ -218,34 +192,34 @@ getTextBeforeOffsetCB(AtkText *aText, gi
 
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     ConvertTexttoAsterisks(accWrap, autoStr);
     NS_ConvertUTF16toUTF8 cautoStr(autoStr);
     return (cautoStr.get()) ? g_strdup(cautoStr.get()) : nsnull;
 }
 
-gint
+static gint
 getCaretOffsetCB(AtkText *aText)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return 0;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                             getter_AddRefs(accText));
     NS_ENSURE_TRUE(accText, 0);
 
     PRInt32 offset;
     nsresult rv = accText->GetCaretOffset(&offset);
     return (NS_FAILED(rv)) ? 0 : static_cast<gint>(offset);
 }
 
-AtkAttributeSet *
+static AtkAttributeSet*
 getRunAttributesCB(AtkText *aText, gint aOffset,
                    gint *aStartOffset,
                    gint *aEndOffset)
 {
     *aStartOffset = -1;
     *aEndOffset = -1;
 
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
@@ -265,17 +239,17 @@ getRunAttributesCB(AtkText *aText, gint 
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     *aStartOffset = startOffset;
     *aEndOffset = endOffset;
 
     return ConvertToAtkAttributeSet(attributes);
 }
 
-AtkAttributeSet *
+static AtkAttributeSet*
 getDefaultAttributesCB(AtkText *aText)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@@ -285,17 +259,17 @@ getDefaultAttributesCB(AtkText *aText)
     nsCOMPtr<nsIPersistentProperties> attributes;
     nsresult rv = accText->GetDefaultTextAttributes(getter_AddRefs(attributes));
     if (NS_FAILED(rv))
         return nsnull;
 
     return ConvertToAtkAttributeSet(attributes);
 }
 
-void
+static void
 getCharacterExtentsCB(AtkText *aText, gint aOffset,
                       gint *aX, gint *aY,
                       gint *aWidth, gint *aHeight,
                       AtkCoordType aCoords)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if(!accWrap || !aX || !aY || !aWidth || !aHeight)
         return;
@@ -324,17 +298,17 @@ getCharacterExtentsCB(AtkText *aText, gi
     *aX = extX;
     *aY = extY;
     *aWidth = extWidth;
     *aHeight = extHeight;
     NS_ASSERTION(NS_SUCCEEDED(rv),
                  "MaiInterfaceText::GetCharacterExtents, failed\n");
 }
 
-void
+static void
 getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
                   AtkCoordType aCoords, AtkTextRectangle *aRect)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if(!accWrap || !aRect)
         return;
 
     nsCOMPtr<nsIAccessibleText> accText;
@@ -362,29 +336,29 @@ getRangeExtentsCB(AtkText *aText, gint a
     aRect->x = extX;
     aRect->y = extY;
     aRect->width = extWidth;
     aRect->height = extHeight;
     NS_ASSERTION(NS_SUCCEEDED(rv),
                  "MaiInterfaceText::GetRangeExtents, failed\n");
 }
 
-gint
+static gint
 getCharacterCountCB(AtkText *aText)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return 0;
 
     nsHyperTextAccessible* textAcc = accWrap->AsHyperText();
     return textAcc->IsDefunct() ?
         0 : static_cast<gint>(textAcc->CharacterCount());
 }
 
-gint
+static gint
 getOffsetAtPointCB(AtkText *aText,
                    gint aX, gint aY,
                    AtkCoordType aCoords)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return -1;
 
@@ -399,17 +373,17 @@ getOffsetAtPointCB(AtkText *aText,
         geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
     else
         geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
 
     accText->GetOffsetAtPoint(aX, aY, geckoCoordType, &offset);
     return static_cast<gint>(offset);
 }
 
-gint
+static gint
 getTextSelectionCountCB(AtkText *aText)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@@ -417,17 +391,17 @@ getTextSelectionCountCB(AtkText *aText)
     NS_ENSURE_TRUE(accText, nsnull);
 
     PRInt32 selectionCount;
     nsresult rv = accText->GetSelectionCount(&selectionCount);
  
     return NS_FAILED(rv) ? 0 : selectionCount;
 }
 
-gchar *
+static gchar*
 getTextSelectionCB(AtkText *aText, gint aSelectionNum,
                    gint *aStartOffset, gint *aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return nsnull;
 
     nsCOMPtr<nsIAccessibleText> accText;
@@ -443,17 +417,17 @@ getTextSelectionCB(AtkText *aText, gint 
     *aEndOffset = endOffset;
 
     NS_ENSURE_SUCCESS(rv, nsnull);
 
     return getTextCB(aText, *aStartOffset, *aEndOffset);
 }
 
 // set methods
-gboolean
+static gboolean
 addTextSelectionCB(AtkText *aText,
                    gint aStartOffset,
                    gint aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return FALSE;
 
@@ -462,17 +436,17 @@ addTextSelectionCB(AtkText *aText,
                             getter_AddRefs(accText));
     NS_ENSURE_TRUE(accText, FALSE);
 
     nsresult rv = accText->AddSelection(aStartOffset, aEndOffset);
 
     return NS_SUCCEEDED(rv) ? TRUE : FALSE;
 }
 
-gboolean
+static gboolean
 removeTextSelectionCB(AtkText *aText,
                       gint aSelectionNum)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleText> accText;
@@ -480,17 +454,17 @@ removeTextSelectionCB(AtkText *aText,
                             getter_AddRefs(accText));
     NS_ENSURE_TRUE(accText, FALSE);
 
     nsresult rv = accText->RemoveSelection(aSelectionNum);
 
     return NS_SUCCEEDED(rv) ? TRUE : FALSE;
 }
 
-gboolean
+static gboolean
 setTextSelectionCB(AtkText *aText, gint aSelectionNum,
                    gint aStartOffset, gint aEndOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleText> accText;
@@ -498,23 +472,53 @@ setTextSelectionCB(AtkText *aText, gint 
                             getter_AddRefs(accText));
     NS_ENSURE_TRUE(accText, FALSE);
 
     nsresult rv = accText->SetSelectionBounds(aSelectionNum,
                                               aStartOffset, aEndOffset);
     return NS_SUCCEEDED(rv) ? TRUE : FALSE;
 }
 
-gboolean
+static gboolean
 setCaretOffsetCB(AtkText *aText, gint aOffset)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleText> accText;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
                             getter_AddRefs(accText));
     NS_ENSURE_TRUE(accText, FALSE);
 
     nsresult rv = accText->SetCaretOffset(aOffset);
     return NS_SUCCEEDED(rv) ? TRUE : FALSE;
 }
+}
+
+void
+textInterfaceInitCB(AtkTextIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid aIface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->get_text = getTextCB;
+  aIface->get_text_after_offset = getTextAfterOffsetCB;
+  aIface->get_text_at_offset = getTextAtOffsetCB;
+  aIface->get_character_at_offset = getCharacterAtOffsetCB;
+  aIface->get_text_before_offset = getTextBeforeOffsetCB;
+  aIface->get_caret_offset = getCaretOffsetCB;
+  aIface->get_run_attributes = getRunAttributesCB;
+  aIface->get_default_attributes = getDefaultAttributesCB;
+  aIface->get_character_extents = getCharacterExtentsCB;
+  aIface->get_range_extents = getRangeExtentsCB;
+  aIface->get_character_count = getCharacterCountCB;
+  aIface->get_offset_at_point = getOffsetAtPointCB;
+  aIface->get_n_selections = getTextSelectionCountCB;
+  aIface->get_selection = getTextSelectionCB;
+
+    // set methods
+  aIface->add_selection = addTextSelectionCB;
+  aIface->remove_selection = removeTextSelectionCB;
+  aIface->set_selection = setTextSelectionCB;
+  aIface->set_caret_offset = setCaretOffsetCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceText.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Bolian Yin (bolian.yin@sun.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 __MAI_INTERFACE_TEXT_H__
-#define __MAI_INTERFACE_TEXT_H__
-
-#include "nsMai.h"
-#include "nsIAccessibleText.h"
-
-G_BEGIN_DECLS
-
-void textInterfaceInitCB(AtkTextIface *aIface);
-
-/* text interface callbacks */
-gchar *getTextCB(AtkText *aText,
-                 gint aStartOffset, gint aEndOffset);
-gchar *getTextAfterOffsetCB(AtkText *aText, gint aOffset,
-                            AtkTextBoundary aBoundaryType,
-                            gint *aStartOffset, gint *aEndOffset);
-gchar *getTextAtOffsetCB(AtkText *aText, gint aOffset,
-                         AtkTextBoundary aBoundaryType,
-                         gint *aStartOffset, gint *aEndOffset);
-gunichar getCharacterAtOffsetCB(AtkText *aText, gint aOffset);
-gchar *getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
-                             AtkTextBoundary aBoundaryType,
-                             gint *aStartOffset, gint *aEndOffset);
-gint getCaretOffsetCB(AtkText *aText);
-AtkAttributeSet *getRunAttributesCB(AtkText *aText, gint aOffset,
-                                    gint *aStartOffset,
-                                    gint *aEndOffset);
-AtkAttributeSet* getDefaultAttributesCB(AtkText *aText);
-void getCharacterExtentsCB(AtkText *aText, gint aOffset,
-                           gint *aX, gint *aY,
-                           gint *aWidth, gint *aHeight,
-                           AtkCoordType aCoords);
-void getRangeExtentsCB(AtkText *aText, gint aStartOffset,
-                       gint aEndOffset, AtkCoordType aCoords,
-                       AtkTextRectangle *aRect);
-gint getCharacterCountCB(AtkText *aText);
-gint getOffsetAtPointCB(AtkText *aText,
-                        gint aX, gint aY,
-                        AtkCoordType aCoords);
-gint getTextSelectionCountCB(AtkText *aText);
-gchar *getTextSelectionCB(AtkText *aText, gint aSelectionNum,
-                          gint *aStartOffset, gint *aEndOffset);
-
-// set methods
-gboolean addTextSelectionCB(AtkText *aText,
-                            gint aStartOffset,
-                            gint aEndOffset);
-gboolean removeTextSelectionCB(AtkText *aText,
-                               gint aSelectionNum);
-gboolean setTextSelectionCB(AtkText *aText, gint aSelectionNum,
-                            gint aStartOffset, gint aEndOffset);
-gboolean setCaretOffsetCB(AtkText *aText, gint aOffset);
-
-/*************************************************
- // signal handlers
- //
-    void TextChangedCB(AtkText *aText, gint aPosition, gint aLength);
-    void TextCaretMovedCB(AtkText *aText, gint aLocation);
-    void TextSelectionChangedCB(AtkText *aText);
-*/
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_TEXT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceValue.cpp
+++ b/accessible/src/atk/nsMaiInterfaceValue.cpp
@@ -32,33 +32,24 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "nsMaiInterfaceValue.h"
-
-void
-valueInterfaceInitCB(AtkValueIface *aIface)
-{
-    NS_ASSERTION(aIface, "Invalid aIface");
-    if (!aIface)
-        return;
+#include "InterfaceInitFuncs.h"
 
-    aIface->get_current_value = getCurrentValueCB;
-    aIface->get_maximum_value = getMaximumValueCB;
-    aIface->get_minimum_value = getMinimumValueCB;
-    aIface->get_minimum_increment = getMinimumIncrementCB;
-    aIface->set_current_value = setCurrentValueCB;
-}
+#include "nsAccessibleWrap.h"
+#include "nsMai.h"
 
-void
+extern "C" {
+
+static void
 getCurrentValueCB(AtkValue *obj, GValue *value)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
@@ -69,17 +60,17 @@ getCurrentValueCB(AtkValue *obj, GValue 
     memset (value,  0, sizeof (GValue));
     double accDouble;
     if (NS_FAILED(accValue->GetCurrentValue(&accDouble)))
         return;
     g_value_init (value, G_TYPE_DOUBLE);
     g_value_set_double (value, accDouble);
 }
 
-void
+static void
 getMaximumValueCB(AtkValue *obj, GValue *value)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
@@ -90,17 +81,17 @@ getMaximumValueCB(AtkValue *obj, GValue 
     memset (value,  0, sizeof (GValue));
     double accDouble;
     if (NS_FAILED(accValue->GetMaximumValue(&accDouble)))
         return;
     g_value_init (value, G_TYPE_DOUBLE);
     g_value_set_double (value, accDouble);
 }
 
-void
+static void
 getMinimumValueCB(AtkValue *obj, GValue *value)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
@@ -111,17 +102,17 @@ getMinimumValueCB(AtkValue *obj, GValue 
     memset (value,  0, sizeof (GValue));
     double accDouble;
     if (NS_FAILED(accValue->GetMinimumValue(&accDouble)))
         return;
     g_value_init (value, G_TYPE_DOUBLE);
     g_value_set_double (value, accDouble);
 }
 
-void
+static void
 getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
     if (!accWrap)
         return;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
@@ -132,23 +123,38 @@ getMinimumIncrementCB(AtkValue *obj, GVa
     memset (minimumIncrement,  0, sizeof (GValue));
     double accDouble;
     if (NS_FAILED(accValue->GetMinimumIncrement(&accDouble)))
         return;
     g_value_init (minimumIncrement, G_TYPE_DOUBLE);
     g_value_set_double (minimumIncrement, accDouble);
 }
 
-gboolean
+static gboolean
 setCurrentValueCB(AtkValue *obj, const GValue *value)
 {
     nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
     if (!accWrap)
         return FALSE;
 
     nsCOMPtr<nsIAccessibleValue> accValue;
     accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
                             getter_AddRefs(accValue));
     NS_ENSURE_TRUE(accValue, FALSE);
 
     double accDouble =g_value_get_double (value);
     return !NS_FAILED(accValue->SetCurrentValue(accDouble));
 }
+}
+
+void
+valueInterfaceInitCB(AtkValueIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid aIface");
+  if (NS_UNLIKELY(!aIface))
+    return;
+
+  aIface->get_current_value = getCurrentValueCB;
+  aIface->get_maximum_value = getMaximumValueCB;
+  aIface->get_minimum_value = getMinimumValueCB;
+  aIface->get_minimum_increment = getMinimumIncrementCB;
+  aIface->set_current_value = setCurrentValueCB;
+}
deleted file mode 100644
--- a/accessible/src/atk/nsMaiInterfaceValue.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* ***** 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
- * Sun Microsystems, Inc.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Silvia Zhao (silvia.zhao@sun.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 __MAI_INTERFACE_VALUE_H__
-#define __MAI_INTERFACE_VALUE_H__
-
-#include "nsMai.h"
-#include "nsIAccessibleValue.h"
-
-G_BEGIN_DECLS
-
-/*value interface callbacks*/
-void valueInterfaceInitCB(AtkValueIface *aIface);
-void getCurrentValueCB(AtkValue *obj, GValue *value);
-void getMaximumValueCB(AtkValue *obj, GValue *value);
-void getMinimumValueCB(AtkValue *obj, GValue *value);
-void getMinimumIncrementCB(AtkValue *obj, GValue *minIncrement);
-gboolean setCurrentValueCB(AtkValue *obj, const GValue *value);
-
-G_END_DECLS
-
-#endif /* __MAI_INTERFACE_VALUE_H__ */
--- a/accessible/src/base/nsAccessNode.cpp
+++ b/accessible/src/base/nsAccessNode.cpp
@@ -272,19 +272,19 @@ nsAccessNode::ScrollTo(PRUint32 aScrollT
   nsIFrame *frame = GetFrame();
   if (!frame)
     return;
 
   nsIContent* content = frame->GetContent();
   if (!content)
     return;
 
-  PRInt16 vPercent, hPercent;
-  nsCoreUtils::ConvertScrollTypeToPercents(aScrollType, &vPercent, &hPercent);
-  shell->ScrollContentIntoView(content, vPercent, hPercent,
+  nsIPresShell::ScrollAxis vertical, horizontal;
+  nsCoreUtils::ConvertScrollTypeToPercents(aScrollType, &vertical, &horizontal);
+  shell->ScrollContentIntoView(content, vertical, horizontal,
                                nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 }
 
 void
 nsAccessNode::Language(nsAString& aLanguage)
 {
   aLanguage.Truncate();
 
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -2225,18 +2225,19 @@ void
 nsAccessible::DispatchClickEvent(nsIContent *aContent, PRUint32 aActionIndex)
 {
   if (IsDefunct())
     return;
 
   nsIPresShell* presShell = mDoc->PresShell();
 
   // Scroll into view.
-  presShell->ScrollContentIntoView(aContent, NS_PRESSHELL_SCROLL_ANYWHERE,
-                                   NS_PRESSHELL_SCROLL_ANYWHERE,
+  presShell->ScrollContentIntoView(aContent,
+                                   nsIPresShell::ScrollAxis(),
+                                   nsIPresShell::ScrollAxis(),
                                    nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 
   // Fire mouse down and mouse up events.
   bool res = nsCoreUtils::DispatchMouseEvent(NS_MOUSE_BUTTON_DOWN, presShell,
                                                aContent);
   if (!res)
     return;
 
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -291,28 +291,29 @@ nsCoreUtils::IsAncestorOf(nsINode *aPoss
 }
 
 nsresult
 nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame,
                                nsIDOMNode *aStartNode, PRInt32 aStartIndex,
                                nsIDOMNode *aEndNode, PRInt32 aEndIndex,
                                PRUint32 aScrollType)
 {
-  PRInt16 vPercent, hPercent;
-  ConvertScrollTypeToPercents(aScrollType, &vPercent, &hPercent);
+  nsIPresShell::ScrollAxis vertical, horizontal;
+  ConvertScrollTypeToPercents(aScrollType, &vertical, &horizontal);
 
   return ScrollSubstringTo(aFrame, aStartNode, aStartIndex, aEndNode, aEndIndex,
-                           vPercent, hPercent);
+                           vertical, horizontal);
 }
 
 nsresult
 nsCoreUtils::ScrollSubstringTo(nsIFrame *aFrame,
                                nsIDOMNode *aStartNode, PRInt32 aStartIndex,
                                nsIDOMNode *aEndNode, PRInt32 aEndIndex,
-                               PRInt16 aVPercent, PRInt16 aHPercent)
+                               nsIPresShell::ScrollAxis aVertical,
+                               nsIPresShell::ScrollAxis aHorizontal)
 {
   if (!aFrame || !aStartNode || !aEndNode)
     return NS_ERROR_FAILURE;
 
   nsPresContext *presContext = aFrame->PresContext();
 
   nsRefPtr<nsIDOMRange> scrollToRange = new nsRange();
   nsCOMPtr<nsISelectionController> selCon;
@@ -325,18 +326,19 @@ nsCoreUtils::ScrollSubstringTo(nsIFrame 
   nsCOMPtr<nsISelection> selection;
   selCon->GetSelection(nsISelectionController::SELECTION_ACCESSIBILITY,
                        getter_AddRefs(selection));
 
   nsCOMPtr<nsISelectionPrivate> privSel(do_QueryInterface(selection));
   selection->RemoveAllRanges();
   selection->AddRange(scrollToRange);
 
-  privSel->ScrollIntoView(nsISelectionController::SELECTION_ANCHOR_REGION,
-                          true, aVPercent, aHPercent);
+  privSel->ScrollIntoViewInternal(
+    nsISelectionController::SELECTION_ANCHOR_REGION,
+    true, aVertical, aHorizontal);
 
   selection->CollapseToStart();
 
   return NS_OK;
 }
 
 void
 nsCoreUtils::ScrollFrameToPoint(nsIFrame *aScrollableFrame,
@@ -360,49 +362,67 @@ nsCoreUtils::ScrollFrameToPoint(nsIFrame
   nsPoint scrollPoint = scrollableFrame->GetScrollPosition();
   scrollPoint -= deltaPoint;
 
   scrollableFrame->ScrollTo(scrollPoint, nsIScrollableFrame::INSTANT);
 }
 
 void
 nsCoreUtils::ConvertScrollTypeToPercents(PRUint32 aScrollType,
-                                         PRInt16 *aVPercent,
-                                         PRInt16 *aHPercent)
+                                         nsIPresShell::ScrollAxis *aVertical,
+                                         nsIPresShell::ScrollAxis *aHorizontal)
 {
+  PRInt16 whereY, whereX;
+  nsIPresShell::WhenToScroll whenY, whenX;
   switch (aScrollType)
   {
     case nsIAccessibleScrollType::SCROLL_TYPE_TOP_LEFT:
-      *aVPercent = NS_PRESSHELL_SCROLL_TOP;
-      *aHPercent = NS_PRESSHELL_SCROLL_LEFT;
+      whereY = nsIPresShell::SCROLL_TOP;
+      whenY  = nsIPresShell::SCROLL_ALWAYS;
+      whereX = nsIPresShell::SCROLL_LEFT;
+      whenX  = nsIPresShell::SCROLL_ALWAYS;
       break;
     case nsIAccessibleScrollType::SCROLL_TYPE_BOTTOM_RIGHT:
-      *aVPercent = NS_PRESSHELL_SCROLL_BOTTOM;
-      *aHPercent = NS_PRESSHELL_SCROLL_RIGHT;
+      whereY = nsIPresShell::SCROLL_BOTTOM;
+      whenY  = nsIPresShell::SCROLL_ALWAYS;
+      whereX = nsIPresShell::SCROLL_RIGHT;
+      whenX  = nsIPresShell::SCROLL_ALWAYS;
       break;
     case nsIAccessibleScrollType::SCROLL_TYPE_TOP_EDGE:
-      *aVPercent = NS_PRESSHELL_SCROLL_TOP;
-      *aHPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
+      whereY = nsIPresShell::SCROLL_TOP;
+      whenY  = nsIPresShell::SCROLL_ALWAYS;
+      whereX = nsIPresShell::SCROLL_MINIMUM;
+      whenX  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
       break;
     case nsIAccessibleScrollType::SCROLL_TYPE_BOTTOM_EDGE:
-      *aVPercent = NS_PRESSHELL_SCROLL_BOTTOM;
-      *aHPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
+      whereY = nsIPresShell::SCROLL_BOTTOM;
+      whenY  = nsIPresShell::SCROLL_ALWAYS;
+      whereX = nsIPresShell::SCROLL_MINIMUM;
+      whenX  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
       break;
     case nsIAccessibleScrollType::SCROLL_TYPE_LEFT_EDGE:
-      *aVPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
-      *aHPercent = NS_PRESSHELL_SCROLL_LEFT;
+      whereY = nsIPresShell::SCROLL_MINIMUM;
+      whenY  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
+      whereX = nsIPresShell::SCROLL_LEFT;
+      whenX  = nsIPresShell::SCROLL_ALWAYS;
       break;
     case nsIAccessibleScrollType::SCROLL_TYPE_RIGHT_EDGE:
-      *aVPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
-      *aHPercent = NS_PRESSHELL_SCROLL_RIGHT;
+      whereY = nsIPresShell::SCROLL_MINIMUM;
+      whenY  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
+      whereX = nsIPresShell::SCROLL_RIGHT;
+      whenX  = nsIPresShell::SCROLL_ALWAYS;
       break;
     default:
-      *aVPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
-      *aHPercent = NS_PRESSHELL_SCROLL_ANYWHERE;
+      whereY = nsIPresShell::SCROLL_MINIMUM;
+      whenY  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
+      whereX = nsIPresShell::SCROLL_MINIMUM;
+      whenX  = nsIPresShell::SCROLL_IF_NOT_FULLY_VISIBLE;
   }
+  *aVertical = nsIPresShell::ScrollAxis(whereY, whenY);
+  *aHorizontal = nsIPresShell::ScrollAxis(whereX, whenX);
 }
 
 nsIntPoint
 nsCoreUtils::GetScreenCoordsForWindow(nsINode *aNode)
 {
   nsIntPoint coords(0, 0);
   nsCOMPtr<nsIDocShellTreeItem> treeItem(GetDocShellTreeItemFor(aNode));
   if (!treeItem)
--- a/accessible/src/base/nsCoreUtils.h
+++ b/accessible/src/base/nsCoreUtils.h
@@ -176,42 +176,43 @@ public:
   /** Helper method to scroll range into view, used for implementation of
    * nsIAccessibleText::scrollSubstringTo[Point]().
    *
    * @param aFrame        the frame for accessible the range belongs to.
    * @param aStartNode    start node of a range
    * @param aStartOffset  an offset inside the start node
    * @param aEndNode      end node of a range
    * @param aEndOffset    an offset inside the end node
-   * @param aVPercent     how to align vertically, specified in percents
-   * @param aHPercent     how to align horizontally, specified in percents
+   * @param aVertical     how to align vertically, specified in percents, and when.
+   * @param aHorizontal     how to align horizontally, specified in percents, and when.
    */
   static nsresult ScrollSubstringTo(nsIFrame *aFrame,
                                     nsIDOMNode *aStartNode, PRInt32 aStartIndex,
                                     nsIDOMNode *aEndNode, PRInt32 aEndIndex,
-                                    PRInt16 aVPercent, PRInt16 aHPercent);
+                                    nsIPresShell::ScrollAxis aVertical,
+                                    nsIPresShell::ScrollAxis aHorizontal);
 
   /**
    * Scrolls the given frame to the point, used for implememntation of
    * nsIAccessible::scrollToPoint and nsIAccessibleText::scrollSubstringToPoint.
    *
    * @param aScrollableFrame  the scrollable frame
    * @param aFrame            the frame to scroll
    * @param aPoint            the point scroll to
    */
   static void ScrollFrameToPoint(nsIFrame *aScrollableFrame,
                                  nsIFrame *aFrame, const nsIntPoint& aPoint);
 
   /**
    * Converts scroll type constant defined in nsIAccessibleScrollType to
-   * vertical and horizontal percents.
+   * vertical and horizontal parameters.
    */
   static void ConvertScrollTypeToPercents(PRUint32 aScrollType,
-                                          PRInt16 *aVPercent,
-                                          PRInt16 *aHPercent);
+                                          nsIPresShell::ScrollAxis *aVertical,
+                                          nsIPresShell::ScrollAxis *aHorizontal);
 
   /**
    * Returns coordinates relative screen for the top level window.
    *
    * @param aNode  the DOM node hosted in the window.
    */
   static nsIntPoint GetScreenCoordsForWindow(nsINode *aNode);
 
--- a/accessible/src/html/nsHTMLSelectAccessible.cpp
+++ b/accessible/src/html/nsHTMLSelectAccessible.cpp
@@ -342,41 +342,16 @@ nsHTMLSelectOptionAccessible::GetLevelIn
     parentContent->NodeInfo()->Equals(nsGkAtoms::optgroup) ? 2 : 1;
 
   if (level == 1 && Role() != roles::HEADING)
     level = 0; // In a single level list, the level is irrelevant
 
   return level;
 }
 
-void
-nsHTMLSelectOptionAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
-                                                         PRInt32 *aSetSize)
-{
-  PRInt32 posInSet = 0, setSize = 0;
-  bool isContentFound = false;
-
-  nsIContent* parentContent = mContent->GetParent();
-  for (nsIContent* childContent = parentContent->GetFirstChild(); childContent;
-       childContent = childContent->GetNextSibling()) {
-    if (childContent->NodeInfo()->Equals(mContent->NodeInfo())) {
-      if (!isContentFound) {
-        if (childContent == mContent)
-          isContentFound = true;
-
-        posInSet++;
-      }
-      setSize++;
-    }
-  }
-
-  *aSetSize = setSize;
-  *aPosInSet = posInSet;
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLSelectOptionAccessible: nsIAccessible
 
 /** select us! close combo box if necessary*/
 NS_IMETHODIMP nsHTMLSelectOptionAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
 {
   if (aIndex == eAction_Select) {
     aName.AssignLiteral("select"); 
--- a/accessible/src/html/nsHTMLSelectAccessible.h
+++ b/accessible/src/html/nsHTMLSelectAccessible.h
@@ -117,18 +117,16 @@ public:
   NS_IMETHOD SetSelected(bool aSelect);
 
   // nsAccessible
   virtual nsresult GetNameInternal(nsAString& aName);
   virtual mozilla::a11y::role NativeRole();
   virtual PRUint64 NativeState();
 
   virtual PRInt32 GetLevelInternal();
-  virtual void GetPositionAndSizeInternal(PRInt32 *aPosInSet,
-                                          PRInt32 *aSetSize);
 
   // ActionAccessible
   virtual PRUint8 ActionCount();
 
   // Widgets
   virtual nsAccessible* ContainerWidget() const;
 
 protected:
--- a/accessible/tests/mochitest/relations/test_ui_modalprompt.html
+++ b/accessible/tests/mochitest/relations/test_ui_modalprompt.html
@@ -17,16 +17,24 @@
   <script type="application/javascript"
           src="../role.js"></script>
   <script type="application/javascript"
           src="../events.js"></script>
   <script type="application/javascript"
           src="../browser.js"></script>
 
   <script type="application/javascript">
+    function hasTabModalPrompts() {
+      try {
+        return SpecialPowers.getBoolPref("prompts.tab_modal.enabled");
+      } catch (ex) {
+        return false;
+      }
+    }
+
     function showAlert()
     {
       this.eventSeq = [
         {
           type: EVENT_SHOW,
           match: function(aEvent)
           {
             return aEvent.accessible.role == ROLE_DIALOG;
@@ -67,18 +75,22 @@
       gQueue.onFinish = function()
       {
         synthesizeKey("VK_RETURN", {}, browserWindow());
         closeBrowserWindow();
       }
       gQueue.invoke(); // will call SimpleTest.finish()
     }
 
-    SimpleTest.waitForExplicitFinish();
-    openBrowserWindow(doTests);
+    if (!hasTabModalPrompts()) {
+      todo(false, "Test disabled when tab modal prompts are not enabled.");
+    } else {
+      SimpleTest.waitForExplicitFinish();
+      openBrowserWindow(doTests);
+    }
   </script>
 
 </head>
 
 <body id="body">
 
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=661293"
--- a/b2g/chrome/content/webapi.js
+++ b/b2g/chrome/content/webapi.js
@@ -1,83 +1,28 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-dump('======================= webapi+apps.js ======================= \n');
+'use strict';
 
-'use strict';
+dump('======================= webapi+apps.js ======================= \n');
 
 let { classes: Cc, interfaces: Ci, utils: Cu }  = Components;
 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
 Cu.import('resource://gre/modules/Services.jsm');
+Cu.import('resource://gre/modules/Geometry.jsm');
 
 XPCOMUtils.defineLazyGetter(Services, 'fm', function() {
   return Cc['@mozilla.org/focus-manager;1']
            .getService(Ci.nsIFocusManager);
 });
 
-(function() {
-  function generateAPI(window) {
-    let navigator = window.navigator;
-
-    XPCOMUtils.defineLazyGetter(navigator, 'mozKeyboard', function() {
-      return new MozKeyboard();
-    });
-  };
-
-  let progressListener = {
-    onStateChange: function onStateChange(progress, request,
-                                          flags, status) {
-    },
-
-    onProgressChange: function onProgressChange(progress, request,
-                                                curSelf, maxSelf,
-                                                curTotal, maxTotal) {
-    },
-
-    onLocationChange: function onLocationChange(progress, request,
-                                                locationURI, flags) {
-      content.addEventListener('appwillopen', function(evt) {
-        let appManager = content.wrappedJSObject.Gaia.AppManager;
-        let topWindow = appManager.foregroundWindow.contentWindow;
-        generateAPI(topWindow);
-      });
-
-      generateAPI(content.wrappedJSObject);
-    },
-
-    onStatusChange: function onStatusChange(progress, request,
-                                            status, message) {
-    },
-
-    onSecurityChange: function onSecurityChange(progress, request,
-                                                state) {
-    },
-
-    QueryInterface: function QueryInterface(aIID) {
-      if (aIID.equals(Ci.nsIWebProgressListener) ||
-          aIID.equals(Ci.nsISupportsWeakReference) ||
-          aIID.equals(Ci.nsISupports)) {
-          return this;
-      }
-
-      throw Components.results.NS_ERROR_NO_INTERFACE;
-    }
-  };
-
-  let flags = Ci.nsIWebProgress.NOTIFY_LOCATION;
-  let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
-                            .getInterface(Ci.nsIWebProgress);
-  flags = Ci.nsIWebProgress.NOTIFY_ALL;
-  webProgress.addProgressListener(progressListener, flags);
-})();
-
 // MozKeyboard
 (function VirtualKeyboardManager() {
   let activeElement = null;
   let isKeyboardOpened = false;
   
   function fireEvent(type, details) {
     let event = content.document.createEvent('CustomEvent');
     event.initCustomEvent(type, true, true, details ? details : {});
@@ -134,37 +79,16 @@ XPCOMUtils.defineLazyGetter(Services, 'f
   };
 
   Services.obs.addObserver(constructor, 'ime-enabled-state-changed', false);
   ['keypress', 'mousedown'].forEach(function vkm_events(type) {
     addEventListener(type, constructor, true);
   });
 })();
 
-
-function MozKeyboard() {
-}
-
-MozKeyboard.prototype = {
-  sendKey: function mozKeyboardSendKey(keyCode, charCode) {
-    charCode = (charCode == undefined) ? keyCode : charCode;
-
-    let utils = content.QueryInterface(Ci.nsIInterfaceRequestor)
-                       .getInterface(Ci.nsIDOMWindowUtils);
-    ['keydown', 'keypress', 'keyup'].forEach(function sendKey(type) {
-      utils.sendKeyEvent(type, keyCode, charCode, null);
-    });
-  }
-};
-
-let { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
-Cu.import('resource://gre/modules/Geometry.jsm');
-Cu.import('resource://gre/modules/Services.jsm');
-
 const ContentPanning = {
   init: function cp_init() {
     ['mousedown', 'mouseup', 'mousemove'].forEach(function(type) {
       addEventListener(type, ContentPanning, true);
     });
   },
 
   handleEvent: function cp_handleEvent(evt) {
@@ -323,17 +247,16 @@ const ContentPanning = {
 
     const kStateActive = 0x00000001;
     this._domUtils.setContentState(root.documentElement, kStateActive);
   }
 };
 
 ContentPanning.init();
 
-
 // Min/max velocity of kinetic panning. This is in pixels/millisecond.
 const kMinVelocity = 0.4;
 const kMaxVelocity = 6;
 
 // Constants that affect the "friction" of the scroll pane.
 const kExponentialC = 1000;
 const kPolynomialC = 100 / 1000000;
 
@@ -492,9 +415,8 @@ const KineticPanning = {
       }
 
       content.mozRequestAnimationFrame(callback);
     }).bind(this);
 
     content.mozRequestAnimationFrame(callback);
   }
 };
-
--- a/b2g/components/B2GComponents.manifest
+++ b/b2g/components/B2GComponents.manifest
@@ -8,8 +8,13 @@ category JavaScript-navigator-property m
 
 # AlertsService.js
 component {5dce03b2-8faa-4b6e-9242-6ddb0411750c} AlertsService.js
 contract @mozilla.org/alerts-service;1 {5dce03b2-8faa-4b6e-9242-6ddb0411750c}
 
 # ContentPermissionPrompt.js
 component {8c719f03-afe0-4aac-91ff-6c215895d467} ContentPermissionPrompt.js
 contract @mozilla.org/content-permission/prompt;1 {8c719f03-afe0-4aac-91ff-6c215895d467}
+
+# MozKeyboard.js
+component {397a7fdf-2254-47be-b74e-76625a1a66d5} MozKeyboard.js
+contract @mozilla.org/b2g-keyboard;1 {397a7fdf-2254-47be-b74e-76625a1a66d5}
+category JavaScript-navigator-property mozKeyboard @mozilla.org/b2g-keyboard;1
--- a/b2g/components/Makefile.in
+++ b/b2g/components/Makefile.in
@@ -48,11 +48,12 @@ XPIDLSRCS = \
         b2g.idl \
         $(NULL)
 
 EXTRA_PP_COMPONENTS = \
         B2GComponents.manifest \
         CameraContent.js \
         AlertsService.js \
         ContentPermissionPrompt.js \
+        MozKeyboard.js \
         $(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/b2g/components/MozKeyboard.js
@@ -0,0 +1,52 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+'use strict';
+
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+// -----------------------------------------------------------------------
+// MozKeyboard
+// -----------------------------------------------------------------------
+
+function MozKeyboard() { } 
+
+MozKeyboard.prototype = {
+  classID: Components.ID("{397a7fdf-2254-47be-b74e-76625a1a66d5}"),
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIB2GKeyboard, Ci.nsIDOMGlobalPropertyInitializer, Ci.nsIObserver]),
+  classInfo: XPCOMUtils.generateCI({classID: Components.ID("{397a7fdf-2254-47be-b74e-76625a1a66d5}"),
+                                    contractID: "@mozilla.org/b2g-keyboard;1",
+                                    interfaces: [Ci.nsIB2GKeyboard],
+                                    flags: Ci.nsIClassInfo.DOM_OBJECT,
+                                    classDescription: "B2G Virtual Keyboard"}),
+
+  init: function(aWindow) {
+    this._utils = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+    Services.obs.addObserver(this, "inner-window-destroyed", false);
+    this.innerWindowID = this._utils.currentInnerWindowID;
+  },
+
+  observe: function(aSubject, aTopic, aData) {
+    if (aTopic == "inner-window-destroyed") {
+      let wId = aSubject.QueryInterface(Ci.nsISupportsPRUint64).data;
+      if (wId == this.innerWindowID) {
+        Services.obs.removeObserver(this, "inner-window-destroyed");
+        this._utils = null;
+      }
+    }
+  },
+
+  sendKey: function mozKeyboardSendKey(keyCode, charCode) {
+    charCode = (charCode == undefined) ? keyCode : charCode;
+    ['keydown', 'keypress', 'keyup'].forEach((function sendKey(type) {
+      this._utils.sendKeyEvent(type, keyCode, charCode, null);
+    }).bind(this));
+  }
+};
+
+const NSGetFactory = XPCOMUtils.generateNSGetFactory([MozKeyboard]);
--- a/b2g/components/b2g.idl
+++ b/b2g/components/b2g.idl
@@ -3,10 +3,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "domstubs.idl"
 
 [scriptable, uuid(3615a616-571d-4194-bf54-ccf546067b14)]
 interface nsIB2GCameraContent : nsISupports
 {
     /* temporary solution, waiting for getUserMedia */
-	DOMString getCameraURI([optional] in jsval options);
+    DOMString getCameraURI([optional] in jsval options);
 };
+
+[scriptable, uuid(80ad05f8-e5f6-4a36-b25d-5d5a969b365d)]
+interface nsIB2GKeyboard : nsISupports
+{
+    void sendKey(in long aKeyCode, in long aCharCode);
+};
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -614,8 +614,9 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DL
 @BINPATH@/chrome/icons/
 @BINPATH@/chrome/chrome@JAREXT@
 @BINPATH@/chrome/chrome.manifest
 @BINPATH@/components/B2GComponents.manifest
 @BINPATH@/components/B2GComponents.xpt
 @BINPATH@/components/CameraContent.js
 @BINPATH@/components/AlertsService.js
 @BINPATH@/components/ContentPermissionPrompt.js
+@BINPATH@/components/MozKeyboard.js
--- a/browser/base/content/aboutDialog.xul
+++ b/browser/base/content/aboutDialog.xul
@@ -119,17 +119,17 @@
           <description class="text-blurb" id="currentChannelText">
             &channel.description.start;<label id="currentChannel"/>&channel.description.end;
           </description>
 #endif
           <vbox id="experimental" hidden="true">
             <description class="text-blurb" id="warningDesc">
               &warningDesc.version;
 #ifdef MOZ_TELEMETRY_REPORTING
-              &warningDesc.telemetry;
+              &warningDesc.telemetryDesc;
 #endif
             </description>
             <description class="text-blurb" id="communityExperimentalDesc">
               &community.exp.start;<label class="text-link" href="http://www.mozilla.org/">&community.exp.mozillaLink;</label>&community.exp.middle;<label class="text-link" href="about:credits">&community.exp.creditsLink;</label>&community.exp.end;
             </description>
           </vbox>
           <description class="text-blurb" id="communityDesc">
             &community.start2;<label class="text-link" href="http://www.mozilla.org/">&community.mozillaLink;</label>&community.middle2;<label class="text-link" href="about:credits">&community.creditsLink;</label>&community.end3;
--- a/browser/base/content/abouthome/aboutHome.css
+++ b/browser/base/content/abouthome/aboutHome.css
@@ -49,20 +49,16 @@ html {
                     -moz-linear-gradient(hsla(0,0%,100%,.7), hsla(0,0%,100%,.4));
   background-attachment: fixed;
   color: #000;
   height: 100%;
 }
 
 body {
   margin: 0;
-  height: 100%;
-}
-
-#container {
   display: -moz-box;
   -moz-box-orient: vertical;
   width: 100%;
   height: 100%;
 }
 
 input,
 button {
@@ -292,16 +288,17 @@ body[narrow] #restorePreviousSessionSepa
 }
 
 body[narrow] #restorePreviousSession {
   font-size: 80%;
 }
 
 .launchButton::before {
   display: block;
+  height: 32px;
   margin-bottom: 6px;
   line-height: 0; /* remove extra vertical space due to non-zero font-size */
 }
 
 #bookmarks::before {
   content: url("chrome://browser/content/abouthome/bookmarks.png");
 }
 
@@ -322,28 +319,32 @@ body[narrow] #restorePreviousSession {
 }
 
 #sync::before {
   content: url("chrome://browser/content/abouthome/sync.png");
 }
 
 #restorePreviousSession::before {
   content: url("chrome://browser/content/abouthome/restore-large.png");
+  height: 48px;
+  width: 48px;
   display: inline-block; /* display on same line as text label */
   vertical-align: middle;
   margin-bottom: 0;
   -moz-margin-end: 8px;
 }
 
 body[dir=rtl] #restorePreviousSession::before {
   -moz-transform: scaleX(-1);
 }
 
 body[narrow] #restorePreviousSession::before {
   content: url("chrome://browser/content/abouthome/restore.png");
+  height: 32px;
+  width: 32px;
 }
 
 #aboutMozilla {
   display: block;
   position: relative; /* pin wordmark to edge of document, not of viewport */
   -moz-box-ordinal-group: 0;
   opacity: .5;
   -moz-transition: opacity 150ms;
--- a/browser/base/content/abouthome/aboutHome.xhtml
+++ b/browser/base/content/abouthome/aboutHome.xhtml
@@ -63,46 +63,44 @@
     <link rel="stylesheet" type="text/css" media="all"
           href="chrome://browser/content/abouthome/aboutHome.css"/>
 
     <script type="text/javascript;version=1.8"
             src="chrome://browser/content/abouthome/aboutHome.js"/>
   </head>
 
   <body dir="&locale.dir;" onload="onLoad(event)">
-    <div id="container">
-      <div class="spacer"/>
-      <div id="topSection">
-        <img id="brandLogo" src="chrome://branding/content/about-logo.png" alt=""/>
-
-        <div id="searchContainer">
-          <form name="searchForm" id="searchForm" onsubmit="onSearchSubmit(event)">
-            <div id="searchLogoContainer"><img id="searchEngineLogo"/></div>
-            <input type="text" name="q" value="" id="searchText" maxlength="256"/>
-            <input id="searchSubmit" type="submit" value="&abouthome.searchEngineButton.label;"/>
-          </form>
-        </div>
+    <div class="spacer"/>
+    <div id="topSection">
+      <img id="brandLogo" src="chrome://branding/content/about-logo.png" alt=""/>
 
-        <div id="snippetContainer">
-          <div id="defaultSnippets" hidden="true">
-            <span id="defaultSnippet1">&abouthome.defaultSnippet1.v1;</span>
-            <span id="defaultSnippet2">&abouthome.defaultSnippet2.v1;</span>
-          </div>
-          <div id="snippets"/>
-        </div>
-      </div>
-      <div class="spacer"/>
-
-      <div id="launcher" session="true">
-        <button class="launchButton" id="bookmarks">&abouthome.bookmarksButton.label;</button>
-        <button class="launchButton" id="history">&abouthome.historyButton.label;</button>
-        <button class="launchButton" id="settings">&abouthome.settingsButton.label;</button>
-        <button class="launchButton" id="addons">&abouthome.addonsButton.label;</button>
-        <button class="launchButton" id="downloads">&abouthome.downloadsButton.label;</button>
-        <button class="launchButton" id="sync">&syncBrand.shortName.label;</button>
-        <div id="restorePreviousSessionSeparator"/>
-        <button class="launchButton" id="restorePreviousSession">&historyRestoreLastSession.label;</button>
+      <div id="searchContainer">
+        <form name="searchForm" id="searchForm" onsubmit="onSearchSubmit(event)">
+          <div id="searchLogoContainer"><img id="searchEngineLogo"/></div>
+          <input type="text" name="q" value="" id="searchText" maxlength="256"/>
+          <input id="searchSubmit" type="submit" value="&abouthome.searchEngineButton.label;"/>
+        </form>
       </div>
 
-      <a id="aboutMozilla" href="http://www.mozilla.com/about/"/>
+      <div id="snippetContainer">
+        <div id="defaultSnippets" hidden="true">
+          <span id="defaultSnippet1">&abouthome.defaultSnippet1.v1;</span>
+          <span id="defaultSnippet2">&abouthome.defaultSnippet2.v1;</span>
+        </div>
+        <div id="snippets"/>
+      </div>
     </div>
+    <div class="spacer"/>
+
+    <div id="launcher" session="true">
+      <button class="launchButton" id="bookmarks">&abouthome.bookmarksButton.label;</button>
+      <button class="launchButton" id="history">&abouthome.historyButton.label;</button>
+      <button class="launchButton" id="settings">&abouthome.settingsButton.label;</button>
+      <button class="launchButton" id="addons">&abouthome.addonsButton.label;</button>
+      <button class="launchButton" id="downloads">&abouthome.downloadsButton.label;</button>
+      <button class="launchButton" id="sync">&syncBrand.shortName.label;</button>
+      <div id="restorePreviousSessionSeparator"/>
+      <button class="launchButton" id="restorePreviousSession">&historyRestoreLastSession.label;</button>
+    </div>
+
+    <a id="aboutMozilla" href="http://www.mozilla.com/about/"/>
   </body>
 </html>
--- a/browser/components/preferences/applications.js
+++ b/browser/components/preferences/applications.js
@@ -1828,21 +1828,21 @@ var gApplicationsPane = {
 
     return "moz-icon://" + urlSpec + "?size=16";
   },
 
   _getIconURLForWebApp: function(aWebAppURITemplate) {
     var uri = this._ioSvc.newURI(aWebAppURITemplate, null, null);
 
     // Unfortunately we can't use the favicon service to get the favicon,
-    // because the service looks in the annotations table for a record with
-    // the exact URL we give it, and users won't have such records for URLs
-    // they don't visit, and users won't visit the web app's URL template,
-    // they'll only visit URLs derived from that template (i.e. with %s
-    // in the template replaced by the URL of the content being handled).
+    // because the service looks for a record with the exact URL we give it, and
+    // users won't have such records for URLs they don't visit, and users won't
+    // visit the handler's URL template, they'll only visit URLs derived from
+    // that template (i.e. with %s in the template replaced by the URL of the
+    // content being handled).
 
     if (/^https?/.test(uri.scheme) && this._prefSvc.getBoolPref("browser.chrome.favicons"))
       return uri.prePath + "/favicon.ico";
 
     return "";
   },
 
   _getIconURLForSystemDefault: function(aHandlerInfo) {
--- a/browser/components/sessionstore/test/browser_625016.js
+++ b/browser/components/sessionstore/test/browser_625016.js
@@ -18,16 +18,20 @@ function test() {
 
   // We speed up the interval between session saves to ensure that the test
   // runs quickly.
   Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
   registerCleanupFunction(function () {
     Services.prefs.clearUserPref("browser.sessionstore.interval");
   });
 
+  waitForSaveState(setup);
+}
+
+function setup() {
   // We'll clear all closed windows to make sure our state is clean
   // forgetClosedWindow doesn't trigger a delayed save
   while (ss.getClosedWindowCount()) {
     ss.forgetClosedWindow(0);
   }
   is(ss.getClosedWindowCount(), 0, "starting with no closed windows");
 
   // Open a new window, which should trigger a save event soon.
--- a/browser/components/tabview/groupitems.js
+++ b/browser/components/tabview/groupitems.js
@@ -1186,16 +1186,20 @@ GroupItem.prototype = Utils.extend(new I
   //   xulTab - the xul:tab.
   //   options - change how the app tab is added.
   //
   // Options:
   //   position - the position of the app tab should be added to.
   //   dontAdjustTray - (boolean) if true, do not adjust the tray.
   addAppTab: function GroupItem_addAppTab(xulTab, options) {
     GroupItems.getAppTabFavIconUrl(xulTab, function(iconUrl) {
+      // The tab might have been removed or unpinned while waiting.
+      if (xulTab.closing || !xulTab.parentNode || !xulTab.pinned)
+        return;
+
       let self = this;
       let $appTab = iQ("<img>")
         .addClass("appTabIcon")
         .attr("src", iconUrl)
         .data("xulTab", xulTab)
         .mousedown(function GroupItem_addAppTab_onAppTabMousedown(event) {
           // stop mousedown propagation to disable group dragging on app tabs
           event.stopPropagation();
--- a/browser/devtools/debugger/DebuggerUI.jsm
+++ b/browser/devtools/debugger/DebuggerUI.jsm
@@ -573,16 +573,17 @@ DebuggerUI.prototype = {
     let scripts = doc.getElementById("scripts");
     let elt = scripts.getElementsByAttribute("value", aSourceUrl)[0];
     let script = elt.getUserData("sourceScript");
     script.loaded = true;
     script.text = aSourceText;
     script.contentType = aContentType;
     elt.setUserData("sourceScript", script, null);
     dbg._updateEditorBreakpoints();
+    dbg.debuggerWindow.StackFrames.updateEditor();
   }
 };
 
 /**
  * Various debugger UI preferences (currently just the pane height).
  */
 let DebuggerUIPreferences = {
 
--- a/browser/devtools/debugger/debugger-view.js
+++ b/browser/devtools/debugger/debugger-view.js
@@ -276,51 +276,84 @@ DebuggerView.Stackframes = {
     if (ThreadState.activeThread.paused) {
       ThreadState.activeThread.resume();
     } else {
       ThreadState.activeThread.interrupt();
     }
   },
 
   /**
+   * Listener handling the step over button click event.
+   */
+  _onStepOverClick: function DVF__onStepOverClick() {
+    ThreadState.activeThread.stepOver();
+  },
+
+  /**
+   * Listener handling the step in button click event.
+   */
+  _onStepInClick: function DVF__onStepInClick() {
+    ThreadState.activeThread.stepIn();
+  },
+
+  /**
+   * Listener handling the step out button click event.
+   */
+  _onStepOutClick: function DVF__onStepOutClick() {
+    ThreadState.activeThread.stepOut();
+  },
+
+  /**
    * Specifies if the active thread has more frames which need to be loaded.
    */
   _dirty: false,
 
   /**
    * The cached stackframes container.
    */
   _frames: null,
 
   /**
    * Initialization function, called when the debugger is initialized.
    */
   initialize: function DVF_initialize() {
     let close = document.getElementById("close");
     let resume = document.getElementById("resume");
+    let stepOver = document.getElementById("step-over");
+    let stepIn = document.getElementById("step-in");
+    let stepOut = document.getElementById("step-out");
     let frames = document.getElementById("stackframes");
 
     close.addEventListener("click", this._onCloseButtonClick, false);
     resume.addEventListener("click", this._onResumeButtonClick, false);
+    stepOver.addEventListener("click", this._onStepOverClick, false);
+    stepIn.addEventListener("click", this._onStepInClick, false);
+    stepOut.addEventListener("click", this._onStepOutClick, false);
     frames.addEventListener("scroll", this._onFramesScroll, false);
     window.addEventListener("resize", this._onFramesScroll, false);
 
     this._frames = frames;
   },
 
   /**
    * Destruction function, called when the debugger is shut down.
    */
   destroy: function DVF_destroy() {
     let close = document.getElementById("close");
     let resume = document.getElementById("resume");
+    let stepOver = document.getElementById("step-over");
+    let stepIn = document.getElementById("step-in");
+    let stepOut = document.getElementById("step-out");
     let frames = this._frames;
 
     close.removeEventListener("click", this._onCloseButtonClick, false);
     resume.removeEventListener("click", this._onResumeButtonClick, false);
+    stepOver.removeEventListener("click", this._onStepOverClick, false);
+    stepIn.removeEventListener("click", this._onStepInClick, false);
+    stepOut.removeEventListener("click", this._onStepOutClick, false);
     frames.removeEventListener("click", this._onFramesClick, false);
     frames.removeEventListener("scroll", this._onFramesScroll, false);
     window.removeEventListener("resize", this._onFramesScroll, false);
 
     this._frames = null;
   }
 };
 
@@ -1193,8 +1226,11 @@ DebuggerView.Scripts = {
   }
 };
 
 
 let DVF = DebuggerView.Stackframes;
 DVF._onFramesScroll = DVF._onFramesScroll.bind(DVF);
 DVF._onCloseButtonClick = DVF._onCloseButtonClick.bind(DVF);
 DVF._onResumeButtonClick = DVF._onResumeButtonClick.bind(DVF);
+DVF._onStepOverClick = DVF._onStepOverClick.bind(DVF);
+DVF._onStepInClick = DVF._onStepInClick.bind(DVF);
+DVF._onStepOutClick = DVF._onStepOutClick.bind(DVF);
--- a/browser/devtools/debugger/debugger.js
+++ b/browser/devtools/debugger/debugger.js
@@ -19,16 +19,17 @@
  *   Mozilla Foundation
  * Portions created by the Initial Developer are Copyright (C) 2011
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Dave Camp <dcamp@mozilla.com>
  *   Panos Astithas <past@mozilla.com>
  *   Victor Porof <vporof@mozilla.com>
+ *   Mihai Sucan <mihai.sucan@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * 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
@@ -170,39 +171,48 @@ var StackFrames = {
    * @param function aCallback
    *        The next function in the initialization sequence.
    */
   connect: function SF_connect(aThreadClient, aCallback) {
     DebuggerView.Stackframes.addClickListener(this.onClick);
 
     this.activeThread = aThreadClient;
     aThreadClient.addListener("paused", this.onPaused);
+    aThreadClient.addListener("resumed", this.onResume);
     aThreadClient.addListener("framesadded", this.onFrames);
     aThreadClient.addListener("framescleared", this.onFramesCleared);
     this.onFramesCleared();
     aCallback && aCallback();
   },
 
   /**
    * Disconnect from the client.
    */
   disconnect: function TS_disconnect() {
     this.activeThread.removeListener("paused", this.onPaused);
+    this.activeThread.removeListener("resumed", this.onResume);
     this.activeThread.removeListener("framesadded", this.onFrames);
     this.activeThread.removeListener("framescleared", this.onFramesCleared);
   },
 
   /**
    * Handler for the thread client's paused notification.
    */
   onPaused: function SF_onPaused() {
     this.activeThread.fillFrames(this.pageSize);
   },
 
   /**
+   * Handler for the thread client's resumed notification.
+   */
+  onResume: function SF_onResume() {
+    window.editor.setDebugLocation(-1);
+  },
+
+  /**
    * Handler for the thread client's framesadded notification.
    */
   onFrames: function SF_onFrames() {
     DebuggerView.Stackframes.empty();
 
     for each (let frame in this.activeThread.cachedFrames) {
       this._addFramePanel(frame);
     }
@@ -260,21 +270,25 @@ var StackFrames = {
 
     let frame = this.activeThread.cachedFrames[aDepth];
     if (!frame) {
       return;
     }
     // Move the editor's caret to the proper line.
     if (DebuggerView.Scripts.isSelected(frame.where.url) && frame.where.line) {
       window.editor.setCaretPosition(frame.where.line - 1);
+      window.editor.setDebugLocation(frame.where.line - 1);
     } else if (DebuggerView.Scripts.contains(frame.where.url)) {
       DebuggerView.Scripts.selectScript(frame.where.url);
       SourceScripts.onChange({ target: DebuggerView.Scripts._scripts });
       window.editor.setCaretPosition(frame.where.line - 1);
+    } else {
+      window.editor.setDebugLocation(-1);
     }
+
     // Display the local variables.
     let localScope = DebuggerView.Properties.localScope;
     localScope.empty();
     // Add "this".
     if (frame["this"]) {
       let thisVar = localScope.addVar("this");
       thisVar.setGrip({ "type": frame["this"].type,
                         "class": frame["this"].class });
@@ -296,16 +310,38 @@ var StackFrames = {
           let paramVal = frame.arguments[i];
           paramVar.setGrip(paramVal);
           this._addExpander(paramVar, paramVal);
         }
       }.bind(this));
     }
   },
 
+  /**
+   * Update the source editor current debug location based on the selected frame
+   * and script.
+   */
+  updateEditor: function SF_updateEditor() {
+    if (this.selectedFrame === null) {
+      return;
+    }
+
+    let frame = this.activeThread.cachedFrames[this.selectedFrame];
+    if (!frame) {
+      return;
+    }
+
+    // Move the editor's caret to the proper line.
+    if (DebuggerView.Scripts.isSelected(frame.where.url) && frame.where.line) {
+      window.editor.setDebugLocation(frame.where.line - 1);
+    } else {
+      window.editor.setDebugLocation(-1);
+    }
+  },
+
   _addExpander: function SF_addExpander(aVar, aObject) {
     // No need for expansion for null and undefined values, but we do need them
     // for frame.arguments which is a regular array.
     if (!aObject || typeof aObject != "object" ||
         (aObject.type != "object" && !Array.isArray(aObject))) {
       return;
     }
     // Add a dummy property to force the twisty to show up.
@@ -403,16 +439,17 @@ var StackFrames = {
       return aFrame["calleeName"] ? aFrame["calleeName"] : "(anonymous)";
     }
 
     return "(" + aFrame.type + ")";
   }
 };
 
 StackFrames.onPaused = StackFrames.onPaused.bind(StackFrames);
+StackFrames.onResume = StackFrames.onResume.bind(StackFrames);
 StackFrames.onFrames = StackFrames.onFrames.bind(StackFrames);
 StackFrames.onFramesCleared = StackFrames.onFramesCleared.bind(StackFrames);
 StackFrames.onClick = StackFrames.onClick.bind(StackFrames);
 
 /**
  * Keeps the source script list up-to-date, using the thread client's
  * source script cache.
  */
@@ -609,16 +646,17 @@ var SourceScripts = {
       // Notify the chrome code that we need to load a script file.
       var evt = document.createEvent("CustomEvent");
       evt.initCustomEvent("Debugger:LoadSource", true, false, aScript.url);
       document.documentElement.dispatchEvent(evt);
       window.editor.setText(DebuggerView.getStr("loadingText"));
     } else {
       window.editor.setText(aScript.text);
       window.updateEditorBreakpoints();
+      StackFrames.updateEditor();
     }
     window.editor.resetUndo();
   }
 };
 
 SourceScripts.onPaused = SourceScripts.onPaused.bind(SourceScripts);
 SourceScripts.onScripts = SourceScripts.onScripts.bind(SourceScripts);
 SourceScripts.onNewScript = SourceScripts.onNewScript.bind(SourceScripts);
--- a/browser/devtools/debugger/debugger.xul
+++ b/browser/devtools/debugger/debugger.xul
@@ -68,16 +68,19 @@
     <xul:commandset id="editMenuCommands"/>
     <xul:commandset id="sourceEditorCommands"/>
     <xul:keyset id="sourceEditorKeys"/>
 
     <div id="body" class="vbox flex">
         <xul:toolbar id="dbg-toolbar">
             <xul:button id="close">&debuggerUI.closeButton;</xul:button>
             <xul:button id="resume"/>
+            <xul:button id="step-over">&debuggerUI.stepOverButton;</xul:button>
+            <xul:button id="step-in">&debuggerUI.stepInButton;</xul:button>
+            <xul:button id="step-out">&debuggerUI.stepOutButton;</xul:button>
             <xul:menulist id="scripts"/>
         </xul:toolbar>
         <div id="dbg-content" class="hbox flex">
             <div id="stack" class="vbox">
                 <div class="title unselectable">&debuggerUI.stackTitle;</div>
                 <div id="stackframes" class="vbox flex"></div>
             </div>
             <div id="script" class="vbox flex">
--- a/browser/devtools/debugger/test/Makefile.in
+++ b/browser/devtools/debugger/test/Makefile.in
@@ -62,16 +62,17 @@ include $(topsrcdir)/config/rules.mk
 	browser_dbg_propertyview-06.js \
 	browser_dbg_propertyview-07.js \
 	browser_dbg_propertyview-08.js \
 	browser_dbg_panesize.js \
 	browser_dbg_stack-01.js \
 	browser_dbg_stack-02.js \
 	browser_dbg_stack-03.js \
 	browser_dbg_stack-04.js \
+	browser_dbg_stack-05.js \
 	browser_dbg_location-changes.js \
 	browser_dbg_script-switching.js \
 	browser_dbg_pause-resume.js \
 	browser_dbg_update-editor-mode.js \
 	$(warning browser_dbg_select-line.js temporarily disabled due to oranges, see bug 726609) \
 	browser_dbg_clean-exit.js \
 	browser_dbg_bug723069_editor-breakpoints.js \
 	browser_dbg_bug731394_editor-contextmenu.js \
--- a/browser/devtools/debugger/test/browser_dbg_script-switching.js
+++ b/browser/devtools/debugger/test/browser_dbg_script-switching.js
@@ -56,16 +56,19 @@ function testScriptsDisplay() {
         label1), "First script label is incorrect.");
       ok(gDebugger.DebuggerView.Scripts.containsLabel(
         label2), "Second script label is incorrect.");
 
 
       ok(gDebugger.editor.getText().search(/debugger/) != -1,
         "The correct script was loaded initially.");
 
+      is(gDebugger.editor.getDebugLocation(), 5,
+         "editor debugger location is correct.");
+
       gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
                                         function onChange() {
         gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
                                              onChange);
         testSwitchPaused();
       });
       gScripts.selectedIndex = 0;
       gDebugger.SourceScripts.onChange({ target: gScripts });
@@ -78,16 +81,19 @@ function testScriptsDisplay() {
 function testSwitchPaused()
 {
   ok(gDebugger.editor.getText().search(/debugger/) == -1,
     "The second script is no longer displayed.");
 
   ok(gDebugger.editor.getText().search(/firstCall/) != -1,
     "The first script is displayed.");
 
+  is(gDebugger.editor.getDebugLocation(), -1,
+     "editor debugger location has been cleared.");
+
   gDebugger.StackFrames.activeThread.resume(function() {
     gDebugger.editor.addEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
                                       function onSecondChange() {
       gDebugger.editor.removeEventListener(SourceEditor.EVENTS.TEXT_CHANGED,
                                            onSecondChange);
       testSwitchRunning();
     });
     gScripts.selectedIndex = 1;
@@ -98,16 +104,19 @@ function testSwitchPaused()
 function testSwitchRunning()
 {
   ok(gDebugger.editor.getText().search(/debugger/) != -1,
     "The second script is displayed again.");
 
   ok(gDebugger.editor.getText().search(/firstCall/) == -1,
     "The first script is no longer displayed.");
 
+  is(gDebugger.editor.getDebugLocation(), -1,
+     "editor debugger location is still -1.");
+
   closeDebuggerAndFinish(gTab);
 }
 
 registerCleanupFunction(function() {
   removeTab(gTab);
   gPane = null;
   gTab = null;
   gDebuggee = null;
new file mode 100644
--- /dev/null
+++ b/browser/devtools/debugger/test/browser_dbg_stack-05.js
@@ -0,0 +1,92 @@
+/* vim:set ts=2 sw=2 sts=2 et: */
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Test that switching between stack frames properly sets the current debugger
+// location in the source editor.
+
+const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
+
+var gPane = null;
+var gTab = null;
+var gDebuggee = null;
+var gDebugger = null;
+
+function test() {
+  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
+    gTab = aTab;
+    gDebuggee = aDebuggee;
+    gPane = aPane;
+    gDebugger = gPane.debuggerWindow;
+
+    testRecurse();
+  });
+}
+
+function testRecurse() {
+  gPane.activeThread.addOneTimeListener("scriptsadded", function() {
+    Services.tm.currentThread.dispatch({ run: function() {
+      let frames = gDebugger.DebuggerView.Stackframes._frames;
+      let childNodes = frames.childNodes;
+
+      is(frames.querySelectorAll(".dbg-stackframe").length, 4,
+        "Correct number of frames.");
+
+      is(childNodes.length, frames.querySelectorAll(".dbg-stackframe").length,
+        "All children should be frames.");
+
+      ok(frames.querySelector("#stackframe-0").classList.contains("selected"),
+        "First frame should be selected by default.");
+
+      ok(!frames.querySelector("#stackframe-2").classList.contains("selected"),
+        "Third frame should not be selected.");
+
+      is(gDebugger.editor.getDebugLocation(), 5,
+         "editor debugger location is correct.");
+
+      EventUtils.sendMouseEvent({ type: "click" },
+        frames.querySelector("#stackframe-2"),
+        gDebugger);
+
+      ok(!frames.querySelector("#stackframe-0").classList.contains("selected"),
+         "First frame should not be selected after click.");
+
+      ok(frames.querySelector("#stackframe-2").classList.contains("selected"),
+         "Third frame should be selected after click.");
+
+      is(gDebugger.editor.getDebugLocation(), 4,
+         "editor debugger location is correct after click.");
+
+      EventUtils.sendMouseEvent({ type: "click" },
+        frames.querySelector("#stackframe-0 .dbg-stackframe-name"),
+        gDebugger);
+
+      ok(frames.querySelector("#stackframe-0").classList.contains("selected"),
+         "First frame should be selected after click inside the first frame.");
+
+      ok(!frames.querySelector("#stackframe-2").classList.contains("selected"),
+         "Third frame should not be selected after click inside the first frame.");
+
+      is(gDebugger.editor.getDebugLocation(), 5,
+         "editor debugger location is correct (frame 0 again).");
+
+      gDebugger.StackFrames.activeThread.resume(function() {
+        is(gDebugger.editor.getDebugLocation(), -1,
+           "editor debugger location is correct after resume.");
+        closeDebuggerAndFinish(gTab);
+      });
+    }}, 0);
+  });
+
+  gDebuggee.firstCall();
+}
+
+registerCleanupFunction(function() {
+  removeTab(gTab);
+  gPane = null;
+  gTab = null;
+  gDebuggee = null;
+  gDebugger = null;
+});
--- a/browser/devtools/highlighter/inspector.jsm
+++ b/browser/devtools/highlighter/inspector.jsm
@@ -1242,16 +1242,20 @@ InspectorUI.prototype = {
       // node.textContent below, which also gets text from hidden nodes. The
       // simplest way to do this is to clone the node and remove them from the
       // clone.
       node = node.cloneNode();
       let computed = node.querySelector(".ruleview-computedlist");
       if (computed) {
         computed.parentNode.removeChild(computed);
       }
+      let autosizer = node.querySelector(".autosizer");
+      if (autosizer) {
+        autosizer.parentNode.removeChild(autosizer);
+      }
     }
 
     let text = node.textContent;
 
     // Format the rule
     if (osString == "WINNT") {
       text = text.replace(/{/g, "{\r\n    ");
       text = text.replace(/;/g, ";\r\n    ");
--- a/browser/devtools/sourceeditor/source-editor-orion.jsm
+++ b/browser/devtools/sourceeditor/source-editor-orion.jsm
@@ -20,16 +20,17 @@
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Mihai Sucan <mihai.sucan@gmail.com> (original author)
  *   Kenny Heaton <kennyheaton@gmail.com>
  *   Spyros Livathinos <livathinos.spyros@gmail.com>
  *   Allen Eubank <adeubank@gmail.com>
  *   Girish Sharma <scrapmachines@gmail.com>
+ *   Pranav Ravichandran <prp.1111@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * 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
@@ -107,16 +108,17 @@ const ORION_EVENTS = {
  * Known Orion annotation types.
  */
 const ORION_ANNOTATION_TYPES = {
   currentBracket: "orion.annotation.currentBracket",
   matchingBracket: "orion.annotation.matchingBracket",
   breakpoint: "orion.annotation.breakpoint",
   task: "orion.annotation.task",
   currentLine: "orion.annotation.currentLine",
+  debugLocation: "mozilla.annotation.debugLocation",
 };
 
 /**
  * Default key bindings in the Orion editor.
  */
 const DEFAULT_KEYBINDINGS = [
   {
     action: "enter",
@@ -145,16 +147,27 @@ const DEFAULT_KEYBINDINGS = [
     alt: true,
   },
   {
     action: "Move Lines Down",
     code: Ci.nsIDOMKeyEvent.DOM_VK_DOWN,
     ctrl: Services.appinfo.OS == "Darwin",
     alt: true,
   },
+  {
+    action: "Comment",
+    code: Ci.nsIDOMKeyEvent.DOM_VK_SLASH,
+    accel: true,
+  },
+  {
+    action: "Uncomment",
+    code: Ci.nsIDOMKeyEvent.DOM_VK_SLASH,
+    accel: true,
+    shift: true,
+  },
 ];
 
 var EXPORTED_SYMBOLS = ["SourceEditor"];
 
 /**
  * The SourceEditor object constructor. The SourceEditor component allows you to
  * provide users with an editor tailored to the specific needs of editing source
  * code, aimed primarily at web developers.
@@ -337,22 +350,17 @@ SourceEditor.prototype = {
 
     this._annotationModel = new AnnotationModel(this._model);
 
     if (config.showAnnotationRuler) {
       this._annotationRuler = new AnnotationRuler(this._annotationModel, "left",
         {styleClass: "ruler annotations"});
       this._annotationRuler.onClick = this._annotationRulerClick.bind(this);
       this._annotationRuler.addAnnotationType(ORION_ANNOTATION_TYPES.breakpoint);
-      this._annotationRuler.setMultiAnnotation({
-        html: "<div class='annotationHTML multiple'></div>"
-      });
-      this._annotationRuler.setMultiAnnotationOverlay({
-        html: "<div class='annotationHTML overlay'></div>"
-      });
+      this._annotationRuler.addAnnotationType(ORION_ANNOTATION_TYPES.debugLocation);
       this._view.addRuler(this._annotationRuler);
     }
 
     if (config.showLineNumbers) {
       let rulerClass = this._annotationRuler ?
                        "ruler lines linesWithAnnotations" :
                        "ruler lines";
 
@@ -368,16 +376,17 @@ SourceEditor.prototype = {
     if (config.showOverviewRuler) {
       this._overviewRuler = new OverviewRuler(this._annotationModel, "right",
         {styleClass: "ruler overview"});
       this._overviewRuler.onClick = this._overviewRulerClick.bind(this);
 
       this._overviewRuler.addAnnotationType(ORION_ANNOTATION_TYPES.matchingBracket);
       this._overviewRuler.addAnnotationType(ORION_ANNOTATION_TYPES.currentBracket);
       this._overviewRuler.addAnnotationType(ORION_ANNOTATION_TYPES.breakpoint);
+      this._overviewRuler.addAnnotationType(ORION_ANNOTATION_TYPES.debugLocation);
       this._overviewRuler.addAnnotationType(ORION_ANNOTATION_TYPES.task);
       this._view.addRuler(this._overviewRuler);
     }
 
     this.setMode(config.mode);
 
     this._undoStack = new UndoStack(this._view, config.undoLimit);
 
@@ -389,16 +398,18 @@ SourceEditor.prototype = {
       "tab": [this._doTab, this],
       "Unindent Lines": [this._doUnindentLines, this],
       "enter": [this._doEnter, this],
       "Find...": [this.ui.find, this.ui],
       "Find Next Occurrence": [this.ui.findNext, this.ui],
       "Find Previous Occurrence": [this.ui.findPrevious, this.ui],
       "Goto Line...": [this.ui.gotoLine, this.ui],
       "Move Lines Down": [this._moveLines, this],
+      "Comment": [this._doComment, this],
+      "Uncomment": [this._doUncomment, this],
     };
 
     for (let name in actions) {
       let action = actions[name];
       this._view.setAction(name, action[0].bind(action[1]));
     }
 
     this._view.setAction("Move Lines Up", this._moveLines.bind(this, true));
@@ -481,32 +492,32 @@ SourceEditor.prototype = {
     if (this.readOnly) {
       return false;
     }
 
     let indent = "\t";
     let selection = this.getSelection();
     let model = this._model;
     let firstLine = model.getLineAtOffset(selection.start);
-    let firstLineStart = model.getLineStart(firstLine);
+    let firstLineStart = this.getLineStart(firstLine);
     let lastLineOffset = selection.end > selection.start ?
                          selection.end - 1 : selection.end;
     let lastLine = model.getLineAtOffset(lastLineOffset);
 
     if (this._expandTab) {
       let offsetFromLineStart = firstLine == lastLine ?
                                 selection.start - firstLineStart : 0;
       let spaces = this._tabSize - (offsetFromLineStart % this._tabSize);
       indent = (new Array(spaces + 1)).join(" ");
     }
 
     // Do selection indentation.
     if (firstLine != lastLine) {
       let lines = [""];
-      let lastLineEnd = model.getLineEnd(lastLine, true);
+      let lastLineEnd = this.getLineEnd(lastLine, true);
       let selectedLines = lastLine - firstLine + 1;
 
       for (let i = firstLine; i <= lastLine; i++) {
         lines.push(model.getLine(i, true));
       }
 
       this.startCompoundChange();
 
@@ -553,19 +564,19 @@ SourceEditor.prototype = {
     for (let line, i = firstLine; i <= lastLine; i++) {
       line = model.getLine(i, true);
       if (line.indexOf(indent) != 0) {
         return true;
       }
       lines.push(line.substring(indent.length));
     }
 
-    let firstLineStart = model.getLineStart(firstLine);
-    let lastLineStart = model.getLineStart(lastLine);
-    let lastLineEnd = model.getLineEnd(lastLine, true);
+    let firstLineStart = this.getLineStart(firstLine);
+    let lastLineStart = this.getLineStart(lastLine);
+    let lastLineEnd = this.getLineEnd(lastLine, true);
 
     this.startCompoundChange();
 
     this.setText(lines.join(""), firstLineStart, lastLineEnd);
 
     let selectedLines = lastLine - firstLine + 1;
     let newSelectionStart = firstLineStart == selection.start ?
                             selection.start :
@@ -597,17 +608,17 @@ SourceEditor.prototype = {
     let selection = this.getSelection();
     if (selection.start != selection.end) {
       return false;
     }
 
     let model = this._model;
     let lineIndex = model.getLineAtOffset(selection.start);
     let lineText = model.getLine(lineIndex, true);
-    let lineStart = model.getLineStart(lineIndex);
+    let lineStart = this.getLineStart(lineIndex);
     let index = 0;
     let lineOffset = selection.start - lineStart;
     while (index < lineOffset && /[ \t]/.test(lineText.charAt(index))) {
       index++;
     }
 
     if (!index) {
       return false;
@@ -641,53 +652,53 @@ SourceEditor.prototype = {
     let model = this._model;
     let selection = this.getSelection();
     let firstLine = model.getLineAtOffset(selection.start);
     if (firstLine == 0 && aLineAbove) {
       return true;
     }
 
     let lastLine = model.getLineAtOffset(selection.end);
-    let firstLineStart = model.getLineStart(firstLine);
-    let lastLineStart = model.getLineStart(lastLine);
+    let firstLineStart = this.getLineStart(firstLine);
+    let lastLineStart = this.getLineStart(lastLine);
     if (selection.start != selection.end && lastLineStart == selection.end) {
       lastLine--;
     }
     if (!aLineAbove && (lastLine + 1) == this.getLineCount()) {
       return true;
     }
 
-    let lastLineEnd = model.getLineEnd(lastLine, true);
+    let lastLineEnd = this.getLineEnd(lastLine, true);
     let text = this.getText(firstLineStart, lastLineEnd);
 
     if (aLineAbove) {
       let aboveLine = firstLine - 1;
-      let aboveLineStart = model.getLineStart(aboveLine);
+      let aboveLineStart = this.getLineStart(aboveLine);
 
       this.startCompoundChange();
       if (lastLine == (this.getLineCount() - 1)) {
-        let delimiterStart = model.getLineEnd(aboveLine);
-        let delimiterEnd = model.getLineEnd(aboveLine, true);
+        let delimiterStart = this.getLineEnd(aboveLine);
+        let delimiterEnd = this.getLineEnd(aboveLine, true);
         let lineDelimiter = this.getText(delimiterStart, delimiterEnd);
         text += lineDelimiter;
         this.setText("", firstLineStart - lineDelimiter.length, lastLineEnd);
       } else {
         this.setText("", firstLineStart, lastLineEnd);
       }
       this.setText(text, aboveLineStart, aboveLineStart);
       this.endCompoundChange();
       this.setSelection(aboveLineStart, aboveLineStart + text.length);
     } else {
       let belowLine = lastLine + 1;
-      let belowLineEnd = model.getLineEnd(belowLine, true);
+      let belowLineEnd = this.getLineEnd(belowLine, true);
 
       let insertAt = belowLineEnd - lastLineEnd + firstLineStart;
       let lineDelimiter = "";
       if (belowLine == this.getLineCount() - 1) {
-        let delimiterStart = model.getLineEnd(lastLine);
+        let delimiterStart = this.getLineEnd(lastLine);
         lineDelimiter = this.getText(delimiterStart, lastLineEnd);
         text = lineDelimiter + text.substr(0, text.length -
                                               lineDelimiter.length);
       }
       this.startCompoundChange();
       this.setText("", firstLineStart, lastLineEnd);
       this.setText(text, insertAt, insertAt);
       this.endCompoundChange();
@@ -798,18 +809,18 @@ SourceEditor.prototype = {
       if (oldAnnotation) {
         annotationModel.removeAnnotation(oldAnnotation);
         this._currentLineAnnotation = null;
       }
       return;
     }
 
     let line = model.getLineAtOffset(newSelection.start);
-    let lineStart = model.getLineStart(line);
-    let lineEnd = model.getLineEnd(line);
+    let lineStart = this.getLineStart(line);
+    let lineEnd = this.getLineEnd(line);
 
     let title = oldAnnotation ? oldAnnotation.title :
                 SourceEditorUI.strings.GetStringFromName("annotation.currentLine");
 
     this._currentLineAnnotation = {
       start: lineStart,
       end: lineEnd,
       type: ORION_ANNOTATION_TYPES.currentLine,
@@ -841,19 +852,19 @@ SourceEditor.prototype = {
     }
 
     if (aEvent.shiftKey) {
       let model = this._model;
       let selection = this.getSelection();
       let selectionLineStart = model.getLineAtOffset(selection.start);
       let selectionLineEnd = model.getLineAtOffset(selection.end);
       let newStart = aLineIndex <= selectionLineStart ?
-                     model.getLineStart(aLineIndex) : selection.start;
+                     this.getLineStart(aLineIndex) : selection.start;
       let newEnd = aLineIndex <= selectionLineStart ?
-                   selection.end : model.getLineEnd(aLineIndex);
+                   selection.end : this.getLineEnd(aLineIndex);
       this.setSelection(newStart, newEnd);
     } else {
       this.setCaretPosition(aLineIndex);
     }
   },
 
   /**
    * The dblclick event handler for the lines gutter. This function selects the
@@ -866,18 +877,18 @@ SourceEditor.prototype = {
    *        The DOM dblclick event object.
    */
   _linesRulerDblClick: function SE__linesRulerDblClick(aLineIndex)
   {
     if (aLineIndex === undefined) {
       return;
     }
 
-    let newStart = this._model.getLineStart(aLineIndex);
-    let newEnd = this._model.getLineEnd(aLineIndex);
+    let newStart = this.getLineStart(aLineIndex);
+    let newEnd = this.getLineEnd(aLineIndex);
     this.setSelection(newStart, newEnd);
   },
 
   /**
    * Highlight the Orion annotations. This updates the annotation styler as
    * needed.
    * @private
    */
@@ -892,16 +903,17 @@ SourceEditor.prototype = {
       this._iframeWindow.require("orion/textview/annotations").AnnotationStyler;
 
     let styler = new AnnotationStyler(this._view, this._annotationModel);
     this._annotationStyler = styler;
 
     styler.addAnnotationType(ORION_ANNOTATION_TYPES.matchingBracket);
     styler.addAnnotationType(ORION_ANNOTATION_TYPES.currentBracket);
     styler.addAnnotationType(ORION_ANNOTATION_TYPES.task);
+    styler.addAnnotationType(ORION_ANNOTATION_TYPES.debugLocation);
 
     if (this._config.highlightCurrentLine) {
       styler.addAnnotationType(ORION_ANNOTATION_TYPES.currentLine);
     }
   },
 
   /**
    * Retrieve the list of Orion Annotations filtered by type for the given text range.
@@ -941,18 +953,18 @@ SourceEditor.prototype = {
    *        The DOM click event object.
    */
   _annotationRulerClick: function SE__annotationRulerClick(aLineIndex, aEvent)
   {
     if (aLineIndex === undefined || aLineIndex == -1) {
       return;
     }
 
-    let lineStart = this._model.getLineStart(aLineIndex);
-    let lineEnd = this._model.getLineEnd(aLineIndex);
+    let lineStart = this.getLineStart(aLineIndex);
+    let lineEnd = this.getLineEnd(aLineIndex);
     let annotations = this._getAnnotationsByType("breakpoint", lineStart, lineEnd);
     if (annotations.length > 0) {
       this.removeBreakpoint(aLineIndex);
     } else {
       this.addBreakpoint(aLineIndex);
     }
   },
 
@@ -968,18 +980,18 @@ SourceEditor.prototype = {
    */
   _overviewRulerClick: function SE__overviewRulerClick(aLineIndex, aEvent)
   {
     if (aLineIndex === undefined || aLineIndex == -1) {
       return;
     }
 
     let model = this._model;
-    let lineStart = model.getLineStart(aLineIndex);
-    let lineEnd = model.getLineEnd(aLineIndex);
+    let lineStart = this.getLineStart(aLineIndex);
+    let lineEnd = this.getLineEnd(aLineIndex);
     let annotations = this._annotationModel.getAnnotations(lineStart, lineEnd);
     let annotation = annotations.next();
 
     // Jump to the line where annotation is. If the annotation is specific to
     // a substring part of the line, then select the substring.
     if (!annotation || lineStart == annotation.start && lineEnd == annotation.end) {
       this.setSelection(lineStart, lineStart);
     } else {
@@ -993,16 +1005,168 @@ SourceEditor.prototype = {
    * @return nsIDOMElement
    *         In this implementation a xul:iframe holds the editor.
    */
   get editorElement() {
     return this._iframe;
   },
 
   /**
+   * Helper function to retrieve the strings used for comments in the current
+   * editor mode.
+   *
+   * @private
+   * @return object
+   *         An object that holds the following properties:
+   *         - line: the comment string used for the start of a single line
+   *         comment.
+   *         - blockStart: the comment string used for the start of a comment
+   *         block.
+   *         - blockEnd: the comment string used for the end of a block comment.
+   *         Null is returned for unsupported editor modes.
+   */
+  _getCommentStrings: function SE__getCommentStrings()
+  {
+    let line = "";
+    let blockCommentStart = "";
+    let blockCommentEnd = "";
+
+    switch (this.getMode()) {
+      case SourceEditor.MODES.JAVASCRIPT:
+        line = "//";
+        blockCommentStart = "/*";
+        blockCommentEnd = "*/";
+        break;
+      case SourceEditor.MODES.CSS:
+        blockCommentStart = "/*";
+        blockCommentEnd = "*/";
+        break;
+      case SourceEditor.MODES.HTML:
+      case SourceEditor.MODES.XML:
+        blockCommentStart = "<!--";
+        blockCommentEnd = "-->";
+        break;
+      default:
+        return null;
+    }
+    return {line: line, blockStart: blockCommentStart, blockEnd: blockCommentEnd};
+  },
+
+  /**
+   * Wrap the selected text in comments. If nothing is selected the current
+   * caret line is commented out. Single line and block comments depend on the
+   * current editor mode.
+   *
+   * @private
+   */
+  _doComment: function SE__doComment()
+  {
+    if (this.readOnly) {
+      return false;
+    }
+
+    let commentObject = this._getCommentStrings();
+    if (!commentObject) {
+      return false;
+    }
+
+    let selection = this.getSelection();
+
+    if (selection.start == selection.end) {
+      let selectionLine = this._model.getLineAtOffset(selection.start);
+      let lineStartOffset = this.getLineStart(selectionLine);
+      if (commentObject.line) {
+        this.setText(commentObject.line, lineStartOffset, lineStartOffset);
+      } else {
+        let lineEndOffset = this.getLineEnd(selectionLine);
+        this.startCompoundChange();
+        this.setText(commentObject.blockStart, lineStartOffset, lineStartOffset);
+        this.setText(commentObject.blockEnd,
+                     lineEndOffset + commentObject.blockStart.length,
+                     lineEndOffset + commentObject.blockStart.length);
+        this.endCompoundChange();
+      }
+    } else {
+      this.startCompoundChange();
+      this.setText(commentObject.blockStart, selection.start, selection.start);
+      this.setText(commentObject.blockEnd,
+                   selection.end + commentObject.blockStart.length,
+                   selection.end + commentObject.blockStart.length);
+      this.endCompoundChange();
+    }
+
+    return true;
+  },
+
+  /**
+   * Uncomment the selected text. If nothing is selected the current caret line
+   * is umcommented. Single line and block comments depend on the current editor
+   * mode.
+   *
+   * @private
+   */
+  _doUncomment: function SE__doUncomment()
+  {
+    if (this.readOnly) {
+      return false;
+    }
+
+    let commentObject = this._getCommentStrings();
+    if (!commentObject) {
+      return false;
+    }
+
+    let selection = this.getSelection();
+    let firstLine = this._model.getLineAtOffset(selection.start);
+    let lastLine = this._model.getLineAtOffset(selection.end);
+
+    // Uncomment a block of text.
+    let firstLineText = this._model.getLine(firstLine);
+    let lastLineText = this._model.getLine(lastLine);
+    let openIndex = firstLineText.indexOf(commentObject.blockStart);
+    let closeIndex = lastLineText.lastIndexOf(commentObject.blockEnd);
+    if (openIndex != -1 && closeIndex != -1) {
+      let firstLineStartOffset = this.getLineStart(firstLine);
+      let lastLineStartOffset = this.getLineStart(lastLine);
+      let openOffset = firstLineStartOffset + openIndex;
+      let closeOffset = lastLineStartOffset + closeIndex;
+
+      this.startCompoundChange();
+      this.setText("", closeOffset, closeOffset + commentObject.blockEnd.length);
+      this.setText("", openOffset, openOffset + commentObject.blockStart.length);
+      this.endCompoundChange();
+
+      return true;
+    }
+
+    if (!commentObject.line) {
+      return true;
+    }
+
+    // If the selected text is not a block of comment, then uncomment each line.
+    this.startCompoundChange();
+    let lineCaret = firstLine;
+    while (lineCaret <= lastLine) {
+      let currentLine = this._model.getLine(lineCaret);
+      let lineStart = this.getLineStart(lineCaret);
+      let openIndex = currentLine.indexOf(commentObject.line);
+      let openOffset = lineStart + openIndex;
+      let textUntilComment = this.getText(lineStart, openOffset);
+      if (openIndex != -1 &&
+          (!textUntilComment || /^\s+$/.test(textUntilComment))) {
+        this.setText("", openOffset, openOffset + commentObject.line.length);
+      }
+      lineCaret++;
+    }
+    this.endCompoundChange();
+
+    return true;
+  },
+
+  /**
    * Add an event listener to the editor. You can use one of the known events.
    *
    * @see SourceEditor.EVENTS
    *
    * @param string aEventType
    *        The event type you want to listen for.
    * @param function aCallback
    *        The function you want executed when the event is triggered.
@@ -1212,16 +1376,47 @@ SourceEditor.prototype = {
    *         The text in the given range.
    */
   getText: function SE_getText(aStart, aEnd)
   {
     return this._view.getText(aStart, aEnd);
   },
 
   /**
+   * Get the start character offset of the line with index aLineIndex.
+   *
+   * @param number aLineIndex
+   *        Zero based index of the line.
+   * @return number
+   *        Line start offset or -1 if out of range.
+   */
+  getLineStart: function SE_getLineStart(aLineIndex)
+  {
+    return this._model.getLineStart(aLineIndex);
+  },
+
+  /**
+   * Get the end character offset of the line with index aLineIndex,
+   * excluding the end offset. When the line delimiter is present,
+   * the offset is the start offset of the next line or the char count.
+   * Otherwise, it is the offset of the line delimiter.
+   *
+   * @param number aLineIndex
+   *        Zero based index of the line.
+   * @param boolean [aIncludeDelimiter = false]
+   *        Optional, whether or not to include the line delimiter.
+   * @return number
+   *        Line end offset or -1 if out of range.
+   */
+  getLineEnd: function SE_getLineEnd(aLineIndex, aIncludeDelimiter)
+  {
+    return this._model.getLineEnd(aLineIndex, aIncludeDelimiter);
+  },
+
+  /**
    * Get the number of characters in the editor content.
    *
    * @return number
    *         The number of editor content characters.
    */
   getCharCount: function SE_getCharCount()
   {
     return this._model.getCharCount();
@@ -1318,17 +1513,17 @@ SourceEditor.prototype = {
    *         An object that holds two properties:
    *         - line: the line number, counting from 0.
    *         - col: the column number, counting from 0.
    */
   getCaretPosition: function SE_getCaretPosition()
   {
     let offset = this.getCaretOffset();
     let line = this._model.getLineAtOffset(offset);
-    let lineStart = this._model.getLineStart(line);
+    let lineStart = this.getLineStart(line);
     let column = offset - lineStart;
     return {line: line, col: column};
   },
 
   /**
    * Set the caret position: line and column.
    *
    * @param number aLine
@@ -1345,17 +1540,17 @@ SourceEditor.prototype = {
   setCaretPosition: function SE_setCaretPosition(aLine, aColumn, aAlign)
   {
     let editorHeight = this._view.getClientArea().height;
     let lineHeight = this._view.getLineHeight();
     let linesVisible = Math.floor(editorHeight/lineHeight);
     let halfVisible = Math.round(linesVisible/2);
     let firstVisible = this.getTopIndex();
     let lastVisible = this._view.getBottomIndex();
-    let caretOffset = this._model.getLineStart(aLine) + (aColumn || 0);
+    let caretOffset = this.getLineStart(aLine) + (aColumn || 0);
 
     this._view.setSelection(caretOffset, caretOffset, false);
 
     // If the target line is in view, skip the vertical alignment part.
     if (aLine <= lastVisible && aLine >= firstVisible) {
       this._view.showSelection();
       return;
     }
@@ -1491,27 +1686,86 @@ SourceEditor.prototype = {
    * @type boolean
    */
   get readOnly()
   {
     return this._view.getOptions("readonly");
   },
 
   /**
+   * Set the current debugger location at the given line index. This is useful in
+   * a debugger or in any other context where the user needs to track the
+   * current state, where a debugger-like environment is at.
+   *
+   * @param number aLineIndex
+   *        Line index of the current debugger location, starting from 0.
+   *        Use any negative number to clear the current location.
+   */
+  setDebugLocation: function SE_setDebugLocation(aLineIndex)
+  {
+    let annotations = this._getAnnotationsByType("debugLocation", 0,
+                                                 this.getCharCount());
+    if (annotations.length > 0) {
+      annotations.forEach(this._annotationModel.removeAnnotation,
+                          this._annotationModel);
+    }
+    if (aLineIndex < 0) {
+      return;
+    }
+
+    let lineStart = this._model.getLineStart(aLineIndex);
+    let lineEnd = this._model.getLineEnd(aLineIndex);
+    let lineText = this._model.getLine(aLineIndex);
+    let title = SourceEditorUI.strings.
+                formatStringFromName("annotation.debugLocation.title",
+                                     [lineText], 1);
+
+    let annotation = {
+      type: ORION_ANNOTATION_TYPES.debugLocation,
+      start: lineStart,
+      end: lineEnd,
+      title: title,
+      style: {styleClass: "annotation debugLocation"},
+      html: "<div class='annotationHTML debugLocation'></div>",
+      overviewStyle: {styleClass: "annotationOverview debugLocation"},
+      rangeStyle: {styleClass: "annotationRange debugLocation"},
+      lineStyle: {styleClass: "annotationLine debugLocation"},
+    };
+    this._annotationModel.addAnnotation(annotation);
+  },
+
+  /**
+   * Retrieve the current debugger line index configured for this editor.
+   *
+   * @return number
+   *         The line index starting from 0 where the current debugger is
+   *         paused. If no debugger location has been set -1 is returned.
+   */
+  getDebugLocation: function SE_getDebugLocation()
+  {
+    let annotations = this._getAnnotationsByType("debugLocation", 0,
+                                                 this.getCharCount());
+    if (annotations.length > 0) {
+      return this._model.getLineAtOffset(annotations[0].start);
+    }
+    return -1;
+  },
+
+  /**
    * Add a breakpoint at the given line index.
    *
    * @param number aLineIndex
    *        Line index where to add the breakpoint (starts from 0).
    * @param string [aCondition]
    *        Optional breakpoint condition.
    */
   addBreakpoint: function SE_addBreakpoint(aLineIndex, aCondition)
   {
-    let lineStart = this._model.getLineStart(aLineIndex);
-    let lineEnd = this._model.getLineEnd(aLineIndex);
+    let lineStart = this.getLineStart(aLineIndex);
+    let lineEnd = this.getLineEnd(aLineIndex);
 
     let annotations = this._getAnnotationsByType("breakpoint", lineStart, lineEnd);
     if (annotations.length > 0) {
       return;
     }
 
     let lineText = this._model.getLine(aLineIndex);
     let title = SourceEditorUI.strings.
@@ -1545,18 +1799,18 @@ SourceEditor.prototype = {
    *
    * @param number aLineIndex
    *        Line index from where to remove the breakpoint (starts from 0).
    * @return boolean
    *         True if a breakpoint was removed, false otherwise.
    */
   removeBreakpoint: function SE_removeBreakpoint(aLineIndex)
   {
-    let lineStart = this._model.getLineStart(aLineIndex);
-    let lineEnd = this._model.getLineEnd(aLineIndex);
+    let lineStart = this.getLineStart(aLineIndex);
+    let lineEnd = this.getLineEnd(aLineIndex);
 
     let event = {
       type: SourceEditor.EVENTS.BREAKPOINT_CHANGE,
       added: [],
       removed: [],
     };
 
     let annotations = this._getAnnotationsByType("breakpoint", lineStart, lineEnd);
--- a/browser/devtools/sourceeditor/test/Makefile.in
+++ b/browser/devtools/sourceeditor/test/Makefile.in
@@ -56,12 +56,14 @@ include $(topsrcdir)/config/rules.mk
 		browser_bug650345_find.js \
 		browser_bug703692_focus_blur.js \
 		browser_bug725388_mouse_events.js \
 		browser_bug707987_debugger_breakpoints.js \
 		browser_bug712982_line_ruler_click.js \
 		browser_bug725618_moveLines_shortcut.js \
 		browser_bug700893_dirty_state.js \
 		browser_bug729480_line_vertical_align.js \
+		browser_bug725430_comment_uncomment.js \
+		browser_bug731721_debugger_stepping.js \
 		head.js \
 
 libs:: $(_BROWSER_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/browser/devtools/sourceeditor/test/browser_bug725430_comment_uncomment.js
@@ -0,0 +1,151 @@
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+function test() {
+
+  let temp = {};
+  Cu.import("resource:///modules/source-editor.jsm", temp);
+  let SourceEditor = temp.SourceEditor;
+
+  waitForExplicitFinish();
+
+  let editor;
+
+  const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
+    "<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
+    " title='test for bug 725430' width='600' height='500'><hbox flex='1'/></window>";
+  const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
+
+  let testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
+  testWin.addEventListener("load", function onWindowLoad() {
+    testWin.removeEventListener("load", onWindowLoad, false);
+    waitForFocus(initEditor, testWin);
+  }, false);
+
+  function initEditor()
+  {
+    let hbox = testWin.document.querySelector("hbox");
+    editor = new SourceEditor();
+    editor.init(hbox, {showLineNumbers: true}, editorLoaded);
+  }
+
+  function editorLoaded()
+  {
+    editor.focus();
+    let text = "firstline\nsecondline\nthirdline\nfourthline";
+
+    editor.setMode(SourceEditor.MODES.JAVASCRIPT);
+    editor.setText(text)
+
+    editor.setCaretPosition(0);
+    EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
+    is(editor.getText(), "//" + text, "JS Single line Commenting Works");
+    editor.undo();
+    is(editor.getText(), text, "Undo Single Line Commenting action works");
+    editor.redo();
+    is(editor.getText(), "//" + text, "Redo works");
+    editor.setCaretPosition(0);
+    EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
+    is(editor.getText(), text, "JS Single Line Uncommenting works");
+
+    editor.setText(text);
+
+    EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
+    EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
+    is(editor.getText(), "/*" + text + "*/", "JS Block Commenting works");
+    editor.undo();
+    is(editor.getText(), text, "Undo Block Commenting action works");
+    editor.redo();
+    is(editor.getText(), "/*" + text + "*/", "Redo works");
+    EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
+    EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
+    is(editor.getText(), text, "JS Block Uncommenting works");
+    editor.undo();
+    is(editor.getText(), "/*" + text + "*/", "Undo Block Uncommenting works");
+    editor.redo();
+    is(editor.getText(), text, "Redo works");
+
+    let regText = "//firstline\n    //    secondline\nthird//line\nfourthline//";
+    let expText = "firstline\n        secondline\nthird//line\nfourthline//";
+    editor.setText(regText);
+    EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
+    EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
+    is(editor.getText(), expText, "JS Multiple Line Uncommenting works");
+    editor.undo();
+    is(editor.getText(), regText, "Undo Multiple Line Uncommenting works");
+    editor.redo();
+    is(editor.getText(), expText, "Redo works");
+
+    editor.setMode(SourceEditor.MODES.CSS);
+    editor.setText(text);
+
+    expText = "/*firstline*/\nsecondline\nthirdline\nfourthline";
+    editor.setCaretPosition(0);
+    EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
+    is(editor.getText(), expText, "CSS Commenting without selection works");
+    editor.setCaretPosition(0);
+    EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
+    is(editor.getText(), text, "CSS Uncommenting without selection works");
+
+    editor.setText(text);
+
+    EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
+    EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
+    is(editor.getText(), "/*" + text + "*/", "CSS Multiple Line Commenting works");
+    EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
+    EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
+    is(editor.getText(), text, "CSS Multiple Line Uncommenting works");
+
+    editor.setMode(SourceEditor.MODES.HTML);
+    editor.setText(text);
+
+    expText = "<!--firstline-->\nsecondline\nthirdline\nfourthline";
+    editor.setCaretPosition(0);
+    EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
+    is(editor.getText(), expText, "HTML Commenting without selection works");
+    editor.setCaretPosition(0);
+    EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
+    is(editor.getText(), text, "HTML Uncommenting without selection works");
+
+    editor.setText(text);
+
+    EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
+    EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
+    is(editor.getText(), "<!--" + text + "-->", "HTML Multiple Line Commenting works");
+    EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
+    EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
+    is(editor.getText(), text, "HTML Multiple Line Uncommenting works");
+
+    editor.setMode(SourceEditor.MODES.TEXT);
+    editor.setText(text);
+
+    editor.setCaretPosition(0);
+    EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
+    is(editor.getText(), text, "Commenting disabled in Text mode");
+    editor.setText("//" + text);
+    EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
+    EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
+    is(editor.getText(), "//" + text, "Uncommenting disabled in Text mode");
+
+    editor.setText(text);
+    editor.readOnly = true;
+
+    editor.setCaretPosition(0);
+    EventUtils.synthesizeKey("/", {accelKey: true}, testWin);
+    is(editor.getText(), text, "Commenting disabled in ReadOnly mode");
+    editor.setText("//" + text);
+    EventUtils.synthesizeKey("VK_A", {accelKey: true}, testWin);
+    EventUtils.synthesizeKey("/", {accelKey: true, shiftKey: true}, testWin);
+    is(editor.getText(), "//" + text, "Uncommenting disabled in ReadOnly mode");
+
+    editor.destroy();
+
+    testWin.close();
+    testWin = editor = null;
+
+    waitForFocus(finish, window);
+  }
+}
new file mode 100644
--- /dev/null
+++ b/browser/devtools/sourceeditor/test/browser_bug731721_debugger_stepping.js
@@ -0,0 +1,59 @@
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+function test() {
+
+  let temp = {};
+  Cu.import("resource:///modules/source-editor.jsm", temp);
+  let SourceEditor = temp.SourceEditor;
+
+  waitForExplicitFinish();
+
+  let editor;
+
+  const windowUrl = "data:text/xml,<?xml version='1.0'?>" +
+    "<window xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'" +
+    " title='test for bug 731721' width='600' height='500'><hbox flex='1'/></window>";
+  const windowFeatures = "chrome,titlebar,toolbar,centerscreen,resizable,dialog=no";
+
+  let testWin = Services.ww.openWindow(null, windowUrl, "_blank", windowFeatures, null);
+  testWin.addEventListener("load", function onWindowLoad() {
+    testWin.removeEventListener("load", onWindowLoad, false);
+    waitForFocus(initEditor, testWin);
+  }, false);
+
+  function initEditor()
+  {
+    let hbox = testWin.document.querySelector("hbox");
+    editor = new SourceEditor();
+    editor.init(hbox, {showAnnotationRuler: true}, editorLoaded);
+  }
+
+  function editorLoaded()
+  {
+    editor.focus();
+
+    editor.setText("line1\nline2\nline3\nline4");
+
+    is(editor.getDebugLocation(), -1, "no debugger location");
+
+    editor.setDebugLocation(1);
+    is(editor.getDebugLocation(), 1, "set debugger location works");
+
+    editor.setDebugLocation(3);
+    is(editor.getDebugLocation(), 3, "change debugger location works");
+
+    editor.setDebugLocation(-1);
+    is(editor.getDebugLocation(), -1, "clear debugger location works");
+
+    editor.destroy();
+
+    testWin.close();
+    testWin = editor = null;
+
+    waitForFocus(finish, window);
+  }
+}
--- a/browser/devtools/styleinspector/CssRuleView.jsm
+++ b/browser/devtools/styleinspector/CssRuleView.jsm
@@ -1370,16 +1370,17 @@ InplaceEditor.prototype = {
     // Create a hidden, absolutely-positioned span to measure the text
     // in the input.  Boo.
 
     // We can't just measure the original element because a) we don't
     // change the underlying element's text ourselves (we leave that
     // up to the client), and b) without tweaking the style of the
     // original element, it might wrap differently or something.
     this._measurement = this.doc.createElementNS(HTML_NS, "span");
+    this._measurement.className = "autosizer";
     this.elt.parentNode.appendChild(this._measurement);
     let style = this._measurement.style;
     style.visibility = "hidden";
     style.position = "absolute";
     style.top = "0";
     style.left = "0";
     copyTextStyles(this.input, this._measurement);
     this._updateSize();
--- a/browser/devtools/tilt/test/browser_tilt_picking_highlight01-offs.js
+++ b/browser/devtools/tilt/test/browser_tilt_picking_highlight01-offs.js
@@ -39,32 +39,32 @@ function whenHighlighting() {
   ok(presenter._currentSelection > 0,
     "Highlighting a node didn't work properly.");
   ok(!presenter._highlight.disabled,
     "After highlighting a node, it should be highlighted. D'oh.");
   ok(presenter.controller.arcball._resetInProgress,
     "Highlighting a node that's not already visible should trigger a reset!");
 
   executeSoon(function() {
+    Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
     Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false);
     presenter.highlightNode(null);
   });
 }
 
 function whenUnhighlighting() {
   ok(presenter._currentSelection < 0,
     "Unhighlighting a should remove the current selection.");
   ok(presenter._highlight.disabled,
     "After unhighlighting a node, it shouldn't be highlighted anymore. D'oh.");
 
   executeSoon(function() {
+    Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
     Services.obs.addObserver(cleanup, DESTROYED, false);
     InspectorUI.closeInspectorUI();
   });
 }
 
 function cleanup() {
-  Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
-  Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
   Services.obs.removeObserver(cleanup, DESTROYED);
   gBrowser.removeCurrentTab();
   finish();
 }
--- a/browser/devtools/tilt/test/browser_tilt_picking_highlight01.js
+++ b/browser/devtools/tilt/test/browser_tilt_picking_highlight01.js
@@ -38,32 +38,32 @@ function whenHighlighting() {
   ok(presenter._currentSelection > 0,
     "Highlighting a node didn't work properly.");
   ok(!presenter._highlight.disabled,
     "After highlighting a node, it should be highlighted. D'oh.");
   ok(!presenter.controller.arcball._resetInProgress,
     "Highlighting a node that's already visible shouldn't trigger a reset.");
 
   executeSoon(function() {
+    Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
     Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false);
     presenter.highlightNode(null);
   });
 }
 
 function whenUnhighlighting() {
   ok(presenter._currentSelection < 0,
     "Unhighlighting a should remove the current selection.");
   ok(presenter._highlight.disabled,
     "After unhighlighting a node, it shouldn't be highlighted anymore. D'oh.");
 
   executeSoon(function() {
+    Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
     Services.obs.addObserver(cleanup, DESTROYED, false);
     InspectorUI.closeInspectorUI();
   });
 }
 
 function cleanup() {
-  Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
-  Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
   Services.obs.removeObserver(cleanup, DESTROYED);
   gBrowser.removeCurrentTab();
   finish();
 }
--- a/browser/devtools/tilt/test/browser_tilt_picking_highlight02.js
+++ b/browser/devtools/tilt/test/browser_tilt_picking_highlight02.js
@@ -33,32 +33,32 @@ function test() {
 
 function whenHighlighting() {
   ok(presenter._currentSelection > 0,
     "Highlighting a node didn't work properly.");
   ok(!presenter._highlight.disabled,
     "After highlighting a node, it should be highlighted. D'oh.");
 
   executeSoon(function() {
+    Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
     Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false);
     presenter.highlightNodeAt(-1, -1);
   });
 }
 
 function whenUnhighlighting() {
   ok(presenter._currentSelection < 0,
     "Unhighlighting a should remove the current selection.");
   ok(presenter._highlight.disabled,
     "After unhighlighting a node, it shouldn't be highlighted anymore. D'oh.");
 
   executeSoon(function() {
+    Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
     Services.obs.addObserver(cleanup, DESTROYED, false);
     InspectorUI.closeInspectorUI();
   });
 }
 
 function cleanup() {
-  Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
-  Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
   Services.obs.removeObserver(cleanup, DESTROYED);
   gBrowser.removeCurrentTab();
   finish();
 }
--- a/browser/devtools/tilt/test/browser_tilt_picking_highlight03.js
+++ b/browser/devtools/tilt/test/browser_tilt_picking_highlight03.js
@@ -33,32 +33,32 @@ function test() {
 
 function whenHighlighting() {
   ok(presenter._currentSelection > 0,
     "Highlighting a node didn't work properly.");
   ok(!presenter._highlight.disabled,
     "After highlighting a node, it should be highlighted. D'oh.");
 
   executeSoon(function() {
+    Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
     Services.obs.addObserver(whenUnhighlighting, UNHIGHLIGHTING, false);
     presenter.highlightNodeFor(-1);
   });
 }
 
 function whenUnhighlighting() {
   ok(presenter._currentSelection < 0,
     "Unhighlighting a should remove the current selection.");
   ok(presenter._highlight.disabled,
     "After unhighlighting a node, it shouldn't be highlighted anymore. D'oh.");
 
   executeSoon(function() {
+    Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
     Services.obs.addObserver(cleanup, DESTROYED, false);
     InspectorUI.closeInspectorUI();
   });
 }
 
 function cleanup() {
-  Services.obs.removeObserver(whenHighlighting, HIGHLIGHTING);
-  Services.obs.removeObserver(whenUnhighlighting, UNHIGHLIGHTING);
   Services.obs.removeObserver(cleanup, DESTROYED);
   gBrowser.removeCurrentTab();
   finish();
 }
--- a/browser/installer/Makefile.in
+++ b/browser/installer/Makefile.in
@@ -97,16 +97,20 @@ DEFINES += -DMOZ_CHILD_PROCESS_NAME=$(MO
 ifneq (,$(filter aurora beta,$(MOZ_UPDATE_CHANNEL)))
 DEFINES += -DSHIP_FEEDBACK=1
 endif
 
 ifneq (,$(filter WINNT Darwin Android,$(OS_TARGET)))
 DEFINES += -DMOZ_SHARED_MOZGLUE=1
 endif
 
+ifdef MOZ_JSDEBUGGER
+DEFINES += -DMOZ_JSDEBUGGER
+endif
+
 ifdef MOZ_PKG_MANIFEST_P
 MOZ_PKG_MANIFEST = package-manifest
 
 $(MOZ_PKG_MANIFEST): $(MOZ_PKG_MANIFEST_P) $(GLOBAL_DEPS)
 	$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $< > $@
 
 GARBAGE += $(MOZ_PKG_MANIFEST)
 endif
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -196,17 +196,19 @@
 @BINPATH@/components/gfx.xpt
 @BINPATH@/components/html5.xpt
 @BINPATH@/components/htmlparser.xpt
 @BINPATH@/components/imglib2.xpt
 @BINPATH@/components/imgicon.xpt
 @BINPATH@/components/inspector.xpt
 @BINPATH@/components/intl.xpt
 @BINPATH@/components/jar.xpt
+#ifdef MOZ_JSDEBUGGER
 @BINPATH@/components/jsdservice.xpt
+#endif
 @BINPATH@/components/jsdebugger.xpt
 @BINPATH@/components/jsinspector.xpt
 @BINPATH@/components/layout_base.xpt
 @BINPATH@/components/layout_forms.xpt
 #ifdef NS_PRINTING
 @BINPATH@/components/layout_printing.xpt
 #endif
 @BINPATH@/components/layout_xul_tree.xpt
--- a/browser/locales/en-US/chrome/browser/aboutDialog.dtd
+++ b/browser/locales/en-US/chrome/browser/aboutDialog.dtd
@@ -1,14 +1,14 @@
 <!ENTITY aboutDialog.title          "About &brandFullName;">
 
 <!-- LOCALIZATION NOTE (warningDesc.version): This is a warning about the experimental nature of Nightly and Aurora builds. It is only shown in those versions. -->
 <!ENTITY warningDesc.version        "&brandShortName; is experimental and may be unstable.">
-<!-- LOCALIZATION NOTE (warningDesc.telemetry): This is a notification that Nightly/Aurora builds automatically send Telemetry data back to Mozilla. It is only shown in those versions. "It" refers to brandShortName. -->
-<!ENTITY warningDesc.telemetry      "It automatically sends test information back to &vendorShortName; to help make &brandShortName; better.">
+<!-- LOCALIZATION NOTE (warningDesc.telemetryDesc): This is a notification that Nightly/Aurora builds automatically send Telemetry data back to Mozilla. It is only shown in those versions. "It" refers to brandShortName. -->
+<!ENTITY warningDesc.telemetryDesc  "It automatically sends information about performance, hardware, usage and customizations back to &vendorShortName; to help make &brandShortName; better.">
 
 <!-- LOCALIZATION NOTE (community.exp.*) This paragraph is shown in "experimental" builds, i.e. Nightly and Aurora builds, instead of the other "community.*" strings below. -->
 <!ENTITY community.exp.start        "">
 <!-- LOCALIZATION NOTE (community.exp.mozillaLink): This is a link title that links to http://www.mozilla.org/. -->
 <!ENTITY community.exp.mozillaLink  "&vendorShortName;">
 <!ENTITY community.exp.middle       " is a ">
 <!-- LOCALIZATION NOTE (community.exp.creditslink): This is a link title that links to about:credits. -->
 <!ENTITY community.exp.creditsLink  "global community">
--- a/browser/locales/en-US/chrome/browser/devtools/debugger.dtd
+++ b/browser/locales/en-US/chrome/browser/devtools/debugger.dtd
@@ -14,16 +14,28 @@
 <!-- LOCALIZATION NOTE (debuggerMenu.commandkey): This is the command key that
   -  launches the debugger UI. Do not translate this one! -->
 <!ENTITY debuggerMenu.commandkey     "S">
 
 <!-- LOCALIZATION NOTE (debuggerUI.closeButton): This is the label for the
   -  button that closes the debugger UI. -->
 <!ENTITY debuggerUI.closeButton      "Close">
 
+<!-- LOCALIZATION NOTE (debuggerUI.stepOverButton): This is the label for the
+  -  button that steps over a function call. -->
+<!ENTITY debuggerUI.stepOverButton   "Step Over">
+
+<!-- LOCALIZATION NOTE (debuggerUI.stepInButton): This is the label for the
+  -  button that steps into a function call. -->
+<!ENTITY debuggerUI.stepInButton     "Step In">
+
+<!-- LOCALIZATION NOTE (debuggerUI.stepOutButton): This is the label for the
+  -  button that steps out of a function call. -->
+<!ENTITY debuggerUI.stepOutButton    "Step Out">
+
 <!-- LOCALIZATION NOTE (debuggerUI.stackTitle): This is the label for the
   -  widget that displays the call stack frames in the debugger. -->
 <!ENTITY debuggerUI.stackTitle       "Call stack">
 
 <!-- LOCALIZATION NOTE (debuggerUI.scriptTitle): This is the label for the
   -  widget that displays the source code for the script that is currently
   -  being inspected in the debugger. -->
 <!ENTITY debuggerUI.scriptTitle      "Script">
--- a/browser/locales/en-US/chrome/browser/devtools/sourceeditor.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/sourceeditor.properties
@@ -33,8 +33,14 @@ gotoLineCmd.promptMessage=Jump to line n
 # front of any breakpoint annotation when it is displayed as a tooltip in one of
 # the editor gutters. This feature is used in the JavaScript Debugger.
 annotation.breakpoint.title=Breakpoint: %S
 
 # LOCALIZATION NOTE  (annotation.currentLine): This is the text shown in
 # a tooltip displayed in any of the editor gutters when the user hovers the
 # current line.
 annotation.currentLine=Current line
+
+# LOCALIZATION NOTE  (annotation.debugLocation.title): This is the text shown in
+# a tooltip displayed in any of the editor gutters when the user hovers the
+# current debugger location. The debugger can pause the JavaScript execution at
+# user-defined lines.
+annotation.debugLocation.title=Current step: %S
--- a/browser/modules/KeywordURLResetPrompter.jsm
+++ b/browser/modules/KeywordURLResetPrompter.jsm
@@ -69,16 +69,17 @@ let KeywordURLResetPrompter = {
     let buttons = [
       {
         label: browserBundle.getFormattedString("keywordPrompt.yesButton",
                                                 [defaultEngine.name]),
         accessKey: browserBundle.getString("keywordPrompt.yesButton.accessKey"),
         popup:     null,
         callback: function(aNotificationBar, aButton) {
           Services.prefs.clearUserPref("keyword.URL");
+          Services.prefs.clearUserPref("browser.search.defaultenginename");
           try {
             // If the currently loaded URI still has the same base domain as the
             // keyword URI (this is used as a rough approximation of whether the
             // user is still seeing search results as opposed to having clicked
             // on a result link), load the default engine's searchForm URL so
             // that they can re-do their search.
             let currentBaseDomain = Services.eTLD.getBaseDomain(tabbrowser.currentURI);
             if (currentBaseDomain == keywordBaseDomain)
--- a/browser/modules/test/Makefile.in
+++ b/browser/modules/test/Makefile.in
@@ -41,16 +41,17 @@ VPATH		= @srcdir@
 relativesrcdir  = browser/modules/test
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _BROWSER_FILES = \
                  browser_NetworkPrioritizer.js \
                  browser_TelemetryTimestamps.js \
+                 browser_keywordURLReset.js \
                  $(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows) 
 _BROWSER_FILES += \
                  browser_taskbar_preview.js \
                  $(NULL)
 endif
 
new file mode 100644
--- /dev/null
+++ b/browser/modules/test/browser_keywordURLReset.js
@@ -0,0 +1,110 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  waitForExplicitFinish();
+
+  let newTab = gBrowser.selectedTab = gBrowser.addTab("about:blank", {skipAnimation: true});
+  registerCleanupFunction(function () {
+    gBrowser.removeTab(newTab);
+    Services.prefs.clearUserPref("keyword.URL");
+    Services.prefs.clearUserPref("browser.search.defaultenginename");
+  });
+
+  function onKeywordPrefUse(cb) {
+    Services.obs.addObserver(function obs() {
+      Services.obs.removeObserver(obs, "defaultURIFixup-using-keyword-pref");
+      executeSoon(function () {
+        let nbox = gBrowser.getNotificationBox();
+        let notification = nbox.getNotificationWithValue("keywordURL-reset");
+        cb(notification);
+      });
+    }, "defaultURIFixup-using-keyword-pref", false);
+  }
+
+  function testQuery(cb) {
+    onKeywordPrefUse(cb);
+    gURLBar.focus();
+    gURLBar.value = "foo bar";
+    gURLBar.handleCommand();
+  }
+
+  function setKeywordURL(value) {
+    Services.prefs.setCharPref("keyword.URL", value);
+    let keywordURI = XULBrowserWindow._uriFixup.keywordToURI("foo bar");
+    is(keywordURI.spec, value + "foo+bar", "keyword.URL was set to " + value);
+  }
+
+  // Before modifying any prefs, get a submission object for this build's
+  // actual default engine for verification of the "Reset" functionality.
+  let originalDefaultEngine = Services.search.originalDefaultEngine;
+  let defaultSubmission = originalDefaultEngine.getSubmission("foo bar", "application/x-moz-keywordsearch");
+  if (!defaultSubmission)
+    defaultSubmission = originalDefaultEngine.getSubmission("foo bar");
+
+  var tests = [
+    {
+      name: "similar URL that shouldn't trigger prompt",
+      setup: function () {
+        setKeywordURL(defaultSubmission.uri.prePath + "/othersearch");
+      },
+      check: function (notification) {
+        ok(!notification, "didn't get a search reset notification");
+      }
+    },
+    {
+      name: "URL that should trigger prompt",
+      setup: function () {
+        // First clear any values from the previous test so that we can verify
+        // that the dummy default engine we're adding below has an effect.
+        Services.prefs.clearUserPref("keyword.URL");
+
+        // Add a dummy "default engine" to verify that the "reset" actually
+        // resets the originalDefaultEngine too (and not just keyword.URL)
+        Services.search.addEngineWithDetails("TestEngine", "", "", "", "GET", "http://mochi.test/test?q={searchTerms}");
+        Services.prefs.setCharPref("browser.search.defaultenginename", "TestEngine");
+
+        // Check that it was added successfully
+        let engine = Services.search.getEngineByName("TestEngine");
+        ok(engine, "added engine successfully");
+        registerCleanupFunction(function () {
+          Services.search.removeEngine(engine);
+        });
+        is(Services.search.originalDefaultEngine, engine, "engine is now the originalDefaultEngine");
+        let keywordURI = XULBrowserWindow._uriFixup.keywordToURI("foo bar");
+        is(keywordURI.spec, "http://mochi.test/test?q=foo+bar", "default engine affects keywordToURI");
+
+        setKeywordURL("http://invalid.foo/search/");
+      },
+      check: function (notification) {
+        ok(notification, "got a search reset notification");
+
+        // Press the "reset" button
+        notification.getElementsByTagName("button").item(0).click();
+
+        // Check that the reset worked
+        let keywordURI = XULBrowserWindow._uriFixup.keywordToURI("foo bar");
+        is(keywordURI.spec, defaultSubmission.uri.spec,
+           "keyword.URL came from original default engine after reset");
+      }
+    }
+  ];
+
+  function nextTest() {
+    let test = tests.shift();
+    if (!test) {
+      finish();
+      return;
+    }
+
+    info("Running test: " + test.name);
+    test.setup();
+    testQuery(function (notification) {
+      test.check(notification);
+      executeSoon(nextTest);
+    });
+  }
+  
+  nextTest();
+}
+
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ebb8d8d86d8bb78515739c4efaa59d1870c35602
GIT binary patch
literal 203
zc%17D@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5M?jcysy3fAP_Wk1
z#WBR9ckARpp#}vG)_7m`&uM$}j-7qASmLZe#;hMjBG*bC9-L1&DECw+&XC(-jsTaM
zc0QlXfk(G@FeL3&ka1#SZcWG#Vv3r=>dAOzQR^PF7m8UQnKoSAdSx5m^8<Qn8s9g&
xh|fFvHee@PluzQ_*J?%;O|{upM)O}5%X~Sa7n^T$;1JLu44$rjF6*2UngA#GM>GHc
--- a/browser/themes/gnomestripe/devtools/orion.css
+++ b/browser/themes/gnomestripe/devtools/orion.css
@@ -56,32 +56,39 @@
   background-repeat: no-repeat;
 }
 .annotationHTML.task {
   background-image: url("chrome://browser/skin/devtools/orion-task.png");
 }
 .annotationHTML.breakpoint {
   background-image: url("chrome://browser/skin/devtools/orion-breakpoint.png");
 }
+.annotationHTML.debugLocation {
+  background-image: url("chrome://browser/skin/devtools/orion-debug-location.png");
+}
 
 /* Styles for the overview ruler  */
 .annotationOverview {
   cursor: pointer;
   border-radius: 2px;
   left: 2px;
   width: 8px;
 }
 .annotationOverview.task {
   background-color: lightgreen;
   border: 1px solid green;
 }
 .annotationOverview.breakpoint {
   background-color: lightblue;
   border: 1px solid blue;
 }
+.annotationOverview.debugLocation {
+  background-color: white;
+  border: 1px solid green;
+}
 .annotationOverview.currentBracket {
   background-color: lightgray;
   border: 1px solid red;
 }
 .annotationOverview.matchingBracket {
   background-color: lightgray;
   border: 1px solid red;
 }
--- a/browser/themes/gnomestripe/jar.mn
+++ b/browser/themes/gnomestripe/jar.mn
@@ -93,16 +93,17 @@ browser.jar:
   skin/classic/browser/devtools/webconsole_networkpanel.css     (devtools/webconsole_networkpanel.css)
   skin/classic/browser/devtools/webconsole.png                  (devtools/webconsole.png)
   skin/classic/browser/devtools/gcli.css              (devtools/gcli.css)
   skin/classic/browser/devtools/htmlpanel.css         (devtools/htmlpanel.css)
   skin/classic/browser/devtools/orion.css             (devtools/orion.css)
   skin/classic/browser/devtools/orion-container.css   (devtools/orion-container.css)
   skin/classic/browser/devtools/orion-task.png        (devtools/orion-task.png)
   skin/classic/browser/devtools/orion-breakpoint.png  (devtools/orion-breakpoint.png)
+  skin/classic/browser/devtools/orion-debug-location.png (devtools/orion-debug-location.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-end-pressed.png              (devtools/breadcrumbs/ltr-end-pressed.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-end-selected-pressed.png     (devtools/breadcrumbs/ltr-end-selected-pressed.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-end-selected.png             (devtools/breadcrumbs/ltr-end-selected.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-end.png                      (devtools/breadcrumbs/ltr-end.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-middle-pressed.png           (devtools/breadcrumbs/ltr-middle-pressed.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-middle-selected-pressed.png  (devtools/breadcrumbs/ltr-middle-selected-pressed.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-middle-selected.png          (devtools/breadcrumbs/ltr-middle-selected.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-middle.png                   (devtools/breadcrumbs/ltr-middle.png)
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ebb8d8d86d8bb78515739c4efaa59d1870c35602
GIT binary patch
literal 203
zc%17D@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5M?jcysy3fAP_Wk1
z#WBR9ckARpp#}vG)_7m`&uM$}j-7qASmLZe#;hMjBG*bC9-L1&DECw+&XC(-jsTaM
zc0QlXfk(G@FeL3&ka1#SZcWG#Vv3r=>dAOzQR^PF7m8UQnKoSAdSx5m^8<Qn8s9g&
xh|fFvHee@PluzQ_*J?%;O|{upM)O}5%X~Sa7n^T$;1JLu44$rjF6*2UngA#GM>GHc
--- a/browser/themes/pinstripe/devtools/orion.css
+++ b/browser/themes/pinstripe/devtools/orion.css
@@ -56,32 +56,39 @@
   background-repeat: no-repeat;
 }
 .annotationHTML.task {
   background-image: url("chrome://browser/skin/devtools/orion-task.png");
 }
 .annotationHTML.breakpoint {
   background-image: url("chrome://browser/skin/devtools/orion-breakpoint.png");
 }
+.annotationHTML.debugLocation {
+  background-image: url("chrome://browser/skin/devtools/orion-debug-location.png");
+}
 
 /* Styles for the overview ruler  */
 .annotationOverview {
   cursor: pointer;
   border-radius: 2px;
   left: 2px;
   width: 8px;
 }
 .annotationOverview.task {
   background-color: lightgreen;
   border: 1px solid green;
 }
 .annotationOverview.breakpoint {
   background-color: lightblue;
   border: 1px solid blue;
 }
+.annotationOverview.debugLocation {
+  background-color: white;
+  border: 1px solid green;
+}
 .annotationOverview.currentBracket {
   background-color: lightgray;
   border: 1px solid red;
 }
 .annotationOverview.matchingBracket {
   background-color: lightgray;
   border: 1px solid red;
 }
--- a/browser/themes/pinstripe/jar.mn
+++ b/browser/themes/pinstripe/jar.mn
@@ -129,16 +129,17 @@ browser.jar:
   skin/classic/browser/devtools/goto-mdn.png                (devtools/goto-mdn.png)
   skin/classic/browser/devtools/csshtmltree.css             (devtools/csshtmltree.css)
   skin/classic/browser/devtools/gcli.css                    (devtools/gcli.css)
   skin/classic/browser/devtools/htmlpanel.css               (devtools/htmlpanel.css)
   skin/classic/browser/devtools/orion.css                   (devtools/orion.css)
   skin/classic/browser/devtools/orion-container.css         (devtools/orion-container.css)
   skin/classic/browser/devtools/orion-task.png              (devtools/orion-task.png)
   skin/classic/browser/devtools/orion-breakpoint.png        (devtools/orion-breakpoint.png)
+  skin/classic/browser/devtools/orion-debug-location.png    (devtools/orion-debug-location.png)
   skin/classic/browser/devtools/toolbarbutton-close.png     (devtools/toolbarbutton-close.png)
 * skin/classic/browser/devtools/webconsole.css                  (devtools/webconsole.css)
   skin/classic/browser/devtools/webconsole_networkpanel.css     (devtools/webconsole_networkpanel.css)
   skin/classic/browser/devtools/webconsole.png                  (devtools/webconsole.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-end-pressed.png              (devtools/breadcrumbs/ltr-end-pressed.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-end-selected-pressed.png     (devtools/breadcrumbs/ltr-end-selected-pressed.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-end-selected.png             (devtools/breadcrumbs/ltr-end-selected.png)
   skin/classic/browser/devtools/breadcrumbs/ltr-end.png                      (devtools/breadcrumbs/ltr-end.png)
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ebb8d8d86d8bb78515739c4efaa59d1870c35602
GIT binary patch
literal 203
zc%17D@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5M?jcysy3fAP_Wk1
z#WBR9ckARpp#}vG)_7m`&uM$}j-7qASmLZe#;hMjBG*bC9-L1&DECw+&XC(-jsTaM
zc0QlXfk(G@FeL3&ka1#SZcWG#Vv3r=>dAOzQR^PF7m8UQnKoSAdSx5m^8<Qn8s9g&
xh|fFvHee@PluzQ_*J?%;O|{upM)O}5%X~Sa7n^T$;1JLu44$rjF6*2UngA#GM>GHc
--- a/browser/themes/winstripe/devtools/orion.css
+++ b/browser/themes/winstripe/devtools/orion.css
@@ -56,32 +56,39 @@
   background-repeat: no-repeat;
 }
 .annotationHTML.task {
   background-image: url("chrome://browser/skin/devtools/orion-task.png");
 }
 .annotationHTML.breakpoint {
   background-image: url("chrome://browser/skin/devtools/orion-breakpoint.png");
 }
+.annotationHTML.debugLocation {
+  background-image: url("chrome://browser/skin/devtools/orion-debug-location.png");
+}
 
 /* Styles for the overview ruler  */
 .annotationOverview {
   cursor: pointer;
   border-radius: 2px;
   left: 2px;
   width: 8px;
 }
 .annotationOverview.task {
   background-color: lightgreen;
   border: 1px solid green;
 }
 .annotationOverview.breakpoint {
   background-color: lightblue;
   border: 1px solid blue;
 }
+.annotationOverview.debugLocation {
+  background-color: white;
+  border: 1px solid green;
+}
 .annotationOverview.currentBracket {
   background-color: lightgray;
   border: 1px solid red;
 }
 .annotationOverview.matchingBracket {
   background-color: lightgray;
   border: 1px solid red;
 }
--- a/browser/themes/winstripe/jar.mn
+++ b/browser/themes/winstripe/jar.mn
@@ -116,16 +116,17 @@ browser.jar:
         skin/classic/browser/devtools/goto-mdn.png                  (devtools/goto-mdn.png)
         skin/classic/browser/devtools/csshtmltree.css               (devtools/csshtmltree.css)
         skin/classic/browser/devtools/gcli.css                      (devtools/gcli.css)
         skin/classic/browser/devtools/htmlpanel.css                 (devtools/htmlpanel.css)
         skin/classic/browser/devtools/orion.css                     (devtools/orion.css)
         skin/classic/browser/devtools/orion-container.css           (devtools/orion-container.css)
         skin/classic/browser/devtools/orion-task.png                (devtools/orion-task.png)
         skin/classic/browser/devtools/orion-breakpoint.png          (devtools/orion-breakpoint.png)
+        skin/classic/browser/devtools/orion-debug-location.png      (devtools/orion-debug-location.png)
         skin/classic/browser/devtools/toolbarbutton-close.png       (devtools/toolbarbutton-close.png)
         skin/classic/browser/devtools/webconsole.css                  (devtools/webconsole.css)
         skin/classic/browser/devtools/webconsole_networkpanel.css     (devtools/webconsole_networkpanel.css)
         skin/classic/browser/devtools/webconsole.png                  (devtools/webconsole.png)
         skin/classic/browser/devtools/breadcrumbs/ltr-end-pressed.png              (devtools/breadcrumbs/ltr-end-pressed.png)
         skin/classic/browser/devtools/breadcrumbs/ltr-end-selected-pressed.png     (devtools/breadcrumbs/ltr-end-selected-pressed.png)
         skin/classic/browser/devtools/breadcrumbs/ltr-end-selected.png             (devtools/breadcrumbs/ltr-end-selected.png)
         skin/classic/browser/devtools/breadcrumbs/ltr-end.png                      (devtools/breadcrumbs/ltr-end.png)
@@ -288,16 +289,17 @@ browser.jar:
         skin/classic/aero/browser/devtools/goto-mdn.png              (devtools/goto-mdn.png)
         skin/classic/aero/browser/devtools/csshtmltree.css           (devtools/csshtmltree.css)
         skin/classic/aero/browser/devtools/gcli.css                  (devtools/gcli.css)
         skin/classic/aero/browser/devtools/htmlpanel.css             (devtools/htmlpanel.css)
         skin/classic/aero/browser/devtools/orion.css                 (devtools/orion.css)
         skin/classic/aero/browser/devtools/orion-container.css       (devtools/orion-container.css)
         skin/classic/aero/browser/devtools/orion-task.png            (devtools/orion-task.png)
         skin/classic/aero/browser/devtools/orion-breakpoint.png      (devtools/orion-breakpoint.png)
+        skin/classic/aero/browser/devtools/orion-debug-location.png  (devtools/orion-debug-location.png)
         skin/classic/aero/browser/devtools/toolbarbutton-close.png   (devtools/toolbarbutton-close.png)
         skin/classic/aero/browser/devtools/webconsole.css                  (devtools/webconsole.css)
         skin/classic/aero/browser/devtools/webconsole_networkpanel.css     (devtools/webconsole_networkpanel.css)
         skin/classic/aero/browser/devtools/webconsole.png                  (devtools/webconsole.png)
         skin/classic/aero/browser/devtools/breadcrumbs/ltr-end-pressed.png              (devtools/breadcrumbs/ltr-end-pressed.png)
         skin/classic/aero/browser/devtools/breadcrumbs/ltr-end-selected-pressed.png     (devtools/breadcrumbs/ltr-end-selected-pressed.png)
         skin/classic/aero/browser/devtools/breadcrumbs/ltr-end-selected.png             (devtools/breadcrumbs/ltr-end-selected.png)
         skin/classic/aero/browser/devtools/breadcrumbs/ltr-end.png                      (devtools/breadcrumbs/ltr-end.png)
--- a/build/autoconf/compiler-opts.m4
+++ b/build/autoconf/compiler-opts.m4
@@ -77,8 +77,54 @@ if test "$GNU_CC" -a "$GCC_USE_GNU_LD" -
         fi
         rm -rf conftest*])
     if test "$GC_SECTIONS_BREAKS_DEBUG_RANGES" = no; then
         DSO_LDOPTS="$DSO_LDOPTS -Wl,--gc-sections"
     fi
 fi
 
 ])
+
+dnl GCC and clang will fail if given an unknown warning option like -Wfoobar. 
+dnl But later versions won't fail if given an unknown negated warning option
+dnl like -Wno-foobar.  So when we are check for support of negated warning 
+dnl options, we actually test the positive form, but add the negated form to 
+dnl the flags variable.
+
+AC_DEFUN([MOZ_C_SUPPORTS_WARNING],
+[
+    AC_CACHE_CHECK(whether the C compiler supports $1$2, $3,
+        [
+            AC_LANG_SAVE
+            AC_LANG_C
+            _SAVE_CFLAGS="$CFLAGS"
+            CFLAGS="$CFLAGS -W$2"
+            AC_TRY_COMPILE([],
+                           [return(0);],
+                           $3="yes",
+                           $3="no")
+            CFLAGS="$_SAVE_CFLAGS"
+            AC_LANG_RESTORE
+        ])
+    if test "${$3}" = "yes"; then
+        _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} $1$2"
+    fi
+])
+
+AC_DEFUN([MOZ_CXX_SUPPORTS_WARNING],
+[
+    AC_CACHE_CHECK(whether the C++ compiler supports $1$2, $3,
+        [
+            AC_LANG_SAVE
+            AC_LANG_CPLUSPLUS
+            _SAVE_CXXFLAGS="$CXXFLAGS"
+            CXXFLAGS="$CXXFLAGS -W$2"
+            AC_TRY_COMPILE([],
+                           [return(0);],
+                           $3="yes",
+                           $3="no")
+            CXXFLAGS="$_SAVE_CXXFLAGS"
+            AC_LANG_RESTORE
+        ])
+    if test "${$3}" = "yes"; then
+        _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} $1$2"
+    fi
+])
--- a/build/mobile/devicemanagerADB.py
+++ b/build/mobile/devicemanagerADB.py
@@ -10,16 +10,17 @@ class DeviceManagerADB(DeviceManager):
   def __init__(self, host = None, port = 20701, retrylimit = 5, packageName = None):
     self.host = host
     self.port = port
     self.retrylimit = retrylimit
     self.retries = 0
     self._sock = None
     self.useRunAs = False
     self.haveRoot = False
+    self.useDDCopy = False
     self.useZip = False
     self.packageName = None
     self.tempDir = None
 
     if packageName:
       self.packageName = packageName
     else:
       if os.getenv('USER'):
--- a/caps/include/nsJSPrincipals.h
+++ b/caps/include/nsJSPrincipals.h
@@ -42,17 +42,16 @@
 #include "nsIPrincipal.h"
 
 class nsCString;
 
 struct nsJSPrincipals : nsIPrincipal, JSPrincipals
 {
   static JSBool Subsume(JSPrincipals *jsprin, JSPrincipals *other);
   static void Destroy(JSPrincipals *jsprin);
-  static JSBool Transcode(JSXDRState *xdr, JSPrincipals **jsprinp);
 
   /*
    * Get a weak reference to nsIPrincipal associated with the given JS
    * principal.
    */
   static nsJSPrincipals* get(JSPrincipals *principals) {
     nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principals);
     MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN);
--- a/caps/include/nsScriptSecurityManager.h
+++ b/caps/include/nsScriptSecurityManager.h
@@ -496,17 +496,17 @@ private:
     // Callers MUST pass in a non-null rv here.
     nsIPrincipal*
     GetFramePrincipal(JSContext* cx, JSStackFrame* fp, nsresult* rv);
 
     // Returns null if a principal cannot be found.  Note that rv can be NS_OK
     // when this happens -- this means that there was no script.  Callers MUST
     // pass in a non-null rv here.
     static nsIPrincipal*
-    GetScriptPrincipal(JSContext* cx, JSScript* script, nsresult* rv);
+    GetScriptPrincipal(JSScript* script, nsresult* rv);
 
     // Returns null if a principal cannot be found.  Note that rv can be NS_OK
     // when this happens -- this means that there was no script associated
     // with the function object, and no global object associated with the scope
     // of obj (the last object on its parent chain).  If the caller is walking
     // the JS stack, fp must point to the current frame in the stack iteration.
     // Callers MUST pass in a non-null rv here.
     static nsIPrincipal*
--- a/caps/src/nsJSPrincipals.cpp
+++ b/caps/src/nsJSPrincipals.cpp
@@ -81,80 +81,16 @@ nsJSPrincipals::Destroy(JSPrincipals *js
     nsjsprin->AddRef();
     nsjsprin->refcount--;
 #else
     nsjsprin->refcount++;
 #endif
     nsjsprin->Release();
 }
 
-/* static */ JSBool
-nsJSPrincipals::Transcode(JSXDRState *xdr, JSPrincipals **jsprinp)
-{
-    nsresult rv;
-
-    if (xdr->mode == JSXDR_ENCODE) {
-        nsIObjectOutputStream *stream =
-            reinterpret_cast<nsIObjectOutputStream*>(xdr->userdata);
-
-        // Flush xdr'ed data to the underlying object output stream.
-        uint32_t size;
-        char *data = (char*) ::JS_XDRMemGetData(xdr, &size);
-
-        rv = stream->Write32(size);
-        if (NS_SUCCEEDED(rv)) {
-            rv = stream->WriteBytes(data, size);
-            if (NS_SUCCEEDED(rv)) {
-                ::JS_XDRMemResetData(xdr);
-
-                rv = stream->WriteObject(nsJSPrincipals::get(*jsprinp), true);
-            }
-        }
-    } else {
-        NS_ASSERTION(JS_XDRMemDataLeft(xdr) == 0, "XDR out of sync?!");
-        nsIObjectInputStream *stream =
-            reinterpret_cast<nsIObjectInputStream*>(xdr->userdata);
-
-        nsCOMPtr<nsIPrincipal> prin;
-        rv = stream->ReadObject(true, getter_AddRefs(prin));
-        if (NS_SUCCEEDED(rv)) {
-            PRUint32 size;
-            rv = stream->Read32(&size);
-            if (NS_SUCCEEDED(rv)) {
-                char *data = nsnull;
-                if (size != 0)
-                    rv = stream->ReadBytes(size, &data);
-                if (NS_SUCCEEDED(rv)) {
-                    char *olddata;
-                    uint32_t oldsize;
-
-                    // Any decode-mode JSXDRState whose userdata points to an
-                    // nsIObjectInputStream instance must use nsMemory to Alloc
-                    // and Free its data buffer.  Swap the new buffer we just
-                    // read for the old, exhausted data.
-                    olddata = (char*) ::JS_XDRMemGetData(xdr, &oldsize);
-                    nsMemory::Free(olddata);
-                    ::JS_XDRMemSetData(xdr, data, size);
-
-                    *jsprinp = nsJSPrincipals::get(prin);
-                    JS_HoldPrincipals(*jsprinp);
-                }
-            }
-        }
-    }
-
-    if (NS_FAILED(rv)) {
-        ::JS_ReportError(xdr->cx, "can't %scode principals (failure code %x)",
-                         (xdr->mode == JSXDR_ENCODE) ? "en" : "de",
-                         (unsigned int) rv);
-        return JS_FALSE;
-    }
-    return JS_TRUE;
-}
-
 #ifdef DEBUG
 
 // Defined here so one can do principals->dump() in the debugger
 JS_EXPORT_API(void)
 JSPrincipals::dump()
 {
     if (debugToken == nsJSPrincipals::DEBUG_TOKEN) {
         static_cast<nsJSPrincipals *>(this)->dumpImpl();
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -1395,47 +1395,47 @@ nsScriptSecurityManager::CheckLoadURIWit
     NS_ENSURE_FALSE(aFlags & ~(nsIScriptSecurityManager::LOAD_IS_AUTOMATIC_DOCUMENT_REPLACEMENT |
                                nsIScriptSecurityManager::ALLOW_CHROME |
                                nsIScriptSecurityManager::DISALLOW_SCRIPT |
                                nsIScriptSecurityManager::DISALLOW_INHERIT_PRINCIPAL),
                     NS_ERROR_UNEXPECTED);
     NS_ENSURE_ARG_POINTER(aPrincipal);
     NS_ENSURE_ARG_POINTER(aTargetURI);
 
+    // If DISALLOW_INHERIT_PRINCIPAL is set, we prevent loading of URIs which
+    // would do such inheriting. That would be URIs that do not have their own
+    // security context. We do this even for the system principal.
+    if (aFlags & nsIScriptSecurityManager::DISALLOW_INHERIT_PRINCIPAL) {
+        nsresult rv =
+            DenyAccessIfURIHasFlags(aTargetURI,
+                                    nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT);
+        NS_ENSURE_SUCCESS(rv, rv);
+    }
+
     if (aPrincipal == mSystemPrincipal) {
         // Allow access
         return NS_OK;
     }
-    
+
     nsCOMPtr<nsIURI> sourceURI;
     aPrincipal->GetURI(getter_AddRefs(sourceURI));
     if (!sourceURI) {
         NS_ERROR("Non-system principals passed to CheckLoadURIWithPrincipal "
                  "must have a URI!");
         return NS_ERROR_UNEXPECTED;
     }
     
     // Automatic loads are not allowed from certain protocols.
     if (aFlags & nsIScriptSecurityManager::LOAD_IS_AUTOMATIC_DOCUMENT_REPLACEMENT) {
         nsresult rv =
             DenyAccessIfURIHasFlags(sourceURI,
                                     nsIProtocolHandler::URI_FORBIDS_AUTOMATIC_DOCUMENT_REPLACEMENT);
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
-    // If DISALLOW_INHERIT_PRINCIPAL is set, we prevent loading of URIs which
-    // would do such inheriting.  That would be URIs that do not have their own
-    // security context.
-    if (aFlags & nsIScriptSecurityManager::DISALLOW_INHERIT_PRINCIPAL) {
-        nsresult rv =
-            DenyAccessIfURIHasFlags(aTargetURI,
-                                    nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT);
-        NS_ENSURE_SUCCESS(rv, rv);
-    }
-
     // If either URI is a nested URI, get the base URI
     nsCOMPtr<nsIURI> sourceBaseURI = NS_GetInnermostURI(sourceURI);
     nsCOMPtr<nsIURI> targetBaseURI = NS_GetInnermostURI(aTargetURI);
 
     //-- get the target scheme
     nsCAutoString targetScheme;
     nsresult rv = targetBaseURI->GetScheme(targetScheme);
     if (NS_FAILED(rv)) return rv;
@@ -2165,27 +2165,26 @@ nsScriptSecurityManager::GetPrincipalFro
     if (globalData)
         NS_IF_ADDREF(*result = globalData->GetPrincipal());
 
     return NS_OK;
 }
 
 // static
 nsIPrincipal*
-nsScriptSecurityManager::GetScriptPrincipal(JSContext *cx,
-                                            JSScript *script,
+nsScriptSecurityManager::GetScriptPrincipal(JSScript *script,
                                             nsresult* rv)
 {
     NS_PRECONDITION(rv, "Null out param");
     *rv = NS_OK;
     if (!script)
     {
         return nsnull;
     }
-    JSPrincipals *jsp = JS_GetScriptPrincipals(cx, script);
+    JSPrincipals *jsp = JS_GetScriptPrincipals(script);
     if (!jsp) {
         *rv = NS_ERROR_FAILURE;
         NS_ERROR("Script compiled without principals!");
         return nsnull;
     }
     return nsJSPrincipals::get(jsp);
 }
 
@@ -2248,31 +2247,31 @@ nsScriptSecurityManager::GetFunctionObje
         // reliable principals compiled into the function itself.
 
         nsIPrincipal *result = doGetObjectPrincipal(obj);
         if (!result)
             *rv = NS_ERROR_FAILURE;
         return result;
     }
 
-    return GetScriptPrincipal(cx, script, rv);
+    return GetScriptPrincipal(script, rv);
 }
 
 nsIPrincipal*
 nsScriptSecurityManager::GetFramePrincipal(JSContext *cx,
                                            JSStackFrame *fp,
                                            nsresult *rv)
 {
     NS_PRECONDITION(rv, "Null out param");
     JSObject *obj = JS_GetFrameFunctionObject(cx, fp);
     if (!obj)
     {
         // Must be in a top-level script. Get principal from the script.
         JSScript *script = JS_GetFrameScript(cx, fp);
-        return GetScriptPrincipal(cx, script, rv);
+        return GetScriptPrincipal(script, rv);
     }
 
     nsIPrincipal* result = GetFunctionObjectPrincipal(cx, obj, fp, rv);
 
 #ifdef DEBUG
     if (NS_SUCCEEDED(*rv) && !result)
     {
         JSFunction *fun = JS_GetObjectFunction(obj);
@@ -3376,17 +3375,16 @@ nsresult nsScriptSecurityManager::Init()
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = runtimeService->GetRuntime(&sRuntime);
     NS_ENSURE_SUCCESS(rv, rv);
 
     static const JSSecurityCallbacks securityCallbacks = {
         CheckObjectAccess,
         nsJSPrincipals::Subsume,
-        nsJSPrincipals::Transcode,
         ObjectPrincipalFinder,
         ContentSecurityPolicyPermitsJSAction
     };
 
     MOZ_ASSERT(!JS_GetSecurityCallbacks(sRuntime));
     JS_SetSecurityCallbacks(sRuntime, &securityCallbacks);
     JS_InitDestroyPrincipalsCallback(sRuntime, nsJSPrincipals::Destroy);
 
--- a/caps/tests/mochitest/Makefile.in
+++ b/caps/tests/mochitest/Makefile.in
@@ -43,18 +43,19 @@ VPATH		= @srcdir@
 relativesrcdir  = caps/tests/mochitest
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = 	test_bug423375.html \
                 test_bug246699.html \
                 test_bug292789.html \
-		test_bug470804.html \
-		$(NULL)
+                test_bug470804.html \
+                test_disallowInheritPrincipal.html \
+                $(NULL)
 
 test_bug292789.html : % : %.in
 	$(PYTHON) $(topsrcdir)/config/Preprocessor.py \
 	     $(AUTOMATION_PPARGS) $(DEFINES) $(ACDEFINES) $< > $@
 
 GARBAGE += test_bug292789.html
 
 libs:: $(_TEST_FILES)
copy from caps/tests/mochitest/test_bug470804.html
copy to caps/tests/mochitest/test_disallowInheritPrincipal.html
--- a/caps/tests/mochitest/test_bug470804.html
+++ b/caps/tests/mochitest/test_disallowInheritPrincipal.html
@@ -1,43 +1,61 @@
 <!DOCTYPE HTML>
 <html>
 <!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=470804
+https://bugzilla.mozilla.org/show_bug.cgi?id=732413
 -->
 <head>
-  <title>Test for Bug 470804</title>
+  <title>Test for Bug 732413</title>
   <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=470804">Mozilla Bug 470804</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=732413">Mozilla Bug 732413</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script type="application/javascript">
 
-/** Test for Bug 470804
-    Passing a null targetURL to checkLoadURIWithPrincipal shouldn't crash
+/** Test for Bug 732413
+    Passing DISALLOW_INHERIT_PRINCIPAL flag should be effective even if
+    aPrincipal is the system principal.
  **/
 
 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
 const nsIScriptSecurityManager = Components.interfaces.nsIScriptSecurityManager;
 var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
                        .getService(nsIScriptSecurityManager);
-var principal = SpecialPowers.getNodePrincipal(document);
-isnot(principal, undefined, "Should have a principal");
-isnot(principal, null, "Should have a non-null principal");
-is(secMan.isSystemPrincipal(principal), false,
-   "Shouldn't have system principal here");
+var sysPrincipal = secMan.getSystemPrincipal();
+isnot(sysPrincipal, undefined, "Should have a principal");
+isnot(sysPrincipal, null, "Should have a non-null principal");
+is(secMan.isSystemPrincipal(sysPrincipal), true,
+   "Should have system principal here");
+
+
+var ioService = Components.classes["@mozilla.org/network/io-service;1"].
+                getService(Components.interfaces.nsIIOService);
+var inheritingURI = ioService.newURI("javascript:1+1", null, null);
+
+// First try a normal call to checkLoadURIWithPrincipal
 try {
-  secMan.checkLoadURIWithPrincipal(principal, null,
+  secMan.checkLoadURIWithPrincipal(sysPrincipal, inheritingURI,
                                    nsIScriptSecurityManager.STANDARD);
+  ok(true, "checkLoadURI allowed the load");
 } catch (e) {
-  // throwing is fine, it's just crashing that's bad
+  ok(false, "checkLoadURI failed unexpectedly: " + e);
 }
-ok(true, "Survival", "We should get here without crashing");
+
+// Now call checkLoadURIWithPrincipal with DISALLOW_INHERIT_PRINCIPAL
+try {
+  secMan.checkLoadURIWithPrincipal(sysPrincipal, inheritingURI,
+                                   nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
+  ok(false, "checkLoadURI allowed the load unexpectedly");
+} catch (e) {
+  ok(true, "checkLoadURI prevented load of principal-inheriting URI");
+}
+
 </script>
 </pre>
 </body>
 </html>
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -149,17 +149,16 @@ MOZ_UPDATE_CHANNEL	= @MOZ_UPDATE_CHANNEL
 MOZ_UPDATE_PACKAGING	= @MOZ_UPDATE_PACKAGING@
 MOZ_DISABLE_PARENTAL_CONTROLS = @MOZ_DISABLE_PARENTAL_CONTROLS@
 NS_ENABLE_TSF = @NS_ENABLE_TSF@
 MOZ_SPELLCHECK = @MOZ_SPELLCHECK@
 MOZ_ANDROID_HISTORY = @MOZ_ANDROID_HISTORY@
 MOZ_WEBSMS_BACKEND = @MOZ_WEBSMS_BACKEND@
 MOZ_JAVA_COMPOSITOR = @MOZ_JAVA_COMPOSITOR@
 MOZ_ONLY_TOUCH_EVENTS = @MOZ_ONLY_TOUCH_EVENTS@
-MOZ_TOUCH = @MOZ_TOUCH@
 MOZ_PROFILELOCKING = @MOZ_PROFILELOCKING@
 MOZ_FEEDS = @MOZ_FEEDS@
 MOZ_TOOLKIT_SEARCH = @MOZ_TOOLKIT_SEARCH@
 MOZ_PLACES = @MOZ_PLACES@
 MOZ_SAFE_BROWSING = @MOZ_SAFE_BROWSING@
 MOZ_URL_CLASSIFIER = @MOZ_URL_CLASSIFIER@
 MOZ_ZIPWRITER = @MOZ_ZIPWRITER@
 MOZ_OGG = @MOZ_OGG@
--- a/configure.in
+++ b/configure.in
@@ -1691,46 +1691,54 @@ if test "$GNU_CC"; then
     fi
     WARNINGS_AS_ERRORS='-Werror -Wno-error=uninitialized'
     DSO_CFLAGS=''
     DSO_PIC_CFLAGS='-fPIC'
     ASFLAGS="$ASFLAGS -fPIC"
     _MOZ_RTTI_FLAGS_ON=-frtti
     _MOZ_RTTI_FLAGS_OFF=-fno-rtti
 
-    # Turn on GNU specific features
-    # -Wall - turn on all warnings
-    # -pedantic - make compiler warn about non-ANSI stuff, and
-    #             be a little bit stricter
-    # -Wdeclaration-after-statement - MSVC doesn't like these
-    # Warnings slamm took out for now (these were giving more noise than help):
-    # -Wbad-function-cast - warns when casting a function to a new return type
-    # -Wshadow - removed because it generates more noise than help --pete
-    _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -W -Wno-unused -Wpointer-arith -Wdeclaration-after-statement"
+    # Turn on GNU-specific warnings:
+    # -Wall - turn on a lot of warnings
+    # -pedantic - this is turned on below
+    # -Wpointer-arith - enabled with -pedantic, but good to have even if not
+    # -Werror=declaration-after-statement - MSVC doesn't like these
+    # -Werror=return-type - catches missing returns, zero false positives
+    # -Wtype-limits - catches overflow bugs, few false positives
+    # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
+    #
+    _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wall -Wpointer-arith -Werror=declaration-after-statement"
+    MOZ_C_SUPPORTS_WARNING(-W, error=return-type, ac_c_has_werror_return_type)
+    MOZ_C_SUPPORTS_WARNING(-W, type-limits, ac_c_has_wtype_limits)
+    MOZ_C_SUPPORTS_WARNING(-W, empty-body, ac_c_has_wempty_body)
+    
+    # Turn off the following warnings that -Wall/-pedantic turn on:
+    # -Wno-overlength-strings - we exceed the minimum maximum length frequently
+    # -Wno-unused - lots of violations in third-party code
+    #
+    _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wno-overlength-strings -Wno-unused"
+
     if test -z "$INTEL_CC" -a -z "$CLANG_CC"; then
        # Don't use -Wcast-align with ICC or clang
        case "$CPU_ARCH" in
            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
            hppa | ia64 | sparc | arm)
            ;;
            *)
         _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
            ;;
        esac
     fi
 
     dnl Turn pedantic on but disable the warnings for long long
     _PEDANTIC=1
 
-    if test -z "$INTEL_CC"; then
-      _WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -W"
-    fi
-
     _DEFINES_CFLAGS='-include $(DEPTH)/mozilla-config.h -DMOZILLA_CLIENT'
     _USE_CPP_INCLUDE_FLAG=1
+
 elif test "$SOLARIS_SUNPRO_CC"; then
     DSO_CFLAGS=''
     if test "$CPU_ARCH" = "sparc"; then
         # for Sun Studio on Solaris/SPARC
         DSO_PIC_CFLAGS='-xcode=pic32'
     else
         DSO_PIC_CFLAGS='-KPIC'
     fi
@@ -1748,18 +1756,41 @@ else
     DSO_CFLAGS=''
     DSO_PIC_CFLAGS='-KPIC'
     _DEFINES_CFLAGS='$(ACDEFINES) -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT'
 fi
 
 if test "$GNU_CXX"; then
     # FIXME: Let us build with strict aliasing. bug 414641.
     CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-strict-aliasing"
-    # Turn on GNU specific features
-    _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor"
+
+    # Turn on GNU-specific warnings:
+    # -Wall - turn on a lot of warnings
+    # -pedantic - this is turned on below
+    # -Wpointer-arith - enabled with -pedantic, but good to have even if not
+    # -Woverloaded-virtual - ???
+    # -Werror=return-type - catches missing returns, zero false positives
+    # -Wtype-limits - catches overflow bugs, few false positives
+    # -Wempty-body - catches bugs, e.g. "if (c); foo();", few false positives
+    #
+    _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wall -Wpointer-arith -Woverloaded-virtual"
+    MOZ_CXX_SUPPORTS_WARNING(-W, error=return-type, ac_cxx_has_werror_return_type)
+    MOZ_CXX_SUPPORTS_WARNING(-W, type-limits, ac_cxx_has_wtype_limits)
+    MOZ_CXX_SUPPORTS_WARNING(-W, empty-body, ac_cxx_has_wempty_body)
+
+    # Turn off the following warnings that -Wall/-pedantic turn on:
+    # -Wno-overlength-strings - we exceed the minimum maximum length frequently 
+    # -Wno-ctor-dtor-privacy - ???
+    # -Wno-invalid-offsetof - we use offsetof on non-POD types frequently
+    # -Wno-variadic-macros - ???
+    #
+    _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-overlength-strings -Wno-ctor-dtor-privacy"
+    MOZ_CXX_SUPPORTS_WARNING(-Wno-, invalid-offsetof, ac_cxx_has_wno_invalid_offsetof)
+    MOZ_CXX_SUPPORTS_WARNING(-Wno-, variadic-macros, ac_cxx_has_wno_variadic_macros)
+
     if test -z "$INTEL_CXX" -a -z "$CLANG_CXX"; then
        # Don't use -Wcast-align with ICC or clang
        case "$CPU_ARCH" in
            # And don't use it on hppa, ia64, sparc, arm, since it's noisy there
            hppa | ia64 | sparc | arm)
            ;;
            *)
         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
@@ -1773,91 +1804,17 @@ if test "$GNU_CXX"; then
     # Recent clang and gcc support C++11 deleted functions without warnings if
     # compiling with -std=c++0x or -std=gnu++0x (or c++11 or gnu++11 in very new
     # versions).  We can't use -std=c++0x yet, so gcc's support must remain
     # unused.  But clang's warning can be disabled, so when compiling with clang
     # we use it to opt out of the warning, enabling (macro-encapsulated) use of
     # deleted function syntax.
     if test "$CLANG_CXX"; then
         _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-c++0x-extensions"
-    fi
-
-    AC_CACHE_CHECK(whether the compiler supports -Wno-extended-offsetof,
-                   ac_has_wno_extended_offsetof,
-        [
-            AC_LANG_SAVE
-            AC_LANG_CPLUSPLUS
-            _SAVE_CXXFLAGS="$CXXFLAGS"
-            CXXFLAGS="$CXXFLAGS -Wno-extended-offsetof"
-            AC_TRY_COMPILE([$configure_static_assert_macros
-                            #ifndef __has_warning
-                            #define __has_warning(x) 0
-                            #endif],
-                           [CONFIGURE_STATIC_ASSERT(__has_warning("-Wextended-offsetof"))],
-                           ac_has_wno_extended_offsetof="yes",
-                           ac_has_wno_extended_offsetof="no")
-            CXXFLAGS="$_SAVE_CXXFLAGS"
-            AC_LANG_RESTORE
-        ])
-    if test "$ac_has_wno_extended_offsetof" = "yes"; then
-        _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-extended-offsetof"
-    fi
-
-    AC_CACHE_CHECK(whether the compiler supports -Wno-invalid-offsetof,
-                   ac_has_wno_invalid_offsetof,
-        [
-            AC_LANG_SAVE
-            AC_LANG_CPLUSPLUS
-            _SAVE_CXXFLAGS="$CXXFLAGS"
-            CXXFLAGS="$CXXFLAGS -Wno-invalid-offsetof"
-            AC_TRY_COMPILE([],
-                           [return(0);],
-                           ac_has_wno_invalid_offsetof="yes",
-                           ac_has_wno_invalid_offsetof="no")
-            CXXFLAGS="$_SAVE_CXXFLAGS"
-            AC_LANG_RESTORE
-        ])
-    if test "$ac_has_wno_invalid_offsetof" = "yes"; then
-        _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-invalid-offsetof"
-    fi
-
-    AC_CACHE_CHECK(whether the compiler supports -Wno-variadic-macros,
-                   ac_has_wno_variadic_macros,
-        [
-            AC_LANG_SAVE
-            AC_LANG_CPLUSPLUS
-            _SAVE_CXXFLAGS="$CXXFLAGS"
-            CXXFLAGS="$CXXFLAGS -Wno-variadic-macros"
-            AC_TRY_COMPILE([],
-                           [return(0);],
-                           ac_has_wno_variadic_macros="yes",
-                           ac_has_wno_variadic_macros="no")
-            CXXFLAGS="$_SAVE_CXXFLAGS"
-            AC_LANG_RESTORE
-        ])
-    if test "$ac_has_wno_variadic_macros" = "yes"; then
-        _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-variadic-macros"
-    fi
-
-    AC_CACHE_CHECK(whether the compiler supports -Werror=return-type,
-                   ac_has_werror_return_type,
-        [
-            AC_LANG_SAVE
-            AC_LANG_CPLUSPLUS
-            _SAVE_CXXFLAGS="$CXXFLAGS"
-            CXXFLAGS="$CXXFLAGS -Werror=return-type"
-            AC_TRY_COMPILE([],
-                           [return(0);],
-                           ac_has_werror_return_type="yes",
-                           ac_has_werror_return_type="no")
-            CXXFLAGS="$_SAVE_CXXFLAGS"
-            AC_LANG_RESTORE
-        ])
-    if test "$ac_has_werror_return_type" = "yes"; then
-        _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Werror=return-type"
+        MOZ_CXX_SUPPORTS_WARNING(-Wno-, extended-offsetof, ac_cxx_has_wno_extended_offsetof)
     fi
 
 else
     _DEFINES_CXXFLAGS='-DMOZILLA_CLIENT -D_MOZILLA_CONFIG_H_ $(ACDEFINES)'
 fi
 
 dnl gcc can come with its own linker so it is better to use the pass-thru calls
 dnl MKSHLIB_FORCE_ALL is used to force the linker to include all object
@@ -4846,27 +4803,25 @@ cairo-uikit)
     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
     MOZ_USER_DIR="Mozilla"
     MOZ_FS_LAYOUT=bundle
     ;;
 
 cairo-android)
     AC_DEFINE(MOZ_WIDGET_ANDROID)
-    AC_DEFINE(MOZ_TOUCH)
     MOZ_WIDGET_TOOLKIT=android
     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
     TK_LIBS='$(MOZ_CAIRO_LIBS)'
     MOZ_WEBGL=1
     MOZ_PDF_PRINTING=1
     MOZ_INSTRUMENT_EVENT_LOOP=1
     if test "$MOZ_BUILD_APP" = "mobile/xul"; then
         MOZ_OLD_LINKER=1
     fi
-    MOZ_TOUCH=1
     ;;
 
 cairo-gonk)
     AC_DEFINE(MOZ_WIDGET_GONK)
     AC_DEFINE(MOZ_TOUCH)
     MOZ_WIDGET_TOOLKIT=gonk
     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
     TK_LIBS='$(MOZ_CAIRO_LIBS)'
--- a/content/base/public/nsISelectionPrivate.idl
+++ b/content/base/public/nsISelectionPrivate.idl
@@ -47,29 +47,31 @@ interface nsIContent;
 interface nsINode;
 
 %{C++
 class nsFrameSelection;
 class nsIFrame;
 class nsIPresShell;
 struct nsTextRangeStyle;
 struct nsPoint;
+struct ScrollAxis;
 #include "nsIFrame.h"
 #include "nsTArray.h"
 %}
 
 [ptr] native nsFrameSelection(nsFrameSelection);
 [ptr] native nsIFrame(nsIFrame);
 [ptr] native nsIPresShell(nsIPresShell);
 [ptr] native RangeArray(nsTArray<nsRange*>);
 [ref] native constTextRangeStyleRef(const nsTextRangeStyle);
 [ref] native nsPointRef(nsPoint);
 native nsDirection(nsDirection);
+native ScrollAxis(nsIPresShell::ScrollAxis);
 
-[scriptable, uuid(1820a940-6203-4e27-bc94-fa81131722a4)]
+[scriptable, uuid(0ced91b9-3e77-4191-943f-95bcde5e2d14)]
 interface nsISelectionPrivate : nsISelection
  {
     const short ENDOFPRECEDINGLINE=0;
     const short STARTOFNEXTLINE=1;
     
     attribute boolean interlinePosition;
 
     /* startBatchChanges
@@ -169,34 +171,36 @@ interface nsISelectionPrivate : nsISelec
      * the scrolled view.
      *
      * @param aRegion - the region inside the selection to scroll into view
      *                  (see selection region constants defined in
      *                   nsISelectionController).
      * @param aIsSynchronous - when true, scrolls the selection into view
      *                         before returning. If false, posts a request which
      *                         is processed at some point after the method returns.
-     * @param aVPercent - how to align the frame vertically. A value of 0
-     *                   means the frame's upper edge is aligned with the top edge
-     *                   of the visible area. A value of 100 means the frame's
-     *                   bottom edge is aligned with the bottom edge of
-     *                   the visible area. For values in between, the point
-     *                   "aVPercent" down the frame is placed at the point
-     *                   "aVPercent" down the visible area. A value of 50 centers
-     *                   the frame vertically. A value of -1 means move
-     *                   the frame the minimum amount necessary in order for
-     *                   the entire frame to be visible vertically (if possible).
-     * @param aHPercent - how to align the frame horizontally. A value of 0
-     *                    means the frame's left edge is aligned with the left
-     *                    edge of the visible area. A value of 100 means the
-     *                    frame's right edge is aligned with the right edge of
-     *                    the visible area. For values in between, the point
-     *                    "aHPercent" across the frame is placed at the point
-     *                    "aHPercent" across the visible area. A value of 50
-     *                    centers the frame horizontally . A value of -1 means
-     *                    move the frame the minimum amount necessary in order
-     *                    for the entire frame to be visible horizontally
-     *                    (if possible).
+     * @param aVPercent - how to align the frame vertically.
+     * @param aHPercent - how to align the frame horizontally.
      */
     void scrollIntoView(in short aRegion, in boolean aIsSynchronous,
-                        in short aVPercent, in short aHPercent);
+                        in PRInt16 aVPercent,
+                        in PRInt16 aHPercent);
+
+    /**
+     * Scrolls a region of the selection, so that it is visible in
+     * the scrolled view.
+     *
+     * @param aRegion - the region inside the selection to scroll into view
+     *                  (see selection region constants defined in
+     *                   nsISelectionController).
+     * @param aIsSynchronous - when true, scrolls the selection into view
+     *                         before returning. If false, posts a request which
+     *                         is processed at some point after the method returns.
+     * @param aVertical - how to align the frame vertically and when.
+     *                    See nsIPresShell.h:ScrollAxis for details.
+     * @param aHorizontal - how to align the frame horizontally and when.
+     *                    See nsIPresShell.h:ScrollAxis for details.
+     */
+    [noscript] void scrollIntoViewInternal(in short aRegion,
+                                           in boolean aIsSynchronous,
+                                           in ScrollAxis aVertical,
+                                           in ScrollAxis aHorizontal);
 };
 
--- a/content/base/src/nsImageLoadingContent.cpp
+++ b/content/base/src/nsImageLoadingContent.cpp
@@ -56,16 +56,17 @@
 #include "nsIURI.h"
 #include "nsILoadGroup.h"
 #include "imgIContainer.h"
 #include "imgILoader.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsGenericElement.h"
+#include "nsImageFrame.h"
 
 #include "nsIPresShell.h"
 #include "nsEventStates.h"
 #include "nsGUIEvent.h"
 
 #include "nsIChannel.h"
 #include "nsIStreamListener.h"
 
@@ -295,20 +296,17 @@ nsImageLoadingContent::OnStopDecode(imgI
   // XXXbholley - When we fix bug 505385,  everything here should go in
   // OnStopRequest.
 
   // Our state may change. Watch it.
   AutoStateChanger changer(this, true);
 
   // If the pending request is loaded, switch to it.
   if (aRequest == mPendingRequest) {
-    PrepareCurrentRequest() = mPendingRequest;
-    mPendingRequest = nsnull;
-    mCurrentRequestNeedsResetAnimation = mPendingRequestNeedsResetAnimation;
-    mPendingRequestNeedsResetAnimation = false;
+    MakePendingRequestCurrent();
   }
   NS_ABORT_IF_FALSE(aRequest == mCurrentRequest,
                     "One way or another, we should be current by now");
 
   if (mCurrentRequestNeedsResetAnimation) {
     nsCOMPtr<imgIContainer> container;
     mCurrentRequest->GetImage(getter_AddRefs(container));
     if (container)
@@ -787,16 +785,36 @@ nsImageLoadingContent::LoadImage(nsIURI*
   nsresult rv;
   rv = nsContentUtils::LoadImage(aNewURI, aDocument,
                                  aDocument->NodePrincipal(),
                                  aDocument->GetDocumentURI(),
                                  this, loadFlags,
                                  getter_AddRefs(req));
   if (NS_SUCCEEDED(rv)) {
     TrackImage(req);
+
+    // Handle cases when we just ended up with a pending request but it's
+    // already done.  In that situation we have to synchronously switch that
+    // request to being the current request, because websites depend on that
+    // behavior.
+    if (req == mPendingRequest) {
+      PRUint32 pendingLoadStatus;
+      rv = req->GetImageStatus(&pendingLoadStatus);
+      if (NS_SUCCEEDED(rv) &&
+          (pendingLoadStatus & imgIRequest::STATUS_LOAD_COMPLETE)) {
+        MakePendingRequestCurrent();
+        MOZ_ASSERT(mCurrentRequest,
+                   "How could we not have a current request here?");
+
+        nsImageFrame *f = do_QueryFrame(GetOurPrimaryFrame());
+        if (f) {
+          f->NotifyNewCurrentRequest(mCurrentRequest, NS_OK);
+        }
+      }
+    }
   } else {
     // If we don't have a current URI, we might as well store this URI so people
     // know what we tried (and failed) to load.
     if (!mCurrentRequest)
       mCurrentURI = aNewURI;
     FireEvent(NS_LITERAL_STRING("error"));
     return NS_OK;
   }
@@ -1042,16 +1060,26 @@ nsImageLoadingContent::PreparePendingReq
 
   mPendingRequestNeedsResetAnimation = mNewRequestsWillNeedAnimationReset;
 
   // Return a reference.
   return mPendingRequest;
 }
 
 void
+nsImageLoadingContent::MakePendingRequestCurrent()
+{
+  MOZ_ASSERT(mPendingRequest);
+  PrepareCurrentRequest() = mPendingRequest;
+  mPendingRequest = nsnull;
+  mCurrentRequestNeedsResetAnimation = mPendingRequestNeedsResetAnimation;
+  mPendingRequestNeedsResetAnimation = false;
+}
+
+void
 nsImageLoadingContent::ClearCurrentRequest(nsresult aReason)
 {
   if (!mCurrentRequest) {
     // Even if we didn't have a current request, we might have been keeping
     // a URI as a placeholder for a failed load. Clear that now.
     mCurrentURI = nsnull;
     return;
   }
--- a/content/base/src/nsImageLoadingContent.h
+++ b/content/base/src/nsImageLoadingContent.h
@@ -293,16 +293,22 @@ protected:
    * to get rid of one of the requests, you should call
    * Clear*Request(NS_BINDING_ABORTED) instead, since it passes a more appropriate
    * aReason than Prepare*Request() does (NS_ERROR_IMAGE_SRC_CHANGED).
    */
   nsCOMPtr<imgIRequest>& PrepareCurrentRequest();
   nsCOMPtr<imgIRequest>& PreparePendingRequest();
 
   /**
+   * Switch our pending request to be our current request.
+   * mPendingRequest must be non-null!
+   */
+  void MakePendingRequestCurrent();
+
+  /**
    * Cancels and nulls-out the "current" and "pending" requests if they exist.
    */
   void ClearCurrentRequest(nsresult aReason);
   void ClearPendingRequest(nsresult aReason);
 
   /**
    * Retrieve a pointer to the 'registered with the refresh driver' flag for
    * which a particular image request corresponds.
--- a/content/base/src/nsTreeSanitizer.cpp
+++ b/content/base/src/nsTreeSanitizer.cpp
@@ -1093,20 +1093,24 @@ nsTreeSanitizer::MustPrune(PRInt32 aName
       // emulate the quirks of the old parser
       return true;
     }
     if (mDropForms && (nsGkAtoms::select == aLocal ||
                        nsGkAtoms::button == aLocal ||
                        nsGkAtoms::datalist == aLocal)) {
       return true;
     }
-    if (mDropMedia && (nsGkAtoms::img == aLocal ||
+    if (mDropMedia && (nsGkAtoms::img == aLocal
+#ifdef MOZ_MEDIA
+                       ||
                        nsGkAtoms::video == aLocal ||
                        nsGkAtoms::audio == aLocal ||
-                       nsGkAtoms::source == aLocal)) {
+                       nsGkAtoms::source == aLocal
+#endif
+                       )) {
       return true;
     }
     if (nsGkAtoms::meta == aLocal &&
         (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::charset) ||
          aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv))) {
       // Throw away charset declarations even if they also have microdata
       // which they can't validly have.
       return true;
--- a/content/events/src/nsContentEventHandler.cpp
+++ b/content/events/src/nsContentEventHandler.cpp
@@ -1104,13 +1104,14 @@ nsContentEventHandler::OnSelectionEvent(
       } else {
         rv = mSelection->Extend(endDomNode, endOffset);
       }
     }
   }
   selPrivate->EndBatchChanges();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  selPrivate->ScrollIntoView(
-      nsISelectionController::SELECTION_FOCUS_REGION, false, -1, -1);
+  selPrivate->ScrollIntoViewInternal(
+    nsISelectionController::SELECTION_FOCUS_REGION,
+    false, nsIPresShell::ScrollAxis(), nsIPresShell::ScrollAxis());
   aEvent->mSucceeded = true;
   return NS_OK;
 }
--- a/content/events/src/nsDOMMouseEvent.cpp
+++ b/content/events/src/nsDOMMouseEvent.cpp
@@ -231,67 +231,51 @@ nsDOMMouseEvent::GetRelatedTarget(nsIDOM
     CallQueryInterface(relatedTarget, aRelatedTarget);
   }
   return NS_OK;
 }
 
 NS_METHOD nsDOMMouseEvent::GetScreenX(PRInt32* aScreenX)
 {
   NS_ENSURE_ARG_POINTER(aScreenX);
-#ifdef MOZ_TOUCH
   *aScreenX = nsDOMEvent::GetScreenCoords(mPresContext,
                                           mEvent,
                                           mEvent->refPoint).x;
-#else
-  *aScreenX = GetScreenPoint().x;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMouseEvent::GetScreenY(PRInt32* aScreenY)
 {
   NS_ENSURE_ARG_POINTER(aScreenY);
-#ifdef MOZ_TOUCH
   *aScreenY = nsDOMEvent::GetScreenCoords(mPresContext,
                                           mEvent,
                                           mEvent->refPoint).y;
-#else
-  *aScreenY = GetScreenPoint().y;
-#endif
   return NS_OK;
 }
 
 
 NS_METHOD nsDOMMouseEvent::GetClientX(PRInt32* aClientX)
 {
   NS_ENSURE_ARG_POINTER(aClientX);
-#ifdef MOZ_TOUCH
   *aClientX = nsDOMEvent::GetClientCoords(mPresContext,
                                           mEvent,
                                           mEvent->refPoint,
                                           mClientPoint).x;
-#else
-  *aClientX = GetClientPoint().x;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMouseEvent::GetClientY(PRInt32* aClientY)
 {
   NS_ENSURE_ARG_POINTER(aClientY);
-#ifdef MOZ_TOUCH
   *aClientY = nsDOMEvent::GetClientCoords(mPresContext,
                                           mEvent,
                                           mEvent->refPoint,
                                           mClientPoint).y;
-#else
-  *aClientY = GetClientPoint().y;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMouseEvent::GetAltKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = ((nsInputEvent*)mEvent)->isAlt;
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -239,47 +239,39 @@ nsDOMUIEvent::GetPagePoint()
 
   return pagePoint;
 }
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetPageX(PRInt32* aPageX)
 {
   NS_ENSURE_ARG_POINTER(aPageX);
-#ifdef MOZ_TOUCH
   if (mPrivateDataDuplicated) {
     *aPageX = mPagePoint.x;
   } else {
     *aPageX = nsDOMEvent::GetPageCoords(mPresContext,
                                         mEvent,
                                         mEvent->refPoint,
                                         mClientPoint).x;
   }
-#else
-  *aPageX = GetPagePoint().x;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetPageY(PRInt32* aPageY)
 {
   NS_ENSURE_ARG_POINTER(aPageY);
-#ifdef MOZ_TOUCH
   if (mPrivateDataDuplicated) {
     *aPageY = mPagePoint.y;
   } else {
     *aPageY = nsDOMEvent::GetPageCoords(mPresContext,
                                         mEvent,
                                         mEvent->refPoint,
                                         mClientPoint).y;
   }
-#else
-  *aPageY = GetPagePoint().y;
-#endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetWhich(PRUint32* aWhich)
 {
   return Which(aWhich);
 }
@@ -408,37 +400,29 @@ nsDOMUIEvent::GetIsChar(bool* aIsChar)
       *aIsChar = false;
       return NS_OK;
   }
 }
 
 NS_METHOD
 nsDOMUIEvent::DuplicatePrivateData()
 {
-#ifdef MOZ_TOUCH
   mClientPoint = nsDOMEvent::GetClientCoords(mPresContext,
                                              mEvent,
                                              mEvent->refPoint,
                                              mClientPoint);
   mLayerPoint = GetLayerPoint();
   mPagePoint = nsDOMEvent::GetPageCoords(mPresContext,
                                          mEvent,
                                          mEvent->refPoint,
                                          mClientPoint);
   // GetScreenPoint converts mEvent->refPoint to right coordinates.
   nsIntPoint screenPoint = nsDOMEvent::GetScreenCoords(mPresContext,
                                                        mEvent,
                                                        mEvent->refPoint);
-#else
-  mClientPoint = GetClientPoint();
-  mLayerPoint = GetLayerPoint();
-  mPagePoint = GetPagePoint();
-  // GetScreenPoint converts mEvent->refPoint to right coordinates.
-  nsIntPoint screenPoint = GetScreenPoint();
-#endif
   nsresult rv = nsDOMEvent::DuplicatePrivateData();
   if (NS_SUCCEEDED(rv)) {
     mEvent->refPoint = screenPoint;
   }
   return rv;
 }
 
 void
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -978,21 +978,24 @@ nsGenericHTMLElement::ScrollIntoView(boo
   if (!presShell) {
     return NS_OK;
   }
 
   if (!optional_argc) {
     aTop = true;
   }
 
-  PRIntn vpercent = aTop ? NS_PRESSHELL_SCROLL_TOP :
-    NS_PRESSHELL_SCROLL_BOTTOM;
-
-  presShell->ScrollContentIntoView(this, vpercent,
-                                   NS_PRESSHELL_SCROLL_ANYWHERE,
+  PRInt16 vpercent = aTop ? nsIPresShell::SCROLL_TOP :
+    nsIPresShell::SCROLL_BOTTOM;
+
+  presShell->ScrollContentIntoView(this,
+                                   nsIPresShell::ScrollAxis(
+                                     vpercent,
+                                     nsIPresShell::SCROLL_ALWAYS),
+                                   nsIPresShell::ScrollAxis(),
                                    nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGenericHTMLElement::GetSpellcheck(bool* aSpellcheck)
 {
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -1404,17 +1404,20 @@ nsHTMLMediaElement::LookupMediaElementUR
   for (PRUint32 i = 0; i < entry->mElements.Length(); ++i) {
     nsHTMLMediaElement* elem = entry->mElements[i];
     bool equal;
     // Look for elements that have the same principal and CORS mode.
     // Ditto for anything else that could cause us to send different headers.
     if (NS_SUCCEEDED(elem->NodePrincipal()->Equals(NodePrincipal(), &equal)) && equal &&
         elem->mCORSMode == mCORSMode) {
       NS_ASSERTION(elem->mDecoder && elem->mDecoder->GetResource(), "Decoder gone");
-      return elem;
+      MediaResource* resource = elem->mDecoder->GetResource();
+      if (resource->CanClone()) {
+        return elem;
+      }
     }
   }
   return nsnull;
 }
 
 nsHTMLMediaElement::nsHTMLMediaElement(already_AddRefed<nsINodeInfo> aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo),
     mCurrentLoadID(0),
--- a/content/media/MediaResource.cpp
+++ b/content/media/MediaResource.cpp
@@ -525,19 +525,25 @@ nsresult ChannelMediaResource::Close()
 already_AddRefed<nsIPrincipal> ChannelMediaResource::GetCurrentPrincipal()
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
   nsCOMPtr<nsIPrincipal> principal = mCacheStream.GetCurrentPrincipal();
   return principal.forget();
 }
 
+bool ChannelMediaResource::CanClone()
+{
+  return mCacheStream.IsAvailableForSharing();
+}
+
 MediaResource* ChannelMediaResource::CloneData(nsMediaDecoder* aDecoder)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
+  NS_ASSERTION(mCacheStream.IsAvailableForSharing(), "Stream can't be cloned");
 
   ChannelMediaResource* resource = new ChannelMediaResource(aDecoder, nsnull, mURI);
   if (resource) {
     // Initially the clone is treated as suspended by the cache, because
     // we don't have a channel. If the cache needs to read data from the clone
     // it will call CacheClientResume (or CacheClientSeek with aResume true)
     // which will recreate the channel. This way, if all of the media data
     // is already in the cache we don't create an unneccesary HTTP channel
@@ -905,16 +911,17 @@ public:
   }
 
   // Main thread
   virtual nsresult Open(nsIStreamListener** aStreamListener);
   virtual nsresult Close();
   virtual void     Suspend(bool aCloseImmediately) {}
   virtual void     Resume() {}
   virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal();
+  virtual bool     CanClone();
   virtual MediaResource* CloneData(nsMediaDecoder* aDecoder);
   virtual nsresult ReadFromCache(char* aBuffer, PRInt64 aOffset, PRUint32 aCount);
 
   // These methods are called off the main thread.
 
   // Other thread
   virtual void     SetReadMode(nsMediaCacheStream::ReadMode aMode) {}
   virtual void     SetPlaybackRate(PRUint32 aBytesPerSecond) {}
@@ -1082,16 +1089,21 @@ already_AddRefed<nsIPrincipal> FileMedia
   nsCOMPtr<nsIPrincipal> principal;
   nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
   if (!secMan || !mChannel)
     return nsnull;
   secMan->GetChannelPrincipal(mChannel, getter_AddRefs(principal));
   return principal.forget();
 }
 
+bool FileMediaResource::CanClone()
+{
+  return true;
+}
+
 MediaResource* FileMediaResource::CloneData(nsMediaDecoder* aDecoder)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
   nsHTMLMediaElement* element = aDecoder->GetMediaElement();
   if (!element) {
     // The decoder is being shut down, so we can't clone
     return nsnull;
--- a/content/media/MediaResource.h
+++ b/content/media/MediaResource.h
@@ -186,16 +186,22 @@ public:
   // since we don't expect to resume again any time soon. Otherwise we
   // may resume again soon so resources should be held for a little
   // while.
   virtual void Suspend(bool aCloseImmediately) = 0;
   // Resume any downloads that have been suspended.
   virtual void Resume() = 0;
   // Get the current principal for the channel
   virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal() = 0;
+  // If this returns false, then we shouldn't try to clone this MediaResource
+  // because its underlying resources are not suitable for reuse (e.g.
+  // because the underlying connection has been lost, or this resource
+  // just can't be safely cloned). If this returns true, CloneData could
+  // still fail. If this returns false, CloneData should not be called.
+  virtual bool CanClone() { return false; }
   // Create a new stream of the same type that refers to the same URI
   // with a new channel. Any cached data associated with the original
   // stream should be accessible in the new stream too.
   virtual MediaResource* CloneData(nsMediaDecoder* aDecoder) = 0;
 
   // These methods are called off the main thread.
   // The mode is initially MODE_PLAYBACK.
   virtual void SetReadMode(nsMediaCacheStream::ReadMode aMode) = 0;
@@ -386,16 +392,17 @@ public:
   // Main thread
   virtual nsresult Open(nsIStreamListener** aStreamListener);
   virtual nsresult Close();
   virtual void     Suspend(bool aCloseImmediately);
   virtual void     Resume();
   virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal();
   // Return true if the stream has been closed.
   bool IsClosed() const { return mCacheStream.IsClosed(); }
+  virtual bool     CanClone();
   virtual MediaResource* CloneData(nsMediaDecoder* aDecoder);
   virtual nsresult ReadFromCache(char* aBuffer, PRInt64 aOffset, PRUint32 aCount);
   virtual void     EnsureCacheUpToDate();
 
   // Other thread
   virtual void     SetReadMode(nsMediaCacheStream::ReadMode aMode);
   virtual void     SetPlaybackRate(PRUint32 aBytesPerSecond);
   virtual nsresult Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes);
--- a/content/media/nsMediaCache.cpp
+++ b/content/media/nsMediaCache.cpp
@@ -173,16 +173,22 @@ public:
   // This can return partial reads.
   nsresult ReadCacheFile(PRInt64 aOffset, void* aData, PRInt32 aLength,
                          PRInt32* aBytes);
   // This will fail if all aLength bytes are not read
   nsresult ReadCacheFileAllBytes(PRInt64 aOffset, void* aData, PRInt32 aLength);
   // This will fail if all aLength bytes are not written
   nsresult WriteCacheFile(PRInt64 aOffset, const void* aData, PRInt32 aLength);
 
+  PRInt64 AllocateResourceID()
+  {
+    mReentrantMonitor.AssertCurrentThreadIn();
+    return mNextResourceID++;
+  }
+
   // mReentrantMonitor must be held, called on main thread.
   // These methods are used by the stream to set up and tear down streams,
   // and to handle reads and writes.
   // Add aStream to the list of streams.
   void OpenStream(nsMediaCacheStream* aStream);
   // Remove aStream from the list of streams.
   void ReleaseStream(nsMediaCacheStream* aStream);
   // Free all blocks belonging to aStream.
@@ -1573,17 +1579,17 @@ nsMediaCache::AllocateAndWriteBlock(nsMe
 void
 nsMediaCache::OpenStream(nsMediaCacheStream* aStream)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   LOG(PR_LOG_DEBUG, ("Stream %p opened", aStream));
   mStreams.AppendElement(aStream);
-  aStream->mResourceID = mNextResourceID++;
+  aStream->mResourceID = AllocateResourceID();
 
   // Queue an update since a new stream has been opened.
   gMediaCache->QueueUpdate();
 }
 
 void
 nsMediaCache::ReleaseStream(nsMediaCacheStream* aStream)
 {
@@ -1851,16 +1857,23 @@ nsMediaCacheStream::NotifyDataReceived(P
 
 void
 nsMediaCacheStream::NotifyDataEnded(nsresult aStatus)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
   ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
 
+  if (NS_FAILED(aStatus)) {
+    // Disconnect from other streams sharing our resource, since they
+    // should continue trying to load. Our load might have been deliberately
+    // canceled and that shouldn't affect other streams.
+    mResourceID = gMediaCache->AllocateResourceID();
+  }
+
   PRInt32 blockOffset = PRInt32(mChannelOffset%BLOCK_SIZE);
   if (blockOffset > 0) {
     // Write back the partial block
     memset(reinterpret_cast<char*>(mPartialBlockBuffer) + blockOffset, 0,
            BLOCK_SIZE - blockOffset);
     gMediaCache->AllocateAndWriteBlock(this, mPartialBlockBuffer,
         mMetadataInPartialBlockBuffer ? MODE_METADATA : MODE_PLAYBACK);
     // Wake up readers who may be waiting for this data
@@ -1877,16 +1890,17 @@ nsMediaCacheStream::NotifyDataEnded(nsre
       NS_ASSERTION(!stream->mDidNotifyDataEnded, "Stream already ended!");
       stream->mDidNotifyDataEnded = true;
       stream->mNotifyDataEndedStatus = aStatus;
       stream->mClient->CacheClientNotifyDataEnded(aStatus);
     }
   }
 
   mChannelEnded = true;
+  gMediaCache->QueueUpdate();
 }
 
 nsMediaCacheStream::~nsMediaCacheStream()
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
   NS_ASSERTION(!mPinCount, "Unbalanced Pin");
 
   if (gMediaCache) {
@@ -2329,16 +2343,19 @@ nsMediaCacheStream::Init()
   gMediaCache->OpenStream(this);
   mInitialized = true;
   return NS_OK;
 }
 
 nsresult
 nsMediaCacheStream::InitAsClone(nsMediaCacheStream* aOriginal)
 {
+  if (!aOriginal->IsAvailableForSharing())
+    return NS_ERROR_FAILURE;
+
   if (mInitialized)
     return NS_OK;
 
   nsresult rv = Init();
   if (NS_FAILED(rv))
     return rv;
   mResourceID = aOriginal->mResourceID;
 
--- a/content/media/nsMediaCache.h
+++ b/content/media/nsMediaCache.h
@@ -227,24 +227,25 @@ public:
     MODE_PLAYBACK
   };
 
   // aClient provides the underlying transport that cache will use to read
   // data for this stream.
   nsMediaCacheStream(ChannelMediaResource* aClient)
     : mClient(aClient), mResourceID(0), mInitialized(false),
       mHasHadUpdate(false),
+      mClosed(false),
+      mDidNotifyDataEnded(false),
       mIsSeekable(false), mCacheSuspended(false),
-      mChannelEnded(false), mDidNotifyDataEnded(false),
+      mChannelEnded(false),
       mUsingNullPrincipal(false),
       mChannelOffset(0), mStreamLength(-1),  
       mStreamOffset(0), mPlaybackBytesPerSecond(10000),
       mPinCount(0), mCurrentMode(MODE_PLAYBACK),
-      mMetadataInPartialBlockBuffer(false),
-      mClosed(false) {}
+      mMetadataInPartialBlockBuffer(false) {}
   ~nsMediaCacheStream();
 
   // Set up this stream with the cache. Can fail on OOM. One
   // of InitAsClone or Init must be called before any other method on
   // this class. Does nothing if already initialized.
   nsresult Init();
 
   // Set up this stream with the cache, assuming it's for the same data
@@ -261,16 +262,22 @@ public:
   // we do an HTTP load the seekability may be different (and sometimes
   // is, in practice, due to the effects of caching proxies).
   void SetSeekable(bool aIsSeekable);
   // This must be called (and return) before the ChannelMediaResource
   // used to create this nsMediaCacheStream is deleted.
   void Close();
   // This returns true when the stream has been closed
   bool IsClosed() const { return mClosed; }
+  // Returns true when this stream is can be shared by a new resource load
+  bool IsAvailableForSharing() const
+  {
+    return !mClosed &&
+      (!mDidNotifyDataEnded || NS_SUCCEEDED(mNotifyDataEndedStatus));
+  }
   // Get the principal for this stream.
   nsIPrincipal* GetCurrentPrincipal() { return mPrincipal; }
   // Ensure a global media cache update has run with this stream present.
   // This ensures the cache has had a chance to suspend or unsuspend this stream.
   // Called only on main thread. This can change the state of streams, fire
   // notifications, etc.
   void EnsureCacheUpdate();
 
@@ -461,30 +468,33 @@ private:
   // All streams with the same mResourceID are loading the same
   // underlying resource and should share data.
   PRInt64                mResourceID;
   // Set to true when Init or InitAsClone has been called
   bool                   mInitialized;
   // Set to true when nsMediaCache::Update() has finished while this stream
   // was present.
   bool                   mHasHadUpdate;
+  // Set to true when the stream has been closed either explicitly or
+  // due to an internal cache error
+  bool                   mClosed;
+  // True if CacheClientNotifyDataEnded has been called for this stream.
+  bool                   mDidNotifyDataEnded;
 
   // The following fields are protected by the cache's monitor but are
   // only written on the main thread. 
 
   // The last reported seekability state for the underlying channel
   bool mIsSeekable;
   // True if the cache has suspended our channel because the cache is
   // full and the priority of the data that would be received is lower
   // than the priority of the data already in the cache
   bool mCacheSuspended;
   // True if the channel ended and we haven't seeked it again.
   bool mChannelEnded;
-  // True if CacheClientNotifyDataEnded has been called for this stream.
-  bool mDidNotifyDataEnded;
   // True if mPrincipal is a null principal because we saw data from
   // multiple origins
   bool mUsingNullPrincipal;
   // The offset where the next data from the channel will arrive
   PRInt64      mChannelOffset;
   // The reported or discovered length of the data, or -1 if nothing is
   // known
   PRInt64      mStreamLength;
@@ -505,25 +515,23 @@ private:
   BlockList         mMetadataBlocks;
   // The list of played-back blocks; the first block is the most recently used
   BlockList         mPlayedBlocks;
   // The last reported estimate of the decoder's playback rate
   PRUint32          mPlaybackBytesPerSecond;
   // The number of times this stream has been Pinned without a
   // corresponding Unpin
   PRUint32          mPinCount;
-  // The status used when we did CacheClientNotifyDataEnded
+  // The status used when we did CacheClientNotifyDataEnded. Only valid
+  // when mDidNotifyDataEnded is true.
   nsresult          mNotifyDataEndedStatus;
   // The last reported read mode
   ReadMode          mCurrentMode;
   // True if some data in mPartialBlockBuffer has been read as metadata
   bool              mMetadataInPartialBlockBuffer;
-  // Set to true when the stream has been closed either explicitly or
-  // due to an internal cache error
-  bool              mClosed;
 
   // The following field is protected by the cache's monitor but are
   // only written on the main thread.
 
   // Data received for the block containing mChannelOffset. Data needs
   // to wait here so we can write back a complete block. The first
   // mChannelOffset%BLOCK_SIZE bytes have been filled in with good data,
   // the rest are garbage.
--- a/content/smil/nsSMILAnimationFunction.cpp
+++ b/content/smil/nsSMILAnimationFunction.cpp
@@ -666,17 +666,17 @@ nsSMILAnimationFunction::ScaleSimpleProg
     return aProgress;
 
   PRUint32 numTimes = mKeyTimes.Length();
 
   if (numTimes < 2)
     return aProgress;
 
   PRUint32 i = 0;
-  for (; i < numTimes - 2 && aProgress >= mKeyTimes[i+1]; ++i);
+  for (; i < numTimes - 2 && aProgress >= mKeyTimes[i+1]; ++i) { }
 
   if (aCalcMode == CALC_DISCRETE) {
     // discrete calcMode behaviour differs in that each keyTime defines the time
     // from when the corresponding value is set, and therefore the last value
     // needn't be 1. So check if we're in the last 'interval', that is, the
     // space between the final value and 1.0.
     if (aProgress >= mKeyTimes[i+1]) {
       NS_ABORT_IF_FALSE(i == numTimes - 2,
--- a/content/smil/nsSMILTimedElement.cpp
+++ b/content/smil/nsSMILTimedElement.cpp
@@ -1762,17 +1762,17 @@ nsSMILTimedElement::GetNextInterval(cons
 
 nsSMILInstanceTime*
 nsSMILTimedElement::GetNextGreater(const InstanceTimeList& aList,
                                    const nsSMILTimeValue& aBase,
                                    PRInt32& aPosition) const
 {
   nsSMILInstanceTime* result = nsnull;
   while ((result = GetNextGreaterOrEqual(aList, aBase, aPosition)) &&
-         result->Time() == aBase);
+         result->Time() == aBase) { }
   return result;
 }
 
 nsSMILInstanceTime*
 nsSMILTimedElement::GetNextGreaterOrEqual(const InstanceTimeList& aList,
                                           const nsSMILTimeValue& aBase,
                                           PRInt32& aPosition) const
 {
--- a/content/xbl/src/nsXBLSerialize.cpp
+++ b/content/xbl/src/nsXBLSerialize.cpp
@@ -33,82 +33,26 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsXBLSerialize.h"
 #include "nsDOMScriptObjectHolder.h"
 #include "nsContentUtils.h"
-#include "jsxdrapi.h"
 
 nsresult
 XBL_SerializeFunction(nsIScriptContext* aContext,
                       nsIObjectOutputStream* aStream,
                       JSObject* aFunctionObject)
 {
   JSContext* cx = aContext->GetNativeContext();
-  JSXDRState *xdr = ::JS_XDRNewMem(cx, JSXDR_ENCODE);
-  if (!xdr)
-    return NS_ERROR_OUT_OF_MEMORY;
-  xdr->userdata = static_cast<void*>(aStream);
-
-  JSAutoRequest ar(cx);
-  nsresult rv;
-  if (!JS_XDRFunctionObject(xdr, &aFunctionObject)) {
-    rv = NS_ERROR_FAILURE;
-  } else {
-    uint32_t size;
-    const char* data = reinterpret_cast<const char*>
-                                       (JS_XDRMemGetData(xdr, &size));
-    NS_ASSERTION(data, "no decoded JSXDRState data!");
-
-    rv = aStream->Write32(size);
-    if (NS_SUCCEEDED(rv))
-      rv = aStream->WriteBytes(data, size);
-  }
-
-  JS_XDRDestroy(xdr);
-
-  return rv;
+  return nsContentUtils::XPConnect()->WriteFunction(aStream, cx, aFunctionObject);
 }
 
-// static
 nsresult
 XBL_DeserializeFunction(nsIScriptContext* aContext,
                         nsIObjectInputStream* aStream,
-                        JSObject** aFunctionObject)
+                        JSObject** aFunctionObjectp)
 {
-  *aFunctionObject = nsnull;
-
-  PRUint32 size;
-  nsresult rv = aStream->Read32(&size);
-  if (NS_FAILED(rv))
-    return rv;
-
-  char* data;
-  rv = aStream->ReadBytes(size, &data);
-  if (NS_FAILED(rv))
-    return rv;
-
   JSContext* cx = aContext->GetNativeContext();
-  JSXDRState *xdr = JS_XDRNewMem(cx, JSXDR_DECODE);
-  if (!xdr) {
-    rv = NS_ERROR_OUT_OF_MEMORY;
-  } else {
-    xdr->userdata = static_cast<void*>(aStream);
-    JSAutoRequest ar(cx);
-    JS_XDRMemSetData(xdr, data, size);
-
-    if (!JS_XDRFunctionObject(xdr, aFunctionObject)) {
-      rv = NS_ERROR_FAILURE;
-    }
-
-    uint32_t junk;
-    data = static_cast<char*>(JS_XDRMemGetData(xdr, &junk));
-    JS_XDRMemSetData(xdr, NULL, 0);
-    JS_XDRDestroy(xdr);
-  }
-
-  nsMemory::Free(data);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return rv;
+  return nsContentUtils::XPConnect()->ReadFunction(aStream, cx, aFunctionObjectp);
 }
--- a/content/xslt/src/base/txExpandedNameMap.h
+++ b/content/xslt/src/base/txExpandedNameMap.h
@@ -97,28 +97,26 @@ protected:
 
         bool next()
         {
             return ++mCurrentPos < mMap.mItems.Length();
         }
 
         const txExpandedName key()
         {
-            NS_ASSERTION(mCurrentPos >= 0 &&
-                         mCurrentPos < mMap.mItems.Length(),
+            NS_ASSERTION(mCurrentPos < mMap.mItems.Length(),
                          "invalid position in txExpandedNameMap::iterator");
             return txExpandedName(mMap.mItems[mCurrentPos].mNamespaceID,
                                   mMap.mItems[mCurrentPos].mLocalName);
         }
 
     protected:
         void* itemValue()
         {
-            NS_ASSERTION(mCurrentPos >= 0 &&
-                         mCurrentPos < mMap.mItems.Length(),
+            NS_ASSERTION(mCurrentPos < mMap.mItems.Length(),
                          "invalid position in txExpandedNameMap::iterator");
             return mMap.mItems[mCurrentPos].mValue;
         }
 
     private:
         txExpandedNameMap_base& mMap;
         PRUint32 mCurrentPos;
     };
--- a/dom/base/Makefile.in
+++ b/dom/base/Makefile.in
@@ -108,16 +108,17 @@ EXPORTS = \
   nsWindowMemoryReporter.h \
   $(NULL)
 
 EXPORTS_NAMESPACES = mozilla/dom
 EXPORTS_mozilla/dom = \
   DOMError.h \
   DOMRequest.h \
   StructuredCloneTags.h \
+  ScreenOrientation.h \
   $(NULL)
 
 CPPSRCS =			\
 	nsBarProps.cpp          \
 	nsDOMException.cpp 	\
 	nsDOMWindowUtils.cpp 	\
 	nsJSEnvironment.cpp	\
 	nsJSTimeoutHandler.cpp	\
new file mode 100644
--- /dev/null
+++ b/dom/base/ScreenOrientation.h
@@ -0,0 +1,59 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_ScreenOrientation_h
+#define mozilla_dom_ScreenOrientation_h
+
+namespace mozilla {
+namespace dom {
+
+enum ScreenOrientation {
+  eScreenOrientation_Current            = 0,
+  eScreenOrientation_PortraitPrimary    = 1,  // 00000001
+  eScreenOrientation_PortraitSecondary  = 2,  // 00000010
+  eScreenOrientation_Portrait           = 3,  // 00000011
+  eScreenOrientation_LandscapePrimary   = 4,  // 00000100
+  eScreenOrientation_LandscapeSecondary = 8,  // 00001000
+  eScreenOrientation_Landscape          = 12, // 00001100
+  eScreenOrientation_EndGuard
+};
+
+/**
+ * ScreenOrientationWrapper is a class wrapping ScreenOrientation so it can be
+ * used with Observer<T> which is taking a class, not an enum.
+ * C++11 should make this useless.
+ */
+class ScreenOrientationWrapper {
+public:
+  ScreenOrientationWrapper()
+    : orientation(eScreenOrientation_Current)
+  {}
+
+  ScreenOrientationWrapper(ScreenOrientation aOrientation)
+    : orientation(aOrientation)
+  {}
+
+  ScreenOrientation orientation;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+namespace IPC {
+
+/**
+ * Screen orientation serializer.
+ * Note that technically, 5, 6, 7, 9, 10 and 11 are illegal values but will
+ * not make the serializer to fail. We might want to write our own serializer.
+ */
+template <>
+struct ParamTraits<mozilla::dom::ScreenOrientation>
+  : public EnumSerializer<mozilla::dom::ScreenOrientation,
+                          mozilla::dom::eScreenOrientation_Current,
+                          mozilla::dom::eScreenOrientation_EndGuard>
+{};
+
+} // namespace IPC
+
+#endif // mozilla_dom_ScreenOrientation_h
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -34,17 +34,18 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/Util.h"
-#include "SmsFilter.h" // On top because it includes basictypes.h.
+// On top because they include basictypes.h:
+#include "SmsFilter.h"
 
 #ifdef XP_WIN
 #undef GetClassName
 #endif
 
 // JavaScript includes
 #include "jsapi.h"
 #include "jsfriendapi.h"
@@ -2470,16 +2471,17 @@ nsDOMClassInfo::Init()
 
   DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(Performance, nsIDOMPerformance,
                                         !nsGlobalWindow::HasPerformanceSupport())
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformance)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(Screen, nsIDOMScreen)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMScreen)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(DOMConstructor, nsIDOMDOMConstructor)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
@@ -4063,16 +4065,17 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozSmsCursor, nsIDOMMozSmsCursor)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsCursor)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozConnection, nsIDOMMozConnection)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozConnection)
+     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(CSSFontFaceStyleDecl,
                                       nsIDOMCSSStyleDeclaration)
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -1955,18 +1955,22 @@ nsFocusManager::SendFocusOrBlurEvent(PRU
 void
 nsFocusManager::ScrollIntoView(nsIPresShell* aPresShell,
                                nsIContent* aContent,
                                PRUint32 aFlags)
 {
   // if the noscroll flag isn't set, scroll the newly focused element into view
   if (!(aFlags & FLAG_NOSCROLL))
     aPresShell->ScrollContentIntoView(aContent,
-                                      NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,
-                                      NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,
+                                      nsIPresShell::ScrollAxis(
+                                        nsIPresShell::SCROLL_MINIMUM,
+                                        nsIPresShell::SCROLL_IF_NOT_VISIBLE),
+                                      nsIPresShell::ScrollAxis(
+                                        nsIPresShell::SCROLL_MINIMUM,
+                                        nsIPresShell::SCROLL_IF_NOT_VISIBLE),
                                       nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 }
 
 
 void
 nsFocusManager::RaiseWindow(nsPIDOMWindow* aWindow)
 {
   // don't raise windows that are already raised or are in the process of
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -59,16 +59,22 @@
 #include "nsHistory.h"
 #include "nsPerformance.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsBarProps.h"
 #include "nsDOMStorage.h"
 #include "nsDOMOfflineResourceList.h"
 #include "nsDOMError.h"
 
+#ifdef XP_WIN
+#ifdef GetClassName
+#undef GetClassName
+#endif // GetClassName
+#endif // XP_WIN
+
 // Helper Classes
 #include "nsXPIDLString.h"
 #include "nsJSUtils.h"
 #include "prmem.h"
 #include "jsapi.h"              // for JSAutoRequest
 #include "jsdbgapi.h"           // for JS_ClearWatchPointsForObject
 #include "jsfriendapi.h"        // for JS_GetGlobalForFrame
 #include "nsReadableUtils.h"
@@ -1301,16 +1307,20 @@ nsGlobalWindow::FreeInnerObjects()
   mLocation = nsnull;
   mHistory = nsnull;
 
   if (mNavigator) {
     mNavigator->Invalidate();
     mNavigator = nsnull;
   }
 
+  if (mScreen) {
+    mScreen = nsnull;
+  }
+
   if (mDocument) {
     NS_ASSERTION(mDoc, "Why is mDoc null?");
 
     // Remember the document's principal.
     mDocumentPrincipal = mDoc->NodePrincipal();
   }
 
 #ifdef DEBUG
@@ -2443,18 +2453,16 @@ nsGlobalWindow::SetDocShell(nsIDocShell*
   }
 
   mDocShell = aDocShell;        // Weak Reference
 
   NS_ASSERTION(!mNavigator, "Non-null mNavigator in outer window!");
 
   if (mFrames)
     mFrames->SetDocShell(aDocShell);
-  if (mScreen)
-    mScreen->SetDocShell(aDocShell);
 
   if (!mDocShell) {
     MaybeForgiveSpamCount();
     CleanUp(false);
   } else {
     // Get our enclosing chrome shell and retrieve its global window impl, so
     // that we can do some forwarding to the chrome document.
     nsCOMPtr<nsIDOMEventTarget> chromeEventHandler;
@@ -2952,24 +2960,24 @@ nsGlobalWindow::GetNavigator(nsIDOMNavig
   NS_ADDREF(*aNavigator = mNavigator);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScreen(nsIDOMScreen** aScreen)
 {
-  FORWARD_TO_OUTER(GetScreen, (aScreen), NS_ERROR_NOT_INITIALIZED);
+  FORWARD_TO_INNER(GetScreen, (aScreen), NS_ERROR_NOT_INITIALIZED);
 
   *aScreen = nsnull;
 
-  if (!mScreen && mDocShell) {
-    mScreen = new nsScreen(mDocShell);
+  if (!mScreen) {
+    mScreen = nsScreen::Create(this);
     if (!mScreen) {
-      return NS_ERROR_OUT_OF_MEMORY;
+      return NS_ERROR_UNEXPECTED;
     }
   }
 
   NS_IF_ADDREF(*aScreen = mScreen);
 
   return NS_OK;
 }
 
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -73,17 +73,16 @@
 #include "nsXPCOMCIDInternal.h"
 #include "nsIXULRuntime.h"
 
 #include "nsDOMClassInfo.h"
 #include "xpcpublic.h"
 
 #include "jsdbgapi.h"           // for JS_ClearWatchPointsForObject
 #include "jswrapper.h"
-#include "jsxdrapi.h"
 #include "nsIArray.h"
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
 #include "nsDOMScriptObjectHolder.h"
 #include "prmem.h"
 #include "WrapperFactory.h"
 #include "nsGlobalWindow.h"
 #include "nsScriptNameSpaceManager.h"
@@ -1960,129 +1959,33 @@ nsJSContext::BindCompiledEventHandler(ns
 
   return rv;
 }
 
 // serialization
 nsresult
 nsJSContext::Serialize(nsIObjectOutputStream* aStream, JSScript* aScriptObject)
 {
-    if (!aScriptObject)
-        return NS_ERROR_FAILURE;
-
-    nsresult rv;
-
-    JSContext* cx = mContext;
-    JSXDRState *xdr = ::JS_XDRNewMem(cx, JSXDR_ENCODE);
-    if (! xdr)
-        return NS_ERROR_OUT_OF_MEMORY;
-    xdr->userdata = (void*) aStream;
-
-    JSAutoRequest ar(cx);
-    if (! ::JS_XDRScript(xdr, &aScriptObject)) {
-        rv = NS_ERROR_FAILURE;  // likely to be a principals serialization error
-    } else {
-        // Get the encoded JSXDRState data and write it.  The JSXDRState owns
-        // this buffer memory and will free it beneath ::JS_XDRDestroy.
-        //
-        // If an XPCOM object needs to be written in the midst of the JS XDR
-        // encoding process, the C++ code called back from the JS engine (e.g.,
-        // nsEncodeJSPrincipals in caps/src/nsJSPrincipals.cpp) will flush data
-        // from the JSXDRState to aStream, then write the object, then return
-        // to JS XDR code with xdr reset so new JS data is encoded at the front
-        // of the xdr's data buffer.
-        //
-        // However many XPCOM objects are interleaved with JS XDR data in the
-        // stream, when control returns here from ::JS_XDRScript, we'll have
-        // one last buffer of data to write to aStream.
-
-        uint32_t size;
-        const char* data = reinterpret_cast<const char*>
-                                           (::JS_XDRMemGetData(xdr, &size));
-        NS_ASSERTION(data, "no decoded JSXDRState data!");
-
-        rv = aStream->Write32(size);
-        if (NS_SUCCEEDED(rv))
-            rv = aStream->WriteBytes(data, size);
-    }
-
-    ::JS_XDRDestroy(xdr);
-    if (NS_FAILED(rv)) return rv;
-
-    return rv;
+  if (!aScriptObject)
+    return NS_ERROR_FAILURE;
+
+  return nsContentUtils::XPConnect()->WriteScript(aStream, mContext, aScriptObject);
 }
 
 nsresult
 nsJSContext::Deserialize(nsIObjectInputStream* aStream,
                          nsScriptObjectHolder<JSScript>& aResult)
 {
-    NS_TIME_FUNCTION_MIN(1.0);
-
-    PRUint32 size;
-    nsresult rv = aStream->Read32(&size);
-    if (NS_FAILED(rv)) return rv;
-
-    char* data;
-    rv = aStream->ReadBytes(size, &data);
-    if (NS_FAILED(rv)) return rv;
-
-    JSContext* cx = mContext;
-
-    JSXDRState *xdr = ::JS_XDRNewMem(cx, JSXDR_DECODE);
-    JSScript *result = nsnull;
-    if (! xdr) {
-        rv = NS_ERROR_OUT_OF_MEMORY;
-    } else {
-        xdr->userdata = (void*) aStream;
-        JSAutoRequest ar(cx);
-        ::JS_XDRMemSetData(xdr, data, size);
-
-        if (! ::JS_XDRScript(xdr, &result)) {
-            rv = NS_ERROR_FAILURE;  // principals deserialization error?
-        }
-
-        // Update data in case ::JS_XDRScript called back into C++ code to
-        // read an XPCOM object.
-        //
-        // In that case, the serialization process must have flushed a run
-        // of counted bytes containing JS data at the point where the XPCOM
-        // object starts, after which an encoding C++ callback from the JS
-        // XDR code must have written the XPCOM object directly into the
-        // nsIObjectOutputStream.
-        //
-        // The deserialization process will XDR-decode counted bytes up to
-        // but not including the XPCOM object, then call back into C++ to
-        // read the object, then read more counted bytes and hand them off
-        // to the JSXDRState, so more JS data can be decoded.
-        //
-        // This interleaving of JS XDR data and XPCOM object data may occur
-        // several times beneath the call to ::JS_XDRScript, above.  At the
-        // end of the day, we need to free (via nsMemory) the data owned by
-        // the JSXDRState.  So we steal it back, nulling xdr's buffer so it
-        // doesn't get passed to ::JS_free by ::JS_XDRDestroy.
-
-        uint32_t junk;
-        data = (char*) ::JS_XDRMemGetData(xdr, &junk);
-        if (data)
-            ::JS_XDRMemSetData(xdr, NULL, 0);
-        ::JS_XDRDestroy(xdr);
-    }
-
-    // If data is null now, it must have been freed while deserializing an
-    // XPCOM object (e.g., a principal) beneath ::JS_XDRScript.
-    if (data)
-        nsMemory::Free(data);
-    NS_ASSERTION(aResult.getScriptTypeID()==JAVASCRIPT,
-                 "Expecting JS script object holder");
-
-    // Now that we've cleaned up, handle the case when rv is a failure
-    // code, which could happen for all sorts of reasons above.
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    return aResult.set(result);
+  NS_TIME_FUNCTION_MIN(1.0);
+  
+  JSScript *script;
+  nsresult rv = nsContentUtils::XPConnect()->ReadScript(aStream, mContext, &script);
+  if (NS_FAILED(rv)) return rv;
+    
+  return aResult.set(script);
 }
 
 nsIScriptGlobalObject *
 nsJSContext::GetGlobalObject()
 {
   JSObject *global = ::JS_GetGlobalObject(mContext);
 
   if (!global) {
--- a/dom/base/nsScreen.cpp
+++ b/dom/base/nsScreen.cpp
@@ -42,69 +42,133 @@
 #include "nsPresContext.h"
 #include "nsCOMPtr.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsLayoutUtils.h"
 #include "nsContentUtils.h"
 #include "mozilla/Preferences.h"
+#include "nsDOMEvent.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 /* static */ bool nsScreen::sInitialized = false;
 /* static */ bool nsScreen::sAllowScreenEnabledProperty = false;
 /* static */ bool nsScreen::sAllowScreenBrightnessProperty = false;
 
+namespace {
+
+bool
+IsChromeType(nsIDocShell *aDocShell)
+{
+  nsCOMPtr<nsIDocShellTreeItem> ds = do_QueryInterface(aDocShell);
+  if (!ds) {
+    return false;
+  }
+
+  PRInt32 itemType;
+  ds->GetItemType(&itemType);
+  return itemType == nsIDocShellTreeItem::typeChrome;
+}
+
+} // anonymous namespace
+
 /* static */ void
 nsScreen::Initialize()
 {
   MOZ_ASSERT(!sInitialized);
   sInitialized = true;
   Preferences::AddBoolVarCache(&sAllowScreenEnabledProperty,
                                "dom.screenEnabledProperty.enabled");
   Preferences::AddBoolVarCache(&sAllowScreenBrightnessProperty,
                                "dom.screenBrightnessProperty.enabled");
 }
 
-//
-//  Screen class implementation
-//
-nsScreen::nsScreen(nsIDocShell* aDocShell)
-  : mDocShell(aDocShell)
+/* static */ already_AddRefed<nsScreen>
+nsScreen::Create(nsPIDOMWindow* aWindow)
 {
   if (!sInitialized) {
     Initialize();
   }
+
+  if (!aWindow->GetDocShell()) {
+    return nsnull;
+  }
+
+  nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aWindow);
+  NS_ENSURE_TRUE(sgo, nsnull);
+
+  nsRefPtr<nsScreen> screen = new nsScreen();
+  screen->BindToOwner(aWindow);
+  screen->mIsChrome = IsChromeType(aWindow->GetDocShell());
+
+  hal::RegisterScreenOrientationObserver(screen);
+  hal::GetCurrentScreenOrientation(&(screen->mOrientation));
+
+  return screen.forget();
+}
+
+nsScreen::nsScreen()
+{
 }
 
 nsScreen::~nsScreen()
 {
+  hal::UnregisterScreenOrientationObserver(this);
 }
 
 
 DOMCI_DATA(Screen, nsScreen)
 
+NS_IMPL_CYCLE_COLLECTION_CLASS(nsScreen)
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsScreen,
+                                                  nsDOMEventTargetHelper)
+  NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(mozorientationchange)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsScreen,
+                                                nsDOMEventTargetHelper)
+  NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(mozorientationchange)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
 // QueryInterface implementation for nsScreen
-NS_INTERFACE_MAP_BEGIN(nsScreen)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsScreen)
   NS_INTERFACE_MAP_ENTRY(nsIDOMScreen)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMScreen)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Screen)
-NS_INTERFACE_MAP_END
+NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
 
+NS_IMPL_ADDREF_INHERITED(nsScreen, nsDOMEventTargetHelper)
+NS_IMPL_RELEASE_INHERITED(nsScreen, nsDOMEventTargetHelper)
 
-NS_IMPL_ADDREF(nsScreen)
-NS_IMPL_RELEASE(nsScreen)
+NS_IMPL_EVENT_HANDLER(nsScreen, mozorientationchange)
 
+bool
+nsScreen::IsWhiteListed() {
+  if (mIsChrome) {
+    return true;
+  }
 
-NS_IMETHODIMP
-nsScreen::SetDocShell(nsIDocShell* aDocShell)
-{
-   mDocShell = aDocShell; // Weak Reference
-   return NS_OK;
+  if (!GetOwner()) {
+    return false;
+  }
+
+  nsCOMPtr<nsIDocument> doc = do_GetInterface(GetOwner()->GetDocShell());
+  if (!doc) {
+    return false;
+  }
+
+  nsIPrincipal *principal = doc->NodePrincipal();
+  nsCOMPtr<nsIURI> principalURI;
+  principal->GetURI(getter_AddRefs(principalURI));
+  return nsContentUtils::URIIsChromeOrInPref(principalURI,
+                                             "dom.mozScreenWhitelist");
 }
 
 NS_IMETHODIMP
 nsScreen::GetTop(PRInt32* aTop)
 {
   nsRect rect;
   nsresult rv = GetRect(rect);
 
@@ -215,17 +279,17 @@ nsScreen::GetAvailTop(PRInt32* aAvailTop
   *aAvailTop = rect.y;
 
   return rv;
 }
 
 nsDeviceContext*
 nsScreen::GetDeviceContext()
 {
-  return nsLayoutUtils::GetDeviceContextForScreenInfo(mDocShell);
+  return nsLayoutUtils::GetDeviceContextForScreenInfo(GetOwner());
 }
 
 nsresult
 nsScreen::GetRect(nsRect& aRect)
 {
   nsDeviceContext *context = GetDeviceContext();
 
   if (!context) {
@@ -256,85 +320,116 @@ nsScreen::GetAvailRect(nsRect& aRect)
   aRect.x = nsPresContext::AppUnitsToIntCSSPixels(aRect.x);
   aRect.y = nsPresContext::AppUnitsToIntCSSPixels(aRect.y);
   aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
   aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
 
   return NS_OK;
 }
 
-namespace {
-
-bool IsWhiteListed(nsIDocShell *aDocShell) {
-  nsCOMPtr<nsIDocShellTreeItem> ds = do_QueryInterface(aDocShell);
-  if (!ds) {
-    return false;
-  }
-
-  PRInt32 itemType;
-  ds->GetItemType(&itemType);
-  if (itemType == nsIDocShellTreeItem::typeChrome) {
-    return true;
-  }
-
-  nsCOMPtr<nsIDocument> doc = do_GetInterface(aDocShell);
-  nsIPrincipal *principal = doc->NodePrincipal();
-
-  nsCOMPtr<nsIURI> principalURI;
-  principal->GetURI(getter_AddRefs(principalURI));
-  if (nsContentUtils::URIIsChromeOrInPref(principalURI,
-                                          "dom.mozScreenWhitelist")) {
-    return true;
-  }
-
-  return false;
-}
-
-} // anonymous namespace
-
 nsresult
 nsScreen::GetMozEnabled(bool *aEnabled)
 {
-  if (!sAllowScreenEnabledProperty || !IsWhiteListed(mDocShell)) {
+  if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
     *aEnabled = true;
     return NS_OK;
   }
 
   *aEnabled = hal::GetScreenEnabled();
   return NS_OK;
 }
 
 nsresult
 nsScreen::SetMozEnabled(bool aEnabled)
 {
-  if (!sAllowScreenEnabledProperty || !IsWhiteListed(mDocShell)) {
+  if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
     return NS_OK;
   }
 
   // TODO bug 707589: When the screen's state changes, all visible windows
   // should fire a visibility change event.
   hal::SetScreenEnabled(aEnabled);
   return NS_OK;
 }
 
 nsresult
 nsScreen::GetMozBrightness(double *aBrightness)
 {
-  if (!sAllowScreenEnabledProperty || !IsWhiteListed(mDocShell)) {
+  if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
     *aBrightness = 1;
     return NS_OK;
   }
 
   *aBrightness = hal::GetScreenBrightness();
   return NS_OK;
 }
 
 nsresult
 nsScreen::SetMozBrightness(double aBrightness)
 {
-  if (!sAllowScreenEnabledProperty || !IsWhiteListed(mDocShell)) {
+  if (!sAllowScreenEnabledProperty || !IsWhiteListed()) {
     return NS_OK;
   }
 
   NS_ENSURE_TRUE(0 <= aBrightness && aBrightness <= 1, NS_ERROR_INVALID_ARG);
   hal::SetScreenBrightness(aBrightness);
   return NS_OK;
 }
+
+void
+nsScreen::Notify(const ScreenOrientationWrapper& aOrientation)
+{
+  ScreenOrientation previousOrientation = mOrientation;
+  mOrientation = aOrientation.orientation;
+
+  NS_ASSERTION(mOrientation != eScreenOrientation_Current &&
+               mOrientation != eScreenOrientation_EndGuard &&
+               mOrientation != eScreenOrientation_Portrait &&
+               mOrientation != eScreenOrientation_Landscape,
+               "Invalid orientation value passed to notify method!");
+
+  if (mOrientation != previousOrientation) {
+    // TODO: use an helper method, see bug 720768.
+    nsRefPtr<nsDOMEvent> event = new nsDOMEvent(nsnull, nsnull);
+    nsresult rv = event->InitEvent(NS_LITERAL_STRING("mozorientationchange"), false, false);
+    if (NS_FAILED(rv)) {
+      return;
+    }
+
+    rv = event->SetTrusted(true);
+    if (NS_FAILED(rv)) {
+      return;
+    }
+
+    bool dummy;
+    rv = DispatchEvent(event, &dummy);
+    if (NS_FAILED(rv)) {
+      return;
+    }
+  }
+}
+
+NS_IMETHODIMP
+nsScreen::GetMozOrientation(nsAString& aOrientation)
+{
+  switch (mOrientation) {
+    case eScreenOrientation_Current:
+    case eScreenOrientation_EndGuard:
+    case eScreenOrientation_Portrait:
+    case eScreenOrientation_Landscape:
+      NS_ASSERTION(false, "Shouldn't be used when getting value!");
+      return NS_ERROR_FAILURE;
+    case eScreenOrientation_PortraitPrimary:
+      aOrientation.AssignLiteral("portrait-primary");
+      break;
+    case eScreenOrientation_PortraitSecondary:
+      aOrientation.AssignLiteral("portrait-secondary");
+      break;
+    case eScreenOrientation_LandscapePrimary:
+      aOrientation.AssignLiteral("landscape-primary");
+      break;
+    case eScreenOrientation_LandscapeSecondary:
+      aOrientation.AssignLiteral("landscape-secondary");
+      break;
+  }
+
+  return NS_OK;
+}
--- a/dom/base/nsScreen.h
+++ b/dom/base/nsScreen.h
@@ -32,45 +32,65 @@
  * 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 nsScreen_h___
 #define nsScreen_h___
 
+#include "mozilla/Hal.h"
 #include "nsIDOMScreen.h"
 #include "nsISupports.h"
 #include "nsIScriptContext.h"
 #include "nsCOMPtr.h"
+#include "mozilla/dom/ScreenOrientation.h"
+#include "nsDOMEventTargetHelper.h"
+#include "mozilla/Observer.h"
 
 class nsIDocShell;
 class nsDeviceContext;
 struct nsRect;
 
 // Script "screen" object
-class nsScreen : public nsIDOMScreen
+class nsScreen : public nsDOMEventTargetHelper
+               , public nsIDOMScreen
+               , public mozilla::hal::ScreenOrientationObserver
 {
 public:
-  nsScreen(nsIDocShell* aDocShell);
-  virtual ~nsScreen();
+  static already_AddRefed<nsScreen> Create(nsPIDOMWindow* aWindow);
 
-  NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
+  void Invalidate();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMSCREEN
+  NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
+
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen,
+                                           nsDOMEventTargetHelper)
+
+  void Notify(const mozilla::dom::ScreenOrientationWrapper& aOrientation);
 
 protected:
   nsDeviceContext* GetDeviceContext();
   nsresult GetRect(nsRect& aRect);
   nsresult GetAvailRect(nsRect& aRect);
 
-  nsIDocShell* mDocShell; // Weak Reference
+  bool mIsChrome;
+
+  mozilla::dom::ScreenOrientation mOrientation;
 
 private:
+  nsScreen();
+  virtual ~nsScreen();
+
   static bool sInitialized;
   static bool sAllowScreenEnabledProperty;
   static bool sAllowScreenBrightnessProperty;
 
   static void Initialize();
+
+  bool IsWhiteListed();
+
+  NS_DECL_EVENT_HANDLER(mozorientationchange)
 };
 
 #endif /* nsScreen_h___ */
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -511,18 +511,17 @@ GenerateRequest(IDBObjectStore* aObjectS
                             aObjectStore->Transaction());
 }
 
 JSClass gDummyPropClass = {
   "dummy", 0,
   JS_PropertyStub,  JS_PropertyStub,
   JS_PropertyStub,  JS_StrictPropertyStub,
   JS_EnumerateStub, JS_ResolveStub,
-  JS_ConvertStub, JS_FinalizeStub,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  JS_ConvertStub
 };
 
 } // anonymous namespace
 
 // static
 already_AddRefed<IDBObjectStore>
 IDBObjectStore::Create(IDBTransaction* aTransaction,
                        ObjectStoreInfo* aStoreInfo,
@@ -2471,17 +2470,17 @@ class ThreadLocalJSRuntime
     }
   }
 };
 
 JSClass ThreadLocalJSRuntime::sGlobalClass = {
   "IndexedDBTransactionThreadGlobal",
   JSCLASS_GLOBAL_FLAGS,
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
+  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub
 };
 
 CreateIndexHelper::CreateIndexHelper(IDBTransaction* aTransaction,
                                      IDBIndex* aIndex)
   : AsyncConnectionHelper(aTransaction, nsnull), mIndex(aIndex)
 {
   if (sTLSIndex == BAD_TLS_INDEX) {
     PR_NewThreadPrivateIndex(&sTLSIndex, DestroyTLSEntry);
--- a/dom/interfaces/base/Makefile.in
+++ b/dom/interfaces/base/Makefile.in
@@ -86,8 +86,10 @@ XPIDLSRCS =					\
 	nsIDOMGlobalPropertyInitializer.idl	\
 	nsIStructuredCloneContainer.idl		\
 	nsIDOMPerformance.idl			\
 	nsIDOMPerformanceTiming.idl		\
 	nsIDOMPerformanceNavigation.idl		\
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
+
+XPIDL_FLAGS += -I$(topsrcdir)/dom/interfaces/events/
--- a/dom/interfaces/base/nsIDOMScreen.idl
+++ b/dom/interfaces/base/nsIDOMScreen.idl
@@ -32,20 +32,20 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "domstubs.idl"
+#include "nsIDOMEventTarget.idl"
 
-[scriptable, uuid(4507e43f-097c-452a-bfc4-dbb99748f6fd)]
-interface nsIDOMScreen : nsISupports
+[scriptable, uuid(6366afc9-0072-4231-a4ec-98cd65f350ef)]
+interface nsIDOMScreen : nsIDOMEventTarget
 {
   readonly attribute long             top;
   readonly attribute long             left;
   readonly attribute long             width;
   readonly attribute long             height;
   readonly attribute long             pixelDepth;
   readonly attribute long             colorDepth;
   readonly attribute long             availWidth;
@@ -70,9 +70,18 @@ interface nsIDOMScreen : nsISupports
    * If you write a value of X into this attribute, the attribute may not have
    * the same value X when you later read it.  Most screens don't support as
    * many different brightness levels as there are doubles between 0 and 1, so
    * we may reduce the value's precision before storing it.
    *
    * @throw NS_ERROR_INVALID_ARG if brightness is not in the range [0, 1].
    */
   attribute double mozBrightness;
+
+  /**
+   * Returns the current screen orientation.
+   * Can be: landscape-primary, landscape-secondary,
+   *         portrait-primary or portrait-secondary.
+   */
+  readonly attribute DOMString       mozOrientation;
+
+  attribute nsIDOMEventListener      onmozorientationchange;
 };
--- a/dom/network/tests/test_network_basics.html
+++ b/dom/network/tests/test_network_basics.html
@@ -20,16 +20,18 @@ function checkInterface(aInterface) {
 }
 
 ok('mozConnection' in navigator, "navigator.mozConnection should exist");
 
 ok(navigator.mozConnection, "navigator.mozConnection returns an object");
 
 ok(navigator.mozConnection instanceof MozConnection,
    "navigator.mozConnection is a MozConnection object");
+ok(navigator.mozConnection instanceof EventTarget,
+   "navigator.mozConnection is a EventTarget object");
 
 checkInterface("Connection");
 
 ok('bandwidth' in navigator.mozConnection,
    "bandwidth should be a Connection attribute");
 is(navigator.mozConnection.bandwidth, Infinity,
    "By default connection.bandwidth is equals to Infinity");
 
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -1799,17 +1799,17 @@ bool nsPluginInstanceOwner::AddPluginVie
                             aRect.height);
 #endif
 
   return true;
 }
 
 void nsPluginInstanceOwner::RemovePluginView()
 {
-  if (!mInstance || !mObjectFrame)
+  if (!mInstance)
     return;
 
   void* surface = mInstance->GetJavaSurface();
   if (!surface)
     return;
 
   JNIEnv* env = GetJNIForThread();
   if (!env)
--- a/dom/workers/EventTarget.cpp
+++ b/dom/workers/EventTarget.cpp
@@ -54,18 +54,17 @@ USING_WORKERS_NAMESPACE
 using mozilla::dom::workers::events::EventTarget;
 
 namespace {
 
 #define DECL_EVENTTARGET_CLASS(_varname, _name) \
   JSClass _varname = { \
     _name, 0, \
     JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, \
-    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, \
-    JSCLASS_NO_OPTIONAL_MEMBERS \
+    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub \
   };
 
 DECL_EVENTTARGET_CLASS(gClass, "EventTarget")
 DECL_EVENTTARGET_CLASS(gMainThreadClass, "WorkerEventTarget")
 
 #undef DECL_EVENTTARGET_CLASS
 
 inline
--- a/dom/workers/Events.cpp
+++ b/dom/workers/Events.cpp
@@ -360,18 +360,17 @@ private:
   }
 };
 
 #define DECL_EVENT_CLASS(_varname, _name) \
   JSClass _varname = { \
     _name, \
     JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT), \
     JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, \
-    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize, \
-    JSCLASS_NO_OPTIONAL_MEMBERS \
+    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize \
   };
 
 DECL_EVENT_CLASS(Event::sClass, "Event")
 DECL_EVENT_CLASS(Event::sMainRuntimeClass, "WorkerEvent")
 
 #undef DECL_EVENT_CLASS
 
 JSPropertySpec Event::sProperties[] = {
@@ -613,18 +612,17 @@ private:
   }
 };
 
 #define DECL_MESSAGEEVENT_CLASS(_varname, _name) \
   JSClass _varname = { \
     _name, \
     JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT), \
     JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, \
-    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize, \
-    JSCLASS_NO_OPTIONAL_MEMBERS \
+    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize \
   };
 
 DECL_MESSAGEEVENT_CLASS(MessageEvent::sClass, "MessageEvent")
 DECL_MESSAGEEVENT_CLASS(MessageEvent::sMainRuntimeClass, "WorkerMessageEvent")
 
 #undef DECL_MESSAGEEVENT_CLASS
 
 JSPropertySpec MessageEvent::sProperties[] = {
@@ -799,18 +797,17 @@ private:
   }
 };
 
 #define DECL_ERROREVENT_CLASS(_varname, _name) \
   JSClass _varname = { \
     _name, \
     JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT), \
     JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, \
-    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize, \
-    JSCLASS_NO_OPTIONAL_MEMBERS \
+    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize \
   };
 
 DECL_ERROREVENT_CLASS(ErrorEvent::sClass, "ErrorEvent")
 DECL_ERROREVENT_CLASS(ErrorEvent::sMainRuntimeClass, "WorkerErrorEvent")
 
 #undef DECL_ERROREVENT_CLASS
 
 JSPropertySpec ErrorEvent::sProperties[] = {
@@ -979,18 +976,17 @@ private:
     return true;
   }
 };
 
 JSClass ProgressEvent::sClass = {
   "ProgressEvent",
   JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT),
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize
 };
 
 JSPropertySpec ProgressEvent::sProperties[] = {
   { "lengthComputable", SLOT_lengthComputable, PROPERTY_FLAGS, GetProperty,
     js_GetterOnlyPropertyStub },
   { "loaded", SLOT_loaded, PROPERTY_FLAGS, GetProperty, 
     js_GetterOnlyPropertyStub },
   { "total", SLOT_total, PROPERTY_FLAGS, GetProperty, 
--- a/dom/workers/Exceptions.cpp
+++ b/dom/workers/Exceptions.cpp
@@ -181,18 +181,17 @@ private:
     return true;
   }
 };
 
 JSClass DOMException::sClass = {
   "DOMException",
   JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT),
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize
 };
 
 JSPropertySpec DOMException::sProperties[] = {
   { "code", SLOT_code, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
   { "name", SLOT_name, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
   { 0, 0, 0, NULL, NULL }
 };
 
@@ -353,18 +352,17 @@ private:
     return true;
   }
 };
 
 JSClass FileException::sClass = {
   "FileException",
   JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT),
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize
 };
 
 JSPropertySpec FileException::sProperties[] = {
   { "code", SLOT_code, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
   { "name", SLOT_name, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
   { 0, 0, 0, NULL, NULL }
 };
 
--- a/dom/workers/File.cpp
+++ b/dom/workers/File.cpp
@@ -214,18 +214,17 @@ private:
     return true;
   }
 };
 
 JSClass Blob::sClass = {
   "Blob",
   JSCLASS_HAS_PRIVATE,
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize
 };
 
 JSPropertySpec Blob::sProperties[] = {
   { "size", 0, PROPERTY_FLAGS, GetSize, js_GetterOnlyPropertyStub },
   { "type", 0, PROPERTY_FLAGS, GetType, js_GetterOnlyPropertyStub },
   { 0, 0, 0, NULL, NULL }
 };
 
@@ -365,18 +364,17 @@ private:
     return true;
   }
 };
 
 JSClass File::sClass = {
   "File",
   JSCLASS_HAS_PRIVATE,
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize
 };
 
 JSPropertySpec File::sProperties[] = {
   { "name", 0, PROPERTY_FLAGS, GetName, js_GetterOnlyPropertyStub },
   { "mozFullPath", 0, PROPERTY_FLAGS, GetMozFullPath,
     js_GetterOnlyPropertyStub },
   { 0, 0, 0, NULL, NULL }
 };
--- a/dom/workers/FileReaderSync.cpp
+++ b/dom/workers/FileReaderSync.cpp
@@ -338,18 +338,17 @@ private:
     return true;
   }
 };
 
 JSClass FileReaderSync::sClass = {
   "FileReaderSync",
   JSCLASS_HAS_PRIVATE,
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize
 };
 
 JSFunctionSpec FileReaderSync::sFunctions[] = {
   JS_FN("readAsArrayBuffer", ReadAsArrayBuffer, 1, FUNCTION_FLAGS),
   JS_FN("readAsBinaryString", ReadAsBinaryString, 1, FUNCTION_FLAGS),
   JS_FN("readAsText", ReadAsText, 1, FUNCTION_FLAGS),
   JS_FN("readAsDataURL", ReadAsDataURL, 1, FUNCTION_FLAGS),
   JS_FS_END
--- a/dom/workers/Location.cpp
+++ b/dom/workers/Location.cpp
@@ -178,18 +178,17 @@ private:
     return true;
   }
 };
 
 JSClass Location::sClass = {
   "WorkerLocation",
   JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT),
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize
 };
 
 JSPropertySpec Location::sProperties[] = {
   { "href", SLOT_href, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
   { "protocol", SLOT_protocol, PROPERTY_FLAGS, GetProperty, 
     js_GetterOnlyPropertyStub },
   { "host", SLOT_host, PROPERTY_FLAGS, GetProperty, js_GetterOnlyPropertyStub },
   { "hostname", SLOT_hostname, PROPERTY_FLAGS, GetProperty, 
--- a/dom/workers/Navigator.cpp
+++ b/dom/workers/Navigator.cpp
@@ -167,18 +167,17 @@ private:
     return true;
   }
 };
 
 JSClass Navigator::sClass = {
   "WorkerNavigator",
   JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT),
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize
 };
 
 JSPropertySpec Navigator::sProperties[] = {
   { "appName", SLOT_appName, PROPERTY_FLAGS, GetProperty, 
     js_GetterOnlyPropertyStub },
   { "appVersion", SLOT_appVersion, PROPERTY_FLAGS, GetProperty, 
     js_GetterOnlyPropertyStub },
   { "platform", SLOT_platform, PROPERTY_FLAGS, GetProperty, 
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -587,18 +587,17 @@ private:
     return true;
   }
 };
 
 JSClass WorkerGlobalScope::sClass = {
   "WorkerGlobalScope",
   0,
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
-  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
-  JSCLASS_NO_OPTIONAL_MEMBERS
+  JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub
 };
 
 JSPropertySpec WorkerGlobalScope::sProperties[] = {
   { "location", SLOT_location, PROPERTY_FLAGS, GetLocation, 
     js_GetterOnlyPropertyStub },
   { sEventStrings[STRING_onerror], STRING_onerror, PROPERTY_FLAGS,
     GetOnErrorListener, SetOnErrorListener },
   { sEventStrings[STRING_onclose], STRING_onclose, PROPERTY_FLAGS,
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -336,16 +336,23 @@ nsEditor::PostCreate()
 
     nsIMEStateManager::OnTextStateBlur(pc, nsnull);
     nsIMEStateManager::OnTextStateFocus(pc, focusedContent);
 
     nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(focusedContent);
     if (target) {
       InitializeSelection(target);
     }
+
+    // If the text control gets reframed during focus, Focus() would not be
+    // called, so take a chance here to see if we need to spell check the text
+    // control.
+    nsEditorEventListener* listener =
+      reinterpret_cast<nsEditorEventListener*> (mEventListener.get());
+    listener->SpellCheckIfNeeded();
   }
   return NS_OK;
 }
 
 /* virtual */
 void
 nsEditor::CreateEventListeners()
 {
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -900,27 +900,19 @@ nsEditorEventListener::Focus(nsIDOMEvent
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_ARG(aEvent);
 
   // Don't turn on selection and caret when the editor is disabled.
   if (mEditor->IsDisabled()) {
     return NS_OK;
   }
-  
-  // If the spell check skip flag is still enabled from creation time,
-  // disable it because focused editors are allowed to spell check.
-  PRUint32 currentFlags = 0;
-  mEditor->GetFlags(&currentFlags);
-  if(currentFlags & nsIPlaintextEditor::eEditorSkipSpellCheck)
-  {
-    currentFlags ^= nsIPlaintextEditor::eEditorSkipSpellCheck;
-    mEditor->SetFlags(currentFlags);
-  }
-  
+
+  // Spell check a textarea the first time that it is focused.
+  SpellCheckIfNeeded();
 
   nsCOMPtr<nsIDOMEventTarget> target;
   aEvent->GetTarget(getter_AddRefs(target));
   nsCOMPtr<nsINode> node = do_QueryInterface(target);
   NS_ENSURE_TRUE(node, NS_ERROR_UNEXPECTED);
 
   // If the traget is a document node but it's not editable, we should ignore
   // it because actual focused element's event is going to come.
@@ -1008,8 +1000,21 @@ nsEditorEventListener::Blur(nsIDOMEvent*
     }
 
     selCon->RepaintSelection(nsISelectionController::SELECTION_NORMAL);
   }
 
   return NS_OK;
 }
 
+void
+nsEditorEventListener::SpellCheckIfNeeded() {
+  // If the spell check skip flag is still enabled from creation time,
+  // disable it because focused editors are allowed to spell check.
+  PRUint32 currentFlags = 0;
+  mEditor->GetFlags(&currentFlags);
+  if(currentFlags & nsIPlaintextEditor::eEditorSkipSpellCheck)
+  {
+    currentFlags ^= nsIPlaintextEditor::eEditorSkipSpellCheck;
+    mEditor->SetFlags(currentFlags);
+  }
+}
+
--- a/editor/libeditor/base/nsEditorEventListener.h
+++ b/editor/libeditor/base/nsEditorEventListener.h
@@ -81,16 +81,18 @@ public:
   NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent);
   NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent);
   NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
   NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent) { return NS_OK; }
   NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
   NS_IMETHOD Focus(nsIDOMEvent* aEvent);
   NS_IMETHOD Blur(nsIDOMEvent* aEvent);
 
+  void SpellCheckIfNeeded();
+
 protected:
   nsresult InstallToEditor();
   void UninstallFromEditor();
 
   bool CanDrop(nsIDOMDragEvent* aEvent);
   nsresult DragEnter(nsIDOMDragEvent* aDragEvent);
   nsresult DragOver(nsIDOMDragEvent* aDragEvent);
   nsresult DragExit(nsIDOMDragEvent* aDragEvent);
--- a/embedding/android/GeckoAppShell.java
+++ b/embedding/android/GeckoAppShell.java
@@ -1100,19 +1100,23 @@ public class GeckoAppShell
         GeckoApp.mFullscreen = fullscreen;
 
         // force a reconfiguration to hide/show the system bar
         GeckoApp.mAppContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
         GeckoApp.mAppContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
         GeckoApp.mAppContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
     }
 
-    public static String showFilePicker(String aFilters) {
+    public static String showFilePickerForExtensions(String aExtensions) {
         return GeckoApp.mAppContext.
-            showFilePicker(getMimeTypeFromExtensions(aFilters));
+            showFilePicker(getMimeTypeFromExtensions(aExtensions));
+    }
+
+    public static String showFilePickerForMimeType(String aMimeType) {
+        return GeckoApp.mAppContext.showFilePicker(aMimeType);
     }
 
     public static void performHapticFeedback(boolean aIsLongPress) {
         GeckoApp.surfaceView.
             performHapticFeedback(aIsLongPress ?
                                   HapticFeedbackConstants.LONG_PRESS :
                                   HapticFeedbackConstants.VIRTUAL_KEY);
     }
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -50,16 +50,17 @@
 struct _cairo_surface;
 typedef _cairo_surface cairo_surface_t;
 
 struct _cairo_scaled_font;
 typedef _cairo_scaled_font cairo_scaled_font_t;
 
 struct ID3D10Device1;
 struct ID3D10Texture2D;
+struct IDWriteRenderingParams;
 
 namespace mozilla {
 namespace gfx {
 
 class SourceSurface;
 class DataSourceSurface;
 class DrawTarget;
 
@@ -483,16 +484,33 @@ public:
    * passed in.
    */
   virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget) = 0;
 
 protected:
   ScaledFont() {}
 };
 
+/* This class is designed to allow passing additional glyph rendering
+ * parameters to the glyph drawing functions. This is an empty wrapper class
+ * merely used to allow holding on to and passing around platform specific
+ * parameters. This is because different platforms have unique rendering
+ * parameters.
+ */
+class GlyphRenderingOptions : public RefCounted<GlyphRenderingOptions>
+{
+public:
+  virtual ~GlyphRenderingOptions() {}
+
+  virtual FontType GetType() const = 0;
+
+protected:
+  GlyphRenderingOptions() {}
+};
+
 /* This is the main class used for all the drawing. It is created through the
  * factory and accepts drawing commands. The results of drawing to a target
  * may be used either through a Snapshot or by flushing the target and directly
  * accessing the backing store a DrawTarget was created with.
  */
 class DrawTarget : public RefCounted<DrawTarget>
 {
 public:
@@ -635,17 +653,18 @@ public:
                     const DrawOptions &aOptions = DrawOptions()) = 0;
 
   /*
    * Fill a series of clyphs on the draw target with a certain source pattern.
    */
   virtual void FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
-                          const DrawOptions &aOptions = DrawOptions()) = 0;
+                          const DrawOptions &aOptions = DrawOptions(),
+                          const GlyphRenderingOptions *aRenderingOptions = NULL) = 0;
 
   /*
    * This takes a source pattern and a mask, and composites the source pattern
    * onto the destination surface using the alpha channel of the mask pattern
    * as a mask for the operation.
    *
    * aSource Source pattern
    * aMask Mask pattern
@@ -801,16 +820,19 @@ public:
     CreateDataSourceSurfaceFromData(unsigned char *aData, int32_t aStride,
                                     const IntSize &aSize, SurfaceFormat aFormat);
 
 #ifdef WIN32
   static TemporaryRef<DrawTarget> CreateDrawTargetForD3D10Texture(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
   static void SetDirect3D10Device(ID3D10Device1 *aDevice);
   static ID3D10Device1 *GetDirect3D10Device();
 
+  static TemporaryRef<GlyphRenderingOptions>
+    CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams);
+
 private:
   static ID3D10Device1 *mD3D10Device;
 #endif
 };
 
 }
 }
 
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -694,17 +694,18 @@ DrawTargetCG::Fill(const Path *aPath, co
   }
 
   fixer.Fix(mCg);
   CGContextRestoreGState(mCg);
 }
 
 
 void
-DrawTargetCG::FillGlyphs(ScaledFont *aFont, const GlyphBuffer &aBuffer, const Pattern &aPattern, const DrawOptions &aDrawOptions)
+DrawTargetCG::FillGlyphs(ScaledFont *aFont, const GlyphBuffer &aBuffer, const Pattern &aPattern, const DrawOptions &aDrawOptions,
+                         const GlyphRenderingOptions*)
 {
   MarkChanged();
 
   assert(aBuffer.mNumGlyphs);
   CGContextSaveGState(mCg);
 
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
   UnboundnessFixer fixer;
--- a/gfx/2d/DrawTargetCG.h
+++ b/gfx/2d/DrawTargetCG.h
@@ -142,17 +142,17 @@ public:
 
   virtual void DrawSurfaceWithShadow(SourceSurface *, const Point &, const Color &, const Point &, Float, CompositionOp);
   virtual void ClearRect(const Rect &);
   virtual void CopySurface(SourceSurface *, const IntRect&, const IntPoint&);
   virtual void StrokeRect(const Rect &, const Pattern &, const StrokeOptions&, const DrawOptions&);
   virtual void StrokeLine(const Point &, const Point &, const Pattern &, const StrokeOptions &, const DrawOptions &);
   virtual void Stroke(const Path *, const Pattern &, const StrokeOptions &, const DrawOptions &);
   virtual void Fill(const Path *, const Pattern &, const DrawOptions &);
-  virtual void FillGlyphs(ScaledFont *, const GlyphBuffer&, const Pattern &, const DrawOptions &);
+  virtual void FillGlyphs(ScaledFont *, const GlyphBuffer&, const Pattern &, const DrawOptions &, const GlyphRenderingOptions *);
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void PushClip(const Path *);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
   virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromNativeSurface(const NativeSurface&) const { return NULL;}
   virtual TemporaryRef<DrawTarget> CreateSimilarDrawTarget(const IntSize &, SurfaceFormat) const;
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -582,17 +582,18 @@ DrawTargetCairo::Fill(const Path *aPath,
 
   DrawPattern(aPattern, StrokeOptions(), aOptions, DRAW_FILL);
 }
 
 void
 DrawTargetCairo::FillGlyphs(ScaledFont *aFont,
                             const GlyphBuffer &aBuffer,
                             const Pattern &aPattern,
-                            const DrawOptions &aOptions)
+                            const DrawOptions &aOptions,
+                            const GlyphRenderingOptions*)
 {
   AutoPrepareForDrawing prep(this, mContext);
 
   ScaledFontBase* scaledFont = static_cast<ScaledFontBase*>(aFont);
   cairo_set_scaled_font(mContext, scaledFont->GetCairoScaledFont());
 
   cairo_pattern_t* pat = GfxPatternToCairoPattern(aPattern, aOptions.mAlpha);
   cairo_set_source(mContext, pat);
--- a/gfx/2d/DrawTargetCairo.h
+++ b/gfx/2d/DrawTargetCairo.h
@@ -120,17 +120,18 @@ public:
 
   virtual void Fill(const Path *aPath,
                     const Pattern &aPattern,
                     const DrawOptions &aOptions = DrawOptions());
 
   virtual void FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
-                          const DrawOptions &aOptions);
+                          const DrawOptions &aOptions,
+                          const GlyphRenderingOptions *aRenderingOptions = NULL);
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
 
   virtual void PushClip(const Path *aPath);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
 
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -875,29 +875,43 @@ DrawTargetD2D::Fill(const Path *aPath,
   }
   FinalizeRTForOperation(aOptions.mCompositionOp, aPattern, bounds);
 }
 
 void
 DrawTargetD2D::FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
-                          const DrawOptions &aOptions)
+                          const DrawOptions &aOptions,
+                          const GlyphRenderingOptions* aRenderOptions)
 {
   if (aFont->GetType() != FONT_DWRITE) {
     gfxDebug() << *this << ": Ignoring drawing call for incompatible font.";
     return;
   }
 
   ScaledFontDWrite *font = static_cast<ScaledFontDWrite*>(aFont);
 
   ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
 
   PrepareForDrawing(rt);
 
+  IDWriteRenderingParams *params = NULL;
+  if (aRenderOptions) {
+    if (aRenderOptions->GetType() != FONT_DWRITE) {
+    gfxDebug() << *this << ": Ignoring incompatible GlyphRenderingOptions.";
+    // This should never happen.
+    MOZ_ASSERT(false);
+    } else {
+      params = static_cast<const GlyphRenderingOptionsDWrite*>(aRenderOptions)->mParams;
+    }
+  }
+
+  rt->SetTextRenderingParams(params);
+
   RefPtr<ID2D1Brush> brush = CreateBrushForPattern(aPattern, aOptions.mAlpha);
 
   DWRITE_GLYPH_RUN glyphRun;
 
   glyphRun.bidiLevel = 0;
   glyphRun.fontEmSize = font->mSize;
   glyphRun.isSideways = FALSE;
   glyphRun.fontFace = font->mFontFace;
--- a/gfx/2d/DrawTargetD2D.h
+++ b/gfx/2d/DrawTargetD2D.h
@@ -112,17 +112,18 @@ public:
                       const StrokeOptions &aStrokeOptions = StrokeOptions(),
                       const DrawOptions &aOptions = DrawOptions());
   virtual void Fill(const Path *aPath,
                     const Pattern &aPattern,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
-                          const DrawOptions &aOptions = DrawOptions());
+                          const DrawOptions &aOptions = DrawOptions(),
+                          const GlyphRenderingOptions *aRenderingOptions = NULL);
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void PushClip(const Path *aPath);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
 
   virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -538,17 +538,18 @@ DrawTargetSkia::Fill(const Path *aPath,
 
   mCanvas->drawPath(skiaPath->GetPath(), paint.mPaint);
 }
 
 void
 DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
                            const GlyphBuffer &aBuffer,
                            const Pattern &aPattern,
-                           const DrawOptions &aOptions)
+                           const DrawOptions &aOptions,
+                           const GlyphRenderingOptions*)
 {
   if (aFont->GetType() != FONT_MAC && aFont->GetType() != FONT_SKIA) {
     return;
   }
 
   MarkChanged();
 
   ScaledFontBase* skiaFont = static_cast<ScaledFontBase*>(aFont);
--- a/gfx/2d/DrawTargetSkia.h
+++ b/gfx/2d/DrawTargetSkia.h
@@ -93,17 +93,18 @@ public:
                       const StrokeOptions &aStrokeOptions = StrokeOptions(),
                       const DrawOptions &aOptions = DrawOptions());
   virtual void Fill(const Path *aPath,
                     const Pattern &aPattern,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
-                          const DrawOptions &aOptions = DrawOptions());
+                          const DrawOptions &aOptions = DrawOptions(),
+                          const GlyphRenderingOptions *aRenderingOptions = NULL);
   virtual void Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions = DrawOptions());
   virtual void PushClip(const Path *aPath);
   virtual void PushClipRect(const Rect& aRect);
   virtual void PopClip();
   virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                             const IntSize &aSize,
--- a/gfx/2d/Factory.cpp
+++ b/gfx/2d/Factory.cpp
@@ -212,16 +212,25 @@ Factory::SetDirect3D10Device(ID3D10Devic
 }
 
 ID3D10Device1*
 Factory::GetDirect3D10Device()
 {
   return mD3D10Device;
 }
 
+TemporaryRef<GlyphRenderingOptions>
+Factory::CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams)
+{
+  RefPtr<GlyphRenderingOptions> options =
+    new GlyphRenderingOptionsDWrite(aParams);
+
+  return options;
+}
+
 #endif // XP_WIN
 
 #ifdef USE_CAIRO
 TemporaryRef<DrawTarget>
 Factory::CreateDrawTargetForCairoSurface(cairo_surface_t* aSurface)
 {
   RefPtr<DrawTargetCairo> newTarget = new DrawTargetCairo();
   if (newTarget->Init(aSurface)) {
--- a/gfx/2d/ScaledFontDWrite.h
+++ b/gfx/2d/ScaledFontDWrite.h
@@ -58,12 +58,28 @@ public:
 
 private:
   friend class DrawTargetD2D;
 
   RefPtr<IDWriteFontFace> mFontFace;
   Float mSize;
 };
 
+class GlyphRenderingOptionsDWrite : public GlyphRenderingOptions
+{
+public:
+  GlyphRenderingOptionsDWrite(IDWriteRenderingParams *aParams)
+    : mParams(aParams)
+  {
+  }
+
+  virtual FontType GetType() const { return FONT_DWRITE; }
+
+private:
+  friend class DrawTargetD2D;
+
+  RefPtr<IDWriteRenderingParams> mParams;