Bug 1419362 part 2: Move AccessibleTextTearoff into AccessibleHandler. r?MarcoZ draft
authorJames Teh <jteh@mozilla.com>
Wed, 22 Nov 2017 12:16:18 +1000
changeset 703075 1603b89a53d7089c8cbe009e5c306474becad266
parent 703074 e098330f9b5345db353ec6630ccdb315100ee71d
child 703076 6ca36ba4e39e48f8a2cc48f7c02cc48f161c5096
push id90698
push userbmo:jteh@mozilla.com
push dateFri, 24 Nov 2017 09:13:42 +0000
reviewersMarcoZ
bugs1419362
milestone59.0a1
Bug 1419362 part 2: Move AccessibleTextTearoff into AccessibleHandler. r?MarcoZ We want to be able to cache data related to both IAccessibleText and IAccessibleHypertext2 in a single call. This is difficult with the tearoff because separate instances of the tearoff get created for the two interfaces. Ensuring we use the same instance means working around reference cycles. We could maintain a separate cache object, but that makes things more complex. Therefore, it's much simpler to get rid of the tearoff. A few things to note: 1. ResolveAccHypertext has been renamed to ResolveIAHypertext for consistency with the rest of AccessibleHandler. 2. mAccHypertextProxy has been renamed to mIAHypertextPassThru for consistency with the rest of AccessibleHandler. 3. mIAHypertextPassThru is a weak reference (just like the rest of the passthru pointers) because it refers to a proxy interface and the proxy aggregates the handler. Thus, we release it immediately to avoid reference cycles. When it was a tearoff, this was not the case; it was a strong reference. MozReview-Commit-ID: 8NwPA0T1MFX
accessible/ipc/win/handler/AccessibleHandler.cpp
accessible/ipc/win/handler/AccessibleHandler.h
accessible/ipc/win/handler/AccessibleTextTearoff.cpp
accessible/ipc/win/handler/AccessibleTextTearoff.h
accessible/ipc/win/handler/moz.build
--- a/accessible/ipc/win/handler/AccessibleHandler.cpp
+++ b/accessible/ipc/win/handler/AccessibleHandler.cpp
@@ -7,17 +7,16 @@
 #if defined(MOZILLA_INTERNAL_API)
 #error This code is NOT for internal Gecko use!
 #endif // defined(MOZILLA_INTERNAL_API)
 
 #define INITGUID
 
 #include "AccessibleHandler.h"
 #include "AccessibleHandlerControl.h"
-#include "AccessibleTextTearoff.h"
 
 #include "Factory.h"
 #include "HandlerData.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/mscom/Registration.h"
 #include "mozilla/UniquePtr.h"
 
 #include <objbase.h>
@@ -26,19 +25,22 @@
 
 #include "AccessibleHypertext.h"
 #include "AccessibleHypertext2.h"
 #include "Accessible2_i.c"
 #include "Accessible2_2_i.c"
 #include "Accessible2_3_i.c"
 #include "AccessibleAction_i.c"
 #include "AccessibleHyperlink_i.c"
+#include "AccessibleHypertext_i.c"
+#include "AccessibleHypertext2_i.c"
 #include "AccessibleTable_i.c"
 #include "AccessibleTable2_i.c"
 #include "AccessibleTableCell_i.c"
+#include "AccessibleText_i.c"
 
 namespace mozilla {
 namespace a11y {
 
 static mscom::Factory<AccessibleHandler> sHandlerFactory;
 
 HRESULT
 AccessibleHandler::Create(IUnknown* aOuter, REFIID aIid, void** aOutInterface)
@@ -63,16 +65,17 @@ AccessibleHandler::Create(IUnknown* aOut
 
 AccessibleHandler::AccessibleHandler(IUnknown* aOuter, HRESULT* aResult)
   : mscom::Handler(aOuter, aResult)
   , mDispatch(nullptr)
   , mIA2PassThru(nullptr)
   , mServProvPassThru(nullptr)
   , mIAHyperlinkPassThru(nullptr)
   , mIATableCellPassThru(nullptr)
+  , mIAHypertextPassThru(nullptr)
   , mCachedData()
   , mCacheGen(0)
 {
   RefPtr<AccessibleHandlerControl> ctl(gControlFactory.GetOrCreateSingleton());
   MOZ_ASSERT(ctl);
   if (!ctl) {
     if (aResult) {
       *aResult = E_UNEXPECTED;
@@ -154,16 +157,39 @@ AccessibleHandler::ResolveIATableCell()
     // (see comments in AccesssibleHandler.h)
     mIATableCellPassThru->Release();
   }
 
   return hr;
 }
 
 HRESULT
+AccessibleHandler::ResolveIAHypertext()
+{
+  if (mIAHypertextPassThru) {
+    return S_OK;
+  }
+
+  RefPtr<IUnknown> proxy(GetProxy());
+  if (!proxy) {
+    return E_UNEXPECTED;
+  }
+
+  HRESULT hr = proxy->QueryInterface(IID_IAccessibleHypertext,
+    reinterpret_cast<void**>(&mIAHypertextPassThru));
+  if (SUCCEEDED(hr)) {
+    // mIAHypertextPassThru is a weak reference
+    // (see comments in AccessibleHandler.h)
+    mIAHypertextPassThru->Release();
+  }
+
+  return hr;
+}
+
+HRESULT
 AccessibleHandler::MaybeUpdateCachedData()
 {
   RefPtr<AccessibleHandlerControl> ctl(gControlFactory.GetOrCreateSingleton());
   if (!ctl) {
     return E_OUTOFMEMORY;
   }
 
   uint32_t gen = ctl->GetCacheGen();
@@ -275,18 +301,19 @@ AccessibleHandler::QueryHandlerInterface
     RefPtr<IAccessibleTableCell> iaCell(
       static_cast<IAccessibleTableCell*>(this));
     iaCell.forget(aOutInterface);
     return S_OK;
   }
 
   if (aIid == IID_IAccessibleText || aIid == IID_IAccessibleHypertext ||
       aIid == IID_IAccessibleHypertext2) {
-    RefPtr<IAccessibleHypertext2> textTearoff(new AccessibleTextTearoff(this));
-    textTearoff.forget(aOutInterface);
+    RefPtr<IAccessibleHypertext2> iaHt(
+      static_cast<IAccessibleHypertext2*>(this));
+    iaHt.forget(aOutInterface);
     return S_OK;
   }
 
   if (aIid == IID_IProvideClassInfo) {
     RefPtr<IProvideClassInfo> clsInfo(this);
     clsInfo.forget(aOutInterface);
     return S_OK;
   }
@@ -1528,16 +1555,330 @@ AccessibleHandler::get_table(IUnknown** 
   HRESULT hr = ResolveIATableCell();
   if (FAILED(hr)) {
     return hr;
   }
 
   return mIATableCellPassThru->get_table(table);
 }
 
+/*** IAccessibleText ***/
+
+HRESULT
+AccessibleHandler::addSelection(long startOffset, long endOffset)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->addSelection(startOffset, endOffset);
+}
+
+HRESULT
+AccessibleHandler::get_attributes(long offset, long *startOffset,
+                                  long *endOffset, BSTR *textAttributes)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_attributes(offset, startOffset, endOffset,
+                                              textAttributes);
+}
+
+HRESULT
+AccessibleHandler::get_caretOffset(long *offset)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_caretOffset(offset);
+}
+
+HRESULT
+AccessibleHandler::get_characterExtents(long offset,
+                                        enum IA2CoordinateType coordType,
+                                        long *x, long *y, long *width,
+                                        long *height)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_characterExtents(offset, coordType, x, y,
+                                                    width, height);
+}
+
+HRESULT
+AccessibleHandler::get_nSelections(long *nSelections)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_nSelections(nSelections);
+}
+
+HRESULT
+AccessibleHandler::get_offsetAtPoint(long x, long y,
+                                     enum IA2CoordinateType coordType,
+                                     long *offset)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_offsetAtPoint(x, y, coordType, offset);
+}
+
+HRESULT
+AccessibleHandler::get_selection(long selectionIndex, long *startOffset,
+                                 long *endOffset)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_selection(selectionIndex, startOffset,
+                                             endOffset);
+}
+
+HRESULT
+AccessibleHandler::get_text(long startOffset, long endOffset, BSTR *text)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_text(startOffset, endOffset, text);
+}
+
+HRESULT
+AccessibleHandler::get_textBeforeOffset(long offset,
+                                        enum IA2TextBoundaryType boundaryType,
+                                        long *startOffset, long *endOffset,
+                                        BSTR *text)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_textBeforeOffset(offset, boundaryType,
+                                                    startOffset, endOffset,
+                                                    text);
+}
+
+HRESULT
+AccessibleHandler::get_textAfterOffset(long offset,
+                                       enum IA2TextBoundaryType boundaryType,
+                                       long *startOffset, long *endOffset,
+                                       BSTR *text)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_textAfterOffset(offset, boundaryType,
+                                                   startOffset, endOffset,
+                                                   text);
+}
+
+HRESULT
+AccessibleHandler::get_textAtOffset(long offset,
+                                    enum IA2TextBoundaryType boundaryType,
+                                    long *startOffset, long *endOffset,
+                                    BSTR *text)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_textAtOffset(offset, boundaryType,
+                                                 startOffset, endOffset, text);
+}
+
+HRESULT
+AccessibleHandler::removeSelection(long selectionIndex)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->removeSelection(selectionIndex);
+}
+
+HRESULT
+AccessibleHandler::setCaretOffset(long offset)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->setCaretOffset(offset);
+}
+
+HRESULT
+AccessibleHandler::setSelection(long selectionIndex, long startOffset,
+                                long endOffset)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->setSelection(selectionIndex, startOffset,
+                                            endOffset);
+}
+
+HRESULT
+AccessibleHandler::get_nCharacters(long *nCharacters)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_nCharacters(nCharacters);
+}
+
+HRESULT
+AccessibleHandler::scrollSubstringTo(long startIndex, long endIndex,
+                                     enum IA2ScrollType scrollType)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->scrollSubstringTo(startIndex, endIndex,
+                                                 scrollType);
+}
+
+HRESULT
+AccessibleHandler::scrollSubstringToPoint(long startIndex, long endIndex,
+                                          enum IA2CoordinateType coordinateType,
+                                          long x, long y)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->scrollSubstringToPoint(startIndex, endIndex,
+                                                      coordinateType, x, y);
+}
+
+HRESULT
+AccessibleHandler::get_newText(IA2TextSegment *newText)
+{
+  if (!newText) {
+    return E_INVALIDARG;
+  }
+
+  RefPtr<AccessibleHandlerControl> ctl(gControlFactory.GetSingleton());
+  MOZ_ASSERT(ctl);
+  if (!ctl) {
+    return S_OK;
+  }
+
+  long id;
+  HRESULT hr = this->get_uniqueID(&id);
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return ctl->GetNewText(id, WrapNotNull(newText));
+}
+
+HRESULT
+AccessibleHandler::get_oldText(IA2TextSegment *oldText)
+{
+  if (!oldText) {
+    return E_INVALIDARG;
+  }
+
+  RefPtr<AccessibleHandlerControl> ctl(gControlFactory.GetSingleton());
+  MOZ_ASSERT(ctl);
+  if (!ctl) {
+    return S_OK;
+  }
+
+  long id;
+  HRESULT hr = this->get_uniqueID(&id);
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return ctl->GetOldText(id, WrapNotNull(oldText));
+}
+
+/*** IAccessibleHypertext ***/
+
+HRESULT
+AccessibleHandler::get_nHyperlinks(long *hyperlinkCount)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_nHyperlinks(hyperlinkCount);
+}
+
+HRESULT
+AccessibleHandler::get_hyperlink(long index,
+                                 IAccessibleHyperlink **hyperlink)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_hyperlink(index, hyperlink);
+}
+
+HRESULT
+AccessibleHandler::get_hyperlinkIndex(long charIndex, long *hyperlinkIndex)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_hyperlinkIndex(charIndex, hyperlinkIndex);
+}
+
+/*** IAccessibleHypertext2 ***/
+
+HRESULT
+AccessibleHandler::get_hyperlinks(IAccessibleHyperlink*** hyperlinks,
+                                  long* nHyperlinks)
+{
+  HRESULT hr = ResolveIAHypertext();
+  if (FAILED(hr)) {
+    return hr;
+  }
+
+  return mIAHypertextPassThru->get_hyperlinks(hyperlinks, nHyperlinks);
+}
+
 } // namespace a11y
 } // namespace mozilla
 
 extern "C" HRESULT __stdcall
 ProxyDllCanUnloadNow();
 
 extern "C" HRESULT __stdcall
 DllCanUnloadNow()
--- a/accessible/ipc/win/handler/AccessibleHandler.h
+++ b/accessible/ipc/win/handler/AccessibleHandler.h
@@ -31,16 +31,17 @@ import NEWEST_IA2_IDL;
 #include "HandlerData.h"
 
 #include <windows.h>
 
 #if !defined(MOZILLA_INTERNAL_API)
 
 #include "Accessible2_3.h"
 #include "AccessibleHyperlink.h"
+#include "AccessibleHypertext2.h"
 #include "AccessibleTableCell.h"
 #include "Handler.h"
 #include "mozilla/mscom/StructStream.h"
 #include "mozilla/UniquePtr.h"
 
 #include <ocidl.h>
 #include <servprov.h>
 
@@ -48,16 +49,17 @@ namespace mozilla {
 namespace a11y {
 
 class AccessibleHandler final : public mscom::Handler
                               , public NEWEST_IA2_INTERFACE
                               , public IServiceProvider
                               , public IProvideClassInfo
                               , public IAccessibleHyperlink
                               , public IAccessibleTableCell
+                              , public IAccessibleHypertext2
 {
 public:
   static HRESULT Create(IUnknown* aOuter, REFIID aIid, void** aOutInterface);
 
   // mscom::Handler
   HRESULT QueryHandlerInterface(IUnknown* aProxyUnknown, REFIID aIid,
                                 void** aOutInterface) override;
   HRESULT ReadHandlerPayload(IStream* aStream, REFIID aIid) override;
@@ -185,23 +187,74 @@ public:
                                   long* nRowHeaderCells) override;
   STDMETHODIMP get_rowIndex(long* rowIndex) override;
   STDMETHODIMP get_isSelected(boolean* isSelected) override;
   STDMETHODIMP get_rowColumnExtents(long* row, long* column,
                                     long* rowExtents, long* columnExtents,
                                     boolean* isSelected) override;
   STDMETHODIMP get_table(IUnknown** table) override;
 
+  // IAccessibleText
+  STDMETHODIMP addSelection(long startOffset, long endOffset) override;
+  STDMETHODIMP get_attributes(long offset, long *startOffset, long *endOffset,
+                              BSTR *textAttributes) override;
+  STDMETHODIMP get_caretOffset(long *offset) override;
+  STDMETHODIMP get_characterExtents(long offset,
+                                    enum IA2CoordinateType coordType, long *x,
+                                    long *y, long *width, long *height) override;
+  STDMETHODIMP get_nSelections(long *nSelections) override;
+  STDMETHODIMP get_offsetAtPoint(long x, long y,
+                                 enum IA2CoordinateType coordType,
+                                 long *offset) override;
+  STDMETHODIMP get_selection(long selectionIndex, long *startOffset,
+                             long *endOffset) override;
+  STDMETHODIMP get_text(long startOffset, long endOffset, BSTR *text) override;
+  STDMETHODIMP get_textBeforeOffset(long offset,
+                                    enum IA2TextBoundaryType boundaryType,
+                                    long *startOffset, long *endOffset,
+                                    BSTR *text) override;
+  STDMETHODIMP get_textAfterOffset(long offset,
+                                   enum IA2TextBoundaryType boundaryType,
+                                   long *startOffset, long *endOffset,
+                                   BSTR *text) override;
+  STDMETHODIMP get_textAtOffset(long offset,
+                                enum IA2TextBoundaryType boundaryType,
+                                long *startOffset, long *endOffset,
+                                BSTR *text) override;
+  STDMETHODIMP removeSelection(long selectionIndex) override;
+  STDMETHODIMP setCaretOffset(long offset) override;
+  STDMETHODIMP setSelection(long selectionIndex, long startOffset,
+                            long endOffset) override;
+  STDMETHODIMP get_nCharacters(long *nCharacters) override;
+  STDMETHODIMP scrollSubstringTo(long startIndex, long endIndex,
+                                 enum IA2ScrollType scrollType) override;
+  STDMETHODIMP scrollSubstringToPoint(long startIndex, long endIndex,
+                                      enum IA2CoordinateType coordinateType,
+                                      long x, long y) override;
+  STDMETHODIMP get_newText(IA2TextSegment *newText) override;
+  STDMETHODIMP get_oldText(IA2TextSegment *oldText) override;
+
+  // IAccessibleHypertext
+  STDMETHODIMP get_nHyperlinks(long *hyperlinkCount) override;
+  STDMETHODIMP get_hyperlink(long index,
+                             IAccessibleHyperlink **hyperlink) override;
+  STDMETHODIMP get_hyperlinkIndex(long charIndex, long *hyperlinkIndex) override;
+
+  // IAccessibleHypertext2
+  STDMETHODIMP get_hyperlinks(IAccessibleHyperlink*** hyperlinks,
+                              long* nHyperlinks) override;
+
 private:
   AccessibleHandler(IUnknown* aOuter, HRESULT* aResult);
   virtual ~AccessibleHandler();
 
   HRESULT ResolveIA2();
   HRESULT ResolveIDispatch();
   HRESULT ResolveIAHyperlink();
+  HRESULT ResolveIAHypertext();
   HRESULT ResolveIATableCell();
   HRESULT MaybeUpdateCachedData();
 
   RefPtr<IUnknown>                  mDispatchUnk;
   /**
    * Handlers aggregate their proxies. This means that their proxies delegate
    * their IUnknown implementation to us.
    *
@@ -220,16 +273,17 @@ private:
    * It is safe for us to use these raw pointers because the aggregated
    * objects's lifetimes are proper subsets of our own lifetime.
    */
   IDispatch*                        mDispatch;         // weak
   NEWEST_IA2_INTERFACE*             mIA2PassThru;      // weak
   IServiceProvider*                 mServProvPassThru; // weak
   IAccessibleHyperlink*             mIAHyperlinkPassThru; // weak
   IAccessibleTableCell*             mIATableCellPassThru; // weak
+  IAccessibleHypertext2*             mIAHypertextPassThru; // weak
   IA2Payload                        mCachedData;
   UniquePtr<mscom::StructToStream>  mSerializer;
   uint32_t                          mCacheGen;
 };
 
 } // namespace a11y
 } // namespace mozilla
 
deleted file mode 100644
--- a/accessible/ipc/win/handler/AccessibleTextTearoff.cpp
+++ /dev/null
@@ -1,356 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=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/. */
-
-#if defined(MOZILLA_INTERNAL_API)
-#error This code is NOT for internal Gecko use!
-#endif // defined(MOZILLA_INTERNAL_API)
-
-#include "AccessibleTextTearoff.h"
-
-#include "AccessibleHandlerControl.h"
-#include "AccessibleText_i.c"
-#include "AccessibleHypertext_i.c"
-#include "AccessibleHypertext2_i.c"
-#include "Factory.h"
-
-#include "mozilla/Assertions.h"
-
-namespace mozilla {
-namespace a11y {
-
-AccessibleTextTearoff::AccessibleTextTearoff(AccessibleHandler* aHandler)
-  : mHandler(aHandler)
-{
-  MOZ_ASSERT(aHandler);
-}
-
-HRESULT
-AccessibleTextTearoff::ResolveAccHypertext()
-{
-  if (mAccHypertextProxy) {
-    return S_OK;
-  }
-
-  RefPtr<IUnknown> proxy(mHandler->GetProxy());
-  if (!proxy) {
-    return E_UNEXPECTED;
-  }
-
-  return proxy->QueryInterface(IID_IAccessibleHypertext2,
-                               getter_AddRefs(mAccHypertextProxy));
-}
-
-IMPL_IUNKNOWN_QUERY_HEAD(AccessibleTextTearoff)
-IMPL_IUNKNOWN_QUERY_IFACE(IAccessibleText)
-IMPL_IUNKNOWN_QUERY_IFACE(IAccessibleHypertext)
-IMPL_IUNKNOWN_QUERY_IFACE(IAccessibleHypertext2)
-IMPL_IUNKNOWN_QUERY_TAIL_AGGREGATED(mHandler)
-
-HRESULT
-AccessibleTextTearoff::addSelection(long startOffset, long endOffset)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->addSelection(startOffset, endOffset);
-}
-
-HRESULT
-AccessibleTextTearoff::get_attributes(long offset, long *startOffset,
-                                      long *endOffset, BSTR *textAttributes)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_attributes(offset, startOffset, endOffset,
-                                       textAttributes);
-}
-
-HRESULT
-AccessibleTextTearoff::get_caretOffset(long *offset)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_caretOffset(offset);
-}
-
-HRESULT
-AccessibleTextTearoff::get_characterExtents(long offset,
-                                            enum IA2CoordinateType coordType,
-                                            long *x, long *y, long *width,
-                                            long *height)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_characterExtents(offset, coordType, x, y, width,
-                                             height);
-}
-
-HRESULT
-AccessibleTextTearoff::get_nSelections(long *nSelections)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_nSelections(nSelections);
-}
-
-HRESULT
-AccessibleTextTearoff::get_offsetAtPoint(long x, long y,
-                                         enum IA2CoordinateType coordType,
-                                         long *offset)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_offsetAtPoint(x, y, coordType, offset);
-}
-
-HRESULT
-AccessibleTextTearoff::get_selection(long selectionIndex, long *startOffset,
-                                     long *endOffset)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_selection(selectionIndex, startOffset, endOffset);
-}
-
-HRESULT
-AccessibleTextTearoff::get_text(long startOffset, long endOffset, BSTR *text)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_text(startOffset, endOffset, text);
-}
-
-HRESULT
-AccessibleTextTearoff::get_textBeforeOffset(long offset,
-                                            enum IA2TextBoundaryType boundaryType,
-                                            long *startOffset, long *endOffset,
-                                            BSTR *text)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_textBeforeOffset(offset, boundaryType, startOffset,
-                                             endOffset, text);
-}
-
-HRESULT
-AccessibleTextTearoff::get_textAfterOffset(long offset,
-                                           enum IA2TextBoundaryType boundaryType,
-                                           long *startOffset, long *endOffset,
-                                           BSTR *text)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_textAfterOffset(offset, boundaryType,
-                                            startOffset, endOffset, text);
-}
-
-HRESULT
-AccessibleTextTearoff::get_textAtOffset(long offset,
-                                        enum IA2TextBoundaryType boundaryType,
-                                        long *startOffset, long *endOffset,
-                                        BSTR *text)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_textAtOffset(offset, boundaryType, startOffset,
-                                         endOffset, text);
-}
-
-HRESULT
-AccessibleTextTearoff::removeSelection(long selectionIndex)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->removeSelection(selectionIndex);
-}
-
-HRESULT
-AccessibleTextTearoff::setCaretOffset(long offset)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->setCaretOffset(offset);
-}
-
-HRESULT
-AccessibleTextTearoff::setSelection(long selectionIndex, long startOffset,
-                                    long endOffset)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->setSelection(selectionIndex, startOffset, endOffset);
-}
-
-HRESULT
-AccessibleTextTearoff::get_nCharacters(long *nCharacters)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_nCharacters(nCharacters);
-}
-
-HRESULT
-AccessibleTextTearoff::scrollSubstringTo(long startIndex, long endIndex,
-                                         enum IA2ScrollType scrollType)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->scrollSubstringTo(startIndex, endIndex, scrollType);
-}
-
-HRESULT
-AccessibleTextTearoff::scrollSubstringToPoint(long startIndex, long endIndex,
-                                              enum IA2CoordinateType coordinateType,
-                                              long x, long y)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->scrollSubstringToPoint(startIndex, endIndex,
-                                               coordinateType, x, y);
-}
-
-HRESULT
-AccessibleTextTearoff::get_newText(IA2TextSegment *newText)
-{
-  if (!newText) {
-    return E_INVALIDARG;
-  }
-
-  RefPtr<AccessibleHandlerControl> ctl(gControlFactory.GetSingleton());
-  MOZ_ASSERT(ctl);
-  if (!ctl) {
-    return S_OK;
-  }
-
-  long id;
-  HRESULT hr = mHandler->get_uniqueID(&id);
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return ctl->GetNewText(id, WrapNotNull(newText));
-}
-
-HRESULT
-AccessibleTextTearoff::get_oldText(IA2TextSegment *oldText)
-{
-  if (!oldText) {
-    return E_INVALIDARG;
-  }
-
-  RefPtr<AccessibleHandlerControl> ctl(gControlFactory.GetSingleton());
-  MOZ_ASSERT(ctl);
-  if (!ctl) {
-    return S_OK;
-  }
-
-  long id;
-  HRESULT hr = mHandler->get_uniqueID(&id);
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return ctl->GetOldText(id, WrapNotNull(oldText));
-}
-
-HRESULT
-AccessibleTextTearoff::get_nHyperlinks(long *hyperlinkCount)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_nHyperlinks(hyperlinkCount);
-}
-
-HRESULT
-AccessibleTextTearoff::get_hyperlink(long index,
-                                     IAccessibleHyperlink **hyperlink)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_hyperlink(index, hyperlink);
-}
-
-HRESULT
-AccessibleTextTearoff::get_hyperlinkIndex(long charIndex, long *hyperlinkIndex)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_hyperlinkIndex(charIndex, hyperlinkIndex);
-}
-
-HRESULT
-AccessibleTextTearoff::get_hyperlinks(IAccessibleHyperlink*** hyperlinks,
-                                      long* nHyperlinks)
-{
-  HRESULT hr = ResolveAccHypertext();
-  if (FAILED(hr)) {
-    return hr;
-  }
-
-  return mAccHypertextProxy->get_hyperlinks(hyperlinks, nHyperlinks);
-}
-
-} // namespace a11y
-} // namespace mozilla
deleted file mode 100644
--- a/accessible/ipc/win/handler/AccessibleTextTearoff.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=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/. */
-
-#if defined(MOZILLA_INTERNAL_API)
-#error This code is NOT for internal Gecko use!
-#endif // defined(MOZILLA_INTERNAL_API)
-
-#ifndef mozilla_a11y_AccessibleTextTearoff_h
-#define mozilla_a11y_AccessibleTextTearoff_h
-
-#include "AccessibleHandler.h"
-#include "AccessibleHypertext2.h"
-#include "IUnknownImpl.h"
-#include "mozilla/RefPtr.h"
-
-namespace mozilla {
-namespace a11y {
-
-class AccessibleTextTearoff final : public IAccessibleHypertext2
-{
-public:
-  explicit AccessibleTextTearoff(AccessibleHandler* aHandler);
-
-  DECL_IUNKNOWN
-
-  // IAccessibleText
-  STDMETHODIMP addSelection(long startOffset, long endOffset) override;
-  STDMETHODIMP get_attributes(long offset, long *startOffset, long *endOffset,
-                              BSTR *textAttributes) override;
-  STDMETHODIMP get_caretOffset(long *offset) override;
-  STDMETHODIMP get_characterExtents(long offset,
-                                    enum IA2CoordinateType coordType, long *x,
-                                    long *y, long *width, long *height) override;
-  STDMETHODIMP get_nSelections(long *nSelections) override;
-  STDMETHODIMP get_offsetAtPoint(long x, long y,
-                                 enum IA2CoordinateType coordType,
-                                 long *offset) override;
-  STDMETHODIMP get_selection(long selectionIndex, long *startOffset,
-                             long *endOffset) override;
-  STDMETHODIMP get_text(long startOffset, long endOffset, BSTR *text) override;
-  STDMETHODIMP get_textBeforeOffset(long offset,
-                                    enum IA2TextBoundaryType boundaryType,
-                                    long *startOffset, long *endOffset,
-                                    BSTR *text) override;
-  STDMETHODIMP get_textAfterOffset(long offset,
-                                   enum IA2TextBoundaryType boundaryType,
-                                   long *startOffset, long *endOffset,
-                                   BSTR *text) override;
-  STDMETHODIMP get_textAtOffset(long offset,
-                                enum IA2TextBoundaryType boundaryType,
-                                long *startOffset, long *endOffset,
-                                BSTR *text) override;
-  STDMETHODIMP removeSelection(long selectionIndex) override;
-  STDMETHODIMP setCaretOffset(long offset) override;
-  STDMETHODIMP setSelection(long selectionIndex, long startOffset,
-                            long endOffset) override;
-  STDMETHODIMP get_nCharacters(long *nCharacters) override;
-  STDMETHODIMP scrollSubstringTo(long startIndex, long endIndex,
-                                 enum IA2ScrollType scrollType) override;
-  STDMETHODIMP scrollSubstringToPoint(long startIndex, long endIndex,
-                                      enum IA2CoordinateType coordinateType,
-                                      long x, long y) override;
-  STDMETHODIMP get_newText(IA2TextSegment *newText) override;
-  STDMETHODIMP get_oldText(IA2TextSegment *oldText) override;
-
-  // IAccessibleHypertext
-  STDMETHODIMP get_nHyperlinks(long *hyperlinkCount) override;
-  STDMETHODIMP get_hyperlink(long index,
-                             IAccessibleHyperlink **hyperlink) override;
-  STDMETHODIMP get_hyperlinkIndex(long charIndex, long *hyperlinkIndex) override;
-
-  // IAccessibleHypertext2
-  STDMETHODIMP get_hyperlinks(IAccessibleHyperlink*** hyperlinks,
-                              long* nHyperlinks) override;
-
-private:
-  ~AccessibleTextTearoff() = default;
-  HRESULT ResolveAccHypertext();
-
-  RefPtr<AccessibleHandler>     mHandler;
-  RefPtr<IAccessibleHypertext2>  mAccHypertextProxy;
-};
-
-} // namespace a11y
-} // namespace mozilla
-
-#endif // mozilla_a11y_AccessibleTextTearoff_h
--- a/accessible/ipc/win/handler/moz.build
+++ b/accessible/ipc/win/handler/moz.build
@@ -15,17 +15,16 @@ LOCAL_INCLUDES += [
 
 SOURCES += [
     '!dlldata.c',
     '!HandlerData_c.c',
     '!HandlerData_i.c',
     '!HandlerData_p.c',
     'AccessibleHandler.cpp',
     'AccessibleHandlerControl.cpp',
-    'AccessibleTextTearoff.cpp',
 ]
 
 GENERATED_FILES += [
     'dlldata.c',
     'HandlerData.h',
     'HandlerData.tlb',
     'HandlerData_c.c',
     'HandlerData_i.c',