Merge inbound to m-c a=merge
authorWes Kocher <wkocher@mozilla.com>
Tue, 16 Sep 2014 17:06:43 -0700
changeset 228880 8252eae8278ccca736f4de4ca6ed999b8a33a0f1
parent 228793 49ef7b18963dd0722004be46d4bb14ac12aa3c1c (current diff)
parent 228879 bb579e3de64b12ee5628c327619440ab9aaed1c2 (diff)
child 228881 641d450532be536fcbb30f0fb31593ad7707a696
child 228902 f1473daa91addda691dcc12fb05de0803ed193cc
child 228939 18a5272e3ddc6909d18c7c1f57b2b0d35fcd5502
child 228986 490b8cb576f95cf0f0a41c4529536d860b60933e
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone35.0a1
first release with
nightly linux32
8252eae8278c / 35.0a1 / 20140917030202 / files
nightly linux64
8252eae8278c / 35.0a1 / 20140917030202 / files
nightly mac
8252eae8278c / 35.0a1 / 20140917030202 / files
nightly win32
8252eae8278c / 35.0a1 / 20140917030202 / files
nightly win64
8252eae8278c / 35.0a1 / 20140917030202 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to m-c a=merge
dom/bindings/BindingUtils.h
intl/uconv/tests/unit/test_decode_CP850.js
intl/uconv/tests/unit/test_decode_CP852.js
intl/uconv/tests/unit/test_decode_CP855.js
intl/uconv/tests/unit/test_decode_CP857.js
intl/uconv/tests/unit/test_decode_CP862.js
intl/uconv/tests/unit/test_decode_CP864.js
intl/uconv/tests/unit/test_encode_CP850.js
intl/uconv/tests/unit/test_encode_CP852.js
intl/uconv/tests/unit/test_encode_CP855.js
intl/uconv/tests/unit/test_encode_CP857.js
intl/uconv/tests/unit/test_encode_CP862.js
intl/uconv/tests/unit/test_encode_CP864.js
intl/uconv/ucvibm/cp1125.uf
intl/uconv/ucvibm/cp1125.ut
intl/uconv/ucvibm/cp1131.uf
intl/uconv/ucvibm/cp1131.ut
intl/uconv/ucvibm/cp850.uf
intl/uconv/ucvibm/cp850.ut
intl/uconv/ucvibm/cp852.uf
intl/uconv/ucvibm/cp852.ut
intl/uconv/ucvibm/cp855.uf
intl/uconv/ucvibm/cp855.ut
intl/uconv/ucvibm/cp857.uf
intl/uconv/ucvibm/cp857.ut
intl/uconv/ucvibm/cp862.uf
intl/uconv/ucvibm/cp862.ut
intl/uconv/ucvibm/cp864.uf
intl/uconv/ucvibm/cp864.ut
intl/uconv/ucvibm/cp869.uf
intl/uconv/ucvibm/cp869.ut
intl/uconv/ucvibm/nsCP850ToUnicode.cpp
intl/uconv/ucvibm/nsCP850ToUnicode.h
intl/uconv/ucvibm/nsCP852ToUnicode.cpp
intl/uconv/ucvibm/nsCP852ToUnicode.h
intl/uconv/ucvibm/nsCP855ToUnicode.cpp
intl/uconv/ucvibm/nsCP855ToUnicode.h
intl/uconv/ucvibm/nsCP857ToUnicode.cpp
intl/uconv/ucvibm/nsCP857ToUnicode.h
intl/uconv/ucvibm/nsCP862ToUnicode.cpp
intl/uconv/ucvibm/nsCP862ToUnicode.h
intl/uconv/ucvibm/nsCP864ToUnicode.cpp
intl/uconv/ucvibm/nsCP864ToUnicode.h
intl/uconv/ucvibm/nsUCvIBMCID.h
intl/uconv/ucvibm/nsUnicodeToCP850.cpp
intl/uconv/ucvibm/nsUnicodeToCP850.h
intl/uconv/ucvibm/nsUnicodeToCP852.cpp
intl/uconv/ucvibm/nsUnicodeToCP852.h
intl/uconv/ucvibm/nsUnicodeToCP855.cpp
intl/uconv/ucvibm/nsUnicodeToCP855.h
intl/uconv/ucvibm/nsUnicodeToCP857.cpp
intl/uconv/ucvibm/nsUnicodeToCP857.h
intl/uconv/ucvibm/nsUnicodeToCP862.cpp
intl/uconv/ucvibm/nsUnicodeToCP862.h
intl/uconv/ucvibm/nsUnicodeToCP864.cpp
intl/uconv/ucvibm/nsUnicodeToCP864.h
layout/base/FrameLayerBuilder.cpp
modules/libpref/init/all.js
--- a/accessible/atk/nsMaiInterfaceAction.cpp
+++ b/accessible/atk/nsMaiInterfaceAction.cpp
@@ -16,21 +16,17 @@
 using namespace mozilla::a11y;
 
 extern "C" {
 
 static gboolean
 doActionCB(AtkAction *aAction, gint aActionIndex)
 {
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
-  if (!accWrap)
-    return FALSE;
- 
-  nsresult rv = accWrap->DoAction(aActionIndex);
-  return (NS_FAILED(rv)) ? FALSE : TRUE;
+  return accWrap && accWrap->DoAction(aActionIndex);
 }
 
 static gint
 getActionCountCB(AtkAction *aAction)
 {
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
   return accWrap ? accWrap->ActionCount() : 0;
 }
@@ -46,24 +42,23 @@ getActionDescriptionCB(AtkAction *aActio
   nsresult rv = accWrap->GetActionDescription(aActionIndex, description);
   NS_ENSURE_SUCCESS(rv, nullptr);
   return AccessibleWrap::ReturnString(description);
 }
 
 static const gchar*
 getActionNameCB(AtkAction *aAction, gint aActionIndex)
 {
-    AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
-    if (!accWrap)
-        return nullptr;
+  AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
+  if (!accWrap)
+    return nullptr;
 
-    nsAutoString autoStr;
-    nsresult rv = accWrap->GetActionName(aActionIndex, autoStr);
-    NS_ENSURE_SUCCESS(rv, nullptr);
-    return AccessibleWrap::ReturnString(autoStr);
+  nsAutoString autoStr;
+  accWrap->ActionNameAt(aActionIndex, autoStr);
+  return AccessibleWrap::ReturnString(autoStr);
 }
 
 static const gchar*
 getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
 {
   AccessibleWrap* acc = GetAccessibleWrap(ATK_OBJECT(aAction));
   if (!acc)
     return nullptr;
--- a/accessible/atk/nsMaiInterfaceComponent.cpp
+++ b/accessible/atk/nsMaiInterfaceComponent.cpp
@@ -34,18 +34,18 @@ getExtentsCB(AtkComponent* aComponent, g
 
 static gboolean
 grabFocusCB(AtkComponent* aComponent)
 {
   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
   if (!accWrap)
     return FALSE;
 
-  nsresult rv = accWrap->TakeFocus();
-  return (NS_FAILED(rv)) ? FALSE : TRUE;
+  accWrap->TakeFocus();
+  return TRUE;
 }
 }
 
 AtkObject*
 refAccessibleAtPointHelper(AccessibleWrap* aAccWrap, gint aX, gint aY,
                            AtkCoordType aCoordType)
 {
   if (!aAccWrap || aAccWrap->IsDefunct() || nsAccUtils::MustPrune(aAccWrap))
@@ -75,33 +75,31 @@ getExtentsHelper(AccessibleWrap* aAccWra
                  gint* aX, gint* aY, gint* aWidth, gint* aHeight,
                  AtkCoordType aCoordType)
 {
   *aX = *aY = *aWidth = *aHeight = 0;
 
   if (!aAccWrap || aAccWrap->IsDefunct())
     return;
 
-  int32_t x = 0, y = 0, width = 0, height = 0;
-  // Returned in screen coordinates
-  nsresult rv = aAccWrap->GetBounds(&x, &y, &width, &height);
-  if (NS_FAILED(rv))
+  nsIntRect screenRect = aAccWrap->Bounds();
+  if (screenRect.IsEmpty())
     return;
 
   if (aCoordType == ATK_XY_WINDOW) {
     nsIntPoint winCoords =
       nsCoreUtils::GetScreenCoordsForWindow(aAccWrap->GetNode());
-    x -= winCoords.x;
-    y -= winCoords.y;
+    screenRect.x -= winCoords.x;
+    screenRect.y -= winCoords.y;
   }
 
-  *aX = x;
-  *aY = y;
-  *aWidth = width;
-  *aHeight = height;
+  *aX = screenRect.x;
+  *aY = screenRect.y;
+  *aWidth = screenRect.width;
+  *aHeight = screenRect.height;
 }
 
 void
 componentInterfaceInitCB(AtkComponentIface* aIface)
 {
   NS_ASSERTION(aIface, "Invalid Interface");
   if(MOZ_UNLIKELY(!aIface))
     return;
--- a/accessible/base/nsAccessiblePivot.cpp
+++ b/accessible/base/nsAccessiblePivot.cpp
@@ -579,22 +579,21 @@ nsAccessiblePivot::MoveToPoint(nsIAccess
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Ignore any matching nodes that were below this one
     if (filtered & nsIAccessibleTraversalRule::FILTER_IGNORE_SUBTREE)
       match = nullptr;
 
     // Match if no node below this is a match
     if ((filtered & nsIAccessibleTraversalRule::FILTER_MATCH) && !match) {
-      int32_t childX, childY, childWidth, childHeight;
-      child->GetBounds(&childX, &childY, &childWidth, &childHeight);
+      nsIntRect childRect = child->Bounds();
       // Double-check child's bounds since the deepest child may have been out
       // of bounds. This assures we don't return a false positive.
-      if (aX >= childX && aX < childX + childWidth &&
-          aY >= childY && aY < childY + childHeight)
+      if (aX >= childRect.x && aX < childRect.x + childRect.width &&
+          aY >= childRect.y && aY < childRect.y + childRect.height)
         match = child;
     }
 
     child = child->Parent();
   }
 
   if (match || !aIgnoreNoMatch)
     *aResult = MovePivotInternal(match, nsIAccessiblePivot::REASON_POINT,
--- a/accessible/generic/Accessible-inl.h
+++ b/accessible/generic/Accessible-inl.h
@@ -2,18 +2,19 @@
 /* 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 mozilla_a11y_Accessible_inl_h_
 #define mozilla_a11y_Accessible_inl_h_
 
-#include "Accessible.h"
+#include "DocAccessible.h"
 #include "ARIAMap.h"
+#include "nsCoreUtils.h"
 
 namespace mozilla {
 namespace a11y {
 
 inline mozilla::a11y::role
 Accessible::Role()
 {
   if (!mRoleMapEntry || mRoleMapEntry->roleRule != kUseMapRole)
@@ -54,12 +55,19 @@ inline bool
 Accessible::HasNumericValue() const
 {
   if (mStateFlags & eHasNumericValue)
     return true;
 
   return mRoleMapEntry && mRoleMapEntry->valueRule != eNoValue;
 }
 
+inline void
+Accessible::ScrollTo(uint32_t aHow) const
+{
+  if (mContent)
+    nsCoreUtils::ScrollTo(mDoc->PresShell(), mContent, aHow);
+}
+
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -6,22 +6,18 @@
 #include "Accessible-inl.h"
 
 #include "nsIXBLAccessible.h"
 
 #include "AccCollector.h"
 #include "AccGroupInfo.h"
 #include "AccIterator.h"
 #include "nsAccUtils.h"
-#include "nsAccessibleRelation.h"
 #include "nsAccessibilityService.h"
 #include "ApplicationAccessible.h"
-#include "nsCoreUtils.h"
-#include "nsIAccessibleRelation.h"
-#include "nsIAccessibleRole.h"
 #include "nsEventShell.h"
 #include "nsTextEquivUtils.h"
 #include "Relation.h"
 #include "Role.h"
 #include "RootAccessible.h"
 #include "States.h"
 #include "StyleInfo.h"
 #include "TableAccessible.h"
@@ -137,69 +133,16 @@ Accessible::Accessible(nsIContent* aCont
 #endif
 }
 
 Accessible::~Accessible()
 {
   NS_ASSERTION(!mDoc, "LastRelease was never called!?!");
 }
 
-NS_IMETHODIMP
-Accessible::GetDocument(nsIAccessibleDocument** aDocument)
-{
-  NS_ENSURE_ARG_POINTER(aDocument);
-
-  NS_IF_ADDREF(*aDocument = Document());
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Accessible::GetDOMNode(nsIDOMNode** aDOMNode)
-{
-  NS_ENSURE_ARG_POINTER(aDOMNode);
-  *aDOMNode = nullptr;
-
-  nsINode *node = GetNode();
-  if (node)
-    CallQueryInterface(node, aDOMNode);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Accessible::GetRootDocument(nsIAccessibleDocument** aRootDocument)
-{
-  NS_ENSURE_ARG_POINTER(aRootDocument);
-
-  NS_IF_ADDREF(*aRootDocument = RootAccessible());
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Accessible::GetLanguage(nsAString& aLanguage)
-{
-  Language(aLanguage);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Accessible::GetName(nsAString& aName)
-{
-  aName.Truncate();
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsAutoString name;
-  Name(name);
-  aName.Assign(name);
-
-  return NS_OK;
-}
-
 ENameValueFlag
 Accessible::Name(nsString& aName)
 {
   aName.Truncate();
 
   if (!HasOwnContent())
     return eNameOK;
 
@@ -242,29 +185,16 @@ Accessible::Name(nsString& aName)
   }
 
   if (nameFlag != eNoNameOnPurpose)
     aName.SetIsVoid(true);
 
   return nameFlag;
 }
 
-NS_IMETHODIMP
-Accessible::GetDescription(nsAString& aDescription)
-{
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsAutoString desc;
-  Description(desc);
-  aDescription.Assign(desc);
-
-  return NS_OK;
-}
-
 void
 Accessible::Description(nsString& aDescription)
 {
   // There are 4 conditions that make an accessible have no accDescription:
   // 1. it's a text node; or
   // 2. It has no DHTML describedby property
   // 3. it doesn't have an accName; or
   // 4. its title attribute already equals to its accName nsAutoString name;
@@ -313,28 +243,16 @@ Accessible::Description(nsString& aDescr
         if (nameFlag == eNameFromTooltip)
           aDescription.Truncate();
       }
     }
   }
   aDescription.CompressWhitespace();
 }
 
-NS_IMETHODIMP
-Accessible::GetAccessKey(nsAString& aAccessKey)
-{
-  aAccessKey.Truncate();
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  AccessKey().ToString(aAccessKey);
-  return NS_OK;
-}
-
 KeyBinding
 Accessible::AccessKey() const
 {
   if (!HasOwnContent())
     return KeyBinding();
 
   uint32_t key = nsCoreUtils::GetAccessKeyFor(mContent);
   if (!key && mContent->IsElement()) {
@@ -400,161 +318,22 @@ Accessible::AccessKey() const
 }
 
 KeyBinding
 Accessible::KeyboardShortcut() const
 {
   return KeyBinding();
 }
 
-NS_IMETHODIMP
-Accessible::GetParent(nsIAccessible** aParent)
-{
-  NS_ENSURE_ARG_POINTER(aParent);
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  NS_IF_ADDREF(*aParent = Parent());
-  return *aParent ? NS_OK : NS_ERROR_FAILURE;
-}
-
-  /* readonly attribute nsIAccessible nextSibling; */
-NS_IMETHODIMP
-Accessible::GetNextSibling(nsIAccessible** aNextSibling)
-{
-  NS_ENSURE_ARG_POINTER(aNextSibling);
-  *aNextSibling = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsresult rv = NS_OK;
-  NS_IF_ADDREF(*aNextSibling = GetSiblingAtOffset(1, &rv));
-  return rv;
-}
-
-  /* readonly attribute nsIAccessible previousSibling; */
-NS_IMETHODIMP
-Accessible::GetPreviousSibling(nsIAccessible ** aPreviousSibling)
-{
-  NS_ENSURE_ARG_POINTER(aPreviousSibling);
-  *aPreviousSibling = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsresult rv = NS_OK;
-  NS_IF_ADDREF(*aPreviousSibling = GetSiblingAtOffset(-1, &rv));
-  return rv;
-}
-
-  /* readonly attribute nsIAccessible firstChild; */
-NS_IMETHODIMP
-Accessible::GetFirstChild(nsIAccessible** aFirstChild)
-{
-  NS_ENSURE_ARG_POINTER(aFirstChild);
-  *aFirstChild = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  NS_IF_ADDREF(*aFirstChild = FirstChild());
-  return NS_OK;
-}
-
-  /* readonly attribute nsIAccessible lastChild; */
-NS_IMETHODIMP
-Accessible::GetLastChild(nsIAccessible** aLastChild)
-{
-  NS_ENSURE_ARG_POINTER(aLastChild);
-  *aLastChild = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  NS_IF_ADDREF(*aLastChild = LastChild());
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Accessible::GetChildAt(int32_t aChildIndex, nsIAccessible** aChild)
-{
-  NS_ENSURE_ARG_POINTER(aChild);
-  *aChild = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  // If child index is negative, then return last child.
-  // XXX: do we really need this?
-  if (aChildIndex < 0)
-    aChildIndex = ChildCount() - 1;
-
-  Accessible* child = GetChildAt(aChildIndex);
-  if (!child)
-    return NS_ERROR_INVALID_ARG;
-
-  NS_ADDREF(*aChild = child);
-  return NS_OK;
-}
-
-// readonly attribute nsIArray children;
-NS_IMETHODIMP
-Accessible::GetChildren(nsIArray** aOutChildren)
-{
-  NS_ENSURE_ARG_POINTER(aOutChildren);
-  *aOutChildren = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsresult rv = NS_OK;
-  nsCOMPtr<nsIMutableArray> children =
-    do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  uint32_t childCount = ChildCount();
-  for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
-    nsIAccessible* child = GetChildAt(childIdx);
-    children->AppendElement(child, false);
-  }
-
-  NS_ADDREF(*aOutChildren = children);
-  return NS_OK;
-}
-
 bool
 Accessible::CanHaveAnonChildren()
 {
   return true;
 }
 
-/* readonly attribute long childCount; */
-NS_IMETHODIMP
-Accessible::GetChildCount(int32_t* aChildCount)
-{
-  NS_ENSURE_ARG_POINTER(aChildCount);
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  *aChildCount = ChildCount();
-  return NS_OK;
-}
-
-/* readonly attribute long indexInParent; */
-NS_IMETHODIMP
-Accessible::GetIndexInParent(int32_t* aIndexInParent)
-{
-  NS_ENSURE_ARG_POINTER(aIndexInParent);
-
-  *aIndexInParent = IndexInParent();
-  return *aIndexInParent != -1 ? NS_OK : NS_ERROR_FAILURE;
-}
-
 void
 Accessible::TranslateString(const nsString& aKey, nsAString& aStringOut)
 {
   nsCOMPtr<nsIStringBundleService> stringBundleService =
     services::GetStringBundleService();
   if (!stringBundleService)
     return;
 
@@ -730,52 +509,39 @@ Accessible::NativelyUnavailable() const
 {
   if (mContent->IsHTML())
     return mContent->AsElement()->State().HasState(NS_EVENT_STATE_DISABLED);
 
   return mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
                                nsGkAtoms::_true, eCaseMatters);
 }
 
-  /* readonly attribute boolean focusedChild; */
-NS_IMETHODIMP
-Accessible::GetFocusedChild(nsIAccessible** aChild)
-{
-  NS_ENSURE_ARG_POINTER(aChild);
-  *aChild = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  NS_IF_ADDREF(*aChild = FocusedChild());
-  return NS_OK;
-}
-
 Accessible*
 Accessible::FocusedChild()
 {
   Accessible* focus = FocusMgr()->FocusedAccessible();
   if (focus && (focus == this || focus->Parent() == this))
     return focus;
 
   return nullptr;
 }
 
 Accessible*
 Accessible::ChildAtPoint(int32_t aX, int32_t aY,
                          EWhichChildAtPoint aWhichChild)
 {
   // If we can't find the point in a child, we will return the fallback answer:
   // we return |this| if the point is within it, otherwise nullptr.
-  int32_t x = 0, y = 0, width = 0, height = 0;
-  nsresult rv = GetBounds(&x, &y, &width, &height);
-  NS_ENSURE_SUCCESS(rv, nullptr);
+  nsIntRect rect = Bounds();
+  if (rect.IsEmpty())
+   return nullptr;
 
   Accessible* fallbackAnswer = nullptr;
-  if (aX >= x && aX < x + width && aY >= y && aY < y + height)
+  if (aX >= rect.x && aX < rect.x + rect.width &&
+      aY >= rect.y && aY < rect.y + rect.height)
     fallbackAnswer = this;
 
   if (nsAccUtils::MustPrune(this))  // Do not dig any further
     return fallbackAnswer;
 
   // Search an accessible at the given point starting from accessible document
   // because containing block (see CSS2) for out of flow element (for example,
   // absolutely positioned element) may be different from its DOM parent and
@@ -867,64 +633,33 @@ Accessible::ChildAtPoint(int32_t aX, int
   // point. Skip offscreen or invisible accessibles. This takes care of cases
   // where layout won't walk into things for us, such as image map areas and
   // sub documents (XXX: subdocuments should be handled by methods of
   // OuterDocAccessibles).
   uint32_t childCount = accessible->ChildCount();
   for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
     Accessible* child = accessible->GetChildAt(childIdx);
 
-    int32_t childX, childY, childWidth, childHeight;
-    child->GetBounds(&childX, &childY, &childWidth, &childHeight);
-    if (aX >= childX && aX < childX + childWidth &&
-        aY >= childY && aY < childY + childHeight &&
+    nsIntRect childRect = child->Bounds();
+    if (aX >= childRect.x && aX < childRect.x + childRect.width &&
+        aY >= childRect.y && aY < childRect.y + childRect.height &&
         (child->State() & states::INVISIBLE) == 0) {
 
       if (aWhichChild == eDeepestChild)
         return child->ChildAtPoint(aX, aY, eDeepestChild);
 
       return child;
     }
   }
 
   return accessible;
 }
 
-// nsIAccessible getChildAtPoint(in long x, in long y)
-NS_IMETHODIMP
-Accessible::GetChildAtPoint(int32_t aX, int32_t aY,
-                            nsIAccessible** aAccessible)
-{
-  NS_ENSURE_ARG_POINTER(aAccessible);
-  *aAccessible = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  NS_IF_ADDREF(*aAccessible = ChildAtPoint(aX, aY, eDirectChild));
-  return NS_OK;
-}
-
-// nsIAccessible getDeepestChildAtPoint(in long x, in long y)
-NS_IMETHODIMP
-Accessible::GetDeepestChildAtPoint(int32_t aX, int32_t aY,
-                                   nsIAccessible** aAccessible)
-{
-  NS_ENSURE_ARG_POINTER(aAccessible);
-  *aAccessible = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  NS_IF_ADDREF(*aAccessible = ChildAtPoint(aX, aY, eDeepestChild));
-  return NS_OK;
-}
-
-void
-Accessible::GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame)
+nsRect
+Accessible::RelativeBounds(nsIFrame** aBoundingFrame) const
 {
   nsIFrame* frame = GetFrame();
   if (frame && mContent) {
     bool* hasHitRegionRect = static_cast<bool*>(mContent->GetProperty(nsGkAtoms::hitregion));
 
     if (hasHitRegionRect && mContent->IsElement()) {
       // This is for canvas fallback content
       // Find a canvas frame the found hit region is relative to.
@@ -935,128 +670,100 @@ Accessible::GetBoundsRect(nsRect& aTotal
 
       // make the canvas the bounding frame
       if (canvasFrame) {
         *aBoundingFrame = canvasFrame;
         dom::HTMLCanvasElement *canvas =
           dom::HTMLCanvasElement::FromContent(canvasFrame->GetContent());
 
         // get the bounding rect of the hit region
+        nsRect bounds;
         if (canvas && canvas->CountContexts() &&
-          canvas->GetContextAtIndex(0)->GetHitRegionRect(mContent->AsElement(), aTotalBounds)) {
-          return;
+          canvas->GetContextAtIndex(0)->GetHitRegionRect(mContent->AsElement(), bounds)) {
+          return bounds;
         }
       }
     }
 
     *aBoundingFrame = nsLayoutUtils::GetContainingBlockForClientRect(frame);
-    aTotalBounds = nsLayoutUtils::
+    return nsLayoutUtils::
       GetAllInFlowRectsUnion(frame, *aBoundingFrame,
                              nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS);
   }
+
+  return nsRect();
 }
 
-/* void getBounds (out long x, out long y, out long width, out long height); */
-NS_IMETHODIMP
-Accessible::GetBounds(int32_t* aX, int32_t* aY,
-                      int32_t* aWidth, int32_t* aHeight)
+nsIntRect
+Accessible::Bounds() const
 {
-  NS_ENSURE_ARG_POINTER(aX);
-  *aX = 0;
-  NS_ENSURE_ARG_POINTER(aY);
-  *aY = 0;
-  NS_ENSURE_ARG_POINTER(aWidth);
-  *aWidth = 0;
-  NS_ENSURE_ARG_POINTER(aHeight);
-  *aHeight = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  // This routine will get the entire rectangle for all the frames in this node.
-  // -------------------------------------------------------------------------
-  //      Primary Frame for node
-  //  Another frame, same node                <- Example
-  //  Another frame, same node
-
-  nsRect unionRectTwips;
   nsIFrame* boundingFrame = nullptr;
-  GetBoundsRect(unionRectTwips, &boundingFrame);   // Unions up all primary frames for this node and all siblings after it
-  NS_ENSURE_STATE(boundingFrame);
-
+  nsRect unionRectTwips = RelativeBounds(&boundingFrame);
+  if (!boundingFrame)
+    return nsIntRect();
+
+  nsIntRect screenRect;
   nsPresContext* presContext = mDoc->PresContext();
-  *aX = presContext->AppUnitsToDevPixels(unionRectTwips.x);
-  *aY = presContext->AppUnitsToDevPixels(unionRectTwips.y);
-  *aWidth = presContext->AppUnitsToDevPixels(unionRectTwips.width);
-  *aHeight = presContext->AppUnitsToDevPixels(unionRectTwips.height);
-
-  // We have the union of the rectangle, now we need to put it in absolute screen coords
+  screenRect.x = presContext->AppUnitsToDevPixels(unionRectTwips.x);
+  screenRect.y = presContext->AppUnitsToDevPixels(unionRectTwips.y);
+  screenRect.width = presContext->AppUnitsToDevPixels(unionRectTwips.width);
+  screenRect.height = presContext->AppUnitsToDevPixels(unionRectTwips.height);
+
+  // We have the union of the rectangle, now we need to put it in absolute
+  // screen coords.
   nsIntRect orgRectPixels = boundingFrame->GetScreenRectInAppUnits().
     ToNearestPixels(presContext->AppUnitsPerDevPixel());
-  *aX += orgRectPixels.x;
-  *aY += orgRectPixels.y;
-
-  return NS_OK;
+  screenRect.x += orgRectPixels.x;
+  screenRect.y += orgRectPixels.y;
+
+  return screenRect;
 }
 
-NS_IMETHODIMP
+void
 Accessible::SetSelected(bool aSelect)
 {
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   if (!HasOwnContent())
-    return NS_OK;
+    return;
 
   Accessible* select = nsAccUtils::GetSelectableContainer(this, State());
   if (select) {
     if (select->State() & states::MULTISELECTABLE) {
       if (mRoleMapEntry) {
         if (aSelect) {
-          return mContent->SetAttr(kNameSpaceID_None,
-                                   nsGkAtoms::aria_selected,
-                                   NS_LITERAL_STRING("true"), true);
+          mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::aria_selected,
+                            NS_LITERAL_STRING("true"), true);
+        } else {
+          mContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::aria_selected, true);
         }
-        return mContent->UnsetAttr(kNameSpaceID_None,
-                                   nsGkAtoms::aria_selected, true);
       }
-
-      return NS_OK;
+      return;
     }
 
-    return aSelect ? TakeFocus() : NS_ERROR_FAILURE;
+    if (aSelect)
+      TakeFocus();
   }
-
-  return NS_OK;
 }
 
-NS_IMETHODIMP
+void
 Accessible::TakeSelection()
 {
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   Accessible* select = nsAccUtils::GetSelectableContainer(this, State());
   if (select) {
     if (select->State() & states::MULTISELECTABLE)
       select->UnselectAll();
-    return SetSelected(true);
+    SetSelected(true);
   }
-
-  return NS_ERROR_FAILURE;
 }
 
-NS_IMETHODIMP
+void
 Accessible::TakeFocus()
 {
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsIFrame *frame = GetFrame();
-  NS_ENSURE_STATE(frame);
+  nsIFrame* frame = GetFrame();
+  if (!frame)
+    return;
 
   nsIContent* focusContent = mContent;
 
   // If the accessible focus is managed by container widget then focus the
   // widget and set the accessible as its current item.
   if (!frame->IsFocusable()) {
     Accessible* widget = ContainerWidget();
     if (widget && widget->AreItemsOperable()) {
@@ -1068,18 +775,16 @@ Accessible::TakeFocus()
       }
     }
   }
 
   nsCOMPtr<nsIDOMElement> element(do_QueryInterface(focusContent));
   nsFocusManager* fm = nsFocusManager::GetFocusManager();
   if (fm)
     fm->SetFocus(element, 0);
-
-  return NS_OK;
 }
 
 void
 Accessible::XULElmName(DocAccessible* aDocument,
                        nsIContent* aElm, nsString& aName)
 {
   /**
    * 3 main cases for XUL Controls to be labeled
@@ -1168,44 +873,16 @@ Accessible::HandleAccEvent(AccEvent* aEv
   if (hasObservers) {
     nsCOMPtr<nsIAccessibleEvent> event = MakeXPCEvent(aEvent);
     return obsService->NotifyObservers(event, NS_ACCESSIBLE_EVENT_TOPIC, nullptr);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-Accessible::GetRole(uint32_t *aRole)
-{
-  NS_ENSURE_ARG_POINTER(aRole);
-  *aRole = nsIAccessibleRole::ROLE_NOTHING;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  *aRole = Role();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Accessible::GetAttributes(nsIPersistentProperties** aAttributes)
-{
-  NS_ENSURE_ARG_POINTER(aAttributes);
-  *aAttributes = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsCOMPtr<nsIPersistentProperties> attributes = Attributes();
-  attributes.swap(*aAttributes);
-
-  return NS_OK;
-}
-
 already_AddRefed<nsIPersistentProperties>
 Accessible::Attributes()
 {
   nsCOMPtr<nsIPersistentProperties> attributes = NativeAttributes();
   if (!HasOwnContent() || !mContent->IsElement())
     return attributes.forget();
 
   // 'xml-roles' attribute coming from ARIA.
@@ -1414,51 +1091,16 @@ Accessible::GroupPosition()
       if (groupPos.setSize == 0)
         groupPos.setSize = setSize;
     }
   }
 
   return groupPos;
 }
 
-NS_IMETHODIMP
-Accessible::ScriptableGroupPosition(int32_t* aGroupLevel,
-                                    int32_t* aSimilarItemsInGroup,
-                                    int32_t* aPositionInGroup)
-{
-  NS_ENSURE_ARG_POINTER(aGroupLevel);
-  *aGroupLevel = 0;
-
-  NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
-  *aSimilarItemsInGroup = 0;
-
-  NS_ENSURE_ARG_POINTER(aPositionInGroup);
-  *aPositionInGroup = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  GroupPos groupPos = GroupPosition();
-
-  *aGroupLevel = groupPos.level;
-  *aSimilarItemsInGroup = groupPos.setSize;
-  *aPositionInGroup = groupPos.posInSet;
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Accessible::GetState(uint32_t* aState, uint32_t* aExtraState)
-{
-  NS_ENSURE_ARG_POINTER(aState);
-
-  nsAccUtils::To32States(State(), aState, aExtraState);
-  return NS_OK;
-}
-
 uint64_t
 Accessible::State()
 {
   if (IsDefunct())
     return states::DEFUNCT;
 
   uint64_t state = NativeState();
   // Apply ARIA states to be sure accessible states will be overridden.
@@ -1610,29 +1252,16 @@ Accessible::ApplyARIAState(uint64_t* aSt
         uint64_t gridState = 0;
         grid->ApplyARIAState(&gridState);
         *aState |= (gridState & (states::READONLY | states::EDITABLE));
       }
     }
   }
 }
 
-NS_IMETHODIMP
-Accessible::GetValue(nsAString& aValue)
-{
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsAutoString value;
-  Value(value);
-  aValue.Assign(value);
-
-  return NS_OK;
-}
-
 void
 Accessible::Value(nsString& aValue)
 {
   if (!mRoleMapEntry)
     return;
 
   if (mRoleMapEntry->valueRule != eNoValue) {
     // aria-valuenow is a number, and aria-valuetext is the optional text
@@ -1722,34 +1351,16 @@ Accessible::SetCurValue(double aValue)
 
   nsAutoString strValue;
   strValue.AppendFloat(aValue);
 
   return NS_SUCCEEDED(
     mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::aria_valuenow, strValue, true));
 }
 
-/* void setName (in DOMString name); */
-NS_IMETHODIMP
-Accessible::SetName(const nsAString& aName)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-Accessible::GetKeyboardShortcut(nsAString& aKeyBinding)
-{
-  aKeyBinding.Truncate();
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  KeyboardShortcut().ToString(aKeyBinding);
-  return NS_OK;
-}
-
 role
 Accessible::ARIATransformRole(role aRole)
 {
   // XXX: these unfortunate exceptions don't fit into the ARIA table. This is
   // where the accessible role depends on both the role and ARIA state.
   if (aRole == roles::PUSHBUTTON) {
     if (nsAccUtils::HasDefinedARIAToken(mContent, nsGkAtoms::aria_pressed)) {
       // For simplicity, any existing pressed attribute except "" or "undefined"
@@ -1794,173 +1405,114 @@ Accessible::ARIATransformRole(role aRole
 }
 
 role
 Accessible::NativeRole()
 {
   return roles::NOTHING;
 }
 
-// readonly attribute uint8_t actionCount
-NS_IMETHODIMP
-Accessible::GetActionCount(uint8_t* aActionCount)
-{
-  NS_ENSURE_ARG_POINTER(aActionCount);
-  *aActionCount = 0;
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  *aActionCount = ActionCount();
-  return NS_OK;
-}
-
 uint8_t
 Accessible::ActionCount()
 {
   return GetActionRule() == eNoAction ? 0 : 1;
 }
 
-/* DOMString getAccActionName (in uint8_t index); */
-NS_IMETHODIMP
-Accessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+Accessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
 
   if (aIndex != 0)
-    return NS_ERROR_INVALID_ARG;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
+    return;
 
   uint32_t actionRule = GetActionRule();
 
  switch (actionRule) {
    case eActivateAction:
      aName.AssignLiteral("activate");
-     return NS_OK;
+     return;
 
    case eClickAction:
      aName.AssignLiteral("click");
-     return NS_OK;
+     return;
 
    case ePressAction:
      aName.AssignLiteral("press");
-     return NS_OK;
+     return;
 
    case eCheckUncheckAction:
    {
      uint64_t state = State();
      if (state & states::CHECKED)
        aName.AssignLiteral("uncheck");
      else if (state & states::MIXED)
        aName.AssignLiteral("cycle");
      else
        aName.AssignLiteral("check");
-     return NS_OK;
+     return;
    }
 
    case eJumpAction:
      aName.AssignLiteral("jump");
-     return NS_OK;
+     return;
 
    case eOpenCloseAction:
      if (State() & states::COLLAPSED)
        aName.AssignLiteral("open");
      else
        aName.AssignLiteral("close");
-     return NS_OK;
+     return;
 
    case eSelectAction:
      aName.AssignLiteral("select");
-     return NS_OK;
+     return;
 
    case eSwitchAction:
      aName.AssignLiteral("switch");
-     return NS_OK;
+     return;
 
    case eSortAction:
      aName.AssignLiteral("sort");
-     return NS_OK;
+     return;
 
    case eExpandAction:
      if (State() & states::COLLAPSED)
        aName.AssignLiteral("expand");
      else
        aName.AssignLiteral("collapse");
-     return NS_OK;
+     return;
   }
-
-  return NS_ERROR_INVALID_ARG;
 }
 
-// AString getActionDescription(in uint8_t index)
-NS_IMETHODIMP
-Accessible::GetActionDescription(uint8_t aIndex, nsAString& aDescription)
-{
-  // default to localized action name.
-  nsAutoString name;
-  nsresult rv = GetActionName(aIndex, name);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  TranslateString(name, aDescription);
-  return NS_OK;
-}
-
-// void doAction(in uint8_t index)
-NS_IMETHODIMP
+bool
 Accessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != 0)
-    return NS_ERROR_INVALID_ARG;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
+    return false;
 
   if (GetActionRule() != eNoAction) {
     DoCommand();
-    return NS_OK;
+    return true;
   }
 
-  return NS_ERROR_INVALID_ARG;
-}
-
-/* DOMString getHelp (); */
-NS_IMETHODIMP Accessible::GetHelp(nsAString& _retval)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
+  return false;
 }
 
 nsIContent*
 Accessible::GetAtomicRegion() const
 {
   nsIContent *loopContent = mContent;
   nsAutoString atomic;
   while (loopContent && !loopContent->GetAttr(kNameSpaceID_None, nsGkAtoms::aria_atomic, atomic))
     loopContent = loopContent->GetParent();
 
   return atomic.EqualsLiteral("true") ? loopContent : nullptr;
 }
 
-// nsIAccessible getRelationByType()
-NS_IMETHODIMP
-Accessible::GetRelationByType(uint32_t aType, nsIAccessibleRelation** aRelation)
-{
-  NS_ENSURE_ARG_POINTER(aRelation);
-  *aRelation = nullptr;
-
-  NS_ENSURE_ARG(aType <= static_cast<uint32_t>(RelationType::LAST));
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  Relation rel = RelationByType(static_cast<RelationType>(aType));
-  NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &rel));
-  return *aRelation ? NS_OK : NS_ERROR_FAILURE;
-}
-
 Relation
 Accessible::RelationByType(RelationType aType)
 {
   if (!HasOwnContent())
     return Relation();
 
   // Relationships are defined on the same content node that the role would be
   // defined on.
@@ -2162,74 +1714,16 @@ Accessible::RelationByType(RelationType 
     case RelationType::CONTAINING_APPLICATION:
       return Relation(ApplicationAcc());
 
     default:
       return Relation();
   }
 }
 
-NS_IMETHODIMP
-Accessible::GetRelations(nsIArray **aRelations)
-{
-  NS_ENSURE_ARG_POINTER(aRelations);
-  *aRelations = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsCOMPtr<nsIMutableArray> relations = do_CreateInstance(NS_ARRAY_CONTRACTID);
-  NS_ENSURE_TRUE(relations, NS_ERROR_OUT_OF_MEMORY);
-
-  static const uint32_t relationTypes[] = {
-    nsIAccessibleRelation::RELATION_LABELLED_BY,
-    nsIAccessibleRelation::RELATION_LABEL_FOR,
-    nsIAccessibleRelation::RELATION_DESCRIBED_BY,
-    nsIAccessibleRelation::RELATION_DESCRIPTION_FOR,
-    nsIAccessibleRelation::RELATION_NODE_CHILD_OF,
-    nsIAccessibleRelation::RELATION_NODE_PARENT_OF,
-    nsIAccessibleRelation::RELATION_CONTROLLED_BY,
-    nsIAccessibleRelation::RELATION_CONTROLLER_FOR,
-    nsIAccessibleRelation::RELATION_FLOWS_TO,
-    nsIAccessibleRelation::RELATION_FLOWS_FROM,
-    nsIAccessibleRelation::RELATION_MEMBER_OF,
-    nsIAccessibleRelation::RELATION_SUBWINDOW_OF,
-    nsIAccessibleRelation::RELATION_EMBEDS,
-    nsIAccessibleRelation::RELATION_EMBEDDED_BY,
-    nsIAccessibleRelation::RELATION_POPUP_FOR,
-    nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF,
-    nsIAccessibleRelation::RELATION_DEFAULT_BUTTON,
-    nsIAccessibleRelation::RELATION_CONTAINING_DOCUMENT,
-    nsIAccessibleRelation::RELATION_CONTAINING_TAB_PANE,
-    nsIAccessibleRelation::RELATION_CONTAINING_APPLICATION
-  };
-
-  for (uint32_t idx = 0; idx < ArrayLength(relationTypes); idx++) {
-    nsCOMPtr<nsIAccessibleRelation> relation;
-    nsresult rv = GetRelationByType(relationTypes[idx], getter_AddRefs(relation));
-
-    if (NS_SUCCEEDED(rv) && relation) {
-      uint32_t targets = 0;
-      relation->GetTargetsCount(&targets);
-      if (targets)
-        relations->AppendElement(relation, false);
-    }
-  }
-
-  NS_ADDREF(*aRelations = relations);
-  return NS_OK;
-}
-
-/* void extendSelection (); */
-NS_IMETHODIMP Accessible::ExtendSelection()
-{
-  // XXX Should be implemented, but not high priority
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 /* [noscript] void getNativeInterface(out voidPtr aOutAccessible); */
 NS_IMETHODIMP Accessible::GetNativeInterface(void **aOutAccessible)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 void
 Accessible::DoCommand(nsIContent *aContent, uint32_t aActionIndex)
@@ -2297,134 +1791,29 @@ Accessible::DispatchClickEvent(nsIConten
 
   // Simulate a touch interaction by dispatching touch events with mouse events.
   nsCoreUtils::DispatchTouchEvent(NS_TOUCH_START, x, y, aContent, frame, presShell, widget);
   nsCoreUtils::DispatchMouseEvent(NS_MOUSE_BUTTON_DOWN, x, y, aContent, frame, presShell, widget);
   nsCoreUtils::DispatchTouchEvent(NS_TOUCH_END, x, y, aContent, frame, presShell, widget);
   nsCoreUtils::DispatchMouseEvent(NS_MOUSE_BUTTON_UP, x, y, aContent, frame, presShell, widget);
 }
 
-NS_IMETHODIMP
-Accessible::ScrollTo(uint32_t aHow)
-{
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  nsCoreUtils::ScrollTo(mDoc->PresShell(), mContent, aHow);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
+void
 Accessible::ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY)
 {
-  nsIFrame *frame = GetFrame();
+  nsIFrame* frame = GetFrame();
   if (!frame)
-    return NS_ERROR_FAILURE;
-
-  nsIntPoint coords = nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType,
-                                                        this);
-
-  nsIFrame *parentFrame = frame;
+    return;
+
+  nsIntPoint coords =
+    nsAccUtils::ConvertToScreenCoords(aX, aY, aCoordinateType, this);
+
+  nsIFrame* parentFrame = frame;
   while ((parentFrame = parentFrame->GetParent()))
     nsCoreUtils::ScrollFrameToPoint(parentFrame, frame, coords);
-
-  return NS_OK;
-}
-
-// nsIAccessibleHyperLink
-// Because of new-atk design, any embedded object in text can implement
-// nsIAccessibleHyperLink, which helps determine where it is located
-// within containing text
-
-// readonly attribute long nsIAccessibleHyperLink::anchorCount
-NS_IMETHODIMP
-Accessible::GetAnchorCount(int32_t *aAnchorCount)
-{
-  NS_ENSURE_ARG_POINTER(aAnchorCount);
-  *aAnchorCount = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  *aAnchorCount = AnchorCount();
-  return NS_OK;
-}
-
-// readonly attribute long nsIAccessibleHyperLink::startIndex
-NS_IMETHODIMP
-Accessible::GetStartIndex(int32_t *aStartIndex)
-{
-  NS_ENSURE_ARG_POINTER(aStartIndex);
-  *aStartIndex = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  *aStartIndex = StartOffset();
-  return NS_OK;
-}
-
-// readonly attribute long nsIAccessibleHyperLink::endIndex
-NS_IMETHODIMP
-Accessible::GetEndIndex(int32_t *aEndIndex)
-{
-  NS_ENSURE_ARG_POINTER(aEndIndex);
-  *aEndIndex = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  *aEndIndex = EndOffset();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Accessible::GetURI(int32_t aIndex, nsIURI **aURI)
-{
-  NS_ENSURE_ARG_POINTER(aURI);
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  if (aIndex < 0 || aIndex >= static_cast<int32_t>(AnchorCount()))
-    return NS_ERROR_INVALID_ARG;
-
-  nsRefPtr<nsIURI>(AnchorURIAt(aIndex)).forget(aURI);
-  return NS_OK;
-}
-
-
-NS_IMETHODIMP
-Accessible::GetAnchor(int32_t aIndex, nsIAccessible** aAccessible)
-{
-  NS_ENSURE_ARG_POINTER(aAccessible);
-  *aAccessible = nullptr;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  if (aIndex < 0 || aIndex >= static_cast<int32_t>(AnchorCount()))
-    return NS_ERROR_INVALID_ARG;
-
-  NS_IF_ADDREF(*aAccessible = AnchorAt(aIndex));
-  return NS_OK;
-}
-
-// readonly attribute boolean nsIAccessibleHyperLink::valid
-NS_IMETHODIMP
-Accessible::GetValid(bool *aValid)
-{
-  NS_ENSURE_ARG_POINTER(aValid);
-  *aValid = false;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  *aValid = IsLinkValid();
-  return NS_OK;
 }
 
 void
 Accessible::AppendTextTo(nsAString& aText, uint32_t aStartOffset,
                          uint32_t aLength)
 {
   // Return text representation of non-text accessible within hypertext
   // accessible. Text accessible overrides this method to return enclosed text.
@@ -3117,17 +2506,17 @@ Accessible::AttrNumericValue(nsIAtom* aA
     return UnspecifiedNaN<double>();
 
   nsresult error = NS_OK;
   double value = attrValue.ToDouble(&error);
   return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
 }
 
 uint32_t
-Accessible::GetActionRule()
+Accessible::GetActionRule() const
 {
   if (!HasOwnContent() || (InteractiveState() & states::UNAVAILABLE))
     return eNoAction;
 
   // Return "click" action on elements that have an attached popup menu.
   if (mContent->IsXUL())
     if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::popup))
       return eClickAction;
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -6,32 +6,33 @@
 #ifndef _Accessible_H_
 #define _Accessible_H_
 
 #include "mozilla/a11y/AccTypes.h"
 #include "mozilla/a11y/RelationType.h"
 #include "mozilla/a11y/Role.h"
 #include "mozilla/a11y/States.h"
 
-#include "nsIAccessible.h"
-#include "nsIAccessibleHyperLink.h"
+#include "xpcAccessible.h"
+#include "xpcAccessibleHyperLink.h"
 #include "nsIAccessibleStates.h"
 #include "xpcAccessibleSelectable.h"
 #include "xpcAccessibleValue.h"
 
 #include "nsIContent.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsRefPtrHashtable.h"
 
 struct nsRoleMapEntry;
 
 struct nsRect;
 class nsIFrame;
 class nsIAtom;
+struct nsIntRect;
 class nsView;
 
 namespace mozilla {
 namespace a11y {
 
 class Accessible;
 class AccEvent;
 class AccGroupInfo;
@@ -117,31 +118,32 @@ typedef nsRefPtrHashtable<nsPtrHashKey<c
 #define NS_ACCESSIBLE_IMPL_IID                          \
 {  /* 133c8bf4-4913-4355-bd50-426bd1d6e1ad */           \
   0x133c8bf4,                                           \
   0x4913,                                               \
   0x4355,                                               \
   { 0xbd, 0x50, 0x42, 0x6b, 0xd1, 0xd6, 0xe1, 0xad }    \
 }
 
-class Accessible : public nsIAccessible,
-                   public nsIAccessibleHyperLink,
+class Accessible : public xpcAccessible,
+                   public xpcAccessibleHyperLink,
                    public xpcAccessibleSelectable,
                    public xpcAccessibleValue
 {
 public:
   Accessible(nsIContent* aContent, DocAccessible* aDoc);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(Accessible, nsIAccessible)
 
-  NS_DECL_NSIACCESSIBLE
-  NS_DECL_NSIACCESSIBLEHYPERLINK
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID)
 
+  // nsIAccessible
+  NS_IMETHOD GetNativeInterface(void** aOutAccessible);
+
   //////////////////////////////////////////////////////////////////////////////
   // Public methods
 
   /**
    * Return the document accessible for this accessible.
    */
   DocAccessible* Document() const { return mDoc; }
 
@@ -516,19 +518,49 @@ public:
 
   /**
    * Assert if child not in parent's cache if the cache was initialized at this
    * point.
    */
   void TestChildCache(Accessible* aCachedChild) const;
 
   /**
+   * Return boundaries in screen coordinates.
+   */
+  virtual nsIntRect Bounds() const;
+
+  /**
    * Return boundaries rect relative the bounding frame.
    */
-  virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
+  virtual nsRect RelativeBounds(nsIFrame** aRelativeFrame) const;
+
+  /**
+   * Selects the accessible within its container if applicable.
+   */
+  virtual void SetSelected(bool aSelect);
+
+  /**
+   * Select the accessible within its container.
+   */
+  void TakeSelection();
+
+  /**
+   * Focus the accessible.
+   */
+  virtual void TakeFocus();
+
+  /**
+   * Scroll the accessible into view.
+   */
+  void ScrollTo(uint32_t aHow) const;
+
+  /**
+   * Scroll the accessible to the given point.
+   */
+  void ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY);
 
   //////////////////////////////////////////////////////////////////////////////
   // Downcasting and types
 
   inline bool IsAbbreviation() const
   {
     return mContent->IsHTML() &&
       (mContent->Tag() == nsGkAtoms::abbr || mContent->Tag() == nsGkAtoms::acronym);
@@ -617,28 +649,49 @@ public:
   // ActionAccessible
 
   /**
    * Return the number of actions that can be performed on this accessible.
    */
   virtual uint8_t ActionCount();
 
   /**
+   * Return action name at given index.
+   */
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName);
+
+  /**
+   * Default to localized action name.
+   */
+  void ActionDescriptionAt(uint8_t aIndex, nsAString& aDescription)
+  {
+    nsAutoString name;
+    ActionNameAt(aIndex, name);
+    TranslateString(name, aDescription);
+  }
+
+  /**
+   * Invoke the accessible action.
+   */
+  virtual bool DoAction(uint8_t aIndex);
+
+  /**
    * Return access key, such as Alt+D.
    */
   virtual KeyBinding AccessKey() const;
 
   /**
    * Return global keyboard shortcut for default action, such as Ctrl+O for
    * Open file menuitem.
    */
   virtual KeyBinding KeyboardShortcut() const;
 
   //////////////////////////////////////////////////////////////////////////////
-  // HyperLinkAccessible
+  // HyperLinkAccessible (any embedded object in text can implement HyperLink,
+  // which helps determine where it is located within containing text).
 
   /**
    * Return true if the accessible is hyper link accessible.
    */
   virtual bool IsLink();
 
   /**
    * Return the start offset of the link within the parent accessible.
@@ -972,19 +1025,19 @@ protected:
    *
    * @param aARIAProperty  [in] the ARIA property we're using
    * @return  a numeric value
    */
   double AttrNumericValue(nsIAtom* aARIAAttr) const;
 
   /**
    * Return the action rule based on ARIA enum constants EActionRule
-   * (see ARIAMap.h). Used by ActionCount() and GetActionName().
+   * (see ARIAMap.h). Used by ActionCount() and ActionNameAt().
    */
-  uint32_t GetActionRule();
+  uint32_t GetActionRule() const;
 
   /**
    * Return group info.
    */
   AccGroupInfo* GetGroupInfo();
 
   /**
    * Set dirty state of the accessible's group info.
@@ -1023,16 +1076,17 @@ protected:
   uint32_t mStateFlags : kStateFlagsBits;
   uint32_t mContextFlags : kContextFlagsBits;
   uint32_t mType : kTypeBits;
   uint32_t mGenericTypes : kGenericTypesBits;
 
   void StaticAsserts() const;
 
   friend class DocAccessible;
+  friend class xpcAccessible;
 
   nsAutoPtr<mozilla::a11y::EmbeddedObjCollector> mEmbeddedObjCollector;
   int32_t mIndexOfEmbeddedChild;
   friend class EmbeddedObjCollector;
 
   nsAutoPtr<AccGroupInfo> mGroupInfo;
   friend class AccGroupInfo;
 
--- a/accessible/generic/ApplicationAccessible.cpp
+++ b/accessible/generic/ApplicationAccessible.cpp
@@ -34,40 +34,16 @@ ApplicationAccessible::ApplicationAccess
 // nsISupports
 
 NS_IMPL_ISUPPORTS_INHERITED(ApplicationAccessible, Accessible,
                             nsIAccessibleApplication)
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIAccessible
 
-NS_IMETHODIMP
-ApplicationAccessible::GetParent(nsIAccessible** aAccessible)
-{
-  NS_ENSURE_ARG_POINTER(aAccessible);
-  *aAccessible = nullptr;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::GetNextSibling(nsIAccessible** aNextSibling)
-{
-  NS_ENSURE_ARG_POINTER(aNextSibling);
-  *aNextSibling = nullptr;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::GetPreviousSibling(nsIAccessible** aPreviousSibling)
-{
-  NS_ENSURE_ARG_POINTER(aPreviousSibling);
-  *aPreviousSibling = nullptr;
-  return NS_OK;
-}
-
 ENameValueFlag
 ApplicationAccessible::Name(nsString& aName)
 {
   aName.Truncate();
 
   nsCOMPtr<nsIStringBundleService> bundleService =
     mozilla::services::GetStringBundleService();
 
@@ -141,74 +117,20 @@ ApplicationAccessible::FocusedChild()
 }
 
 Relation
 ApplicationAccessible::RelationByType(RelationType aRelationType)
 {
   return Relation();
 }
 
-NS_IMETHODIMP
-ApplicationAccessible::GetBounds(int32_t* aX, int32_t* aY,
-                                 int32_t* aWidth, int32_t* aHeight)
-{
-  NS_ENSURE_ARG_POINTER(aX);
-  *aX = 0;
-  NS_ENSURE_ARG_POINTER(aY);
-  *aY = 0;
-  NS_ENSURE_ARG_POINTER(aWidth);
-  *aWidth = 0;
-  NS_ENSURE_ARG_POINTER(aHeight);
-  *aHeight = 0;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::SetSelected(bool aIsSelected)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::TakeSelection()
+nsIntRect
+ApplicationAccessible::Bounds() const
 {
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::TakeFocus()
-{
-  return NS_OK;
-}
-
-uint8_t
-ApplicationAccessible::ActionCount()
-{
-  return 0;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
-{
-  aName.Truncate();
-  return NS_ERROR_INVALID_ARG;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::GetActionDescription(uint8_t aIndex,
-                                            nsAString& aDescription)
-{
-  aDescription.Truncate();
-  return NS_ERROR_INVALID_ARG;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::DoAction(uint8_t aIndex)
-{
-  return NS_OK;
+  return nsIntRect();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIAccessibleApplication
 
 NS_IMETHODIMP
 ApplicationAccessible::GetAppName(nsAString& aName)
 {
@@ -350,40 +272,8 @@ Accessible*
 ApplicationAccessible::GetSiblingAtOffset(int32_t aOffset,
                                           nsresult* aError) const
 {
   if (aError)
     *aError = NS_OK; // fail peacefully
 
   return nullptr;
 }
-
-////////////////////////////////////////////////////////////////////////////////
-// nsIAccessible
-
-NS_IMETHODIMP
-ApplicationAccessible::GetRootDocument(nsIAccessibleDocument** aRootDocument)
-{
-  NS_ENSURE_ARG_POINTER(aRootDocument);
-  *aRootDocument = nullptr;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::ScrollTo(uint32_t aScrollType)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::ScrollToPoint(uint32_t aCoordinateType,
-                                     int32_t aX, int32_t aY)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ApplicationAccessible::GetLanguage(nsAString& aLanguage)
-{
-  aLanguage.Truncate();
-  return NS_OK;
-}
-
--- a/accessible/generic/ApplicationAccessible.h
+++ b/accessible/generic/ApplicationAccessible.h
@@ -32,57 +32,40 @@ class ApplicationAccessible : public Acc
 {
 public:
 
   ApplicationAccessible();
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
-  // nsIAccessible
-  NS_IMETHOD GetRootDocument(nsIAccessibleDocument** aRootDocument);
-  NS_IMETHOD ScrollTo(uint32_t aScrollType);
-  NS_IMETHOD ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY);
-  NS_IMETHOD GetLanguage(nsAString& aLanguage);
-  NS_IMETHOD GetParent(nsIAccessible **aParent);
-  NS_IMETHOD GetNextSibling(nsIAccessible **aNextSibling);
-  NS_IMETHOD GetPreviousSibling(nsIAccessible **aPreviousSibling);
-  NS_IMETHOD GetBounds(int32_t *aX, int32_t *aY,
-                       int32_t *aWidth, int32_t *aHeight);
-  NS_IMETHOD SetSelected(bool aIsSelected);
-  NS_IMETHOD TakeSelection();
-  NS_IMETHOD TakeFocus();
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString &aName);
-  NS_IMETHOD GetActionDescription(uint8_t aIndex, nsAString &aDescription);
-  NS_IMETHOD DoAction(uint8_t aIndex);
-
   // nsIAccessibleApplication
   NS_DECL_NSIACCESSIBLEAPPLICATION
 
   // Accessible
   virtual void Shutdown();
+  virtual nsIntRect Bounds() const MOZ_OVERRIDE;
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
   virtual GroupPos GroupPosition();
   virtual ENameValueFlag Name(nsString& aName);
   virtual void ApplyARIAState(uint64_t* aState) const;
   virtual void Description(nsString& aDescription);
   virtual void Value(nsString& aValue);
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t State();
-  virtual uint64_t NativeState();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t State() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 
   virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
                                    EWhichChildAtPoint aWhichChild);
   virtual Accessible* FocusedChild();
 
   virtual void InvalidateChildren();
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
   virtual KeyBinding AccessKey() const;
 
 protected:
   virtual ~ApplicationAccessible() {}
 
   // Accessible
   virtual void CacheChildren();
   virtual Accessible* GetSiblingAtOffset(int32_t aOffset,
--- a/accessible/generic/BaseAccessibles.cpp
+++ b/accessible/generic/BaseAccessibles.cpp
@@ -76,20 +76,23 @@ LinkableAccessible::
 {
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(LinkableAccessible, AccessibleWrap)
 
 ////////////////////////////////////////////////////////////////////////////////
 // LinkableAccessible. nsIAccessible
 
-NS_IMETHODIMP
+void
 LinkableAccessible::TakeFocus()
 {
-  return mActionAcc ? mActionAcc->TakeFocus() : AccessibleWrap::TakeFocus();
+  if (mActionAcc)
+    mActionAcc->TakeFocus();
+  else
+    AccessibleWrap::TakeFocus();
 }
 
 uint64_t
 LinkableAccessible::NativeLinkState() const
 {
   if (mIsLink)
     return states::LINKED | (mActionAcc->LinkState() & states::TRAVERSED);
 
@@ -111,41 +114,35 @@ LinkableAccessible::Value(nsString& aVal
 
 
 uint8_t
 LinkableAccessible::ActionCount()
 {
   return (mIsOnclick || mIsLink) ? 1 : 0;
 }
 
-NS_IMETHODIMP
-LinkableAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+LinkableAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
 
   // Action 0 (default action): Jump to link
   if (aIndex == eAction_Jump) {
-    if (mIsLink) {
+    if (mIsLink)
       aName.AssignLiteral("jump");
-      return NS_OK;
-    }
-    else if (mIsOnclick) {
+    else if (mIsOnclick)
       aName.AssignLiteral("click");
-      return NS_OK;
-    }
-    return NS_ERROR_NOT_IMPLEMENTED;
   }
-  return NS_ERROR_INVALID_ARG;
 }
 
-NS_IMETHODIMP
+bool
 LinkableAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != eAction_Jump)
-    return NS_ERROR_INVALID_ARG;
+    return false;
 
   return mActionAcc ? mActionAcc->DoAction(aIndex) :
     AccessibleWrap::DoAction(aIndex);
 }
 
 KeyBinding
 LinkableAccessible::AccessKey() const
 {
--- a/accessible/generic/BaseAccessibles.h
+++ b/accessible/generic/BaseAccessibles.h
@@ -55,28 +55,26 @@ class LinkableAccessible : public Access
 {
 public:
   enum { eAction_Jump = 0 };
 
   LinkableAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   NS_DECL_ISUPPORTS_INHERITED
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t index);
-  NS_IMETHOD TakeFocus();
-
   // Accessible
-  virtual void Shutdown();
-  virtual void Value(nsString& aValue);
-  virtual uint64_t NativeLinkState() const;
+  virtual void Shutdown() MOZ_OVERRIDE;
+  virtual void Value(nsString& aValue) MOZ_OVERRIDE;
+  virtual uint64_t NativeLinkState() const MOZ_OVERRIDE;
+  virtual void TakeFocus() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t index) MOZ_OVERRIDE;
   virtual KeyBinding AccessKey() const;
 
   // HyperLinkAccessible
   virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex);
 
 protected:
   virtual ~LinkableAccessible() {}
 
@@ -99,17 +97,17 @@ class EnumRoleAccessible : public Access
 {
 public:
   EnumRoleAccessible(nsIContent* aContent, DocAccessible* aDoc, 
                      a11y::role aRole);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 
 protected:
   virtual ~EnumRoleAccessible() { }
 
   a11y::role mRole;
 };
 
 
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -308,30 +308,24 @@ DocAccessible::Attributes()
 Accessible*
 DocAccessible::FocusedChild()
 {
   // Return an accessible for the current global focus, which does not have to
   // be contained within the current document.
   return FocusMgr()->FocusedAccessible();
 }
 
-NS_IMETHODIMP
+void
 DocAccessible::TakeFocus()
 {
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   // Focus the document.
   nsFocusManager* fm = nsFocusManager::GetFocusManager();
-  NS_ENSURE_STATE(fm);
-
   nsCOMPtr<nsIDOMElement> newFocus;
-  return fm->MoveFocus(mDocumentNode->GetWindow(), nullptr,
-                       nsIFocusManager::MOVEFOCUS_ROOT, 0,
-                       getter_AddRefs(newFocus));
+  fm->MoveFocus(mDocumentNode->GetWindow(), nullptr,
+                nsFocusManager::MOVEFOCUS_ROOT, 0, getter_AddRefs(newFocus));
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIAccessibleDocument
 
 NS_IMETHODIMP
 DocAccessible::GetURL(nsAString& aURL)
@@ -640,55 +634,57 @@ DocAccessible::GetFrame() const
   nsIFrame* root = nullptr;
   if (mPresShell)
     root = mPresShell->GetRootFrame();
 
   return root;
 }
 
 // DocAccessible protected member
-void
-DocAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aRelativeFrame)
+nsRect
+DocAccessible::RelativeBounds(nsIFrame** aRelativeFrame) const
 {
   *aRelativeFrame = GetFrame();
 
   nsIDocument *document = mDocumentNode;
   nsIDocument *parentDoc = nullptr;
 
+  nsRect bounds;
   while (document) {
     nsIPresShell *presShell = document->GetShell();
-    if (!presShell) {
-      return;
-    }
+    if (!presShell)
+      return nsRect();
 
     nsRect scrollPort;
     nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollableExternal();
     if (sf) {
       scrollPort = sf->GetScrollPortRect();
     } else {
       nsIFrame* rootFrame = presShell->GetRootFrame();
-      if (!rootFrame) {
-        return;
-      }
+      if (!rootFrame)
+        return nsRect();
+
       scrollPort = rootFrame->GetRect();
     }
 
     if (parentDoc) {  // After first time thru loop
       // XXXroc bogus code! scrollPort is relative to the viewport of
       // this document, but we're intersecting rectangles derived from
       // multiple documents and assuming they're all in the same coordinate
       // system. See bug 514117.
-      aBounds.IntersectRect(scrollPort, aBounds);
+      bounds.IntersectRect(scrollPort, bounds);
     }
     else {  // First time through loop
-      aBounds = scrollPort;
+      bounds = scrollPort;
     }
 
     document = parentDoc = document->GetParentDocument();
   }
+
+  return bounds;
 }
 
 // DocAccessible protected member
 nsresult
 DocAccessible::AddEventListeners()
 {
   nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem(mDocumentNode->GetDocShell());
 
--- a/accessible/generic/DocAccessible.h
+++ b/accessible/generic/DocAccessible.h
@@ -54,19 +54,16 @@ class DocAccessible : public HyperTextAc
 
   NS_DECL_NSIACCESSIBLEPIVOTOBSERVER
 
 public:
 
   DocAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
                 nsIPresShell* aPresShell);
 
-  // nsIAccessible
-  NS_IMETHOD TakeFocus(void);
-
   // nsIScrollPositionListener
   virtual void ScrollPositionWillChange(nscoord aX, nscoord aY) {}
   virtual void ScrollPositionDidChange(nscoord aX, nscoord aY);
 
   // nsIDocumentObserver
   NS_DECL_NSIDOCUMENTOBSERVER
 
   // Accessible
@@ -74,28 +71,30 @@ public:
   virtual void Shutdown();
   virtual nsIFrame* GetFrame() const;
   virtual nsINode* GetNode() const { return mDocumentNode; }
   nsIDocument* DocumentNode() const { return mDocumentNode; }
 
   virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
   virtual void Description(nsString& aDescription);
   virtual Accessible* FocusedChild();
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
   virtual bool NativelyUnavailable() const;
   virtual void ApplyARIAState(uint64_t* aState) const;
   virtual already_AddRefed<nsIPersistentProperties> Attributes();
 
+  virtual void TakeFocus() MOZ_OVERRIDE;
+
 #ifdef A11Y_LOG
   virtual nsresult HandleAccEvent(AccEvent* aEvent);
 #endif
 
-  virtual void GetBoundsRect(nsRect& aRect, nsIFrame** aRelativeFrame);
+  virtual nsRect RelativeBounds(nsIFrame** aRelativeFrame) const MOZ_OVERRIDE;
 
   // HyperTextAccessible
   virtual already_AddRefed<nsIEditor> GetEditor() const;
 
   // DocAccessible
 
   /**
    * Return presentation shell for this document accessible.
--- a/accessible/generic/FormControlAccessible.cpp
+++ b/accessible/generic/FormControlAccessible.cpp
@@ -169,34 +169,31 @@ RadioButtonAccessible::
 }
 
 uint8_t
 RadioButtonAccessible::ActionCount()
 {
   return 1;
 }
 
-NS_IMETHODIMP
-RadioButtonAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+RadioButtonAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (aIndex == eAction_Click) {
-    aName.AssignLiteral("select"); 
-    return NS_OK;
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex == eAction_Click)
+    aName.AssignLiteral("select");
 }
 
-NS_IMETHODIMP
+bool
 RadioButtonAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != eAction_Click)
-    return NS_ERROR_INVALID_ARG;
+    return false;
 
   DoCommand();
-  return NS_OK;
+  return true;
 }
 
 role
 RadioButtonAccessible::NativeRole()
 {
   return roles::RADIOBUTTON;
 }
 
--- a/accessible/generic/FormControlAccessible.h
+++ b/accessible/generic/FormControlAccessible.h
@@ -26,18 +26,18 @@ public:
     mStateFlags |= eHasNumericValue | eIgnoreDOMUIEvent;
     mType = eProgressType;
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
   virtual void Value(nsString& aValue);
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // Value
   virtual double MaxValue() const MOZ_OVERRIDE;
   virtual double MinValue() const MOZ_OVERRIDE;
   virtual double CurValue() const MOZ_OVERRIDE;
   virtual double Step() const MOZ_OVERRIDE;
   virtual bool SetCurValue(double aValue) MOZ_OVERRIDE;
 
@@ -52,25 +52,23 @@ protected:
   * Generic class used for radio buttons.
   */
 class RadioButtonAccessible : public LeafAccessible
 {
 
 public:
   RadioButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t aIndex);
-
   // Accessible
   virtual mozilla::a11y::role NativeRole();
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   enum { eAction_Click = 0 };
 
   // Widgets
   virtual bool IsWidget() const;
 };
 
 } // namespace a11y
--- a/accessible/generic/HyperTextAccessible.h
+++ b/accessible/generic/HyperTextAccessible.h
@@ -52,18 +52,18 @@ class HyperTextAccessible : public Acces
 public:
   HyperTextAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
   virtual int32_t GetLevelInternal();
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   virtual void InvalidateChildren();
   virtual bool RemoveChild(Accessible* aAccessible);
 
   // HyperTextAccessible (static helper method)
 
   // Convert content offset to rendered text offset
   nsresult ContentToRenderedOffset(nsIFrame *aFrame, int32_t aContentOffset,
--- a/accessible/generic/ImageAccessible.cpp
+++ b/accessible/generic/ImageAccessible.cpp
@@ -104,79 +104,80 @@ ImageAccessible::NativeRole()
 
 uint8_t
 ImageAccessible::ActionCount()
 {
   uint8_t actionCount = LinkableAccessible::ActionCount();
   return HasLongDesc() ? actionCount + 1 : actionCount;
 }
 
-NS_IMETHODIMP
-ImageAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+ImageAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  if (IsLongDescIndex(aIndex) && HasLongDesc()) {
+  if (IsLongDescIndex(aIndex) && HasLongDesc())
     aName.AssignLiteral("showlongdesc"); 
-    return NS_OK;
-  }
-  return LinkableAccessible::GetActionName(aIndex, aName);
+  else
+    LinkableAccessible::ActionNameAt(aIndex, aName);
 }
 
-NS_IMETHODIMP
+bool
 ImageAccessible::DoAction(uint8_t aIndex)
 {
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   // Get the long description uri and open in a new window.
   if (!IsLongDescIndex(aIndex))
     return LinkableAccessible::DoAction(aIndex);
 
   nsCOMPtr<nsIURI> uri = GetLongDescURI();
   if (!uri)
-    return NS_ERROR_INVALID_ARG;
+    return false;
 
   nsAutoCString utf8spec;
   uri->GetSpec(utf8spec);
   NS_ConvertUTF8toUTF16 spec(utf8spec);
 
   nsIDocument* document = mContent->OwnerDoc();
   nsCOMPtr<nsPIDOMWindow> piWindow = document->GetWindow();
   nsCOMPtr<nsIDOMWindow> win = do_QueryInterface(piWindow);
-  NS_ENSURE_STATE(win);
+  if (!win)
+    return false;
 
   nsCOMPtr<nsIDOMWindow> tmp;
-  return win->Open(spec, EmptyString(), EmptyString(),
-                   getter_AddRefs(tmp));
+  return NS_SUCCEEDED(win->Open(spec, EmptyString(), EmptyString(),
+                                getter_AddRefs(tmp)));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIAccessibleImage
 
 NS_IMETHODIMP
 ImageAccessible::GetImagePosition(uint32_t aCoordType, int32_t* aX, int32_t* aY)
 {
-  int32_t width, height;
-  nsresult rv = GetBounds(aX, aY, &width, &height);
-  if (NS_FAILED(rv))
-    return rv;
+  NS_ENSURE_ARG_POINTER(aX);
+  NS_ENSURE_ARG_POINTER(aY);
 
+  nsIntRect rect = Bounds();
+  *aX = rect.x;
+  *aY = rect.y;
   nsAccUtils::ConvertScreenCoordsTo(aX, aY, aCoordType, this);
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ImageAccessible::GetImageSize(int32_t* aWidth, int32_t* aHeight)
 {
-  int32_t x, y;
-  return GetBounds(&x, &y, aWidth, aHeight);
+  NS_ENSURE_ARG_POINTER(aWidth);
+  NS_ENSURE_ARG_POINTER(aHeight);
+
+  nsIntRect rect = Bounds();
+  *aWidth = rect.width;
+  *aHeight = rect.height;
+
+  return NS_OK;
 }
 
 // Accessible
 already_AddRefed<nsIPersistentProperties>
 ImageAccessible::NativeAttributes()
 {
   nsCOMPtr<nsIPersistentProperties> attributes =
     LinkableAccessible::NativeAttributes();
--- a/accessible/generic/ImageAccessible.h
+++ b/accessible/generic/ImageAccessible.h
@@ -23,30 +23,28 @@ class ImageAccessible : public LinkableA
                         public nsIAccessibleImage
 {
 public:
   ImageAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t index);
-
   // nsIAccessibleImage
   NS_DECL_NSIACCESSIBLEIMAGE
 
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
 protected:
   virtual ~ImageAccessible();
 
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 
 private:
@@ -60,17 +58,17 @@ private:
   }
 
   /**
    * Return an URI for showlongdesc action if any.
    */
   already_AddRefed<nsIURI> GetLongDescURI() const;
 
   /**
-   * Used by GetActionName and DoAction to ensure the index for opening the
+   * Used by ActionNameAt and DoAction to ensure the index for opening the
    * longdesc URL is valid.
    * It is always assumed that the highest possible index opens the longdesc.
    * This doesn't check that there is actually a longdesc, just that the index
    * would be correct if there was one.
    *
    * @param aIndex  The 0-based index to be tested.
    *
    * @returns  true if index is valid for longdesc action.
--- a/accessible/generic/OuterDocAccessible.cpp
+++ b/accessible/generic/OuterDocAccessible.cpp
@@ -46,67 +46,32 @@ OuterDocAccessible::NativeRole()
 {
   return roles::INTERNAL_FRAME;
 }
 
 Accessible*
 OuterDocAccessible::ChildAtPoint(int32_t aX, int32_t aY,
                                  EWhichChildAtPoint aWhichChild)
 {
-  int32_t docX = 0, docY = 0, docWidth = 0, docHeight = 0;
-  nsresult rv = GetBounds(&docX, &docY, &docWidth, &docHeight);
-  NS_ENSURE_SUCCESS(rv, nullptr);
-
-  if (aX < docX || aX >= docX + docWidth || aY < docY || aY >= docY + docHeight)
+  nsIntRect docRect = Bounds();
+  if (aX < docRect.x || aX >= docRect.x + docRect.width ||
+      aY < docRect.y || aY >= docRect.y + docRect.height)
     return nullptr;
 
   // Always return the inner doc as direct child accessible unless bounds
   // outside of it.
   Accessible* child = GetChildAt(0);
   NS_ENSURE_TRUE(child, nullptr);
 
   if (aWhichChild == eDeepestChild)
     return child->ChildAtPoint(aX, aY, eDeepestChild);
   return child;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// nsIAccessible
-
-uint8_t
-OuterDocAccessible::ActionCount()
-{
-  // Internal frame, which is the doc's parent, should not have a click action.
-  return 0;
-}
-
-NS_IMETHODIMP
-OuterDocAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
-{
-  aName.Truncate();
-
-  return NS_ERROR_INVALID_ARG;
-}
-
-NS_IMETHODIMP
-OuterDocAccessible::GetActionDescription(uint8_t aIndex,
-                                         nsAString& aDescription)
-{
-  aDescription.Truncate();
-
-  return NS_ERROR_INVALID_ARG;
-}
-
-NS_IMETHODIMP
-OuterDocAccessible::DoAction(uint8_t aIndex)
-{
-  return NS_ERROR_INVALID_ARG;
-}
-
-////////////////////////////////////////////////////////////////////////////////
 // Accessible public
 
 void
 OuterDocAccessible::Shutdown()
 {
   // XXX: sometimes outerdoc accessible is shutdown because of layout style
   // change however the presshell of underlying document isn't destroyed and
   // the document doesn't get pagehide events. Schedule a document rebind
--- a/accessible/generic/OuterDocAccessible.h
+++ b/accessible/generic/OuterDocAccessible.h
@@ -22,34 +22,26 @@ namespace a11y {
 
 class OuterDocAccessible MOZ_FINAL : public AccessibleWrap
 {
 public:
   OuterDocAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   NS_DECL_ISUPPORTS_INHERITED
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD GetActionDescription(uint8_t aIndex, nsAString& aDescription);
-  NS_IMETHOD DoAction(uint8_t aIndex);
-
   // Accessible
   virtual void Shutdown();
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
   virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
                                    EWhichChildAtPoint aWhichChild);
 
   virtual void InvalidateChildren();
   virtual bool InsertChildAt(uint32_t aIdx, Accessible* aChild) MOZ_OVERRIDE;
   virtual bool RemoveChild(Accessible* aAccessible);
 
-  // ActionAccessible
-  virtual uint8_t ActionCount();
-
 protected:
   virtual ~OuterDocAccessible();
 
   // Accessible
   virtual void CacheChildren();
 };
 
 } // namespace a11y
--- a/accessible/generic/RootAccessible.h
+++ b/accessible/generic/RootAccessible.h
@@ -28,17 +28,17 @@ public:
   // nsIDOMEventListener
   NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
 
   // Accessible
   virtual void Shutdown();
   virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
   virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // RootAccessible
 
   /**
    * Notify that the sub document presshell was activated.
    */
   virtual void DocumentActivated(DocAccessible* aDocument);
 
--- a/accessible/generic/TableAccessible.h
+++ b/accessible/generic/TableAccessible.h
@@ -20,17 +20,17 @@ class Accessible;
  */
 class TableAccessible
 {
 public:
 
   /**
    * Return the caption accessible if any for this table.
    */
-  virtual Accessible* Caption() { return nullptr; }
+  virtual Accessible* Caption() const { return nullptr; }
 
   /**
    * Get the summary for this table.
    */
   virtual void Summary(nsString& aSummary) { aSummary.Truncate(); }
 
   /**
    * Return the number of columns in the table.
--- a/accessible/generic/TextLeafAccessible.cpp
+++ b/accessible/generic/TextLeafAccessible.cpp
@@ -25,17 +25,17 @@ TextLeafAccessible::
 TextLeafAccessible::~TextLeafAccessible()
 {
 }
 
 role
 TextLeafAccessible::NativeRole()
 {
   nsIFrame* frame = GetFrame();
-  if (frame && frame->IsGeneratedContentFrame()) 
+  if (frame && frame->IsGeneratedContentFrame())
     return roles::STATICTEXT;
 
   return roles::TEXT_LEAF;
 }
 
 void
 TextLeafAccessible::AppendTextTo(nsAString& aText, uint32_t aStartOffset,
                                  uint32_t aLength)
--- a/accessible/generic/TextLeafAccessible.h
+++ b/accessible/generic/TextLeafAccessible.h
@@ -16,17 +16,17 @@ namespace a11y {
  */
 class TextLeafAccessible : public LinkableAccessible
 {
 public:
   TextLeafAccessible(nsIContent* aContent, DocAccessible* aDoc);
   virtual ~TextLeafAccessible();
 
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
   virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
                             uint32_t aLength = UINT32_MAX);
   virtual ENameValueFlag Name(nsString& aName);
 
   // TextLeafAccessible
   void SetText(const nsAString& aText) { mText = aText; }
   const nsString& Text() const { return mText; }
 
--- a/accessible/html/HTMLCanvasAccessible.h
+++ b/accessible/html/HTMLCanvasAccessible.h
@@ -18,17 +18,17 @@ class HTMLCanvasAccessible : public Hype
 {
 public:
   HTMLCanvasAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 
 protected:
   virtual ~HTMLCanvasAccessible() { }
 };
 
 } // namespace a11y
 } // namespace mozilla
 
--- a/accessible/html/HTMLElementAccessibles.h
+++ b/accessible/html/HTMLElementAccessibles.h
@@ -18,34 +18,34 @@ namespace a11y {
 class HTMLHRAccessible : public LeafAccessible
 {
 public:
 
   HTMLHRAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     LeafAccessible(aContent, aDoc) {}
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 };
 
 /**
  * Used for HTML br element.
  */
 class HTMLBRAccessible : public LeafAccessible
 {
 public:
   HTMLBRAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     LeafAccessible(aContent, aDoc)
   {
     mType = eHTMLBRType;
   }
 
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 };
 
 /**
  * Used for HTML label element.
@@ -55,17 +55,17 @@ class HTMLLabelAccessible : public Hyper
 public:
 
   HTMLLabelAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     HyperTextAccessibleWrap(aContent, aDoc) {}
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 
 protected:
   virtual ~HTMLLabelAccessible() {}
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 };
 
 /**
@@ -76,17 +76,17 @@ class HTMLOutputAccessible : public Hype
 public:
 
   HTMLOutputAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     HyperTextAccessibleWrap(aContent, aDoc) {}
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 
 protected:
   virtual ~HTMLOutputAccessible() {}
 };
 
 } // namespace a11y
--- a/accessible/html/HTMLFormControlAccessible.cpp
+++ b/accessible/html/HTMLFormControlAccessible.cpp
@@ -46,43 +46,38 @@ HTMLCheckboxAccessible::NativeRole()
 }
 
 uint8_t
 HTMLCheckboxAccessible::ActionCount()
 {
   return 1;
 }
 
-NS_IMETHODIMP
-HTMLCheckboxAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+HTMLCheckboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   if (aIndex == eAction_Click) {    // 0 is the magic value for default action
-    // cycle, check or uncheck
     uint64_t state = NativeState();
-
     if (state & states::CHECKED)
-      aName.AssignLiteral("uncheck"); 
+      aName.AssignLiteral("uncheck");
     else if (state & states::MIXED)
-      aName.AssignLiteral("cycle"); 
+      aName.AssignLiteral("cycle");
     else
-      aName.AssignLiteral("check"); 
-
-    return NS_OK;
+      aName.AssignLiteral("check");
   }
-  return NS_ERROR_INVALID_ARG;
 }
 
-NS_IMETHODIMP
+bool
 HTMLCheckboxAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != 0)
-    return NS_ERROR_INVALID_ARG;
+    return false;
 
   DoCommand();
-  return NS_OK;
+  return true;
 }
 
 uint64_t
 HTMLCheckboxAccessible::NativeState()
 {
   uint64_t state = LeafAccessible::NativeState();
 
   state |= states::CHECKABLE;
@@ -184,34 +179,31 @@ HTMLButtonAccessible::
 }
 
 uint8_t
 HTMLButtonAccessible::ActionCount()
 {
   return 1;
 }
 
-NS_IMETHODIMP
-HTMLButtonAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+HTMLButtonAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (aIndex == eAction_Click) {
-    aName.AssignLiteral("press"); 
-    return NS_OK;
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex == eAction_Click)
+    aName.AssignLiteral("press");
 }
 
-NS_IMETHODIMP
+bool
 HTMLButtonAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != eAction_Click)
-    return NS_ERROR_INVALID_ARG;
+    return false;
 
   DoCommand();
-  return NS_OK;
+  return true;
 }
 
 uint64_t
 HTMLButtonAccessible::State()
 {
   uint64_t state = HyperTextAccessibleWrap::State();
   if (state == states::DEFUNCT)
     return state;
@@ -288,17 +280,17 @@ HTMLButtonAccessible::IsWidget() const
 HTMLTextFieldAccessible::
   HTMLTextFieldAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   HyperTextAccessibleWrap(aContent, aDoc)
 {
   mType = eHTMLTextFieldType;
 }
 
 NS_IMPL_ISUPPORTS_INHERITED(HTMLTextFieldAccessible,
-                            Accessible,                            
+                            Accessible,
                             nsIAccessibleText,
                             nsIAccessibleEditableText)
 
 role
 HTMLTextFieldAccessible::NativeRole()
 {
   if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
                             nsGkAtoms::password, eIgnoreCase)) {
@@ -440,33 +432,31 @@ HTMLTextFieldAccessible::NativeState()
 }
 
 uint8_t
 HTMLTextFieldAccessible::ActionCount()
 {
   return 1;
 }
 
-NS_IMETHODIMP
-HTMLTextFieldAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+HTMLTextFieldAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (aIndex == eAction_Click) {
+  if (aIndex == eAction_Click)
     aName.AssignLiteral("activate");
-    return NS_OK;
-  }
-  return NS_ERROR_INVALID_ARG;
 }
 
-NS_IMETHODIMP
+bool
 HTMLTextFieldAccessible::DoAction(uint8_t aIndex)
 {
-  if (aIndex == 0)
-    return TakeFocus();
+  if (aIndex != 0)
+    return false;
 
-  return NS_ERROR_INVALID_ARG;
+  TakeFocus();
+  return true;
 }
 
 already_AddRefed<nsIEditor>
 HTMLTextFieldAccessible::GetEditor() const
 {
   nsCOMPtr<nsIDOMNSEditableElement> editableElt(do_QueryInterface(mContent));
   if (!editableElt)
     return nullptr;
@@ -702,17 +692,17 @@ HTMLGroupboxAccessible::
 
 role
 HTMLGroupboxAccessible::NativeRole()
 {
   return roles::GROUPING;
 }
 
 nsIContent*
-HTMLGroupboxAccessible::GetLegend()
+HTMLGroupboxAccessible::GetLegend() const
 {
   for (nsIContent* legendContent = mContent->GetFirstChild(); legendContent;
        legendContent = legendContent->GetNextSibling()) {
     if (legendContent->NodeInfo()->Equals(nsGkAtoms::legend,
                                           mContent->GetNameSpaceID())) {
       // Either XHTML namespace or no namespace
       return legendContent;
     }
--- a/accessible/html/HTMLFormControlAccessible.h
+++ b/accessible/html/HTMLFormControlAccessible.h
@@ -29,26 +29,24 @@ public:
   HTMLCheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     LeafAccessible(aContent, aDoc)
   {
     // Ignore "CheckboxStateChange" DOM event in lieu of document observer
     // state change notification.
     mStateFlags |= eIgnoreDOMUIEvent;
   }
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t index);
-
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
   virtual uint64_t NativeState();
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsWidget() const;
 };
 
 
 /**
  * Accessible for HTML input@type="radio" element.
@@ -61,17 +59,17 @@ public:
     RadioButtonAccessible(aContent, aDoc)
   {
     // Ignore "RadioStateChange" DOM event in lieu of document observer
     // state change notification.
     mStateFlags |= eIgnoreDOMUIEvent;
   }
 
   // Accessible
-  virtual uint64_t NativeState();
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
   virtual void GetPositionAndSizeInternal(int32_t *aPosInSet,
                                           int32_t *aSetSize);
 };
 
 
 /**
  * Accessible for HTML input@type="button", @type="submit", @type="image"
  * and HTML button elements.
@@ -79,27 +77,25 @@ public:
 class HTMLButtonAccessible : public HyperTextAccessibleWrap
 {
 
 public:
   enum { eAction_Click = 0 };
 
   HTMLButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t index);
-
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t State();
-  virtual uint64_t NativeState();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t State() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsWidget() const;
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 };
@@ -114,32 +110,30 @@ class HTMLTextFieldAccessible MOZ_FINAL 
 
 public:
   enum { eAction_Click = 0 };
 
   HTMLTextFieldAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   NS_DECL_ISUPPORTS_INHERITED
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t index);
-
   // HyperTextAccessible
   virtual already_AddRefed<nsIEditor> GetEditor() const;
 
   // Accessible
   virtual void Value(nsString& aValue);
   virtual void ApplyARIAState(uint64_t* aState) const;
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsWidget() const;
   virtual Accessible* ContainerWidget() const;
 
 protected:
   virtual ~HTMLTextFieldAccessible() {}
 
@@ -157,17 +151,17 @@ protected:
  * Accessible for input@type="file" element.
  */
 class HTMLFileInputAccessible : public HyperTextAccessibleWrap
 {
 public:
   HTMLFileInputAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
   virtual nsresult HandleAccEvent(AccEvent* aAccEvent);
 };
 
 
 /**
  * Used for HTML input@type="number".
  */
 class HTMLSpinnerAccessible : public AccessibleWrap
@@ -200,17 +194,17 @@ public:
   HTMLRangeAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     LeafAccessible(aContent, aDoc)
   {
     mStateFlags |= eHasNumericValue;
   }
 
   // Accessible
   virtual void Value(nsString& aValue);
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
 
   // Value
   virtual double MaxValue() const MOZ_OVERRIDE;
   virtual double MinValue() const MOZ_OVERRIDE;
   virtual double CurValue() const MOZ_OVERRIDE;
   virtual double Step() const MOZ_OVERRIDE;
   virtual bool SetCurValue(double aValue) MOZ_OVERRIDE;
 
@@ -223,52 +217,52 @@ public:
  * Accessible for HTML fieldset element.
  */
 class HTMLGroupboxAccessible : public HyperTextAccessibleWrap
 {
 public:
   HTMLGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 
   // HTMLGroupboxAccessible
-  nsIContent* GetLegend();
+  nsIContent* GetLegend() const;
 };
 
 
 /**
  * Accessible for HTML legend element.
  */
 class HTMLLegendAccessible : public HyperTextAccessibleWrap
 {
 public:
   HTMLLegendAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 };
 
 /**
  * Accessible for HTML5 figure element.
  */
 class HTMLFigureAccessible : public HyperTextAccessibleWrap
 {
 public:
   HTMLFigureAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 
   // HTMLLegendAccessible
   nsIContent* Caption() const;
@@ -279,16 +273,16 @@ protected:
  * Accessible for HTML5 figcaption element.
  */
 class HTMLFigcaptionAccessible : public HyperTextAccessibleWrap
 {
 public:
   HTMLFigcaptionAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/html/HTMLImageMapAccessible.cpp
+++ b/accessible/html/HTMLImageMapAccessible.cpp
@@ -231,29 +231,30 @@ HTMLAreaAccessible::EndOffset()
 // HTMLAreaAccessible: Accessible protected
 
 void
 HTMLAreaAccessible::CacheChildren()
 {
   // No children for aria accessible.
 }
 
-void
-HTMLAreaAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame)
+nsRect
+HTMLAreaAccessible::RelativeBounds(nsIFrame** aBoundingFrame) const
 {
   nsIFrame* frame = GetFrame();
   if (!frame)
-    return;
+    return nsRect();
 
   nsImageFrame* imageFrame = do_QueryFrame(frame);
   nsImageMap* map = imageFrame->GetImageMap();
 
-  nsresult rv = map->GetBoundsForAreaContent(mContent, aBounds);
+  nsRect bounds;
+  nsresult rv = map->GetBoundsForAreaContent(mContent, bounds);
   if (NS_FAILED(rv))
-    return;
+    return nsRect();
 
   // XXX Areas are screwy; they return their rects as a pair of points, one pair
   // stored into the width and height.
-  aBounds.width -= aBounds.x;
-  aBounds.height -= aBounds.y;
-
   *aBoundingFrame = frame;
+  bounds.width -= bounds.x;
+  bounds.height -= bounds.y;
+  return bounds;
 }
--- a/accessible/html/HTMLImageMapAccessible.h
+++ b/accessible/html/HTMLImageMapAccessible.h
@@ -20,17 +20,17 @@ class HTMLImageMapAccessible MOZ_FINAL :
 {
 public:
   HTMLImageMapAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // nsISupports and cycle collector
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 
   // HyperLinkAccessible
   virtual uint32_t AnchorCount();
   virtual Accessible* AnchorAt(uint32_t aAnchorIndex);
   virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex);
 
   /**
    * Update area children of the image map.
@@ -57,17 +57,17 @@ class HTMLAreaAccessible MOZ_FINAL : pub
 public:
 
   HTMLAreaAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
   virtual void Description(nsString& aDescription);
   virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
                                    EWhichChildAtPoint aWhichChild);
-  virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
+  virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const MOZ_OVERRIDE;
 
   // HyperLinkAccessible
   virtual uint32_t StartOffset();
   virtual uint32_t EndOffset();
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
--- a/accessible/html/HTMLLinkAccessible.cpp
+++ b/accessible/html/HTMLLinkAccessible.cpp
@@ -87,47 +87,43 @@ HTMLLinkAccessible::Value(nsString& aVal
 }
 
 uint8_t
 HTMLLinkAccessible::ActionCount()
 {
   return IsLinked() ? 1 : HyperTextAccessible::ActionCount();
 }
 
-NS_IMETHODIMP
-HTMLLinkAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+HTMLLinkAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
 
-  if (!IsLinked())
-    return HyperTextAccessible::GetActionName(aIndex, aName);
+  if (!IsLinked()) {
+    HyperTextAccessible::ActionNameAt(aIndex, aName);
+    return;
+  }
 
   // Action 0 (default action): Jump to link
-  if (aIndex != eAction_Jump)
-    return NS_ERROR_INVALID_ARG;
-
-  aName.AssignLiteral("jump");
-  return NS_OK;
+  if (aIndex == eAction_Jump)
+    aName.AssignLiteral("jump");
 }
 
-NS_IMETHODIMP
+bool
 HTMLLinkAccessible::DoAction(uint8_t aIndex)
 {
   if (!IsLinked())
     return HyperTextAccessible::DoAction(aIndex);
 
   // Action 0 (default action): Jump to link
   if (aIndex != eAction_Jump)
-    return NS_ERROR_INVALID_ARG;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
+    return false;
 
   DoCommand();
-  return NS_OK;
+  return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HyperLinkAccessible
 
 bool
 HTMLLinkAccessible::IsLink()
 {
@@ -140,17 +136,14 @@ HTMLLinkAccessible::AnchorURIAt(uint32_t
 {
   return aAnchorIndex == 0 ? mContent->GetHrefURI() : nullptr;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Protected members
 
 bool
-HTMLLinkAccessible::IsLinked()
+HTMLLinkAccessible::IsLinked() const
 {
-  if (IsDefunct())
-    return false;
-
   EventStates state = mContent->AsElement()->State();
   return state.HasAtLeastOneOfStates(NS_EVENT_STATE_VISITED |
                                      NS_EVENT_STATE_UNVISITED);
 }
--- a/accessible/html/HTMLLinkAccessible.h
+++ b/accessible/html/HTMLLinkAccessible.h
@@ -10,44 +10,42 @@
 
 namespace mozilla {
 namespace a11y {
 
 class HTMLLinkAccessible : public HyperTextAccessibleWrap
 {
 public:
   HTMLLinkAccessible(nsIContent* aContent, DocAccessible* aDoc);
- 
+
   NS_DECL_ISUPPORTS_INHERITED
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t aIndex);
-
   // Accessible
   virtual void Value(nsString& aValue);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeLinkState() const;
-  virtual uint64_t NativeInteractiveState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeLinkState() const MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // HyperLinkAccessible
   virtual bool IsLink();
   virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex);
 
 protected:
   virtual ~HTMLLinkAccessible() {}
 
   enum { eAction_Jump = 0 };
 
   /**
    * Returns true if the link has href attribute.
    */
-  bool IsLinked();
+  bool IsLinked() const;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/html/HTMLListAccessible.cpp
+++ b/accessible/html/HTMLListAccessible.cpp
@@ -76,31 +76,28 @@ HTMLLIAccessible::NativeRole()
 }
 
 uint64_t
 HTMLLIAccessible::NativeState()
 {
   return HyperTextAccessibleWrap::NativeState() | states::READONLY;
 }
 
-NS_IMETHODIMP
-HTMLLIAccessible::GetBounds(int32_t* aX, int32_t* aY,
-                            int32_t* aWidth, int32_t* aHeight)
+nsIntRect
+HTMLLIAccessible::Bounds() const
 {
-  nsresult rv = AccessibleWrap::GetBounds(aX, aY, aWidth, aHeight);
-  if (NS_FAILED(rv) || !mBullet || mBullet->IsInside())
-    return rv;
+  nsIntRect rect = AccessibleWrap::Bounds();
+  if (rect.IsEmpty() || !mBullet || mBullet->IsInside())
+    return rect;
 
-  int32_t bulletX = 0, bulletY = 0, bulletWidth = 0, bulletHeight = 0;
-  rv = mBullet->GetBounds(&bulletX, &bulletY, &bulletWidth, &bulletHeight);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsIntRect bulletRect = mBullet->Bounds();
 
-  *aWidth += *aX - bulletX;
-  *aX = bulletX; // Move x coordinate of list item over to cover bullet as well
-  return NS_OK;
+  rect.width += rect.x - bulletRect.x;
+  rect.x = bulletRect.x; // Move x coordinate of list item over to cover bullet as well
+  return rect;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLLIAccessible: public
 
 void
 HTMLLIAccessible::UpdateBullet(bool aHasBullet)
 {
--- a/accessible/html/HTMLListAccessible.h
+++ b/accessible/html/HTMLListAccessible.h
@@ -23,18 +23,18 @@ class HTMLListAccessible : public HyperT
 public:
   HTMLListAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     HyperTextAccessibleWrap(aContent, aDoc) { mGenericTypes |= eList; }
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
 protected:
   virtual ~HTMLListAccessible() { }
 };
 
 
 /**
  * Used for HTML list item (e.g. HTML li).
@@ -42,24 +42,21 @@ protected:
 class HTMLLIAccessible : public HyperTextAccessibleWrap
 {
 public:
   HTMLLIAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
-  // nsIAccessible
-  NS_IMETHOD GetBounds(int32_t* aX, int32_t* aY,
-                       int32_t* aWidth, int32_t* aHeight);
-
   // Accessible
   virtual void Shutdown();
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual nsIntRect Bounds() const MOZ_OVERRIDE;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // HTMLLIAccessible
   HTMLListBulletAccessible* Bullet() const { return mBullet; }
   void UpdateBullet(bool aHasBullet);
 
 protected:
   virtual ~HTMLLIAccessible() { }
 
@@ -78,18 +75,18 @@ class HTMLListBulletAccessible : public 
 {
 public:
   HTMLListBulletAccessible(nsIContent* aContent, DocAccessible* aDoc);
   virtual ~HTMLListBulletAccessible() { }
 
   // Accessible
   virtual nsIFrame* GetFrame() const;
   virtual ENameValueFlag Name(nsString& aName);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
   virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
                             uint32_t aLength = UINT32_MAX);
 
   // HTMLListBulletAccessible
 
   /**
    * Return true if the bullet is inside of list item element boundaries.
    */
--- a/accessible/html/HTMLSelectAccessible.cpp
+++ b/accessible/html/HTMLSelectAccessible.cpp
@@ -226,26 +226,25 @@ HTMLSelectOptionAccessible::NativeState(
     }
   } else {
     // XXX list frames are weird, don't rely on Accessible's general
     // visibility implementation unless they get reimplemented in layout
     state &= ~states::OFFSCREEN;
     // <select> is not collapsed: compare bounds to calculate OFFSCREEN
     Accessible* listAcc = Parent();
     if (listAcc) {
-      int32_t optionX, optionY, optionWidth, optionHeight;
-      int32_t listX, listY, listWidth, listHeight;
-      GetBounds(&optionX, &optionY, &optionWidth, &optionHeight);
-      listAcc->GetBounds(&listX, &listY, &listWidth, &listHeight);
-      if (optionY < listY || optionY + optionHeight > listY + listHeight) {
+      nsIntRect optionRect = Bounds();
+      nsIntRect listRect = listAcc->Bounds();
+      if (optionRect.y < listRect.y ||
+          optionRect.y + optionRect.height > listRect.y + listRect.height) {
         state |= states::OFFSCREEN;
       }
     }
   }
- 
+
   return state;
 }
 
 uint64_t
 HTMLSelectOptionAccessible::NativeInteractiveState() const
 {
   return NativelyUnavailable() ?
     states::UNAVAILABLE : states::FOCUSABLE | states::SELECTABLE;
@@ -260,64 +259,55 @@ HTMLSelectOptionAccessible::GetLevelInte
     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
-HTMLSelectOptionAccessible::GetBoundsRect(nsRect& aTotalBounds,
-                                          nsIFrame** aBoundingFrame)
+nsRect
+HTMLSelectOptionAccessible::RelativeBounds(nsIFrame** aBoundingFrame) const
 {
   Accessible* combobox = GetCombobox();
   if (combobox && (combobox->State() & states::COLLAPSED))
-    combobox->GetBoundsRect(aTotalBounds, aBoundingFrame);
-  else
-    HyperTextAccessibleWrap::GetBoundsRect(aTotalBounds, aBoundingFrame);
+    return combobox->RelativeBounds(aBoundingFrame);
+
+  return HyperTextAccessibleWrap::RelativeBounds(aBoundingFrame);
 }
 
-NS_IMETHODIMP
-HTMLSelectOptionAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+HTMLSelectOptionAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (aIndex == eAction_Select) {
-    aName.AssignLiteral("select"); 
-    return NS_OK;
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex == eAction_Select)
+    aName.AssignLiteral("select");
 }
 
 uint8_t
 HTMLSelectOptionAccessible::ActionCount()
 {
   return 1;
 }
 
-NS_IMETHODIMP
+bool
 HTMLSelectOptionAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != eAction_Select)
-    return NS_ERROR_INVALID_ARG;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
+    return false;
 
   DoCommand();
-  return NS_OK;
+  return true;
 }
 
-NS_IMETHODIMP
+void
 HTMLSelectOptionAccessible::SetSelected(bool aSelect)
 {
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   HTMLOptionElement* option = HTMLOptionElement::FromContent(mContent);
-  return option ? option->SetSelected(aSelect) : NS_ERROR_FAILURE;
+  if (option)
+    option->SetSelected(aSelect);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLSelectOptionAccessible: Widgets
 
 Accessible*
 HTMLSelectOptionAccessible::ContainerWidget() const
 {
@@ -339,34 +329,34 @@ HTMLSelectOptGroupAccessible::NativeRole
 }
 
 uint64_t
 HTMLSelectOptGroupAccessible::NativeInteractiveState() const
 {
   return NativelyUnavailable() ? states::UNAVAILABLE : 0;
 }
 
-NS_IMETHODIMP
-HTMLSelectOptGroupAccessible::DoAction(uint8_t index)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-HTMLSelectOptGroupAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 uint8_t
 HTMLSelectOptGroupAccessible::ActionCount()
 {
   return 0;
 }
 
+void
+HTMLSelectOptGroupAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
+{
+  aName.Truncate();
+}
+
+bool
+HTMLSelectOptGroupAccessible::DoAction(uint8_t aIndex)
+{
+  return false;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLComboboxAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 HTMLComboboxAccessible::
   HTMLComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   AccessibleWrap(aContent, aDoc)
 {
@@ -472,51 +462,40 @@ HTMLComboboxAccessible::Value(nsString& 
 }
 
 uint8_t
 HTMLComboboxAccessible::ActionCount()
 {
   return 1;
 }
 
-NS_IMETHODIMP
+bool
 HTMLComboboxAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != eAction_Click)
-    return NS_ERROR_INVALID_ARG;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
+    return false;
 
   DoCommand();
-  return NS_OK;
+  return true;
 }
 
-/**
-  * Our action name is the reverse of our state: 
-  *     if we are closed -> open is our name.
-  *     if we are open -> closed is our name.
-  * Uses the frame to get the state, updated on every click
-  */
-NS_IMETHODIMP
-HTMLComboboxAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+HTMLComboboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (aIndex != HTMLComboboxAccessible::eAction_Click) {
-    return NS_ERROR_INVALID_ARG;
-  }
+  if (aIndex != HTMLComboboxAccessible::eAction_Click)
+    return;
+
   nsIComboboxControlFrame* comboFrame = do_QueryFrame(GetFrame());
-  if (!comboFrame) {
-    return NS_ERROR_FAILURE;
-  }
+  if (!comboFrame)
+    return;
+
   if (comboFrame->IsDroppedDown())
-    aName.AssignLiteral("close"); 
+    aName.AssignLiteral("close");
   else
-    aName.AssignLiteral("open"); 
-
-  return NS_OK;
+    aName.AssignLiteral("open");
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLComboboxAccessible: Widgets
 
 bool
 HTMLComboboxAccessible::IsWidget() const
 {
@@ -620,47 +599,42 @@ HTMLComboboxListAccessible::NativeState(
   if (comboFrame && comboFrame->IsDroppedDown())
     state |= states::FLOATING;
   else
     state |= states::INVISIBLE;
 
   return state;
 }
 
-/**
-  * Gets the bounds for the areaFrame.
-  *     Walks the Frame tree and checks for proper frames.
-  */
-void
-HTMLComboboxListAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame)
+nsRect
+HTMLComboboxListAccessible::RelativeBounds(nsIFrame** aBoundingFrame) const
 {
   *aBoundingFrame = nullptr;
 
   Accessible* comboAcc = Parent();
   if (!comboAcc)
-    return;
+    return nsRect();
 
   if (0 == (comboAcc->State() & states::COLLAPSED)) {
-    HTMLSelectListAccessible::GetBoundsRect(aBounds, aBoundingFrame);
-    return;
+    return HTMLSelectListAccessible::RelativeBounds(aBoundingFrame);
   }
 
   // Get the first option.
   nsIContent* content = mContent->GetFirstChild();
-  if (!content) {
-    return;
-  }
+  if (!content)
+    return nsRect();
+
   nsIFrame* frame = content->GetPrimaryFrame();
   if (!frame) {
     *aBoundingFrame = nullptr;
-    return;
+    return nsRect();
   }
 
   *aBoundingFrame = frame->GetParent();
-  aBounds = (*aBoundingFrame)->GetRect();
+  return (*aBoundingFrame)->GetRect();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLComboboxListAccessible: Widgets
 
 bool
 HTMLComboboxListAccessible::IsActiveWidget() const
 {
--- a/accessible/html/HTMLSelectAccessible.h
+++ b/accessible/html/HTMLSelectAccessible.h
@@ -34,18 +34,18 @@ namespace a11y {
 class HTMLSelectListAccessible : public AccessibleWrap
 {
 public:
 
   HTMLSelectListAccessible(nsIContent* aContent, DocAccessible* aDoc);
   virtual ~HTMLSelectListAccessible() {}
 
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // SelectAccessible
   virtual bool SelectAll();
   virtual bool UnselectAll();
 
   // Widgets
   virtual bool IsWidget() const;
   virtual bool IsActiveWidget() const;
@@ -65,31 +65,29 @@ protected:
 class HTMLSelectOptionAccessible : public HyperTextAccessibleWrap
 {
 public:
   enum { eAction_Select = 0 };
 
   HTMLSelectOptionAccessible(nsIContent* aContent, DocAccessible* aDoc);
   virtual ~HTMLSelectOptionAccessible() {}
 
-  // nsIAccessible
-  NS_IMETHOD DoAction(uint8_t index);
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD SetSelected(bool aSelect);
-
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
 
   virtual int32_t GetLevelInternal();
-  virtual void GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame);
+  virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const MOZ_OVERRIDE;
+  virtual void SetSelected(bool aSelect) MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // Widgets
   virtual Accessible* ContainerWidget() const;
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 
@@ -137,26 +135,24 @@ class HTMLSelectOptGroupAccessible : pub
 {
 public:
 
   HTMLSelectOptGroupAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     HTMLSelectOptionAccessible(aContent, aDoc)
     { mType = eHTMLOptGroupType; }
   virtual ~HTMLSelectOptGroupAccessible() {}
 
-  // nsIAccessible
-  NS_IMETHOD DoAction(uint8_t index);
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 };
 
 /** ------------------------------------------------------ */
 /**  Finally, the Combobox widgets                         */
 /** ------------------------------------------------------ */
 
 class HTMLComboboxListAccessible;
 
@@ -166,30 +162,28 @@ class HTMLComboboxListAccessible;
 class HTMLComboboxAccessible MOZ_FINAL : public AccessibleWrap
 {
 public:
   enum { eAction_Click = 0 };
 
   HTMLComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
   virtual ~HTMLComboboxAccessible() {}
 
-  // nsIAccessible
-  NS_IMETHOD DoAction(uint8_t index);
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-
   // Accessible
   virtual void Shutdown();
   virtual void Description(nsString& aDescription);
   virtual void Value(nsString& aValue);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
   virtual void InvalidateChildren();
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsWidget() const;
   virtual bool IsActiveWidget() const;
   virtual bool AreItemsOperable() const;
   virtual Accessible* CurrentItem();
   virtual void SetCurrentItem(Accessible* aItem);
 
@@ -216,19 +210,19 @@ class HTMLComboboxListAccessible : publi
 public:
 
   HTMLComboboxListAccessible(nsIAccessible* aParent, nsIContent* aContent,
                              DocAccessible* aDoc);
   virtual ~HTMLComboboxListAccessible() {}
 
   // Accessible
   virtual nsIFrame* GetFrame() const;
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
-  virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual nsRect RelativeBounds(nsIFrame** aBoundingFrame) const MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsActiveWidget() const;
   virtual bool AreItemsOperable() const;
 };
 
 } // namespace a11y
 } // namespace mozilla
--- a/accessible/html/HTMLTableAccessible.cpp
+++ b/accessible/html/HTMLTableAccessible.cpp
@@ -455,17 +455,17 @@ HTMLTableAccessible::RelationByType(Rela
 
   return rel;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // HTMLTableAccessible: nsIAccessibleTable implementation
 
 Accessible*
-HTMLTableAccessible::Caption()
+HTMLTableAccessible::Caption() const
 {
   Accessible* child = mChildren.SafeElementAt(0, nullptr);
   return child && child->Role() == roles::CAPTION ? child : nullptr;
 }
 
 void
 HTMLTableAccessible::Summary(nsString& aSummary)
 {
--- a/accessible/html/HTMLTableAccessible.h
+++ b/accessible/html/HTMLTableAccessible.h
@@ -34,19 +34,19 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIAccessibleTableCell
   NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
 
   // Accessible
   virtual TableCellAccessible* AsTableCell() { return this; }
   virtual void Shutdown();
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
 
   // TableCellAccessible
   virtual TableAccessible* Table() const MOZ_OVERRIDE;
   virtual uint32_t ColIdx() const MOZ_OVERRIDE;
   virtual uint32_t RowIdx() const MOZ_OVERRIDE;
   virtual uint32_t ColExtent() const MOZ_OVERRIDE;
   virtual uint32_t RowExtent() const MOZ_OVERRIDE;
@@ -78,17 +78,17 @@ protected:
  * HTML table row/column header accessible (html:th or html:td@scope).
  */
 class HTMLTableHeaderCellAccessible : public HTMLTableCellAccessible
 {
 public:
   HTMLTableHeaderCellAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 };
 
 
 /**
  * HTML table row accessible (html:tr).
  */
 class HTMLTableRowAccessible : public AccessibleWrap
 {
@@ -98,17 +98,17 @@ public:
   {
     mType = eHTMLTableRowType;
     mGenericTypes |= eTableRow;
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 
 protected:
   virtual ~HTMLTableRowAccessible() { }
 };
 
 
 /**
  * HTML table accessible (html:table).
@@ -133,17 +133,17 @@ public:
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIAccessible Table
   NS_FORWARD_NSIACCESSIBLETABLE(xpcAccessibleTable::)
 
   // TableAccessible
-  virtual Accessible* Caption();
+  virtual Accessible* Caption() const;
   virtual void Summary(nsString& aSummary);
   virtual uint32_t ColCount();
   virtual uint32_t RowCount();
   virtual Accessible* CellAt(uint32_t aRowIndex, uint32_t aColumnIndex);
   virtual int32_t CellIndexAt(uint32_t aRowIdx, uint32_t aColIdx);
   virtual int32_t ColIndexAt(uint32_t aCellIdx);
   virtual int32_t RowIndexAt(uint32_t aCellIdx);
   virtual void RowAndColIndicesAt(uint32_t aCellIdx, int32_t* aRowIdx,
@@ -166,18 +166,18 @@ public:
   virtual void UnselectRow(uint32_t aRowIdx);
   virtual bool IsProbablyLayoutTable();
   virtual Accessible* AsAccessible() { return this; }
 
   // Accessible
   virtual void Shutdown();
   virtual TableAccessible* AsTable() { return this; }
   virtual void Description(nsString& aDescription);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
 
 protected:
   virtual ~HTMLTableAccessible() {}
 
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
@@ -229,16 +229,16 @@ class HTMLCaptionAccessible : public Hyp
 public:
   HTMLCaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     HyperTextAccessibleWrap(aContent, aDoc) { }
   virtual ~HTMLCaptionAccessible() { }
 
   // nsIAccessible
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aRelationType) MOZ_OVERRIDE;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/interfaces/nsIAccessible.idl
+++ b/accessible/interfaces/nsIAccessible.idl
@@ -17,17 +17,17 @@ interface nsIAccessibleRelation;
  * accessibility APIs like MSAA and ATK. Contains the sum of what's needed
  * to support IAccessible as well as ATK's generic accessibility objects.
  * Can also be used by in-process accessibility clients to get information
  * about objects in the accessible tree. The accessible tree is a subset of 
  * nodes in the DOM tree -- such as documents, focusable elements and text.
  * Mozilla creates the implementations of nsIAccessible on demand.
  * See http://www.mozilla.org/projects/ui/accessibility for more information.
  */
-[scriptable, uuid(ee62158b-bb83-424b-a88d-d7d7f9cf460d)]
+[scriptable, uuid(66b110b0-c25a-4784-8623-f6ba40c7cfee)]
 interface nsIAccessible : nsISupports
 {
   /**
    * Parent node in accessible tree.
    */
   readonly attribute nsIAccessible parent;
 
   /**
@@ -91,17 +91,17 @@ interface nsIAccessible : nsISupports
    * specified by ARIA or by native markup. Example of ARIA markup is
    * aria-labelledby attribute placed on element of this accessible. Example
    * of native markup is HTML label linked with HTML element of this accessible.
    *
    * Value can be string or null. A null value indicates that AT may attempt to
    * compute the name. Any string value, including the empty string, should be
    * considered author-intentional, and respected.
    */
-  attribute AString name;
+  readonly attribute AString name;
 
   /**
    * Accessible value -- a number or a secondary text equivalent for this node
    * Widgets that use role attribute can force a value using the valuenow attribute
    */
   readonly attribute AString value;
 
   /**
@@ -193,16 +193,17 @@ interface nsIAccessible : nsISupports
    * @param y  screen's y coordinate
    * @return   the deepest accessible child containing the given point
    */
   nsIAccessible getDeepestChildAtPoint(in long x, in long y);
 
   /**
    * Nth accessible child using zero-based index or last child if index less than zero
    */
+  [binaryname(ScriptableGetChildAt)]
   nsIAccessible getChildAt(in long aChildIndex);
 
   /**
    * Return accessible relation by the given relation type (see.
    * constants defined in nsIAccessibleRelation).
    */
   nsIAccessibleRelation getRelationByType(in unsigned long aRelationType);
 
@@ -215,37 +216,40 @@ interface nsIAccessible : nsISupports
    * Return accessible's x and y coordinates relative to the screen and
    * accessible's width and height.
    */
   void getBounds(out long x, out long y, out long width, out long height);
 
   /**
    * Add or remove this accessible to the current selection
    */
+  [binaryname(ScriptableSetSelected)]
   void setSelected(in boolean isSelected);
 
   /**
    * Extend the current selection from its current accessible anchor node
    * to this accessible
    */
   void extendSelection();
 
   /**
    * Select this accessible node only
    */
+  [binaryname(ScriptableTakeSelection)]
   void takeSelection();
 
   /**
    * Focus this accessible node,
    * The state STATE_FOCUSABLE indicates whether this node is normally focusable.
    * It is the callers responsibility to determine whether this node is focusable.
    * accTakeFocus on a node that is not normally focusable (such as a table),
    * will still set focus on that node, although normally that will not be visually 
    * indicated in most style sheets.
    */
+  [binaryname(ScriptableTakeFocus)]
   void takeFocus();
 
   /**
    * The number of accessible actions associated with this accessible
    */
   readonly attribute uint8_t actionCount;
 
   /**
@@ -257,36 +261,39 @@ interface nsIAccessible : nsISupports
    * The description of the accessible action at the given zero-based index
    */
   AString getActionDescription(in uint8_t aIndex);
 
   /**
    * Perform the accessible action at the given zero-based index
    * Action number 0 is the default action
    */
-  void doAction(in uint8_t index);   
+  [binaryname(ScriptableDoAction)]
+  void doAction(in uint8_t index);
 
   /**
    * Makes an object visible on screen.
    *
    * @param scrollType - defines where the object should be placed on
    *                     the screen (see nsIAccessibleScrollType for
    *                     available constants).
    */
+  [binaryname(ScriptableScrollTo)]
   void scrollTo(in unsigned long aScrollType);
 
   /**
    * Moves the top left of an object to a specified location.
    *
    * @param coordinateType [in] - specifies whether the coordinates are relative to
    *                         the screen or the parent object (for available
    *                         constants refer to nsIAccessibleCoordinateType)
    * @param x [in] - defines the x coordinate
    * @param y [in] - defines the y coordinate
   */
+  [binaryname(ScriptableScrollToPoint)]
   void scrollToPoint(in unsigned long coordinateType, in long x, in long y);
 
   /**
    * Get a pointer to accessibility interface for this node, which is specific 
    * to the OS/accessibility toolkit we're running on.
    */
   [noscript] void getNativeInterface(out voidPtr aOutAccessible);
 };
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -369,23 +369,22 @@ GetClosestInterestingAccessible(id anObj
 
 - (NSValue*)position
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if (!mGeckoAccessible)
     return nil;
 
-  int32_t x = 0, y = 0, width = 0, height = 0;
-  mGeckoAccessible->GetBounds(&x, &y, &width, &height);
+  nsIntRect rect = mGeckoAccessible->Bounds();
 
   NSScreen* mainView = [[NSScreen screens] objectAtIndex:0];
   CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(mainView);
-  NSPoint p = NSMakePoint(static_cast<CGFloat>(x) / scaleFactor,
-                         [mainView frame].size.height - static_cast<CGFloat>(y + height) / scaleFactor);
+  NSPoint p = NSMakePoint(static_cast<CGFloat>(rect.x) / scaleFactor,
+                         [mainView frame].size.height - static_cast<CGFloat>(rect.y + rect.height) / scaleFactor);
 
   return [NSValue valueWithPoint:p];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (NSValue*)size
 {
@@ -605,19 +604,19 @@ GetClosestInterestingAccessible(id anObj
 {
   return mGeckoAccessible && (mGeckoAccessible->InteractiveState() & states::FOCUSABLE);
 }
 
 - (BOOL)focus
 {
   if (!mGeckoAccessible)
     return NO;
-  
-  nsresult rv = mGeckoAccessible->TakeFocus();
-  return NS_SUCCEEDED(rv);
+
+  mGeckoAccessible->TakeFocus();
+  return YES;
 }
 
 - (BOOL)isEnabled
 {
   return mGeckoAccessible && ((mGeckoAccessible->InteractiveState() & states::UNAVAILABLE) == 0);
 }
 
 // The root accessible calls this when the focused node was
--- a/accessible/windows/ia2/ia2Accessible.cpp
+++ b/accessible/windows/ia2/ia2Accessible.cpp
@@ -216,18 +216,18 @@ ia2Accessible::scrollToPoint(enum IA2Coo
   AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
   if (acc->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   uint32_t geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
     nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
     nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
 
-  nsresult rv = acc->ScrollToPoint(geckoCoordType, aX, aY);
-  return GetHRESULT(rv);
+  acc->ScrollToPoint(geckoCoordType, aX, aY);
+  return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2Accessible::get_groupPosition(long* aGroupLevel,
                                  long* aSimilarItemsInGroup,
                                  long* aPositionInGroup)
--- a/accessible/windows/ia2/ia2AccessibleAction.cpp
+++ b/accessible/windows/ia2/ia2AccessibleAction.cpp
@@ -60,18 +60,17 @@ ia2AccessibleAction::doAction(long aActi
 {
   A11Y_TRYBLOCK_BEGIN
 
   AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
   if (acc->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   uint8_t index = static_cast<uint8_t>(aActionIndex);
-  nsresult rv = acc->DoAction(index);
-  return GetHRESULT(rv);
+  return acc->DoAction(index) ? S_OK : E_INVALIDARG;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleAction::get_description(long aActionIndex, BSTR *aDescription)
 {
   A11Y_TRYBLOCK_BEGIN
@@ -162,22 +161,19 @@ ia2AccessibleAction::get_name(long aActi
   *aName = nullptr;
 
   AccessibleWrap* acc = static_cast<AccessibleWrap*>(this);
   if (acc->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   nsAutoString name;
   uint8_t index = static_cast<uint8_t>(aActionIndex);
-  nsresult rv = acc->GetActionName(index, name);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
+  acc->ActionNameAt(index, name);
   if (name.IsEmpty())
-    return S_FALSE;
+    return E_INVALIDARG;
 
   *aName = ::SysAllocStringLen(name.get(), name.Length());
   return *aName ? S_OK : E_OUTOFMEMORY;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
--- a/accessible/windows/ia2/ia2AccessibleComponent.cpp
+++ b/accessible/windows/ia2/ia2AccessibleComponent.cpp
@@ -53,41 +53,32 @@ ia2AccessibleComponent::get_locationInPa
   if (acc->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   // If the object is not on any screen the returned position is (0,0).
   uint64_t state = acc->State();
   if (state & states::INVISIBLE)
     return S_OK;
 
-  int32_t x = 0, y = 0, width = 0, height = 0;
-  nsresult rv = acc->GetBounds(&x, &y, &width, &height);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
-  Accessible* parentAcc = acc->Parent();
+  nsIntRect rect = acc->Bounds();
 
   // The coordinates of the returned position are relative to this object's
   // parent or relative to the screen on which this object is rendered if it
   // has no parent.
-  if (!parentAcc) {
-    *aX = x;
-    *aY = y;
+  if (!acc->Parent()) {
+    *aX = rect.x;
+    *aY = rect.y;
     return S_OK;
   }
 
   // The coordinates of the bounding box are given relative to the parent's
   // coordinate system.
-  int32_t parentx = 0, parenty = 0;
-  rv = acc->GetBounds(&parentx, &parenty, &width, &height);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
-
-  *aX = x - parentx;
-  *aY = y - parenty;
+  nsIntRect parentRect = acc->Parent()->Bounds();
+  *aX = rect.x - parentRect.x;
+  *aY = rect.y - parentRect.y;
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 ia2AccessibleComponent::get_foreground(IA2Color* aForeground)
 {
--- a/accessible/windows/msaa/AccessibleWrap.cpp
+++ b/accessible/windows/msaa/AccessibleWrap.cpp
@@ -773,19 +773,17 @@ AccessibleWrap::get_accDefaultAction(
   Accessible* xpAccessible = GetXPAccessibleFor(varChild);
   if (!xpAccessible)
     return E_INVALIDARG;
 
   if (xpAccessible->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
   nsAutoString defaultAction;
-  if (NS_FAILED(xpAccessible->GetActionName(0, defaultAction)))
-    return E_FAIL;
-
+  xpAccessible->ActionNameAt(0, defaultAction);
   *pszDefaultAction = ::SysAllocStringLen(defaultAction.get(),
                                           defaultAction.Length());
   return *pszDefaultAction ? S_OK : E_OUTOFMEMORY;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
@@ -854,24 +852,21 @@ AccessibleWrap::accLocation(
 
   Accessible* xpAccessible = GetXPAccessibleFor(varChild);
   if (!xpAccessible)
     return E_INVALIDARG;
 
   if (xpAccessible->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
-  int32_t x, y, width, height;
-  if (NS_FAILED(xpAccessible->GetBounds(&x, &y, &width, &height)))
-    return E_FAIL;
-
-  *pxLeft = x;
-  *pyTop = y;
-  *pcxWidth = width;
-  *pcyHeight = height;
+  nsIntRect rect = xpAccessible->Bounds();
+  *pxLeft = rect.x;
+  *pyTop = rect.y;
+  *pcxWidth = rect.width;
+  *pcyHeight = rect.height;
   return S_OK;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 AccessibleWrap::accNavigate(
       /* [in] */ long navDir,
@@ -999,17 +994,17 @@ AccessibleWrap::accDoDefaultAction(
 
   Accessible* xpAccessible = GetXPAccessibleFor(varChild);
   if (!xpAccessible)
     return E_INVALIDARG;
 
   if (xpAccessible->IsDefunct())
     return CO_E_OBJNOTCONNECTED;
 
-  return GetHRESULT(xpAccessible->DoAction(0));
+  return xpAccessible->DoAction(0) ? S_OK : E_INVALIDARG;
 
   A11Y_TRYBLOCK_END
 }
 
 STDMETHODIMP
 AccessibleWrap::put_accName(
       /* [optional][in] */ VARIANT varChild,
       /* [in] */ BSTR szName)
--- a/accessible/windows/msaa/DocAccessibleWrap.cpp
+++ b/accessible/windows/msaa/DocAccessibleWrap.cpp
@@ -124,32 +124,32 @@ DocAccessibleWrap::DoInitialUpdate()
       mozilla::WindowsHandle nativeData = 0;
       if (tabChild)
         tabChild->SendGetWidgetNativeData(&nativeData);
       else
         nativeData = reinterpret_cast<mozilla::WindowsHandle>(
           rootDocument->GetNativeWindow());
 
       bool isActive = true;
-      int32_t x = CW_USEDEFAULT, y = CW_USEDEFAULT, width = 0, height = 0;
+      nsIntRect rect(CW_USEDEFAULT, CW_USEDEFAULT, 0, 0);
       if (Compatibility::IsDolphin()) {
-        GetBounds(&x, &y, &width, &height);
-        int32_t rootX = 0, rootY = 0, rootWidth = 0, rootHeight = 0;
-        rootDocument->GetBounds(&rootX, &rootY, &rootWidth, &rootHeight);
-        x = rootX - x;
-        y -= rootY;
+        rect = Bounds();
+        nsIntRect rootRect = rootDocument->Bounds();
+        rect.x = rootRect.x - rect.x;
+        rect.y -= rootRect.y;
 
         nsCOMPtr<nsISupports> container = mDocumentNode->GetContainer();
         nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
         docShell->GetIsActive(&isActive);
       }
 
       HWND parentWnd = reinterpret_cast<HWND>(nativeData);
       mHWND = nsWinUtils::CreateNativeWindow(kClassNameTabContent, parentWnd,
-                                             x, y, width, height, isActive);
+                                             rect.x, rect.y,
+                                             rect.width, rect.height, isActive);
 
       nsWinUtils::sHWNDCache->Put(mHWND, this);
 
     } else {
       DocAccessible* parentDocument = ParentDocument();
       if (parentDocument)
         mHWND = parentDocument->GetNativeWindow();
     }
--- a/accessible/windows/sdn/sdnTextAccessible.cpp
+++ b/accessible/windows/sdn/sdnTextAccessible.cpp
@@ -70,21 +70,18 @@ sdnTextAccessible::get_clippedSubstringB
                                             &x, &y, &width, &height);
   if (FAILED(rv))
     return rv;
 
   DocAccessible* document = mAccessible->Document();
   NS_ASSERTION(document,
                "There must always be a doc accessible, but there isn't. Crash!");
 
-  nscoord docX = 0, docY = 0, docWidth = 0, docHeight = 0;
-  document->GetBounds(&docX, &docY, &docWidth, &docHeight);
-
+  nsIntRect docRect = document->Bounds();
   nsIntRect unclippedRect(x, y, width, height);
-  nsIntRect docRect(docX, docY, docWidth, docHeight);
 
   nsIntRect clippedRect;
   clippedRect.IntersectRect(unclippedRect, docRect);
 
   *aX = clippedRect.x;
   *aY = clippedRect.y;
   *aWidth = clippedRect.width;
   *aHeight = clippedRect.height;
--- a/accessible/xpcom/moz.build
+++ b/accessible/xpcom/moz.build
@@ -1,22 +1,26 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 EXPORTS += [
+    'xpcAccessible.h',
+    'xpcAccessibleHyperLink.h',
     'xpcAccessibleHyperText.h',
     'xpcAccessibleSelectable.h',
     'xpcAccessibleValue.h',
 ]
 
 UNIFIED_SOURCES += [
     'nsAccessibleRelation.cpp',
+    'xpcAccessible.cpp',
+    'xpcAccessibleHyperLink.cpp',
     'xpcAccessibleHyperText.cpp',
     'xpcAccessibleSelectable.cpp',
     'xpcAccessibleTable.cpp',
     'xpcAccessibleTableCell.cpp',
     'xpcAccessibleTextRange.cpp',
     'xpcAccessibleValue.cpp',
 ]
 
new file mode 100644
--- /dev/null
+++ b/accessible/xpcom/xpcAccessible.cpp
@@ -0,0 +1,572 @@
+/* -*- 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/. */
+
+#include "xpcAccessible.h"
+
+#include "Accessible-inl.h"
+#include "nsAccUtils.h"
+#include "nsIAccessibleRelation.h"
+#include "nsIAccessibleRole.h"
+#include "nsAccessibleRelation.h"
+#include "Relation.h"
+#include "Role.h"
+#include "RootAccessible.h"
+
+#include "nsIMutableArray.h"
+#include "nsIPersistentProperties2.h"
+
+using namespace mozilla::a11y;
+
+NS_IMETHODIMP
+xpcAccessible::GetParent(nsIAccessible** aParent)
+{
+  NS_ENSURE_ARG_POINTER(aParent);
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  NS_IF_ADDREF(*aParent = static_cast<Accessible*>(this)->Parent());
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetNextSibling(nsIAccessible** aNextSibling)
+{
+  NS_ENSURE_ARG_POINTER(aNextSibling);
+  *aNextSibling = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsresult rv = NS_OK;
+  NS_IF_ADDREF(*aNextSibling = static_cast<Accessible*>(this)->GetSiblingAtOffset(1, &rv));
+  return rv;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetPreviousSibling(nsIAccessible** aPreviousSibling)
+{
+  NS_ENSURE_ARG_POINTER(aPreviousSibling);
+  *aPreviousSibling = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsresult rv = NS_OK;
+  NS_IF_ADDREF(*aPreviousSibling = static_cast<Accessible*>(this)->GetSiblingAtOffset(-1, &rv));
+  return rv;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetFirstChild(nsIAccessible** aFirstChild)
+{
+  NS_ENSURE_ARG_POINTER(aFirstChild);
+  *aFirstChild = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  NS_IF_ADDREF(*aFirstChild = static_cast<Accessible*>(this)->FirstChild());
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetLastChild(nsIAccessible** aLastChild)
+{
+  NS_ENSURE_ARG_POINTER(aLastChild);
+  *aLastChild = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  NS_IF_ADDREF(*aLastChild = static_cast<Accessible*>(this)->LastChild());
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetChildCount(int32_t* aChildCount)
+{
+  NS_ENSURE_ARG_POINTER(aChildCount);
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  *aChildCount = static_cast<Accessible*>(this)->ChildCount();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::ScriptableGetChildAt(int32_t aChildIndex, nsIAccessible** aChild)
+{
+  NS_ENSURE_ARG_POINTER(aChild);
+  *aChild = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  // If child index is negative, then return last child.
+  // XXX: do we really need this?
+  if (aChildIndex < 0)
+    aChildIndex = static_cast<Accessible*>(this)->ChildCount() - 1;
+
+  Accessible* child = static_cast<Accessible*>(this)->GetChildAt(aChildIndex);
+  if (!child)
+    return NS_ERROR_INVALID_ARG;
+
+  NS_ADDREF(*aChild = child);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetChildren(nsIArray** aChildren)
+{
+  NS_ENSURE_ARG_POINTER(aChildren);
+  *aChildren = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsresult rv = NS_OK;
+  nsCOMPtr<nsIMutableArray> children =
+    do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  uint32_t childCount = static_cast<Accessible*>(this)->ChildCount();
+  for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
+    nsIAccessible* child = static_cast<Accessible*>(this)->GetChildAt(childIdx);
+    children->AppendElement(child, false);
+  }
+
+  NS_ADDREF(*aChildren = children);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetIndexInParent(int32_t* aIndexInParent)
+{
+  NS_ENSURE_ARG_POINTER(aIndexInParent);
+
+  *aIndexInParent = static_cast<Accessible*>(this)->IndexInParent();
+  return *aIndexInParent != -1 ? NS_OK : NS_ERROR_FAILURE;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetDOMNode(nsIDOMNode** aDOMNode)
+{
+  NS_ENSURE_ARG_POINTER(aDOMNode);
+  *aDOMNode = nullptr;
+
+  nsINode *node = static_cast<Accessible*>(this)->GetNode();
+  if (node)
+    CallQueryInterface(node, aDOMNode);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetDocument(nsIAccessibleDocument** aDocument)
+{
+  NS_ENSURE_ARG_POINTER(aDocument);
+
+  NS_IF_ADDREF(*aDocument = static_cast<Accessible*>(this)->Document());
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetRootDocument(nsIAccessibleDocument** aRootDocument)
+{
+  NS_ENSURE_ARG_POINTER(aRootDocument);
+
+  NS_IF_ADDREF(*aRootDocument = static_cast<Accessible*>(this)->RootAccessible());
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetRole(uint32_t* aRole)
+{
+  NS_ENSURE_ARG_POINTER(aRole);
+  *aRole = nsIAccessibleRole::ROLE_NOTHING;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  *aRole = static_cast<Accessible*>(this)->Role();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetState(uint32_t* aState, uint32_t* aExtraState)
+{
+  NS_ENSURE_ARG_POINTER(aState);
+
+  nsAccUtils::To32States(static_cast<Accessible*>(this)->State(),
+                         aState, aExtraState);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetName(nsAString& aName)
+{
+  aName.Truncate();
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsAutoString name;
+  static_cast<Accessible*>(this)->Name(name);
+  aName.Assign(name);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetDescription(nsAString& aDescription)
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsAutoString desc;
+  static_cast<Accessible*>(this)->Description(desc);
+  aDescription.Assign(desc);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetLanguage(nsAString& aLanguage)
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  static_cast<Accessible*>(this)->Language(aLanguage);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetValue(nsAString& aValue)
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsAutoString value;
+  static_cast<Accessible*>(this)->Value(value);
+  aValue.Assign(value);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetHelp(nsAString& aHelp)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetAccessKey(nsAString& aAccessKey)
+{
+  aAccessKey.Truncate();
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  static_cast<Accessible*>(this)->AccessKey().ToString(aAccessKey);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetKeyboardShortcut(nsAString& aKeyBinding)
+{
+  aKeyBinding.Truncate();
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  static_cast<Accessible*>(this)->KeyboardShortcut().ToString(aKeyBinding);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
+{
+  NS_ENSURE_ARG_POINTER(aAttributes);
+  *aAttributes = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsCOMPtr<nsIPersistentProperties> attributes =
+    static_cast<Accessible*>(this)->Attributes();
+  attributes.swap(*aAttributes);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetBounds(int32_t* aX, int32_t* aY,
+                         int32_t* aWidth, int32_t* aHeight)
+{
+  NS_ENSURE_ARG_POINTER(aX);
+  *aX = 0;
+  NS_ENSURE_ARG_POINTER(aY);
+  *aY = 0;
+  NS_ENSURE_ARG_POINTER(aWidth);
+  *aWidth = 0;
+  NS_ENSURE_ARG_POINTER(aHeight);
+  *aHeight = 0;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsIntRect rect = static_cast<Accessible*>(this)->Bounds();
+  *aX = rect.x;
+  *aY = rect.y;
+  *aWidth = rect.width;
+  *aHeight = rect.height;;
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::ScriptableGroupPosition(int32_t* aGroupLevel,
+                                       int32_t* aSimilarItemsInGroup,
+                                       int32_t* aPositionInGroup)
+{
+  NS_ENSURE_ARG_POINTER(aGroupLevel);
+  *aGroupLevel = 0;
+
+  NS_ENSURE_ARG_POINTER(aSimilarItemsInGroup);
+  *aSimilarItemsInGroup = 0;
+
+  NS_ENSURE_ARG_POINTER(aPositionInGroup);
+  *aPositionInGroup = 0;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  GroupPos groupPos = static_cast<Accessible*>(this)->GroupPosition();
+
+  *aGroupLevel = groupPos.level;
+  *aSimilarItemsInGroup = groupPos.setSize;
+  *aPositionInGroup = groupPos.posInSet;
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetRelationByType(uint32_t aType,
+                                 nsIAccessibleRelation** aRelation)
+{
+  NS_ENSURE_ARG_POINTER(aRelation);
+  *aRelation = nullptr;
+
+  NS_ENSURE_ARG(aType <= static_cast<uint32_t>(RelationType::LAST));
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  Relation rel = static_cast<Accessible*>(this)->RelationByType(static_cast<RelationType>(aType));
+  NS_ADDREF(*aRelation = new nsAccessibleRelation(aType, &rel));
+  return *aRelation ? NS_OK : NS_ERROR_FAILURE;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetRelations(nsIArray** aRelations)
+{
+  NS_ENSURE_ARG_POINTER(aRelations);
+  *aRelations = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  nsCOMPtr<nsIMutableArray> relations = do_CreateInstance(NS_ARRAY_CONTRACTID);
+  NS_ENSURE_TRUE(relations, NS_ERROR_OUT_OF_MEMORY);
+
+  static const uint32_t relationTypes[] = {
+    nsIAccessibleRelation::RELATION_LABELLED_BY,
+    nsIAccessibleRelation::RELATION_LABEL_FOR,
+    nsIAccessibleRelation::RELATION_DESCRIBED_BY,
+    nsIAccessibleRelation::RELATION_DESCRIPTION_FOR,
+    nsIAccessibleRelation::RELATION_NODE_CHILD_OF,
+    nsIAccessibleRelation::RELATION_NODE_PARENT_OF,
+    nsIAccessibleRelation::RELATION_CONTROLLED_BY,
+    nsIAccessibleRelation::RELATION_CONTROLLER_FOR,
+    nsIAccessibleRelation::RELATION_FLOWS_TO,
+    nsIAccessibleRelation::RELATION_FLOWS_FROM,
+    nsIAccessibleRelation::RELATION_MEMBER_OF,
+    nsIAccessibleRelation::RELATION_SUBWINDOW_OF,
+    nsIAccessibleRelation::RELATION_EMBEDS,
+    nsIAccessibleRelation::RELATION_EMBEDDED_BY,
+    nsIAccessibleRelation::RELATION_POPUP_FOR,
+    nsIAccessibleRelation::RELATION_PARENT_WINDOW_OF,
+    nsIAccessibleRelation::RELATION_DEFAULT_BUTTON,
+    nsIAccessibleRelation::RELATION_CONTAINING_DOCUMENT,
+    nsIAccessibleRelation::RELATION_CONTAINING_TAB_PANE,
+    nsIAccessibleRelation::RELATION_CONTAINING_APPLICATION
+  };
+
+  for (uint32_t idx = 0; idx < ArrayLength(relationTypes); idx++) {
+    nsCOMPtr<nsIAccessibleRelation> relation;
+    nsresult rv = GetRelationByType(relationTypes[idx], getter_AddRefs(relation));
+
+    if (NS_SUCCEEDED(rv) && relation) {
+      uint32_t targets = 0;
+      relation->GetTargetsCount(&targets);
+      if (targets)
+        relations->AppendElement(relation, false);
+    }
+  }
+
+  NS_ADDREF(*aRelations = relations);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetFocusedChild(nsIAccessible** aChild)
+{
+  NS_ENSURE_ARG_POINTER(aChild);
+  *aChild = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  NS_IF_ADDREF(*aChild = static_cast<Accessible*>(this)->FocusedChild());
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetChildAtPoint(int32_t aX, int32_t aY,
+                               nsIAccessible** aAccessible)
+{
+  NS_ENSURE_ARG_POINTER(aAccessible);
+  *aAccessible = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  NS_IF_ADDREF(*aAccessible =
+               static_cast<Accessible*>(this)->ChildAtPoint(aX, aY,
+                                                            Accessible::eDirectChild));
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetDeepestChildAtPoint(int32_t aX, int32_t aY,
+                                      nsIAccessible** aAccessible)
+{
+  NS_ENSURE_ARG_POINTER(aAccessible);
+  *aAccessible = nullptr;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  NS_IF_ADDREF(*aAccessible =
+               static_cast<Accessible*>(this)->ChildAtPoint(aX, aY,
+                                                            Accessible::eDeepestChild));
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::ScriptableSetSelected(bool aSelect)
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  static_cast<Accessible*>(this)->SetSelected(aSelect);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::ExtendSelection()
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+xpcAccessible::ScriptableTakeSelection()
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  static_cast<Accessible*>(this)->TakeSelection();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::ScriptableTakeFocus()
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  static_cast<Accessible*>(this)->TakeFocus();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetActionCount(uint8_t* aActionCount)
+{
+  NS_ENSURE_ARG_POINTER(aActionCount);
+  *aActionCount = 0;
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  *aActionCount = static_cast<Accessible*>(this)->ActionCount();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  if (aIndex >= static_cast<Accessible*>(this)->ActionCount())
+    return NS_ERROR_INVALID_ARG;
+
+  static_cast<Accessible*>(this)->ActionNameAt(aIndex, aName);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::GetActionDescription(uint8_t aIndex, nsAString& aDescription)
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  if (aIndex >= static_cast<Accessible*>(this)->ActionCount())
+    return NS_ERROR_INVALID_ARG;
+
+  static_cast<Accessible*>(this)->ActionDescriptionAt(aIndex, aDescription);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::ScriptableDoAction(uint8_t aIndex)
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  return static_cast<Accessible*>(this)->DoAction(aIndex) ?
+    NS_OK : NS_ERROR_INVALID_ARG;
+}
+
+NS_IMETHODIMP
+xpcAccessible::ScriptableScrollTo(uint32_t aHow)
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  static_cast<Accessible*>(this)->ScrollTo(aHow);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessible::ScriptableScrollToPoint(uint32_t aCoordinateType,
+                                       int32_t aX, int32_t aY)
+{
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  static_cast<Accessible*>(this)->ScrollToPoint(aCoordinateType, aX, aY);
+  return NS_OK;
+}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/accessible/xpcom/xpcAccessible.h
@@ -0,0 +1,88 @@
+/* -*- 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 mozilla_a11y_xpcAccessible_h_
+#define mozilla_a11y_xpcAccessible_h_
+
+#include "nsIAccessible.h"
+
+class nsIAccessible;
+
+namespace mozilla {
+namespace a11y {
+
+class xpcAccessible : public nsIAccessible
+{
+public:
+  NS_IMETHOD GetParent(nsIAccessible** aParent) MOZ_FINAL;
+  NS_IMETHOD GetNextSibling(nsIAccessible** aNextSibling) MOZ_FINAL;
+  NS_IMETHOD GetPreviousSibling(nsIAccessible** aPreviousSibling) MOZ_FINAL;
+  NS_IMETHOD GetFirstChild(nsIAccessible** aFirstChild) MOZ_FINAL;
+  NS_IMETHOD GetLastChild(nsIAccessible** aLastChild) MOZ_FINAL;
+  NS_IMETHOD GetChildCount(int32_t* aChildCount) MOZ_FINAL;
+  NS_IMETHOD ScriptableGetChildAt(int32_t aChildIndex,
+                                  nsIAccessible** aChild) MOZ_FINAL;
+  NS_IMETHOD GetChildren(nsIArray** aChildren) MOZ_FINAL;
+  NS_IMETHOD GetIndexInParent(int32_t* aIndexInParent) MOZ_FINAL;
+
+  NS_IMETHOD GetDOMNode(nsIDOMNode** aDOMNode) MOZ_FINAL;
+  NS_IMETHOD GetDocument(nsIAccessibleDocument** aDocument) MOZ_FINAL;
+  NS_IMETHOD GetRootDocument(nsIAccessibleDocument** aRootDocument) MOZ_FINAL;
+
+  NS_IMETHOD GetRole(uint32_t* aRole) MOZ_FINAL;
+  NS_IMETHOD GetState(uint32_t* aState, uint32_t* aExtraState) MOZ_FINAL;
+
+  NS_IMETHOD GetDescription(nsAString& aDescription) MOZ_FINAL;
+  NS_IMETHOD GetName(nsAString& aName) MOZ_FINAL;
+  NS_IMETHOD GetLanguage(nsAString& aLanguage) MOZ_FINAL;
+  NS_IMETHOD GetValue(nsAString& aValue) MOZ_FINAL;
+  NS_IMETHOD GetHelp(nsAString& aHelp) MOZ_FINAL;
+
+  NS_IMETHOD GetAccessKey(nsAString& aAccessKey) MOZ_FINAL;
+  NS_IMETHOD GetKeyboardShortcut(nsAString& aKeyBinding) MOZ_FINAL;
+
+  NS_IMETHOD GetAttributes(nsIPersistentProperties** aAttributes) MOZ_FINAL;
+  NS_IMETHOD GetBounds(int32_t* aX, int32_t* aY,
+                       int32_t* aWidth, int32_t* aHeight) MOZ_FINAL;
+  NS_IMETHOD ScriptableGroupPosition(int32_t* aGroupLevel,
+                                     int32_t* aSimilarItemsInGroup,
+                                     int32_t* aPositionInGroup) MOZ_FINAL;
+  NS_IMETHOD GetRelationByType(uint32_t aType,
+                               nsIAccessibleRelation** aRelation) MOZ_FINAL;
+  NS_IMETHOD GetRelations(nsIArray** aRelations) MOZ_FINAL;
+
+  NS_IMETHOD GetFocusedChild(nsIAccessible** aChild) MOZ_FINAL;
+  NS_IMETHOD GetChildAtPoint(int32_t aX, int32_t aY,
+                             nsIAccessible** aAccessible) MOZ_FINAL;
+  NS_IMETHOD GetDeepestChildAtPoint(int32_t aX, int32_t aY,
+                                    nsIAccessible** aAccessible) MOZ_FINAL;
+
+  NS_IMETHOD ScriptableSetSelected(bool aSelect) MOZ_FINAL;
+  NS_IMETHOD ExtendSelection() MOZ_FINAL;
+  NS_IMETHOD ScriptableTakeSelection() MOZ_FINAL;
+  NS_IMETHOD ScriptableTakeFocus() MOZ_FINAL;
+
+  NS_IMETHOD GetActionCount(uint8_t* aActionCount) MOZ_FINAL;
+  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName) MOZ_FINAL;
+  NS_IMETHOD GetActionDescription(uint8_t aIndex, nsAString& aDescription) MOZ_FINAL;
+  NS_IMETHOD ScriptableDoAction(uint8_t aIndex) MOZ_FINAL;
+
+  NS_IMETHOD ScriptableScrollTo(uint32_t aHow) MOZ_FINAL;
+  NS_IMETHOD ScriptableScrollToPoint(uint32_t aCoordinateType,
+                                     int32_t aX, int32_t aY) MOZ_FINAL;
+
+private:
+  xpcAccessible() { }
+  friend class Accessible;
+
+  xpcAccessible(const xpcAccessible&) MOZ_DELETE;
+  xpcAccessible& operator =(const xpcAccessible&) MOZ_DELETE;
+};
+
+} // namespace a11y
+} // namespace mozilla
+
+#endif
new file mode 100644
--- /dev/null
+++ b/accessible/xpcom/xpcAccessibleHyperLink.cpp
@@ -0,0 +1,97 @@
+/* -*- 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/. */
+
+#include "xpcAccessibleHyperLink.h"
+
+#include "Accessible-inl.h"
+
+using namespace mozilla::a11y;
+
+NS_IMETHODIMP
+xpcAccessibleHyperLink::GetStartIndex(int32_t* aStartIndex)
+{
+  NS_ENSURE_ARG_POINTER(aStartIndex);
+  *aStartIndex = 0;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  *aStartIndex = static_cast<Accessible*>(this)->StartOffset();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessibleHyperLink::GetEndIndex(int32_t* aEndIndex)
+{
+  NS_ENSURE_ARG_POINTER(aEndIndex);
+  *aEndIndex = 0;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  *aEndIndex = static_cast<Accessible*>(this)->EndOffset();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessibleHyperLink::GetAnchorCount(int32_t* aAnchorCount)
+{
+  NS_ENSURE_ARG_POINTER(aAnchorCount);
+  *aAnchorCount = 0;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  *aAnchorCount = static_cast<Accessible*>(this)->AnchorCount();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessibleHyperLink::GetURI(int32_t aIndex, nsIURI** aURI)
+{
+  NS_ENSURE_ARG_POINTER(aURI);
+
+  Accessible* thisAcc = static_cast<Accessible*>(this);
+  if (thisAcc->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  if (aIndex < 0 || aIndex >= static_cast<int32_t>(thisAcc->AnchorCount()))
+    return NS_ERROR_INVALID_ARG;
+
+  nsRefPtr<nsIURI>(thisAcc->AnchorURIAt(aIndex)).forget(aURI);
+  return NS_OK;
+}
+
+
+NS_IMETHODIMP
+xpcAccessibleHyperLink::GetAnchor(int32_t aIndex, nsIAccessible** aAccessible)
+{
+  NS_ENSURE_ARG_POINTER(aAccessible);
+  *aAccessible = nullptr;
+
+  Accessible* thisAcc = static_cast<Accessible*>(this);
+  if (thisAcc->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  if (aIndex < 0 || aIndex >= static_cast<int32_t>(thisAcc->AnchorCount()))
+    return NS_ERROR_INVALID_ARG;
+
+  NS_IF_ADDREF(*aAccessible = thisAcc->AnchorAt(aIndex));
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessibleHyperLink::GetValid(bool* aValid)
+{
+  NS_ENSURE_ARG_POINTER(aValid);
+  *aValid = false;
+
+  if (static_cast<Accessible*>(this)->IsDefunct())
+    return NS_ERROR_FAILURE;
+
+  *aValid = static_cast<Accessible*>(this)->IsLinkValid();
+  return NS_OK;
+}
new file mode 100644
--- /dev/null
+++ b/accessible/xpcom/xpcAccessibleHyperLink.h
@@ -0,0 +1,38 @@
+/* -*- 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 mozilla_a11y_xpcAccessibleHyperLink_h_
+#define mozilla_a11y_xpcAccessibleHyperLink_h_
+
+#include "nsIAccessibleHyperLink.h"
+
+class nsIAccessible;
+
+namespace mozilla {
+namespace a11y {
+
+class xpcAccessibleHyperLink : public nsIAccessibleHyperLink
+{
+public:
+  NS_IMETHOD GetAnchorCount(int32_t* aAnchorCount) MOZ_FINAL;
+  NS_IMETHOD GetStartIndex(int32_t* aStartIndex) MOZ_FINAL;
+  NS_IMETHOD GetEndIndex(int32_t* aEndIndex) MOZ_FINAL;
+  NS_IMETHOD GetURI(int32_t aIndex, nsIURI** aURI) MOZ_FINAL;
+  NS_IMETHOD GetAnchor(int32_t aIndex, nsIAccessible** aAccessible) MOZ_FINAL;
+  NS_IMETHOD GetValid(bool* aValid) MOZ_FINAL;
+
+private:
+  xpcAccessibleHyperLink() { }
+  friend class Accessible;
+
+  xpcAccessibleHyperLink(const xpcAccessibleHyperLink&) MOZ_DELETE;
+  xpcAccessibleHyperLink& operator =(const xpcAccessibleHyperLink&) MOZ_DELETE;
+};
+
+} // namespace a11y
+} // namespace mozilla
+
+#endif
--- a/accessible/xul/XULAlertAccessible.h
+++ b/accessible/xul/XULAlertAccessible.h
@@ -19,18 +19,18 @@ class XULAlertAccessible : public Access
 {
 public:
   XULAlertAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Accessible
   virtual mozilla::a11y::ENameValueFlag Name(nsString& aName);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsWidget() const;
   virtual Accessible* ContainerWidget() const;
 
 protected:
   ~XULAlertAccessible();
 };
--- a/accessible/xul/XULColorPickerAccessible.h
+++ b/accessible/xul/XULColorPickerAccessible.h
@@ -17,36 +17,36 @@ namespace a11y {
 class XULColorPickerTileAccessible : public AccessibleWrap
 {
 public:
   XULColorPickerTileAccessible(nsIContent* aContent,
                                DocAccessible* aDoc);
 
   // Accessible
   virtual void Value(nsString& aValue);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
 
   // Widgets
   virtual Accessible* ContainerWidget() const;
 };
 
 
 /**
  * Used for colorpicker button (xul:colorpicker@type="button").
  */
 class XULColorPickerAccessible : public XULColorPickerTileAccessible
 {
 public:
   XULColorPickerAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsWidget() const;
   virtual bool IsActiveWidget() const;
   virtual bool AreItemsOperable() const;
 
   virtual bool IsAcceptableChild(Accessible* aPossibleChild) const MOZ_OVERRIDE;
 };
--- a/accessible/xul/XULComboboxAccessible.cpp
+++ b/accessible/xul/XULComboboxAccessible.cpp
@@ -115,63 +115,50 @@ XULComboboxAccessible::CanHaveAnonChildr
 
 uint8_t
 XULComboboxAccessible::ActionCount()
 {
   // Just one action (click).
   return 1;
 }
 
-NS_IMETHODIMP
+bool
 XULComboboxAccessible::DoAction(uint8_t aIndex)
 {
-  if (aIndex != XULComboboxAccessible::eAction_Click) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
+  if (aIndex != XULComboboxAccessible::eAction_Click)
+    return false;
 
   // Programmaticaly toggle the combo box.
   nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent));
-  if (!menuList) {
-    return NS_ERROR_FAILURE;
-  }
-  bool isDroppedDown;
+  if (!menuList)
+    return false;
+
+  bool isDroppedDown = false;
   menuList->GetOpen(&isDroppedDown);
-  return menuList->SetOpen(!isDroppedDown);
+  menuList->SetOpen(!isDroppedDown);
+  return true;
 }
 
-NS_IMETHODIMP
-XULComboboxAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULComboboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (aIndex != XULComboboxAccessible::eAction_Click) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
-  // Our action name is the reverse of our state:
-  //     if we are close -> open is our name.
-  //     if we are open -> close is our name.
-  // Uses the frame to get the state, updated on every click.
+  aName.Truncate();
+  if (aIndex != XULComboboxAccessible::eAction_Click)
+    return;
 
   nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mContent));
-  if (!menuList) {
-    return NS_ERROR_FAILURE;
-  }
-  bool isDroppedDown;
+  if (!menuList)
+    return;
+
+  bool isDroppedDown = false;
   menuList->GetOpen(&isDroppedDown);
   if (isDroppedDown)
-    aName.AssignLiteral("close"); 
+    aName.AssignLiteral("close");
   else
-    aName.AssignLiteral("open"); 
-
-  return NS_OK;
+    aName.AssignLiteral("open");
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Widgets
 
 bool
 XULComboboxAccessible::IsActiveWidget() const
 {
--- a/accessible/xul/XULComboboxAccessible.h
+++ b/accessible/xul/XULComboboxAccessible.h
@@ -16,29 +16,27 @@ namespace a11y {
  */
 class XULComboboxAccessible : public AccessibleWrap
 {
 public:
   enum { eAction_Click = 0 };
 
   XULComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD DoAction(uint8_t aIndex);
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-
   // Accessible
   virtual void Description(nsString& aDescription);
   virtual void Value(nsString& aValue);
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
   virtual uint64_t NativeState();
   virtual bool CanHaveAnonChildren();
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsActiveWidget() const;
   virtual bool AreItemsOperable() const;
 };
 
 } // namespace a11y
 } // namespace mozilla
--- a/accessible/xul/XULElementAccessibles.cpp
+++ b/accessible/xul/XULElementAccessibles.cpp
@@ -228,39 +228,33 @@ XULLinkAccessible::NativeLinkState() con
 }
 
 uint8_t
 XULLinkAccessible::ActionCount()
 {
   return 1;
 }
 
-NS_IMETHODIMP
-XULLinkAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULLinkAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
 
-  if (aIndex != eAction_Jump)
-    return NS_ERROR_INVALID_ARG;
-
-  aName.AssignLiteral("jump");
-  return NS_OK;
+  if (aIndex == eAction_Jump)
+    aName.AssignLiteral("jump");
 }
 
-NS_IMETHODIMP
+bool
 XULLinkAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != eAction_Jump)
-    return NS_ERROR_INVALID_ARG;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
+    return false;
 
   DoCommand();
-  return NS_OK;
+  return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULLinkAccessible: HyperLinkAccessible
 
 bool
 XULLinkAccessible::IsLink()
 {
--- a/accessible/xul/XULElementAccessibles.h
+++ b/accessible/xul/XULElementAccessibles.h
@@ -19,18 +19,18 @@ class XULLabelTextLeafAccessible;
  */
 class XULLabelAccessible : public HyperTextAccessibleWrap
 {
 public:
   XULLabelAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
   virtual void Shutdown();
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 
   void UpdateLabelValue(const nsString& aValue);
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
   virtual void CacheChildren() MOZ_OVERRIDE;
@@ -70,39 +70,37 @@ public:
  */
 class XULTooltipAccessible : public LeafAccessible
 {
 
 public:
   XULTooltipAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 };
 
 class XULLinkAccessible : public XULLabelAccessible
 {
 
 public:
   XULLinkAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   NS_DECL_ISUPPORTS_INHERITED
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t aIndex);
-
   // Accessible
   virtual void Value(nsString& aValue);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeLinkState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeLinkState() const MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // HyperLinkAccessible
   virtual bool IsLink();
   virtual uint32_t StartOffset();
   virtual uint32_t EndOffset();
   virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex);
 
 protected:
--- a/accessible/xul/XULFormControlAccessible.cpp
+++ b/accessible/xul/XULFormControlAccessible.cpp
@@ -60,34 +60,31 @@ NS_IMPL_ISUPPORTS_INHERITED0(XULButtonAc
 // XULButtonAccessible: nsIAccessible
 
 uint8_t
 XULButtonAccessible::ActionCount()
 {
   return 1;
 }
 
-NS_IMETHODIMP
-XULButtonAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULButtonAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (aIndex == eAction_Click) {
-    aName.AssignLiteral("press"); 
-    return NS_OK;
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex == eAction_Click)
+    aName.AssignLiteral("press");
 }
 
-NS_IMETHODIMP
+bool
 XULButtonAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != 0)
-    return NS_ERROR_INVALID_ARG;
+    return false;
 
   DoCommand();
-  return NS_OK;
+  return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULButtonAccessible: Accessible
 
 role
 XULButtonAccessible::NativeRole()
 {
@@ -191,17 +188,17 @@ XULButtonAccessible::IsAcceptableChild(A
   return mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
                                nsGkAtoms::menuButton, eCaseMatters);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULButtonAccessible protected
 
 bool
-XULButtonAccessible::ContainsMenu()
+XULButtonAccessible::ContainsMenu() const
 {
   static nsIContent::AttrValuesArray strings[] =
     {&nsGkAtoms::menu, &nsGkAtoms::menuButton, nullptr};
 
   return mContent->FindAttrValueIn(kNameSpaceID_None,
                                    nsGkAtoms::type,
                                    strings, eCaseMatters) >= 0;
 }
@@ -218,17 +215,17 @@ XULDropmarkerAccessible::
 
 uint8_t
 XULDropmarkerAccessible::ActionCount()
 {
   return 1;
 }
 
 bool
-XULDropmarkerAccessible::DropmarkerOpen(bool aToggleOpen)
+XULDropmarkerAccessible::DropmarkerOpen(bool aToggleOpen) const
 {
   bool isOpen = false;
 
   nsCOMPtr<nsIDOMXULButtonElement> parentButtonElement =
     do_QueryInterface(mContent->GetFlattenedTreeParent());
 
   if (parentButtonElement) {
     parentButtonElement->GetOpen(&isOpen);
@@ -243,44 +240,36 @@ XULDropmarkerAccessible::DropmarkerOpen(
       if (aToggleOpen)
         parentMenuListElement->SetOpen(!isOpen);
     }
   }
 
   return isOpen;
 }
 
-/**
-  * Return the name of our only action
-  */
-NS_IMETHODIMP
-XULDropmarkerAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULDropmarkerAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
+  aName.Truncate();
   if (aIndex == eAction_Click) {
     if (DropmarkerOpen(false))
       aName.AssignLiteral("close");
     else
       aName.AssignLiteral("open");
-    return NS_OK;
   }
-
-  return NS_ERROR_INVALID_ARG;
 }
 
-/**
-  * Tell the Dropmarker to do its action
-  */
-NS_IMETHODIMP
+bool
 XULDropmarkerAccessible::DoAction(uint8_t index)
 {
   if (index == eAction_Click) {
     DropmarkerOpen(true); // Reverse the open attribute
-    return NS_OK;
+    return true;
   }
-  return NS_ERROR_INVALID_ARG;
+  return false;
 }
 
 role
 XULDropmarkerAccessible::NativeRole()
 {
   return roles::PUSHBUTTON;
 }
 
@@ -307,46 +296,35 @@ XULCheckboxAccessible::NativeRole()
 }
 
 uint8_t
 XULCheckboxAccessible::ActionCount()
 {
   return 1;
 }
 
-/**
-  * Return the name of our only action
-  */
-NS_IMETHODIMP
-XULCheckboxAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULCheckboxAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   if (aIndex == eAction_Click) {
-    // check or uncheck
-
     if (NativeState() & states::CHECKED)
       aName.AssignLiteral("uncheck");
     else
       aName.AssignLiteral("check");
-
-    return NS_OK;
   }
-  return NS_ERROR_INVALID_ARG;
 }
 
-/**
-  * Tell the checkbox to do its only action -- check( or uncheck) itself
-  */
-NS_IMETHODIMP
+bool
 XULCheckboxAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != eAction_Click)
-    return NS_ERROR_INVALID_ARG;
+    return false;
 
   DoCommand();
-  return NS_OK;
+  return true;
 }
 
 uint64_t
 XULCheckboxAccessible::NativeState()
 {
   // Possible states: focused, focusable, unavailable(disabled), checked
   // Get focus and disable status from base class
   uint64_t state = LeafAccessible::NativeState();
--- a/accessible/xul/XULFormControlAccessible.h
+++ b/accessible/xul/XULFormControlAccessible.h
@@ -30,98 +30,92 @@ class XULButtonAccessible : public Acces
 {
 public:
   enum { eAction_Click = 0 };
   XULButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t index);
-
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsWidget() const;
   virtual bool IsActiveWidget() const;
   virtual bool AreItemsOperable() const;
   virtual Accessible* ContainerWidget() const;
 
   virtual bool IsAcceptableChild(Accessible* aPossibleChild) const MOZ_OVERRIDE;
 
 protected:
   virtual ~XULButtonAccessible();
 
   // XULButtonAccessible
-  bool ContainsMenu();
+  bool ContainsMenu() const;
 };
 
 
 /**
  * Used for XUL checkbox element.
  */
 class XULCheckboxAccessible : public LeafAccessible
 {
 public:
   enum { eAction_Click = 0 };
   XULCheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t index);
-
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 };
 
 /**
  * Used for XUL dropmarker element.
  */
 class XULDropmarkerAccessible : public LeafAccessible
 {
 public:
   enum { eAction_Click = 0 };
   XULDropmarkerAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t index);
-
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
 private:
-  bool DropmarkerOpen(bool aToggleOpen);
+  bool DropmarkerOpen(bool aToggleOpen) const;
 };
 
 /**
  * Used for XUL groupbox element.
  */
 class XULGroupboxAccessible MOZ_FINAL : public AccessibleWrap
 {
 public:
   XULGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 };
 
 /**
@@ -129,51 +123,51 @@ protected:
  */
 class XULRadioButtonAccessible : public RadioButtonAccessible
 {
 
 public:
   XULRadioButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
 
   // Widgets
   virtual Accessible* ContainerWidget() const;
 };
 
 /**
  * Used for XUL radiogroup element.
  */
 class XULRadioGroupAccessible : public XULSelectControlAccessible
 {
 public:
   XULRadioGroupAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsWidget() const;
   virtual bool IsActiveWidget() const;
   virtual bool AreItemsOperable() const;
 };
 
 /**
  * Used for XUL statusbar element.
  */
 class XULStatusBarAccessible : public AccessibleWrap
 {
 public:
   XULStatusBarAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
 };
 
 /**
  * Used for XUL toolbarbutton element.
  */
 class XULToolbarButtonAccessible : public XULButtonAccessible
 {
 public:
@@ -191,34 +185,34 @@ public:
  * Used for XUL toolbar element.
  */
 class XULToolbarAccessible : public AccessibleWrap
 {
 public:
   XULToolbarAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 };
 
 /**
  * Used for XUL toolbarseparator element.
  */
 class XULToolbarSeparatorAccessible : public LeafAccessible
 {
 public:
   XULToolbarSeparatorAccessible(nsIContent* aContent,
                                 DocAccessible* aDoc);
 
   // Accessible
-  virtual mozilla::a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual mozilla::a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
 
--- a/accessible/xul/XULListboxAccessible.cpp
+++ b/accessible/xul/XULListboxAccessible.cpp
@@ -71,34 +71,31 @@ XULColumnItemAccessible::NativeState()
 }
 
 uint8_t
 XULColumnItemAccessible::ActionCount()
 {
   return 1;
 }
 
-NS_IMETHODIMP
-XULColumnItemAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULColumnItemAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (aIndex != eAction_Click)
-    return NS_ERROR_INVALID_ARG;
-
-  aName.AssignLiteral("click");
-  return NS_OK;
+  if (aIndex == eAction_Click)
+    aName.AssignLiteral("click");
 }
 
-NS_IMETHODIMP
+bool
 XULColumnItemAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != eAction_Click)
-    return NS_ERROR_INVALID_ARG;
+    return false;
 
   DoCommand();
-  return NS_OK;
+  return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULListboxAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 XULListboxAccessible::
   XULListboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
@@ -588,17 +585,17 @@ XULListitemAccessible::
 
 XULListitemAccessible::~XULListitemAccessible()
 {
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(XULListitemAccessible, Accessible)
 
 Accessible*
-XULListitemAccessible::GetListAccessible()
+XULListitemAccessible::GetListAccessible() const
 {
   if (IsDefunct())
     return nullptr;
 
   nsCOMPtr<nsIDOMXULSelectControlItemElement> listItem =
     do_QueryInterface(mContent);
   if (!listItem)
     return nullptr;
@@ -691,31 +688,26 @@ XULListitemAccessible::NativeState()
 
 uint64_t
 XULListitemAccessible::NativeInteractiveState() const
 {
   return NativelyUnavailable() || (mParent && mParent->NativelyUnavailable()) ?
     states::UNAVAILABLE : states::FOCUSABLE | states::SELECTABLE;
 }
 
-NS_IMETHODIMP
-XULListitemAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULListitemAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   if (aIndex == eAction_Click && mIsCheckbox) {
-    // check or uncheck
     uint64_t states = NativeState();
-
     if (states & states::CHECKED)
       aName.AssignLiteral("uncheck");
     else
       aName.AssignLiteral("check");
-
-    return NS_OK;
   }
-  return NS_ERROR_INVALID_ARG;
 }
 
 bool
 XULListitemAccessible::CanHaveAnonChildren()
 {
   // That indicates we should walk anonymous children for listitems
   return true;
 }
--- a/accessible/xul/XULListboxAccessible.h
+++ b/accessible/xul/XULListboxAccessible.h
@@ -25,39 +25,37 @@ namespace a11y {
  * (xul:treecols and xul:listcols).
  */
 class XULColumAccessible : public AccessibleWrap
 {
 public:
   XULColumAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 };
 
 /**
  * XULColumnItemAccessible are accessibles for list and tree column elements
  * (xul:listcol and xul:treecol).
  */
 class XULColumnItemAccessible : public LeafAccessible
 {
 public:
   XULColumnItemAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t aIndex);
-
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   enum { eAction_Click = 0 };
 };
 
 /*
  * A class the represents the XUL Listbox widget.
  */
 class XULListboxAccessible : public XULSelectControlAccessible,
@@ -90,18 +88,18 @@ public:
   virtual void SelectRow(uint32_t aRowIdx);
   virtual void UnselectRow(uint32_t aRowIdx);
   virtual Accessible* AsAccessible() { return this; }
 
   // Accessible
   virtual void Shutdown();
   virtual void Value(nsString& aValue);
   virtual TableAccessible* AsTable() { return this; }
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsWidget() const;
   virtual bool IsActiveWidget() const;
   virtual bool AreItemsOperable() const;
 
   virtual Accessible* ContainerWidget() const;
 
@@ -118,42 +116,41 @@ class XULListitemAccessible : public XUL
 {
 public:
   enum { eAction_Click = 0 };
 
   NS_DECL_ISUPPORTS_INHERITED
 
   XULListitemAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t index, nsAString& aName);
-  // Don't use XUL menuitems's description attribute
-
   // Accessible
   virtual void Description(nsString& aDesc);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
   virtual bool CanHaveAnonChildren();
 
+  // Actions
+  virtual void ActionNameAt(uint8_t index, nsAString& aName) MOZ_OVERRIDE;
+
   // Widgets
   virtual Accessible* ContainerWidget() const;
 
 protected:
   virtual ~XULListitemAccessible();
 
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 
   // XULListitemAccessible
 
   /**
    * Return listbox accessible for the listitem.
    */
-  Accessible* GetListAccessible();
+  Accessible* GetListAccessible() const;
 
 private:
   bool mIsCheckbox;
 };
 
 /**
  * Class represents xul:listcell.
  */
@@ -170,17 +167,17 @@ public:
 
   // nsIAccessibleTableCell
   NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
 
   // Accessible
   virtual TableCellAccessible* AsTableCell() { return this; }
   virtual void Shutdown();
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 
   // TableCellAccessible
   virtual TableAccessible* Table() const MOZ_OVERRIDE;
   virtual uint32_t ColIdx() const MOZ_OVERRIDE;
   virtual uint32_t RowIdx() const MOZ_OVERRIDE;
   virtual void ColHeaderCells(nsTArray<Accessible*>* aHeaderCells) MOZ_OVERRIDE;
   virtual bool Selected() MOZ_OVERRIDE;
 
--- a/accessible/xul/XULMenuAccessible.cpp
+++ b/accessible/xul/XULMenuAccessible.cpp
@@ -269,36 +269,32 @@ XULMenuitemAccessible::GetLevelInternal(
 
 bool
 XULMenuitemAccessible::CanHaveAnonChildren()
 {
   // That indicates we don't walk anonymous children for menuitems
   return false;
 }
 
-NS_IMETHODIMP
+bool
 XULMenuitemAccessible::DoAction(uint8_t index)
 {
   if (index == eAction_Click) {   // default action
     DoCommand();
-    return NS_OK;
+    return true;
   }
 
-  return NS_ERROR_INVALID_ARG;
+  return false;
 }
 
-/** select us! close combo box if necessary*/
-NS_IMETHODIMP
-XULMenuitemAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULMenuitemAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (aIndex == eAction_Click) {
-    aName.AssignLiteral("click"); 
-    return NS_OK;
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex == eAction_Click)
+    aName.AssignLiteral("click");
 }
 
 uint8_t
 XULMenuitemAccessible::ActionCount()
 {
   return 1;
 }
 
@@ -378,26 +374,26 @@ XULMenuSeparatorAccessible::NativeName(n
 }
 
 role
 XULMenuSeparatorAccessible::NativeRole()
 {
   return roles::SEPARATOR;
 }
 
-NS_IMETHODIMP
+bool
 XULMenuSeparatorAccessible::DoAction(uint8_t index)
 {
-  return NS_ERROR_NOT_IMPLEMENTED;
+  return false;
 }
 
-NS_IMETHODIMP
-XULMenuSeparatorAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULMenuSeparatorAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  return NS_ERROR_NOT_IMPLEMENTED;
+  aName.Truncate();
 }
 
 uint8_t
 XULMenuSeparatorAccessible::ActionCount()
 {
   return 0;
 }
 
--- a/accessible/xul/XULMenuAccessible.h
+++ b/accessible/xul/XULMenuAccessible.h
@@ -18,31 +18,29 @@ namespace a11y {
  */
 class XULMenuitemAccessible : public AccessibleWrap
 {
 public:
   enum { eAction_Click = 0 };
 
   XULMenuitemAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD DoAction(uint8_t index);
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-
   // Accessible
   virtual void Description(nsString& aDescription);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
   virtual int32_t GetLevelInternal();
 
   virtual bool CanHaveAnonChildren();
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
   virtual KeyBinding AccessKey() const;
   virtual KeyBinding KeyboardShortcut() const;
 
   // Widgets
   virtual bool IsActiveWidget() const;
   virtual bool AreItemsOperable() const;
   virtual Accessible* ContainerWidget() const;
 
@@ -54,44 +52,42 @@ protected:
 /**
  * Used for XUL menuseparator element.
  */
 class XULMenuSeparatorAccessible : public XULMenuitemAccessible
 {
 public:
   XULMenuSeparatorAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD DoAction(uint8_t index);
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 };
 
 
 /**
  * Used for XUL menupopup and panel.
  */
 class XULMenupopupAccessible : public XULSelectControlAccessible
 {
 public:
   XULMenupopupAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
 
   // Widgets
   virtual bool IsWidget() const;
   virtual bool IsActiveWidget() const;
   virtual bool AreItemsOperable() const;
 
   virtual Accessible* ContainerWidget() const;
 
@@ -104,17 +100,17 @@ protected:
  * Used for XUL menubar element.
  */
 class XULMenubarAccessible : public AccessibleWrap
 {
 public:
   XULMenubarAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 
   // Widget
   virtual bool IsActiveWidget() const;
   virtual bool AreItemsOperable() const;
   virtual Accessible* CurrentItem();
   virtual void SetCurrentItem(Accessible* aItem);
 
 protected:
--- a/accessible/xul/XULSliderAccessible.cpp
+++ b/accessible/xul/XULSliderAccessible.cpp
@@ -66,37 +66,35 @@ XULSliderAccessible::Value(nsString& aVa
 }
 
 uint8_t
 XULSliderAccessible::ActionCount()
 {
   return 1;
 }
 
-NS_IMETHODIMP
-XULSliderAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULSliderAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
-
-  NS_ENSURE_ARG(aIndex == 0);
-
-  aName.AssignLiteral("activate");
-  return NS_OK;
+  if (aIndex == 0)
+    aName.AssignLiteral("activate");
 }
 
-NS_IMETHODIMP
+bool
 XULSliderAccessible::DoAction(uint8_t aIndex)
 {
-  NS_ENSURE_ARG(aIndex == 0);
+  if (aIndex != 0)
+    return false;
 
   nsIContent* sliderElm = GetSliderElement();
   if (sliderElm)
     DoCommand(sliderElm);
 
-  return NS_OK;
+  return true;
 }
 
 double
 XULSliderAccessible::MaxValue() const
 {
   double value = AccessibleWrap::MaxValue();
   return IsNaN(value) ? GetSliderAttr(nsGkAtoms::maxpos) : value;
 }
--- a/accessible/xul/XULSliderAccessible.h
+++ b/accessible/xul/XULSliderAccessible.h
@@ -16,36 +16,34 @@ namespace a11y {
 /**
  * Used for XUL slider and scale elements.
  */
 class XULSliderAccessible : public AccessibleWrap
 {
 public:
   XULSliderAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t aIndex);
-
   // Accessible
   virtual void Value(nsString& aValue);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
   virtual bool NativelyUnavailable() const;
   virtual bool CanHaveAnonChildren();
 
   // Value
   virtual double MaxValue() const MOZ_OVERRIDE;
   virtual double MinValue() const MOZ_OVERRIDE;
   virtual double CurValue() const MOZ_OVERRIDE;
   virtual double Step() const MOZ_OVERRIDE;
   virtual bool SetCurValue(double aValue) MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
 protected:
   /**
    * Return anonymous slider element.
    */
   nsIContent* GetSliderElement() const;
 
   nsresult GetSliderAttr(nsIAtom *aName, nsAString& aValue) const;
@@ -63,16 +61,16 @@ private:
  * Used for slider's thumb element.
  */
 class XULThumbAccessible : public AccessibleWrap
 {
 public:
   XULThumbAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
 
--- a/accessible/xul/XULTabAccessible.cpp
+++ b/accessible/xul/XULTabAccessible.cpp
@@ -34,40 +34,34 @@ XULTabAccessible::
 
 uint8_t
 XULTabAccessible::ActionCount()
 {
   return 1;
 }
 
 /** Return the name of our only action  */
-NS_IMETHODIMP
-XULTabAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULTabAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (aIndex == eAction_Switch) {
-    aName.AssignLiteral("switch"); 
-    return NS_OK;
-  }
-  return NS_ERROR_INVALID_ARG;
+  if (aIndex == eAction_Switch)
+    aName.AssignLiteral("switch");
 }
 
-/** Tell the tab to do its action */
-NS_IMETHODIMP
+bool
 XULTabAccessible::DoAction(uint8_t index)
 {
   if (index == eAction_Switch) {
     nsCOMPtr<nsIDOMXULElement> tab(do_QueryInterface(mContent));
-    if ( tab )
-    {
+    if (tab) {
       tab->Click();
-      return NS_OK;
+      return true;
     }
-    return NS_ERROR_FAILURE;
   }
-  return NS_ERROR_INVALID_ARG;
+  return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTabAccessible: Accessible
 
 role
 XULTabAccessible::NativeRole()
 {
--- a/accessible/xul/XULTabAccessible.h
+++ b/accessible/xul/XULTabAccessible.h
@@ -18,45 +18,43 @@ namespace a11y {
  */
 class XULTabAccessible : public AccessibleWrap
 {
 public:
   enum { eAction_Switch = 0 };
 
   XULTabAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
-  // nsIAccessible
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t index);
-
   // Accessible
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 };
 
 
 /**
  * A container of tab objects, xul:tabs element.
  */
 class XULTabsAccessible : public XULSelectControlAccessible
 {
 public:
   XULTabsAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
   virtual void Value(nsString& aValue);
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) MOZ_OVERRIDE;
 };
 
 
 /**
@@ -65,34 +63,34 @@ protected:
 class XULTabpanelsAccessible : public AccessibleWrap
 {
 public:
   XULTabpanelsAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     AccessibleWrap(aContent, aDoc)
     { mType = eXULTabpanelsType; }
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 };
 
 
 /**
  * A tabpanel object, child elements of xul:tabpanels element.
  *
  * XXX: we need to move the class logic into generic class since
  * for example we do not create instance of this class for XUL textbox used as
  * a tabpanel.
  */
 class XULTabpanelAccessible : public AccessibleWrap
 {
 public:
   XULTabpanelAccessible(nsIContent* aContent, DocAccessible* aDoc);
 
   // Accessible
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
 #endif
 
--- a/accessible/xul/XULTreeAccessible.cpp
+++ b/accessible/xul/XULTreeAccessible.cpp
@@ -728,94 +728,73 @@ NS_IMPL_RELEASE_INHERITED(XULTreeItemAcc
 // XULTreeItemAccessibleBase: nsIAccessible implementation
 
 Accessible*
 XULTreeItemAccessibleBase::FocusedChild()
 {
   return FocusMgr()->FocusedAccessible() == this ? this : nullptr;
 }
 
-NS_IMETHODIMP
-XULTreeItemAccessibleBase::GetBounds(int32_t* aX, int32_t* aY,
-                                     int32_t* aWidth, int32_t* aHeight)
+nsIntRect
+XULTreeItemAccessibleBase::Bounds() const
 {
-  NS_ENSURE_ARG_POINTER(aX);
-  *aX = 0;
-  NS_ENSURE_ARG_POINTER(aY);
-  *aY = 0;
-  NS_ENSURE_ARG_POINTER(aWidth);
-  *aWidth = 0;
-  NS_ENSURE_ARG_POINTER(aHeight);
-  *aHeight = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   // Get x coordinate and width from treechildren element, get y coordinate and
   // height from tree cell.
 
   nsCOMPtr<nsIBoxObject> boxObj = nsCoreUtils::GetTreeBodyBoxObject(mTree);
-  NS_ENSURE_STATE(boxObj);
+  if (!boxObj)
+    return nsIntRect();
 
   nsCOMPtr<nsITreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
 
   int32_t x = 0, y = 0, width = 0, height = 0;
   nsresult rv = mTree->GetCoordsForCellItem(mRow, column, EmptyCString(),
                                             &x, &y, &width, &height);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_FAILED(rv))
+    return nsIntRect();
 
   boxObj->GetWidth(&width);
 
   int32_t tcX = 0, tcY = 0;
   boxObj->GetScreenX(&tcX);
   boxObj->GetScreenY(&tcY);
 
   x = tcX;
   y += tcY;
 
   nsPresContext* presContext = mDoc->PresContext();
-  *aX = presContext->CSSPixelsToDevPixels(x);
-  *aY = presContext->CSSPixelsToDevPixels(y);
-  *aWidth = presContext->CSSPixelsToDevPixels(width);
-  *aHeight = presContext->CSSPixelsToDevPixels(height);
-
-  return NS_OK;
+  return nsIntRect(presContext->CSSPixelsToDevPixels(x),
+                   presContext->CSSPixelsToDevPixels(y),
+                   presContext->CSSPixelsToDevPixels(width),
+                   presContext->CSSPixelsToDevPixels(height));
 }
 
-NS_IMETHODIMP
+void
 XULTreeItemAccessibleBase::SetSelected(bool aSelect)
 {
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   nsCOMPtr<nsITreeSelection> selection;
   mTreeView->GetSelection(getter_AddRefs(selection));
   if (selection) {
-    bool isSelected;
+    bool isSelected = false;
     selection->IsSelected(mRow, &isSelected);
     if (isSelected != aSelect)
       selection->ToggleSelect(mRow);
   }
-
-  return NS_OK;
 }
 
-NS_IMETHODIMP
+void
 XULTreeItemAccessibleBase::TakeFocus()
 {
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   nsCOMPtr<nsITreeSelection> selection;
   mTreeView->GetSelection(getter_AddRefs(selection));
   if (selection)
     selection->SetCurrentIndex(mRow);
 
   // focus event will be fired here
-  return Accessible::TakeFocus();
+  Accessible::TakeFocus();
 }
 
 Relation
 XULTreeItemAccessibleBase::RelationByType(RelationType aType)
 {
 
   switch (aType) {
     case RelationType::NODE_CHILD_OF: {
@@ -850,53 +829,43 @@ XULTreeItemAccessibleBase::RelationByTyp
 uint8_t
 XULTreeItemAccessibleBase::ActionCount()
 {
   // "activate" action is available for all treeitems, "expand/collapse" action
   // is avaible for treeitem which is container.
   return IsExpandable() ? 2 : 1;
 }
 
-NS_IMETHODIMP
-XULTreeItemAccessibleBase::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULTreeItemAccessibleBase::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   if (aIndex == eAction_Click) {
     aName.AssignLiteral("activate");
-    return NS_OK;
+    return;
   }
 
   if (aIndex == eAction_Expand && IsExpandable()) {
-    bool isContainerOpen;
+    bool isContainerOpen = false;
     mTreeView->IsContainerOpen(mRow, &isContainerOpen);
     if (isContainerOpen)
       aName.AssignLiteral("collapse");
     else
       aName.AssignLiteral("expand");
-
-    return NS_OK;
   }
-
-  return NS_ERROR_INVALID_ARG;
 }
 
-NS_IMETHODIMP
+bool
 XULTreeItemAccessibleBase::DoAction(uint8_t aIndex)
 {
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   if (aIndex != eAction_Click &&
       (aIndex != eAction_Expand || !IsExpandable()))
-    return NS_ERROR_INVALID_ARG;
+    return false;
 
   DoCommand(nullptr, aIndex);
-  return NS_OK;
+  return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeItemAccessibleBase: Accessible implementation
 
 void
 XULTreeItemAccessibleBase::Shutdown()
 {
--- a/accessible/xul/XULTreeAccessible.h
+++ b/accessible/xul/XULTreeAccessible.h
@@ -36,18 +36,18 @@ public:
 
   // nsISupports and cycle collection
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeAccessible, Accessible)
 
   // Accessible
   virtual void Shutdown();
   virtual void Value(nsString& aValue);
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
   virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
                                    EWhichChildAtPoint aWhichChild);
 
   virtual Accessible* GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
   virtual uint32_t ChildCount() const MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 
   // SelectAccessible
@@ -141,37 +141,32 @@ public:
                             Accessible* aParent, nsITreeBoxObject* aTree,
                             nsITreeView* aTreeView, int32_t aRow);
 
   // nsISupports and cycle collection
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeItemAccessibleBase,
                                            AccessibleWrap)
 
-  // nsIAccessible
-  NS_IMETHOD GetBounds(int32_t *aX, int32_t *aY,
-                       int32_t *aWidth, int32_t *aHeight);
-
-  NS_IMETHOD SetSelected(bool aSelect);
-  NS_IMETHOD TakeFocus();
-
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t aIndex);
-
   // Accessible
-  virtual void Shutdown();
-  virtual GroupPos GroupPosition();
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeInteractiveState() const;
-  virtual int32_t IndexInParent() const;
+  virtual void Shutdown() MOZ_OVERRIDE;
+  virtual nsIntRect Bounds() const MOZ_OVERRIDE;
+  virtual GroupPos GroupPosition() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
+  virtual int32_t IndexInParent() const MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
-  virtual Accessible* FocusedChild();
+  virtual Accessible* FocusedChild() MOZ_OVERRIDE;
+  virtual void SetSelected(bool aSelect) MOZ_OVERRIDE;
+  virtual void TakeFocus() MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // Widgets
   virtual Accessible* ContainerWidget() const;
 
   // XULTreeItemAccessibleBase
   NS_DECLARE_STATIC_IID_ACCESSOR(XULTREEITEMBASEACCESSIBLE_IMPL_CID)
 
   /**
@@ -235,17 +230,17 @@ public:
   // nsISupports and cycle collection
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeItemAccessible,
                                            XULTreeItemAccessibleBase)
 
   // Accessible
   virtual void Shutdown();
   virtual ENameValueFlag Name(nsString& aName);
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 
   // XULTreeItemAccessibleBase
   virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx);
 
 protected:
   virtual ~XULTreeItemAccessible();
 
   // Accessible
--- a/accessible/xul/XULTreeGridAccessible.cpp
+++ b/accessible/xul/XULTreeGridAccessible.cpp
@@ -141,23 +141,21 @@ XULTreeGridAccessible::CellAt(uint32_t a
   return rowAcc->GetCellAccessible(column);
 }
 
 void
 XULTreeGridAccessible::ColDescription(uint32_t aColIdx, nsString& aDescription)
 {
   aDescription.Truncate();
 
-  nsCOMPtr<nsIAccessible> treeColumns;
-  Accessible::GetFirstChild(getter_AddRefs(treeColumns));
+  Accessible* treeColumns = Accessible::GetChildAt(0);
   if (treeColumns) {
-    nsCOMPtr<nsIAccessible> treeColumnItem;
-    treeColumns->GetChildAt(aColIdx, getter_AddRefs(treeColumnItem));
+    Accessible* treeColumnItem = treeColumns->GetChildAt(aColIdx);
     if (treeColumnItem)
-      treeColumnItem->GetName(aDescription);
+      treeColumnItem->Name(aDescription);
   }
 }
 
 bool
 XULTreeGridAccessible::IsColSelected(uint32_t aColIdx)
 {
   // If all the row has been selected, then all the columns are selected.
   // Because we can't select a column alone.
@@ -508,56 +506,43 @@ XULTreeGridCellAccessible::Name(nsString
   // something shown in the cell (non-text) such as a star icon; in which case
   // GetCellValue for that cell would return "starred" or "flagged" for example.
   if (aName.IsEmpty())
     mTreeView->GetCellValue(mRow, mColumn, aName);
 
   return eNameOK;
 }
 
-NS_IMETHODIMP
-XULTreeGridCellAccessible::GetBounds(int32_t* aX, int32_t* aY,
-                                     int32_t* aWidth, int32_t* aHeight)
+nsIntRect
+XULTreeGridCellAccessible::Bounds() const
 {
-  NS_ENSURE_ARG_POINTER(aX);
-  *aX = 0;
-  NS_ENSURE_ARG_POINTER(aY);
-  *aY = 0;
-  NS_ENSURE_ARG_POINTER(aWidth);
-  *aWidth = 0;
-  NS_ENSURE_ARG_POINTER(aHeight);
-  *aHeight = 0;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
-
   // Get bounds for tree cell and add x and y of treechildren element to
   // x and y of the cell.
   nsCOMPtr<nsIBoxObject> boxObj = nsCoreUtils::GetTreeBodyBoxObject(mTree);
-  NS_ENSURE_STATE(boxObj);
+  if (!boxObj)
+    return nsIntRect();
 
   int32_t x = 0, y = 0, width = 0, height = 0;
   nsresult rv = mTree->GetCoordsForCellItem(mRow, mColumn,
                                             NS_LITERAL_CSTRING("cell"),
                                             &x, &y, &width, &height);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_FAILED(rv))
+    return nsIntRect();
 
   int32_t tcX = 0, tcY = 0;
   boxObj->GetScreenX(&tcX);
   boxObj->GetScreenY(&tcY);
   x += tcX;
   y += tcY;
 
   nsPresContext* presContext = mDoc->PresContext();
-  *aX = presContext->CSSPixelsToDevPixels(x);
-  *aY = presContext->CSSPixelsToDevPixels(y);
-  *aWidth = presContext->CSSPixelsToDevPixels(width);
-  *aHeight = presContext->CSSPixelsToDevPixels(height);
-
-  return NS_OK;
+  return nsIntRect(presContext->CSSPixelsToDevPixels(x),
+                   presContext->CSSPixelsToDevPixels(y),
+                   presContext->CSSPixelsToDevPixels(width),
+                   presContext->CSSPixelsToDevPixels(height));
 }
 
 uint8_t
 XULTreeGridCellAccessible::ActionCount()
 {
   bool isCycler = false;
   mColumn->GetCycler(&isCycler);
   if (isCycler)
@@ -566,74 +551,64 @@ XULTreeGridCellAccessible::ActionCount()
   int16_t type;
   mColumn->GetType(&type);
   if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable())
     return 1;
 
   return 0;
 }
 
-NS_IMETHODIMP
-XULTreeGridCellAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
+void
+XULTreeGridCellAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
 
-  if (aIndex != eAction_Click)
-    return NS_ERROR_INVALID_ARG;
-
-  if (IsDefunct() || !mTreeView)
-    return NS_ERROR_FAILURE;
+  if (aIndex != eAction_Click || !mTreeView)
+    return;
 
   bool isCycler = false;
   mColumn->GetCycler(&isCycler);
   if (isCycler) {
     aName.AssignLiteral("cycle");
-    return NS_OK;
+    return;
   }
 
-  int16_t type;
+  int16_t type = 0;
   mColumn->GetType(&type);
   if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
     nsAutoString value;
     mTreeView->GetCellValue(mRow, mColumn, value);
     if (value.EqualsLiteral("true"))
       aName.AssignLiteral("uncheck");
     else
       aName.AssignLiteral("check");
-
-    return NS_OK;
   }
-
-  return NS_ERROR_INVALID_ARG;
 }
 
-NS_IMETHODIMP
+bool
 XULTreeGridCellAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != eAction_Click)
-    return NS_ERROR_INVALID_ARG;
-
-  if (IsDefunct())
-    return NS_ERROR_FAILURE;
+    return false;
 
   bool isCycler = false;
   mColumn->GetCycler(&isCycler);
   if (isCycler) {
     DoCommand();
-    return NS_OK;
+    return true;
   }
 
   int16_t type;
   mColumn->GetType(&type);
   if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
     DoCommand();
-    return NS_OK;
+    return true;
   }
 
-  return NS_ERROR_INVALID_ARG;
+  return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridCellAccessible: nsIAccessibleTableCell implementation
 
 TableAccessible*
 XULTreeGridCellAccessible::Table() const
 {
--- a/accessible/xul/XULTreeGridAccessible.h
+++ b/accessible/xul/XULTreeGridAccessible.h
@@ -52,17 +52,17 @@ public:
   virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows);
   virtual void SelectRow(uint32_t aRowIdx);
   virtual void UnselectRow(uint32_t aRowIdx);
   virtual Accessible* AsAccessible() { return this; }
 
   // Accessible
   virtual void Shutdown();
   virtual TableAccessible* AsTable() { return this; }
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
 
 protected:
   virtual ~XULTreeGridAccessible();
 
   // XULTreeAccessible
   virtual already_AddRefed<Accessible>
     CreateTreeItemAccessible(int32_t aRow) const MOZ_OVERRIDE;
 };
@@ -83,17 +83,17 @@ public:
 
   // nsISupports and cycle collection
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeGridRowAccessible,
                                            XULTreeItemAccessibleBase)
 
   // Accessible
   virtual void Shutdown();
-  virtual a11y::role NativeRole();
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
   virtual ENameValueFlag Name(nsString& aName);
   virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
                                    EWhichChildAtPoint aWhichChild);
 
   virtual Accessible* GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
   virtual uint32_t ChildCount() const MOZ_OVERRIDE;
 
   // XULTreeItemAccessibleBase
@@ -136,41 +136,36 @@ public:
                             nsITreeBoxObject* aTree, nsITreeView* aTreeView,
                             int32_t aRow, nsITreeColumn* aColumn);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeGridCellAccessible,
                                            LeafAccessible)
 
-  // nsIAccessible
-
-  NS_IMETHOD GetBounds(int32_t* aX, int32_t* aY,
-                       int32_t* aWidth, int32_t* aHeight);
-
-  NS_IMETHOD GetActionName(uint8_t aIndex, nsAString& aName);
-  NS_IMETHOD DoAction(uint8_t aIndex);
-
   // nsIAccessibleTableCell
   NS_FORWARD_NSIACCESSIBLETABLECELL(xpcAccessibleTableCell::)
 
   // Accessible
   virtual TableCellAccessible* AsTableCell() { return this; }
   virtual void Shutdown();
+  virtual nsIntRect Bounds() const MOZ_OVERRIDE;
   virtual ENameValueFlag Name(nsString& aName);
   virtual Accessible* FocusedChild();
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() MOZ_OVERRIDE;
   virtual int32_t IndexInParent() const;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
-  virtual a11y::role NativeRole();
-  virtual uint64_t NativeState();
-  virtual uint64_t NativeInteractiveState() const;
+  virtual a11y::role NativeRole() MOZ_OVERRIDE;
+  virtual uint64_t NativeState() MOZ_OVERRIDE;
+  virtual uint64_t NativeInteractiveState() const MOZ_OVERRIDE;
 
   // ActionAccessible
-  virtual uint8_t ActionCount();
+  virtual uint8_t ActionCount() MOZ_OVERRIDE;
+  virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) MOZ_OVERRIDE;
+  virtual bool DoAction(uint8_t aIndex) MOZ_OVERRIDE;
 
   // TableCellAccessible
   virtual TableAccessible* Table() const MOZ_OVERRIDE;
   virtual uint32_t ColIdx() const MOZ_OVERRIDE;
   virtual uint32_t RowIdx() const MOZ_OVERRIDE;
   virtual void ColHeaderCells(nsTArray<Accessible*>* aHeaderCells) MOZ_OVERRIDE;
   virtual void RowHeaderCells(nsTArray<Accessible*>* aCells) MOZ_OVERRIDE { }
   virtual bool Selected() MOZ_OVERRIDE;
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -1283,21 +1283,21 @@ nsScriptSecurityManager::nsScriptSecurit
 {
     static_assert(sizeof(intptr_t) == sizeof(void*),
                   "intptr_t and void* have different lengths on this platform. "
                   "This may cause a security failure with the SecurityLevel union.");
 }
 
 nsresult nsScriptSecurityManager::Init()
 {
-    InitPrefs();
-
     nsresult rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
     NS_ENSURE_SUCCESS(rv, rv);
 
+    InitPrefs();
+
     nsCOMPtr<nsIStringBundleService> bundleService =
         mozilla::services::GetStringBundleService();
     if (!bundleService)
         return NS_ERROR_FAILURE;
 
     rv = bundleService->CreateBundle("chrome://global/locale/security/caps.properties", &sStrBundle);
     NS_ENSURE_SUCCESS(rv, rv);
 
--- a/configure.in
+++ b/configure.in
@@ -9132,17 +9132,17 @@ export WRAP_LDFLAGS
 
 if test -n "$_WRAP_MALLOC"; then
     # Avoid doubling wrap malloc arguments
     _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--enable-wrap-malloc *//'`"
 fi
 
 if test -n "$MOZ_USING_CCACHE"; then
     # Avoid double prepending ccache by omitting --with-ccache in building NSPR.
-    _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--with-ccache[^ ]*//'`"
+    _SUBDIR_CONFIG_ARGS="`echo $_SUBDIR_CONFIG_ARGS | sed -e 's/--with-ccache[[^ ]]*//'`"
 fi
 
 MOZ_SUBCONFIGURE_NSPR()
 
 dnl ========================================================
 dnl = Setup a nice relatively clean build environment for
 dnl = sub-configures.
 dnl ========================================================
--- a/content/base/src/nsLineBreaker.cpp
+++ b/content/base/src/nsLineBreaker.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include "nsLineBreaker.h"
 #include "nsContentUtils.h"
 #include "nsILineBreaker.h"
-#include "gfxFont.h" // for the gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_* values
+#include "gfxTextRun.h" // for the gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_* values
 #include "nsHyphenationManager.h"
 #include "nsHyphenator.h"
 #include "mozilla/gfx/2D.h"
 
 nsLineBreaker::nsLineBreaker()
   : mCurrentWordLanguage(nullptr),
     mCurrentWordContainsMixedLang(false),
     mCurrentWordContainsComplexChar(false),
--- a/content/media/CubebUtils.cpp
+++ b/content/media/CubebUtils.cpp
@@ -1,37 +1,50 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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/. */
 
 #include <stdint.h>
 #include <algorithm>
+#include "mozilla/Atomics.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/StaticMutex.h"
 #include "CubebUtils.h"
+#include "nsAutoRef.h"
 #include "prdtoa.h"
 
 #define PREF_VOLUME_SCALE "media.volume_scale"
 #define PREF_CUBEB_LATENCY "media.cubeb_latency_ms"
 
 namespace mozilla {
 
+namespace {
+
+// Prefered samplerate, in Hz (characteristic of the
+// hardware/mixer/platform/API used).
+Atomic<uint32_t> sPreferredSampleRate;
+
+// This mutex protects the variables below.
+StaticMutex sMutex;
+cubeb* sCubebContext;
+double sVolumeScale;
+uint32_t sCubebLatency;
+bool sCubebLatencyPrefSet;
+
+} // anonymous namespace
+
 extern PRLogModuleInfo* gAudioStreamLog;
 
 static const uint32_t CUBEB_NORMAL_LATENCY_MS = 100;
 
-StaticMutex CubebUtils::sMutex;
-cubeb* CubebUtils::sCubebContext;
-uint32_t CubebUtils::sPreferredSampleRate;
-double CubebUtils::sVolumeScale;
-uint32_t CubebUtils::sCubebLatency;
-bool CubebUtils::sCubebLatencyPrefSet;
+namespace CubebUtils {
 
-/*static*/ void CubebUtils::PrefChanged(const char* aPref, void* aClosure)
+void PrefChanged(const char* aPref, void* aClosure)
 {
   if (strcmp(aPref, PREF_VOLUME_SCALE) == 0) {
     nsAdoptingString value = Preferences::GetString(aPref);
     StaticMutexAutoLock lock(sMutex);
     if (value.IsEmpty()) {
       sVolumeScale = 1.0;
     } else {
       NS_ConvertUTF16toUTF8 utf8(value);
@@ -43,116 +56,123 @@ bool CubebUtils::sCubebLatencyPrefSet;
     // audible.
     sCubebLatencyPrefSet = Preferences::HasUserValue(aPref);
     uint32_t value = Preferences::GetUint(aPref, CUBEB_NORMAL_LATENCY_MS);
     StaticMutexAutoLock lock(sMutex);
     sCubebLatency = std::min<uint32_t>(std::max<uint32_t>(value, 1), 1000);
   }
 }
 
-/*static*/ bool CubebUtils::GetFirstStream()
+bool GetFirstStream()
 {
   static bool sFirstStream = true;
 
   StaticMutexAutoLock lock(sMutex);
   bool result = sFirstStream;
   sFirstStream = false;
   return result;
 }
 
-/*static*/ double CubebUtils::GetVolumeScale()
+double GetVolumeScale()
 {
   StaticMutexAutoLock lock(sMutex);
   return sVolumeScale;
 }
 
-/*static*/ cubeb* CubebUtils::GetCubebContext()
+cubeb* GetCubebContext()
 {
   StaticMutexAutoLock lock(sMutex);
   return GetCubebContextUnlocked();
 }
 
-/*static*/ void CubebUtils::InitPreferredSampleRate()
+void InitPreferredSampleRate()
 {
+  // The mutex is used here to prohibit concurrent initialization calls, but
+  // sPreferredSampleRate itself is safe to access without the mutex because
+  // it is using atomic storage.
   StaticMutexAutoLock lock(sMutex);
+  uint32_t preferredSampleRate = 0;
   if (sPreferredSampleRate == 0 &&
       cubeb_get_preferred_sample_rate(GetCubebContextUnlocked(),
-                                      &sPreferredSampleRate) != CUBEB_OK) {
+                                      &preferredSampleRate) == CUBEB_OK) {
+    sPreferredSampleRate = preferredSampleRate;
+  } else {
+    // Query failed, use a sensible default.
     sPreferredSampleRate = 44100;
   }
 }
 
-/*static*/ cubeb* CubebUtils::GetCubebContextUnlocked()
+cubeb* GetCubebContextUnlocked()
 {
   sMutex.AssertCurrentThreadOwns();
   if (sCubebContext ||
       cubeb_init(&sCubebContext, "CubebUtils") == CUBEB_OK) {
     return sCubebContext;
   }
   NS_WARNING("cubeb_init failed");
   return nullptr;
 }
 
-/*static*/ uint32_t CubebUtils::GetCubebLatency()
+uint32_t GetCubebLatency()
 {
   StaticMutexAutoLock lock(sMutex);
   return sCubebLatency;
 }
 
-/*static*/ bool CubebUtils::CubebLatencyPrefSet()
+bool CubebLatencyPrefSet()
 {
   StaticMutexAutoLock lock(sMutex);
   return sCubebLatencyPrefSet;
 }
 
-/*static*/ void CubebUtils::InitLibrary()
+void InitLibrary()
 {
 #ifdef PR_LOGGING
   gAudioStreamLog = PR_NewLogModule("AudioStream");
 #endif
   PrefChanged(PREF_VOLUME_SCALE, nullptr);
   Preferences::RegisterCallback(PrefChanged, PREF_VOLUME_SCALE);
   PrefChanged(PREF_CUBEB_LATENCY, nullptr);
   Preferences::RegisterCallback(PrefChanged, PREF_CUBEB_LATENCY);
 }
 
-/*static*/ void CubebUtils::ShutdownLibrary()
+void ShutdownLibrary()
 {
   Preferences::UnregisterCallback(PrefChanged, PREF_VOLUME_SCALE);
   Preferences::UnregisterCallback(PrefChanged, PREF_CUBEB_LATENCY);
 
   StaticMutexAutoLock lock(sMutex);
   if (sCubebContext) {
     cubeb_destroy(sCubebContext);
     sCubebContext = nullptr;
   }
 }
 
-/*static*/ int CubebUtils::MaxNumberOfChannels()
+uint32_t MaxNumberOfChannels()
 {
-  cubeb* cubebContext = CubebUtils::GetCubebContext();
+  cubeb* cubebContext = GetCubebContext();
   uint32_t maxNumberOfChannels;
   if (cubebContext &&
       cubeb_get_max_channel_count(cubebContext,
                                   &maxNumberOfChannels) == CUBEB_OK) {
-    return static_cast<int>(maxNumberOfChannels);
+    return maxNumberOfChannels;
   }
 
   return 0;
 }
 
-/*static*/ int CubebUtils::PreferredSampleRate()
+uint32_t PreferredSampleRate()
 {
   MOZ_ASSERT(sPreferredSampleRate,
              "sPreferredSampleRate has not been initialized!");
   return sPreferredSampleRate;
 }
 
 #if defined(__ANDROID__) && defined(MOZ_B2G)
-/*static*/ cubeb_stream_type CubebUtils::ConvertChannelToCubebType(dom::AudioChannel aChannel)
+cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel)
 {
   switch(aChannel) {
     case dom::AudioChannel::Normal:
       return CUBEB_STREAM_TYPE_SYSTEM;
     case dom::AudioChannel::Content:
       return CUBEB_STREAM_TYPE_MUSIC;
     case dom::AudioChannel::Notification:
       return CUBEB_STREAM_TYPE_NOTIFICATION;
@@ -166,9 +186,10 @@ bool CubebUtils::sCubebLatencyPrefSet;
       return CUBEB_STREAM_TYPE_SYSTEM_ENFORCED;
     default:
       NS_ERROR("The value of AudioChannel is invalid");
       return CUBEB_STREAM_TYPE_MAX;
   }
 }
 #endif
 
-}
+} // namespace CubebUtils
+} // namespace mozilla
--- a/content/media/CubebUtils.h
+++ b/content/media/CubebUtils.h
@@ -3,70 +3,47 @@
 /* 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/. */
 
 #if !defined(CubebUtils_h_)
 #define CubebUtils_h_
 
 #include "cubeb/cubeb.h"
-#include "nsAutoRef.h"
-#include "mozilla/StaticMutex.h"
 #include "mozilla/dom/AudioChannelBinding.h"
 
-template <>
-class nsAutoRefTraits<cubeb_stream> : public nsPointerRefTraits<cubeb_stream>
-{
-public:
-  static void Release(cubeb_stream* aStream) { cubeb_stream_destroy(aStream); }
-};
-
 namespace mozilla {
+namespace CubebUtils {
 
-class CubebUtils {
-public:
-  // Initialize Audio Library. Some Audio backends require initializing the
-  // library before using it.
-  static void InitLibrary();
+// Initialize Audio Library. Some Audio backends require initializing the
+// library before using it.
+void InitLibrary();
 
-  // Shutdown Audio Library. Some Audio backends require shutting down the
-  // library after using it.
-  static void ShutdownLibrary();
+// Shutdown Audio Library. Some Audio backends require shutting down the
+// library after using it.
+void ShutdownLibrary();
 
-  // Returns the maximum number of channels supported by the audio hardware.
-  static int MaxNumberOfChannels();
+// Returns the maximum number of channels supported by the audio hardware.
+uint32_t MaxNumberOfChannels();
 
-  // Queries the samplerate the hardware/mixer runs at, and stores it.
-  // Can be called on any thread. When this returns, it is safe to call
-  // PreferredSampleRate without locking.
-  static void InitPreferredSampleRate();
-  // Get the aformentionned sample rate. Does not lock.
-  static int PreferredSampleRate();
+// Queries the samplerate the hardware/mixer runs at, and stores it.
+// Can be called on any thread. When this returns, it is safe to call
+// PreferredSampleRate.
+void InitPreferredSampleRate();
+
+// Get the aforementioned sample rate. Thread safe.
+uint32_t PreferredSampleRate();
 
-  static void PrefChanged(const char* aPref, void* aClosure);
-  static double GetVolumeScale();
-  static bool GetFirstStream();
-  static cubeb* GetCubebContext();
-  static cubeb* GetCubebContextUnlocked();
-  static uint32_t GetCubebLatency();
-  static bool CubebLatencyPrefSet();
+void PrefChanged(const char* aPref, void* aClosure);
+double GetVolumeScale();
+bool GetFirstStream();
+cubeb* GetCubebContext();
+cubeb* GetCubebContextUnlocked();
+uint32_t GetCubebLatency();
+bool CubebLatencyPrefSet();
 #if defined(__ANDROID__) && defined(MOZ_B2G)
-  static cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel);
+cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel);
 #endif
 
-private:
-  // This mutex protects the static members below.
-  static StaticMutex sMutex;
-  static cubeb* sCubebContext;
-
-  // Prefered samplerate, in Hz (characteristic of the
-  // hardware/mixer/platform/API used).
-  static uint32_t sPreferredSampleRate;
-
-  static double sVolumeScale;
-  static uint32_t sCubebLatency;
-  static bool sCubebLatencyPrefSet;
-};
-}
-
-
+} // namespace CubebUtils
+} // namespace mozilla
 
 #endif // CubebUtils_h_
--- a/content/media/DecoderTraits.cpp
+++ b/content/media/DecoderTraits.cpp
@@ -2,16 +2,17 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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/. */
 
 #include "DecoderTraits.h"
 #include "MediaDecoder.h"
 #include "nsCharSeparatedTokenizer.h"
+#include "nsMimeTypes.h"
 #include "mozilla/Preferences.h"
 
 #ifdef MOZ_ANDROID_OMX
 #include "AndroidMediaPluginHost.h"
 #endif
 
 #include "OggDecoder.h"
 #include "OggReader.h"
@@ -214,16 +215,17 @@ IsGStreamerSupportedType(const nsACStrin
 }
 #endif
 
 #ifdef MOZ_OMX_DECODER
 static const char* const gOmxTypes[] = {
   "audio/mpeg",
   "audio/mp4",
   "audio/amr",
+  "audio/3gpp",
   "video/mp4",
   "video/3gpp",
   "video/3gpp2",
   "video/quicktime",
 #ifdef MOZ_OMX_WEBM_DECODER
   "video/webm",
   "audio/webm",
 #endif
@@ -537,17 +539,17 @@ InstantiateDecoder(const nsACString& aTy
     decoder = new WaveDecoder();
     return decoder.forget();
   }
 #endif
 #ifdef MOZ_OMX_DECODER
   if (IsOmxSupportedType(aType)) {
     // AMR audio is enabled for MMS, but we are discouraging Web and App
     // developers from using AMR, thus we only allow AMR to be played on WebApps.
-    if (aType.EqualsASCII("audio/amr")) {
+    if (aType.EqualsLiteral(AUDIO_AMR) || aType.EqualsLiteral(AUDIO_3GPP)) {
       dom::HTMLMediaElement* element = aOwner->GetMediaElement();
       if (!element) {
         return nullptr;
       }
       nsIPrincipal* principal = element->NodePrincipal();
       if (!principal) {
         return nullptr;
       }
@@ -710,17 +712,18 @@ bool DecoderTraits::IsSupportedInVideoDo
     return false;
   }
 
   return
     IsOggType(aType) ||
 #ifdef MOZ_OMX_DECODER
     // We support amr inside WebApps on firefoxOS but not in general web content.
     // Ensure we dont create a VideoDocument when accessing amr URLs directly.
-    (IsOmxSupportedType(aType) && !aType.EqualsASCII("audio/amr")) ||
+    (IsOmxSupportedType(aType) &&
+     (!aType.EqualsLiteral(AUDIO_AMR) && !aType.EqualsLiteral(AUDIO_3GPP))) ||
 #endif
 #ifdef MOZ_WEBM
     IsWebMType(aType) ||
 #endif
 #ifdef MOZ_GSTREAMER
     IsGStreamerSupportedType(aType) ||
 #endif
 #ifdef MOZ_ANDROID_OMX
--- a/content/media/GraphDriver.h
+++ b/content/media/GraphDriver.h
@@ -9,19 +9,25 @@
 #include "nsAutoPtr.h"
 #include "nsAutoRef.h"
 #include "AudioBufferUtils.h"
 #include "AudioMixer.h"
 #include "AudioSegment.h"
 
 struct cubeb_stream;
 
+template <>
+class nsAutoRefTraits<cubeb_stream> : public nsPointerRefTraits<cubeb_stream>
+{
+public:
+  static void Release(cubeb_stream* aStream) { cubeb_stream_destroy(aStream); }
+};
+
 namespace mozilla {
 
-
 /**
  * Assume we can run an iteration of the MediaStreamGraph loop in this much time
  * or less.
  * We try to run the control loop at this rate.
  */
 static const int MEDIA_GRAPH_TARGET_PERIOD_MS = 10;
 
 /**
--- a/content/media/MP3FrameParser.h
+++ b/content/media/MP3FrameParser.h
@@ -127,17 +127,21 @@ public:
   bool ParsedHeaders();
 
   // Returns true if we know the exact duration of the MP3 stream;
   // false otherwise.
   bool HasExactDuration();
 
   // Returns true if the parser needs more data for duration estimation.
   bool NeedsData();
-
+  // Assign the total lenght of this mp3 stream
+  void SetLength(int64_t aLength) {
+    MutexAutoLock mon(mLock);
+    mLength = aLength;
+  }
 private:
 
   // Parses aBuffer, starting at offset 0. Returns the number of bytes
   // parsed, relative to the start of the buffer. Note this may be
   // greater than aLength if the headers in the buffer indicate that
   // the frame or ID3 tag extends outside of aBuffer. Returns failure
   // if too many non-MP3 bytes are parsed.
   nsresult ParseBuffer(const uint8_t* aBuffer,
--- a/content/media/MediaDecoderStateMachine.cpp
+++ b/content/media/MediaDecoderStateMachine.cpp
@@ -1906,16 +1906,21 @@ MediaDecoderStateMachine::CallDecodeMeta
 
 nsresult MediaDecoderStateMachine::DecodeMetadata()
 {
   AssertCurrentThreadInMonitor();
   NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");
   MOZ_ASSERT(mState == DECODER_STATE_DECODING_METADATA);
   DECODER_LOG("Decoding Media Headers");
 
+  if (mReader->IsWaitingMediaResources()) {
+    StartWaitForResources();
+    return NS_OK;
+  }
+
   nsresult res;
   MediaInfo info;
   {
     ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
     res = mReader->ReadMetadata(&info, getter_Transfers(mMetadataTags));
   }
 
   if (NS_SUCCEEDED(res)) {
--- a/content/media/fmp4/wmf/MFTDecoder.cpp
+++ b/content/media/fmp4/wmf/MFTDecoder.cpp
@@ -106,17 +106,17 @@ MFTDecoder::SetDecoderOutputType()
       NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
       return S_OK;
     }
   }
   return E_FAIL;
 }
 
 HRESULT
-MFTDecoder::SendMFTMessage(MFT_MESSAGE_TYPE aMsg, UINT32 aData)
+MFTDecoder::SendMFTMessage(MFT_MESSAGE_TYPE aMsg, ULONG_PTR aData)
 {
   NS_ENSURE_TRUE(mDecoder != nullptr, E_POINTER);
   HRESULT hr = mDecoder->ProcessMessage(aMsg, aData);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
   return S_OK;
 }
 
 HRESULT
--- a/content/media/fmp4/wmf/MFTDecoder.h
+++ b/content/media/fmp4/wmf/MFTDecoder.h
@@ -69,17 +69,17 @@ public:
   //  - S_OK if an output frame is produced.
   HRESULT Output(RefPtr<IMFSample>* aOutput);
 
   // Sends a flush message to the MFT. This causes it to discard all
   // input data. Use before seeking.
   HRESULT Flush();
 
   // Sends a message to the MFT.
-  HRESULT SendMFTMessage(MFT_MESSAGE_TYPE aMsg, UINT32 aData);
+  HRESULT SendMFTMessage(MFT_MESSAGE_TYPE aMsg, ULONG_PTR aData);
 
 private:
 
   HRESULT SetDecoderOutputType();
 
   HRESULT CreateInputSample(const uint8_t* aData,
                             uint32_t aDataSize,
                             int64_t aTimestampUsecs,
--- a/content/media/gmp/GMPPlatform.cpp
+++ b/content/media/gmp/GMPPlatform.cpp
@@ -252,17 +252,17 @@ GMPThreadImpl::Join()
     if (mThread.IsRunning()) {
       mThread.Stop();
     }
   }
   delete this;
 }
 
 GMPMutexImpl::GMPMutexImpl()
-: mMutex("gmp-mutex")
+: mMonitor("gmp-mutex")
 {
   MOZ_COUNT_CTOR(GMPMutexImpl);
 }
 
 GMPMutexImpl::~GMPMutexImpl()
 {
   MOZ_COUNT_DTOR(GMPMutexImpl);
 }
@@ -271,19 +271,19 @@ void
 GMPMutexImpl::Destroy()
 {
   delete this;
 }
 
 void
 GMPMutexImpl::Acquire()
 {
-  mMutex.Lock();
+  mMonitor.Enter();
 }
 
 void
 GMPMutexImpl::Release()
 {
-  mMutex.Unlock();
+  mMonitor.Exit();
 }
 
 } // namespace gmp
 } // namespace mozilla
--- a/content/media/gmp/GMPPlatform.h
+++ b/content/media/gmp/GMPPlatform.h
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GMPPlatform_h_
 #define GMPPlatform_h_
 
 #include "mozilla/Mutex.h"
 #include "gmp-platform.h"
 #include "base/thread.h"
+#include "mozilla/ReentrantMonitor.h"
 
 namespace mozilla {
 namespace gmp {
 
 class GMPChild;
 
 void InitPlatformAPI(GMPPlatformAPI& aPlatformAPI, GMPChild* aChild);
 
@@ -41,15 +42,15 @@ public:
   virtual ~GMPMutexImpl();
 
   // GMPMutex
   virtual void Acquire() MOZ_OVERRIDE;
   virtual void Release() MOZ_OVERRIDE;
   virtual void Destroy() MOZ_OVERRIDE;
 
 private:
-  Mutex mMutex;
+  ReentrantMonitor mMonitor;
 };
 
 } // namespace gmp
 } // namespace mozilla
 
 #endif // GMPPlatform_h_
--- a/content/media/gmp/gmp-api/gmp-platform.h
+++ b/content/media/gmp/gmp-api/gmp-platform.h
@@ -48,16 +48,18 @@ public:
 
 class GMPThread {
 public:
   virtual ~GMPThread() {}
   virtual void Post(GMPTask* aTask) = 0;
   virtual void Join() = 0; // Deletes object after join completes.
 };
 
+// A re-entrant monitor; can be locked from the same thread multiple times.
+// Must be unlocked the same number of times it's locked.
 class GMPMutex {
 public:
   virtual ~GMPMutex() {}
   virtual void Acquire() = 0;
   virtual void Release() = 0;
   virtual void Destroy() = 0; // Deletes object.
 };
 
--- a/content/media/mediasource/MediaSource.h
+++ b/content/media/mediasource/MediaSource.h
@@ -100,16 +100,20 @@ public:
 
 #if defined(DEBUG)
   // Dump the contents of each SourceBuffer to a series of files under aPath.
   // aPath must exist.  Debug only, invoke from your favourite debugger.
   void Dump(const char* aPath);
 #endif
 
 private:
+  // MediaSourceDecoder uses DurationChange to set the duration
+  // without hitting the checks in SetDuration.
+  friend class mozilla::MediaSourceDecoder;
+
   ~MediaSource();
 
   explicit MediaSource(nsPIDOMWindow* aWindow);
 
   friend class AsyncEventRunner<MediaSource>;
   void DispatchSimpleEvent(const char* aName);
   void QueueAsyncSimpleEvent(const char* aName);
 
--- a/content/media/mediasource/MediaSourceDecoder.cpp
+++ b/content/media/mediasource/MediaSourceDecoder.cpp
@@ -71,16 +71,17 @@ MediaSourceDecoder::Load(nsIStreamListen
 
 nsresult
 MediaSourceDecoder::GetSeekable(dom::TimeRanges* aSeekable)
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (!mMediaSource) {
     return NS_ERROR_FAILURE;
   }
+
   double duration = mMediaSource->Duration();
   if (IsNaN(duration)) {
     // Return empty range.
   } else if (duration > 0 && mozilla::IsInfinite(duration)) {
     nsRefPtr<dom::TimeRanges> bufferedRanges = new dom::TimeRanges();
     mMediaSource->GetBuffered(bufferedRanges);
     aSeekable->Add(bufferedRanges->GetStartTime(), bufferedRanges->GetEndTime());
   } else {
@@ -164,17 +165,17 @@ MediaSourceDecoder::Ended()
 void
 MediaSourceDecoder::SetMediaSourceDuration(double aDuration)
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (!mMediaSource) {
     return;
   }
   ErrorResult dummy;
-  mMediaSource->SetDuration(aDuration, dummy);
+  mMediaSource->DurationChange(aDuration, dummy);
 }
 
 void
 MediaSourceDecoder::NotifyTimeRangesChanged()
 {
   ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
   mon.NotifyAll();
 }
--- a/content/media/mediasource/MediaSourceReader.cpp
+++ b/content/media/mediasource/MediaSourceReader.cpp
@@ -465,24 +465,20 @@ MediaSourceReader::Seek(int64_t aTime, i
     }
   }
   return NS_OK;
 }
 
 nsresult
 MediaSourceReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
 {
-  bool waiting = IsWaitingMediaResources();
-  MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata waiting=%d tracks=%u/%u audio=%p video=%p",
-            this, waiting, mEssentialTrackBuffers.Length(), mTrackBuffers.Length(),
+  MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata tracks=%u/%u audio=%p video=%p",
+            this, mEssentialTrackBuffers.Length(), mTrackBuffers.Length(),
             mAudioTrack.get(), mVideoTrack.get());
-  // ReadMetadata is called *before* checking IsWaitingMediaResources.
-  if (waiting) {
-    return NS_OK;
-  }
+
   mEssentialTrackBuffers.Clear();
   if (!mAudioTrack && !mVideoTrack) {
     MSE_DEBUG("MediaSourceReader(%p)::ReadMetadata missing track: mAudioTrack=%p mVideoTrack=%p",
               this, mAudioTrack.get(), mVideoTrack.get());
     return NS_ERROR_FAILURE;
   }
 
   int64_t maxDuration = -1;
--- a/content/media/mediasource/ResourceQueue.h
+++ b/content/media/mediasource/ResourceQueue.h
@@ -98,30 +98,29 @@ public:
   }
 
   void AppendItem(const uint8_t* aData, uint32_t aLength) {
     mLogicalLength += aLength;
     Push(new ResourceItem(aData, aLength));
   }
 
   // Evict data in queue if the total queue size is greater than
-  // aThreshold past the offset. Returns true if some data was
-  // actually evicted.
-  bool Evict(uint64_t aOffset, uint32_t aThreshold) {
-    bool evicted = false;
+  // aThreshold past the offset. Returns amount evicted.
+  uint32_t Evict(uint64_t aOffset, uint32_t aThreshold) {
+    uint32_t evicted = 0;
     while (GetLength() - mOffset > aThreshold) {
       ResourceItem* item = ResourceAt(0);
       if (item->mData.Length() + mOffset > aOffset) {
         break;
       }
       mOffset += item->mData.Length();
+      evicted += item->mData.Length();
       SBR_DEBUGV("ResourceQueue(%p)::Evict(%llu, %u) removed chunk length=%u",
                  this, aOffset, aThreshold, item->mData.Length());
       delete PopFront();
-      evicted = true;
     }
     return evicted;
   }
 
   size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const {
     // Calculate the size of the internal deque.
     size_t size = nsDeque::SizeOfExcludingThis(aMallocSizeOf);
 
--- a/content/media/mediasource/SourceBuffer.cpp
+++ b/content/media/mediasource/SourceBuffer.cpp
@@ -509,16 +509,18 @@ SourceBuffer::SourceBuffer(MediaSource* 
   , mAppendWindowStart(0)
   , mAppendWindowEnd(PositiveInfinity<double>())
   , mTimestampOffset(0)
   , mAppendMode(SourceBufferAppendMode::Segments)
   , mUpdating(false)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aMediaSource);
+  mEvictionThreshold = Preferences::GetUint("media.mediasource.eviction_threshold",
+                                            75 * (1 << 20));
   mParser = ContainerParser::CreateForMIMEType(aType);
   mTrackBuffer = new TrackBuffer(aMediaSource->GetDecoder(), aType);
   MSE_DEBUG("SourceBuffer(%p)::SourceBuffer: Create mParser=%p mTrackBuffer=%p",
             this, mParser.get(), mTrackBuffer.get());
 }
 
 SourceBuffer::~SourceBuffer()
 {
@@ -654,18 +656,18 @@ SourceBuffer::AppendData(const uint8_t* 
 
   // Eviction uses a byte threshold. If the buffer is greater than the
   // number of bytes then data is evicted. The time range for this
   // eviction is reported back to the media source. It will then
   // evict data before that range across all SourceBuffers it knows
   // about.
   // TODO: Make the eviction threshold smaller for audio-only streams.
   // TODO: Drive evictions off memory pressure notifications.
-  const uint32_t evict_threshold = 75 * (1 << 20);
-  bool evicted = mTrackBuffer->EvictData(evict_threshold);
+  // TODO: Consider a global eviction threshold  rather than per TrackBuffer.
+  bool evicted = mTrackBuffer->EvictData(mEvictionThreshold);
   if (evicted) {
     MSE_DEBUG("SourceBuffer(%p)::AppendData Evict; current buffered start=%f",
               this, GetBufferedStart());
 
     // We notify that we've evicted from the time range 0 through to
     // the current start point.
     mMediaSource->NotifyEvicted(0.0, GetBufferedStart());
   }
--- a/content/media/mediasource/SourceBuffer.h
+++ b/content/media/mediasource/SourceBuffer.h
@@ -134,16 +134,18 @@ private:
 
   // Shared implementation of AppendBuffer overloads.
   void AppendData(const uint8_t* aData, uint32_t aLength, ErrorResult& aRv);
 
   nsRefPtr<MediaSource> mMediaSource;
 
   const nsCString mType;
 
+  uint32_t mEvictionThreshold;
+
   nsAutoPtr<ContainerParser> mParser;
 
   nsRefPtr<TrackBuffer> mTrackBuffer;
 
   double mAppendWindowStart;
   double mAppendWindowEnd;
 
   double mTimestampOffset;
--- a/content/media/mediasource/SourceBufferResource.cpp
+++ b/content/media/mediasource/SourceBufferResource.cpp
@@ -142,17 +142,17 @@ SourceBufferResource::ReadFromCache(char
             this, aBuffer, aOffset, aCount);
   ReentrantMonitorAutoEnter mon(mMonitor);
   int64_t oldOffset = mOffset;
   nsresult rv = ReadAt(aOffset, aBuffer, aCount, nullptr);
   mOffset = oldOffset;
   return rv;
 }
 
-bool
+uint32_t
 SourceBufferResource::EvictData(uint32_t aThreshold)
 {
   SBR_DEBUG("SourceBufferResource(%p)::EvictData(aThreshold=%u)", this, aThreshold);
   ReentrantMonitorAutoEnter mon(mMonitor);
   return mInputBuffer.Evict(mOffset, aThreshold);
 }
 
 void
--- a/content/media/mediasource/SourceBufferResource.h
+++ b/content/media/mediasource/SourceBufferResource.h
@@ -60,16 +60,17 @@ public:
   virtual void StartSeekingForMetadata() MOZ_OVERRIDE { UNIMPLEMENTED(); }
   virtual void EndSeekingForMetadata() MOZ_OVERRIDE { UNIMPLEMENTED(); }
   virtual int64_t Tell() MOZ_OVERRIDE { return mOffset; }
   virtual void Pin() MOZ_OVERRIDE { UNIMPLEMENTED(); }
   virtual void Unpin() MOZ_OVERRIDE { UNIMPLEMENTED(); }
   virtual double GetDownloadRate(bool* aIsReliable) MOZ_OVERRIDE { UNIMPLEMENTED(); *aIsReliable = false; return 0; }
   virtual int64_t GetLength() MOZ_OVERRIDE { return mInputBuffer.GetLength(); }
   virtual int64_t GetNextCachedData(int64_t aOffset) MOZ_OVERRIDE {
+    ReentrantMonitorAutoEnter mon(mMonitor);
     MOZ_ASSERT(aOffset >= 0);
     if (uint64_t(aOffset) < mInputBuffer.GetOffset()) {
       return mInputBuffer.GetOffset();
     } else if (aOffset == GetLength()) {
       return -1;
     }
     return aOffset;
   }
@@ -78,16 +79,17 @@ public:
   virtual bool IsSuspendedByCache() MOZ_OVERRIDE { UNIMPLEMENTED(); return false; }
   virtual bool IsSuspended() MOZ_OVERRIDE { UNIMPLEMENTED(); return false; }
   virtual nsresult ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount) MOZ_OVERRIDE;
   virtual bool IsTransportSeekable() MOZ_OVERRIDE { UNIMPLEMENTED(); return true; }
   virtual nsresult Open(nsIStreamListener** aStreamListener) MOZ_OVERRIDE { UNIMPLEMENTED(); return NS_ERROR_FAILURE; }
 
   virtual nsresult GetCachedRanges(nsTArray<MediaByteRange>& aRanges) MOZ_OVERRIDE
   {
+    ReentrantMonitorAutoEnter mon(mMonitor);
     if (mInputBuffer.GetLength()) {
       aRanges.AppendElement(MediaByteRange(mInputBuffer.GetOffset(),
                                            mInputBuffer.GetLength()));
     }
     return NS_OK;
   }
 
   virtual const nsCString& GetContentType() const MOZ_OVERRIDE { return mType; }
@@ -109,22 +111,28 @@ public:
   {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
   }
 
   // Used by SourceBuffer.
   void AppendData(const uint8_t* aData, uint32_t aLength);
   void Ended();
   // Remove data from resource if it holds more than the threshold
-  // number of bytes. Returns true if some data was evicted.
-  bool EvictData(uint32_t aThreshold);
+  // number of bytes. Returns amount evicted.
+  uint32_t EvictData(uint32_t aThreshold);
 
   // Remove data from resource before the given offset.
   void EvictBefore(uint64_t aOffset);
 
+  // Returns the amount of data currently retained by this resource.
+  int64_t GetSize() {
+    ReentrantMonitorAutoEnter mon(mMonitor);
+    return mInputBuffer.GetLength() - mInputBuffer.GetOffset();
+  }
+
 #if defined(DEBUG)
   void Dump(const char* aPath) {
     mInputBuffer.Dump(aPath);
   }
 #endif
 
 private:
   ~SourceBufferResource();
--- a/content/media/mediasource/TrackBuffer.cpp
+++ b/content/media/mediasource/TrackBuffer.cpp
@@ -119,30 +119,46 @@ TrackBuffer::AppendData(const uint8_t* a
 
   return true;
 }
 
 bool
 TrackBuffer::EvictData(uint32_t aThreshold)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  // XXX Call EvictData on mDecoders?
-  return mCurrentDecoder->GetResource()->EvictData(aThreshold);
+
+  int64_t totalSize = 0;
+  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
+    totalSize += mDecoders[i]->GetResource()->GetSize();
+  }
+
+  int64_t toEvict = totalSize - aThreshold;
+  if (toEvict <= 0) {
+    return false;
+  }
+
+  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
+    MSE_DEBUG("TrackBuffer(%p)::EvictData decoder=%u threshold=%u toEvict=%lld",
+              this, i, aThreshold, toEvict);
+    toEvict -= mDecoders[i]->GetResource()->EvictData(toEvict);
+  }
+  return toEvict < (totalSize - aThreshold);
 }
 
 void
 TrackBuffer::EvictBefore(double aTime)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  // XXX Call EvictBefore on mDecoders?
-  int64_t endOffset = mCurrentDecoder->ConvertToByteOffset(aTime);
-  if (endOffset > 0) {
-    mCurrentDecoder->GetResource()->EvictBefore(endOffset);
+  for (uint32_t i = 0; i < mDecoders.Length(); ++i) {
+    int64_t endOffset = mDecoders[i]->ConvertToByteOffset(aTime);
+    if (endOffset > 0) {
+      MSE_DEBUG("TrackBuffer(%p)::EvictBefore decoder=%u offset=%lld", this, i, endOffset);
+      mDecoders[i]->GetResource()->EvictBefore(endOffset);
+    }
   }
-  MSE_DEBUG("TrackBuffer(%p)::EvictBefore offset=%lld", this, endOffset);
 }
 
 double
 TrackBuffer::Buffered(dom::TimeRanges* aRanges)
 {
   ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
   MOZ_ASSERT(NS_IsMainThread());
 
--- a/content/media/mediasource/test/test_MediaSource.html
+++ b/content/media/mediasource/test/test_MediaSource.html
@@ -67,19 +67,18 @@ runWithMSE(function () {
   });
 
   ms.addEventListener("sourceended", function () {
     ok(true, "Receive a sourceended event");
     is(ms.readyState, "ended", "MediaSource must be in ended state after sourceended");
   });
 
   v.addEventListener("ended", function () {
-    // XXX: Duration should be exactly 4.0, see bug 1065207.
-    is(v.duration, 4.001, "Video has correct duration");
-    is(v.currentTime, 4.001, "Video has played to end");
+    is(v.duration, 4, "Video has correct duration");
+    is(v.currentTime, 4, "Video has played to end");
     v.parentNode.removeChild(v);
     SimpleTest.finish();
   });
 });
 
 </script>
 </pre>
 </body>
--- a/content/media/mediasource/test/test_SplitAppend.html
+++ b/content/media/mediasource/test/test_SplitAppend.html
@@ -27,19 +27,18 @@ runWithMSE(function (ms, v) {
           ms.endOfStream();
         }
       });
       v.play();
     });
   });
 
   v.addEventListener("ended", function () {
-    // XXX: Duration should be exactly 4.0, see bug 1065207.
-    is(v.duration, 4.001, "Video has correct duration");
-    is(v.currentTime, 4.001, "Video has played to end");
+    is(v.duration, 4, "Video has correct duration");
+    is(v.currentTime, 4, "Video has played to end");
     SimpleTest.finish();
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/mediasource/test/test_SplitAppendDelay.html
+++ b/content/media/mediasource/test/test_SplitAppendDelay.html
@@ -29,19 +29,18 @@ runWithMSE(function (ms, v) {
           ms.endOfStream();
         }
       });
       v.play();
     });
   });
 
   v.addEventListener("ended", function () {
-    // XXX: Duration should be exactly 4.0, see bug 1065207.
-    is(v.duration, 4.001, "Video has correct duration");
-    is(v.currentTime, 4.001, "Video has played to end");
+    is(v.duration, 4, "Video has correct duration");
+    is(v.currentTime, 4, "Video has played to end");
     SimpleTest.finish();
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/omx/MediaOmxReader.cpp
+++ b/content/media/omx/MediaOmxReader.cpp
@@ -30,23 +30,116 @@ namespace mozilla {
 
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* gMediaDecoderLog;
 #define DECODER_LOG(type, msg) PR_LOG(gMediaDecoderLog, type, msg)
 #else
 #define DECODER_LOG(type, msg)
 #endif
 
+class OmxReaderProcessCachedDataTask : public Task
+{
+public:
+  OmxReaderProcessCachedDataTask(MediaOmxReader* aOmxReader, int64_t aOffset)
+  : mOmxReader(aOmxReader),
+    mOffset(aOffset)
+  { }
+
+  void Run()
+  {
+    MOZ_ASSERT(!NS_IsMainThread());
+    MOZ_ASSERT(mOmxReader.get());
+    mOmxReader->ProcessCachedData(mOffset, false);
+  }
+
+private:
+  nsRefPtr<MediaOmxReader> mOmxReader;
+  int64_t                  mOffset;
+};
+
+// When loading an MP3 stream from a file, we need to parse the file's
+// content to find its duration. Reading files of 100 MiB or more can
+// delay the player app noticably, so the file is read and decoded in
+// smaller chunks.
+//
+// We first read on the decode thread, but parsing must be done on the
+// main thread. After we read the file's initial MiBs in the decode
+// thread, an instance of this class is scheduled to the main thread for
+// parsing the MP3 stream. The decode thread waits until it has finished.
+//
+// If there is more data available from the file, the runnable dispatches
+// a task to the IO thread for retrieving the next chunk of data, and
+// the IO task dispatches a runnable to the main thread for parsing the
+// data. This goes on until all of the MP3 file has been parsed.
+
+class OmxReaderNotifyDataArrivedRunnable : public nsRunnable
+{
+public:
+  OmxReaderNotifyDataArrivedRunnable(MediaOmxReader* aOmxReader,
+                                     const char* aBuffer, uint64_t aLength,
+                                     int64_t aOffset, uint64_t aFullLength)
+  : mOmxReader(aOmxReader),
+    mBuffer(aBuffer),
+    mLength(aLength),
+    mOffset(aOffset),
+    mFullLength(aFullLength)
+  {
+    MOZ_ASSERT(mOmxReader.get());
+    MOZ_ASSERT(mBuffer.get() || !mLength);
+  }
+
+  NS_IMETHOD Run()
+  {
+    NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
+
+    NotifyDataArrived();
+
+    return NS_OK;
+  }
+
+private:
+  void NotifyDataArrived()
+  {
+    const char* buffer = mBuffer.get();
+
+    while (mLength) {
+      uint32_t length = std::min<uint64_t>(mLength, UINT32_MAX);
+      mOmxReader->NotifyDataArrived(buffer, length,
+                                    mOffset);
+      buffer  += length;
+      mLength -= length;
+      mOffset += length;
+    }
+
+    if (mOffset < mFullLength) {
+      // We cannot read data in the main thread because it
+      // might block for too long. Instead we post an IO task
+      // to the IO thread if there is more data available.
+      XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
+          new OmxReaderProcessCachedDataTask(mOmxReader.get(), mOffset));
+    }
+  }
+
+  nsRefPtr<MediaOmxReader> mOmxReader;
+  nsAutoArrayPtr<const char>       mBuffer;
+  uint64_t                         mLength;
+  int64_t                          mOffset;
+  uint64_t                         mFullLength;
+};
+
 MediaOmxReader::MediaOmxReader(AbstractMediaDecoder *aDecoder)
   : MediaOmxCommonReader(aDecoder)
+  , mMP3FrameParser(-1)
   , mHasVideo(false)
   , mHasAudio(false)
   , mVideoSeekTimeUs(-1)
   , mAudioSeekTimeUs(-1)
   , mSkipCount(0)
+  , mUseParserDuration(false)
+  , mLastParserDuration(-1)
 {
 #ifdef PR_LOGGING
   if (!gMediaDecoderLog) {
     gMediaDecoderLog = PR_NewLogModule("MediaDecoder");
   }
 #endif
 
   mAudioChannel = dom::AudioChannelService::GetDefaultAudioChannel();
@@ -138,30 +231,51 @@ nsresult MediaOmxReader::ReadMetadata(Me
   *aTags = nullptr;
 
   // Initialize the internal OMX Decoder.
   nsresult rv = InitOmxDecoder();
   if (NS_FAILED(rv)) {
     return rv;
   }
 
+  bool isMP3 = mDecoder->GetResource()->GetContentType().EqualsASCII(AUDIO_MP3);
+  if (isMP3) {
+    // When read sdcard's file on b2g platform at constructor,
+    // the mDecoder->GetResource()->GetLength() would return -1.
+    // Delay set the total duration on this function.
+    mMP3FrameParser.SetLength(mDecoder->GetResource()->GetLength());
+    ProcessCachedData(0, true);
+  }
+
   if (!mOmxDecoder->TryLoad()) {
     return NS_ERROR_FAILURE;
   }
 
   if (IsWaitingMediaResources()) {
     return NS_OK;
   }
 
-  // Set the total duration (the max of the audio and video track).
-  int64_t durationUs;
-  mOmxDecoder->GetDuration(&durationUs);
-  if (durationUs) {
-    ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
-    mDecoder->SetMediaDuration(durationUs);
+  if (isMP3 && mMP3FrameParser.IsMP3()) {
+    int64_t duration = mMP3FrameParser.GetDuration();
+    // The MP3FrameParser may reported a duration;
+    // return -1 if no frame has been parsed.
+    if (duration >= 0) {
+      ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+      mUseParserDuration = true;
+      mLastParserDuration = duration;
+      mDecoder->SetMediaDuration(mLastParserDuration);
+    }
+  } else {
+    // Set the total duration (the max of the audio and video track).
+    int64_t durationUs;
+    mOmxDecoder->GetDuration(&durationUs);
+    if (durationUs) {
+      ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+      mDecoder->SetMediaDuration(durationUs);
+    }
   }
 
   if (mOmxDecoder->HasVideo()) {
     int32_t displayWidth, displayHeight, width, height;
     mOmxDecoder->GetVideoParameters(&displayWidth, &displayHeight,
                                     &width, &height);
     nsIntRect pictureRect(0, 0, width, height);
 
@@ -329,20 +443,32 @@ bool MediaOmxReader::DecodeVideoFrame(bo
     break;
   }
 
   return true;
 }
 
 void MediaOmxReader::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
 {
-  android::OmxDecoder *omxDecoder = mOmxDecoder.get();
+  MOZ_ASSERT(NS_IsMainThread());
+
+  if (HasVideo()) {
+    return;
+  }
 
-  if (omxDecoder) {
-    omxDecoder->NotifyDataArrived(aBuffer, aLength, aOffset);
+  if (!mMP3FrameParser.NeedsData()) {
+    return;
+  }
+
+  mMP3FrameParser.Parse(aBuffer, aLength, aOffset);
+  int64_t duration = mMP3FrameParser.GetDuration();
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
+  if (duration != mLastParserDuration && mUseParserDuration) {
+    mLastParserDuration = duration;
+    mDecoder->UpdateEstimatedMediaDuration(mLastParserDuration);
   }
 }
 
 bool MediaOmxReader::DecodeAudioData()
 {
   NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
   EnsureActive();
 
@@ -414,16 +540,58 @@ void MediaOmxReader::SetIdle() {
 void MediaOmxReader::EnsureActive() {
   if (!mOmxDecoder.get()) {
     return;
   }
   DebugOnly<nsresult> result = mOmxDecoder->Play();
   NS_ASSERTION(result == NS_OK, "OmxDecoder should be in play state to continue decoding");
 }
 
+int64_t MediaOmxReader::ProcessCachedData(int64_t aOffset, bool aWaitForCompletion)
+{
+  // We read data in chunks of 32 KiB. We can reduce this
+  // value if media, such as sdcards, is too slow.
+  // Because of SD card's slowness, need to keep sReadSize to small size.
+  // See Bug 914870.
+  static const int64_t sReadSize = 32 * 1024;
+
+  NS_ASSERTION(!NS_IsMainThread(), "Should not be on main thread.");
+
+  MOZ_ASSERT(mDecoder->GetResource());
+  int64_t resourceLength = mDecoder->GetResource()->GetCachedDataEnd(0);
+  NS_ENSURE_TRUE(resourceLength >= 0, -1);
+
+  if (aOffset >= resourceLength) {
+    return 0; // Cache is empty, nothing to do
+  }
+
+  int64_t bufferLength = std::min<int64_t>(resourceLength-aOffset, sReadSize);
+
+  nsAutoArrayPtr<char> buffer(new char[bufferLength]);
+
+  nsresult rv = mDecoder->GetResource()->ReadFromCache(buffer.get(),
+                                                       aOffset, bufferLength);
+  NS_ENSURE_SUCCESS(rv, -1);
+
+  nsRefPtr<OmxReaderNotifyDataArrivedRunnable> runnable(
+    new OmxReaderNotifyDataArrivedRunnable(this,
+                                           buffer.forget(),
+                                           bufferLength,
+                                           aOffset,
+                                           resourceLength));
+  if (aWaitForCompletion) {
+    rv = NS_DispatchToMainThread(runnable.get(), NS_DISPATCH_SYNC);
+  } else {
+    rv = NS_DispatchToMainThread(runnable.get());
+  }
+  NS_ENSURE_SUCCESS(rv, -1);
+
+  return resourceLength - aOffset - bufferLength;
+}
+
 android::sp<android::MediaSource> MediaOmxReader::GetAudioOffloadTrack()
 {
   if (!mOmxDecoder.get()) {
     return nullptr;
   }
   return mOmxDecoder->GetAudioOffloadTrack();
 }
 
--- a/content/media/omx/MediaOmxReader.h
+++ b/content/media/omx/MediaOmxReader.h
@@ -4,16 +4,18 @@
  * 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/. */
 #if !defined(MediaOmxReader_h_)
 #define MediaOmxReader_h_
 
 #include "MediaOmxCommonReader.h"
 #include "MediaResource.h"
 #include "MediaDecoderReader.h"
+#include "nsMimeTypes.h"
+#include "MP3FrameParser.h"
 #include "nsRect.h"
 #include <ui/GraphicBuffer.h>
 #include <stagefright/MediaSource.h>
 
 namespace android {
 class OmxDecoder;
 class MOZ_EXPORT MediaExtractor;
 }
@@ -30,22 +32,23 @@ class MediaOmxReader : public MediaOmxCo
 {
   nsCString mType;
   bool mHasVideo;
   bool mHasAudio;
   nsIntRect mPicture;
   nsIntSize mInitialFrame;
   int64_t mVideoSeekTimeUs;
   int64_t mAudioSeekTimeUs;
+  int64_t mLastParserDuration;
   int32_t mSkipCount;
-
+  bool mUseParserDuration;
 protected:
   android::sp<android::OmxDecoder> mOmxDecoder;
   android::sp<android::MediaExtractor> mExtractor;
-
+  MP3FrameParser mMP3FrameParser;
   // Called by ReadMetadata() during MediaDecoderStateMachine::DecodeMetadata()
   // on decode thread. It create and initialize the OMX decoder including
   // setting up custom extractor. The extractor provide the essential
   // information used for creating OMX decoder such as video/audio codec.
   virtual nsresult InitOmxDecoder();
 
   // Called inside DecodeVideoFrame, DecodeAudioData, ReadMetadata and Seek
   // to activate the decoder automatically.
@@ -85,14 +88,16 @@ public:
   virtual bool IsMediaSeekable() MOZ_OVERRIDE;
 
   virtual void SetIdle() MOZ_OVERRIDE;
 
   virtual void Shutdown() MOZ_OVERRIDE;
 
   void ReleaseDecoder();
 
+  int64_t ProcessCachedData(int64_t aOffset, bool aWaitForCompletion);
+
   android::sp<android::MediaSource> GetAudioOffloadTrack();
 };
 
 } // namespace mozilla
 
 #endif
--- a/content/media/omx/OmxDecoder.cpp
+++ b/content/media/omx/OmxDecoder.cpp
@@ -39,166 +39,16 @@ PRLogModuleInfo *gOmxDecoderLog;
 #else
 #define LOG(x...)
 #endif
 
 using namespace MPAPI;
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
-
-namespace mozilla {
-
-class ReleaseOmxDecoderRunnable : public nsRunnable
-{
-public:
-  ReleaseOmxDecoderRunnable(const android::sp<android::OmxDecoder>& aOmxDecoder)
-  : mOmxDecoder(aOmxDecoder)
-  {
-  }
-
-  NS_METHOD Run() MOZ_OVERRIDE
-  {
-    MOZ_ASSERT(NS_IsMainThread());
-    mOmxDecoder = nullptr; // release OmxDecoder
-    return NS_OK;
-  }
-
-private:
-  android::sp<android::OmxDecoder> mOmxDecoder;
-};
-
-class OmxDecoderProcessCachedDataTask : public Task
-{
-public:
-  OmxDecoderProcessCachedDataTask(android::OmxDecoder* aOmxDecoder, int64_t aOffset)
-  : mOmxDecoder(aOmxDecoder),
-    mOffset(aOffset)
-  { }
-
-  void Run()
-  {
-    MOZ_ASSERT(!NS_IsMainThread());
-    MOZ_ASSERT(mOmxDecoder.get());
-    int64_t rem = mOmxDecoder->ProcessCachedData(mOffset, false);
-
-    if (rem <= 0) {
-      ReleaseOmxDecoderRunnable* r = new ReleaseOmxDecoderRunnable(mOmxDecoder);
-      mOmxDecoder.clear();
-      NS_DispatchToMainThread(r);
-    }
-  }
-
-private:
-  android::sp<android::OmxDecoder> mOmxDecoder;
-  int64_t                          mOffset;
-};
-
-// When loading an MP3 stream from a file, we need to parse the file's
-// content to find its duration. Reading files of 100 MiB or more can
-// delay the player app noticably, so the file is read and decoded in
-// smaller chunks.
-//
-// We first read on the decode thread, but parsing must be done on the
-// main thread. After we read the file's initial MiBs in the decode
-// thread, an instance of this class is scheduled to the main thread for
-// parsing the MP3 stream. The decode thread waits until it has finished.
-//
-// If there is more data available from the file, the runnable dispatches
-// a task to the IO thread for retrieving the next chunk of data, and
-// the IO task dispatches a runnable to the main thread for parsing the
-// data. This goes on until all of the MP3 file has been parsed.
-
-class OmxDecoderNotifyDataArrivedRunnable : public nsRunnable
-{
-public:
-  OmxDecoderNotifyDataArrivedRunnable(android::OmxDecoder* aOmxDecoder,
-                                      const char* aBuffer, uint64_t aLength,
-                                      int64_t aOffset, uint64_t aFullLength)
-  : mOmxDecoder(aOmxDecoder),
-    mBuffer(aBuffer),
-    mLength(aLength),
-    mOffset(aOffset),
-    mFullLength(aFullLength),
-    mCompletedMonitor("OmxDecoderNotifyDataArrived.mCompleted"),
-    mCompleted(false)
-  {
-    MOZ_ASSERT(mOmxDecoder.get());
-    MOZ_ASSERT(mBuffer.get() || !mLength);
-  }
-
-  NS_IMETHOD Run()
-  {
-    NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
-
-    NotifyDataArrived();
-    Completed();
-
-    return NS_OK;
-  }
-
-  void WaitForCompletion()
-  {
-    MOZ_ASSERT(!NS_IsMainThread());
-
-    MonitorAutoLock mon(mCompletedMonitor);
-    if (!mCompleted) {
-      mCompletedMonitor.Wait();
-    }
-  }
-
-private:
-  void NotifyDataArrived()
-  {
-    const char* buffer = mBuffer.get();
-
-    while (mLength) {
-      uint32_t length = std::min<uint64_t>(mLength, UINT32_MAX);
-      bool success = mOmxDecoder->NotifyDataArrived(buffer, mLength,
-                                                    mOffset);
-      if (!success) {
-        return;
-      }
-
-      buffer  += length;
-      mLength -= length;
-      mOffset += length;
-    }
-
-    if (mOffset < mFullLength) {
-      // We cannot read data in the main thread because it
-      // might block for too long. Instead we post an IO task
-      // to the IO thread if there is more data available.
-      XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
-          new OmxDecoderProcessCachedDataTask(mOmxDecoder.get(), mOffset));
-    }
-  }
-
-  // Call this function at the end of Run() to notify waiting
-  // threads.
-  void Completed()
-  {
-    MonitorAutoLock mon(mCompletedMonitor);
-    MOZ_ASSERT(!mCompleted);
-    mCompleted = true;
-    mCompletedMonitor.Notify();
-  }
-
-  android::sp<android::OmxDecoder> mOmxDecoder;
-  nsAutoArrayPtr<const char>       mBuffer;
-  uint64_t                         mLength;
-  int64_t                          mOffset;
-  uint64_t                         mFullLength;
-
-  Monitor mCompletedMonitor;
-  bool    mCompleted;
-};
-
-}
-
 using namespace android;
 
 OmxDecoder::OmxDecoder(MediaResource *aResource,
                        AbstractMediaDecoder *aDecoder) :
   mDecoder(aDecoder),
   mResource(aResource),
   mDisplayWidth(0),
   mDisplayHeight(0),
@@ -206,18 +56,16 @@ OmxDecoder::OmxDecoder(MediaResource *aR
   mVideoHeight(0),
   mVideoColorFormat(0),
   mVideoStride(0),
   mVideoSliceHeight(0),
   mVideoRotation(0),
   mAudioChannels(-1),
   mAudioSampleRate(-1),
   mDurationUs(-1),
-  mMP3FrameParser(aResource->GetLength()),
-  mIsMp3(false),
   mVideoBuffer(nullptr),
   mAudioBuffer(nullptr),
   mIsVideoSeeking(false),
   mAudioMetadataRead(false),
   mAudioPaused(false),
   mVideoPaused(false)
 {
   mLooper = new ALooper;
@@ -263,19 +111,16 @@ bool OmxDecoder::Init(sp<MediaExtractor>
 #ifdef PR_LOGGING
   if (!gOmxDecoderLog) {
     gOmxDecoderLog = PR_NewLogModule("OmxDecoder");
   }
 #endif
 
   const char* extractorMime;
   sp<MetaData> meta = extractor->getMetaData();
-  if (meta->findCString(kKeyMIMEType, &extractorMime) && !strcasecmp(extractorMime, AUDIO_MP3)) {
-    mIsMp3 = true;
-  }
 
   ssize_t audioTrackIndex = -1;
   ssize_t videoTrackIndex = -1;
 
   for (size_t i = 0; i < extractor->countTracks(); ++i) {
     sp<MetaData> meta = extractor->getTrackMetaData(i);
 
     int32_t bitRate;
@@ -337,27 +182,16 @@ bool OmxDecoder::TryLoad() {
     if (durationUs > totalDurationUs)
       totalDurationUs = durationUs;
   }
   if (mAudioTrack.get()) {
     durationUs = -1;
     const char* audioMime;
     sp<MetaData> meta = mAudioTrack->getFormat();
 
-    if (mIsMp3) {
-      // Feed MP3 parser with cached data. Local files will be fully
-      // cached already, network streams will update with sucessive
-      // calls to NotifyDataArrived.
-      if (ProcessCachedData(0, true) >= 0) {
-        durationUs = mMP3FrameParser.GetDuration();
-        if (durationUs > totalDurationUs) {
-          totalDurationUs = durationUs;
-        }
-      }
-    }
     if ((durationUs == -1) && meta->findInt64(kKeyDuration, &durationUs)) {
       if (durationUs > totalDurationUs) {
         totalDurationUs = durationUs;
       }
     }
   }
   mDurationUs = totalDurationUs;
 
@@ -630,37 +464,16 @@ bool OmxDecoder::SetAudioFormat() {
   return true;
 }
 
 void OmxDecoder::ReleaseDecoder()
 {
   mDecoder = nullptr;
 }
 
-bool OmxDecoder::NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
-{
-  if (!mAudioTrack.get() || !mIsMp3 || !mMP3FrameParser.IsMP3() || !mDecoder) {
-    return false;
-  }
-
-  mMP3FrameParser.Parse(aBuffer, aLength, aOffset);
-
-  int64_t durationUs = mMP3FrameParser.GetDuration();
-
-  if (durationUs != mDurationUs) {
-    mDurationUs = durationUs;
-
-    MOZ_ASSERT(mDecoder);
-    ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
-    mDecoder->UpdateEstimatedMediaDuration(mDurationUs);
-  }
-
-  return true;
-}
-
 void OmxDecoder::ReleaseVideoBuffer() {
   if (mVideoBuffer) {
     mVideoBuffer->release();
     mVideoBuffer = nullptr;
   }
 }
 
 void OmxDecoder::ReleaseAudioBuffer() {
@@ -1080,51 +893,8 @@ void OmxDecoder::RecycleCallbackImp(Text
 }
 
 /* static */ void
 OmxDecoder::RecycleCallback(TextureClient* aClient, void* aClosure)
 {
   OmxDecoder* decoder = static_cast<OmxDecoder*>(aClosure);
   decoder->RecycleCallbackImp(aClient);
 }
-
-int64_t OmxDecoder::ProcessCachedData(int64_t aOffset, bool aWaitForCompletion)
-{
-  // We read data in chunks of 32 KiB. We can reduce this
-  // value if media, such as sdcards, is too slow.
-  // Because of SD card's slowness, need to keep sReadSize to small size.
-  // See Bug 914870.
-  static const int64_t sReadSize = 32 * 1024;
-
-  NS_ASSERTION(!NS_IsMainThread(), "Should not be on main thread.");
-
-  MOZ_ASSERT(mResource);
-
-  int64_t resourceLength = mResource->GetCachedDataEnd(0);
-  NS_ENSURE_TRUE(resourceLength >= 0, -1);
-
-  if (aOffset >= resourceLength) {
-    return 0; // Cache is empty, nothing to do
-  }
-
-  int64_t bufferLength = std::min<int64_t>(resourceLength-aOffset, sReadSize);
-
-  nsAutoArrayPtr<char> buffer(new char[bufferLength]);
-
-  nsresult rv = mResource->ReadFromCache(buffer.get(), aOffset, bufferLength);
-  NS_ENSURE_SUCCESS(rv, -1);
-
-  nsRefPtr<OmxDecoderNotifyDataArrivedRunnable> runnable(
-    new OmxDecoderNotifyDataArrivedRunnable(this,
-                                            buffer.forget(),
-                                            bufferLength,
-                                            aOffset,
-                                            resourceLength));
-
-  rv = NS_DispatchToMainThread(runnable.get());
-  NS_ENSURE_SUCCESS(rv, -1);
-
-  if (aWaitForCompletion) {
-    runnable->WaitForCompletion();
-  }
-
-  return resourceLength - aOffset - bufferLength;
-}
--- a/content/media/omx/OmxDecoder.h
+++ b/content/media/omx/OmxDecoder.h
@@ -157,18 +157,16 @@ public:
   bool IsWaitingMediaResources();
   bool AllocateMediaResources();
   void ReleaseMediaResources();
   bool SetVideoFormat();
   bool SetAudioFormat();
 
   void ReleaseDecoder();
 
-  bool NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset);
-
   void GetDuration(int64_t *durationUs) {
     *durationUs = mDurationUs;
   }
 
   void GetVideoParameters(int32_t* aDisplayWidth, int32_t* aDisplayHeight,
                           int32_t* aWidth, int32_t* aHeight) {
     *aDisplayWidth = mDisplayWidth;
     *aDisplayHeight = mDisplayHeight;
--- a/content/media/test/test_playback.html
+++ b/content/media/test/test_playback.html
@@ -12,40 +12,21 @@
 
 //longer timeout for sometimes B2G emulator runs very slowly
 if (SpecialPowers.Services.appinfo.name == "B2G") {
   SimpleTest.requestLongerTimeout(3);
 }
 
 var manager = new MediaTestManager;
 
-function localCheckMetadata(msg, e, test) {
-  if (test.width) {
-    is(e.videoWidth, test.width, msg + " video width");
-  }
-  if (test.height) {
-    is(e.videoHeight, test.height, msg + " video height");
-  }
-  if (test.duration) {
-    // see bug 1039901 for skipping mp3 duration test on B2G
-    if (SpecialPowers.Services.appinfo.name == "B2G" && /mp3$/.test(test.name)) {
-      todo(false, "Fix mp3 duration bug on B2G");
-      return;
-    }
-    ok(Math.abs(e.duration - test.duration) < 0.1,
-       msg + " duration (" + e.duration + ") should be around " + test.duration);
-  }
-}
-
 function startTest(test, token) {
   var v = document.createElement('video');
   v.preload = "metadata";
   v.token = token;
   manager.started(token);
-  var checkMetadata = localCheckMetadata;
 
   v.src = test.name;
   v.name = test.name;
   var check = function(test, v) { return function() {
     is(test.name, v.name, "Name should match test.name #1");
     checkMetadata(test.name, v, test);
   }}(test, v);
   var noLoad = function(test, v) { return function() {
--- a/content/media/webrtc/MediaEngineWebRTC.h
+++ b/content/media/webrtc/MediaEngineWebRTC.h
@@ -192,17 +192,17 @@ public:
   void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType);
 
   void AllocImpl();
   void DeallocImpl();
   void StartImpl(webrtc::CaptureCapability aCapability);
   void StopImpl();
   void SnapshotImpl();
   void RotateImage(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight);
-  uint32_t ConvertPixexFormatToFOURCC(int aFormat);
+  uint32_t ConvertPixelFormatToFOURCC(int aFormat);
   void Notify(const mozilla::hal::ScreenConfiguration& aConfiguration);
 
   nsresult TakePhoto(PhotoCallback* aCallback) MOZ_OVERRIDE;
 
 #endif
 
   // This runnable is for creating a temporary file on the main thread.
   NS_IMETHODIMP
--- a/content/media/webrtc/MediaEngineWebRTCVideo.cpp
+++ b/content/media/webrtc/MediaEngineWebRTCVideo.cpp
@@ -964,17 +964,17 @@ MediaEngineWebRTCVideoSource::OnTakePict
   MonitorAutoLock lock(mMonitor);
   if (mPhotoCallbacks.Length()) {
     NS_DispatchToMainThread(
       new GenerateBlobRunnable(mPhotoCallbacks, aData, aLength, aMimeType));
   }
 }
 
 uint32_t
-MediaEngineWebRTCVideoSource::ConvertPixexFormatToFOURCC(int aFormat)
+MediaEngineWebRTCVideoSource::ConvertPixelFormatToFOURCC(int aFormat)
 {
   switch (aFormat) {
   case HAL_PIXEL_FORMAT_YCrCb_420_SP:
     return libyuv::FOURCC_NV21;
   case HAL_PIXEL_FORMAT_YV12:
     return libyuv::FOURCC_YV12;
   default: {
     LOG((" xxxxx Unknown pixel format %d", aFormat));
@@ -1014,17 +1014,17 @@ MediaEngineWebRTCVideoSource::RotateImag
   libyuv::ConvertToI420(srcPtr, size,
                         dstPtr, dstWidth,
                         dstPtr + (dstWidth * dstHeight), half_width,
                         dstPtr + (dstWidth * dstHeight * 5 / 4), half_width,
                         0, 0,
                         aWidth, aHeight,
                         aWidth, aHeight,
                         static_cast<libyuv::RotationMode>(mRotation),
-                        ConvertPixexFormatToFOURCC(graphicBuffer->getPixelFormat()));
+                        ConvertPixelFormatToFOURCC(graphicBuffer->getPixelFormat()));
   graphicBuffer->unlock();
 
   const uint8_t lumaBpp = 8;
   const uint8_t chromaBpp = 4;
 
   layers::PlanarYCbCrData data;
   data.mYChannel = dstPtr;
   data.mYSize = IntSize(dstWidth, dstHeight);
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -9,17 +9,17 @@
 #include <vector>
 #include "nsIDOMCanvasRenderingContext2D.h"
 #include "nsICanvasRenderingContextInternal.h"
 #include "mozilla/RefPtr.h"
 #include "nsColor.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "CanvasUtils.h"
-#include "gfxFont.h"
+#include "gfxTextRun.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/CanvasGradient.h"
 #include "mozilla/dom/CanvasRenderingContext2DBinding.h"
 #include "mozilla/dom/CanvasPattern.h"
 #include "mozilla/gfx/Rect.h"
 #include "mozilla/gfx/2D.h"
 #include "gfx2DGlue.h"
 #include "imgIEncoder.h"
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -70,16 +70,25 @@ var ecmaGlobals =
     "Number",
     "Object",
     "Proxy",
     "RangeError",
     "ReferenceError",
     "RegExp",
     "Set",
     {name: "SharedArrayBuffer", nightly: true},
+    {name: "SharedInt8Array", nightly: true},
+    {name: "SharedUint8Array", nightly: true},
+    {name: "SharedUint8ClampedArray", nightly: true},
+    {name: "SharedInt16Array", nightly: true},
+    {name: "SharedUint16Array", nightly: true},
+    {name: "SharedInt32Array", nightly: true},
+    {name: "SharedUint32Array", nightly: true},
+    {name: "SharedFloat32Array", nightly: true},
+    {name: "SharedFloat64Array", nightly: true},
     {name: "SIMD", nightly: true},
     "StopIteration",
     "String",
     "SyntaxError",
     {name: "TypedObject", nightly: true},
     "TypeError",
     "Uint16Array",
     "Uint32Array",
--- a/dom/tests/mochitest/notification/mochitest.ini
+++ b/dom/tests/mochitest/notification/mochitest.ini
@@ -1,10 +1,12 @@
 [DEFAULT]
 skip-if = e10s || buildapp == 'mulet'
 support-files =
   MockServices.js
   NotificationTest.js
 
 [test_notification_basics.html]
 [test_notification_storage.html]
+skip-if = (toolkit == 'gonk' && debug) #debug-only timeout
 [test_bug931307.html]
+skip-if = (toolkit == 'gonk' && debug) #debug-only timeout
 [test_notification_resend.html]
--- a/dom/webidl/Selection.webidl
+++ b/dom/webidl/Selection.webidl
@@ -37,25 +37,25 @@ interface Selection {
   Range              getRangeAt(unsigned long index);
   [Throws]
   void               addRange(Range range);
   [Throws]
   void               removeRange(Range range);
   [Throws]
   void               removeAllRanges();
 
+  [Throws]
+  boolean            containsNode(Node node, boolean allowPartialContainment);
+
   stringifier;
 };
 
 // Additional methods not currently in the spec
 partial interface Selection {
   [Throws]
-  boolean containsNode(Node? node, boolean partlyContained);
-
-  [Throws]
   void modify(DOMString alter, DOMString direction,
               DOMString granularity);
 };
 
 // Additional chrome-only methods from nsISelectionPrivate
 interface nsISelectionListener;
 partial interface Selection {
   [ChromeOnly]
--- a/dom/workers/test/test_worker_interfaces.js
+++ b/dom/workers/test/test_worker_interfaces.js
@@ -44,16 +44,25 @@ var ecmaGlobals =
     "Number",
     "Object",
     "Proxy",
     "RangeError",
     "ReferenceError",
     "RegExp",
     "Set",
     {name: "SharedArrayBuffer", nightly: true},
+    {name: "SharedInt8Array", nightly: true},
+    {name: "SharedUint8Array", nightly: true},
+    {name: "SharedUint8ClampedArray", nightly: true},
+    {name: "SharedInt16Array", nightly: true},
+    {name: "SharedUint16Array", nightly: true},
+    {name: "SharedInt32Array", nightly: true},
+    {name: "SharedUint32Array", nightly: true},
+    {name: "SharedFloat32Array", nightly: true},
+    {name: "SharedFloat64Array", nightly: true},
     {name: "SIMD", nightly: true},
     "StopIteration",
     "String",
     "SyntaxError",
     {name: "TypedObject", nightly: true},
     "TypeError",
     "Uint16Array",
     "Uint32Array",
--- a/extensions/cookie/test/unit/test_cookies_read.js
+++ b/extensions/cookie/test/unit/test_cookies_read.js
@@ -1,15 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // test cookie database asynchronous read operation.
 
 let test_generator = do_run_test();
 
+let CMAX = 1000;    // # of cookies to create
+
 function run_test() {
   do_test_pending();
   test_generator.next();
 }
 
 function finish_test() {
   do_execute_soon(function() {
     test_generator.close();
@@ -28,25 +30,25 @@ function do_run_test() {
   Services.cookies;
 
   // Open a database connection now, after synchronous initialization has
   // completed. We may not be able to open one later once asynchronous writing
   // begins.
   do_check_true(do_get_cookie_file(profile).exists());
   let db = new CookieDatabaseConnection(do_get_cookie_file(profile), 4);
 
-  for (let i = 0; i < 3000; ++i) {
+  for (let i = 0; i < CMAX; ++i) {
     let uri = NetUtil.newURI("http://" + i + ".com/");
     Services.cookies.setCookieString(uri, null, "oh=hai; max-age=1000", null);
   }
 
-  do_check_eq(do_count_cookies(), 3000);
+  do_check_eq(do_count_cookies(), CMAX);
 
-  // Wait until all 3000 cookies have been written out to the database.
-  while (do_count_cookies_in_db(db.db) < 3000) {
+  // Wait until all CMAX cookies have been written out to the database.
+  while (do_count_cookies_in_db(db.db) < CMAX) {
     do_execute_soon(function() {
       do_run_generator(test_generator);
     });
     yield;
   }
 
   // Check the WAL file size. We set it to 16 pages of 32k, which means it
   // should be around 500k.
@@ -56,65 +58,65 @@ function do_run_test() {
   db.close();
 
   // fake a profile change
   do_close_profile(test_generator);
   yield;
   do_load_profile();
 
   // test a few random cookies
-  do_check_eq(Services.cookiemgr.countCookiesFromHost("2000.com"), 1);
+  do_check_eq(Services.cookiemgr.countCookiesFromHost("999.com"), 1);
   do_check_eq(Services.cookiemgr.countCookiesFromHost("abc.com"), 0);
   do_check_eq(Services.cookiemgr.countCookiesFromHost("100.com"), 1);
-  do_check_eq(Services.cookiemgr.countCookiesFromHost("1400.com"), 1);
+  do_check_eq(Services.cookiemgr.countCookiesFromHost("400.com"), 1);
   do_check_eq(Services.cookiemgr.countCookiesFromHost("xyz.com"), 0);
 
   // force synchronous load of everything
-  do_check_eq(do_count_cookies(), 3000);
+  do_check_eq(do_count_cookies(), CMAX);
 
   // check that everything's precisely correct
-  for (let i = 0; i < 3000; ++i) {
+  for (let i = 0; i < CMAX; ++i) {
     let host = i.toString() + ".com";
     do_check_eq(Services.cookiemgr.countCookiesFromHost(host), 1);
   }
 
   // reload again, to make sure the additions were written correctly
   do_close_profile(test_generator);
   yield;
   do_load_profile();
 
   // remove some of the cookies, in both reverse and forward order
   for (let i = 100; i-- > 0; ) {
     let host = i.toString() + ".com";
     Services.cookiemgr.remove(host, "oh", "/", false);
   }
-  for (let i = 2900; i < 3000; ++i) {
+  for (let i = CMAX - 100; i < CMAX; ++i) {
     let host = i.toString() + ".com";
     Services.cookiemgr.remove(host, "oh", "/", false);
   }
 
   // check the count
-  do_check_eq(do_count_cookies(), 2800);
+  do_check_eq(do_count_cookies(), CMAX - 200);
 
   // reload again, to make sure the removals were written correctly
   do_close_profile(test_generator);
   yield;
   do_load_profile();
 
   // check the count
-  do_check_eq(do_count_cookies(), 2800);
+  do_check_eq(do_count_cookies(), CMAX - 200);
 
   // reload again, but wait for async read completion
   do_close_profile(test_generator);
   yield;
   do_load_profile(test_generator);
   yield;
 
   // check that everything's precisely correct
-  do_check_eq(do_count_cookies(), 2800);
-  for (let i = 100; i < 2900; ++i) {
+  do_check_eq(do_count_cookies(), CMAX - 200);
+  for (let i = 100; i < CMAX - 100; ++i) {
     let host = i.toString() + ".com";
     do_check_eq(Services.cookiemgr.countCookiesFromHost(host), 1);
   }
 
   finish_test();
 }
 
--- a/gfx/2d/DrawTargetDual.cpp
+++ b/gfx/2d/DrawTargetDual.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
   * 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/. */
      
 #include "DrawTargetDual.h"
 #include "Tools.h"
+#include "Logging.h"
 
 namespace mozilla {
 namespace gfx {
 
 class DualSurface
 {
 public:
   inline explicit DualSurface(SourceSurface *aSurface)
@@ -181,13 +182,18 @@ DrawTargetDual::Mask(const Pattern &aSou
 }
 
 TemporaryRef<DrawTarget>
 DrawTargetDual::CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const
 {
   RefPtr<DrawTarget> dtA = mA->CreateSimilarDrawTarget(aSize, aFormat);
   RefPtr<DrawTarget> dtB = mB->CreateSimilarDrawTarget(aSize, aFormat);
 
+  if (!dtA || !dtB) {
+    gfxWarning() << "Failure to allocate a similar DrawTargetDual. Size: " << aSize;
+    return nullptr;
+  }
+
   return new DrawTargetDual(dtA, dtB);
 }
 
 }
 }
--- a/gfx/gl/GLReadTexImageHelper.cpp
+++ b/gfx/gl/GLReadTexImageHelper.cpp
@@ -619,17 +619,17 @@ GLReadTexImageHelper::ReadTexImage(GLuin
     mGL->MakeCurrent();
 
     /* Allocate resulting image surface */
     int32_t stride = aSize.width * BytesPerPixel(SurfaceFormat::R8G8B8A8);
     RefPtr<DataSourceSurface> isurf =
         Factory::CreateDataSourceSurfaceWithStride(aSize,
                                                    SurfaceFormat::R8G8B8A8,
                                                    stride);
-    if (NS_WARN_IF(isurf)) {
+    if (NS_WARN_IF(!isurf)) {
         return nullptr;
     }
 
     GLint oldrb, oldfb, oldprog, oldTexUnit, oldTex;
     GLuint rb, fb;
 
     do {
         mGL->fGetIntegerv(LOCAL_GL_RENDERBUFFER_BINDING, &oldrb);
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -660,16 +660,31 @@ ClientLayerManager::GetSimpleTileTexture
                                                           gfxPrefs::LayersTileShrinkPoolTimeout(),
                                                           mForwarder);
   }
 
   return mSimpleTilePools[index];
 }
 
 void
+ClientLayerManager::ReturnTextureClientDeferred(TextureClient& aClient) {
+  GetTexturePool(aClient.GetFormat())->ReturnTextureClientDeferred(&aClient);
+}
+
+void
+ClientLayerManager::ReturnTextureClient(TextureClient& aClient) {
+  GetTexturePool(aClient.GetFormat())->ReturnTextureClient(&aClient);
+}
+
+void
+ClientLayerManager::ReportClientLost(TextureClient& aClient) {
+  GetTexturePool(aClient.GetFormat())->ReportClientLost();
+}
+
+void
 ClientLayerManager::ClearCachedResources(Layer* aSubtree)
 {
   MOZ_ASSERT(!HasShadowManager() || !aSubtree);
   mForwarder->ClearCachedResources();
   if (aSubtree) {
     ClearLayer(aSubtree);
   } else if (mRoot) {
     ClearLayer(mRoot);
--- a/gfx/layers/client/ClientLayerManager.h
+++ b/gfx/layers/client/ClientLayerManager.h
@@ -121,16 +121,21 @@ public:
   virtual bool IsCompositingCheap();
   virtual bool HasShadowManagerInternal() const { return HasShadowManager(); }
 
   virtual void SetIsFirstPaint() MOZ_OVERRIDE;
 
   TextureClientPool* GetTexturePool(gfx::SurfaceFormat aFormat);
   SimpleTextureClientPool* GetSimpleTileTexturePool(gfx::SurfaceFormat aFormat);
 
+  /// Utility methods for managing texture clients.
+  void ReturnTextureClientDeferred(TextureClient& aClient);
+  void ReturnTextureClient(TextureClient& aClient);
+  void ReportClientLost(TextureClient& aClient);
+
   // Drop cached resources and ask our shadow manager to do the same,
   // if we have one.
   virtual void ClearCachedResources(Layer* aSubtree = nullptr) MOZ_OVERRIDE;
 
   void HandleMemoryPressure();
 
   void SetRepeatTransaction() { mRepeatTransaction = true; }
   bool GetRepeatTransaction() { return mRepeatTransaction; }
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -683,16 +683,19 @@ BufferTextureClient::AllocateForSurface(
   return true;
 }
 
 gfx::DrawTarget*
 BufferTextureClient::BorrowDrawTarget()
 {
   MOZ_ASSERT(IsValid());
   MOZ_ASSERT(mLocked, "BorrowDrawTarget should be called on locked textures only");
+  if (!mLocked) {
+    return nullptr;
+  }
 
   if (mDrawTarget) {
     mDrawTarget->SetTransform(Matrix());
     return mDrawTarget;
   }
 
   ImageDataSerializer serializer(GetBuffer(), GetBufferSize());
   if (!serializer.IsValid()) {
--- a/gfx/layers/client/TextureClientPool.cpp
+++ b/gfx/layers/client/TextureClientPool.cpp
@@ -37,21 +37,20 @@ TextureClientPool::TextureClientPool(gfx
 TextureClientPool::~TextureClientPool()
 {
   mTimer->Cancel();
 }
 
 TemporaryRef<TextureClient>
 TextureClientPool::GetTextureClient()
 {
-  mOutstandingClients++;
-
   // Try to fetch a client from the pool
   RefPtr<TextureClient> textureClient;
   if (mTextureClients.size()) {
+    mOutstandingClients++;
     textureClient = mTextureClients.top();
     mTextureClients.pop();
     return textureClient;
   }
 
   // We're increasing the number of outstanding TextureClients without reusing a
   // client, we may need to free a deferred-return TextureClient.
   ShrinkToMaximumSize();
@@ -62,58 +61,64 @@ TextureClientPool::GetTextureClient()
     textureClient = TextureClient::CreateForRawBufferAccess(mSurfaceAllocator,
       mFormat, mSize, gfx::BackendType::NONE,
       TextureFlags::IMMEDIATE_UPLOAD, ALLOC_DEFAULT);
   } else {
     textureClient = TextureClient::CreateForDrawing(mSurfaceAllocator,
       mFormat, mSize, gfx::BackendType::NONE, TextureFlags::IMMEDIATE_UPLOAD);
   }
 
+  mOutstandingClients++;
   return textureClient;
 }
 
 void
 TextureClientPool::ReturnTextureClient(TextureClient *aClient)
 {
   if (!aClient) {
     return;
   }
-  MOZ_ASSERT(mOutstandingClients);
+  // Add the client to the pool:
+  MOZ_ASSERT(mOutstandingClients > mTextureClientsDeferred.size());
   mOutstandingClients--;
+  mTextureClients.push(aClient);
 
-  // Add the client to the pool and shrink down if we're beyond our maximum size
-  mTextureClients.push(aClient);
+  // Shrink down if we're beyond our maximum size
   ShrinkToMaximumSize();
 
   // Kick off the pool shrinking timer if there are still more unused texture
   // clients than our desired minimum cache size.
   if (mTextureClients.size() > sMinCacheSize) {
     mTimer->InitWithFuncCallback(ShrinkCallback, this, mShrinkTimeoutMsec,
                                  nsITimer::TYPE_ONE_SHOT);
   }
 }
 
 void
 TextureClientPool::ReturnTextureClientDeferred(TextureClient *aClient)
 {
+  if (!aClient) {
+    return;
+  }
   mTextureClientsDeferred.push(aClient);
   ShrinkToMaximumSize();
 }
 
 void
 TextureClientPool::ShrinkToMaximumSize()
 {
   uint32_t totalClientsOutstanding = mTextureClients.size() + mOutstandingClients;
 
   // We're over our desired maximum size, immediately shrink down to the
   // maximum, or zero if we have too many outstanding texture clients.
   // We cull from the deferred TextureClients first, as we can't reuse those
   // until they get returned.
   while (totalClientsOutstanding > mMaxTextureClients) {
     if (mTextureClientsDeferred.size()) {
+      MOZ_ASSERT(mOutstandingClients > 0);
       mOutstandingClients--;
       mTextureClientsDeferred.pop();
     } else {
       if (!mTextureClients.size()) {
         // Getting here means we're over our desired number of TextureClients
         // with none in the pool. This can happen for pathological cases, or
         // it could mean that mMaxTextureClients needs adjusting for whatever
         // device we're running on.
@@ -138,31 +143,33 @@ TextureClientPool::ReturnDeferredClients
 {
   while (!mTextureClientsDeferred.empty()) {
     mTextureClients.push(mTextureClientsDeferred.top());
     mTextureClientsDeferred.pop();
 
     MOZ_ASSERT(mOutstandingClients > 0);
     mOutstandingClients--;
   }
-  ShrinkToMinimumSize();
+  ShrinkToMaximumSize();
+
   // Kick off the pool shrinking timer if there are still more unused texture
   // clients than our desired minimum cache size.
   if (mTextureClients.size() > sMinCacheSize) {
     mTimer->InitWithFuncCallback(ShrinkCallback, this, mShrinkTimeoutMsec,
                                  nsITimer::TYPE_ONE_SHOT);
   }
 }
 
 void
 TextureClientPool::Clear()
 {
   while (!mTextureClients.empty()) {
     mTextureClients.pop();
   }
   while (!mTextureClientsDeferred.empty()) {
+    MOZ_ASSERT(mOutstandingClients > 0);
     mOutstandingClients--;
     mTextureClientsDeferred.pop();
   }
 }
 
 }
 }
--- a/gfx/layers/client/TextureClientPool.h
+++ b/gfx/layers/client/TextureClientPool.h
@@ -70,17 +70,20 @@ public:
    * ReturnTextureClientDeferred.
    */
   void ReturnDeferredClients();
 
   /**
    * Report that a client retrieved via GetTextureClient() has become
    * unusable, so that it will no longer be tracked.
    */
-  void ReportClientLost() { mOutstandingClients--; }
+  void ReportClientLost() {
+    MOZ_ASSERT(mOutstandingClients > mTextureClientsDeferred.size());
+    mOutstandingClients--;
+  }
 
   /**
    * Calling this will cause the pool to attempt to relinquish any unused
    * clients.
    */
   void Clear();
 
   gfx::SurfaceFormat GetFormat() { return mFormat; }
@@ -99,16 +102,19 @@ private:
   // The maximum number of texture clients managed by this pool that we want
   // to remain active.
   uint32_t mMaxTextureClients;
 
   // The time in milliseconds before the pool will be shrunk to the minimum
   // size after returning a client.
   uint32_t mShrinkTimeoutMsec;
 
+  /// This is a total number of clients in the wild and in the stack of
+  /// deferred clients (see below).  So, the total number of clients in
+  /// existence is always mOutstandingClients + the size of mTextureClients.
   uint32_t mOutstandingClients;
 
   // On b2g gonk, std::queue might be a better choice.
   // On ICS, fence wait happens implicitly before drawing.
   // Since JB, fence wait happens explicitly when fetching a client from the pool.
   std::stack<RefPtr<TextureClient> > mTextureClients;
   std::stack<RefPtr<TextureClient> > mTextureClientsDeferred;
   nsRefPtr<nsITimer> mTimer;
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -653,19 +653,19 @@ TileClient::DiscardFrontBuffer()
       tracker->SetTextureClient(mFrontBuffer);
       mFrontBuffer->SetRemoveFromCompositableTracker(tracker);
       // RemoveTextureFromCompositableAsync() expects CompositorChild's presence.
       mManager->AsShadowForwarder()->RemoveTextureFromCompositableAsync(tracker,
                                                                         mCompositableClient,
                                                                         mFrontBuffer);
     }
 #endif
-    mManager->GetTexturePool(mFrontBuffer->GetFormat())->ReturnTextureClientDeferred(mFrontBuffer);
+    mManager->ReturnTextureClientDeferred(*mFrontBuffer);
     if (mFrontBufferOnWhite) {
-      mManager->GetTexturePool(mFrontBufferOnWhite->GetFormat())->ReturnTextureClientDeferred(mFrontBufferOnWhite);
+      mManager->ReturnTextureClientDeferred(*mFrontBufferOnWhite);
     }
     mFrontLock->ReadUnlock();
     if (mFrontBuffer->IsLocked()) {
       mFrontBuffer->Unlock();
     }
     if (mFrontBufferOnWhite && mFrontBufferOnWhite->IsLocked()) {
       mFrontBufferOnWhite->Unlock();
     }
@@ -679,42 +679,44 @@ void
 TileClient::DiscardBackBuffer()
 {
   if (mBackBuffer) {
     MOZ_ASSERT(mBackLock);
     if (!mBackBuffer->ImplementsLocking() && mBackLock->GetReadCount() > 1) {
       // Our current back-buffer is still locked by the compositor. This can occur
       // when the client is producing faster than the compositor can consume. In
       // this case we just want to drop it and not return it to the pool.
-     mManager->GetTexturePool(mBackBuffer->GetFormat())->ReportClientLost();
+     mManager->ReportClientLost(*mBackBuffer);
      if (mBackBufferOnWhite) {
-       mManager->GetTexturePool(mBackBufferOnWhite->GetFormat())->ReportClientLost();
+       mManager->ReportClientLost(*mBackBufferOnWhite);
      }
     } else {
 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
+      // If this assertions stops being true, we need to add
+      // ReturnTextureClientDeferred(*mBackBufferOnWhite) below.
       MOZ_ASSERT(!mBackBufferOnWhite);
       if (mBackBuffer->GetIPDLActor() &&
           mCompositableClient && mCompositableClient->GetIPDLActor()) {
         // remove old buffer from CompositableHost
         RefPtr<AsyncTransactionTracker> tracker = new RemoveTextureFromCompositableTracker();
         // Hold TextureClient until transaction complete.
         tracker->SetTextureClient(mBackBuffer);
         mBackBuffer->SetRemoveFromCompositableTracker(tracker);
         // RemoveTextureFromCompositableAsync() expects CompositorChild's presence.
         mManager->AsShadowForwarder()->RemoveTextureFromCompositableAsync(tracker,
                                                                           mCompositableClient,
                                                                           mBackBuffer);
       }
       // TextureClient can be reused after transaction complete,
       // when RemoveTextureFromCompositableTracker is used.
-      mManager->GetTexturePool(mBackBuffer->GetFormat())->ReturnTextureClientDeferred(mBackBuffer);
+      mManager->ReturnTextureClientDeferred(*mBackBuffer);
 #else
-      mManager->GetTexturePool(mBackBuffer->GetFormat())->ReturnTextureClient(mBackBuffer);
+      mManager->ReturnTextureClient(*mBackBuffer);
       if (mBackBufferOnWhite) {
-        mManager->GetTexturePool(mBackBufferOnWhite->GetFormat())->ReturnTextureClient(mBackBufferOnWhite);
+        mManager->ReturnTextureClient(*mBackBufferOnWhite);
       }
 #endif
     }
     mBackLock->ReadUnlock();
     if (mBackBuffer->IsLocked()) {
       mBackBuffer->Unlock();
     }
     if (mBackBufferOnWhite && mBackBufferOnWhite->IsLocked()) {
@@ -730,18 +732,16 @@ TextureClient*
 TileClient::GetBackBuffer(const nsIntRegion& aDirtyRegion,
                           gfxContentType aContent,
                           SurfaceMode aMode,
                           bool *aCreatedTextureClient,
                           nsIntRegion& aAddPaintedRegion,
                           bool aCanRerasterizeValidRegion,
                           RefPtr<TextureClient>* aBackBufferOnWhite)
 {
-  TextureClientPool *pool =
-    mManager->GetTexturePool(gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aContent));
   // Try to re-use the front-buffer if possible
   if (mFrontBuffer &&
       mFrontBuffer->HasInternalBuffer() &&
       mFrontLock->GetReadCount() == 1) {
     // If we had a backbuffer we no longer care about it since we'll
     // re-use the front buffer.
     DiscardBackBuffer();
     Flip();
@@ -756,21 +756,25 @@ TileClient::GetBackBuffer(const nsIntReg
       // Before we Replacing the lock by another one we need to unlock it!
       mBackLock->ReadUnlock();
     }
 
     if (mBackBuffer) {
       // Our current back-buffer is still locked by the compositor. This can occur
       // when the client is producing faster than the compositor can consume. In
       // this case we just want to drop it and not return it to the pool.
-      pool->ReportClientLost();
-      if (mBackBufferOnWhite) {
-        pool->ReportClientLost();
-      }
+      mManager->ReportClientLost(*mBackBuffer);
     }
+    if (mBackBufferOnWhite) {
+      mManager->ReportClientLost(*mBackBufferOnWhite);
+      mBackBufferOnWhite = nullptr;
+    }
+
+    TextureClientPool *pool =
+      mManager->GetTexturePool(gfxPlatform::GetPlatform()->Optimal2DFormatForContent(aContent));
     mBackBuffer.Set(this, pool->GetTextureClient());
     if (!mBackBuffer) {
       return nullptr;
     }
 
     if (aMode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
       mBackBufferOnWhite = pool->GetTextureClient();
       if (!mBackBufferOnWhite) {
--- a/gfx/layers/client/TiledContentClient.h
+++ b/gfx/layers/client/TiledContentClient.h
@@ -221,16 +221,18 @@ struct TileClient
   * Returns an unlocked TextureClient that can be used for writing new
   * data to the tile. This may flip the front-buffer to the back-buffer if
   * the front-buffer is still locked by the host, or does not have an
   * internal buffer (and so will always be locked).
   *
   * If getting the back buffer required copying pixels from the front buffer
   * then the copied region is stored in aAddPaintedRegion so the host side
   * knows to upload it.
+  *
+  * If nullptr is returned, aTextureClientOnWhite is undefined.
   */
   TextureClient* GetBackBuffer(const nsIntRegion& aDirtyRegion,
                                gfxContentType aContent, SurfaceMode aMode,
                                bool *aCreatedTextureClient,
                                nsIntRegion& aAddPaintedRegion,
                                bool aCanRerasterizeValidRegion,
                                RefPtr<TextureClient>* aTextureClientOnWhite);
 
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -305,17 +305,17 @@ TextureClientD3D11::Unlock()
   mIsLocked = false;
 }
 
 DrawTarget*
 TextureClientD3D11::BorrowDrawTarget()
 {
   MOZ_ASSERT(mIsLocked, "Calling TextureClient::BorrowDrawTarget without locking :(");
 
-  if (!mTexture && !mTexture10) {
+  if (!mIsLocked || (!mTexture && !mTexture10)) {
     return nullptr;
   }
 
   if (mDrawTarget) {
     return mDrawTarget;
   }
 
   // This may return a null DrawTarget
--- a/gfx/layers/d3d9/TextureD3D9.cpp
+++ b/gfx/layers/d3d9/TextureD3D9.cpp
@@ -659,16 +659,21 @@ CairoTextureClientD3D9::ToSurfaceDescrip
   aOutDescriptor = SurfaceDescriptorD3D9(reinterpret_cast<uintptr_t>(mTexture.get()));
   return true;
 }
 
 gfx::DrawTarget*
 CairoTextureClientD3D9::BorrowDrawTarget()
 {
   MOZ_ASSERT(mIsLocked && mD3D9Surface);
+  if (!mIsLocked || !mD3D9Surface) {
+    NS_WARNING("Calling BorrowDrawTarget on an Unlocked TextureClient");
+    return nullptr;
+  }
+
   if (mDrawTarget) {
     return mDrawTarget;
   }
 
   if (ContentForFormat(mFormat) == gfxContentType::COLOR) {
     mSurface = new gfxWindowsSurface(mD3D9Surface);
     if (!mSurface || mSurface->CairoStatus()) {
       NS_WARNING("Could not create surface for d3d9 surface");
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1388,17 +1388,19 @@ CompositorOGL::SetFBAcquireFence(Layer* 
       SetFBAcquireFence(child);
     }
     return;
   }
 
   // Set FBAcquireFence as tiles' ReleaseFence on TiledLayerComposer.
   TiledLayerComposer* composer = nullptr;
   LayerComposite* shadow = aLayer->AsLayerComposite();
-  if (shadow) {
+  // Only ask for the composer if we have a compositable host. Timing
+  // may make it so that we don't - see bug 1000634.
+  if (shadow && shadow->GetCompositableHost()) {
     composer = shadow->GetTiledLayerComposer();
     if (composer) {
       composer->SetReleaseFence(new android::Fence(GetGonkDisplay()->GetPrevFBAcquireFd()));
       return;
     }
   }
 
   // Set FBAcquireFence as layer buffer's ReleaseFence
--- a/gfx/layers/opengl/GrallocTextureClient.cpp
+++ b/gfx/layers/opengl/GrallocTextureClient.cpp
@@ -189,17 +189,17 @@ SurfaceFormatForPixelFormat(android::Pix
 }
 
 gfx::DrawTarget*
 GrallocTextureClientOGL::BorrowDrawTarget()
 {
   MOZ_ASSERT(IsValid());
   MOZ_ASSERT(mMappedBuffer, "Calling TextureClient::BorrowDrawTarget without locking :(");
 
-  if (!IsValid() || !IsAllocated()) {
+  if (!IsValid() || !IsAllocated() || !mMappedBuffer) {
     return nullptr;
   }
 
   if (mDrawTarget) {
     return mDrawTarget;
   }
 
   gfx::SurfaceFormat format = SurfaceFormatForPixelFormat(mGraphicBuffer->getPixelFormat());
--- a/gfx/skia/generate_mozbuild.py
+++ b/gfx/skia/generate_mozbuild.py
@@ -32,17 +32,17 @@ if not CONFIG['INTEL_ARCHITECTURE'] and 
         'trunk/src/opts/memset.arm.S',
     ]
     if CONFIG['BUILD_ARM_NEON']:
         SOURCES += [
             'trunk/src/opts/memset16_neon.S',
             'trunk/src/opts/memset32_neon.S',
         ]
 
-if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']:
+if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC'] and CONFIG['OS_ARCH'] != 'WINNT':
     if CONFIG['CPU_ARCH'] == 'x86_64':
         SOURCES += [
             'trunk/src/opts/SkBlitRow_opts_SSE4_x64_asm.S',
         ]
     else:
         SOURCES += [
             'trunk/src/opts/SkBlitRow_opts_SSE4_asm.S',
         ]
@@ -105,16 +105,18 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=31']
     SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
     SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
     SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
     SOURCES['trunk/src/opts/SkBlurImage_opts_SSE4.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=41']
     SOURCES['trunk/src/opts/SkMorphology_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
     SOURCES['trunk/src/opts/SkUtils_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
     SOURCES['trunk/src/opts/SkXfermode_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
+    if CONFIG['CLANG_CL']:
+        SOURCES['trunk/src/opts/SkBlurImage_opts_SSE4.cpp'].flags += ['-msse4.1']
 
 if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']:
     SOURCES['trunk/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3']
     SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
     SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
     SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -864,17 +864,17 @@ if not CONFIG['INTEL_ARCHITECTURE'] and 
         'trunk/src/opts/memset.arm.S',
     ]
     if CONFIG['BUILD_ARM_NEON']:
         SOURCES += [
             'trunk/src/opts/memset16_neon.S',
             'trunk/src/opts/memset32_neon.S',
         ]
 
-if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']:
+if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC'] and CONFIG['OS_ARCH'] != 'WINNT':
     if CONFIG['CPU_ARCH'] == 'x86_64':
         SOURCES += [
             'trunk/src/opts/SkBlitRow_opts_SSE4_x64_asm.S',
         ]
     else:
         SOURCES += [
             'trunk/src/opts/SkBlitRow_opts_SSE4_asm.S',
         ]
@@ -933,16 +933,18 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=31']
     SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
     SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
     SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
     SOURCES['trunk/src/opts/SkBlurImage_opts_SSE4.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=41']
     SOURCES['trunk/src/opts/SkMorphology_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
     SOURCES['trunk/src/opts/SkUtils_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
     SOURCES['trunk/src/opts/SkXfermode_opts_SSE2.cpp'].flags += ['-DSK_CPU_SSE_LEVEL=20']
+    if CONFIG['CLANG_CL']:
+        SOURCES['trunk/src/opts/SkBlurImage_opts_SSE4.cpp'].flags += ['-msse4.1']
 
 if CONFIG['INTEL_ARCHITECTURE'] and CONFIG['GNU_CC']:
     SOURCES['trunk/src/opts/SkBitmapFilter_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
     SOURCES['trunk/src/opts/SkBitmapProcState_opts_SSSE3.cpp'].flags += ['-mssse3']
     SOURCES['trunk/src/opts/SkBlitRect_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
     SOURCES['trunk/src/opts/SkBlitRow_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
     SOURCES['trunk/src/opts/SkBlurImage_opts_SSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
--- a/gfx/skia/trunk/include/config/SkUserConfig.h
+++ b/gfx/skia/trunk/include/config/SkUserConfig.h
@@ -175,19 +175,23 @@
  * possibly inline implementations of threading primitives.
  *
  * See SkThread.h for documentation on what these includes must contain.
  */
 //#define SK_ATOMICS_PLATFORM_H "SkAtomics_xxx.h"
 //#define SK_MUTEX_PLATFORM_H "SkMutex_xxx.h"
 #if defined(_MSC_VER)
 #  define SK_ATOMICS_PLATFORM_H "skia/SkAtomics_win.h"
+#else
+#  define SK_ATOMICS_PLATFORM_H "skia/SkAtomics_sync.h"
+#endif
+
+#if defined(_WIN32)
 #  define SK_MUTEX_PLATFORM_H   "skia/SkMutex_win.h"
 #else
-#  define SK_ATOMICS_PLATFORM_H "skia/SkAtomics_sync.h"
 #  define SK_MUTEX_PLATFORM_H   "skia/SkMutex_pthread.h"
 #endif
 
 #if defined(SK_CPU_ARM32) || defined(SK_CPU_ARM64)
 #  define SK_BARRIERS_PLATFORM_H "skia/SkBarriers_arm.h"
 #else
 #  define SK_BARRIERS_PLATFORM_H "skia/SkBarriers_x86.h"
 #endif
--- a/gfx/skia/trunk/src/core/SkTraceEvent.h
+++ b/gfx/skia/trunk/src/core/SkTraceEvent.h
@@ -944,17 +944,17 @@ const uint64_t kNoEventId = 0;
 // are by default mangled with the Process ID so that they are unlikely to
 // collide when the same pointer is used on different processes.
 class TraceID {
  public:
   class DontMangle {
    public:
     explicit DontMangle(const void* id)
         : data_(static_cast<uint64_t>(
-              reinterpret_cast<unsigned long>(id))) {}
+              reinterpret_cast<uintptr_t>(id))) {}
     explicit DontMangle(uint64_t id) : data_(id) {}
     explicit DontMangle(unsigned int id) : data_(id) {}
     explicit DontMangle(unsigned short id) : data_(id) {}
     explicit DontMangle(unsigned char id) : data_(id) {}
     explicit DontMangle(long long id)
         : data_(static_cast<uint64_t>(id)) {}
     explicit DontMangle(long id)
         : data_(static_cast<uint64_t>(id)) {}
@@ -987,17 +987,17 @@ class TraceID {
         : data_(static_cast<uint64_t>(id)) {}
     uint64_t data() const { return data_; }
    private:
     uint64_t data_;
   };
 
   TraceID(const void* id, unsigned char* flags)
       : data_(static_cast<uint64_t>(
-              reinterpret_cast<unsigned long>(id))) {
+              reinterpret_cast<uintptr_t>(id))) {
     *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
   }
   TraceID(ForceMangle id, unsigned char* flags) : data_(id.data()) {
     *flags |= TRACE_EVENT_FLAG_MANGLE_ID;
   }
   TraceID(DontMangle id, unsigned char* flags) : data_(id.data()) {
   }
   TraceID(uint64_t id, unsigned char* flags)
--- a/gfx/src/nsFontMetrics.h
+++ b/gfx/src/nsFontMetrics.h
@@ -3,17 +3,17 @@
  * 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 NSFONTMETRICS__H__
 #define NSFONTMETRICS__H__
 
 #include <stdint.h>                     // for uint32_t
 #include <sys/types.h>                  // for int32_t
-#include "gfxFont.h"                    // for gfxFont, gfxFontGroup
+#include "gfxTextRun.h"                 // for gfxFont, gfxFontGroup
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsCOMPtr.h"                   // for nsCOMPtr
 #include "nsCoord.h"                    // for nscoord
 #include "nsError.h"                    // for nsresult
 #include "nsFont.h"                     // for nsFont
 #include "nsISupports.h"                // for NS_INLINE_DECL_REFCOUNTING
 #include "nscore.h"                     // for char16_t
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -9,16 +9,17 @@
 #include "gfxAndroidPlatform.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/CountingAllocatorBase.h"
 #include "mozilla/Preferences.h"
 
 #include "gfx2DGlue.h"
 #include "gfxFT2FontList.h"
 #include "gfxImageSurface.h"
+#include "gfxTextRun.h"
 #include "mozilla/dom/ContentChild.h"
 #include "nsXULAppAPI.h"
 #include "nsIScreen.h"
 #include "nsIScreenManager.h"
 #include "nsILocaleService.h"
 #include "nsServiceManagerUtils.h"
 #include "gfxPrefs.h"
 #include "cairo.h"
--- a/gfx/thebes/gfxCoreTextShaper.cpp
+++ b/gfx/thebes/gfxCoreTextShaper.cpp
@@ -2,16 +2,17 @@
  * 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/. */
 
 #include "mozilla/ArrayUtils.h"
 #include "gfxCoreTextShaper.h"
 #include "gfxMacFont.h"
 #include "gfxFontUtils.h"
+#include "gfxTextRun.h"
 #include "mozilla/gfx/2D.h"
 
 #include <algorithm>
 
 using namespace mozilla;
 
 // standard font descriptors that we construct the first time they're needed
 CTFontDescriptorRef gfxCoreTextShaper::sDefaultFeaturesDescriptor = nullptr;
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -5,16 +5,17 @@
 
 #include "gfxDWriteFonts.h"
 
 #include "mozilla/MemoryReporting.h"
 
 #include <algorithm>
 #include "gfxDWriteFontList.h"
 #include "gfxContext.h"
+#include "gfxTextRun.h"
 #include <dwrite.h>
 
 #include "harfbuzz/hb.h"
 
 // Chosen this as to resemble DWrite's own oblique face style.
 #define OBLIQUE_SKEW_FACTOR 0.3
 
 using namespace mozilla;
--- a/gfx/thebes/gfxFT2Fonts.cpp
+++ b/gfx/thebes/gfxFT2Fonts.cpp
@@ -18,16 +18,17 @@
 #define gfxToolkitPlatform gfxAndroidPlatform
 #endif
 
 #include "gfxTypes.h"
 #include "gfxFT2Fonts.h"
 #include "gfxFT2FontBase.h"
 #include "gfxFT2Utils.h"
 #include "gfxFT2FontList.h"
+#include "gfxTextRun.h"
 #include <locale.h>
 #include "nsGkAtoms.h"
 #include "nsTArray.h"
 #include "nsUnicodeRange.h"
 #include "nsCRT.h"
 #include "nsXULAppAPI.h"
 
 #include "prlog.h"
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -6,1862 +6,85 @@
 #include "mozilla/DebugOnly.h"
 #include "mozilla/MathAlgorithms.h"
 
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG /* Allow logging in the release build */
 #endif
 #include "prlog.h"
 
-#include "nsServiceManagerUtils.h"
 #include "nsExpirationTracker.h"
-#include "nsILanguageAtomService.h"
 #include "nsITimer.h"
 
 #include "gfxFont.h"
+#include "gfxGlyphExtents.h"
 #include "gfxPlatform.h"
+#include "gfxTextRun.h"
 #include "nsGkAtoms.h"
 
 #include "gfxTypes.h"
 #include "gfxContext.h"
 #include "gfxFontMissingGlyphs.h"
 #include "gfxGraphiteShaper.h"
 #include "gfxHarfBuzzShaper.h"
 #include "gfxUserFontSet.h"
-#include "gfxPlatformFontList.h"
-#include "gfxScriptItemizer.h"
 #include "nsSpecialCasingData.h"
 #include "nsTextRunTransformations.h"
 #include "nsUnicodeProperties.h"
-#include "nsMathUtils.h"
-#include "nsBidiUtils.h"
-#include "nsUnicodeRange.h"
 #include "nsStyleConsts.h"
 #include "mozilla/AppUnits.h"
-#include "mozilla/FloatingPoint.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/Telemetry.h"
 #include "gfxSVGGlyphs.h"
-#include "gfxMathTable.h"
 #include "gfx2DGlue.h"
 
 #include "GreekCasing.h"
 
-#if defined(XP_MACOSX)
-#include "nsCocoaFeatures.h"
-#endif
-
 #include "cairo.h"
-#include "gfxFontTest.h"
 
 #include "harfbuzz/hb.h"
 #include "harfbuzz/hb-ot.h"
 #include "graphite2/Font.h"
 
-#include "nsCRT.h"
-#include "GeckoProfiler.h"
-#include "gfxFontConstants.h"
-
 #include <algorithm>
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::unicode;
 using mozilla::services::GetObserverService;
 
 gfxFontCache *gfxFontCache::gGlobalCache = nullptr;
 
-static const char16_t kEllipsisChar[] = { 0x2026, 0x0 };
-static const char16_t kASCIIPeriodsChar[] = { '.', '.', '.', 0x0 };
-
 #ifdef DEBUG_roc
 #define DEBUG_TEXT_RUN_STORAGE_METRICS
 #endif
 
 #ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
-static uint32_t gTextRunStorageHighWaterMark = 0;
-static uint32_t gTextRunStorage = 0;
-static uint32_t gFontCount = 0;
-static uint32_t gGlyphExtentsCount = 0;
-static uint32_t gGlyphExtentsWidthsTotalSize = 0;
-static uint32_t gGlyphExtentsSetupEagerSimple = 0;
-static uint32_t gGlyphExtentsSetupEagerTight = 0;
-static uint32_t gGlyphExtentsSetupLazyTight = 0;
-static uint32_t gGlyphExtentsSetupFallBackToTight = 0;
+uint32_t gTextRunStorageHighWaterMark = 0;
+uint32_t gTextRunStorage = 0;
+uint32_t gFontCount = 0;
+uint32_t gGlyphExtentsCount = 0;
+uint32_t gGlyphExtentsWidthsTotalSize = 0;
+uint32_t gGlyphExtentsSetupEagerSimple = 0;
+uint32_t gGlyphExtentsSetupEagerTight = 0;
+uint32_t gGlyphExtentsSetupLazyTight = 0;
+uint32_t gGlyphExtentsSetupFallBackToTight = 0;
 #endif
 
 #ifdef PR_LOGGING
 #define LOG_FONTINIT(args) PR_LOG(gfxPlatform::GetLog(eGfxLog_fontinit), \
                                   PR_LOG_DEBUG, args)
 #define LOG_FONTINIT_ENABLED() PR_LOG_TEST( \
                                         gfxPlatform::GetLog(eGfxLog_fontinit), \
                                         PR_LOG_DEBUG)
 #endif // PR_LOGGING
 
-void
-gfxCharacterMap::NotifyReleased()
-{
-    gfxPlatformFontList *fontlist = gfxPlatformFontList::PlatformFontList();
-    if (mShared) {
-        fontlist->RemoveCmap(this);
-    }
-    delete this;
-}
-
-gfxFontEntry::gfxFontEntry() :
-    mItalic(false), mFixedPitch(false),
-    mIsValid(true),
-    mIsBadUnderlineFont(false),
-    mIsUserFontContainer(false),
-    mIsDataUserFont(false),
-    mIsLocalUserFont(false),
-    mStandardFace(false),
-    mSymbolFont(false),
-    mIgnoreGDEF(false),
-    mIgnoreGSUB(false),
-    mSVGInitialized(false),
-    mMathInitialized(false),
-    mHasSpaceFeaturesInitialized(false),
-    mHasSpaceFeatures(false),
-    mHasSpaceFeaturesKerning(false),
-    mHasSpaceFeaturesNonKerning(false),
-    mSkipDefaultFeatureSpaceCheck(false),
-    mCheckedForGraphiteTables(false),
-    mHasCmapTable(false),
-    mGrFaceInitialized(false),
-    mCheckedForColorGlyph(false),
-    mWeight(500), mStretch(NS_FONT_STRETCH_NORMAL),
-    mUVSOffset(0), mUVSData(nullptr),
-    mLanguageOverride(NO_FONT_LANGUAGE_OVERRIDE),
-    mCOLR(nullptr),
-    mCPAL(nullptr),
-    mUnitsPerEm(0),
-    mHBFace(nullptr),
-    mGrFace(nullptr),
-    mGrFaceRefCnt(0)
-{
-    memset(&mDefaultSubSpaceFeatures, 0, sizeof(mDefaultSubSpaceFeatures));
-    memset(&mNonDefaultSubSpaceFeatures, 0, sizeof(mNonDefaultSubSpaceFeatures));
-}
-
-gfxFontEntry::gfxFontEntry(const nsAString& aName, bool aIsStandardFace) :
-    mName(aName), mItalic(false), mFixedPitch(false),
-    mIsValid(true),
-    mIsBadUnderlineFont(false),
-    mIsUserFontContainer(false),
-    mIsDataUserFont(false),
-    mIsLocalUserFont(false), mStandardFace(aIsStandardFace),
-    mSymbolFont(false),
-    mIgnoreGDEF(false),
-    mIgnoreGSUB(false),
-    mSVGInitialized(false),
-    mMathInitialized(false),
-    mHasSpaceFeaturesInitialized(false),
-    mHasSpaceFeatures(false),
-    mHasSpaceFeaturesKerning(false),
-    mHasSpaceFeaturesNonKerning(false),
-    mSkipDefaultFeatureSpaceCheck(false),
-    mCheckedForGraphiteTables(false),
-    mHasCmapTable(false),
-    mGrFaceInitialized(false),
-    mCheckedForColorGlyph(false),
-    mWeight(500), mStretch(NS_FONT_STRETCH_NORMAL),
-    mUVSOffset(0), mUVSData(nullptr),
-    mLanguageOverride(NO_FONT_LANGUAGE_OVERRIDE),
-    mCOLR(nullptr),
-    mCPAL(nullptr),
-    mUnitsPerEm(0),
-    mHBFace(nullptr),
-    mGrFace(nullptr),
-    mGrFaceRefCnt(0)
-{
-    memset(&mDefaultSubSpaceFeatures, 0, sizeof(mDefaultSubSpaceFeatures));
-    memset(&mNonDefaultSubSpaceFeatures, 0, sizeof(mNonDefaultSubSpaceFeatures));
-}
-
-static PLDHashOperator
-DestroyHBSet(const uint32_t& aTag, hb_set_t*& aSet, void *aUserArg)
-{
-    hb_set_destroy(aSet);
-    return PL_DHASH_NEXT;
-}
-
-gfxFontEntry::~gfxFontEntry()
-{
-    if (mCOLR) {
-        hb_blob_destroy(mCOLR);
-    }
-
-    if (mCPAL) {
-        hb_blob_destroy(mCPAL);
-    }
-
-    // For downloaded fonts, we need to tell the user font cache that this
-    // entry is being deleted.
-    if (mIsDataUserFont) {
-        gfxUserFontSet::UserFontCache::ForgetFont(this);
-    }
-
-    if (mFeatureInputs) {
-        mFeatureInputs->Enumerate(DestroyHBSet, nullptr);
-    }
-
-    // By the time the entry is destroyed, all font instances that were
-    // using it should already have been deleted, and so the HB and/or Gr
-    // face objects should have been released.
-    MOZ_ASSERT(!mHBFace);
-    MOZ_ASSERT(!mGrFaceInitialized);
-}
-
-bool gfxFontEntry::IsSymbolFont() 
-{
-    return mSymbolFont;
-}
-
-bool gfxFontEntry::TestCharacterMap(uint32_t aCh)
-{
-    if (!mCharacterMap) {
-        ReadCMAP();
-        NS_ASSERTION(mCharacterMap, "failed to initialize character map");
-    }
-    return mCharacterMap->test(aCh);
-}
-
-nsresult gfxFontEntry::InitializeUVSMap()
-{
-    // mUVSOffset will not be initialized
-    // until cmap is initialized.
-    if (!mCharacterMap) {
-        ReadCMAP();
-        NS_ASSERTION(mCharacterMap, "failed to initialize character map");
-    }
-
-    if (!mUVSOffset) {
-        return NS_ERROR_FAILURE;
-    }
-
-    if (!mUVSData) {
-        const uint32_t kCmapTag = TRUETYPE_TAG('c','m','a','p');
-        AutoTable cmapTable(this, kCmapTag);
-        if (!cmapTable) {
-            mUVSOffset = 0; // don't bother to read the table again
-            return NS_ERROR_FAILURE;
-        }
-
-        uint8_t* uvsData;
-        unsigned int cmapLen;
-        const char* cmapData = hb_blob_get_data(cmapTable, &cmapLen);
-        nsresult rv = gfxFontUtils::ReadCMAPTableFormat14(
-                          (const uint8_t*)cmapData + mUVSOffset,
-                          cmapLen - mUVSOffset, uvsData);
-
-        if (NS_FAILED(rv)) {
-            mUVSOffset = 0; // don't bother to read the table again
-            return rv;
-        }
-
-        mUVSData = uvsData;
-    }
-
-    return NS_OK;
-}
-
-uint16_t gfxFontEntry::GetUVSGlyph(uint32_t aCh, uint32_t aVS)
-{
-    InitializeUVSMap();
-
-    if (mUVSData) {
-        return gfxFontUtils::MapUVSToGlyphFormat14(mUVSData, aCh, aVS);
-    }
-
-    return 0;
-}
-
-bool gfxFontEntry::SupportsScriptInGSUB(const hb_tag_t* aScriptTags)
-{
-    hb_face_t *face = GetHBFace();
-    if (!face) {
-        return false;
-    }
-
-    unsigned int index;
-    hb_tag_t     chosenScript;
-    bool found =
-        hb_ot_layout_table_choose_script(face, TRUETYPE_TAG('G','S','U','B'),
-                                         aScriptTags, &index, &chosenScript);
-    hb_face_destroy(face);
-
-    return found && chosenScript != TRUETYPE_TAG('D','F','L','T');
-}
-
-nsresult gfxFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
-{
-    NS_ASSERTION(false, "using default no-op implementation of ReadCMAP");
-    mCharacterMap = new gfxCharacterMap();
-    return NS_OK;
-}
-
-nsString
-gfxFontEntry::RealFaceName()
-{
-    AutoTable nameTable(this, TRUETYPE_TAG('n','a','m','e'));
-    if (nameTable) {
-        nsAutoString name;
-        nsresult rv = gfxFontUtils::GetFullNameFromTable(nameTable, name);
-        if (NS_SUCCEEDED(rv)) {
-            return name;
-        }
-    }
-    return Name();
-}
-
-already_AddRefed<gfxFont>
-gfxFontEntry::FindOrMakeFont(const gfxFontStyle *aStyle, bool aNeedsBold)
-{
-    // the font entry name is the psname, not the family name
-    nsRefPtr<gfxFont> font = gfxFontCache::GetCache()->Lookup(this, aStyle);
-
-    if (!font) {
-        gfxFont *newFont = CreateFontInstance(aStyle, aNeedsBold);
-        if (!newFont)
-            return nullptr;
-        if (!newFont->Valid()) {
-            delete newFont;
-            return nullptr;
-        }
-        font = newFont;
-        gfxFontCache::GetCache()->AddNew(font);
-    }
-    return font.forget();
-}
-
-uint16_t
-gfxFontEntry::UnitsPerEm()
-{
-    if (!mUnitsPerEm) {
-        AutoTable headTable(this, TRUETYPE_TAG('h','e','a','d'));
-        if (headTable) {
-            uint32_t len;
-            const HeadTable* head =
-                reinterpret_cast<const HeadTable*>(hb_blob_get_data(headTable,
-                                                                    &len));
-            if (len >= sizeof(HeadTable)) {
-                mUnitsPerEm = head->unitsPerEm;
-            }
-        }
-
-        // if we didn't find a usable 'head' table, or if the value was
-        // outside the valid range, record it as invalid
-        if (mUnitsPerEm < kMinUPEM || mUnitsPerEm > kMaxUPEM) {
-            mUnitsPerEm = kInvalidUPEM;
-        }
-    }
-    return mUnitsPerEm;
-}
-
-bool
-gfxFontEntry::HasSVGGlyph(uint32_t aGlyphId)
-{
-    NS_ASSERTION(mSVGInitialized, "SVG data has not yet been loaded. TryGetSVGData() first.");
-    return mSVGGlyphs->HasSVGGlyph(aGlyphId);
-}
-
-bool
-gfxFontEntry::GetSVGGlyphExtents(gfxContext *aContext, uint32_t aGlyphId,
-                                 gfxRect *aResult)
-{
-    NS_ABORT_IF_FALSE(mSVGInitialized,
-                      "SVG data has not yet been loaded. TryGetSVGData() first.");
-    NS_ABORT_IF_FALSE(mUnitsPerEm >= kMinUPEM && mUnitsPerEm <= kMaxUPEM,
-                      "font has invalid unitsPerEm");
-
-    gfxContextAutoSaveRestore matrixRestore(aContext);
-    cairo_matrix_t fontMatrix;
-    cairo_get_font_matrix(aContext->GetCairo(), &fontMatrix);
-
-    gfxMatrix svgToAppSpace = *reinterpret_cast<gfxMatrix*>(&fontMatrix);
-    svgToAppSpace.Scale(1.0f / mUnitsPerEm, 1.0f / mUnitsPerEm);
-
-    return mSVGGlyphs->GetGlyphExtents(aGlyphId, svgToAppSpace, aResult);
-}
-
-bool
-gfxFontEntry::RenderSVGGlyph(gfxContext *aContext, uint32_t aGlyphId,
-                             int aDrawMode, gfxTextContextPaint *aContextPaint)
-{
-    NS_ASSERTION(mSVGInitialized, "SVG data has not yet been loaded. TryGetSVGData() first.");
-    return mSVGGlyphs->RenderGlyph(aContext, aGlyphId, DrawMode(aDrawMode),
-                                   aContextPaint);
-}
-
-bool
-gfxFontEntry::TryGetSVGData(gfxFont* aFont)
-{
-    if (!gfxPlatform::GetPlatform()->OpenTypeSVGEnabled()) {
-        return false;
-    }
-
-    if (!mSVGInitialized) {
-        mSVGInitialized = true;
-
-        // If UnitsPerEm is not known/valid, we can't use SVG glyphs
-        if (UnitsPerEm() == kInvalidUPEM) {
-            return false;
-        }
-
-        // We don't use AutoTable here because we'll pass ownership of this
-        // blob to the gfxSVGGlyphs, once we've confirmed the table exists
-        hb_blob_t *svgTable = GetFontTable(TRUETYPE_TAG('S','V','G',' '));
-        if (!svgTable) {
-            return false;
-        }
-
-        // gfxSVGGlyphs will hb_blob_destroy() the table when it is finished
-        // with it.
-        mSVGGlyphs = new gfxSVGGlyphs(svgTable, this);
-    }
-
-    if (!mFontsUsingSVGGlyphs.Contains(aFont)) {
-        mFontsUsingSVGGlyphs.AppendElement(aFont);
-    }
-
-    return !!mSVGGlyphs;
-}
-
-void
-gfxFontEntry::NotifyFontDestroyed(gfxFont* aFont)
-{
-    mFontsUsingSVGGlyphs.RemoveElement(aFont);
-}
-
-void
-gfxFontEntry::NotifyGlyphsChanged()
-{
-    for (uint32_t i = 0, count = mFontsUsingSVGGlyphs.Length(); i < count; ++i) {
-        gfxFont* font = mFontsUsingSVGGlyphs[i];
-        font->NotifyGlyphsChanged();
-    }
-}
-
-bool
-gfxFontEntry::TryGetMathTable()
-{
-    if (!mMathInitialized) {
-        mMathInitialized = true;
-
-        // If UnitsPerEm is not known/valid, we can't use MATH table
-        if (UnitsPerEm() == kInvalidUPEM) {
-            return false;
-        }
-
-        // We don't use AutoTable here because we'll pass ownership of this
-        // blob to the gfxMathTable, once we've confirmed the table exists
-        hb_blob_t *mathTable = GetFontTable(TRUETYPE_TAG('M','A','T','H'));
-        if (!mathTable) {
-            return false;
-        }
-
-        // gfxMathTable will hb_blob_destroy() the table when it is finished
-        // with it.
-        mMathTable = new gfxMathTable(mathTable);
-        if (!mMathTable->HasValidHeaders()) {
-            mMathTable = nullptr;
-            return false;
-        }
-    }
-
-    return !!mMathTable;
-}
-
-gfxFloat
-gfxFontEntry::GetMathConstant(gfxFontEntry::MathConstant aConstant)
-{
-    NS_ASSERTION(mMathTable, "Math data has not yet been loaded. TryGetMathData() first.");
-    gfxFloat value = mMathTable->GetMathConstant(aConstant);
-    if (aConstant == gfxFontEntry::ScriptPercentScaleDown ||
-        aConstant == gfxFontEntry::ScriptScriptPercentScaleDown ||
-        aConstant == gfxFontEntry::RadicalDegreeBottomRaisePercent) {
-        return value / 100.0;
-    }
-    return value / mUnitsPerEm;
-}
-
-bool
-gfxFontEntry::GetMathItalicsCorrection(uint32_t aGlyphID,
-                                       gfxFloat* aItalicCorrection)
-{
-    NS_ASSERTION(mMathTable, "Math data has not yet been loaded. TryGetMathData() first.");
-    int16_t italicCorrection;
-    if (!mMathTable->GetMathItalicsCorrection(aGlyphID, &italicCorrection)) {
-        return false;
-    }
-    *aItalicCorrection = gfxFloat(italicCorrection) / mUnitsPerEm;
-    return true;
-}
-
-uint32_t
-gfxFontEntry::GetMathVariantsSize(uint32_t aGlyphID, bool aVertical,
-                                  uint16_t aSize)
-{
-    NS_ASSERTION(mMathTable, "Math data has not yet been loaded. TryGetMathData() first.");
-    return mMathTable->GetMathVariantsSize(aGlyphID, aVertical, aSize);
-}
-
-bool
-gfxFontEntry::GetMathVariantsParts(uint32_t aGlyphID, bool aVertical,
-                                   uint32_t aGlyphs[4])
-{
-    NS_ASSERTION(mMathTable, "Math data has not yet been loaded. TryGetMathData() first.");
-    return mMathTable->GetMathVariantsParts(aGlyphID, aVertical, aGlyphs);
-}
-
-bool
-gfxFontEntry::TryGetColorGlyphs()
-{
-    if (mCheckedForColorGlyph) {
-        return (mCOLR && mCPAL);
-    }
-
-    mCheckedForColorGlyph = true;
-
-    mCOLR = GetFontTable(TRUETYPE_TAG('C', 'O', 'L', 'R'));
-    if (!mCOLR) {
-        return false;
-    }
-
-    mCPAL = GetFontTable(TRUETYPE_TAG('C', 'P', 'A', 'L'));
-    if (!mCPAL) {
-        hb_blob_destroy(mCOLR);
-        mCOLR = nullptr;
-        return false;
-    }
-
-    // validation COLR and CPAL table
-    if (gfxFontUtils::ValidateColorGlyphs(mCOLR, mCPAL)) {
-        return true;
-    }
-
-    hb_blob_destroy(mCOLR);
-    hb_blob_destroy(mCPAL);
-    mCOLR = nullptr;
-    mCPAL = nullptr;
-    return false;
-}
-
-/**
- * FontTableBlobData
- *
- * See FontTableHashEntry for the general strategy.
- */
-
-class gfxFontEntry::FontTableBlobData {
-public:
-    // Adopts the content of aBuffer.
-    explicit FontTableBlobData(FallibleTArray<uint8_t>& aBuffer)
-        : mHashtable(nullptr), mHashKey(0)
-    {
-        MOZ_COUNT_CTOR(FontTableBlobData);
-        mTableData.SwapElements(aBuffer);
-    }
-
-    ~FontTableBlobData() {
-        MOZ_COUNT_DTOR(FontTableBlobData);
-        if (mHashtable && mHashKey) {
-            mHashtable->RemoveEntry(mHashKey);
-        }
-    }
-
-    // Useful for creating blobs
-    const char *GetTable() const
-    {
-        return reinterpret_cast<const char*>(mTableData.Elements());
-    }
-    uint32_t GetTableLength() const { return mTableData.Length(); }
-
-    // Tell this FontTableBlobData to remove the HashEntry when this is
-    // destroyed.
-    void ManageHashEntry(nsTHashtable<FontTableHashEntry> *aHashtable,
-                         uint32_t aHashKey)
-    {
-        mHashtable = aHashtable;
-        mHashKey = aHashKey;
-    }
-
-    // Disconnect from the HashEntry (because the blob has already been
-    // removed from the hashtable).
-    void ForgetHashEntry()
-    {
-        mHashtable = nullptr;
-        mHashKey = 0;
-    }
-
-    size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const {
-        return mTableData.SizeOfExcludingThis(aMallocSizeOf);
-    }
-    size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
-        return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
-    }
-
-private:
-    // The font table data block, owned (via adoption)
-    FallibleTArray<uint8_t> mTableData;
-
-    // The blob destroy function needs to know the owning hashtable
-    // and the hashtable key, so that it can remove the entry.
-    nsTHashtable<FontTableHashEntry> *mHashtable;
-    uint32_t                          mHashKey;
-
-    // not implemented
-    FontTableBlobData(const FontTableBlobData&);
-};
-
-hb_blob_t *
-gfxFontEntry::FontTableHashEntry::
-ShareTableAndGetBlob(FallibleTArray<uint8_t>& aTable,
-                     nsTHashtable<FontTableHashEntry> *aHashtable)
-{
-    Clear();
-    // adopts elements of aTable
-    mSharedBlobData = new FontTableBlobData(aTable);
-    mBlob = hb_blob_create(mSharedBlobData->GetTable(),
-                           mSharedBlobData->GetTableLength(),
-                           HB_MEMORY_MODE_READONLY,
-                           mSharedBlobData, DeleteFontTableBlobData);
-    if (!mSharedBlobData) {
-        // The FontTableBlobData was destroyed during hb_blob_create().
-        // The (empty) blob is still be held in the hashtable with a strong
-        // reference.
-        return hb_blob_reference(mBlob);
-    }
-
-    // Tell the FontTableBlobData to remove this hash entry when destroyed.
-    // The hashtable does not keep a strong reference.
-    mSharedBlobData->ManageHashEntry(aHashtable, GetKey());
-    return mBlob;
-}
-
-void
-gfxFontEntry::FontTableHashEntry::Clear()
-{
-    // If the FontTableBlobData is managing the hash entry, then the blob is
-    // not owned by this HashEntry; otherwise there is strong reference to the
-    // blob that must be removed.
-    if (mSharedBlobData) {
-        mSharedBlobData->ForgetHashEntry();
-        mSharedBlobData = nullptr;
-    } else if (mBlob) {
-        hb_blob_destroy(mBlob);
-    }
-    mBlob = nullptr;
-}
-
-// a hb_destroy_func for hb_blob_create
-
-/* static */ void
-gfxFontEntry::FontTableHashEntry::DeleteFontTableBlobData(void *aBlobData)
-{
-    delete static_cast<FontTableBlobData*>(aBlobData);
-}
-
-hb_blob_t *
-gfxFontEntry::FontTableHashEntry::GetBlob() const
-{
-    return hb_blob_reference(mBlob);
-}
-
-bool
-gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t **aBlob)
-{
-    if (!mFontTableCache) {
-        // we do this here rather than on fontEntry construction
-        // because not all shapers will access the table cache at all
-        mFontTableCache = new nsTHashtable<FontTableHashEntry>(8);
-    }
-
-    FontTableHashEntry *entry = mFontTableCache->GetEntry(aTag);
-    if (!entry) {
-        return false;
-    }
-
-    *aBlob = entry->GetBlob();
-    return true;
-}
-
-hb_blob_t *
-gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
-                                       FallibleTArray<uint8_t>* aBuffer)
-{
-    if (MOZ_UNLIKELY(!mFontTableCache)) {
-        // we do this here rather than on fontEntry construction
-        // because not all shapers will access the table cache at all
-      mFontTableCache = new nsTHashtable<FontTableHashEntry>(8);
-    }
-
-    FontTableHashEntry *entry = mFontTableCache->PutEntry(aTag);
-    if (MOZ_UNLIKELY(!entry)) { // OOM
-        return nullptr;
-    }
-
-    if (!aBuffer) {
-        // ensure the entry is null
-        entry->Clear();
-        return nullptr;
-    }
-
-    return entry->ShareTableAndGetBlob(*aBuffer, mFontTableCache);
-}
-
-static int
-DirEntryCmp(const void* aKey, const void* aItem)
-{
-    int32_t tag = *static_cast<const int32_t*>(aKey);
-    const TableDirEntry* entry = static_cast<const TableDirEntry*>(aItem);
-    return tag - int32_t(entry->tag);
-}
-
-hb_blob_t*
-gfxFontEntry::GetTableFromFontData(const void* aFontData, uint32_t aTableTag)
-{
-    const SFNTHeader* header =
-        reinterpret_cast<const SFNTHeader*>(aFontData);
-    const TableDirEntry* dir =
-        reinterpret_cast<const TableDirEntry*>(header + 1);
-    dir = static_cast<const TableDirEntry*>
-        (bsearch(&aTableTag, dir, uint16_t(header->numTables),
-                 sizeof(TableDirEntry), DirEntryCmp));
-    if (dir) {
-        return hb_blob_create(reinterpret_cast<const char*>(aFontData) +
-                                  dir->offset, dir->length,
-                              HB_MEMORY_MODE_READONLY, nullptr, nullptr);
-
-    }
-    return nullptr;
-}
-
-already_AddRefed<gfxCharacterMap>
-gfxFontEntry::GetCMAPFromFontInfo(FontInfoData *aFontInfoData,
-                                  uint32_t& aUVSOffset,
-                                  bool& aSymbolFont)
-{
-    if (!aFontInfoData || !aFontInfoData->mLoadCmaps) {
-        return nullptr;
-    }
-
-    return aFontInfoData->GetCMAP(mName, aUVSOffset, aSymbolFont);
-}
-
-hb_blob_t *
-gfxFontEntry::GetFontTable(uint32_t aTag)
-{
-    hb_blob_t *blob;
-    if (GetExistingFontTable(aTag, &blob)) {
-        return blob;
-    }
-
-    FallibleTArray<uint8_t> buffer;
-    bool haveTable = NS_SUCCEEDED(CopyFontTable(aTag, buffer));
-
-    return ShareFontTableAndGetBlob(aTag, haveTable ? &buffer : nullptr);
-}
-
-// callback for HarfBuzz to get a font table (in hb_blob_t form)
-// from the font entry (passed as aUserData)
-/*static*/ hb_blob_t *
-gfxFontEntry::HBGetTable(hb_face_t *face, uint32_t aTag, void *aUserData)
-{
-    gfxFontEntry *fontEntry = static_cast<gfxFontEntry*>(aUserData);
-
-    // bug 589682 - ignore the GDEF table in buggy fonts (applies to
-    // Italic and BoldItalic faces of Times New Roman)
-    if (aTag == TRUETYPE_TAG('G','D','E','F') &&
-        fontEntry->IgnoreGDEF()) {
-        return nullptr;
-    }
-
-    // bug 721719 - ignore the GSUB table in buggy fonts (applies to Roboto,
-    // at least on some Android ICS devices; set in gfxFT2FontList.cpp)
-    if (aTag == TRUETYPE_TAG('G','S','U','B') &&
-        fontEntry->IgnoreGSUB()) {
-        return nullptr;
-    }
-
-    return fontEntry->GetFontTable(aTag);
-}
-
-/*static*/ void
-gfxFontEntry::HBFaceDeletedCallback(void *aUserData)
-{
-    gfxFontEntry *fe = static_cast<gfxFontEntry*>(aUserData);
-    fe->ForgetHBFace();
-}
-
-void
-gfxFontEntry::ForgetHBFace()
-{
-    mHBFace = nullptr;
-}
-
-hb_face_t*
-gfxFontEntry::GetHBFace()
-{
-    if (!mHBFace) {
-        mHBFace = hb_face_create_for_tables(HBGetTable, this,
-                                            HBFaceDeletedCallback);
-        return mHBFace;
-    }
-    return hb_face_reference(mHBFace);
-}
-
-/*static*/ const void*
-gfxFontEntry::GrGetTable(const void *aAppFaceHandle, unsigned int aName,
-                         size_t *aLen)
-{
-    gfxFontEntry *fontEntry =
-        static_cast<gfxFontEntry*>(const_cast<void*>(aAppFaceHandle));
-    hb_blob_t *blob = fontEntry->GetFontTable(aName);
-    if (blob) {
-        unsigned int blobLength;
-        const void *tableData = hb_blob_get_data(blob, &blobLength);
-        fontEntry->mGrTableMap->Put(tableData, blob);
-        *aLen = blobLength;
-        return tableData;
-    }
-    *aLen = 0;
-    return nullptr;
-}
-
-/*static*/ void
-gfxFontEntry::GrReleaseTable(const void *aAppFaceHandle,
-                             const void *aTableBuffer)
-{
-    gfxFontEntry *fontEntry =
-        static_cast<gfxFontEntry*>(const_cast<void*>(aAppFaceHandle));
-    void *data;
-    if (fontEntry->mGrTableMap->Get(aTableBuffer, &data)) {
-        fontEntry->mGrTableMap->Remove(aTableBuffer);
-        hb_blob_destroy(static_cast<hb_blob_t*>(data));
-    }
-}
-
-gr_face*
-gfxFontEntry::GetGrFace()
-{
-    if (!mGrFaceInitialized) {
-        gr_face_ops faceOps = {
-            sizeof(gr_face_ops),
-            GrGetTable,
-            GrReleaseTable
-        };
-        mGrTableMap = new nsDataHashtable<nsPtrHashKey<const void>,void*>;
-        mGrFace = gr_make_face_with_ops(this, &faceOps, gr_face_default);
-        mGrFaceInitialized = true;
-    }
-    ++mGrFaceRefCnt;
-    return mGrFace;
-}
-
-void
-gfxFontEntry::ReleaseGrFace(gr_face *aFace)
-{
-    MOZ_ASSERT(aFace == mGrFace); // sanity-check
-    MOZ_ASSERT(mGrFaceRefCnt > 0);
-    if (--mGrFaceRefCnt == 0) {
-        gr_face_destroy(mGrFace);
-        mGrFace = nullptr;
-        mGrFaceInitialized = false;
-        delete mGrTableMap;
-        mGrTableMap = nullptr;
-    }
-}
-
-void
-gfxFontEntry::DisconnectSVG()
-{
-    if (mSVGInitialized && mSVGGlyphs) {
-        mSVGGlyphs = nullptr;
-        mSVGInitialized = false;
-    }
-}
-
-bool
-gfxFontEntry::HasFontTable(uint32_t aTableTag)
-{
-    AutoTable table(this, aTableTag);
-    return table && hb_blob_get_length(table) > 0;
-}
-
-void
-gfxFontEntry::CheckForGraphiteTables()
-{
-    mHasGraphiteTables = HasFontTable(TRUETYPE_TAG('S','i','l','f'));
-}
-
-
-#define FEATURE_SCRIPT_MASK 0x000000ff // script index replaces low byte of tag
-
-// check for too many script codes
-PR_STATIC_ASSERT(MOZ_NUM_SCRIPT_CODES <= FEATURE_SCRIPT_MASK);
-
-// high-order three bytes of tag with script in low-order byte
-#define SCRIPT_FEATURE(s,tag) (((~FEATURE_SCRIPT_MASK) & (tag)) | \
-                               ((FEATURE_SCRIPT_MASK) & (s)))
-
-bool
-gfxFontEntry::SupportsOpenTypeFeature(int32_t aScript, uint32_t aFeatureTag)
-{
-    if (!mSupportedFeatures) {
-        mSupportedFeatures = new nsDataHashtable<nsUint32HashKey,bool>();
-    }
-
-    // note: high-order three bytes *must* be unique for each feature
-    // listed below (see SCRIPT_FEATURE macro def'n)
-    NS_ASSERTION(aFeatureTag == HB_TAG('s','m','c','p') ||
-                 aFeatureTag == HB_TAG('c','2','s','c') ||
-                 aFeatureTag == HB_TAG('p','c','a','p') ||
-                 aFeatureTag == HB_TAG('c','2','