Bug 1466673 part 5. Remove the nsITreeColumns interface. r=mossop
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 05 Jun 2018 13:30:17 -0400
changeset 421350 2628bc75afae2cec4756c3808f395872e5eb8806
parent 421349 2095e4b302d2536b79be7cb7efe0356615a739fd
child 421351 ef1dd76af6f97b337a219e119e874f49b278aea6
push id104034
push userbzbarsky@mozilla.com
push dateTue, 05 Jun 2018 17:31:52 +0000
treeherdermozilla-inbound@2628bc75afae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1466673
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 1466673 part 5. Remove the nsITreeColumns interface. r=mossop
layout/xul/tree/nsITreeColumns.idl
layout/xul/tree/nsTreeColFrame.h
layout/xul/tree/nsTreeColumns.cpp
layout/xul/tree/nsTreeColumns.h
--- a/layout/xul/tree/nsITreeColumns.idl
+++ b/layout/xul/tree/nsITreeColumns.idl
@@ -32,62 +32,8 @@ interface nsITreeColumn : nsISupports
   const short TYPE_PASSWORD            = 3;
   readonly attribute short type;
 
   nsITreeColumn getNext();
   nsITreeColumn getPrevious();
 
   void invalidate();
 };
-
-interface nsITreeBoxObject;
-
-[scriptable, builtinclass, uuid(f8a8d6b4-6788-438d-9009-7142798767ab)]
-interface nsITreeColumns : nsISupports
-{
-  /**
-   * The tree widget for these columns.
-   */
-  readonly attribute nsITreeBoxObject tree;
-
-  /**
-   * The number of columns.
-   */
-  readonly attribute long count;
-
-  /**
-   * An alias for count (for the benefit of scripts which treat this as an
-   * array).
-   */
-  readonly attribute long length;
-
-  /**
-   * Get the first/last column.
-   */
-  nsITreeColumn getFirstColumn();
-  nsITreeColumn getLastColumn();
-
-  /**
-   * Attribute based column getters.
-   */
-  nsITreeColumn getPrimaryColumn();
-  nsITreeColumn getSortedColumn();
-  nsITreeColumn getKeyColumn();
-
-  /**
-   * Get the column for the given element.
-   */
-  nsITreeColumn getColumnFor(in Element element);
-
-  /**
-   * Parametric column getters.
-   */
-  nsITreeColumn getNamedColumn(in AString id);
-  nsITreeColumn getColumnAt(in long index);
-
-  /**
-   * This method is called whenever a treecol is added or removed and
-   * the column cache needs to be rebuilt.
-   */
-  void invalidateColumns();
-
-  void restoreNaturalOrder();
-};
--- a/layout/xul/tree/nsTreeColFrame.h
+++ b/layout/xul/tree/nsTreeColFrame.h
@@ -43,13 +43,13 @@ protected:
   virtual ~nsTreeColFrame();
 
   /**
    * @return the tree box object of the tree this column belongs to, or nullptr.
    */
   nsITreeBoxObject* GetTreeBoxObject();
 
   /**
-   * Helper method that gets the nsITreeColumns object this column belongs to
+   * Helper method that gets the TreeColumns object this column belongs to
    * and calls InvalidateColumns() on it.
    */
   void InvalidateColumns(bool aCanWalkFrameTree = true);
 };
--- a/layout/xul/tree/nsTreeColumns.cpp
+++ b/layout/xul/tree/nsTreeColumns.cpp
@@ -399,17 +399,16 @@ nsTreeColumns::~nsTreeColumns()
   nsTreeColumns::InvalidateColumns();
 }
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(nsTreeColumns)
 
 // QueryInterface implementation for nsTreeColumns
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeColumns)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsITreeColumns)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTreeColumns)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTreeColumns)
 
 nsIContent*
 nsTreeColumns::GetParentObject() const
@@ -424,105 +423,56 @@ nsTreeColumns::WrapObject(JSContext* aCx
 }
 
 dom::TreeBoxObject*
 nsTreeColumns::GetTree() const
 {
   return mTree ? static_cast<mozilla::dom::TreeBoxObject*>(mTree->GetTreeBoxObject()) : nullptr;
 }
 
-NS_IMETHODIMP
-nsTreeColumns::GetTree(nsITreeBoxObject** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetTree());
-  return NS_OK;
-}
-
 uint32_t
 nsTreeColumns::Count()
 {
   EnsureColumns();
   uint32_t count = 0;
   for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
     ++count;
   }
   return count;
 }
 
-NS_IMETHODIMP
-nsTreeColumns::GetCount(int32_t* _retval)
-{
-  *_retval = Count();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumns::GetLength(int32_t* _retval)
-{
-  *_retval = Length();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumns::GetFirstColumn(nsITreeColumn** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetFirstColumn());
-  return NS_OK;
-}
-
 nsTreeColumn*
 nsTreeColumns::GetLastColumn()
 {
   EnsureColumns();
   nsTreeColumn* currCol = mFirstColumn;
   while (currCol) {
     nsTreeColumn* next = currCol->GetNext();
     if (!next) {
       return currCol;
     }
     currCol = next;
   }
   return nullptr;
 }
 
-NS_IMETHODIMP
-nsTreeColumns::GetLastColumn(nsITreeColumn** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetLastColumn());
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumns::GetPrimaryColumn(nsITreeColumn** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetPrimaryColumn());
-  return NS_OK;
-}
-
 nsTreeColumn*
 nsTreeColumns::GetSortedColumn()
 {
   EnsureColumns();
   for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
     if (currCol->mContent &&
         nsContentUtils::HasNonEmptyAttr(currCol->mContent, kNameSpaceID_None,
                                         nsGkAtoms::sortDirection)) {
       return currCol;
     }
   }
   return nullptr;
 }
 
-NS_IMETHODIMP
-nsTreeColumns::GetSortedColumn(nsITreeColumn** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetSortedColumn());
-  return NS_OK;
-}
-
 nsTreeColumn*
 nsTreeColumns::GetKeyColumn()
 {
   EnsureColumns();
 
   nsTreeColumn* first = nullptr;
   nsTreeColumn* primary = nullptr;
   nsTreeColumn* sorted = nullptr;
@@ -557,42 +507,28 @@ nsTreeColumns::GetKeyColumn()
 
   if (sorted)
     return sorted;
   if (primary)
     return primary;
   return first;
 }
 
-NS_IMETHODIMP
-nsTreeColumns::GetKeyColumn(nsITreeColumn** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetKeyColumn());
-  return NS_OK;
-}
-
 nsTreeColumn*
 nsTreeColumns::GetColumnFor(dom::Element* aElement)
 {
   EnsureColumns();
   for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
     if (currCol->mContent == aElement) {
       return currCol;
     }
   }
   return nullptr;
 }
 
-NS_IMETHODIMP
-nsTreeColumns::GetColumnFor(dom::Element* aElement, nsITreeColumn** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetColumnFor(aElement));
-  return NS_OK;
-}
-
 nsTreeColumn*
 nsTreeColumns::NamedGetter(const nsAString& aId, bool& aFound)
 {
   EnsureColumns();
   for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
     if (currCol->GetId().Equals(aId)) {
       aFound = true;
       return currCol;
@@ -604,23 +540,16 @@ nsTreeColumns::NamedGetter(const nsAStri
 
 nsTreeColumn*
 nsTreeColumns::GetNamedColumn(const nsAString& aId)
 {
   bool dummy;
   return NamedGetter(aId, dummy);
 }
 
-NS_IMETHODIMP
-nsTreeColumns::GetNamedColumn(const nsAString& aId, nsITreeColumn** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetNamedColumn(aId));
-  return NS_OK;
-}
-
 void
 nsTreeColumns::GetSupportedNames(nsTArray<nsString>& aNames)
 {
   for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
     aNames.AppendElement(currCol->GetId());
   }
 }
 
@@ -641,47 +570,41 @@ nsTreeColumns::IndexedGetter(uint32_t aI
 
 nsTreeColumn*
 nsTreeColumns::GetColumnAt(uint32_t aIndex)
 {
   bool dummy;
   return IndexedGetter(aIndex, dummy);
 }
 
-NS_IMETHODIMP
-nsTreeColumns::GetColumnAt(int32_t aIndex, nsITreeColumn** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetColumnAt(static_cast<uint32_t>(aIndex)));
-  return NS_OK;
-}
-
-NS_IMETHODIMP
+void
 nsTreeColumns::InvalidateColumns()
 {
   for (nsTreeColumn* currCol = mFirstColumn; currCol;
        currCol = currCol->GetNext()) {
     currCol->SetColumns(nullptr);
   }
   mFirstColumn = nullptr;
-  return NS_OK;
 }
 
-NS_IMETHODIMP
+void
 nsTreeColumns::RestoreNaturalOrder()
 {
-  if (!mTree)
-    return NS_OK;
+  if (!mTree) {
+    return;
+  }
 
   nsIContent* content = mTree->GetBaseElement();
 
   // Strong ref, since we'll be setting attributes
   nsCOMPtr<nsIContent> colsContent =
     nsTreeUtils::GetImmediateChild(content, nsGkAtoms::treecols);
-  if (!colsContent)
-    return NS_OK;
+  if (!colsContent) {
+    return;
+  }
 
   int32_t i = 0;
   for (nsINode* child = colsContent->GetFirstChild();
        child; child = child->GetNextSibling()) {
     nsAutoString ordinal;
     ordinal.AppendInt(i++);
     if (child->IsElement()) {
       child->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::ordinal, ordinal,
@@ -689,17 +612,16 @@ nsTreeColumns::RestoreNaturalOrder()
     }
   }
 
   nsTreeColumns::InvalidateColumns();
 
   if (mTree) {
     mTree->Invalidate();
   }
-  return NS_OK;
 }
 
 nsTreeColumn*
 nsTreeColumns::GetPrimaryColumn()
 {
   EnsureColumns();
   for (nsTreeColumn* currCol = mFirstColumn; currCol; currCol = currCol->GetNext()) {
     if (currCol->IsPrimary()) {
--- a/layout/xul/tree/nsTreeColumns.h
+++ b/layout/xul/tree/nsTreeColumns.h
@@ -156,28 +156,27 @@ private:
   int8_t mTextAlignment;
 
   RefPtr<nsTreeColumn> mNext;
   nsTreeColumn* mPrevious;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsTreeColumn, NS_TREECOLUMN_IMPL_CID)
 
-class nsTreeColumns final : public nsITreeColumns
+class nsTreeColumns final : public nsISupports
                           , public nsWrapperCache
 {
 private:
   ~nsTreeColumns();
 
 public:
   explicit nsTreeColumns(nsTreeBodyFrame* aTree);
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsTreeColumns)
-  NS_DECL_NSITREECOLUMNS
 
   nsIContent* GetParentObject() const;
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   // WebIDL
   mozilla::dom::TreeBoxObject* GetTree() const;
   uint32_t Count();
   uint32_t Length()
@@ -195,18 +194,18 @@ public:
   nsTreeColumn* GetColumnFor(mozilla::dom::Element* aElement);
 
   nsTreeColumn* IndexedGetter(uint32_t aIndex, bool& aFound);
   nsTreeColumn* GetColumnAt(uint32_t aIndex);
   nsTreeColumn* NamedGetter(const nsAString& aId, bool& aFound);
   nsTreeColumn* GetNamedColumn(const nsAString& aId);
   void GetSupportedNames(nsTArray<nsString>& aNames);
 
-  // Uses XPCOM InvalidateColumns().
-  // Uses XPCOM RestoreNaturalOrder().
+  void InvalidateColumns();
+  void RestoreNaturalOrder();
 
   friend class nsTreeBodyFrame;
 protected:
   void SetTree(nsTreeBodyFrame* aTree) { mTree = aTree; }
 
   // Builds our cache of column info.
   void EnsureColumns();