Bug 1466727 part 4. Stop using nsITreeColumn in accessibility code. r=surkov
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 05 Jun 2018 23:01:37 -0400
changeset 421562 a819042f190938ddc234eadf42b13ab871b722cf
parent 421561 55feb670e0704c0447eb9cdd2c1ce917b2949806
child 421563 3cc696a399ed28c3e00f04fdedbe601016e20764
push id34098
push usernbeleuzu@mozilla.com
push dateWed, 06 Jun 2018 17:00:32 +0000
treeherdermozilla-central@04cc917f68c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1466727
milestone62.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 1466727 part 4. Stop using nsITreeColumn in accessibility code. r=surkov
accessible/base/nsCoreUtils.cpp
accessible/base/nsCoreUtils.h
accessible/xul/XULTreeGridAccessible.cpp
--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -569,46 +569,43 @@ nsCoreUtils::GetSensibleColumnAt(nsITree
     idx--;
     column = GetNextSensibleColumn(column);
   }
 
   return nullptr;
 }
 
 already_AddRefed<nsTreeColumn>
-nsCoreUtils::GetNextSensibleColumn(nsITreeColumn *aColumn)
+nsCoreUtils::GetNextSensibleColumn(nsTreeColumn* aColumn)
 {
-  RefPtr<nsTreeColumn> nextColumn;
-  aColumn->GetNext(getter_AddRefs(nextColumn));
+  RefPtr<nsTreeColumn> nextColumn = aColumn->GetNext();
 
   while (nextColumn && IsColumnHidden(nextColumn)) {
     nextColumn = nextColumn->GetNext();
   }
 
   return nextColumn.forget();
 }
 
 already_AddRefed<nsTreeColumn>
-nsCoreUtils::GetPreviousSensibleColumn(nsITreeColumn *aColumn)
+nsCoreUtils::GetPreviousSensibleColumn(nsTreeColumn* aColumn)
 {
-  RefPtr<nsTreeColumn> prevColumn;
-  aColumn->GetPrevious(getter_AddRefs(prevColumn));
+  RefPtr<nsTreeColumn> prevColumn = aColumn->GetPrevious();
 
   while (prevColumn && IsColumnHidden(prevColumn)) {
     prevColumn = prevColumn->GetPrevious();
   }
 
   return prevColumn.forget();
 }
 
 bool
-nsCoreUtils::IsColumnHidden(nsITreeColumn *aColumn)
+nsCoreUtils::IsColumnHidden(nsTreeColumn* aColumn)
 {
-  RefPtr<Element> element;
-  aColumn->GetElement(getter_AddRefs(element));
+  Element* element = aColumn->Element();
   return element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
                               nsGkAtoms::_true, eCaseMatters);
 }
 
 void
 nsCoreUtils::ScrollTo(nsIPresShell* aPresShell, nsIContent* aContent,
                       uint32_t aScrollType)
 {
--- a/accessible/base/nsCoreUtils.h
+++ b/accessible/base/nsCoreUtils.h
@@ -16,17 +16,16 @@
 #include "nsPoint.h"
 #include "nsTArray.h"
 
 class nsRange;
 class nsTreeColumn;
 class nsIBoxObject;
 class nsIFrame;
 class nsIDocShell;
-class nsITreeColumn;
 class nsITreeBoxObject;
 class nsIWidget;
 
 /**
  * Core utils.
  */
 class nsCoreUtils
 {
@@ -263,28 +262,28 @@ public:
    */
   static already_AddRefed<nsTreeColumn>
     GetSensibleColumnAt(nsITreeBoxObject *aTree, uint32_t aIndex);
 
   /**
    * Return next sensible column for the given column.
    */
   static already_AddRefed<nsTreeColumn>
-    GetNextSensibleColumn(nsITreeColumn *aColumn);
+    GetNextSensibleColumn(nsTreeColumn *aColumn);
 
   /**
    * Return previous sensible column for the given column.
    */
   static already_AddRefed<nsTreeColumn>
-    GetPreviousSensibleColumn(nsITreeColumn *aColumn);
+    GetPreviousSensibleColumn(nsTreeColumn *aColumn);
 
   /**
    * Return true if the given column is hidden (i.e. not sensible).
    */
-  static bool IsColumnHidden(nsITreeColumn *aColumn);
+  static bool IsColumnHidden(nsTreeColumn *aColumn);
 
   /**
    * Scroll content into view.
    */
   static void ScrollTo(nsIPresShell* aPresShell, nsIContent* aContent,
                        uint32_t aScrollType);
 
   /**
--- a/accessible/xul/XULTreeGridAccessible.cpp
+++ b/accessible/xul/XULTreeGridAccessible.cpp
@@ -17,16 +17,17 @@
 #include "nsTreeColumns.h"
 
 #include "nsIBoxObject.h"
 #include "nsIMutableArray.h"
 #include "nsIPersistentProperties2.h"
 #include "nsITreeSelection.h"
 #include "nsComponentManagerUtils.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/TreeColumnBinding.h"
 
 using namespace mozilla::a11y;
 using namespace mozilla;
 
 XULTreeGridAccessible::~XULTreeGridAccessible()
 {
 }
 
@@ -425,19 +426,17 @@ XULTreeGridCellAccessible::
   mTreeView(aTreeView), mRow(aRow), mColumn(aColumn)
 {
   mParent = aRowAcc;
   mStateFlags |= eSharedNode;
   mGenericTypes |= eTableCell;
 
   NS_ASSERTION(mTreeView, "mTreeView is null");
 
-  int16_t type = -1;
-  mColumn->GetType(&type);
-  if (type == nsITreeColumn::TYPE_CHECKBOX)
+  if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX)
     mTreeView->GetCellValue(mRow, mColumn, mCachedTextEquiv);
   else
     mTreeView->GetCellText(mRow, mColumn, mCachedTextEquiv);
 }
 
 XULTreeGridCellAccessible::~XULTreeGridCellAccessible()
 {
 }
@@ -531,72 +530,62 @@ XULTreeGridCellAccessible::BoundsInAppUn
                 presContext->CSSPixelsToAppUnits(bounds.Y()),
                 presContext->CSSPixelsToAppUnits(bounds.Width()),
                 presContext->CSSPixelsToAppUnits(bounds.Height()));
 }
 
 uint8_t
 XULTreeGridCellAccessible::ActionCount() const
 {
-  bool isCycler = false;
-  mColumn->GetCycler(&isCycler);
-  if (isCycler)
+  if (mColumn->Cycler())
     return 1;
 
-  int16_t type;
-  mColumn->GetType(&type);
-  if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable())
+  if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX && IsEditable())
     return 1;
 
   return 0;
 }
 
 void
 XULTreeGridCellAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
 
   if (aIndex != eAction_Click || !mTreeView)
     return;
 
-  bool isCycler = false;
-  mColumn->GetCycler(&isCycler);
-  if (isCycler) {
+  if (mColumn->Cycler()) {
     aName.AssignLiteral("cycle");
     return;
   }
 
-  int16_t type = 0;
-  mColumn->GetType(&type);
-  if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
+  if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX &&
+      IsEditable()) {
     nsAutoString value;
     mTreeView->GetCellValue(mRow, mColumn, value);
     if (value.EqualsLiteral("true"))
       aName.AssignLiteral("uncheck");
     else
       aName.AssignLiteral("check");
   }
 }
 
 bool
 XULTreeGridCellAccessible::DoAction(uint8_t aIndex) const
 {
   if (aIndex != eAction_Click)
     return false;
 
-  bool isCycler = false;
-  mColumn->GetCycler(&isCycler);
-  if (isCycler) {
+  if (mColumn->Cycler()) {
     DoCommand();
     return true;
   }
 
-  int16_t type;
-  mColumn->GetType(&type);
-  if (type == nsITreeColumn::TYPE_CHECKBOX && IsEditable()) {
+  if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX &&
+      IsEditable()) {
     DoCommand();
     return true;
   }
 
   return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -627,18 +616,17 @@ uint32_t
 XULTreeGridCellAccessible::RowIdx() const
 {
   return mRow;
 }
 
 void
 XULTreeGridCellAccessible::ColHeaderCells(nsTArray<Accessible*>* aHeaderCells)
 {
-  RefPtr<dom::Element> columnElm;
-  mColumn->GetElement(getter_AddRefs(columnElm));
+  dom::Element* columnElm = mColumn->Element();
 
   Accessible* headerCell = mDoc->GetAccessible(columnElm);
   if (headerCell)
     aHeaderCells->AppendElement(headerCell);
 }
 
 bool
 XULTreeGridCellAccessible::Selected()
@@ -666,19 +654,17 @@ XULTreeGridCellAccessible::NativeAttribu
   if (!table)
     return attributes.forget();
 
   nsAutoString stringIdx;
   stringIdx.AppendInt(table->CellIndexAt(mRow, ColIdx()));
   nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);
 
   // "cycles" attribute
-  bool isCycler = false;
-  nsresult rv = mColumn->GetCycler(&isCycler);
-  if (NS_SUCCEEDED(rv) && isCycler)
+  if (mColumn->Cycler())
     nsAccUtils::SetAccAttr(attributes, nsGkAtoms::cycles,
                            NS_LITERAL_STRING("true"));
 
   return attributes.forget();
 }
 
 role
 XULTreeGridCellAccessible::NativeRole() const
@@ -700,19 +686,17 @@ XULTreeGridCellAccessible::NativeState()
   if (selection) {
     bool isSelected = false;
     selection->IsSelected(mRow, &isSelected);
     if (isSelected)
       states |= states::SELECTED;
   }
 
   // checked state
-  int16_t type;
-  mColumn->GetType(&type);
-  if (type == nsITreeColumn::TYPE_CHECKBOX) {
+  if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX) {
     states |= states::CHECKABLE;
     nsAutoString checked;
     mTreeView->GetCellValue(mRow, mColumn, checked);
     if (checked.EqualsIgnoreCase("true"))
       states |= states::CHECKED;
   }
 
   return states;
@@ -740,19 +724,17 @@ XULTreeGridCellAccessible::RelationByTyp
 // XULTreeGridCellAccessible: public implementation
 
 bool
 XULTreeGridCellAccessible::CellInvalidated()
 {
 
   nsAutoString textEquiv;
 
-  int16_t type;
-  mColumn->GetType(&type);
-  if (type == nsITreeColumn::TYPE_CHECKBOX) {
+  if (mColumn->Type() == dom::TreeColumnBinding::TYPE_CHECKBOX) {
     mTreeView->GetCellValue(mRow, mColumn, textEquiv);
     if (mCachedTextEquiv != textEquiv) {
       bool isEnabled = textEquiv.EqualsLiteral("true");
       RefPtr<AccEvent> accEvent =
         new AccStateChangeEvent(this, states::CHECKED, isEnabled);
       nsEventShell::FireEvent(accEvent);
 
       mCachedTextEquiv = textEquiv;
@@ -821,20 +803,17 @@ XULTreeGridCellAccessible::IsEditable() 
 
   // XXX: logic corresponds to tree.xml, it's preferable to have interface
   // method to check it.
   bool isEditable = false;
   nsresult rv = mTreeView->IsEditable(mRow, mColumn, &isEditable);
   if (NS_FAILED(rv) || !isEditable)
     return false;
 
-  RefPtr<dom::Element> columnElm;
-  mColumn->GetElement(getter_AddRefs(columnElm));
-  if (!columnElm)
-    return false;
+  dom::Element* columnElm = mColumn->Element();
 
   if (!columnElm->AttrValueIs(kNameSpaceID_None,
                               nsGkAtoms::editable,
                               nsGkAtoms::_true,
                               eCaseMatters))
     return false;
 
   return mContent->AsElement()->AttrValueIs(kNameSpaceID_None,