Bug 1466727 part 7. Remove nsITreeColumn. r=mossop
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 05 Jun 2018 23:01:37 -0400
changeset 475783 830e780325e49a0b9c90449e50b943bad39a09f4
parent 475782 4f9c0f55aa88ab4ed421394203557e5e8396d380
child 475784 5b8e7ac3a4a51ee85ec31852935aac78eed09751
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
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 7. Remove nsITreeColumn. r=mossop
layout/xul/tree/moz.build
layout/xul/tree/nsITreeColumns.idl
layout/xul/tree/nsTreeColumns.cpp
layout/xul/tree/nsTreeColumns.h
--- a/layout/xul/tree/moz.build
+++ b/layout/xul/tree/moz.build
@@ -4,17 +4,16 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files('**'):
     BUG_COMPONENT = ('Core', 'XUL')
 
 XPIDL_SOURCES += [
     'nsITreeBoxObject.idl',
-    'nsITreeColumns.idl',
     'nsITreeSelection.idl',
     'nsITreeView.idl',
 ]
 
 XPIDL_MODULE = 'layout_xul_tree'
 
 EXPORTS += [
     'nsTreeColFrame.h',
deleted file mode 100644
--- a/layout/xul/tree/nsITreeColumns.idl
+++ /dev/null
@@ -1,40 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-
-webidl Element;
-webidl TreeColumn;
-webidl TreeColumns;
-
-[scriptable, builtinclass, uuid(ae835ecf-6b32-4660-9b43-8a270df56e02)]
-interface nsITreeColumn : nsISupports
-{
-  readonly attribute Element element;
-
-  readonly attribute TreeColumns columns;
-
-  readonly attribute long x;
-  readonly attribute long width;
-
-  readonly attribute AString id;
-  [noscript] void getIdConst([shared] out wstring idConst);
-
-  readonly attribute long index;
-
-  readonly attribute boolean primary;
-  readonly attribute boolean cycler;
-  readonly attribute boolean editable;
-  readonly attribute boolean selectable;
-
-  const short TYPE_TEXT                = 1;
-  const short TYPE_CHECKBOX            = 2;
-  const short TYPE_PASSWORD            = 3;
-  readonly attribute short type;
-
-  TreeColumn getNext();
-  TreeColumn getPrevious();
-
-  void invalidate();
-};
--- a/layout/xul/tree/nsTreeColumns.cpp
+++ b/layout/xul/tree/nsTreeColumns.cpp
@@ -25,17 +25,17 @@ nsTreeColumn::nsTreeColumn(nsTreeColumns
     mColumns(aColumns),
     mPrevious(nullptr)
 {
   NS_ASSERTION(aElement &&
                aElement->NodeInfo()->Equals(nsGkAtoms::treecol,
                                             kNameSpaceID_XUL),
                "nsTreeColumn's content must be a <xul:treecol>");
 
-  Invalidate();
+  Invalidate(IgnoreErrors());
 }
 
 nsTreeColumn::~nsTreeColumn()
 {
   if (mNext) {
     mNext->SetPrevious(nullptr);
   }
 }
@@ -57,17 +57,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsTreeColumn)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTreeColumn)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTreeColumn)
 
 // QueryInterface implementation for nsTreeColumn
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeColumn)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsITreeColumn)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_INTERFACE_MAP_ENTRY_CONCRETE(nsTreeColumn)
 NS_INTERFACE_MAP_END
 
 nsIFrame*
 nsTreeColumn::GetFrame()
 {
   return mContent->GetPrimaryFrame();
@@ -137,125 +136,30 @@ nsTreeColumn::GetWidthInTwips(nsTreeBody
   }
   *aResult = frame->GetRect().width;
   if (IsLastVisible(aBodyFrame))
     *aResult += aBodyFrame->mAdjustWidth;
   return NS_OK;
 }
 
 
-NS_IMETHODIMP
-nsTreeColumn::GetElement(class Element** aElement)
-{
-  NS_ADDREF(*aElement = Element());
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetColumns(nsTreeColumns** aColumns)
-{
-  NS_IF_ADDREF(*aColumns = mColumns);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetX(int32_t* aX)
-{
-  nsIFrame* frame = GetFrame();
-  NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
-
-  *aX = nsPresContext::AppUnitsToIntCSSPixels(frame->GetRect().x);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetWidth(int32_t* aWidth)
-{
-  nsIFrame* frame = GetFrame();
-  NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
-
-  *aWidth = nsPresContext::AppUnitsToIntCSSPixels(frame->GetRect().width);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetId(nsAString& aId)
+void
+nsTreeColumn::GetId(nsAString& aId) const
 {
   aId = GetId();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetIdConst(const char16_t** aIdConst)
-{
-  *aIdConst = mId.get();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetIndex(int32_t* aIndex)
-{
-  *aIndex = GetIndex();
-  return NS_OK;
 }
 
-NS_IMETHODIMP
-nsTreeColumn::GetPrimary(bool* aPrimary)
-{
-  *aPrimary = IsPrimary();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetCycler(bool* aCycler)
-{
-  *aCycler = IsCycler();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetEditable(bool* aEditable)
-{
-  *aEditable = IsEditable();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetSelectable(bool* aSelectable)
-{
-  *aSelectable = IsSelectable();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetType(int16_t* aType)
-{
-  *aType = GetType();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetNext(nsTreeColumn** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetNext());
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::GetPrevious(nsTreeColumn** _retval)
-{
-  NS_IF_ADDREF(*_retval = GetPrevious());
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsTreeColumn::Invalidate()
+void
+nsTreeColumn::Invalidate(ErrorResult& aRv)
 {
   nsIFrame* frame = GetFrame();
-  NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
+  if (NS_WARN_IF(!frame)) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return;
+  }
 
   // Fetch the Id.
   mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::id, mId);
 
   // If we have an Id, cache the Id as an atom.
   if (!mId.IsEmpty()) {
     mAtom = NS_Atomize(mId);
   }
@@ -328,18 +232,16 @@ nsTreeColumn::Invalidate()
     case 0:
       mCropStyle = 1;
       break;
     case 1:
     case 2:
       mCropStyle = 2;
       break;
   }
-
-  return NS_OK;
 }
 
 nsIContent*
 nsTreeColumn::GetParentObject() const
 {
   return mContent;
 }
 
@@ -353,33 +255,35 @@ Element*
 nsTreeColumn::Element()
 {
   return mContent;
 }
 
 int32_t
 nsTreeColumn::GetX(mozilla::ErrorResult& aRv)
 {
-  int32_t x;
-  aRv = GetX(&x);
-  return x;
+  nsIFrame* frame = GetFrame();
+  if (NS_WARN_IF(!frame)) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return 0;
+  }
+  
+  return nsPresContext::AppUnitsToIntCSSPixels(frame->GetRect().x);
 }
 
 int32_t
 nsTreeColumn::GetWidth(mozilla::ErrorResult& aRv)
 {
-  int32_t width;
-  aRv = GetWidth(&width);
-  return width;
-}
+  nsIFrame* frame = GetFrame();
+  if (NS_WARN_IF(!frame)) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return 0;
+  }
 
-void
-nsTreeColumn::Invalidate(mozilla::ErrorResult& aRv)
-{
-  aRv = Invalidate();
+  return nsPresContext::AppUnitsToIntCSSPixels(frame->GetRect().width);
 }
 
 nsTreeColumns::nsTreeColumns(nsTreeBodyFrame* aTree)
   : mTree(aTree)
 {
 }
 
 nsTreeColumns::~nsTreeColumns()
--- a/layout/xul/tree/nsTreeColumns.h
+++ b/layout/xul/tree/nsTreeColumns.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsTreeColumns_h__
 #define nsTreeColumns_h__
 
-#include "nsITreeColumns.h"
 #include "nsITreeBoxObject.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/RefPtr.h"
 #include "nsCoord.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsQueryObject.h"
 #include "nsWrapperCache.h"
 #include "nsString.h"
@@ -37,40 +36,39 @@ class TreeBoxObject;
     0x02cd1963,                                      \
     0x4b5d,                                          \
     0x4a6c,                                          \
     {0x92, 0x23, 0x81, 0x4d, 0x3a, 0xde, 0x93, 0xa3} \
 }
 
 // This class is our column info.  We use it to iterate our columns and to obtain
 // information about each column.
-class nsTreeColumn final : public nsITreeColumn
+class nsTreeColumn final : public nsISupports
                          , public nsWrapperCache
 {
 public:
   nsTreeColumn(nsTreeColumns* aColumns, mozilla::dom::Element* aElement);
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_TREECOLUMN_IMPL_CID)
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsTreeColumn)
-  NS_DECL_NSITREECOLUMN
 
   // WebIDL
   nsIContent* GetParentObject() const;
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   mozilla::dom::Element* Element();
 
   nsTreeColumns* GetColumns() const { return mColumns; }
 
   int32_t GetX(mozilla::ErrorResult& aRv);
   int32_t GetWidth(mozilla::ErrorResult& aRv);
 
-  // GetId is fine
+  void GetId(nsAString& aId) const;
   int32_t Index() const { return mIndex; }
 
   bool Primary() const { return mIsPrimary; }
   bool Cycler() const { return mIsCycler; }
   bool Editable() const { return mIsEditable; }
   bool Selectable() const { return mIsSelectable; }
   int16_t Type() const { return mType; }
 
@@ -97,17 +95,17 @@ protected:
                    nsRect* aResult);
 
   nsresult GetXInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult);
   nsresult GetWidthInTwips(nsTreeBodyFrame* aBodyFrame, nscoord* aResult);
 
   void SetColumns(nsTreeColumns* aColumns) { mColumns = aColumns; }
 
 public:
-  const nsAString& GetId() { return mId; }
+  const nsAString& GetId() const { return mId; }
   nsAtom* GetAtom() { return mAtom; }
   int32_t GetIndex() { return mIndex; }
 
 protected:
   bool IsPrimary() { return mIsPrimary; }
   bool IsCycler() { return mIsCycler; }
   bool IsEditable() { return mIsEditable; }
   bool IsSelectable() { return mIsSelectable; }