Bug 1260237 - remove InvalidateChildren, r=yzen
authorAlexander Surkov <surkov.alexander@gmail.com>
Thu, 31 Mar 2016 20:46:58 -0400
changeset 291164 18963f8a2c46048c8c45f330799af71b118e34c6
parent 291163 7a2b0755a6bacd831ea28e0bc3499a11a0acac63
child 291165 0d7b5a4fbffa4df34440e19c04e5628060315576
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)
reviewersyzen
bugs1260237
milestone48.0a1
Bug 1260237 - remove InvalidateChildren, r=yzen
accessible/base/EventQueue.cpp
accessible/generic/Accessible.cpp
accessible/generic/Accessible.h
accessible/generic/ApplicationAccessible.cpp
accessible/generic/ApplicationAccessible.h
accessible/generic/HyperTextAccessible.cpp
accessible/generic/HyperTextAccessible.h
accessible/generic/OuterDocAccessible.cpp
accessible/generic/OuterDocAccessible.h
accessible/html/HTMLSelectAccessible.cpp
accessible/html/HTMLSelectAccessible.h
accessible/mac/AccessibleWrap.h
accessible/mac/AccessibleWrap.mm
--- a/accessible/base/EventQueue.cpp
+++ b/accessible/base/EventQueue.cpp
@@ -259,20 +259,18 @@ EventQueue::CoalesceReorderEvents(AccEve
     //   then ignore thisEvent and its show and hide events
     //   otherwise ignore thisEvent but not its show and hide events
     Accessible* thisParent = thisEvent->mAccessible;
     while (thisParent && thisParent != mDocument) {
       if (thisParent->Parent() == aTailEvent->mAccessible) {
         AccReorderEvent* tailReorder = downcast_accEvent(aTailEvent);
         uint32_t eventType = tailReorder->IsShowHideEventTarget(thisParent);
 
-        // Sometimes InvalidateChildren() and
-        // DocAccessible::CacheChildrenInSubtree() can conspire to reparent an
-        // accessible in this case no need for mutation events.  Se bug 883708
-        // for details.
+        // It can be either hide or show events which may occur because of
+        // accessible reparenting.
         if (eventType == nsIAccessibleEvent::EVENT_SHOW ||
             eventType == nsIAccessibleEvent::EVENT_HIDE) {
           AccReorderEvent* thisReorder = downcast_accEvent(thisEvent);
           thisReorder->DoNotEmitAll();
         } else {
           thisEvent->mEventRule = AccEvent::eDoNotEmit;
         }
 
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -1876,17 +1876,24 @@ Accessible::AppendTextTo(nsAString& aTex
 
 void
 Accessible::Shutdown()
 {
   // Mark the accessible as defunct, invalidate the child count and pointers to
   // other accessibles, also make sure none of its children point to this parent
   mStateFlags |= eIsDefunct;
 
-  InvalidateChildren();
+  int32_t childCount = mChildren.Length();
+  for (int32_t childIdx = 0; childIdx < childCount; childIdx++) {
+    mChildren.ElementAt(childIdx)->UnbindFromParent();
+  }
+  mChildren.Clear();
+
+  mEmbeddedObjCollector = nullptr;
+
   if (mParent)
     mParent->RemoveChild(this);
 
   mContent = nullptr;
   mDoc = nullptr;
   if (SelectionMgr() && SelectionMgr()->AccessibleWithCaret(nullptr) == this)
     SelectionMgr()->ResetCaretOffset();
 }
@@ -2064,29 +2071,16 @@ Accessible::Language(nsAString& aLanguag
 
   nsCoreUtils::GetLanguageFor(mContent, nullptr, aLanguage);
   if (aLanguage.IsEmpty()) { // Nothing found, so use document's language
     mDoc->DocumentNode()->GetHeaderData(nsGkAtoms::headerContentLanguage,
                                         aLanguage);
   }
 }
 
-void
-Accessible::InvalidateChildren()
-{
-  int32_t childCount = mChildren.Length();
-  for (int32_t childIdx = 0; childIdx < childCount; childIdx++) {
-    mChildren.ElementAt(childIdx)->UnbindFromParent();
-  }
-
-  mEmbeddedObjCollector = nullptr;
-  mChildren.Clear();
-  SetChildrenFlag(eChildrenUninitialized);
-}
-
 bool
 Accessible::InsertChildAt(uint32_t aIndex, Accessible* aChild)
 {
   if (!aChild)
     return false;
 
   if (aIndex == mChildren.Length()) {
     if (!mChildren.AppendElement(aChild))
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -376,24 +376,16 @@ public:
     { mRoleMapEntry = aRoleMapEntry; }
 
   /**
    * Cache children if necessary.
    */
   void EnsureChildren();
 
   /**
-   * Set the child count to -1 (unknown) and null out cached child pointers.
-   * Should be called when accessible tree is changed because document has
-   * transformed. Note, if accessible cares about its parent relation chain
-   * itself should override this method to do nothing.
-   */
-  virtual void InvalidateChildren();
-
-  /**
    * 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)
   {
--- a/accessible/generic/ApplicationAccessible.cpp
+++ b/accessible/generic/ApplicationAccessible.cpp
@@ -144,23 +144,16 @@ ApplicationAccessible::NativeRole()
 }
 
 uint64_t
 ApplicationAccessible::NativeState()
 {
   return 0;
 }
 
-void
-ApplicationAccessible::InvalidateChildren()
-{
-  // Do nothing because application children are kept updated by AppendChild()
-  // and RemoveChild() method calls.
-}
-
 KeyBinding
 ApplicationAccessible::AccessKey() const
 {
   return KeyBinding();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Accessible protected methods
--- a/accessible/generic/ApplicationAccessible.h
+++ b/accessible/generic/ApplicationAccessible.h
@@ -47,18 +47,16 @@ public:
   virtual uint64_t State() override;
   virtual uint64_t NativeState() override;
   virtual Relation RelationByType(RelationType aType) override;
 
   virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
                                    EWhichChildAtPoint aWhichChild) override;
   virtual Accessible* FocusedChild() override;
 
-  virtual void InvalidateChildren() override;
-
   // ActionAccessible
   virtual KeyBinding AccessKey() const override;
 
   // ApplicationAccessible
   void AppName(nsAString& aName) const
   {
     nsAutoCString cname;
     mAppInfo->GetName(cname);
--- a/accessible/generic/HyperTextAccessible.cpp
+++ b/accessible/generic/HyperTextAccessible.cpp
@@ -1884,21 +1884,20 @@ HyperTextAccessible::NativeName(nsString
   if (IsAbbreviation() &&
       mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, aName))
     aName.CompressWhitespace();
 
   return hasImgAlt ? eNoNameOnPurpose : eNameOK;
 }
 
 void
-HyperTextAccessible::InvalidateChildren()
+HyperTextAccessible::Shutdown()
 {
   mOffsets.Clear();
-
-  AccessibleWrap::InvalidateChildren();
+  AccessibleWrap::Shutdown();
 }
 
 bool
 HyperTextAccessible::RemoveChild(Accessible* aAccessible)
 {
   int32_t childIndex = aAccessible->IndexInParent();
   int32_t count = mOffsets.Length() - childIndex;
   if (count > 0)
--- a/accessible/generic/HyperTextAccessible.h
+++ b/accessible/generic/HyperTextAccessible.h
@@ -55,17 +55,17 @@ public:
 
   // Accessible
   virtual nsIAtom* LandmarkRole() const override;
   virtual int32_t GetLevelInternal() override;
   virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
   virtual mozilla::a11y::role NativeRole() override;
   virtual uint64_t NativeState() override;
 
-  virtual void InvalidateChildren() override;
+  virtual void Shutdown() override;
   virtual bool RemoveChild(Accessible* aAccessible) override;
   virtual Relation RelationByType(RelationType aType) override;
 
   // HyperTextAccessible (static helper method)
 
   // Convert content offset to rendered text offset
   nsresult ContentToRenderedOffset(nsIFrame *aFrame, int32_t aContentOffset,
                                    uint32_t *aRenderedOffset) const;
--- a/accessible/generic/OuterDocAccessible.cpp
+++ b/accessible/generic/OuterDocAccessible.cpp
@@ -96,31 +96,16 @@ OuterDocAccessible::Shutdown()
 #endif
     RemoveChild(child);
     mDoc->BindChildDocument(child->AsDoc());
   }
 
   AccessibleWrap::Shutdown();
 }
 
-void
-OuterDocAccessible::InvalidateChildren()
-{
-  // Do not invalidate children because DocManager is responsible for
-  // document accessible lifetime when DOM document is created or destroyed. If
-  // DOM document isn't destroyed but its presshell is destroyed (for example,
-  // when DOM node of outerdoc accessible is hidden), then outerdoc accessible
-  // notifies DocManager about this. If presshell is created for existing
-  // DOM document (for example when DOM node of outerdoc accessible is shown)
-  // then allow DocManager to handle this case since the document
-  // accessible is created and appended as a child when it's requested.
-
-  SetChildrenFlag(eChildrenUninitialized);
-}
-
 bool
 OuterDocAccessible::InsertChildAt(uint32_t aIdx, Accessible* aAccessible)
 {
   NS_ASSERTION(aAccessible->IsDoc(),
                "OuterDocAccessible should only have document child!");
   // We keep showing the old document for a bit after creating the new one,
   // and while building the new DOM and frame tree. That's done on purpose
   // to avoid weird flashes of default background color.
--- a/accessible/generic/OuterDocAccessible.h
+++ b/accessible/generic/OuterDocAccessible.h
@@ -31,17 +31,16 @@ public:
   ProxyAccessible* RemoteChildDoc() const;
 
   // Accessible
   virtual void Shutdown() override;
   virtual mozilla::a11y::role NativeRole() override;
   virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
                                    EWhichChildAtPoint aWhichChild) override;
 
-  virtual void InvalidateChildren() override;
   virtual bool InsertChildAt(uint32_t aIdx, Accessible* aChild) override;
   virtual bool RemoveChild(Accessible* aAccessible) override;
 
 protected:
   virtual ~OuterDocAccessible() override;
 
   // Accessible
   virtual void CacheChildren() override;
--- a/accessible/html/HTMLSelectAccessible.cpp
+++ b/accessible/html/HTMLSelectAccessible.cpp
@@ -343,25 +343,16 @@ HTMLComboboxAccessible::
 // HTMLComboboxAccessible: Accessible
 
 role
 HTMLComboboxAccessible::NativeRole()
 {
   return roles::COMBOBOX;
 }
 
-void
-HTMLComboboxAccessible::InvalidateChildren()
-{
-  AccessibleWrap::InvalidateChildren();
-
-  if (mListAccessible)
-    mListAccessible->InvalidateChildren();
-}
-
 bool
 HTMLComboboxAccessible::RemoveChild(Accessible* aChild)
 {
   MOZ_ASSERT(aChild == mListAccessible);
   if (AccessibleWrap::RemoveChild(aChild)) {
     mListAccessible = nullptr;
     return true;
   }
@@ -392,17 +383,20 @@ HTMLComboboxAccessible::CacheChildren()
     mListAccessible->EnsureChildren();
   }
 }
 
 void
 HTMLComboboxAccessible::Shutdown()
 {
   MOZ_ASSERT(mDoc->IsDefunct() || !mListAccessible);
-  mListAccessible = nullptr;
+  if (mListAccessible) {
+    mListAccessible->Shutdown();
+    mListAccessible = nullptr;
+  }
 
   AccessibleWrap::Shutdown();
 }
 
 uint64_t
 HTMLComboboxAccessible::NativeState()
 {
   // As a HTMLComboboxAccessible we can have the following states:
--- a/accessible/html/HTMLSelectAccessible.h
+++ b/accessible/html/HTMLSelectAccessible.h
@@ -163,17 +163,16 @@ public:
   virtual ~HTMLComboboxAccessible() {}
 
   // Accessible
   virtual void Shutdown() override;
   virtual void Description(nsString& aDescription) override;
   virtual void Value(nsString& aValue) override;
   virtual a11y::role NativeRole() override;
   virtual uint64_t NativeState() override;
-  virtual void InvalidateChildren() override;
   virtual bool RemoveChild(Accessible* aChild) override;
 
   // ActionAccessible
   virtual uint8_t ActionCount() override;
   virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
   virtual bool DoAction(uint8_t aIndex) override;
 
   // Widgets
--- a/accessible/mac/AccessibleWrap.h
+++ b/accessible/mac/AccessibleWrap.h
@@ -41,17 +41,16 @@ public: // construction, destruction
   /**
    * The objective-c |Class| type that this accessible's native object
    * should be instantied with.   used on runtime to determine the
    * right type for this accessible's associated native object.
    */
   virtual Class GetNativeType ();
 
   virtual void Shutdown () override;
-  virtual void InvalidateChildren() override;
 
   virtual bool InsertChildAt(uint32_t aIdx, Accessible* aChild) override;
   virtual bool RemoveChild(Accessible* aAccessible) override;
 
   virtual nsresult HandleAccEvent(AccEvent* aEvent) override;
 
   /**
    * Ignored means that the accessible might still have children, but is not
--- a/accessible/mac/AccessibleWrap.mm
+++ b/accessible/mac/AccessibleWrap.mm
@@ -130,28 +130,16 @@ AccessibleWrap::HandleAccEvent(AccEvent*
 
   FireNativeEvent(nativeAcc, eventType);
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
-void
-AccessibleWrap::InvalidateChildren()
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  [GetNativeObject() invalidateChildren];
-
-  Accessible::InvalidateChildren();
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
 bool
 AccessibleWrap::InsertChildAt(uint32_t aIdx, Accessible* aAccessible)
 {
   bool inserted = Accessible::InsertChildAt(aIdx, aAccessible);
   if (inserted && mNativeObject)
     [mNativeObject appendChild:aAccessible];
 
   return inserted;