Bug 1260277 - remove empty CacheChildren's, r=marcoz
authorAlexander Surkov <surkov.alexander@gmail.com>
Thu, 31 Mar 2016 21:40:56 -0400
changeset 291176 8af4e6b9642767e130a8e30ce15d84d93b8eacaf
parent 291175 293229046bc268cf9fd3a40e53da0c792be924ae
child 291177 e6f5d08d29a00d838977d1222bb65182af84db05
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcoz
bugs1260277
milestone48.0a1
Bug 1260277 - remove empty CacheChildren's, r=marcoz
accessible/generic/Accessible.cpp
accessible/generic/Accessible.h
accessible/generic/BaseAccessibles.cpp
accessible/generic/BaseAccessibles.h
accessible/generic/DocAccessible.cpp
accessible/generic/TextLeafAccessible.cpp
accessible/generic/TextLeafAccessible.h
accessible/html/HTMLSelectAccessible.cpp
accessible/html/HTMLSelectAccessible.h
accessible/windows/msaa/HTMLWin32ObjectAccessible.cpp
accessible/windows/msaa/HTMLWin32ObjectAccessible.h
accessible/xul/XULTreeAccessible.cpp
accessible/xul/XULTreeAccessible.h
accessible/xul/XULTreeGridAccessible.cpp
accessible/xul/XULTreeGridAccessible.h
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -2588,17 +2588,19 @@ Accessible::EnsureChildren()
 {
   NS_ASSERTION(!IsDefunct(), "Caching children for defunct accessible!");
 
   if (!IsChildrenFlag(eChildrenUninitialized))
     return;
 
   // State is embedded children until text leaf accessible is appended.
   SetChildrenFlag(eEmbeddedChildren); // Prevent reentry
-  CacheChildren();
+  if (KidsFromDOM()) {
+    CacheChildren();
+  }
 }
 
 Accessible*
 Accessible::GetSiblingAtOffset(int32_t aOffset, nsresult* aError) const
 {
   if (!mParent || mIndexInParent == -1) {
     if (aError)
       *aError = NS_ERROR_UNEXPECTED;
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -928,17 +928,23 @@ public:
     else
       mStateFlags &= ~eRelocated;
   }
 
   /**
    * Return true if the accessible doesn't allow accessible children from XBL
    * anonymous subtree.
    */
-  bool NoXBLKids() { return mStateFlags & eNoXBLKids; }
+  bool NoXBLKids() const { return mStateFlags & eNoXBLKids; }
+
+  /**
+   * Return true if the accessible allows accessible children from subtree of
+   * a DOM element of this accessible.
+   */
+  bool KidsFromDOM() const { return !(mStateFlags & eNoKidsFromDOM); }
 
   /**
    * Return true if this accessible has a parent whose name depends on this
    * accessible.
    */
   bool HasNameDependentParent() const
     { return mContextFlags & eHasNameDependentParent; }
 
@@ -1027,18 +1033,19 @@ protected:
     eNotNodeMapEntry = 1 << 3, // accessible shouldn't be in document node map
     eHasNumericValue = 1 << 4, // accessible has a numeric value
     eGroupInfoDirty = 1 << 5, // accessible needs to update group info
     eSubtreeMutating = 1 << 6, // subtree is being mutated
     eIgnoreDOMUIEvent = 1 << 7, // don't process DOM UI events for a11y events
     eSurvivingInUpdate = 1 << 8, // parent drops children to recollect them
     eRelocated = 1 << 9, // accessible was moved in tree
     eNoXBLKids = 1 << 10, // accessible don't allows XBL children
+    eNoKidsFromDOM = 1 << 11, // accessible doesn't allow children from DOM
 
-    eLastStateFlag = eNoXBLKids
+    eLastStateFlag = eNoKidsFromDOM
   };
 
   /**
    * Flags used for contextual information about the accessible.
    */
   enum ContextFlags {
     eHasNameDependentParent = 1 << 0, // Parent's name depends on this accessible.
     eARIAHidden = 1 << 1,
@@ -1144,17 +1151,17 @@ protected:
   nsCOMPtr<nsIContent> mContent;
   DocAccessible* mDoc;
 
   RefPtr<Accessible> mParent;
   nsTArray<RefPtr<Accessible> > mChildren;
   int32_t mIndexInParent;
 
   static const uint8_t kChildrenFlagsBits = 2;
-  static const uint8_t kStateFlagsBits = 11;
+  static const uint8_t kStateFlagsBits = 12;
   static const uint8_t kContextFlagsBits = 3;
   static const uint8_t kTypeBits = 6;
   static const uint8_t kGenericTypesBits = 15;
 
   /**
    * Keep in sync with ChildrenFlags, StateFlags, ContextFlags, and AccTypes.
    */
   uint32_t mChildrenFlags : kChildrenFlagsBits;
--- a/accessible/generic/BaseAccessibles.cpp
+++ b/accessible/generic/BaseAccessibles.cpp
@@ -19,16 +19,17 @@ using namespace mozilla::a11y;
 ////////////////////////////////////////////////////////////////////////////////
 // LeafAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 LeafAccessible::
   LeafAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   AccessibleWrap(aContent, aDoc)
 {
+  mStateFlags |= eNoKidsFromDOM;
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(LeafAccessible, Accessible)
 
 ////////////////////////////////////////////////////////////////////////////////
 // LeafAccessible: Accessible public
 
 Accessible*
@@ -55,25 +56,16 @@ LeafAccessible::RemoveChild(Accessible* 
 
 bool
 LeafAccessible::IsAcceptableChild(nsIContent* aEl) const
 {
   // No children for leaf accessible.
   return false;
 }
 
-////////////////////////////////////////////////////////////////////////////////
-// LeafAccessible: Accessible private
-
-void
-LeafAccessible::CacheChildren()
-{
-  // No children for leaf accessible.
-}
-
 
 ////////////////////////////////////////////////////////////////////////////////
 // LinkableAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 NS_IMPL_ISUPPORTS_INHERITED0(LinkableAccessible, AccessibleWrap)
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/accessible/generic/BaseAccessibles.h
+++ b/accessible/generic/BaseAccessibles.h
@@ -37,19 +37,16 @@ public:
                                    EWhichChildAtPoint aWhichChild) override;
   virtual bool InsertChildAt(uint32_t aIndex, Accessible* aChild) override final;
   virtual bool RemoveChild(Accessible* aChild) override final;
 
   virtual bool IsAcceptableChild(nsIContent* aEl) const override;
 
 protected:
   virtual ~LeafAccessible() {}
-
-  // Accessible
-  virtual void CacheChildren() override;
 };
 
 /**
  * Used for text or image accessible nodes contained by link accessibles or
  * accessibles for nodes with registered click event handler. It knows how to
  * report the state of the host link (traveled or not) and can activate (click)
  * the host accessible programmatically.
  */
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -2267,18 +2267,19 @@ DocAccessible::CacheChildrenInSubtree(Ac
   // Make sure we create accessible tree defined in DOM only, i.e. if accessible
   // provides specific tree (like XUL trees) then tree creation is handled by
   // this accessible.
   uint32_t count = aRoot->ContentChildCount();
   for (uint32_t idx = 0; idx < count; idx++) {
     Accessible* child = aRoot->ContentChildAt(idx);
     NS_ASSERTION(child, "Illicit tree change while tree is created!");
     // Don't cross document boundaries.
-    if (child && child->IsContent())
+    if (child && child->IsContent()) {
       CacheChildrenInSubtree(child, aFocusedAcc);
+    }
   }
 
   // Fire document load complete on ARIA documents.
   // XXX: we should delay an event if the ARIA document has aria-busy.
   if (aRoot->HasARIARole() && !aRoot->IsDoc()) {
     a11y::role role = aRoot->ARIARole();
     if (role == roles::DIALOG || role == roles::DOCUMENT)
       FireDelayedEvent(nsIAccessibleEvent::EVENT_DOCUMENT_LOAD_COMPLETE, aRoot);
--- a/accessible/generic/TextLeafAccessible.cpp
+++ b/accessible/generic/TextLeafAccessible.cpp
@@ -15,16 +15,17 @@ using namespace mozilla::a11y;
 // TextLeafAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 TextLeafAccessible::
   TextLeafAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   LinkableAccessible(aContent, aDoc)
 {
   mType = eTextLeafType;
+  mStateFlags |= eNoKidsFromDOM;
 }
 
 TextLeafAccessible::~TextLeafAccessible()
 {
 }
 
 role
 TextLeafAccessible::NativeRole()
@@ -45,14 +46,8 @@ TextLeafAccessible::AppendTextTo(nsAStri
 
 ENameValueFlag
 TextLeafAccessible::Name(nsString& aName)
 {
   // Text node, ARIA can't be used.
   aName = mText;
   return eNameOK;
 }
-
-void
-TextLeafAccessible::CacheChildren()
-{
-  // No children for text accessible.
-}
--- a/accessible/generic/TextLeafAccessible.h
+++ b/accessible/generic/TextLeafAccessible.h
@@ -26,20 +26,16 @@ public:
                             uint32_t aLength = UINT32_MAX) override;
   virtual ENameValueFlag Name(nsString& aName) override;
 
   // TextLeafAccessible
   void SetText(const nsAString& aText) { mText = aText; }
   const nsString& Text() const { return mText; }
 
 protected:
-  // Accessible
-  virtual void CacheChildren() override;
-
-protected:
   nsString mText;
 };
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // Accessible downcast method
 
 inline TextLeafAccessible*
--- a/accessible/html/HTMLSelectAccessible.cpp
+++ b/accessible/html/HTMLSelectAccessible.cpp
@@ -332,16 +332,17 @@ HTMLSelectOptGroupAccessible::DoAction(u
 ////////////////////////////////////////////////////////////////////////////////
 
 HTMLComboboxAccessible::
   HTMLComboboxAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   AccessibleWrap(aContent, aDoc)
 {
   mType = eHTMLComboboxType;
   mGenericTypes |= eCombobox;
+  mStateFlags |= eNoKidsFromDOM;
 
   nsIComboboxControlFrame* comboFrame = do_QueryFrame(GetFrame());
   if (comboFrame) {
     nsIFrame* listFrame = comboFrame->GetDropDown();
     if (listFrame) {
       mListAccessible = new HTMLComboboxListAccessible(mParent, mContent, mDoc);
       Document()->BindToDocument(mListAccessible, nullptr);
       AppendChild(mListAccessible);
@@ -365,21 +366,16 @@ HTMLComboboxAccessible::RemoveChild(Acce
   if (AccessibleWrap::RemoveChild(aChild)) {
     mListAccessible = nullptr;
     return true;
   }
   return false;
 }
 
 void
-HTMLComboboxAccessible::CacheChildren()
-{
-}
-
-void
 HTMLComboboxAccessible::Shutdown()
 {
   MOZ_ASSERT(mDoc->IsDefunct() || !mListAccessible);
   if (mListAccessible) {
     mListAccessible->Shutdown();
     mListAccessible = nullptr;
   }
 
--- a/accessible/html/HTMLSelectAccessible.h
+++ b/accessible/html/HTMLSelectAccessible.h
@@ -178,19 +178,16 @@ public:
   // Widgets
   virtual bool IsWidget() const override;
   virtual bool IsActiveWidget() const override;
   virtual bool AreItemsOperable() const override;
   virtual Accessible* CurrentItem() override;
   virtual void SetCurrentItem(Accessible* aItem) override;
 
 protected:
-  // Accessible
-  virtual void CacheChildren() override;
-
   /**
    * Return selected option.
    */
   Accessible* SelectedOption() const;
 
 private:
   RefPtr<HTMLComboboxListAccessible> mListAccessible;
 };
--- a/accessible/windows/msaa/HTMLWin32ObjectAccessible.cpp
+++ b/accessible/windows/msaa/HTMLWin32ObjectAccessible.cpp
@@ -14,16 +14,18 @@ using namespace mozilla::a11y;
 // HTMLWin32ObjectOwnerAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 HTMLWin32ObjectOwnerAccessible::
   HTMLWin32ObjectOwnerAccessible(nsIContent* aContent,
                                  DocAccessible* aDoc, void* aHwnd) :
   AccessibleWrap(aContent, aDoc), mHwnd(aHwnd)
 {
+  mStateFlags |= eNoKidsFromDOM;
+
   // Our only child is a HTMLWin32ObjectAccessible object.
   if (mHwnd) {
     mNativeAccessible = new HTMLWin32ObjectAccessible(mHwnd, aDoc);
     AppendChild(mNativeAccessible);
   }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -46,25 +48,16 @@ bool
 HTMLWin32ObjectOwnerAccessible::NativelyUnavailable() const
 {
   // XXX: No HWND means this is windowless plugin which is not accessible in
   // the meantime.
   return !mHwnd;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// HTMLWin32ObjectOwnerAccessible: Accessible protected implementation
-
-void
-HTMLWin32ObjectOwnerAccessible::CacheChildren()
-{
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
 // HTMLWin32ObjectAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd,
                                                      DocAccessible* aDoc) :
   DummyAccessible(aDoc)
 {
   mHwnd = aHwnd;
--- a/accessible/windows/msaa/HTMLWin32ObjectAccessible.h
+++ b/accessible/windows/msaa/HTMLWin32ObjectAccessible.h
@@ -27,20 +27,16 @@ public:
   virtual ~HTMLWin32ObjectOwnerAccessible() {}
 
   // Accessible
   virtual void Shutdown();
   virtual mozilla::a11y::role NativeRole();
   virtual bool NativelyUnavailable() const;
 
 protected:
-
-  // Accessible
-  virtual void CacheChildren();
-
   void* mHwnd;
   RefPtr<Accessible> mNativeAccessible;
 };
 
 /**
   * This class is used only internally, we never! send out an IAccessible linked
   *   back to this object. This class is used to represent a plugin object when
   *   referenced as a child or sibling of another Accessible node. We need only
--- a/accessible/xul/XULTreeAccessible.cpp
+++ b/accessible/xul/XULTreeAccessible.cpp
@@ -1065,16 +1065,17 @@ XULTreeItemAccessibleBase::GetCellName(n
 ////////////////////////////////////////////////////////////////////////////////
 
 XULTreeItemAccessible::
   XULTreeItemAccessible(nsIContent* aContent, DocAccessible* aDoc,
                         Accessible* aParent, nsITreeBoxObject* aTree,
                         nsITreeView* aTreeView, int32_t aRow) :
   XULTreeItemAccessibleBase(aContent, aDoc, aParent, aTree, aTreeView, aRow)
 {
+  mStateFlags |= eNoKidsFromDOM;
   mColumn = nsCoreUtils::GetFirstSensibleColumn(mTree);
   GetCellName(mColumn, mCachedName);
 }
 
 XULTreeItemAccessible::~XULTreeItemAccessible()
 {
 }
 
@@ -1138,24 +1139,16 @@ XULTreeItemAccessible::RowInvalidated(in
   Name(name);
 
   if (name != mCachedName) {
     nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
     mCachedName = name;
   }
 }
 
-////////////////////////////////////////////////////////////////////////////////
-// XULTreeItemAccessible: Accessible protected implementation
-
-void
-XULTreeItemAccessible::CacheChildren()
-{
-}
-
 
 ////////////////////////////////////////////////////////////////////////////////
 //  XULTreeColumAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 XULTreeColumAccessible::
   XULTreeColumAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   XULColumAccessible(aContent, aDoc)
--- a/accessible/xul/XULTreeAccessible.h
+++ b/accessible/xul/XULTreeAccessible.h
@@ -236,19 +236,16 @@ public:
   virtual a11y::role NativeRole() override;
 
   // XULTreeItemAccessibleBase
   virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx) override;
 
 protected:
   virtual ~XULTreeItemAccessible();
 
-  // Accessible
-  virtual void CacheChildren() override;
-
   // XULTreeItemAccessible
   nsCOMPtr<nsITreeColumn> mColumn;
   nsString mCachedName;
 };
 
 
 /**
  * Accessible class for columns element of XUL tree.
--- a/accessible/xul/XULTreeGridAccessible.cpp
+++ b/accessible/xul/XULTreeGridAccessible.cpp
@@ -244,16 +244,17 @@ XULTreeGridAccessible::CreateTreeItemAcc
 XULTreeGridRowAccessible::
   XULTreeGridRowAccessible(nsIContent* aContent, DocAccessible* aDoc,
                            Accessible* aTreeAcc, nsITreeBoxObject* aTree,
                            nsITreeView* aTreeView, int32_t aRow) :
   XULTreeItemAccessibleBase(aContent, aDoc, aTreeAcc, aTree, aTreeView, aRow),
   mAccessibleCache(kDefaultTreeCacheLength)
 {
   mGenericTypes |= eTableRow;
+  mStateFlags |= eNoKidsFromDOM;
 }
 
 XULTreeGridRowAccessible::~XULTreeGridRowAccessible()
 {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridRowAccessible: nsISupports and cycle collection implementation
@@ -404,23 +405,16 @@ XULTreeGridRowAccessible::RowInvalidated
     }
   }
 
   if (nameChanged)
     nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
 
 }
 
-////////////////////////////////////////////////////////////////////////////////
-// XULTreeGridRowAccessible: Accessible protected implementation
-
-void
-XULTreeGridRowAccessible::CacheChildren()
-{
-}
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridCellAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 XULTreeGridCellAccessible::
   XULTreeGridCellAccessible(nsIContent* aContent, DocAccessible* aDoc,
                             XULTreeGridRowAccessible* aRowAcc,
--- a/accessible/xul/XULTreeGridAccessible.h
+++ b/accessible/xul/XULTreeGridAccessible.h
@@ -92,19 +92,16 @@ public:
   // XULTreeItemAccessibleBase
   virtual XULTreeGridCellAccessible* GetCellAccessible(nsITreeColumn* aColumn)
     const override final;
   virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx) override;
 
 protected:
   virtual ~XULTreeGridRowAccessible();
 
-  // Accessible
-  virtual void CacheChildren() override;
-
   // XULTreeItemAccessibleBase
   mutable nsRefPtrHashtable<nsPtrHashKey<const void>, XULTreeGridCellAccessible>
     mAccessibleCache;
 };
 
 
 /**
  * Represents an accessible for XUL tree cell in the case when XUL tree has