Bug 1629838 - Don't flush reentrantly from XUL a11y construction. r=Jamie, a=RyanVM
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 15 Apr 2020 01:01:12 +0000
changeset 585541 9d27f85c23cb252ee9a832582cde377f0b3ff77c
parent 585540 a3482e46d0b6af349252648d0221ae262ef38886
child 585542 65b23e473a4d1b74b32e05c5b6934411b8bb9ac6
push id13004
push userryanvm@gmail.com
push dateWed, 15 Apr 2020 20:35:43 +0000
treeherdermozilla-beta@9d27f85c23cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie, RyanVM
bugs1629838, 1625991
milestone76.0
Bug 1629838 - Don't flush reentrantly from XUL a11y construction. r=Jamie, a=RyanVM This code has pretty much always been broken, we've started to flush more because we fixed a bug that was not looking at XUL trees inside shadow DOM in bug 1625991. We cannot flush layout from a11y tree construction. Differential Revision: https://phabricator.services.mozilla.com/D70917
accessible/base/nsCoreUtils.cpp
accessible/base/nsCoreUtils.h
accessible/xul/XULTreeAccessible.cpp
dom/xul/XULTreeElement.cpp
dom/xul/XULTreeElement.h
--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -430,22 +430,22 @@ XULTreeElement* nsCoreUtils::GetTree(nsI
     }
     currentContent = currentContent->GetFlattenedTreeParent();
   }
 
   return nullptr;
 }
 
 already_AddRefed<nsTreeColumn> nsCoreUtils::GetFirstSensibleColumn(
-    XULTreeElement* aTree) {
+    XULTreeElement* aTree, FlushType aFlushType) {
   if (!aTree) {
     return nullptr;
   }
 
-  RefPtr<nsTreeColumns> cols = aTree->GetColumns();
+  RefPtr<nsTreeColumns> cols = aTree->GetColumns(aFlushType);
   if (!cols) {
     return nullptr;
   }
 
   RefPtr<nsTreeColumn> column = cols->GetFirstColumn();
   if (column && IsColumnHidden(column)) return GetNextSensibleColumn(column);
 
   return column.forget();
--- a/accessible/base/nsCoreUtils.h
+++ b/accessible/base/nsCoreUtils.h
@@ -6,16 +6,17 @@
 #ifndef nsCoreUtils_h_
 #define nsCoreUtils_h_
 
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/Element.h"
 #include "nsIAccessibleEvent.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Document.h"  // for GetPresShell()
+#include "mozilla/FlushType.h"
 
 #include "nsPoint.h"
 #include "nsTArray.h"
 
 class nsRange;
 class nsTreeColumn;
 class nsIFrame;
 class nsIDocShell;
@@ -248,17 +249,18 @@ class nsCoreUtils {
    * Return tree from any levels DOMNode under the XUL tree.
    */
   static mozilla::dom::XULTreeElement* GetTree(nsIContent* aContent);
 
   /**
    * Return first sensible column for the given tree box object.
    */
   static already_AddRefed<nsTreeColumn> GetFirstSensibleColumn(
-      mozilla::dom::XULTreeElement* aTree);
+      mozilla::dom::XULTreeElement* aTree,
+      mozilla::FlushType = mozilla::FlushType::Frames);
 
   /**
    * Return sensible columns count for the given tree box object.
    */
   static uint32_t GetSensibleColumnCount(mozilla::dom::XULTreeElement* aTree);
 
   /**
    * Return sensible column at the given index for the given tree box object.
--- a/accessible/xul/XULTreeAccessible.cpp
+++ b/accessible/xul/XULTreeAccessible.cpp
@@ -899,17 +899,17 @@ void XULTreeItemAccessibleBase::GetCellN
 ////////////////////////////////////////////////////////////////////////////////
 
 XULTreeItemAccessible::XULTreeItemAccessible(
     nsIContent* aContent, DocAccessible* aDoc, Accessible* aParent,
     dom::XULTreeElement* aTree, nsITreeView* aTreeView, int32_t aRow)
     : XULTreeItemAccessibleBase(aContent, aDoc, aParent, aTree, aTreeView,
                                 aRow) {
   mStateFlags |= eNoKidsFromDOM;
-  mColumn = nsCoreUtils::GetFirstSensibleColumn(mTree);
+  mColumn = nsCoreUtils::GetFirstSensibleColumn(mTree, FlushType::None);
   GetCellName(mColumn, mCachedName);
 }
 
 XULTreeItemAccessible::~XULTreeItemAccessible() {}
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeItemAccessible: nsISupports implementation
 
--- a/dom/xul/XULTreeElement.cpp
+++ b/dom/xul/XULTreeElement.cpp
@@ -168,19 +168,19 @@ already_AddRefed<Element> XULTreeElement
     nsCOMPtr<Element> element;
     body->GetTreeBody(getter_AddRefs(element));
     return element.forget();
   }
 
   return nullptr;
 }
 
-already_AddRefed<nsTreeColumns> XULTreeElement::GetColumns() {
-  nsTreeBodyFrame* body = GetTreeBodyFrame();
-  if (body) {
+already_AddRefed<nsTreeColumns> XULTreeElement::GetColumns(
+    FlushType aFlushType) {
+  if (nsTreeBodyFrame* body = GetTreeBodyFrame(aFlushType)) {
     return body->Columns();
   }
   return nullptr;
 }
 
 int32_t XULTreeElement::RowHeight() {
   nsTreeBodyFrame* body = GetTreeBodyFrame();
   if (body) {
--- a/dom/xul/XULTreeElement.h
+++ b/dom/xul/XULTreeElement.h
@@ -36,17 +36,17 @@ class XULTreeElement final : public nsXU
   NS_IMPL_FROMNODE_WITH_TAG(XULTreeElement, kNameSpaceID_XUL, tree)
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeElement, nsXULElement)
 
   nsTreeBodyFrame* GetTreeBodyFrame(FlushType = FlushType::Frames);
   nsTreeBodyFrame* GetCachedTreeBodyFrame() { return mTreeBody; }
 
-  already_AddRefed<nsTreeColumns> GetColumns();
+  already_AddRefed<nsTreeColumns> GetColumns(FlushType = FlushType::Frames);
 
   already_AddRefed<nsITreeView> GetView(CallerType /* unused */) {
     return GetView();
   }
   already_AddRefed<nsITreeView> GetView();
 
   void SetView(nsITreeView* arg, CallerType aCallerType, ErrorResult& aRv);