Bug 1260862 - "remove Cache/EnsureChildren". r=mzehe
authoralexander <surkov.alexander>
Wed, 30 Mar 2016 12:53:00 +0200
changeset 347731 725a9dc9e9bf0dedbbfabe8481b28eaad329ac46
parent 347730 954444d01cd10f263850121c87c706ca65682cd3
child 347732 f001332ad789062c28a73f0bef1ace98569c5d50
push id14653
push userolivier@olivieryiptong.com
push dateTue, 05 Apr 2016 19:21:01 +0000
reviewersmzehe
bugs1260862
milestone48.0a1
Bug 1260862 - "remove Cache/EnsureChildren". r=mzehe
accessible/generic/Accessible.cpp
accessible/generic/Accessible.h
accessible/html/HTMLListAccessible.cpp
accessible/html/HTMLListAccessible.h
accessible/html/HTMLTableAccessible.cpp
accessible/xul/XULElementAccessibles.cpp
accessible/xul/XULElementAccessibles.h
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -2514,30 +2514,16 @@ Accessible::LastRelease()
     NS_ASSERTION(!mDoc,
                  "A Shutdown() impl forgot to call its parent's Shutdown?");
   }
   // ... then die.
   delete this;
 }
 
 void
-Accessible::CacheChildren()
-{
-  NS_ENSURE_TRUE_VOID(Document());
-
-  AutoTreeMutation mt(this);
-  TreeWalker walker(this);
-  Accessible* child = nullptr;
-  while ((child = walker.Next()) && AppendChild(child)) {
-    mt.AfterInsertion(child);
-  }
-  mt.Done();
-}
-
-void
 Accessible::TestChildCache(Accessible* aCachedChild) const
 {
 #ifdef DEBUG
   int32_t childCount = mChildren.Length();
   if (childCount == 0) {
     NS_ASSERTION(IsChildrenFlag(eChildrenUninitialized),
                  "No children but initialized!");
     return;
@@ -2550,31 +2536,16 @@ Accessible::TestChildCache(Accessible* a
       break;
   }
 
   NS_ASSERTION(child == aCachedChild,
                "[TestChildCache] cached accessible wasn't found. Wrong accessible tree!");
 #endif
 }
 
-void
-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
-  if (KidsFromDOM()) {
-    CacheChildren();
-  }
-}
-
 Accessible*
 Accessible::GetSiblingAtOffset(int32_t aOffset, nsresult* aError) const
 {
   if (!mParent || mIndexInParent == -1) {
     if (aError)
       *aError = NS_ERROR_UNEXPECTED;
 
     return nullptr;
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -371,21 +371,16 @@ public:
 
   /**
    * Set the ARIA role map entry for a new accessible.
    */
   void SetRoleMapEntry(const nsRoleMapEntry* aRoleMapEntry)
     { mRoleMapEntry = aRoleMapEntry; }
 
   /**
-   * Cache children if necessary.
-   */
-  void EnsureChildren();
-
-  /**
    * Append/insert/remove a child. Return true if operation was successful.
    */
   bool AppendChild(Accessible* aChild)
     { return InsertChildAt(mChildren.Length(), aChild); }
   virtual bool InsertChildAt(uint32_t aIndex, Accessible* aChild);
 
   bool InsertAfter(Accessible* aNewChild, Accessible* aRefChild)
   {
@@ -979,21 +974,16 @@ protected:
   // Initializing, cache and tree traverse methods
 
   /**
    * Destroy the object.
    */
   void LastRelease();
 
   /**
-   * Cache accessible children.
-   */
-  virtual void CacheChildren();
-
-  /**
    * Set accessible parent and index in parent.
    */
   void BindToParent(Accessible* aParent, uint32_t aIndexInParent);
   void UnbindFromParent();
 
   /**
    * Return sibling accessible at the given offset.
    */
--- a/accessible/html/HTMLListAccessible.cpp
+++ b/accessible/html/HTMLListAccessible.cpp
@@ -126,29 +126,16 @@ HTMLLIAccessible::UpdateBullet(bool aHas
     mBullet = nullptr;
   }
   mt.Done();
 
   mDoc->FireDelayedEvent(reorderEvent);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-// HTMLLIAccessible: Accessible protected
-
-void
-HTMLLIAccessible::CacheChildren()
-{
-  if (mBullet)
-    AppendChild(mBullet);
-
-  // Cache children from subtree.
-  AccessibleWrap::CacheChildren();
-}
-
-////////////////////////////////////////////////////////////////////////////////
 // HTMLListBulletAccessible
 ////////////////////////////////////////////////////////////////////////////////
 HTMLListBulletAccessible::
   HTMLListBulletAccessible(nsIContent* aContent, DocAccessible* aDoc) :
   LeafAccessible(aContent, aDoc)
 {
   mStateFlags |= eSharedNode;
 }
--- a/accessible/html/HTMLListAccessible.h
+++ b/accessible/html/HTMLListAccessible.h
@@ -55,19 +55,16 @@ public:
 
   // HTMLLIAccessible
   HTMLListBulletAccessible* Bullet() const { return mBullet; }
   void UpdateBullet(bool aHasBullet);
 
 protected:
   virtual ~HTMLLIAccessible() { }
 
-  // Accessible
-  virtual void CacheChildren() override;
-
 private:
   RefPtr<HTMLListBulletAccessible> mBullet;
 };
 
 
 /**
  * Used for bullet of HTML list item element (for example, HTML li).
  */
--- a/accessible/html/HTMLTableAccessible.cpp
+++ b/accessible/html/HTMLTableAccessible.cpp
@@ -907,17 +907,17 @@ HTMLTableAccessible::HasDescendant(const
     return true;
 
   // If we found more than one node then return true not depending on
   // aAllowEmpty flag.
   // XXX it might be dummy but bug 501375 where we changed this addresses
   // performance problems only. Note, currently 'aAllowEmpty' flag is used for
   // caption element only. On another hand we create accessible object for
   // the first entry of caption element (see
-  // HTMLTableAccessible::CacheChildren).
+  // HTMLTableAccessible::InsertChildAt).
   return !!elements->Item(1);
 }
 
 bool
 HTMLTableAccessible::IsProbablyLayoutTable()
 {
   // Implement a heuristic to determine if table is most likely used for layout
   // XXX do we want to look for rowspan or colspan, especialy that span all but a couple cells
--- a/accessible/xul/XULElementAccessibles.cpp
+++ b/accessible/xul/XULElementAccessibles.cpp
@@ -116,28 +116,16 @@ XULLabelAccessible::UpdateLabelValue(con
                       NS_ConvertUTF16toUTF8(aValue).get());
     logging::MsgEnd();
   }
 #endif
 
   TextUpdater::Run(mDoc, mValueTextLeaf, aValue);
 }
 
-void
-XULLabelAccessible::CacheChildren()
-{
-  if (mValueTextLeaf) {
-    AppendChild(mValueTextLeaf);
-    return;
-  }
-
-  // Cache children from subtree.
-  AccessibleWrap::CacheChildren();
-}
-
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULLabelTextLeafAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 role
 XULLabelTextLeafAccessible::NativeRole()
 {
--- a/accessible/xul/XULElementAccessibles.h
+++ b/accessible/xul/XULElementAccessibles.h
@@ -28,17 +28,16 @@ public:
   virtual uint64_t NativeState() override;
   virtual Relation RelationByType(RelationType aType) override;
 
   void UpdateLabelValue(const nsString& aValue);
 
 protected:
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) override;
-  virtual void CacheChildren() override;
 
 private:
   RefPtr<XULLabelTextLeafAccessible> mValueTextLeaf;
 };
 
 inline XULLabelAccessible*
 Accessible::AsXULLabel()
 {