Bug 1512567 - Check that we didn't already create an IPCDoc for the DocAccessible. r=Jamie
authorEitan Isaacson <eitan@monotonous.org>
Tue, 26 Feb 2019 17:05:47 +0000
changeset 519082 8e6506978820a5ece5c7f18a6e9c14024517b109
parent 519081 e6333b7c1331dd7c04d27cbf51c8e25eb201d8b3
child 519083 b7ea35510cf18afcb86d64c050172db079912ad3
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie
bugs1512567
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1512567 - Check that we didn't already create an IPCDoc for the DocAccessible. r=Jamie Differential Revision: https://phabricator.services.mozilla.com/D20594
accessible/generic/DocAccessible.cpp
accessible/generic/DocAccessible.h
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -1333,31 +1333,36 @@ void DocAccessible::NotifyOfLoading(bool
 }
 
 void DocAccessible::DoInitialUpdate() {
   if (nsCoreUtils::IsTabDocument(mDocumentNode)) {
     mDocFlags |= eTabDocument;
     if (IPCAccessibilityActive()) {
       nsIDocShell* docShell = mDocumentNode->GetDocShell();
       if (RefPtr<dom::TabChild> tabChild = dom::TabChild::GetFrom(docShell)) {
-        DocAccessibleChild* ipcDoc = new DocAccessibleChild(this, tabChild);
-        SetIPCDoc(ipcDoc);
+        DocAccessibleChild* ipcDoc = IPCDoc();
+        if (!ipcDoc) {
+          ipcDoc = new DocAccessibleChild(this, tabChild);
+          SetIPCDoc(ipcDoc);
+
+#if defined(XP_WIN)
+          IAccessibleHolder holder(
+              CreateHolderFromAccessible(WrapNotNull(this)));
+          MOZ_ASSERT(!holder.IsNull());
+          int32_t childID = AccessibleWrap::GetChildIDFor(this);
+#else
+          int32_t holder = 0, childID = 0;
+#endif
+          tabChild->SendPDocAccessibleConstructor(ipcDoc, nullptr, 0, childID,
+                                                  holder);
+        }
+
         if (IsRoot()) {
           tabChild->SetTopLevelDocAccessibleChild(ipcDoc);
         }
-
-#if defined(XP_WIN)
-        IAccessibleHolder holder(CreateHolderFromAccessible(WrapNotNull(this)));
-        MOZ_ASSERT(!holder.IsNull());
-        int32_t childID = AccessibleWrap::GetChildIDFor(this);
-#else
-        int32_t holder = 0, childID = 0;
-#endif
-        tabChild->SendPDocAccessibleConstructor(ipcDoc, nullptr, 0, childID,
-                                                holder);
       }
     }
   }
 
   mLoadState |= eTreeConstructed;
 
   // Set up a root element and ARIA role mapping.
   UpdateRootElIfNeeded();
@@ -2248,16 +2253,21 @@ bool DocAccessible::IsLoadEventTarget() 
     DocAccessible* parentDoc = ParentDocument();
     return parentDoc && parentDoc->HasLoadState(eCompletelyLoaded);
   }
 
   // It's content (not chrome) root document.
   return (treeItem->ItemType() == nsIDocShellTreeItem::typeContent);
 }
 
+void DocAccessible::SetIPCDoc(DocAccessibleChild* aIPCDoc) {
+  MOZ_ASSERT(!mIPCDoc || !aIPCDoc, "Clobbering an attached IPCDoc!");
+  mIPCDoc = aIPCDoc;
+}
+
 void DocAccessible::DispatchScrollingEvent(uint32_t aEventType) {
   nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
   if (!sf) {
     return;
   }
 
   int32_t appUnitsPerDevPixel =
       mPresShell->GetPresContext()->AppUnitsPerDevPixel();
--- a/accessible/generic/DocAccessible.h
+++ b/accessible/generic/DocAccessible.h
@@ -555,17 +555,17 @@ class DocAccessible : public HyperTextAc
    * coalescence).
    */
   bool IsLoadEventTarget() const;
 
   /*
    * Set the object responsible for communicating with the main process on
    * behalf of this document.
    */
-  void SetIPCDoc(DocAccessibleChild* aIPCDoc) { mIPCDoc = aIPCDoc; }
+  void SetIPCDoc(DocAccessibleChild* aIPCDoc);
 
   friend class DocAccessibleChildBase;
 
   /**
    * Used to fire scrolling end event after page scroll.
    *
    * @param aTimer    [in] the timer object
    * @param aClosure  [in] the document accessible where scrolling happens